Jump to content

PHP Code in a PHP Code..


Azzyh

Recommended Posts

Hello.

I have made this script:

<?
$msg = $_GET['testc'];
    if($_GET["testc"]) {
             if(mkdir(strtolower($msg), 0775)) {
                if(fwrite(fopen(strtolower($msg)."/index.php", "w+"), "CONTENT FOR THE INDEX FILE")) {
                    print "Done: <a href='http://azzyh.dk/$msg'>$msg.azzyh.dk</a>";
                     }else{
                    print "Error #8 contact admin, and report please.";
                }
            }else{
                print "Error #9 contact admin, and report please.";
            }
        }
?>

 

But i want to have a PHP script in the index.php file that the script above ^ is writing.

How should i do that ?

Here's the script i want in:

<?
$msg = $_GET['test'];
$logfile= 'log.html';
$fp = fopen($logfile, "a"); 
fwrite($fp, $msg);
fclose($fp); 
?>

 

Should i go like this:

<?
$msg = $_GET['testc'];
    if($_GET["testc"]) {
             if(mkdir(strtolower($msg), 0775)) {
                if(fwrite(fopen(strtolower($msg)."/index.php", "w+"), 
			?>
			<?
$msg = $_GET['test'];
$logfile= 'log.html';
$fp = fopen($logfile, "a"); 
fwrite($fp, $msg);
fclose($fp); 
?>
			<?
			)) {
                    print "Done: <a href='http://azzyh.dk/$msg'>$msg.azzyh.dk</a>";
                     }else{
                    print "Error #8 contact admin, and report please.";
                }
            }else{
                print "Error #9 contact admin, and report please.";
            }
        }
?>

That wouldn't work i believe!? unexpected syntax.

 

Thanks in forward!

 

 

-  My other topic, i was too fast saying that i solved it myself, because the include function didnt work. And i couldnt change the topic again to not solved..

 

 

Link to comment
Share on other sites

<?
$msg = $_GET['testc'];
    if($_GET["testc"]) {
             if(mkdir(strtolower($msg), 0775)) {
                if(fwrite(fopen(strtolower($msg)."/index.php", "w+"),

$msg = $_GET['test'];
$logfile= 'log.html';
$fp = fopen($logfile, "a");
fwrite($fp, $msg);
fclose($fp);

            )) {
                    print "Done: <a href='http://azzyh.dk/$msg'>$msg.azzyh.dk</a>";
                     }else{
                    print "Error #8 contact admin, and report please.";
                }
            }else{
                print "Error #9 contact admin, and report please.";
            }
        }
?>


Link to comment
Share on other sites

if ur doing it for multiples or maybe not, then u can have the file that has the php script in it, then copy that file....

$nameyourfile = $documentroot ."/". $variableornothere ."/index.php" ;
$filegettingcopied = $documentroot ."/directory/index.php" ;
if (copy($filegettingcopied, $nameyourfile))
{$congrats = "Congrats!the file was copied";}

Link to comment
Share on other sites

Purencool- I get, Parse error: syntax error, unexpected ';' in on line 7

 

emopoops - I dont get that coding, more than thankful if you would explain more.

 

Just to clear it up,  the php script

$msg = $_GET['test'];
$logfile= 'log.html';
$fp = fopen($logfile, "a");
fwrite($fp, $msg);
fclose($fp);

Shall not be used with that script, BUT the script shall be on the index.php' the script is building

Link to comment
Share on other sites

When you get this error always look at the line above

Parse error: syntax error, unexpected ';' in on line 7

 

below I have gone through your code with comments that tell you what it does

I not trying  to mean. Because you are new I  stepping you though what you have written

 

In dot point what is you want to do exactly and I will help you write the code

 

<?
// grabbing a global var
$msg = $_GET['testc'];
   // if testc is what eg empty full what?
    if($_GET["testc"]) {
              // change $msg to lower cand and make a dir
             if(mkdir(strtolower($msg), 0775)) {
                 // make  it lowercase and then open the file and write into the file
                if(fwrite(fopen(strtolower($msg)."/index.php", "w+"),
// the the test var and place into msg
$msg = $_GET['test'];
// log file  = log .html (if it exists)
$logfile= 'log.html';
// open log file and place into $fp
$fp = fopen($logfile, "a");
// write message into log
fwrite($fp, $msg);
// close log file
fclose($fp);

            )) {
// This code is not attached to any thing?
                    print "Done: <a href='http://azzyh.dk/$msg'>$msg.azzyh.dk</a>";
                     }else{
                    print "Error #8 contact admin, and report please.";
                }
            }else{
                print "Error #9 contact admin, and report please.";
            }
        }
?>

Link to comment
Share on other sites

$newfile = $documentroot ."/thedrectoryyouarewritingyourfilein/thenameofthenewfile.php" ;
   $thefilethatsgettingcopiedAKAtheonewithallthephpcodeyourtryingtoputinthephp = $documentroot ."/anydirectoryornot/thefilenameTHATISGETTINGCOPIED.php" ;
   if (copy($thefilethatsgettingcopiedAKAtheonewithallthephpcodeyourtryingtoputinthephp, $newfile))
   {$congrats = "Congrats!the file was copied";}

a. make a file with the contents u want the new file thats being created to have.

b.make the new file.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.