Advertisement
Guest User

includes/comments_include.php

a guest
Dec 8th, 2012
480
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 20.71 KB | None | 0 0
  1. <?php
  2. /*-------------------------------------------------------+
  3. | PHP-Fusion Content Management System
  4. | Copyright (C) 2002 - 2011 Nick Jones
  5. | http://www.php-fusion.co.uk/
  6. +--------------------------------------------------------+
  7. | Filename: comments_include.php
  8. | Author: Nick Jones (Digitanium)
  9. +--------------------------------------------------------+
  10. | Name: Extended Comments
  11. | Version: 1.01
  12. | Filename: comments_include.php
  13. | Author: Fangree Productions
  14. | Developers: Fangree_Craig
  15. | Site: http://www.fangree.co.uk
  16. +--------------------------------------------------------+
  17. | This program is released as free software under the
  18. | Affero GPL license. You can redistribute it and/or
  19. | modify it under the terms of this license which you
  20. | can read by viewing the included agpl.txt or online
  21. | at www.gnu.org/licenses/agpl.html. Removal of this
  22. | copyright header is strictly prohibited without
  23. | written permission from the original author(s).
  24. +--------------------------------------------------------*/
  25. if (!defined("IN_FUSION")) { die("Access Denied"); }
  26.  
  27. include LOCALE.LOCALESET."comments.php";
  28.  
  29. function showcomments($ctype, $cdb, $ccol, $cid, $clink) {
  30.  
  31. global $settings, $locale, $userdata, $aidlink;
  32.  
  33. // Check if locale file is available matching the current site locale setting.
  34. if (file_exists(INFUSIONS."extended_comments/locale/".$settings['locale'].".php")) {
  35. // Load the locale file matching the current site locale setting.
  36. include INFUSIONS."extended_comments/locale/".$settings['locale'].".php";
  37. } else {
  38. // Load the infusion's default locale file.
  39. include INFUSIONS."extended_comments/locale/English.php";
  40. }
  41. include INFUSIONS."extended_comments/infusion_db.php";
  42.  
  43. $comments_settings = dbarray(dbquery("SELECT * FROM ".DB_EXTCOMMENTS_TABLE));
  44.  
  45.  
  46.  
  47.     $link = FUSION_SELF.(FUSION_QUERY ? "?".FUSION_QUERY : "");
  48.     $link = preg_replace("^(&amp;|\?)c_action=(edit|delete)&amp;comment_id=\d*^", "", $link);
  49.  
  50.     if (iMEMBER && (isset($_GET['c_action']) && $_GET['c_action'] == "delete") && (isset($_GET['comment_id']) && isnum($_GET['comment_id']))) {
  51.         if ((iADMIN && checkrights("C")) || (iMEMBER && dbcount("(comment_id)", DB_COMMENTS, "comment_id='".$_GET['comment_id']."' AND comment_name='".$userdata['user_id']."'"))) {
  52.             $result = dbquery("DELETE FROM ".DB_COMMENTS." WHERE comment_id='".$_GET['comment_id']."'".(iADMIN ? "" : " AND comment_name='".$userdata['user_id']."'"));
  53.         }
  54.         redirect($clink);
  55.     }
  56.  
  57.     if ($settings['comments_enabled'] == "1") {
  58.         if ((iMEMBER || $settings['guestposts'] == "1") && isset($_POST['post_comment'])) {
  59.  
  60.             if (iMEMBER) {
  61.                 $comment_name = $userdata['user_id'];
  62.             } elseif ($settings['guestposts'] == "1") {
  63.                 $comment_name = trim(stripinput($_POST['comment_name']));
  64.                 $comment_name = preg_replace("(^[+0-9\s]*)", "", $comment_name);                if (isnum($comment_name)) { $comment_name = ""; }
  65.                 include_once INCLUDES."securimage/securimage.php";
  66.                 $securimage = new Securimage();
  67.                 if (!isset($_POST['com_captcha_code']) || $securimage->check($_POST['com_captcha_code']) == false) { redirect($link); }
  68.             }
  69.  
  70.             $comment_message = trim(stripinput(censorwords($_POST['comment_message'])));
  71.  
  72.             if (iMEMBER && (isset($_GET['c_action']) && $_GET['c_action'] == "edit") && (isset($_GET['comment_id']) && isnum($_GET['comment_id']))) {
  73.                 $comment_updated = false;
  74.                 if ((iADMIN && checkrights("C")) || (iMEMBER && dbcount("(comment_id)", DB_COMMENTS, "comment_id='".$_GET['comment_id']."' AND comment_item_id='".$cid."' AND comment_type='".$ctype."' AND comment_name='".$userdata['user_id']."' AND comment_hidden='0'"))) {
  75.                     if ($comment_message) {
  76.                         $result = dbquery("UPDATE ".DB_COMMENTS." SET comment_message='$comment_message' WHERE comment_id='".$_GET['comment_id']."'".(iADMIN ? "" : " AND comment_name='".$userdata['user_id']."'"));
  77.                         $comment_updated = true;
  78.                     }
  79.                 }
  80.                 if ($comment_updated) {
  81.                     $c_start = (ceil(dbcount("(comment_id)", DB_COMMENTS, "comment_id<='".$_GET['comment_id']."' AND comment_item_id='".$cid."' AND comment_type='".$ctype."'") / 10) - 1) * 10;
  82.                 }
  83.                 redirect($clink."&amp;c_start=".(isset($c_start) && isnum($c_start) ? $c_start : ""));
  84.             } else {
  85.                 if (!dbcount("(".$ccol.")", $cdb, $ccol."='".$cid."'")) { redirect(BASEDIR."index.php"); }
  86.                 if ($comment_name && $comment_message) {
  87.                     require_once INCLUDES."flood_include.php";
  88.                     if (!flood_control("comment_datestamp", DB_COMMENTS, "comment_ip='".USER_IP."'")) {
  89.                         $result = dbquery("INSERT INTO ".DB_COMMENTS." (comment_item_id, comment_type, comment_name, comment_message, comment_datestamp, comment_ip, comment_hidden) VALUES ('$cid', '$ctype', '$comment_name', '$comment_message', '".time()."', '".USER_IP."', '0')");
  90.                     }
  91.                 }
  92.                 $c_start = (ceil(dbcount("(comment_id)", DB_COMMENTS, "comment_item_id='".$cid."' AND comment_type='".$ctype."'") / 10) - 1) * 10;
  93.                 redirect($clink."&amp;c_start=".$c_start);
  94.             }
  95.         }
  96.  
  97.         opentable($locale['c100']);
  98.         // Comments Styles
  99.          require_once INFUSIONS."extended_comments/includes/comments_styles_include.php";
  100.  
  101.         echo "<a id='comments' name='comments'></a>";
  102.         $c_rows = dbcount("(comment_id)", DB_COMMENTS, "comment_item_id='$cid' AND comment_type='$ctype' AND comment_hidden='0'");
  103.         if (!isset($_GET['c_start']) && $c_rows > 10) {$_GET['c_start'] = (ceil($c_rows / 10) - 1) * 10;}
  104.         if (!isset($_GET['c_start']) || !isnum($_GET['c_start'])){ $_GET['c_start'] = 0; }
  105.        
  106.         $result = dbquery(
  107.             "SELECT tcm.comment_id, tcm.comment_name, tcm.comment_message, tcm.comment_datestamp, tcm.comment_ip, tcu.user_id, tcu.user_name, tcu.user_status, tcu.user_avatar,  tcu.user_lastvisit, tcu.user_joined
  108.             FROM ".DB_COMMENTS." tcm
  109.             LEFT JOIN ".DB_USERS." tcu ON tcm.comment_name=tcu.user_id
  110.             WHERE comment_item_id='$cid' AND comment_type='$ctype' AND comment_hidden='0'
  111.             ORDER BY comment_datestamp ASC LIMIT ".$_GET['c_start'].",10"
  112.         );
  113.         if (dbrows($result)) {
  114.             $i = $_GET['c_start']+1;
  115.             if ($c_rows > 10) {
  116.                 echo "<div style='text-align:center;margin-bottom:5px;'>".makecommentnav($_GET['c_start'], 10, $c_rows, 3, $clink."&amp;")."</div>\n";
  117.             }
  118.             echo "<table cellpadding='0' cellspacing='1' width='100%' class='tbl-border' style='vertical-align:top;'>\n";
  119.             while ($data = dbarray($result)) {
  120.        
  121.                
  122.                 if (($comments_settings['colour1']) || ($comments_settings['colour1_font'])) {
  123.             echo "<tr><td colspan='2' class='tbl2-colour1 border-radius'>";
  124.             }else{
  125.                 echo "<tr><td colspan='2' class='tbl2 border-radius'>";
  126.                 }
  127.                
  128.                 if ((iADMIN && checkrights("C")) || (iMEMBER && $data['comment_name'] == $userdata['user_id'] && isset($data['user_name']))) {
  129.                    
  130.                 if ($comments_settings['icons'] == '1'){
  131.                 echo "<div style='float:right' class='comment_actions'><!--comment_actions-->\n<a href='".FUSION_REQUEST."&amp;c_action=edit&amp;comment_id=".$data['comment_id']."#edit_comment'><img src='".INFUSIONS."extended_comments/images/edit_comment.png' style='vertical-align: middle; border:0px;' alt='".$locale['c108']."' title='".$locale['c108']."' /></a> |\n";
  132.                 echo "<a href='".FUSION_REQUEST."&amp;c_action=delete&amp;comment_id=".$data['comment_id']."'><img src='".INFUSIONS."extended_comments/images/delete_comment.png' style='vertical-align: middle; border:0px;' alt='".$locale['c109']."' title='".$locale['c109']."' /></a>\n</div>\n";
  133.                 }else{
  134.                
  135.                 if (($comments_settings['colour1']) || ($comments_settings['colour1_font'])) {
  136.                     echo "<div style='float:right' class='com-name'>\n<a class='com-name' href='".FUSION_REQUEST."&amp;c_action=edit&amp;comment_id=".$data['comment_id']."#edit_comment'>".$locale['c108']."</a> |\n";
  137.                      echo "<a class='com-name' href='".FUSION_REQUEST."&amp;c_action=delete&amp;comment_id=".$data['comment_id']."'>".$locale['c109']."</a>\n</div>\n";
  138.                       }else{
  139.                      echo "<div style='float:right' class='comment_actions'><!--comment_actions-->\n<a href='".FUSION_REQUEST."&amp;c_action=edit&amp;comment_id=".$data['comment_id']."#edit_comment'>".$locale['c108']."</a> |\n";
  140.                     echo "<a href='".FUSION_REQUEST."&amp;c_action=delete&amp;comment_id=".$data['comment_id']."'>".$locale['c109']."</a>\n</div>\n";
  141.                     }
  142.                 }
  143.                 }
  144.                     if ($data['user_name']) {
  145.                     if(iMEMBER && $data['user_id'] != $userdata['user_id'] && $comments_settings['comment_reply'] == '1') {
  146.                     echo' <a title="@:'.($data['user_name']?$data['user_name']:$data['comment_name']).'" href="javascript:insertText(\'comment_message\',\'[b]@'.($data['user_name']?$data['user_name']:$data['comment_name']).' #'.$i.':[/b] \', \'inputform\');" class="side small"><img src=\''.INFUSIONS.'extended_comments/images/commentat.gif\' style=\'vertical-align:middle;\'  alt=\''.$locale['com015c'].'\' title=\''.$locale['com015c'].'\' border=\'0\' /></a> | ';
  147.                     }
  148.                     if (($comments_settings['colour1']) || ($comments_settings['colour1_font'])) {
  149.                     echo "<a class='com-name' href='".BASEDIR."profile.php?lookup=".$data['comment_name']."'>".$data['user_name']."</a>\n";
  150.                      }else{
  151.                     echo "<span class='comment-name'><a href='".BASEDIR."profile.php?lookup=".$data['comment_name']."'>".$data['user_name']."</a></span>\n";
  152.                     }
  153.                      
  154.                         if ($comments_settings['status'] == '1'){
  155.                         echo" | ";
  156.                         if ($data['user_lastvisit']<(time()-60)) {
  157.                 echo " <img src='".IMAGES."offline.gif' alt='".$data['user_name']." ".$locale['c003']."' title='".$data['user_name']." ".$locale['c003']."'  style='vertical-align:middle; border:0px;'/> <span class='small'>|</span> \n";
  158.                  } else {
  159.                 echo " <img src='".IMAGES."online.gif' alt='".$data['user_name']." ".$locale['c002']."' title='".$data['user_name']." ".$locale['c002']."'  style='vertical-align:middle; border:0px;' /> <span class='small'>|</span> \n";
  160.                 }
  161.                 }
  162.                 } else {
  163.            
  164.                 if (($comments_settings['colour1']) || ($comments_settings['colour1_font'])) {
  165.                 echo "<span class='com-name'>".$data['comment_name']."</span> |\n";
  166.                     }else{
  167.                 echo "<span class='comment-name'>".$data['comment_name']."</span> |\n";
  168.                 }
  169.                 }
  170.        
  171.                 if (($comments_settings['colour1']) || ($comments_settings['colour1_font'])) {
  172.                     echo "<a class='com-name' href='".FUSION_REQUEST."#c".$data['comment_id']."' id='c".$data['comment_id']."' name='c".$data['comment_id']."'>#".$i."</a> | ".$locale['c001']." ".$locale['global_071'].showdate("longdate", $data['comment_datestamp'])."\n";    
  173.                      }else{
  174.                         echo "<span class='small'><a href='".FUSION_REQUEST."#c".$data['comment_id']."' id='c".$data['comment_id']."' name='c".$data['comment_id']."'>#".$i."</a> | ".$locale['c001']." ".$locale['global_071'].showdate("longdate", $data['comment_datestamp'])."</span>\n";
  175.                         }
  176.                     echo "</td></tr>";
  177.                
  178.                 if (($comments_settings['avatar_c'] == '1') || ($comments_settings['country'] == '1') || ($comments_settings['joined'] == '1') || ($comments_settings['display_ip'] == '1')) {
  179.  
  180.                 if (($comments_settings['colour2']) || ($comments_settings['colour2_font'])) {
  181.                 echo "<tr>\n<td valign='top' class='tbl2-colour2 border-radiustlbl'>\n";
  182.                  }else{
  183.                 echo "<tr>\n<td valign='top' class='tbl2 border-radiustlbl'>\n";
  184.                 }
  185.                
  186.                 if ($comments_settings['avatar_c'] == '1') {
  187.                 if ($data['user_avatar'] && file_exists(IMAGES."avatars/".$data['user_avatar'])) {
  188.                 $user_avatar = "<img class='avatar'  src='".IMAGES."avatars/".$data['user_avatar']."' alt='".$data['user_name']."'/><br /><br />";
  189.                 echo profile_link($data['comment_name'], $user_avatar, $data['user_status']);
  190.                 } else {
  191.                 $user_avatar = "<img class='avatar' src='".IMAGES."avatars/noav.gif' alt='".$data['user_name']."'/><br /><br />";
  192.                 echo profile_link($data['comment_name'], $user_avatar, $data['user_status']);
  193.  
  194.                 }
  195.                }
  196.                 if ($comments_settings['country'] == '1') {
  197.                
  198.                     $result_country = dbquery("SHOW COLUMNS FROM ".DB_USERS. " LIKE 'user_country'");
  199.                         if (dbrows($result_country) > 0) {
  200.                     $ucountry = dbarray(dbquery("SELECT user_country FROM ".DB_USERS." WHERE user_id='".$data['user_id']."'"));
  201.                         if (isset($ucountry['user_country'])) {
  202.                         $c = dbarray(dbquery("SELECT * FROM ".DB_PREFIX."nations WHERE nat_id='".$ucountry['user_country']."'"));
  203.                         echo "<span class='small'><strong>".$locale['c004']."</strong> <img style='vertical-align:middle;border:none' src='".BASEDIR."".($ucountry['user_country'] != 0 ? $c['nat_pic'] : "".BASEDIR."/images/flags/f-00.gif")."' alt='".$c['nat_name']."' title='".$c['nat_name']."'/></span><br />\n";
  204.                     }
  205.                 }
  206.                
  207.  
  208.                
  209.                 $result_location = dbquery("SHOW COLUMNS FROM ".DB_USERS. " LIKE 'user_location'");
  210.                     if (dbrows($result_location) > 0) {
  211.                 $ulocation = dbarray(dbquery("SELECT user_location FROM ".DB_USERS." WHERE user_id='".$data['user_id']."'"));
  212.                     if ($ulocation['user_location'] !=="") {
  213.                     echo "<span class='small'><strong>".$locale['c005']."</strong> ".$ulocation['user_location']."<br />\n";
  214.                   }
  215.                  }
  216.                 }
  217.        
  218.        
  219.         if ($comments_settings['joined'] == '1' ) {
  220.         if ($data['user_joined']) {
  221.         echo "<span class='small'><strong>".$locale['c006']."</strong> ".showdate("%d.%m.%y", $data['user_joined'])."\n";
  222.         echo"</span><br />\n";
  223.         }
  224.         }
  225.        
  226.         if ($comments_settings['display_ip'] == '1' && iADMIN && checkrights("C")) {
  227.         echo"<span class='small'><strong>".$locale['c007']."</strong> ".$data['comment_ip']."</span>";
  228.         }
  229.         echo "</td>";
  230. }
  231.         if (($comments_settings['avatar_c'] ==1) || ($comments_settings['country'] ==1) || ($comments_settings['joined'] ==1) || ($comments_settings['display_ip'] ==1)) {
  232.         if (($comments_settings['colour3']) || ($comments_settings['colour3_font'])) {
  233.         echo "<td valign='top'  class='tbl1-colour3 border-radiustrbr comment_message'>";
  234.          }else{
  235.         echo "<td valign='top' class='tbl1 border-radiustrbr comment_message'>";
  236.        }
  237.      
  238.       }else{
  239.        
  240.        if (($comments_settings['colour3']) || ($comments_settings['colour3_font'])) {
  241.         echo "<td valign='top' class='tbl1-colour3 border-radius'>";
  242.         }else{
  243.         echo "<td valign='top' class='tbl1 border-radius comment_message'>";
  244.         }
  245.         }
  246.         echo"<!--comment_message-->".nl2br(parseubb(parsesmileys($data['comment_message'])))."";
  247.        
  248.         $result_sig = dbquery("SHOW COLUMNS FROM ".DB_USERS. " LIKE 'user_sig'");
  249.        
  250.         if (dbrows($result_sig) > 0) {
  251.         $usig = dbarray(dbquery("SELECT user_sig FROM ".DB_USERS." WHERE user_id='".$data['user_id']."'"));
  252.         if (isset($usig['user_sig']) && $usig['user_sig'] && $comments_settings['sig'] ==1) {
  253.          echo "\n<br /><br /><hr><div class='forum_sig'><fieldset class='comments-fieldset'><legend class='comments-legend'>".$locale['c009']."</legend>".nl2br(parseubb(parsesmileys($usig['user_sig']), "b|i|u||center|small|url|mail|img|color"))."</fieldset></div>\n";
  254.         }
  255.         }
  256.          echo"</div>\n";
  257.  
  258.          echo "</td>\n</tr>\n";
  259.        
  260.         if ($comments_settings['addthis'] ==1) {
  261.         include INFUSIONS."extended_comments/locale/English.php";
  262.         if (($comments_settings['avatar_c'] == '1') || ($comments_settings['country'] ==1) || ($comments_settings['joined'] ==1) || ($comments_settings['display_ip'] ==1)) {
  263.         if (($comments_settings['colour1']) || ($comments_settings['colour1_font'])) {
  264.          echo "<td valign='top' class='tbl2-colour1 border-radiustlbl'><span class='small'>".$locale['com015']."</span>";
  265.           }else{
  266.             echo "<td valign='top' class='tbl1 border-radiustlbl'><span class='small'>".$locale['com015']."</span>";
  267.         }
  268.         }
  269.         if (($comments_settings['avatar_c'] == 1) || ($comments_settings['country'] ==1) || ($comments_settings['joined'] ==1) || ($comments_settings['display_ip'] ==1)) {
  270.         if (($comments_settings['colour1']) || ($comments_settings['colour1_font'])) {
  271.         echo"</td><td valign='top' class='tbl2-colour1 border-radiustrbr'>";
  272.         }else{
  273.        
  274.          echo"</td><td valign='top' class='tbl1 border-radiustrbr'>";
  275.         }
  276.         }else{
  277.        
  278.         if (($comments_settings['colour1']) || ($comments_settings['colour1_font'])) {
  279.          echo"</td><td valign='top' class='tbl2-colour1 border-radius'>";
  280.        
  281.         }else{
  282.        
  283.         echo"</td><td valign='top' class='tbl1 border-radius'>";
  284.         }
  285.         }
  286.         echo "<div align='left'>\n";
  287.           include INFUSIONS."extended_comments/includes/addthis_comments_include.php";
  288.           echo "</div>\n";
  289.         echo"</td></tr>";
  290.  
  291.        }
  292.    
  293.        $i++;
  294.          }
  295.         echo"</table>";
  296.            
  297.         if (iADMIN && checkrights("C")) {
  298.             echo "<div align='right' class='tbl2'><a href='".ADMIN."comments.php".$aidlink."&amp;ctype=$ctype&amp;cid=$cid'>".$locale['c106']."</a></div>\n";
  299.         }
  300.         if ($c_rows > 10) {
  301.             echo "<div style='text-align:center;margin-top:5px;'>".makecommentnav($_GET['c_start'], 10, $c_rows, 3, $clink."&amp;")."</div>\n";
  302.         }
  303.        } else {
  304.         echo $locale['c101']."\n";
  305.        }
  306.    
  307.       closetable();
  308.  
  309.         opentable($locale['c102']);
  310.         if (iMEMBER && (isset($_GET['c_action']) && $_GET['c_action'] == "edit") && (isset($_GET['comment_id']) && isnum($_GET['comment_id']))) {
  311.             $eresult = dbquery(
  312.                 "SELECT tcm.comment_id, tcm.comment_name, tcm.comment_message, tcu.user_name FROM ".DB_COMMENTS." tcm
  313.                 LEFT JOIN ".DB_USERS." tcu ON tcm.comment_name=tcu.user_id
  314.                 WHERE comment_id='".$_GET['comment_id']."' AND comment_item_id='".$cid."' AND comment_type='".$ctype."' AND comment_hidden='0'"
  315.             );
  316.             if (dbrows($eresult)) {
  317.                 $edata = dbarray($eresult);
  318.                 if ((iADMIN && checkrights("C")) || (iMEMBER && $edata['comment_name'] == $userdata['user_id'] && isset($edata['user_name']))) {
  319.                     $clink .= "&amp;c_action=edit&amp;comment_id=".$edata['comment_id'];
  320.                     $comment_message = $edata['comment_message'];
  321.                 }
  322.             } else {
  323.                 $comment_message = "";
  324.             }
  325.         } else {
  326.             $comment_message = "";
  327.         }
  328.         if (iMEMBER || $settings['guestposts'] == "1") {
  329.             require_once INCLUDES."bbcode_include.php";
  330.             echo "<a id='edit_comment' name='edit_comment'></a>\n";
  331.             echo "<form name='inputform' method='post' action='".$clink."'>\n";
  332.             if (iGUEST) {
  333.                 echo "<div align='center' class='tbl'>\n".$locale['c104']."<br />\n";
  334.                 echo "<input type='text' name='comment_name' maxlength='30' class='textbox' style='width:360px' />\n";
  335.                 echo "</div>\n";
  336.             }
  337.    
  338.                $delay_spam = stripslashes($comments_settings['delay_spam']);
  339.                 if (iMEMBER && ((time()-$userdata['user_joined'])<$delay_spam)) {
  340.                 echo"<br /><div class='admin-message' style='text-align: center;margin:auto'><strong>".$locale['co_spam001']."</strong></div><br />";
  341.                 }else{
  342.                  echo "<div align='center' class='tbl'>\n";
  343.                   echo "<textarea name='comment_message' cols='70' rows='6' class='textbox' style='width:360px'>".$comment_message."</textarea><br />\n";
  344.                    echo display_bbcodes("360px", "comment_message");
  345.                     if (iGUEST) {
  346.                    echo $locale['global_158']."<br />\n";
  347.                   echo "<img id='com_captcha' src='".INCLUDES."securimage/securimage_show.php' alt='' /><br />\n";
  348.                  echo "<a href='".INCLUDES."securimage/securimage_play.php'><img src='".INCLUDES."securimage/images/audio_icon.gif' alt='' class='tbl-border' style='margin-bottom:1px' /></a>\n";
  349.                 echo "<a href='#' onclick=\"document.getElementById('com_captcha').src = '".INCLUDES."securimage/securimage_show.php?sid=' + Math.random(); return false\"><img src='".INCLUDES."securimage/images/refresh.gif' alt='' class='tbl-border' /></a><br />\n";
  350.                echo $locale['global_159']."<br />\n<input type='text' name='com_captcha_code' class='textbox' style='width:100px' />\n";
  351.               }
  352.               echo "<br />\n<input type='submit' name='post_comment' value='".($comment_message ? $locale['c103'] : $locale['c102'])."' class='button' />\n";
  353.                echo "</div>\n</form>\n";
  354.               }
  355.            
  356.         } else {
  357.             echo $locale['c105']."\n";
  358.         }
  359.         closetable();
  360.     }
  361. }
  362.  
  363. function makecommentnav($start, $count, $total, $range = 0, $link) {
  364.  
  365.     global $locale;
  366.  
  367.     $pg_cnt = ceil($total / $count);
  368.     if ($pg_cnt <= 1) { return ""; }
  369.  
  370.     $idx_back = $start - $count;
  371.     $idx_next = $start + $count;
  372.     $cur_page = ceil(($start + 1) / $count);
  373.  
  374.     $res = $locale['global_092']." ".$cur_page.$locale['global_093'].$pg_cnt.": ";
  375.     if ($idx_back >= 0) {
  376.         if ($cur_page > ($range + 1)) {
  377.             $res .= "<a href='".$link."c_start=0'>1</a>";
  378.             if ($cur_page != ($range + 2)) {
  379.                 $res .= "...";
  380.             }
  381.         }
  382.     }
  383.     $idx_fst = max($cur_page - $range, 1);
  384.     $idx_lst = min($cur_page + $range, $pg_cnt);
  385.     if ($range == 0) {
  386.         $idx_fst = 1;
  387.         $idx_lst = $pg_cnt;
  388.     }
  389.     for ($i = $idx_fst; $i <= $idx_lst; $i++) {
  390.         $offset_page = ($i - 1) * $count;
  391.         if ($i == $cur_page) {
  392.             $res .= "<span><strong>".$i."</strong></span>";
  393.         } else {
  394.             $res .= "<a href='".$link."c_start=".$offset_page."'>".$i."</a>";
  395.         }
  396.     }
  397.     if ($idx_next < $total) {
  398.         if ($cur_page < ($pg_cnt - $range)) {
  399.             if ($cur_page != ($pg_cnt - $range - 1)) {
  400.                 $res .= "...";
  401.             }
  402.             $res .= "<a href='".$link."c_start=".($pg_cnt - 1) * $count."'>".$pg_cnt."</a>\n";
  403.         }
  404.     }
  405.  
  406.     return "<div class='pagenav'>\n".$res."</div>\n";
  407. }
  408. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement