Advertisement
Jousway

Who needs a database

Feb 28th, 2015
431
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.22 KB | None | 0 0
  1. <!DOCTYPE html>
  2.  
  3. <html>
  4.     <head>
  5.         <title>Mindup Computer Werkplaats Test Website</title>
  6.     <style>
  7.         body {
  8.         margin: 0px;
  9.         }
  10.         .banner {
  11.         background-color: black;
  12.         text-align: center;
  13.         color: lime;
  14.         margin: 0px auto;
  15.         height: 100px;
  16.         padding:5px;
  17.         }
  18.         a {color: #c8d401;text-decoration:none;}
  19.         a:link {color: #c8d401;}
  20.         a:visited {color: #c8d401;}
  21.         a:hover {color: #FF0000;}
  22.     </style>
  23.  
  24.         <?php
  25.             function ldir($dir) {
  26.                 if ($dh = opendir($dir)){
  27.                     $c = "0";
  28.                     while (($file = readdir($dh)) !== false){
  29.                         $ctime = filectime($dir.$file).','.$file;
  30.                         $list[$ctime] = $file;
  31.                     }
  32.                     closedir($dh);
  33.                     asort($list);
  34.                 }
  35.             if (!empty($_GET)) {
  36.                     foreach ($_GET as $num => $value) {
  37.                 foreach ($list as &$file) {
  38.                 $con = file_get_contents($dir.$file);
  39.                 if ($file !== "." and $file !== ".."){
  40.                     $c = $c + 1;
  41.                 }
  42.                 if ($c == $num) {
  43.                         echo "<h2 style='color:#c8d401'>".$file."</h2><br/>".$con;
  44.                 $fof = true;
  45.                         }
  46.             }
  47.             if ($fof !== true) {
  48.                 echo "<h1 style='text-align:center'>404 Document niet gevonden.</h1>";
  49.             }
  50.             }
  51.                 }
  52.         else {
  53.                foreach ($list as &$file) {
  54.                $con = file_get_contents($dir.$file);
  55.                        if ($file !== "." and $file !== ".."){
  56.                    $c = $c + 1;
  57.                             echo "<h2><a href='index.php?".$c."'>".$file."</a></h2><br/>";
  58.                             if ($c  < 6){
  59.                                 if (strlen($con) > 300){
  60.                                     $con = substr($con, 0, 300) . '...';
  61.                                 }
  62.                                 echo $con."<br/>";
  63.                 }
  64.                         }
  65.                     }
  66.                 }
  67.             }
  68.         ?>
  69.     </head>
  70.     <body>
  71.     <div class="banner"><h1><a href="index.php" >MindUp Computer Werkplaats Drachten</a></h1></div>
  72.     <div id="Content">
  73.             <?php ldir("./content/"); ?>
  74.     </div>
  75.  
  76.     </body>
  77. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement