Hello everyone, there are 3 filestestcrea.php // reads testexample.php and writes to testtext.php and test.phptest.php // reads testtext.php if there is a match in itself, replaces with an empty stringtestexample.php // template with specified text
The problem is that everything works, but it is worth going to test.php and adding
for example echo 'ok'; , and test.php stops working at start-up as if str_replace is not even in the code, although I don’t touch the search and replace line at all.
Here is the code
testexample.txt
$selftext = 'testtext.php'; $selffile = 'test.php'; $selffilecont = file_get_contents($selffile); $selftextcont = file_get_contents($selftext); $selfcontold = array($selftextcont); $selfcontnew = array(""); $selfphrase = str_replace($selfcontold, $selfcontnew, $selffilecont); if(file_put_contents($selffile, $selfphrase)) { echo "succes self remove"; } testcrea.txt
<?php $delete = 'test.php'; $exampledel = 'testexample.txt'; $exampled = file_get_contents($exampledel); $fulldeletetext = 'testtext1.php'; // Delete $delold1 = array("testtext"); $delnew1 = array("testtext1"); $delphrase1 = str_replace($delold1, $delnew1, $exampled); if(file_put_contents($delete, PHP_EOL . $delphrase1, FILE_APPEND)) { echo "succesdelete\n"; } if(file_put_contents($fulldeletetext, $delphrase1)) { //запись в deletetext.php (тогоже контента что и в delete) echo "succesdeletetext\n"; } test.php (empty, waiting to be written to it, to check if there is a similar line in testtext after launching, if so, remove this line from yourself
<?php /* ------ BEGIN SCRIPT WORKING -----------*/
echo 'ok'and there is no coincidence on the salb. Why do you need such a creepy algorithm? - Naumov