Guest User

Untitled

a guest
Jan 3rd, 2013
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.09 KB | None | 0 0
  1.   <?php
  2. /*
  3. * home.php
  4. * Description: example file for displaying latest posts and topics
  5. * by battye (for phpBB.com MOD Team)
  6. * September 29, 2009
  7. */
  8.  
  9. define('IN_PHPBB', true);
  10. $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './phpBB3/';
  11. $phpEx = substr(strrchr(__FILE__, '.'), 1);
  12. include($phpbb_root_path . 'common.' . $phpEx);
  13. include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
  14. include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
  15.  
  16. // Start session management
  17. $user->session_begin();
  18. $auth->acl($user->data);
  19. $user->setup('viewforum');
  20. /* create_where_clauses( int[] gen_id, String type )
  21. * This function outputs an SQL WHERE statement for use when grabbing
  22. * posts and topics */
  23.  
  24. function create_where_clauses($gen_id, $type)
  25. {
  26. global $db, $auth;
  27.  
  28.     $size_gen_id = sizeof($gen_id);
  29.  
  30.         switch($type)
  31.         {
  32.             case 'forum':
  33.                 $type = 'forum_id';
  34.                 break;
  35.             case 'topic':
  36.                 $type = 'topic_id';
  37.                 break;
  38.             default:
  39.                 trigger_error('No type defined');
  40.         }
  41.  
  42.     // Set $out_where to nothing, this will be used of the gen_id
  43.     // size is empty, in other words "grab from anywhere" with
  44.     // no restrictions
  45.     $out_where = '';
  46.  
  47.     if( $size_gen_id > 0 )
  48.     {
  49.     // Get a list of all forums the user has permissions to read
  50.     $auth_f_read = array_keys($auth->acl_getf('f_read', true));
  51.  
  52.         if( $type == 'topic_id' )
  53.         {
  54.             $sql     = 'SELECT topic_id FROM ' . TOPICS_TABLE . '
  55.                        WHERE ' .  $db->sql_in_set('topic_id', $gen_id) . '
  56.                        AND ' .  $db->sql_in_set('forum_id', $auth_f_read);
  57.  
  58.             $result     = $db->sql_query($sql);
  59.  
  60.                 while( $row = $db->sql_fetchrow($result) )
  61.                 {
  62.                         // Create an array with all acceptable topic ids
  63.                         $topic_id_list[] = $row['topic_id'];
  64.                 }
  65.  
  66.             unset($gen_id);
  67.  
  68.             $gen_id = $topic_id_list;
  69.             $size_gen_id = sizeof($gen_id);
  70.         }
  71.  
  72.     $j = 0;    
  73.  
  74.         for( $i = 0; $i < $size_gen_id; $i++ )
  75.         {
  76.         $id_check = (int) $gen_id[$i];
  77.  
  78.             // If the type is topic, all checks have been made and the query can start to be built
  79.             if( $type == 'topic_id' )
  80.             {
  81.                 $out_where .= ($j == 0) ? 'WHERE ' . $type . ' = ' . $id_check . ' ' : 'OR ' . $type . ' = ' . $id_check . ' ';
  82.             }
  83.  
  84.             // If the type is forum, do the check to make sure the user has read permissions
  85.             else if( $type == 'forum_id' && $auth->acl_get('f_read', $id_check) )
  86.             {
  87.                 $out_where .= ($j == 0) ? 'WHERE ' . $type . ' = ' . $id_check . ' ' : 'OR ' . $type . ' = ' . $id_check . ' ';
  88.             }    
  89.  
  90.         $j++;
  91.         }
  92.     }
  93.  
  94.     if( $out_where == '' && $size_gen_id > 0 )
  95.     {
  96.         trigger_error('A list of topics/forums has not been created');
  97.     }
  98.  
  99.     return $out_where;
  100. }
  101. $search_limit = 5;
  102.  
  103.     $forum_id = array();
  104.     $forum_id_where = create_where_clauses($forum_id, 'forum');
  105.  
  106.     $topic_id = array( );
  107.     $topic_id_where = create_where_clauses($topic_id, 'topic');
  108.     ?>
  109. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  110. <html>
  111. <head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  112. <title>Kurdan Update :  Möteplats för alla kurder i norden </title>
  113.  
  114. <style type="text/css">
  115. <!--
  116. body {
  117.     background-color: #CCCCCC;
  118.     a:link {color:#FFFFFF;}      /* unvisited link */
  119.     a:visited {color:#FFFFFF;}  /* visited link */
  120.     a:hover {color:#FFFFFF;}  /* mouse over link */
  121.     a:active {color:#FFFFFF;}  /* selected link */
  122.     a:link {text-decoration:none;}
  123.     a:visited {text-decoration:none;}
  124.     a:hover {text-decoration:underline;}
  125.     a:active {text-decoration:underline;}
  126. }
  127. body,td,th {
  128.     font-family: Tahoma;
  129.     font-size: 10px;
  130.     color: #000000;
  131.     border-radius: 5px ;
  132.    
  133.        
  134. }
  135. .style1 {
  136.     font-size: 12px;
  137.     color: #FFFFFF;
  138.     a:link {color:#FFFFFF;}      /* unvisited link */
  139.     a:visited {color:#FFFFFF;}  /* visited link */
  140.     a:hover {color:#FFFFFF;}  /* mouse over link */
  141.     a:active {color:#FFFFFF;}  /* selected link */
  142.     a:link {text-decoration:none;}
  143.     a:visited {text-decoration:none;}
  144.     a:hover {text-decoration:underline;}
  145.     a:active {text-decoration:underline;}
  146. }
  147. .index {
  148.     background-color: #CCCCCC;
  149.     a:link {color:#FFFFFF;}      /* unvisited link */
  150.     a:visited {color:#FFFFFF;}  /* visited link */
  151.     a:hover {color:#FFFFFF;}  /* mouse over link */
  152.     a:active {color:#FFFFFF;}  /* selected link */
  153.     a:link {text-decoration:none;}
  154.     a:visited {text-decoration:none;}
  155.     a:hover {text-decoration:underline;}
  156.     a:active {text-decoration:underline;}
  157. }
  158. -->
  159. </style>
  160.     <body>
  161.  
  162.  
  163. <table width="100%" border="0" cellpadding="0" cellspacing="0">
  164.   <!--DWLayoutTable-->
  165.   <tr>
  166.     <td width="291" height="134"></td>
  167.     <td width="100%"></td>
  168.     <td width="271"></td>
  169.   </tr>
  170.   <tr>
  171.     <td height="38"></td>
  172.     <td align="center" valign="middle" bgcolor="#999999" update><div align="left">
  173.       <body link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF">
  174.       <blockquote>
  175.         <p><span class="style1">Senaste inl&auml;gg : <a href="http://kurdanforum.comule.com/phpBB3/ucp.php?mode=register">Bli medlem</a> f&ouml;r att kunna delta i diskussioner! </span> </p>
  176.       </blockquote>
  177.     </div>
  178.     <div align="left"></div></td>
  179.     <td></td>
  180.   </tr>
  181.   <tr>
  182.     <td height="21"></td>
  183.     <td></td>
  184.     <td></td>
  185.   </tr>
  186.   <tr>
  187.     <td height="290"></td>
  188.     <td align="center" valign="middle" bgcolor="#666666" update><?php
  189.     $posts_ary = array(
  190.         'SELECT'    => 'p.*, t.*, u.username, u.user_colour',
  191.    
  192.         'FROM'      => array(
  193.             POSTS_TABLE     => 'p',
  194.         ),
  195.    
  196.         'LEFT_JOIN' => array(
  197.             array(
  198.                 'FROM'  => array(USERS_TABLE => 'u'),
  199.                 'ON'    => 'u.user_id = p.poster_id'
  200.             ),
  201.             array(
  202.                 'FROM'  => array(TOPICS_TABLE => 't'),
  203.                 'ON'    => 'p.topic_id = t.topic_id'
  204.             ),
  205.         ),
  206.    
  207.         'WHERE'     => $db->sql_in_set('t.forum_id', array_keys($auth->acl_getf('f_read', true))) . '
  208.                        AND t.topic_status <> ' . ITEM_MOVED . '
  209.                         AND t.topic_approved = 1',
  210.    
  211.         'ORDER_BY'  => 'p.post_id DESC',
  212.     );
  213.    
  214.     $posts = $db->sql_build_query('SELECT', $posts_ary);
  215.  
  216.    $posts_result = $db->sql_query_limit($posts, $search_limit);
  217.  
  218.       while( $posts_row = $db->sql_fetchrow($posts_result) )
  219.       {
  220.          $topic_title       = $posts_row['topic_title'];
  221.          $post_author       = get_username_string('full', $posts_row['poster_id'], $posts_row['username'], $posts_row['user_colour']);
  222.          $post_date          = $user->format_date($posts_row['post_time']);
  223.          $post_link       = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $posts_row['forum_id'] . '&amp;t=' . $posts_row['topic_id'] . '&amp;p=' . $posts_row['post_id']) . '#p' . $posts_row['post_id'];
  224.  
  225.          $post_text = nl2br($posts_row['post_text']);
  226.  
  227.          $bbcode = new bbcode(base64_encode($bbcode_bitfield));        
  228.          $bbcode->bbcode_second_pass($post_text, $posts_row['bbcode_uid'], $posts_row['bbcode_bitfield']);
  229.  
  230.          $post_text = smiley_text($post_text);
  231.  
  232.          $template->assign_block_vars('announcements', array(
  233.          'TOPIC_TITLE'       => censor_text($topic_title),
  234.          'POST_AUTHOR'       => $post_author,
  235.          'POST_DATE'       => $post_date,
  236.          'POST_LINK'       => $post_link,
  237.          'POST_TEXT'         => censor_text($post_text),
  238.          ));
  239.      }
  240.      ?>
  241.  
  242.  
  243. </td>
  244.     <td></td>
  245.   </tr>
  246.   <tr>
  247.     <td height="485"></td>
  248.     <td></td>
  249.     <td></td>
  250.   </tr>
  251.   <tr>
  252.     <td height="1"><img src="spacer.gif" alt="" width="291" height="1"></td>
  253.     <td></td>
  254.     <td><img src="spacer.gif" alt="" width="271" height="1"></td>
  255.   </tr>
  256. </table>
  257. </body>
  258. </head>
  259. </html>
Add Comment
Please, Sign In to add comment