/** * Default Constructor * * @param array $config options * @access public */ public function __construct($config) { // _toPost keys are case sensitive for google api, changin them will result in bad authentication $_toPost['accountType'] = $config['accounttype']; $_toPost['Email'] = $config['email']; $_toPost['Passwd'] = $config['passwd']; $_toPost['service'] = $config['service']; $_toPost['source'] = $config['source']; $this->HttpSocket = new HttpSocket(); // Initializing Cake Session $session = new CakeSession(); $session->start(); // Validating if curl is available if (function_exists('curl_init')) { $this->_method = 'curl'; } else { $this->_method = 'fopen'; } // Looking for auth key in cookie of google api client login $cookie_key = $session->read('GoogleClientLogin' . $_toPost['service'] . '._auth_key'); if ($cookie_key == null || $cookie_key == "") { // Geting auth key via HttpSocket $results = $this->HttpSocket->post($this->_login_uri, $_toPost); $first_split = split("\n", $results); foreach ($first_split as $string) { $arr = split("=", $string); if ($arr[0] == "Auth") { $this->_auth_key = $arr[1]; } } $session->write('GoogleClientLogin' . $_toPost['service'] . '._auth_key', $this->_auth_key); } else { $this->_auth_key = $cookie_key; } }
function beforeFilter() { if (!CakeSession::started()) { CakeSession::start(); } $this->Auth->allow(); }
/** * 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. Additionally * accepts "sharedSession" as a boolean to turn on a secondary * cookie for environments with a shared session (that is, your app * shares the domain with other apps). * @see BaseFacebook::__construct in facebook.php */ public function __construct($config) { if (!session_id()) { CakeSession::start(); } parent::__construct($config); if (!empty($config['sharedSession'])) { $this->initSharedSession(); } }
/** * setUp method * * @return void */ public function setUp() { parent::setUp(); $controller = null; $this->View = new View($controller); $this->Flash = new FlashHelper($this->View); if (!CakeSession::started()) { CakeSession::start(); } CakeSession::write(array('Flash' => array('flash' => array('key' => 'flash', 'message' => 'This is a calling', 'element' => 'Flash/default', 'params' => array()), 'notification' => array('key' => 'notification', 'message' => 'Broadcast message testing', 'element' => 'flash_helper', 'params' => array('title' => 'Notice!', 'name' => 'Alert!')), 'classy' => array('key' => 'classy', 'message' => 'Recorded', 'element' => 'flash_classy', 'params' => array())))); }
/** * setUp method * * @access public * @return void */ function setUp() { parent::setUp(); $controller = null; $this->View = new View($controller); $this->Session = new SessionHelper($this->View); if (!CakeSession::started()) { CakeSession::start(); } $_SESSION = array('test' => 'info', 'Message' => array('flash' => array('element' => 'default', 'params' => array(), 'message' => 'This is a calling'), 'notification' => array('element' => 'session_helper', 'params' => array('title' => 'Notice!', 'name' => 'Alert!'), 'message' => 'This is a test of the emergency broadcasting system'), 'classy' => array('element' => 'default', 'params' => array('class' => 'positive'), 'message' => 'Recorded'), 'bare' => array('element' => null, 'message' => 'Bare message', 'params' => array())), 'Deeply' => array('nested' => array('key' => 'value'))); }
public function beforeFilter() { if (isset($_GET['xid']) && $_GET['xid'] != "undefined" && !empty($_GET['xid']) && $this->request->params['action'] == "handle_upload") { CakeSession::id($_GET['xid']); CakeSession::start(); } parent::beforeFilter(); //$this->Auth->allowedActions = array(); $this->Auth->allow(); $this->Auth->deny("challenge", "handle_upload"); $this->initPermissions(); //die(print_r($this->Auth)); $this->theme = "for-the-record"; if ($this->request->params['action'] == "view") { $this->request->params['action'] = "section"; $this->view = "section"; } }
/** * 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. Additionally * accepts "sharedSession" as a boolean to turn on a secondary * cookie for environments with a shared session (that is, your app * shares the domain with other apps). * * @see BaseFacebook::__construct */ public function __construct($config) { if (function_exists('session_status') && session_status() !== PHP_SESSION_ACTIVE || !session_id()) { CakeSession::start(); } parent::__construct($config); if (!empty($config['sharedSession'])) { $this->initSharedSession(); // re-load the persisted state, since parent // attempted to read out of non-shared cookie $state = $this->getPersistentData('state'); if (!empty($state)) { $this->state = $state; } else { $this->state = null; } } }
/** * 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. Additionally * accepts "sharedSession" as a boolean to turn on a secondary * cookie for environments with a shared session (that is, your app * shares the domain with other apps). * * @see BaseFacebook::__construct */ public function __construct($config) { if (!session_id()) { CakeSession::start(); //User CakePHP's session to replace original session_start() } parent::__construct($config); if (!empty($config['sharedSession'])) { $this->initSharedSession(); // re-load the persisted state, since parent // attempted to read out of non-shared cookie $state = $this->getPersistentData('state'); if (!empty($state)) { $this->state = $state; } else { $this->state = null; } } }
*/ $memoryLimit = (int) ini_get('memory_limit'); if ($memoryLimit < 32 && $memoryLimit != -1) { ini_set('memory_limit', '32M'); } /** * ロケール設定 * 指定しないと 日本語入りの basename 等が失敗する */ setlocale(LC_ALL, 'ja_JP.UTF-8'); /** * セッションスタート */ if (!isConsole()) { $Session = new CakeSession(); $Session->start(); } /** * Viewのキャッシュ設定・ログの設定 */ if (Configure::read('debug') == 0) { if (isset($_SESSION) && session_id()) { // 管理ユーザーでログインしている場合、ページ機能の編集ページへのリンクを表示する為、キャッシュをオフにする。 // ただし、現在の仕様としては、セッションでチェックしているので、ブラウザを閉じてしまった場合、一度管理画面を表示する必要がある。 // TODO ブラウザを閉じても最初から編集ページへのリンクを表示する場合は、クッキーのチェックを行い、認証処理を行う必要があるが、 // セキュリティ上の問題もあるので実装は検討が必要。 // bootstrapで実装した場合、他ページへの負荷の問題もある if (isset($_SESSION['Auth']['User'])) { Configure::write('Cache.check', false); } }
/** * Starts Session if SessionComponent is used in Controller::beforeFilter(), * or is called from * * @return boolean * @access private */ function __start() { if ($this->__started === false) { if (!$this->id() && parent::start()) { $this->__started = true; parent::_checkValid(); } else { $this->__started = parent::start(); } } return $this->__started; }
/** * Starts Session if SessionComponent is used in Controller::beforeFilter(), * or is called from * * @return boolean * @access private */ function __start() { if ($this->started() === false) { if (!$this->id() && parent::start()) { parent::_checkValid(); } else { parent::start(); } } return $this->started(); }
/** * Get/Set the session id. * * When fetching the session id, the session will be started * if it has not already been started. When setting the session id, * the session will not be started. * * @param string $id Id to use (optional) * @return string The current session id. */ public function id($id = null) { if (empty($id)) { CakeSession::start(); } return CakeSession::id($id); }
/** * Determine if Session has been started * and attempt to start it if not * * @return boolean true if Session is already started, false if * Session could not be started * @access public */ function __start() { if (!parent::started()) { parent::start(); } return true; }
/** * testSessionId method * * @return void */ public function testSessionId() { unset($_SESSION); $Session = new SessionComponent($this->ComponentCollection); CakeSession::start(); $this->assertEquals(session_id(), $Session->id()); }
public function beforeRender() { if ($this->request->params['controller'] == "media" || $this->skip_page_view == true) { return; } if ($this->request->params['controller'] == "news" && $this->request->params['isAjax']) { return; } if ($this->skip_page_view == true) { return; } $this->loadModel("PageView"); //check if we are mobile $mobile = false; if ($this->RequestHandler->isMobile()) { $mobile = true; } $domain_name = $_SERVER['HTTP_HOST']; $domain_name = str_replace("www.", "", $domain_name); $domains = array("dev.theberrics.com", "theberrics.com", "dev.batb4.thberrics.com", "batb4.theberrics.com", "aberrica.com", "dev.admin.theberrics.com"); if (!in_array($domain_name, $domains)) { } if (CakeSession::id() == '') { CakeSession::start(); } $data = array(); $data["geo_country"] = isset($_SERVER['GEOIP_COUNTRY_CODE']) ? $_SERVER['GEOIP_COUNTRY_CODE'] : NULL; $data["geo_region"] = isset($_SERVER['GEOIP_REGION']) ? $_SERVER['GEOIP_REGION'] : NULL; $data["geo_region_name"] = isset($_SERVER['GEOIP_REGION_NAME']) ? $_SERVER['GEOIP_REGION_NAME'] : NULL; $data["geo_dma_code"] = isset($_SERVER['GEOIP_DMA_CODE']) ? $_SERVER['GEOIP_DMA_CODE'] : NULL; $data["geo_postal_code"] = isset($_SERVER['GEOIP_POSTAL_CODE']) ? $_SERVER['GEOIP_POSTAL_CODE'] : NULL; $data["geo_city"] = isset($_SERVER['GEOIP_CITY']) ? $_SERVER['GEOIP_CITY'] : NULL; $data["session"] = $this->Session->id(); $data["ip_address"] = $_SERVER['GEOIP_ADDR']; $data["domain_name"] = $domain_name; $data["script_url"] = $this->request->here; $data["mobile"] = $mobile; $this->PageView->save($data); }
/** * HTTPSによるSession設定テスト * * @param int $expects 予測値 * @param string $siteUrl BcEnv.siteUrlの値 * @param string $sslUrl BcEnv.sslUrlの値 * @return void * * @dataProvider sessionConfigureUrlDataProvider */ public function testSessionConfigureUrl($expects, $siteUrl, $sslUrl) { if (CakeSession::started()) { CakeSession::destroy(); } // p(CakeSession::started()); ini_set('session.cookie_secure', 0); Configure::write('BcEnv.siteUrl', $siteUrl); Configure::write('BcEnv.sslUrl', $sslUrl); require APP . 'Config' . DS . 'session.php'; CakeSession::start(); $this->assertEquals($expects, intval(ini_get('session.cookie_secure'))); }