selectitem('id', 'linkstable', fieldmatchcond('title', unrewritetitle($linktitle))." AND deleted=0"); if (!$switches['comments']) throw404(); // this page is not applicable, so get rid of the spiders $disablejavascriptquickreply = false; if (ismobile()) $disablejavascriptquickreply = true; // javascript quickpost method fails on some phones and is off screen so not intuitive, so let's disable it on mobile devices $format = paramvalue('format'); $modnote = paramvalue('modnote'); // allow using next and previous links on comments page if (!paramset('orderlinks')) $orderlinks = $settings->orderlinks; $condition = 'validated=1 AND deleted=0 AND hide=0'; if (paramset('catid') && $catid > 0) $condition .= ' AND catid='. $catid; if (paramset('orderid') && is_numeric($orderid) && $orderid > 0) { $getit = $db->select('all', 'linkstable', $condition, $orderlinks, "LIMIT $orderid,1"); $n = $db->numrows($getit); if ($n) { $thislink = new onelink('row', $db->row($getit)); if ($orderid == 0) $previous = $orderid; } else { $orderid = $orderid - 1; $getit = $db->select('all', 'linkstable', $condition, $orderlinks, "LIMIT $orderid,1"); $row = $db->row($getit); $thislink = new onelink('row', $row); if ($orderid == 0) $previous = $orderid; } if ($thislink) $id = $thislink->id; } // end (for now -- more to follow way below) allow using next and previous links on comments page setflag('commentspage'); $settings->searchhighlightexclude .= 'postername,name,'; $settings->searchhighlightexclude .= trim($settings->searchhighlightexclude, ','); if (paramset('highlight')) { $searchhighlight = true; $searchhighlightterms = explode(' ', $highlight); } // find thread for post if (paramset('post') && !$linkid && !$id) { $p = new comment('id', $post); $id = $p->linkid; } // check that this is a valid thread if (paramset('linkid')) $linkid = paramvalue('linkid'); else $linkid = $id; if ($linkid == '') { // fix obscure rewrite issue $url = str_replace($settings->dirurl .'/', '', currenturl()); $url = str_replace($settings->rewritethread, '', $url); $url = trim($url, '/'); $bits = explode('/', $url); $linkid = $bits[0]; $page = $bits[1]; } if (paramset('goto')) { $l = new onelink('id', $linkid); $condition = 'validated=1 AND hide=0 AND deleted=0'; if ($catid > 0) $condition .= ' AND catid='. $catid; if ($goto == 'previous') { $getid = $db->select('id', 'linkstable', $condition .' AND lastcomment < '. $l->lastcomment, 'ORDER BY lastcomment DESC', 'LIMIT 0,1'); if ($db->numrows($getid)) $linkid = $db->rowitem($getid); } else if ($goto == 'next') { $getid = $db->select('id', 'linkstable', $condition .' AND lastcomment > '. $l->lastcomment, 'ORDER BY lastcomment ASC', 'LIMIT 0,1'); if ($db->numrows($getid)) $linkid = $db->rowitem($getid); } } if (paramvalue('format') == 'events') { if ($memid == '') $memid = $id; if (!$memid) endwithbadrequest(); $thislink = new member('id', $memid); $path[0][0] = $settings->dirurl .'/profile.php'; $path[1][0] = $language->title_memhome; $dest = 'comments.php?format=events&id='. $id; $itemcond = "eventid={$thislink->id}"; //$area = $thislink->replacements($language->title_eventcomments); } else if (paramvalue('format') == 'usernotes') { if (!isset($memid) || $memid == '') $memid = $id; if (!$memid) endwithbadrequest(); $thislink = new member('id', $memid); $thislink->deleted = 0; $thislink->internalto = 0; $internalto = 0; $thislink->lastedit = $thislink->time; $path[0][0] = $settings->dirurl .'/profile.php'; $path[1][0] = $language->title_memhome; $dest = 'comments.php?format=usernotes&modnote='.paramvalue('modnote').'&id='. $id; if (paramset('modnote')) { $itemcond = "usernoteon={$thislink->id} AND modnote=1"; $area = $thislink->replacements($language->title_modnotes); } else { $itemcond = "usernoteon={$thislink->id} AND modnote=0"; $area = $thislink->replacements($language->title_guestbook); } } else if (paramvalue('format') == 'savedcollection') { if ($memid == '') $memid = $id; if (!$memid) endwithbadrequest(); $thislink = new member('id', $memid); $path[0][0] = $settings->dirurl .'/profile.php'; $path[1][0] = $language->title_memhome; $dest = 'comments.php?format=savedcollection&id='. $id; $itemcond = "savedcollection={$thislink->id}"; $area = $thislink->replacements($language->title_savedcollection); } else { if ($lin && $lin->id == $linkid) $thislink = $lin; // created in start.php else $thislink = new onelink('id', $linkid); $area = $thislink->replacements($language->title_comments); $itemcond = "linkid=".$thislink->effectiveid(); } $lastreadid = 0; if ($thismember->isregistered() && !paramset('format')) $lastreadid = $db->selectitem('lastcommentid', 'lastreadtable', "ownerid='{$thismember->id}' AND linkid=".$thislink->effectiveid()); if ($thislink->objecttype == 'link' && $thislink->archived) { $commentstable = $prefix.'archivedcomments'; $settings->commentsfields = $settings->archivedcommentsfields; } if (paramvalue('page') == 999999) { redirect302($thislink->threadurl(ceil($thislink->numcomments() / $thismember->commentsperpage())).'#lastpost'); // redirect to last page, last post in a way that doesn't count as duplicate content } if (paramvalue('filled') == 1 && paramvalue('action') == 'addtags') { $tags = listtoarray($tags); $n = safecount($tags); for ($x=0; $x<$n; $x++) { $t = new tag($tags[$x], $thislink, $thismember->id); $t->add(); } redirect("", $returnurl, true); } if ($thislink->objecttype == 'link' && $thislink->pollid > 0) $thispoll = new poll('id', $thislink->pollid); if ($thislink->objecttype == 'link' && $thislink->catid) { $thiscategory = $thislink->makecat(); $thiscategory->extractpermissions(); } else $thiscategory = new category('blank', 'blank'); if ($thislink->objecttype != 'member') $cache['categories'][$thislink->catid] = $thiscategory; // prevents recalculating a lot later $cache['links'][$thislink->id] = $thislink; // prevents recalculating a lot later if ($thislink->objecttype == 'link' && $thislink->threadclosed && !$thismember->isadmin() && !$thismember->ismoderator()) $thismember->groupcansubmitcomments = 0; if (!$thislink->id) { if ($archiveurl) { $url = $archiveurl."comments.php?id=".$linkid."&page=".$page; redirect302($url); } else endwithbadrequest(); } if (!$thislink->makecat()->canviewlinkdetails()) { $thislink->makecat()->nopermission(); } if ($thislink->objecttype == 'link' && $thislink->deleted == 1 && !$thismember->groupcanviewdeleted && !$thiscategory->ismoderator()) { $template = new template('noaccess.tpl'); } if ($thiscategory->reqlinks > 0 || $thiscategory->reqcoms > 0) { if (($thismember->links < $thiscategory->reqlinks) || ($thismember->comments < $thiscategory->reqcoms)) $thismember->groupcansubmitcomments = 0; } // add name to thread viewers list if ($settings->trackviews == 'yes') { if (!strstr('[END]'. $thislink->threadviewers, '[END]'. $thismember->id .'[,]')) { $thislink->threadviewers .= $thismember->id .'[,]'. $thismember->name .'[END]'; $thislink->update('threadviewers'); } } if (!$thislink->validated || !isset($thislink->id)) endwithbadrequest(); if ($action == 'subscribe') { $message = $thislink->subscribe($thismember->id); $dest = $redirects['aftersubscribecom']; $message = $thislink->replacements($message); $dest = str_replace('{ID}', $thislink->id, $dest); $dest = $thislink->replacements($dest); redirect($message, $dest); } else if ($action == 'pollvote' && $thispoll->open()) { $mes = $thispoll->castvote(); redirect($mes, $thislink->threadurl()); } if (!$action) { // access with comments.php?id=linkid&page=x // set cookie to mark comment thread as read if (strstr(getcookievalue('commentsread'), "]".$id."[,]")) { $linksread = getcookievalue('commentsread'); $remove = limitedtemplateextract($linksread, "]".$id."[,]", '[END]'); $linksread = str_replace($remove, "]".$id."[,]". time() .'[END]', $linksread); } else { if (!getcookievalue('commentsread')) $linksread = "[END]".$id."[,]". time() .'[END]'; else $linksread = getcookievalue('commentsread') . "$id"."[,]". time() .'[END]'; } if ($linksread && strlen($linksread) > 1900) { $linksread = ''; } makecookie('commentsread', $linksread, time() + 999999); // troublesome for opera somehow if ($switches['detailcomments'] && !$format) { include 'includes/detailandcomments.php'; } else { if ($format == 'usernotes' && paramset('modnote')) maketemplate('usernotes.tpl'); else if ($format == 'usernotes') maketemplate('guestbook.tpl'); else if ($format == 'savedcollection') maketemplate('savedcollection.tpl'); else if ($format == 'events') maketemplate('eventcomments.tpl'); else maketemplate('viewcomments.tpl'); if ($thislink->objecttype == 'link' && $thislink->expire > 0 && $thislink->expire < time()) $template->text = '