本文整理汇总了PHP中CSession类的典型用法代码示例。如果您正苦于以下问题:PHP CSession类的具体用法?PHP CSession怎么用?PHP CSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CSession类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: logout
/**
* Log-out the current user.
*/
public static function logout()
{
self::$data['sessionid'] = self::getSessionCookie();
self::$data = API::User()->logout([]);
CSession::destroy();
zbx_unsetcookie('zbx_sessionid');
}
示例2: actionAdd
public function actionAdd()
{
$biography = new CBiography();
$biography->user_id = CSession::getCurrentUser()->getId();
$this->setData("biography", $biography);
$this->renderView("_biography/add.tpl");
}
示例3: actionSave
public function actionSave()
{
$quest = new CQuestion();
$quest->setAttributes(CRequest::getArray($quest::getClassName()));
if ($quest->validate()) {
if (!CSession::isAuth()) {
$user = "";
} else {
$user = CStaffManager::getUser(CSession::getCurrentUser()->getId())->getName();
}
$quest->contact_info .= " " . $user . '; ip ' . $_SERVER["REMOTE_ADDR"];
if ($quest->answer_text != '') {
$quest->datetime_answ = date("Y-d-m H:i:s", time());
}
$quest->save();
if ($this->continueEdit()) {
$this->redirect("?action=edit&id=" . $quest->getId());
} else {
$this->redirect(WEB_ROOT);
}
return true;
}
$this->setData("quest", $quest);
$this->renderView("__public/_question_add/edit.tpl");
}
示例4: isSessionIDValid
function isSessionIDValid($config, $xsid)
{
$bValid = false;
//Instantiate the CR3DCQuery Class
$oR3DCQuery = new CR3DCQuery($config);
//$oR3DCQuery->CheckSIDTimeout();
CSession::initialise($config);
CSession::CheckSIDTimeout();
if ($xsid != "") {
//if($oR3DCQuery->CheckLogin($config, $xsid))
if (CSession::CheckLogin($xsid)) {
$session = base64_decode($xsid);
// list($uniq, $player_id) = preg_split("/\|/", $session);
list($uniq, $player_id) = explode("|", $session);
if ($uniq != "" && is_numeric($player_id)) {
$bValid = true;
//$oR3DCQuery->UpdateSIDTimeout($config, $xsid);
CSession::UpdateSIDTimeout($xsid);
$oR3DCQuery->SetPlayerCreditsInit($player_id);
}
}
}
if ($oR3DCQuery->ELOIsActive()) {
$oR3DCQuery->ELOCreateRatings();
}
$oR3DCQuery->MangeGameTimeOuts();
$oR3DCQuery->Close();
unset($oR3DCQuery);
return $bValid;
}
示例5: checkRight
/**
* 是否有权限
*/
public static function checkRight($thisRoute = null)
{
// 用户资源
$userData = CSession::get('user');
if ($userData['groupId'] == 1) {
return true;
}
$userRightList = isset($userData['rightAll']) ? $userData['rightAll'] : array();
// 附加公共资源
array_push($userRightList, 'system@welcome');
array_push($userRightList, 'system@navList');
array_push($userRightList, 'system@addNav');
array_push($userRightList, 'system@addNavHandle');
array_push($userRightList, 'system@ajaxAddNav');
array_push($userRightList, 'system@editNav');
array_push($userRightList, 'system@editNavHandle');
array_push($userRightList, 'system@delNav');
array_push($userRightList, 'system@changeMyPassword');
array_push($userRightList, 'system@changeMyPassHandle');
array_push($userRightList, 'adminRole@messageCenterForClient');
array_push($userRightList, 'system@seeHelp');
// 转小写
foreach ($userRightList as $key => $val) {
$userRightList[$key] = strtolower($val);
}
// 获取当前请求的路由
if ($thisRoute == null) {
$route = CRequest::getController() . '@' . str_replace(CConfig::getInstance()->load('ACTION_PREFIX'), '', CRequest::getAction());
} else {
$route = $thisRoute;
}
return in_array(strtolower($route), $userRightList);
}
示例6: doAction
protected function doAction()
{
$data = ['theme' => getUserTheme(CWebUser::$data), 'messages' => []];
if (CSession::keyExists('messages')) {
$data['messages'] = CSession::getValue('messages');
CSession::unsetValue(['messages']);
}
$this->setResponse(new CControllerResponseData($data));
}
示例7: __construct
public function __construct()
{
if (!CSession::isAuth()) {
$this->redirectNoAccess();
}
$this->_smartyEnabled = true;
$this->setPageTitle("Управление моделями данных");
parent::__construct();
}
示例8: TemplateValues
public function TemplateValues()
{
$sFootError = '';
if (CSession::Has('wm_install_pass_error')) {
$sFootError = CSession::Get('wm_install_pass_error', '');
CSession::Clear('wm_install_pass_error');
}
return array('Login' => $this->oSettings->GetConf('Common/AdminLogin'), 'Password1' => '', 'Password2' => '', 'FootError' => $sFootError);
}
示例9: __construct
public function __construct()
{
if (!CSession::isAuth()) {
//$this->redirectNoAccess();
}
$this->_smartyEnabled = true;
$this->setPageTitle("Личные настройки");
parent::__construct();
}
示例10: __construct
public function __construct()
{
if (!CSession::isAuth()) {
if (!in_array(CRequest::getString("action"), $this->allowedAnonymous)) {
$this->redirectNoAccess();
}
}
$this->_smartyEnabled = true;
$this->setPageTitle("Управление таблицами доступа");
parent::__construct();
}
示例11: actionIndex
public function actionIndex()
{
$parent = 0;
$title = "Нормативные документы";
if (CRequest::getInt("parent")) {
$parent = CRequest::getInt("parent");
$parentFolder = CDocumentsManager::getFolder($parent);
if (!is_null($parentFolder)) {
$title = $parentFolder->title;
}
}
// извлекаем все папки с учетом иерархии
$query = new CQuery();
$query->select("f.*")->from(TABLE_DOCUMENT_FOLDERS . " as f")->condition("f.parent_id = " . $parent)->order("f.title asc");
$objects = new CArrayList();
foreach ($query->execute()->getItems() as $ar) {
$folder = new CDocumentFolder(new CActiveRecord($ar));
$objects->add($objects->getCount(), $folder);
}
// теперь извлекаем все файлы
$query = new CQuery();
$query->select("f.*")->from(TABLE_DOCUMENTS . " as f")->condition("f.folder_id = " . $parent . " and f.nameFolder like 'gost%'")->order("f.browserFile asc");
foreach ($query->execute()->getItems() as $ar) {
$file = new CDocumentFile(new CDocumentActiveRecord($ar));
$objects->add($objects->getCount(), $file);
}
$this->setData("title", $title);
$this->setData("objects", $objects);
/**
* Генерация меню
*/
// если есть родительская папка, то переходим в нее
if ($parent != 0) {
$parentFolder = CDocumentsManager::getFolder($parent);
if (!is_null($parentFolder)) {
$this->addActionsMenuItem(array("title" => "Назад", "link" => "index.php?action=index&parent=" . $parentFolder->parent_id, "icon" => "actions/edit-undo.png"));
}
}
// если пользователь может чего-нибудь добавлять, то пусть добавит
$this->setData("canEdit", false);
if (CSession::isAuth()) {
if (CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_WRITE_ALL || CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_WRITE_OWN_ONLY) {
$this->addActionsMenuItem(array("title" => "Создать папку", "link" => "index.php?action=add&parent=" . $parent, "icon" => "actions/folder-new.png"));
$this->addActionsMenuItem(array("title" => "Загрузить файл", "link" => "files.php?action=add&parent=" . $parent, "icon" => "actions/bookmark-new.png"));
$this->setData("canEdit", true);
}
}
/**
* Отображение представления
*/
$this->addCSSInclude("_modules/_documents/style.css");
$this->renderView("_documents/_folder/index.tpl");
}
示例12: __construct
public function __construct()
{
if (!CSession::isAuth()) {
if (!in_array(CRequest::getString("action"), $this->allowedAnonymous)) {
$this->redirectNoAccess();
}
}
$this->_smartyEnabled = true;
$this->setPageTitle("Учебные группы студентов");
$this->_useDojo = true;
parent::__construct();
}
示例13: getLevelForCurrentTask
/**
* Уровень доступа к текущей задаче
*
* @return int
*/
public function getLevelForCurrentTask()
{
$level = ACCESS_LEVEL_NO_ACCESS;
$task = CSession::getCurrentTask();
if (!is_null($task)) {
if ($this->getRoles()->hasElement($task->getId())) {
$personTask = $this->getRoles()->getItem($task->getId());
$level = $personTask->level;
}
}
return $level;
}
示例14: onCreate
public function onCreate(CModel $model)
{
$result = false;
if (CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_WRITE_ALL) {
/**
* Пользователь может создавать что-нибудь только если у него уровень
* Чтение и запись всех записей.
*/
$result = true;
}
return $result;
}
示例15: actionAdd
public function actionAdd()
{
$newsItem = new CNewsItem();
$newsItem->user_id_insert = CSession::getCurrentUser()->getId();
$newsItem->date_time = date("d.m.Y");
$newsItem->news_type = "notice";
$this->addJSInclude(JQUERY_UI_JS_PATH);
$this->addCSSInclude(JQUERY_UI_CSS_PATH);
$this->addCSSInclude("_modules/_redactor/redactor.css");
$this->addJSInclude("_modules/_redactor/redactor.min.js");
$this->setData("newsItem", $newsItem);
$this->renderView("_news/add.tpl");
}