Ok, it's quite simple. I have my script open a file and remove a line of it using "str_replace". I've only gotten it to work when I enter only plain text to replace. I can not get it to replace the text using any variables or anything:
Here's what works:
str_replace("<!--test - qwe --><?PHP include ('userFiles/original_Destroyer_test_qwe.php'); ?><!---->", "", "".$filecontents."");
This deletes the line as needed.
Here's what I need to work:
str_replace("<!--$FileUsrName - $FileNoExt --><?PHP include ('userFiles/$ModType".."$FileObjType".."$FileUsrName"._."$FileIs'); ?><!---->", "", "".$filecontents."");
I've also tried putting it into a string and trying this:
str_replace("".$Listdash1."", "","".$filecontents."");
Any idea's why this is not working or a work around?
Thanks for your hep people!

    Try this:

    $string = "<!--$FileUsrName - $FileNoExt --><?PHP include ('userFiles/$ModType_$FileObjType_$FileUsrName_$FileIs'); ?><!---->";
    
    str_replace($string, "", $filecontents);
    

      no luck, same problem. Anyone else?

        have you echoed the string when you're using the variables, to see what it actually does put out?

          aaa crap. I just looked at it adn relized that is was echoing back the ZIP file istead of the PHP file. My bad. It works now. but thanks alot.
          Well here it is. It takes a file that is passed to it and parses off part of it. Then open another file which contains links to the diffrent files and deletes the link from the link file, and resaves the link file.

          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
          <?
          if (!class_exists(auth))
          {
          include ("auth.php");
          }
          include ("authconfig.php");
          include ("check.php");

          if ($check["level"] != 1 && $check["level"] != 999)
          {
          	// Feel free to change the error message below. Just make sure you put a "\" before
          	// any double quote.
          	include ('permissionerror.php');
          	exit; // End program execution. This will disable continuation of processing the rest of the page.
          }

          $authuser = $check["uname"];
          include('../phpscripts/sitevariables.php');
          $deleteroot=$systemroot."userFiles/";
          if(substr($file, -4, 4)==".zip")
          {
          //pars down to the file name
          $ModEndCounter=0;
          $dash1="";
          while ($dash1 !== "")
          {$dash1 = substr("$file",$ModEndCounter,1);$ModEndCounter++;}
          if ($ModEndCounter>32)
          {break;return;}
          if ($dash1 == "
          ")
          {
          $FileName1=substr("$file",0,128);
          $fileminusmod=substr("$FileName1",$ModEndCounter,128);
          $ModTypeab=substr("$FileName1",0,$ModEndCounter);
          $ModType=substr("$ModTypeab",0,$ModEndCounter-1);

          			$ObjEndCounter=0;
          			$dash2="";
          			while ($dash2 !== "_")
          				{$dash2 = substr("$fileminusmod",$ObjEndCounter,1);$ObjEndCounter++;}
          			if ($ObjEndCounter>32)
          				{break;return;}
          			if ($dash2 == "_")
          				{
          					$FileObjType=substr("$fileminusmod",0,128);
          					$FilenameMinusObj=substr("$fileminusmod",$ObjEndCounter,128);
          					$FileObjType=substr("$fileminusmod",0,$ObjEndCounter-1);
          
          					$UsrEndCounter=0;
          					$dash3="";
          					while ($dash3 !== "_")
          						{$dash3 = substr("$FilenameMinusObj",$UsrEndCounter,1);$UsrEndCounter++;}
          					if ($UsrEndCounter>32)
          						{break;return;}
          					if ($dash3 == "_")
          						{
          							$FileUsr=substr("$FilenameMinusObj",0,128);
          							$FilenameMinusUSr=substr("$FilenameMinusObj",$UsrEndCounter,128);
          							$FileUsrName=substr("$FilenameMinusObj",0,$UsrEndCounter-1);
          
          							$FileEndCounter=0;
          							$dash4="";
          							while ($dash4 !== ".")
          								{$dash4 = substr("$FilenameMinusObj",$FileEndCounter,1);$FileEndCounter++;}
          							if ($FileEndCounter>32)
          								{break;return;}
          							if ($dash4 == ".")
          								{
          									$FileIs= substr("$FilenameMinusUSr",0,128);
          									$FileUsrIs=substr("$FilenameMinusObj",$FileEndCounter,128);
          									$FileNoExt=substr("$FilenameMinusUSr",0,$FileEndCounter-6);

          if ($authuser == $FileUsrName)
          {
          $filetoworkon = $deleteroot."lists/".$ModTypeab.$FileObjType.".php";
          $handle = fopen ($filetoworkon, "r+");
          $filecontents = fread ($handle, filesize ($filetoworkon));
          fclose ($handle);
          $FindListCounter=0;
          $Listdash1="<!--$FileUsrName - $FileNoExt --><?PHP include ('userFiles/$ModType".."$FileObjType".."$FileUsrName".."$FileNoExt.php'); ?><!---->";
          while ($Listdash1 !== "<!--$FileUsrName - $FileNoExt --><?PHP include ('userFiles/$ModType".
          ."$FileObjType".."$FileUsrName".."$FileNoExt.php'); ?><!---->")
          {$Listdash1 = substr("$filecontents",$FindListCounter);$FindListCounter++;}
          if ($FindListCounter>256)
          {break;return;}
          if ($Listdash1 == "<!--$FileUsrName - $FileNoExt --><?PHP include ('userFiles/$ModType".."$FileObjType".."$FileUsrName".."$FileNoExt.php'); ?><!---->")
          {
          $wearegood = "ok";
          $filecontents_minuslink_done = str_replace("<!--$FileUsrName - $FileNoExt --><?PHP include ('userFiles/$ModType".
          ."$FileObjType".."$FileUsrName".."$FileNoExt.php'); ?><!---->", "", $filecontents);
          }
          $handle = fopen ($filetoworkon, "w");
          fwrite($handle, $filecontents_minuslink_done);
          fclose($handle);

          $filename_only=substr($file,0,-4);
          unlink("".$deleteroot.$filename_only.".zip");
          unlink("".$deleteroot.$filename_only.".php");
          unlink("".$deleteroot.$filename_only."info.php");
          if(file_exists($deleteroot.$filename_only."-1.jpg"))
          {
          unlink("".$deleteroot.$filename_only."-1.jpg");
          unlink("".$deleteroot."tmb
          ".$filename_only."-1.jpg");
          }
          if(file_exists("".$deleteroot.$filename_only."-2.jpg"))
          {
          unlink("".$deleteroot.$filename_only."-2.jpg");
          unlink("".$deleteroot."tmb_".$filename_only."-2.jpg");
          }
          }
          elseif ($authuser !== $FileUsrName)
          {break;return;}

          								}
          						}
          				}
          		}
          }

          ?>
          <html>
          <head>
          <meta http-equiv="refresh" content="0;url=<?PHP echo $httproot ?>SecureZone/FileAdmin.php">

          </head>
          <body>
          <?PHP
          echo "Level: ";echo $check["level"];echo "<BR><br>";
          echo "SystemRoot: ";echo $systemroot;echo "<BR>";
          echo "DeleteRoot: ";echo $deleteroot;echo "<BR>";
          echo "File: ";echo $file;echo "<BR><br>";
          echo "ModEndCounter: ";echo $ModEndCounter;echo "<BR>";
          echo "Dash1: ";echo $dash1;echo "<BR>";
          echo "FileName1: ";echo $FileName1;echo "<BR>";
          //echo "FileMinusMod: ";echo $fileminusmod;echo "<BR>";
          //echo "ModType Abbriv: ";echo $ModTypeab;echo "<BR>";
          echo "ModType: ";echo $ModType;echo "<BR>";
          //echo "ObjEndCounter: ";echo $ObjEndCounter;echo "<BR><br>";
          echo "dash2: ";echo $dash2;echo "<BR>";
          echo "FileObjType: ";echo $FileObjType;echo "<BR>";
          //echo "FileNameMinusObj: ";echo $FilenameMinusObj;echo "<BR>";
          //echo "FileObjType: ";echo $FileObjType; echo "<BR>";
          //echo "UsrEndCounter: ";echo $UsrEndCounter;echo "<BR><br>";
          echo "dash3: ";echo $dash3;echo "<BR>";
          echo "UserSignInIs: ";echo $authuser; echo"<br>";
          echo "FileUsr: ";echo $FileUsr;echo "<BR>";
          //echo "FilenameMinusUsr: ";echo $FilenameMinusUSr;echo "<BR>";
          echo "FileUsrName: ";echo $FileUsrName;echo "<BR>";
          //echo "FileEndCounter: ";echo $FileEndCounter;echo "<BR><br>";
          echo "dash4: ";echo $dash4;echo "<BR>";
          echo "FileIS: ";echo $FileIs; echo "<br>";
          echo "FileNoExt: ";echo $FileNoExt;echo "<BR>";
          echo "fileExt: ";echo $FileUsrIs;echo "<BR><br>";
          echo "File to Work on: ";echo $filetoworkon;echo "<br>";
          echo "File content: ";echo $filecontents;echo "<BR>";
          echo "FindListCounter: "; echo $FindListCounter; echo "<br>";
          echo "isitok: ";echo $isitok; echo "<br>";
          echo "Listdash B4 removal: "; echo $Listdash1_spaces; echo "<br>";
          echo "List Dash: "; echo $Listdash1; echo "<br>";
          echo "File Contents After Link is Removed: "; echo $filecontents_minuslink_done; echo "<br>";
          echo "we are good:"; echo $wearegood; echo "<br>";
          ?>

          </body>
          </html>

            Write a Reply...