当前位置: 首页>>代码示例>>PHP>>正文


PHP _server函数代码示例

本文整理汇总了PHP中_server函数的典型用法代码示例。如果您正苦于以下问题:PHP _server函数的具体用法?PHP _server怎么用?PHP _server使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了_server函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct($r = null, $t = null, $c = null)
 {
     $this->uri = $_SERVER['REQUEST_URI'];
     $this->path = parse_url($this->uri, PHP_URL_PATH);
     // set up basic delegation concepts (via params or htaccess)
     $this->container = presto_lib::_get('c', $c);
     $this->route = presto_lib::_get('r', $r);
     $this->type = presto_lib::_c(presto_lib::_get('t', $t), 'json');
     $params = $this->params();
     if (!array_key_exists('r', $_GET) || !array_key_exists('t', $_GET) || !array_key_exists('c', $_GET)) {
         presto_lib::_trace("Rewrite delegation setup for {$this->uri} is missing.", json_encode($_GET));
     }
     unset($_GET['t']);
     unset($_GET['r']);
     unset($_GET['c']);
     // pop routing parameters
     // setup request parameters
     $this->method = strtolower($_SERVER['REQUEST_METHOD']);
     $this->action = presto_lib::_c($this->method, 'get');
     // default to GET
     $this->host = $_SERVER['HTTP_HOST'];
     $this->referer = _server('HTTP_REFERER', '');
     $this->refererPath = parse_url($this->referer, PHP_URL_PATH);
     $this->service = strstr($this->host, '.', -1);
     $this->tld = pathinfo($this->host, PATHINFO_EXTENSION);
     $this->scheme = _server_has('HTTPS', 'on') || _server_has('HTTP_X_FORWARDED_PROTO', 'https') || _server_has('HTTP_X_FORWARDED_SSL', 'on') ? 'https' : 'http';
     $this->options = $_GET;
     $_GET = array();
     // discourage use of $_GET
 }
开发者ID:robotpony,项目名称:Presto,代码行数:30,代码来源:request.php

示例2: printHeader

function printHeader($filename, $type)
{
    $mime = getImageType($filename);
    if ($type == "view") {
        header("Content-type: {$mime}");
        header("Content-Transfer-Encoding: binary\n");
        header("Expires: 0");
        //header('Content-length: '.sizeOf($imgcode));
    } elseif ($type == "download") {
        if (strpos(_server('HTTP_USER_AGENT'), "MSIE") !== FALSE) {
            header("Content-type: {$mime}");
            header("Content-Disposition: attachment; filename={$filename}");
            header("Expires: 0");
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            header("Content-Transfer-Encoding: binary");
            header('Pragma: public');
            //header("Content-Length: ".strlen($data));
        } else {
            header("Content-type: {$mime}");
            header("Content-Disposition: attachment; filename={$filename}");
            header("Content-Transfer-Encoding: binary");
            header("Expires: 0");
            header('Pragma: no-cache');
            //header("Content-Length: ".strlen($data));
        }
    }
}
开发者ID:logiks,项目名称:logiks-core,代码行数:27,代码来源:viewphoto.php

示例3: transferFileHTTPToLocal

 function transferFileHTTPToLocal($src, $dest = "", $autoExtension = false)
 {
     if (strlen($dest) <= 0) {
         $dest = ROOT . CACHE_FOLDER;
     }
     if (strpos($src, "http://") != 0 && strpos($src, "https://") != 0) {
         return false;
     }
     $fpath = $dest;
     if ($autoExtension) {
         $arr = explode("/", $src);
         $ext = $arr[sizeOf($arr) - 1];
         $fpath = $dest . $ext;
     }
     if (!function_exists('curl_init')) {
         //Use File_get_contents
         $fh1 = fopen($src, "rb");
         if ($fh1) {
             $fh = fopen($fpath, "w");
             if ($fh) {
                 while (!feof($fh1)) {
                     $contents = fread($fh1, 8192);
                     fwrite($fh, $contents);
                 }
                 return $fpath;
             } else {
                 return false;
             }
         }
         return false;
     } else {
         //Use CURL
         $site = SiteLocation . _server("SCRIPT_NAME");
         $site = str_replace("http://", "h1", $site);
         $site = str_replace("https://", "h2", $site);
         $site = str_replace("//", "/", $site);
         $site = str_replace("h1", "http://", $site);
         $site = str_replace("h2", "https://", $site);
         $ch = curl_init();
         // Set URL to download
         curl_setopt($ch, CURLOPT_URL, $src);
         // Set a referer
         curl_setopt($ch, CURLOPT_REFERER, $site);
         // User agent
         curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");
         // Include header in result? (0 = yes, 1 = no)
         curl_setopt($ch, CURLOPT_HEADER, 0);
         // Should cURL return or print out the data? (true = return, false = print)
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         // Timeout in seconds
         curl_setopt($ch, CURLOPT_TIMEOUT, 100);
         // Download the given URL, and return output
         $data = curl_exec($ch);
         // Close the cURL resource, and free system resources
         curl_close($ch);
         file_put_contents($fpath, $data);
         return $fpath;
     }
     return false;
 }
开发者ID:logiks,项目名称:logiks-core,代码行数:60,代码来源:filetransfer.php

示例4: forceDownloadData

 function forceDownloadData($data = '', $extension = "*", $filename = "download")
 {
     include ROOT . 'config/mimes.php';
     $mime = getMimeTypeFor($extension);
     if ($extension == "*") {
         $extension = "";
     }
     if (!(substr($filename, strlen($filename) - strlen($extension)) == $extension)) {
         $filename .= "." . $extension;
     }
     if (strpos(_server('HTTP_USER_AGENT'), "MSIE") !== FALSE) {
         header('Content-Type: "' . $mime . '"');
         header('Content-Disposition: attachment; filename="' . $filename . '"');
         header('Expires: 0');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header("Content-Transfer-Encoding: binary");
         header('Pragma: public');
         header("Content-Length: " . strlen($data));
     } else {
         header('Content-Type: "' . $mime . '"');
         header('Content-Disposition: attachment; filename="' . $filename . '"');
         header("Content-Transfer-Encoding: binary");
         header('Expires: 0');
         header('Pragma: no-cache');
         header("Content-Length: " . strlen($data));
     }
     exit($data);
 }
开发者ID:logiks,项目名称:logiks-core,代码行数:28,代码来源:downloader.php

示例5: doFilter

function doFilter()
{
    $file = _server("SCRIPT_NAME");
    $uri = _server("REQUEST_URI");
    $ip = _server("REMOTE_ADDR");
    $method = _server("REQUEST_METHOD");
    $agent = _server("HTTP_USER_AGENT");
    $post = json_encode($_POST);
    $dt = date("H:i:s");
    $msg = "{$dt} {$method} {$uri} {$ip}";
    if (strlen($post) > 2) {
        $msg .= " {$post}";
    }
    $msg .= "\r\n";
    $path = getRoot() . "/myfolder/log/filter_" . date("Ymd") . ".log";
    $handle = fopen($path, "a");
    fwrite($handle, $msg);
    fclose($handle);
    $path = getRoot() . "/myfolder/log/register_" . date("Ymd") . ".log";
    if ($file == "/registerAuth.php" && file_exists($path)) {
        $handle = fopen($path, "r");
        $count = 0;
        while ($line = fgets($handle)) {
            if (strlen($line) > 2) {
                $count++;
            }
        }
        fclose($handle);
        if ($count > 10) {
            header("content-type:text/json;charset=utf-8");
            echo '{"result":false,"msg":"用户注册量异常,注册功能暂不可用"}';
            exit;
        }
    }
}
开发者ID:fancige,项目名称:demo,代码行数:35,代码来源:filter.php

示例6: authorize

 public function authorize()
 {
     if (!User::is_login()) {
         $this->flash->add('message_error', '로그 인이 필요합니다.');
         $this->redirect_to('/user/login_form?return_url=' . _server('REQUEST_URI'));
     }
 }
开发者ID:utumdol,项目名称:codeseed,代码行数:7,代码来源:application_controller.class.php

示例7: __log

function __log($user)
{
    $path = getRoot() . "/myfolder/log/register_" . date("Ymd") . ".log";
    $handle = fopen($path, "a");
    $msg = date("H:i:s") . " " . _server("REMOTE_ADDR") . " {$user}\r\n";
    fwrite($handle, $msg);
    fclose($handle);
}
开发者ID:fancige,项目名称:demo,代码行数:8,代码来源:registerAuth.php

示例8: back

 public function back()
 {
     $http_referer = _server('HTTP_REFERER');
     if (!empty($http_referer)) {
         $this->redirect_to($http_referer);
     }
     echo '<script type="text/javascript">history.back();</script>';
     $this->skip();
 }
开发者ID:utumdol,项目名称:codeseed,代码行数:9,代码来源:controller.class.php

示例9: getBasePath

 function getBasePath()
 {
     if (_server('PATH_INFO')) {
         $file = _server('PATH_INFO');
         return getRelativePath($file);
     } else {
         return "";
     }
 }
开发者ID:arunjoseph,项目名称:Logiks-Core,代码行数:9,代码来源:pathfuncs.php

示例10: _log

 function _log($logMsg, $logkey = "activity", $logLevel = null, $logData = array())
 {
     if ($logLevel == null) {
         $logLevel = LogiksLogger::LOG_WARNING;
     }
     if (_server('REQUEST_TIME_FLOAT')) {
         $logData['time'] = microtime(true) - _server('REQUEST_TIME_FLOAT');
     } elseif (_server('REQUEST_PAGE_START')) {
         $logData['time'] = microtime(true) - _server('REQUEST_PAGE_START');
     } elseif (_server('REQUEST_SERVICE_START')) {
         $logData['time'] = microtime(true) - _server('REQUEST_SERVICE_START');
     }
     LogiksLogger::log($logkey, $logLevel, $logMsg, $logData);
 }
开发者ID:arunjoseph,项目名称:Logiks-Core,代码行数:14,代码来源:tests.php

示例11: __closeDevMode

 function __closeDevMode()
 {
     if (defined("DEV_MODE_IP") && strlen(DEV_MODE_IP) > 0) {
         $addr = explode(",", DEV_MODE_IP);
         if (count($addr) > 0) {
             if (is_array($addr)) {
                 if (!in_array(_server("REMOTE_ADDR"), $addr)) {
                     ob_end_clean();
                 } else {
                     ob_end_flush();
                 }
             } else {
                 if (_server("REMOTE_ADDR") != $addr) {
                     ob_end_clean();
                 } else {
                     ob_end_flush();
                 }
             }
         }
     }
 }
开发者ID:logiks,项目名称:logiks-core,代码行数:21,代码来源:devmode.php

示例12: checkBrowser

 function checkBrowser()
 {
     if (!_server('HTTP_USER_AGENT')) {
         return array("browser" => "", "version" => "", "platform" => "", "userAgent" => "");
     }
     $browsers = "mozilla msie gecko firefox ";
     $browsers .= "konqueror safari netscape navigator ";
     $browsers .= "opera mosaic lynx amaya omniweb chrome";
     $browsers = explode(" ", $browsers);
     $userAgent = strtolower(_server('HTTP_USER_AGENT'));
     $l = count($browsers);
     for ($i = 0; $i < $l; $i++) {
         $browser = $browsers[$i];
         $n = stristr($userAgent, $browser);
         if (strlen($n) > 0) {
             $version = "";
             $navigator = $browser;
             $j = strpos($userAgent, $navigator) + $n + strlen($navigator) + 1;
             for (; $j <= strlen($userAgent); $j++) {
                 $s = substr($userAgent, $j, 1);
                 if (is_numeric($version . $s)) {
                     $version .= $s;
                 } else {
                     break;
                 }
             }
         }
     }
     if (strpos($userAgent, 'linux')) {
         $platform = 'linux';
     } elseif (strpos($userAgent, 'macintosh') || strpos($userAgent, 'mac platform x')) {
         $platform = 'mac';
     } elseif (strpos($userAgent, 'windows') || strpos($userAgent, 'win32')) {
         $platform = 'windows';
     }
     return array("browser" => $navigator, "version" => $version, "platform" => $platform, "userAgent" => $userAgent);
 }
开发者ID:logiks,项目名称:logiks-core,代码行数:37,代码来源:browser.php

示例13: _server

			alert('로그 인이 필요합니다.');
			$('#comment_textarea').val('');
			location.href="/user/login_form?return_url=<?php 
    echo _server('REQUEST_URI');
    ?>
";
		<?php 
}
?>
	});
	$('#submit_comment').click(function() {
		<?php 
if (User::is_login()) {
    ?>
			$('#blog_comment_form').submit();
		<?php 
} else {
    ?>
			alert('로그 인이 필요합니다.');
			location.href="/user/login_form?return_url=<?php 
    echo _server('REQUEST_URI');
    ?>
";
		<?php 
}
?>
	});
});
</script>

开发者ID:utumdol,项目名称:codeseed,代码行数:29,代码来源:view.php

示例14: exit

<?php

if (!defined('ROOT')) {
    exit('No direct script access allowed');
}
if (MASTER_DEBUG_MODE && !defined("SERVICE_ROOT") && !defined("TEST_ROOT") && isset($_GET['debug']) && $_GET['debug'] == "true") {
    if (_server("REQUEST_TIME_FLOAT")) {
        //Use server's inbuilt time
        echo "<div style='position:fixed;right:0px;bottom:0px;padding:5px;background:maroon;color:white;z-index:99999999999999999;'>DT:" . (microtime(true) - _server("REQUEST_TIME_FLOAT")) . " secs</div>";
    } else {
        echo "<div style='position:fixed;right:0px;bottom:0px;padding:5px;background:maroon;color:white;z-index:99999999999999999;'>DT:" . (microtime(true) - _server('REQUEST_PAGE_START')) . " secs</div>";
    }
}
开发者ID:logiks,项目名称:logiks-core,代码行数:13,代码来源:requestTime.php

示例15: getSysHash

 function getSysHash()
 {
     return md5(session_id() . _server('REMOTE_ADDR'));
 }
开发者ID:logiks,项目名称:logiks-core,代码行数:4,代码来源:commons.php


注:本文中的_server函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。