- <?php
-
- /*
- inc.fns.es.php
- Shared Functions for ePrintsStats
- */
-
- function error($message,$level)
- {
- $admin_name = $GLOBALS["config_vars"]["general"]["admin_name"];
- $admin_email = $GLOBALS["config_vars"]["general"]["admin_email"];
- $short_prog_title = $GLOBALS["config_vars"]["general"]["short_prog_title"];
- // Not making use of $level
- if ( $level )
- {
- email($admin_email,"$short_prog_title - Critical Error",$message,$admin_email);
- trigger_error ("$short_prog_title - $message", E_USER_NOTICE);
- }
- else
- {
- email($admin_email,"$short_prog_title - Critical Error",$message,$admin_email);
- trigger_error ("$short_prog_title - $message", E_USER_NOTICE);
- }
- }
-
- function email($to,$mail_subject,$mail_message,$from,$reply_to='')
- {
- if ($reply_to != '') {
- $reply_to = "Reply-To: $reply_to\r\n";
- }
- $is_sent = mail($to,$mail_subject,$mail_message,"From: $from\r\n" . $reply_to . "X-Mailer: PHP/" . phpversion() . "\r\n");
- return $is_sent;
- }
- function printError($message="Service unavailable",$level)
- {
- /*
- How to make the message meaningful?
- $level signifies if the program exits or continues.
- */
- print "Program encountered an error: $message<br>";
-
- }
- function exitScript()
- {
- die;
- }
- function prettyDebug($output,$line,$file,$function,$class,$printout=FALSE)
- {
- /*
- HTML output debug information.
- */
- ob_start();
- print "<div class=\"debug\">\n";
- print "<pre>";
- if (!empty($line)) { print "LINE: $line\n"; };
- if (!empty($file)) { print "FILE: $file\n"; };
- if (!empty($function)) { print "FUNCTION: $function\n"; };
- if (!empty($class)) { print "CLASS: $class\n"; };
- if (!empty($method)) { print "METHOD: $method\n"; };
- print_r($output);
- print "</ pre></div>";
- $ret_str = ob_get_contents();
- ob_end_clean();
- if ($GLOBALS["config_vars"]["debug"][$GLOBALS["config_vars"]["thisrequest"]]) { print $ret_str; }
- }
- function loadPages($action)
- {
- global $login;
- global $message;
- global $sql;
- global $debug;
- global $lastmodified;
- global $platform;
- global $logger;
-
- if (!isset($GLOBALS["config_vars"]["actions"]["includes"][$GLOBALS["config_vars"]["thisrequest"]][$GLOBALS["config_vars"]["archivename"]][$action]))
- loadPages("default_logged_in");
- // Should also here check for page existence.
-
- for ($i=0;$i<count($GLOBALS["config_vars"]["actions"]["includes"][$GLOBALS["config_vars"]["thisrequest"]][$GLOBALS["config_vars"]["archivename"]][$action]);$i++)
- {
- $include = include($GLOBALS["config_vars"]["actions"]["includes"][$GLOBALS["config_vars"]["thisrequest"]][$GLOBALS["config_vars"]["archivename"]][$action][$i]);
- if (!$include) {
- print "NO INCLUDE";
- error(
- $GLOBALS["config_vars"]["messages"]["message_missing_include"].' '.$GLOBALS["config_vars"]["actions"]["includes"][$GLOBALS["config_vars"]["thisrequest"]][$GLOBALS["config_vars"]["archivename"]][$action][$i],
- ERROR_EXIT);
- } else {
- if (!is_numeric($include)) {
- return $include;
- }
- }
- }
- }
-
-
-
- ?>