mirror of
https://gitlab.com/hacklab01/pivilion.git
synced 2025-04-29 16:47:17 +00:00
Make gen.php a bit prettier
This commit is contained in:
parent
de4f6ea951
commit
748f415de9
@ -1,42 +1,43 @@
|
|||||||
<?php
|
<?php
|
||||||
ob_start(); // start trapping output
|
ob_start(); // start trapping output
|
||||||
$banana = @$_POST['banana'];
|
$banana = @$_POST['banana'];
|
||||||
$title = @$_POST['title'];
|
$title = @$_POST['title'];
|
||||||
$description = @$_POST['description'];
|
$description = @$_POST['description'];
|
||||||
$images_array = $_FILES['mytest'];
|
$images_array = $_FILES['mytest'];
|
||||||
$slides_array = @$_POST['imgs'];
|
$slides_array = @$_POST['imgs'];
|
||||||
$slides_autors = @$_POST['author'];
|
$slides_autors = @$_POST['author'];
|
||||||
$slides_desc = @$_POST['work_desc'];
|
$slides_desc = @$_POST['work_desc'];
|
||||||
$color = @$_POST['color'];
|
$color = @$_POST['color'];
|
||||||
|
|
||||||
function rearrange( $arr ){
|
function rearrange($arr)
|
||||||
foreach( $arr as $key => $all ){
|
{
|
||||||
foreach( $all as $i => $val ){
|
foreach ($arr as $key => $all)
|
||||||
|
{
|
||||||
|
foreach ($all as $i => $val)
|
||||||
|
{
|
||||||
$new[$i][$key] = $val;
|
$new[$i][$key] = $val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $new;
|
return $new;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$myfiles = array();
|
$myfiles = array();
|
||||||
// $file_ary = $_FILES['mytest'];
|
// $file_ary = $_FILES['mytest'];
|
||||||
if (isset($_FILES['mytest'])){
|
if (isset($_FILES['mytest']))
|
||||||
|
{
|
||||||
foreach (rearrange($images_array) as $file)
|
foreach (rearrange($images_array) as $file)
|
||||||
{
|
{
|
||||||
//echo $file['name'];
|
//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;
|
||||||
$target_dir = "gen/upload/";
|
$imageFileType = pathinfo($target_file, PATHINFO_EXTENSION);
|
||||||
usleep(1);
|
// Check if image file is a actual image or fake image
|
||||||
$target_file = $target_dir . str_replace( ",", "",str_replace( ".", "", number_format(microtime(true),4))) . '.' . pathinfo($file['name'], PATHINFO_EXTENSION);
|
//echo $imageFileType;
|
||||||
|
|
||||||
$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']);
|
// $check = getimagesize($file['tmp_name']);
|
||||||
// if($check !== false) {
|
// if($check !== false) {
|
||||||
// // echo "File is an image - " . $check["mime"] . ".";
|
// // echo "File is an image - " . $check["mime"] . ".";
|
||||||
@ -45,40 +46,49 @@ $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
|
|||||||
// // echo "File is not an image.";
|
// // echo "File is not an image.";
|
||||||
// $uploadOk = 0;
|
// $uploadOk = 0;
|
||||||
// }
|
// }
|
||||||
|
// Check if file already exists
|
||||||
// Check if file already exists
|
if (file_exists($target_file))
|
||||||
if (file_exists($target_file)) {
|
{
|
||||||
// echo "Sorry, file already exists.";
|
// echo "Sorry, file already exists.";
|
||||||
$uploadOk = 0;
|
$uploadOk = 0;
|
||||||
}
|
}
|
||||||
// Check file size
|
// Check file size
|
||||||
/*if ($file["size"] > 500000) {
|
/*if ($file["size"] > 500000) {
|
||||||
echo "Sorry, your file is too large.";
|
echo "Sorry, your file is too large.";
|
||||||
$uploadOk = 0;
|
$uploadOk = 0;
|
||||||
}*/
|
}*/
|
||||||
// Allow certain file formats
|
// Allow certain file formats
|
||||||
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
|
if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" && $imageFileType != "webm" && $imageFileType != "ogg")
|
||||||
&& $imageFileType != "gif" && $imageFileType != "webm" && $imageFileType != "ogg" ) {
|
{
|
||||||
// echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
|
// echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
|
||||||
$uploadOk = 0;
|
$uploadOk = 0;
|
||||||
}
|
}
|
||||||
// Check if $uploadOk is set to 0 by an error
|
// Check if $uploadOk is set to 0 by an error
|
||||||
if ($uploadOk == 0) {
|
if ($uploadOk == 0)
|
||||||
|
{
|
||||||
array_push($myfiles, "");
|
array_push($myfiles, "");
|
||||||
// echo "Sorry, your file was not uploaded.";
|
// echo "Sorry, your file was not uploaded.";
|
||||||
// if everything is ok, try to upload file
|
// 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;
|
$file['tmp_name'] = $target_file;
|
||||||
array_push($myfiles, $target_file);
|
array_push($myfiles, $target_file);
|
||||||
//echo "The file ". basename( $file['name']). " has been uploaded.";
|
//echo "The file ". basename( $file['name']). " has been uploaded.";
|
||||||
} else {
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
array_push($myfiles, "");
|
array_push($myfiles, "");
|
||||||
// echo "Sorry, there was an error uploading your file.";
|
// echo "Sorry, there was an error uploading your file.";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
@ -145,9 +155,7 @@ Menu -> Tools -> Add-ons -> NoScript -> Enable/Disable/Configure
|
|||||||
</div>
|
</div>
|
||||||
</noscript>
|
</noscript>
|
||||||
<?php
|
<?php
|
||||||
|
if (isset($_POST['togetherjs']) && $_POST['togetherjs'] == 'Yes')
|
||||||
if(isset($_POST['togetherjs']) &&
|
|
||||||
$_POST['togetherjs'] == 'Yes')
|
|
||||||
{
|
{
|
||||||
echo '<script>
|
echo '<script>
|
||||||
TogetherJSConfig_findRoom = {prefix: "piviliontestrun2", max: 50};
|
TogetherJSConfig_findRoom = {prefix: "piviliontestrun2", max: 50};
|
||||||
@ -177,45 +185,49 @@ else
|
|||||||
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
$myfiles = preg_replace("/gen\//", "", $myfiles);
|
||||||
|
|
||||||
$myfiles = preg_replace("/gen\//", "", $myfiles);
|
//var_dump($myfiles);
|
||||||
|
$cnt = 1;
|
||||||
|
foreach ($slides_array as $imageVal)
|
||||||
//var_dump($myfiles);
|
{
|
||||||
$cnt = 1;
|
|
||||||
foreach ($slides_array as $imageVal) {
|
|
||||||
// echo $cnt;
|
// echo $cnt;
|
||||||
|
|
||||||
|
|
||||||
if ($imageVal == '--SECTION--'){
|
if ($imageVal == '--SECTION--')
|
||||||
|
{
|
||||||
$sld = 1;
|
$sld = 1;
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
echo '<div class="section" id="section'.$cnt.'">';
|
echo '<div class="section" id="section' . $cnt . '">';
|
||||||
$cnt++;
|
$cnt++;
|
||||||
//next($myfiles);
|
//next($myfiles);
|
||||||
}else{
|
|
||||||
$ext ="";
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$ext = "";
|
||||||
$ext = explode(".", current($myfiles));
|
$ext = explode(".", current($myfiles));
|
||||||
$format = $ext[sizeof($ext)-1];
|
$format = $ext[sizeof($ext) - 1];
|
||||||
switch ($format) {
|
switch ($format)
|
||||||
|
{
|
||||||
case "webm":
|
case "webm":
|
||||||
echo'<div class="slide" id="slide'.$sld.'">
|
echo '<div class="slide" id="slide' . $sld . '">
|
||||||
<video src="'.current($myfiles).'" data-autoplay="1" loop="1" controls ="1"></video>
|
<video src="' . current($myfiles) . '" data-autoplay="1" loop="1" controls ="1"></video>
|
||||||
<div>'.$imageVal.'</div><div>'.current($slides_autors).'</div><div>'.current($slides_desc).'</div>
|
<div>' . $imageVal . '</div><div>' . current($slides_autors) . '</div><div>' . current($slides_desc) . '</div>
|
||||||
</div>';
|
</div>';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "ogg":
|
case "ogg":
|
||||||
echo'<div class="slide" id="slide'.$sld.'">
|
echo '<div class="slide" id="slide' . $sld . '">
|
||||||
<audio src="'.current($myfiles).'" data-autoplay="1" controls="1" loop="1"></audio>
|
<audio src="' . current($myfiles) . '" data-autoplay="1" controls="1" loop="1"></audio>
|
||||||
<div>'.$imageVal.'</div><div>'.current($slides_autors).'</div><div>'.current($slides_desc).'</div>
|
<div>' . $imageVal . '</div><div>' . current($slides_autors) . '</div><div>' . current($slides_desc) . '</div>
|
||||||
</div>';
|
</div>';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default :
|
default:
|
||||||
echo'<div class="slide" id="slide'.$sld.'">
|
echo '<div class="slide" id="slide' . $sld . '">
|
||||||
<img src="'.current($myfiles).'" />
|
<img src="' . current($myfiles) . '" />
|
||||||
<div>'.$imageVal.'</div><div>'.current($slides_autors).'</div><div>'.current($slides_desc).'</div>
|
<div>' . $imageVal . '</div><div>' . current($slides_autors) . '</div><div>' . current($slides_desc) . '</div>
|
||||||
</div>';
|
</div>';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -227,39 +239,40 @@ else
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!--<div class="arrowUp"></div>
|
<!--<div class="arrowUp"></div>
|
||||||
<div class="arrowDown"></div>-->
|
<div class="arrowDown"></div>-->
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
<?php
|
<?php
|
||||||
$source = "skeleton/";
|
$source = "skeleton/";
|
||||||
$dest= "/var/www/html/pivilion/gen";
|
$dest = "/var/www/html/pivilion/gen";
|
||||||
|
|
||||||
mkdir($dest, 0755);
|
mkdir($dest, 0755);
|
||||||
foreach (
|
foreach ($iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS) , \RecursiveIteratorIterator::SELF_FIRST) as $item)
|
||||||
$iterator = new \RecursiveIteratorIterator(
|
{
|
||||||
new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS),
|
if ($item->isDir())
|
||||||
\RecursiveIteratorIterator::SELF_FIRST) as $item
|
{
|
||||||
) {
|
|
||||||
if ($item->isDir()) {
|
|
||||||
mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
|
mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
|
copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<?php
|
<?php
|
||||||
$torname = file_get_contents('/home/pi/pivilion/torname');
|
$torname = file_get_contents('/home/pi/pivilion/torname');
|
||||||
$tornamemode = preg_replace('/\s+/', '', $torname);
|
$tornamemode = preg_replace('/\s+/', '', $torname);
|
||||||
$output = ob_get_contents(); // get contents of trapped output
|
$output = ob_get_contents(); // get contents of trapped output
|
||||||
//write to file, e.g.
|
//write to file, e.g.
|
||||||
$newfile="/var/www/html/pivilion/gen/index.html";
|
$newfile = "/var/www/html/pivilion/gen/index.html";
|
||||||
$file = fopen ($newfile, "w");
|
$file = fopen($newfile, "w");
|
||||||
fwrite($file, $output);
|
fwrite($file, $output);
|
||||||
fclose ($file);
|
fclose($file);
|
||||||
ob_end_clean(); // discard trapped output and stop trapping
|
ob_end_clean(); // discard trapped output and stop trapping
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<a href="http://<?php echo $torname;?>/" target="_blank">Gallery is here!</a>
|
<a href="http://<?php echo $torname; ?>/" target="_blank">Gallery is here!</a>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user