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


PHP Surfer::set方法代码示例

本文整理汇总了PHP中Surfer::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Surfer::set方法的具体用法?PHP Surfer::set怎么用?PHP Surfer::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Surfer的用法示例。


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

示例1: unset

    Surfer::set_cookie('screening', $_SESSION['surfer_token']);
    // don't do that again
    unset($_SESSION['surfer_token']);
}
// retrieve session data, but not if run from the command line, and not from robot nor spider
if (isset($_SERVER['REMOTE_ADDR']) && !Surfer::is_crawler() && !headers_sent()) {
    // permanent identification has been selected
    if (isset($context['users_with_permanent_authentication']) && $context['users_with_permanent_authentication'] != 'N') {
        // use cookie to identify user -- user id, time of login, gmt offset, salt
        if (!Surfer::is_logged() && isset($_COOKIE['screening']) && ($nouns = explode('|', $_COOKIE['screening'], 4)) && count($nouns) == 4) {
            // get user by id
            if (!($user = Users::get($nouns[0]))) {
            } elseif (!isset($user['id']) || $user['id'] != $nouns[0]) {
            } elseif (!isset($user['handle']) || strcmp($nouns[3], md5($nouns[1] . '|' . $user['handle']))) {
            } else {
                Surfer::set($user, TRUE);
            }
        }
        // allow no more than one hour of inactivity
    } elseif (isset($_SESSION['watchdog']) && time() > $_SESSION['watchdog'] + 3600) {
        Surfer::reset();
    }
    // refresh the watchdog
    $_SESSION['watchdog'] = time();
    // bare server-side flash detection
    if (isset($_SERVER['HTTP_ACCEPT']) && preg_match('/application\\/x-shockwave-flash/i', $_SERVER['HTTP_ACCEPT'])) {
        $_SESSION['browser_has_flash'] = TRUE;
    }
}
// filter HTML tags of submitted material
if (@count($_REQUEST) && (!isset($context['allow_html_input']) || $context['allow_html_input'] != 'Y')) {
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:surfer.php

示例2: send_body

/**
 * dynamically generate the page
 *
 * @see skins/index.php
 */
function send_body()
{
    global $context, $action;
    // check that the user is an admin, but only if there is at least one user record
    $query = "SELECT count(*) FROM " . SQL::table_name('users');
    if (!Surfer::is_associate() && SQL::query($query) !== FALSE) {
        Safe::header('Status: 401 Unauthorized', TRUE, 401);
        echo '<p>' . i18n::s('You are not allowed to perform this operation.') . "</p>\n";
        return;
    }
    // log the current surfer as an associate if not yet the case
    if (!Surfer::is_associate()) {
        $fields = array();
        $fields['id'] = 1;
        $fields['nick_name'] = 'admin';
        $fields['email'] = '';
        $fields['capability'] = 'A';
        Surfer::set($fields);
        echo '<p>' . i18n::s('You have associate privilege') . '</p>';
    }
    // check every table of the database
    if ($action == 'build') {
        // maybe we will have to switch the server off
        $temporary_off = FALSE;
        // ensure nobody else will access the database during the operation
        if (file_exists('../parameters/switch.on')) {
            if (Safe::rename($context['path_to_root'] . 'parameters/switch.on', $context['path_to_root'] . 'parameters/switch.off')) {
                echo BR . i18n::s('The server has been switched off.');
                $temporary_off = TRUE;
            }
            // let concurrent on-going transactions finish properly
            Safe::sleep(3);
            // first installation
        } elseif (!file_exists('../parameters/switch.off')) {
            echo '<p>' . i18n::s('Review provided information and go to the bottom of the page to move forward.') . "</a></p>\n";
        }
        // ensure utf8 character set for this database
        $query = "ALTER DATABASE `" . $context['database'] . "`  DEFAULT CHARACTER SET utf8";
        SQL::query($query);
        // create tables for users
        echo Users::setup();
        // create tables for activities
        echo Activities::setup();
        // create tables for notifications
        include_once '../users/notifications.php';
        echo Notifications::setup();
        // create tables for messages
        echo Mailer::setup();
        // create tables for visits
        include_once '../users/visits.php';
        echo Visits::setup();
        // create tables for sections
        echo Sections::setup();
        // create tables for articles
        echo Articles::setup();
        // create tables for images
        include_once '../images/images.php';
        echo Images::setup();
        // create tables for tables
        include_once '../tables/tables.php';
        echo Tables::setup();
        // create tables for files
        echo Files::setup();
        // create tables for links
        include_once '../links/links.php';
        echo Links::setup();
        // create tables for locations
        include_once '../locations/locations.php';
        echo Locations::setup();
        // create tables for comments
        include_once '../comments/comments.php';
        echo Comments::setup();
        // create tables for categories
        echo Categories::setup();
        // create tables for members
        include_once '../shared/members.php';
        echo Members::setup();
        // create tables for dates
        include_once '../dates/dates.php';
        echo Dates::setup();
        // create tables for servers
        include_once '../servers/servers.php';
        echo Servers::setup();
        // create tables for versions
        include_once '../versions/versions.php';
        echo Versions::setup();
        // create tables for enrolments
        include_once '../shared/enrolments.php';
        echo Enrolments::setup();
        // create tables for values
        include_once '../shared/values.php';
        echo Values::setup();
        // create tables for the cache
        echo Cache::setup();
        // create tables for the php documentation
//.........这里部分代码省略.........
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:setup.php

示例3: elseif

$context['page_title'] = i18n::s('Validate your e-mail address');
// stop crawlers
if (Surfer::is_crawler()) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // not found
} elseif (!isset($item['id'])) {
    include '../error.php';
    // bad handle
} elseif ($id != $item['handle']) {
    include '../error.php';
} elseif (Users::validate($item['id'])) {
    // congratulations
    $context['text'] .= sprintf(i18n::s('<p>%s,</p><p>Your e-mail address has been validated, and you are now an active member of this community.</p>'), ucfirst($item['nick_name']));
    // set permanent name shown from top level
    Safe::setcookie('surfer_name', $item['nick_name'], time() + 60 * 60 * 24 * 500, '/');
    // save surfer profile in session context
    Surfer::set($item);
    // follow-up commands
    $follow_up = i18n::s('Where do you want to go now?');
    $menu = array();
    $menu = array_merge($menu, array(Users::get_permalink($item) => i18n::s('My profile')));
    $menu = array_merge($menu, array($context['url_to_root'] => i18n::s('Front page')));
    $follow_up .= Skin::build_list($menu, 'menu_bar');
    $context['text'] .= Skin::build_block($follow_up, 'bottom');
    // failed operation
} else {
    $context['text'] .= '<p>' . i18n::s('Your e-mail address has not been validated.') . "</p>\n";
}
// render the skin
render_skin();
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:validate.php

示例4: define

if (!defined('BR')) {
    define('BR', '<br>');
}
if (!defined('EOT')) {
    define('EOT', '>');
}
// if no configuration file or if no database
if (!file_exists('../parameters/control.include.php') || !isset($context['connection']) || !$context['connection']) {
    // consider the current surfer as an associate, but only on first installation
    if (!Surfer::is_associate() && !file_exists('../parameters/switch.on') && !file_exists('../parameters/switch.off')) {
        $fields = array();
        $fields['id'] = 1;
        $fields['nick_name'] = 'admin';
        $fields['email'] = '';
        $fields['capability'] = 'A';
        Surfer::set($fields);
        Logger::error(i18n::s('You are considered temporarily as an associate, with specific rights on this server. Please do not close your browser until the end of the configuration.'));
    }
}
// the path to this page
$context['path_bar'] = array('control/' => i18n::s('Control Panel'));
// the title of the page
$context['page_title'] = sprintf(i18n::s('%s: %s'), i18n::s('Configure'), i18n::s('System parameters'));
// ensure we have an associate
if (!Surfer::is_associate()) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // forward to the control panel
    $menu = array('control/' => i18n::s('Control Panel'));
    $context['text'] .= Skin::build_list($menu, 'menu_bar');
    // nothing more in demo mode
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:configure.php

示例5: elseif

 * @author Christophe Battarel [email]christophe.battarel@altairis.fr[/email]
 * @tester Ghjmora
 * @tester GnapZ
 * @tester Cyandrea
 * @tester Lucrecius
 * @reference
 * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
 */
// common definitions and initial processing
include_once '../shared/global.php';
include_once 'links.php';
// allow for direct login
if (isset($_REQUEST['account']) && isset($_REQUEST['password'])) {
    // authenticate the surfer and start a session
    if ($user = Users::login($_REQUEST['account'], $_REQUEST['password'])) {
        Surfer::set($user);
    }
}
// look for the id
$id = NULL;
if (isset($_REQUEST['id'])) {
    $id = $_REQUEST['id'];
} elseif (isset($context['arguments'][0]) && !isset($context['arguments'][1])) {
    $id = $context['arguments'][0];
}
$id = strip_tags($id);
// get the item from the database
$item = Links::get($id);
// get the related anchor, if any
$anchor = NULL;
if (isset($_REQUEST['anchor'])) {
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:edit.php

示例6: put

 /**
  * put an updated user profile in the database
  *
  * If present, only the password is changed. Or other fields except the password are modified.
  *
  * To change a password, set fields 'id', 'password' and 'confirm'
  *
  * @param array an array of fields
  * @return TRUE on success, FALSE otherwise
  *
  * @see users/edit.php
  * @see users/password.php
  * @see users/select_avatar.php
  **/
 public static function put(&$fields)
 {
     global $context;
     // load the record
     $item = Users::get($fields['id']);
     if (!isset($item['id']) || !$item['id']) {
         Logger::error(i18n::s('No item has the provided id.'));
         return FALSE;
     }
     // remember who is changing this record
     Surfer::check_default_editor($fields);
     // if a password change
     if (isset($fields['password'])) {
         // ensure that the password has been provided twice
         if (!isset($fields['confirm']) || $fields['confirm'] != $fields['password']) {
             Logger::error(i18n::s('New password has to be confirmed.'));
             return FALSE;
         }
         // hash password, we are coming from an interactive form
         $fields['password'] = md5($fields['password']);
         // else if a regular profile update
     } else {
         // nick_name is required
         if (!isset($fields['nick_name']) || !trim($fields['nick_name'])) {
             Logger::error(i18n::s('Please indicate a nick name.'));
             return FALSE;
         }
         // some weird users put spaces around
         $fields['nick_name'] = trim($fields['nick_name']);
         // nick_name may be already used
         if (($used = Users::get($fields['nick_name'])) && $used['id'] != $fields['id']) {
             Logger::error(i18n::s('Another member already has this nick name. Please select a different one.'));
             return FALSE;
         }
         // ensure we have a full name
         if (!isset($fields['full_name']) || !trim($fields['full_name'])) {
             $fields['full_name'] = $fields['nick_name'];
         }
         // protect from hackers
         if (isset($fields['avatar_url'])) {
             $fields['avatar_url'] = encode_link($fields['avatar_url']);
         }
         // set default values
         if (!isset($fields['active']) || !$fields['active']) {
             $fields['active'] = 'Y';
         }
         if (isset($fields['selected_editor'])) {
             $fields['editor'] = $fields['selected_editor'];
         } elseif (isset($context['users_default_editor'])) {
             $fields['editor'] = $context['users_default_editor'];
         } else {
             $fields['editor'] = 'yacs';
         }
         if (!isset($fields['interface']) || $fields['interface'] != 'C') {
             $fields['interface'] = 'I';
         }
         if (!isset($fields['with_newsletters']) || $fields['with_newsletters'] != 'Y') {
             $fields['with_newsletters'] = 'N';
         }
         if (!isset($fields['without_alerts']) || $fields['without_alerts'] != 'N') {
             $fields['without_alerts'] = 'Y';
         }
         if (!isset($fields['without_confirmations']) || $fields['without_confirmations'] != 'N') {
             $fields['without_confirmations'] = 'Y';
         }
         if (!isset($fields['without_messages']) || $fields['without_messages'] != 'N') {
             $fields['without_messages'] = 'Y';
         }
         if (!isset($fields['birth_date']) || !$fields['birth_date']) {
             $fields['birth_date'] = NULL_DATE;
         }
         // clean provided tags
         if (isset($fields['tags'])) {
             $fields['tags'] = trim($fields['tags'], " \t.:,!?");
         }
         // save new settings in session and in cookie
         if (Surfer::is($fields['id'])) {
             // change preferred editor
             $_SESSION['surfer_editor'] = $fields['editor'];
             Safe::setcookie('surfer_editor', $fields['editor'], NULL, '/');
             // change preferred language
             if (isset($fields['language']) && $_SESSION['surfer_language'] != $fields['language']) {
                 $_SESSION['surfer_language'] = $fields['language'];
                 $_SESSION['l10n_modules'] = array();
             }
         }
//.........这里部分代码省略.........
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:users.php


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