コード例 #1
0
 public static function create(CookieManager $cookie, $id)
 {
     $link = $cookie->getArrayWithSubreddits()[$id];
     $downloader = new SubredditDownloader($link);
     $subreddit = new Subreddit($downloader);
     return $subreddit;
 }
コード例 #2
0
 /**
  * $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'));
     }
 }
コード例 #3
0
ファイル: pre.php プロジェクト: rinodung/tuleap
        }
    }
}
//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
コード例 #4
0
ファイル: pre.php プロジェクト: nterray/tuleap
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();
コード例 #5
0
 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');
 }
コード例 #6
0
ファイル: subreddits.php プロジェクト: Witoso/CleanReddit
<?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());
    }
}
コード例 #7
0
 /**
  * Clear user credentials from session and cookies
  */
 public function clearCredentials()
 {
     session_destroy();
     $cookieManager = new CookieManager();
     $cookieManager->destroyCookie('Loggedin', '/');
 }
コード例 #8
0
ファイル: Response.class.php プロジェクト: nterray/tuleap
 function removeCookie($name)
 {
     $cookie_manager = new CookieManager();
     $cookie_manager->removeCookie($name);
 }
コード例 #9
0
ファイル: Container.php プロジェクト: bbeckman/NDL-VuFind2
 /**
  * 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);
 }
コード例 #10
0
 public function isCookie($name)
 {
     $cookie_manager = new CookieManager();
     return $cookie_manager->isCookie($name);
 }
コード例 #11
0
<?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");