コード例 #1
2
ファイル: Application.php プロジェクト: x33n/ImpressPages
 /**
  * @ignore
  * @param array $options
  */
 public function prepareEnvironment($options = array())
 {
     if (empty($options['skipErrorHandler'])) {
         set_error_handler(array('Ip\\Internal\\ErrorHandler', 'ipErrorHandler'));
     }
     if (empty($options['skipError'])) {
         if (ipConfig()->showErrors()) {
             error_reporting(E_ALL | E_STRICT);
             ini_set('display_errors', '1');
         } else {
             ini_set('display_errors', '0');
         }
     }
     if (empty($options['skipSession'])) {
         if (session_id() == '' && !headers_sent()) {
             //if session hasn't been started yet
             session_name(ipConfig()->get('sessionName'));
             if (!ipConfig()->get('disableHttpOnlySetting')) {
                 ini_set('session.cookie_httponly', 1);
             }
             session_start();
         }
     }
     if (empty($options['skipEncoding'])) {
         mb_internal_encoding(ipConfig()->get('charset'));
     }
     if (empty($options['skipTimezone'])) {
         date_default_timezone_set(ipConfig()->get('timezone'));
         //PHP 5 requires timezone to be set.
     }
 }
コード例 #2
2
ファイル: class.session.php プロジェクト: brendo/symphony-3
 public static function start($lifetime = 0, $path = '/', $domain = NULL)
 {
     if (!self::$_initialized) {
         if (!is_object(Symphony::Database()) || !Symphony::Database()->connected()) {
             return false;
         }
         $cache = Cache::instance()->read('_session_config');
         if (is_null($cache) || $cache === false) {
             self::create();
             Cache::instance()->write('_session_config', true);
         }
         if (!session_id()) {
             ini_set('session.save_handler', 'user');
             ini_set('session.gc_maxlifetime', $lifetime);
             ini_set('session.gc_probability', '1');
             ini_set('session.gc_divisor', '3');
         }
         session_set_save_handler(array('Session', 'open'), array('Session', 'close'), array('Session', 'read'), array('Session', 'write'), array('Session', 'destroy'), array('Session', 'gc'));
         session_set_cookie_params($lifetime, $path, $domain ? $domain : self::getDomain(), false, false);
         if (strlen(session_id()) == 0) {
             if (headers_sent()) {
                 throw new Exception('Headers already sent. Cannot start session.');
             }
             session_start();
         }
         self::$_initialized = true;
     }
     return session_id();
 }
コード例 #3
0
 function tracker()
 {
     $session_id = session_id();
     $ip = $_SERVER['REMOTE_ADDR'];
     $referrer = isset($_SERVER['HTTP_REFERRER']) ? $_SERVER['HTTP_REFERRER'] : '';
     $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
     $created = time();
     // ERROR HERE..
     $date = date("Y-m-d");
     if (!$_SESSION['online']) {
         $query = "INSERT INTO people_online\tVALUES('" . session_id() . "', '{$date}', 'n', '{$ip}', '{$referrer}', '{$user_agent}')";
         if (!$this->query($query)) {
             $this->error();
         }
         // session_register('online');
         $_SESSION['online'] = true;
         //echo "Session ID (online 1): ".session_id();
     }
     #} else {
     if (isset($_SESSION['userID'])) {
         //echo "<br>Session ID (userID) for users: ".session_id();
         $query = "INSERT INTO people_online\tVALUES('" . session_id() . "', '{$date}', 'y', '{$ip}', '{$referrer}', '{$user_agent}')";
         if (!$this->query($query)) {
             $this->error();
         }
     }
     #}
 }
コード例 #4
0
ファイル: Csrf.php プロジェクト: akinyeleolubodun/PhireCMS2
 /**
  * Constructor
  *
  * Instantiate the CSRF form element object.
  *
  * @param  string $name
  * @param  string $value
  * @param  int    $expire
  * @param  string $indent
  * @return \Pop\Form\Element\Csrf
  */
 public function __construct($name, $value = null, $expire = 300, $indent = null)
 {
     // Start a session.
     if (session_id() == '') {
         session_start();
     }
     // If token does not exist, create one
     if (!isset($_SESSION['pop_csrf'])) {
         $this->token = array('value' => sha1(rand(10000, getrandmax()) . $value), 'expire' => (int) $expire, 'start' => time());
         $_SESSION['pop_csrf'] = serialize($this->token);
         // Else, retrieve existing token
     } else {
         $this->token = unserialize($_SESSION['pop_csrf']);
         // Check to see if the token has expired
         if ($this->token['expire'] > 0) {
             if ($this->token['expire'] + $this->token['start'] < time()) {
                 $this->token = array('value' => sha1(rand(10000, getrandmax()) . $value), 'expire' => (int) $expire, 'start' => time());
                 $_SESSION['pop_csrf'] = serialize($this->token);
             }
         }
     }
     parent::__construct('hidden', $name, $this->token['value'], null, $indent);
     $this->setRequired(true);
     $this->setValidator();
 }
コード例 #5
0
ファイル: Session.php プロジェクト: reneartweb/finnplus
 public static function Factory(&$source, $conf_file = NULL, $conf_section = NULL, $strict = TRUE)
 {
     if (!is_array($source)) {
         user_error('$source ' . $source . ' is not an array', E_USER_NOTICE);
     }
     $cage = new Inspekt_Cage_Session();
     $cage->_setSource($source);
     $cage->_parseAndApplyAutoFilters($conf_file);
     if (ini_get('session.use_cookies') || ini_get('session.use_only_cookies')) {
         if (isset($_COOKIE) && isset($_COOKIE[session_name()])) {
             session_id($_COOKIE[session_name()]);
         } elseif ($cookie = Inspekt::makeSessionCage()) {
             session_id($cookie->getAlnum(session_name()));
         }
     } else {
         // we're using session ids passed via GET
         if (isset($_GET) && isset($_GET[session_name()])) {
             session_id($_GET[session_name()]);
         } elseif ($cookie = Inspekt::makeSessionCage()) {
             session_id($cookie->getAlnum(session_name()));
         }
     }
     if ($strict) {
         $source = NULL;
     }
     return $cage;
     register_shutdown_function();
     register_shutdown_function(array($this, '_repopulateSession'));
 }
コード例 #6
0
ファイル: NativeSession.php プロジェクト: gitfreengers/larus
 /**
  * Starts the session if it does not exist.
  *
  * @return void
  */
 protected function startSession()
 {
     // Check that the session hasn't already been started
     if (session_id() == '' && !headers_sent()) {
         session_start();
     }
 }
コード例 #7
0
ファイル: SessionContext.php プロジェクト: que273/siremis
 /**
  * Constructor of SessionContext, init session and set session file path
  *
  * @return void
  **/
 function __construct()
 {
     if (defined('SESSION_PATH')) {
         session_save_path(SESSION_PATH);
     }
     if (is_writable(session_save_path())) {
         if (!defined('CLI') || CLI == 0) {
             session_start();
         }
     } else {
         // we cannot write in the session save path; aborting
         die("Unable to write in the session save path [" . session_save_path() . "]");
     }
     // retrieve objects data
     if (defined('SESSION_PATH')) {
         $this->_sessObjFileName = SESSION_PATH . "/" . session_id() . "_obj";
     }
     // record access time
     $curTime = time();
     if (isset($_SESSION["LastAccessTime"])) {
         $this->_lastAccessTime = $_SESSION["LastAccessTime"];
     } else {
         $this->_lastAccessTime = $curTime;
     }
     $_SESSION["LastAccessTime"] = $curTime;
     // see if timeout
     $this->_timeOut = false;
     if (TIMEOUT > 0 && $curTime - $this->_lastAccessTime > TIMEOUT) {
         $this->_timeOut = true;
     }
 }
コード例 #8
0
 /**
  * Receives oauth_verifier, requests for access_token and redirect to callback
  */
 public function oauth_callback()
 {
     if (!session_id()) {
         session_start();
     }
     $session = $_SESSION['_opauth_twitter'];
     unset($_SESSION['_opauth_twitter']);
     if (!empty($_REQUEST['oauth_token']) && $_REQUEST['oauth_token'] == $session['oauth_token']) {
         $this->tmhOAuth->config['user_token'] = $session['oauth_token'];
         $this->tmhOAuth->config['user_secret'] = $session['oauth_token_secret'];
         $params = array('oauth_verifier' => $_REQUEST['oauth_verifier']);
         $results = $this->_request('POST', $this->strategy['access_token_url'], $params);
         if ($results !== false && !empty($results['oauth_token']) && !empty($results['oauth_token_secret'])) {
             $credentials = $this->_verify_credentials($results['oauth_token'], $results['oauth_token_secret']);
             // 				print_r($credentials);exit;
             if (!empty($credentials['id'])) {
                 // Create a dummy email for registration purpose
                 $email = $credentials['screen_name'] . '@twitter.com';
                 $this->auth = array('uid' => $credentials['id'], 'info' => array('name' => $credentials['name'], 'nickname' => $credentials['screen_name'], 'email' => $email, 'urls' => array('twitter' => str_replace('{screen_name}', $credentials['screen_name'], $this->strategy['twitter_profile_url']))), 'credentials' => array('token' => $results['oauth_token'], 'secret' => $results['oauth_token_secret']), 'raw' => $credentials);
                 $this->mapProfile($credentials, 'location', 'info.location');
                 $this->mapProfile($credentials, 'description', 'info.description');
                 $this->mapProfile($credentials, 'profile_image_url', 'info.image');
                 $this->mapProfile($credentials, 'url', 'info.urls.website');
                 $this->callback();
             }
         }
     } else {
         $error = array('code' => 'access_denied', 'message' => 'User denied access.', 'raw' => $_GET);
         $this->errorCallback($error);
     }
 }
コード例 #9
0
 public function initialize($options = null)
 {
     if (session_id() != '') {
         self::$sessionStarted = true;
     }
     parent::initialize($options);
 }
コード例 #10
0
 public function call()
 {
     $that = $this;
     if (!$this->app->config('session.preventSession') && session_id() === '') {
         throw new \Exception('NotificationMiddleware needs \\Bono\\Middleware\\SessionMiddleware or php native session');
     }
     $this->app->hook('notification.error', function ($options) use($that) {
         $that->notify('error', $options);
     });
     $this->app->hook('notification.info', function ($options) use($that) {
         $that->notify('info', $options);
     });
     $this->app->filter('notification.show', function ($options = null) use($that) {
         return $that->show($options);
     });
     $this->app->filter('notification.message', function ($context) use($that) {
         $errors = $that->query(array('level' => 'error', 'context' => $context));
         if (!empty($errors)) {
             return $errors[0]['message'];
         }
     });
     $this->app->notification = $this;
     $this->populate();
     try {
         $this->next->call();
     } catch (INotifiedException $e) {
         h('notification.error', $e);
     }
     $this->save();
 }
コード例 #11
0
ファイル: apUploads.php プロジェクト: PapaKot/Horowitz
 function getMessage()
 {
     if (!session_id() && !headers_sent()) {
         session_start();
     }
     $mess = null;
     switch ($_SESSION['apMess'][$this->getMessSessionName()]) {
         case 'delete_ok':
             $mess = 'File delete';
             break;
         case 'delete_fail':
             $mess = 'Error! Record is not removed';
             break;
         case 'update_ok':
             $mess = 'The information has been updated successfully';
             break;
         case 'update_fail':
             $mess = 'Error update';
             break;
         case 'add_ok':
             $mess = 'File add';
             break;
         case 'add_fail':
             $mess = 'When adding an entry error has occurred';
             break;
     }
     $_SESSION['apMess'] = array();
     return $mess;
 }
コード例 #12
0
ファイル: class.pdf.php プロジェクト: sjhelios/trikemindo
 protected function setuserpdffont()
 {
     if (session_id() == '') {
         session_start();
     }
     if (isset($_SESSION['PDFLanguage'])) {
         $UserPdfLang = $_SESSION['PDFLanguage'];
         switch ($UserPdfLang) {
             case 0:
                 $UserPdfFont = 'times';
                 break;
             case 1:
                 $UserPdfFont = 'javierjp';
                 break;
             case 2:
                 $UserPdfFont = 'javiergb';
                 break;
             case 3:
                 $UserPdfFont = 'freeserif';
                 break;
         }
     } else {
         $UserPdfFont = 'helvetica';
     }
     $this->SetFont($UserPdfFont, '', 11);
     //     SetFont($family, $style='', $size=0, $fontfile='')
 }
コード例 #13
0
ファイル: EAjaxUpload.php プロジェクト: hipogea/zega
 public function run()
 {
     if (empty($this->config['action'])) {
         throw new CException('EAjaxUpload: param "action" cannot be empty.');
     }
     if (empty($this->config['allowedExtensions'])) {
         throw new CException('EAjaxUpload: param "allowedExtensions" cannot be empty.');
     }
     if (empty($this->config['sizeLimit'])) {
         throw new CException('EAjaxUpload: param "sizeLimit" cannot be empty.');
     }
     unset($this->config['element']);
     echo '<div id="' . $this->id . '"><noscript><p>Habilite Jva Script en este navegador para usar esta funcion .</p></noscript></div>';
     $assets = dirname(__FILE__) . '/assets';
     $baseUrl = Yii::app()->assetManager->publish($assets);
     Yii::app()->clientScript->registerScriptFile($baseUrl . '/fileuploader.js', CClientScript::POS_HEAD);
     $this->css = !empty($this->css) ? $this->css : $baseUrl . '/fileuploader.css';
     Yii::app()->clientScript->registerCssFile($this->css);
     $postParams = array('PHPSESSID' => session_id(), 'YII_CSRF_TOKEN' => Yii::app()->request->csrfToken);
     if (isset($this->postParams)) {
         $postParams = array_merge($postParams, $this->postParams);
     }
     $config = array('element' => 'js:document.getElementById("' . $this->id . '")', 'debug' => false, 'multiple' => false);
     $config = array_merge($config, $this->config);
     $config['params'] = $postParams;
     $config = CJavaScript::encode($config);
     Yii::app()->getClientScript()->registerScript("FileUploader_" . $this->id, "var FileUploader_" . $this->id . " = new qq.FileUploader({$config}); ", CClientScript::POS_LOAD);
 }
コード例 #14
0
 /**
  * Open PHP SESSION using amazon provided sessionId, for storing data about the session.
  * Session cookie won't be sent.
  */
 public function openSession()
 {
     ini_set('session.use_cookies', 0);
     # disable session cookies
     session_id($this->parseSessionId($this->sessionId));
     return session_start();
 }
コード例 #15
0
 /**
  * logout
  */
 public function actionAuthorizeView($appkey, $clientid)
 {
     $sessionid = session_id();
     $map = $this->getRestMap();
     /**
      * @var AccessToken $token
      */
     try {
         Assert::hasText($appkey, "appkey传递参数为空!");
         Assert::hasText($clientid, "clientid传递参数为空!");
         $token = BCacheHelper::getToken($clientid, 'model');
         Assert::hasText($token, "token 查询结果为空!");
         //data
         $map["appkey"] = $token->appkey;
         $map["clientid"] = $token->clientid;
         $map["tokenid"] = $token->tokenid;
         $map[AjaxStatus::PROPERTY_MESSAGES] = "操作成功";
         $map[AjaxStatus::PROPERTY_STATUS] = AjaxStatus::STATUS_SUCCESSFUL;
         $map[AjaxStatus::PROPERTY_CODE] = AjaxStatus::CODE_OK;
     } catch (IllegalArgumentException $e) {
         $map[AjaxStatus::PROPERTY_STATUS] = AjaxStatus::STATUS_FAILED;
         $map[AjaxStatus::PROPERTY_CODE] = AjaxStatus::CODE_503;
         $map[AjaxStatus::PROPERTY_MESSAGES] = $e->getMessage();
     } catch (Exception $e) {
         $map[AjaxStatus::PROPERTY_STATUS] = AjaxStatus::STATUS_FAILED;
         $map[AjaxStatus::PROPERTY_CODE] = AjaxStatus::CODE_503;
         $map[AjaxStatus::PROPERTY_MESSAGES] = $e->getMessage();
     }
     echo SnapshotHelper::encodeArray($map);
 }
コード例 #16
0
function nextend_api_auth_flow()
{
    $api_key = NextendRequest::getVar('api_key');
    $api_secret = NextendRequest::getVar('api_secret');
    $redirect_uri = NextendRequest::getVar('redirect_uri');
    if (session_id() == "") {
        @session_start();
    }
    if (!$api_key || !$api_secret || !$redirect_uri) {
        $api_key = isset($_SESSION['api_key']) ? $_SESSION['api_key'] : null;
        $api_secret = isset($_SESSION['api_secret']) ? $_SESSION['api_secret'] : null;
        $redirect_uri = isset($_SESSION['redirect_uri']) ? $_SESSION['redirect_uri'] : null;
    } else {
        $_SESSION['api_key'] = $api_key;
        $_SESSION['api_secret'] = $api_secret;
        $_SESSION['redirect_uri'] = $redirect_uri;
    }
    if ($api_key && $api_secret) {
        require_once dirname(__FILE__) . "/api/Instagram.php";
        $config = array('client_id' => $api_key, 'client_secret' => $api_secret, 'redirect_uri' => $redirect_uri, 'grant_type' => 'authorization_code');
        $instagram = new Instagram($config);
        $accessCode = $instagram->getAccessCode();
        if ($accessCode === null) {
            $instagram->openAuthorizationUrl();
        } else {
            $accessToken = $instagram->getAccessToken();
            unset($_SESSION['api_key']);
            unset($_SESSION['api_secret']);
            unset($_SESSION['redirect_uri']);
            echo '<script type="text/javascript">';
            echo 'window.opener.setToken("' . $accessToken . '");';
            echo '</script>';
        }
    }
}
コード例 #17
0
function wsl_watchdog_log_to_database($action_name, $action_args = array(), $user_id = 0, $provider = '')
{
    global $wpdb;
    $sql = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}wslwatchdog` ( \n\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t  `session_id` varchar(50) NOT NULL,\n\t\t\t  `user_id` int(11) NOT NULL,\n\t\t\t  `user_ip` varchar(50) NOT NULL,\n\t\t\t  `url` varchar(450) NOT NULL,\n\t\t\t  `provider` varchar(50) NOT NULL,\n\t\t\t  `action_name` varchar(255) NOT NULL,\n\t\t\t  `action_args` text NOT NULL,\n\t\t\t  `is_connected` int(11) NOT NULL,\n\t\t\t  `created_at` varchar(50) NOT NULL,\n\t\t\t  PRIMARY KEY (`id`) \n\t\t\t)";
    $wpdb->query($sql);
    $wpdb->insert("{$wpdb->prefix}wslwatchdog", array("session_id" => session_id(), "user_id" => $user_id, "user_ip" => $_SERVER['REMOTE_ADDR'], "url" => wsl_get_current_url(), "provider" => $provider, "action_name" => $action_name, "action_args" => json_encode($action_args), "is_connected" => get_current_user_id() ? 1 : 0, "created_at" => microtime(true)));
}
コード例 #18
0
ファイル: TokenListenerTest.php プロジェクト: webpants/YAWIK
 /**
  * @dataProvider provideRequestParameterTestData
  * @runInSeparateProcess
  */
 public function testSetsSessionIdIfAuthParameterIsPassedWhenCalledAsListener($type, $token)
 {
     $event = $this->getMvcEventMock($type, array('auth' => $token));
     $target = new TokenListener();
     $target->onBootstrap($event);
     $this->assertEquals($token, session_id());
 }
コード例 #19
0
 /**
  * Returns the ID of the user session
  *
  * Automatically starts the session if necessary.
  *
  * @return string  The session ID
  */
 protected function getSessionId()
 {
     if (!session_id()) {
         session_start();
     }
     return session_id();
 }
コード例 #20
0
ファイル: Session.php プロジェクト: dulitharuvin/Ambula
 /**
  * starts the session
  */
 public static function init()
 {
     // if no session exist, start the session
     if (session_id() == '') {
         session_start();
     }
 }
コード例 #21
0
 public function run()
 {
     if (empty($this->config['action'])) {
         throw new CException('EAjaxUpload: param "action" cannot be empty.');
     }
     if (empty($this->config['allowedExtensions'])) {
         throw new CException('EAjaxUpload: param "allowedExtensions" cannot be empty.');
     }
     if (empty($this->config['sizeLimit'])) {
         throw new CException('EAjaxUpload: param "sizeLimit" cannot be empty.');
     }
     unset($this->config['element']);
     echo '<div id="' . $this->id . '"><noscript><p>Please enable JavaScript to use file uploader.</p></noscript></div>';
     //$assets = dirname(__FILE__).'/assets';
     //$baseUrl = Yii::app()->assetManager->publish($assets);
     //Yii::app()->clientScript->registerScriptFile($baseUrl . '/fileuploader.js', CClientScript::POS_HEAD);
     //$this->css=(!empty($this->css))?$this->css:$baseUrl.'/fileuploader.css';
     //Yii::app()->clientScript->registerCssFile($this->css);
     $this->css = !empty($this->css) ? $this->css : 'fileuploader.css';
     Yii::setPathOfAlias('ajaxupload', dirname(__FILE__));
     $cs = Yii::app()->getClientScript();
     $cs->packages['ajaxupload'] = array('basePath' => 'ajaxupload.assets', 'css' => array($this->css), 'js' => array('fileuploader.js'));
     $cs->registerPackage('ajaxupload');
     $postParams = array('PHPSESSID' => session_id(), 'YII_CSRF_TOKEN' => Yii::app()->request->csrfToken);
     if (isset($this->postParams)) {
         $postParams = array_merge($postParams, $this->postParams);
     }
     $config = array('button' => 'js:document.getElementById("' . $this->id . '")', 'debug' => false, 'multiple' => false);
     $config = array_merge($config, $this->config);
     $config['params'] = $postParams;
     $config = CJavaScript::encode($config);
     Yii::app()->getClientScript()->registerScript("FileUploader_" . $this->id, "var FileUploader_" . $this->id . " = new qq.FileUploaderBasic({$config}); ", CClientScript::POS_LOAD);
 }
コード例 #22
0
ファイル: swfupload.php プロジェクト: ubiopen/KI_Board
 function index()
 {
     if ($this->input->post('PHPSESSID')) {
         session_id($this->input->post('PHPSESSID'));
     } else {
         return FALSE;
     }
     if (is_uploaded_file($_FILES['Filedata']['tmp_name'])) {
         $config['allowed_types'] = $this->input->post('upload_ext');
         $config['upload_path'] = DATA_PATH . '/temp';
         $config['max_size'] = $this->input->post('upload_size');
         $config['encrypt_name'] = TRUE;
         $this->load->library('upload', $config);
         if ($this->upload->do_upload('Filedata')) {
             $data = $this->upload->data();
             $file = '/temp/' . $data['file_name'];
             $filedir = $this->config->item('base_url') . DATA_DIR . $file;
             $filepath = DATA_PATH . $file;
             if (strpos('.jpg.gif.png', strtolower($data['file_ext'])) !== FALSE) {
                 $info = array('imageurl' => $filedir, 'filename' => $data['orig_name'], 'filesize' => filesize($filepath), 'imagealign' => 'L', 'thumburl' => $filedir);
             } else {
                 $info = array('attachurl' => $filedir, 'filemime' => $data['file_type'], 'filename' => $data['orig_name'], 'filesize' => filesize($filepath));
             }
             echo json_encode($info);
         } else {
             echo $this->upload->display_errors('', '');
         }
     } else {
         return FALSE;
     }
 }
コード例 #23
0
ファイル: Session.php プロジェクト: clee03/metal
 public function init()
 {
     /** @var Uri $uri */
     $uri = $this->grav['uri'];
     $config = $this->grav['config'];
     $is_admin = false;
     $session_timeout = $config->get('system.session.timeout', 1800);
     $session_path = $config->get('system.session.path', '/' . ltrim($uri->rootUrl(false), '/'));
     // Activate admin if we're inside the admin path.
     if ($config->get('plugins.admin.enabled')) {
         $route = $config->get('plugins.admin.route');
         $base = '/' . trim($route, '/');
         if (substr($uri->route(), 0, strlen($base)) == $base) {
             $session_timeout = $config->get('plugins.admin.session.timeout', 1800);
             $is_admin = true;
         }
     }
     if ($config->get('system.session.enabled') || $is_admin) {
         // Define session service.
         parent::__construct($session_timeout, $session_path);
         $unique_identifier = GRAV_ROOT;
         $this->setName($config->get('system.session.name', 'grav_site') . '-' . substr(md5($unique_identifier), 0, 7) . ($is_admin ? '-admin' : ''));
         $this->start();
         setcookie(session_name(), session_id(), time() + $session_timeout, $session_path);
     }
 }
コード例 #24
0
ファイル: SessionStorage.php プロジェクト: unkerror/Budabot
 private static function generateId()
 {
     @session_start();
     $id = session_id();
     session_destroy();
     return $id;
 }
コード例 #25
0
 public static function set($key, $value)
 {
     if (empty(session_id())) {
         session_start();
     }
     $_SESSION[$key] = $value;
 }
コード例 #26
0
ファイル: jky_export.php プロジェクト: shadobladez/erp2
 public function query($domain, $postvars)
 {
     $this->log_proxy('  domain: ' . $domain);
     $this->log_proxy('POSTVARS: ' . $postvars);
     $ch = curl_init($domain);
     curl_setopt($ch, CURLOPT_POST, 0);
     curl_setopt($ch, CURLOPT_VERBOSE, 0);
     //   curl_setopt( $ch, CURLOPT_USERAGENT     , isset( $_SERVER[ 'User-Agent' ]) ? $_SERVER[ 'User-Agent' ] : '' );
     curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars);
     //   curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );
     curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
     curl_setopt($ch, CURLOPT_REFERER, $domain);
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
     curl_setopt($ch, CURLOPT_AUTOREFERER, 0);
     curl_setopt($ch, CURLOPT_COOKIEJAR, 'ses_' . session_id());
     curl_setopt($ch, CURLOPT_COOKIEFILE, 'ses_' . session_id());
     //   curl_setopt( $ch, CURLOPT_COOKIE        , $COOKIE );
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_FAILONERROR, 1);
     $content = curl_exec($ch);
     $response = curl_getinfo($ch);
     curl_close($ch);
     unlink('ses_' . session_id());
     return $content;
 }
コード例 #27
0
function regenerateSession($reload = false)
{
    // This token is used by forms to prevent cross site forgery attempts
    if (!isset($_SESSION['nonce']) || $reload) {
        $_SESSION['nonce'] = md5(microtime(true));
    }
    if (!isset($_SESSION['IPaddress']) || $reload) {
        $_SESSION['IPaddress'] = $_SERVER['REMOTE_ADDR'];
    }
    if (!isset($_SESSION['userAgent']) || $reload) {
        $_SESSION['userAgent'] = $_SERVER['HTTP_USER_AGENT'];
    }
    //$_SESSION['user_id'] = $this->user->getId();
    // Set current session to expire in 1 minute
    $_SESSION['OBSOLETE'] = true;
    $_SESSION['EXPIRES'] = time() + 60;
    // Create new session without destroying the old one
    session_regenerate_id(false);
    // Grab current session ID and close both sessions to allow other scripts to use them
    $newSession = session_id();
    session_write_close();
    // Set session ID to the new one, and start it back up again
    session_id($newSession);
    session_start();
    // Don't want this one to expire
    unset($_SESSION['OBSOLETE']);
    unset($_SESSION['EXPIRES']);
}
コード例 #28
0
 /**
  * Identical to the parent constructor, except that
  * we start a PHP session to store the user ID and
  * access token if during the course of execution
  * we discover them.
  *
  * @param Array $config the application configuration.
  * @see BaseFacebook::__construct in facebook.php
  */
 public function __construct($config)
 {
     if (!session_id()) {
         session_start();
     }
     parent::__construct($config);
 }
コード例 #29
-1
ファイル: sessionSwitcher.php プロジェクト: skdong/nfs-ovd
 /** Construction. This kills the current session if any started, and restart the given session */
 public function __construct($name, $cleanPreviousSession = false)
 {
     if (session_id() == "") {
         // Start a default session and save on the handler
         session_start();
         SessionSwitcher::$sessionArray[] = array('id' => session_id(), 'name' => session_name());
         session_write_close();
     }
     // Please note that there is no start here, session might be already started
     if (session_id() != "") {
         // There was a previous session
         if ($cleanPreviousSession) {
             if (isset($_COOKIE[session_name()])) {
                 setcookie(session_name(), '', time() - 42000, '/');
             }
             session_destroy();
         }
         // Close the session
         session_write_close();
         session_regenerate_id(false);
         $_SESSION = array();
         // Need to generate a new session id
     }
     session_id(md5(SessionSwitcher::$sessionArray[0]['id'] . $name));
     session_name($name);
     session_start();
 }
コード例 #30
-1
ファイル: Session.php プロジェクト: cygnite/framework
 public function __construct($name = null, $cacheLimiter = null, $wrapperInstance = null)
 {
     $this->name = $name;
     /*
     | Override native session handler
     */
     $this->sessionSaveHandler();
     /*
     | Get user configuration
     */
     $this->config = Config::get('config.session');
     /*
     | Set Database and Table for storing
     | session into database
     */
     $this->database($this->config['database_name']);
     $this->table($this->config['table']);
     $this->setWrapperInstance($wrapperInstance);
     /*
     |Check if session started if not we will start new session
     |if session started already we will try
     */
     if (!session_id()) {
         $this->start();
     }
     $this->storage =& $_SESSION;
     /*
     | Check csrf token already exists into session
     | else regenerate the token
     */
     $this->checkToken();
     // This line prevents unexpected effects when using objects as save handlers.
     register_shutdown_function('session_write_close');
 }