{"id":447,"date":"2015-10-11T13:24:09","date_gmt":"2015-10-11T11:24:09","guid":{"rendered":"https:\/\/olkn.myvnc.com\/?p=447"},"modified":"2016-05-16T10:41:32","modified_gmt":"2016-05-16T08:41:32","slug":"picture-viewer","status":"publish","type":"post","link":"https:\/\/olkn.myvnc.com\/?p=447","title":{"rendered":"picture viewer"},"content":{"rendered":"<p>This is my own version of a picture archive and view web interface. On the corresponding server the pictures are stored in folders for year, month and day. There is also the possibility to create specific albums with pictures as well as storing pictures in a folder to reprint\/copy.<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt;?php ############# HEAD  ############################\r\necho &quot;&lt;!DOCTYPE html&gt;\\n&quot;;\r\necho &quot;&lt;html&gt;\\n&lt;head&gt;\\n &lt;meta charset='utf-8'&gt;&lt;meta name='viewport' content='width=device-width, initial-scale=1.0'&gt;\\n&quot;;\r\n############# style sheets ########################\r\necho &quot;&lt;link rel='stylesheet' type='text\/css' href='stylesheet.css'&gt;&quot;;\r\necho &quot;&lt;title&gt;PictureViewer&lt;\/title&gt;\\n&lt;\/head&gt;\\n&lt;body&gt;\\n\\n&quot;;\r\necho &quot;&lt;header&gt;&lt;h1&gt;My Thoughts&lt;\/h1&gt;&lt;h4&gt;sniplets worth to be remebered&lt;\/h4&gt;&lt;\/header&gt;\\n&quot;;\r\n############# Configuration ##########################\r\n$PHP_SELF = htmlspecialchars($_SERVER&#x5B;'PHP_SELF']); # use one file only which will be reload with new parameters all the time\r\n$pathes = array(&quot;pictures&quot; =&gt; &quot;BackupFromMobile&quot;,\r\n\t\t\t\t&quot;reprint&quot; =&gt; &quot;BackupFromMobile\/reprint&quot;,\r\n\t\t\t\t&quot;albums&quot; =&gt; &quot;BackupFromMobile\/albums&quot;);\r\n$thumb_params = array(&quot;width&quot; =&gt; 300, &quot;height&quot; =&gt; 300, &quot;row&quot; =&gt; 5, &quot;big&quot; =&gt; 500);# thumbnail parameters\r\n$folder_to_hide = array(&quot;pictures&quot;, &quot;icons&quot;, &quot;thumbnails&quot;, &quot;bin&quot;);# some folders should not be showed normally\r\n$file_extensions = array( &quot;image&quot; =&gt; array(&quot;.jpg&quot;, &quot;.jpeg&quot;, &quot;.png&quot;, &quot;.gif&quot;),\r\n\t\t\t\t\t\t  &quot;audio&quot; =&gt; array(&quot;.mp3&quot;, &quot;.ogg&quot;, &quot;.wav&quot;),\r\n\t\t\t\t\t\t  &quot;ebook&quot; =&gt; array(&quot;.epub&quot;, &quot;.pdf&quot;, &quot;.rtx&quot;),\r\n\t\t\t\t\t\t  &quot;video&quot; =&gt; array(&quot;.avi&quot;, &quot;.3gp&quot;, &quot;.flv&quot;));# allowed extensions for files\r\n$rotation_select_box=&quot;&lt;option selected value='none'&gt;none&lt;\/option&gt;\r\n\t\t&lt;option value='0'&gt;0&amp;deg;&lt;\/option&gt;\r\n\t\t&lt;option value='90'&gt;+90&amp;deg;&lt;\/option&gt;\r\n\t\t&lt;option value='180'&gt;+180&amp;deg;&lt;\/option&gt;\r\n\t\t&lt;option value='270'&gt;-90&amp;deg;&lt;\/option&gt;&quot;;# select box for image rotation in 90 degree grade\r\n####### clear html variables from malicious code\r\nfunction clean_html($variable){\r\n\treturn trim(htmlspecialchars($variable));\r\n}\r\n###### debug output of POST\u00e5\r\nfunction debug_output(){\r\n\techo &quot;&lt;pre&gt;&lt;br&gt;&lt;h1&gt;Hier kommt der schamass!&lt;\/h1&gt;&quot;;\r\n\tprint_r($_POST);\r\n\techo &quot;&lt;\/pre&gt;&quot;; return ;\r\n}\r\n############# create thumbnails in subfolder ######\r\nfunction check_thumbnail($path, $filename){\r\n\tglobal $thumb_params;\r\n\tif (!file_exists($path.&quot;thumbnails&quot;)){#create thumbnail folder\r\n\t\tif (!mkdir($path.&quot;thumbnails&quot;)) die (&quot;Unable to create folder (&quot;.$path.&quot;thumbnails)!&quot;);\r\n\t}\r\n\t$thumb = new Imagick(realpath($path.&quot;\/&quot;.$filename));# Imagick needs absolute path for reference\r\n\t$orientation = $thumb -&gt; getimageorientation();# check for image orientation\r\n\t# check if rotation was selected\r\n\tif (!empty($orientation)){\r\n\t\tswitch ($orientation){# rotate image to get it upright\r\n\t\t\tcase imagick::ORIENTATION_BOTTOMRIGHT:\r\n\t\t\t\t$thumb-&gt;rotateimage(&quot;#000000&quot;, 180);\r\n\t\t\t\tbreak;\r\n\t\t\tcase imagick::ORIENTATION_RIGHTTOP:\r\n\t\t\t\t$thumb-&gt;rotateimage(&quot;#000000&quot;, 90);\r\n\t\t\t\tbreak;\r\n\t\t\tcase imagick::ORIENTATION_LEFTBOTTOM:\r\n\t\t\t\t$thumb-&gt;rotateimage(&quot;#000000&quot;, -90);\r\n\t\t\t\tbreak;\r\n\t\t\tcase imagick::ORIENTATION_UNDEFINED:\r\n\t\t\t\t$thumb-&gt;rotateimage(&quot;#000000&quot;, 90);\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t\t$thumb-&gt;setImageOrientation(imagick::ORIENTATION_TOPLEFT);# set exif data\r\n\t}# resize image but keep ratio\r\n\t$thumb-&gt;setResourceLimit( Imagick::RESOURCETYPE_MEMORY, 2 );\r\n\t$thumb-&gt;thumbnailImage($thumb_params&#x5B;&quot;width&quot;], $thumb_params&#x5B;&quot;height&quot;], true);\r\n\t$thumb-&gt;writeImage(realpath($path).&quot;\/thumbnails\/&quot;.$filename);\r\n\treturn ; }\r\n############# show side navigation #######################\r\nfunction explore_directories($current_path, $target_path, $expert_mode){\r\n\tglobal $file_extensions, $folder_to_hide;\r\n\techo &quot;&lt;ul class='navigation'&gt;\\n&quot;;\r\n\tforeach (scandir($current_path, 0) as $element){\r\n\t\tif (substr($element, 0, 1) != &quot;.&quot; &amp;&amp; !in_array($element, $folder_to_hide)){\r\n\t\t\tif (is_file($current_path.&quot;\/&quot;.$element)){\r\n\t\t\t\techo &quot;&lt;input type='hidden' name='elements&#x5B;]' value='&quot;.$current_path.&quot;\/&quot;.$element.&quot;'&gt;&quot;;\r\n\t\t\t\tforeach ($file_extensions as $key =&gt; $value){# extensions are grouped in multidimensional array\r\n\t\t\t\t\tif (in_array(strtolower(strrchr($element, &quot;.&quot;)), $file_extensions&#x5B;$key])){# only some file extensions will be shown\r\n\t\t\t\t\t\techo &quot;&lt;li class='actual_entry'&gt;&lt;label&gt;&lt;img src='icons\/file.png'&gt;&quot;;\r\n\t\t\t\t\t\techo &quot;&lt;input class='hidden' type='submit' name='folder&#x5B;&quot;.$key.&quot;]' value='&quot;.$current_path.&quot;\/&quot;.$element.&quot;'&gt;&quot;.$element.&quot;&lt;\/label&gt;&lt;\/li&gt;\\n&quot;;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse { #subfolder\r\n\t\t\t\techo &quot;&lt;li class='navigation'&gt;&lt;label&gt;&lt;img src='icons\/dir.png'&gt;&quot;;\r\n\t\t\t\techo &quot;&lt;input class='hidden' type='submit' name='folder&#x5B;folder]' value='&quot;.$current_path.&quot;\/&quot;.$element.&quot;\/test'&gt;&quot;.$element.&quot;&lt;\/label&gt;&lt;\/li&gt;\\n&quot;;\r\n\t\t\t}\r\n\t\t\tif (strncmp($current_path.&quot;\/&quot;.$element, $target_path, strlen($current_path.&quot;\/&quot;.$element)) == 0){\r\n\t\t\t\texplore_directories($current_path.&quot;\/&quot;.$element, $target_path, $expert_mode);\r\n\t\t\t}\r\n\t\t} elseif ($element == &quot;reprint&quot; &amp;&amp; $expert_mode == &quot;normal&quot;){# show reprint folder contents if in expert mode\r\n\t\t\techo &quot;&lt;li class='navigation'&gt;&lt;label&gt;&lt;img src='icons\/dir.png'&gt;&quot;;\r\n\t\t\techo &quot;&lt;input class='hidden' type='submit' name='folder&#x5B;folder]' value='&quot;.$current_path.&quot;\/&quot;.$element.&quot;\/test'&gt;&quot;.$element.&quot;&lt;\/label&gt;&lt;\/li&gt;\\n&quot;;\r\n\t\t}\r\n\t}\r\n\techo &quot;&lt;\/ul&gt;\\n&quot;;\r\n\treturn ; }\r\n############ show thumbnails #############################\r\nfunction show_thumbnails($path, $number_of_rows, $expert_mode){\r\n\tglobal $file_extensions,$rotation_select_box, $pathes;\r\n\t$i=0;\r\n\tforeach (scandir($path) as $file){# iterate over complete directory contents\r\n\t\tif (substr($file,0,1) != &quot;.&quot; &amp;&amp; in_array(strtolower(strrchr($file, &quot;.&quot;)), $file_extensions&#x5B;&quot;image&quot;])){# only allowed extension will be shown\r\n\t\t\t$file = htmlspecialchars($file); $i++;# clean filename\r\n\t\t\tif (!file_exists($path.&quot;\/thumbnails\/&quot;.$file)){\r\n\t\t\t\tcheck_thumbnail($path.&quot;\/&quot;, $file);\r\n\t\t\t}\r\n\t\t\techo &quot;&lt;div class='gallery'&gt;&lt;label&gt;&lt;input class='hidden' type='submit' name='folder&#x5B;image]' value='&quot;.$path.&quot;\/&quot;.$file.&quot;'&gt;&quot;;\r\n\t\t\techo &quot;&lt;img src='&quot;.$path.&quot;\/thumbnails\/&quot;.$file.&quot;' alt='&quot;.$file.&quot;'&gt;&lt;\/label&gt;\\n&quot;;\r\n\t\t\tif ($expert_mode == &quot;normal&quot;){# show checkbox for reprint\r\n\t\t\t\tif (strncmp($path, $pathes&#x5B;'reprint'], strlen($pathes&#x5B;'reprint'])) == 0 ) {\r\n\t\t\t\t\techo &quot;&lt;p class='delete'&gt;&lt;input type='checkbox' name='delete&quot;.$i.&quot;' value='&quot;.$path.&quot;\/&quot;.$file.&quot;'&gt; delete from reprint list &lt;\/p&gt;\\n&quot;;\r\n\t\t\t\t}\r\n\t\t\t\telse {\r\n\t\t\t\t\techo &quot;&lt;p class='reprint'&gt;&lt;input type='checkbox' name='reprint&quot;.$i.&quot;' value='&quot;.$path.&quot;\/&quot;.$file.&quot;'&gt; reprint &lt;span&gt; rotate &lt;select name='rotate&quot;.$i.&quot;'&gt;&quot;;\r\n\t\t\t\t\techo $rotation_select_box.&quot;&lt;\/select&gt;&lt;\/span&gt;&lt;input type='hidden' name='rotation&quot;.$i.&quot;' value='&quot;.$path.&quot;\/&quot;.$file.&quot;'&gt;&lt;\/p&gt;\\n&quot;;# we need the filename beside the rotation value\r\n\t\t\t\t\tif (strncmp($path, $pathes&#x5B;'albums'], strlen($pathes&#x5B;'albums'])) == 0)\r\n\t\t\t\t\t\techo &quot;&lt;p class='delete'&gt;&lt;input type='checkbox' name='delete&quot;.$i.&quot;' value='&quot;.$path.&quot;\/&quot;.$file.&quot;'&gt; delete from album &lt;\/p&gt;\\n&quot;;\r\n\t\t\t\t\telse\r\n\t\t\t\t\t\techo &quot;&lt;p class='album'&gt;&lt;input type='checkbox' name='album&quot;.$i.&quot;' value='&quot;.$path.&quot;\/&quot;.$file.&quot;'&gt; add to album choosen above&lt;\/p&gt;\\n&quot;;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\techo &quot;&lt;\/div&gt;\\n&quot;;\r\n\t\t}\r\n\t}\r\n\treturn ;}\r\n############# rotate pictures from list in given direction ##############\r\nfunction rotatepictures($rotation, $files){\r\n\tglobal $thumb_params; $i=0;\r\n\t$path = dirname($files&#x5B;0]);\r\n\tforeach ($files as $value) {\r\n\t\t$thumb = new Imagick(realpath($value));# Imagick needs absolute path for reference\r\n\t\tswitch ($rotation&#x5B;$i]){# rotate image to get it upright\r\n\t\t\tcase &quot;0&quot;;\r\n\t\t\t\t$thumb-&gt;rotateimage(&quot;#000000&quot;, 0);\r\n\t\t\t\tbreak;\r\n\t\t\tcase &quot;90&quot;;\r\n\t\t\t\t$thumb-&gt;rotateimage(&quot;#000000&quot;, 90);\r\n\t\t\t\tbreak;\r\n\t\t\tcase &quot;180&quot;:\r\n\t\t\t\t$thumb-&gt;rotateimage(&quot;#000000&quot;, 180);\r\n\t\t\t\tbreak;\r\n\t\t\tcase &quot;270&quot;:\r\n\t\t\t\t$thumb-&gt;rotateimage(&quot;#000000&quot;, -90);\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t\t$thumb-&gt;setImageOrientation(imagick::ORIENTATION_TOPLEFT);# set exif data\r\n\t\t$thumb-&gt;setResourceLimit( Imagick::RESOURCETYPE_MEMORY, 2 );# resize image but keep ratio\r\n\t\t$thumb-&gt;thumbnailImage($thumb_params&#x5B;&quot;width&quot;], $thumb_params&#x5B;&quot;height&quot;], true);\r\n\t\t$thumb-&gt;writeImage(realpath($path).&quot;\/thumbnails\/&quot;.basename($value));\r\n\t\t$i++; # take a counter with us to get desired orientation\r\n\t}\r\n\treturn &quot;done&quot;;}\r\n############# copy pics for reprint ###################\r\nfunction copypictures($files, $folder){\r\n\tif (!file_exists($folder)){\r\n\t\tif (!mkdir($folder)) die(&quot;Could not create folder:&quot;.$folder);\r\n\t}\r\n\tforeach ($files as $value) {\r\n\t\tif (!copy($value, $folder.&quot;\/&quot;.basename($value) ))\r\n\t\t\t\tdie(&quot;Could not copy file&quot;.$value.&quot; to &quot;.$folder.&quot;\/&quot;.basename($value));\r\n\t\t}\r\n\treturn &quot;done&quot;;}\r\n############# delete pictures from album ##############\r\nfunction delpictures($files){\r\n\tforeach ($files as $value) {\r\n\t\tif (!unlink($value))\r\n\t\t\tdie(&quot;Could not delete file&quot;.$value);\r\n\t}\r\n\treturn &quot;done&quot;;}\r\n######################################################################\r\n############################## MAIN ##################################\r\n######################################################################\r\necho &quot;&lt;body&gt;&lt;form method='POST' action='$PHP_SELF'&gt;\\n&quot;;# page header with headline and table headers\r\n$filelist=array(); $albumlist=array();$dellist=array();$rotatelist=array();$rotationnamelist=array();# list of files for reprint\r\nforeach (array_diff_key($_POST, array(&quot;change&quot; =&gt; &quot;&quot;, &quot;action&quot; =&gt; &quot;&quot;, &quot;folder&quot; =&gt; &quot;&quot;, &quot;album&quot; =&gt; &quot;&quot;)) as $key =&gt; $value){\r\n\tif (substr($key, 0, 7) == &quot;reprint&quot;)# files for reprint are numbered as reprint1..9\r\n\t\tarray_push($filelist, $value);# generate array list of files to reprint\r\n\telseif (substr($key, 0, 5) == &quot;album&quot;)# files for album are numbered as album1..9\r\n\t\tarray_push($albumlist, $value);# generate array list of files for actual album\r\n\telseif (substr($key, 0, 6) == &quot;delete&quot;)# files to delete from album\r\n\t\tarray_push($dellist, $value);\r\n\telseif (substr($key, 0, 6) == &quot;rotate&quot; &amp;&amp; $_POST&#x5B;$key] != &quot;none&quot;){# files to rotate\r\n\t\tarray_push($rotatelist, $value);# store value for rotation\r\n\t\t$index_for_rotation=&quot;rotation&quot;.substr($key, 6);\r\n\t\tarray_push($rotationnamelist, $_POST&#x5B;$index_for_rotation]);# get image name to rotate\r\n\t}\r\n}\r\n# get default values for action, target folder and expert view mode\r\n# $key = last action choosen, e.g. play video, show pictures\r\n# $target_folder = the last folder that was opened\r\n# $expert_mode = status of expert view\r\nif (isset($_POST&#x5B;'actual_action']) &amp;&amp; $_POST&#x5B;'actual_action'] != &quot;&quot;)\r\n\t$key = clean_html($_POST&#x5B;'actual_action']);\r\nelse \r\n\t$key = &quot;folder&quot;;# default action is showing pictures in folder\r\nif (isset($_POST&#x5B;'folder']) &amp;&amp; $_POST&#x5B;'folder'] != &quot;&quot;){\r\n\tforeach ($_POST&#x5B;folder] as $key =&gt; $value)# generate target folder variable from POST\r\n\t\t$target_path = clean_html(dirname($value));# if a new folder icon was clicked update target folder\r\n\t$key = clean_html(array_keys($_POST&#x5B;'folder'])&#x5B;0]);$value = clean_html($_POST&#x5B;'folder']&#x5B;$key]);\r\n}elseif (isset($_POST&#x5B;'actual_folder']) &amp;&amp; $_POST&#x5B;'actual_folder'] != &quot;&quot;){\r\n\t$target_path = clean_html($_POST&#x5B;'actual_folder']);$value = clean_html($_POST&#x5B;'actual_contents']);\r\n} else \r\n\t$target_path = $pathes&#x5B;'pictures'];\r\n# check the actual status of expert view and toggle if requested by user button press\r\nif (isset($_POST&#x5B;'change']) &amp;&amp; $_POST&#x5B;'change'] == &quot;expert&quot;)# button is pressed, so we need to toggle\r\n\t$expert_mode = &quot;normal&quot;;# change value as user triggered the button to change\r\nelseif (isset($_POST&#x5B;'change']) &amp;&amp; $_POST&#x5B;'change'] == &quot;normal&quot;)\r\n\t$expert_mode = &quot;expert&quot;;# keep the old stage if set\r\nelseif (isset($_POST&#x5B;'expert_mode']) &amp;&amp; $_POST&#x5B;'expert_mode'] == &quot;normal&quot;)\r\n\t$expert_mode = &quot;normal&quot;;\r\nelse \r\n\t$expert_mode = &quot;expert&quot;;\r\necho &quot;&lt;input type='hidden' name='expert_mode' value='&quot;.$expert_mode.&quot;'&gt;&lt;input type='hidden' name='actual_folder' value='&quot;.$target_path.&quot;'&gt;&quot;;\r\necho &quot;&lt;input type='hidden' name='actual_action' value='&quot;.$key.&quot;'&gt;&lt;input type='hidden' name='actual_contents' value='&quot;.$value.&quot;'&gt;&quot;;\r\n############## show navigation on top ###########################################\r\necho &quot;&lt;div class='navi'&gt;&lt;input type='submit' name='change' value='&quot;.$expert_mode.&quot;'&gt;&quot;;\r\n# manage access to albums in special folder\r\nif ($expert_mode == &quot;normal&quot;){# select album from list if in expert mode\r\n\techo &quot;&lt;select name='album'&gt;\\n&lt;option value='new'&gt;create new entry&lt;\/option&gt;\\n&quot;;\r\n\tforeach ( glob($pathes&#x5B;'albums'].&quot;\/*&quot;, GLOB_ONLYDIR) as $directory){\r\n\t\techo &quot;&lt;option &quot;;\r\n\t\tif (isset($_POST&#x5B;'album']) &amp;&amp; $_POST&#x5B;'album'] == $directory)\r\n\t\t\techo &quot; selected &quot;;\r\n\t\t\techo &quot;value='&quot;.$directory.&quot;'&gt;&quot;.basename($directory).&quot;&lt;\/option&gt;\\n&quot;;\r\n\t}\r\n\techo &quot;&lt;\/select&gt;\\n&lt;input type='submit' name='action' value='action'&gt;\\n&quot;;\r\n}\r\nif (isset($_POST&#x5B;'action'])){# action button pressed\r\n\techo &quot;&lt;span class='response'&gt;&quot;;\r\n\tif (isset($_POST&#x5B;'new_album']) &amp;&amp; !empty($_POST&#x5B;'new_album'])){\r\n\t\tif (!file_exists($pathes&#x5B;'albums'].&quot;\/&quot;.$_POST&#x5B;'new_album']))\r\n\t\t\tif (!mkdir($pathes&#x5B;'albums'].&quot;\/&quot;.$_POST&#x5B;'new_album'])) die(&quot;Could not create folder:&quot;.$_POST&#x5B;'new_album']);\r\n\t}\r\n\telse {\r\n\t\tif (isset($_POST&#x5B;'album']) &amp;&amp; $_POST&#x5B;'album'] == &quot;new&quot;){\r\n\t\t\techo &quot;Create new album: &lt;input type='text' size='20' name='new_album'&gt;\\n&quot;;\r\n\t\t}\r\n\t\telseif (!empty($albumlist))# copy pictures to album\r\n\t\t\techo copypictures($albumlist, $_POST&#x5B;'album']);\r\n\t\tif (!empty($filelist)) # copy pictures for reprint\r\n\t\t\techo copypictures($filelist, $pathes&#x5B;'reprint']);\r\n\t\tif (!empty($dellist)) # delete entries from album\r\n\t\t\techo delpictures($dellist);\r\n\t\tif (!empty($rotatelist))# rotate pictures in given direction\r\n\t\t\techo rotatepictures($rotatelist, $rotationnamelist);\r\n}\r\n\techo &quot;&lt;\/span&gt;\\n&quot;;\r\n}\r\nexplore_directories($pathes&#x5B;'pictures'], $target_path, $expert_mode);# show the navigation menue\r\necho &quot;&lt;\/div&gt;\\n&quot;;\r\n############### page content to the right ##################################\r\necho &quot;&lt;section class='contents'&gt;&quot;;\r\nswitch ($key){\r\n\tcase &quot;audio&quot;:\r\n\t\techo &quot;&lt;&quot;.$key.&quot; controls height='240' width='320'&gt;\\n&lt;source src='&quot;.$value.&quot;' type='&quot;.$key.&quot;\/&quot;.strtolower(substr(strrchr($value, &quot;.&quot;),1)).&quot;'&gt;\\n&quot;;\r\n\t\techo &quot;No support for file: &quot;.$value.&quot; in your Browser!&lt;\/&quot;.$key.&quot;&gt;\\n&quot;;\r\n\t\tbreak;\r\n\tcase &quot;video&quot;:\r\n\t\techo &quot;&lt;&quot;.$key.&quot; controls height='240' width='320'&gt;\\n&lt;source src='&quot;.$value.&quot;' type='&quot;.$key.&quot;\/&quot;.strtolower(substr(strrchr($value, &quot;.&quot;),1)).&quot;'&gt;\\n&quot;;\r\n\t\techo &quot;No support for file: &quot;.$value.&quot; in your Browser!&lt;\/&quot;.$key.&quot;&gt;\\n&quot;;\r\n\t\tbreak;\r\n\tcase &quot;ebook&quot;:\r\n\t\techo &quot;&lt;br&gt;Read ebook: &quot;.$value.&quot;&lt;br&gt;&quot;;\r\n\t\tbreak;\r\n\tcase &quot;image&quot;:\r\n\t\techo &quot;&lt;div class='gallery'&gt;\\n&quot;;\r\n\t\tif (isset($_POST&#x5B;'elements']) &amp;&amp; $_POST&#x5B;'elements'] != &quot;&quot;) {\r\n\t\t\t$number_of_pictures = count($_POST&#x5B;'elements'])-1;# index is running from 0 up\r\n\t\t\tfor ($i=0; $i&lt;=$number_of_pictures; $i++){# iterate over complete image list\r\n\t\t\t\tif ($_POST&#x5B;'elements']&#x5B;$i] == $value){ # find the number of the current image in list\r\n\t\t\t\t\tif ($i == 0) $last = $_POST&#x5B;'elements']&#x5B;$number_of_pictures];# we are at position 0 already\r\n\t\t\t\t\telse $last = $_POST&#x5B;'elements']&#x5B;$i-1];\r\n\t\t\t\t\tif ($i == $number_of_pictures) $next = $_POST&#x5B;'elements']&#x5B;0];# we are at the end already\r\n\t\t\t\t\telse $next = $_POST&#x5B;'elements']&#x5B;$i+1];\r\n\t\t\t\t\techo &quot;&lt;div class='arrow-left'&gt;&lt;button type='submit' name='folder&#x5B;image]' value='&quot;.$last.&quot;'&gt;&quot;;\r\n\t\t\t\t\techo &quot;&lt;img src='icons\/transparent.png' style='border:none;'&gt;&lt;\/button&gt;&lt;\/div&gt;&quot;;\r\n\t\t\t\t\techo &quot;&lt;a href='&quot;.$value.&quot;'&gt; &lt;img src='&quot;.$value.&quot;' width='&quot;.$thumb_params&#x5B;&quot;big&quot;].&quot;' alt='&quot;.$value.&quot;'&gt;&lt;\/a&gt;&quot;;\r\n\t\t\t\t\techo &quot;&lt;div class='arrow-right'&gt;&lt;button type='submit' name='folder&#x5B;image]' value='&quot;.$next.&quot;'&gt;&quot;;\r\n\t\t\t\t\techo &quot;&lt;img src='icons\/transparent.png' style='border:none;'&gt;&lt;\/button&gt;&lt;\/div&gt;&quot;;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tif ($expert_mode == &quot;normal&quot;){# show checkbox for reprint\r\n\t\t\tif (explode(&quot;\/&quot;, $value)&#x5B;0] == $pathes&#x5B;'reprint']) {\r\n\t\t\t\techo &quot;&lt;p class='delete'&gt;&lt;input type='checkbox' name='delete&quot;.$i.&quot;' value='&quot;.$value.&quot;'&gt; delete from reprint list &lt;\/p&gt;\\n&quot;;\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\techo &quot;&lt;p class='reprint'&gt;&lt;input type='checkbox' name='reprint&quot;.$i.&quot;' value='&quot;.$value.&quot;'&gt; reprint &lt;span&gt; rotate &lt;select name='rotate&quot;.$i.&quot;'&gt;&quot;;\r\n\t\t\t\techo $rotation_select_box.&quot;&lt;\/select&gt;&lt;\/span&gt;&lt;input type='hidden' name='rotation&quot;.$i.&quot;' value='&quot;.$value.&quot;'&gt;&lt;\/p&gt;\\n&quot;;# we need the filename beside the rotation value\r\n\t\t\t\tif (explode(&quot;\/&quot;, $value)&#x5B;0] == $pathes&#x5B;'albums'])\r\n\t\t\t\t\techo &quot;&lt;p class='delete'&gt;&lt;input type='checkbox' name='delete&quot;.$i.&quot;' value='&quot;.$value.&quot;'&gt; delete from album &lt;\/p&gt;\\n&quot;;\r\n\t\t\t\telse\r\n\t\t\t\t\techo &quot;&lt;p class='album'&gt;&lt;input type='checkbox' name='album&quot;.$i.&quot;' value='&quot;.$value.&quot;'&gt; add to album choosen above&lt;\/p&gt;\\n&quot;;\r\n\t\t\t}\r\n\t\t}\r\n\t\techo &quot;&lt;\/div&gt;&quot;;\r\n\t\tbreak;\r\n\tcase &quot;folder&quot;:\r\n\t\tshow_thumbnails($target_path, $thumb_params&#x5B;'row'], $expert_mode);# show thumbs\r\n\t\tbreak;\r\n\tdefault:\r\n\t\techo &quot;&lt;br&gt;File type not supported!&lt;br&gt;&quot;;\r\n\t\tbreak;\r\n}\r\necho &quot;&lt;\/section&gt;\\n&quot;;\r\n############# cleanup and end ########################################\t\t\r\ndebug_output();\r\necho &quot;&lt;\/form&gt;\\n&lt;footer id='footer'&gt;My personal page hosted on my own server &amp;copy; olkn&lt;\/footer&gt;&lt;\/body&gt;&lt;\/HTML&gt;\\n&quot;;\r\n########### END ###################################?&gt;\r\n<\/pre>\n<pre class=\"brush: css; title: ; notranslate\" title=\"\">\r\n@CHARSET &quot;ISO-8859-1&quot;;\r\nbody {\r\n    background-color: #2C2C29;\r\n   \tfont-family:&quot;Times New Roman&quot;, Times, serif;\r\n    font-size: 13px;\r\n    color: white;\r\n}\r\n.arrow-right {\r\n    position: absolute;\r\n\twidth: 20%;\r\n    height: 100%;\r\n    right: -50px;\r\n    top: 0;\r\n}\r\n.arrow-left {\r\n    position: absolute;\r\n\twidth: 20%;\r\n    height: 100%;\r\n    left: -50px;\r\n    top: 0;\r\n}\r\n.arrow-left:hover {\r\n\tbackground: transparent url(icons\/arrow-left.png) no-repeat left center;\r\n}\r\n.arrow-right:hover {\r\n\tbackground: transparent url(icons\/arrow-right.png) no-repeat right center;\r\n}\r\n.hidden {\r\n\tdisplay: none;\r\n}\r\n.response {\r\n\tpadding: 0 0 0 50px;\r\n}\r\n.navigation {\/* navigation divs are nested on the left *\/\r\n\tpadding: 0px 0px 0px 12px;\r\n\ttext-shadow: 4px 3px 0 #444444;\r\n}\r\nul {\r\n    list-style-type: none;\r\n    padding: 0px 20px 0px 0px;\r\n}\r\nli {\r\n\tpadding: 0px 0px 0px 12px;\r\n}\r\n.navi { \/* show text shadow *\/\r\n\tfloat: left;\r\n\ttext-shadow: 4px 3px 0 #444444;\r\n}\r\na { \/* some stylings for links *\/\r\n\ttext-decoration:none;\r\n}\r\na:link {\r\n    color: dimgray;\r\n}\r\na:visited {\r\n    color: darkgray;\r\n}\r\na:hover {\r\n    color: royalblue;\r\n}\r\na:active {\r\n    color: silver;\r\n}\r\np.reprint { \/* caption for reprint *\/\r\n\tbackground: teal;\r\n\tmargin: 5px;\r\n\ttext-align: left;\r\n}\r\np.reprint span { \r\n\tfloat:right;\r\n\tpadding: 0 5px 0 0;\r\n}\r\np.album { \/* caption for add to album *\/\r\n\tbackground: royalblue;\r\n\tmargin: 5px;\r\n\ttext-align: left;\r\n}\r\np.delete { \/* caption for pic delete *\/\r\n\tbackground: darkred;\r\n\tmargin: 5px;\r\n\ttext-align: left;\r\n}\r\n.gallery { \/* show nice white border for pics *\/\r\n\tposition: relative;\r\n\tdisplay: inline-block;\r\n\tpadding: 5px 5px 20px 5px;\r\n\tmargin: 20px;\r\n\tbackground: white;\r\n}\r\n.gallery img {\r\n\tmargin:2px;\r\n\tborder:1px solid #000000;\r\n  \theight:auto;\r\n}\r\n.gallery img:hover { \/* blurr image when mouse is over *\/\r\n\topacity:0.7;\r\n\tfilter:alpha(opacity=70); \r\n}\r\nimg.arrow {\r\n\tborder: none;\r\n\tmargin: 100% 0;\r\n}\r\nbutton {\r\n\theight: 100%;\r\n\twidth: 130px;\r\n\tbackground: transparent;\r\n\tborder: none;\r\n}\r\nfooter { \/* footer in new line *\/\r\n\tclear: left;\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This is my own version of a picture archive and view web interface. On the corresponding server the pictures are stored in folders for year, month and day. There is also the possibility to create specific albums with pictures as well as storing pictures in a folder to reprint\/copy. &lt;?php ############# HEAD ############################ echo &quot;&lt;!DOCTYPE &hellip; <a href=\"https:\/\/olkn.myvnc.com\/?p=447\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">picture viewer<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24],"tags":[51,79,123,131],"class_list":["post-447","post","type-post","status-publish","format-standard","hentry","category-programming","tag-debian","tag-linux","tag-sync","tag-webfrontend"],"_links":{"self":[{"href":"https:\/\/olkn.myvnc.com\/index.php?rest_route=\/wp\/v2\/posts\/447","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/olkn.myvnc.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/olkn.myvnc.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/olkn.myvnc.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/olkn.myvnc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=447"}],"version-history":[{"count":4,"href":"https:\/\/olkn.myvnc.com\/index.php?rest_route=\/wp\/v2\/posts\/447\/revisions"}],"predecessor-version":[{"id":495,"href":"https:\/\/olkn.myvnc.com\/index.php?rest_route=\/wp\/v2\/posts\/447\/revisions\/495"}],"wp:attachment":[{"href":"https:\/\/olkn.myvnc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=447"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/olkn.myvnc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=447"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/olkn.myvnc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=447"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}