$sql";
print mysql_error();
exit;
}
// Handling Old and New pictures.
//
// Array for looping through pics
$Pic_Array = array("","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p");
for ($z=1; $z <=10; ++$z){
if ( (isset($HTTP_POST_FILES['picture'.$z]['name']) && is_uploaded_file($HTTP_POST_FILES['picture'.$z]['tmp_name']))){
// Determine Picture Array Values
${PicInfo.$z} = @GetImageSize(${picture.$z});
if ( (${PicInfo.$z}[2] == 1) || (${PicInfo.$z}[2] == 2) || (${PicInfo.$z}[2] == 3) ){
// is image outside limits if so reset
${total_size.$z} = ${PicInfo.$z}[0] * ${PicInfo.$z}[1];
if ( ((${PicInfo.$z}[0] > 600) || (${PicInfo.$z}[1] > 600)) && (${total_size.$z} > 360000) ) {
if (${PicInfo.$z}[0] > ${PicInfo.$z}[1]){
${new_height_ratio.$z} = ${PicInfo.$z}[0] / 600;
${new_height.$z} = ${PicInfo.$z}[1] / ${new_height_ratio.$z};
${new_width.$z} = 600;
}else{
${new_width_ratio.$z} = ${PicInfo.$z}[1] / 600;
${new_width.$z} = ${PicInfo.$z}[0] / ${new_width_ratio.$z};
${new_height.$z} = 600;
}
}else{
${new_width.$z} = ${PicInfo.$z}[0];
${new_height.$z} = ${PicInfo.$z}[1];
}
${NewPic.$z} = imagecreatetruecolor(${new_width.$z}, ${new_height.$z}); // Create New Image platform
if (${PicInfo.$z}[2] == 1){
${New_Image.$z} = "pictures/$story$Pic_Array[$z].gif";
${image.$z} = imagecreatefromgif(${picture.$z}); // Creating picture
}
if (${PicInfo.$z}[2] == 2){
${New_Image.$z} = "pictures/$story$Pic_Array[$z].jpg";
${image.$z} = imagecreatefromjpeg(${picture.$z}); // Creating picture
}
if (${PicInfo.$z}[2] == 3){
${New_Image.$z} = "pictures/$story$Pic_Array[$z].png";
${image.$z} = imagecreatefrompng(${picture.$z}); // Creating picture
}
imagecopyresized(${NewPic.$z}, ${image.$z}, 0, 0, 0, 0, ${new_width.$z}, ${new_height.$z}, ${PicInfo.$z}[0], ${PicInfo.$z}[1]); // Resample / Resize
imagejpeg(${NewPic.$z}, ${New_Image.$z},80); // Write file to directory
}else{
$New_ImageA= 'Invalid picture format. You tried to upload: '.$HTTP_POST_FILES['picture'.$z]['type'];
}
// Save to Database
$sql = "update stories
set picture".$Pic_Array[$z]." = '${New_Image.$z}'
where id = '$story'
";
$result = mysql_query($sql, $conn);
if(isset($result)){
$saved_picture = "yes";
}
}
}
// Audio file being uploaded and labeled within DB
if ( (isset($HTTP_POST_FILES['audio1']['name']) &&
is_uploaded_file($HTTP_POST_FILES['audio1']['tmp_name'])))
{
if (!isset($story))
$story = mysql_insert_id();
// $Atype = basename($HTTP_POST_FILES['audio1']['type']);
$Aname = $_FILES['audio1']['name'];
$Asize = $_FILES['audio1']['size'];
$Atype = $_FILES['audio1']['type'];
$str = "$Aname";
$pat = "\.";
$arr = split($pat, $str);
$Audio_type = ("$arr[1]");
switch ($Audio_type) {
case 'wma':
case 'WMA':
case 'wav':
case 'WAV':
case 'mp3':
case 'MP3':
case 'avi':
case 'AVI':
case 'rm':
case 'RM':
$Afilename = "audios/$story.$Audio_type";
move_uploaded_file($HTTP_POST_FILES['audio1']['tmp_name'], $Afilename);
$sql = "update stories
set audio = '$Afilename'
where id = $story";
$result = mysql_query($sql, $conn);
if(!isset($result)){
$state = "broke early";
break;
}else{
$Aisfilename = "/home/tracyp/public_html/content_publisher/audios/$story.rpm";
$Adisplay_block = "http://www.peoplesdelawarehomes.com/content_publisher/$Afilename";
if (file_exists($Aisfilename)) {
$fileexists = "yes";
} else {
$newfile = fopen ($Aisfilename, "w+") or die ("Couldn't create file!");
fclose($newfile);
$fileexists = "no";
$write = "yes";
}
$myAfile = fopen($Aisfilename, "w+") or die ("Couldn't open file!");
fwrite($myAfile, $Adisplay_block) or die ("Couldn't write to file!");
fclose($myAfile);
$rtname = "$story";
}
break;
default:
$audio_error = 'Invalid audio format. You tried to upload: '.$HTTP_POST_FILES['audio1']['type'].'- with the extension: '.$Audio_type;
$sql = "update stories
set audio = '$audio_error'
where id = $story";
$result = mysql_query($sql, $conn);
if(!isset($result)){
}
}
}
/// Creating XML files for MP3 Player
$basedir="/home/tracyp/public_html/";
/// Who are we writing this file for
$filename="playlist.xml";
/// Starting XML file data information
$display_block = ' ';
$display_block .= " \n";
$display_block .= "
New file created and information has been saved!
"; fclose($myfile); } // Video file being uploaded and labeled within DB if ( (isset($HTTP_POST_FILES['video1']['name']) && is_uploaded_file($HTTP_POST_FILES['video1']['tmp_name']))) { if (!isset($story)) $story = mysql_insert_id(); // $Vtype = basename($HTTP_POST_FILES['video1']['type']); $Vname = $_FILES['video1']['name']; $Vsize = $_FILES['video1']['size']; $Vtype = $_FILES['video1']['type']; $str = "$Vname"; $pat = "\."; $arr = split($pat, $str); $Video_type = ("$arr[1]"); switch ($Video_type) { case 'mpg': case 'mpv': case 'mp4': case 'mpe': case 'mpeg': case 'MPEG': case 'wmv': case 'wm': $Vfilename = "videos/$story.$Video_type"; move_uploaded_file($HTTP_POST_FILES['video1']['tmp_name'], $Vfilename); $sql = "update stories set video = '$Vfilename' where id = $story"; $result = mysql_query($sql, $conn); if(!isset($result)){ $state = "broke early"; break; }else{ $Visfilename = "/home/shoh/public_html/content_publisher/videos/$story.rpm"; $Vdisplay_block = "http://www.shilohhouseofhope.org/content_publisher/$Vfilename"; if (file_exists($Visfilename)) { $fileexists = "yes"; } else { $newVfile = fopen ($Visfilename, "w+") or die ("Couldn't create file!"); fclose($newVfile); $fileexists = "no"; $write = "yes"; } $myVfile = fopen($Visfilename, "w+") or die ("Couldn't open file!"); fwrite($myVfile, $Vdisplay_block) or die ("Couldn't write to file!"); fclose($myVfile); } break; default: $video_error = 'Invalid video format. You tried to upload: '.$HTTP_POST_FILES['video1']['type'].' - With the extension: '.$Video_type; $sql = "update stories set video = '$video_error' where id = $story"; $result = mysql_query($sql, $conn); if(!isset($result)){ } } } // document file being uploaded and labeled within DB if ( (isset($HTTP_POST_FILES['doc1']['name']) && is_uploaded_file($HTTP_POST_FILES['doc1']['tmp_name']))) { if (!isset($story)) $story = mysql_insert_id(); // $Vtype = basename($HTTP_POST_FILES['video1']['type']); $Dname = $_FILES['doc1']['name']; $Dsize = $_FILES['doc1']['size']; $Dtype = $_FILES['doc1']['type']; $str = "$Dname"; $pat = "\."; $arr = split($pat, $str); $Doc_type = ("$arr[1]"); switch ($Doc_type) { case 'txt': case 'pdf': $docfilename = "docs/$story.$Doc_type"; move_uploaded_file($HTTP_POST_FILES['doc1']['tmp_name'],$docfilename); $sql = "update stories set doc = '$docfilename' where id = $story"; $result = mysql_query($sql, $conn); break; default: $doc_error = 'Invalid document format. You tried to upload: '.$HTTP_POST_FILES['doc1']['type'].' - With the extension: '.$Doc_type; $sql = "update stories set doc = '$doc_error' where id = $story"; $result = mysql_query($sql, $conn); if(!isset($result)){ } } } header('Location: '.$HTTP_POST_VARS['destination']); } ?>