本文整理汇总了PHP中Session::write方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::write方法的具体用法?PHP Session::write怎么用?PHP Session::write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Session
的用法示例。
在下文中一共展示了Session::write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
function login()
{
if ($this->checkUserEmail($this->email_id)) {
if ($this->checkpassword($this->password)) {
$db = new Db();
$mailid = $db->quote($this->email_id);
$pass = $db->quote($this->password);
$query = "SELECT * FROM " . $this->tableName() . " WHERE EmailId = {$mailid} and Password = {$pass} ";
$row = $db->select($query);
if (count($row) == 0) {
Error::set(ACCOUNT_IS_NOT_EXIST);
return FALSE;
} else {
if ($row[0]["active"] == 0) {
Error::set(ACCOUNT_IS_BLOCKED);
return FALSE;
} else {
Session::write("email", $row[0]["EmailId"]);
Session::write("userid", $row[0]["UserId"]);
Session::write("access_type", $row[0]["RoleId"]);
return TRUE;
}
}
}
}
}
示例2: login
function login()
{
if (isset($this->data['request']) && isset($this->data["request"]['submit'])) {
if ($this->checkUserEmail($this->data['request']['email'])) {
if ($this->checkpassword($this->data['request']['password'])) {
$db = new Db();
$mailid = $db->quote($this->data['request']["email"]);
$pass = $db->quote($this->data['request']["password"]);
$query = "select * from " . $this->tableName() . " where EmailId={$mailid} and Password={$pass} ";
$row = $db->select($query);
if (count($row) == 0) {
Error::set(ACCOUNT_IS_NOT_EXIST);
return FALSE;
} else {
if ($row[0]["active"] == 0) {
Error::set(ACCOUNT_IS_BLOCKED);
return FALSE;
} else {
Session::write("email", $row[0]["EmailId"]);
Session::write("userid", $row[0]["UserId"]);
Session::write("access_type", $row[0]["RoleId"]);
return TRUE;
}
}
}
}
}
return false;
}
示例3: buildXml
function buildXml()
{
// A "must have", checking whether the connector is enabled and the basic parameters (like current folder) are safe.
$this->checkConnector();
$this->checkRequest();
// Checking ACL permissions, we're just getting an information about a file, so FILE_VIEW permission seems to be ok.
if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_VIEW)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
}
// Make sure we actually received a file name
if (!isset($_GET["fileName"])) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
}
$fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_GET["fileName"]);
$resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
// Use the resource type configuration object to check whether the extension of a file to check is really allowed.
if (!$resourceTypeInfo->checkExtension($fileName)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION);
}
// Make sure that the file name is really ok and has not been sent by a hacker
if (!CKFinder_Connector_Utils_FileSystem::checkFileName($fileName) || $resourceTypeInfo->checkIsHiddenFile($fileName)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
}
$filePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $fileName);
if (!file_exists($filePath) || !is_file($filePath)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND);
}
//set session values to be check by process.php upon returning from pixlr.com
$maketoken = md5(session_id());
///////////////////
//HACK KOEZIONCMS//
$thumbFolder = $this->_currentFolder->getThumbsServerPath();
$pixlrSession = array('token' => substr($maketoken, 0, 16), 'ImagePath' => $filePath, 'clientImagePath' => $this->_currentFolder->getUrl(), 'fileName' => $fileName, 'return' => $_SERVER['HTTP_REFERER'], 'thumbLocation' => $thumbFolder . $fileName);
Session::write('Pixlr', $pixlrSession);
//$_SESSION['pixlr']['token'] = substr($maketoken,0,16);
//$_SESSION['pixlr']['ImagePath'] = $filePath;
//$_SESSION['pixlr']['clientImagePath'] = $this->_currentFolder->getUrl(); // ie: /CMSfiles/images/subdirectory/
//$_SESSION['pixlr']['fileName'] = $fileName;
//$_SESSION['pixlr']['return'] = $_SERVER['HTTP_REFERER'];
//$thumbFolder = $this->_currentFolder->getThumbsServerPath();
//$_SESSION['pixlr']['thumbLocation'] = $thumbFolder . $fileName;
//get the client-side absolute path to the image being edited
//$absolute_filePath = "http://".$_SERVER['HTTP_HOST'].$_SESSION['pixlr']['clientImagePath'].$_SESSION['pixlr']['fileName'];
$absolute_filePath = "http://" . $_SERVER['HTTP_HOST'] . $pixlrSession['clientImagePath'] . $pixlrSession['fileName'];
//get teh directory this plugin is in so we can return to the process.php script in this folder
$pluginFolder = dirname(__FILE__);
//the directory holding this plugin
//make the directory a client-side absolute URL
$clientPluginFolder = preg_replace("@" . $_SERVER['DOCUMENT_ROOT'] . "@", "http://" . $_SERVER['HTTP_HOST'], $pluginFolder);
//parameters to send to pixlr.com
$pixlr_params = array("referrer" => $_SERVER['HTTP_HOST'], "loc" => "en", "exit" => $_SERVER['HTTP_REFERER'] != "" ? urlencode($_SERVER['HTTP_REFERER']) : "http://www.pixlr.com", "image" => $absolute_filePath, "title" => $fileName, "method" => "GET", "target" => urlencode($clientPluginFolder . "/process.php?token=" . $pixlrSession['token']), "locktarget" => "TRUE", "locktitle" => "TRUE", "locktype" => "TRUE", "lockquality" => "80");
$pixlr_link = "http://www.pixlr.com/editor?";
foreach ($pixlr_params as $key => $val) {
$pixlr_link .= $key . "=" . $val . "&";
}
$pixlr_link = rtrim($pixlr_link, "&");
$oNode = new Ckfinder_Connector_Utils_XmlNode("Pixlr");
$oNode->addAttribute("pixlr_link", $pixlr_link);
$this->_connectorNode->addChild($oNode);
}
示例4: saveFile
/**
* ファイルを保存する
*
* @param Model $model
* @param array 画像保存対象フィールドの設定
* @return ファイル名 Or false
* @access public
*/
function saveFile(&$model, $field)
{
// データを取得
$file = $model->data[$model->name][$field['name']];
if (empty($file['tmp_name'])) {
return false;
}
if (!empty($file['error']) && $file['error'] != 0) {
return false;
}
// プレフィックス、サフィックスを取得
$prefix = '';
$suffix = '';
if (!empty($field['prefix'])) {
$prefix = $field['prefix'];
}
if (!empty($field['suffix'])) {
$suffix = $field['suffix'];
}
// 保存ファイル名を生成
$basename = preg_replace("/\\." . $field['ext'] . "\$/is", '', $file['name']);
if (!$this->tmpId) {
$fileName = $prefix . $basename . $suffix . '.' . $field['ext'];
} else {
if (!empty($field['namefield'])) {
$model->data[$model->alias][$field['namefield']] = $this->tmpId;
$fileName = $this->getFieldBasename($model, $field, $field['ext']);
} else {
$fileName = $this->tmpId . '_' . $field['name'] . '.' . $field['ext'];
}
}
$filePath = $this->savePath . $fileName;
if (!$this->tmpId) {
if (copy($file['tmp_name'], $filePath)) {
chmod($filePath, 0666);
// ファイルをリサイズ
if (!empty($field['imageresize']) && ($field['ext'] == 'jpg' || $field['ext'] == 'gif' || $field['ext'] == 'png')) {
if (!empty($field['imageresize']['thumb'])) {
$thumb = $field['imageresize']['thumb'];
} else {
$thumb = false;
}
$this->resizeImage($filePath, $filePath, $field['imageresize']['width'], $field['imageresize']['height'], $thumb);
}
$ret = $fileName;
} else {
$ret = false;
}
} else {
$_fileName = str_replace('.', '_', $fileName);
$this->Session->write('Upload.' . $_fileName, $field);
$this->Session->write('Upload.' . $_fileName . '.type', $file['type']);
$this->Session->write('Upload.' . $_fileName . '.data', file_get_contents($file['tmp_name']));
return $fileName;
}
return $ret;
}
示例5: set
public static function set($error = "")
{
if (!Session::read("error")) {
$err = array();
$err[] = $error;
Session::write("error", $err);
} else {
$err = Session::read("error");
$err[] = $error;
Session::write("error", $err);
}
}
示例6: is_logged_in
function is_logged_in()
{
if (isset($_SESSION['logged_in'])) {
$DB = Mysql::init();
$data = $DB->select('*', ACCOUNT_DATABASE . '.account', "id='" . $_SESSION['user_data']['id'] . "'");
clear_site();
if (is_array($data)) {
assign('user_data', $data);
Session::write('user_data', $data);
return true;
}
}
return false;
}
示例7: get_website_datas
/**
* Cette fonction permet la récupération des données du site courant
*
* @return varchar Url du site à prendre en compte
* @access public
* @author koéZionCMS
* @version 0.1 - 02/05/2012 by FI
* @version 0.2 - 14/06/2012 by FI - Modification de la récupération du site pour la boucle locale - On récupère le premier site de la liste et plus celui avec l'id 1 pour éviter les éventuelles erreurs
* @version 0.3 - 04/09/2012 by FI - Mise en place d'un passage de paramètre en GET pour pouvoir changer de site en local
* @version 0.4 - 02/04/2014 by FI - Mise en place d'un passage de paramètre en GET pour pouvoir changer le host du site en local
* @version 0.5 - 21/05/2014 by FI - Mise en place d'un passage de paramètre dans la fonction pour pouvoir changer le host du site
* @version 0.6 - 23/04/2015 by FI - Rajout de la condition OR dans la récupération du site courant afin de traiter également les alias d'url
* @version 0.7 - 24/04/2015 by FI - Gestion de la traduction
*/
public function get_website_datas($hackWsHost = null)
{
//Si un hack du host est passé dans l'url on le stocke dans la variable de session
if (isset($_GET['hack_ws_host'])) {
Session::write('Frontoffice.hack_ws_host', $_GET['hack_ws_host']);
}
//On va contrôler que le hack du host n'est pas passé en paramètre de la fonction si c'est le cas il prendra le dessus sur celui dans la variable de session
$hackWsHost = isset($hackWsHost) ? $hackWsHost : Session::read('Frontoffice.hack_ws_host');
$httpHost = isset($hackWsHost) && !empty($hackWsHost) ? $hackWsHost : $_SERVER["HTTP_HOST"];
//Récupération de l'url
$cacheFolder = TMP . DS . 'cache' . DS . 'variables' . DS . 'Websites' . DS;
//On contrôle si le modèle est traduit
$this->load_model('Website');
//Chargement du modèle
if ($this->Website->fieldsToTranslate) {
$cacheFile = $httpHost . '_' . DEFAULT_LANGUAGE;
} else {
$cacheFile = $httpHost;
}
$website = Cache::exists_cache_file($cacheFolder, $cacheFile);
if (!$website) {
//HACK SPECIAL LOCAL POUR CHANGER DE SITE pour permettre la passage de l'identifiant du site en paramètre
if (isset($_GET['hack_ws_id'])) {
Session::write('Frontoffice.hack_ws_id', $_GET['hack_ws_id']);
}
$hackWsId = Session::read('Frontoffice.hack_ws_id');
if ($httpHost == 'localhost' || $httpHost == '127.0.0.1') {
if ($hackWsId) {
$websiteId = $hackWsId;
} else {
$websites = $this->Website->findList(array('order' => 'id ASC'));
$websiteId = current(array_keys($websites));
}
$websiteConditions = array('conditions' => array('id' => $websiteId, 'online' => 1));
} else {
if ($hackWsId) {
$websiteConditions = array('conditions' => array('id' => $hackWsId, 'online' => 1));
} else {
//On récupère les sites dont l'url ou un alias est égal à $httpHost
$websiteConditions = array('conditions' => array('OR' => array("url LIKE '%" . $httpHost . "%'", "url_alias LIKE '%" . $httpHost . "%'"), 'online' => 1));
}
}
$website = $this->Website->findFirst($websiteConditions);
Cache::create_cache_file($cacheFolder, $cacheFile, $website);
}
if (!defined('CURRENT_WEBSITE_ID')) {
define('CURRENT_WEBSITE_ID', $website['id']);
}
return array('layout' => $website['tpl_layout'], 'website' => $website);
}
示例8: saveFile
/**
* ファイルを保存する
*
* @param Model $Model
* @param array 画像保存対象フィールドの設定
* @return ファイル名 Or false
* @access public
*/
public function saveFile(Model $Model, $field)
{
// データを取得
$file = $Model->data[$Model->name][$field['name']];
if (empty($file['tmp_name'])) {
return false;
}
if (!empty($file['error']) && $file['error'] != 0) {
return false;
}
// プレフィックス、サフィックスを取得
$prefix = '';
$suffix = '';
if (!empty($field['prefix'])) {
$prefix = $field['prefix'];
}
if (!empty($field['suffix'])) {
$suffix = $field['suffix'];
}
// 保存ファイル名を生成
$basename = preg_replace("/\\." . $field['ext'] . "\$/is", '', $file['name']);
if (!$this->tmpId) {
$fileName = $prefix . $basename . $suffix . '.' . $field['ext'];
} else {
if (!empty($field['namefield'])) {
$Model->data[$Model->alias][$field['namefield']] = $this->tmpId;
$fileName = $this->getFieldBasename($Model, $field, $field['ext']);
} else {
$fileName = $this->tmpId . '_' . $field['name'] . '.' . $field['ext'];
}
}
$filePath = $this->savePath[$Model->alias] . $fileName;
if (!$this->tmpId) {
if (copy($file['tmp_name'], $filePath)) {
chmod($filePath, 0666);
$ret = $fileName;
} else {
$ret = false;
}
} else {
$_fileName = str_replace(array('.', '/'), array('_', '_'), $fileName);
$this->Session->write('Upload.' . $_fileName, $field);
$this->Session->write('Upload.' . $_fileName . '.type', $file['type']);
$this->Session->write('Upload.' . $_fileName . '.data', file_get_contents($file['tmp_name']));
return $fileName;
}
return $ret;
}
示例9: loadControllerFile
public function loadControllerFile($controllerToLoad)
{
$controllerName = Inflector::underscore($controllerToLoad);
$controller_path = CONTROLLERS . DS . $controllerName . '_controller.php';
//On récupère dans une variable le chemin du controller
//////////////////////////////////////////////
// RECUPERATION DES CONNECTEURS PLUGINS //
//Les connecteurs sont utilisés pour la correspondance entre les plugins et les dossiers des plugins
$pluginsConnectors = get_plugins_connectors();
if (isset($pluginsConnectors[$controllerName])) {
$this->request->pluginFolder = $sFolderPlugin = $pluginsConnectors[$controllerName];
//Récupération du dossier du plugin si le controller appellé est dans un connector d'un plugin
$controller_path = PLUGINS . DS . $sFolderPlugin . DS . 'controllers' . DS . $controllerName . '_controller.php';
$controller_name = strtolower($controllerName . '_plugin_controller');
} else {
$controller_name = strtolower($controllerName . '_controller');
}
//////////////////////////////////////////////
if (file_exists($controller_path)) {
if (isset($sFolderPlugin)) {
//On doit contrôler si le plugin est installé en allant lire le fichiers
$pluginsList = Cache::exists_cache_file(TMP . DS . 'cache' . DS . 'variables' . DS . 'Plugins' . DS, "plugins");
$pluginControllerToLoad = Inflector::camelize($sFolderPlugin);
if (!isset($pluginsList[$pluginControllerToLoad])) {
Session::write('redirectMessage', $message);
$this->redirect('home/e404');
die;
}
$pluginControllerBoostrap = PLUGINS . DS . $sFolderPlugin . DS . 'controller.php';
if (file_exists($pluginControllerBoostrap)) {
require_once $pluginControllerBoostrap;
}
}
require_once $controller_path;
//Inclusion de ce fichier si il existe
return $controller_name;
} else {
if (isset($sFolderPlugin)) {
$message = "Le controller du plugin " . $controllerToLoad . " n'existe pas" . " dans le fichier dispatcher ou n'est pas correctement installé";
} else {
$message = "Le controller " . $controllerToLoad . " n'existe pas" . " dans le fichier dispatcher";
}
Session::write('redirectMessage', $message);
$this->redirect('home/e404');
die;
}
}
示例10: foreach
$mail->Body = "\nRECRU(リクルー)の事前登録を受け付けました。\n" . "\nこの度は就活生同士のクローズドSNS「RECRU(リクルー)」への事前登録\n" . "誠にありがとうございます。\n" . "今後、本サービスの開始まで\n" . "お得な就活情報やサービスリリースに関する情報をお知らせいたしますので、\n" . "ぜひご活用ください!!\n" . "\n※このメールはサービスの事前登録受付後、自動送信されております.\n" . "返信には対応しておりませんので、ご注意くださいませ。\n" . "\n============================================================\n" . "RECRU(リクルー)\n" . "運営事務局\n" . "http://recru.asia" . "";
$mailfailed = "";
if (!$mail->send()) {
$mailfailed = "\n事前登録のメールの送信に失敗しました。\n" . "手動での送信が必要になります\n" . "以下登録者への完了メール===================\n\n" . "件名: " . $mail->Subject . "\n" . "本文:\n" . $mail->Body . "\n" . "\n===============登録者への完了メール内容ここまで\n" . "";
$logger->error("ユーザーへのメール送信に失敗しました。");
$logger->error($mail->ErrorInfo);
}
// to bellpark
$mail->clearAllRecipients();
foreach (Mailconfig::$to as $address => $name) {
$mail->addAddress($address, $name);
}
foreach (Mailconfig::$cc as $address => $name) {
$mail->addCC($address, $name);
}
foreach (Mailconfig::$bcc as $address => $name) {
$mail->addBCC($address, $name);
}
$mail->Subject = '【RECRU】事前登録の受付';
$mail->Body = "\nサービスの事前登録を受け付けました。\n\n" . $mailfailed . "メールアドレス:{$posted['mail']}\n" . "\n※このメールはサービスの事前登録受付後、自動送信されております.\n" . "返信には対応しておりませんので、ご注意くださいませ。\n" . "\n============================================================\n" . "RECRU(リクルー)\n" . "運営事務局\n" . "http://recru.asia" . "";
if (!$mail->send()) {
$logger->fatal("管理者へのメール送信に失敗しました。");
$logger->fatal($mail->ErrorInfo);
$logger->fatal($mail->Body);
Session::write('failed.register', "登録処理中にエラーが発生しました。<br/>お手数ですが、登録内容をご確認の上再度ご登録をお願いします。");
// $dbconn->rollback(); //DB rollback
return header('Location: index.php');
}
// $dbconn->commit(); //DB commit
Session::delete('posted');
return header('Location: complete.php');
示例11: _write
/**
* Session write handler.
* This method should be overridden if {@link setUseCustomStorage UseCustomStorage} is set true.
* @param string session ID
* @param string session data
* @return boolean whether session write is successful
*/
public function _write($id, $data)
{
$session = Session::write($id, $data);
return $session instanceof Session;
}
示例12:
* @link http://madebykieron.co.uk
* @copyright http://unlicense.org/
*/
/**
* Boot the environment
*/
require SYS . 'boot' . EXT;
/**
* Boot the application
*/
require APP . 'run' . EXT;
/**
* Set input
*/
Input::detect(Request::method());
/**
* Read session data
*/
Session::read();
/**
* Route the request
*/
$response = Router::create()->dispatch();
/**
* Update session
*/
Session::write();
/**
* Output stuff
*/
$response->send();
示例13: testSessionWrite
/**
* Test writing something to the session
*/
public function testSessionWrite()
{
Session::write($this->testSessionID, $this->testSessionData);
}
示例14: PASSWORD
if (Session::read('login_attempts') > 3) {
if (isset($_SESSION['security_code']) && $_SESSION['security_code'] != $captcha) {
$login_failed = true;
}
}
if (!$login_failed) {
$data = $DB->select("*", ACCOUNT_DATABASE . ".account", "login LIKE '" . $username . "' AND password LIKE PASSWORD('" . $password . "')");
if (is_array($data)) {
if ($data['status'] == 'BLOCK') {
$smarty->assign('blocked_account', true);
$smarty->assign('active', $data['active']);
} else {
$_SESSION['logged_in'] = true;
$_SESSION['user_data'] = $data;
$logged_in = true;
Session::write('login_attempts', 0);
}
}
}
}
if ($logged_in) {
header('Location: ' . site_url() . '/main/index');
exit;
} else {
if (Session::read('login_attempts') > 3) {
assign('captcha', site_url() . 'captcha.php');
}
if ($logged_in == false) {
assign('login_error', true);
if (isset($_SESSION['login_attempts'])) {
$_SESSION['login_attempts']++;
示例15: error
/**
* Cette fonction va insérer dans le fichier de log les différentes erreurs rencontrées
*
* @param varchar $message Message à insérer dans les logs
* @access public
* @author koéZionCMS
* @version 0.1 - 23/12/2011
*/
public function error($message)
{
require_once LIBS . DS . 'config_magik.php';
$cfg = new ConfigMagik(CONFIGS . DS . 'files' . DS . 'core.ini', true, false);
$coreConfs = $cfg->keys_values();
if ($coreConfs['log_php']) {
//Rajout le 02/04/2013
$date = date('Y-m-d');
$traceSql = date('Y-m-d H:i:s') . "|#|" . $message . "|#|" . $this->request->url . "\n";
FileAndDir::put(TMP . DS . 'logs' . DS . 'php' . DS . 'e404_' . $date . '.log', $traceSql, FILE_APPEND);
}
$url = Router::url('e404');
$url .= "?e404=" . $this->request->url;
Session::write('redirectMessage', $message);
header("Location: " . $url);
die;
}