本文整理汇总了PHP中validateToken函数的典型用法代码示例。如果您正苦于以下问题:PHP validateToken函数的具体用法?PHP validateToken怎么用?PHP validateToken使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了validateToken函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
parent::run();
$this->getInputJson();
if (!($token = validateToken($this->input['token']))) {
throw new \Exception("Invalid token.");
}
//TODO: delete global somehow
global $user;
$user = new \User($token['uid']);
if (isset($this->input['remove'])) {
if (!$user->removeFavorites($this->input['remove'])) {
throw new \Exception("Could not remove favorites.");
}
}
if (isset($this->input['add'])) {
if (!$user->addFavorites($this->input['add'])) {
throw new \Exception("Could not add favorites.");
}
}
$favorites = array();
$user->getFavorites();
foreach ($user->favorites as $favorite) {
$favorites[] = $favorite['tid'];
}
$this->return['favorites'] = $favorites;
}
示例2: ModifyHolidays
/**
* The function that handles adding, and deleting holiday data
*/
function ModifyHolidays()
{
global $sourcedir, $scripturl, $txt, $context;
// Submitting something...
if (isset($_REQUEST['delete']) && !empty($_REQUEST['holiday'])) {
checkSession();
validateToken('admin-mc');
foreach ($_REQUEST['holiday'] as $id => $value) {
$_REQUEST['holiday'][$id] = (int) $id;
}
// Now the IDs are "safe" do the delete...
require_once $sourcedir . '/Subs-Calendar.php';
removeHolidays($_REQUEST['holiday']);
}
createToken('admin-mc');
$listOptions = array('id' => 'holiday_list', 'title' => $txt['current_holidays'], 'items_per_page' => 20, 'base_href' => $scripturl . '?action=admin;area=managecalendar;sa=holidays', 'default_sort_col' => 'name', 'get_items' => array('file' => $sourcedir . '/Subs-Calendar.php', 'function' => 'list_getHolidays'), 'get_count' => array('file' => $sourcedir . '/Subs-Calendar.php', 'function' => 'list_getNumHolidays'), 'no_items_label' => $txt['holidays_no_entries'], 'columns' => array('name' => array('header' => array('value' => $txt['holidays_title']), 'data' => array('sprintf' => array('format' => '<a href="' . $scripturl . '?action=admin;area=managecalendar;sa=editholiday;holiday=%1$d">%2$s</a>', 'params' => array('id_holiday' => false, 'title' => false))), 'sort' => array('default' => 'title', 'reverse' => 'title DESC')), 'date' => array('header' => array('value' => $txt['date']), 'data' => array('function' => create_function('$rowData', '
global $txt;
// Recurring every year or just a single year?
$year = $rowData[\'year\'] == \'0004\' ? sprintf(\'(%1$s)\', $txt[\'every_year\']) : $rowData[\'year\'];
// Construct the date.
return sprintf(\'%1$d %2$s %3$s\', $rowData[\'day\'], $txt[\'months\'][(int) $rowData[\'month\']], $year);
')), 'sort' => array('default' => 'event_date', 'reverse' => 'event_date DESC')), 'check' => array('header' => array('value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />'), 'data' => array('sprintf' => array('format' => '<input type="checkbox" name="holiday[%1$d]" class="input_check" />', 'params' => array('id_holiday' => false)), 'style' => 'text-align: center'))), 'form' => array('href' => $scripturl . '?action=admin;area=managecalendar;sa=holidays', 'token' => 'admin-mc'), 'additional_rows' => array(array('position' => 'below_table_data', 'value' => '
<input type="submit" name="delete" value="' . $txt['quickmod_delete_selected'] . '" class="button_submit" />
<a class="button_link" href="' . $scripturl . '?action=admin;area=managecalendar;sa=editholiday" style="margin: 0 1em">' . $txt['holidays_add'] . '</a>', 'style' => 'text-align: right;')));
require_once $sourcedir . '/Subs-List.php';
createList($listOptions);
//loadTemplate('ManageCalendar');
$context['page_title'] = $txt['manage_holidays'];
// Since the list is the only thing to show, use the default list template.
$context['default_list'] = 'holiday_list';
$context['sub_template'] = 'show_list';
}
示例3: action_holidays
/**
* The function that handles adding, and deleting holiday data
*/
public function action_holidays()
{
global $scripturl, $txt, $context;
// Submitting something...
if (isset($_REQUEST['delete']) && !empty($_REQUEST['holiday'])) {
checkSession();
validateToken('admin-mc');
$to_remove = array_map('intval', array_keys($_REQUEST['holiday']));
// Now the IDs are "safe" do the delete...
require_once SUBSDIR . '/Calendar.subs.php';
removeHolidays($to_remove);
}
createToken('admin-mc');
$listOptions = array('id' => 'holiday_list', 'title' => $txt['current_holidays'], 'items_per_page' => 20, 'base_href' => $scripturl . '?action=admin;area=managecalendar;sa=holidays', 'default_sort_col' => 'name', 'get_items' => array('file' => SUBSDIR . '/Calendar.subs.php', 'function' => 'list_getHolidays'), 'get_count' => array('file' => SUBSDIR . '/Calendar.subs.php', 'function' => 'list_getNumHolidays'), 'no_items_label' => $txt['holidays_no_entries'], 'columns' => array('name' => array('header' => array('value' => $txt['holidays_title']), 'data' => array('sprintf' => array('format' => '<a href="' . $scripturl . '?action=admin;area=managecalendar;sa=editholiday;holiday=%1$d">%2$s</a>', 'params' => array('id_holiday' => false, 'title' => false))), 'sort' => array('default' => 'title', 'reverse' => 'title DESC')), 'date' => array('header' => array('value' => $txt['date']), 'data' => array('function' => create_function('$rowData', '
global $txt;
// Recurring every year or just a single year?
$year = $rowData[\'year\'] == \'0004\' ? sprintf(\'(%1$s)\', $txt[\'every_year\']) : $rowData[\'year\'];
// Construct the date.
return sprintf(\'%1$d %2$s %3$s\', $rowData[\'day\'], $txt[\'months\'][(int) $rowData[\'month\']], $year);
')), 'sort' => array('default' => 'event_date', 'reverse' => 'event_date DESC')), 'check' => array('header' => array('value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />', 'class' => 'centertext'), 'data' => array('sprintf' => array('format' => '<input type="checkbox" name="holiday[%1$d]" class="input_check" />', 'params' => array('id_holiday' => false)), 'class' => 'centertext'))), 'form' => array('href' => $scripturl . '?action=admin;area=managecalendar;sa=holidays', 'token' => 'admin-mc'), 'additional_rows' => array(array('position' => 'below_table_data', 'class' => 'submitbutton', 'value' => '<input type="submit" name="delete" value="' . $txt['quickmod_delete_selected'] . '" class="right_submit" onclick="return confirm(\'' . $txt['holidays_delete_confirm'] . '\');" />
<a class="linkbutton" href="' . $scripturl . '?action=admin;area=managecalendar;sa=editholiday">' . $txt['holidays_add'] . '</a>')));
require_once SUBSDIR . '/GenericList.class.php';
createList($listOptions);
$context['page_title'] = $txt['manage_holidays'];
}
示例4: SetCensor
/**
* Shows an interface to set and test censored words.
* It uses the censor_vulgar, censor_proper, censorWholeWord, and censorIgnoreCase
* settings.
* Requires the admin_forum permission.
* Accessed from ?action=admin;area=postsettings;sa=censor.
*
* @uses the Admin template and the edit_censored sub template.
*/
function SetCensor()
{
global $txt, $modSettings, $context, $smcFunc, $sourcedir;
if (!empty($_POST['save_censor'])) {
// Make sure censoring is something they can do.
checkSession();
validateToken('admin-censor');
$censored_vulgar = array();
$censored_proper = array();
// Rip it apart, then split it into two arrays.
if (isset($_POST['censortext'])) {
$_POST['censortext'] = explode("\n", strtr($_POST['censortext'], array("\r" => '')));
foreach ($_POST['censortext'] as $c) {
list($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, '');
}
} elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper'])) {
if (is_array($_POST['censor_vulgar'])) {
foreach ($_POST['censor_vulgar'] as $i => $value) {
if (trim(strtr($value, '*', ' ')) == '') {
unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]);
}
}
$censored_vulgar = $_POST['censor_vulgar'];
$censored_proper = $_POST['censor_proper'];
} else {
$censored_vulgar = explode("\n", strtr($_POST['censor_vulgar'], array("\r" => '')));
$censored_proper = explode("\n", strtr($_POST['censor_proper'], array("\r" => '')));
}
}
// Set the new arrays and settings in the database.
$updates = array('censor_vulgar' => implode("\n", $censored_vulgar), 'censor_proper' => implode("\n", $censored_proper), 'censorWholeWord' => empty($_POST['censorWholeWord']) ? '0' : '1', 'censorIgnoreCase' => empty($_POST['censorIgnoreCase']) ? '0' : '1');
call_integration_hook('integrate_save_censors', array(&$updates));
updateSettings($updates);
}
if (isset($_POST['censortest'])) {
require_once $sourcedir . '/Subs-Post.php';
$censorText = htmlspecialchars($_POST['censortest'], ENT_QUOTES);
preparsecode($censorText);
$context['censor_test'] = strtr(censorText($censorText), array('"' => '"'));
}
// Set everything up for the template to do its thang.
$censor_vulgar = explode("\n", $modSettings['censor_vulgar']);
$censor_proper = explode("\n", $modSettings['censor_proper']);
$context['censored_words'] = array();
for ($i = 0, $n = count($censor_vulgar); $i < $n; $i++) {
if (empty($censor_vulgar[$i])) {
continue;
}
// Skip it, it's either spaces or stars only.
if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '') {
continue;
}
$context['censored_words'][htmlspecialchars(trim($censor_vulgar[$i]))] = isset($censor_proper[$i]) ? htmlspecialchars($censor_proper[$i]) : '';
}
call_integration_hook('integrate_censors');
$context['sub_template'] = 'edit_censored';
$context['page_title'] = $txt['admin_censored_words'];
createToken('admin-censor');
}
示例5: validateInput
public function validateInput()
{
parent::validateInput();
if (!isset($this->input['token'])) {
throw new \Exception("JSON input misses token.");
}
if (!($token = validateToken($this->input['token']))) {
throw new \Exception("Invalid token.");
}
}
示例6: run
public function run()
{
parent::run();
$this->getInputJson();
if (!($token = validateToken($this->input['token']))) {
throw new \Exception("Invalid token.");
}
//TODO: delete global somehow
global $user;
$user = new \User($token['uid']);
$user->getFavorites();
$data = array('username' => $user->username, 'nickname' => $user->nickname, 'name' => $user->name, 'email' => $user->email);
foreach ($user->favorites as $favorite) {
$data['favorites'][] = $favorite['tid'];
}
$this->return['user'] = $data;
}
示例7: validatePrivileges
function validatePrivileges($privileges = array(), $no_error = false)
{
return function () use($privileges, $no_error) {
try {
// Inicjalizacja modelu użytkownika
$user = new \Model\User();
// Pobranie instancji szkieletu Slim Framework
$app = \Slim\Slim::getInstance();
// Pobranie tokenu z pola Authorization nagłówka HTTP i jego walidacja
$token = validateToken($app->request->headers->get('Authorization'));
try {
// Pobranie danych uzytkownika o zadanym tokenie
$u = $user->getByToken($token, 'administrator');
} catch (Exception $e) {
throw new Exception('Użytkownik nie jest zalogowany.', 401);
}
// Sprawdzenie wymaganych uprawnień
if (!in_array($u['privileges'], $privileges)) {
throw new Exception('Brak uprawnień.', 401);
}
// Zapamiętanie danych potrzebnych do logowania jako zmienne globalne
$GLOBALS['user_id'] = $u['user_id'];
$GLOBALS['token'] = $token;
$GLOBALS['privileges'] = $u['privileges'];
try {
// Jeśli różnica pomiędzy ostatnią aktywnością, a bierzącym czasem
// wynosi 60 sekund, to odświeżamy autoryzację
$diff = abs(strtotime(date('Y-m-d H:i:s')) - strtotime($u['last_auth']));
if ($diff > 60) {
$res = $user->refreshAuth($token);
}
} catch (Exception $e) {
}
} catch (Exception $e) {
$GLOBALS['user_id'] = -1;
$GLOBALS['token'] = '';
$GLOBALS['privileges'] = 'guest';
if (!$no_error) {
jsonError($app, $e, true);
}
}
};
}
示例8: action_modify_bounce_templates
/**
* Edit a 'it bounced' template.
*
* @uses bounce_template sub template
*/
public function action_modify_bounce_templates()
{
global $context, $txt, $user_info;
require_once SUBSDIR . '/Moderation.subs.php';
$context['id_template'] = isset($_REQUEST['tid']) ? (int) $_REQUEST['tid'] : 0;
$context['is_edit'] = (bool) $context['id_template'];
// Standard template things, you know the drill
$context['page_title'] = $context['is_edit'] ? $txt['ml_bounce_template_modify'] : $txt['ml_bounce_template_add'];
$context['sub_template'] = 'bounce_template';
$context[$context['admin_menu_name']]['current_subsection'] = 'templates';
// Defaults to show
$context['template_data'] = array('title' => '', 'body' => $txt['ml_bounce_template_body_default'], 'subject' => $txt['ml_bounce_template_subject_default'], 'personal' => false, 'can_edit_personal' => true);
// If it's an edit load it.
if ($context['is_edit']) {
modLoadTemplate($context['id_template'], 'bnctpl');
}
// Wait, we are saving?
if (isset($_POST['save'])) {
checkSession('post');
validateToken('mod-mlt');
// To check the BBC is good...
require_once SUBSDIR . '/Post.subs.php';
// Bit of cleaning!
$template_body = trim($_POST['template_body']);
$template_title = trim($_POST['template_title']);
// Need something in both boxes.
if (!empty($template_body) && !empty($template_title)) {
// Safety first.
$template_title = Util::htmlspecialchars($template_title);
// Clean up BBC.
preparsecode($template_body);
// But put line breaks back!
$template_body = strtr($template_body, array('<br />' => "\n"));
// Is this personal?
$recipient_id = !empty($_POST['make_personal']) ? $user_info['id'] : 0;
// Updating or adding ?
if ($context['is_edit']) {
// Simple update...
modAddUpdateTemplate($recipient_id, $template_title, $template_body, $context['id_template'], true, 'bnctpl');
// If it wasn't visible and now is they've effectively added it.
if ($context['template_data']['personal'] && !$recipient_id) {
logAction('add_bounce_template', array('template' => $template_title));
} elseif (!$context['template_data']['personal'] && $recipient_id) {
logAction('delete_bounce_template', array('template' => $template_title));
} else {
logAction('modify_bounce_template', array('template' => $template_title));
}
} else {
modAddUpdateTemplate($recipient_id, $template_title, $template_body, $context['id_template'], false, 'bnctpl');
logAction('add_bounce_template', array('template' => $template_title));
}
// Get out of town...
redirectexit('action=admin;area=maillist;sa=emailtemplates');
} else {
$context['warning_errors'] = array();
$context['template_data']['title'] = !empty($template_title) ? $template_title : '';
$context['template_data']['body'] = !empty($template_body) ? $template_body : $txt['ml_bounce_template_body_default'];
$context['template_data']['personal'] = !empty($recipient_id);
if (empty($template_title)) {
$context['warning_errors'][] = $txt['ml_bounce_template_error_no_title'];
}
if (empty($template_body)) {
$context['warning_errors'][] = $txt['ml_bounce_template_error_no_body'];
}
}
}
createToken('mod-mlt');
}
示例9: action_contact
/**
* Shows the contact form for the user to fill out
* Needs to be enabled to be used
*/
public function action_contact()
{
global $context, $txt, $user_info, $modSettings;
// Already inside, no need to use this, just send a PM
// Disabled, you cannot enter.
if (!$user_info['is_guest'] || empty($modSettings['enable_contactform']) || $modSettings['enable_contactform'] == 'disabled') {
redirectexit();
}
loadLanguage('Login');
loadTemplate('Register');
if (isset($_REQUEST['send'])) {
checkSession('post');
validateToken('contact');
spamProtection('contact');
// No errors, yet.
$context['errors'] = array();
loadLanguage('Errors');
// Could they get the right send topic verification code?
require_once SUBSDIR . '/VerificationControls.class.php';
require_once SUBSDIR . '/Members.subs.php';
// form validation
require_once SUBSDIR . '/DataValidator.class.php';
$validator = new Data_Validator();
$validator->sanitation_rules(array('emailaddress' => 'trim', 'contactmessage' => 'trim|Util::htmlspecialchars'));
$validator->validation_rules(array('emailaddress' => 'required|valid_email', 'contactmessage' => 'required'));
$validator->text_replacements(array('emailaddress' => $txt['error_email'], 'contactmessage' => $txt['error_message']));
// Any form errors
if (!$validator->validate($_POST)) {
$context['errors'] = $validator->validation_errors();
}
// How about any verification errors
$verificationOptions = array('id' => 'contactform');
$context['require_verification'] = create_control_verification($verificationOptions, true);
if (is_array($context['require_verification'])) {
foreach ($context['require_verification'] as $error) {
$context['errors'][] = $txt['error_' . $error];
}
}
// No errors, then send the PM to the admins
if (empty($context['errors'])) {
$admins = admins();
if (!empty($admins)) {
require_once SUBSDIR . '/PersonalMessage.subs.php';
sendpm(array('to' => array_keys($admins), 'bcc' => array()), $txt['contact_subject'], $_REQUEST['contactmessage'], false, array('id' => 0, 'name' => $validator->emailaddress, 'username' => $validator->emailaddress));
}
// Send the PM
redirectexit('action=contact;sa=done');
} else {
$context['emailaddress'] = $validator->emailaddress;
$context['contactmessage'] = $validator->contactmessage;
}
}
if (isset($_GET['sa']) && $_GET['sa'] == 'done') {
$context['sub_template'] = 'contact_form_done';
} else {
$context['sub_template'] = 'contact_form';
$context['page_title'] = $txt['admin_contact_form'];
require_once SUBSDIR . '/VerificationControls.class.php';
$verificationOptions = array('id' => 'contactform');
$context['require_verification'] = create_control_verification($verificationOptions);
$context['visual_verification_id'] = $verificationOptions['id'];
}
createToken('contact');
}
示例10: list_integration_hooks
function list_integration_hooks()
{
global $sourcedir, $scripturl, $context, $txt, $modSettings, $settings;
$context['filter'] = '';
$currentHooks = get_integration_hooks();
if (isset($_GET['filter']) && in_array($_GET['filter'], array_keys($currentHooks))) {
$context['filter'] = ';filter=' . $_GET['filter'];
}
if (!empty($modSettings['handlinghooks_enabled'])) {
if (!empty($_REQUEST['do']) && isset($_REQUEST['hook']) && isset($_REQUEST['function'])) {
checkSession('request');
validateToken('admin-hook', 'request');
if ($_REQUEST['do'] == 'remove') {
remove_integration_function($_REQUEST['hook'], urldecode($_REQUEST['function']));
} else {
if ($_REQUEST['do'] == 'disable') {
// It's a hack I know...but I'm way too lazy!!!
$function_remove = $_REQUEST['function'];
$function_add = $_REQUEST['function'] . ']';
} else {
$function_remove = $_REQUEST['function'] . ']';
$function_add = $_REQUEST['function'];
}
$file = !empty($_REQUEST['includedfile']) ? urldecode($_REQUEST['includedfile']) : '';
remove_integration_function($_REQUEST['hook'], $function_remove, $file);
add_integration_function($_REQUEST['hook'], $function_add, $file);
redirectexit('action=admin;area=modsettings;sa=hooks' . $context['filter']);
}
}
}
$list_options = array('id' => 'list_integration_hooks', 'title' => $txt['hooks_title_list'], 'items_per_page' => 20, 'base_href' => $scripturl . '?action=admin;area=modsettings;sa=hooks' . $context['filter'] . ';' . $context['session_var'] . '=' . $context['session_id'], 'default_sort_col' => 'hook_name', 'get_items' => array('function' => 'get_integration_hooks_data'), 'get_count' => array('function' => 'get_integration_hooks_count'), 'no_items_label' => $txt['hooks_no_hooks'], 'columns' => array('hook_name' => array('header' => array('value' => $txt['hooks_field_hook_name']), 'data' => array('db' => 'hook_name'), 'sort' => array('default' => 'hook_name', 'reverse' => 'hook_name DESC')), 'function_name' => array('header' => array('value' => $txt['hooks_field_function_name']), 'data' => array('function' => create_function('$data', '
global $txt;
if (!empty($data[\'included_file\']))
return $txt[\'hooks_field_function\'] . \': \' . $data[\'real_function\'] . \'<br />\' . $txt[\'hooks_field_included_file\'] . \': \' . $data[\'included_file\'];
else
return $data[\'real_function\'];
')), 'sort' => array('default' => 'function_name', 'reverse' => 'function_name DESC')), 'file_name' => array('header' => array('value' => $txt['hooks_field_file_name']), 'data' => array('db' => 'file_name'), 'sort' => array('default' => 'file_name', 'reverse' => 'file_name DESC')), 'status' => array('header' => array('value' => $txt['hooks_field_hook_exists'], 'style' => 'width:3%'), 'data' => array('function' => create_function('$data', '
global $txt, $settings, $scripturl, $context;
$change_status = array(\'before\' => \'\', \'after\' => \'\');
if ($data[\'can_be_disabled\'] && $data[\'status\'] != \'deny\')
{
$change_status[\'before\'] = \'<a href="\' . $scripturl . \'?action=admin;area=modsettings;sa=hooks;do=\' . ($data[\'enabled\'] ? \'disable\' : \'enable\') . \';hook=\' . $data[\'hook_name\'] . \';function=\' . $data[\'real_function\'] . (!empty($data[\'included_file\']) ? \';includedfile=\' . urlencode($data[\'included_file\']) : \'\') . $context[\'filter\'] . \';\' . $context[\'admin-hook_token_var\'] . \'=\' . $context[\'admin-hook_token\'] . \';\' . $context[\'session_var\'] . \'=\' . $context[\'session_id\'] . \'" onclick="return confirm(\' . javaScriptEscape($txt[\'quickmod_confirm\']) . \');">\';
$change_status[\'after\'] = \'</a>\';
}
return $change_status[\'before\'] . \'<img src="\' . $settings[\'images_url\'] . \'/admin/post_moderation_\' . $data[\'status\'] . \'.png" alt="\' . $data[\'img_text\'] . \'" title="\' . $data[\'img_text\'] . \'" />\' . $change_status[\'after\'];
'), 'class' => 'centertext'), 'sort' => array('default' => 'status', 'reverse' => 'status DESC'))), 'additional_rows' => array(array('position' => 'after_title', 'value' => $txt['hooks_disable_instructions'] . '<br />
' . $txt['hooks_disable_legend'] . ':
<ul style="list-style: none;">
<li><img src="' . $settings['images_url'] . '/admin/post_moderation_allow.png" alt="' . $txt['hooks_active'] . '" title="' . $txt['hooks_active'] . '" /> ' . $txt['hooks_disable_legend_exists'] . '</li>
<li><img src="' . $settings['images_url'] . '/admin/post_moderation_moderate.png" alt="' . $txt['hooks_disabled'] . '" title="' . $txt['hooks_disabled'] . '" /> ' . $txt['hooks_disable_legend_disabled'] . '</li>
<li><img src="' . $settings['images_url'] . '/admin/post_moderation_deny.png" alt="' . $txt['hooks_missing'] . '" title="' . $txt['hooks_missing'] . '" /> ' . $txt['hooks_disable_legend_missing'] . '</li>
</ul>')));
if (!empty($modSettings['handlinghooks_enabled'])) {
createToken('admin-hook', 'request');
$list_options['columns']['remove'] = array('header' => array('value' => $txt['hooks_button_remove'], 'style' => 'width:3%'), 'data' => array('function' => create_function('$data', '
global $txt, $settings, $scripturl, $context;
if (!$data[\'hook_exists\'])
return \'
<a href="\' . $scripturl . \'?action=admin;area=modsettings;sa=hooks;do=remove;hook=\' . $data[\'hook_name\'] . \';function=\' . urlencode($data[\'function_name\']) . $context[\'filter\'] . \';\' . $context[\'admin-hook_token_var\'] . \'=\' . $context[\'admin-hook_token\'] . \';\' . $context[\'session_var\'] . \'=\' . $context[\'session_id\'] . \'" onclick="return confirm(\' . javaScriptEscape($txt[\'quickmod_confirm\']) . \');">
<img src="\' . $settings[\'images_url\'] . \'/icons/quick_remove.png" alt="\' . $txt[\'hooks_button_remove\'] . \'" title="\' . $txt[\'hooks_button_remove\'] . \'" />
</a>\';
'), 'class' => 'centertext'));
$list_options['form'] = array('href' => $scripturl . '?action=admin;area=modsettings;sa=hooks' . $context['filter'] . ';' . $context['session_var'] . '=' . $context['session_id'], 'name' => 'list_integration_hooks');
}
require_once $sourcedir . '/Subs-List.php';
createList($list_options);
$context['page_title'] = $txt['hooks_title_list'];
$context['sub_template'] = 'show_list';
$context['default_list'] = 'list_integration_hooks';
}
示例11: checkToken
function checkToken()
{
if (isset($_POST["reg-borrower"])) {
return true;
// capcha support already there
//return validateToken('reg-borrower');
} else {
if (isset($_POST["reg-lender"])) {
return true;
// capcha support already there
//return validateToken('reg-lender');
} else {
if (isset($_POST['reg-partner'])) {
return true;
// capcha support already there
//return validateToken('reg-partner');
} else {
if (isset($_POST["userlogin"])) {
return true;
//return validateToken('userlogin');
} else {
if (isset($_POST['loanapplication'])) {
return validateToken('loanapplication');
} else {
if (isset($_POST['editloanapplication'])) {
return validateToken('editloanapplication');
} else {
if (isset($_POST['exrate'])) {
return validateToken('exrate');
} else {
if (isset($_POST['amt_entered'])) {
return validateToken('amt_entered');
} else {
if (isset($_POST['confirmApplication'])) {
return validateToken('confirmApplication');
} else {
if (isset($_POST['lenderbid'])) {
return validateToken('lenderbid');
} else {
if (isset($_POST['lenderbidUp'])) {
return validateToken('lenderbidUp');
} else {
if (isset($_POST['minfundamount'])) {
return validateToken('minfundamount');
} else {
if (isset($_POST['activatePartner'])) {
return validateToken('activatePartner');
} else {
if (isset($_POST['deactivatePartner'])) {
return validateToken('deactivatePartner');
} else {
if (isset($_POST['activateLender'])) {
return validateToken('activateLender');
} else {
if (isset($_POST['deactivateLender'])) {
return validateToken('deactivateLender');
} else {
if (isset($_POST['deactivateBorrower'])) {
return validateToken('deactivateBorrower');
} else {
if (isset($_POST['deleteBorrower'])) {
return validateToken('deleteBorrower');
} else {
if (isset($_POST['deletePartner'])) {
return validateToken('deletePartner');
} else {
if (isset($_POST['deleteLender'])) {
return validateToken('deleteLender');
} else {
if (isset($_POST['makeLoanExpire'])) {
return validateToken('makeLoanExpire');
} else {
if (isset($_POST['makeLoanActive'])) {
return validateToken('makeLoanActive');
} else {
if (isset($_POST['sendbulkmails'])) {
return validateToken('sendbulkmails');
} else {
if (isset($_POST['addpaymenttolender'])) {
return validateToken('addpaymenttolender');
} else {
if (isset($_POST['adddonationtolender'])) {
return validateToken('adddonationtolender');
} else {
if (isset($_POST['changePassword'])) {
return validateToken('changePassword');
} else {
if (isset($_POST['forgiveShare'])) {
return validateToken('forgiveShare');
} else {
if (isset($_POST['assignedPartner'])) {
return true;
} else {
if (isset($_POST['referral'])) {
return validateToken('referral');
} else {
if (isset($_POST['add-repayment_instruction'])) {
return validateToken('add-repayment_instruction');
}
}
//.........这里部分代码省略.........
示例12: TaskLog
/**
* Show the log of all tasks that have taken place.
*
* @uses ManageScheduledTasks language file
*/
function TaskLog()
{
global $scripturl, $context, $txt, $smcFunc, $sourcedir;
// Lets load the language just incase we are outside the Scheduled area.
loadLanguage('ManageScheduledTasks');
// Empty the log?
if (!empty($_POST['removeAll'])) {
checkSession();
validateToken('admin-tl');
$smcFunc['db_query']('truncate_table', '
TRUNCATE {db_prefix}log_scheduled_tasks', array());
}
// Setup the list.
$listOptions = array('id' => 'task_log', 'items_per_page' => 30, 'title' => $txt['scheduled_log'], 'no_items_label' => $txt['scheduled_log_empty'], 'base_href' => $context['admin_area'] == 'scheduledtasks' ? $scripturl . '?action=admin;area=scheduledtasks;sa=tasklog' : $scripturl . '?action=admin;area=logs;sa=tasklog', 'default_sort_col' => 'date', 'get_items' => array('function' => 'list_getTaskLogEntries'), 'get_count' => array('function' => 'list_getNumTaskLogEntries'), 'columns' => array('name' => array('header' => array('value' => $txt['scheduled_tasks_name']), 'data' => array('db' => 'name')), 'date' => array('header' => array('value' => $txt['scheduled_log_time_run']), 'data' => array('function' => create_function('$rowData', '
return timeformat($rowData[\'time_run\'], true);
')), 'sort' => array('default' => 'lst.id_log DESC', 'reverse' => 'lst.id_log')), 'time_taken' => array('header' => array('value' => $txt['scheduled_log_time_taken']), 'data' => array('sprintf' => array('format' => $txt['scheduled_log_time_taken_seconds'], 'params' => array('time_taken' => false))), 'sort' => array('default' => 'lst.time_taken', 'reverse' => 'lst.time_taken DESC'))), 'form' => array('href' => $context['admin_area'] == 'scheduledtasks' ? $scripturl . '?action=admin;area=scheduledtasks;sa=tasklog' : $scripturl . '?action=admin;area=logs;sa=tasklog', 'token' => 'admin-tl'), 'additional_rows' => array(array('position' => 'below_table_data', 'value' => '
<input type="submit" name="removeAll" value="' . $txt['scheduled_log_empty_log'] . '" onclick="return confirm(\'' . $txt['scheduled_log_empty_log_confirm'] . '\');" class="button_submit" />', 'style' => 'text-align: right;'), array('position' => 'after_title', 'value' => $txt['scheduled_tasks_time_offset'], 'class' => 'windowbg2')));
createToken('admin-tl');
require_once $sourcedir . '/Subs-List.php';
createList($listOptions);
$context['sub_template'] = 'show_list';
$context['default_list'] = 'task_log';
// Make it all look tify.
$context[$context['admin_menu_name']]['current_subsection'] = 'tasklog';
$context['page_title'] = $txt['scheduled_log'];
}
示例13: action_log
/**
* Show the log of all tasks that have taken place.
*
* @uses ManageScheduledTasks language file
*/
public function action_log()
{
global $scripturl, $context, $txt;
require_once SUBSDIR . '/ScheduledTasks.subs.php';
// Lets load the language just in case we are outside the Scheduled area.
loadLanguage('ManageScheduledTasks');
// Empty the log?
if (!empty($_POST['removeAll'])) {
checkSession();
validateToken('admin-tl');
emptyTaskLog();
}
// Setup the list.
$listOptions = array('id' => 'task_log', 'items_per_page' => 30, 'title' => $txt['scheduled_log'], 'no_items_label' => $txt['scheduled_log_empty'], 'base_href' => $context['admin_area'] == 'scheduledtasks' ? $scripturl . '?action=admin;area=scheduledtasks;sa=tasklog' : $scripturl . '?action=admin;area=logs;sa=tasklog', 'default_sort_col' => 'date', 'get_items' => array('function' => array($this, 'list_getTaskLogEntries')), 'get_count' => array('function' => array($this, 'list_getNumTaskLogEntries')), 'columns' => array('name' => array('header' => array('value' => $txt['scheduled_tasks_name']), 'data' => array('db' => 'name')), 'date' => array('header' => array('value' => $txt['scheduled_log_time_run']), 'data' => array('function' => create_function('$rowData', '
return standardTime($rowData[\'time_run\'], true);
')), 'sort' => array('default' => 'lst.id_log DESC', 'reverse' => 'lst.id_log')), 'time_taken' => array('header' => array('value' => $txt['scheduled_log_time_taken']), 'data' => array('sprintf' => array('format' => $txt['scheduled_log_time_taken_seconds'], 'params' => array('time_taken' => false))), 'sort' => array('default' => 'lst.time_taken', 'reverse' => 'lst.time_taken DESC')), 'task_completed' => array('header' => array('value' => $txt['scheduled_log_completed']), 'data' => array('function' => create_function('$rowData', '
global $settings, $txt;
return \'<img src="\' . $settings[\'images_url\'] . \'/admin/complete_\' . ($rowData[\'task_completed\'] ? \'success\' : \'fail\') . \'.png" alt="\' . sprintf($txt[$rowData[\'task_completed\'] ? \'maintain_done\' : \'maintain_fail\'], $rowData[\'name\']) . \'" />\';
')))), 'form' => array('href' => $context['admin_area'] == 'scheduledtasks' ? $scripturl . '?action=admin;area=scheduledtasks;sa=tasklog' : $scripturl . '?action=admin;area=logs;sa=tasklog', 'token' => 'admin-tl'), 'additional_rows' => array(array('position' => 'below_table_data', 'value' => '
<input type="submit" name="removeAll" value="' . $txt['scheduled_log_empty_log'] . '" onclick="return confirm(\'' . $txt['scheduled_log_empty_log_confirm'] . '\');" class="right_submit" />'), array('position' => 'after_title', 'value' => $txt['scheduled_tasks_time_offset'], 'class' => 'windowbg2')));
createToken('admin-tl');
require_once SUBSDIR . '/GenericList.class.php';
createList($listOptions);
$context['sub_template'] = 'show_list';
$context['default_list'] = 'task_log';
// Make it all look tify.
$context[$context['admin_menu_name']]['current_subsection'] = 'tasklog';
$context['page_title'] = $txt['scheduled_log'];
}
示例14: EditMembergroup
/**
* Editing a membergroup.
* Screen to edit a specific membergroup.
* Called by ?action=admin;area=membergroups;sa=edit;group=x.
* It requires the manage_membergroups permission.
* Also handles the delete button of the edit form.
* Redirects to ?action=admin;area=membergroups.
*
* @uses the edit_group sub template of ManageMembergroups.
*/
function EditMembergroup()
{
global $context, $txt, $sourcedir, $modSettings, $smcFunc;
$_REQUEST['group'] = isset($_REQUEST['group']) && $_REQUEST['group'] > 0 ? (int) $_REQUEST['group'] : 0;
if (!empty($modSettings['deny_boards_access'])) {
loadLanguage('ManagePermissions');
}
// Make sure this group is editable.
if (!empty($_REQUEST['group'])) {
$request = $smcFunc['db_query']('', '
SELECT id_group
FROM {db_prefix}membergroups
WHERE id_group = {int:current_group}' . (allowedTo('admin_forum') ? '' : '
AND group_type != {int:is_protected}') . '
LIMIT {int:limit}', array('current_group' => $_REQUEST['group'], 'is_protected' => 1, 'limit' => 1));
list($_REQUEST['group']) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
}
// Now, do we have a valid id?
if (empty($_REQUEST['group'])) {
fatal_lang_error('membergroup_does_not_exist', false);
}
// The delete this membergroup button was pressed.
if (isset($_POST['delete'])) {
checkSession();
validateToken('admin-mmg');
require_once $sourcedir . '/Subs-Membergroups.php';
deleteMembergroups($_REQUEST['group']);
redirectexit('action=admin;area=membergroups;');
} elseif (isset($_POST['save'])) {
// Validate the session.
checkSession();
validateToken('admin-mmg');
// Can they really inherit from this group?
if (isset($_POST['group_inherit']) && $_POST['group_inherit'] != -2 && !allowedTo('admin_forum')) {
$request = $smcFunc['db_query']('', '
SELECT group_type
FROM {db_prefix}membergroups
WHERE id_group = {int:inherit_from}
LIMIT {int:limit}', array('inherit_from' => $_POST['group_inherit'], 'limit' => 1));
list($inherit_type) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
}
// Set variables to their proper value.
$_POST['max_messages'] = isset($_POST['max_messages']) ? (int) $_POST['max_messages'] : 0;
$_POST['min_posts'] = isset($_POST['min_posts']) && isset($_POST['group_type']) && $_POST['group_type'] == -1 && $_REQUEST['group'] > 3 ? abs($_POST['min_posts']) : ($_REQUEST['group'] == 4 ? 0 : -1);
$_POST['icons'] = empty($_POST['icon_count']) || $_POST['icon_count'] < 0 ? '' : min((int) $_POST['icon_count'], 99) . '#' . $_POST['icon_image'];
$_POST['group_desc'] = isset($_POST['group_desc']) && ($_REQUEST['group'] == 1 || isset($_POST['group_type']) && $_POST['group_type'] != -1) ? trim($_POST['group_desc']) : '';
$_POST['group_type'] = !isset($_POST['group_type']) || $_POST['group_type'] < 0 || $_POST['group_type'] > 3 || $_POST['group_type'] == 1 && !allowedTo('admin_forum') ? 0 : (int) $_POST['group_type'];
$_POST['group_hidden'] = empty($_POST['group_hidden']) || $_POST['min_posts'] != -1 || $_REQUEST['group'] == 3 ? 0 : (int) $_POST['group_hidden'];
$_POST['group_inherit'] = $_REQUEST['group'] > 1 && $_REQUEST['group'] != 3 && (empty($inherit_type) || $inherit_type != 1) ? (int) $_POST['group_inherit'] : -2;
//@todo Don't set online_color for the Moderators group?
// Do the update of the membergroup settings.
$smcFunc['db_query']('', '
UPDATE {db_prefix}membergroups
SET group_name = {string:group_name}, online_color = {string:online_color},
max_messages = {int:max_messages}, min_posts = {int:min_posts}, icons = {string:icons},
description = {string:group_desc}, group_type = {int:group_type}, hidden = {int:group_hidden},
id_parent = {int:group_inherit}
WHERE id_group = {int:current_group}', array('max_messages' => $_POST['max_messages'], 'min_posts' => $_POST['min_posts'], 'group_type' => $_POST['group_type'], 'group_hidden' => $_POST['group_hidden'], 'group_inherit' => $_POST['group_inherit'], 'current_group' => (int) $_REQUEST['group'], 'group_name' => $smcFunc['htmlspecialchars']($_POST['group_name']), 'online_color' => $_POST['online_color'], 'icons' => $_POST['icons'], 'group_desc' => $_POST['group_desc']));
call_integration_hook('integrate_save_membergroup', array((int) $_REQUEST['group']));
// Time to update the boards this membergroup has access to.
if ($_REQUEST['group'] == 2 || $_REQUEST['group'] > 3) {
$accesses = empty($_POST['boardaccess']) || !is_array($_POST['boardaccess']) ? array() : $_POST['boardaccess'];
$changed_boards['allow'] = array();
$changed_boards['deny'] = array();
$changed_boards['ignore'] = array();
foreach ($accesses as $group_id => $action) {
$changed_boards[$action][] = (int) $group_id;
}
foreach (array('allow', 'deny') as $board_action) {
// Find all board this group is in, but shouldn't be in.
$request = $smcFunc['db_query']('', '
SELECT id_board, {raw:column}
FROM {db_prefix}boards
WHERE FIND_IN_SET({string:current_group}, {raw:column}) != 0' . (empty($changed_boards[$board_action]) ? '' : '
AND id_board NOT IN ({array_int:board_access_list})'), array('current_group' => (int) $_REQUEST['group'], 'board_access_list' => $changed_boards[$board_action], 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups'));
while ($row = $smcFunc['db_fetch_assoc']($request)) {
$smcFunc['db_query']('', '
UPDATE {db_prefix}boards
SET {raw:column} = {string:member_group_access}
WHERE id_board = {int:current_board}', array('current_board' => $row['id_board'], 'member_group_access' => implode(',', array_diff(explode(',', $row['member_groups']), array($_REQUEST['group']))), 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups'));
}
$smcFunc['db_free_result']($request);
// Add the membergroup to all boards that hadn't been set yet.
if (!empty($changed_boards[$board_action])) {
$smcFunc['db_query']('', '
UPDATE {db_prefix}boards
SET {raw:column} = CASE WHEN {raw:column} = {string:blank_string} THEN {string:group_id_string} ELSE CONCAT({raw:column}, {string:comma_group}) END
WHERE id_board IN ({array_int:board_list})
//.........这里部分代码省略.........
示例15: action_managesphinx
/**
* Edit settings related to the sphinx or sphinxQL search function.
*
* - Called by ?action=admin;area=managesearch;sa=sphinx.
* - Checks if connection to search daemon is possible
*/
public function action_managesphinx()
{
global $txt, $context, $modSettings;
// Saving the settings
if (isset($_POST['save'])) {
checkSession();
validateToken('admin-mssphinx');
updateSettings(array('sphinx_data_path' => rtrim($_POST['sphinx_data_path'], '/'), 'sphinx_log_path' => rtrim($_POST['sphinx_log_path'], '/'), 'sphinx_stopword_path' => $_POST['sphinx_stopword_path'], 'sphinx_indexer_mem' => (int) $_POST['sphinx_indexer_mem'], 'sphinx_searchd_server' => $_POST['sphinx_searchd_server'], 'sphinx_searchd_port' => (int) $_POST['sphinx_searchd_port'], 'sphinxql_searchd_port' => (int) $_POST['sphinxql_searchd_port'], 'sphinx_max_results' => (int) $_POST['sphinx_max_results']));
} elseif (isset($_POST['checkconnect'])) {
checkSession();
validateToken('admin-mssphinx');
// If they have not picked sphinx yet, let them know, but we can still check connections
if (empty($modSettings['search_index']) || $modSettings['search_index'] !== 'sphinx' && $modSettings['search_index'] !== 'sphinxql') {
$context['settings_message'][] = $txt['sphinx_test_not_selected'];
$context['error_type'] = 'notice';
}
// Try to connect via Sphinx API?
if (!empty($modSettings['search_index']) && ($modSettings['search_index'] === 'sphinx' || empty($modSettings['search_index']))) {
if (@file_exists(SOURCEDIR . '/sphinxapi.php')) {
include_once SOURCEDIR . '/sphinxapi.php';
$mySphinx = new SphinxClient();
$mySphinx->SetServer($modSettings['sphinx_searchd_server'], (int) $modSettings['sphinx_searchd_port']);
$mySphinx->SetLimits(0, (int) $modSettings['sphinx_max_results']);
$mySphinx->SetMatchMode(SPH_MATCH_BOOLEAN);
$mySphinx->SetSortMode(SPH_SORT_ATTR_ASC, 'id_topic');
$request = $mySphinx->Query('test', 'elkarte_index');
if ($request === false) {
$context['settings_message'][] = $txt['sphinx_test_connect_failed'];
$context['error_type'] = 'serious';
} else {
$context['settings_message'][] = $txt['sphinx_test_passed'];
}
} else {
$context['settings_message'][] = $txt['sphinx_test_api_missing'];
$context['error_type'] = 'serious';
}
}
// Try to connect via SphinxQL
if (!empty($modSettings['search_index']) && ($modSettings['search_index'] === 'sphinxql' || empty($modSettings['search_index']))) {
if (!empty($modSettings['sphinx_searchd_server']) && !empty($modSettings['sphinxql_searchd_port'])) {
$result = @mysqli_connect($modSettings['sphinx_searchd_server'] === 'localhost' ? '127.0.0.1' : $modSettings['sphinx_searchd_server'], '', '', '', (int) $modSettings['sphinxql_searchd_port']);
if ($result === false) {
$context['settings_message'][] = $txt['sphinxql_test_connect_failed'];
$context['error_type'] = 'serious';
} else {
$context['settings_message'][] = $txt['sphinxql_test_passed'];
}
} else {
$context['settings_message'][] = $txt['sphinxql_test_connect_failed'];
$context['error_type'] = 'serious';
}
}
} elseif (isset($_POST['createconfig'])) {
checkSession();
validateToken('admin-mssphinx');
require_once SUBSDIR . '/ManageSearch.subs.php';
createSphinxConfig();
}
// Setup for the template
$context['page_title'] = $txt['search_sphinx'];
$context['page_description'] = $txt['sphinx_description'];
$context['sub_template'] = 'manage_sphinx';
createToken('admin-mssphinx');
}