3) { $sql = "SELECT COUNT(tid) FROM ".$GLOBALS['DBprefix']."Subscription WHERE uid=".$GLOBALS['inuserid']." AND fid=".$GLOBALS['forum']." AND tid=4294967294"; $res = db_query($sql,$link); list($inforum)=db_fetch_row($res); db_free_result($res); $sql = "SELECT COUNT(tid) FROM ".$GLOBALS['DBprefix']."Subscription WHERE uid=".$GLOBALS['inuserid']." AND fid=".$GLOBALS['forum']." AND tid=4294967295"; $res = db_query($sql,$link); list($autosub)=db_fetch_row($res); db_free_result($res); } if (!$order) { $order="tl_lasttime"; $direct=" DESC"; } if (getvar("desc")) $direct=" DESC"; if ($time && $time!="0") $timelimit=$time*24*60*60; else $timelimit=$GLOBALS['curtime']; $timeexpr="AND tl_lasttime>=".($GLOBALS['curtime']-$timelimit); if ($start!="all") $limit = " LIMIT $start,".($perpage); $sql = "SELECT t.*,p1.p_uname, p1.p_uid, p1.p__time, p2.p_uname AS lp_uname, p2.p_uid AS lp_uid, p2.p__time AS lp__time, tl.*, pl_tid, AVG(tr.tr_value) AS trating, COUNT(tv.tid) AS visited ". "FROM ".$GLOBALS['DBprefix']."Topic t, ".$GLOBALS['DBprefix']."Post p1, ".$GLOBALS['DBprefix']."Post p2, tmpTopics tl ". "LEFT JOIN ".$GLOBALS['DBprefix']."TopicRate tr ON (tr.tid=t.t_id) ". "LEFT JOIN ".$GLOBALS['DBprefix']."TopicView tv ON (tv.tid=t.t_id AND tv.uid=".$GLOBALS['inuserid'].") ". "LEFT JOIN ".$GLOBALS['DBprefix']."Poll pl ON (pl.pl_tid=t.t_id) ". "WHERE t.t_fid=$forum AND t.t_id=tl.tl_tid AND p1.p_id=tl.tl_pmin AND p2.p_id=tl.tl_pmax ". "$timeexpr ". "GROUP BY p1.p_id ORDER BY t__sticky DESC,$order".$direct.$limit; $res = db_query($sql,$link); std_forum_start($pages,$perpage,$filter,$time); $sql = "DROP TABLE tmpTopics"; $res2 = db_query($sql,$link); $counter=0; if ($start=="all") $perpage=$tcount; while (($tdata=db_fetch_array($res))) { $tpages = build_pages($tdata['tl_count'],-1,$GLOBALS['inuser']['u_mperpage'],"index.php?f=$forum&t=".$tdata['t_id']); std_topic_entry($tdata,$tpages); } if (db_num_rows($res)==0) std_forum_noentries(); std_forum_end($pages,$inforum,$autosub); } function view_topic() { if ($GLOBALS['inuserlevel']<$GLOBALS['inforum']['f_lread']) error(MSG_e_f_norightsread); $forum=$GLOBALS['forum']; $topic=$GLOBALS['topic']; $link=$GLOBALS['link']; $sql = "SELECT COUNT(p_id) FROM ".$GLOBALS['DBprefix']."Post WHERE p_tid=$topic AND p__premoderate=0 GROUP BY p_tid"; $res = db_query($sql,$link); $pcount = db_fetch_row($res); db_free_result($res); $sql = "SELECT MAX(t_id) FROM ".$GLOBALS['DBprefix']."Topic WHERE t_id<".$GLOBALS['topic']." AND t_fid=".$GLOBALS['forum']; $res = db_query($sql,$link); list($prev_tid)=db_fetch_row($res); db_free_result($res); $sql = "SELECT MIN(t_id) FROM ".$GLOBALS['DBprefix']."Topic WHERE t_id>".$GLOBALS['topic']." AND t_fid=".$GLOBALS['forum']; $res = db_query($sql,$link); list($next_tid)=db_fetch_row($res); db_free_result($res); $rated=common_topic_view($topic); if (getvar("o")=="1") $sort=1; elseif (getvar("o")=="0") $sort=0; else $sort=$GLOBALS['inuser']['u_sortposts']; if ($sort==1) $order="DESC"; if (!isset($_GET['st']) && !isset($_GET['p']) && $pcount[0]>$GLOBALS['inuser']['u_mperpage']) { $start="0"; if ($GLOBALS['inuserid']>3 && $GLOBALS['userlast2'] && $pcount[0]>$GLOBALS['u_mperpage'] && $GLOBALS['inuser']['u_sortposts']==0) { $start=$pcount[0]-$GLOBALS['inuser']['u_mperpage']; } } elseif ($post = getvar("p")) $start="0"; elseif (!$start=getvar("st")) $start="0"; elseif ($start=="new") { $border=" AND p__time>".$GLOBALS['userlast2']." "; $start=-1; $onlynew=1; } if ($start!="all" && !$onlynew) $limit = " LIMIT $start,".$GLOBALS['inuser']['u_mperpage']; elseif ($onlynew) $limit = " LIMIT 0,".($GLOBALS['inuser']['u_mperpage']); if ($post) $start=-1; $pages=build_pages($pcount[0],$start,$GLOBALS['inuser']['u_mperpage'],"index.php?f=$forum&t=$topic&o=$sort"); $sql = "DROP TABLE IF EXISTS tmpUserdata"; $res = db_query($sql,$link); $sql = "SELECT DISTINCT p_uid FROM ".$GLOBALS['DBprefix']."Post WHERE p_tid=$topic"; $res = db_query($sql,$link); $sqldata = ""; while ($udata=db_fetch_row($res)) { if ($sqldata) $sqldata.=" OR "; $sqldata.="p.p_uid=".$udata[0]; } if ($sqldata) $sqldata=" AND ($sqldata) "; $sql = "CREATE TEMPORARY TABLE tmpUserdata (ud_uid INT UNSIGNED NOT NULL, ud_count INT NOT NULL, ud_level SMALLINT NOT NULL, INDEX ud_key (ud_uid)) TYPE=HEAP"; //ud_rating INT NOT NULL, $res = db_query($sql,$link); $sql = "INSERT INTO tmpUserdata SELECT p.p_uid, COUNT(p.p_id), IFNULL(ua_level,u__level) ".//, SUM(ur.ur_value)/COUNT(DISTINCT p.p_id) ". "FROM ".$GLOBALS['DBprefix']."Post p, ".$GLOBALS['DBprefix']."User u, ". $GLOBALS['DBprefix']."Topic t, ".$GLOBALS['DBprefix']."Forum f ". "LEFT JOIN ".$GLOBALS['DBprefix']."UserAccess ua ON (ua.uid=u_id AND ua.fid=f.f_id) ". "WHERE p.p_tid=t.t_id AND t.t_fid=f.f_id AND p_uid=u_id AND p__premoderate=0 AND f_nostats=0 AND ". "((ua.ua_level IS NULL AND f.f_lview<=\"".$GLOBALS['inuserbasic']."\") OR (ua.ua_level IS NOT NULL AND f.f_lview<=ua.ua_level)) $sqldata". "GROUP BY p.p_uid"; $res = db_query($sql,$link); if (!getvar("preview")) { $intopic=$GLOBALS['intopic']; if ($intopic['pl_tid']) { if ($intopic['voted'] || $GLOBALS['inuserid']<=3 || ($intopic['pl_enddate'] && $intopic['pl_enddate']<$GLOBALS['curtime'])) std_vote_resbegin($intopic); else std_vote_begin($intopic); $sql = "SELECT pv_id,pv_text, COUNT(pvid) AS pv_count FROM ".$GLOBALS['DBprefix']."PollVariant pv ". "LEFT JOIN ".$GLOBALS['DBprefix']."Vote v ON (v.pvid=pv.pv_id) WHERE pv_plid=".$intopic['pl_id']. " GROUP BY pv.pv_id"; $res = db_query($sql,$link); $pv_text = array(); while ($pv_data=db_fetch_array($res)) { $pv_count[$pv_data['pv_id']]=$pv_data['pv_count']; $pv_total+=$pv_data['pv_count']; $pv_text[$pv_data['pv_id']]=$pv_data['pv_text']; } db_free_result($res); foreach ($pv_text as $curid=>$curtext) { if ($intopic['voted'] || $GLOBALS['inuserid']<=3 || ($intopic['pl_enddate'] && $intopic['pl_enddate']<$GLOBALS['curtime'])) std_vote_resentry($pv_text[$curid],$pv_count[$curid],$pv_total); else std_vote_entry($pv_text[$curid],$curid); } if ($intopic['voted'] || $GLOBALS['inuserid']<=3 || ($intopic['pl_enddate'] && $intopic['pl_enddate']<$GLOBALS['curtime'])) std_vote_resend($pv_total); else std_vote_end(); } } if ($post && $sort==0) $border=" AND p_id>=\"$post\""; elseif ($post && $sort==1) $border=" AND p_id<=\"$post\""; $sql = "SELECT p.*, ud.*, ua.ua_level, u.*, l_title, file_type, file_name, ". "OCTET_LENGTH(file_data) AS file_size, MAX(lv.lv_time1) AS ud_last, SUM(uw.uw_value) AS uw_count, ". "COUNT(ur.uid) AS rated, SUM(ur2.ur_value) AS ud_rating ". "FROM ".$GLOBALS['DBprefix']."Post p, ".$GLOBALS['DBprefix']."User u ". "LEFT JOIN ".$GLOBALS['DBprefix']."UserAccess ua ON (ua.uid=u.u_id AND ua.fid=".$GLOBALS['forum'].") ". "LEFT JOIN tmpUserdata ud ON (ud.ud_uid=u.u_id) ". "LEFT JOIN ".$GLOBALS['DBprefix']."UserLevel ul ON (ud.ud_level=l_level)". "LEFT JOIN ".$GLOBALS['DBprefix']."LastVisit lv ON (lv.uid=u.u_id AND lv.fid=$forum) ". "LEFT JOIN ".$GLOBALS['DBprefix']."UserRating ur ON (ur.uid=u.u_id AND ur.ur_rated=".$GLOBALS['inuserid']." AND ur.ur_time>".($GLOBALS['curtime']-$GLOBALS['opt_ratetime']*24*60*60).") ". "LEFT JOIN ".$GLOBALS['DBprefix']."File ON (".$GLOBALS['DBprefix']."File.file_id=p.p_attach) ". "LEFT JOIN ".$GLOBALS['DBprefix']."UserWarning uw ON (uw.uw_uid=u.u_id AND (uw.uw_validtill>".$GLOBALS['curtime']." OR uw.uw_validtill=0) AND lv.fid=0) ". "LEFT JOIN ".$GLOBALS['DBprefix']."UserRating ur2 ON (ur2.uid=u.u_id) ". " WHERE p.p_tid = $topic AND p.p_uid=u.u_id AND p__premoderate=0 ".$border. "GROUP BY p.p_id"; std_topic_start($pages,$GLOBALS['intopic'],$rated,$sort,$prev_tid,$next_tid); if ($GLOBALS['intopic']['t__stickypost'] && $start!=0 && $start!="all") { $sql2=str_replace($border,"",$sql." LIMIT 1"); $res = db_query($sql2,$link); $pdata=db_fetch_array($res); std_post_entry($pdata); } $sql.=" $order $limit"; $res = db_query($sql,$link); $sql2 = "DROP TABLE tmpUserdata"; $res2 = db_query($sql2,$link); while ($pdata=db_fetch_array($res)) { if ($pdata['p_uid']==2) std_system_post($pdata['p_text']); else std_post_entry($pdata); } std_topic_end($pages,$GLOBALS['intopic'],$prev_tid,$next_tid,$intopic['pl_tid']); if ($GLOBALS['inuserlevel']>=$GLOBALS['inforum']['f_lpost'] && !$GLOBALS['intopic']['t__status'] && !$GLOBALS['intopic']['f_status']) { $pdata['p__html']=($GLOBALS['inuserlevel']>=$GLOBALS['inforum']['f_lhtml']); $pdata['p__bcode']=$GLOBALS['inforum']['f_bcode']; $pdata['p__smiles']=$GLOBALS['inforum']['f_smiles']; $pdata['p_signature']=$GLOBALS['inuser']['u_usesignature']; std_post_form(MSG_p_create,"do_post",$pdata,0); } } function do_post() { if (getvar("preview")) { preview(); return; } process_post($GLOBALS['topic']); $link=$GLOBALS['link']; if (!$GLOBALS['inforum']['f_premoderate'] || $GLOBALS['inuserlevel']>=$GLOBALS['inforum']['f_lmoderate']) topic_message(MSG_p_done,1); else topic_message(MSG_p_premoderated,1); } function do_topic() { if (getvar("more")) { preview(1); return; } if (getvar("preview")) { preview(); return;} $inforum=$GLOBALS['inforum']; $forum=$GLOBALS['forum']; $inuserlevel=$GLOBALS['inuserlevel']; $inuser=$GLOBALS['inuser']; $inuserid=$GLOBALS['inuserid']; $link=$GLOBALS['link']; if ($inuserlevel<$inforum['f_ltopic']) error(MSG_e_t_norights); if (!getvar("t_title")) error(MSG_e_t_empty); if ($inforum['f_status']!=0) error(MSG_e_f_closed); $sqldata = build_sql("t_"); $sqldata.= check_topic_params(); $sql = "INSERT INTO ".$GLOBALS['DBprefix']."Topic SET t_fid=\"$forum\", $sqldata"; $res = db_query($sql,$link); $GLOBALS['topic'] = db_insert_id($res); $topic = $GLOBALS['topic']; $sql = "SELECT uid FROM ".$GLOBALS['DBprefix']."Subscription WHERE fid=".$GLOBALS['forum']." AND tid=4294967295"; $res = db_query($sql,$link); $sqldata=""; while ($uid=db_fetch_row($res)) { if ($sqldata) $sqldata.=", "; $sqldata = "(".$uid[0].",$topic,$forum)"; } if ($sqldata) { $sql = "INSERT INTO ".$GLOBALS['DBprefix']."Subscription VALUES $sqldata"; $res = db_query($sql,$link); } if (!$GLOBALS['inforum']['f_premoderate'] || $GLOBALS['inuserlevel']>=$GLOBALS['inforum']['f_lmoderate']) { $sql = "SELECT u__name,u__email FROM ".$GLOBALS['DBprefix']."Subscription sb, ".$GLOBALS['DBprefix']."User u WHERE sb.uid=u.u_id ". " AND sb.tid=4294967294 AND sb.uid!=".$GLOBALS['inuserid']; $res = db_query($sql,$link); $buffer=load_mail("std_tpc.txt"); } else { $sql = "SELECT u__name,u__email FROM ".$GLOBALS['DBprefix']."Subscription sb, ".$GLOBALS['DBprefix']."User u ". "LEFT JOIN ".$GLOBALS['DBprefix']."UserAccess ua ON (ua.uid=u.u_id AND ua.fid=".$GLOBALS['forum'].") ". " WHERE sb.uid=u.u_id". " AND sb.tid=4294967294 AND sb.uid!=".$GLOBALS['inuserid']. " AND ((ua_level IS NULL AND u__level<=".$GLOBALS['inforum']['f_lmoderate'].") OR (ua_level IS NOT NULL AND ua_level<=".$GLOBALS['inforum']['f_lmoderate']."))"; $res = db_query($sql,$link); $buffer=load_mail("std_tpm.txt"); $GLOBALS['premod_link']=$GLOBALS['opt_url']."/index.php?m=moderate&a=premod&f=".$GLOBALS['forum']; } while ($email=db_fetch_row($res)) { $GLOBALS['username']=$email[0]; $GLOBALS['postername']=$GLOBALS['inuser']['u__name']; $GLOBALS['ttitle']=$GLOBALS['intopic']['t_title']; $GLOBALS['ftitle']=$GLOBALS['inforum']['f_title']; $GLOBALS['text']=$_POST['p_text']; $GLOBALS['flink']=$GLOBALS['opt_url']."/index.php?t=".$GLOBALS['topic']; $GLOBALS['sublink']=$GLOBALS['opt_url']."/agent.php?a=subscr&u=".$GLOBALS['inuserid']."&t=". $GLOBALS['topic']."&key=".md5($GLOBALS['topic'].$GLOBALS['inuser']['u__key']); $GLOBALS['unsublink']=$GLOBALS['opt_url']."/agent.php?a=unsub&u=".$GLOBALS['inuserid']."&t=". $GLOBALS['topic']."&key=".md5($GLOBALS['topic'].$GLOBALS['inuser']['u__key']); replace_mail($buffer,$email[1],MSG_p_newmessage." ".$GLOBALS['ttitle']); } if (getvar("vote") && isset($_POST['pl_text'])) { if ($GLOBALS['inuserlevel']<$inforum['f_lpoll']) error(MSG_e_v_norights); $pl_title=getvar("pl_title"); $pl_tid=$GLOBALS['topic']; if (getvar("voteend")) $pl_enddate=time()+getvar("voteend")*24*60*60; else $pl_enddate=0; $sql = "INSERT INTO ".$GLOBALS['DBprefix']."Poll VALUES (0,$pl_tid,\"$pl_title\",$pl_enddate)"; $res = db_query($sql,$link); $pl_plid=db_insert_id($res); $votevars = $_POST['pl_text']; foreach ($votevars as $curnumer=>$curvalue) { if ($curvalue) { if ($sqldata) $sqldata.=", "; $sqldata.="(0,$pl_plid,\"".addslashes($curvalue)."\")"; } } $sql = "INSERT INTO ".$GLOBALS['DBprefix']."PollVariant VALUES $sqldata"; $res = db_query($sql,$link); } process_post($GLOBALS['topic']); if (!$GLOBALS['inforum']['f_premoderate'] || $GLOBALS['inuserlevel']>=$GLOBALS['inforum']['f_lmoderate']) topic_message(MSG_t_done,1); else { $GLOBALS['refpage']="index.php?f=".$GLOBALS['forum']; message(MSG_t_premoderated,1); } } function edit() { $link=$GLOBALS['link']; $pid=getvar("p"); $sql = "SELECT * FROM ".$GLOBALS['DBprefix']."Post p, ".$GLOBALS['DBprefix']."User u ". "LEFT JOIN ".$GLOBALS['DBprefix']."UserAccess ua ON (ua.uid=u.u_id AND ua.fid=".$GLOBALS['forum'].") ". "WHERE p_id=\"$pid\" AND u.u_id=p.p_uid AND p_tid=".$GLOBALS['topic']; $res = db_query($sql,$link); if (db_num_rows($res)!=1) error(MSG_e_p_notfound); $pdata = db_fetch_array($res); db_free_result($res); if (($pdata['p_uid']!=$GLOBALS['inuserid'] || $GLOBALS['inuserlevel']<$GLOBALS['inforum']['f_ledit']) && $GLOBALS['inuserlevel']<$GLOBALS['inforum']['f_lmoderate']) error(MSG_e_p_noeditrights); if ($pdata['p_uid']!=$GLOBALS['inuserid'] && check_moderate($pdata,$GLOBALS['inuserlevel'])) error(MSG_e_mod_subordinate); std_post_form(MSG_p_edit,"do_edit",$pdata,0); } function do_edit() { if (getvar("delete")) { do_delete(); return; } $pid=getvar("p"); $link=$GLOBALS['link']; $sql = "SELECT * FROM ".$GLOBALS['DBprefix']."Post p, ".$GLOBALS['DBprefix']."User u ". "LEFT JOIN ".$GLOBALS['DBprefix']."UserAccess ua ON (ua.uid=u.u_id AND ua.fid=".$GLOBALS['forum'].") ". "WHERE p_id=\"$pid\" AND u.u_id=p.p_uid"; $res = db_query($sql,$link); if (db_num_rows($res)!=1) error(MSG_e_p_notfound); $pdata = db_fetch_array($res); db_free_result($res); if ($GLOBALS['inuserlevel']<$GLOBALS['inforum']['f_ledit']) error(MSG_e_p_noeditrights); if ($pdata['p_uid']!=$GLOBALS['inuserid'] && check_moderate($pdata,$GLOBALS['inuserlevel'])) error(MSG_e_mod_subordinate); unset($_POST['p_uid']); unset($_POST['p_tid']); $inforum=$GLOBALS['inforum']; $sqldata = build_sql("p_"); $sqldata.= check_post_params(); if ($GLOBALS['inuserid']==$pdata['p_uid']) $sqldata .= ", p__edittime=".$GLOBALS['curtime']; if (getvar("delattach") && $pdata['p_attach']!=0) { $sqldata.=", p_attach=0"; $sql = "DELETE FROM ".$GLOBALS['DBprefix']."File WHERE file_id=".$pdata['p_attach']; $res = db_query($sql,$link); } $sql = "UPDATE ".$GLOBALS['DBprefix']."Post SET $sqldata WHERE p_id=\"$pid\""; $res = db_query($sql,$link); topic_message(MSG_p_edited,1); } function do_delete() { if ($GLOBALS['inuserlevel']<$GLOBALS['inforum']['f_lmoderate']) error(MSG_e_mod_norights); $link = $GLOBALS['link']; $pid=getvar("p"); $sql = "SELECT u.u__level,ua.ua_level,p.p_attach,p.p_tid,p_uid FROM ".$GLOBALS['DBprefix']."Post p, ".$GLOBALS['DBprefix']."User u ". "LEFT JOIN ".$GLOBALS['DBprefix']."UserAccess ua ON (ua.uid=u.u_id AND ua.fid=".$GLOBALS['forum'].") ". "WHERE p_id=\"$pid\" AND u.u_id=p.p_uid"; $res = db_query($sql,$link); if (db_num_rows($res)!=1) error(MSG_e_p_notfound); $pdata=db_fetch_array($res); db_free_result($res); if ($pdata['p_uid']!=$GLOBALS['inuserid'] && check_moderate($pdata,$GLOBALS['inuserlevel'])) error(MSG_e_mod_subordinate); if ($pdata['p_attach']) { $sql = "DELETE FROM ".$GLOBALS['DBprefix']."File WHERE file_id=".$pdata['p_attach']; $res = db_query($sql,$link); } $sql = "DELETE FROM ".$GLOBALS['DBprefix']."Post WHERE p_id=\"$pid\""; $res = db_query($sql,$link); $sql = "SELECT COUNT(*) FROM ".$GLOBALS['DBprefix']."Post WHERE p_tid=".$pdata['p_tid']; $res = db_query($sql,$link); $count = db_fetch_row($res); db_free_result($res); if (!$count[0]) delete_topic($pdata['p_tid']); topic_message(MSG_p_deleted,1); } function stdforum_title($fdata,$pmax) { $link=$GLOBALS['link']; if ($fdata['t_count'] && $fdata['p_count']) { $sql = "SELECT * FROM ".$GLOBALS['DBprefix']."Post p, ".$GLOBALS['DBprefix']."User u WHERE p.p_id=".$pmax." AND p.p_uid=u.u_id"; $res = db_query($sql,$link); $pmaxdata = db_fetch_array($res); db_free_result($res); } else { $pmaxdata['p_name']=MSG_na; $pmaxdata['p_date']=0; } std_title($fdata,$pmaxdata); } function std_newtopic() { if ($GLOBALS['inuserlevel']<$GLOBALS['inforum']['f_ltopic']) error(MSG_e_t_norights); if ($GLOBALS['inuserlevel']<$GLOBALS['inforum']['f_lpoll'] && getvar("vote")) error(MSG_e_v_norights); $pdata['p__html']=($GLOBALS['inuserlevel']>=$GLOBALS['inforum']['f_lhtml']); $pdata['p__bcode']=$GLOBALS['inforum']['f_bcode']; $pdata['p__smiles']=$GLOBALS['inforum']['f_smiles']; $pdata['p_signature']=$GLOBALS['inuser']['u_usesignature']; $votecount=array(); if (getvar("vote")) for ($i=0; $i<$GLOBALS['opt_defvotecount']; $i++) array_push($votecount,$i); std_post_form(MSG_t_create,"do_topic",$pdata,$votecount); } function preview($type=0) { if ($type==0) std_topic_start("",$GLOBALS['intopic'],0,0,0,0); $pdata=$GLOBALS['inuser']; $pdata['p_uname']=$pdata['u__name']; $pdata['p_text']=getvar("p_text"); $pdata['p__html']=getvar("p__html"); $pdata['p__bcode']=getvar("p__bcode"); $pdata['p__smiles']=getvar("p__smiles"); $pdata['t_title']=getvar("t_title"); $pdata['t_descr']=getvar("t_descr"); $pdata['p_title']=getvar("p_title"); $pdata['t_descr']=getvar("t_descr"); $pdata['voteend']=getvar("voteend"); $pdata['p_signature']=getvar("p_signature"); $pdata['p_uid']=$GLOBALS['inuserid']; $pdata['ud_last']=time(); $pdata['p__time']=$pdata['ud_last']; $pdata['pl_title']=getvar("pl_title"); $pl_text=$_POST['pl_text']; $counter=array(); if ($pl_text) { foreach ($pl_text as $curid=>$curtext) { $pdata['votevar'][$curid]=$curtext; array_push($counter,$curid); } } if ($type==1) for ($i=0; $i<$GLOBALS['opt_defvotecount']; $i++) array_push($counter,$i+count($pl_text)); if ($type==0) { std_post_entry($pdata); std_topic_end("",$GLOBALS['intopic'],0,0,0); } std_post_form(MSG_preview,$GLOBALS['action'],$pdata,$counter); } function do_vote() { if ($GLOBALS['inuserlevel']<$inforum['f_lvote']) error(MSG_e_v_norightsvote); $link=$GLOBALS['link']; $intopic=$GLOBALS['intopic']; if ($intopic['voted']) error(MSG_e_v_already); $pvid=getvar("pv_id"); if (!$pvid) error(MSG_e_v_novariant); $sql = "INSERT INTO ".$GLOBALS['DBprefix']."Vote VALUES(\"".$pvid."\",\"".$GLOBALS['inuserid']."\")"; $res = db_query($sql,$link); message(MSG_v_voted); } function do_print() { print_start(); $link=$GLOBALS['link']; $sql = "SELECT * FROM ".$GLOBALS['DBprefix']."Post WHERE p_tid=\"".$GLOBALS['topic']."\""; $res = db_query($sql,$link); while ($pdata=db_fetch_array($res)) { print_entry($pdata); } print_end(); } function do_sub() { $link=$GLOBALS['link']; $tid=getvar("tid"); $fid=$GLOBALS['forum']; $sql = "DELETE FROM ".$GLOBALS['DBprefix']."Subscription WHERE fid=$fid AND tid=\"$tid\" AND uid=".$GLOBALS['inuserid']; $res = db_query($sql,$link); if (getvar("sub")) { $sql = "INSERT INTO ".$GLOBALS['DBprefix']."Subscription SET uid=".$GLOBALS['inuserid'].", fid=$fid, tid=\"$tid\""; $res = db_query($sql,$link); } $GLOBALS['refpage']="index.php?f=".$GLOBALS['forum']; message(MSG_sub_saved,1); } function stdforum_locations($locations) { push_parents($locations,$GLOBALS['inforum']['f_parent']); if ($GLOBALS['action']=="stdforum_view") { if ($GLOBALS['topic']) { array_push($locations,"".$GLOBALS['inforum']['f_title'].""); array_push($locations,$GLOBALS['intopic']['t_title']); } else { array_push($locations,$GLOBALS['inforum']['f_title']); } } elseif ($GLOBALS['action']=="std_newtopic") { array_push($locations,"".$GLOBALS['inforum']['f_title'].""); array_push($locations,MSG_t_creating); if (getvar("preview")) array_push($locations,MSG_preview); } elseif ($GLOBALS['action']=="do_post") { array_push($locations,"".$GLOBALS['inforum']['f_title'].""); array_push($locations,"".$GLOBALS['intopic']['t_title'].""); if (getvar("preview")) array_push($locations,MSG_preview); } elseif ($GLOBALS['action']=="do_topic") { array_push($locations,"".$GLOBALS['inforum']['f_title'].""); array_push($locations,MSG_t_creating); if (getvar("preview")) array_push($locations,MSG_preview); } elseif ($GLOBALS['action']=="edit") { array_push($locations,"".$GLOBALS['inforum']['f_title'].""); array_push($locations,"".$GLOBALS['intopic']['t_title'].""); array_push($locations,MSG_p_edit); } return $locations; }