5 * Functions that need to be loaded on every request.
11 function setARIRoot() {
14 if (isset($_SERVER['PHP_SELF'])) {
15 if ($_SERVER['PHP_SELF']!='') {
16 $_SESSION['ARI_ROOT'] = $_SERVER['PHP_SELF'];
21 $_SESSION['ARI_ROOT'] = "index.php";
29 * The name of the array being acted upon.
31 * The name of the variable to return.
33 * The value of the variable.
35 function getArgument($args, $name) {
37 return isset($args[$name]) ? $args[$name] : '';
41 * Gets top level directory names
46 * string to use as a filter to match files to return
47 * @return $directories
50 function getDirectories($path,$filter) {
52 $directories = array();
57 while (false!== ($item = readdir($dh))) {
58 if($item!="." && $item!="..") {
60 $path = fixPathSlash($path);
62 $directory = appendPath($directory,$item);
64 if (is_dir($directory)) {
68 if (strpos($directory,$filter)) {
75 $directories[count($directories) + 1] = $directory;
86 * Gets file names recursively 6 folders deep
91 * string to use as a filter to match files to return
92 * @param $recursive_max
93 * max number of sub folders to search
94 * @param $recursive_count
95 * current sub folder count
99 function getFiles($path,$filter,$recursive_max,$recursive_count) {
103 if (@is_dir($path) && @is_readable($path)) {
104 $dh = opendir($path);
105 while (false!== ($item = readdir($dh))) {
108 $path = fixPathSlash($path);
109 $msg_path = appendPath($path,$item);
112 if ($fileCount>3000) {
113 $_SESSION['ari_error']
114 .= _("To many files in $msg_path Not all files processed") . "<br>";
118 if ($recursive_count<$recursive_max && is_dir($msg_path)) {
122 $_SESSION['ari_error']
123 .= sprintf(_("To many directories in %s Not all files processed"),$msg_path) . "<br>";
127 $count = $recursive_count + 1;
128 $path_files = getFiles($msg_path,$filter,$recursive_max,$count);
129 $files = array_merge($files,$path_files);
134 if (strpos($msg_path,$filter)) {
141 $files[count($files) + 1] = $msg_path;
154 * Fixes the path for a trailing slash
161 function fixPathSlash($path) {
166 if (!preg_match('/\/$/',$path)) {
175 * Appends folder to end of path
180 * folder to append to path
184 function appendPath($path,$folder) {
189 if (!preg_match('/\/$/',$path)) {
192 $ret .= $m . $folder;
201 * timestamp to be converted
203 function getDateFormat($timestamp) {
204 return date('Y-m-d', $timestamp);
211 * timestamp to be converted
213 function getTimeFormat($timestamp) {
214 return date('G:i:s', $timestamp);
220 * Checks ARI dependencies
222 function checkDependencies() {
225 if (!version_compare(phpversion(), '4.3', '>=')) {
226 echo _("ARI requires a version of PHP 4.3 or later");
231 $include_path = ini_get('include_path');
232 $buf = split(':|,',$include_path);
235 foreach ($buf as $path) {
236 $path = fixPathSlash($path);
237 $pear_check_path = $path . "DB.php";
238 if (is_file($pear_check_path)) {
245 echo _("PHP PEAR must be installed. Visit http://pear.php.net for help with installation.");
253 function startARISession() {
255 if (!isset($_SESSION['ari_user']) ) {
257 // start a new session for the user
258 ini_set('session.name', 'ARI'); // prevent session name clashes
259 ini_set('session.gc_maxlifetime', '3900'); // make the session timeout a long time
268 * Loads critical variables needed for every page request
271 function bootstrap() {
273 // set error reporting
274 error_reporting (E_ALL & ~ E_NOTICE);
278 * Set HTTP headers in preparation for a page response.
280 * TODO: Figure out caching
282 function ariPageHeader() {
288 * Perform end-of-request tasks.
290 * This function sets the page cache if appropriate, and allows modules to
291 * react to the closing of the page by calling hook_exit().
293 function ariPageFooter() {
298 * Includes and run functions
301 include_once("./includes/lang.php");
302 $language = new Language();
309 include_once("./includes/main.conf.php");
310 include_once("./version.php");
311 include_once("./includes/crypt.php");
312 include_once("./includes/login.php");