-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclasses.misc.php
81 lines (66 loc) · 2.52 KB
/
classes.misc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Amiga.org classic browser proxy project
//
// (c) Karl Churchill 2010
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class Session implements SessionConfig {
public static function getVar($name, $defaultValue) {
return isset($_SESSION[$name]) ? $_SESSION[$name] : $defaultValue;
}
public static function setVar($name, $value) {
$_SESSION[$name] = $value;
$_SESSION['updateUserCookies'] = 1;
}
public static function init() {
@session_start();
if ( !isset($_SESSION[self::SESSION_HIDE_DISCLAIMER]) ) {
if ( !isset($_COOKIE[self::SESSION_HIDE_DISCLAIMER])) {
$_SESSION[self::SESSION_HIDE_DISCLAIMER] = 0;
setcookie(self::SESSION_HIDE_DISCLAIMER, 0, time()+86400*365, '/', '.'.Config::PROXY_URI);
}
else {
$_SESSION[self::SESSION_HIDE_DISCLAIMER] = (intval($_COOKIE[self::SESSION_HIDE_DISCLAIMER])!=0);
}
}
if ( !isset($_SESSION[self::SESSION_USE_SMALL]) ) {
if ( !isset($_COOKIE[self::SESSION_USE_SMALL])) {
$_SESSION[self::SESSION_USE_SMALL] = 0;
setcookie(self::SESSION_USE_SMALL, 0, time()+86400*365, '/', '.'.Config::PROXY_URI);
}
else {
$_SESSION[self::SESSION_USE_SMALL] = (intval($_COOKIE[self::SESSION_USE_SMALL])!=0);
}
}
if (isset($_SESSION['updateUserCookies'])) {
setcookie(self::SESSION_HIDE_DISCLAIMER, $_SESSION[self::SESSION_HIDE_DISCLAIMER], time()+86400*365, '/', '.'.Config::PROXY_URI);
setcookie(self::SESSION_USE_SMALL, $_SESSION[self::SESSION_USE_SMALL], time()+86400*365, '/', '.'.Config::PROXY_URI);
unset($_SESSION['updateUserCookies']);
}
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Timer - simple start/stop/elapsed stopwatch for benchmarking
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class Timer {
public function __construct() {
$this->set();
}
public final function set() {
$this->mark = microtime(true);
}
public final function elapsed() {
return microtime(true) - $this->mark;
}
public final function lastInterval() {
$mark = microtime(true);
$interval = $mark - $this->mark;
$this->mark = $mark;
return $interval;
}
private $mark;
}