Support Joomla!

Joomla! 1.5 Documentation

Packages

Package: Joomla-Framework

Developer Network License

The Joomla! Developer Network content is © copyright 2006 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution- NonCommercial- ShareAlike 2.5
Source code for file /joomla/utilities/compat/php50x.php

Documentation is available at php50x.php

  1. <?php
  2. /**
  3. @version        $Id: php50x.php 6138 2007-01-02 03:44:18Z eddiea $
  4. @package        Joomla.Framework
  5. @subpackage    Compatibility
  6. @copyright    Copyright (C) 2005 - 2007 Open Source Matters. All rights reserved.
  7. @license        GNU/GPL, see LICENSE.php
  8. *  Joomla! is free software. This version may have been modified pursuant
  9. *  to the GNU General Public License, and as distributed it includes or
  10. *  is derivative of works licensed under the GNU General Public License or
  11. *  other free or open source software licenses.
  12. *  See COPYRIGHT.php for copyright notices and details.
  13. */
  14.  
  15.  /**
  16.  * PHP 5.0.x Compatibility functions
  17.  *
  18.  * @since        1.5
  19.  */
  20. if (!defined('FILE_USE_INCLUDE_PATH')) {
  21.     define('FILE_USE_INCLUDE_PATH'1);
  22. }
  23.  
  24. if (!defined('FILE_APPEND')) {
  25.     define('FILE_APPEND'8);
  26. }
  27.  
  28. /**
  29.  * Replace file_put_contents()
  30.  *
  31.  * @link        http://php.net/function.file_put_contents
  32.  * @author        Aidan Lister <[email protected]>
  33.  * @version         $Revision: 47 $
  34.  * @internal    resource_context is not supported
  35.  * @since        PHP 5
  36.  */
  37. if (!function_exists('file_put_contents')) {
  38.     function file_put_contents($filename$content$flags null$resource_context null)
  39.     {
  40.         // If $content is an array, convert it to a string
  41.         if (is_array($content)) {
  42.             $content implode(''$content);
  43.         }
  44.  
  45.         // If we don't have a string, throw an error
  46.         if (!is_scalar($content)) {
  47.             trigger_error('file_put_contents() The 2nd parameter should be either a string or an array'E_USER_WARNING);
  48.             return false;
  49.         }
  50.  
  51.         // Get the length of date to write
  52.         $length strlen($content);
  53.  
  54.         // Check what mode we are using
  55.         $mode ($flags FILE_APPEND?
  56.                     $mode 'a' :
  57.                     $mode 'w';
  58.  
  59.         // Check if we're using the include path
  60.         $use_inc_path ($flags FILE_USE_INCLUDE_PATH?
  61.                     true :
  62.                     false;
  63.  
  64.         // Open the file for writing
  65.         if (($fh @fopen($filename$mode$use_inc_path)) === false{
  66.             trigger_error('file_put_contents() failed to open stream: Permission denied'E_USER_WARNING);
  67.             return false;
  68.         }
  69.  
  70.         // Write to the file
  71.         $bytes 0;
  72.         if (($bytes @fwrite($fh$content)) === false{
  73.             $errormsg sprintf('file_put_contents() Failed to write %d bytes to %s',
  74.                             $length,
  75.                             $filename);
  76.             trigger_error($errormsgE_USER_WARNING);
  77.             return false;
  78.         }
  79.  
  80.         // Close the handle
  81.         @fclose($fh);
  82.  
  83.         // Check all the data was written
  84.         if ($bytes != $length{
  85.             $errormsg sprintf('file_put_contents() Only %d of %d bytes written, possibly out of free disk space.',
  86.                             $bytes,
  87.                             $length);
  88.             trigger_error($errormsgE_USER_WARNING);
  89.             return false;
  90.         }
  91.  
  92.         // Return length
  93.         return $bytes;
  94.     }
  95. }
  96.  
  97. /**
  98.  * Ported PHP5 function to PHP4 for forward compatibility
  99.  */
  100. function clone($object{
  101.     return $object;
  102. }
  103. ?>

Documentation generated on Mon, 05 Mar 2007 21:17:04 +0000 by phpDocumentor 1.3.1