X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=fs_selfservice%2Ffri%2Fincludes%2Fbootstrap.php;fp=fs_selfservice%2Ffri%2Fincludes%2Fbootstrap.php;h=a01a2f5c8b28d26ab39e7dba9cc6ae26ee365c91;hp=0000000000000000000000000000000000000000;hb=3a17b276638200475d54201fa62566b7440e819a;hpb=46c6025ca0759b96e5bd16e7ce4b16d4df8a0988 diff --git a/fs_selfservice/fri/includes/bootstrap.php b/fs_selfservice/fri/includes/bootstrap.php new file mode 100644 index 000000000..a01a2f5c8 --- /dev/null +++ b/fs_selfservice/fri/includes/bootstrap.php @@ -0,0 +1,315 @@ +3000) { + $_SESSION['ari_error'] + .= _("To many files in $msg_path Not all files processed") . "
"; + return; + } + + if ($recursive_count<$recursive_max && is_dir($msg_path)) { + + $dirCount++; + if ($dirCount>10) { + $_SESSION['ari_error'] + .= sprintf(_("To many directories in %s Not all files processed"),$msg_path) . "
"; + return; + } + + $count = $recursive_count + 1; + $path_files = getFiles($msg_path,$filter,$recursive_max,$count); + $files = array_merge($files,$path_files); + } + else { + $found = 0; + if ($filter) { + if (strpos($msg_path,$filter)) { + $found = 1; + } + } else { + $found = 1; + } + if ($found) { + $files[count($files) + 1] = $msg_path; + } + } + } + } + } + + return $files; +} + +/* Utilities */ + +/** + * Fixes the path for a trailing slash + * + * @param $path + * path to append + * @return $ret + * path to returned + */ +function fixPathSlash($path) { + + $ret = $path; + + $slash = ''; + if (!preg_match('/\/$/',$path)) { + $slash = '/'; + } + $ret .= $slash; + + return $ret; +} + +/** + * Appends folder to end of path + * + * @param $path + * path to append + * @param $folder + * folder to append to path + * @return $ret + * path to returned + */ +function appendPath($path,$folder) { + + $ret = $path; + + $m = ''; + if (!preg_match('/\/$/',$path)) { + $m = '/'; + } + $ret .= $m . $folder; + + return $ret; +} + +/** + * Get Date format + * + * @param $timestamp + * timestamp to be converted + */ +function getDateFormat($timestamp) { + return date('Y-m-d', $timestamp); +} + +/** + * Get time format + * + * @param $timestamp + * timestamp to be converted + */ +function getTimeFormat($timestamp) { + return date('G:i:s', $timestamp); +} + +/* */ + +/** + * Checks ARI dependencies + */ +function checkDependencies() { + + // check for PHP + if (!version_compare(phpversion(), '4.3', '>=')) { + echo _("ARI requires a version of PHP 4.3 or later"); + exit(); + } + + // check for PEAR + $include_path = ini_get('include_path'); + $buf = split(':|,',$include_path); + + $found = 0; + foreach ($buf as $path) { + $path = fixPathSlash($path); + $pear_check_path = $path . "DB.php"; + if (is_file($pear_check_path)) { + $found = 1; + break; + } + } + + if (!$found) { + echo _("PHP PEAR must be installed. Visit http://pear.php.net for help with installation."); + exit(); + } +} + +/** + * Starts the session + */ +function startARISession() { + + if (!isset($_SESSION['ari_user']) ) { + + // start a new session for the user + ini_set('session.name', 'ARI'); // prevent session name clashes + ini_set('session.gc_maxlifetime', '3900'); // make the session timeout a long time + set_time_limit(360); + session_start(); + } +} + +/** + * Bootstrap + * + * Loads critical variables needed for every page request + * + */ +function bootstrap() { + + // set error reporting + error_reporting (E_ALL & ~ E_NOTICE); +} + +/** + * Set HTTP headers in preparation for a page response. + * + * TODO: Figure out caching + */ +function ariPageHeader() { + + bootstrap(); +} + +/** + * Perform end-of-request tasks. + * + * This function sets the page cache if appropriate, and allows modules to + * react to the closing of the page by calling hook_exit(). + */ +function ariPageFooter() { + +} + +/** + * Includes and run functions + */ + +include_once("./includes/lang.php"); +$language = new Language(); +$language->set(); + +checkDependencies(); +startARISession(); +setARIRoot(); + +include_once("./includes/main.conf.php"); +include_once("./version.php"); +include_once("./includes/crypt.php"); +include_once("./includes/login.php"); + + +?>