本文整理汇总了PHP中secure类的典型用法代码示例。如果您正苦于以下问题:PHP secure类的具体用法?PHP secure怎么用?PHP secure使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了secure类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: clear
static function clear($key = null, $is_secret_key = false)
{
$is_secret_key and $key = secure::token($key);
if (is_null($key)) {
session_unset();
} elseif (is_array($key)) {
foreach ($key as $k) {
unset($_SESSION[$k]);
}
} else {
unset($_SESSION[$key]);
}
return true;
}
示例2: csrf
static function csrf($mode, $csrf = '')
{
$key = config('secure.csrf_name', 'secure');
if ($mode === 'get') {
return session::get($key);
}
if ($mode === 'check') {
//Notice 是否只用一次并清掉cookie
// input::cookie($key,$value,1);
return $csrf && $csrf === session::get($key);
}
if ($mode === 'set') {
$value = substr(secure::token(time()), 5, 8);
session::set($key, $value);
input::cookie($key, $value, 7200);
}
return true;
}
示例3: changeAdminPassword
/**
* функция проверки авторизации админа
* Берет логин и пароль админа из сесси и сверяет их с данными в БД
*
* @param (string) $login - новый логин (может быть false)
* @param (string) $password - новый пароль (может быть false)
*
* @return bool (сообщение перезагружающее страницу)
*/
static function changeAdminPassword($login, $password)
{
$link = isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '';
if ($login && $password) {
$change = "login='" . md5($login) . "', password='" . md5($password) . "'";
$arrSession = array('administrator_login' => md5($login), 'administrator_password' => md5($password));
} elseif (!$login && $password) {
$change = "password='" . md5($password) . "'";
$arrSession = array('administrator_password' => md5($password));
} elseif ($login && !$password) {
$change = "login='" . md5($login) . "'";
$arrSession = array('administrator_login' => md5($login));
} else {
$change = false;
}
$strQuery = "UPDATE " . USR_PREFIX . "admin SET " . $change . " WHERE login IN (" . secure::escQuoteData($_SESSION['administrator_login']) . ") AND password IN (" . secure::escQuoteData($_SESSION['administrator_password']) . ")";
if (!empty($change) && db::dbQuery($strQuery)) {
// обновляем пароль в сессии
tools::updateSessionData($_SESSION, $arrSession);
messages::messageChangeSaved(MESSAGE_DATA_HAS_BEEN_CHANGED, false, CONF_ADMIN_FILE . $link);
} else {
messages::messageChangeSaved(MESSAGE_DATA_HAS_NOT_BEEN_CHANGED, false, CONF_ADMIN_FILE . $link);
}
}
示例4: spl_autoload_register
############################### INIT ###############################
####################################################################
/********** Автозагрузчик классов **********/
spl_autoload_register('expert__autoload');
function expert__autoload($className)
{
/********** Библиотека статических классов **********/
if (file_exists(SD_ROOT_DIR . 'core/classes/lib/' . $className . '.class.php')) {
require_once SD_ROOT_DIR . 'core/classes/lib/' . $className . '.class.php';
} else {
// Файл класса ненайден печатаем сообщение об ошибке
spl_autoload_register('smartyAutoload');
}
}
/********** Очистка полученных данных **********/
secure::clearRequestData();
/********** Языковые файлы **********/
if (!empty($_COOKIE['instLang']) && is_dir(SD_ROOT_DIR . 'install/lang/' . $_COOKIE['instLang'] . '/')) {
$currLang = $_COOKIE['instLang'];
} else {
$currLang = SDG_DEFAULT_LANGUAGE;
}
foreach (filesys::getFilesInDir(SD_ROOT_DIR . 'install/lang/' . $currLang . '/') as $fileLang) {
require_once SD_ROOT_DIR . 'install/lang/' . $currLang . '/' . $fileLang;
}
/********** Инициализация Smarty **********/
define('SMARTY_SPL_AUTOLOAD', 1);
require_once SD_ROOT_DIR . 'install/Smarty/Smarty.class.php';
$smarty = new Smarty();
//core smarty object
$smarty->error_reporting = E_ALL & ~E_NOTICE;
示例5: sendUserDeletedArticle
/**
* Функция отправляет пользователю сообщение о том, что его статья удалена
*
* @param (array) $arrData - массив данных статьи
*
* @return void
*/
public function sendUserDeletedArticle(&$arrData)
{
/** Получаем данные пользователя **/
$user = new user();
if ($uData = $user->getUser("id IN (" . secure::escQuoteData($arrData['id']) . ")")) {
$mailer = new mailer();
// массив для замены в шаблоне
$mailer->setAddReplace(array('%ARTICLE_TITLE%' => $arrData['title'], '%COMMENTS%' => CONF_MAIL_FORMAT_HTML ? nl2br($arrData['comments']) : $arrData['comments']));
// отправляем письмо администратору
$mailer->sendEmail(CONF_MAIL_ADMIN_EMAIL, CONF_SITE_NAME, false, $uData['email'], $uData['first_name'], MAIL_MODERATE_ARTICLES_DELETED . ': ' . $arrData['title'], 'user.article.deleted.txt');
unset($mailer);
// уничтожаем объект
}
unset($user);
// уничтожаем объект
}
示例6: array_filter
$arrID = array_filter(explode('-', $retFields['id_user']), 'strings::ifInt');
!empty($arrID[0]) && !empty($arrID[1]) ? $strWhere .= " AND id_user>=" . $arrID[0] . " AND id_user<=" . $arrID[1] : null;
} elseif ((int) $retFields['id_user']) {
$strWhere .= " AND id_user IN (" . secure::escQuoteData((int) abs($retFields['id_user'])) . ")";
}
}
/** Автор **/
!empty($retFields['author']) ? $strWhere .= " AND author LIKE " . secure::escQuoteData($retFields['author']) : null;
/** Заголовок **/
!empty($retFields['title']) ? $strWhere .= " AND title LIKE " . secure::escQuoteData($retFields['title']) : null;
/** Раздел **/
!empty($retFields['id_section']) ? $strWhere .= " AND id_section IN (" . secure::escQuoteData($retFields['id_section']) . ")" : null;
// проверяем поле "Дата от" и создаем условие для запроса
!empty($retFields['sDate']) ? !validate::validateMySqlDate($retFields['sDate']) ? $arrErrors[] = ERROR_DATE_FORMAT : ($strWhere .= " AND datetime>=" . secure::escQuoteData($retFields['sDate'])) : null;
// проверяем поле "Дата до" и создаем условие для запроса
!empty($retFields['eDate']) ? !validate::validateMySqlDate($retFields['eDate']) ? $arrErrors[] = ERROR_DATE_FORMAT : ($strWhere .= " AND datetime<=" . secure::escQuoteData($retFields['eDate'])) : null;
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
$smarty->assignByRef('retFields', $retFields);
/** текущий обработанный URL **/
$path .= 'do=filter&id=' . $retFields['id'] . '&id_user=' . $retFields['id_user'] . '&author=' . $retFields['author'] . '&title=' . $retFields['title'] . '&id_section=' . $retFields['id_section'] . '&sDate=' . $retFields['sDate'] . '&eDate=' . $retFields['eDate'] . '&records=' . $retFields['records'] . '&';
}
/** смещение, всегда 0 (затем берется из $_GET) **/
$offset = !empty($_GET['offset']) && strings::ifInt($_GET['offset']) && (int) $_GET['offset'] > 0 ? (int) abs($_GET['offset']) : 0;
$strLimit = array('strLimit' => $offset . ',' . $retFields['records'], 'calcRows' => true);
$arrFields = array('id', 'title', 'id_section', 'id_user', 'author', 'datetime');
$smarty->assign('arrArticles', $articles->getArticles($strWhere, false, $strLimit, $arrFields));
// массив всех статей
/** формируем страницы **/
$allRecords = $articles->cntArticles();
// получаем общее количество статей
示例7: elseif
// массив всех новостей
$smarty->assignByRef('news', $arrNews);
// для блока боковой части
$currMonth = terms::currentDateTime('n');
$smarty->assignByRef('currMonth', $currMonth);
//$smarty->assignByRef('arrMonth', $arrAddDict['Month']['values']);
} elseif (isset($_GET['month'])) {
messages::error404();
} elseif (!empty($_GET['year']) && ($year = chpu::getId_out_tId($_GET['year'])) && 4 == strlen($year)) {
$arrNamePage[] = array('name' => MENU_ACTION_ARCHIVED, 'link' => chpu::createChpuUrl(CONF_SCRIPT_URL . 'index.php?do=news&action=archive'));
$arrNamePage[] = array('name' => $year, 'link' => false);
//смещение, всегда 0 (затем берется из $_GET)
$offset = !empty($_GET['offset']) && validate::checkNaturalNumber($_GET['offset']) ? validate::checkNaturalNumber($_GET['offset']) : 0;
//получаем массив, содержащий текущий обработанный URL
$path = CONF_SCRIPT_URL . 'index.php?do=news&action=archive&year=' . $year . '&page=offset&';
$strWhere = "token IN ('archived') AND YEAR(`datetime`)=" . secure::escQuoteData($year);
$arrOrderBy = array('datetime' => 'DESC');
$arrLimit = array('strLimit' => $offset . ',' . CONF_NEWS_PERPAGE, 'calcRows' => true);
$arrNews = $news->getNewses($strWhere, $arrOrderBy, $arrLimit, false);
// формируем страницы
// получаем общее количество новостей
$allRecords = $news->cntNews();
// формируем странциы
$strPages = strings::generatePage($allRecords, $offset, CONF_NEWS_PERPAGE, $path);
//передаем в шаблон строку сформированных страниц
$smarty->assignByRef('string_page', $strPages);
// массив всех новостей
$smarty->assignByRef('news', $arrNews);
// для блока боковой части
$currMonth = terms::currentDateTime('n');
$smarty->assignByRef('currMonth', $currMonth);
示例8: IN
if (!empty($_POST['action'])) {
// удаление
if ('delete' === $_POST['action'] && !empty($_SESSION['sd_' . DB_PREFIX . 'codex']['rights']['del_articles']) && !empty($_POST['articles'])) {
$strWhere = "id_user IN (" . secure::escQuoteData($arrUser['id']) . ")";
!$articles->deleteArticles(array_keys($_POST['articles']), $strWhere) ? $arrErrors[] = db::$message_error : messages::messageChangeSaved(MESSAGE_CHANGE_SAVED, false, chpu::createChpuUrl(CONF_SCRIPT_URL . 'index.php?ut=' . $_SESSION['sd_user'][DB_PREFIX . 'conf']['user_type'] . '&do=user.articles&action=active'));
}
// архивация
if ('archive' === $_POST['action'] && !empty($_SESSION['sd_' . DB_PREFIX . 'codex']['rights']['arc_articles']) && !empty($_POST['articles'])) {
$arrData = array('token' => 'archived');
$strWhere = "id_user IN (" . secure::escQuoteData($arrUser['id']) . ")";
!$articles->updateArticles($arrData, array_keys($_POST['articles']), $strWhere) ? $arrErrors[] = db::$message_error : messages::messageChangeSaved(MESSAGE_CHANGE_SAVED, false, chpu::createChpuUrl(CONF_SCRIPT_URL . 'index.php?ut=' . $_SESSION['sd_user'][DB_PREFIX . 'conf']['user_type'] . '&do=user.articles&action=active'));
}
}
// инициируем "Наименование страницы" отображаемое в заголовке формы
$arrNamePage[] = array('name' => constant('MENU_ACTION_ACTIVE'), 'link' => false);
$strWhere = "id_user IN (" . secure::escQuoteData($arrUser['id']) . ") AND token IN ('active')";
if ($arrArticles = $articles->getArticles($strWhere, false, false, false)) {
// если есть статьи, устанавливаем признак публикации
foreach ($arrArticles as $key => &$value) {
$value['link'] = strtotime($value['datetime']) > time() ? false : true;
$arrArticles[$key] = $value;
}
}
$smarty->assignByRef('arrArticles', $arrArticles);
} else {
messages::error404();
}
$smarty->assignByRef('retFields', $retFields);
$smarty->assignByRef('arrUser', $arrUser);
$smarty->assignByRef('errors', $arrErrors);
$smarty->assignByRef('warnings', $arrWarnings);
示例9: pDeleteSections
/**
* protected функция помечает разделы и сатьи этих разделов как удаленные
*
* @param (array) $arrSections - массив, содержащий id разделов для удаления
*
* @return bool
*/
protected function pDeleteSections(&$arrSections)
{
// помечаем статьи разделов как удаленные
foreach ($arrSections as &$value) {
$articles = new articles();
$articles->deleteArticlesBySection($value);
}
$strWhere = 'id IN (' . implode(',', secure::escQuoteData($arrSections)) . ')';
caching::clearCache($this->retTableName());
return $this->delEntrys($strWhere);
}
示例10: md5
$new_password = md5($_POST['new_password']);
if (md5($_POST['password']) !== $_SESSION['sd_user']['data']['password']) {
$arrErrors[] = ERROR_PASSWORD;
}
if (strlen($_POST['new_password']) < CONF_REGISTER_USER_PASSWORD) {
$arrErrors[] = ERROR_PASSWORD_SHORT;
}
if (md5($_POST['password']) === md5($_POST['new_password'])) {
$arrErrors[] = ERROR_PASSWORD_NOT_NEW_PASSWORD;
}
if ($_POST['new_password'] !== $_POST['confirm_password']) {
$arrErrors[] = ERROR_PASSWORD_NOT_CONFIRM_PASSWORD;
}
} else {
$arrErrors[] = ERROR_EMPTY_FIELDS;
}
if (!$arrErrors) {
$user->updateUser(array('password' => md5($_POST['new_password'])), "id IN (" . secure::escQuoteData($_SESSION['sd_user']['data']['id']) . ")");
// обновляем пароль в сессии
tools::updateSessionData($_SESSION['sd_user']['data'], array('password' => md5($_POST['new_password'])));
messages::messageChangeSaved(MESSAGE_PASSWORD_HAS_BEEEN_CHANGED, false, chpu::createChpuUrl(CONF_SCRIPT_URL . 'index.php?ut=' . $_SESSION['sd_user'][DB_PREFIX . 'conf']['user_type'] . '&do=user.data'));
} else {
$smarty->assignByRef('errors', $arrErrors);
}
}
} else {
messages::error404();
}
} else {
messages::error404();
}
示例11: array_merge
$arrUser = array_merge($_SESSION['sd_user']['data'], $_SESSION['sd_user'][DB_PREFIX . 'conf']);
// объединяем данные пользователя
/**
* Действия
*/
if (isset($_GET['action'])) {
/**
* Редактирование личных данных
*/
if ('edit' === $_GET['action']) {
/**
* Сохранение личных данных пользователя
*/
if (isset($_POST['save'])) {
if (!empty($_POST['alias'])) {
if ($user->issetUser("id NOT IN (" . secure::escQuoteData($_SESSION['sd_user']['data']['id']) . ") AND alias IN (" . secure::escQuoteData($_POST['alias']) . ") AND token IN ('active','archived','moderate','new')")) {
$arrErrors[] = ERROR_USER_ALIAS_EXISTS;
}
} else {
$arrErrors[] = ERROR_EMPTY_BIND_FIELDS;
}
// массив основных данных пользователя
$arrData = array('alias' => $_POST['alias'], 'middle_name' => !empty($_POST['middle_name']) ? $_POST['middle_name'] : '');
// Разрешаем пользователю изменять имя и фамилиию только если включена соотв. настройка
if (CONF_USER_CHANGE_NAME) {
if (!empty($_POST['first_name']) && !empty($_POST['last_name'])) {
$arrData['first_name'] = $_POST['first_name'];
$arrData['last_name'] = $_POST['last_name'];
} else {
$arrErrors[] = ERROR_EMPTY_NAME_OR_SURNAME;
}
示例12: Group
JobExpert v1.0
powered by Script Developers Group (SD-Group)
email: info@sd-group.org.ua
url: http://sd-group.org.ua/
Copyright 2010-2015 (c) SD-Group
All rights reserved
=========================================================
Дополнительные страницы
********************************************************/
/**
* @package
* @todo
*/
!defined('SDG') ? die('Triple protection!') : null;
if (!empty($_GET['action']) && 'view' === $_GET['action'] && !empty($_GET['id'])) {
$strWhere = "id IN (" . secure::escQuoteData($_GET['id']) . ") AND token IN ('active')";
$fields = array('title', 'text', 'meta_keywords', 'meta_description');
if ($arrData = $pages->getPage($strWhere, $fields)) {
$arrNamePage[] = array('name' => $arrData['title'], 'link' => false);
$smarty->assignByRef('menu', $_GET['id']);
// выбранный пункт меню
// HEAD страницы
$smarty->assignByRef('meta_keywords', $arrData['meta_keywords']);
$smarty->assignByRef('meta_description', $arrData['meta_description']);
$smarty->assignByRef('arrPage', $arrData);
// параметры выбранной страницы
} else {
messages::error404();
}
} else {
messages::error404();
示例13: actionRegions
/**
* public функция выполняет действия над группой регионов
*
* @param string $action
* @param array $arrFields
*
* @return bool
*/
public function actionRegions($action, $arrFields, $silentMode = false)
{
if ('edit' === $action || 'sort' === $action || 'del' === $action || 'setRegionMajor' === $action || 'resetRegionMajor' === $action || 'setAddCityAllowed' === $action || 'resetAddCityAllowed' === $action) {
if ('del' === $action) {
global $citys;
$citys->delCategorys('parent_id IN (' . implode(',', secure::escQuoteData($arrFields)) . ')');
}
if (!$this->actionCategorys($action, $arrFields)) {
if ($silentMode) {
return false;
} else {
messages::messageChangeSaved(ERROR_NOT_SAVE_CHANGE, false, CONF_ADMIN_FILE . '?m=dictionary&s=regions');
}
} else {
if ($silentMode) {
return true;
} else {
messages::messageChangeSaved(MESSAGE_CHANGE_SAVED, false, CONF_ADMIN_FILE . '?m=dictionary&s=regions');
}
}
} else {
if ($silentMode) {
return false;
} else {
messages::messageChangeSaved(MESSAGE_WARNING_UNKNOWN_ACTION, false, CONF_ADMIN_FILE . '?m=dictionary&s=regions');
}
}
}
示例14: secure
<?php
$secure = new secure();
$payflow = new payflow();
$module_name = $args[2];
$module_id = $args[3];
$selected_option = $args[0];
$chart_assign_id = $args[1];
$result = $this->db->query("SELECT * FROM payments WHERE chart_assign_id = '{$chart_assign_id}'");
$tmp1 = $this->db->fetch_assoc($this->db->query("SELECT grant_total FROM erp_order WHERE order_id = {$module_id}"));
$full_amount = $tmp1["grant_total"];
$bill_amount = $full_amount / 2;
$total_arr = $this->db->fetch_assoc($this->db->query("SELECT SUM( amount ) total FROM `payments` WHERE for_module_name = 'order' AND for_module_id = '{$module_id}' AND refund='no'"));
$already_payed = $total_arr["total"];
// $return["javascript"] = "alert('ba: $bill_amount|ap: $already_payed');";
//$return["javascript"] = "alert('" . $this->db->num_rows($result) . "| $already_payed | $bill_amount" . "');";
if ($this->db->num_rows($result) == 0 && $already_payed < $bill_amount) {
$return["stop"] = "YES";
$bill = $bill_amount - $already_payed;
$contacts = $this->get_contact_by_module($module_id, $module_name);
$credit_cards = $secure->get_creditcards("contacts", $contacts[0]);
$tmp1 = $this->db->fetch_assoc($this->db->query("SELECT ccid FROM erp_order WHERE order_id = {$module_id}"));
$ccid = $tmp1["ccid"];
if (array_key_exists($ccid, $credit_cards) == false && $ccid != '0') {
$cc2 = $secure->get_creditcard($ccid);
$credit_cards[$ccid] = $cc2[$ccid];
}
$ccoptions = '<option value="">--SELECT ONE--</option>';
foreach ($credit_cards as $num => $card) {
if ($num = $ccid) {
$select = " SELECTED ";
示例15: actionCategorys
/**
* protected функция выполняет действия над группой строк в таблице БД
*
* @param string $action
* @param array $arrFields
*
* @return bool
*/
protected function actionCategorys($action, $arrFields, $silentMode = false)
{
switch ($action) {
case 'edit':
foreach ($arrFields as $key => $value) {
$arrData = isset($value['arrNoBindFields']) ? $value['arrBindFields'] + $value['arrNoBindFields'] : $value['arrBindFields'];
$result = $this->editEntrys(secure::escQuoteData($arrData), "id IN (" . secure::escQuoteData($key) . ")");
}
break;
case 'sort':
foreach ($arrFields as $key => $value) {
$arrSort[$value][] = $key;
}
foreach ($arrSort as $key => $value) {
$result = $this->editEntrys(array('sort' => "'{$key}'"), "id IN (" . implode(',', secure::escQuoteData($value)) . ")");
}
break;
case 'del':
$table = $this->retTableName();
$strFields = implode(',', secure::escQuoteData($arrFields));
$vacancy = new vacancy();
$result = $vacancy->delAnnounces('id_' . $table . ' IN (' . $strFields . ')');
$resume = new resume();
$result = $resume->delAnnounces('id_' . $table . ' IN (' . $strFields . ')');
$subscription = new subscription();
$strWhere = 'profession' !== $table ? 'id_' . $table . ' IN (' . $strFields . ')' : 'id_' . $table . ' IN (' . $strFields . ') OR id_' . $table . '_1 IN (' . $strFields . ') OR id_' . $table . '_2 IN (' . $strFields . ')';
$result = $subscription->delSubscriptions($strWhere);
$result = $this->delCategorys('id IN (' . $strFields . ')');
break;
case 'setcapital':
$result = $this->editEntrys(array('capital' => "'on'"), "id IN (" . implode(',', secure::escQuoteData($arrFields)) . ") AND capital IN ('0')");
break;
case 'resetcapital':
$result = $this->editEntrys(array('capital' => "'0'"), "parent_id IN (" . implode(',', secure::escQuoteData($arrFields)) . ") AND capital IN ('on')");
break;
case 'setRegionMajor':
$result = $this->editEntrys(array('major' => "'on'"), "id IN (" . implode(',', secure::escQuoteData($arrFields)) . ") AND major IN ('0')");
break;
case 'resetRegionMajor':
$result = $this->editEntrys(array('major' => "'0'"), "id IN (" . implode(',', secure::escQuoteData($arrFields)) . ") AND major IN ('on')");
break;
case 'setAddCityAllowed':
$result = $this->editEntrys(array('add_city_allowed' => "'on'"), "id IN (" . implode(',', secure::escQuoteData($arrFields)) . ") AND add_city_allowed IN ('0')");
break;
case 'resetAddCityAllowed':
$result = $this->editEntrys(array('add_city_allowed' => "'0'"), "id IN (" . implode(',', secure::escQuoteData($arrFields)) . ") AND add_city_allowed IN ('on')");
break;
default:
if ($silentMode) {
$result = false;
} else {
messages::messageChangeSaved(MESSAGE_WARNING_UNKNOWN_ACTION, false, CONF_ADMIN_FILE);
}
}
return $result;
}