Bug #53374 [NEW]: str_replace & fwrite
| From: | pascalholscher at gmail dot com | Date: | Mon, 22 Nov 2010 08:04:25 +0000 |
| Subject: | Bug #53374 [NEW]: str_replace & fwrite | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-156270@lists.php.net to get a copy of this message | ||
From:
Operating system: Windows
PHP version: Irrelevant
Package: *General Issues
Bug Type: Bug
Bug description:str_replace & fwrite
Description:
------------
A bug with str_replace & fwrite
Test script:
---------------
function installNewerVersion($newversion) {
$docroot = $_SERVER['DOCUMENT_ROOT'];
// url naar zip (update site)
$src = 'http://support.telsec.nl/tms_updates/'.$newversion.'.zip';
//locatie voor het zip bestand
$dest = $docroot.'/tmp/'.$newversion.'.zip';
// open de locaties
$fsrc = fopen($src,'r');
$fdest = fopen($dest,'w+');
// kopieër bestand van locatie a naar b
$len = copy($src,$dest);
// sluit locaties
fclose($fsrc);
fclose($fdest);
$command = 'x "'.$docroot.'/tmp/'.$newversion.'.zip" -aoa
-o"'.$docroot.'/tmp/" && exit';
$programDir = $docroot."/../7za.exe";
if(file_exists('tmp/upgrade_'.$newversion.'.php')) {
require_once('tmp/upgrade_'.$newversion.'.php');
}
$filename = $_SERVER['DOCUMENT_ROOT'].'/product_version.php';
if(!$openfile = fopen($filename, 'rb+')) {
echo 'Kan bestand niet openen.';
}
$data = file_get_contents($filename);
$data1 = str_replace('3.3.4', '3.3.5', $data);
rewind($openfile);
fwrite($openfile, $data1);
fclose($openfile);
if(isset($_COOKIE['checked'])) {
setcookie("checked", "", time() - 3600);
}
echo "<script type='text/javascript'>
alert('De update is geslaagd.');
</script>";
return $len;
}
Expected result:
----------------
Show the output/alertbox "update succes"
Actual result:
--------------
No output of echo's or alerts at all.
Extra info:
This is a function included in another file when I comment out the fwrite
the script shows the output but doesn't write the data in the correct way.
So there are some issues with str_replace & fwrite.
I'm using php 4.4.4 as that is the version the firmware is using where we
want to let users implent an auto update.
--
Edit bug report at http://bugs.php.net/bug.php?id=53374&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53374&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53374&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53374&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=53374&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53374&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=53374&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=53374&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=53374&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=53374&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=53374&r=support
Expected behavior: http://bugs.php.net/fix.php?id=53374&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=53374&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=53374&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=53374&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53374&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=53374&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=53374&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=53374&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=53374&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=53374&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=53374&r=mysqlcfg