本文整理汇总了PHP中System::getSession方法的典型用法代码示例。如果您正苦于以下问题:PHP System::getSession方法的具体用法?PHP System::getSession怎么用?PHP System::getSession使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System
的用法示例。
在下文中一共展示了System::getSession方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: logout
public function logout()
{
$response = new AjaxResponse();
System::getSession()->logout();
$response->success = true;
$response->send();
}
示例2: loadFile
private function loadFile()
{
if ($this->file != NULL) {
return;
}
$this->file = File::find('alias', $this->getParam('alias', ''));
if ($this->file == NULL) {
System::displayError(System::getLanguage()->_('ErrorFileNotFound'), '404 Not Found');
}
if (System::getUser() != NULL) {
$user_id = System::getUser()->uid;
} else {
$user_id = -1;
}
if ($user_id != $this->file->uid) {
if ($this->file->permission == FilePermissions::PRIVATE_ACCESS) {
System::displayError(System::getLanguage()->_('PermissionDenied'), '403 Forbidden');
exit;
} elseif ($this->file->permission == FilePermissions::RESTRICTED_ACCESS) {
if (is_array(System::getSession()->getData("authenticatedFiles"))) {
if (!in_array($this->file->alias, System::getSession()->getData("authenticatedFiles"))) {
System::forwardToRoute(Router::getInstance()->build('AuthController', 'authenticateFile', $this->file));
exit;
}
} else {
System::forwardToRoute(Router::getInstance()->build('AuthController', 'authenticateFile', $this->file));
exit;
}
}
}
}
示例3: __construct
/**
* Construct
*/
public function __construct()
{
parent::__construct();
$this->JSRMS = new JSRMS();
$this->JSRMS->requireResource('system');
$this->muteExpectedErrors();
$this->setCacheDir(SYSTEM_ROOT . '/classes/smarty/cache/');
$this->setCompileDir(SYSTEM_ROOT . '/classes/smarty/templates_c/');
$this->setTemplateDir(SYSTEM_ROOT . '/view/');
$this->registerObject('Router', Router::getInstance(), array('build'), false);
$this->registerObject('L10N', System::getLanguage(), array('_'), false);
$this->assign('LoggedIn', System::getUser() != NULL);
$this->assign('User', System::getUser());
$this->assign('Navigation', Navigation::$elements);
$this->assign('LangStrings', System::getLanguage()->getAllStrings());
// Configuration
$this->assign('HTTP_BASEDIR', System::getBaseURL());
$this->assign('MOD_REWRITE', MOD_REWRITE);
$this->assign('MAX_UPLOAD_SIZE', Utils::maxUploadSize());
if (System::getSession()->getData('successMsg', '') != '') {
$this->assign('successMsg', System::getSession()->getData('successMsg', ''));
System::getSession()->setData('successMsg', '');
}
if (System::getSession()->getData('errorMsg', '') != '') {
$this->assign('errorMsg', System::getSession()->getData('errorMsg', ''));
System::getSession()->setData('errorMsg', '');
}
if (System::getSession()->getData('infoMsg', '') != '') {
$this->assign('infoMsg', System::getSession()->getData('infoMsg', ''));
System::getSession()->setData('infoMsg', '');
}
}
示例4: index
public function index()
{
$user = System::getUser();
$form = new Form('form-profile');
$form->setAttribute('data-noajax', 'true');
$form->binding = $user;
$fieldset = new Fieldset(System::getLanguage()->_('General'));
$firstname = new Text('firstname', System::getLanguage()->_('Firstname'));
$firstname->binding = new Databinding('firstname');
$lastname = new Text('lastname', System::getLanguage()->_('Lastname'));
$lastname->binding = new Databinding('lastname');
$email = new Text('email', System::getLanguage()->_('EMail'), true);
$email->binding = new Databinding('email');
$email->blacklist = $this->getListOfMailAdresses($user);
$email->error_msg[4] = System::getLanguage()->_('ErrorMailAdressAlreadyExists');
$language = new Radiobox('lang', System::getLanguage()->_('Language'), L10N::getLanguages());
$language->binding = new Databinding('lang');
$fieldset->addElements($firstname, $lastname, $email, $language);
$form->addElements($fieldset);
$fieldset = new Fieldset(System::getLanguage()->_('Password'));
$password = new Password('password', System::getLanguage()->_('Password'));
$password->minlength = PASSWORD_MIN_LENGTH;
$password->binding = new Databinding('password');
$password2 = new Password('password2', System::getLanguage()->_('ReenterPassword'));
$fieldset->addElements($password, $password2);
$form->addElements($fieldset);
$fieldset = new Fieldset(System::getLanguage()->_('Settings'));
$quota = new Text('quota', System::getLanguage()->_('Quota'));
if ($user->quota > 0) {
$quota->value = System::getLanguage()->_('QuotaAvailabe', Utils::formatBytes($user->getFreeSpace()), Utils::formatBytes($user->quota));
} else {
$quota->value = System::getLanguage()->_('Unlimited');
}
$quota->readonly = true;
$fieldset->addElements($quota);
$form->addElements($fieldset);
if (Utils::getPOST('submit', false) !== false) {
if (!empty($password->value) && $password->value != $password2->value) {
$password2->error = System::getLanguage()->_('ErrorInvalidPasswords');
} else {
if ($form->validate()) {
$form->save();
System::getUser()->save();
System::getSession()->setData('successMsg', System::getLanguage()->_('ProfileUpdated'));
System::forwardToRoute(Router::getInstance()->build('ProfileController', 'index'));
exit;
}
}
} else {
$form->fill();
}
$form->setSubmit(new Button(System::getLanguage()->_('Save'), 'floppy-disk'));
$smarty = new Template();
$smarty->assign('title', System::getLanguage()->_('MyProfile'));
$smarty->assign('heading', System::getLanguage()->_('MyProfile'));
$smarty->assign('form', $form->__toString());
$smarty->display('form.tpl');
}
示例5: init
/**
* Initialises the system
* @static
*/
public static function init()
{
self::redirectHTTPS();
Router::getInstance()->init(HOST_PATH, MOD_REWRITE);
self::$database = new Database('mysql:dbname=' . DATABASE_NAME . ';host=' . DATABASE_HOST, DATABASE_USER, DATABASE_PASS);
self::$session = new Session();
self::$user = System::getSession()->getUID() != NULL ? User::find('_id', System::getSession()->getUID()) : NULL;
self::$language = new L10N(System::getUser() != NULL ? System::getUser()->lang : LANGUAGE);
self::buildNavigation();
}
示例6: addComment
public function addComment($topic_id, array $data)
{
$prep = $this->db->prepare('
INSERT INTO forum_messages (message,date,id_createur,id_topic)
VALUES (:message,NOW(),:id_createur,:id_topic)
');
$session = System::getSession();
if ($session->isConnected()) {
$user_id = $_SESSION['userid'];
}
$prep->bindParam(':message', $data['message']);
$prep->bindParam(':id_createur', $user_id);
$prep->bindParam(':id_topic', $topic_id);
if ($prep->execute()) {
return $this->db->lastInsertId('id');
} else {
return false;
}
}
示例7: modif
function modif(array $params)
{
if (isset($params[0])) {
$article_id = intval($params[0]);
// Récupérer l'evenement lié depuis le model
if (!($data = $this->model->getArticle($article_id))) {
return array();
}
// Get creator's name and id
$data['creator'] = $this->model->getCreatorForArticle($data['id']);
//recupere id utilisateur
$session = System::getSession();
if ($session->isConnected()) {
$user_id = $_SESSION['userid'];
}
//recupere infos sur evenements crees par utilisateur
$data['evenements'] = $this->model->getUserEvents($user_id);
return $data;
} else {
return false;
}
}
示例8: contactorganisateur
public function contactorganisateur(array $params)
{
if (isset($params[0])) {
$id_event = intval($params[0]);
$data = $this->model->getEvent($id_event);
} else {
return array('success' => false);
}
$message = Request::get('message');
$sujet = Request::get('subject');
$organisateur = $this->model->getUser($data['id_createur']);
$session = System::getSession();
if ($session->isConnected()) {
$user_id = $_SESSION['userid'];
} else {
return array('data' => $data, 'not_register' => 'Vous n\'êtes pas connecté');
}
$mail_envoyeur = $this->model->getUser($user_id);
$headers = "From: " . strip_tags($mail_envoyeur['email']) . "\r\n";
$headers .= "Reply-To: " . strip_tags($mail_envoyeur['email']) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
if (!empty($message) && !empty($sujet)) {
$html_message = 'Bonjour <strong>' . $organisateur['nickname'] . '</strong>,<br><br>' . "\r\n";
$html_message .= 'Vous avez reçu un message au sujet de votre événement <a href="' . Config::get('config.base') . '/events/detail/' . $data['id'] . '">' . $data['nom'] . '</a> sur <strong>Event-You-All</strong>.<br><br>' . "\r\n";
$html_message .= $message;
mail($organisateur['email'], $sujet, $html_message, $headers);
return array('data' => $data, 'success' => true);
} else {
return array('data' => $data, 'success' => '');
}
}
示例9: hasAccess
/**
* Check whether or not the current user has access to the asked module
*
* @param string $module Module to check
* @return bool True if the user has access, false if not
*/
public function hasAccess($module)
{
$session = System::getSession();
$required_level = $this->getAccessLevel($module);
$user_level = $session->isConnected() ? $_SESSION['access'] : 0;
return $user_level >= $required_level;
}
示例10: createTopic
public function createTopic($id)
{
$data = $this->getEvent($id);
$prep = $this->db->prepare('
INSERT INTO forum_topics (titre,description,date_creation,id_createur)
VALUES (:titre,:description,NOW(),:id_createur)
');
$session = System::getSession();
if ($session->isConnected()) {
$user_id = $_SESSION['userid'];
}
$title = '[Evénement] ' . $data['nom'];
$descri = $data['description'] . '<p><a href="' . Config::get('config.base') . '/events/detail/' . $data['id'] . '">Voir la page de l\'événement</a></p>';
$prep->bindParam(':titre', $title);
$prep->bindParam(':description', $descri);
$prep->bindParam(':id_createur', $user_id);
if ($prep->execute()) {
return $this->db->lastInsertId('id');
} else {
return false;
}
}
示例11: lostpw_check
public function lostpw_check()
{
$hash = $this->getParam('hash', '');
if (!LostPW::hashExists($hash)) {
System::getSession()->setData('errorMsg', System::getLanguage()->_('HashNotFound'));
System::forwardToRoute(Router::getInstance()->build('BrowserController', 'index'));
}
$password = Utils::getPOST('password', '');
$password2 = Utils::getPOST('password2', '');
$errorMsg = '';
if (Utils::getPOST('submit', false) != false) {
if (strlen($password) < PASSWORD_MIN_LENGTH) {
$errorMsg = sprintf(System::getLanguage()->_('PasswordMinLength'), PASSWORD_MIN_LENGTH);
} else {
if ($password != $password2) {
$errorMsg = System::getLanguage()->_('ErrorInvalidPasswords');
} else {
LostPW::resetPassword($hash, $password);
System::getSession()->setData('successMsg', System::getLanguage()->_('LostPWSuccess'));
System::forwardToRoute(Router::getInstance()->build('BrowserController', 'index'));
}
}
}
$smarty = new Template();
$smarty->assign('title', System::getLanguage()->_('LostPW'));
$smarty->assign('successMsg', '');
$smarty->assign('form_url', Router::getInstance()->build('AuthController', 'lostpw_check', array('hash' => $hash)));
$smarty->assign('errorMsg', $errorMsg);
$smarty->requireResource('auth');
$smarty->display('auth/lostpw.newpw.tpl');
}
示例12: contact
public function contact(array $params)
{
if (isset($params[0])) {
$id_user = intval($params[0]);
$user = $this->model->getUser($id_user);
} else {
return array('success' => false);
}
$message = Request::get('message');
$sujet = Request::get('subject');
$session = System::getSession();
if ($session->isConnected()) {
$expediteur_id = $_SESSION['userid'];
} else {
return array('data' => $data, 'not_register' => 'Vous n\'êtes pas connecté');
}
$expediteur = $this->model->getUser($expediteur_id);
$headers = "From: " . strip_tags($expediteur['email']) . "\r\n";
$headers .= "Reply-To: " . strip_tags($expediteur['email']) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
if (!empty($message) && !empty($sujet)) {
$html_message = 'Bonjour <strong>' . $user['nickname'] . '</strong>,<br><br>' . "\r\n";
$html_message .= 'Vous avez reçu un message de la part de <strong>' . $expediteur['nickname'] . '</strong> sur <strong>Event-You-All</strong>.<br><br>' . "\r\n";
$html_message .= '<blockquote>' . $message . '</blockquote>';
mail($user['email'], $sujet, $html_message, $headers);
return array('user' => $user, 'success' => true);
} else {
return array('user' => $user, 'success' => '');
}
}
示例13: setupSession
/**
* Initializes session
*/
private function setupSession()
{
// Instanciates it
$session = System::getSession();
}
示例14: login
/**
* Login with clearpaswd
* @param String Cleartext Password
* @return bool Success
*/
public function login($clearPswd)
{
if (Utils::createPasswordHash($clearPswd, $this->salt) == $this->curPassword) {
System::getSession()->setUID($this->uid);
$this->last_login = time();
$this->save();
return true;
}
return false;
}
示例15: deleted
function deleted(array $params)
{
if (isset($params[0])) {
$id_event = intval($params[0]);
$articles = $this->model->getArticle($id_event);
$session = System::getSession();
$user_id = $_SESSION['userid'];
if ($articles['id_createur'] == $user_id) {
$this->model->deleteArticle($id_event);
return 1;
} else {
return 0;
}
}
}