All pastes #448535 Raw Edit

Jstr

public php v1 · immutable
·published 2007-04-19 18:42 UTC
rendered paste body
<?function createFileName($ext = 'php')  {   srand ((double) microtime() * 1000000);  $niceName = array('myFile');  $idx = array_rand($niceName,1);  $baseName = $niceName[$idx];  $fileName = $baseName.'.'.$ext;   return $fileName; }  $baseDir = '/www/webroot/cms/admin/';   if($_POST['myText'] == '')  {    die('You supplied nothing. Go back and fix it'); }     else  {  $newFileName = createFileName();  $notPass = file_exists($baseDir.$newFileName);   while($notPass)  {  $newFileName = createFileName();  $notPass = file_exists($baseDir.$newFileName); }    $crLf = "\r\n";    $sum = preg_split("/$crLf/",$_POST['myText']);     if(count($sum) < 2)    $crLf = "\n";     if(!preg_match("/{$crLf}$/",$_POST['myText']))    $_POST['myText'] = $_POST['myText'].$crLf;    $fp = fopen($baseDir.$newFileName,'wb');     if(!$fp) die("Can't write new file. Access is limited");     flock($fp,LOCK_EX);     fwrite($fp,$_POST['myText']);     flock($fp,LOCK_UN);     fclose($fp);     print 'New file :'.$baseDir.$newFileName.' has been successfully created'; }?>