public function getHtml() { $transHtml = array(); $request = $this->controller->getRequest(); if ($this->controller instanceof CheckoutController && $request->getActionName() == 'completed') { $session = new Session(); if ($orderID = $session->get('completedOrderID')) { $order = CustomerOrder::getInstanceByID((int) $session->get('completedOrderID'), CustomerOrder::LOAD_DATA); $order->loadAll(); $orderArray = $order->toArray(); $data = array($order->getID(), '', $orderArray['total'][$orderArray['Currency']['ID']], $order->getTaxAmount(), $orderArray['ShippingAddress']['city'], $orderArray['ShippingAddress']['stateName'], $orderArray['ShippingAddress']['countryID']); $transHtml[] = 'pageTracker._addTrans' . $this->getJSParams($data); foreach ($orderArray['cartItems'] as $item) { $data = array($order->getID(), $item['Product']['sku'], $item['Product']['name'], $item['Product']['Category']['name'], $item['price'], $item['count']); $transHtml[] = 'pageTracker._addItem' . $this->getJSParams($data); } } $transHtml[] = 'pageTracker._trackTrans();'; } return '<script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src=\'" + gaJsHost + "google-analytics.com/ga.js\' type=\'text/javascript\'%3E%3C/script%3E")); </script> <script type="text/javascript"> var pageTracker = _gat._getTracker("' . $this->getValue('code') . '"); pageTracker._initData(); pageTracker._trackPageview(); ' . implode("\n", $transHtml) . ' </script>'; }
public static function login($username, $password, $language) { if ($username and $password) { $auth = new Auth(); if ($auth->login($username, $password) == true) { $session_id = $auth->get_session_id(); $session = new Session($session_id); $user = new User($session->get_user_id()); $regional = new Regional($session->get_user_id()); if (is_numeric($language)) { $session->write_value("LANGUAGE", $language); } else { $session->write_value("LANGUAGE", $regional->get_language_id()); } if ($user->get_boolean_user_entry("user_locked") == false) { return "index.php?username="******"&session_id=" . $session_id; } else { return 0; } } else { return 0; } } else { return 0; } }
private function login() { $session = new Session(); if (!$session->has('documentsUser')) { $this->redirect('dokumenty-login.html', true); } }
function app_start() { // Create a new instance of the Session object, and get the channel information. $session = new Session(); $from_info = $session->getFrom(); $network = $from_info['channel']; // Create a new instance of the Tropo object. $tropo = new Tropo(); // See if any text was sent with session start. $initial_text = $session->getInitialText(); // If the initial text is a zip code, skip the input collection and go right to results. if (strlen($initial_text) == 1 && is_numeric($initial_text)) { valid_text($tropo, $initial_text); } else { // Welcome prompt. $tropo->say("Welcome to the Tropo PHP example for {$network}"); // Set up options for input. $options = array("attempts" => 3, "bargein" => true, "choices" => "1,2,3,4", "mode" => "dtmf", "name" => "movie", "timeout" => 30); // Ask the caller for input, pass in options. $tropo->ask("Which of these trilogies do you like the best? Press 1 to vote for Lord of the Rings, press 2 for the original Star Wars, 3 for the Star Wars prequels, or press 4 for the Matrix", $options); // Tell Tropo what to do when the user has entered input, or if there's a problem. This redirects to the instructions under dispatch_post('/choice', 'app_choice') or dispatch_post('/incomplete', 'app_incomplete'). $tropo->on(array("event" => "continue", "next" => "favorite-movie-webapi.php?uri=choice", "say" => "Please hold.")); $tropo->on(array("event" => "incomplete", "next" => "favorite-movie-webapi.php?uri=incomplete")); } // Render the JSON for the Tropo WebAPI to consume. return $tropo->RenderJson(); }
public static function Create($p_sessionId, &$p_objectId, $p_objectTypeId = null, $p_userId = null, $p_updateStats = false) { if (empty($p_sessionId)) { throw new SessionIdNotSet(); } $session = new Session($p_sessionId); if (!$session->exists()) { $sessionParams = array('start_time' => strftime("%Y-%m-%d %T")); if (!empty($p_userId)) { $sessionParams['user_id'] = $p_userId; } $session->create($sessionParams); } $sessionUserId = $session->getUserId(); if (!empty($p_userId) && !empty($sessionUserId) && $sessionUserId != $p_userId) { throw new InvalidUserId(); } $requestObject = new RequestObject($p_objectId); if (!$requestObject->exists()) { if (empty($p_objectTypeId)) { throw new ObjectTypeIdNotSet(); } $requestObject->create(array('object_type_id' => $p_objectTypeId)); $p_objectId = $requestObject->getObjectId(); } elseif (empty($p_objectId)) { throw new ObjectIdNotSet(); } if ($p_updateStats) { self::UpdateStats($p_sessionId, $p_objectId); } }
public function testGetShellInterpreter() { $instance = new Session(__FILE__); $shellInterpreter1 = $instance->getShellInterpreter(); $shellInterpreter2 = $instance->getShellInterpreter(); $this->assertSame($shellInterpreter1, $shellInterpreter2); }
/** * Obtém mensagem contida na sessão * * @return string */ public function getMessage() { $sessao = new Session(); $message = $sessao->get(self::_NAMESPACE); self::clear(); return $message; }
function __construct() { parent::__construct(); $session = new Session(); $getSessi = $session->get_session(); $this->user = $getSessi[0]; }
/** * @covers \Heystack\Core\State\Backends\Session::setSession * @covers \Heystack\Core\State\Backends\Session::getKeys * @covers \Heystack\Core\State\Backends\Session::removeAll * @covers \Heystack\Core\State\Backends\Session::removeByKey */ public function testRemoveAll() { $session = new Session(); $session->setSession(new \Session(['test' => 'hello'])); $session->removeAll(); $this->assertNull($session->getByKey('test')); }
protected function buildData() { $builders = array(); //Add owner $session = new Session(); $cryptpass = $session->pwdcrypt("oldpassword"); $builders[] = FixtureBuilder::build('owners', array('id'=>1, 'full_name'=>'ThinkUp J. User', 'email'=>'*****@*****.**', 'is_activated'=>1, 'pwd'=>$cryptpass)); $builders[] = FixtureBuilder::build('owners', array('id'=>2, 'full_name'=>'ThinkUp J. Admin', 'email'=>'*****@*****.**', 'is_activated'=>1, 'is_admin'=>1)); //Add instance_owner $builders[] = FixtureBuilder::build('owner_instances', array('owner_id'=>1, 'instance_id'=>1)); $builders[] = FixtureBuilder::build('owner_instances', array('owner_id'=>2, 'instance_id'=>1)); //Insert test data into test table $builders[] = FixtureBuilder::build('users', array('user_id'=>13, 'user_name'=>'ev', 'full_name'=>'Ev Williams')); //Make public //Insert test data into test table $builders[] = FixtureBuilder::build('instances', array('id'=>1, 'network_user_id'=>13, 'network_username'=>'ev', 'is_public'=>1, 'network'=>'twitter')); return $builders; }
/** Creates a new session. */ public static function newSession($assignment_id, $worker_id, Game $game) { $new_session = new Session(); $new_session->id = uniqid('', true); $new_session->assignment_id = $assignment_id; $new_session->worker_id = $worker_id; $new_session->game = $game; $new_session->current_step = $game->steps[0]; $new_session->repetition = 0; $new_session->data = array(); $new_session->status = self::awaiting_user_input; $new_session->setExpiration($new_session->current_step->time_limit); $dbh = Database::handle(); $sth = $dbh->prepare('INSERT INTO sessions ' . '(session_id, assignment_id, worker_id, game, data, status, expires) ' . 'VALUES ' . '(:session, :assignment, :worker, :game, :data, :status, :expires)'); $sth->bindValue(':session', $new_session->id); $sth->bindValue(':assignment', $new_session->assignment_id); $sth->bindValue(':worker', $new_session->worker_id); $sth->bindValue(':game', $new_session->game->getID()); $sth->bindValue(':data', serialize($new_session->data)); $sth->bindValue(':status', $new_session->status); $sth->bindValue(':expires', $new_session->expires); $sth->execute(); self::$sessions[$new_session->id] = $new_session; return self::$sessions[$new_session->id]; }
/** @param string[] $data */ public function SetData($data) { if (isset($data['baseIngredientID'])) { if ($data['baseIngredientID']) { $baseIngredient = $this->Session->IngredientByID($data['baseIngredientID']); if (!$baseIngredient) { APIResponse(RESPONSE_400, "Update Ingredient with bad base ingredient ID."); } else { $this->BaseIngredient = $baseIngredient; } } else { $this->BaseIngredient = false; } } if (isset($data['id'])) { $this->ID = (int) $data['id']; } if (isset($data['title'])) { $this->Title = $data['title']; } if (isset($data['type'])) { $this->Type = $data['type']; } if (isset($data['description'])) { $this->Description = $data['description']; } }
/** * @covers $this->object->flash */ public function testFlash() { $this->object->flash('test', 'Trixie'); $this->object->flash('test', 'Tinkerbell'); $this->assertEquals('Tinkerbell', $this->object->flash('test')); $this->assertEquals(null, $this->object->flash('test')); }
/** * Constructor. * * @param SessionInterface $session * @param TranslatorInterface $translator */ public function __construct(SessionInterface $session, TranslatorInterface $translator) { $this->session = $session; $this->translator = $translator; /* @var SessionBagInterface flashBag */ $this->flashBag = $this->session->getFlashBag(); }
public function RecupPodcast($object) { //session_start(); $pseudo = 'pseudo'; $object = strtolower($object); $sess = new Session(); $user_session = $sess->__get($pseudo); echo 'type :' . gettype($user_session) . '<br/>'; $yy = var_dump($user_session); if ($object == "url") { try { $req = $this->db->query("SELECT url as lurl FROM podcast p, preference p, utilisateur u WHERE pseudo='{$user_session}' AND u.id_util=pref.id_util AND pref.id_genre=p.id_genre "); $req = $req->fetch_object()->lurl; echo $req; } catch (Exception $e) { echo "Une erreur est survenue !" . $e->getMessage(); } } else { if (strtolower($object) == "prenom" || strtolower($object) == "prénom") { try { $req = $this->db->query("SELECT u_prenom as leprenom FROM utilisateur WHERE pseudo='{$user_session}' "); $req = $req->fetch_object()->leprenom; } catch (Exception $e) { echo "Une erreur est survenue !" . $e->getMessage(); } } } return $req; }
/** * Returns the object of the active session. * Tries to find an existing session. * Otherwise creates a new session. * * @return Session $session */ public function get() { // get session id $this->sessionID = $this->readSessionID(); $this->session = null; // get existing session if (!empty($this->sessionID)) { $this->session = $this->getExistingSession($this->sessionID); } // create new session if ($this->session == null) { $this->session = $this->create(); } self::$activeSession = $this->session; // call shouldInit event if (!defined('NO_IMPORTS')) { EventHandler::fireAction($this, 'shouldInit'); } // init session $this->session->init(); // call didInit event if (!defined('NO_IMPORTS')) { EventHandler::fireAction($this, 'didInit'); } return $this->session; }
/** @test */ public function endShouldEmitEndEvent() { $dog = new Dog(); $session = new Session(0, $dog); $session->on('end', $this->expectCallableOnce()); $session->end(); }
public function control() { $session = new Session(); $dao = DAOFactory::getDAO('OwnerDAO'); $this->setViewTemplate('session.resetpassword.tpl'); $this->disableCaching(); if (!isset($_GET['token']) || !preg_match('/^[\\da-f]{32}$/', $_GET['token']) || !($user = $dao->getByPasswordToken($_GET['token']))) { // token is nonexistant or bad $this->addErrorMessage('You have reached this page in error.'); return $this->generateView(); } if (!$user->validateRecoveryToken($_GET['token'])) { $this->addErrorMessage('Your token is expired.'); return $this->generateView(); } if (isset($_POST['password'])) { if ($_POST['password'] == $_POST['password_confirm']) { if ($dao->updatePassword($user->email, $session->pwdcrypt($_POST['password'])) < 1) { echo "not updated"; } $login_controller = new LoginController(true); $login_controller->addSuccessMessage('You have changed your password.'); return $login_controller->go(); } else { $this->addErrorMessage("Passwords didn't match."); } } else { if (isset($_POST['Submit'])) { $this->addErrorMessage('Please enter a new password.'); } } return $this->generateView(); }
function __construct() { $sessi = new Session(); $getUserSes = $sessi->get_session('login'); $this->user = $getUserSes['login']['login']; $this->prefix = "lelang"; }
public function shopId() { $session = new Session(); $session->open(); $shop = AdminUser::find($session['pk'])->one(); return $shop->shopid; }
public function executeFilter(Request $request, Session $session, $renderer) { $this->addHeadLink('images/favicon.ico', 'icon', 'image/x-icon'); $this->addHeadLink('images/favicon.ico', 'shortcut icon', 'image/x-icon'); // Check permission // add your permission checker code here // check if user has signed in? // get user $user = $session->get('user'); if (empty($user)) { $this->forward('Security', 'Login'); } // make the current signed in user's info available to the view. $data = $user->getAllData(); if (is_array($data)) { foreach ($data as $k => $v) { $this->setAttribute('session_user_' . $k, $v); } } $this->setModel('current_date', date('m/d/Y H:i', time())); if (strcmp($this->_currentModule, 'Security') == 0) { // change this to the module and controller for forwarding when // the requested module is Security $this->forward('Admin', 'Index'); } $this->_includeHeader(); }
public function __construct(Session $session) { $this->_session = $session->get('alerts'); // Load any previously saved messages. $this->messages = (array) $this->_session->messages; unset($this->_session->messages); }
public function upload() { $sesion = new Session(); $user = $sesion->get("user"); $directorio = $_POST['categorias']; if ($this->error) { return false; } if ($_FILES[$this->parametro]["error"] != UPLOAD_ERR_OK) { return false; } if ($_FILES[$this->parametro]["size"] > $this->tamaño) { return false; } if (!$this->isTipo($this->extension)) { return false; } if (!(is_dir($this->destino) && substr($this->destino, -1) === "/")) { return false; } if ($this->politica === self::CONSERVAR && file_exists($this->destino . $this->nombre . "." . $this->extension)) { return false; } $nombre = $this->nombre; if ($this->politica === self::RENOMBRAR && file_exists("../subir/" . $user . "/" . $directorio . "/" . $this->nombre . "." . $this->extension)) { $nombre = $this->renombrar($nombre, $user, $directorio); } if (!self::directory($user, $directorio)) { return mkdir("../subir/" . $user . "/" . $directorio) + move_uploaded_file($_FILES[$this->parametro]["tmp_name"], $user . "./" . $directorio . "/" . $nombre . "." . $this->extension); } else { return move_uploaded_file($_FILES[$this->parametro]["tmp_name"], $user . "/" . $directorio . "/" . $nombre . "." . $this->extension); } }
function __construct() { parent::__construct(); $session = new Session(); $getSessi = $session->get_session(); $this->user = $getSessi['ses_user']['login']; }
function zip_start() { // Create a new instance of the Session object, and get the channel information. $session = new Session(); $from_info = $session->getFrom(); $channel = $from_info['channel']; // Create a new instance of the Tropo object. $tropo = new Tropo(); // See if any text was sent with session start. $initial_text = $session->getInitialText(); // If the initial text is a zip code, skip the input collection and get weather information. if (strlen($initial_text) == 5 && is_numeric($initial_text)) { formatWeatherResponse($tropo, $initial_text); } else { // Welcome prompt (for phone channel, and IM/SMS sessions with invalid initial text). $tropo->say("Welcome to the Tropo PHP zip code example for {$channel}"); // Set up options form zip code input $options = array("attempts" => 3, "bargein" => true, "choices" => "[5 DIGITS]", "name" => "zip", "timeout" => 5); // Ask the user for input, pass in options. $tropo->ask("Please enter your 5 digit zip code.", $options); // Tell Tropo what to do when the user has entered input, or if there is an error. $tropo->on(array("event" => "continue", "next" => "get_zip_code.php?uri=end", "say" => "Please hold.")); $tropo->on(array("event" => "error", "next" => "get_zip_code.php?uri=error", "say" => "An error has occured.")); } // Render the JSON for the Tropo WebAPI to consume. return $tropo->RenderJson(); }
protected function buildData() { $session = new Session(); $cryptpass = $session->pwdcrypt("oldpassword"); $builder = FixtureBuilder::build('owners', array('id' => 1, 'full_name' => 'ThinkUp J. User', 'email' => '*****@*****.**', 'pwd' => $cryptpass, 'activation_code' => 8888, 'is_activated' => 1)); return $builder; }
public function control() { $this->setPageTitle('Log in'); $this->setViewTemplate('session.login.tpl'); $this->view_mgr->addHelp('login', 'userguide/accounts/index'); $this->disableCaching(); //don't show login form if already logged in if ($this->isLoggedIn()) { $controller = new DashboardController(true); return $controller->go(); } else { $owner_dao = DAOFactory::getDAO('OwnerDAO'); if (isset($_POST['Submit']) && $_POST['Submit'] == 'Log In' && isset($_POST['email']) && isset($_POST['pwd'])) { if ($_POST['email'] == '' || $_POST['pwd'] == '') { if ($_POST['email'] == '') { $this->addErrorMessage("Email must not be empty"); return $this->generateView(); } else { $this->addErrorMessage("Password must not be empty"); return $this->generateView(); } } else { $session = new Session(); $user_email = $_POST['email']; if (get_magic_quotes_gpc()) { $user_email = stripslashes($user_email); } $this->addToView('email', $user_email); $owner = $owner_dao->getByEmail($user_email); if (!$owner) { $this->addErrorMessage("Incorrect email"); return $this->generateView(); } elseif (!$owner->is_activated) { $this->addErrorMessage("Inactive account. " . $owner->account_status . ". " . '<a href="forgot.php">Reset your password.</a>'); return $this->generateView(); } elseif (!$session->pwdCheck($_POST['pwd'], $owner_dao->getPass($user_email))) { //failed login if ($owner->failed_logins >= 10) { $owner_dao->deactivateOwner($user_email); $owner_dao->setAccountStatus($user_email, "Account deactivated due to too many failed logins"); } $owner_dao->incrementFailedLogins($user_email); $this->addErrorMessage("Incorrect password"); return $this->generateView(); } else { // this sets variables in the session $session->completeLogin($owner); $owner_dao->updateLastLogin($user_email); $owner_dao->resetFailedLogins($user_email); $owner_dao->clearAccountStatus(''); $controller = new DashboardController(true); return $controller->control(); } } } else { return $this->generateView(); } } }
public function __construct() { parent::__construct(); $this->loadmodule(); $this->view = $this->setSmarty(); $sessionAdmin = new Session(); $this->admin = $sessionAdmin->get_session(); }
function __construct() { $session = new Session(); $getSessi = $session->get_session(); $this->user = $getSessi['login']; $this->loadmodule(); $this->salt = '12345678PnD'; }
/** * Set page width * * @param string $width */ public function width($width) { $this->session->set('page_width', $width == 'wide' ? 'liquid' : 'fixed'); if (request::is_ajax()) { return; } url::back(); }