public static function is_exists($name, $value = false) { if ($value === false) { if (isset($_COOKIE[$name])) { return true; } return false; } return cookies::is_equals($name, $value); }
protected function setLangDict(&$lang) { if ($this->currLang !== $lang) { !empty($lang) && in_array($lang, $this->arrLangs) ? $this->currLang =& $lang : ($this->currLang = CONF_LANGUAGE); } cookies::setCookieSite('langDictSelects', $this->currLang, 30); file_exists('lang/' . $this->currLang . '/lang.dictionarys.selects.php') ? include 'lang/' . $this->currLang . '/lang.dictionarys.selects.php' : messages::printDie(ERROR_FILE_NOT_OPEN); $this->arrSysDict =& $arrSysDict; $this->arrAddDict =& $arrAddDict; return true; }
/** * protected функция оцнеки статьи * * @param int $score - оценка статьи * @param int $id - id статьи * * @return echo (печатает результат) */ protected function pRateArticle(&$score, &$id) { // проверяем наличие id статьи в куках пользователя // если $flag = true, значит пользователь уже голосовал за статью isset($_COOKIE['artvote']) && $_COOKIE['artvote'] ? !in_array($id, explode(':', $_COOKIE['artvote'])) ? $flag = false : ($flag = true) : ($flag = false); if (!$flag) { if ($arrData = $this->pGetArticle("id IN (" . secure::escQuoteData($id) . ") AND token IN ('active')")) { // проверяем, голосовал ли пользователь за эту статью if ($_SERVER['REMOTE_ADDR'] !== $arrData['ip_last']) { // вычисляем рейтинг с учетом всех голосов // считаем балл, и доавляем его к рейтингу $fullRating = $arrData['rating'] * $arrData['votes'] + $score * 20; // увеличиваем количество голосов $votes = !$arrData['votes'] ? 1 : $arrData['votes'] + 1; // высчитываем новый средний рейтинг $rating = $fullRating / $votes; $this->pUpdateArticles(array('rating' => $rating, 'votes' => $votes, 'ip_last' => $_SERVER['REMOTE_ADDR']), array($id)); // устанавливаем куку isset($_COOKIE['artvote']) && $_COOKIE['artvote'] ? cookies::setCookieSite('artvote', $_COOKIE['artvote'] . ':' . $id) : cookies::setCookieSite('artvote', $id); // выводим результат $result = '<div class="rate">' . '<div class="rating">' . FORM_ARTICLES_RATING . ': ' . $rating . '</div>' . '<div class="base" style="height:16px;"><div class="average" style="width: ' . $rating . '%;"> </div></div>' . '<div class="votes">' . $votes . ' ' . FORM_ARTICLES_VOTES . '</div>' . '</div>' . '<div class="status">' . '</div>'; print $result; } else { print ERROR_ONLY_ONE_VOTING_ARTICLE; } } else { print ERROR_SELECTED_ARTICLE; } } else { print ERROR_ONLY_ONE_VOTING_ARTICLE; } }
public function logout() { $this->_db->delete('user_session', array('user_id', '=', $this->data()->id)); Session::delete($this->_sessionName); cookies::delete($this->_cookieName); }
public static function sidebar() { template_html::dimmer(); template_html::registration(); template_html::authorization(); template_html::access_violation(); ?> <div id="sidebar"> <div class="ui vertical menu square-corners"> <div class="item header" onclick="rude.animate('#navigation'); rude.cookie.toggle('hide_navigation')"> Навигация </div> <div id="navigation" <?php if (cookies::is_equals('hide_navigation', 1)) { ?> style="display: none;"<?php } ?> > <a class="item subcategory" href="/"> <i class="icon home"></i> Вернуться на главную </a> <?php if (!template_session::is_authorized()) { ?> <a class="item subcategory" href="#" onclick="$('#authorization').modal('show'); return false;"> <i class="icon sign in"></i> Авторизация </a> <?php } ?> <?php if (!template_session::is_authorized()) { ?> <a class="item subcategory" href="#" onclick="$('#registration').modal('show'); return false;"> <i class="icon edit"></i> Регистрация </a> <?php } ?> <?php if (template_session::is_authorized()) { ?> <a class="item subcategory" href="#" onclick="$.post('/?page=logout', function() { rude.redirect('/'); }); return false;"> <i class="icon sign out"></i> Выход </a> <?php } ?> </div> <?php if (template_session::is_authorized()) { ?> <div class="item header" onclick="rude.animate('#management'); rude.cookie.toggle('hide_management')"> Управление </div> <div id="management" <?php if (cookies::is_equals('hide_management', 1)) { ?> style="display: none;"<?php } ?> > <a class="item subcategory <?php if (get('page') == 'departments') { ?> active<?php } ?> " href="/?page=departments"> <i class="icon"></i> Кафедры </a> <a class="item subcategory <?php if (get('page') == 'faculties') { ?> active<?php } ?> " href="/?page=faculties"> <i class="icon"></i> Факультеты </a> <a class="item subcategory <?php if (get('page') == 'qualifications') { ?> active<?php } ?> " href="/?page=qualifications"> <i class="icon"></i> Квалификации </a> <a class="item subcategory <?php if (get('page') == 'specializations') { ?> active<?php } ?> " href="/?page=specializations"> <i class="icon"></i> Специализации </a> <a class="item subcategory <?php if (get('page') == 'specialties') { ?> active<?php } ?> " href="/?page=specialties"> <i class="icon"></i> Специальности </a> <a class="item subcategory <?php if (get('page') == 'users') { ?> active<?php } ?> " href="/?page=users"> <i class="icon"></i> Пользователи </a> <a class="item subcategory <?php if (get('page') == 'calendar_legend') { ?> active<?php } ?> " href="/?page=calendar_legend"> <i class="icon"></i> Условные обозначения </a> <a class="item subcategory <?php if (get('page') == 'directions') { ?> active<?php } ?> " href="/?page=directions"> <i class="icon"></i> Направления </a> <a class="item subcategory <?php if (get('page') == 'settings') { ?> active<?php } ?> " href="/?page=settings"> <i class="icon"></i> Настройки </a> <a class="item subcategory <?php if (get('page') == 'stats') { ?> active<?php } ?> " href="/?page=stats"> <i class="icon"></i> База данных </a> </div> <div class="item header" onclick="rude.animate('#reports'); rude.cookie.toggle('hide_reports')"> Учебные планы </div> <div id="reports" <?php if (cookies::is_equals('hide_reports', 1)) { ?> style="display: none;"<?php } ?> > <a class="item subcategory <?php if (get('page') == 'reports') { ?> active<?php } ?> " href="/?page=reports"> <i class="icon"></i> Все планы </a> <a class="item subcategory <?php if (get('page') == 'reports-edit') { ?> active<?php } ?> " href="/?page=reports-edit"> <i class="icon"></i> Добавить новый </a> </div> <?php } ?> </div> </div> <?php }
$mdp_post = filter_input(INPUT_POST, "motdepasse", FILTER_SANITIZE_STRING); //Gestion des données du formulaire. if (filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL) && !empty($mdp_post)) { //Requête SQL. $sql_connexion_prepare = "SELECT `id_participant`,COUNT(*) FROM `" . PREFIXE . "participants` WHERE `email_participant` = :email AND `motdepasse` = :mdp ;"; $resultat_connexion = $dbh->prepare($sql_connexion_prepare); $resultat_connexion->execute(array(':email' => $email_post, ':mdp' => $mdp_post)); //On vérifie le nombre de résultat. $compte = count($resultat_connexion); //Action si le résultat est validé. if ($compte == 1) { $donnees = $resultat_connexion->fetchAll(); $_SESSION["compte"]["id_participant"] = $donnees['0']['id_participant']; //Inclusion du fichier contenant la classe pour les cookies. require_once './modules/cookies/cookies.php'; $cookies = new cookies(); //Mise à jour du token pour le cookie. $cookie_update = $cookies->update_cookie($_SESSION["compte"]["id_participant"], $dbh); //On crée une cookie permettant de se connecter. Il est valable 30 jours. $cookie_create = $cookies->create_cookie($_SESSION["compte"]["id_participant"], $dbh); $login = $deconnexion; header($redirection); } else { $login = $form; $login .= $erreur_connexion; } } else { //Les données ne sont pas valides. $login = $form; $login .= $erreur_connexion; }
/** * @package * @todo */ !defined('SDG') ? die('Triple protection!') : null; // инициируем "Наименование страницы" отображаемое в форме $arrNamePage = array(array('name' => MENU_ADMIN_MAIN, 'link' => CONF_ADMIN_FILE), array('name' => MENU_SERVICE, 'link' => false), array('name' => MENU_MANAGER_TEMPLATES_SITE, 'link' => false)); if (!empty($_POST['currTemplate']) && is_dir('templates/site/' . $_POST['currTemplate'])) { $currTemplate =& $_POST['currTemplate']; } elseif (!empty($_COOKIE['adm_currTmplManage']) && is_dir('templates/site/' . $_COOKIE['adm_currTmplManage'])) { $currTemplate =& $_COOKIE['adm_currTmplManage']; } else { $currTemplate = CONF_TEMPLATE; } // устанавливаем кукисы cookies::setCookieSite('adm_currTmplManage', $currTemplate); // передаем текуший шаблон в Smarty $smarty->assignByRef('currTemplate', $currTemplate); // текущий шаблон // формируем данные - Список файлов шаблона foreach (filesys::getFilesInDir("templates/site/{$currTemplate}/") as $fileName) { if (false !== strstr($fileName, '.tpl')) { // записываем данные в массив $listTemplates[] = array('name' => $fileName, 'id' => $id = str_replace('.', '_', $fileName)); } } // формируем данные - Список файлов стилей foreach (filesys::getFilesInDir("templates/site/{$currTemplate}/style/") as $fileName) { if (false !== strstr($fileName, '.css')) { // записываем данные в массив $listCSS[] = array('name' => $fileName, 'id' => $id = str_replace('.', '_', $fileName));
public function admLogout() { $this->_db->delete('adm_user_session', ['user_id', '=', $this->data()->id]); Session::delete('adm_' . $this->_sessionName); cookies::delete('adm_' . $this->_cookieName); }
// проверяем, есть ли в кукисах наши параметры $arrData = $user->getUser("id IN (" . secure::escQuoteData((int) $_COOKIE['remid']) . ")"); // если пользователь с таким id найден, сверяем хеш if (!empty($arrData)) { // выполняем вход if ($_COOKIE['remh'] === $user->cookieUserHash($arrData)) { $user->authorizeUser($arrData['email'], $arrData['password'], false, true); die('<script type="text/javascript">window.location="' . chpu::createChpuUrl(CONF_SCRIPT_URL . 'index.php?ut=' . $_SESSION['sd_user'][DB_PREFIX . 'conf']['user_type']) . '";</script>'); } else { cookies::deleteAccessCookie(); } } else { cookies::deleteAccessCookie(); } } else { cookies::deleteAccessCookie(); } if (!isset($_SESSION['sd_' . DB_PREFIX . 'codex'])) { // записываем в сессию права пользователя $_SESSION['sd_' . DB_PREFIX . 'codex'] = $group->setUserRights('guest', 'guest'); } // определяем тип пользователя, по умолчанию $_SESSION['sd_user'][DB_PREFIX . 'conf']['user_type'] = !isset($_GET['ut']) ? 'competitor' : ('competitor' !== $_GET['ut'] && 'employer' !== $_GET['ut'] ? 'competitor' : $_GET['ut']); $smarty->assign('user_email', false); $smarty->assign('user_type', $_SESSION['sd_user'][DB_PREFIX . 'conf']['user_type']); $smarty->assign('codex', $_SESSION['sd_' . DB_PREFIX . 'codex']); // значения, возвращаемые в форму } /** * обработка страниц */
<?php /* * Ce fichier est utilisé pour couper une session. */ //Début de la session. session_start(); //Inclusion du fichier pour la connexion à la base de données. include_once '../bdd/connect.php'; //On détruit le cookie. unset($cookie_token); require_once '../cookies/cookies.php'; $cookies = new cookies(); //On met à jour le token de connexion. $cookie_update = $cookies->update_cookie($_SESSION["compte"]["id_participant"], $dbh); //On crée un cookie "antidaté" $destroy_cookie = $cookies->destroy_cookie($_SESSION["compte"]["id_participant"]); //On détruit toutes les variables de session. session_unset(); //On détruit la session. session_destroy(); //Redirection vers la page d'accueil. header("Location:../../index.php"); //Texte à afficher en cas de dysfonctionnement. echo $LANG_texte_deconnexion;
} /** * Очистка данных полученных извне PHP */ secure::clearRequestData(); /** * Определение текущей локализации */ if (!empty($_COOKIE['currLang']) && false !== ($currLang = array_search($_COOKIE['currLang'], $existLangs))) { unset($existLangs[$currLang]); array_unshift($existLangs, $currLang =& $_COOKIE['currLang']); cookies::setCookieSite('currLang', $currLang, 30); } else { unset($existLangs[array_search(CONF_LANGUAGE, $existLangs)]); array_unshift($existLangs, $currLang = CONF_LANGUAGE); cookies::setCookieSite('currLang', $currLang, 30); } /** * Подключения языковых файлов текущей локализации */ foreach (filesys::getFilesInDir('lang/' . $currLang . '/') as $fileLang) { 0 !== strpos($fileLang, 'adm.') ? require_once 'lang/' . $currLang . '/' . $fileLang : null; } /** * Капча */ require_once 'core/si/securimage.php'; /** * Моды */ // empty
/** * protected функция очищает куки и сессию текущего пользователя * * @return void */ protected function clearUserSessionAndCookie() { cookies::deleteAccessCookie(); unset($_SESSION['sd_job_codex'], $_SESSION['sd_user']); }