Annotation of kcms/src/forum_viewtopic.php, revision 1.2

1.1       kanaco      1: <?php
                      2: /*
                      3: +---------------------------------------------------------------+
1.2     ! kanaco      4: |      kCMS 0.1.5
1.1       kanaco      5: |      /forum_viewtopic.php
                      6: |
                      7: |      kCMS.Kanaco.Com
                      8: |      optiK@kcms.kanaco.com
                      9: |
                     10: +---------------------------------------------------------------+
                     11: */
                     12: 
                     13: require_once("set.php");
                     14: 
                     15: require_once(e_HANDLER."textparse/basic.php");
                     16: $etp = new kCMS_basicparse;
                     17: 
                     18: if(IsSet($_POST['fjsubmit'])){
                     19:        header("location:".e_BASE."forum_viewforum.php?".$_POST['forumjump']);
                     20:        exit;
                     21: }
                     22: $highlight_search = FALSE;
                     23: if(IsSet($_POST['highlight_search'])){
                     24:        $highlight_search = TRUE;
                     25: }
                     26: define("IMAGE_reply", (file_exists(THEME."forum/reply.png") ? "<img src='".THEME."forum/reply.png' alt='' style='border:0' />" : "<img src='".e_IMAGE."forum/reply.png' alt='' style='border:0' />"));
                     27: define("IMAGE_newthread", (file_exists(THEME."forum/newthread.png") ? "<img src='".THEME."forum/newthread.png' alt='' style='border:0' />" : "<img src='".e_IMAGE."forum/newthread.png' alt='' style='border:0' />"));
                     28: //define("IMAGE_profile", (file_exists(THEME."forum/profile.png") ? "<img src='".THEME."forum/profile.png' alt='".LAN_398."' style='border:0' />" : "<img src='".e_IMAGE."forum/profile.png' alt='".LAN_398."' style='border:0' />"));
                     29: define("IMAGE_rank_moderator_image", ($pref['rank_moderator_image'] && file_exists(THEME."forum/".$pref['rank_moderator_image']) ? "<img src='".THEME."forum/".$pref['rank_moderator_image']."' alt='' />" : "<img src='".e_IMAGE."forum/moderator.png' alt='' />"));
                     30: define("IMAGE_rank_main_admin_image", ($pref['rank_main_admin_image'] && file_exists(THEME."forum/".$pref['rank_main_admin_image']) ? "<img src='".THEME."forum/".$pref['rank_main_admin_image']."' alt='' />" : "<img src='".e_IMAGE."forum/main_admin.png' alt='' />"));
                     31: define("IMAGE_rank_admin_image", ($pref['rank_admin_image'] && file_exists(THEME."forum/".$pref['rank_admin_image']) ? "<img src='".THEME."forum/".$pref['rank_admin_image']."' alt='' />" : "<img src='".e_IMAGE."forum/admin.png' alt='' />"));
                     32: define("IMAGE_pm", (file_exists(THEME."forum/pm.png") ? "<img src='".THEME."forum/pm.png' alt='".LAN_399."' style='border:0' />" : "<img src='".e_IMAGE."forum/pm.png' alt='".LAN_399."' style='border:0' />"));
                     33: define("IMAGE_website", (file_exists(THEME."forum/website.png") ? "<img src='".THEME."forum/website.png' alt='".LAN_396."' style='border:0' />" : "<img src='".e_IMAGE."forum/website.png' alt='".LAN_396."' style='border:0' />"));
                     34: define("IMAGE_edit", (file_exists(THEME."forum/edit.png") ? "<img src='".THEME."forum/edit.png' alt='".LAN_400."' style='border:0' />" : "<img src='".e_IMAGE."forum/edit.png' alt='".LAN_400."' style='border:0' />"));
                     35: define("IMAGE_quote", (file_exists(THEME."forum/quote.png") ? "<img src='".THEME."forum/quote.png' alt='".LAN_401."' style='border:0' />" : "<img src='".e_IMAGE."forum/quote.png' alt='".LAN_401."' style='border:0' />"));
                     36: define("IMAGE_admin_edit", (file_exists(THEME."forum/admin_edit.png") ? "<img src='".THEME."forum/admin_edit.png' alt='".LAN_406."' style='border:0' />" : "<img src='".e_IMAGE."forum/admin_edit.png' alt='".LAN_406."' style='border:0' />"));
                     37: define("IMAGE_admin_move", (file_exists(THEME."forum/admin_move.png") ? "<img src='".THEME."forum/admin_move.png' alt='".LAN_408."' style='border:0' />" : "<img src='".e_IMAGE."forum/admin_move.png' alt='".LAN_408."' style='border:0' />"));
                     38: define("IMAGE_new", (file_exists(THEME."forum/new.png") ? "<img src='".THEME."forum/new.png' alt='' style='float:left' />" : "<img src='".e_IMAGE."forum/new.png' alt='' style='float:left' />"));
                     39: define("IMAGE_post", (file_exists(THEME."forum/post.png") ? "<img src='".THEME."forum/post.png' alt='' style='border:0' />" : "<img src='".e_IMAGE."forum/post.png' alt='' style='border:0' />"));
                     40: define("IMAGE_report", (file_exists(THEME."forum/report.png") ? "<img src='".THEME."forum/report.png' alt='".LAN_413."' style='border:0' />" : "<img src='".e_IMAGE."forum/report.png' alt='".LAN_413."' style='border:0' />"));
                     41: 
                     42: define("IMAGE_admin_delete", (file_exists(THEME."forum/admin_delete.png") ? "src='".THEME."forum/admin_delete.png' alt='".LAN_407."' title='".LAN_407."' style='border:0' " : " src='".e_IMAGE."forum/admin_delete.png' alt='".LAN_407."' title='".LAN_407."' style='border:0' "));
                     43: 
                     44: 
                     45: if(!e_QUERY){
                     46:        header("Location:".e_BASE."forum.php");
                     47:        exit;
                     48: }else{
                     49:        $tmp = explode(".", e_QUERY);
                     50:        $forum_id = $tmp[0]; $thread_id = $tmp[1]; $from = $tmp[2]; $action = $tmp[3];
                     51:        if(!$from){ $from = 0; }
                     52:        if(!$thread_id || !is_numeric($thread_id)){
                     53:                header("Location:".e_BASE."forum.php");
                     54:                exit;
                     55:        }
                     56: }
                     57: $sql -> db_Select("forum_t", "*", "thread_id='".$thread_id."'  LIMIT 1 ");
                     58:        $row = $sql-> db_Fetch(); extract($row);
                     59:        if($thread_forum_id != $forum_id){
                     60:                header("Location:".e_BASE."forum.php");
                     61:                exit;
                     62:        }
                     63: 
                     64: if($action == "track" && USER){
                     65:        $sql -> db_Update("user", "user_realm='".USERREALM."-".$thread_id."-' WHERE user_id='".USERID."' ");
                     66:        header("location:".e_SELF."?".$forum_id.".".$thread_id);
                     67:        exit;
                     68: }
                     69: 
                     70: if($action == "untrack" && USER){
                     71:        $tmp = ereg_replace("-".$thread_id."-", "", USERREALM);
                     72:        $sql -> db_Update("user", "user_realm='$tmp' WHERE user_id='".USERID."' ");
                     73:        header("location:".e_SELF."?".$forum_id.".".$thread_id);
                     74:        exit;
                     75: }
                     76: if($action == "report"){
                     77:        $aj = new textparse();
                     78:        if(IsSet($_POST['report_thread'])){     
                     79:                $user = $_POST['user'];$report_thread_id = $_POST['report_thread_id'];$report_thread_name = $_POST['report_thread_name'];
                     80:                if($pref['reported_post_email']){
                     81:                        require_once(e_HANDLER."mail.php");
                     82:                        $report_add = $aj -> tpa($_POST['report_add']);
                     83:                        $report = LAN_422.SITENAME." : ".(substr(SITEURL, -1) == "/" ? SITEURL : SITEURL."/")."forum_viewtopic.php?".$forum_id.".".$report_thread_id."#".$thread_id."\n".LAN_425.$user."\n".$report_add;
                     84:                        $subject = LAN_421." ".SITENAME;
                     85:                        sendemail(SITEADMINEMAIL, $subject, $report);
                     86:                }
                     87:                $reported_post = $forum_id."^".$report_thread_id."^".$thread_id."^".$report_thread_name."^".$user;
                     88:                $sql -> db_Insert("tmp", "'reported_post', '".time()."', '$reported_post' ");
                     89:         define("e_PAGETITLE", LAN_01." / ".LAN_428);
                     90:                require_once(HEADERF);  
                     91:                $text = LAN_424."<br /><a href='forum_viewtopic.php?".$forum_id.".".$report_thread_id."#".$thread_id."'>".LAN_429."</a";
                     92:                $ns -> tablerender(LAN_414, $text);
                     93:        }else{
                     94:                $number = $thread_id;
                     95:                $sql -> db_Select("forum_t", "*", "thread_id='".$thread_id."' ");
                     96:                $row = $sql -> db_Fetch();
                     97:                if($row['thread_parent']){
                     98:                        $sql2 = new db;
                     99:                        $sql2 -> db_Select("forum_t", "*", "thread_id = $thread_parent");
                    100:                        list($thread_id, $thread_name) = $sql2 -> db_Fetch();
                    101:                }else{
                    102:                        $thread_name = $row['thread_name'];
                    103:                }
                    104:                $report_thread_id = $thread_id;
                    105:                define("e_PAGETITLE", LAN_01." / ".LAN_426." ".$thread_name);
                    106:                require_once(HEADERF);  
                    107:                $user = (USER ? USERNAME : LAN_194);
                    108:                $text = "<form action='".e_BASE."forum_viewtopic.php?".e_QUERY."' method='post'> <table style='width:100%'>
                    109:                <tr>
                    110:                <td  style='width:50%' >
                    111:                ".LAN_415.": ".$thread_name." <a href='forum_viewtopic.php?".$forum_id.".".$thread_id."#".$number."'><span class='smalltext'>".LAN_420." </span>
                    112:                </a>
                    113:                </td>
                    114:                <td style='text-align:center;width:50%'>
                    115:                </td>
                    116:                </tr>
                    117:                <tr>
                    118:                <td>".LAN_417."<br />".LAN_418."
                    119:                </td>
                    120:                <td style='text-align:center;'>
                    121:                <textarea cols='40' rows='10' class='tbox' name='report_add'></textarea>
                    122:                </td>
                    123:                </tr>
                    124:                <tr>
                    125:                <td colspan='2' style='text-align:center;'><br />
                    126:                <input type ='hidden' name='user' value='$user' />
                    127:                <input type ='hidden' name='report_thread_id' value='$report_thread_id' />
                    128:                <input type ='hidden' name='report_thread_name' value='$thread_name' />
                    129:                <input class='button' type='submit' name='report_thread' value='".LAN_419."' />
                    130:                </td>
                    131:                </tr>
                    132:                </table>";
                    133:                $ns -> tablerender(LAN_414, $text);
                    134:        }
                    135: 
                    136:        require_once(FOOTERF);
                    137:        exit;
                    138: }
                    139: $pm_installed = ($pref['pm_title'] ? TRUE : FALSE);
                    140: 
                    141: $gen = new convert;
                    142: $aj = new textparse();
                    143: 
                    144: $sql -> db_Update("forum_t", "thread_views=thread_views+1 WHERE thread_id='$thread_id' ");
                    145: 
                    146: $sql -> db_Select("forum", "*", "forum_id='".$forum_id."' ");
                    147: $row = $sql-> db_Fetch(); extract($row);
                    148: $fname = $row['forum_name'];
                    149: 
                    150: if(($forum_class && !check_class($forum_class)) || ($forum_class == 254 && !USER)){ header("Location:".e_BASE."forum.php"); exit;}
                    151: 
                    152: $sql -> db_Select("forum_t", "*", "thread_id='".$thread_id."' ORDER BY thread_datestamp DESC ");
                    153: $row = $sql-> db_Fetch("no_strip"); extract($row);
                    154: define("e_PAGETITLE", LAN_01." / ".$fname." / ".$row['thread_name']);
                    155: 
                    156: define("MODERATOR", (preg_match("/".preg_quote(ADMINNAME)."/", $forum_moderators) && getperms("A") ? TRUE : FALSE));
                    157: $message="";
                    158: if(MODERATOR)
                    159: {
                    160:        if($_POST)
                    161:        {
                    162:                require_once(e_HANDLER."forum_mod.php");
                    163:                $message = forum_thread_moderate($_POST);
                    164:        }
                    165: }
                    166: 
                    167: require_once(HEADERF);
                    168: require_once(e_HANDLER."level_handler.php");
                    169: if($message)
                    170: {
                    171:        $ns -> tablerender("",$message);
                    172: }
                    173: 
                    174: If(IsSet($_POST['pollvote'])){
                    175:        $sql -> db_Select("poll", "poll_active, poll_ip", "poll_id='".$_POST['pollid']."' ");
                    176:        $row = $sql -> db_Fetch(); extract($row);
                    177:        $user_id = ($poll_active == 9 ? getip() : USERID);
                    178:        if(!preg_match("/".$user_id."\^/", $poll_ip)){
                    179:                if($_POST['votea']){
                    180:                        $num = "poll_votes_".$_POST['votea'];
                    181:                        $sql -> db_Update("poll", "$num=$num+1, poll_ip='".$poll_ip.$user_id."^' WHERE poll_id='".$_POST['pollid']."' ");
                    182:                }
                    183:        }
                    184: }
                    185: 
                    186: if(eregi("\[".LAN_430."\]", $thread_name)){
                    187:        if($sql -> db_Select("poll", "*", "poll_datestamp='$thread_id' ")){
                    188:                list($poll_id, $poll_datestamp, $poll_end_datestamp, $poll_admin_id, $poll_title, $poll_option[0], $poll_option[1], $poll_option[2], $poll_option[3], $poll_option[4], $poll_option[5], $poll_option[6], $poll_option[7], $poll_option[8], $poll_option[9], $votes[0], $votes[1], $votes[2], $votes[3], $votes[4], $votes[5], $votes[6], $votes[7], $votes[8], $votes[9], $poll_ip, $poll_active) = $sql-> db_Fetch();
                    189: 
                    190:                $user_id = ($poll_active == 9 ? getip() : USERID);
                    191:                if(preg_match("/".$user_id."\^/", $poll_ip)){
                    192:                        $mode = "voted";
                    193:                }else if($poll_active == 2 && !USER){
                    194:                        $mode = "disallowed";
                    195:                }else{
                    196:                        $mode = "notvoted";
                    197:                }
                    198:                require_once(e_HANDLER."poll_class.php");
                    199:                $poll = new poll;
                    200:                $pollstr = "<div class='spacer'>".$poll -> render_poll($poll_id, $poll_title, $poll_option, $votes, $mode, "forum")."</div>";
                    201:        }
                    202: }
                    203: 
                    204: 
                    205: 
                    206: 
                    207: $sql -> db_Select("forum_t", "thread_id",  "thread_forum_id='".$forum_id."' AND thread_parent='0' ORDER BY thread_s ASC, thread_lastpost ASC, thread_datestamp ASC");
                    208: $c = 0;
                    209: while($row = $sql -> db_Fetch()){
                    210:        $array[$c] = $row['thread_id'];
                    211:        if($row['thread_id'] == $thread_id){
                    212:                $prevthread = $array[$c-1];
                    213:                $row = $sql -> db_Fetch();
                    214:                $nextthread = $row['thread_id'];
                    215:                break;
                    216:        }
                    217:        $c++;
                    218: }
                    219: 
                    220: if(!$FORUMSTART){
                    221:        if(file_exists(THEME."forum_viewtopic_template.php")){
                    222:     require_once(THEME."forum_viewtopic_template.php");
                    223:   }
                    224:        else{
                    225:     require_once(e_BASE.$THEMES_DIRECTORY."templates/forum_viewtopic_template.php");
                    226:   }
                    227: }
                    228: 
                    229: // get info for main thread -------------------------------------------------------------------------------------------------------------------------------------------------------------------
                    230: 
                    231: $thread_name = $aj -> tpa($thread_name);
                    232: 
                    233: $BREADCRUMB = "<a class='forumlink' href='".e_BASE."index.php'>".SITENAME."</a> -> <a class='forumlink' href='forum.php'>".LAN_01."</a> -> <a class='forumlink' href='forum_viewforum.php?".$forum_id."'>".$forum_name."</a> -> ".$thread_name;
                    234: 
                    235: $BACKLINK = "<a class='forumlink' href='".e_BASE."index.php'>".SITENAME."</a> -> <a class='forumlink' href='forum.php'>".LAN_01."</a> -> <a class='forumlink' href='forum_viewforum.php?".$forum_id."'>".$forum_name."</a>";
                    236: 
                    237: $THREADNAME = $thread_name;
                    238: 
                    239: $NEXTPREV = ($prevthread ? "&lt;&lt; <a href='".e_SELF."?".$forum_id.".".$prevthread."'>".LAN_389."</a> " : LAN_404." ")."|".($nextthread ? " <a href='".e_SELF."?".$forum_id.".".$nextthread."'>".LAN_390."</a> &gt;&gt;" : " ".LAN_405." ");
                    240: 
                    241: if($pref['forum_track'] && USER){
                    242:        $TRACK = (preg_match("/-".$thread_id."-/", USERREALM) ? "<span class='smalltext'><a href='".e_SELF."?".$forum_id.".".$thread_id.".0."."untrack'>".LAN_392."</a></span>" : "<span class='smalltext'><a href='".e_SELF."?".$forum_id.".".$thread_id.".0."."track'>".LAN_391."</a></span>");
                    243: }
                    244: 
                    245: $MODERATORS = LAN_321.$forum_moderators;
                    246: $THREADSTATUS = (!$thread_active ? LAN_66 : "");
                    247: 
                    248: $replies = $sql -> db_Count("forum_t", "(*)", "WHERE thread_parent='".$thread_id."'");
                    249: $pref['forum_postspage'] = ($pref['forum_postspage'] ? $pref['forum_postspage'] : 10);
                    250: $pages = ceil($replies/$pref['forum_postspage']);
                    251: if($pages>1){
                    252:        $currentpage = ($from/$pref['forum_postspage'])+1;
                    253:        $prevpage = $from - $pref['forum_postspage'];
                    254:        $nextpage = $from + $pref['forum_postspage'];
                    255:        $GOTOPAGES = LAN_02." ".($currentpage > 1 ? " <a href='forum_viewtopic.php?".$forum_id.".".$thread_id.".".$prevpage."'>".LAN_04."</a> " : "");
                    256:        for($a=0; $a<=($pages-1); $a++){
                    257:                $GOTOPAGES .= (($a+1) == $currentpage ? "-".($a+1) : "-<a href='forum_viewtopic.php?".$forum_id.".".$thread_id.".".($a*$pref['forum_postspage'])."'>".($a+1)."</a>");
                    258:        }
                    259:        $GOTOPAGES .= ($nextpage < $replies ? " <a href='forum_viewtopic.php?".$forum_id.".".$thread_id.".".$nextpage."'>".LAN_05."</a> " : "");
                    260: }
                    261: 
                    262: if((ANON || USER) && ($forum_class != e_UC_READONLY || MODERATOR)){
                    263:        if($thread_active){
                    264:                $BUTTONS = "<a href='forum_post.php?rp.".e_QUERY."'>".IMAGE_reply."</a>";
                    265:        }
                    266:        $BUTTONS .= "<a href='forum_post.php?nt.".$forum_id."'>".IMAGE_newthread."</a>";
                    267: }
                    268: 
                    269: $post_author_id = substr($thread_user, 0, strpos($thread_user, "."));
                    270: $post_author_name = substr($thread_user, (strpos($thread_user, ".")+1));
                    271: if(strstr($post_author_name, chr(1))){
                    272:        $tmp = explode(chr(1), $post_author_name);
                    273:        $post_author_name = $tmp[0];
                    274:        $ip = $tmp[1];
                    275:        $host = gethostbyaddr($ip);
                    276:        $iphost = "<div class='smalltext' style='text-align:right'>IP: <a href='".e_ADMIN."userinfo.php?$ip'>$ip ( $host )</a></div>";
                    277: }
                    278: 
                    279: if(!$post_author_id || !$sql -> db_Select("user", "*", "user_id='".$post_author_id."' ")){     // guest
                    280:        $POSTER = "<b>".$post_author_name."</b>";
                    281:        $AVATAR = "<br /><span class='smallblacktext'>".LAN_194."</span>";
                    282: }else{ // regged member - get member info
                    283:        unset($iphost);
                    284:        $row = $sql -> db_Fetch(); extract($row);
                    285:        $POSTER = "<a href='user.php?id.".$post_author_id."'><b>".$post_author_name."</b></a>";
                    286:        if($user_image){
                    287:                require_once(e_HANDLER."avatar_handler.php");
                    288:                $AVATAR = "<div class='spacer'><img src='".avatar($user_image)."' alt='' /></div><br />";
                    289:        }else{
                    290:                unset($AVATAR);
                    291:        }
                    292:        
                    293:        $JOINED = ($user_perms == "0" ? "" : LAN_06." ".$gen->convert_date($user_join, "forum")."<br />");
                    294:        $LOCATION = ($user_location ? LAN_07.": ".$user_location."<br />" : "");
                    295:        $CUSTOMTITLE = ($user_customtitle ? $aj -> tpa($user_customtitle)."<br />" : "");
                    296:        $WEBSITE = ($user_homepage ? LAN_08.": ".$user_homepage."<br />" : "");
                    297:        $POSTS = LAN_67." ".$user_forums."<br />";
                    298:        $VISITS = LAN_09.": ".$user_visits;
                    299: 
                    300:        $ldata = get_level($user_id, $user_forums, $user_comments, $user_chats, $user_visits, $user_join, $user_admin, $user_perms, $pref);
                    301:        $MEMBERID = $ldata[0];
                    302:        $LEVEL = $ldata[1];
                    303: 
                    304:        $SIGNATURE = ($user_signature ? "<br /><hr style='width:15%; text-align:left'><span class='smalltext'>".$aj -> tpa($user_signature) : "");
                    305:        
                    306:        $PROFILEIMG = (USER ? kCMS_parse("{CODE=CORE.profile.{$user_id}}","admin") : "");
                    307:        $EMAILIMG = (!$user_hideemail ? kCMS_parse("{CODE=CORE.emailto.{$user_email}}","admin") : "");
                    308: 
                    309:        $PRIVMESSAGE = kCMS_parse("{CODE=pm_menu.sendpm.{$post_author_id}}");
                    310: 
                    311:        $WEBSITEIMG = ($user_homepage && $user_homepage != "http://" ? "<a href='$user_homepage'>".IMAGE_website."</a>" : "");
                    312:        $RPG = rpg($user_join, $user_forums);
                    313:        
                    314: }
                    315: 
                    316: $EDITIMG = ($post_author_id != "0" && $post_author_name == USERNAME && $thread_active ? "<a href='forum_post.php?edit.".$forum_id.".".$thread_id."'>".IMAGE_edit."</a> " : "");
                    317: if($thread_active){
                    318:        $QUOTEIMG = "<a href='forum_post.php?quote.".$forum_id.".".$thread_id."'>".IMAGE_quote."</a>";
                    319: }else{
                    320:        $T_ACTIVE = TRUE;
                    321: }
                    322: $REPORTIMG = (USER ? "<a href='forum_viewtopic.php?".$forum_id.".".$thread_id.".".$from.".report'>".IMAGE_report."</a> " : "");
                    323: if(MODERATOR){
                    324:        $MODOPTIONS = "
                    325:                <form method='post' action='".e_HTTP."forum_viewforum.php?{$forum_id}' id='frmMod_{$forum_id}_{$thread_id}'>
                    326:                <div>
                    327:                <a href='forum_post.php?edit.".$forum_id.".".$thread_id."'>".IMAGE_admin_edit."</a>
                    328:                <input type='image' ".IMAGE_admin_delete." name='delete_{$thread_id}' value='thread_action' onclick=\"return confirm_('thread', $forum_id, $thread_id, '')\" />
                    329:                <a href='".e_ADMIN."forum_conf.php?move.".$forum_id.".".$thread_id."'>".IMAGE_admin_move."</a>
                    330:                </div>
                    331:                </form>";
                    332: }
                    333: //     $MODOPTIONS .= "<a style='cursor:pointer; cursor:hand' onclick=\"confirm_('thread', $forum_id, $thread_id, '')\"'>".IMAGE_admin_delete."</a>\n";
                    334: 
                    335: unset($newflag);
                    336: if(USER){
                    337:        if($thread_datestamp > USERLV && (!ereg("\.".$thread_id."\.", USERVIEWED))){
                    338:                $NEWFLAG = IMAGE_new." ";
                    339:                $u_new = ".".$thread_id.".";
                    340:        }
                    341: }
                    342: 
                    343: $THREADDATESTAMP = "<a id='$thread_id'>".IMAGE_post."</a> ".$gen->convert_date($thread_datestamp, "forum");
                    344: $POST = $aj -> tpa($thread_thread, "forum", "off", $highlight_search,$post_author_id);
                    345: if(ADMIN && $iphost){ $POST .= "<br />".$iphost; }
                    346: $TOP = "<a href='".e_SELF."?".e_QUERY."#top'>".LAN_10."</a>";
                    347: $FORUMJUMP = forumjump();
                    348: 
                    349: $forstr = preg_replace("/\{(.*?)\}/e", '$\1', $FORUMSTART);
                    350: $forthr = preg_replace("/\{(.*?)\}/e", '$\1', $FORUMTHREADSTYLE);
                    351: 
                    352: // end thread parse -------------------------------------------------------------------------------------------------------------------------------------------------------------------
                    353: // begine reply parse -------------------------------------------------------------------------------------------------------------------------------------------------------------------
                    354: 
                    355: unset($forrep);
                    356: if(!$FORUMREPLYSTYLE) $FORUMREPLYSTYLE = $FORUMTHREADSTYLE;
                    357: 
                    358: if($sql -> db_Select("forum_t", "*", "thread_parent='".$thread_id."' ORDER BY thread_datestamp ASC LIMIT ".$from.", ".$pref['forum_postspage'])){
                    359:        $sql2 = new db;
                    360:        while($row = $sql-> db_Fetch()){
                    361:                extract($row);
                    362:                $post_author_id = substr($thread_user, 0, strpos($thread_user, "."));
                    363:                $post_author_name = substr($thread_user, (strpos($thread_user, ".")+1));
                    364:                if(strstr($post_author_name, chr(1))){
                    365:                        $tmp = explode(chr(1), $post_author_name);
                    366:                        $post_author_name = $tmp[0];
                    367:                        $ip = $tmp[1];
                    368:                        $host = gethostbyaddr($ip);
                    369:                        $iphost = "<div class='smalltext' style='text-align:right'>IP: <a href='".e_ADMIN."userinfo.php?$ip'>$ip ( $host )</a></div>";
                    370:                }
                    371:                //$post_author_count = $sql -> db_Count("forum_t", "(*)", " WHERE thread_user='$thread_user' OR thread_user='$post_author_name' ");
                    372: 
                    373:                if(!$post_author_id || !$sql2 -> db_Select("user", "*", "user_id='".$post_author_id."' ")){     // guest
                    374:                        $POSTER = "<b>".$post_author_name."</b>";
                    375:                        $AVATAR = "<br /><span class='smallblacktext'>".LAN_194."</span>";
                    376:                        unset($JOINED, $LOCATION, $CUSTOMTITLE, $WEBSITE, $POSTS, $VISITS, $MEMBERID, $SIGNATURE, $RPG, $LEVEL, $PRIVMESSAGE, $PROFILEIMG, $EMAILIMG, $WEBSITEIMG);
                    377:                }else{  // regged member - get member info
                    378:                        unset($iphost);
                    379:                        
                    380:                        $row = $sql2 -> db_Fetch(); extract($row);
                    381:                        $POSTER =  "<a href='user.php?id.".$post_author_id."'><b>".$post_author_name."</b></a>";
                    382:                        if($user_image){
                    383:                                require_once(e_HANDLER."avatar_handler.php");
                    384:                                $AVATAR = "<div class='spacer'><img src='".avatar($user_image)."' alt='' /></div><br />";
                    385:                        }else{
                    386:                                unset($AVATAR);
                    387:                        }
                    388:                        
                    389:                        $JOINED = ($user_perms == "0" ? "" : LAN_06.": ".$gen->convert_date($user_join, "forum")."<br />");
                    390:                        $LOCATION = ($user_location ? LAN_07.": ".$user_location."<br />" : "");
                    391:                        $CUSTOMTITLE = ($user_customtitle ? $aj -> tpa($user_customtitle)."<br />" : "");
                    392:                        $WEBSITE = ($user_homepage ? LAN_08.": ".$user_homepage."<br />" : "");
                    393:                        $POSTS = LAN_67." ".$user_forums."<br />";
                    394:                        $VISITS = LAN_09.": ".$user_visits;
                    395:                        
                    396:                        $ldata = get_level($user_id, $user_forums, $user_comments, $user_chats, $user_visits, $user_join, $user_admin, $user_perms, $pref);
                    397:                        $MEMBERID = $ldata[0];
                    398:                        $LEVEL = $ldata[1];
                    399: 
                    400:                        $SIGNATURE = ($user_signature ? "<br /><hr style='width:15%; text-align:left'><span class='smalltext'>".$aj -> tpa($user_signature) : "");
                    401:                        $PROFILEIMG = (USER ? kCMS_parse("{CODE=CORE.profile.{$user_id}}","admin") : "");
                    402:                        $EMAILIMG = (!$user_hideemail ? kCMS_parse("{CODE=CORE.emailto.{$user_email}}","admin") : "");
                    403: 
                    404:                        $PRIVMESSAGE = kCMS_parse("{CODE=pm_menu.sendpm.{$post_author_id}}");
                    405: 
                    406:                        $WEBSITEIMG = ($user_homepage && $user_homepage != "http://" ? "<a href='$user_homepage'>".IMAGE_website."</a>" : "");
                    407:                        $RPG = rpg($user_join, $user_forums);
                    408:                        
                    409:                }
                    410:                $EDITIMG = ($post_author_id != "0" && $post_author_name == USERNAME && $thread_active ? "<a href='forum_post.php?edit.".$forum_id.".".$thread_id."'>".IMAGE_edit."</a> " : "");
                    411:                if(!$T_ACTIVE){
                    412:                        $QUOTEIMG = "<a href='forum_post.php?quote.".$forum_id.".".$thread_id."'>".IMAGE_quote."</a>";
                    413:                }
                    414:                $REPORTIMG = (USER ? "<a href='forum_viewtopic.php?".$forum_id.".".$thread_id.".".$from.".report'>".IMAGE_report."</a> " : "");
                    415:                if(MODERATOR){
                    416: 
                    417:        $MODOPTIONS = "
                    418:                <form method='post' action='".e_HTTP."forum_viewtopic.php?{$forum_id}.{$thread_parent}' id='frmMod_{$forum_id}_{$thread_id}'>
                    419:                <div>
                    420:                <a href='forum_post.php?edit.".$forum_id.".".$thread_id."'>".IMAGE_admin_edit."</a>
                    421:                <input type='image' ".IMAGE_admin_delete." name='delete_{$thread_id}' value='thread_action' onclick=\"return confirm_('reply', $forum_id, $thread_id, '{$post_author_name}')\" />
                    422:                <a href='".e_ADMIN."forum_conf.php?move.".$forum_id.".".$thread_id."'>".IMAGE_admin_move."</a>
                    423:                </div>
                    424:                </form>";
                    425: }
                    426: 
                    427:                unset($newflag);
                    428:                if(USER){
                    429:                        if($thread_datestamp > USERLV && (!ereg("\.".$thread_id."\.", USERVIEWED))){
                    430:                                $NEWFLAG = IMAGE_new." ";
                    431:                                $u_new .= ".".$thread_id.".";
                    432:                        }
                    433:                }
                    434: 
                    435:                $THREADDATESTAMP = "<a id='$thread_id'>".IMAGE_post."</a> ".$gen->convert_date($thread_datestamp, "forum");
                    436:                $POST = $aj -> tpa($thread_thread, "forum", "off", $highlight_search,$post_author_id);
                    437:                if(ADMIN && $iphost){ $POST .= "<br />".$iphost; }
                    438: 
                    439:                $forrep .= preg_replace("/\{(.*?)\}/e", '$\1', $FORUMREPLYSTYLE);
                    440:        }
                    441: }
                    442: 
                    443: if((ANON || USER) && ($forum_class != e_UC_READONLY || MODERATOR) && !$T_ACTIVE ){
                    444:        $QUICKREPLY = "<form action='".e_BASE."forum_post.php?rp.".e_QUERY."' method='post'>\n<p>\n".LAN_393.":<br /><textarea cols='60' rows='4' class='tbox' name='post'></textarea><br /><input type='submit' name='fpreview' value='".LAN_394."' class='button' /> &nbsp;\n<input type='submit' name='reply' value='".LAN_395."' class='button' />\n<input type='hidden' name='thread_id' value='$thread_parent' />\n</p>\n</form>";
                    445: }
                    446: 
                    447: $forend = preg_replace("/\{(.*?)\}/e", '$\1', $FORUMEND);
                    448: $forumstring = (!$from ? $pollstr.$forstr.$forthr.$forrep.$forend : $pollstr.$forstr.$forrep.$forend);
                    449: if($pref['forum_enclose']){ $ns -> tablerender(LAN_01, $forumstring); }else{ echo $forumstring; }
                    450: 
                    451: $u_new = USERVIEWED . $u_new;
                    452: if($u_new != ""){ $sql -> db_Update("user", "user_viewed='$u_new' WHERE user_id='".USERID."' "); }
                    453: 
                    454: // end -------------------------------------------------------------------------------------------------------------------------------------------------------------------
                    455: 
                    456: function forumjump(){
                    457:        global $sql;
                    458:        $sql -> db_Select("forum", "*", "forum_parent !=0 AND forum_class!='255' ");
                    459:        $text .= "<form method='post' action='".e_SELF."'><p>".LAN_65.": <select name='forumjump' class='tbox'>";
                    460:        while($row = $sql -> db_Fetch()){
                    461:                extract($row);
                    462:                if(($forum_class && check_class($forum_class)) || ($forum_class == 254 && USER) || !$forum_class){
                    463:                        $text .= "\n<option value='".$forum_id."'>".$forum_name."</option>";
                    464:                }
                    465:        }
                    466:        $text .= "</select> <input class='button' type='submit' name='fjsubmit' value='".LAN_03."' />&nbsp;&nbsp;&nbsp;&nbsp;<a href='".e_SELF."?".$_SERVER['QUERY_STRING']."#top'>".LAN_10."</a></p></form>";
                    467:        return $text;
                    468: }
                    469: 
                    470: function rpg($user_join, $user_forums){
                    471:        // rpg mod by Ikari ( kilokan1@yahoo.it | http://artemanga.altervista.org )
                    472: 
                    473:        $lvl_post_mp_cost = 2.5;
                    474:        $lvl_mp_regen_per_day = 4;
                    475:        $lvl_avg_ppd = 5;
                    476:        $lvl_bonus_redux = 5;
                    477:        $lvl_user_days = max(1, round( ( time() - $user_join ) / 86400 ));
                    478:        $lvl_ppd = $user_forums / $lvl_user_days;
                    479:        if($user_forums < 1){
                    480:                $lvl_level = 0;
                    481:        }else{
                    482:                $lvl_level = floor( pow( log10( $user_forums ), 3 ) ) + 1;
                    483:        }
                    484:        if($lvl_level < 1){
                    485:                $lvl_hp = "0 / 0";
                    486:                $lvl_hp_percent = 0;
                    487:        }else{
                    488:                $lvl_max_hp = floor( (pow( $lvl_level, (1/4) ) ) * (pow( 10, pow( $lvl_level+2, (1/3) ) ) ) / (1.5) );
                    489:                                        
                    490:                if($lvl_ppd >= $lvl_avg_ppd){
                    491:                        $lvl_hp_percent = floor( (.5 + (($lvl_ppd - $lvl_avg_ppd) / ($lvl_bonus_redux * 2)) ) * 100);
                    492:                }else{
                    493:                        $lvl_hp_percent = floor( $lvl_ppd / ($lvl_avg_ppd / 50) );
                    494:                }
                    495:                if($lvl_hp_percent > 100){
                    496:                        $lvl_max_hp += floor( ($lvl_hp_percent - 100) * pi() );
                    497:                        $lvl_hp_percent = 100;
                    498:                }else{
                    499:                        $lvl_hp_percent = max(0, $lvl_hp_percent);
                    500:                }
                    501:                $lvl_cur_hp = floor($lvl_max_hp * ($lvl_hp_percent / 100) );
                    502:                $lvl_cur_hp = max(0, $lvl_cur_hp);
                    503:                $lvl_cur_hp = min($lvl_max_hp, $lvl_cur_hp);
                    504:                $lvl_hp = $lvl_cur_hp . '/' . $lvl_max_hp;
                    505:        }
                    506:        if($lvl_level < 1){
                    507:                $lvl_mp = '0 / 0';
                    508:                $lvl_mp_percent = 0;
                    509:        }else{
                    510:                $lvl_max_mp = floor( (pow( $lvl_level, (1/4) ) ) * (pow( 10, pow( $lvl_level+2, (1/3) ) ) ) / (pi()) );
                    511:                $lvl_mp_cost = $user_forums * $lvl_post_mp_cost;
                    512:                $lvl_mp_regen = max(1, $lvl_user_days * $lvl_mp_regen_per_day);
                    513:                $lvl_cur_mp = floor($lvl_max_mp - $lvl_mp_cost + $lvl_mp_regen);
                    514:                $lvl_cur_mp = max(0, $lvl_cur_mp);
                    515:                $lvl_cur_mp = min($lvl_max_mp, $lvl_cur_mp);
                    516:                $lvl_mp = $lvl_cur_mp . '/' . $lvl_max_mp;
                    517:                $lvl_mp_percent = floor($lvl_cur_mp / $lvl_max_mp * 100 );
                    518:        }
                    519:        if($lvl_level < 1){
                    520:                $lvl_exp = "0 / 0";
                    521:                $lvl_exp_percent = 100;
                    522:        }else{
                    523:                $lvl_posts_for_next = floor( pow( 10, pow( $lvl_level, (1/3) ) ) );
                    524:                if ($lvl_level == 1){ 
                    525:                        $lvl_posts_for_this = max(1, floor(pow (10, ( ($lvl_level - 1) ) ) ) ); 
                    526:                }else{ 
                    527:                        $lvl_posts_for_this = max(1, floor(pow (10, pow( ($lvl_level - 1), (1/3) ) ) ) ); 
                    528:                }
                    529:                $lvl_exp = ($user_forums - $lvl_posts_for_this) . "/" . ($lvl_posts_for_next - $lvl_posts_for_this);
                    530:                $lvl_exp_percent = floor( ( ($user_forums - $lvl_posts_for_this) / max( 1, ($lvl_posts_for_next - $lvl_posts_for_this ) ) ) * 100);
                    531:        }
                    532:        $rpg_info .= "<div style='padding:2px;'>";
                    533:        $rpg_info .= "<b>Level = ".$lvl_level."</b><br />";
                    534:        $rpg_info .= "HP = ".$lvl_hp."<br /><img src='".THEME."images/bar.jpg' height='10' alt='' style='border:#345487 1px solid; width:".$lvl_hp_percent."'><br />";
                    535:        $rpg_info .= "EXP = ".$lvl_exp."<br /><img src='".THEME."images/bar.jpg' height='10' alt='' style='border:#345487 1px solid; width:".$lvl_exp_percent."'><br />";
                    536:        $rpg_info .= "MP = ".$lvl_mp."<br /><img src='".THEME."images/bar.jpg' height='10' alt='' style='border:#345487 1px solid; width:".$lvl_mp_percent."'><br />";
                    537:        $rpg_info .= "</div>";
                    538:        return $rpg_info;
                    539: }
                    540: 
                    541: echo "<script type=\"text/javascript\">
                    542: function confirm_(mode, forum_id, thread_id, thread){
                    543:        if(mode == 'thread'){
                    544:                return confirm(\"".$etp->unentity(LAN_409)."\");
                    545:        }else{
                    546:                return confirm(\"".$etp->unentity(LAN_410)." [ ".$etp->unentity(LAN_411)."\" + thread + \" ]\");
                    547:        }
                    548: }
                    549: </script>";
                    550: 
                    551: require_once(FOOTERF);
                    552: 
                    553: ?>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>