2 AND p__premoderate=0"; $res = db_query($sql,$link); $numrows=db_num_rows($res)+1; } if ($numrows>1 || $adata['a_disc_tid']) { article_discuss_start(); while ($aentry=db_fetch_array($res)) { article_discuss_entry($aentry); } article_discuss_end($adata['a_disc_tid']); } $trash['p__bcode']=$GLOBALS['inforum']['f_bcode']; $trash['p__smiles']=$GLOBALS['inforum']['f_smiles']; if ($GLOBALS['inuserlevel']>=$GLOBALS['inforum']['f_lpost'] && !$adata['a_disc_tid']) article_discuss_form($trash,MSG_a_addcoment,"do_post"); } function do_post() { $link=$GLOBALS['link']; $sql = "SELECT a_disc_tid FROM ".$GLOBALS['DBprefix']."Article WHERE a_tid=".$GLOBALS['topic']; $res = db_query($sql,$link); list ($tid)=db_fetch_row($res); if (!$tid) $tid=$GLOBALS['topic']; process_post($tid); if (!$GLOBALS['inforum']['f_premoderate'] || $GLOBALS['inuserlevel']>=$GLOBALS['inforum']['f_lmoderate']) { topic_message(MSG_a_commentadded,1); } else { message(MSG_p_premoderated,1); } } function add_article() { $forumlist=build_forum_select("f_ltopic",1); $pdata['p__bcode']=$GLOBALS['inforum']['f_bcode']; $pdata['p__smiles']=$GLOBALS['inforum']['f_smiles']; article_edit_form($tdata,$adata,$pdata,"do_topic",MSG_a_adding,$forumlist); } function do_topic() { if ($GLOBALS['inuserlevel']<$inforum['f_ltopic']) error(MSG_e_t_norights); if (!getvar("t_title")) { // error(MSG_e_a_emptytitle); $_POST['t_title']=substr($_POST['p_text'],0,20)."..."; } if ($GLOBALS['inforum']['f_status']!=0) error(MSG_e_f_closed); if (!getvar("a_author")) { //error(MSG_e_a_noauthor); $_POST['a_author']=$GLOBALS['inuser']['u__name']; } if (!getvar("p_text")) error(MSG_e_a_emptytext); $forum=$GLOBALS['forum']; $link=$GLOBALS['link']; $sqldata = build_sql("t_"); $sqldata.= check_topic_params(); $sql = "INSERT INTO ".$GLOBALS['DBprefix']."Topic SET t_fid=$forum, $sqldata"; $res = db_query($sql,$link); $tid = db_insert_id($res); $pid=process_post($tid); $sqldata = build_sql("a_"); $sql = "INSERT INTO ".$GLOBALS['DBprefix']."Article SET a_tid=$tid, $sqldata"; $res = db_query($sql,$link); topic_increment($forum,$tid,$pid); $newfid = getvar("fid"); if ($newfid) { $title = getvar("t_title"); $descr = MSG_a_discussion; $sql = "INSERT INTO ".$GLOBALS['DBprefix']."Topic SET t_fid=\"$newfid\", t_title=\"$title\", t_descr=\"$descr\""; $res = db_query($sql,$link); $newtid = db_insert_id($res); $text = MSG_a_disclink." \\\"$title\\\""; $sql = "INSERT INTO ".$GLOBALS['DBprefix']."Post SET p_tid=$newtid, p_text=\"$text\", p__time=".$GLOBALS['curtime'].", p__html=1, p_uid=2, p_uname=\"System\""; $res = db_query($sql,$link); $sql = "UPDATE ".$GLOBALS['DBprefix']."Article SET a_disc_tid=$newtid WHERE a_tid=$tid"; $res = db_query($sql,$link); } if (!$GLOBALS['inforum']['f_premoderate'] || $GLOBALS['inuserlevel']>=$GLOBALS['inforum']['f_lmoderate']) { $GLOBALS['topic']=$tid; topic_message(MSG_a_added,1); } else { $GLOBALS['refpage']="index.php?f=".$GLOBALS['forum']; message(MSG_t_premoderated,1); } } function edit_article() { $link=$GLOBALS['link']; $tid=$GLOBALS['topic']; $sql = "SELECT * FROM ".$GLOBALS['DBprefix']."Topic WHERE t_id=$tid"; $res = db_query($sql,$link); $tdata = db_fetch_array($res); db_free_result($res); $sql = "SELECT * FROM ".$GLOBALS['DBprefix']."Post WHERE p_tid=$tid"; $res = db_query($sql,$link); $pdata=db_fetch_array($res); db_free_result($res); $sql = "SELECT * FROM ".$GLOBALS['DBprefix']."Article WHERE a_tid=$tid"; $res = db_query($sql,$link); $adata = db_fetch_array($res); $sql = "DELETE FROM ".$GLOBALS['DBprefix']."TopicView WHERE tid=$tid"; $res = db_query($sql,$link); article_edit_form($tdata,$adata,$pdata,"do_edit",MSG_a_edit); } function do_edit() { if ($inuserlevel<$inforum['f_lmoderate']) error(MSG_e_t_norights); if (!getvar("t_title")) error(MSG_e_a_emptytitle); if (!getvar("p_text")) error(MSG_e_a_emptytext); if (!getvar("a_author")) error(MSG_e_a_noauthor); if (!$_POST['a_origin']) { $_POST['a_origin']=$GLOBALS['opt_title']; $_POST['a_originurl']=$GLOBALS['opt_url']; } $forum=$GLOBALS['forum']; $link=$GLOBALS['link']; $sqldata = build_sql("t_"); $sql = "UPDATE ".$GLOBALS['DBprefix']."Topic SET $sqldata WHERE t_id=".$GLOBALS['topic']; $res = db_query($sql,$link); $tid = db_insert_id($res); $sqldata = build_sql("a_"); $sql = "UPDATE ".$GLOBALS['DBprefix']."Article SET $sqldata WHERE a_tid=".$GLOBALS['topic']; $res = db_query($sql,$link); $sql = "SELECT MIN(p_id) FROM ".$GLOBALS['DBprefix']."Post WHERE p_tid=".$GLOBALS['topic']; $res = db_query($sql,$link); list($pid)=db_fetch_row($res); $sqldata = build_sql("p_"); $sqldata.= check_post_params(); $sql = "UPDATE ".$GLOBALS['DBprefix']."Post SET $sqldata WHERE p_id=\"$pid\" AND p_tid=".$GLOBALS['topic']; $res = db_query($sql,$link); topic_message(MSG_a_saved,1); } function do_delete_article() { if ($inuserlevel<$inforum['f_lmoderate']) error(MSG_e_t_norights); $tid=$GLOBALS['topic']; $link=$GLOBALS['link']; $sql = "DELETE FROM ".$GLOBALS['DBprefix']."Article WHERE a_tid=$tid"; $res = db_query($sql,$link); delete_topic($tid); forum_resync($GLOBALS['forum']); $GLOBALS['refpage']="index.php?f=".$GLOBALS['forum']; message(MSG_t_deleted); } function do_print() { $link=$GLOBALS['link']; $tid=$GLOBALS['topic']; $sql = "SELECT * FROM ".$GLOBALS['DBprefix']."Topic WHERE t_id=$tid"; $res = db_query($sql,$link); $tdata = db_fetch_array($res); db_free_result($res); $sql = "SELECT * FROM ".$GLOBALS['DBprefix']."Post WHERE p_tid=$tid"; $res = db_query($sql,$link); $pdata=db_fetch_array($res); db_free_result($res); $sql = "SELECT * FROM ".$GLOBALS['DBprefix']."Article WHERE a_tid=$tid"; $res = db_query($sql,$link); $adata = db_fetch_array($res); article_print_form($tdata,$adata,$pdata); } function delete_confirm() { $params['t']=$GLOBALS['topic']; confirm("article","do_delete_article",$params,MSG_a_deleteconfirm." ".$GLOBALS['intopic']['t_title'],"index.php?t=".$GLOBALS['topic']); } function edit_comment() { edit_post('article_discuss_form',MSG_a_editcoment,"do_edit_post"); } function split_article($text) { $result=array(); $buffer=""; array_push($result,0); $counter=0; if ($GLOBALS['opt_article_split']) { $tmp=explode("\n",$text); foreach ($tmp as $curstr) { $buffer.=$curstr; $counter+=strlen($curstr)+1; if (strlen($buffer)>=$GLOBALS['opt_article_split']) { array_push($result,$counter); $buffer=""; } } } array_push($result,strlen($text)); return $result; } function build_article_pages($start,&$list,$topic) { $numpages = count($list)-1; if ($numpages>1 || $start>0) { $pages = MSG_pages; $number=0; for ($i=1; $i<=$numpages; $i++) { if ($number!=$start || $start=="all") $pages.="$i "; else $pages.="$i "; $number++; } if ($start=="all") $pages.="#"; else $pages.="# "; } return $pages; } function article_subtext($start,&$list,$text) { if ($start=="all") return $text; else return substr($text,$list[$start],$list[$start+1]-$list[$start]); } function article_locations($locations) { push_parents($locations,$GLOBALS['inforum']['f_parent']); if ($GLOBALS['topic']) { array_push($locations,"".$GLOBALS['inforum']['f_title'].""); if ($GLOBALS['action']=='article_view') array_push($locations,$GLOBALS['intopic']['t_title']); else array_push($locations,"".$GLOBALS['intopic']['t_title'].""); } else { array_push($locations,$GLOBALS['inforum']['f_title']); } if ($GLOBALS['action']=="edit_article") { array_push($locations,MSG_a_edit); } elseif ($GLOBALS['action']=="edit_comment") { array_push($locations,MSG_a_editcomment); } elseif ($GLOBALS['action']=="add_article") { array_push($locations,MSG_a_adding); } return $locations; }