function raiseException($errorNum, $errorString)
 {
     //die('HTTP Exception: ' . $errorNum  .  "\n " . $errorString);
     if ($GLOBALS['HTTP_Exception_errorHandler'] != null) {
         call_user_func($GLOBALS['HTTP_Exception_errorHandler'], $errorNum, $errorString);
     } else {
         $errorMessageText = $errorNum . ' ' . $errorString;
         $errorMessage = 'Error: ' . $errorMessageText;
         if (!isset($GLOBALS['HTTP_ERROR_FORMATTING_HTML']) || $GLOBALS['HTTP_ERROR_FORMATTING_HTML'] == true) {
             $errorMessage = "<p><pre>" . $errorMessage . "</pre></p>";
         }
         //log error to file
         if (isset($GLOBALS['HTTP_Exception_log']) && $GLOBALS['HTTP_Exception_log'] != null) {
             require_once PHP_HTTP_TOOLS_INCLUDE_PATH . 'php_file_utilities.php';
             $logItem = "\n" . date('Y-m-d H:i:s') . ' HTTP Error ' . $errorMessageText;
             php_file_utilities::putDataToFile($GLOBALS['HTTP_Exception_log'], $logItem, 'a');
         }
         switch ($GLOBALS['HTTP_Exception_mode']) {
             case HTTP_ONERROR_CONTINUE:
                 return;
                 break;
             case HTTP_ONERROR_DIE:
                 die($errorMessage);
                 break;
         }
     }
 }
 /**
  * Imports the specified file, encodes it as a base64 encoded string and stores it in $stringData
  * @param string The file path
  */
 function fromFile($fileName)
 {
     //input file name
     require_once DOM_XMLRPC_INCLUDE_PATH . 'php_file_utilities.php';
     $binaryData =& php_file_utilities::getDataFromFile($fileName, 'rb');
     $this->stringData = $this->encode($binaryData);
 }
 /**
  * Unserializes a cached DOMIT! document
  * @param string The name of the xml file to be retrieved
  * @return Object The retrieved document
  */
 function &fromCache($xmlFileName)
 {
     require_once DOMIT_INCLUDE_PATH . 'xml_domit_utilities.php';
     require_once DOMIT_INCLUDE_PATH . 'php_file_utilities.php';
     $name = DOMIT_Utilities::removeExtension($xmlFileName) . '.' . DOMIT_FILE_EXTENSION_CACHE;
     $fileContents =& php_file_utilities::getDataFromFile($name, 'r');
     $newxmldoc =& unserialize($fileContents);
     return $newxmldoc;
 }
Example #4
0
 /**
  * Get text from an url or file
  * @param string The url or file path
  * @return string The text contained in the url or file, or an empty string
  */
 function fromFile($filename)
 {
     if (function_exists('file_get_contents')) {
         return @file_get_contents($filename);
     } else {
         require_once PHP_TEXT_CACHE_INCLUDE_PATH . 'php_file_utilities.php';
         $fileContents = php_file_utilities::getDataFromFile($filename, 'r');
         return $fileContents;
     }
     return '';
 }
 /**
  * Saves text to a file
  * @param string The file path
  * @param string The text to be saved
  * @return boolean True if the save is successful
  */
 function saveTextToFile($filename, $text)
 {
     if (function_exists('file_put_contents')) {
         file_put_contents($filename, $text);
     } else {
         require_once DOMIT_INCLUDE_PATH . 'php_file_utilities.php';
         php_file_utilities::putDataToFile($filename, $text, 'w');
     }
     return file_exists($filename) && is_writable($filename);
 }
 /**
  * Get text from an url or file
  * @param string The url or file path
  * @return string The text contained in the url or file, or an empty string
  */
 function getTextFromFile($filename)
 {
     $fileContents = '';
     if (function_exists('file_get_contents')) {
         $fileContents = @file_get_contents($filename);
     } else {
         require_once DOMIT_RSS_INCLUDE_PATH . 'php_file_utilities.php';
         $fileContents =& php_file_utilities::getDataFromFile($filename, 'r');
     }
     if ($fileContents == '') {
         $this->establishConnection($filename);
         $response =& $this->httpConnection->get($filename);
         $fileContents = $response->getResponse();
     }
     return $fileContents;
 }