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


PHP validateSession函数代码示例

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


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

示例1: ModerationMain

/**
 * Entry point for the moderation center.
 *
 * @param bool $dont_call = false
 */
function ModerationMain($dont_call = false)
{
    global $txt, $context, $scripturl, $sc, $modSettings, $user_info, $settings, $sourcedir, $options, $smcFunc;
    // Don't run this twice... and don't conflict with the admin bar.
    if (isset($context['admin_area'])) {
        return;
    }
    $context['can_moderate_boards'] = $user_info['mod_cache']['bq'] != '0=1';
    $context['can_moderate_groups'] = $user_info['mod_cache']['gq'] != '0=1';
    $context['can_moderate_approvals'] = $modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap']);
    // Everyone using this area must be allowed here!
    if (!$context['can_moderate_boards'] && !$context['can_moderate_groups'] && !$context['can_moderate_approvals']) {
        isAllowedTo('access_mod_center');
    }
    // We're gonna want a menu of some kind.
    require_once $sourcedir . '/Subs-Menu.php';
    // Load the language, and the template.
    loadLanguage('ModerationCenter');
    loadTemplate(false, 'admin');
    $context['admin_preferences'] = !empty($options['admin_preferences']) ? unserialize($options['admin_preferences']) : array();
    $context['robot_no_index'] = true;
    // This is the menu structure - refer to Subs-Menu.php for the details.
    $moderation_areas = array('main' => array('title' => $txt['mc_main'], 'areas' => array('index' => array('label' => $txt['moderation_center'], 'function' => 'ModerationHome'), 'settings' => array('label' => $txt['mc_settings'], 'function' => 'ModerationSettings'), 'modlogoff' => array('label' => $txt['mc_logoff'], 'function' => 'ModEndSession', 'enabled' => empty($modSettings['securityDisable_moderate'])), 'notice' => array('file' => 'ModerationCenter.php', 'function' => 'ShowNotice', 'select' => 'index'))), 'logs' => array('title' => $txt['mc_logs'], 'areas' => array('modlog' => array('label' => $txt['modlog_view'], 'enabled' => !empty($modSettings['modlog_enabled']) && $context['can_moderate_boards'], 'file' => 'Modlog.php', 'function' => 'ViewModlog'), 'warnings' => array('label' => $txt['mc_warnings'], 'enabled' => in_array('w', $context['admin_features']) && $modSettings['warning_settings'][0] == 1 && $context['can_moderate_boards'], 'function' => 'ViewWarnings', 'subsections' => array('log' => array($txt['mc_warning_log']), 'templates' => array($txt['mc_warning_templates'], 'issue_warning'))))), 'posts' => array('title' => $txt['mc_posts'], 'enabled' => $context['can_moderate_boards'] || $context['can_moderate_approvals'], 'areas' => array('postmod' => array('label' => $txt['mc_unapproved_posts'], 'enabled' => $context['can_moderate_approvals'], 'file' => 'PostModeration.php', 'function' => 'PostModerationMain', 'custom_url' => $scripturl . '?action=moderate;area=postmod', 'subsections' => array('posts' => array($txt['mc_unapproved_replies']), 'topics' => array($txt['mc_unapproved_topics']))), 'attachmod' => array('label' => $txt['mc_unapproved_attachments'], 'enabled' => $context['can_moderate_approvals'], 'file' => 'PostModeration.php', 'function' => 'PostModerationMain', 'custom_url' => $scripturl . '?action=moderate;area=attachmod;sa=attachments'), 'reports' => array('label' => $txt['mc_reported_posts'], 'enabled' => $context['can_moderate_boards'], 'file' => 'ModerationCenter.php', 'function' => 'ReportedPosts', 'subsections' => array('open' => array($txt['mc_reportedp_active']), 'closed' => array($txt['mc_reportedp_closed']))))), 'groups' => array('title' => $txt['mc_groups'], 'enabled' => $context['can_moderate_groups'], 'areas' => array('userwatch' => array('label' => $txt['mc_watched_users_title'], 'enabled' => in_array('w', $context['admin_features']) && $modSettings['warning_settings'][0] == 1 && $context['can_moderate_boards'], 'function' => 'ViewWatchedUsers', 'subsections' => array('member' => array($txt['mc_watched_users_member']), 'post' => array($txt['mc_watched_users_post']))), 'groups' => array('label' => $txt['mc_group_requests'], 'file' => 'Groups.php', 'function' => 'Groups', 'custom_url' => $scripturl . '?action=moderate;area=groups;sa=requests'), 'viewgroups' => array('label' => $txt['mc_view_groups'], 'file' => 'Groups.php', 'function' => 'Groups'))));
    // Make sure the administrator has a valid session...
    validateSession('moderate');
    // I don't know where we're going - I don't know where we've been...
    $menuOptions = array('action' => 'moderate', 'disable_url_session_check' => true);
    $mod_include_data = createMenu($moderation_areas, $menuOptions);
    unset($moderation_areas);
    // We got something - didn't we? DIDN'T WE!
    if ($mod_include_data == false) {
        fatal_lang_error('no_access', false);
    }
    // Retain the ID information in case required by a subaction.
    $context['moderation_menu_id'] = $context['max_menu_id'];
    $context['moderation_menu_name'] = 'menu_data_' . $context['moderation_menu_id'];
    // What a pleasant shortcut - even tho we're not *really* on the admin screen who cares...
    $context['admin_area'] = $mod_include_data['current_area'];
    // Build the link tree.
    $context['linktree'][] = array('url' => $scripturl . '?action=moderate', 'name' => $txt['moderation_center']);
    if (isset($mod_include_data['current_area']) && $mod_include_data['current_area'] != 'index') {
        $context['linktree'][] = array('url' => $scripturl . '?action=moderate;area=' . $mod_include_data['current_area'], 'name' => $mod_include_data['label']);
    }
    if (!empty($mod_include_data['current_subsection']) && $mod_include_data['subsections'][$mod_include_data['current_subsection']][0] != $mod_include_data['label']) {
        $context['linktree'][] = array('url' => $scripturl . '?action=moderate;area=' . $mod_include_data['current_area'] . ';sa=' . $mod_include_data['current_subsection'], 'name' => $mod_include_data['subsections'][$mod_include_data['current_subsection']][0]);
    }
    // Now - finally - the bit before the encore - the main performance of course!
    if (!$dont_call) {
        if (isset($mod_include_data['file'])) {
            require_once $sourcedir . '/' . $mod_include_data['file'];
        }
        $mod_include_data['function']();
    }
}
开发者ID:Glyph13,项目名称:SMF2.1,代码行数:59,代码来源:ModerationCenter.php

示例2: prepareModcenter

 /**
  * Prepare menu, make checks, load files, and create moderation menu.
  * This can be called from the class, or from outside, to
  * set up moderation menu.
  */
 public function prepareModcenter()
 {
     global $txt, $context, $scripturl, $modSettings, $user_info, $options;
     // Don't run this twice... and don't conflict with the admin bar.
     if (isset($context['admin_area'])) {
         return;
     }
     $context['can_moderate_boards'] = $user_info['mod_cache']['bq'] != '0=1';
     $context['can_moderate_groups'] = $user_info['mod_cache']['gq'] != '0=1';
     $context['can_moderate_approvals'] = $modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap']);
     // Everyone using this area must be allowed here!
     if (!$context['can_moderate_boards'] && !$context['can_moderate_groups'] && !$context['can_moderate_approvals']) {
         isAllowedTo('access_mod_center');
     }
     // We're gonna want a menu of some kind.
     require_once SUBSDIR . '/Menu.subs.php';
     // Load the language, and the template.
     loadLanguage('ModerationCenter');
     loadTemplate(false, 'admin');
     $context['admin_preferences'] = !empty($options['admin_preferences']) ? unserialize($options['admin_preferences']) : array();
     $context['robot_no_index'] = true;
     // Moderation counts for things that this moderator can take care of
     require_once SUBSDIR . '/Moderation.subs.php';
     $mod_counts = loadModeratorMenuCounts();
     // This is the menu structure - refer to subs/Menu.subs.php for the details.
     $moderation_areas = array('main' => array('title' => $txt['mc_main'], 'areas' => array('index' => array('label' => $txt['moderation_center'], 'controller' => 'ModerationCenter_Controller', 'function' => 'action_moderationHome', 'icon' => 'transparent.png', 'class' => 'admin_img_home'), 'settings' => array('label' => $txt['mc_settings'], 'controller' => 'ModerationCenter_Controller', 'function' => 'action_moderationSettings', 'icon' => 'transparent.png', 'class' => 'admin_img_features'), 'modlogoff' => array('label' => $txt['mc_logoff'], 'controller' => 'ModerationCenter_Controller', 'function' => 'action_modEndSession', 'enabled' => empty($modSettings['securityDisable_moderate']), 'icon' => 'transparent.png', 'class' => 'admin_img_exit'), 'notice' => array('controller' => 'ModerationCenter_Controller', 'function' => 'action_showNotice', 'select' => 'index', 'icon' => 'transparent.png', 'class' => 'admin_img_news'))), 'logs' => array('title' => $txt['mc_logs'], 'areas' => array('modlog' => array('label' => $txt['modlog_view'], 'enabled' => !empty($modSettings['modlog_enabled']) && $context['can_moderate_boards'], 'file' => 'Modlog.controller.php', 'dir' => ADMINDIR, 'controller' => 'Modlog_Controller', 'function' => 'action_log', 'icon' => 'transparent.png', 'class' => 'admin_img_logs'), 'warnings' => array('label' => $txt['mc_warnings'], 'enabled' => in_array('w', $context['admin_features']) && !empty($modSettings['warning_enable']) && $context['can_moderate_boards'], 'controller' => 'ModerationCenter_Controller', 'function' => 'action_viewWarnings', 'icon' => 'transparent.png', 'class' => 'admin_img_reports', 'subsections' => array('log' => array($txt['mc_warning_log']), 'templates' => array($txt['mc_warning_templates'], 'issue_warning'))))), 'posts' => array('title' => $txt['mc_posts'] . (!empty($mod_counts['pt_total']) ? ' [' . $mod_counts['pt_total'] . ']' : ''), 'enabled' => $context['can_moderate_boards'] || $context['can_moderate_approvals'], 'areas' => array('postmod' => array('label' => $txt['mc_unapproved_posts'] . (!empty($mod_counts['postmod']) ? ' [' . $mod_counts['postmod'] . ']' : ''), 'enabled' => $context['can_moderate_approvals'], 'file' => 'PostModeration.controller.php', 'controller' => 'PostModeration_Controller', 'function' => 'action_index', 'icon' => 'transparent.png', 'class' => 'admin_img_posts', 'custom_url' => $scripturl . '?action=moderate;area=postmod', 'subsections' => array('posts' => array($txt['mc_unapproved_replies']), 'topics' => array($txt['mc_unapproved_topics']))), 'emailmod' => array('label' => $txt['mc_emailerror'] . (!empty($mod_counts['emailmod']) ? ' [' . $mod_counts['emailmod'] . ']' : ''), 'enabled' => !empty($modSettings['maillist_enabled']) && allowedTo('approve_emails'), 'file' => 'ManageMaillist.controller.php', 'dir' => ADMINDIR, 'function' => 'UnapprovedEmails', 'icon' => 'transparent.png', 'class' => 'admin_img_mail', 'custom_url' => $scripturl . '?action=admin;area=maillist;sa=emaillist'), 'attachmod' => array('label' => $txt['mc_unapproved_attachments'] . (!empty($mod_counts['attachments']) ? ' [' . $mod_counts['attachments'] . ']' : ''), 'enabled' => $context['can_moderate_approvals'], 'file' => 'PostModeration.controller.php', 'controller' => 'PostModeration_Controller', 'function' => 'action_index', 'icon' => 'transparent.png', 'class' => 'admin_img_attachment', 'custom_url' => $scripturl . '?action=moderate;area=attachmod;sa=attachments'), 'reports' => array('label' => $txt['mc_reported_posts'] . (!empty($mod_counts['reports']) ? ' [' . $mod_counts['reports'] . ']' : ''), 'enabled' => $context['can_moderate_boards'], 'controller' => 'ModerationCenter_Controller', 'function' => 'action_reportedPosts', 'icon' => 'transparent.png', 'class' => 'admin_img_reports', 'subsections' => array('open' => array($txt['mc_reportedp_active'] . (!empty($mod_counts['reports']) ? ' [' . $mod_counts['reports'] . ']' : '')), 'closed' => array($txt['mc_reportedp_closed']))))), 'groups' => array('title' => $txt['mc_groups'] . (!empty($mod_counts['mg_total']) ? ' [' . $mod_counts['mg_total'] . ']' : ''), 'enabled' => $context['can_moderate_groups'], 'areas' => array('userwatch' => array('label' => $txt['mc_watched_users_title'], 'enabled' => in_array('w', $context['admin_features']) && !empty($modSettings['warning_enable']) && $context['can_moderate_boards'], 'controller' => 'ModerationCenter_Controller', 'function' => 'action_viewWatchedUsers', 'icon' => 'transparent.png', 'class' => 'admin_img_permissions', 'subsections' => array('member' => array($txt['mc_watched_users_member']), 'post' => array($txt['mc_watched_users_post']))), 'groups' => array('label' => $txt['mc_group_requests'] . (!empty($mod_counts['groupreq']) ? ' [' . $mod_counts['groupreq'] . ']' : ''), 'file' => 'Groups.controller.php', 'controller' => 'Groups_Controller', 'function' => 'action_index', 'icon' => 'transparent.png', 'class' => 'admin_img_regcenter', 'custom_url' => $scripturl . '?action=moderate;area=groups;sa=requests'), 'members' => array('enabled' => allowedTo('moderate_forum'), 'label' => $txt['mc_member_requests'] . (!empty($mod_counts['memberreq']) ? ' [' . $mod_counts['memberreq'] . ']' : ''), 'file' => 'ManageMembers.controller.php', 'controller' => 'ManageMembers_Controller', 'function' => 'action_approve', 'icon' => 'transparent.png', 'class' => 'admin_img_members', 'custom_url' => $scripturl . '?action=admin;area=viewmembers;sa=browse;type=approve'), 'viewgroups' => array('label' => $txt['mc_view_groups'], 'file' => 'Groups.controller.php', 'controller' => 'Groups_Controller', 'function' => 'action_index', 'icon' => 'transparent.png', 'class' => 'admin_img_membergroups'))));
     // Make sure the administrator has a valid session...
     validateSession('moderate');
     // I don't know where we're going - I don't know where we've been...
     $menuOptions = array('action' => 'moderate', 'hook' => 'moderation', 'disable_url_session_check' => true, 'default_include_dir' => CONTROLLERDIR);
     $mod_include_data = createMenu($moderation_areas, $menuOptions);
     unset($moderation_areas);
     // We got something - didn't we? DIDN'T WE!
     if ($mod_include_data == false) {
         fatal_lang_error('no_access', false);
     }
     // Retain the ID information in case required by a subaction.
     $context['moderation_menu_id'] = $context['max_menu_id'];
     $context['moderation_menu_name'] = 'menu_data_' . $context['moderation_menu_id'];
     $context[$context['moderation_menu_name']]['tab_data'] = array('title' => $txt['moderation_center'], 'help' => '', 'description' => sprintf($txt['mc_description'], $context['user']['name'], $scripturl . '?action=moderate;area=settings'));
     // What a pleasant shortcut - even tho we're not *really* on the admin screen who cares...
     $context['admin_area'] = $mod_include_data['current_area'];
     // Build the link tree.
     $context['linktree'][] = array('url' => $scripturl . '?action=moderate', 'name' => $txt['moderation_center']);
     if (isset($mod_include_data['current_area']) && $mod_include_data['current_area'] != 'index') {
         $context['linktree'][] = array('url' => $scripturl . '?action=moderate;area=' . $mod_include_data['current_area'], 'name' => $mod_include_data['label']);
     }
     if (!empty($mod_include_data['current_subsection']) && $mod_include_data['subsections'][$mod_include_data['current_subsection']][0] != $mod_include_data['label']) {
         $context['linktree'][] = array('url' => $scripturl . '?action=moderate;area=' . $mod_include_data['current_area'] . ';sa=' . $mod_include_data['current_subsection'], 'name' => $mod_include_data['subsections'][$mod_include_data['current_subsection']][0]);
     }
     // Finally, store this, so that if we're called from the class, it can use it.
     $this->_mod_include_data = $mod_include_data;
 }
开发者ID:KeiroD,项目名称:Elkarte,代码行数:58,代码来源:ModerationCenter.controller.php

示例3: pre_dispatch

 /**
  * Set up the context for the announce topic function (action=announce).
  * This function is called before the flow is redirected to action_selectgroup() or action_send().
  *
  * checks the topic announcement permissions and loads the announcement template.
  * requires the announce_topic permission.
  * uses the Announce template and Post language file.
  */
 public function pre_dispatch()
 {
     global $context, $txt, $topic;
     isAllowedTo('announce_topic');
     validateSession();
     if (empty($topic)) {
         fatal_lang_error('topic_gone', false);
     }
     loadLanguage('Post');
     loadTemplate('Announce');
     $context['page_title'] = $txt['announce_topic'];
 }
开发者ID:KeiroD,项目名称:Elkarte,代码行数:20,代码来源:Announce.controller.php

示例4: isValidSession

 /**
  * @param $session_db		array('user_id' => id, 'current' => 'hash_of_current_time_on_db', 'expire' => 'hash_of_expire_at_on_db')
  * @param $current_time 		String of current DateTime
  * @return True 				if session between has_current_time and $hash_expire_at
  */
 public function isValidSession($session_db, $current_time)
 {
     if (session_status() !== PHP_SESSION_ACTIVE) {
         session_start();
     }
     if (validateSession($user_id, $current_time, $expire_at, $hash_expire_at)) {
         return true;
     } else {
         session_destroy();
         return false;
     }
 }
开发者ID:Hismahil,项目名称:PHPAuth,代码行数:17,代码来源:UserSessionHelper.php

示例5: EnableCoreFeatures

function EnableCoreFeatures()
{
    global $context, $smcFunc, $sourcedir, $modSettings, $txt;
    $context['xml_data'] = array();
    // Just in case, maybe we don't need it
    loadLanguage('Errors');
    // We need (at least) this to ensure that mod files are included
    if (!empty($modSettings['integrate_admin_include'])) {
        $admin_includes = explode(',', $modSettings['integrate_admin_include']);
        foreach ($admin_includes as $include) {
            $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
            if (file_exists($include)) {
                require_once $include;
            }
        }
    }
    $errors = array();
    $returns = array();
    $tokens = array();
    if (allowedTo('admin_forum')) {
        $validation = validateSession();
        if (empty($validation)) {
            require_once $sourcedir . '/ManageSettings.php';
            $result = ModifyCoreFeatures();
            if (empty($result)) {
                $id = isset($_POST['feature_id']) ? $_POST['feature_id'] : '';
                if (!empty($id) && isset($context['features'][$id])) {
                    $feature = $context['features'][$id];
                    $returns[] = array('value' => !empty($_POST['feature_' . $id]) && $feature['url'] ? '<a href="' . $feature['url'] . '">' . $feature['title'] . '</a>' : $feature['title']);
                    createToken('admin-core', 'post');
                    $tokens = array(array('value' => $context['admin-core_token'], 'attributes' => array('type' => 'token_var')), array('value' => $context['admin-core_token_var'], 'attributes' => array('type' => 'token')));
                } else {
                    $errors[] = array('value' => $txt['feature_no_exists']);
                }
            } else {
                $errors[] = array('value' => $txt[$result]);
            }
        } else {
            $errors[] = array('value' => $txt[$validation]);
        }
    } else {
        $errors[] = array('value' => $txt['cannot_admin_forum']);
    }
    $context['sub_template'] = 'generic_xml';
    $context['xml_data'] = array('corefeatures' => array('identifier' => 'corefeature', 'children' => $returns), 'tokens' => array('identifier' => 'token', 'children' => $tokens), 'errors' => array('identifier' => 'error', 'children' => $errors));
}
开发者ID:Glyph13,项目名称:SMF2.1,代码行数:46,代码来源:Xml.php

示例6: get

/**
 * Function to handle HTTP-GET-requests.
 * @param Array, $requestData are the requested data
 */
function get(array $requestData)
{
    $logger = Logger::getLogger(basename(__FILE__));
    if (validateSession()) {
        $logger->info("Session is valid.");
        header(HTTP_VERSION . ' ' . HTTP_200);
        return;
    } else {
        $headers = getallheaders();
        if (isset($headers['sid'])) {
            session_write_close();
            session_id($headers['sid']);
            session_start();
            if (validateSession()) {
                header(HTTP_VERSION . ' ' . HTTP_200);
                return;
            }
        }
        $logger->info("Session is invalid.");
        header(HTTP_VERSION . ' ' . HTTP_401);
    }
}
开发者ID:hofrichter,项目名称:pdadmin,代码行数:26,代码来源:init.incl.php

示例7: session_start

<?php

session_start();
require "../mysql_config.php";
require "getLists.php";
mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die('Could not connect to MySQL server.');
mysql_select_db(DB_DATABASE);
mysql_query("SET NAMES 'utf8'");
validateSession("../admin/autos.php");
if ($_GET["confirm"] == 1) {
    $abfrage = "SELECT personenid, adminid FROM Person, Admin WHERE email LIKE '" . $_SESSION["username"] . "' AND personenid=adminid;";
    $ergebnis = mysql_query($abfrage);
    $row = mysql_fetch_array($ergebnis);
    if (mysql_num_rows($ergebnis) == 0) {
        header('Location: ../admin/autos.php');
    }
    $id = $_GET["id"];
    $abfrage = "DELETE FROM Auto WHERE id='{$id}'";
    // echo $abfrage;
    mysql_query($abfrage);
    header("Location: ../admin/autos.php");
}
?>

<script type="text/javascript">
	var txt;
	var r = confirm("Das Auto wird jetzt gel\u00f6scht!");
	if (r == true) {
		window.location = window.location.href+"&confirm=1";
	} else {
		window.location = "../admin/autos.php";
开发者ID:class142,项目名称:proj,代码行数:31,代码来源:autoLoeschen.php

示例8: GetPicklistValues

function GetPicklistValues($username, $sessionid, $tablename)
{
    global $current_user, $log, $adb;
    if (!validateSession($username, $sessionid)) {
        return null;
    }
    require_once "modules/Users/Users.php";
    $seed_user = new Users();
    $user_id = $seed_user->retrieve_user_id($username);
    $current_user = $seed_user;
    $current_user->retrieve_entity_info($user_id, 'Users');
    require_once "include/utils/UserInfoUtil.php";
    $roleid = fetchUserRole($user_id);
    checkFileAccessForInclusion('user_privileges/user_privileges_' . $current_user->id . '.php');
    require 'user_privileges/user_privileges_' . $current_user->id . '.php';
    if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) {
        $query = "select " . $adb->sql_escape_string($tablename) . " from vtiger_" . $adb->sql_escape_string($tablename);
        $result1 = $adb->pquery($query, array());
        for ($i = 0; $i < $adb->num_rows($result1); $i++) {
            $output[$i] = decode_html($adb->query_result($result1, $i, $tablename));
        }
    } else {
        if (isPermitted("HelpDesk", "EditView") == "yes" && CheckFieldPermission($tablename, 'HelpDesk') == 'true') {
            $query = "select " . $adb->sql_escape_string($tablename) . " from vtiger_" . $adb->sql_escape_string($tablename) . " inner join vtiger_role2picklist on vtiger_role2picklist.picklistvalueid = vtiger_" . $adb->sql_escape_string($tablename) . ".picklist_valueid where roleid=? and picklistid in (select picklistid from vtiger_" . $adb->sql_escape_string($tablename) . " ) order by sortid";
            $result1 = $adb->pquery($query, array($roleid));
            for ($i = 0; $i < $adb->num_rows($result1); $i++) {
                $output[$i] = decode_html($adb->query_result($result1, $i, $tablename));
            }
        } else {
            $output[] = 'Not Accessible';
        }
    }
    return $output;
}
开发者ID:cannking,项目名称:vtigercrm-debug,代码行数:34,代码来源:firefoxtoolbar.php

示例9: get_service_list_values

function get_service_list_values($id, $modulename, $sessionid, $only_mine = 'true')
{
    require_once 'modules/Services/Services.php';
    require_once 'include/utils/UserInfoUtil.php';
    $adb = PearDatabase::getInstance();
    $log = vglobal('log');
    $log->debug("Entering customer portal Function get_service_list_values");
    $check = checkModuleActive($modulename);
    if ($check == false) {
        return array("#MODULE INACTIVE#");
    }
    $user = new Users();
    $userid = getPortalUserid();
    $current_user = $user->retrieveCurrentUserInfoFromFile($userid);
    //To avoid SQL injection we are type casting as well as bound the id variable
    $id = (int) vtlib_purify($id);
    $entity_ids_list = array();
    $show_all = show_all($modulename);
    if (!validateSession($id, $sessionid)) {
        return null;
    }
    if ($only_mine == 'true' || $show_all == 'false') {
        array_push($entity_ids_list, $id);
    } else {
        $contactquery = "SELECT contactid, parentid FROM vtiger_contactdetails " . " INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_contactdetails.contactid" . " AND vtiger_crmentity.deleted = 0 " . " WHERE (parentid = (SELECT parentid FROM vtiger_contactdetails WHERE contactid = ?)  AND parentid != 0) OR contactid = ?";
        $contactres = $adb->pquery($contactquery, array($id, $id));
        $no_of_cont = $adb->num_rows($contactres);
        for ($i = 0; $i < $no_of_cont; $i++) {
            $cont_id = $adb->query_result($contactres, $i, 'contactid');
            $acc_id = $adb->query_result($contactres, $i, 'parentid');
            if (!in_array($cont_id, $entity_ids_list)) {
                $entity_ids_list[] = $cont_id;
            }
            if (!in_array($acc_id, $entity_ids_list) && $acc_id != '0') {
                $entity_ids_list[] = $acc_id;
            }
        }
    }
    $focus = new Services();
    $focus->filterInactiveFields('Services');
    foreach ($focus->list_fields as $fieldlabel => $values) {
        foreach ($values as $table => $fieldname) {
            $fields_list[$fieldlabel] = $fieldname;
        }
    }
    $fields_list['Related To'] = 'entityid';
    $query = array();
    $params = array();
    $query[] = "select vtiger_service.*," . "case when vtiger_crmentityrel.crmid != vtiger_service.serviceid then vtiger_crmentityrel.crmid else vtiger_crmentityrel.relcrmid end as entityid, " . "'' as setype from vtiger_service " . "inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_service.serviceid " . "left join vtiger_crmentityrel on (vtiger_crmentityrel.relcrmid=vtiger_service.serviceid or vtiger_crmentityrel.crmid=vtiger_service.serviceid) " . "where vtiger_crmentity.deleted = 0 and " . "( vtiger_crmentityrel.crmid in (" . generateQuestionMarks($entity_ids_list) . ") OR " . "(vtiger_crmentityrel.relcrmid in (" . generateQuestionMarks($entity_ids_list) . ") AND vtiger_crmentityrel.module = 'Services')" . ")";
    $params[] = array($entity_ids_list, $entity_ids_list);
    $checkQuotes = checkModuleActive('Quotes');
    if ($checkQuotes == true) {
        $query[] = "select distinct vtiger_service.*,\n\t\t\tvtiger_quotes.accountid as entityid,\n\t\t\t'Accounts' as setype\n\t\t\tfrom vtiger_quotes INNER join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_quotes.quoteid\n\t\t\tleft join vtiger_inventoryproductrel on vtiger_inventoryproductrel.id=vtiger_quotes.quoteid\n\t\t\tleft join vtiger_service on vtiger_service.serviceid = vtiger_inventoryproductrel.productid\n\t\t\twhere vtiger_inventoryproductrel.productid = vtiger_service.serviceid AND vtiger_crmentity.deleted=0 and accountid in  (" . generateQuestionMarks($entity_ids_list) . ")";
        $params[] = array($entity_ids_list);
    }
    $checkInvoices = checkModuleActive('Invoice');
    if ($checkInvoices == true) {
        $query[] = "select distinct vtiger_service.*, vtiger_invoice.accountid as entityid, 'Accounts' as setype\n\t\t\tfrom vtiger_invoice\n\t\t\tINNER join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_invoice.invoiceid\n\t\t\tleft join vtiger_inventoryproductrel on vtiger_inventoryproductrel.id=vtiger_invoice.invoiceid\n\t\t\tleft join vtiger_service on vtiger_service.serviceid = vtiger_inventoryproductrel.productid\n\t\t\twhere vtiger_inventoryproductrel.productid = vtiger_service.serviceid AND vtiger_crmentity.deleted=0 and accountid in (" . generateQuestionMarks($entity_ids_list) . ")";
        $params[] = array($entity_ids_list, $entity_ids_list);
    }
    $ServicesfieldVisibilityPermissions = array();
    foreach ($fields_list as $fieldlabel => $fieldname) {
        $ServicesfieldVisibilityPermissions[$fieldname] = getFieldVisibilityPermission('Services', $current_user->id, $fieldname);
    }
    $fieldValuesToRound = array('unit_price', 'commissionrate');
    for ($k = 0; $k < count($query); $k++) {
        $res[$k] = $adb->pquery($query[$k], $params[$k]);
        $noofdata[$k] = $adb->num_rows($res[$k]);
        if ($noofdata[$k] == 0) {
            $output[$k][$modulename]['data'] = '';
        }
        for ($j = 0; $j < $noofdata[$k]; $j++) {
            $i = 0;
            foreach ($fields_list as $fieldlabel => $fieldname) {
                $fieldper = $ServicesfieldVisibilityPermissions[$fieldname];
                if ($fieldper == '1' && $fieldname != 'entityid') {
                    continue;
                }
                $output[$k][$modulename]['head'][0][$i]['fielddata'] = Vtiger_Language_Handler::getTranslatedString($fieldlabel, 'Services', vglobal('default_language'));
                $fieldvalue = $adb->query_result($res[$k], $j, $fieldname);
                $fieldid = $adb->query_result($res[$k], $j, 'serviceid');
                if (in_array($fieldname, $fieldValuesToRound)) {
                    $fieldvalue = round($fieldvalue, 2);
                }
                if ($fieldname == 'entityid') {
                    $crmid = $fieldvalue;
                    $module = $adb->query_result($res[$k], $j, 'setype');
                    if ($module == '') {
                        $module = $adb->query_result($adb->pquery("SELECT setype FROM vtiger_crmentity WHERE crmid = ?", array($crmid)), 0, 'setype');
                    }
                    if ($crmid != '' && $module != '') {
                        $fieldvalues = getEntityName($module, array($crmid));
                        if ($module == 'Contacts') {
                            $fieldvalue = '<a href="index.php?module=Contacts&action=index&id=' . $crmid . '">' . $fieldvalues[$crmid] . '</a>';
                        } elseif ($module == 'Accounts') {
                            $fieldvalue = '<a href="index.php?module=Accounts&action=index&id=' . $crmid . '">' . $fieldvalues[$crmid] . '</a>';
                        }
                    } else {
                        $fieldvalue = '';
                    }
//.........这里部分代码省略.........
开发者ID:JeRRimix,项目名称:YetiForceCRM,代码行数:101,代码来源:yetiportal.php

示例10: DeleteClndr

function DeleteClndr($username, $session, $crmid)
{
    if (!validateSession($username, $session)) {
        return null;
    }
    global $current_user;
    require_once 'modules/Users/Users.php';
    require_once 'modules/Calendar/Activity.php';
    $seed_user = new Users();
    $user_id = $seed_user->retrieve_user_id($username);
    $current_user = $seed_user;
    $current_user->retrieve_entity_info($user_id, "Users");
    $clndr = new Activity();
    $clndr->id = $crmid;
    $clndr->mark_deleted($clndr->id);
    return $clndr->id;
}
开发者ID:hardikk,项目名称:HNH,代码行数:17,代码来源:vtigerolservice.php

示例11: TPadminIndex

function TPadminIndex($tpsub = '', $module_admin = false)
{
    global $txt, $context, $scripturl, $smcFunc;
    if (loadLanguage('TPortalAdmin') == false) {
        loadLanguage('TPortalAdmin', 'english');
    }
    if ($module_admin) {
        // make sure tpadmin is still active
        $_GET['action'] = 'tpadmin';
    }
    $context['admin_tabs'] = array();
    $context['admin_header']['tp_news'] = $txt['tp-adminnews1'];
    $context['admin_header']['tp_settings'] = $txt['tp-adminheader1'];
    $context['admin_header']['tp_articles'] = $txt['tp-articles'];
    $context['admin_header']['tp_blocks'] = $txt['tp-adminpanels'];
    $context['admin_header']['tp_modules'] = $txt['tp-modules'];
    $context['admin_header']['tp_menubox'] = $txt['tp-menumanager'];
    $context['admin_header']['custom_modules'] = $txt['custom_modules'];
    if (allowedTo('tp_settings')) {
        $context['admin_tabs']['tp_news'] = array('news' => array('title' => $txt['tp-adminnews1'], 'description' => $txt['tp-adminnews2'], 'href' => $scripturl . '?action=tpadmin;sa=news', 'is_selected' => $tpsub == 'news'));
    }
    if (allowedTo('tp_settings')) {
        $context['admin_tabs']['tp_settings'] = array('settings' => array('title' => $txt['tp-settings'], 'description' => $txt['tp-settingdesc1'], 'href' => $scripturl . '?action=tpadmin;sa=settings', 'is_selected' => $tpsub == 'settings'), 'frontpage' => array('title' => $txt['tp-frontpage'], 'description' => $txt['tp-frontpagedesc1'], 'href' => $scripturl . '?action=tpadmin;sa=frontpage', 'is_selected' => $tpsub == 'frontpage'));
    }
    if (allowedTo('tp_articles')) {
        $context['admin_tabs']['tp_articles'] = array('articles' => array('title' => $txt['tp-articles'], 'description' => $txt['tp-articledesc1'], 'href' => $scripturl . '?action=tpadmin;sa=articles', 'is_selected' => substr($tpsub, 0, 11) == 'editarticle' || in_array($tpsub, array('articles', 'addarticle', 'addarticle_php', 'addarticle_bbc', 'addarticle_import', 'strays'))), 'categories' => array('title' => $txt['tp-tabs5'], 'description' => $txt['tp-articledesc2'], 'href' => $scripturl . '?action=tpadmin;sa=categories', 'is_selected' => in_array($tpsub, array('categories', 'addcategory', 'clist'))), 'artsettings' => array('title' => $txt['tp-settings'], 'description' => $txt['tp-articledesc3'], 'href' => $scripturl . '?action=tpadmin;sa=artsettings', 'is_selected' => $tpsub == 'artsettings'), 'submission' => array('title' => (isset($context['TPortal']['submissions']) && $context['TPortal']['submissions']) > 0 ? $txt['tp-tabs4'] . ' [' . $context['TPortal']['submissions'] . ']' : $txt['tp-tabs4'], 'description' => $txt['tp-articledesc4'], 'href' => $scripturl . '?action=tpadmin;sa=submission', 'is_selected' => $tpsub == 'submission'), 'icons' => array('title' => $txt['tp-adminicons'], 'description' => $txt['tp-articledesc5'], 'href' => $scripturl . '?action=tpadmin;sa=articons', 'is_selected' => $tpsub == 'articons'));
    }
    if (allowedTo('tp_blocks')) {
        $context['admin_tabs']['tp_blocks'] = array('panelsettings' => array('title' => $txt['tp-allpanels'], 'description' => $txt['tp-paneldesc1'], 'href' => $scripturl . '?action=tpadmin;sa=panels', 'is_selected' => $tpsub == 'panels'), 'blocks' => array('title' => $txt['tp-allblocks'], 'description' => $txt['tp-blocksdesc1'], 'href' => $scripturl . '?action=tpadmin;sa=blocks', 'is_selected' => $tpsub == 'blocks' && !isset($_GET['latest']) && !isset($_GET['overview'])), 'blockoverview' => array('title' => $txt['tp-blockoverview'], 'description' => '', 'href' => $scripturl . '?action=tpadmin;sa=blocks;overview', 'is_selected' => $tpsub == 'blocks' && isset($_GET['overview'])));
    }
    if (allowedTo('tp_settings')) {
        $context['admin_tabs']['tp_modules'] = array('modules' => array('title' => $txt['tp-modules'], 'description' => $txt['tp-moduledesc1'], 'href' => $scripturl . '?action=tpadmin;sa=modules', 'is_selected' => $tpsub == 'modules' && !isset($_GET['import']) && !isset($_GET['tags'])));
    }
    // collect modules and their permissions
    $result = $smcFunc['db_query']('', '
		SELECT * FROM {db_prefix}tp_modules 
		WHERE 1', array());
    if ($smcFunc['db_num_rows']($result) > 0) {
        while ($row = $smcFunc['db_fetch_assoc']($result)) {
            $context['TPortal']['admmodules'][] = $row;
        }
        $smcFunc['db_free_result']($result);
    }
    if (allowedTo('tp_blocks')) {
        $context['admin_tabs']['tp_menubox'] = array('menubox' => array('title' => $txt['tp-menumanager'], 'description' => '', 'href' => $scripturl . '?action=tpadmin;sa=menubox', 'is_selected' => in_array($tpsub, array('menubox', 'linkmanager'))), 'addmenu' => array('title' => isset($_GET['mid']) ? $txt['tp-addmenuitem'] : $txt['tp-addmenu'], 'description' => '', 'href' => isset($_GET['mid']) && is_numeric($_GET['mid']) ? $scripturl . '?action=tpadmin;sa=addmenu;mid=' . $_GET['mid'] : $scripturl . '?action=tpadmin;sa=addmenu;fullmenu', 'is_selected' => in_array($tpsub, array('addmenu'))));
    }
    TPsetupAdminAreas();
    validateSession();
}
开发者ID:DiegoCortes,项目名称:TinyPortal,代码行数:49,代码来源:TPSubs.php

示例12: validateUserSession

/**
 * Check that the session is active and valid for the user passed.
 * @param string $userid
 * @return User or Error
 */
function validateUserSession($userid)
{
    global $USER, $LNG;
    $validateSession = validateSession($userid);
    if (strcmp($validateSession, $LNG->CORE_SESSION_OK) != 0) {
        $ERROR = new error();
        $ERROR->createValidateSessionError($validateSession);
        return $ERROR;
    }
    $user = $USER;
    return $user;
}
开发者ID:uniteddiversity,项目名称:LiteMap,代码行数:17,代码来源:apilib.php

示例13: ModifyProfile2

function ModifyProfile2()
{
    global $txt, $modSettings;
    global $cookiename, $context;
    global $sourcedir, $scripturl, $db_prefix;
    global $ID_MEMBER, $user_info;
    global $context, $newpassemail, $user_profile, $validationCode;
    loadLanguage('Profile');
    /* Set allowed sub-actions.
    
    	 The format of $sa_allowed is as follows:
    
    	$sa_allowed = array(
    		'sub-action' => array(permission_array_for_editing_OWN_profile, permission_array_for_editing_ANY_profile, session_validation_method[, require_password]),
    		...
    	);
    
    	*/
    $sa_allowed = array('account' => array(array('manage_membergroups', 'profile_identity_any', 'profile_identity_own'), array('manage_membergroups', 'profile_identity_any'), 'post', true), 'forumProfile' => array(array('profile_extra_any', 'profile_extra_own'), array('profile_extra_any'), 'post'), 'theme' => array(array('profile_extra_any', 'profile_extra_own'), array('profile_extra_any'), 'post'), 'notification' => array(array('profile_extra_any', 'profile_extra_own'), array('profile_extra_any'), 'post'), 'pmprefs' => array(array('profile_extra_any', 'profile_extra_own'), array('profile_extra_any'), 'post'), 'deleteAccount' => array(array('profile_remove_any', 'profile_remove_own'), array('profile_remove_any'), 'post', true), 'activateAccount' => array(array(), array('moderate_forum'), 'get'));
    // Is the current sub-action allowed?
    if (empty($_REQUEST['sa']) || !isset($sa_allowed[$_REQUEST['sa']])) {
        fatal_lang_error(453, false);
    }
    checkSession($sa_allowed[$_REQUEST['sa']][2]);
    // Start with no updates and no errors.
    $profile_vars = array();
    $post_errors = array();
    // Normally, don't send an email.
    $newpassemail = false;
    // Clean up the POST variables.
    $_POST = htmltrim__recursive($_POST);
    $_POST = stripslashes__recursive($_POST);
    $_POST = htmlspecialchars__recursive($_POST);
    $_POST = addslashes__recursive($_POST);
    // Search for the member being edited and put the information in $user_profile.
    $memberResult = loadMemberData((int) $_REQUEST['userID'], false, 'profile');
    if (!is_array($memberResult)) {
        fatal_lang_error(453, false);
    }
    list($memID) = $memberResult;
    // Are you modifying your own, or someone else's?
    if ($ID_MEMBER == $memID) {
        $context['user']['is_owner'] = true;
    } else {
        $context['user']['is_owner'] = false;
        validateSession();
    }
    // Check profile editing permissions.
    isAllowedTo($sa_allowed[$_REQUEST['sa']][$context['user']['is_owner'] ? 0 : 1]);
    // If this is yours, check the password.
    if ($context['user']['is_owner'] && !empty($sa_allowed[$_REQUEST['sa']][3])) {
        // You didn't even enter a password!
        if (trim($_POST['oldpasswrd']) == '') {
            $post_errors[] = 'no_password';
        }
        // Since the password got modified due to all the $_POST cleaning, lets undo it so we can get the correct password
        $_POST['oldpasswrd'] = addslashes(un_htmlspecialchars(stripslashes($_POST['oldpasswrd'])));
        // Does the integration want to check passwords?
        $good_password = false;
        if (isset($modSettings['integrate_verify_password']) && function_exists($modSettings['integrate_verify_password'])) {
            if (call_user_func($modSettings['integrate_verify_password'], $user_profile[$memID]['memberName'], $_POST['oldpasswrd'], false) === true) {
                $good_password = true;
            }
        }
        // Bad password!!!
        if (!$good_password && $user_info['passwd'] != sha1(strtolower($user_profile[$memID]['memberName']) . $_POST['oldpasswrd'])) {
            $post_errors[] = 'bad_password';
        }
    }
    // No need for the sub action array.
    unset($sa_allowed);
    // If the user is an admin - see if they are resetting someones username.
    if ($user_info['is_admin'] && isset($_POST['memberName'])) {
        // We'll need this...
        require_once $sourcedir . '/Subs-Auth.php';
        // Do the reset... this will send them an email too.
        resetPassword($memID, $_POST['memberName']);
    }
    // Change the IP address in the database.
    if ($context['user']['is_owner']) {
        $profile_vars['memberIP'] = "'{$user_info['ip']}'";
    }
    // Now call the sub-action function...
    if (isset($_POST['sa']) && $_POST['sa'] == 'deleteAccount') {
        deleteAccount2($profile_vars, $post_errors, $memID);
        if (empty($post_errors)) {
            redirectexit();
        }
    } else {
        saveProfileChanges($profile_vars, $post_errors, $memID);
    }
    // There was a problem, let them try to re-enter.
    if (!empty($post_errors)) {
        // Load the language file so we can give a nice explanation of the errors.
        loadLanguage('Errors');
        $context['post_errors'] = $post_errors;
        $_REQUEST['sa'] = $_POST['sa'];
        $_REQUEST['u'] = $memID;
        return ModifyProfile($post_errors);
    }
//.........这里部分代码省略.........
开发者ID:alencarmo,项目名称:OCF,代码行数:101,代码来源:Profile.php

示例14: adminIndex

function adminIndex($area)
{
    global $txt, $context, $scripturl, $sc, $modSettings, $user_info, $settings;
    // Load the language and templates....
    loadLanguage('Admin');
    loadTemplate('Admin');
    // Admin area 'Main'.
    $context['admin_areas']['forum'] = array('title' => $txt[427], 'areas' => array('index' => '<a href="' . $scripturl . '?action=admin">' . $txt[208] . '</a>', 'credits' => '<a href="' . $scripturl . '?action=admin;credits">' . $txt['support_credits_title'] . '</a>'));
    if (allowedTo(array('edit_news', 'send_mail', 'admin_forum'))) {
        $context['admin_areas']['forum']['areas']['news'] = '<a href="' . $scripturl . '?action=news">' . $txt['news_title'] . '</a>';
    }
    if (allowedTo('admin_forum')) {
        $context['admin_areas']['forum']['areas']['manage_packages'] = '<a href="' . $scripturl . '?action=packages">' . $txt['package1'] . '</a>';
    }
    // Admin area 'Configuration'.
    if (allowedTo('admin_forum')) {
        $context['admin_areas']['config'] = array('title' => $txt[428], 'areas' => array('edit_mods_settings' => '<a href="' . $scripturl . '?action=featuresettings">' . $txt['modSettings_title'] . '</a>', 'edit_settings' => '<a href="' . $scripturl . '?action=serversettings;sesc=' . $sc . '">' . $txt[222] . '</a>', 'edit_theme_settings' => '<a href="' . $scripturl . '?action=theme;sa=settings;th=' . $settings['theme_id'] . ';sesc=' . $sc . '">' . $txt['theme_current_settings'] . '</a>', 'manage_themes' => '<a href="' . $scripturl . '?action=theme;sa=admin;sesc=' . $sc . '">' . $txt['theme_admin'] . '</a>'));
    }
    // Admin area 'Forum'.
    if (allowedTo(array('manage_boards', 'admin_forum', 'manage_smileys', 'manage_attachments', 'moderate_forum'))) {
        $context['admin_areas']['layout'] = array('title' => $txt['layout_controls'], 'areas' => array());
        if (allowedTo('manage_boards')) {
            $context['admin_areas']['layout']['areas']['manage_boards'] = '<a href="' . $scripturl . '?action=manageboards">' . $txt[4] . '</a>';
        }
        if (allowedTo(array('admin_forum', 'moderate_forum'))) {
            $context['admin_areas']['layout']['areas']['posts_and_topics'] = '<a href="' . $scripturl . '?action=postsettings">' . $txt['manageposts'] . '</a>';
        }
        if (allowedTo('admin_forum')) {
            $context['admin_areas']['layout']['areas']['manage_calendar'] = '<a href="' . $scripturl . '?action=managecalendar">' . $txt['manage_calendar'] . '</a>';
            $context['admin_areas']['layout']['areas']['manage_search'] = '<a href="' . $scripturl . '?action=managesearch">' . $txt['manage_search'] . '</a>';
        }
        if (allowedTo('manage_smileys')) {
            $context['admin_areas']['layout']['areas']['manage_smileys'] = '<a href="' . $scripturl . '?action=smileys">' . $txt['smileys_manage'] . '</a>';
        }
        if (allowedTo('manage_attachments')) {
            $context['admin_areas']['layout']['areas']['manage_attachments'] = '<a href="' . $scripturl . '?action=manageattachments">' . $txt['smf201'] . '</a>';
        }
    }
    // Admin area 'Members'.
    if (allowedTo(array('moderate_forum', 'manage_membergroups', 'manage_bans', 'manage_permissions', 'admin_forum'))) {
        $context['admin_areas']['members'] = array('title' => $txt[426], 'areas' => array());
        if (allowedTo('moderate_forum')) {
            $context['admin_areas']['members']['areas']['view_members'] = '<a href="' . $scripturl . '?action=viewmembers">' . $txt[5] . '</a>';
        }
        if (allowedTo('manage_membergroups')) {
            $context['admin_areas']['members']['areas']['edit_groups'] = '<a href="' . $scripturl . '?action=membergroups;">' . $txt[8] . '</a>';
        }
        if (allowedTo('manage_permissions')) {
            $context['admin_areas']['members']['areas']['edit_permissions'] = '<a href="' . $scripturl . '?action=permissions">' . $txt['edit_permissions'] . '</a>';
        }
        if (allowedTo(array('admin_forum', 'moderate_forum'))) {
            $context['admin_areas']['members']['areas']['registration_center'] = '<a href="' . $scripturl . '?action=regcenter">' . $txt['registration_center'] . '</a>';
        }
        if (allowedTo('manage_bans')) {
            $context['admin_areas']['members']['areas']['ban_members'] = '<a href="' . $scripturl . '?action=ban">' . $txt['ban_title'] . '</a>';
        }
    }
    // Admin area 'Maintenance Controls'.
    if (allowedTo('admin_forum')) {
        $context['admin_areas']['maintenance'] = array('title' => $txt[501], 'areas' => array('maintain_forum' => '<a href="' . $scripturl . '?action=maintain">' . $txt['maintain_title'] . '</a>', 'generate_reports' => '<a href="' . $scripturl . '?action=reports">' . $txt['generate_reports'] . '</a>', 'view_errors' => '<a href="' . $scripturl . '?action=viewErrorLog;desc">' . $txt['errlog1'] . '</a>'));
        if (!empty($modSettings['modlog_enabled'])) {
            $context['admin_areas']['maintenance']['areas']['view_moderation_log'] = '<a href="' . $scripturl . '?action=modlog">' . $txt['modlog_view'] . '</a>';
        }
    }
    // Make sure the administrator has a valid session...
    validateSession();
    // Figure out which one we're in now...
    foreach ($context['admin_areas'] as $id => $section) {
        if (isset($section[$area])) {
            $context['admin_section'] = $id;
        }
    }
    $context['admin_area'] = $area;
    // obExit will know what to do!
    $context['template_layers'][] = 'admin';
}
开发者ID:bbon,项目名称:mjncms,代码行数:76,代码来源:Subs.php

示例15: char_edit

function char_edit()
{
    global $context, $smcFunc, $txt, $sourcedir, $user_info, $modSettings;
    // If they don't have permission to be here, goodbye.
    if (!$context['character']['editable']) {
        redirectexit('action=profile;u=' . $context['id_member'] . ';area=characters;char=' . $context['character']['id_character']);
    }
    $context['character']['title_editable'] = !empty($modSettings['titlesEnable']) && allowedTo('admin_forum');
    $context['sub_template'] = 'edit_char';
    loadJavascriptFile('chars.js', array('default_theme' => true), 'chars');
    $context['character']['groups_editable'] = false;
    if (allowedTo('manage_membergroups') && !$context['character']['is_main']) {
        $context['character']['groups_editable'] = true;
        profileLoadCharGroups();
    }
    require_once $sourcedir . '/Subs-Post.php';
    require_once $sourcedir . '/Profile-Modify.php';
    profileLoadSignatureData();
    $context['form_errors'] = [];
    if (isset($_POST['edit_char'])) {
        validateSession();
        validateToken('edit-char' . $context['character']['id_character'], 'post');
        $changes = [];
        $new_name = !empty($_POST['char_name']) ? $smcFunc['htmlspecialchars'](trim($_POST['char_name']), ENT_QUOTES) : '';
        if ($new_name == '') {
            $context['form_errors'][] = $txt['char_error_character_must_have_name'];
        } elseif ($new_name != $context['character']['character_name']) {
            // Check if the name already exists.
            $result = $smcFunc['db_query']('', '
				SELECT COUNT(*)
				FROM {db_prefix}characters
				WHERE character_name LIKE {string:new_name}
					AND id_character != {int:char}', array('new_name' => $new_name, 'char' => $context['character']['id_character']));
            list($matching_names) = $smcFunc['db_fetch_row']($result);
            $smcFunc['db_free_result']($result);
            if ($matching_names) {
                $context['form_errors'][] = $txt['char_error_duplicate_character_name'];
            } else {
                $changes['character_name'] = $new_name;
            }
        }
        if ($context['character']['title_editable']) {
            $new_title = isset($_POST['char_title']) ? $_POST['char_title'] : '';
            preparsecode($new_title);
            if ($new_title != $context['character']['char_title']) {
                $changes['char_title'] = $new_title;
            }
        }
        if ($context['character']['groups_editable']) {
            // Editing groups is a little bit complicated.
            $new_id_group = isset($_POST['id_group'], $context['member_groups'][$_POST['id_group']]) && $context['member_groups'][$_POST['id_group']]['can_be_primary'] ? (int) $_POST['id_group'] : $context['character']['main_char_group'];
            $new_char_groups = [];
            if (isset($_POST['additional_groups']) && is_array($_POST['additional_groups'])) {
                foreach ($_POST['additional_groups'] as $id_group) {
                    if (!isset($context['member_groups'][$id_group])) {
                        continue;
                    }
                    if (!$context['member_groups'][$id_group]['can_be_additional']) {
                        continue;
                    }
                    if ($id_group == $new_id_group) {
                        continue;
                    }
                    $new_char_groups[] = (int) $id_group;
                }
            }
            $new_char_groups = implode(',', $new_char_groups);
            if ($new_id_group != $context['character']['main_char_group']) {
                $changes['main_char_group'] = $new_id_group;
            }
            if ($new_char_groups != $context['character']['char_groups']) {
                $changes['char_groups'] = $new_char_groups;
            }
        }
        $new_age = !empty($_POST['age']) ? $smcFunc['htmlspecialchars'](trim($_POST['age']), ENT_QUOTES) : '';
        if ($new_age != $context['character']['age']) {
            $changes['age'] = $new_age;
        }
        $new_avatar = !empty($_POST['avatar']) ? trim($_POST['avatar']) : '';
        $validatable_avatar = strpos($new_avatar, 'http') !== 0 ? 'http://' . $new_avatar : $new_avatar;
        // filter_var doesn't like // URLs
        if ($new_avatar != $context['character']['avatar']) {
            if (filter_var($validatable_avatar, FILTER_VALIDATE_URL)) {
                $size = get_avatar_url_size($new_avatar);
                if (!$size) {
                    $context['form_errors'][] = $txt['char_error_avatar_link_invalid'];
                } elseif (!empty($modSettings['avatar_max_width_external'])) {
                    if ($size[0] > $modSettings['avatar_max_width_external'] || $size[1] > $modSettings['avatar_max_height_external']) {
                        $txt['char_error_avatar_oversize'] = sprintf($txt['char_error_avatar_oversize'], $size[0], $size[1], $modSettings['avatar_max_width_external'], $modSettings['avatar_max_height_external']);
                        $context['form_errors'][] = $txt['char_error_avatar_oversize'];
                    } else {
                        $changes['avatar'] = $new_avatar;
                    }
                } else {
                    $changes['avatar'] = $new_avatar;
                }
            } elseif ($new_avatar != '') {
                $context['form_errors'][] = $txt['char_error_avatar_must_be_real_url'];
            }
        }
//.........这里部分代码省略.........
开发者ID:Arantor,项目名称:smf-characters,代码行数:101,代码来源:Profile-Chars.php


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