Advertisement
Guest User

PHPRetro: New Comments by RastaLulz

a guest
May 17th, 2010
1,499
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 14.18 KB | None | 0 0
  1. <?php
  2. /*================================================================+\
  3. || # PHPRetro - An extendable virtual hotel site and management
  4. |+==================================================================
  5. || # Copyright (C) 2009 Yifan Lu. All rights reserved.
  6. || # http://www.yifanlu.com
  7. || # Parts Copyright (C) 2009 Meth0d. All rights reserved.
  8. || # http://www.meth0d.org
  9. || # All images, scripts, and layouts
  10. || # Copyright (C) 2009 Sulake Ltd. All rights reserved.
  11. |+==================================================================
  12. || # PHPRetro is provided "as is" and comes without
  13. || # warrenty of any kind. PHPRetro is free software!
  14. || # License: GNU Public License 3.0
  15. || # http://opensource.org/licenses/gpl-license.php
  16. \+================================================================*/
  17.  
  18. $page['allow_guests'] = true;
  19. require_once('./includes/core.php');
  20. require_once('./includes/session.php');
  21. $data = new community_sql;
  22. $lang->addLocale("community.news");
  23.  
  24. $id = $input->FilterText($_GET['id']);
  25. $category = $input->stringToURL($input->HoloText($_GET['category'],true),true,false);
  26. $archive = $_GET['archive'];
  27. $pagenum = $_GET['pageNumber'];
  28. if(!isset($_GET['pageNumber'])){ $pagenum = 1; }
  29.  
  30. if(!isset($id) || $id == ""){ $id = $db->result($db->query("SELECT MAX(id) AS count FROM ".PREFIX."news LIMIT 1")); }
  31.  
  32. $news_row = $db->fetch_assoc($db->query("SELECT * FROM ".PREFIX."news WHERE id = '".$id."' LIMIT 1"));
  33. foreach ($news_row as &$value) {
  34.     $value = $input->HoloText($value, true);
  35. }
  36. $page['id'] = "news";
  37. $page['name'] = $lang->loc['pagename.news']." - ".$news_row['title'];
  38. $page['bodyid'] = "news";
  39. $page['cat'] = "community";
  40.  
  41. require_once('./templates/community_header.php');
  42. ?>
  43. <div id="container">
  44.     <div id="content" style="position: relative" class="clearfix">
  45.     <div id="column1" class="column">
  46.  
  47.                 <div class="habblet-container ">
  48.                         <div class="cbb clearfix default ">
  49.  
  50.  
  51.                             <h2 class="title"><?php echo $lang->loc['pagename.news']; ?>
  52.                             </h2>
  53.                         <div id="article-archive">
  54. <?php if(isset($_GET['archive']) && $archive = "true"){
  55. $count = $db->result($db->query("SELECT COUNT(*) FROM ".PREFIX."news"));
  56. $pages = ceil($count / 20); ?>
  57. <div id="article-paging" class="clearfix">
  58.         <?php if(($pagenum + 1) <= $pages){ ?><a href="<?php echo PATH; ?>/articles/archive?pageNumber=<?php echo $pagenum + 1; ?>" class="older">&lt;&lt; <?php echo $lang->loc['older']; ?></a><?php } ?>
  59.         <?php if(($pagenum - 1) > 0){ ?><a href="<?php echo PATH; ?>/articles/archive?pageNumber=<?php echo $pagenum - 1; ?>" class="newer"><?php echo $lang->loc['newer']; ?> &gt;&gt;</a><?php } ?>
  60. </div>
  61. <?php } ?>
  62. <?php
  63. if((!isset($archive) || $archive == "false") && (!isset($_GET['category']) || $_GET['category'] = "")){
  64. $time['stop'] = time() - 60*60*24;
  65. $sql = $db->query("SELECT * FROM ".PREFIX."news WHERE time > ".$time['stop']." ORDER BY id DESC");
  66. if($db->num_rows($sql) > 0){ ?>
  67. <h2><?php echo $lang->loc['today']; ?></h2>
  68. <ul>
  69.  
  70. <?php while($row = $db->fetch_assoc($sql)){ $row['title_safe'] = $input->stringToURL($input->HoloText($row['title'],true),true,true); ?>
  71.     <li>
  72.         <a href="<?php echo PATH; ?>/articles/<?php echo $row['id']."-".$row['title_safe']; ?>" class="article-<?php echo $row['id']; ?>"><?php echo stripslashes($row['title']); ?>&nbsp;&raquo;</a>
  73.     </li>
  74.  
  75. <?php } ?>
  76.  
  77. </ul>
  78. <?php }
  79. $time['start'] = time() - 60*60*24; $time['stop'] = time() - 60*60*24*2;
  80. $sql = $db->query("SELECT * FROM ".PREFIX."news WHERE time < ".$time['start']." AND time > ".$time['stop']." ORDER BY id DESC");
  81. if($db->num_rows($sql) > 0){ ?>
  82. <h2><?php echo $lang->loc['yesterday']; ?></h2>
  83. <ul>
  84.  
  85. <?php while($row = $db->fetch_assoc($sql)){ $row['title_safe'] = $input->stringToURL($input->HoloText($row['title'],true),true,true); ?>
  86.     <li>
  87.         <a href="<?php echo PATH; ?>/articles/<?php echo $row['id']."-".$row['title_safe']; ?>" class="article-<?php echo $row['id']; ?>"><?php echo stripslashes($row['title']); ?>&nbsp;&raquo;</a>
  88.     </li>
  89.  
  90. <?php } ?>
  91.  
  92. </ul>
  93. <?php }
  94. $time['start'] = time() - 60*60*24*2; $time['stop'] = time() - 60*60*24*7;
  95. $sql = $db->query("SELECT * FROM ".PREFIX."news WHERE time < ".$time['start']." AND time > ".$time['stop']." ORDER BY id DESC");
  96. if($db->num_rows($sql) > 0){ ?>
  97. <h2><?php echo $lang->loc['this.week']; ?></h2>
  98. <ul>
  99.  
  100. <?php while($row = $db->fetch_assoc($sql)){ $row['title_safe'] = $input->stringToURL($input->HoloText($row['title'],true),true,true); ?>
  101.     <li>
  102.         <a href="<?php echo PATH; ?>/articles/<?php echo $row['id']."-".$row['title_safe']; ?>" class="article-<?php echo $row['id']; ?>"><?php echo stripslashes($row['title']); ?>&nbsp;&raquo;</a>
  103.     </li>
  104.  
  105. <?php } ?>
  106.  
  107. </ul>
  108. <?php }
  109. $time['start'] = time() - 60*60*24*7; $time['stop'] = time() - 60*60*24*14;
  110. $sql = $db->query("SELECT * FROM ".PREFIX."news WHERE time < ".$time['start']." AND time > ".$time['stop']." ORDER BY id DESC");
  111. if($db->num_rows($sql) > 0){ ?>
  112. <h2><?php echo $lang->loc['last.week']; ?></h2>
  113. <ul>
  114.  
  115. <?php while($row = $db->fetch_assoc($sql)){ $row['title_safe'] = $input->stringToURL($input->HoloText($row['title'],true),true,true); ?>
  116.     <li>
  117.         <a href="<?php echo PATH; ?>/articles/<?php echo $row['id']."-".$row['title_safe']; ?>" class="article-<?php echo $row['id']; ?>"><?php echo stripslashes($row['title']); ?>&nbsp;&raquo;</a>
  118.     </li>
  119.  
  120. <?php } ?>
  121.  
  122. </ul>
  123. <?php }
  124. $time['start'] = time() - 60*60*24*14; $time['stop'] = time() - 60*60*24*30;
  125. $sql = $db->query("SELECT * FROM ".PREFIX."news WHERE time < ".$time['start']." AND time > ".$time['stop']." ORDER BY id DESC");
  126. if($db->num_rows($sql) > 0){ ?>
  127. <h2><?php echo $lang->loc['this.month']; ?></h2>
  128. <ul>
  129.  
  130. <?php while($row = $db->fetch_assoc($sql)){ $row['title_safe'] = $input->stringToURL($input->HoloText($row['title'],true),true,true); ?>
  131.     <li>
  132.         <a href="<?php echo PATH; ?>/articles/<?php echo $row['id']."-".$row['title_safe']; ?>" class="article-<?php echo $row['id']; ?>"><?php echo stripslashes($row['title']); ?>&nbsp;&raquo;</a>
  133.     </li>
  134.  
  135. <?php } ?>
  136.  
  137. </ul>
  138. <?php }
  139. }elseif(isset($_GET['archive']) && $archive = "true"){ ?>
  140. <h2><?php echo $lang->loc['pagename.news']; ?></h2>
  141. <ul>
  142.  
  143. <?php
  144. $sql = "SELECT * FROM ".PREFIX."news ORDER BY time DESC LIMIT 20";
  145. if($pagenum > 1){ $sql = $sql." OFFSET ".($pagenum - 1) * 20; }
  146. $sql = $db->query($sql);
  147. while($row = $db->fetch_assoc($sql)){ $row['title_safe'] = $input->stringToURL($input->HoloText($row['title'],true),true,true); ?>
  148.     <li>
  149.         <a href="<?php echo PATH; ?>/articles/<?php echo $row['id']."-".$row['title_safe']; ?>/in/archive<?php if($pagenum > 1){ echo $pagenum; } ?>" class="article-<?php echo $row['id']; ?>"><?php echo stripslashes($row['title']); ?>&nbsp;&raquo;</a>
  150.     </li>
  151.  
  152. <?php } ?>
  153.  
  154. </ul>
  155. <?php }elseif(isset($_GET['category'])){ ?>
  156. <h2><?php echo $lang->loc['pagename.news']; ?></h2>
  157. <ul>
  158.  
  159. <?php
  160. $sql = $db->query("SELECT * FROM ".PREFIX."news WHERE categories LIKE '%".$category."%'");
  161. while($row = $db->fetch_assoc($sql)){ $row['title_safe'] = $input->stringToURL($input->HoloText($row['title'],true),true,true); ?>
  162.     <li>
  163.         <a href="<?php echo PATH; ?>/articles/<?php echo $row['id']."-".$row['title_safe']; ?>/in/category/<?php echo $category; ?>" class="article-<?php echo $row['id']; ?>"><?php echo stripslashes($row['title']); ?>&nbsp;&raquo;</a>
  164.     </li>
  165.  
  166. <?php } ?>
  167.  
  168. </ul>
  169. <?php } ?>
  170.  
  171. <a href="<?php echo PATH; ?>/articles/archive"><?php echo $lang->loc['more.news']; ?> &raquo;</a>
  172. </div>
  173.  
  174.  
  175.                     </div>
  176.                 </div>
  177.                 <script type="text/javascript">if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script>
  178.  
  179.  
  180. </div>
  181. <div id="column2" class="column">
  182.  
  183.  
  184.                 <div class="habblet-container ">
  185.                         <div class="cbb clearfix notitle ">
  186.  
  187.  
  188.                         <div id="article-wrapper">
  189.     <h2><?php echo $news_row['title']; ?></h2>
  190.     <div class="article-meta"><?php echo $lang->loc['posted']." ".date('M j, Y',$news_row['time']); ?>
  191.     <?php $categories = explode(",",$news_row['categories']); $output = ""; foreach($categories as &$value){ $output = $output."<a href=\"".PATH."/articles/category/".$input->stringToURL($input->HoloText($value,true),true,true)."\">".$value."</a>, "; } $output = substr_replace($output,"",-2); ?>
  192.         <?php echo $output; ?></div>
  193.  
  194.     <?php $images = explode(",",$news_row['images']); if(!empty($images[0])){ ?>
  195.             <img src="<?php echo $images[0]; ?>" class="article-image"/>
  196.     <?php } ?>
  197.     <p class="summary"><?php echo nl2br($news_row['summary']); ?></p>
  198.  
  199.     <div class="article-body">
  200. <p><?php echo nl2br($news_row['story']); ?></p>
  201. <div class="article-author">- <?php echo $news_row['author']; ?></div>
  202.  
  203. <?php if(count($images) > 1){ unset($images[0]); $output = ""; foreach($images as &$value){ $output = $output."<a href=\"".$value."\" style=\"background-image: url(".$value."); background-position: -0px -0px\"></a>\n"; } ?>
  204.     <div class="article-images clearfix">
  205.  
  206.         <?php echo $output; ?>
  207.  
  208.     </div>
  209. <?php } ?>
  210.  
  211.     <script type="text/javascript" language="Javascript">
  212.         document.observe("dom:loaded", function() {
  213.             $$('.article-images a').each(function(a) {
  214.                 Event.observe(a, 'click', function(e) {
  215.                     Event.stop(e);
  216.                     Overlay.lightbox(a.href, "<?php echo $lang->loc['image.loading']; ?>");
  217.                 });
  218.             });
  219.  
  220.             $$('a.article-<?php echo $news_row['id']; ?>').each(function(a) {
  221.                 a.replace(a.innerHTML);
  222.             });
  223.         });
  224.     </script>
  225.     </div>
  226. </div>
  227.  
  228.  
  229.  
  230.                     </div>
  231.                 </div>
  232.  
  233. <style type="text/css">
  234. input[type="text"], input[type="password"] {
  235.   background-color: #F1F1F1;
  236.   border: 1px solid #999999;
  237.   width: 175px;
  238.   padding: 5px;
  239.   font-family: verdana;
  240.   font-size: 10px;
  241.   color: #666666;
  242. }
  243. input[type="submit"] {
  244.   background-color: #F1F1F1;
  245.   border: 1px solid #999999;
  246.   padding: 5px;
  247.   font-family: verdana;
  248.   font-size: 10px;
  249.   color: #666666;
  250. }
  251. textarea {
  252.   background-color: #F1F1F1;
  253.   border: 1px solid #999999;
  254.   padding: 5px;
  255.   width: 517px;
  256.   height: 70px;
  257.   font-family: verdana;
  258.   font-size: 10px;
  259.   color: #666666;
  260. }
  261. select {
  262.   background-color: #F1F1F1;
  263.   border: 1px solid #999999;
  264.   padding: 5px;
  265.   font-family: verdana;
  266.   font-size: 10px;
  267.   color: #666666;
  268. }
  269. </style>
  270.  
  271. <?php
  272. if(isset($_POST['post_comment']) && $user->name != 'Guest'){
  273.   $posted_on = date("M j, Y g:i A");
  274.   $comment = strip_tags($input->FilterText($_POST['comment']));
  275.   if($comment == NULL){
  276.     $error_message = 'You have left a field empty.<br /><br />';
  277.   }else{
  278.     mysql_query("INSERT INTO cms_news_comments (article, userid, comment, posted_on) VALUES ('".$news_row['id']."', '".$user->id."', '".$comment."', '".$posted_on."');");
  279.     $error_message = 'You have successfully left a comment.<br /><br />';
  280.   }
  281. }
  282. ?>
  283.  
  284. <div class="habblet-container ">
  285.   <div class="cbb clearfix notitle ">
  286.     <div id="article-wrapper"><h2>Post Comment</h2>
  287.       <div class="article-meta"></div>
  288.       <div class="article-body">
  289.         <?php
  290.         if($user->name != 'Guest'){
  291.         echo $error_message; ?>
  292.         <form action="" method="post">
  293.         <textarea name="comment" maxlength="500"></textarea><br /><br />
  294.         <input type="submit" name="post_comment" value="Post Comment" />
  295.         </form>
  296.         <?php
  297.         }else{
  298.           echo 'You must login to post a comment.';
  299.         }
  300.         ?>
  301.       </div>
  302.     </div>
  303.   </div>
  304. </div>
  305.  
  306. <?php
  307. $getComments = mysql_query("SELECT * FROM cms_news_comments WHERE article = '".$news_row['id']."' ORDER by id DESC");
  308. ?>
  309. <div class="habblet-container ">
  310.   <div class="cbb clearfix notitle ">
  311.     <div id="article-wrapper"><h2>Comments (<?php echo mysql_num_rows($getComments); ?>)</h2>
  312.       <div class="article-meta"></div>
  313.       <div class="article-body">
  314.         <?php
  315.         if(mysql_num_rows($getComments) == 0){
  316.           echo 'Sorry, but no one has posted a comment yet.';
  317.         }else{
  318.           echo '<table width="528px">';
  319.           while($Comments = mysql_fetch_array($getComments)){
  320.           $getUserInfo = mysql_query("SELECT * FROM users WHERE id = '".$Comments['userid']."'");
  321.           $userInfo = mysql_fetch_array($getUserInfo);
  322.                   echo '
  323.                  <tr>
  324.                    <td width="90px" valign="top">
  325.                      <div style="float:left"><img src="http://www.habbo.co.uk/habbo-imaging/avatarimage?figure='.$userInfo['figure'].'&size=b&direction=2&head_direction=3&gesture=sml&size=m"></div>
  326.                      ';
  327.                       if($userInfo['rank'] > 5){
  328.                         echo '<div style="position: absolute; z-index:1"><img src="http://habbocity.ath.cx/26_6d82813456b38f80ad83a827eef0fde3/c_images/ADM.gif"></div>';
  329.                       }
  330.                  echo '
  331.                </td>
  332.                    <td width="427px" valign="top">
  333.                      <strong>RE: '.$news_row['title'].'</strong><br /><br />'.$Comments['comment'].'
  334.                    </td>
  335.                  </tr>
  336.          <tr>
  337.                    <td width="90px" valign="top">
  338.                    </td>
  339.            <td width="427px" align="right">
  340.              <i>Posted by <strong><a href="#">'.$userInfo['name'].'</a></strong> on '.$Comments['posted_on'].'</i><br /><br />
  341.            </td>
  342.          </tr>';
  343.           }
  344.           echo '</table>';
  345.         }
  346.         ?>
  347.       </div>
  348.     </div>
  349.   </div>
  350. </div>
  351.  
  352.                 <script type="text/javascript">if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script>
  353.  
  354.  
  355. </div>
  356. <script type="text/javascript">
  357. HabboView.run();
  358. </script>
  359. <?php require_once('./templates/community_footer.php'); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement