Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.
   1  <?php
   2  /**
   3   * general.php
   4   *
   5   * @package MCManager.includes
   6   * @author Moxiecode
   7   * @copyright Copyright � 2007, Moxiecode Systems AB, All rights reserved.
   8   */
   9  
  10  @error_reporting(E_ALL ^ E_NOTICE);
  11  $config = array();
  12  
  13  require_once (__DIR__ . "/../classes/utils/Logger.php");
  14  require_once (__DIR__ . "/../classes/utils/JSON.php");
  15  require_once (__DIR__ . "/../config.php");
  16  require_once (__DIR__ . "/../classes/SpellChecker.php");
  17  
  18  if (isset($config['general.engine']))
  19  	 require_once(__DIR__ . "/../classes/" . $config["general.engine"] . ".php");
  20  
  21  /**
  22   * Returns an request value by name without magic quoting.
  23   *
  24   * @param String $name Name of parameter to get.
  25   * @param String $default_value Default value to return if value not found.
  26   * @return String request value by name without magic quoting or default value.
  27   */
  28  function getRequestParam($name, $default_value = false) {
  29  	 if (!isset($_REQUEST[$name]))
  30  	 	 return $default_value;
  31  
  32  	 if (is_array($_REQUEST[$name])) {
  33  	 	 $newarray = array();
  34  
  35  	 	 foreach ($_REQUEST[$name] as $name => $value)
  36  	 	 	 $newarray[$name] = $value;
  37  
  38  	 	 return $newarray;
  39  	 }
  40  
  41  	 return $_REQUEST[$name];
  42  }
  43  
  44  function &getLogger() {
  45  	 global $mcLogger, $man;
  46  
  47  	 if (isset($man))
  48  	 	 $mcLogger = $man->getLogger();
  49  
  50  	 if (!$mcLogger) {
  51  	 	 $mcLogger = new Moxiecode_Logger();
  52  
  53  	 	 // Set logger options
  54  	 	 $mcLogger->setPath(__DIR__ . "/../logs");
  55  	 	 $mcLogger->setMaxSize("100kb");
  56  	 	 $mcLogger->setMaxFiles("10");
  57  	 	 $mcLogger->setFormat("{time} - {message}");
  58  	 }
  59  
  60  	 return $mcLogger;
  61  }
  62  
  63  function debug($msg) {
  64  	 $args = func_get_args();
  65  
  66  	 $log = getLogger();
  67  	 $log->debug(implode(', ', $args));
  68  }
  69  
  70  function info($msg) {
  71  	 $args = func_get_args();
  72  
  73  	 $log = getLogger();
  74  	 $log->info(implode(', ', $args));
  75  }
  76  
  77  function xx_error($msg) { // collides with our moodle error(), it does not look to be used at all
  78  	 $args = func_get_args();
  79  
  80  	 $log = getLogger();
  81  	 $log->error(implode(', ', $args));
  82  }
  83  
  84  function warn($msg) {
  85  	 $args = func_get_args();
  86  
  87  	 $log = getLogger();
  88  	 $log->warn(implode(', ', $args));
  89  }
  90  
  91  function fatal($msg) {
  92  	 $args = func_get_args();
  93  
  94  	 $log = getLogger();
  95  	 $log->fatal(implode(', ', $args));
  96  }
  97  
  98  ?>