Newer
Older
Digital_Repository / Repositories / statistics / includes / inc.fns.es.php
  1. <?php
  2.  
  3. /*
  4. inc.fns.es.php
  5. Shared Functions for ePrintsStats
  6. */
  7.  
  8. function error($message,$level)
  9. {
  10. $admin_name = $GLOBALS["config_vars"]["general"]["admin_name"];
  11. $admin_email = $GLOBALS["config_vars"]["general"]["admin_email"];
  12. $short_prog_title = $GLOBALS["config_vars"]["general"]["short_prog_title"];
  13. // Not making use of $level
  14. if ( $level )
  15. {
  16. email($admin_email,"$short_prog_title - Critical Error",$message,$admin_email);
  17. trigger_error ("$short_prog_title - $message", E_USER_NOTICE);
  18. }
  19. else
  20. {
  21. email($admin_email,"$short_prog_title - Critical Error",$message,$admin_email);
  22. trigger_error ("$short_prog_title - $message", E_USER_NOTICE);
  23. }
  24. }
  25.  
  26. function email($to,$mail_subject,$mail_message,$from,$reply_to='')
  27. {
  28. if ($reply_to != '') {
  29. $reply_to = "Reply-To: $reply_to\r\n";
  30. }
  31. $is_sent = mail($to,$mail_subject,$mail_message,"From: $from\r\n" . $reply_to . "X-Mailer: PHP/" . phpversion() . "\r\n");
  32. return $is_sent;
  33. }
  34. function printError($message="Service unavailable",$level)
  35. {
  36. /*
  37. How to make the message meaningful?
  38. $level signifies if the program exits or continues.
  39. */
  40. print "Program encountered an error: $message<br>";
  41.  
  42. }
  43. function exitScript()
  44. {
  45. die;
  46. }
  47. function prettyDebug($output,$line,$file,$function,$class,$printout=FALSE)
  48. {
  49. /*
  50. HTML output debug information.
  51. */
  52. ob_start();
  53. print "<div class=\"debug\">\n";
  54. print "<pre>";
  55. if (!empty($line)) { print "LINE: $line\n"; };
  56. if (!empty($file)) { print "FILE: $file\n"; };
  57. if (!empty($function)) { print "FUNCTION: $function\n"; };
  58. if (!empty($class)) { print "CLASS: $class\n"; };
  59. if (!empty($method)) { print "METHOD: $method\n"; };
  60. print_r($output);
  61. print "</ pre></div>";
  62. $ret_str = ob_get_contents();
  63. ob_end_clean();
  64. if ($GLOBALS["config_vars"]["debug"][$GLOBALS["config_vars"]["thisrequest"]]) { print $ret_str; }
  65. }
  66. function loadPages($action)
  67. {
  68. global $login;
  69. global $message;
  70. global $sql;
  71. global $debug;
  72. global $lastmodified;
  73. global $platform;
  74. global $logger;
  75.  
  76. if (!isset($GLOBALS["config_vars"]["actions"]["includes"][$GLOBALS["config_vars"]["thisrequest"]][$GLOBALS["config_vars"]["archivename"]][$action]))
  77. loadPages("default_logged_in");
  78. // Should also here check for page existence.
  79.  
  80. for ($i=0;$i<count($GLOBALS["config_vars"]["actions"]["includes"][$GLOBALS["config_vars"]["thisrequest"]][$GLOBALS["config_vars"]["archivename"]][$action]);$i++)
  81. {
  82. $include = include($GLOBALS["config_vars"]["actions"]["includes"][$GLOBALS["config_vars"]["thisrequest"]][$GLOBALS["config_vars"]["archivename"]][$action][$i]);
  83. if (!$include) {
  84. print "NO INCLUDE";
  85. error(
  86. $GLOBALS["config_vars"]["messages"]["message_missing_include"].' '.$GLOBALS["config_vars"]["actions"]["includes"][$GLOBALS["config_vars"]["thisrequest"]][$GLOBALS["config_vars"]["archivename"]][$action][$i],
  87. ERROR_EXIT);
  88. } else {
  89. if (!is_numeric($include)) {
  90. return $include;
  91. }
  92. }
  93. }
  94. }
  95.  
  96.  
  97.  
  98. ?>