Esempio n. 1
0
function session_test()
{
    tem_load('code/wfpl/test/session_test.html');
    db_delete('wfpl_sessions');
    db_delete('wfpl_session_data');
    session_dump('Clean slate');
    session_new();
    session_dump('new session');
    session_set('username', 'jason');
    session_dump('username jason');
    session_set('username', 'phil');
    session_dump('overwrote username as phil');
    $old = $GLOBALS['session_id'];
    session_new();
    session_dump('new session');
    session_set('username', 'jason');
    session_set('bamph', 'foo');
    session_dump('set username=jason and bamph=foo in new session');
    session_clear('username');
    session_dump('cleared username in new session');
    _kill_session($old);
    session_dump('killed old session');
    kill_session();
    session_dump('kill_session()');
    tem_output();
}
Esempio n. 2
0
 function logout()
 {
     fetch_session();
     //clear sessions
     session_clear();
     addSuccess(getTxt('LogOutSuccess'));
     redirect('/home', 'refresh');
 }
Esempio n. 3
0
/**
 * Menghapus Semua Session
 *
 * @return  void
 */
function session_clear($key)
{
    if (is_array($key)) {
        foreach ($key as $k) {
            session_clear($k);
        }
    } else {
        if (isset($_SESSION[$key])) {
            unset($_SESSION[$key]);
        }
    }
}
Esempio n. 4
0
function session_restore_messages()
{
    if (!session_exists()) {
        return false;
    }
    $messages = session_get('wfpl_messages');
    if ($messages !== false) {
        $messages = string_to_array($messages);
        if (!(isset($GLOBALS['wfpl_messages']) && is_array($GLOBALS['wfpl_messages']))) {
            $GLOBALS['wfpl_messages'] = array();
        }
        # messages from the previous run happened first
        $GLOBALS['wfpl_messages'] = array_merge($messages, $GLOBALS['wfpl_messages']);
    }
    session_clear('wfpl_messages');
}
Esempio n. 5
0
require $libPath . "faqforge-config.inc";
require $libPath . "functions.inc";
session_start();
function session_clear()
{
    // if session exists, unregister all variables that exist and destroy session
    $exists = "no";
    $session_array = explode(";", session_encode());
    for ($x = 0; $x < count($session_array); $x++) {
        $name = substr($session_array[$x], 0, strpos($session_array[$x], "|"));
        if (session_is_registered($name)) {
            session_unregister('$name');
            $exists = "yes";
        }
    }
    if ($exists != "no") {
        session_destroy();
    }
}
session_clear();
$dbLink = mysql_connect($dbServer, $dbUser, $dbPass);
mysql_select_db($dbName);
$q = "truncate FaqPage";
mysql_query($q, $dbLink);
$q = "truncate Faq";
mysql_query($q, $dbLink);
print "<html><head></head><body>DB cleared!</body></html>";
mysql_close($dbLink);
?>

Esempio n. 6
0
function session_set($name, $value)
{
    session_clear($name);
    db_insert('wfpl_session_data', 'session_id,name,value', $GLOBALS['session_id'], $name, $value);
}
Esempio n. 7
0
 /**
  * Method untuk memulai aplikasi
  *
  * @param   string  $modDir  Module directori
  * @return  string
  */
 public function start($modDir = 'modules')
 {
     try {
         $uri = $this->get('uri');
         $module = $this->get('modules');
         foreach ($module->all() as $mod) {
             $init = ucfirst($mod) . '::initialize';
             if (is_callable($init)) {
                 call_user_func($init, $this, $this->conf);
             }
         }
         $this->add('asset.css', function ($c, $name) {
             $out = [];
             foreach ($c->get($name) as $css) {
                 $out[] = '<link href="' . site_url($css) . '" rel="stylesheet">';
             }
             return implode(PHP_EOL, $out);
         });
         $this->add('asset.js', function ($c, $name) {
             $out = [];
             foreach ($c->get($name) as $js) {
                 $out[] = '<script src="' . site_url($js) . '"></script>';
             }
             return implode(PHP_EOL, $out);
         });
         $routes = $this->get('routes');
         $path = $uri->path() ?: $this->conf('basemod');
         list($route) = explode('/', $path);
         if (isset($routes[$route])) {
             $path = str_replace($route, $routes[$route], $path);
         }
         $response = $module->call($path);
         if (is_array($response) or is_object($response)) {
             $response = json_encode($response);
         }
         echo $response;
         if (session('flash')) {
             session('flash', null);
             session_clear('flash');
         }
     } catch (Exception $e) {
         echo $this->show404($e->getMessage());
         exit;
     }
 }
Esempio n. 8
0
 public function logout()
 {
     session(['auth' => 0, 'id' => '', 'username' => '', 'level' => '']);
     session_clear(['auth', 'id', 'username', 'level']);
     redirect('');
 }
Esempio n. 9
0
 /**
  *
  * @SWG\Api(
  *   path="/login",
  *   description="API for user actions",
  * @SWG\Operation(
  *    method="POST",
  *    type="User",
  *    summary="Logs in a user",
  * @SWG\Parameter(
  *     name="username",
  *     description="Username of the user (Should be at least five characters long)",
  *     paramType="form",
  *     required=true,
  *     type="string"
  *     ),
  * @SWG\Parameter(
  *     name="password",
  *     description="Password of the user (Should be at least six characters long)",
  *     paramType="form",
  *     required=true,
  *     type="string"
  *     ),
  * @SWG\Parameter(
  *     name="invite_key",
  *     description="The invite key that the user is using to join a team",
  *     paramType="form",
  *     required=false,
  *     type="string"
  *     ),
  * @SWG\Parameter(
  *     name="invite_type",
  *     description="The invite type that the user is using (either 'team' or 'project')",
  *     paramType="form",
  *     required=false,
  *     type="string"
  *     )
  *   )
  * )
  */
 public function login_post()
 {
     $this->load->model(array('Team', 'Team_Invite', 'Project_Invite', 'Project', 'Subscription'));
     $this->load->library('form_validation');
     $this->form_validation->set_rules('username', 'Username', 'trim|required|min_length[5]|xss_clean');
     $this->form_validation->set_rules('password', 'Password', 'trim|required|min_length[6]|xss_clean');
     $this->form_validation->set_rules('invite_key', 'Invite Key', 'trim|xss_clean');
     $this->form_validation->set_rules('invite_type', 'Invite Type', 'trim|xss_clean|callback_validate_invite_type');
     if ($this->form_validation->run() == FALSE) {
         json_error('There was a problem with your submission: ' . validation_errors(' ', ' '));
         exit;
     } else {
         $username = $this->post('username', TRUE);
         $password = $this->post('password', TRUE);
         $user = $this->User->login($username, $password);
         if ($user && $user->id) {
             session_clear();
             $invite = $this->validate_invite($user);
             if ($invite) {
                 $this->process_invite($invite, $user);
             }
             $this->session->set_userdata(SESS_USER_ID, $user->id);
             $team = $this->Team->get_active_for_user($user->id);
             if ($team) {
                 $this->session->set_userdata(SESS_TEAM_ID, $team->id);
             }
             $subscription = $this->Subscription->load_by_field('user_id', $user->id);
             if ($subscription && !$subscription->failed) {
                 $this->session->set_userdata(SESS_SUBSCRIPTION_ID, $subscription->id);
             }
             log_message('info', 'Login - User ID: ' . $user->id . ', Username: '******'The username/password you have entered are invalid.');
 }