From 748f415de93e69a346e159a3da81b7c35f0ce954 Mon Sep 17 00:00:00 2001 From: v3d Date: Tue, 10 May 2022 12:29:04 +0000 Subject: [PATCH] Make gen.php a bit prettier --- var/www/html/pivilion/gen.php | 315 ++++++++++++++++++---------------- 1 file changed, 164 insertions(+), 151 deletions(-) diff --git a/var/www/html/pivilion/gen.php b/var/www/html/pivilion/gen.php index 03df7ec..69a7ac7 100644 --- a/var/www/html/pivilion/gen.php +++ b/var/www/html/pivilion/gen.php @@ -1,85 +1,95 @@ $all ){ - foreach( $all as $i => $val ){ - $new[$i][$key] = $val; - } +ob_start(); // start trapping output +$banana = @$_POST['banana']; +$title = @$_POST['title']; +$description = @$_POST['description']; +$images_array = $_FILES['mytest']; +$slides_array = @$_POST['imgs']; +$slides_autors = @$_POST['author']; +$slides_desc = @$_POST['work_desc']; +$color = @$_POST['color']; + +function rearrange($arr) +{ + foreach ($arr as $key => $all) + { + foreach ($all as $i => $val) + { + $new[$i][$key] = $val; + } } - return $new; -} - - + return $new; +} + $myfiles = array(); // $file_ary = $_FILES['mytest']; -if (isset($_FILES['mytest'])){ - foreach (rearrange($images_array) as $file) - { - //echo $file['name']; +if (isset($_FILES['mytest'])) +{ + foreach (rearrange($images_array) as $file) + { + //echo $file['name']; + + $target_dir = "gen/upload/"; + usleep(1); + $target_file = $target_dir . str_replace(",", "", str_replace(".", "", number_format(microtime(true) , 4))) . '.' . pathinfo($file['name'], PATHINFO_EXTENSION); + $uploadOk = 1; + $imageFileType = pathinfo($target_file, PATHINFO_EXTENSION); + // Check if image file is a actual image or fake image + //echo $imageFileType; + // $check = getimagesize($file['tmp_name']); + // if($check !== false) { + // // echo "File is an image - " . $check["mime"] . "."; + // $uploadOk = 1; + // } else { + // // echo "File is not an image."; + // $uploadOk = 0; + // } + // Check if file already exists + if (file_exists($target_file)) + { + // echo "Sorry, file already exists."; + $uploadOk = 0; + } + // Check file size + /*if ($file["size"] > 500000) { + echo "Sorry, your file is too large."; + $uploadOk = 0; + }*/ + // Allow certain file formats + if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" && $imageFileType != "webm" && $imageFileType != "ogg") + { + // echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; + $uploadOk = 0; + } + // Check if $uploadOk is set to 0 by an error + if ($uploadOk == 0) + { + array_push($myfiles, ""); + // echo "Sorry, your file was not uploaded."; + // if everything is ok, try to upload file + + } + else + { + if (move_uploaded_file($file['tmp_name'], $target_file)) + { - -$target_dir = "gen/upload/"; -usleep(1); -$target_file = $target_dir . str_replace( ",", "",str_replace( ".", "", number_format(microtime(true),4))) . '.' . pathinfo($file['name'], PATHINFO_EXTENSION); - -$uploadOk = 1; -$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION); -// Check if image file is a actual image or fake image -//echo $imageFileType; - // $check = getimagesize($file['tmp_name']); - // if($check !== false) { - // // echo "File is an image - " . $check["mime"] . "."; - // $uploadOk = 1; - // } else { - // // echo "File is not an image."; - // $uploadOk = 0; - // } - -// Check if file already exists -if (file_exists($target_file)) { -// echo "Sorry, file already exists."; - $uploadOk = 0; -} -// Check file size -/*if ($file["size"] > 500000) { - echo "Sorry, your file is too large."; - $uploadOk = 0; -}*/ -// Allow certain file formats -if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" -&& $imageFileType != "gif" && $imageFileType != "webm" && $imageFileType != "ogg" ) { -// echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; - $uploadOk = 0; -} -// Check if $uploadOk is set to 0 by an error -if ($uploadOk == 0) { - array_push($myfiles, ""); - // echo "Sorry, your file was not uploaded."; -// if everything is ok, try to upload file -} else { - if (move_uploaded_file($file['tmp_name'], $target_file)) { - - $file['tmp_name'] = $target_file; - array_push($myfiles, $target_file); - //echo "The file ". basename( $file['name']). " has been uploaded."; - } else { - array_push($myfiles, ""); - // echo "Sorry, there was an error uploading your file."; + $file['tmp_name'] = $target_file; + array_push($myfiles, $target_file); + //echo "The file ". basename( $file['name']). " has been uploaded."; + + } + else + { + array_push($myfiles, ""); + // echo "Sorry, there was an error uploading your file."; + + } + } } } -} -} ?> @@ -145,9 +155,7 @@ Menu -> Tools -> Add-ons -> NoScript -> Enable/Disable/Configure TogetherJSConfig_findRoom = {prefix: "piviliontestrun2", max: 50}; @@ -160,8 +168,8 @@ if(isset($_POST['togetherjs']) && else { echo " "; -} - +} + ?> @@ -177,89 +185,94 @@ else '; - echo '
'; - $cnt++; - //next($myfiles); - }else{ - $ext =""; - $ext = explode(".", current($myfiles)); - $format = $ext[sizeof($ext)-1]; - switch ($format) { - case "webm": - echo'
- -
'.$imageVal.'
'.current($slides_autors).'
'.current($slides_desc).'
-
'; - break; - - case "ogg": - echo'
- -
'.$imageVal.'
'.current($slides_autors).'
'.current($slides_desc).'
-
'; - break; - - default : - echo'
- -
'.$imageVal.'
'.current($slides_autors).'
'.current($slides_desc).'
-
'; - break; - } - next($slides_desc); - next($slides_autors); - next($myfiles); - - $sld++; - - } - - } +//var_dump($myfiles); +$cnt = 1; +foreach ($slides_array as $imageVal) +{ + // echo $cnt; - ?> + + if ($imageVal == '--SECTION--') + { + $sld = 1; + echo '
'; + echo '
'; + $cnt++; + //next($myfiles); + + } + else + { + $ext = ""; + $ext = explode(".", current($myfiles)); + $format = $ext[sizeof($ext) - 1]; + switch ($format) + { + case "webm": + echo '
+ +
' . $imageVal . '
' . current($slides_autors) . '
' . current($slides_desc) . '
+
'; + break; + + case "ogg": + echo '
+ +
' . $imageVal . '
' . current($slides_autors) . '
' . current($slides_desc) . '
+
'; + break; + + default: + echo '
+ +
' . $imageVal . '
' . current($slides_autors) . '
' . current($slides_desc) . '
+
'; + break; + } + next($slides_desc); + next($slides_autors); + next($myfiles); + + $sld++; + + } + +} + +?> -isDir()) { - mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName()); - } else { - copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName()); - } +foreach ($iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS) , \RecursiveIteratorIterator::SELF_FIRST) as $item) +{ + if ($item->isDir()) + { + mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName()); + } + else + { + copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName()); + } } ?> -Gallery is here! +Gallery is here!