as you can see here it still just displays a white page…
http://www.blazecheerleaders.co.uk/Test … tindex.php
but the original still works…
http://www.blazecheerleaders.co.uk/TestXML/index.php
The white page also occurred when i just removed the list files feature i.e. this section of code:
[php]
while ($file = readdir($handle)) {
if(!is_dir($file) && !is_link($file)) {
$filelist .= "
“.date(“d-m H:i”, filemtime($upload_dir.$file))
.” |
“.$file.”";
if (!$DELETABLE)
$filelist .= “ |
Not Supported |
”;
if ($DELETABLE)
$filelist .= “
x | ”;
[/php]
here is the rest of the code in the working version, before I changed anything, in case it makes it any clearer as to what the problem could be…
[php]
<?php
//vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
// You may change maxsize, and allowable upload file types.
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//Maximum file size. You may increase or decrease.
$MAX_SIZE = 10000000;
//Allowable file ext. names. you may add more extension names.
$FILE_EXTS = array('.jpg','.gif','.bmp','.jpeg','.mp3');
//Allow file delete? no, if only allow upload only.
$DELETABLE = true;
/************************************************************
* Setup variables
************************************************************/
//File you wish to save the playlist to.
$savefile = "playlist.xml";
//Allow download of MP3s.
$info = "no";
//Directory uploaded files go to.
$upload_dir = "files/";
//Image file types checked for in the writting the .xml
$imgfilecheck = array(".jpg",".gif",".bmp",".jpeg");
//vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
// Do not touch the below if you are not confident.
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/************************************************************
* Other variables
************************************************************/
$site_name = $_SERVER['HTTP_HOST'];
$url_dir = "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
$url_this = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
$upload_url = $url_dir."/files/";
$message ="";
/************************************************************
* Create Upload Directory
************************************************************/
if (!is_dir("files")) {
if (!mkdir($upload_dir))
die ("upload_files directory doesn't exist and creation failed");
if (!chmod($upload_dir,0777))
die ("change permission to 777 failed.");
}
/************************************************************
* Process User's Request
************************************************************/
if ($_REQUEST[del] && $DELETABLE) {
$resource = fopen("log.txt","a");
fwrite($resource,date("Ymd h:i:s")."DELETE - $_SERVER[REMOTE_ADDR]"."$_REQUEST[del]n");
fclose($resource);
if (strpos($_REQUEST[del],"/.")>0); //possible hacking
else if (strpos($_REQUEST[del],$upload_dir) === false); //possible hacking
else if (substr($_REQUEST[del],0,6)==$upload_dir) {
unlink($_REQUEST[del]);
print "";}
}
else if ($_FILES['userfile']) {
$resource = fopen("log.txt","a");
fwrite($resource,date("Ymd h:i:s")."UPLOAD - $_SERVER[REMOTE_ADDR]"
.$_FILES['userfile']['name']." "
.$_FILES['userfile']['type']."n");
fclose($resource);
$file_type = $_FILES['userfile']['type'];
$file_name = $_FILES['userfile']['name'];
$file_ext = strtolower(substr($file_name,strrpos($file_name,".")));
//File Size Check
if ( $_FILES['userfile']['size'] > $MAX_SIZE)
$message = "The file size is over 10MB.";
//File Extension Check
else if (!in_array($file_ext, $FILE_EXTS))
$message = "Sorry, $file_name($file_type) is not allowed to be uploaded.";
else
$message = do_upload($upload_dir, $upload_url);
print "";
}
else if (!$_FILES['userfile']);
else
$message = "Invalid File Specified.";
/************************************************************
* List Files/Update XML
************************************************************/
$handle=opendir($upload_dir);
$filelist = "";
$stringdata .= "<?xml version="1.0" encoding="UTF-8" ?>n";
$stringdata .= “n n”;
while ($file = readdir($handle)) {
if(!is_dir($file) && !is_link($file)) {
$filelist .= "
“.date(“d-m H:i”, filemtime($upload_dir.$file))
.” |
“.$file.”";
if (!$DELETABLE)
$filelist .= “ |
Not Supported |
”;
if ($DELETABLE)
$filelist .= “
x | ”;
$stringdata .= “n n “.str_replace(”.mp3”,"",$file).“n $url_dir/$upload_dir$filen”;
if ($info == “yes”)
{$stringdata .= " $url_dir$upload_dir$filen";}
if (file_exists(str_replace(".mp3",$ingfilecheck,$file)))
{$stringdata .= "
$url_dir$upload_dir".str_replace(".mp3",".jpg",$file).“n”;}
$stringdata .= " ";
}
}
$stringdata .= "nn n
";
$fh = fopen($savefile, ‘w’);
fwrite($fh, $stringdata);
fclose($fh);
function do_upload($upload_dir, $upload_url) {
$temp_name = $_FILES['userfile']['tmp_name'];
$file_name = $_FILES['userfile']['name'];
$file_name = str_replace("","",$file_name);
$file_name = str_replace("’","",$file_name);
$file_path = $upload_dir.$file_name;
//File Name Check
if ( $file_name =="") {
$message = “Invalid File Name Specified”;
return $message;
}
$result = move_uploaded_file($temp_name, $file_path);
if (!chmod($file_path,0777))
$message = “change permission to 777 failed.”;
else
{$message = ($result)?"$file_name uploaded successfully." :
“Somthing is wrong with uploading a file.”;}
return $message;
}
?>
[/php]