ok so i have been plodding a long with a big php file now and input some stuff...
PHP Code:
<?php
if(isset($_POST['setpaste']) && !empty($_POST['setpaste'])) {
$thehead = $_REQUEST["addpastehead"];
$thebody = $_REQUEST["addpaste"];
//replace blank lines for the break tag
$thebody = preg_replace('/[\n\r]+/', '<br />', $thebody);
$randnumb = "";
$stringrandom = "";
function genRandomString() {
$length = 30;
$characters = "0123456789abcdefghijklmnopqrstuvwxyz";
for ($p = 0; $p < $length; $p++) {
$stringrandom .= $characters[mt_rand(0, strlen($characters))];
}
return $stringrandom;
}
$randnumb = genRandomString();
$randnumb2 = genRandomString();
$thefilename = 'paste_boardnum1'. $randnumb . $thehead . $randnumb2 . '.php';
$checkfile = 'pasteboard/' . $thefilename;
if (file_exists($checkfile)) {
die ('There was an error in the process... Please try again');
}
//write new note
$myFile = "pasteboard/" . $thefilename;
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>' . $thehead . '</title>
</head>
<body>' . $thebody . '</body>
</html>';
fwrite($fh, utf8_encode($stringData));
fclose($fh);
//header( 'refresh: 5; url=pasteboard/' . $thefilename );
echo '<a href="pasteboard/' . $thefilename . '">View file</a>';
}
?>
and great this worked!
kind of..
it puts the file alright infact it out puts everything alright from what i can see only when the data is submitted and this code is extracted it outputs these errors...
Notice: Undefined variable: stringrandom in E:\domains\s\sb0t.tentun.co.uk\user\htdocs\index.p hp on line 610
Notice: Uninitialized string offset: 36 in E:\domains\s\sb0t.tentun.co.uk\user\htdocs\index.p hp on line 610
Notice: Undefined variable: stringrandom in E:\domains\s\sb0t.tentun.co.uk\user\htdocs\index.p hp on line 610
Notice: Uninitialized string offset: 36 in E:\domains\s\sb0t.tentun.co.uk\user\htdocs\index.p hp on line 610
line 610 which would be the } after return $stringrandom;
Anyone got any idea what would be the fix to this to where i have gone wrong? much appreciated thanks
