Changeset 1675

Show
Ignore:
Timestamp:
10/12/2007 10:25:49 PM (15 months ago)
Author:
jeena
Message:

added file_put_contents() for PHP4

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/scripts/general.func.php

    r1671 r1675  
    248248} 
    249249 
     250if ( !function_exists('file_put_contents') && !defined('FILE_APPEND') ) { 
     251        define('FILE_APPEND', 1); 
     252        function file_put_contents($n, $d, $flag = false) { 
     253            $mode = ($flag == FILE_APPEND || strtoupper($flag) == 'FILE_APPEND') ? 'a' : 'w'; 
     254            $f = @fopen($n, $mode); 
     255            if ($f === false) { 
     256                return 0; 
     257            } else { 
     258                if (is_array($d)) $d = implode($d); 
     259                $bytes_written = fwrite($f, $d); 
     260                fclose($f); 
     261                return $bytes_written; 
     262            } 
     263        } 
     264} 
     265 
    250266// output the administration menu 
    251267function output_admin_menu() {