Viewing file: msgboard_disabled.phtml (11.42 KB) -rw-rw-r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?
require('ax2.inc'); require('multipart.inc');
/* actions:
- new topic "Create!" - new message (in a topic) - display topic list - display messages (on a topic)
*/
function cantpost() { global $REMOTE_ADDR;
$toreview='f'; return $toreview; /* 139.134.108.x 139.134.109.x 139.134.220.x 139.134.221.x 139.134.222.x 139.134.223.x 139.134.224.x 139.134.23.10 170.248.3.6 203.18.50.13 203.63.125.5 - 'KIP' posted from here some vulgarities on the 1st Sep. 99 203.134.2.91 - proxy.primus.com.au - Nickos and 'David Sloan' & co. 203.134.2.92 - proxy.primus.com.au - Nickos and 'David Sloan' & co. */
if (ereg("^139.134.108",$REMOTE_ADDR)) $toreview='t'; if (ereg("^139.134.109",$REMOTE_ADDR)) $toreview='t'; if (ereg("^139.134.220",$REMOTE_ADDR)) $toreview='t'; if (ereg("^139.134.221",$REMOTE_ADDR)) $toreview='t'; if (ereg("^139.134.222",$REMOTE_ADDR)) $toreview='t'; if (ereg("^139.134.223",$REMOTE_ADDR)) $toreview='t'; if (ereg("^139.134.224",$REMOTE_ADDR)) $toreview='t'; if (ereg("^203.109.226",$REMOTE_ADDR)) $toreview='t'; if ($REMOTE_ADDR=='139.134.23.10') $toreview='t'; if ($REMOTE_ADDR=='202.0.106.130') $toreview='t'; if ($REMOTE_ADDR=='203.5.250.244') $toreview='t'; if ($REMOTE_ADDR=='203.18.50.9') $toreview='t'; if ($REMOTE_ADDR=='203.18.50.13') $toreview='t'; if ($REMOTE_ADDR=='203.63.125.5') $toreview='t'; if ($REMOTE_ADDR=='203.134.2.91') $toreview='t'; if ($REMOTE_ADDR=='203.134.2.92') $toreview='t';
// if ($REMOTE_ADDR=='194.88.38.130') $toreview='t'; // if ($REMOTE_ADDR=='194.88.38.131') $toreview='t';
return $toreview; }
function new_topic($conn) { global $text, $topic;
if ($text=="") { disp_preamble("The Ax Discussion Board","Topic creation - empty text"); echo "You haven't specified a topic!</p>\n"; } else { $result=pg_exec($conn,"select nextval ('msgboard topics_id_seq');"); $obj=pg_Fetch_Array($result,0); $topic=$obj[0]; $expired=cantpost(); if (pg_exec($conn,"insert into \"msgboard topics\" (text, id, modified, expired) values ('".addslashes($text)."',".addslashes($topic).",now(),'".$expired."');")) { //disp_preamble("The Ax Discussion Board","Topic creation successful"); //echo "Your topic '".htmlentities($text)."' was successfully created."; pg_exec($conn,"notify newtopic;"); display_thread($conn,$topic); } else { disp_preamble("The Ax Discussion Board","Topic creation failed"); error("Your topic could not be created due to an error."); disp_tail(); } }
}
function new_message($conn) { global $HTTP_COOKIE_VARS, $HTTP_POST_VARS, $REMOTE_ADDR, $name, $email, $url, $msgtype;
if ($HTTP_COOKIE_VARS[name]!=$HTTP_POST_VARS[name]) { pg_exec($conn,"insert into namechange (oldname,newname,ipaddr,date) values ('".addslashes($HTTP_COOKIE_VARS[name])."','".addslashes($HTTP_POST_VARS[name])."','".addslashes($REMOTE_ADDR)."',now());"); setcookie("name",$HTTP_POST_VARS[name],time()+3650*86400); $name=$HTTP_POST_VARS[name]; } if ($HTTP_COOKIE_VARS[email]!=$HTTP_POST_VARS[email]) { setcookie("email",$HTTP_POST_VARS[email],time()+3650*86400); $email=$HTTP_POST_VARS[email]; } if ($HTTP_COOKIE_VARS[url]!=$HTTP_POST_VARS[url]) { setcookie("url",$HTTP_POST_VARS[url],time()+3650*86400); $url=$HTTP_POST_VARS[url]; } if ($HTTP_COOKIE_VARS[msgtype]!=$HTTP_POST_VARS[msgtype]) { setcookie("msgtype",$HTTP_POST_VARS[msgtype],time()+3650*86400); $msgtype=$HTTP_POST_VARS[msgtype]; } if ($msgtype!="HTML") $text=htmlentities($text);
$toreview=cantpost(); $expired=$toreview;
if (pg_exec($conn,"insert into \"msgboard messages\" (topic,name,email,url,subject,date,expired,toreview,text,ipaddr) values (".addslashes($HTTP_POST_VARS[topic]).",'".addslashes($HTTP_POST_VARS[name])."','".addslashes($HTTP_POST_VARS[email])."','".addslashes($HTTP_POST_VARS[url])."','".addslashes($HTTP_POST_VARS[subject])."',now(),'".$expired."','".$toreview."','".addslashes($HTTP_POST_VARS[text])."','".addslashes($REMOTE_ADDR)."');")) { if ($toreview!='t') { pg_exec($conn,"update \"msgboard topics\" set modified=now() where id=".$HTTP_POST_VARS[topic].";"); pg_exec($conn,"notify newmsg;"); } display_thread($conn,$HTTP_POST_VARS[topic]); } else { disp_preamble("The Ax Discussion Board","Message creation failed"); error("Your message could not be posted due to an error."); disp_tail(); } }
function disp_new_topic_form() { echo "<form method=post>\n"; echo "Create a new topic: <input type=text name=text maxlength=50>\n"; echo "<input type=submit name=action value=\"Create!\">\n"; echo "</form>\n"; }
function display_topics($conn) { global $PHP_SELF,$HTTP_USER_AGENT; if (strpos(strtoupper($HTTP_USER_AGENT),"MSIE")) $targetstring=" target=_blank";
$result=pg_exec($conn,"select topic,count(*) from \"msgboard messages\" where expired<>'t' group by topic;");
$rows=pg_numrows($result); for($row=0;$row<$rows;$row++) { $obj=pg_fetch_array($result,$row); $darab[$obj[topic]]=$obj[count]; }
$result=pg_exec($conn,"select *, date_part('epoch',modified::datetime) from \"msgboard topics\" where expired<>'t' order by modified desc;"); if (!$result) { disp_preamble("The Ax Discussion Board","Error listing topics"); error("An error occured while listing the topics."); disp_tail(); exit(); } disp_preamble("The Ax Discussion Board","List of topics"); $timeresult=pg_exec('select current_timestamp;'); $obj=pg_fetch_array($timeresult,0); echo "Is <b>",substr($obj[0],0,19),"</b> your local time? If not, click <a href=\"tzset?back=msgboard\">here</a> to set your timezone!</p>";
pg_exec('update hitcounter set msgboard=msgboard+1;'); $hitresult=pg_exec('select * from hitcounter;'); $hits=pg_fetch_array($hitresult,0); echo "<p>Hit counter (started on 1999-07-18): <b>",$hits[0],"</b> hits up to now.<br>";
$hitresult=pg_exec('select count(date) from agents where date>(\'now\'::timestamp+\'1 day ago\'::reltime)::timestamp;'); $hits=pg_fetch_array($hitresult,0); echo "Daily hit counter: <b>",$hits[0],"</b> hits in the last 24 hours.<br>";
echo "Note: MSIE browsers blindly refresh once every five minutes; Netscape browsers refresh only when any visitor posts a new message.</p>";
$rows=pg_numrows($result); if ($rows==0) {echo "<p align=center>There are no topics onboard.</p>";} else { echo "<table>\n"; echo "<tr><th>Topic<th>Messages<th>Last modified</tr>\n"; for($row=0;$row<$rows;$row++) { echo "<tr>"; $obj=pg_fetch_array($result,$row); echo "<td><a href=\"".$PHP_SELF."?action=dispthread&topic=".$obj[id]."&junk=".urlencode($obj[date_part])."\"".$targetstring.">".htmlentities($obj[text])."</a></td>\n"; echo "<td align=right>".$darab[$obj[id]]."</td>\n"; echo "<td>".substr($obj[modified],0,19)."</td>\n"; echo "</tr>\n"; } echo "</table>"; } disp_new_topic_form(); disp_tail(); }
function display_thread($conn,$topic) { global $name,$email,$url,$PHP_SELF;
$result=pg_exec("select * from \"msgboard topics\" where id=".$topic.";"); if (pg_numrows($result)==0) { disp_preamble("The Ax Discussion Board","Topic ".$topic." not found"); echo "<p align=center><a href=\"".$PHP_SELF."\">[Back to topic list]</a></p>"; error("We could not find this topic.<br>Either it was removed since bookmarked, or we still have bugs in the message board."); disp_tail(); exit(); } $obj=pg_fetch_array($result,0); disp_preamble("The Ax Discussion Board","Topic '".htmlentities($obj[text])."'"); echo "<p align=center><a href=\"".$PHP_SELF."\">[Back to topic list]</a></p>"; $result=pg_exec("select * from \"msgboard messages\" where topic=".$topic." and expired<>'t' order by date;"); if (!$result) { disp_preamble("The Ax Discussion Board","Error listing thread '".$obj[text]."'"); echo "<p align=center><a href=\"".$PHP_SELF."\">[Back to topic list]</a></p>"; error("An error occured while listing the messages in this thread."); disp_tail(); exit(); } $rows=pg_numrows($result); if ($rows==0) { echo "There are no messages in this thread.</p>\n"; } else { for ($row=0;$row<$rows;$row++) { $obj=pg_fetch_array($result,$row); disp_message($obj[name],$obj[email],$obj[url],$obj[subject],$obj[date],$obj[text]); } } disp_new_message_form(); echo "<p align=center><a href=\"".$PHP_SELF."\">[Back to topic list]</a></p>"; disp_tail(); }
function disp_person($name,$email,$url) { if ($name=="") { echo "An unknown poster"; } else { if ($email!="") echo "<a href=\"mailto:".$email."\">"; echo $name; if ($email!="") echo "</a>"; if ($url!="") echo " (<a href=\"".$url."\">".$url."</a>)"; } }
function disp_message($name,$email,$url,$subject,$date,$text) { echo "<font color=#4A7DB7>\n"; echo "<font color=#FFCC33>".$subject,"</font><br>\n"; echo $name,"<br>\n"; echo $email,"<br>\n"; echo $url,"<br>\n"; //echo substr($date,0,10),"<br>\n"; echo "</p>"; echo $name," writes:</p>\n"; echo "</font>"; //disp_person($name,$email,$url); //echo " wrote on ".substr($date,0,10)." regarding ".$subject.":<br>\n"; //echo "<pre>\n"; echo "<font color=#FEFFD2>\n"; // #408080 echo(nl2br($text)); echo "</font>"; //echo "</pre>\n"; echo "<hr>\n"; }
function disp_new_message_form() { global $name,$email,$url,$topic,$msgtype,$REMOTE_ADDR;
if (cantpost()=='t') { echo "<p><b>Warning:</b> Someone using the same IP address (".$REMOTE_ADDR.") you are using right now has previously displayed inappropriate behaviour on the board. Therefore as a preventive measure, we are not displaying messages posted from this IP address right away; they will be reviewed instead, and made available for others to read when found appropriate.<br>We apologize for the inconvenience.</p>"; } echo "<form method=post url=\"".$PHP_SELF."\">\n"; echo "<input type=hidden name=topic value=".$topic.">\n"; echo "<table>\n"; echo "<tr><td align=right>Name:<td><input type=text name=\"name\" size=40 value=\"".$name."\">\n"; echo "<tr><td align=right>Email address:<td><input type=text name=\"email\" size=40 value=\"".$email."\">\n"; echo "<tr><td align=right>URL:<td><input type=text name=\"url\" size=40 value=\"".$url."\">\n"; echo "<tr><td align=right>Subject:<td><input type=text name=\"subject\" size=40 value=\"".$subject."\">\n"; echo "<tr><td align=right>Message type:<td><input type=radio name=msgtype value=plain"; if ($msgtype!="HTML") echo " checked"; echo ">Plain text <input type=radio name=msgtype value=HTML"; if ($msgtype=="HTML") echo " checked"; echo ">HTML\n"; echo "<tr><td align=right>Text:<td><textarea name=\"text\" rows=20 cols=80 wrap=soft>\n"; echo "</textarea>\n"; echo "<tr><td><td><input type=submit name=action value=\"Send!\">\n"; echo "</table>\n"; echo "</form>\n"; }
function handle_table($conn) { global $action, $timezone, $topic, $HTTP_USER_AGENT, $REMOTE_ADDR;
switch ($action) { case "Create!" : new_topic($conn); break; case "Send!" : new_message($conn); break; case "dispthread" : display_thread($conn,$topic); break; default : pg_exec($conn,"set time zone '$timezone';"); pg_exec($conn,"listen newtopic;"); pg_exec($conn,"listen newmsg;"); pg_exec($conn,"insert into agents (agent,ipaddr,date) values('".addslashes($HTTP_USER_AGENT)."','".addslashes($REMOTE_ADDR)."',now());"); if ((strpos(strtoupper($HTTP_USER_AGENT),"MSIE")) | (strtoupper(substr($HTTP_USER_AGENT,0,4))=="LYNX")) { display_topics($conn); } else { multipart_init("ThisRandomString"); while(!connection_aborted()) { multipart_open('text/html'); display_topics($conn); multipart_close(); pg_getnotify($conn,1); } multipart_done(); } break; } } handle_table(pg_connect("","","","","ax")); ?>
|