當前位置: 首頁>>代碼示例>>PHP>>正文


PHP server函數代碼示例

本文整理匯總了PHP中server函數的典型用法代碼示例。如果您正苦於以下問題:PHP server函數的具體用法?PHP server怎麽用?PHP server使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了server函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: page

/**
 * 獲取分頁的HTML代碼
 * 
 * @param number $total_rows
 * @param number $per_page
 * @param string $base_url
 * @return string
 */
function page($total_rows, $per_page = 10, $base_url = NULL)
{
    // 加載CI的pagination類庫
    $CI =& get_instance();
    $CI->load->library('pagination');
    // 處理base_url
    if ($base_url === NULL) {
        // 獲取URI
        $base_url = server('REDIRECT_URL') . '?';
        // 獲取GET參數,並且剔除參數p,組建新的base_url
        $gets = get();
        if ($gets !== FALSE) {
            if (isset($gets['p'])) {
                unset($gets['p']);
            }
            if (count($gets) > 0) {
                $query_string = http_build_query($gets);
                $base_url .= $query_string;
            }
        }
    }
    // 設置CI的分頁配置
    $config = array('base_url' => $base_url, 'per_page' => $per_page, 'total_rows' => $total_rows, 'num_links' => 10, 'query_string_segment' => 'p', 'first_link' => '首頁', 'last_link' => '末頁', 'prev_link' => '<', 'next_link' => '>', 'use_page_numbers' => TRUE, 'page_query_string' => TRUE, 'cur_tag_open' => '<a class="current">', 'cur_tag_close' => '</a>');
    // 初始化和返回鏈接
    $CI->pagination->initialize($config);
    return $CI->pagination->create_links();
}
開發者ID:shanliqun,項目名稱:zhonghang,代碼行數:35,代碼來源:page_helper.php

示例2: ip_address

 function ip_address()
 {
     $ING =& get_instance();
     if ($ING->input->fetch_ip_address() !== FALSE) {
         return $ING->input->fetch_ip_address();
     }
     $proxy_ips = config_item('proxy_ips');
     if (!empty($proxy_ips)) {
         $proxy_ips = explode(',', str_replace(' ', '', $proxy_ips));
         foreach (array('HTTP_X_FORWARDED_FOR', 'HTTP_CLIENT_IP', 'HTTP_X_CLIENT_IP', 'HTTP_X_CLUSTER_CLIENT_IP') as $header) {
             if (($spoof = server($header)) !== FALSE) {
                 // Some proxies typically list the whole chain of IP
                 // addresses through which the client has reached us.
                 // e.g. client_ip, proxy_ip1, proxy_ip2, etc.
                 if (strpos($spoof, ',') !== FALSE) {
                     $spoof = explode(',', $spoof, 2);
                     $spoof = $spoof[0];
                 }
                 if (!valid_ip($spoof)) {
                     $spoof = FALSE;
                 } else {
                     break;
                 }
             }
         }
         $ING->input->set_ip_address($spoof !== FALSE && in_array($_SERVER['REMOTE_ADDR'], $proxy_ips, TRUE) ? $spoof : $_SERVER['REMOTE_ADDR']);
     } else {
         $ING->input->set_ip_address($_SERVER['REMOTE_ADDR']);
     }
     if (!valid_ip($ING->input->fetch_ip_address())) {
         $ING->input->set_ip_address('0.0.0.0');
     }
     return $ING->input->fetch_ip_address();
 }
開發者ID:puncoz,項目名稱:ingnepal.org,代碼行數:34,代碼來源:input_helper.php

示例3: insertElement

function insertElement()
{
    if (isset($_POST['ClassificationID'])) {
        $ClassificationID = json_decode(sanitize($_POST['ClassificationID']));
    }
    if (isset($_POST['Element'])) {
        $Element = json_decode(sanitize($_POST['Element']));
    }
    if (isset($_POST['AtomicMass'])) {
        $AtomicMass = json_decode(sanitize($_POST['AtomicMass']));
    }
    $dbConn = mysqli_connect(server(), username(), password(), db("Elements"));
    if ($dbConn->connect_error) {
        die("Connection failed: " . $dbConn->connect_error);
    }
    $query = "INSERT INTO Elements ( ClassificationID, Element, AtomicMass ) " . "VALUES ( " . "" . $ClassificationID . ", " . "'" . $Element . "', " . "" . $AtomicMass . " );";
    $result = $dbConn->query($query);
    $return = new stdClass();
    $return->querystring = (string) $query;
    if ($result) {
        $return->success = true;
    } else {
        $return->success = false;
    }
    return json_encode($return);
}
開發者ID:d-retterer,項目名稱:nc2016,代碼行數:26,代碼來源:dbInsert.php

示例4: use

 public function use(int $roleId = 6) : bool
 {
     $this->permission = INDIVIDUALSTRUCTURES_PERMISSION_CONFIG['page'];
     if (isset($this->permission[$roleId])) {
         $rules = $this->permission[$roleId];
     } else {
         return false;
     }
     $currentUrl = server('currentPath');
     switch ($rules) {
         case 'all':
             return true;
             break;
         case 'any':
             return false;
             break;
     }
     if (is_array($rules)) {
         $pages = current($rules);
         $type = key($rules);
         foreach ($pages as $page) {
             $page = trim($page);
             if (stripos($page[0], '!') === 0) {
                 $rule = substr(trim($page), 1);
             } else {
                 $rule = trim($page);
             }
             if ($type === "perm") {
                 if (strpos($currentUrl, $rule) > -1) {
                     return true;
                 } else {
                     $this->result = false;
                 }
             } else {
                 if (strpos($currentUrl, $rule) > -1) {
                     return false;
                 } else {
                     $this->result = true;
                 }
             }
         }
         return $this->result;
     } else {
         if ($rules[0] === "!") {
             $page = substr(trim($rules), 1);
         } else {
             $page = trim($rules);
         }
         if (strpos($currentUrl, $page) > -1) {
             if ($rules[0] !== "!") {
                 return true;
             } else {
                 return false;
             }
         } else {
             return true;
         }
     }
 }
開發者ID:znframework,項目名稱:znframework,代碼行數:59,代碼來源:Page.php

示例5: handle

 /**
  * Handle the event.
  *
  * @param  \Apolune\Account\Events\Email\RequestAccepted  $event
  * @return void
  */
 public function handle(Email\RequestAccepted $event)
 {
     list($account, $password) = [$event->account, $event->password];
     $this->mailer->send('theme::_emails.new-email', compact('account', 'password'), function ($message) use($account) {
         $message->to($account->email());
         $message->subject(trans('theme::_emails/new-email.title', ['server' => server()->name()]));
     });
 }
開發者ID:apolune,項目名稱:account,代碼行數:14,代碼來源:SendNewEmailConfirmation.php

示例6: currentUrl

function currentUrl(string $fix = '') : string
{
    $currentUrl = sslStatus() . host() . internalCleanInjection(server('requestUri'));
    if (!empty($fix)) {
        return rtrim(suffix($currentUrl), $fix) . $fix;
    }
    return $currentUrl;
}
開發者ID:znframework,項目名稱:znframework,代碼行數:8,代碼來源:URL.php

示例7: server

 public function server(string $name = '', $value = NULL)
 {
     // @value parametresi boş değilse
     if (!empty($value)) {
         $_SERVER[$name] = $value;
     }
     return server($name);
 }
開發者ID:znframework,項目名稱:znframework,代碼行數:8,代碼來源:InternalMethod.php

示例8: process

 public function process()
 {
     $this->log->add('Request Received from: ' . server('REMOTE_ADDR'));
     $encoding = $this->decode($this->request);
     if ($encoding != self::ENC_RAW) {
         $this->log->add('Parsed Request: ' . print_r($this->request, true));
     }
     return $this;
 }
開發者ID:openlss,項目名稱:lib-xport,代碼行數:9,代碼來源:Response.php

示例9: setUpServer

 protected function setUpServer()
 {
     $username = getenv('DEPLOYER_USERNAME') ?: 'deployer';
     $password = getenv('DEPLOYER_PASSWORD') ?: 'deployer_password';
     server('remote_auth_by_password', 'localhost', 22)->env('deploy_path', self::$deployPath)->user($username)->password($password);
     server('remote_auth_by_identity_file', 'localhost', 22)->env('deploy_path', self::$deployPath)->user($username)->identityFile();
     server('remote_auth_by_pem_file', 'localhost', 22)->env('deploy_path', self::$deployPath)->user($username)->pemFile('~/.ssh/id_rsa.pem');
     server('remote_auth_by_agent', 'localhost', 22)->env('deploy_path', self::$deployPath)->user($username)->forwardAgent();
 }
開發者ID:acorncom,項目名稱:deployer,代碼行數:9,代碼來源:RemoteServerTest.php

示例10: connect

 public function connect($i = 0)
 {
     $env = server("SERVER_ADDR") == "::1" || server("SERVER_ADDR") == "127.0.0.1" ? true : false;
     $conn = mysqli_connect($env ? "localhost" : "mysql.hostinger.com.br", $env ? "root" : "u398318873_tj", $env ? "" : "Knowledge1", $env ? "controk" : "u398318873_bda");
     if (mysqli_connect_errno()) {
         AJAXReturn("error", "Falha ao se conectar ao MySQL:<p>({$conn->connect_errno})</p><p>{$conn->connect_error}</p>");
     } elseif ($i == 0) {
         $this->conn = $conn;
     } elseif ($i == 1) {
         return $conn;
     }
 }
開發者ID:jourdanrodrigues,項目名稱:Controk,代碼行數:12,代碼來源:Connection.php

示例11: onBoot

 public function onBoot()
 {
     // TODO: Implement onBoot() method.
     $this->getDI()->setShared('url', function () {
         $protocol = stripos(server('SERVER_PROTOCOL'), 'https') === true ? 'https://' : 'http://';
         $hostname = server('HTTP_HOST');
         $url = new Url();
         $url->setStaticBaseUri(env('static_url', "{$protocol}{$hostname}/"));
         $url->setBaseUri(env('base_url', '/'));
         return $url;
     });
 }
開發者ID:dotronglong,項目名稱:phalcon-engine,代碼行數:12,代碼來源:ServiceRegister.php

示例12: serverList

/**
 * Load server list file.
 * @param string $file
 */
function serverList($file)
{
    $serverList = Yaml::parse(file_get_contents($file));
    foreach ((array) $serverList as $name => $config) {
        try {
            if (!is_array($config)) {
                throw new \RuntimeException();
            }
            $da = new \Deployer\Type\DotArray($config);
            if ($da->hasKey('local')) {
                $builder = localServer($name);
            } else {
                $builder = $da->hasKey('port') ? server($name, $da['host'], $da['port']) : server($name, $da['host']);
            }
            unset($da['local']);
            unset($da['host']);
            unset($da['port']);
            if ($da->hasKey('identity_file')) {
                if ($da['identity_file'] === null) {
                    $builder->identityFile();
                } else {
                    $builder->identityFile($da['identity_file.public_key'], $da['identity_file.private_key'], $da['identity_file.password']);
                }
                unset($da['identity_file']);
            }
            if ($da->hasKey('identity_config')) {
                if ($da['identity_config'] === null) {
                    $builder->configFile();
                } else {
                    $builder->configFile($da['identity_config']);
                }
                unset($da['identity_config']);
            }
            if ($da->hasKey('forward_agent')) {
                $builder->forwardAgent();
                unset($da['forward_agent']);
            }
            foreach (['user', 'password', 'stage', 'pem_file'] as $key) {
                if ($da->hasKey($key)) {
                    $method = lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', $key))));
                    $builder->{$method}($da[$key]);
                    unset($da[$key]);
                }
            }
            // Everything else are env vars.
            foreach ($da->toArray() as $key => $value) {
                $builder->env($key, $value);
            }
        } catch (\RuntimeException $e) {
            throw new \RuntimeException("Error in parsing `{$file}` file.");
        }
    }
}
開發者ID:onedal88,項目名稱:deployer,代碼行數:57,代碼來源:functions.php

示例13: hookDone

 /**
  * Hook Done
  */
 public function hookDone()
 {
     if (cogear()->session->get('Онлайн') === NULL or time() - cogear()->session->get('Онлайн') > config('widgets.Онлайн.period', 60)) {
         $Онлайн = new Db_ORM('Онлайн');
         $Онлайн->uid = user()->id;
         $Онлайн->user_agent = server('HTTP_USER_AGENT');
         $Онлайн->session_id = cogear()->session->get('session_id');
         $Онлайн->ip = cogear()->session->get('ip');
         $Онлайн->created_date = time();
         $Онлайн->insert();
         cogear()->session->set('Онлайн', time());
     }
 }
開發者ID:brussens,項目名稱:cogear2,代碼行數:16,代碼來源:Online.php

示例14: internalRequestURI

function internalRequestURI() : string
{
    $requestUri = currentUri() ? str_replace(DIRECTORY_INDEX . '/', '', currentUri()) : substr(server('currentPath'), 1);
    if (isset($requestUri[strlen($requestUri) - 1]) && $requestUri[strlen($requestUri) - 1] === '/') {
        $requestUri = substr($requestUri, 0, -1);
    }
    $requestUri = internalCleanInjection(internalRouteURI($requestUri));
    $requestUri = internalCleanURIPrefix($requestUri, currentLang());
    if (defined('_CURRENT_PROJECT')) {
        $requestUri = internalCleanURIPrefix($requestUri, _CURRENT_PROJECT);
    }
    return $requestUri;
}
開發者ID:znframework,項目名稱:znframework,代碼行數:13,代碼來源:Internal.php

示例15: currentPath

function currentPath(bool $isPath = true) : string
{
    $currentPagePath = str_replace("/" . getLang() . "/", "", server('currentPath'));
    if (isset($currentPagePath[0]) && $currentPagePath[0] === "/") {
        $currentPagePath = substr($currentPagePath, 1, strlen($currentPagePath) - 1);
    }
    if ($isPath === true) {
        return $currentPagePath;
    } else {
        $str = explode("/", $currentPagePath);
        if (count($str) > 1) {
            return $str[count($str) - 1];
        }
        return $str[0];
    }
}
開發者ID:znframework,項目名稱:znframework,代碼行數:16,代碼來源:Path.php


注:本文中的server函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。