TimKruz

Движок интерактивных рассказов

Dec 8th, 2014
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.33 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.   <head>
  4.     <link rel="shortcut icon" href="/images/favicon.ico" type="image/x-icon">
  5.     <meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
  6.     <title>Интерактивные книги</title>
  7.     <style>
  8.       a:link    { color:black; font-weight:bold; text-decoration:none }
  9.       a:visited { color:black; font-weight:bold; text-decoration:none }
  10.       a:hover   { color:crimson; font-weight:bold; text-decoration:none }
  11.       a:active  { color:green; font-weight:bold; text-decoration:none }
  12.       p:first-letter { color:crimson; font-weight:bolder;
  13.                        padding:0px 0px 0px 15px; }
  14.     </style>
  15.   </head>
  16. <body>
  17.   <br>
  18.   <div style="position: relative; left:25px; right:25px;
  19.               width:600px; text-align:justify">
  20.   <?php
  21.     if (!isset($_GET["book"]) or $_GET["book"]=="" or $_GET["page"]=="0000") {
  22.       echo "Список книг:<br>";
  23.       $dir=opendir("books");
  24.       while ($file=readdir($dir)) {
  25.         if ($file!=".." and $file!=".") {
  26.           echo '<a href="http://timkruz.tk/read?book='.$file.'">'.$file."</a><br>";
  27.         }
  28.       }
  29.     } else {
  30.       $book=$_GET["book"];
  31.       if (!isset($_GET["page"])) $page="$0001";
  32.       else {
  33.         switch(strlen($_GET["page"])) {
  34.         case 1: $page="$000".$_GET["page"]; break;
  35.         case 2: $page="$00".$_GET["page"]; break;
  36.         case 3: $page="$0".$_GET["page"]; break;
  37.         case 4: $page="$".$_GET["page"]; break;
  38.         }
  39.       }
  40.       $file=fopen("books/".$book,"r");
  41.       if ($file) {
  42.         $pagen="$0001";
  43.         while (!feof($file)) {
  44.           $text=chop(fgets($file));
  45.           if ($text[0]=="$") $pagen=$text;
  46.           if ($text[0]=="%" and $pagen==$page) {
  47.             echo '<a href="?book='.$_GET["book"].'&#38;page='.$text[1].$text[2].$text[3].$text[4].'">';
  48.             $openA=true;
  49.           }
  50.           if (!($text[0]=="$" or $text[0]=="%")) {
  51.             if ($pagen==$page) {
  52.               echo "<p>".$text."</p>";
  53.               if ($openA) {
  54.                 echo "</a>";
  55.                 $openA=false;
  56.               }
  57.             }
  58.           }
  59.         }
  60.         fclose($file);
  61.       } else {
  62.         echo 'Книги "'.$_GET["book"].'" у нас нет.<br><a href=".">Назад</a>';
  63.       }
  64.     }
  65.   ?>
  66.   </div>
  67. </body>
  68. </html>
Add Comment
Please, Sign In to add comment