/** * Function for loading the game from the session storage * @return Game */ public function loadGame() { $data = $this->storage->read(Settings::APP_SESSION_NAME); if (!count($data)) { return false; } $word = new Word($data['word'], $data['right_letters'], $data['tried_letters']); return new Game($word, $data['attempts']); }
/** * アクセス権があるかチェックする * * @param array $check */ public function isPermitted($check) { if (!$this->_Session) { return true; } $url = $check[key($check)]; $prefix = BcUtil::authSessionKey('admin'); $userGroupId = $this->_Session->read('Auth.' . $prefix . '.user_group_id'); if ($userGroupId == Configure::read('BcApp.adminGroupId')) { return true; } $Permission = ClassRegistry::init('Permission'); return $Permission->check($url, $userGroupId); }
public function addcompany() { $errors = Error::get("error"); if (!count($errors) || $errors == "") { $db = new Db(); if (Session::read("userid")) { $user_id = Session::read("userid"); //print_r($user_id); exit(); // $user_id=$db->quote($this->user_id); $name = $db->quote($this->name); $email = $db->quote($this->email); $website = $db->quote($this->website); $phone = $db->quote($this->phone); $city = $db->quote($this->city); $location = $db->quote($this->location); $specialization = $db->quote($this->specialization); $description = $db->quote($this->description); $query = "INSERT INTO " . $this->tableName() . " (user_id,name,city,location,website,email,phone,specialization,description,active) \n VALUES({$user_id},{$name},{$city},{$location},{$website},{$email},{$phone},{$specialization},{$description},1)"; if ($db->query($query)) { //print_r($query); exit(); if ($db->affectedRows()) { return true; } } } } return false; }
public function addjobs() { if (is_numeric($this->id)) { $db = new Db(); if (Session::read("userid")) { $user_id = Session::read("userid"); $id = $db->quote($this->id); $heading = $db->quote($this->heading); $post = $db->quote($this->post); $education = $db->quote($this->education); $exp_min = $db->quote($this->exper_min); $exp_max = $db->quote($this->exper_max); $salary = $db->quote($this->salary); $description = $db->quote($this->description); $company_name = $db->quote($this->company_name); $website = $db->quote($this->website); $email = $db->quote($this->email); $phone = $db->quote($this->phone); $city = $db->quote($this->city); $address = $db->quote($this->address); $query = "INSERT INTO " . $this->tableName() . " (id,user_id, heading, post, education, exp_min, exp_max,\n salary, description, company_name, company_url, phone, city, address, active)\n VALUES({$id} ,{$user_id},{$heading},{$post},{$education},{$exp_min},{$exp_max},{$salary},{$description},{$company_name},{$website},{$email},\n {$phone},{$city},{$address},1)"; if ($db->query($query)) { if ($db->affectedRows()) { return true; } } } } return false; }
public function addSession($mysql, $uid) { $time = Time::getTime(); $session= new Session; $random = Random::getString(32); $expiry = $time + 30*24*60*60; $session->read($uid,$time,$expiry); switch($session->insert($mysql, $random)) { case Session::DATABASE_ERROR : { echo "<p>A Database error has occured.</p>"; return; } case Session::INVALID_DATA : { echo "<p>Invalid operation requested.</p>"; return; } case Session::INSERT_SUCCESS : { return $random; } default : break; } }
/** * セッションに保存されたファイルデータをファイルとして保存する * * @param Model $model * @param string $fieldName * @return void * @access public */ function moveFileSessionToTmp(&$model, $fieldName) { $sessionKey = $model->data[$model->alias][$fieldName . '_tmp']; $tmpName = $this->savePath . $sessionKey; $fileData = $this->Session->read('Upload.' . $sessionKey); $fileType = $this->Session->read('Upload.' . $sessionKey . '_type'); $this->Session->delete('Upload.' . $sessionKey); $this->Session->delete('Upload.' . $sessionKey . '_type'); // サイズを取得 if (ini_get('mbstring.func_overload') & 2 && function_exists('mb_strlen')) { $fileSize = mb_strlen($fileData, 'ASCII'); } else { $fileSize = strlen($fileData); } if ($fileSize == 0) { return false; } // ファイルを一時ファイルとして保存 $file = new File($tmpName, true, 0666); $file->write($fileData); $file->close(); // 元の名前を取得 $pos = strpos($sessionKey, '_'); $fileName = substr($sessionKey, $pos + 1, strlen($sessionKey)); // アップロードされたデータとしてデータを復元する $uploadInfo['error'] = 0; $uploadInfo['name'] = $fileName; $uploadInfo['tmp_name'] = $tmpName; $uploadInfo['size'] = $fileSize; $uploadInfo['type'] = $fileType; $model->data[$model->alias][$fieldName] = $uploadInfo; unset($model->data[$model->alias][$fieldName . '_tmp']); }
/** * The destroy handler, this is executed when a session is destroyed with session_destroy() and takes the session id as its only parameter. */ public function testSessionDestroy() { // destroy the session Session::destroy($this->testSessionID); // assert the session is now empty $result = Session::read($this->testSessionID); $this->assertEmpty($result); }
/** * Cette fonction va permettre l'affichage des configurations des envois de mails * * @access public * @author koéZionCMS * @version 0.1 - 02/03/2012 by FI * @version 0.2 - 18/04/2012 by FI - Passage des traitements dans une fonction privée pour mutualiser */ function backoffice_mailer_liste() { $currentWebsite = Session::read('Backoffice.Websites.current'); //Site courant $websitesList = Session::read('Backoffice.Websites.details'); //Liste des sites $currentWebsiteUrl = $websitesList[$currentWebsite]['url']; //Url du site courant $this->_proceed_datas_ini(CONFIGS . DS . 'files' . DS . 'mailer.ini', 'backoffice/configs/mailer_liste', CURRENT_WEBSITE_ID, $currentWebsiteUrl); }
private function restoreDescriptionUrl($descriptionUrl) { debug_event('upnpdevice', 'readDescriptionUrl: ' . $descriptionUrl, 5); $this->_settings = unserialize(Session::read('upnp_dev_' . $descriptionUrl)); if ($this->_settings['descriptionURL'] == $descriptionUrl) { debug_event('upnpdevice', 'service Urls restored from session.', 5); return true; } return false; }
public function beforeExecute() { if (!empty($this->allowedGroups)) { $sessid = Session::read('sessid'); $session_name = Session::read('session_name'); if (isset($sessid) && isset($session_name)) { $this->Request->setCookie($session_name, $sessid); } else { $this->error = 'You are not logged in!'; } } }
/** * 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); }
/** * * @param AppController $class */ protected function parametros(AppController $class) { $endereco = null; $modelEventos = new Evento(); $meusEventos = $modelEventos->verificaEventosParaPromoter(Session::read('Usuario.pessoas_id')); if (Session::check('Empresa')) { $modelEndereco = new Endereco(); $endereco = $modelEndereco->findEnderecosEmpresa(Session::read('Empresa.empresas_id')); $endereco = $endereco[0]; } $class->set('title_layout', 'Painel Administrativo'); $class->set('endereco', $endereco); $class->set('meusEventos', $meusEventos); }
public static function displayError() { if (!Session::read("error")) { return FALSE; } $output = ""; $err = Session::read("error"); Session::delete("error"); $output = NULL; if (count($err)) { foreach ($err as $val) { $output .= "<div>" . $val . "</div>"; } } return $output; }
private function _set_current_user() { if (User::$current !== null) { return; } // already set if (false === ($uid = Session::read('_user_id'))) { // no user User::$current = false; return; } // TODO auth by token $user = User()->find_by_id($uid, array('limit' => 1)); User::$current = empty($user) ? false : $user[0]; // if we've got a user, touch timestamps if (User::$current) { User::$current->touch_last_request(); } }
public function empresa() { $usuariosEmpresa = array(); $funcionarioId = 0; $entradas = $this->Financeiro->filtrar($this->empresas_id, null, date('Y-m-01'), date('Y-m-t'), array(2, 3, 4, 5)); $despesas = $this->Despesa->filtrar($this->empresas_id, date('Y-m-01'), date('Y-m-t')); /** * SE O ROLE ID FOR Usuario ELE PEGA SOMENTE O Usuario SE NãoO OS USUARIOS DA EMPRESA */ if (Session::read('Usuario.roles_id') == 4) { $usuariosEmpresa = $this->Usuario->usuariosEmpresa($this->empresas_id, $this->pessoas_id); $funcionarioId = $this->pessoas_id; } else { $usuariosEmpresa = $this->Usuario->usuariosEmpresa($this->empresas_id); } $urlPDF = "http://snappypdf.com.br/gerar.php?url=" . Router::url(array('Financeiros', 'imprimir', $funcionarioId, $this->empresas_id, date('Y-m-01'), date('Y-m-t'))); $this->set('title_layout', 'Financeiro: ' . Session::read('Usuario.nome_fantasia')); $this->set('entradas', $entradas); $this->set('despesas', $despesas); $this->set('urlPDF', $urlPDF); $this->set('profissionais', $usuariosEmpresa);
protected function parametros(\AppController $class) { $clientes = 0; $funcionarios = 0; $class->addJs(array('js/chart-js/Chart', 'js/chartjs.init')); $endereco = null; if (Session::check('Empresa')) { $modelCliente = new Cliente(); $modelFuncionario = new Funcionario(); $clientes = $modelCliente->clientesProprietario(Session::read('Usuario.pessoas_id'), Session::read('Usuario.roles_id')); $clientes = count($clientes); $funcionarios = $modelFuncionario->find('all', array('empresas_id' => Session::read('Empresa.empresas_id'))); $funcionarios = count($funcionarios); $endereco = $this->Endereco->findEnderecosEmpresa(Session::read('Empresa.empresas_id')); $endereco = $endereco[0]; } $class->set('title_layout', 'Painel Administrativo'); $class->set('endereco', $endereco); $class->set('clientes', $clientes); $class->set('funcionarios', $funcionarios); }
/** * This function must check the user session to be sure that he/she is * authorized to upload and access files in the File Browser. * * @return boolean */ function CheckAuthentication() { // WARNING : DO NOT simply return "true". By doing so, you are allowing // "anyone" to upload and list the files in your server. You must implement // some kind of session validation here. Even something very simple as... // return isset($_SESSION['IsAuthorized']) && $_SESSION['IsAuthorized']; // ... where $_SESSION['IsAuthorized'] is set to "true" as soon as the // user logs in your system. To be able to use session variables don't // forget to add session_start() at the top of this file. /*return Session::check('Backoffice.User.id'); echo '</pre>'; return isset($_SESSION['Backoffice']);*/ //return true; $session = Session::read('Backoffice.User.id'); /*echo '<pre>'; print_r($session); echo '</pre>';*/ return isset($session) && !empty($session); }
public static function auth_user() { $isLocal = self::is_local(); $headers = apache_request_headers(); $myplex_token = $headers['X-Plex-Token']; if (empty($myplex_token)) { $myplex_token = $_REQUEST['X-Plex-Token']; } if (!$isLocal) { $match_users = AmpConfig::get('plex_match_email'); $myplex_username = $headers['X-Plex-Username']; if (empty($myplex_token)) { // Never fail OPTIONS requests if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') { self::setPlexHeader($headers); exit; } else { debug_event('Access Control', 'Authentication token is missing.', '3'); self::createError(401); } } $createSession = false; Session::gc(); $username = ""; $email = trim(Session::read((string) $myplex_token)); if (empty($email)) { $createSession = true; $xml = self::get_server_authtokens(); $validToken = false; foreach ($xml->access_token as $tk) { if ((string) $tk['token'] == $myplex_token) { $username = (string) $tk['username']; // We should apply filter and access restriction to shared sections only, but that's not easily possible with current Ampache architecture $validToken = true; break; } } if (!$validToken) { debug_event('Access Control', 'Auth-Token ' . $myplex_token . ' invalid for this server.', '3'); self::createError(401); } } // Need to get a match between Plex and Ampache users if ($match_users) { if (!AmpConfig::get('access_control')) { debug_event('Access Control', 'Error Attempted to use Plex with Access Control turned off and plex/ampache link enabled.', '3'); self::createError(401); } if (empty($email)) { $xml = self::get_users_account(); if ((string) $xml->username == $username) { $email = (string) $xml->email; } else { $xml = self::get_server_friends(); foreach ($xml->User as $xuser) { if ((string) $xuser['username'] == $username) { $email = (string) $xuser['email']; } } } } if (!empty($email)) { $user = User::get_from_email($email); } if (!isset($user) || !$user->id) { debug_event('Access Denied', 'Unable to get an Ampache user match for email ' . $email, '3'); self::createError(401); } else { $username = $user->username; if (!Access::check_network('init-api', $username, 5)) { debug_event('Access Denied', 'Unauthorized access attempt to Plex [' . $_SERVER['REMOTE_ADDR'] . ']', '3'); self::createError(401); } else { $GLOBALS['user'] = $user; $GLOBALS['user']->load_playlist(); } } } else { $email = $username; $username = null; $GLOBALS['user'] = new User(); $GLOBALS['user']->load_playlist(); } if ($createSession) { // Create an Ampache session from Plex authtoken Session::create(array('type' => 'api', 'sid' => $myplex_token, 'username' => $username, 'value' => $email)); } } else { AmpConfig::set('cookie_path', '/', true); $sid = $_COOKIE[AmpConfig::get('session_name')]; if (!$sid) { $sid = $myplex_token; if ($sid) { session_id($sid); Session::create_cookie(); } } if (!empty($sid) && Session::exists('api', $sid)) { Session::check(); $GLOBALS['user'] = User::get_from_username($_SESSION['userdata']['username']); } else { $GLOBALS['user'] = new User(); $data = array('type' => 'api', 'sid' => $sid); Session::create($data); Session::check(); } $GLOBALS['user']->load_playlist(); } }
<div class="header-middle"><!--header-middle--> <div class="container"> <div class="row"> <div class="col-sm-4"> <div class="logo pull-left"> <a href="<?php echo SERVER_URL; ?> " ><span ><font style="font-size: 48px; font-weight: bold;color: #FE980F;">L</font><span style="font-size: 32px;">egal Lawyer</span> </span></a> </div> </div> <div class="col-sm-8"> <div class="shop-menu pull-right"> <?php if (Session::read("access_type")) { $access_id = Session::read("access_type"); } else { $access_id = 0; } $access_type = Validation::getAccessType($access_id); $category_name = "Header"; $menus = Menu::getMenus($access_type, $category_name); $subUrl = Menu::getMenuSubUrl($access_type); ?> <ul class="nav navbar-nav"> <?php foreach ($menus as $menu_key => $menu_value) { $class = ""; if (isset($pageDetails[0]["url"]) && $menu_value['url'] == $pageDetails[0]["url"]) { $class = 'class="active"'; }
/** * Given an ID, and some data, save it into `tbl_sessions`. This uses * the ID as a unique key, and will override any existing data. If the * `$data` is deemed to be empty, no row will be saved in the database * unless there is an existing row. * * @param string $id * The ID of the Session, usually a hash * @param string $data * The Session information, usually a serialized object of * `$_SESSION[Cookie->_index]` * @throws DatabaseException * @return boolean * True if the Session information was saved successfully, false otherwise */ public static function write($id, $data) { // Only prevent this record from saving if there isn't already a record // in the database. This prevents empty Sessions from being created, but // allows them to be nulled. $session_data = Session::read($id); if (is_null($session_data)) { $empty = true; $unserialized_data = Session::unserialize($session_data); foreach ($unserialized_data as $d) { if (!empty($d)) { $empty = false; } } if ($empty) { return false; } } $fields = array('session' => $id, 'session_expires' => time(), 'session_data' => $data); return Symphony::Database()->insert($fields, 'tbl_sessions', true); }
/** * Cette fonction permet de charger dans une vue une page html * * @param varchar $element Elément à charger * @param array $vars Variables que l'on souhaite faire passer (en plus) à l'élément * @param boolean $isPlugin Cette variable indique à l'objet View si l'élément à inclure fait partie d'un plugin * @access public * @author koéZionCMS * @version 0.1 - 23/12/2011 * @version 0.2 - 21/05/2012 by FI - Rajout de la possibilité de passer des variables à la fonction * @version 0.3 - 24/09/2012 by FI - Rajout du boolean $inElementsFolder pour indiquer si le dossier de stockage de la vue est dans views * @version 0.4 - 17/01/2013 by FI - Modification du chemin de récupération des éléments suite à la modification du chemin de stockage des éléments des layout pour le frontoffice * @version 0.5 - 17/01/2013 by FI - Mise en place de hooks permettant de redéfinir le chemin des éléments à la volée (cf fichiers dans le dossier hook) * @version 0.6 - 05/06/2013 by FI - Correction inclusion éléments * @version 0.7 - 20/10/2013 by AB - Rajout de la gestion du dossier du plugin * @version 0.8 - 27/10/2013 by FI - Changement du nom de la variable inElementFolder par isPlugin * @version 0.9 - 18/12/2013 by FI - Modification de la gestion des hooks pour le chargement des fichiers * @version 0.6 - 01/11/2014 by FI - Modification de la gestion des hooks, la gestion étant maintenant par site on récupère la donnée issue de la BDD et on ne charge plus tous les fichiers. Fonctionnement plus simple lors de la gestion multisites * @version 0.7 - 21/01/2015 by FI - Réorganisation de la fonction pour une gestion plus souple des hooks éléments plugins (BO) */ public function element($element, $vars = null, $isPlugin = false) { if (isset($vars) && !empty($vars)) { foreach ($vars as $k => $v) { $this->vars[$k] = $v; } } extract($this->vars); ///////////////////// // CAS DES PLUGINS // //On est dans le cas d'un plugin si la variable $this->controller->params['pluginFolder'] existe if ($isPlugin && isset($this->controller->params['pluginFolder']) && !empty($this->controller->params['pluginFolder'])) { $elementHook = $this->controller->params['pluginFolder'] . '/views/elements/' . $this->controller->params['controllerFileName'] . '/' . $element; $element = PLUGINS . '/' . $this->controller->params['pluginFolder'] . '/views/elements/' . $this->controller->params['controllerFileName'] . '/' . $element; } //////////////////////////////////////////////////////////// //VERIFICATION SI UN HOOK EST DISPONIBLE POUR LES ELEMENTS// //Ce hook permet de redéfinir à la volée le chemin de certains éléments //Cela s'avère pratique dans le cas de template particulier n'ayant pas besoin de l'ensemble des fonctionnalités disponible dans la version de base // //La structure du fichier elements.php est : // // $elementsHooks = array( // 'ELEMENT_INITIALEMENT_SOUHAITE' => 'ELEMENT_REELLEMENT_SOUHAITE' // ); // //Par exemple : // // $elementsHooks = array( // 'backoffice/formulaires/categories' => 'backoffice/MON_DOSSIER/formulaires/categories' // ); // //Nous allons donc charger les fichiers hooks, s'il y en a, et effectuer des tests sur l'existence d'une ligne pour l'élément courant if (isset($this->vars['websiteParams'])) { $websiteHooks = $this->vars['websiteParams']; } else { $websiteHooks = Session::read('Backoffice.Websites.details.' . CURRENT_WEBSITE_ID); } //Backoffice $elementsHooks = $this->_load_hooks_files('ELEMENTS', $websiteHooks); if (isset($elementsHooks[$element])) { $element = $elementsHooks[$element]; } else { if (isset($elementHook) && isset($elementsHooks[$elementHook])) { $element = $elementsHooks[$elementHook]; } } //////////////////////////////////////////////////////////// $element = str_replace('/', DS, $element); $element = $element . '.php'; if (file_exists($element)) { require $element; } else { if (defined('LAYOUT_VIEWS') && file_exists(LAYOUT_VIEWS . DS . 'elements' . DS . $element)) { require LAYOUT_VIEWS . DS . 'elements' . DS . $element; } else { if (file_exists(ELEMENTS . DS . $element)) { require ELEMENTS . DS . $element; } else { require ELEMENTS . DS . 'backoffice' . DS . 'missing_element.php'; } } } }
/** * アクセストークンを取得する * @param Model $Model * @param Session $Session * @return AccessToken $accessToken */ function getAccessToken(&$Model, &$Session) { $requestToken = $Session->read('request_token'); $accessToken = $this->consumer->getAccessToken($this->accessTokenUri, $requestToken); if ($accessToken) { $this->accessTokenKey = $accessToken->key; $this->accessTokenSecret = $accessToken->secret; } return $accessToken; }
/** * Retorna a action requisitada quando a autorização falhou. * * @return string Endereço da action */ public function getAction() { $action = Session::read("Auth.action"); Session::delete("Auth.action"); return $action; }
public function cadastro() { try { $this->checaEmpresa(); /** * verificando a quantidade de funcionarios restante * se for 0 ou menor ele renderiza uma pagina de erro */ $quantidadeFuncionarios = $this->Funcionario->quantidadeFuncionariosEmpresa($this->empresas_id); if ($quantidadeFuncionarios['total_restante'] == 0) { throw new BusinessException('Limite de funcioários excedido!'); } $listGrupo = NULL; /** * verifico o nivel do usuario para que ele possa escolher quais os outros niveis de usuario ele possa cadastrar abaixo do dele */ if (Session::read('Usuario.roles_id') == 4) { $grupos = $this->Grupo->findGrupolistFuncionario(array(1, 4, 5)); } else { if (Session::read('Usuario.roles_id') == 3) { $grupos = $this->Grupo->findGrupolistFuncionario(array(1, 4, 3, 5)); } } foreach ($grupos as $grupo) { $listGrupo[] = new GrupoEntity($grupo['id'], $grupo['nome'], NULL); } $this->set('title_layout', 'Cadastro de Funcionário'); $this->set('grupos', $listGrupo); $this->render(); } catch (BusinessException $buEx) { $buEx->getNotLimitEmployees($this); } catch (Exception $ex) { if ($ex->getCode() == 2015) { $this->set('mensagem', $ex->getMessage()); die($this->render(array('controller' => 'Erros', 'view' => 'sessaoEmpresa'))); } else { echo $ex->getMessage(); } } }
<?php /* * @author sudhir vishwakarma <*****@*****.**> * @copyright Sudhir Vishwakarma (www.itwebinfo.com) * * @version 0.1 20100602 * How to use : * Create your database in MySQL, and create a table in which * to store your session information. The example code below * uses a table called "session". Here is the SQL command * which created it: * * CREATE TABLE sessions (id varchar(32) NOT NULL,access * int(10) unsigned,data text,PRIMARY KEY (id)); */ require_once "session.class.php"; $oSession = new Session(); //$uid=$_SESSION['uid'] = "63"; //echo Session::read('4ec755f49559e17064802cf0964fb35f'); echo $oSession->read(session_id()); //print_r(Session::users()); $max = '5'; print_r($oSession->clean($max)); session_destroy(); //$_SESSION['uid'] = "63"; // Comment this Once sessoin is set //$_SESSION['test'] = "great"; // Comment this Once sessoin is set ?>
/** * Session read handler. * This method should be overridden if {@link setUseCustomStorage UseCustomStorage} is set true. * @param string session ID * @return string the session data */ public function _read($id) { return Session::read($id); }
<section class="m-b-md"> <h3 class="m-b-none">Ambientes do estabelecimento</h3> </section> <div class="col-sm-8"> <div class="panel panel-default"> <header class="panel-heading"> Ambientes : <?php echo Session::read('Empresa.nome_fantasia'); ?> </header> <div class="panel panel-body"> <div class="clearfix"></div> <table class="table table-condensed table-hover table-responsive table-striped" id="dynamic-table"> <thead> <th class="col-sm-1">#</th> <th>SALÃO</th> <th>NOME</th> <th>CAPACIDADE</th> <th class="text-center col-md-2">ATIVO</th> <th style="width: 6%"></th> </thead> <tbody> <?php if (!empty($registros)) { foreach ($registros as $registro) { ?>
<!-- page start--> <div class="row"> <div class="col-md-12"> <section class="panel"> <div class="panel panel-body"> <div class="col-md-12" style="margin-bottom:0px"> <div class="col-md-4"> <small>Funcionario: </small> <select name="funcionario_id" id="funcionario_id" class="form-control"> <option value="" <?php echo $selected; ?> > -- Ver Completo -- </option> <?php foreach ($profissionais as $registro) { $selected = null; if (Session::read('Usuario.pessoa_id') == $registro['id']) { $selected = 'selected="selected"'; } ?> <option value="<?php echo $registro['id']; ?> " <?php echo $selected; ?> > <?php echo ucwords($registro['nome']); ?> </option>
public function envioEmail() { try { $this->layout = 'null'; $token = $_GET['param']; $reserva = $this->Reserva->find('first', array('token' => $token)); $reserva = array_shift($reserva); /** * recupero o salão e ambiente da reserva */ $dadoEmailReserva = $this->Reserva->recuperaDadosReservaEmail($reserva['Reserva']['id']); $cliente = $this->Cliente->find('first', array('id' => $reserva['Reserva']['clientes_id'])); /** * VERIFICO SE O CLIENTE TEM EMAIL CADASTRADO */ if (!empty($dadoEmailReserva[0]['email']) && Session::read('Empresa.envio_sistema') == 1) { /** * envio o email para o cliente cadastrado para inserir na lista os dados das pessoas relacionadas */ $email = new Email(); $email->useTable = 'emails_sistema'; if (in_array(Session::read('ContaEmpresa.contas_empresas_tipos_id'), array(1, 3, 5))) { $registro = $email->find('first', array('tag' => 'email_confirmacao')); } else { $registro = $email->find('first', array('tag' => 'email_confirmacao')); } /** * recupero o endereço da empresa */ $endereco = $this->Endereco->findEnderecosEmpresa($this->empresas_id); $enderecoEmpresa = $endereco[0]['logradouro'] . ', ' . $endereco[0]['numero'] . ' | ' . $endereco[0]['cidade'] . ' - ' . $endereco[0]['bairro'] . ' - ' . $endereco[0]['uf']; /** * recupero as mesas */ $mesaModel = new Mesa(); $ambientesModel = new Ambiente(); $mesas = $mesaModel->mesasReservas($reserva['Reserva']['id']); $ambientes = $ambientesModel->ambientesReservas($reserva['Reserva']['id']); /** * #faço a troca de siglas para personalizar o email */ $dataMail = explode(' ', Utils::convertData($reserva['Reserva']['start'])); $email->useTable = 'empresas_email_parametros'; $email_parametros = $email->find('first', array('emails_sistema_id' => 5, 'empresas_id' => $this->empresas_id)); $corpoEmailConfirmacao = $email->ajusteEmailConfirmacao($registro[0]['Email']['corpo_mail'], $email_parametros[0][$email->name]); $array = array('__CLIENTE__' => $cliente[0]['Cliente']['nome'], '__DATE__' => date('d/m/Y h:i:s'), '__NOME_FANTASIA__' => Session::read('Empresa.nome_fantasia'), '__CONVIDADOS__' => $reserva['Reserva']['qtde_pessoas'], '__LUGARES__' => $reserva['Reserva']['assentos'], '__ENDERECO_EMPRESA__' => $enderecoEmpresa, '__MESAS__' => join(' - ', array_values($mesas)), '__DATA_INICIO__' => $dataMail[0], '__HORAS_INICIO__' => $dataMail[1], '__SALAO__' => $dadoEmailReserva[0]['salao'], '__AMBIENTE__' => join(' - ', array_values($ambientes)), '__CAPACIDADE__' => $dadoEmailReserva[0]['capacidade'], '__URL_ATIVAR__' => Router::url(array('Reservas', 'confirmReservaEmail', $reserva['Reserva']['token']))); #envio o email de confirmação para o meu cliente cadastrado $objeto = new MailPHPMailer(); $objeto->setAssunto('Confirmação : ' . Session::read('Empresa.nome_fantasia')); //$objeto->setRemetente(); /** * CORPO DO EMAIL */ $corpoEmailConfirmacao = str_replace(array_keys($array), array_values($array), $corpoEmailConfirmacao); $objeto->setBody($corpoEmailConfirmacao); /** * DESTINO PARA QUEM VAI O EMAIL - CLIENTE */ $objeto->setDestinatario($dadoEmailReserva[0]['email'], $dadoEmailReserva[0]['cliente']); $emailEnvio = $objeto->sendMail(); if ($emailEnvio) { $gravaEmail = array('reservas_id' => $reserva['Reserva']['id'], 'empresas_id' => $reserva['Reserva']['empresas_id'], 'pessoas_id' => $this->pessoas_id, 'clientes_id' => $reserva['Reserva']['clientes_id'], 'created' => date('Y-m-d H:i:s'), 'status' => 1); /** * inserindo na tabela o envio do email */ $this->Reserva->gravaEnvioEmail($gravaEmail); echo json_encode(array('message' => 'Email enviado com sucesso!', "style" => 'success', 'time' => 5000, 'size' => 'sm', 'callback' => false, 'before' => "\$('#loading').fadeOut(500);", 'icon' => 'check', 'title' => 'Sucesso no envio!')); } else { $gravaEmail = array('reservas_id' => $reserva['Reserva']['id'], 'empresas_id' => $reserva['Reserva']['empresas_id'], 'pessoas_id' => $this->pessoas_id, 'clientes_id' => $reserva['Reserva']['clientes_id'], 'created' => date('Y-m-d H:i:s'), 'status' => 0); /** * inserindo na tabela o envio do email */ $this->Reserva->gravaEnvioEmail($gravaEmail); echo json_encode(array('message' => 'Problema no servidor de envio dos emails, contate o suporte.', "style" => 'warning', 'time' => 5000, 'size' => 'sm', 'callback' => false, 'before' => "\$('#loading').fadeOut(500);", 'icon' => 'times', 'title' => 'Falha no envio!')); } } else { echo json_encode(array('message' => 'Não foi possivel reenviar seu email tente novamente mais tarde ou avise o suporte.', "style" => 'danger', 'time' => 5000, 'size' => 'sm', 'callback' => false, 'before' => false, 'icon' => 'times', 'title' => 'Falha no envio!')); } } catch (Exception $ex) { echo json_encode(array('message' => $ex->getMessage(), "style" => 'danger', 'time' => 5000, 'size' => 'sm', 'callback' => false, 'before' => false, 'icon' => 'times', 'title' => 'Falha no envio!')); } }
<?php require_once 'bootstrap.php'; $logger = Logger::getLogger('default'); $posted = Session::read('posted', null); if ($posted === null) { return header('Location: index.php'); } $logger->info($posted); /** Databaseへの登録. * DB登録が失敗した時用に $dbfailed という変数にエラーメッセージが格納されます. * コメントアウトを忘れずに. * * またメール送信エラーの時のために rollback と commit がファイルの終り付近にあるので、 * DB機能を使う場合はそちらのコメントアウトも忘れずに. $dbconn = Dbmanage::connect();; $dbtable = Dbmanage::$table; $dbconn->beginTransaction(); $stmt = $dbconn->prepare( "INSERT INTO `{$dbtable}` (`name`, `university`, `faculty`, `graduating`, `sex`, `phone`, `mail`, `device`, `created_at`) ". "VALUES (:name, :university, :faculty, :graduating, :sex, :phone, :mail, 'PC', NOW());" ); $stmt->bindValue(':name', Arr::get($posted, 'name'), PDO::PARAM_STR); $stmt->bindValue(':university', Arr::get($posted, 'university'), PDO::PARAM_STR); $stmt->bindValue(':faculty', Arr::get($posted, 'faculty'), PDO::PARAM_STR); $stmt->bindValue(':graduating', Arr::get($posted, 'graduating'), PDO::PARAM_INT); $stmt->bindValue(':sex', Arr::get($posted, 'sex'), PDO::PARAM_STR); $stmt->bindValue(':phone', Arr::get($posted, 'phone'), PDO::PARAM_STR); $stmt->bindValue(':mail', Arr::get($posted, 'mail'), PDO::PARAM_STR); $dbfailed = "";