Advertisement
Chronos_Ouroboros

Dark Realm's index.php

Feb 23rd, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.37 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <?php
  3. include("./Includes/bbcodes.php");
  4. ?>
  5. <html lang="en">
  6. <head>
  7.     <title>Dark Realm</title>
  8.     <link rel="stylesheet" type="text/css" href="../content/global.css">
  9. </head>
  10.  
  11. <body>
  12. <div id="wrapper">
  13.     <!-- Top (navigation) bar -->
  14.     <div id="topbar">
  15.         <p>[Index]</p>
  16.         <?php
  17.        
  18.         ?>
  19.     </div>
  20.     <div id="head"><h1>Dark Realm</h1></div>
  21.     <!-- Main part of the page -->
  22.     <div id="main">
  23.         <?php
  24.         $page = (int) $_GET["page"];
  25.         // count post files //
  26.         $files = 0;
  27.         for($v = 1; $v < 100000; $v++)
  28.         {
  29.             if(file_exists("./content/posts/post$v.xml")) $files++;
  30.             else break;
  31.         }
  32.         if($page == 0 || $page > ceil($files / 5))
  33.         {
  34.             echo("Nothing here...");
  35.             sleep(3);
  36.             echo("<meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=http://darkrealm.altervista.org/?page=1\">");
  37.         }
  38.         else
  39.         {
  40.         // open the xml file, read some stuff from it //
  41.         for($i = 5 * ($page)-4; $i < (5*$page)+1; $i++)
  42.         {
  43.             if($i <= $files)
  44.             {
  45.                 $posts[$i] = fopen("./content/posts/post$i.xml","r");
  46.                
  47.                 $parser[$i] = xml_parser_create();
  48.                 $postdat[$i] = fread($posts[$i], 4096);
  49.                 xml_parse_into_struct($parser[$i],$postdat[$i],$postvals[$i]);
  50.             }
  51.             else break;
  52.         }
  53.        
  54.         xml_parser_free($parser);
  55.         fclose($posts);
  56.        
  57.         // parse it thoroughly and add posts //
  58.         for($v = $i; $v > 0; $v--)
  59.         {
  60.             foreach($postvals[$v] as $key=>$val)
  61.             {
  62.                 if($val[tag] == "TITLE") {
  63.                     $lmod = filemtime("./content/posts/post$v.xml");
  64.                     echo("<a name=\"$v\"> <a href=\"#$v\"><h3>Post $v</a>: " . $val[value] . "</h3>\n" .
  65.                         "<small>Posted " . date("m/j/y h:i", $lmod) . "</small><br/>\n");
  66.                 }
  67.                 if($val[tag] == "BODY")
  68.                 {
  69.                     echo("<p>" .
  70.                         preg_replace('/\\n/', '<br/>$0', parseBBcodes($val[value])) .
  71.                         "</p><br/>\n");
  72.                 }
  73.             }
  74.             unset($val);
  75.         }
  76.         ?>
  77.     </div>
  78.     <!-- Sidebar -->
  79.     <div id="sidebar">
  80.         <h4>Articles</h4>
  81.         <?php
  82.         // add posts to the articles list //
  83.         for($v = $i; $v > 0; $v--)
  84.         {
  85.             foreach($postvals[$v] as $key=>$val)
  86.             {
  87.                 if($val[tag] == "TITLE") {
  88.                     echo("<a href=\"#$v\"><p>$v</a>: " . $val[value] . "</p>\n");
  89.                 }
  90.             }
  91.             unset($val);
  92.         }
  93.         ?>
  94.         <br/><br/>
  95.         <?php
  96.         // add pages to the sidebar //
  97.         for($k = ceil($files / 5); $k > 0; $k--) echo(" : Page <a href=\"?page=$k\">". $k ."</a><br/>\n");
  98.         }
  99.         ?>
  100.     </div>
  101.     <div id="footer"><p></p></div>
  102. </div>
  103. </body>
  104. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement