Make gen.php a bit prettier

This commit is contained in:
v3d 2022-05-10 12:29:04 +00:00
parent de4f6ea951
commit 748f415de9

View File

@ -9,26 +9,27 @@
$slides_desc = @$_POST['work_desc'];
$color = @$_POST['color'];
function rearrange( $arr ){
foreach( $arr as $key => $all ){
foreach( $all as $i => $val ){
function rearrange($arr)
{
foreach ($arr as $key => $all)
{
foreach ($all as $i => $val)
{
$new[$i][$key] = $val;
}
}
return $new;
}
$myfiles = array();
// $file_ary = $_FILES['mytest'];
if (isset($_FILES['mytest'])){
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);
@ -45,9 +46,9 @@ $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
// // echo "File is not an image.";
// $uploadOk = 0;
// }
// Check if file already exists
if (file_exists($target_file)) {
if (file_exists($target_file))
{
// echo "Sorry, file already exists.";
$uploadOk = 0;
}
@ -57,25 +58,34 @@ if (file_exists($target_file)) {
$uploadOk = 0;
}*/
// Allow certain file formats
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
&& $imageFileType != "gif" && $imageFileType != "webm" && $imageFileType != "ogg" ) {
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) {
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)) {
}
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 {
}
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
</div>
</noscript>
<?php
if(isset($_POST['togetherjs']) &&
$_POST['togetherjs'] == 'Yes')
if (isset($_POST['togetherjs']) && $_POST['togetherjs'] == 'Yes')
{
echo '<script>
TogetherJSConfig_findRoom = {prefix: "piviliontestrun2", max: 50};
@ -177,27 +185,31 @@ else
<?php
$myfiles = preg_replace("/gen\//", "", $myfiles);
//var_dump($myfiles);
$cnt = 1;
foreach ($slides_array as $imageVal) {
foreach ($slides_array as $imageVal)
{
// echo $cnt;
if ($imageVal == '--SECTION--'){
if ($imageVal == '--SECTION--')
{
$sld = 1;
echo '</div>';
echo '<div class="section" id="section' . $cnt . '">';
$cnt++;
//next($myfiles);
}else{
}
else
{
$ext = "";
$ext = explode(".", current($myfiles));
$format = $ext[sizeof($ext) - 1];
switch ($format) {
switch ($format)
{
case "webm":
echo '<div class="slide" id="slide' . $sld . '">
<video src="' . current($myfiles) . '" data-autoplay="1" loop="1" controls ="1"></video>
@ -239,14 +251,14 @@ $source = "skeleton/";
$dest = "/var/www/html/pivilion/gen";
mkdir($dest, 0755);
foreach (
$iterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS),
\RecursiveIteratorIterator::SELF_FIRST) as $item
) {
if ($item->isDir()) {
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 {
}
else
{
copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
}
}
@ -261,5 +273,6 @@ foreach (
fwrite($file, $output);
fclose($file);
ob_end_clean(); // discard trapped output and stop trapping
?>
<a href="http://<?php echo $torname; ?>/" target="_blank">Gallery is here!</a>