Hello everyone.
Im trying to make a little script that creates a script in a different directory.
Heres what im trying to do :
I'm trying to have it create a dir called "newdir" and create a file called "log.php" in that dir, then fill the file with the content bellow :
Not sure where im going wrong here.. also, when i try to mkdir() and create the file at the same time it just refuses to do it.
Would appreciate some help on this<3
Kind Regards 🙂
Im trying to make a little script that creates a script in a different directory.
Heres what im trying to do :
PHP Code
<?php
$File = "text.txt";
$Handle = fopen($File, 'w');
?>
<?php
$content = "<?
$fh = fopen( 'log.txt', 'w' );
fclose($fh);
$red = $_SERVER['REQUEST_URI'];
$file = "log.txt";
$hostname = $_SERVER['HTTP_HOST'];
$Browser = $_SERVER['HTTP_USER_AGENT'];
$ip = $_SERVER['REMOTE_ADDR'];
$today = date("F j, Y, g:i a");
$handle = fopen($file, 'a');
fwrite($handle, "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
fwrite($handle, "\n");
fwrite($handle, "IP Address: ");
fwrite($handle, "$ip");
fwrite($handle, "\n");
fwrite($handle, "Date: ");
fwrite($handle, "$today");
fwrite($handle, "\n");
fwrite($handle, "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
fwrite($handle, "\n");
fwrite($handle, "\n");
fclose($handle);
?>
<html><head>
<title>404 Not Found</title>
</head><body bgcolor=black>
<font color=lime><h1>Not Found</h1></font>
<p><font color=lime>The requested URL / was not found on this server.</font></p>
<hr>
<address><font color=lime><? echo $_SERVER['SERVER_SIGNATURE']; ?></font></address>
</body></html>";
$File = "text.txt";
$Handle = fopen($File, 'w');
fwrite($Handle, $content);
print "Data Written";
fclose($Handle);
?>I'm trying to have it create a dir called "newdir" and create a file called "log.php" in that dir, then fill the file with the content bellow :
Code
<?
$fh = fopen( 'log.txt', 'w' );
fclose($fh);
$red = $_SERVER['REQUEST_URI'];
$file = "log.txt";
$hostname = $_SERVER['HTTP_HOST'];
$Browser = $_SERVER['HTTP_USER_AGENT'];
$ip = $_SERVER['REMOTE_ADDR'];
$today = date("F j, Y, g:i a");
$handle = fopen($file, 'a');
fwrite($handle, "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
fwrite($handle, "\n");
fwrite($handle, "IP Address: ");
fwrite($handle, "$ip");
fwrite($handle, "\n");
fwrite($handle, "Date: ");
fwrite($handle, "$today");
fwrite($handle, "\n");
fwrite($handle, "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
fwrite($handle, "\n");
fwrite($handle, "\n");
fclose($handle);
?>
<html><head>
<title>404 Not Found</title>
</head><body bgcolor=black>
<font color=lime><h1>Not Found</h1></font>
<p><font color=lime>The requested URL / was not found on this server.</font></p>
<hr>
<address><font color=lime><? echo $_SERVER['SERVER_SIGNATURE']; ?></font></address>
</body></html>Not sure where im going wrong here.. also, when i try to mkdir() and create the file at the same time it just refuses to do it.
Would appreciate some help on this<3
Kind Regards 🙂
