/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (!$this->session->has('lastActivityTime')) { $this->session->put('lastActivityTime', time()); } else { if (time() - $this->session->get('lastActivityTime') > $this->getTimeOut()) { $this->session->forget('lastActivityTime'); Auth::logout(); return redirect($this->getRedirectUrl())->with([$this->getSessionLabel() => 'You have been inactive for ' . $this->timeout / 60 . ' minutes ago.']); } } $this->session->put('lastActivityTime', time()); return $next($request); }
public static function checkSession() { $engine = EngineAPI::singleton(); $localvars = localvars::getInstance(); if (!session::has('username')) { header('Location:/login'); } return true; }
/** * @brief Constructor * * @param Mixed $stateid The state ID to access * @throw BaseException */ function __construct($stateid = null) { if ($stateid == null) { $this->state = self::$pstate; } else { if (session::has('viewstate_' . $stateid)) { $this->state = session::get('viewstate_' . $stateid); } else { throw new BaseException("No viewstate found with id"); } } }
public function setupForm($id = null) { try { // call engine $engine = EngineAPI::singleton(); $localvars = localvars::getInstance(); $validate = new validate(); // create customer form $form = formBuilder::createForm('TimeTracker'); $form->linkToDatabase(array('table' => 'timeTracking')); if (!is_empty($_POST) || session::has('POST')) { $processor = formBuilder::createProcessor(); $processor->processPost(); } // form titles $form->insertTitle = ""; $form->editTitle = ""; $form->updateTitle = ""; // if no valid id throw an exception if (!$validate->integer($id) && !isnull($id)) { throw new Exception(__METHOD__ . '() - Not a valid integer, please check the integer and try again.'); } // form information $form->addField(array('name' => 'timeID', 'type' => 'hidden', 'value' => $id, 'primary' => TRUE, 'fieldClass' => 'id', 'showIn' => array(formBuilder::TYPE_INSERT, formBuilder::TYPE_UPDATE))); $form->addField(array('name' => 'projectIdLink', 'type' => 'hidden', 'label' => 'Project ID:', 'required' => TRUE, 'fieldClass' => 'projectID')); $form->addField(array('name' => 'customerIdLink', 'type' => 'hidden', 'label' => 'Customer ID:', 'fieldClass' => 'customerID', 'required' => TRUE)); $form->addField(array('name' => 'startTime', 'type' => 'hidden', 'label' => 'start time:', 'fieldClass' => 'startTime', 'required' => TRUE)); $form->addField(array('name' => 'endTime', 'type' => 'hidden', 'label' => 'end time:', 'fieldClass' => 'endTime', 'required' => TRUE)); $form->addField(array('name' => 'totalHours', 'type' => 'hidden', 'label' => 'total time:', 'required' => TRUE, 'fieldClass' => 'totalHours')); $form->addField(array('name' => "completed", 'label' => "Has this project been completed?", 'showInEditStrip' => TRUE, 'type' => 'boolean', 'duplicates' => TRUE, 'options' => array("YES", "N0"))); $form->addField(array('name' => "descriptionOfWork", 'label' => "Enter a description of the project:", 'type' => 'textarea')); // buttons and submissions $form->addField(array('showIn' => array(formBuilder::TYPE_UPDATE), 'name' => 'update', 'type' => 'submit', 'fieldClass' => 'submit', 'value' => 'Update')); $form->addField(array('showIn' => array(formBuilder::TYPE_UPDATE), 'name' => 'delete', 'type' => 'delete', 'fieldClass' => 'delete hidden', 'value' => 'Delete')); $form->addField(array('showIn' => array(formBuilder::TYPE_INSERT), 'name' => 'insert', 'type' => 'submit', 'fieldClass' => 'submit', 'value' => 'Submit')); return '{form name="TimeTracker" display="form"}'; } catch (Exception $e) { errorHandle::errorMsg($e->getMessage()); } }
public function setupForm($id = null) { try { // call engine $engine = EngineAPI::singleton(); $localvars = localvars::getInstance(); $validate = new validate(); // create customer form $form = formBuilder::createForm('Projects'); $form->linkToDatabase(array('table' => 'projects')); if (!is_empty($_POST) || session::has('POST')) { $processor = formBuilder::createProcessor(); $processor->processPost(); } // form titles $form->insertTitle = "Add Project"; $form->editTitle = "Edit Project"; $form->updateTitle = "Edit Project"; // if no valid id throw an exception if (!$validate->integer($id) && !isnull($id)) { throw new Exception(__METHOD__ . '() - Not a valid integer, please check the integer and try again.'); } // form information $form->addField(array('name' => 'projectID', 'type' => 'hidden', 'value' => $id, 'primary' => TRUE, 'fieldClass' => 'id', 'showIn' => array(formBuilder::TYPE_INSERT, formBuilder::TYPE_UPDATE))); $form->addField(array('name' => 'customerID', 'label' => 'What customer owns this project?', 'type' => 'select', 'blankOption' => 'Select a Customer', 'linkedTo' => array('foreignTable' => 'customers', 'foreignField' => 'id', 'foreignLabel' => 'companyName'))); $form->addField(array('name' => 'projectName', 'label' => 'Project Name:', 'required' => TRUE)); $form->addField(array('name' => 'scope', 'label' => 'A simple statement of the scope of work being done:', 'required' => TRUE)); $form->addField(array('name' => 'type', 'label' => 'Project Type:', 'required' => TRUE, 'type' => 'select', 'options' => array('design' => 'Design', 'development' => 'Programming or Development', 'consult' => 'Meeting or Consultation', 'other' => 'other'))); $form->addField(array('name' => "completed", 'label' => "Has this project been completed?", 'showInEditStrip' => TRUE, 'type' => 'boolean', 'duplicates' => TRUE, 'options' => array("YES", "N0"))); $form->addField(array('name' => "description", 'label' => "Enter a description of the project:", 'type' => 'textarea')); // buttons and submissions $form->addField(array('showIn' => array(formBuilder::TYPE_UPDATE), 'name' => 'update', 'type' => 'submit', 'fieldClass' => 'submit', 'value' => 'Update')); $form->addField(array('showIn' => array(formBuilder::TYPE_UPDATE), 'name' => 'delete', 'type' => 'delete', 'fieldClass' => 'delete hidden', 'value' => 'Delete')); $form->addField(array('showIn' => array(formBuilder::TYPE_INSERT), 'name' => 'insert', 'type' => 'submit', 'fieldClass' => 'submit', 'value' => 'Submit')); return '{form name="Projects" display="form"}'; } catch (Exception $e) { errorHandle::errorMsg($e->getMessage()); } }
public function setupForm($id = null) { try { // call engine $engine = EngineAPI::singleton(); $localvars = localvars::getInstance(); $validate = new validate(); // create customer form $form = formBuilder::createForm('Customers'); $form->linkToDatabase(array('table' => 'customers')); if (!is_empty($_POST) || session::has('POST')) { $processor = formBuilder::createProcessor(); $processor->processPost(); } // form titles $form->insertTitle = "Add Customer"; $form->editTitle = "Edit Customer"; $form->updateTitle = "Edit Customer"; // if no valid id throw an exception if (!$validate->integer($id) && !isnull($id)) { throw new Exception(__METHOD__ . '() - Not a valid integer, please check the integer and try again.'); } // form information $form->addField(array('name' => 'ID', 'type' => 'hidden', 'value' => $id, 'primary' => TRUE, 'fieldClass' => 'id', 'showIn' => array(formBuilder::TYPE_INSERT, formBuilder::TYPE_UPDATE))); $form->addField(array('name' => 'firstName', 'label' => 'First Name:', 'required' => TRUE)); $form->addField(array('name' => 'lastName', 'label' => 'Last Name:', 'required' => TRUE)); $form->addField(array('name' => 'companyName', 'label' => 'Company Name:', 'required' => TRUE)); $form->addField(array('name' => 'email', 'label' => 'Customer Email:', 'required' => TRUE)); $form->addField(array('name' => 'phone', 'label' => 'Customer Phone Number:', 'required' => TRUE)); $form->addField(array('name' => "website", 'label' => "Customers Website:", 'type' => 'URL')); // buttons and submissions $form->addField(array('showIn' => array(formBuilder::TYPE_UPDATE), 'name' => 'update', 'type' => 'submit', 'fieldClass' => 'submit', 'value' => 'Update')); $form->addField(array('showIn' => array(formBuilder::TYPE_UPDATE), 'name' => 'delete', 'type' => 'delete', 'fieldClass' => 'delete hidden', 'value' => 'Delete')); $form->addField(array('showIn' => array(formBuilder::TYPE_INSERT), 'name' => 'insert', 'type' => 'submit', 'fieldClass' => 'submit', 'value' => 'Submit')); return '{form name="Customers" display="form"}'; } catch (Exception $e) { errorHandle::errorMsg($e->getMessage()); } }
$localvars = localvars::getInstance(); // username $username = dbSanitize(session::get('username')); // rating sys $starHTML = '<div class="rating-system"> <span class="star" data-star="1"></span> <span class="star" data-star="2"></span> <span class="star" data-star="3"></span> <span class="star" data-star="4"></span> <span class="star" data-star="5"></span> </div>'; // create customer form $form = formBuilder::createForm('setup'); $form->linkToDatabase(array('table' => 'setupSurvey')); if (!is_empty($_POST) || session::has('POST')) { $processor = formBuilder::createProcessor(); $processor->setCallback('beforeInsert', 'feedbackCheck'); $processor->processPost(); } // form titles $form->insertTitle = "Setup Survey"; $form->editTitle = ""; $form->updateTitle = ""; $form->template = "learningAppTemp"; // form information $form->addField(array('name' => 'ssID', 'type' => 'hidden', 'primary' => TRUE, 'fieldClass' => 'id', 'showIn' => array(formBuilder::TYPE_INSERT, formBuilder::TYPE_UPDATE))); $form->addField(array('name' => 'ipAddr', 'type' => 'hidden', 'fieldClass' => 'ip', 'value' => $_SERVER['REMOTE_ADDR'], 'showIn' => array(formBuilder::TYPE_INSERT, formBuilder::TYPE_UPDATE))); $form->addField(array('name' => 'username', 'type' => 'hidden', 'label' => 'Username:'******'value' => $username, 'required' => TRUE, 'fieldClass' => 'username')); $form->addField(array('name' => 'starRating', 'type' => 'plaintext', 'label' => 'How easy would you consider your choice, based on this lesson, would be to setup?', 'fieldClass' => 'starRating', 'value' => $starHTML)); $form->addField(array('name' => 'rating', 'type' => 'hidden', 'label' => '--', 'fieldClass' => 'rating'));
<?php $localvars = localvars::getInstance(); //do session checks $sessionCheck = User::performChecks(); // set session tracker up if (session::has('completePages')) { $thisPage = $localvars->get('pageName'); $pages = session::get('completePages'); $lesson = $thisPage . "Lesson"; $survey = $thisPage . "LessonSurvey"; if (in_array($lesson, $pages) && in_array($survey, $pages)) { $localvars->set('tracker', 'doNotTrack'); } else { $localvars->set('tracker', 'track'); } } else { $localvars->set('tracker', 'track'); }
use Illuminate\Support\Facades\Session; /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the controller to call when that URI is requested. | */ Route::get('/', function () { session::regenerate(); session::put("name", "haitham"); if (!session::has("name")) { return redirect('user/unauthenticated'); } return view('login'); }); Route::get('/users', "testcontroller@allusers"); Route::get('/employee', function () { return view('employee'); }); Route::get('test', function () { $phpWord = new \PhpOffice\PhpWord\PhpWord(); $section = $phpWord->createSection(); $section->addText('Hello World!'); $file = 'HelloWorld.docx'; header("Content-Description: File Transfer"); header('Content-Disposition: attachment; filename="' . $file . '"');
public function confirm($confirmation_code) { if (!$confirmation_code) { Session::flash('alert-class', 'alert-warning'); return Redirect::to('users/dashboard')->with('message', 'That confirmtion link is bad. Click on accounts to send another one')->with('alert-class', 'alert-danger')->withInput(); } $user = User::whereConfirmationCode($confirmation_code)->first(); if (!$user) { Session::flash('alert-class', 'alert-warning'); return Redirect::to('users/dashboard')->with('message', 'That confirmtion link is bad. Click on accounts to send another one')->with('alert-class', 'alert-danger')->withInput(); } $user->confirmed = 1; $user->confirmation_code = null; $user->save(); //if there is a live order then redirect to that quote page if (session::has('order')) { return Redirect::to('quote/' . session::get('order') . '')->with('registerMessage', 'You are now verified and logged in.')->with('type', 'success'); } //otherwise go to the dashboard return Redirect::to('users/dashboard')->with('message', 'You are now verified and logged in.')->with('alert-class', 'alert-success')->withInput(); }
<?php if (session::has('username')) { $localvars = localvars::getInstance(); $user = session::get('username'); $localvars->set('user', $user); $completedModules = User::numCompleted(session::get('username')); switch ($completedModules) { case 0: $progress = "5%"; break; case 1: $progress = "10%"; break; case 2: $progress = "20%"; break; case 3: $progress = "30%"; break; case 4: $progress = "40%"; break; case 5: $progress = "50%"; break; case 6: $progress = "60%"; break; case 7: $progress = "70%";
public static function updateFormInstance($token, array $data) { if (!session::has('fp')) { session::set('fp', array()); } $fpdata = session::get('fp'); $fpdata[$token] = $data; session::set('fp', $fpdata); }
<?php require_once "../includes/engine.php"; templates::display('header'); if (isset($_POST['MYSQL']) && !session::has('username')) { $data = dbSanitize($_POST['MYSQL']); $username = $data['username']; $email = $data['email']; if (User::checkUser($username, $email) === true) { $options['timeout'] = strtotime('+2 years', time()); session::set('username', $username, $options); header('Location:/welcomeback'); } else { header('Location:/login?failed'); } } if (isset($_GET['MYSQL']['failed'])) { $localvars->set('feedback', '<div class="error-message"> Login failed please check your password, or <a href="/"> register your account. </a> </div>'); } ?> <section class="wrapper"> <div class="container"> <form class="registerUser" action="<?php print htmlspecialchars($_SERVER["PHP_SELF"]); ?> " method="post"> <div class="feedback"> {local var="feedback"} </div> {csrf} <div class='username form-group'>