diff --git a/css/base.css b/css/base.css index efab625..a291063 100644 --- a/css/base.css +++ b/css/base.css @@ -78,3 +78,18 @@ input[type=radio] { color: black; background: white; } .imgtag { max-width: 100%; } .post { position: relative; } + +textarea.newposttextbox { + max-width: 100%; + width: 800px; + height: 20em; + resize: both; +} + +table.table-fixed { + table-layout: fixed; +} + +input, select { vertical-align: middle; } + +img[src^="images/smilies/"] { vertical-align: middle; } diff --git a/lib/function.php b/lib/function.php index e11c463..c1dd636 100644 --- a/lib/function.php +++ b/lib/function.php @@ -268,6 +268,11 @@ */ +function v(&$v, $d = null) { + $v = isset($v) ? $v : $d; + return $v; +} + function filter_int(&$v) { if (!isset($v)) { return null; @@ -950,9 +955,13 @@ function jspageexpand($start, $end) { } */ -function redirect($url,$msg,$delay){ - if($delay<1) $delay=1; - return "You will now be redirected to $msg..."; +function redirect($url,$msg,$delay = 1){ + if ($delay >= 0) { + return "You will now be redirected to $msg..."; + } else { + return "Go back to $msg."; + + } } function postradar($userid){ @@ -1076,49 +1085,62 @@ function errorpage($text, $redir = '', $redirurl = '') { die(); } + +function boardmessage($text, $title = "Message") { + global $header,$tblstart,$tccellh,$tccell1,$tblend,$footer,$startingtime; + + print " + $header +
+ $tblstart + + $tccellh>$title + + + $tccell1 style='padding: 1em 0;'>$text + + $tblend + $footer + "; + + printtimedif($startingtime); + die(); +} + + function moodlist($sel = 0, $return = false) { global $loguserid, $log, $loguser; - $sel = floor($sel); + //$sel = $sel; - $a = array("None", "neutral", "angry", "tired/upset", "playful", "doom", "delight", "guru", "hope", "puzzled", "whatever", "hyperactive", "sadness", "bleh", "embarrassed", "amused", "afraid"); - //if ($loguserid == 1) $a[99] = "special"; - if ($return) return $a; + $moodlist = array( + "(default)", + "neutral", + "angry", + "tired/upset", + "playful", + "doom", + "delight", + "guru", + "hope", + "puzzled", + "whatever", + "hyperactive", + "sadness", + "bleh", + "embarrassed", + "amused", + "afraid" + ); - $c[$sel] = " checked"; - $ret = ""; + if ($return) return $moodlist; - if ($log && $loguser['moodurl']) - $ret = ' - - '; + $ret = " -
\r\n"; + foreach($moodlist as $num => $name) { + $ret .= "\t\n"; } - if (!$sel || !$log || !$loguser['moodurl']) - $startimg = 'images/_.gif'; - else - $startimg = htmlspecialchars(str_replace('$', $sel, $loguser['moodurl'])); - - $ret .= ""; + $ret .= "\n"; return $ret; } @@ -1430,72 +1452,6 @@ function addslashes_array($data) { } -function adbox() { - - // no longer needed. RIP - return ""; - - global $loguser, $bgcolor, $linkcolor; - -/* - $tagline = array(); - $tagline[] = "Viewing this ad requires
ZSNES 1.42 or older!"; - $tagline[] = "Celebrating 5 years of
ripping off SMAS!"; - $tagline[] = "Now with 100% more
buggy custom sprites!"; - $tagline[] = "Try using AddMusic to give your hack
that 1999 homepage feel!"; - $tagline[] = "Pipe cutoff? In my SMW hack?
It's more likely than you think!"; - $tagline[] = "Just keep giving us your money!"; - $tagline[] = "Now with 97% more floating munchers!"; - $tagline[] = "Tip: If you can beat your level without
savestates, it's too easy!"; - $tagline[] = "Tip: Leave exits to level 0 for
easy access to that fun bonus game!"; - $tagline[] = "Now with 100% more Touhou fads!
It's like Jul, but three years behind!"; - $tagline[] = "Isn't as cool as this
witty subtitle!"; - $tagline[] = "Finally beta!"; - $tagline[] = "If this is blocking other text
try disabling AdBlock next time!"; - $tagline[] = "bsnes sucks!"; - $tagline[] = "Now in raspberry, papaya,
and roast beef flavors!"; - $tagline[] = "We <3 terrible Japanese hacks!"; - $tagline[] = "573 crappy joke hacks and counting!"; - $tagline[] = "Don't forget your RATS tag!"; - $tagline[] = "Now with exclusive support for
127½Mbit SuperUltraFastHiDereROM!"; - $tagline[] = "More SMW sequels than you can
shake a dead horse at!"; - $tagline[] = "xkas v0.06 or bust!"; - $tagline[] = "SMWC is calling for your blood!"; - $tagline[] = "You can run,
but you can't hide!"; - $tagline[] = "Now with 157% more CSS3!"; - $tagline[] = "Stickers and cake don't mix!"; - $tagline[] = "Better than a 4-star crap cake
with garlic topping!"; - $tagline[] = "We need some IRC COPS!"; - - if (isset($_GET['lolol'])) { - $taglinec = $_GET['lolol'] % count($tagline); - $taglinec = $tagline[$taglinec]; - } - else - $taglinec = pick_any($tagline); -*/ - - return " -
- - - - - - -
"; -} - // for you-know-who's bullshit function gethttpheaders() { $ret = ''; diff --git a/lib/layout.php b/lib/layout.php index a905f87..bf92e59 100644 --- a/lib/layout.php +++ b/lib/layout.php @@ -500,15 +500,7 @@ $header=makeheader($header1,$headlinks,$header2); $footer=" -
- - -
$smallfont

$sitename
". filter_string($affiliatelinks) ." diff --git a/newreply.php b/newreply.php index 2d72246..36893f7 100644 --- a/newreply.php +++ b/newreply.php @@ -1,189 +1,115 @@ fetchq("SELECT forum, closed, sticky,title,lastposter FROM threads WHERE id=$id"); // Stop this insanity. Never index newreply. $meta['noindex'] = true; + // Give failed replies a last-chance to copy and save their work, + // as way too often you'll miss and then it's just gone forever + $lastchance = null; + $redirectTime = 3; + if (v($_POST['message']) !== null) { + $lastchance = "

You can copy and save what you were going to post, if you want: +
"; + $redirectTime = -1; + } + if (!$thread) { require_once 'lib/layout.php'; - print " - $header
$tblstart - $tccell1>Nice try. Next time, wait until someone makes the thread before trying to reply to it.
".redirect("index.php", 'return to the index page', 0)." - $tblend$footer - "; - printtimedif($startingtime); - die(); + boardmessage("You can't reply to threads that don't exist!
". redirect("index.php", "the forum index", $redirectTime) . $lastchance, "Error"); } - $forumid=intval($thread['forum']); - $forum=$sql->fetchq("SELECT title,minpower,minpowerreply,id,specialscheme FROM forums WHERE id=$forumid"); + $forumid =intval($thread['forum']); + $forum =$sql->fetchq("SELECT title,minpower,minpowerreply,id,specialscheme FROM forums WHERE id=$forumid"); + if ($forum['minpower'] && $power < $forum['minpower']) { - $forum['title'] = ''; - $thread['title'] = '(restricted thread)'; + require_once 'lib/layout.php'; + boardmessage("You aren't allowed to view this thread.
". redirect("index.php", "the forum index", $redirectTime) . $lastchance, "Error"); } - $specialscheme = $forum['specialscheme']; - $windowtitle="$boardname -- $forum[title]: $thread[title] -- New Reply"; - $thread['title']=str_replace('<','<',$thread['title']); + $specialscheme = $forum['specialscheme']; + $windowtitle = "$boardname -- $forum[title]: $thread[title] -- New reply"; + + $thread['title'] = str_replace('<','<',$thread['title']); require_once 'lib/layout.php'; - $smilies=readsmilies(); - if(!filter_int($ppp)) $ppp=(!$log?20:$loguser['postsperpage']); - $fonline=fonlineusers($forumid); - $header=makeheader($header1,$headlinks,$header2 ." $tblstart$tccell1s>$fonline$tblend"); + // Do access checks. Can't post while banned... + if ($power < $forum['minpowerreply'] || $banned) { + boardmessage("You aren't allowed to reply to this thread.
". redirect("thread.php?id=$id", "the thread", $redirectTime) . $lastchance, "Error"); + } - if(mysql_num_rows($sql->query("SELECT user FROM forummods WHERE forum='$forumid' and user='$loguserid'"))) $ismod=1; + // ...or in a closed thread + if ($thread['closed']) { + boardmessage("You can't reply to this thread because it is closed.
". redirect("thread.php?id=$id", "the thread", $redirectTime) . $lastchance, "Error"); + } + + // Check if we are a global moderator, or a local mod of this forum $modoptions = ""; + if ($ismod || mysql_num_rows($sql->query("SELECT user FROM forummods WHERE forum='$forumid' and user='$loguserid'"))) { + $ismod = 1; - if ($ismod) { - if ($thread['sticky'] == 1) $sticky = "checked"; - $modoptions = " $tccell1>Moderator Options:$tccell2l colspan=2> - $inpc=\"close\" id=\"close\" value=\"1\"> - - $inpc=\"stick\" id=\"stick\" value=\"1\" $sticky>"; - } - - if ($forum['minpowerreply'] > $power && $forum['minpowerreply'] > 0) - $restricted = true; - - $header = "$header - $fonttag$boardname - $forum[title] - $thread[title]
$tblstart"; - - // Post preview - if (($power>=$forum['minpowerreply'] || $forum['minpowerreply']<1) && $id>0) { - $postlist="$tccellh colspan=2 style=\"font-weight:bold;\">Thread history$tccellh width=150>User$tccellh width=*>Post"; - $qppp = $ppp + 1; - $posts=$sql->query("SELECT name,posts,sex,powerlevel,user,text,options,num FROM users u,posts p,posts_text WHERE thread=$id AND p.id=pid AND user=u.id ORDER BY p.id DESC LIMIT $qppp"); - $i = 0; - - while($post=$sql->fetch($posts)){ - $bg = ((($i++) & 1) ? 'tdbg2' : 'tdbg1'); - if ($ppp-- > 0){ - $postnum=($post['num']?"$post[num]/":''); - $tcellbg=""; - $namecolor=getnamecolor($post['sex'],$post['powerlevel']); - $postlist.=" - $tcellbg$post[name]$smallfont
- Posts: $postnum$post[posts] - $tcellbg".doreplace2(dofilters($post['text']), $post['options'])." - "; - } - else{ - $tcellbg="=$forum['minpowerreply'] || $forum['minpowerreply']<1) && $id>0) { - print $header; - print ""; - - if ($log) { - $username=$loguser['name']; - $passhint = 'Alternate Login:'; - $altloginjs = "Use an alternate login - "; - } - else { - $username = ''; - $passhint = 'Login Info:'; - $altloginjs = ""; - } - - $quotemsg = ""; - if(filter_int($postid)){ - $post=$sql->fetchq("SELECT user,text,thread FROM posts,posts_text WHERE id=$postid AND id=pid"); - $post['text']=str_replace('
',$br,$post['text']); - $u=$post['user']; - $users[$u]=loaduser($u,1); - if($post['thread']==$id) $quotemsg="[quote={$users[$u]['name']}]{$post['text']}[/quote]\r\n"; - } - - print " - - $tccellh width=150> $tccellh colspan=2>  - $tccell1>{$passhint} $tccell2l colspan=2> - {$altloginjs} - Username: $inpt=username VALUE=\"".htmlspecialchars($username)."\" SIZE=25 MAXLENGTH=25 autocomplete=\"off\"> - - - - - - Password: $inpp=password SIZE=13 MAXLENGTH=64 autocomplete=\"off\"> -
- $tccell1>Reply: - $tccell2l width=800px valign=top> - $txta=message ROWS=21 COLS=$numcols style=\"width: 100%; max-width: 800px; resize:vertical;\">". htmlspecialchars($quotemsg, ENT_QUOTES) ." - $tccell2l width=*>".moodlist(filter_int($moodid))." - - $tccell1> $tccell2l colspan=2> - $inph=action VALUE=postreply> - $inph=id VALUE=$id> - $inph=valid value=\"". md5($_SERVER['REMOTE_ADDR'] . $id ."sillysaltstring") ."\"> - $inps=submit VALUE=\"Submit reply\"> - $inps=preview VALUE=\"Preview reply\"> - $tccell1>Options:$tccell2l colspan=2> - $inpc=\"nosmilies\" id=\"nosmilies\" value=\"1\"> - - $inpc=\"nolayout\" id=\"nolayout\" value=\"1\"> - - $inpc=\"nohtml\" id=\"nohtml\" value=\"1\"> - $modoptions - $tblend -
- $tblstart$postlist$tblend - - - $fonttag$boardname - $forum[title] - $thread[title]"; - } elseif(!$_POST['action']) { - print $header; - print "$tccell1>You are not allowed to post in this thread. -
".redirect("index.php", 'return to the index page', 0).""; + $modoptions = " + + $tccell1>Moderator Options: + $tccell2l> + $inpc='close' id='close' value='1'> - + $inpc='stick' id='stick' value='1'". ($thread['sticky'] ? "checked" : "") ."> + + "; } - if ($_POST['action'] == 'postreply' && !($banned && $log) && $id > 0) { - if ($log && !$password) + if(!filter_int($ppp)) $ppp=(!$log?20:$loguser['postsperpage']); + $smilies = readsmilies(); + $fonline = fonlineusers($forumid); + $header = makeheader($header1,$headlinks,$header2 ."\t$tblstart$tccell1s>$fonline$tblend"); + $breadcrumb = "$boardname - $forum[title] - $thread[title] - New Reply"; + + $header .= "$fonttag$breadcrumb"; + + + // Show the new reply form? + $showform = true; + $usererror = ""; + $preview = ""; + + if (v($_POST['action']) == 'postreply') { + + if ($log) $userid = $loguserid; else - $userid = checkuser($username,$password); + $userid = checkuser($_POST['username'], $_POST['password']); - - $error=''; - - if ($userid == -1) { - $error = "Either you didn't enter an existing username, or you haven't entered the right password for the username."; + if ($userid == -1 || $userid == 0) { + $usererror = " * Invalid username or password."; } else { $user = @$sql->fetchq("SELECT * FROM users WHERE id='$userid'"); - if ($thread['closed']) - $error = 'The thread is closed and no more replies can be posted.'; - if ($user['powerlevel']<$forum['minpowerreply']) - $error = 'Replying in this forum is restricted, and you are not allowed to post in this forum.'; - if (!$message) - $error = "You didn't enter anything in the post."; + if (!$user) { + boardmessage("Something went really weird? Contact an admin: Userid $userid but no user??", "This shouldn't happen"); + } } - if (!$error) { + if ($user) { - $sign = $user['signature']; - $head = $user['postheader']; - // @TODO: Remove this code - if($user['postbg']) $head="
$head"; + $sign = $user['signature']; + $head = $user['postheader']; - $numposts = $user['posts']+ 1; + $numposts = $user['posts'] + 1; - $numdays = (ctime()-$user['regdate'])/86400; + $numdays = (ctime() - $user['regdate']) / 86400; $tags = array(); - $message = doreplace($message,$numposts,$numdays,$username, $tags); + $message = doreplace($message, $numposts, $numdays, $username, $tags); $tagval = $sql->escape(json_encode($tags)); - $rsign = doreplace($sign,$numposts,$numdays,$username); - $rhead = doreplace($head,$numposts,$numdays,$username); + $rsign = doreplace($sign, $numposts, $numdays, $username); + $rhead = doreplace($head, $numposts, $numdays, $username); $currenttime = ctime(); + + // Submitting a post if (filter_string($_POST['submit'])) { $sql->query("UPDATE `users` SET `posts` = $numposts, `lastposttime` = '$currenttime' WHERE `id` = '$userid'"); @@ -231,7 +157,7 @@ return header("Location: thread.php?pid=$pid#$pid"); - + // Previewing a post } else { loadtlayout(); @@ -255,57 +181,125 @@ $ppost['text'] = $message; $ppost['options'] = filter_int($nosmilies) . "|" . filter_int($nohtml); - if($isadmin) $ip=$userip; + $ip = ""; - $chks = array("", "", ""); - if ($nosmilies) $chks[0] = "checked"; - if ($nolayout) $chks[1] = "checked"; - if ($nohtml) $chks[2] = "checked"; - - print "$header - - $tccellh>Post preview - $tblend$tblstart - ".threadpost($ppost,1)." - $tblend
$tblstart -
- $tccellh width=150> $tccellh colspan=2>  - $tccell1>Reply: - $tccell2l width=800px valign=top>$txta=message ROWS=21 COLS=$numcols style=\"width: 100%; max-width: 800px; resize:vertical;\">". htmlspecialchars($message, ENT_QUOTES) ." - $tccell2l width=*>".moodlist($moodid)." - $tccell1> $tccell2l colspan=2> - $inps=submit VALUE=\"Submit reply\"> - $inps=preview VALUE=\"Preview reply\"> - $inph=username VALUE=\"".htmlspecialchars($username)."\"> - $inph=password VALUE=\"".htmlspecialchars($password)."\"> - $inph=valid value=\"". md5($_SERVER['REMOTE_ADDR'] . $id ."sillysaltstring") ."\"> - $inph=action VALUE=postreply> - $inph=id VALUE=$id> - $tccell1>Options:$tccell2l colspan=2> - $inpc=\"nosmilies\" id=\"nosmilies\" value=\"1\" $chks[0]> - - $inpc=\"nolayout\" id=\"nolayout\" value=\"1\" $chks[1]> - - $inpc=\"nohtml\" id=\"nohtml\" value=\"1\" $chks[2]> - $modoptions + $preview = " + $tblstart + $tccellh>Post preview $tblend - - $tblstart$postlist$tblend - - "; + ".threadpost($ppost,1)." +
"; } - } else { - print "$header$tccell1>Couldn't enter the post. $error
".redirect("thread.php?id=$id", $thread['title'], 0); } + } - if ($thread['closed']) { + + // Totally new reply, with optional quote + if ($showform) { + + $userlogin = ""; + if (!$log) { + $userlogin = " + + $tccell1>Username: + $tccell2l>$inpt='username' size='25' maxlength='25' value='". htmlspecialchars(v($_POST['username']), ENT_QUOTES) ."'> $usererror + + $tccell1>Password: + $tccell2l>$inpp='password' size='25' maxlength='64' value='". htmlspecialchars(v($_POST['password']), ENT_QUOTES) ."'> + + "; + } + + $quotemsg = ""; + if (filter_int($postid)) { + $post = $sql->fetchq("SELECT user,text,thread FROM posts,posts_text WHERE id=$postid AND id=pid"); + $post['text'] = str_replace('
', $br, $post['text']); + $u = $post['user']; + $users[$u] = loaduser($u, 1); + if ($post['thread'] == $id) $quotemsg = "[quote={$users[$u]['name']}]{$post['text']}[/quote]\r\n"; + } + + $message = $quotemsg . stripslashes(v($_POST['message'])); + + print "$header + $preview +
+ $tblstartf + + + + + + $tccellh colspan=2>New reply + + $userlogin + + $tccell1 style='width: 150px; max-width: 150px;'>Reply: + $tccell2l>$txta=message class='newposttextbox'>". htmlspecialchars($message, ENT_QUOTES) ." + + $tccell1> $tccell2l> + $inph=action VALUE=postreply> + $inph=id VALUE=$id> + $inph=valid value='". md5($_SERVER['REMOTE_ADDR'] . $id ."sillysaltstring") ."'> + $inps=submit VALUE='Submit reply'> + $inps=preview VALUE='Preview reply'> + + + $tccell1>Mood avatar: + $tccell2l>". moodlist(filter_int($moodid)) ." + + + $tccell1>Options: + $tccell2l> + $inpc='nosmilies' id='nosmilies' value='1'". (v($_POST['nosmilies']) ? " checked" : "") ."> - + $inpc='nolayout' id='nolayout' value='1'". (v($_POST['nolayout']) ? " checked" : "") ."> - + $inpc='nohtml' id='nohtml' value='1'". (v($_POST['nohtml']) ? " checked" : "") ."> + + + $modoptions + $tblend +
+ "; + + + + // Thread history view (under the form) + // (originally had a check for power, but that's accounted for above) + if (true) { + $postlist="$tccellh colspan=2 style=\"font-weight:bold;\">Thread history$tccellh width=150>User$tccellh width=*>Post"; + $qppp = $ppp + 1; + $posts=$sql->query("SELECT name,posts,sex,powerlevel,user,text,options,num FROM users u,posts p,posts_text WHERE thread=$id AND p.id=pid AND user=u.id ORDER BY p.id DESC LIMIT $qppp"); + $i = 0; + + while($post=$sql->fetch($posts)){ + $bg = ((($i++) & 1) ? 'tdbg2' : 'tdbg1'); + if ($ppp-- > 0){ + $postnum=($post['num']?"$post[num]/":''); + $tcellbg=""; + $namecolor=getnamecolor($post['sex'],$post['powerlevel']); + $postlist.=" + $tcellbg$post[name]$smallfont
+ Posts: $postnum$post[posts] + $tcellbg".doreplace2(dofilters($post['text']), $post['options'])." + "; + } + else{ + $tcellbg="Sorry, but this thread is closed, and no more replies can be posted in it. -
".redirect("thread.php?id=$id",$thread['title'],0); - } elseif($banned and $log) { - print " - $tccell1>Sorry, but you are banned from the board, and can not post. -
".redirect("thread.php?id=$id",$thread['title'],0); + $tblstart + $postlist + $tblend + $fonttag + $breadcrumb"; } + + print $footer; printtimedif($startingtime);