public static function create(CookieManager $cookie, $id) { $link = $cookie->getArrayWithSubreddits()[$id]; $downloader = new SubredditDownloader($link); $subreddit = new Subreddit($downloader); return $subreddit; }
/** * $params['isScript'] * $params['groupId'] * $params['time'] */ function logUser($params) { if (!$params['isScript']) { $uid = 0; $uid = user_getid(); $request = HTTPRequest::instance(); $cookie_manager = new CookieManager(); $userLogManager = new UserLogManager(); $userLogManager->logAccess($params['time'], $params['groupId'], $uid, $cookie_manager->getCookie('session_hash'), $request->getFromServer('HTTP_USER_AGENT'), $request->getFromServer('REQUEST_METHOD'), $request->getFromServer('REQUEST_URI'), HTTPRequest::instance()->getIPAddress(), $request->getFromServer('HTTP_REFERER')); } }
} } } //Cast group_id as int. foreach (array('group_id', 'atid', 'pv') as $variable) { if (isset($_REQUEST[$variable])) { ${$variable} = $_REQUEST[$variable] = $_GET[$variable] = $_POST[$variable] = (int) $_REQUEST[$variable]; } } //}}} //{{{ define undefined variables if (!isset($GLOBALS['feedback'])) { $GLOBALS['feedback'] = ""; //By default the feedbak is empty } $cookie_manager = new CookieManager(); if (!IS_SCRIPT) { // Prevent "Pragma: no-cache" to be sent to user (break https & IE) session_cache_limiter(false); session_start(); $GLOBALS['session_hash'] = $cookie_manager->isCookie('session_hash') ? $cookie_manager->getCookie('session_hash') : false; } //}}} // Create cache directory if needed if (!file_exists($GLOBALS['codendi_cache_dir'])) { // This directory must be world reachable, but writable only by the web-server mkdir($GLOBALS['codendi_cache_dir'], 0755); } // Instantiate System Event listener $system_event_manager = SystemEventManager::instance(); //Load plugins
foreach (array('group_id', 'atid', 'pv') as $variable) { if (isset($_REQUEST[$variable])) { ${$variable} = $_REQUEST[$variable] = $_GET[$variable] = $_POST[$variable] = (int) $_REQUEST[$variable]; } } //}}} //{{{ define undefined variables if (!isset($GLOBALS['feedback'])) { $GLOBALS['feedback'] = ""; //By default the feedbak is empty } if (!IS_SCRIPT) { // Prevent "Pragma: no-cache" to be sent to user (break https & IE) session_cache_limiter(false); session_start(); $cookie_manager = new CookieManager(); $GLOBALS['session_hash'] = $cookie_manager->isCookie('session_hash') ? $cookie_manager->getCookie('session_hash') : false; } //}}} // Create cache directory if needed if (!file_exists($GLOBALS['codendi_cache_dir'])) { // This directory must be world reachable, but writable only by the web-server mkdir($GLOBALS['codendi_cache_dir'], 0755); } // Instantiate System Event listener require_once 'common/system_event/SystemEventManager.class.php'; $system_event_manager = SystemEventManager::instance(); //Load plugins require_once 'common/plugin/PluginManager.class.php'; $plugin_manager =& PluginManager::instance(); $plugin_manager->loadPlugins();
public function itSetsCookieReadableByJavaScript() { $GLOBALS['sys_cookie_domain'] = 'example.com'; stub($this->cookie_manager)->phpsetcookie('*', '*', '*', '*', '.example.com', '*', false)->once(); $this->cookie_manager->setGlobalCookie('bla', 'bla', 'bla'); }
<?php include_once '../config.php'; require_once ROOT_NAME . "/src/classes/LinkParser.php"; require_once ROOT_NAME . "/src/classes/CookieManager.php"; require_once ROOT_NAME . "/src/classes/SubredditsFactory.php"; require_once ROOT_NAME . "/src/classes/SubredditDownloader.php"; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $url = $_POST["subreddit"]; try { $linkParser = new LinkParser($url); $cookieManager = new CookieManager($_COOKIE); $downloader = new SubredditDownloader($linkParser->getSubredditUrl()); $idInCookie = $cookieManager->addSubreddit($linkParser); $cookieManager->setCookie(); $subreddit = new Subreddit($downloader); echo json_encode(['id' => $idInCookie, 'subreddit' => $subreddit]); } catch (Exception $e) { echo json_encode($e->getMessage()); } } elseif ($_SERVER['REQUEST_METHOD'] === 'GET') { $id = $_GET["id"]; try { $cookieManager = new CookieManager($_COOKIE); $subreddit = SubredditsFactory::create($cookieManager, $id); echo json_encode(['id' => $id, 'subreddit' => $subreddit]); } catch (Exception $e) { echo json_encode($e->getMessage()); } }
/** * Clear user credentials from session and cookies */ public function clearCredentials() { session_destroy(); $cookieManager = new CookieManager(); $cookieManager->destroyCookie('Loggedin', '/'); }
function removeCookie($name) { $cookie_manager = new CookieManager(); $cookie_manager->removeCookie($name); }
/** * Unset a variable in this object. * * @param string $var programmatic name of a key, in a <key,value> pair in the * current groupName * * @return void */ public function __unset($var) { $this->manager->clear($this->groupName . $var); }
public function isCookie($name) { $cookie_manager = new CookieManager(); return $cookie_manager->isCookie($name); }
<?php namespace Fierce; $c = new CookieManager(); // set a session cookie and check if it was set $c->set('foo', 'bar'); $this->assertContains(headers_list(), 'Set-Cookie: foo=bar; path=/', 'Send session cookie'); $this->assertEqual($_COOKIE['foo'], 'bar', "Set session cookie"); $this->assertEqual($c->get('foo'), 'bar', "Get session cookie"); header_remove('Set-Cookie'); // set a non-session cookie and check if it was set with correct expiry $c->set('foo', 'bar', 42); $datetime = date('D, d-M-Y H:i:s', time() + 42) . ' GMT'; $this->assertContains(headers_list(), 'Set-Cookie: foo=bar; expires=' . $datetime . '; Max-Age=42; path=/', 'Send cookie'); $this->assertEqual($_COOKIE['foo'], 'bar', "Set cookie"); $this->assertEqual($c->get('foo'), 'bar', "Get cookie"); header_remove('Set-Cookie'); // set a cookie then clear it, make sure it clears $c->set('foo', 'bar'); $c->clear('foo'); $this->assertEqual($c->get('foo'), null, "Cookie cleared"); $this->assert(!isset($_COOKIE['foo']), "Cookie cleared from \$_COOKIE"); header_remove('Set-Cookie'); // check default value $this->assertEqual($c->get('foo', 'bob'), 'bob', "Check default cookie value");