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


PHP serverSet函数代码示例

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


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

示例1: logit

function logit($r = '')
{
    global $siteurl, $prefs, $pretext;
    $mydomain = str_replace('www.', '', preg_quote($siteurl, "/"));
    $out['uri'] = @$pretext['request_uri'];
    $out['ref'] = clean_url(str_replace("http://", "", serverSet('HTTP_REFERER')));
    $host = $ip = serverSet('REMOTE_ADDR');
    if (!empty($prefs['use_dns'])) {
        // A crude rDNS cache
        if ($h = safe_field('host', 'txp_log', "ip='" . doSlash($ip) . "' limit 1")) {
            $host = $h;
        } else {
            // Double-check the rDNS
            $host = @gethostbyaddr(serverSet('REMOTE_ADDR'));
            if ($host != $ip and @gethostbyname($host) != $ip) {
                $host = $ip;
            }
        }
    }
    $out['ip'] = $ip;
    $out['host'] = $host;
    $out['status'] = 200;
    // FIXME
    $out['method'] = serverSet('REQUEST_METHOD');
    if (preg_match("/^[^\\.]*\\.?{$mydomain}/i", $out['ref'])) {
        $out['ref'] = "";
    }
    if ($r == 'refer') {
        if (trim($out['ref']) != "") {
            insert_logit($out);
        }
    } else {
        insert_logit($out);
    }
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:35,代码来源:log.php

示例2: doDiagnostics

/**
 * Outputs a diagnostics report.
 *
 * This is the main panel.
 */
function doDiagnostics()
{
    global $prefs, $files, $txpcfg, $event, $step, $theme, $DB;
    extract(get_prefs());
    $urlparts = parse_url(hu);
    $mydomain = $urlparts['host'];
    $is_apache = stristr(serverSet('SERVER_SOFTWARE'), 'Apache') || is_callable('apache_get_version');
    $real_doc_root = isset($_SERVER['DOCUMENT_ROOT']) ? realpath($_SERVER['DOCUMENT_ROOT']) : '';
    // ini_get() returns string values passed via php_value as a string, not boolean.
    $is_register_globals = (strcasecmp(ini_get('register_globals'), 'on') === 0 or ini_get('register_globals') === '1');
    // Check for Textpattern updates, at most once every 24 hours.
    $now = time();
    $updateInfo = unserialize(get_pref('last_update_check', ''));
    if (!$updateInfo || $now > $updateInfo['when'] + 60 * 60 * 24) {
        $updates = checkUpdates();
        $updateInfo['msg'] = $updates ? gTxt($updates['msg'], array('{version}' => $updates['version'])) : '';
        $updateInfo['when'] = $now;
        set_pref('last_update_check', serialize($updateInfo), 'publish', PREF_HIDDEN, 'text_input');
    }
    $fail = array();
    if (!empty($updateInfo['msg'])) {
        $fail['textpattern_version_update'] = diag_msg_wrap($updateInfo['msg'], 'information');
    }
    if (!is_callable('version_compare') || version_compare(PHP_VERSION, REQUIRED_PHP_VERSION, '<')) {
        $fail['php_version_required'] = diag_msg_wrap(gTxt('php_version_required', array('{version}' => REQUIRED_PHP_VERSION)));
    }
    if (!isset($path_to_site)) {
        $fail['path_to_site_missing'] = diag_msg_wrap(gTxt('path_to_site_missing'), 'warning');
    }
    if (@gethostbyname($mydomain) === $mydomain) {
        $fail['dns_lookup_fails'] = diag_msg_wrap(gTxt('dns_lookup_fails') . cs . $mydomain, 'warning');
    }
    if (!@is_dir($path_to_site)) {
        $fail['path_to_site_inacc'] = diag_msg_wrap(gTxt('path_to_site_inacc') . cs . $path_to_site);
    }
    if (rtrim($siteurl, '/') != $siteurl) {
        $fail['site_trailing_slash'] = diag_msg_wrap(gTxt('site_trailing_slash') . cs . $path_to_site, 'warning');
    }
    if (!@is_file($path_to_site . "/index.php") || !@is_readable($path_to_site . "/index.php")) {
        $fail['index_inaccessible'] = diag_msg_wrap("{$path_to_site}/index.php " . gTxt('is_inaccessible'));
    }
    $not_readable = array();
    if (!@is_writable($path_to_site . '/' . $img_dir)) {
        $not_readable[] = diag_msg_wrap(str_replace('{dirtype}', gTxt('img_dir'), gTxt('dir_not_writable')) . ": {$path_to_site}/{$img_dir}", 'warning');
    }
    if (!@is_writable($file_base_path)) {
        $not_readable[] = diag_msg_wrap(str_replace('{dirtype}', gTxt('file_base_path'), gTxt('dir_not_writable')) . ": {$file_base_path}", 'warning');
    }
    if (!@is_writable($tempdir)) {
        $not_readable[] = diag_msg_wrap(str_replace('{dirtype}', gTxt('tempdir'), gTxt('dir_not_writable')) . ": {$tempdir}", 'warning');
    }
    if ($not_readable) {
        $fail['dir_not_writable'] = join(n, $not_readable);
    }
    if ($permlink_mode != 'messy' && !$is_apache) {
        $fail['cleanurl_only_apache'] = diag_msg_wrap(gTxt('cleanurl_only_apache'), 'information');
    }
    if ($permlink_mode != 'messy' and !@is_readable($path_to_site . '/.htaccess')) {
        $fail['htaccess_missing'] = diag_msg_wrap(gTxt('htaccess_missing'));
    }
    if ($permlink_mode != 'messy' and is_callable('apache_get_modules') and !apache_module('mod_rewrite')) {
        $fail['mod_rewrite_missing'] = diag_msg_wrap(gTxt('mod_rewrite_missing'));
    }
    if (!ini_get('file_uploads')) {
        $fail['file_uploads_disabled'] = diag_msg_wrap(gTxt('file_uploads_disabled'), 'information');
    }
    if (@is_dir(txpath . DS . 'setup')) {
        $fail['setup_still_exists'] = diag_msg_wrap(txpath . DS . "setup" . DS . ' ' . gTxt('still_exists'), 'warning');
    }
    if (empty($tempdir)) {
        $fail['no_temp_dir'] = diag_msg_wrap(gTxt('no_temp_dir'), 'warning');
    }
    if (is_disabled('mail')) {
        $fail['warn_mail_unavailable'] = diag_msg_wrap(gTxt('warn_mail_unavailable'), 'warning');
    }
    if ($is_register_globals) {
        $fail['warn_register_globals_or_update'] = diag_msg_wrap(gTxt('warn_register_globals_or_update'), 'warning');
    }
    if ($permlink_mode != 'messy') {
        $rs = safe_column("name", "txp_section", "1");
        foreach ($rs as $name) {
            if ($name and @file_exists($path_to_site . '/' . $name)) {
                $fail['old_placeholder_exists'] = diag_msg_wrap(gTxt('old_placeholder') . ": {$path_to_site}/{$name}");
            }
        }
    }
    $cs = check_file_integrity(INTEGRITY_REALPATH);
    if (!$cs) {
        $cs = array();
    }
    // Files that don't match their checksums.
    if ($modified_files = array_keys($cs, INTEGRITY_MODIFIED)) {
        $fail['modified_files'] = diag_msg_wrap(gTxt('modified_files') . cs . n . t . join(', ' . n . t, $modified_files), 'warning');
    }
    // Running development code in live mode is not recommended.
//.........这里部分代码省略.........
开发者ID:bgarrels,项目名称:textpattern,代码行数:101,代码来源:txp_diag.php

示例3: preText

function preText($s, $prefs)
{
    extract($prefs);
    if (gps('rss')) {
        include txpath . '/publish/rss.php';
        exit(rss());
    }
    if (gps('atom')) {
        include txpath . '/publish/atom.php';
        exit(atom());
    }
    // set messy variables
    $out = makeOut('id', 's', 'c', 'q', 'pg', 'p', 'month');
    // if messy vars exist, bypass url parsing
    if (!$out['id'] && !$out['s']) {
        // define the useable url, minus any subdirectories.
        // this is pretty fugly, if anyone wants to have a go at it - dean
        $subpath = preg_quote(preg_replace("/http:\\/\\/.*(\\/.*)/Ui", "\$1", hu), "/");
        $req = preg_replace("/^{$subpath}/i", "/", serverSet('REQUEST_URI'));
        extract(chopUrl($req));
        //first we sniff out some of the preset url schemes
        if (!empty($u1)) {
            switch ($u1) {
                case 'atom':
                    include txpath . '/publish/atom.php';
                    exit(atom());
                case 'rss':
                    include txpath . '/publish/rss.php';
                    exit(rss());
                case strtolower(gTxt('section')):
                    $out['s'] = ckEx('section', $u2) ? $u2 : 'default';
                    break;
                case strtolower(gTxt('category')):
                    $out['c'] = ckEx('category', $u2) ? $u2 : '';
                    break;
                case urlencode(strtolower(gTxt('author'))):
                    $author_name = !empty($u2) ? urldecode($u2) : '';
                    $out['author'] = safe_field('name', 'txp_users', "RealName like '{$author_name}'");
                    break;
                case strtolower(gTxt('file_download')):
                    $out['s'] = 'file_download';
                    $out['id'] = !empty($u2) ? $u2 : '';
                    break;
                case 'p':
                    $out['p'] = is_numeric($u2) ? $u2 : '';
                    break;
                default:
                    // then see if the prefs-defined permlink scheme is usable
                    switch ($permlink_mode) {
                        case 'section_id_title':
                            $out['s'] = ckEx('section', $u1) ? $u1 : 'default';
                            $out['id'] = is_numeric($u2) && ckExID($u2) ? $u2 : '';
                            break;
                        case 'year_month_day_title':
                            if (empty($u4)) {
                                $out['month'] = "{$u1}-{$u2}";
                                if (!empty($u3)) {
                                    $out['month'] .= "-{$u3}";
                                }
                                $out['s'] = 'default';
                            } else {
                                $when = date("Y-m-d", strtotime("{$u1}-{$u2}-{$u3}") + $timeoffset);
                                $rs = lookupByDateTitle($when, $u4);
                                $out['id'] = !empty($rs['ID']) ? $rs['ID'] : '';
                                $out['s'] = !empty($rs['Section']) ? $rs['Section'] : '';
                            }
                            break;
                        case 'section_title':
                            $rs = lookupByTitleSection($u2, $u1);
                            $out['id'] = !empty($rs['ID']) ? $rs['ID'] : '';
                            $out['s'] = ckEx('section', $u1) ? $u1 : 'default';
                            break;
                        case 'title_only':
                            $rs = lookupByTitle($u1);
                            $out['id'] = !empty($rs['ID']) ? $rs['ID'] : '';
                            $out['s'] = !empty($rs['Section']) ? $rs['Section'] : ckEx('section', $u1) ? $u1 : 'default';
                            break;
                        case 'id_title':
                            if (is_numeric($u1) && ckExID($u1)) {
                                $rs = lookupByID($u1);
                                $out['id'] = !empty($rs['ID']) ? $rs['ID'] : '';
                                $out['s'] = !empty($rs['Section']) ? $rs['Section'] : 'default';
                            } else {
                                # We don't want to miss the /section/ pages
                                $out['s'] = ckEx('section', $u1) ? $u1 : 'default';
                            }
                            break;
                    }
            }
        } else {
            $out['s'] = 'default';
        }
    } else {
        // Messy mode, but prevent to get the id for file_downloads
        if ($out['id'] && !$out['s']) {
            $out['s'] = safe_field('section', 'textpattern', "ID='" . doSlash($out['id']) . "'");
        }
    }
    if ($out['s'] == 'file_download') {
        // get id of potential filename
//.........这里部分代码省略.........
开发者ID:bgarrels,项目名称:textpattern,代码行数:101,代码来源:publish.php

示例4: replace_relative_urls

function replace_relative_urls($html, $permalink = '')
{
    global $siteurl;
    # urls like "/foo/bar" - relative to the domain
    if (serverSet('HTTP_HOST')) {
        $html = preg_replace('@(<a[^>]+href=")/@', '$1' . PROTOCOL . serverSet('HTTP_HOST') . '/', $html);
        $html = preg_replace('@(<img[^>]+src=")/@', '$1' . PROTOCOL . serverSet('HTTP_HOST') . '/', $html);
    }
    # "foo/bar" - relative to the textpattern root
    $html = preg_replace('@(<a[^>]+href=")(?!http://)@', '$1' . PROTOCOL . $siteurl . '/$2', $html);
    $html = preg_replace('@(<img[^>]+src=")(?!http://)@', '$1' . PROTOCOL . $siteurl . '/$2', $html);
    if ($permalink) {
        $html = preg_replace("/href=\\\"#(.*)\"/", "href=\"" . $permalink . "#\\1\"", $html);
    }
    return $html;
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:16,代码来源:txplib_misc.php

示例5: safe_field

if ($DB->connected && $DB->table_exists(PFX . 'textpattern')) {
    $dbversion = safe_field('val', 'txp_prefs', "name = 'version'");
    // global site prefs
    $prefs = get_prefs();
    extract($prefs);
    if (empty($siteurl)) {
        $siteurl = $_SERVER['HTTP_HOST'] . rtrim(dirname(dirname($_SERVER['SCRIPT_NAME'])), '/');
    }
    if (empty($path_to_site)) {
        updateSitePath(dirname(dirname(__FILE__)));
    }
    define("LANG", $language);
    //i18n: define("LANG","en-gb");
    define('txp_version', $thisversion);
    if (!defined('PROTOCOL')) {
        switch (serverSet('HTTPS')) {
            case '':
            case 'off':
                // ISAPI with IIS
                define('PROTOCOL', 'http://');
                break;
            default:
                define('PROTOCOL', 'https://');
                break;
        }
    }
    define("hu", PROTOCOL . $siteurl . '/');
    // v1.0 experimental relative url global
    define("rhu", preg_replace("/https?:\\/\\/.+(\\/.*)\\/?\$/U", "\$1", hu));
    if (!empty($locale)) {
        setlocale(LC_ALL, $locale);
开发者ID:bgarrels,项目名称:textpattern,代码行数:31,代码来源:index.php

示例6: preText

function preText($s, $prefs)
{
    extract($prefs);
    callback_event('pretext');
    // Set messy variables.
    $out = makeOut('id', 's', 'c', 'context', 'q', 'm', 'pg', 'p', 'month', 'author');
    if (gps('rss')) {
        $out['feed'] = 'rss';
    }
    if (gps('atom')) {
        $out['feed'] = 'atom';
    }
    // Some useful vars for taghandlers, plugins.
    $out['request_uri'] = preg_replace("|^https?://[^/]+|i", "", serverSet('REQUEST_URI'));
    $out['qs'] = serverSet('QUERY_STRING');
    // IIS fix.
    if (!$out['request_uri'] and serverSet('SCRIPT_NAME')) {
        $out['request_uri'] = serverSet('SCRIPT_NAME') . (serverSet('QUERY_STRING') ? '?' . serverSet('QUERY_STRING') : '');
    }
    // Another IIS fix.
    if (!$out['request_uri'] and serverSet('argv')) {
        $argv = serverSet('argv');
        $out['request_uri'] = @substr($argv[0], strpos($argv[0], ';') + 1);
    }
    // Define the useable url, minus any subdirectories.
    // This is pretty ugly, if anyone wants to have a go at it.
    $out['subpath'] = $subpath = preg_quote(preg_replace("/https?:\\/\\/.*(\\/.*)/Ui", "\$1", hu), "/");
    $out['req'] = $req = preg_replace("/^{$subpath}/i", "/", $out['request_uri']);
    $is_404 = $out['status'] == '404';
    // If messy vars exist, bypass URL parsing.
    if (!$out['id'] && !$out['s'] && !(txpinterface == 'css') && !(txpinterface == 'admin')) {
        // Return clean URL test results for diagnostics.
        if (gps('txpcleantest')) {
            exit(show_clean_test($out));
        }
        extract(chopUrl($req));
        // First we sniff out some of the preset URL schemes.
        if (strlen($u1)) {
            switch ($u1) {
                case 'atom':
                    $out['feed'] = 'atom';
                    break;
                case 'rss':
                    $out['feed'] = 'rss';
                    break;
                    // urldecode(strtolower(urlencode())) looks ugly but is the
                    // only way to make it multibyte-safe without breaking
                    // backwards-compatibility.
                // urldecode(strtolower(urlencode())) looks ugly but is the
                // only way to make it multibyte-safe without breaking
                // backwards-compatibility.
                case urldecode(strtolower(urlencode(gTxt('section')))):
                    $out['s'] = ckEx('section', $u2) ? $u2 : '';
                    $is_404 = empty($out['s']);
                    break;
                case urldecode(strtolower(urlencode(gTxt('category')))):
                    if ($u3) {
                        $out['context'] = validContext($u2);
                        $out['c'] = $u3;
                    } else {
                        $out['context'] = 'article';
                        $out['c'] = $u2;
                    }
                    $out['c'] = ckCat($out['context'], $out['c']) ? $out['c'] : '';
                    $is_404 = empty($out['c']);
                    break;
                case urldecode(strtolower(urlencode(gTxt('author')))):
                    if ($u3) {
                        $out['context'] = validContext($u2);
                        $out['author'] = $u3;
                    } else {
                        $out['context'] = 'article';
                        $out['author'] = $u2;
                    }
                    $out['author'] = !empty($out['author']) ? $out['author'] : '';
                    break;
                    // AuthorID gets resolved from Name further down.
                // AuthorID gets resolved from Name further down.
                case urldecode(strtolower(urlencode(gTxt('file_download')))):
                    $out['s'] = 'file_download';
                    $out['id'] = !empty($u2) ? $u2 : '';
                    $out['filename'] = !empty($u3) ? $u3 : '';
                    break;
                default:
                    // Then see if the prefs-defined permlink scheme is usable.
                    switch ($permlink_mode) {
                        case 'section_id_title':
                            if (empty($u2)) {
                                $out['s'] = ckEx('section', $u1) ? $u1 : '';
                                $is_404 = empty($out['s']);
                            } else {
                                $rs = lookupByIDSection($u2, $u1);
                                $out['s'] = @$rs['Section'];
                                $out['id'] = @$rs['ID'];
                                $is_404 = (empty($out['s']) or empty($out['id']));
                            }
                            break;
                        case 'year_month_day_title':
                            if (empty($u2)) {
                                $out['s'] = ckEx('section', $u1) ? $u1 : '';
//.........这里部分代码省略.........
开发者ID:ClaireBrione,项目名称:textpattern,代码行数:101,代码来源:publish.php

示例7: mem_form_serverinfo

function mem_form_serverinfo($atts)
{
    global $mem_form_submit;
    extract(mem_form_lAtts(array('label' => '', 'name' => ''), $atts));
    if (empty($name)) {
        $name = mem_form_label2name($label);
    }
    if (strlen($name) and $mem_form_submit) {
        if (!$label) {
            $label = $name;
        }
        mem_form_store($name, $label, serverSet($name));
    }
}
开发者ID:netcarver,项目名称:mem_form,代码行数:14,代码来源:mem_form.php

示例8: preText

function preText($s, $prefs)
{
    extract($prefs);
    callback_event('pretext');
    if (gps('rss')) {
        include txpath . '/publish/rss.php';
        exit(rss());
    }
    if (gps('atom')) {
        include txpath . '/publish/atom.php';
        exit(atom());
    }
    // set messy variables
    $out = makeOut('id', 's', 'c', 'q', 'pg', 'p', 'month', 'author');
    // some useful vars for taghandlers, plugins
    $out['request_uri'] = preg_replace("|^https?://[^/]+|i", "", serverSet('REQUEST_URI'));
    $out['qs'] = serverSet('QUERY_STRING');
    // IIS fix
    if (!$out['request_uri'] and serverSet('SCRIPT_NAME')) {
        $out['request_uri'] = serverSet('SCRIPT_NAME') . (serverSet('QUERY_STRING') ? '?' . serverSet('QUERY_STRING') : '');
    }
    // another IIS fix
    if (!$out['request_uri'] and serverSet('argv')) {
        $argv = serverSet('argv');
        $out['request_uri'] = @substr($argv[0], strpos($argv[0], ';') + 1);
    }
    // define the useable url, minus any subdirectories.
    // this is pretty fugly, if anyone wants to have a go at it - dean
    $out['subpath'] = $subpath = preg_quote(preg_replace("/https?:\\/\\/.*(\\/.*)/Ui", "\$1", hu), "/");
    $out['req'] = $req = preg_replace("/^{$subpath}/i", "/", $out['request_uri']);
    $is_404 = 0;
    // if messy vars exist, bypass url parsing
    if (!$out['id'] && !$out['s'] && !(txpinterface == 'css') && !(txpinterface == 'admin')) {
        // return clean URL test results for diagnostics
        if (gps('txpcleantest')) {
            exit(show_clean_test($out));
        }
        extract(chopUrl($req));
        //first we sniff out some of the preset url schemes
        if (strlen($u1)) {
            switch ($u1) {
                case 'atom':
                    include txpath . '/publish/atom.php';
                    exit(atom());
                case 'rss':
                    include txpath . '/publish/rss.php';
                    exit(rss());
                    // urldecode(strtolower(urlencode())) looks ugly but is the only way to
                    // make it multibyte-safe without breaking backwards-compatibility
                // urldecode(strtolower(urlencode())) looks ugly but is the only way to
                // make it multibyte-safe without breaking backwards-compatibility
                case urldecode(strtolower(urlencode(gTxt('section')))):
                    $out['s'] = ckEx('section', $u2) ? $u2 : '';
                    $is_404 = empty($out['s']);
                    break;
                case urldecode(strtolower(urlencode(gTxt('category')))):
                    $out['c'] = ckEx('category', $u2) ? $u2 : '';
                    $is_404 = empty($out['c']);
                    break;
                case urldecode(strtolower(urlencode(gTxt('author')))):
                    $out['author'] = !empty($u2) ? $u2 : '';
                    break;
                    // AuthorID gets resolved from Name further down
                // AuthorID gets resolved from Name further down
                case urldecode(strtolower(urlencode(gTxt('file_download')))):
                    $out['s'] = 'file_download';
                    $out['id'] = !empty($u2) ? $u2 : '';
                    break;
                default:
                    // then see if the prefs-defined permlink scheme is usable
                    switch ($permlink_mode) {
                        case 'section_id_title':
                            if (empty($u2)) {
                                $out['s'] = ckEx('section', $u1) ? $u1 : '';
                                $is_404 = empty($out['s']);
                            } else {
                                $rs = lookupByIDSection($u2, $u1);
                                $out['s'] = @$rs['Section'];
                                $out['id'] = @$rs['ID'];
                                $is_404 = (empty($out['s']) or empty($out['id']));
                            }
                            break;
                        case 'year_month_day_title':
                            if (empty($u2)) {
                                $out['s'] = ckEx('section', $u1) ? $u1 : '';
                                $is_404 = empty($out['s']);
                            } elseif (empty($u4)) {
                                $month = "{$u1}-{$u2}";
                                if (!empty($u3)) {
                                    $month .= "-{$u3}";
                                }
                                if (preg_match('/\\d+-\\d+(?:-\\d+)?/', $month)) {
                                    $out['month'] = $month;
                                    $out['s'] = 'default';
                                } else {
                                    $is_404 = 1;
                                }
                            } else {
                                $when = "{$u1}-{$u2}-{$u3}";
                                $rs = lookupByDateTitle($when, $u4);
//.........这里部分代码省略.........
开发者ID:bgarrels,项目名称:textpattern,代码行数:101,代码来源:publish.php

示例9: frompath

function frompath()
{
    $pinfo = serverSet('PATH_INFO');
    if ($pinfo) {
        $frompath = explode('/', $pinfo);
        return !empty($frompath[1]) ? $frompath[1] : '';
    }
    return '';
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:9,代码来源:publish.php

示例10: logit

/**
 * Writes a record to the visitor log using the current visitor's information.
 *
 * This function is used by log_hit(). See it before trying to use this one.
 *
 * The hit is ignore if $r is set to 'refer' and the HTTP REFERER header is empty.
 *
 * @param  string   $r      Type of record to write, e.g. refer
 * @param  int      $status HTTP status code
 * @access private
 * @see    log_hit()
 */
function logit($r = '', $status = 200)
{
    global $prefs, $pretext;
    if (!isset($pretext['request_uri'])) {
        return;
    }
    $host = $ip = (string) remote_addr();
    $protocol = false;
    $referer = serverSet('HTTP_REFERER');
    if ($referer) {
        foreach (do_list(LOG_REFERER_PROTOCOLS) as $option) {
            if (strpos($referer, $option . '://') === 0) {
                $protocol = $option;
                $referer = substr($referer, strlen($protocol) + 3);
                break;
            }
        }
        if (!$protocol || $protocol === 'https' && PROTOCOL !== 'https://') {
            $referer = '';
        } elseif (preg_match('/^[^\\.]*\\.?' . preg_quote(preg_replace('/^www\\./', '', SITE_HOST), '/') . '/i', $referer)) {
            $referer = '';
        } else {
            $referer = $protocol . '://' . clean_url($referer);
        }
    }
    if ($r == 'refer' && !$referer) {
        return;
    }
    if (!empty($prefs['use_dns'])) {
        // A crude rDNS cache.
        if (($h = safe_field('host', 'txp_log', "ip='" . doSlash($ip) . "' limit 1")) !== false) {
            $host = $h;
        } else {
            // Double-check the rDNS.
            $host = @gethostbyaddr($ip);
            if ($host !== $ip && @gethostbyname($host) !== $ip) {
                $host = $ip;
            }
        }
    }
    insert_logit(array('uri' => $pretext['request_uri'], 'ip' => $ip, 'host' => $host, 'status' => $status, 'method' => serverSet('REQUEST_METHOD'), 'ref' => $referer));
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:54,代码来源:log.php

示例11: getmicrotime

$microstart = getmicrotime();
if ($connected && safe_query("describe `" . PFX . "textpattern`")) {
    $dbversion = safe_field('val', 'txp_prefs', "name = 'version'");
    $prefs = get_prefs();
    extract($prefs);
    if (empty($siteurl)) {
        $siteurl = $_SERVER['HTTP_HOST'] . rtrim(dirname(dirname($_SERVER['SCRIPT_NAME'])), '/');
    }
    if (empty($path_to_site)) {
        updateSitePath(dirname(dirname(__FILE__)));
    }
    define("LANG", $language);
    //i18n: define("LANG","en-gb");
    define('txp_version', $thisversion);
    if (!defined('PROTOCOL')) {
        define('PROTOCOL', strtolower(serverSet('HTTPS')) == 'on' ? 'https://' : 'http://');
    }
    define("hu", PROTOCOL . $siteurl . '/');
    // v1.0 experimental relative url global
    define("rhu", preg_replace("/https?:\\/\\/.+(\\/.*)\\/?\$/U", "\$1", hu));
    if (!empty($locale)) {
        setlocale(LC_ALL, $locale);
    }
    $textarray = load_lang(LANG);
    include txpath . '/include/txp_auth.php';
    doAuth();
    $event = gps('event') ? gps('event') : 'article';
    $step = gps('step');
    if (!$dbversion or $dbversion != $thisversion or $txp_using_svn) {
        define('TXP_UPDATE', 1);
        include txpath . '/update/_update.php';
开发者ID:bgarrels,项目名称:textpattern,代码行数:31,代码来源:index.php

示例12: password_protect

function password_protect($atts, $thing = null)
{
    ob_start();
    extract(lAtts(array('login' => null, 'pass' => null, 'privs' => null), $atts));
    if ($pass === null) {
        $access = ($user = is_logged_in($login)) !== false && ($privs === null || in_list($user['privs'], $privs));
    } else {
        $au = serverSet('PHP_AUTH_USER');
        $ap = serverSet('PHP_AUTH_PW');
        // For PHP as (f)cgi, two rules in htaccess often allow this workaround.
        $ru = serverSet('REDIRECT_REMOTE_USER');
        if (!$au && !$ap && strpos($ru, 'Basic') === 0) {
            list($au, $ap) = explode(':', base64_decode(substr($ru, 6)));
        }
        $access = $au === $login && $ap === $pass;
    }
    if ($access === false && $pass !== null) {
        header('WWW-Authenticate: Basic realm="Private"');
    }
    if ($thing === null) {
        if ($access === false) {
            txp_die(gTxt('auth_required'), '401');
        }
        return '';
    }
    return parse(EvalElse($thing, $access));
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:27,代码来源:taghandlers.php

示例13: cnk_pretext

function cnk_pretext()
{
    global $prefs;
    // only takeover url algorithm when in section_title mode
    if (CNK_FRIENDLY_URLS && $prefs['permlink_mode'] == 'section_title') {
        extract($prefs);
        $out = array();
        // some useful vars for taghandlers, plugins
        $out['request_uri'] = preg_replace("|^https?://[^/]+|i", "", serverSet('REQUEST_URI'));
        $out['qs'] = serverSet('QUERY_STRING');
        // IIS fix
        if (!$out['request_uri'] and serverSet('SCRIPT_NAME')) {
            $out['request_uri'] = serverSet('SCRIPT_NAME') . (serverSet('QUERY_STRING') ? '?' . serverSet('QUERY_STRING') : '');
        }
        // another IIS fix
        if (!$out['request_uri'] and serverSet('argv')) {
            $argv = serverSet('argv');
            $out['request_uri'] = @substr($argv[0], strpos($argv[0], ';') + 1);
        }
        $subpath = preg_quote(preg_replace("/https?:\\/\\/.*(\\/.*)/Ui", "\$1", hu), "/");
        $req = preg_replace("/^{$subpath}/i", "/", $out['request_uri']);
        $url_chunks = explode('/', trim($req, '/'));
        $req = '/' . implode('/', array_slice($url_chunks, -2));
        //echo $req;
        extract(chopUrl($req));
        //first we sniff out some of the preset url schemes
        if (strlen($u1)) {
            switch ($u1) {
                case 'atom':
                    include txpath . '/publish/atom.php';
                    exit(atom());
                case 'rss':
                    include txpath . '/publish/rss.php';
                    exit(rss());
                    // urldecode(strtolower(urlencode())) looks ugly but is the only way to
                    // make it multibyte-safe without breaking backwards-compatibility
                // urldecode(strtolower(urlencode())) looks ugly but is the only way to
                // make it multibyte-safe without breaking backwards-compatibility
                case urldecode(strtolower(urlencode(gTxt('section')))):
                    $out['s'] = ckEx('section', $u2) ? $u2 : '';
                    break;
                case urldecode(strtolower(urlencode(gTxt('category')))):
                    $out['c'] = ckEx('category', $u2) ? $u2 : '';
                    break;
                case urldecode(strtolower(urlencode(gTxt('author')))):
                    $out['author'] = !empty($u2) ? $u2 : '';
                    break;
                    // AuthorID gets resolved from Name further down
                // AuthorID gets resolved from Name further down
                case urldecode(strtolower(urlencode(gTxt('file_download')))):
                    $out['s'] = 'file_download';
                    $out['id'] = !empty($u2) ? $u2 : '';
                    break;
                default:
                    // then see if the prefs-defined permlink scheme is usable
                    switch ($permlink_mode) {
                        /*
                        case 'section_id_title':
                        		if (empty($u2)) 
                        		{
                        				$out['s'] = (ckEx('section',$u1)) ? $u1 : '';
                        		}
                        		else 
                        		{
                        				$rs = lookupByIDSection($u2, $u1);
                        				$out['s'] = @$rs['Section'];
                        				$out['id'] = @$rs['ID'];
                        		}
                        break;
                        
                        case 'year_month_day_title':
                        		if (empty($u2)) 
                        		{
                        				$out['s'] = (ckEx('section',$u1)) ? $u1 : '';
                        		}
                        		elseif (empty($u4))
                        		{
                        				$month = "$u1-$u2";
                        				if (!empty($u3)) $month.= "-$u3";
                        				if (preg_match('/\d+-\d+(?:-\d+)?/', $month)) {
                        						$out['month'] = $month;
                        						$out['s'] = 'default';
                        				}
                        		}
                        		else
                        		{
                        				$when = "$u1-$u2-$u3";
                        				$rs = lookupByDateTitle($when,$u4);
                        				$out['id'] = (!empty($rs['ID'])) ? $rs['ID'] : '';
                        				$out['s'] = (!empty($rs['Section'])) ? $rs['Section'] : '';
                        		}
                        break;
                        */
                        case 'section_title':
                            if (empty($u2)) {
                                $out['s'] = ckEx('section', $u1) ? $u1 : '';
                            } else {
                                // match section/title
                                $rs = lookupByTitleSection($u2, $u1);
                                if (count($rs)) {
//.........这里部分代码省略.........
开发者ID:netcarver,项目名称:cnk_section_tree,代码行数:101,代码来源:cnk_section_tree.php

示例14: preText

function preText($s, $prefs)
{
    extract($prefs);
    callback_event('pretext');
    if (gps('rss')) {
        include txpath . '/publish/rss.php';
        exit(rss());
    }
    if (gps('atom')) {
        include txpath . '/publish/atom.php';
        exit(atom());
    }
    // set messy variables
    $out = makeOut('id', 's', 'c', 'q', 'pg', 'p', 'month', 'author');
    // some useful vars for taghandlers, plugins
    $out['request_uri'] = serverSet('REQUEST_URI');
    $out['qs'] = serverSet('QUERY_STRING');
    // IIS - can someone confirm whether or not this works?
    if (!$out['request_uri'] and $argv = serverSet('argv')) {
        $out['request_uri'] = @substr($argv[0], strpos($argv[0], ';' + 1));
    }
    // define the useable url, minus any subdirectories.
    // this is pretty fugly, if anyone wants to have a go at it - dean
    $out['subpath'] = $subpath = preg_quote(preg_replace("/http:\\/\\/.*(\\/.*)/Ui", "\$1", hu), "/");
    $out['req'] = $req = preg_replace("/^{$subpath}/i", "/", serverSet('REQUEST_URI'));
    $is_404 = 0;
    // if messy vars exist, bypass url parsing
    if (!$out['id'] && !$out['s']) {
        extract(chopUrl($req));
        //first we sniff out some of the preset url schemes
        if (!empty($u1)) {
            switch ($u1) {
                case 'atom':
                    include txpath . '/publish/atom.php';
                    exit(atom());
                case 'rss':
                    include txpath . '/publish/rss.php';
                    exit(rss());
                    // urldecode(strtolower(urlencode())) looks ugly but is the only way to
                    // make it multibyte-safe without breaking backwards-compatibility
                // urldecode(strtolower(urlencode())) looks ugly but is the only way to
                // make it multibyte-safe without breaking backwards-compatibility
                case urldecode(strtolower(urlencode(gTxt('section')))):
                    $out['s'] = ckEx('section', $u2) ? $u2 : '';
                    break;
                case urldecode(strtolower(urlencode(gTxt('category')))):
                    $out['c'] = ckEx('category', $u2) ? $u2 : '';
                    break;
                case urldecode(strtolower(urlencode(gTxt('author')))):
                    $out['author'] = !empty($u2) ? $u2 : '';
                    break;
                    // AuthorID gets resolved from Name further down
                // AuthorID gets resolved from Name further down
                case urldecode(strtolower(urlencode(gTxt('file_download')))):
                    $out['s'] = 'file_download';
                    $out['id'] = !empty($u2) ? $u2 : '';
                    break;
                case 'p':
                    $out['p'] = is_numeric($u2) ? $u2 : '';
                    break;
                default:
                    // then see if the prefs-defined permlink scheme is usable
                    switch ($permlink_mode) {
                        case 'section_id_title':
                            if (empty($u2)) {
                                $out['s'] = ckEx('section', $u1) ? $u1 : '';
                                $is_404 = empty($out['s']);
                            } else {
                                $rs = ckExID($u2);
                                $out['s'] = @$rs['Section'];
                                $out['id'] = @$rs['ID'];
                                $is_404 = (empty($out['s']) or empty($out['id']));
                            }
                            break;
                        case 'year_month_day_title':
                            if (empty($u2)) {
                                $out['s'] = ckEx('section', $u1) ? $u1 : '';
                                $is_404 = empty($out['s']);
                            } elseif (empty($u4)) {
                                $month = "{$u1}-{$u2}";
                                if (!empty($u3)) {
                                    $month .= "-{$u3}";
                                }
                                if (preg_match('/\\d+-\\d+(?:-\\d+)?/', $month)) {
                                    $out['month'] = $month;
                                    $out['s'] = 'default';
                                } else {
                                    $is_404 = 1;
                                }
                            } else {
                                $when = "{$u1}-{$u2}-{$u3}";
                                $rs = lookupByDateTitle($when, $u4);
                                $out['id'] = !empty($rs['ID']) ? $rs['ID'] : '';
                                $out['s'] = !empty($rs['Section']) ? $rs['Section'] : '';
                                $is_404 = (empty($out['s']) or empty($out['id']));
                            }
                            break;
                        case 'section_title':
                            if (empty($u2)) {
                                $out['s'] = ckEx('section', $u1) ? $u1 : '';
//.........这里部分代码省略.........
开发者ID:bgarrels,项目名称:textpattern,代码行数:101,代码来源:publish.php

示例15: getmicrotime

$microstart = getmicrotime();
if ($connected && safe_query("describe `" . PFX . "textpattern`")) {
    $dbversion = safe_field('val', 'txp_prefs', "name = 'version'");
    $prefs = get_prefs();
    extract($prefs);
    if (empty($siteurl)) {
        $siteurl = $_SERVER['HTTP_HOST'] . rtrim(dirname(dirname($_SERVER['SCRIPT_NAME'])), '/');
    }
    if (empty($path_to_site)) {
        updateSitePath(dirname(dirname(__FILE__)));
    }
    define("LANG", $language);
    //i18n: define("LANG","en-gb");
    define('txp_version', $thisversion);
    if (!defined('PROTOCOL')) {
        define('PROTOCOL', serverSet('HTTPS') != '' ? 'https://' : 'http://');
    }
    define("hu", PROTOCOL . $siteurl . '/');
    // v1.0 experimental relative url global
    define("rhu", preg_replace("/https?:\\/\\/.+(\\/.*)\\/?\$/U", "\$1", hu));
    if (!empty($locale)) {
        setlocale(LC_ALL, $locale);
    }
    $textarray = load_lang(LANG);
    include txpath . '/include/txp_auth.php';
    doAuth();
    $event = gps('event') ? gps('event') : 'article';
    $step = gps('step');
    if (!$dbversion or $dbversion != $thisversion or $txp_using_svn) {
        define('TXP_UPDATE', 1);
        include txpath . '/update/_update.php';
开发者ID:bgarrels,项目名称:textpattern,代码行数:31,代码来源:index.php


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