Advertisement
Guest User

Untitled

a guest
Apr 20th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 81.25 KB | None | 0 0
  1. <?php
  2. if(!defined('INITIALIZED'))
  3.     exit;
  4.    
  5. // CONFIG
  6. $level_limit = 8; // minimum 1 character with 30 lvl on account to post
  7. $post_interval = 20; // 20 seconds between posts
  8. $group_not_blocked = $config['site']['access_admin_panel']; // group id of player that can always post, remove post, remove threads
  9. $posts_per_page = 20;
  10. $threads_per_page = 20;
  11.  
  12. //Tiny Editor
  13.                 $main_content .= '
  14.                     <script type="text/javascript" src="'.$layout_name.'/tiny_mce/tiny_mce.js"></script>
  15.                     <script type="text/javascript">
  16.                         tinyMCE.init({
  17.                             // General options
  18.                             mode : "textareas",
  19.                             theme : "advanced",
  20.                             plugins : "autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave,visualblocks",
  21.                    
  22.                             // Theme options
  23.                             theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
  24.                             theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,link,unlink,anchor,image,cleanup,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
  25.                             theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,ltr,rtl",
  26.                             theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,restoredraft,visualblocks",
  27.                             theme_advanced_toolbar_location : "top",
  28.                             theme_advanced_toolbar_align : "left",
  29.                             theme_advanced_statusbar_location : "bottom",
  30.                             theme_advanced_resizing : true,
  31.                    
  32.                             // Example content CSS (should be your site CSS)
  33.                             content_css : "css/content.css",
  34.                    
  35.                             // Drop lists for link/image/media/template dialogs
  36.                             template_external_list_url : "lists/template_list.js",
  37.                             external_link_list_url : "lists/link_list.js",
  38.                             external_image_list_url : "lists/image_list.js",
  39.                             media_external_list_url : "lists/media_list.js",
  40.                    
  41.                             // Style formats
  42.                             style_formats : [
  43.                                 {title : \'Bold text\', inline : \'b\'},
  44.                                 {title : \'Red text\', inline : \'span\', styles : {color : \'#ff0000\'}},
  45.                                 {title : \'Red header\', block : \'h1\', styles : {color : \'#ff0000\'}},
  46.                                 {title : \'Example 1\', inline : \'span\', classes : \'example1\'},
  47.                                 {title : \'Example 2\', inline : \'span\', classes : \'example2\'},
  48.                                 {title : \'Table styles\'},
  49.                                 {title : \'Table row 1\', selector : \'tr\', classes : \'tablerow1\'}
  50.                             ],
  51.                    
  52.                             // Replace values for the template plugin
  53.                             template_replace_values : {
  54.                                 username : "Some User",
  55.                                 staffid : "991234"
  56.                             }
  57.                         });
  58.                     </script>';
  59. // SECTION WITH ID 1 IS FOR "NEWS", ONLY ADMINS CAN CREATE NEW THREAD IN IT
  60. $sections = array(
  61.                     1 => 'News',
  62.                     2 => 'Wars',
  63.                     3 => 'Quests',
  64.                     4 => 'Pictures',
  65.                     5 => 'Bug Report',
  66.                     6 => 'Events (English Only)',
  67.                     7 => 'Real Life');
  68. $sections_desc = array(
  69.                     1 => 'Here are the latest news of the server, and you can comment.',
  70.                     2 => 'Feel free to tell what you think about your enemy.',
  71.                     3 => 'Talk with others about quests you made and how to make them.',
  72.                     4 => 'Show others your best photos from server!',
  73.                     5 => 'Report bugs on website and in-game here.',
  74.                     6 => 'This board is all about events. Here you can advertise your events server-wide to find more participants or exchange ideas on how to organise events best.',
  75.                     7 => 'Everything about your private interests which has nothing to do with Tibia.');
  76. $sections_img = array(
  77.                     1 => '<img src="'.$layout_name.'/images/forum/boards/1.png">',
  78.                     2 => '<img src="'.$layout_name.'/images/forum/boards/2.png">',
  79.                     3 => '<img src="'.$layout_name.'/images/forum/boards/3.png">',
  80.                     4 => '<img src="'.$layout_name.'/images/forum/boards/4.png">',
  81.                     5 => '<img src="'.$layout_name.'/images/forum/boards/5.png">',
  82.                     6 => '<img src="'.$layout_name.'/images/forum/boards/6.png">',
  83.                     7 => '<img src="'.$layout_name.'/images/forum/boards/7.png">');
  84. // END
  85. # Check if player can post
  86. function canPost($account)
  87. {
  88.     if($account->isLoaded())
  89.     {
  90.         $SQL = $GLOBALS['SQL'];
  91.         $level_limit = $GLOBALS['level_limit'];
  92.     $player = filter_var($player, FILTER_SANITIZE_STRING); 
  93.         $player = $SQL->query("SELECT " . $SQL->fieldName('level') . " FROM " . $SQL->tableName('players') . " WHERE " . $SQL->fieldName('account_id') . " = ".$SQL->quote($account->getId())." ORDER BY " . $SQL->fieldName('level') . " DESC")->fetch();
  94.         if($player['level'] >= $level_limit)
  95.             return true;
  96.     }
  97.     return false;
  98. }
  99.  
  100. # Replace codes for smiles
  101. function replaceSmile($text, $smile)
  102. {
  103.     $smileys = array(
  104.                         ':p' => 1,
  105.                         ':eek:' => 2,
  106.                         ':rolleyes:' => 3,
  107.                         ';)' => 4,
  108.                         ':o' => 5,
  109.                         ':D' => 6,  
  110.                         ':(' => 7,
  111.                         ':mad:' => 8,
  112.                         ':)' => 9,
  113.                         ':cool:' => 10
  114.                     );
  115.     if($smile == 1)
  116.         return $text;
  117.     else
  118.     {
  119.         foreach($smileys as $search => $replace)
  120.             $text = str_replace($search, '<img src="./images/forum/smile/'.$replace.'.gif" />', $text);
  121.         return $text;
  122.     }
  123. }
  124.  
  125. function replaceAll($text, $smile)
  126. {
  127.     $rows = 0;
  128.     while(stripos($text, '[code]') !== false && stripos($text, '[/code]') !== false )
  129.     {
  130.         $code = substr($text, stripos($text, '[code]')+6, stripos($text, '[/code]') - stripos($text, '[code]') - 6);
  131.         if(!is_int($rows / 2)) { $bgcolor = 'ABED25'; } else { $bgcolor = '23ED25'; } $rows++;
  132.         $text = str_ireplace('[code]'.$code.'[/code]', '<i>Code:</i><br /><table cellpadding="0" style="background-color: #'.$bgcolor.'; width: 480px; border-style: dotted; border-color: #CCCCCC; border-width: 2px"><tr><td>'.$code.'</td></tr></table>', $text);
  133.     }
  134.     $rows = 0;
  135.     while(stripos($text, '[quote]') !== false && stripos($text, '[/quote]') !== false )
  136.     {
  137.         $quote = substr($text, stripos($text, '[quote]')+7, stripos($text, '[/quote]') - stripos($text, '[quote]') - 7);
  138.         if(!is_int($rows / 2)) { $bgcolor = 'AAAAAA'; } else { $bgcolor = 'CCCCCC'; } $rows++;
  139.         $text = str_ireplace('[quote]'.$quote.'[/quote]', '<table cellpadding="0" style="background-color: #'.$bgcolor.'; width: 480px; border-style: dotted; border-color: #007900; border-width: 2px"><tr><td>'.$quote.'</td></tr></table>', $text);
  140.     }
  141.     $rows = 0;
  142.     while(stripos($text, '[url]') !== false && stripos($text, '[/url]') !== false )
  143.     {
  144.         $url = substr($text, stripos($text, '[url]')+5, stripos($text, '[/url]') - stripos($text, '[url]') - 5);
  145.         $text = str_ireplace('[url]'.$url.'[/url]', '<a href="'.$url.'" target="_blank">'.$url.'</a>', $text);
  146.     }
  147.     while(stripos($text, '[player]') !== false && stripos($text, '[/player]') !== false )
  148.     {
  149.         $player = substr($text, stripos($text, '[player]')+8, stripos($text, '[/player]') - stripos($text, '[player]') - 8);
  150.         $text = str_ireplace('[player]'.$player.'[/player]', '<a href="?subtopic=characters&name='.urlencode($player).'">'.$player.'</a>', $text);
  151.     }
  152.     while(stripos($text, '[img]') !== false && stripos($text, '[/img]') !== false )
  153.     {
  154.         $img = substr($text, stripos($text, '[img]')+5, stripos($text, '[/img]') - stripos($text, '[img]') - 5);
  155.         $text = str_ireplace('[img]'.$img.'[/img]', '<img src="'.$img.'">', $text);
  156.     }
  157.     while(stripos($text, '[letter]') !== false && stripos($text, '[/letter]') !== false )
  158.     {
  159.         $letter = substr($text, stripos($text, '[letter]')+8, stripos($text, '[/letter]') - stripos($text, '[letter]') - 8);
  160.         $text = str_ireplace('[letter]'.$letter.'[/letter]', '<img src="./images/forum/letters/letter_martel_'.$letter.'.gif">', $text);
  161.     }
  162.     while(stripos($text, '[b]') !== false && stripos($text, '[/b]') !== false )
  163.     {
  164.         $b = substr($text, stripos($text, '[b]')+3, stripos($text, '[/b]') - stripos($text, '[b]') - 3);
  165.         $text = str_ireplace('[b]'.$b.'[/b]', '<b>'.$b.'</b>', $text);
  166.     }
  167.     while(stripos($text, '[i]') !== false && stripos($text, '[/i]') !== false )
  168.     {
  169.         $i = substr($text, stripos($text, '[i]')+3, stripos($text, '[/i]') - stripos($text, '[i]') - 3);
  170.         $text = str_ireplace('[i]'.$i.'[/i]', '<i>'.$i.'</i>', $text);
  171.     }
  172.     while(stripos($text, '[u]') !== false && stripos($text, '[/u]') !== false )
  173.     {
  174.         $u = substr($text, stripos($text, '[u]')+3, stripos($text, '[/u]') - stripos($text, '[u]') - 3);
  175.         $text = str_ireplace('[u]'.$u.'[/u]', '<u>'.$u.'</u>', $text);
  176.     }
  177.     return replaceSmile($text, $smile);
  178. }
  179.  
  180. function removeBBCode($text)
  181. {
  182.     while(stripos($text, '[code]') !== false && stripos($text, '[/code]') !== false )
  183.     {
  184.         $code = substr($text, stripos($text, '[code]')+6, stripos($text, '[/code]') - stripos($text, '[code]') - 6);
  185.         $text = str_ireplace('[code]'.$code.'[/code]', $code, $text);
  186.     }
  187.     while(stripos($text, '[quote]') !== false && stripos($text, '[/quote]') !== false )
  188.     {
  189.         $quote = substr($text, stripos($text, '[quote]')+7, stripos($text, '[/quote]') - stripos($text, '[quote]') - 7);
  190.         $text = str_ireplace('[quote]'.$quote.'[/quote]', $quote, $text);
  191.     }
  192.     while(stripos($text, '[url]') !== false && stripos($text, '[/url]') !== false )
  193.     {
  194.         $url = substr($text, stripos($text, '[url]')+5, stripos($text, '[/url]') - stripos($text, '[url]') - 5);
  195.         $text = str_ireplace('[url]'.$url.'[/url]', $url, $text);
  196.     }
  197.     while(stripos($text, '[player]') !== false && stripos($text, '[/player]') !== false )
  198.     {
  199.         $player = substr($text, stripos($text, '[player]')+8, stripos($text, '[/player]') - stripos($text, '[player]') - 8);
  200.         $text = str_ireplace('[player]'.$player.'[/player]', $player, $text);
  201.     }
  202.     while(stripos($text, '[img]') !== false && stripos($text, '[/img]') !== false )
  203.     {
  204.         $img = substr($text, stripos($text, '[img]')+5, stripos($text, '[/img]') - stripos($text, '[img]') - 5);
  205.         $text = str_ireplace('[img]'.$img.'[/img]', $img, $text);
  206.     }
  207.     while(stripos($text, '[b]') !== false && stripos($text, '[/b]') !== false )
  208.     {
  209.         $b = substr($text, stripos($text, '[b]')+3, stripos($text, '[/b]') - stripos($text, '[b]') - 3);
  210.         $text = str_ireplace('[b]'.$b.'[/b]', $b, $text);
  211.     }
  212.     while(stripos($text, '[i]') !== false && stripos($text, '[/i]') !== false )
  213.     {
  214.         $i = substr($text, stripos($text, '[i]')+3, stripos($text, '[/i]') - stripos($text, '[i]') - 3);
  215.         $text = str_ireplace('[i]'.$i.'[/i]', $i, $text);
  216.     }
  217.     while(stripos($text, '[u]') !== false && stripos($text, '[/u]') !== false )
  218.     {
  219.         $u = substr($text, stripos($text, '[u]')+3, stripos($text, '[/u]') - stripos($text, '[u]') - 3);
  220.         $text = str_ireplace('[u]'.$u.'[/u]', $u, $text);
  221.     }
  222.     return $text;
  223. }
  224.  
  225. function codeLower($text)
  226. {
  227.     return str_ireplace(array('[b]', '[i]', '[u]', '[/u][/i][/b][i][u]', '[/u][/i][u]', '[/u]', '[url]', '[player]', '[img]', '[code]', '[quote]', '[/quote][/code][/url][code][quote]', '[/player]', '[/img]', '[/quote][/code][quote]', '[/quote]'), array('[b]', '[i]', '[u]', '[/u][/i][/b][i][u]', '[/u][/i][u]', '[/u]', '[url]', '[player]', '[img]', '[code]', '[quote]', '[/quote][/code][/url][code][quote]', '[/player]', '[/img]', '[/quote][/code][quote]', '[/quote]'), $text);
  228. }
  229.  
  230. function showPost($topic, $text, $smile)
  231. {
  232.     $text = "<br><br>".$text;
  233.     $post = '';
  234.     if(!empty($topic))
  235.         $post .= '<b>'.replaceSmile($topic, $smile).'</b>';
  236.     $post .= replaceAll($text, $smile);
  237.     return $post;
  238. }
  239.  
  240. function showPreview($topic, $text, $smile)
  241. {
  242.     $text = $_POST['text'];
  243.     $post = '';
  244.     if(!empty($topic))
  245.         $post .= '<b>'.replaceSmile($topic, $smile).'</b>';
  246.     $post .= replaceAll($text, $smile);
  247.     return $post;
  248. }
  249.  
  250. $main_content .= '
  251.     <table border=0 cellpadding=2 cellspacing=0 width=100%>
  252.         <tr>';
  253.    
  254. if($action == '')
  255. {
  256.     if(!$logged)
  257.     $main_content .=  '
  258.     <table border=0 cellpadding=2 cellspacing=0 width=100% style="width: 99%; border-radius:5px; border:1px dashed #b71313; background-color:#fcbebe; padding:2px">
  259.         <tr>
  260.             <td  class="ff_std" align="left" >You are <b>not</b> logged in. <a href="?subtopic=accountmanagement" >Log in</a> to post on the forum.</td>
  261.         </tr>
  262.     </table>';
  263.         $main_content .= '
  264.     </br>
  265.     <table border="0" cellpadding="2" cellspacing="0" width="100%">
  266.         <tr>
  267.             <td  class="ff_info" align="right" valign="bottom"&nbsp;<br>Current Time: <i>'.date('G:i').' CEST</i></td>
  268.         </tr>
  269.     </table>
  270.     </br>';
  271.        
  272.     $main_content .= '
  273. <div class="TableContainer">
  274.    <div class="CaptionContainer">
  275.        <div class="CaptionInnerContainer">
  276.            <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);"></span>
  277.            <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);"></span>
  278.            <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);"></span>
  279.            <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);"></span>
  280.            <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);"></span>
  281.            <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);"></span>
  282.            <div class="Text" style="min-height: 17px">
  283.                <div style="float: left">Fórum</div>
  284.            </div>
  285.            <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/global/content/box-frame-vertical.gif);"></span>
  286.            <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/global/content/table-headline-border.gif);"></span>
  287.            <span class="CaptionEdgeLeftBottom"></span>
  288.            <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/global/content/box-frame-edge.gif);"></span>
  289.        </div>
  290.    </div>
  291.  
  292.    <table class="Table3" cellpadding="0" cellspacing="0" align="">
  293.        <tbody>
  294.            <tr>
  295.                <td>
  296.                    <div class="InnerTableContainer">
  297.                        <table style="width:100%;">
  298.                            <tbody>
  299.                                <tr>
  300.                                    <td>
  301.                                        <div class="TableShadowContainerRightTop">
  302.                                            <div class="TableShadowRightTop" style="background-image:url('.$layout_name.'/images/global/content/table-shadow-rt.gif);"></div>
  303.                                        </div>
  304.                                        <div class="TableContentAndRightShadow" style="background-image:url('.$layout_name.'/images/global/content/table-shadow-rm.gif);">
  305.                                            <div class="TableContentContainer">
  306.                                                <table class="TableContent " width="100%">
  307.                                                    <tbody>
  308.                                                        <tr>
  309.                                                            <td colspan=1 align="center" width="32" height="16"></td>
  310.                                                            <td colspan=1><b>Board</b></td>
  311.                                                            <td colspan=1 align="center"><b>Posts</b></td>
  312.                                                            <td colspan=1 align="center"><b>Threads</b></td>
  313.                                                            <td colspan=1 align="center"><b>Last Post</b></td>
  314.                                                        </tr>';
  315.            
  316.     $info = filter_var($info, FILTER_SANITIZE_STRING); 
  317.     $info = $SQL->query("SELECT " . $SQL->fieldName('section') . ", COUNT(" . $SQL->fieldName('id') . ") AS 'threads', SUM(" . $SQL->fieldName('replies') . ") AS 'replies' FROM " . $SQL->tableName('z_forum') . " WHERE " . $SQL->fieldName('first_post') . " = " . $SQL->fieldName('id') . " GROUP BY " . $SQL->fieldName('section') . "")->fetchAll();
  318.     foreach($info as $data)
  319.         $counters[$data['section']] = array('threads' => $data['threads'], 'posts' => $data['replies'] + $data['threads']);
  320.     foreach($sections as $id => $section)
  321.     {
  322.         $last_post = filter_var($last_post, FILTER_SANITIZE_STRING);
  323.         $last_post = $SQL->query("SELECT " . $SQL->tableName('players') . "." . $SQL->fieldName('name') . ", " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('post_date') . " FROM " . $SQL->tableName('players') . ", " . $SQL->tableName('z_forum') . " WHERE " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('section') . " = ".(int) $id." AND " . $SQL->tableName('players') . "." . $SQL->fieldName('id') . " = " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('author_guid') . " ORDER BY " . $SQL->fieldName('post_date') . " DESC LIMIT 1")->fetch();
  324.         if(!is_int($number_of_rows / 2)) { $bgcolor = $config['site']['darkborder']; } else { $bgcolor = $config['site']['lightborder']; } $number_of_rows++;
  325.        
  326.         $main_content .= '
  327.             <tr bgcolor="'.$bgcolor.'">
  328.                 <td class="ff_std" >'.$sections_img[$id].'</td>
  329.                 <td class="ff_std"><a href="?subtopic=forum&action=show_board&id='.$id.'">'.$section.'</a><br /><small>'.$sections_desc[$id].'</small></td>
  330.                 <td class="ff_std" colspan=1 align="center">'.(int) $counters[$id]['posts'].'</td>
  331.                 <td class="ff_std" colspan=1 align="center">'.(int) $counters[$id]['threads'].'</td>
  332.                 <td class="ff_std" align="left" NOWRAP>';
  333.         if(isset($last_post['name']))
  334.             $main_content .= '<a href="?subtopic=forum&action=show_board&id='.$id.'"><img src="images/forum/logo_lastpost.gif" border=0 width=10 height=9></a>'.date('d/m/y H:i:s', $last_post['post_date']).'<br>
  335.             <font class="ff_info">by&nbsp;<a href="?subtopic=characters&name='.urlencode($last_post['name']).'">'.$last_post['name'].'</a></font>';
  336.         else
  337.             $main_content .= 'No posts';
  338.         $main_content .= '
  339.                 </td>
  340.             </tr>
  341.             ';
  342.  
  343.     }
  344.     $main_content .= '
  345.                                                    <tr>
  346.                                                        <td colspan=5 align="left"><b>All times are CEST.</b></td>
  347.                                                    </tr>
  348.                                                </tbody>
  349.                                            </table>
  350.                                        </div>
  351.                                    </div>
  352.                                    <div class="TableShadowContainer">
  353.                                        <div class="TableBottomShadow" style="background-image:url(./layouts/tibiacom/images/global/content/table-shadow-bm.gif);">
  354.                                            <div class="TableBottomLeftShadow" style="background-image:url(./layouts/tibiacom/images/global/content/table-shadow-bl.gif);"></div>
  355.                                            <div class="TableBottomRightShadow" style="background-image:url(./layouts/tibiacom/images/global/content/table-shadow-br.gif);"></div>
  356.                                        </div>
  357.                                    </div>
  358.                                </td>
  359.                            </tr>
  360.                        </tbody>
  361.                    </table>
  362.                </div>
  363.            </td>
  364.        </tr>
  365.    </tbody>
  366. </table>';
  367. }
  368.  
  369. if($action == 'show_board')
  370. {
  371.     $section_id = (int) $_REQUEST['id'];
  372.     $page = (int) $_REQUEST['page'];
  373.     $threads_count = filter_var($threads_count, FILTER_SANITIZE_STRING);
  374.     $threads_count = $SQL->query("SELECT COUNT(" . $SQL->tableName('z_forum') . "." . $SQL->fieldName('id') . ") AS threads_count FROM " . $SQL->tableName('players') . ", " . $SQL->tableName('z_forum') . " WHERE " . $SQL->tableName('players') . "." . $SQL->fieldName('id') . " = " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('author_guid') . " AND " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('section') . " = ".(int) $section_id." AND " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('first_post') . " = " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('id') . "")->fetch();
  375.     for($i = 0; $i < $threads_count['threads_count'] / $threads_per_page; $i++)
  376.     {
  377.         if($i != $page)
  378.             $links_to_pages .= '<a href="?subtopic=forum&action=show_board&id='.$section_id.'&page='.$i.'">'.($i + 1).'</a> ';
  379.         else
  380.             $links_to_pages .= '<b>'.($i + 1).' </b>';
  381.     }
  382.    
  383.     $main_content .= '
  384.     <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
  385.         <TR>
  386.             <TD><IMG SRC="'.$layout_name.'/images/global/general/blank.gif" WIDTH=10 HEIGHT=1 BORDER=0></TD>
  387.             <TD WIDTH=100% ALIGN=right><a href="?subtopic=forum" >Community Boards</a> | <b>'.$sections[$section_id].'</b></TD>
  388.             <TD><IMG SRC="'.$layout_name.'/images/global/general/blank.gif" WIDTH=10 HEIGHT=1 BORDER=0></TD>
  389.         </TR>
  390.     </TABLE>';
  391.    
  392.     if(!$logged)
  393.     $main_content .=  '
  394.         <br>You are <b>not</b> logged in. <a href="?subtopic=accountmanagement" >Log in</a> to post on the forum.<br><br>';
  395.        
  396.     $main_content .= '
  397.     <table border=0 cellpadding=2 cellspacing=0 width=100%>
  398.         <tr>
  399.             <td  class="ff_std" colspan=4 align="left" ></td>
  400.         </tr>
  401.         <tr>
  402.             <td  colspan=1 align="left" ><a href="?subtopic=forum&action=new_topic&section_id='.$section_id.'" ><img src="images/forum/topic.gif" name="" width="85" height="20" border="0" ></a>      
  403.             </td>
  404.         </tr>
  405.     </table>';
  406.    
  407.     $last_threads = filter_var($last_threads, FILTER_SANITIZE_STRING);
  408.     $last_threads = $SQL->query("SELECT " . $SQL->tableName('players') . "." . $SQL->fieldName('name') . ", " . $SQL->tableName('players') . "." . $SQL->fieldName('signature') . ", " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('post_text') . ", " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('post_topic') . ", " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('id') . ", " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('last_post') . ", " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('replies') . ", " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('views') . ", " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('post_date') . ", " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('icon_id') . " FROM " . $SQL->tableName('players') . ", " . $SQL->tableName('z_forum') . " WHERE " . $SQL->tableName('players') . "." . $SQL->fieldName('id') . " = " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('author_guid') . " AND " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('section') . " = ".(int) $section_id." AND " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('first_post') . " = " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('id') . " ORDER BY " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('last_post') . " DESC LIMIT ".$threads_per_page." OFFSET ".($page * $threads_per_page))->fetchAll();
  409.    
  410.     if(isset($last_threads[0]))
  411.     {
  412.         $main_content .= '
  413.             <table border=0 cellpadding=3 cellspacing=1 width=100%>
  414.                 <tr>
  415.                     <td  bgcolor="'.$config['site']['vdarkborder'].'" colspan=7 >&nbsp;</td>
  416.                 </tr>';    
  417.         $main_content .= '
  418.                 <tr>
  419.                     <td  bgcolor="'.$config['site']['vdarkborder'].'" class="ff_white" colspan=1 align="center" width=22 >
  420.                         <b><img src="'.$layout_name.'/images/global/general/blank.gif" width=16 height=16 border=0></b>
  421.                     </td>
  422.                     <td  bgcolor="'.$config['site']['vdarkborder'].'" class="ff_white" colspan=1 align="center" width=22 >
  423.                         <b><img src="'.$layout_name.'/images/global/general/blank.gif" width=16 height=16 border=0></b>
  424.                     </td>
  425.                     <td bgcolor="'.$config['site']['vdarkborder'].'" class="ff_white" colspan=1 align="center">
  426.                         <b>Thread</b>
  427.                     </td>
  428.                     <td bgcolor="'.$config['site']['vdarkborder'].'" class="ff_white" colspan=1 align="center">
  429.                         <b> </b>
  430.                     </td>
  431.                     <td bgcolor="'.$config['site']['vdarkborder'].'" class="ff_white" colspan=1 align="center">
  432.                         <b>Replies</b>
  433.                     </td>
  434.                     <td bgcolor="'.$config['site']['vdarkborder'].'" class="ff_white" colspan=1 align="center">
  435.                         <b>Views</b>
  436.                     </td>
  437.                     <td bgcolor="'.$config['site']['vdarkborder'].'" class="ff_white" colspan=1 align="center">
  438.                         <b>Last Post</b>
  439.                     </td>
  440.                 </tr>';
  441.         foreach($last_threads as $thread)
  442.         {
  443.             if(!is_int($number_of_rows / 2)) { $bgcolor = $config['site']['lightborder']; } else { $bgcolor = $config['site']['darkborder']; } $number_of_rows++;
  444.            
  445.             $main_content .= '
  446.                 <tr>
  447.                     <td  bgcolor="#D4C0A1" class="ff_std" colspan=1 align="center" >
  448.                         <div class="HNCContainer" >
  449.                             <img src="';
  450.                             if((int)$thread['replies'] >= 2)
  451.                             $main_content .= $layout_name.'/images/global/forum/logo_hot.gif"';
  452.                             else
  453.                             $main_content .= $layout_name.'/images/global/general/blank.gif"';                         
  454.                         $main_content .=
  455.                              width=22 height=22 border=0>
  456.                         </div>
  457.                     </td>
  458.                     <td  bgcolor="#F1E0C6" class="ff_std" colspan=1 align="center" >';
  459.                     if($thread['icon_id'] >= 1)
  460.                     $main_content .= '
  461.                         <img src="'.$layout_name.'/images/global/forum/icons/'.$thread['icon_id'].'.gif" border=0 width=15 height=15 alt="Eek">';
  462.                     $main_content .= '
  463.                     </td>
  464.                     <td bgcolor="#D4C0A1" class="ff_std" colspan=1 align="left">';
  465.                        
  466.             if($logged && $group_id_of_acc_logged >= $group_not_blocked)
  467.            
  468.                 $main_content .= '
  469.                     <a href="?subtopic=forum&action=remove_post&id='.$thread['id'].'" onclick="return confirm(\'Are you sure you want remove thread > '.htmlspecialchars($thread['post_topic']).' <?\')"><font color="red">[REMOVE]</font></a> ';
  470.                    
  471.             $main_content .= '
  472.                 <a href="?subtopic=forum&action=show_thread&id='.$thread['id'].'">'.htmlspecialchars($thread['post_topic']).'</a></td>
  473.                 <td bgcolor="#F1E0C6" class="font_std" colspan=1 align="center"><a href="?subtopic=characters&name='.urlencode($thread['name']).'">'.$thread['name'].'</a></td>
  474.                 <td bgcolor="#D4C0A1" class="ff_std" colspan=1 align="center">'.(int) $thread['replies'].'</td>
  475.                 <td bgcolor="#F1E0C6" class="ff_std" colspan=1 align="center">'.(int) $thread['views'].'</td>
  476.                 <td bgcolor="#D4C0A1"  class="ff_std" colspan=1 align="left">';
  477.                
  478.             if($thread['last_post'] > 0)
  479.             {
  480.             $last_post = filter_var($last_post, FILTER_SANITIZE_STRING);
  481.                 $last_post = $SQL->query("SELECT " . $SQL->tableName('players') . "." . $SQL->fieldName('name') . ", " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('post_date') . " FROM " . $SQL->tableName('players') . ", " . $SQL->tableName('z_forum') . " WHERE " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('first_post') . " = ".(int) $thread['id']." AND " . $SQL->tableName('players') . "." . $SQL->fieldName('id') . " = " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('author_guid') . " ORDER BY " . $SQL->fieldName('post_date') . " DESC LIMIT 1")->fetch();
  482.                 if(isset($last_post['name']))
  483.                     $main_content .= date('d/m/y H:i:s', $last_post['post_date']).'<br />by <a href="?subtopic=characters&name='.urlencode($last_post['name']).'">'.$last_post['name'].'</a>';
  484.                 else
  485.                     $main_content .= 'No posts.';
  486.             }
  487.             else
  488.                 $main_content .= date('d/m/y H:i:s', $thread['post_date']).'<br />by <a href="?subtopic=characters&name='.urlencode($thread['name']).'">'.$thread['name'].'</a>';
  489.             $main_content .= '
  490.                 </td>
  491.             </tr>';
  492.         }
  493.         $main_content .= '
  494.             <table border=0 cellpadding=6 cellspacing=0 width=100%>
  495.                 <tr>
  496.                     <td  bgcolor="#505050" class="ff_white" colspan=1 align="left" NOWRAP ><b>All times are CEST.</b></td>
  497.                     <td  bgcolor="#505050" class="ff_white" colspan=1 align="right" NOWRAP >&nbsp;</td>
  498.                 </tr>
  499.             </table>
  500.             <table border=0 cellpadding=2 cellspacing=0 width=100%>
  501.                 <tr>
  502.                     <td  colspan=1 align="left" valign="top" >
  503.                         <a href="?subtopic=forum&action=new_topic&section_id='.$section_id.'" >
  504.                             <img src="'.$layout_name.'/images/global/forum/button_newtopic_off.gif" name="" width="85" height="20" border="0" >
  505.                         </a>
  506.                     </td>
  507.                 </tr>                  
  508.             </table>
  509.             <td  class="ff_info" colspan=1 align="right" valign="top" >Page: '.$links_to_pages.'</td>
  510.         </tr>
  511.         <tr>
  512.             <td  class="ff_std" colspan=4 align="left" ><br></td>
  513.         </tr>
  514.     </table>
  515.     <center>
  516.         <table border=0 cellpadding=3 cellspacing=0>
  517.             <tr>
  518.                 <td  class="ff_info" colspan=1 align="center" valign="middle" NOWRAP ><img src="'.$layout_name.'/images/global/forum/logo_new.gif" border=0 width=22 height=22></td>
  519.                 <td  class="ff_info" colspan=1 align="center" valign="middle" NOWRAP ><b>New Posts</b></td>
  520.                 <td  class="ff_info" colspan=1 align="center" valign="middle" NOWRAP ><img src="'.$layout_name.'/images/global/general/blank.gif" width=12 height=1 border=0></td>
  521.                 <td  class="ff_info" colspan=1 align="center" valign="middle" NOWRAP ><img src="'.$layout_name.'/images/global/forum/logo_hot.gif" border=0 width=22 height=22><img src="'.$layout_name.'/images/global/forum/logo_hotnew.gif" border=0 width=22 height=22></td>
  522.                 <td  class="ff_info" colspan=1 align="center" valign="middle" NOWRAP ><b>More Than 16 Replies</b></td>
  523.                 <td  class="ff_info" colspan=1 align="center" valign="middle" NOWRAP ><img src="'.$layout_name.'/images/global/general/blank.gif" width=12 height=1 border=0></td>
  524.                 <td  class="ff_info" colspan=1 align="center" valign="middle" NOWRAP ><img src="'.$layout_name.'/images/global/forum/logo_closed.gif" border=0 width=22 height=22></td>
  525.                 <td  class="ff_info" colspan=1 align="center" valign="middle" NOWRAP ><b>Closed Thread</b></td>
  526.                 <td  class="ff_info" colspan=1 align="center" valign="middle" NOWRAP ><img src="'.$layout_name.'/images/global/forum/logo_sticky.gif" border=0 width=22 height=22></td>
  527.                 <td  class="ff_info" colspan=1 align="center" valign="middle" NOWRAP ><b>Sticky Thread</b></td>
  528.             </tr>
  529.         </table>
  530.     </center>
  531.     <br>
  532.     <br>
  533.     <b>Board Rights:<br>
  534.     </b>View threads.<br>
  535.     <br>
  536.     Replace code is ON. Smileys are ON. Images are OFF. Links are OFF. "Thank You!" option is OFF. <br>
  537.     Account muting option is ON. <br>';
  538.     }
  539.     else
  540.         $main_content .= '<h3>No threads in this board.</h3>';
  541. }
  542. if($action == 'show_thread')
  543. {
  544.     $thread_id = (int) $_REQUEST['id'];
  545.     $page = (int) $_REQUEST['page'];
  546.     $thread_name = filter_var($thread_name, FILTER_SANITIZE_STRING);
  547.     $thread_name = $SQL->query("SELECT " . $SQL->tableName('players') . "." . $SQL->fieldName('name') . ", " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('post_topic') . " FROM " . $SQL->tableName('players') . ", " . $SQL->tableName('z_forum') . " WHERE " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('first_post') . " = ".(int) $thread_id." AND " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('id') . " = " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('first_post') . " AND " . $SQL->tableName('players') . "." . $SQL->fieldName('id') . " = " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('author_guid') . " LIMIT 1")->fetch();
  548.     if(!empty($thread_name['name']))
  549.     {
  550.     $posts_count = filter_var($posts_count, FILTER_SANITIZE_STRING);
  551.         $posts_count = $SQL->query("SELECT COUNT(" . $SQL->tableName('z_forum') . "." . $SQL->fieldName('id') . ") AS posts_count FROM " . $SQL->tableName('players') . ", " . $SQL->tableName('z_forum') . " WHERE " . $SQL->tableName('players') . "." . $SQL->fieldName('id') . " = " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('author_guid') . " AND " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('first_post') . " = ".(int) $thread_id)->fetch();
  552.         for($i = 0; $i < $posts_count['posts_count'] / $threads_per_page; $i++)
  553.         {
  554.             if($i != $page)
  555.                 $links_to_pages .= '<a href="?subtopic=forum&action=show_thread&id='.$thread_id.'&page='.$i.'">'.($i + 1).'</a> ';
  556.             else
  557.                 $links_to_pages .= '<b>'.($i + 1).' </b>';
  558.         }
  559.        
  560.         $threads = $SQL->query("SELECT
  561.                                     " . $SQL->tableName('players') . "." . $SQL->fieldName('name') . ",
  562.                                     " . $SQL->tableName('players') . "." . $SQL->fieldName('group_id') . ",
  563.                                     " . $SQL->tableName('players') . "." . $SQL->fieldName('town_id') . ",
  564.                                     " . $SQL->tableName('players') . "." . $SQL->fieldName('account_id') . ",  
  565.                                     " . $SQL->tableName('players') . "." . $SQL->fieldName('vocation') . ",
  566.                                     " . $SQL->tableName('players') . "." . $SQL->fieldName('level') . ",
  567.                                     " . $SQL->tableName('players') . "." . $SQL->fieldName('signature') . ",
  568.                                     " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('id') . ",
  569.                                     " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('first_post') . ",
  570.                                     " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('section') . ",
  571.                                     " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('icon_id') . ",
  572.                                     " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('post_text') . ",
  573.                                     " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('post_topic') . ",
  574.                                     " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('post_date') . ",
  575.                                     " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('post_smile') . ",
  576.                                     " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('author_aid') . ",
  577.                                     " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('author_guid') . ",
  578.                                     " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('last_edit_aid') . ",
  579.                                     " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('edit_date') . "
  580.                         FROM
  581.                                     " . $SQL->tableName('players') . ",
  582.                                     " . $SQL->tableName('z_forum') . "
  583.                         WHERE
  584.                                     " . $SQL->tableName('players') . "." . $SQL->fieldName('id') . "
  585.                         =
  586.                                     " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('author_guid') . "
  587.                         AND
  588.                                     " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('first_post') . "
  589.                         =
  590.                                     ".(int) $thread_id."
  591.                         ORDER BY
  592.                                     " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('post_date') . "
  593.                         LIMIT
  594.                                     ".$posts_per_page."
  595.                         OFFSET
  596.                                     ".($page * $posts_per_page))->fetchAll();
  597.         if(isset($threads[0]['name']))
  598.             $SQL->query("UPDATE " . $SQL->tableName('z_forum') . " SET " . $SQL->fieldName('views') . "=" . $SQL->fieldName('views') . "+1 WHERE " . $SQL->fieldName('id') . " = ".(int) $thread_id);
  599.        
  600.         $main_content .= '
  601.             <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
  602.                 <TR>
  603.                     <TD><IMG SRC="'.$layout_name.'/images/global/general/blank.gif" WIDTH=10 HEIGHT=1 BORDER=0></TD>
  604.                     <TD WIDTH=100% ALIGN=right>
  605.                         <a href="?subtopic=forum" >Community Boards</a> |
  606.                         <a href="?subtopic=forum&action=show_board&id='.$threads[0]['section'].'">'.$sections[$threads[0]['section']].'</a> | <b>'.htmlspecialchars($thread_name['post_topic']).'</b>
  607.                     </TD>
  608.                     <TD><IMG SRC="'.$layout_name.'/images/global/general/blank.gif" WIDTH=10 HEIGHT=1 BORDER=0></TD>
  609.                 </TR>
  610.             </TABLE>
  611.             <br />';
  612.         if(!$logged)
  613.         $main_content .= '
  614.             <br>
  615.             You are <b>not</b> logged in. <a href="?subtopic=accountmanagement" >Log in</a> to post on the forum.<br>
  616.             <br>';
  617.         $main_content .= '
  618.             <table border=0 cellpadding=0 cellspacing=0 width=100%>
  619.                 <tr>
  620.                     <td  class="ff_std" colspan=4 align="left" ></td>
  621.                 </tr>
  622.                 <tr>
  623.                     <td  bgcolor="#F1E0C6" class="ff_large" colspan=2 align="left" width=800 >
  624.                         <div class="PostReplyLink">
  625.                             <a href="?subtopic=forum&action=new_post&thread_id='.$thread_id.'">
  626.                                 <img src="images/forum/post.gif" name="" width="92" height="20" border="0" >
  627.                             </a>
  628.                         </div>
  629.                         <div class="Text" ><b>'.$sections[$threads[0]['section']].': '.htmlspecialchars($thread_name['post_topic']).'</b></div></td>
  630.                 </tr>
  631.             </table>';
  632.         $main_content .= '
  633.             <table border=0 cellpadding=5 cellspacing=1 width=100%>
  634.                 <tr>
  635.                     <td  bgcolor="'.$config['site']['vdarkborder'].'" class="ff_white" colspan=2 align="left" NOWRAP >
  636.                         <div class="ForumPost" style="position:relative;height:26px;left:0px;">
  637.                             <div style="float:left;width:175;padding: 5 5 0 5;" ><b>Author</b></div>
  638.                             <div style="float:right;width:600px;padding: 5 5 0 5;" >
  639.                                 <table border=0 cellpadding=2 cellspacing=0 width=100%>
  640.                                     <tr>
  641.                                         <td  bgcolor="'.$config['site']['vdarkborder'].'" class="ff_white" colspan=1 align="left" NOWRAP ><b>Thread #'.$threads[0]['id'].'</b></td>
  642.                                         <td  bgcolor="'.$config['site']['vdarkborder'].'" class="ff_white" colspan=1 align="right" NOWRAP ><b>Pages: '.$links_to_pages.'</b>
  643.                                         </td>
  644.                                     </tr>
  645.                                 </table>
  646.                             </div>
  647.                             <div class="PostSeparatorV" ></div>
  648.                         </div>
  649.                     </td>
  650.                 </tr>';
  651.        
  652.         foreach($threads as $thread)
  653.         {
  654.             if(!is_int($number_of_rows / 2)) { $bgcolor = $config['site']['darkborder']; } else { $bgcolor = $config['site']['lightborder']; } $number_of_rows++;
  655.             $main_content .= '
  656.                 <tr>
  657.                     <td colspan="2" class="CipPost" >
  658.                         <div class="ForumPost" style="background-color:'.$bgcolor.';" >';
  659.                     if($thread['group_id'] >= 3)
  660.                     $main_content .= '
  661.                         <div class="CipBorderTop" >
  662.                             <div class="CipBorder" >
  663.                                 <div class="CipBorderCornerL" style="background-image: url('.$layout_name.'/images/global/forum/cip_post_border_lu.jpg)" ></div>
  664.                                 <div class="CipBorderH" style="background-image: url('.$layout_name.'/images/global/forum/cip_post_border_h.jpg)" ></div>
  665.                                 <div class="CipBorderCornerR" style="background-image: url('.$layout_name.'/images/global/forum/cip_post_border_ru.jpg)" ></div>
  666.                             </div>
  667.                         </div>
  668.                         <div class="CipBorderLeft" >
  669.                             <div class="CipBorderV" style="background-image: url('.$layout_name.'/images/global/forum/cip_post_border_v.jpg)" ></div>
  670.                         </div>
  671.                         <div class="CipBorderRight" >
  672.                             <div class="CipBorderV" style="background-image: url('.$layout_name.'/images/global/forum/cip_post_border_v.jpg)" ></div>
  673.                         </div>';
  674.                     $main_content .= '
  675.                         <div class="PostSeparatorV" ></div>
  676.                         <div class="PostUpper">
  677.                             <div class="PostCharacterText" >
  678.                                 <b><a href="?subtopic=characters&name='.urlencode($thread['name']).'">'.htmlspecialchars($thread['name']).'</a></b><br>';
  679.                             if($thread['group_id'] >= 3)
  680.                             $main_content .= '
  681.                                 <font class="ff_smallinfo">Community Manager<br/>';
  682.                                
  683.                                 if($thread['group_id'] >= 3)
  684.                                 $main_content .= '
  685.                                     <img class="CipPostIcon" src="'.$layout_name.'/images/global/forum/cip_post_icon.gif" /><br>';
  686.                                
  687.                             $main_content .= '
  688.                                 </font><br>
  689.                                 <font class="ff_infotext">Inhabitant of ' . $config['server']['serverName'] . '<br>
  690.                                 Vocation: '.htmlspecialchars(Website::getVocationName($thread['vocation'], $thread['promotion'])).'<br>
  691.                                 Level: '.$thread['level'].'<br>
  692.                                 <br>';
  693.             $rank = new GuildRank($thread['rank_id']);
  694.             if($rank->isLoaded())
  695.             {
  696.                 $guild = $rank->getGuild();
  697.                 if($guild->isLoaded())
  698.                     $main_content .= '
  699.                         <font class="ff_smallinfo">'.htmlspecialchars($rank->getName()).' of the <a href="?subtopic=guilds&action=show&guild='.$guild->getId().'" >'.htmlspecialchars($guild->getName()).'</a> (Larissa)</font><br>';
  700.             }
  701.         $posts = filter_var($posts, FILTER_SANITIZE_STRING);
  702.             $posts = $SQL->query("SELECT COUNT(" . $SQL->fieldName('id') . ") AS 'posts' FROM " . $SQL->tableName('z_forum') . " WHERE " . $SQL->fieldName('author_aid') . "=".(int) $thread['account_id'])->fetch();
  703.            
  704.             $main_content .= '
  705.                 <br />Posts: '.(int) $posts['posts'].'<br /></font></div>
  706.                 <div class="PostText" >';
  707.                 if($thread['icon_id'] != 0)
  708.                 $main_content .= '
  709.                     <img src="'.$layout_name.'/images/global/forum/icons/'.$thread['icon_id'].'.gif">
  710.                 ';
  711.             $main_content .= '
  712.                 '.showPost(htmlspecialchars($thread['post_topic']), $thread['post_text'], $thread['post_smile']);
  713.                
  714.             if(!empty($thread['signature'])){
  715.             $main_content .= '
  716.                 <br />________________<br />'.$thread['signature'];
  717.             $main_content .= '
  718.                 <br /><br /><br /><br />
  719.             ';
  720.             }
  721.             $main_content .= '         
  722.                 </div>             
  723.                 <div class="PostLower" >
  724.                     <div class="PostDetailsHelper" >
  725.                         <div class="PostDetails" ><img src="'.$layout_name.'/images/global/forum/logo_oldpost.gif" border=0 width=14 height=11>'.date('d/m/y H:i:s', $thread['post_date']);
  726.            
  727.             if($thread['edit_date'] > 0)
  728.             {
  729.                 if($thread['last_edit_aid'] != $thread['author_aid'])
  730.                     $main_content .= '<br />Edited by moderator';
  731.                 else
  732.                     $main_content .= '<br />Edited by '.htmlspecialchars($thread['name']);
  733.                 $main_content .= '<br />on '.date('d/m/y H:i:s', $thread['edit_date']);
  734.             }
  735.             $main_content .= '</div></div>';
  736.            
  737.             $main_content .= '
  738.                 <div class="PostActions" >
  739.                     <div class="AdditionalBox" >Post #'.$thread['id'].'</div>';
  740.            
  741.             if($logged && $group_id_of_acc_logged >= $group_not_blocked)
  742.            
  743.             if($thread['first_post'] != $thread['id'])
  744.                  $main_content .= '
  745.                     <a href="?subtopic=forum&action=remove_post&id='.$thread['id'].'" onclick="return confirm(\'Are you sure you want remove post of '.htmlspecialchars($thread['name']).'?\')">
  746.                         <font color="red">REMOVE POST</font>
  747.                     </a>';
  748.             else
  749.                  $main_content .= '
  750.                     <a href="?subtopic=forum&action=remove_post&id='.$thread['id'].'" onclick="return confirm(\'Are you sure you want remove thread > '.htmlspecialchars($thread['post_topic']).' <?\')">
  751.                         <font color="red">REMOVE THREAD</font>
  752.                     </a>';
  753.                    
  754.             if($logged && ($thread['account_id'] == $account_logged->getId() || $group_id_of_acc_logged >= $group_not_blocked))
  755.            
  756.                 $main_content .= '
  757.                     <br/><a href="?subtopic=forum&action=edit_post&id='.$thread['id'].'">Edit Post</a>';
  758.             if($logged)
  759.                 $main_content .= '
  760.                     <br/><a href="?subtopic=forum&action=new_post&thread_id='.$thread_id.'&quote='.$thread['id'].'">Quote</a>';
  761.                    
  762.             $main_content .= '
  763.                 </div>';
  764.             if($thread['group_id'] >= 3)
  765.             $main_content .= '
  766.                 <div class="CipBorderBottom">
  767.                 <div class="CipBorder">
  768.                     <div class="CipBorderCornerL" style="background-image: url('.$layout_name.'/images/global/forum/cip_post_border_ll.jpg)" ></div>
  769.                     <div class="CipBorderH" style="background-image: url('.$layout_name.'/images/global/forum/cip_post_border_h.jpg)" ></div>
  770.                     <div class="CipBorderCornerR" style="background-image: url('.$layout_name.'/images/global/forum/cip_post_border_rl.jpg)" ></div>
  771.                 </div>
  772.             </div>';
  773.             else
  774.         $main_content .= '
  775.             </div>';   
  776.      $main_content .= '
  777.         </td>
  778.     </tr>';
  779.         }
  780.         $main_content .= '
  781.             <table border=0 cellpadding=6 cellspacing=0 width=100%>
  782.                 <tr>
  783.                     <td  bgcolor="#505050" class="ff_white" colspan=1 align="left" NOWRAP ><b>All times are CEST.&nbsp;&nbsp;&nbsp;Pages: '.$links_to_pages.'</b></td>
  784.                 </tr>
  785.             </table>
  786.             <table border=0 cellpadding=6 cellspacing=0 width=100%>
  787.                 <tr>
  788.                     <td  class="ff_pagetext" colspan=1 align="left" ></td>
  789.                     <td  class="ff_large" colspan=1 align="right" >
  790.                         <a href="?subtopic=forum&action=new_post&thread_id='.$thread_id.'" >
  791.                             <img src="images/forum/post.gif" name="" width="92" height="20" border="0" >
  792.                         </a>
  793.                     </td>
  794.                 </tr>
  795.                 <tr>
  796.                     <td  class="ff_std" colspan=1 align="left" ></td>
  797.                 </tr>
  798.                 <tr>
  799.                     <td  class="ff_std" colspan=4 align="left" ></td>
  800.                 </tr>
  801.             </table>
  802.             <br>
  803.             <b>Board Rights:<br>
  804.             </b>View threads.<br>
  805.             <br>
  806.             Replace code is ON. Smileys are ON. Images are OFF. Links are OFF. "Thank You!" option is OFF. <br>
  807.             Account muting option is ON. <br>';
  808.     }
  809.     else
  810.         $main_content .= 'Thread with this ID does not exits.';
  811.  
  812. }
  813. if($action == 'remove_post')
  814. {
  815.     if($logged && $group_id_of_acc_logged >= $group_not_blocked)
  816.     {
  817.         $id = (int) $_REQUEST['id'];
  818.     $post = filter_var($post, FILTER_SANITIZE_STRING);
  819.         $post = $SQL->query("SELECT " . $SQL->fieldName('id') . ", " . $SQL->fieldName('first_post') . ", " . $SQL->fieldName('section') . " FROM " . $SQL->tableName('z_forum') . " WHERE " . $SQL->fieldName('id') . " = ".$id." LIMIT 1")->fetch();
  820.         if($post['id'] == $id)
  821.         {
  822.             if($post['id'] == $post['first_post'])
  823.             {
  824.                 $SQL->query("DELETE FROM " . $SQL->tableName('z_forum') . " WHERE " . $SQL->fieldName('first_post') . " = ".$post['id']);
  825.                 header('Location: ?subtopic=forum&action=show_board&id='.$post['section']);
  826.             }
  827.             else
  828.             {
  829.         $post_page = filter_var($post_page, FILTER_SANITIZE_STRING);
  830.                 $post_page = $SQL->query("SELECT COUNT(" . $SQL->tableName('z_forum') . "." . $SQL->fieldName('id') . ") AS posts_count FROM " . $SQL->tableName('players') . ", " . $SQL->tableName('z_forum') . " WHERE " . $SQL->tableName('players') . "." . $SQL->fieldName('id') . " = " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('author_guid') . " AND " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('id') . " < ".$id." AND " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('first_post') . " = ".(int) $post['first_post'])->fetch();
  831.                 $page = (int) ceil($post_page['posts_count'] / $threads_per_page) - 1;
  832.                 $SQL->query("UPDATE " . $SQL->tableName('z_forum') . " SET " . $SQL->fieldName('replies') . " = " . $SQL->fieldName('replies') . " - 1 WHERE " . $SQL->fieldName('id') . " = ".$post['first_post']);
  833.                 $SQL->query("DELETE FROM " . $SQL->tableName('z_forum') . " WHERE " . $SQL->fieldName('id') . " = ".$post['id']);
  834.                 header('Location: ?subtopic=forum&action=show_thread&id='.$post['first_post'].'&page='.(int) $page);
  835.             }
  836.         }
  837.         else
  838.             $main_content .= 'Post with ID '.$id.' does not exist.';
  839.     }
  840.     else
  841.         $main_content .= 'You are not logged in or you are not moderator.';
  842. }
  843. if($action  == 'new_post')
  844. {
  845.     if($logged)
  846.     {
  847.         if(canPost($account_logged) || $group_id_of_acc_logged >= $group_not_blocked)
  848.         {
  849.             $thread_id = (int) $_REQUEST['thread_id'];
  850.             if(isThreadOpen($thread_id)) {          
  851.             $players_from_account = $SQL->query("SELECT `players`.`name`, `players`.`id` FROM `players` WHERE `players`.`account_id` = ".(int) $account_logged->getId())->fetchAll();
  852.             $thread_id = (int) $_REQUEST['thread_id'];
  853.             $thread = $SQL->query("SELECT `z_forum`.`post_topic`, `z_forum`.`id`, `z_forum`.`section` FROM `z_forum` WHERE `z_forum`.`id` = ".(int) $thread_id." AND `z_forum`.`first_post` = ".(int) $thread_id." LIMIT 1")->fetch();
  854.             $main_content .= '<a href="?subtopic=forum">Boards</a> >> <a href="?subtopic=forum&action=show_board&id='.$thread['section'].'">'.$sections[$thread['section']].'</a> >> <a href="?subtopic=forum&action=show_thread&id='.$thread_id.'">'.$thread['post_topic'].'</a> >> <b>Post new reply</b><br /><h3>'.$thread['post_topic'].'</h3>';
  855.             if(isset($thread['id']))
  856.             {
  857.                 $quote = (int) $_REQUEST['quote'];
  858.                 $text = stripslashes(trim(codeLower($_REQUEST['text'])));
  859.                 $char_id = (int) $_REQUEST['char_id'];
  860.                 $post_topic = stripslashes(trim($_REQUEST['topic']));
  861.                 $smile = (int) $_REQUEST['smile'];
  862.                 $saved = false;
  863.                 if(isset($_REQUEST['quote']))
  864.                 {
  865.                     $quoted_post = $SQL->query("SELECT `players`.`name`, `z_forum`.`post_text`, `z_forum`.`post_date` FROM `players`, `z_forum` WHERE `players`.`id` = `z_forum`.`author_guid` AND `z_forum`.`id` = ".(int) $quote)->fetchAll();
  866.                     if(isset($quoted_post[0]['name']))
  867.                         $text = '[i]Originally posted by '.$quoted_post[0]['name'].' on '.date('d.m.y H:i:s', $quoted_post[0]['post_date']).':[/i][quote]'.$quoted_post[0]['post_text'].'[/quote]';
  868.                 }
  869.                 elseif(isset($_REQUEST['save']))
  870.                 {
  871.                     $lenght = 0;
  872.                     for($i = 0; $i <= strlen($text); $i++)
  873.                     {
  874.                         if(ord($text[$i]) >= 33 && ord($text[$i]) <= 126)
  875.                             $lenght++;
  876.                     }
  877.                     if($lenght < 1 || strlen($text) > 15000)
  878.                         $errors[] = 'Too short or too long post (short: '.$lenght.' long: '.strlen($text).' letters). Minimum 1 letter, maximum 15000 letters.';
  879.                     if($char_id == 0)
  880.                         $errors[] = 'Please select a character.';
  881.                     $player_on_account == false;
  882.                     if(count($errors) == 0)
  883.                     {
  884.                         foreach($players_from_account as $player)
  885.                             if($char_id == $player['id'])
  886.                                 $player_on_account = true;
  887.                         if(!$player_on_account)
  888.                             $errors[] = 'Player with selected ID '.$char_id.' doesn\'t exist or isn\'t on your account';
  889.                     }
  890.                     if(count($errors) == 0)
  891.                     {
  892.                         $last_post = $account_logged->getCustomField('last_post');
  893.                         if($last_post+$post_interval-time() > 0 && $group_id_of_acc_logged < $group_not_blocked)
  894.                             $errors[] = 'You can post one time per '.$post_interval.' seconds. Next post after '.($last_post+$post_interval-time()).' second(s).';
  895.                     }
  896.                     if(count($errors) == 0)
  897.                     {
  898.                         $saved = true;
  899.                         $account_logged->setCustomField('last_post', time());
  900.                         $SQL->query("INSERT INTO `z_forum` (`id` ,`first_post` ,`last_post` ,`section` ,`replies` ,`views` ,`author_aid` ,`author_guid` ,`post_text` ,`post_topic` ,`post_smile` ,`post_date` ,`last_edit_aid` ,`edit_date`, `post_ip`) VALUES ('NULL', '".$thread['id']."', '0', '".$thread['section']."', '0', '0', '".$account_logged->getId()."', '".(int) $char_id."', ".$SQL->quote($text).", ".$SQL->quote($post_topic).", '".(int) $smile."', '".time()."', '0', '0', '".$_SERVER['REMOTE_ADDR']."')");
  901.                         $SQL->query("UPDATE `z_forum` SET `replies`=`replies`+1, `last_post`=".time()." WHERE `id` = ".(int) $thread_id);
  902.                         $post_page = $SQL->query("SELECT COUNT(`z_forum`.`id`) AS posts_count FROM `players`, `z_forum` WHERE `players`.`id` = `z_forum`.`author_guid` AND `z_forum`.`post_date` <= ".time()." AND `z_forum`.`first_post` = ".(int) $thread['id'])->fetch();
  903.                         $page = (int) ceil($post_page['posts_count'] / $threads_per_page) - 1;
  904.                         header('Location: ?subtopic=forum&action=show_thread&id='.$thread_id.'&page='.$page);
  905.                         $main_content .= '<br />Thank you for posting.<br /><a href="?subtopic=forum&action=show_thread&id='.$thread_id.'">GO BACK TO LAST THREAD</a>';
  906.                     }
  907.                 }
  908.                 if(!$saved)
  909.                 {
  910.                     if(count($errors) > 0)
  911.                     {
  912.                         $main_content .= '<font color="red" size="2"><b>Errors occured:</b>';
  913.                         foreach($errors as $error)
  914.                             $main_content .= '<br />* '.$error;
  915.                         $main_content .= '</font><br />';
  916.                     }
  917.                     $main_content .= '<form action="?" method="POST"><input type="hidden" name="action" value="new_post" /><input type="hidden" name="thread_id" value="'.$thread_id.'" /><input type="hidden" name="subtopic" value="forum" /><input type="hidden" name="save" value="save" /><table width="100%"><tr bgcolor="'.$config['site']['vdarkborder'].'"><td colspan="2"><font color="white"><b>Post New Reply</b></font></td></tr><tr bgcolor="'.$config['site']['darkborder'].'"><td width="180"><b>Character:</b></td><td><select name="char_id"><option value="0">(Choose character)</option>';
  918.                     foreach($players_from_account as $player)
  919.                     {
  920.                         $main_content .= '<option value="'.$player['id'].'"';
  921.                         if($player['id'] == $char_id)
  922.                             $main_content .= ' selected="selected"';
  923.                         $main_content .= '>'.$player['name'].'</option>';
  924.                     }
  925.                     $main_content .= '</select></td></tr><tr bgcolor="'.$config['site']['lightborder'].'"><td><b>Topic:</b></td><td><input type="text" name="topic" value="'.htmlspecialchars($post_topic).'" size="40" maxlength="60" /> (Optional)</td></tr>
  926.                    <tr bgcolor="'.$config['site']['darkborder'].'"><td valign="top"><b>Message:</b><font size="1"><br />You can use:<br />[player]Nick[/player]<br />[url=http://address.com/]Address Search - Find Email and Addresses @ Address.com[/url]<br />[img]http://images.com/images3.gif[/img]<br />[code]Code[/code]<br />[b]<b>Text</b>[/b][i]<i>Text</i>[/i][u]<u>Text</u>[/u]and smileys:<br />;) , :) , :D , :( , :rolleyes:<br />:cool: , :eek: , :o , :p</font></td><td><textarea rows="10" cols="40" name="text">'.htmlspecialchars($text).'</textarea><br />(Max. 15,000 letters)</td></tr>
  927.                    <tr bgcolor="'.$config['site']['lightborder'].'"><td valign="top">Options:</td><td><label><input type="checkbox" name="smile" value="1"';
  928.                     if($smile == 1)
  929.                         $main_content .= ' checked="checked"';
  930.                     $main_content .= '/>Disable Smileys in This Post </label></td></tr></table><center><input type="submit" value="Post Reply" /></center></form>';
  931.                     $threads = $SQL->query("SELECT `players`.`name`, `z_forum`.`post_text`, `z_forum`.`post_topic`, `z_forum`.`post_smile` FROM `players`, `z_forum` WHERE `players`.`id` = `z_forum`.`author_guid` AND `z_forum`.`first_post` = ".(int) $thread_id." ORDER BY `z_forum`.`post_date` DESC LIMIT 10")->fetchAll();
  932.                     $main_content .= '<table width="100%"><tr bgcolor="'.$config['site']['vdarkborder'].'"><td colspan="2"><font color="white"><b>Last 5 posts from thread: '.$thread['post_topic'].'</b></font></td></tr>';
  933.                     foreach($threads as $thread)
  934.                     {
  935.                         if(is_int($number_of_rows / 2)) { $bgcolor = $config['site']['darkborder']; } else { $bgcolor = $config['site']['lightborder']; } $number_of_rows++;
  936.                         $main_content .= '<tr bgcolor="'.$bgcolor.'"><td>'.$thread['name'].'</td><td>'.showPost($thread['post_topic'], $thread['post_text'], $thread['post_smile']).'</td></tr>';
  937.                     }
  938.                     $main_content .= '</table>';
  939.                 }
  940.             }
  941.             else
  942.                 $main_content .= 'Thread with ID '.$thread_id.' doesn\'t exist.';
  943.         }
  944.             else
  945.             $main_content .= 'This thread is closed. You can\'t post.';
  946.     }
  947.         else
  948.             $main_content .= 'Your account is banned, deleted or you don\'t have any player with level '.$level_limit.' on your account. You can\'t post.';
  949.     }
  950.     else
  951.         $main_content .= 'Login first.';
  952. }
  953. if($action == 'edit_post')
  954. {
  955.     if($logged)
  956.     {
  957.         if(canPost($account_logged) || $group_id_of_acc_logged >= $group_not_blocked)
  958.         {
  959.             $post_id = (int) $_REQUEST['id'];
  960.         $thread = filter_var($thread, FILTER_SANITIZE_STRING);
  961.             $thread = $SQL->query("SELECT " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('author_guid') . ", " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('author_aid') . ", " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('first_post') . ", " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('post_topic') . ", " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('post_date') . ", " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('post_text') . ", " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('post_smile') . ", " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('id') . ", " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('section') . " FROM " . $SQL->tableName('z_forum') . " WHERE " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('id') . " = ".(int) $post_id." LIMIT 1")->fetch();
  962.             if(isset($thread['id']))
  963.             {
  964.         $first_post = filter_var($first_post, FILTER_SANITIZE_STRING);
  965.                 $first_post = $SQL->query("SELECT " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('author_guid') . ", " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('author_aid') . ", " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('first_post') . ", " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('post_topic') . ", " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('post_text') . ", " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('post_smile') . ", " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('id') . ", " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('section') . " FROM " . $SQL->tableName('z_forum') . " WHERE " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('id') . " = ".(int) $thread['first_post']." LIMIT 1")->fetch();
  966.                
  967.                 $main_content .= '
  968.                     <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
  969.                     <TR>
  970.                         <TD><IMG SRC="'.$layout_name.'/images/global/general/blank.gif" WIDTH=10 HEIGHT=1 BORDER=0></TD>
  971.                         <TD WIDTH=100% ALIGN=right>
  972.                             <a href="?subtopic=forum" >Community Boards</a> |
  973.                             <a href="?subtopic=forum&action=show_board&id='.$thread['section'].'">'.$sections[$thread['section']].'</a> |
  974.                             <a href="?subtopic=forum&action=show_thread&id='.$thread['first_post'].'">'.htmlspecialchars($first_post['post_topic']).'</a> |
  975.                             <b><a href="?subtopic=forum" >Post</a></b> |
  976.                             <b>Edit Post</b></TD>
  977.                         <TD><IMG SRC="'.$layout_name.'/images/global/general/blank.gif" WIDTH=10 HEIGHT=1 BORDER=0></TD>
  978.                     </TR>
  979.                 </TABLE>
  980.                 <br>
  981.                 ';
  982.                
  983.                 if(isset($_POST['preview_edit_post'])){
  984.                 $main_content .= '
  985.                     <table border=0 cellpadding=4 cellspacing=1 width=100%>
  986.                         <tr>
  987.                             <td  bgcolor="#505050" class="ff_whitelarge" colspan=1 align="left" NOWRAP ><b>Message Preview</b></td>
  988.                         </tr>
  989.                         <tr>
  990.                             <td style="position:relative; height:100%;background-color:#D4C0A1;" align="top" >
  991.                                 <div style="position:relative; min-height:18px; width:100%; overflow-x:auto; overflow-y:visible; width:734px; word-wrap:break-word;">
  992.                                 '.showPreview(htmlspecialchars($thread['post_topic']), $_POST['text'], $thread['post_smile']).'
  993.                                 </div>
  994.                             </td>
  995.                         </tr>
  996.                     </table><br><br>';
  997.             }
  998.                    
  999.                 if($account_logged->getId() == $thread['author_aid'] || $group_id_of_acc_logged >= $group_not_blocked)
  1000.                 {
  1001.             $players_from_account = filter_var($players_from_account, FILTER_SANITIZE_STRING);
  1002.                     $players_from_account = $SQL->query("SELECT " . $SQL->tableName('players') . "." . $SQL->fieldName('name') . ", " . $SQL->tableName('players') . "." . $SQL->fieldName('id') . " FROM " . $SQL->tableName('players') . " WHERE " . $SQL->tableName('players') . "." . $SQL->fieldName('account_id') . " = ".(int) $account_logged->getId())->fetchAll();
  1003.                     $saved = false;
  1004.                     if(isset($_POST['edit_post']) && $_POST['save'] == "save")
  1005.                     {
  1006.                         $text = trim(codeLower($_REQUEST['text']));
  1007.                         $char_id = (int) $_REQUEST['char_id'];
  1008.                         $forum_iconid = (int) $_REQUEST['forum_iconid'];
  1009.                         $post_topic = trim($_REQUEST['topic']);
  1010.                         $smile = (int) $_REQUEST['smile'];
  1011.                         $lenght = 0;
  1012.                         for($i = 0; $i <= strlen($post_topic); $i++)
  1013.                         {
  1014.                             if(ord($post_topic[$i]) >= 33 && ord($post_topic[$i]) <= 126)
  1015.                                 $lenght++;
  1016.                         }
  1017.                         if(($lenght < 1 || strlen($post_topic) > 60) && $thread['id'] == $thread['first_post'])
  1018.                             $errors[] = 'Too short or too long topic (short: '.$lenght.' long: '.strlen($post_topic).' letters). Minimum 1 letter, maximum 60 letters.';
  1019.                         $lenght = 0;
  1020.                         for($i = 0; $i <= strlen($text); $i++)
  1021.                         {
  1022.                             if(ord($text[$i]) >= 33 && ord($text[$i]) <= 126)
  1023.                                 $lenght++;
  1024.                         }
  1025.                         if($lenght < 1 || strlen($text) > 15000)
  1026.                             $errors[] = 'Too short or too long post (short: '.$lenght.' long: '.strlen($text).' letters). Minimum 1 letter, maximum 15000 letters.';
  1027.                         if($char_id == 0)
  1028.                             $errors[] = 'Please select a character.';
  1029.                         if(empty($post_topic) && $thread['id'] == $thread['first_post'])
  1030.                             $errors[] = 'Thread topic can\'t be empty.';
  1031.                         $player_on_account == false;
  1032.                         if(count($errors) == 0)
  1033.                         {
  1034.                             foreach($players_from_account as $player)
  1035.                                 if($char_id == $player['id'])
  1036.                                     $player_on_account = true;
  1037.                             if(!$player_on_account)
  1038.                                 $errors[] = 'Player with selected ID '.$char_id.' doesn\'t exist or isn\'t on your account';
  1039.                         }
  1040.                         if(count($errors) == 0)
  1041.                         {
  1042.                             $saved = true;
  1043.                             if($account_logged->getId() != $thread['author_aid'])
  1044.                                 $char_id = $thread['author_guid'];
  1045.                             $SQL->query("UPDATE " . $SQL->tableName('z_forum') . " SET " . $SQL->fieldName('author_guid') . " = ".(int) $char_id.", " . $SQL->fieldName('post_text') . " = ".$SQL->quote($text).", " . $SQL->fieldName('post_topic') . " = ".$SQL->quote($post_topic).", " . $SQL->fieldName('post_smile') . " = ".(int) $smile.", " . $SQL->fieldName('last_edit_aid') . " = ".(int) $account_logged->getId()."," . $SQL->fieldName('edit_date') . " = ".time().", " . $SQL->fieldName('icon_id')." = " .(int) $forum_iconid. " WHERE " . $SQL->fieldName('id') . " = ".(int) $thread['id']);
  1046.                             $post_page = $SQL->query("SELECT COUNT(" . $SQL->tableName('z_forum') . "." . $SQL->fieldName('id') . ") AS posts_count FROM " . $SQL->tableName('players') . ", " . $SQL->tableName('z_forum') . " WHERE " . $SQL->tableName('players') . "." . $SQL->fieldName('id') . " = " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('author_guid') . " AND " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('post_date') . " <= ".$thread['post_date']." AND " . $SQL->tableName('z_forum') . "." . $SQL->fieldName('first_post') . " = ".(int) $thread['first_post'])->fetch();
  1047.                             $page = (int) ceil($post_page['posts_count'] / $threads_per_page) - 1;
  1048.                             header('Location: ?subtopic=forum&action=show_thread&id='.$thread['first_post'].'&page='.$page);
  1049.                             $main_content .= '<br />Thank you for editing post.<br /><a href="?subtopic=forum&action=show_thread&id='.$thread['first_post'].'">GO BACK TO LAST THREAD</a>';
  1050.                         }
  1051.                     }
  1052.                     else
  1053.                     {
  1054.                         $text = $thread['post_text'];
  1055.                         $char_id = (int) $thread['author_guid'];
  1056.                         $post_topic = $thread['post_topic'];
  1057.                         $smile = (int) $thread['post_smile'];
  1058.                     }
  1059.                     if(!$saved)
  1060.                     {
  1061.                         if(count($errors) > 0)
  1062.                         {
  1063.                             $main_content .= '<br /><font color="red" size="2"><b>Errors occured:</b>';
  1064.                             foreach($errors as $error)
  1065.                                 $main_content .= '<br />* '.$error;
  1066.                             $main_content .= '</font>';
  1067.                         }
  1068.                         $main_content .= '
  1069.                             <table border=0 cellpadding=4 cellspacing=1>
  1070.                             <form action="?" method="POST">
  1071.                                 <input type="hidden" name="action" value="edit_post" />
  1072.                                 <input type="hidden" name="id" value="'.$post_id.'" />
  1073.                                 <input type="hidden" name="subtopic" value="forum" />
  1074.                                 <input type="hidden" name="save" value="save" />
  1075.                                 <tr>
  1076.                                     <td  bgcolor="#505050" class="ff_whitelarge" colspan=2 align="left" >Edit Post</td>
  1077.                                 </tr>
  1078.                                 <tr>
  1079.                                     <td  bgcolor="#D4C0A1" class="ff_std" colspan=1 align="left" valign="top" ><b>'.$config['server']['serverName'].' Character:</b><br>
  1080.                                         <font class="ff_smallinfo">(This will appear as "Edited by ..." in the post)</font>
  1081.                                     </td>
  1082.                                     <td  bgcolor="#D4C0A1" class="ff_std" colspan=1 align="left" >
  1083.                                         <select name="char_id">
  1084.                                             <option value="0">(Choose character)</option>';
  1085.                         foreach($players_from_account as $player)
  1086.                         {
  1087.                             $main_content .= '<option value="'.$player['id'].'"';
  1088.                             if($player['id'] == $char_id)
  1089.                                 $main_content .= ' selected="selected"';
  1090.                             $main_content .= '>'.$player['name'].'</option>';
  1091.                         }
  1092.                             $main_content .= '
  1093.                                 </select>
  1094.                             </td>
  1095.                         </tr>
  1096.                         <tr>
  1097.                             <td  bgcolor="#F1E0C6" class="ff_std" colspan=1 align="left" valign="top" ><b>Post Subject:</b></td>
  1098.                             <td  bgcolor="#F1E0C6" class="ff_std" colspan=1 align="left" ><input type="text" value="'.htmlspecialchars($post_topic).'" name="topic" size="40" maxlength="60" /><font class="ff_info"> (Optional)</font></td>
  1099.                         </tr>
  1100.                         <tr>
  1101.                             <td  bgcolor="#D4C0A1" class="ff_std" colspan=1 align="left" valign="top" ><b>Post Icon:</b></td>
  1102.                             <td  bgcolor="#D4C0A1" class="ff_std" colspan=1 align="left" ><input type=radio name="forum_iconid" value="11">
  1103.                                 &nbsp;<img src="'.$layout_name.'/images/global/forum/icons/11.gif" border=0 width=15 height=15 alt="Stuck Tongue Out">&nbsp;&nbsp;&nbsp;
  1104.                                 <input type=radio name="forum_iconid" value="12">
  1105.                                 &nbsp;<img src="'.$layout_name.'/images/global/forum/icons/12.gif" border=0 width=15 height=15 alt="Eek">&nbsp;&nbsp;&nbsp;
  1106.                                 <input type=radio name="forum_iconid" value="13">
  1107.                                 &nbsp;<img src="'.$layout_name.'/images/global/forum/icons/13.gif" border=0 width=15 height=15 alt="Roll Eyes">&nbsp;&nbsp;&nbsp;
  1108.                                 <input type=radio name="forum_iconid" value="14">
  1109.                                 &nbsp;<img src="'.$layout_name.'/images/global/forum/icons/14.gif" border=0 width=15 height=15 alt="Thumbs up">&nbsp;&nbsp;&nbsp;
  1110.                                 <input type=radio name="forum_iconid" value="15">
  1111.                                 &nbsp;<img src="'.$layout_name.'/images/global/forum/icons/15.gif" border=0 width=15 height=15 alt="Thumbs down">&nbsp;&nbsp;&nbsp;
  1112.                                 <input type=radio name="forum_iconid" value="16">
  1113.                                 &nbsp;<img src="'.$layout_name.'/images/global/forum/icons/16.gif" border=0 width=15 height=15 alt="Wink">&nbsp;&nbsp;&nbsp;
  1114.                                 <input type=radio name="forum_iconid" value="17">
  1115.                                 &nbsp;<img src="'.$layout_name.'/images/global/forum/icons/17.gif" border=0 width=15 height=15 alt="Red face">&nbsp;&nbsp;&nbsp;<br>
  1116.                                 <input type=radio name="forum_iconid" value="18">
  1117.                                 &nbsp;<img src="'.$layout_name.'/images/global/forum/icons/18.gif" border=0 width=15 height=15 alt="Talking">&nbsp;&nbsp;&nbsp;
  1118.                                 <input type=radio name="forum_iconid" value="19">
  1119.                                 &nbsp;<img src="'.$layout_name.'/images/global/forum/icons/19.gif" border=0 width=15 height=15 alt="Unhappy">&nbsp;&nbsp;&nbsp;
  1120.                                 <input type=radio name="forum_iconid" value="20">
  1121.                                 &nbsp;<img src="'.$layout_name.'/images/global/forum/icons/20.gif" border=0 width=15 height=15 alt="Angry">&nbsp;&nbsp;&nbsp;
  1122.                                 <input type=radio name="forum_iconid" value="21">
  1123.                                 &nbsp;<img src="'.$layout_name.'/images/global/forum/icons/21.gif" border=0 width=15 height=15 alt="Smile">&nbsp;&nbsp;&nbsp;
  1124.                                 <input type=radio name="forum_iconid" value="22">
  1125.                                 &nbsp;<img src="'.$layout_name.'/images/global/forum/icons/22.gif" border=0 width=15 height=15 alt="Cool">&nbsp;&nbsp;&nbsp;
  1126.                                 <input type=radio name="forum_iconid" value="23">
  1127.                                 &nbsp;<img src="'.$layout_name.'/images/global/forum/icons/23.gif" border=0 width=15 height=15 alt="Question">&nbsp;&nbsp;&nbsp;
  1128.                                 <input type=radio name="forum_iconid" value="24">
  1129.                                 &nbsp;<img src="'.$layout_name.'/images/global/forum/icons/24.gif" border=0 width=15 height=15 alt="Exclamation">&nbsp;&nbsp;&nbsp;<br>
  1130.                                 <input type=radio name="forum_iconid" value="25">
  1131.                                 &nbsp;<img src="'.$layout_name.'/images/global/forum/icons/25.gif" border=0 width=15 height=15 alt="Lightbulb">&nbsp;&nbsp;&nbsp;
  1132.                                 <input type=radio name="forum_iconid" value="26">
  1133.                                 &nbsp;<img src="'.$layout_name.'/images/global/forum/icons/26.gif" border=0 width=15 height=15 alt="Arrow">&nbsp;&nbsp;&nbsp;
  1134.                                 <input type=radio name="forum_iconid" value="27">
  1135.                                 &nbsp;<img src="'.$layout_name.'/images/global/forum/icons/27.gif" border=0 width=15 height=15 alt="Post">&nbsp;&nbsp;&nbsp;<br>
  1136.                                 <input type=radio name="forum_iconid" value="0" checked>
  1137.                                 &nbsp;No Icon</td>
  1138.                         </tr>
  1139.                        <tr>
  1140.                             <td  bgcolor="#F1E0C6" class="ff_std" colspan=1 align="left" valign="top" ><b>Message:</b><br>
  1141.                             <br>
  1142.                             <font class="ff_info">Replace codes are allowed.<br><br>
  1143.                             How to use smileys:<br>
  1144.                             <table border=0 cellpadding=2 cellspacing=0 width=100%>
  1145.                             <tr>
  1146.                                 <td  colspan=1 align="left" ><img src="'.$layout_name.'/images/global/forum/smile/1.gif" border=0 width=15 height=15 alt="Stuck Tongue Out"></td>
  1147.                                 <td  colspan=1 align="left" >:p</td>
  1148.                             </tr>
  1149.                             <tr>
  1150.                             <td  colspan=1 align="left" ><img src="'.$layout_name.'/images/global/forum/smile/2.gif" border=0 width=15 height=15 alt="Eek"></td>
  1151.                             <td  colspan=1 align="left" >:eek:</td>
  1152.                             </tr>
  1153.                             <tr>
  1154.                                 <td  colspan=1 align="left" ><img src="'.$layout_name.'/images/global/forum/smile/3.gif" border=0 width=15 height=15 alt="Roll Eyes"></td>
  1155.                                 <td  colspan=1 align="left" >:rolleyes:</td>
  1156.                             </tr>
  1157.                             <tr>
  1158.                                 <td  colspan=1 align="left" ><img src="'.$layout_name.'/images/global/forum/smile/4.gif" border=0 width=15 height=15 alt="Wink"></td>
  1159.                                 <td  colspan=1 align="left" >;)</td>
  1160.                             </tr>
  1161.                             <tr>
  1162.                                 <td  colspan=1 align="left" ><img src="'.$layout_name.'/images/global/forum/smile/5.gif" border=0 width=15 height=15 alt="Red face"></td>
  1163.                                 <td  colspan=1 align="left" >:o</td>
  1164.                             </tr>
  1165.                             <tr>
  1166.                                 <td  colspan=1 align="left" ><img src="'.$layout_name.'/images/global/forum/smile/6.gif" border=0 width=15 height=15 alt="Talking"></td>
  1167.                                 <td  colspan=1 align="left" >:D</td>
  1168.                             </tr>
  1169.                             <tr>
  1170.                                 <td  colspan=1 align="left" ><img src="'.$layout_name.'/images/global/forum/smile/7.gif" border=0 width=15 height=15 alt="Unhappy"></td>
  1171.                                 <td  colspan=1 align="left" >:(</td>
  1172.                             </tr>
  1173.                             <tr>
  1174.                                 <td  colspan=1 align="left" ><img src="'.$layout_name.'/images/global/forum/smile/8.gif" border=0 width=15 height=15 alt="Angry"></td>
  1175.                                 <td  colspan=1 align="left" >:mad:</td>
  1176.                             </tr>
  1177.                             <tr>
  1178.                                 <td  colspan=1 align="left" ><img src="'.$layout_name.'/images/global/forum/smile/9.gif" border=0 width=15 height=15 alt="Smile"></td>
  1179.                                 <td  colspan=1 align="left" >:)</td>
  1180.                             </tr>
  1181.                             <tr>
  1182.                                 <td  colspan=1 align="left" ><img src="'.$layout_name.'/images/global/forum/smile/10.gif" border=0 width=15 height=15 alt="Cool"></td>
  1183.                                 <td  colspan=1 align="left" >:cool:</td>
  1184.                             </tr>
  1185.                         </table>
  1186.                     </font>
  1187.                     </td>
  1188.                     <td  bgcolor="#F1E0C6" class="ff_std" colspan=1 align="left" ><textarea rows=20 cols=55 name="text">'.htmlspecialchars($text).'</textarea><div id="forum_pt_lenght">4094 characters left.</div></td>
  1189.                         </tr>
  1190.                        <tr>
  1191.                             <td  bgcolor="#D4C0A1" class="ff_std" colspan=1 align="left" valign="top" ><b>Options:</td>
  1192.                             <td  bgcolor="#D4C0A1" class="ff_info" colspan=1 align="left" ><input type="checkbox" name="smile" value="1"';
  1193.                         if($smile == 1)
  1194.                             $main_content .= ' checked="checked"';
  1195.                         $main_content .= '/><strong>Disable Smileys in This Post</strong> </td>
  1196.                     </tr>
  1197.                
  1198.                     <tr>
  1199.                         <td  class="ff_std" colspan=2 align="center" ><br>
  1200.                             <input type=submit name="preview_edit_post" value="Preview Changes"  >
  1201.                             &nbsp;
  1202.                             <input type="submit" name="edit_post" value="Submit Message">
  1203.                             &nbsp;
  1204.                             <input type=reset name="reset" value="Reset Fields">
  1205.                         </td>
  1206.                     </tr>
  1207.                 </table>
  1208.             </form>';
  1209.                     }
  1210.                 }
  1211.                 else
  1212.                     $main_content .= '<br />You are not an author of this post.';
  1213.             }
  1214.             else
  1215.                 $main_content .= '<br />Post with ID '.$post_id.' doesn\'t exist.';
  1216.         }
  1217.         else
  1218.             $main_content .= '<br />Your account is banned, deleted or you don\'t have any player with level '.$level_limit.' on your account. You can\'t post.';
  1219.     }
  1220.     else
  1221.         $main_content .= '<br />Login first.';
  1222. }
  1223.  
  1224.  
  1225. if($action == 'new_topic')
  1226. {
  1227.     if($logged)
  1228.     {
  1229.         if(canPost($account_logged) || $group_id_of_acc_logged >= $group_not_blocked)
  1230.         {
  1231.             $players_from_account = $SQL->query("SELECT `players`.`name`, `players`.`id` FROM `players` WHERE `players`.`account_id` = ".(int) $account_logged->getId())->fetchAll();
  1232.             $section_id = (int) $_REQUEST['section_id'];
  1233.             $main_content .= '<a href="?subtopic=forum">Boards</a> >> <a href="?subtopic=forum&action=show_board&id='.$section_id.'">'.$sections[$section_id].'</a> >> <b>Post new thread</b><br />';
  1234.             if(isset($sections[$section_id]))
  1235.             {
  1236.                 if($section_id == 1 && $group_id_of_acc_logged < $group_not_blocked)
  1237.                     $errors[] = 'Only moderators and admins can post on news board.';
  1238.                 $quote = (int) $_REQUEST['quote'];
  1239.                 $text = stripslashes(trim(codeLower($_REQUEST['text'])));
  1240.                 $char_id = (int) $_REQUEST['char_id'];
  1241.                 $post_topic = stripslashes(trim($_REQUEST['topic']));
  1242.                 $smile = (int) $_REQUEST['smile'];
  1243.                 $saved = false;
  1244.                 if(isset($_REQUEST['save']))
  1245.                 {
  1246.                     $lenght = 0;
  1247.                     for($i = 0; $i <= strlen($post_topic); $i++)
  1248.                     {
  1249.                         if(ord($post_topic[$i]) >= 33 && ord($post_topic[$i]) <= 126)
  1250.                             $lenght++;
  1251.                     }
  1252.                     if($lenght < 1 || strlen($post_topic) > 60)
  1253.                         $errors[] = 'Too short or too long topic (short: '.$lenght.' long: '.strlen($post_topic).' letters). Minimum 1 letter, maximum 60 letters.';
  1254.                     $lenght = 0;
  1255.                     for($i = 0; $i <= strlen($text); $i++)
  1256.                     {
  1257.                         if(ord($text[$i]) >= 33 && ord($text[$i]) <= 126)
  1258.                             $lenght++;
  1259.                     }
  1260.                     if($lenght < 1 || strlen($text) > 15000)
  1261.                         $errors[] = 'Too short or too long post (short: '.$lenght.' long: '.strlen($text).' letters). Minimum 1 letter, maximum 15000 letters.';
  1262.                     if($char_id == 0)
  1263.                         $errors[] = 'Please select a character.';
  1264.                     $player_on_account == false;
  1265.                     if(count($errors) == 0)
  1266.                     {
  1267.                         foreach($players_from_account as $player)
  1268.                             if($char_id == $player['id'])
  1269.                                 $player_on_account = true;
  1270.                         if(!$player_on_account)
  1271.                             $errors[] = 'Player with selected ID '.$char_id.' doesn\'t exist or isn\'t on your account';
  1272.                     }
  1273.                     if(count($errors) == 0)
  1274.                     {
  1275.                         $last_post = $account_logged->getCustomField('last_post');
  1276.                         if($last_post+$post_interval-time() > 0 && $group_id_of_acc_logged < $group_not_blocked)
  1277.                             $errors[] = 'You can post one time per '.$post_interval.' seconds. Next post after '.($last_post+$post_interval-time()).' second(s).';
  1278.                     }
  1279.                     if(count($errors) == 0)
  1280.                     {
  1281.                         $saved = true;
  1282.                         $account_logged->setCustomField('last_post', time());
  1283.                         $SQL->query("INSERT INTO `z_forum` (`id` ,`first_post` ,`last_post` ,`section` ,`replies` ,`views` ,`author_aid` ,`author_guid` ,`post_text` ,`post_topic` ,`post_smile` ,`post_date` ,`last_edit_aid` ,`edit_date`, `post_ip`) VALUES ('NULL', '0', '".time()."', '".(int) $section_id."', '0', '0', '".$account_logged->getId()."', '".(int) $char_id."', ".$SQL->quote($text).", ".$SQL->quote($post_topic).", '".(int) $smile."', '".time()."', '0', '0', '".$_SERVER['REMOTE_ADDR']."')");
  1284.                         $thread_id = $SQL->lastInsertId();
  1285.                         $SQL->query("UPDATE `z_forum` SET `first_post`=".(int) $thread_id." WHERE `id` = ".(int) $thread_id);
  1286.                         header('Location: ?subtopic=forum&action=show_thread&id='.$thread_id);
  1287.                         $main_content .= '<br />Thank you for posting.<br /><a href="?subtopic=forum&action=show_thread&id='.$thread_id.'">GO BACK TO LAST THREAD</a>';
  1288.                     }
  1289.                 }
  1290.                 if(!$saved)
  1291.                 {
  1292.                     if(count($errors) > 0)
  1293.                     {
  1294.                         $main_content .= '<font color="red" size="2"><b>Errors occured:</b>';
  1295.                         foreach($errors as $error)
  1296.                             $main_content .= '<br />* '.$error;
  1297.                         $main_content .= '</font><br />';
  1298.                     }
  1299.                     $main_content .= '<form action="?" method="POST"><input type="hidden" name="action" value="new_topic" /><input type="hidden" name="section_id" value="'.$section_id.'" /><input type="hidden" name="subtopic" value="forum" /><input type="hidden" name="save" value="save" /><table width="100%"><tr bgcolor="'.$config['site']['vdarkborder'].'"><td colspan="2"><font color="white"><b>Post New Reply</b></font></td></tr><tr bgcolor="'.$config['site']['darkborder'].'"><td width="180"><b>Character:</b></td><td><select name="char_id"><option value="0">(Choose character)</option>';
  1300.                     foreach($players_from_account as $player)
  1301.                     {
  1302.                         $main_content .= '<option value="'.$player['id'].'"';
  1303.                         if($player['id'] == $char_id)
  1304.                             $main_content .= ' selected="selected"';
  1305.                         $main_content .= '>'.$player['name'].'</option>';
  1306.                     }
  1307.                     $main_content .= '</select></td></tr><tr bgcolor="'.$config['site']['lightborder'].'"><td><b>Topic:</b></td><td><input type="text" name="topic" value="'.htmlspecialchars($post_topic).'" size="40" maxlength="60" /> (Optional)</td></tr>
  1308.                    <tr bgcolor="'.$config['site']['darkborder'].'"><td valign="top"><b>Message:</b><font size="1"><br />You can use:<br />[player]Nick[/player]<br />[url=http://address.com/]Address Search - Find Email and Addresses @ Address.com[/url]<br />[img]http://images.com/images3.gif[/img]<br />[code]Code[/code]<br />[b]<b>Text</b>[/b]<br />[i]<i>Text</i>[/i]<br />[u]<u>Text</u>[/u]<br />and smileys:<br />;) , :) , :D , :( , :rolleyes:<br />:cool: , :eek: , :o , :p</font></td><td><textarea rows="10" cols="40" name="text">'.htmlspecialchars($text).'</textarea><br />(Max. 15,000 letters)</td></tr>
  1309.                    <tr bgcolor="'.$config['site']['lightborder'].'"><td valign="top">Options:</td><td><label><input type="checkbox" name="smile" value="1"';
  1310.                     if($smile == 1)
  1311.                         $main_content .= ' checked="checked"';
  1312.                     $main_content .= '/>Disable Smileys in This Post </label></td></tr></table><center><input type="submit" value="Post Thread" /></center></form>';
  1313.                 }
  1314.             }
  1315.             else
  1316.                 $main_content .= 'Board with ID '.$board_id.' doesn\'t exist.';
  1317.         }
  1318.         else
  1319.             $main_content .= 'Your account is banned, deleted or you don\'t have any player with level '.$level_limit.' on your account. You can\'t post.';
  1320.     }
  1321.     else
  1322.         $main_content .= 'Login first.';
  1323. }
  1324. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement