当前位置: 首页>>代码示例>>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;未经允许,请勿转载。