-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsettings.php
121 lines (101 loc) · 3.59 KB
/
settings.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
// -----------------
// START USER CONFIG
// -----------------
// SYSTEM SETTINGS
// Document root and ICErepo version no:
$docRoot = $_SERVER['DOCUMENT_ROOT'];
$version = "1.0 beta";
// AUTHENTICATION
// Can either be done by token (good idea), or username & password (much less secure!)
// If you don't set them here, they are asked for in the session (recommended)
// oauth
$token = "";
// Basic
$username = "";
$password = "";
// REPOS & SERVER DIRS
// Here you identify the repo location and related path on your server
// (the last param is to identify which dropdown option to select by default).
$repos = array(
"mattpass/ICErepo",$docRoot."/repo","selected",
"mattpass/ICEcoder",$docRoot."/_coder",""
);
// User level setting. Set at 1 or above to use
$_SESSION['userLevel'] = 10;
// ---------------
// END USER CONFIG
// ---------------
// Don't display, but log all errors
ini_set('display_errors', 0);
ini_set('log_errors', 1);
ini_set('error_log', dirname(__FILE__).'/error-log.txt');
error_reporting(-1);
// Set our default timezone and supress warning with @
@date_default_timezone_set(date_default_timezone_get());
// Set a stream context timeout for file reading
$context = stream_context_create(array('http'=>
array(
'timeout' => 60 // secs
)
));
// Start a session if we haven't already
if(!isset($_SESSION)) {@session_start();}
if (!isset($_SESSION['userLevel']) || $_SESSION['userLevel'] < 1) {
die("Sorry, you need to be logged in to use ICErepo");
}
// Set session vars if we're logging in via a session
if (isset($_REQUEST['token']) && $_REQUEST['token']!="") {
$_SESSION['token'] = $_REQUEST['token'];
}
if (isset($_REQUEST['username']) && $_REQUEST['username']!="") {
$_SESSION['username'] = $_REQUEST['username'];
$_SESSION['password'] = $_REQUEST['password'];
}
// Reestablish those session vars in an ongoing way
if (isset($_SESSION['token'])) {
$token = $_SESSION['token'] = $_SESSION['token'];
}
if (isset($_SESSION['username'])) {
$username = $_SESSION['username'] = $_SESSION['username'];
$password = $_SESSION['password'] = $_SESSION['password'];
}
if ($token=="" && $username=="" && !isset($_GET['sessionLogin'])) {
header("Location: ?sessionLogin=true");
}
// returns converted entities where there are HTML entity equivalents
function strClean($var) {
return htmlentities($var, ENT_QUOTES, "UTF-8");
}
// returns a number, whole or decimal or null
function numClean($var) {
return is_numeric($var) ? floatval($var) : false;
}
// Function to sort given values alphabetically
function alphasort($a, $b) {
return strcmp($a->getPathname(), $b->getPathname());
}
// Class to put forward the values for sorting
class SortingIterator implements IteratorAggregate {
private $iterator = null;
public function __construct(Traversable $iterator, $callback) {
$array = iterator_to_array($iterator);
usort($array, $callback);
$this->iterator = new ArrayIterator($array);
}
public function getIterator() {
return $this->iterator;
}
}
// If magic quotes are still on (attempted to switch off in php.ini)
if (get_magic_quotes_gpc ()) {
function stripslashes_deep($value) {
$value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
return $value;
}
$_POST = (isset($_POST) && !empty($_POST)) ? array_map('stripslashes_deep', $_POST) : array();
$_GET = (isset($_GET) && !empty($_GET)) ? array_map('stripslashes_deep', $_GET) : array();
$_COOKIE = (isset($_COOKIE) && !empty($_COOKIE)) ? array_map('stripslashes_deep', $_COOKIE) : array();
$_REQUEST = (isset($_REQUEST) && !empty($_REQUEST)) ? array_map('stripslashes_deep', $_REQUEST) : array();
}
?>