Bug #53374 [Bgs]: str_replace & fwrite
| From: | pascalholscher at gmail dot com | Date: | Tue, 23 Nov 2010 07:53:26 +0000 |
| Subject: | Bug #53374 [Bgs]: str_replace & fwrite | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-156298@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=53374&edit=1
ID: 53374
User updated by: pascalholscher at gmail dot com
Reported by: pascalholscher at gmail dot com
Summary: str_replace & fwrite
Status: Bogus
Type: Bug
Package: *General Issues
Operating System: Windows
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
What do I need to contact to get this fixed.
It seems like a bug to me...
Previous Comments:
------------------------------------------------------------------------
[2010-11-22 10:37:02] johannes@php.net
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions. Due to the volume
of reports we can not explain in detail here why your report is not
a bug. The support channels will be able to provide an explanation
for you.
Thank you for your interest in PHP.
------------------------------------------------------------------------
[2010-11-22 10:34:43] pascalholscher at gmail dot com
Solved
------------------------------------------------------------------------
[2010-11-22 09:04:23] pascalholscher at gmail dot com
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 this bug report at http://bugs.php.net/bug.php?id=53374&edit=1