Fix and add thread meta tags

This commit is contained in:
Xkeeper 2017-07-19 00:20:25 -07:00
parent f50d45104c
commit 4fdd16cf57
2 changed files with 27 additions and 28 deletions

View File

@ -10,7 +10,7 @@
header('Pragma: no-cache'); header('Pragma: no-cache');
$userip = $_SERVER['REMOTE_ADDR']; $userip = $_SERVER['REMOTE_ADDR'];
if (!($clientip = filter_var(getenv("HTTP_CLIENT_IP"), FILTER_VALIDATE_IP))) $clientip = "XXXXXXXXXXXXXXXXX"; if (!($clientip = filter_var(getenv("HTTP_CLIENT_IP"), FILTER_VALIDATE_IP))) $clientip = "XXXXXXXXXXXXXXXXX";
if (!($forwardedip = filter_var(getenv("HTTP_X_FORWARDED_FOR"), FILTER_VALIDATE_IP))) $forwardedip = "XXXXXXXXXXXXXXXXX"; if (!($forwardedip = filter_var(getenv("HTTP_X_FORWARDED_FOR"), FILTER_VALIDATE_IP))) $forwardedip = "XXXXXXXXXXXXXXXXX";
// $clientip=(getenv("HTTP_CLIENT_IP") == "" ? "XXXXXXXXXXXXXXXXX" : getenv("HTTP_CLIENT_IP")); // $clientip=(getenv("HTTP_CLIENT_IP") == "" ? "XXXXXXXXXXXXXXXXX" : getenv("HTTP_CLIENT_IP"));
@ -285,17 +285,17 @@
} }
$views=$sql->resultq('SELECT views FROM misc')+1; $views=$sql->resultq('SELECT views FROM misc')+1;
if (!$ipbanned && !$torbanned && (!defined("IS_AJAX_REQUEST") || !IS_AJAX_REQUEST)) { if (!$ipbanned && !$torbanned && (!defined("IS_AJAX_REQUEST") || !IS_AJAX_REQUEST)) {
// Don't increment the view counter for bots // Don't increment the view counter for bots
// Todo: Actually check for bots and disable it because hdurfs // Todo: Actually check for bots and disable it because hdurfs
$sql->query("UPDATE misc SET views=$views"); $sql->query("UPDATE misc SET views=$views");
if($views%10000000>9999000 or $views%10000000<1000) { if($views%10000000>9999000 or $views%10000000<1000) {
$u=($loguserid?$loguserid:0); $u=($loguserid?$loguserid:0);
$sql->query("INSERT INTO hits VALUES ($views,$u,'$userip',".ctime().')'); $sql->query("INSERT INTO hits VALUES ($views,$u,'$userip',".ctime().')');
} }
// Print out a message to IRC whenever a 10-million-view milestone is hit // Print out a message to IRC whenever a 10-million-view milestone is hit
if ($views%10000000>9999994 || ($views % 10000000 >= 9991000 && $views % 1000 == 0) || ($views % 10000000 >= 9999900 && $views % 10 == 0) || ($views > 5 && $views % 10000000 < 5)) { if ($views%10000000>9999994 || ($views % 10000000 >= 9991000 && $views % 1000 == 0) || ($views % 10000000 >= 9999900 && $views % 10 == 0) || ($views > 5 && $views % 10000000 < 5)) {
xk_ircsend("0|View ". xk(11) . str_pad(number_format($views), 10, " ", STR_PAD_LEFT) . xk() ." by ". ($loguser['id'] ? xk(11) . str_pad($loguser['name'], 25, " ") : xk(12) . str_pad($_SERVER['REMOTE_ADDR'], 25, " ")) . xk() . ($views % 1000000 > 500000 ? " (". xk(12) . str_pad(number_format(1000000 - ($views % 1000000)), 5, " ", STR_PAD_LEFT) . xk(2) ." to go" . xk() .")" : "")); xk_ircsend("0|View ". xk(11) . str_pad(number_format($views), 10, " ", STR_PAD_LEFT) . xk() ." by ". ($loguser['id'] ? xk(11) . str_pad($loguser['name'], 25, " ") : xk(12) . str_pad($_SERVER['REMOTE_ADDR'], 25, " ")) . xk() . ($views % 1000000 > 500000 ? " (". xk(12) . str_pad(number_format(1000000 - ($views % 1000000)), 5, " ", STR_PAD_LEFT) . xk(2) ." to go" . xk() .")" : ""));
@ -359,7 +359,7 @@
$yyy .= "<img src=images/wave/seaweed.png style=\"position: fixed; left: ". mt_rand(0,100) ."%; bottom: -". mt_rand(24,72) ."px;\" title=\"weed\">"; $yyy .= "<img src=images/wave/seaweed.png style=\"position: fixed; left: ". mt_rand(0,100) ."%; bottom: -". mt_rand(24,72) ."px;\" title=\"weed\">";
} }
}*/ }*/
$dispviews = $views; $dispviews = $views;
// if (($views % 1000000 >= 999000) && ($views % 1000000 < 999990)) // if (($views % 1000000 >= 999000) && ($views % 1000000 < 999990))
// $dispviews = substr((string)$views, 0, -3) . "???"; // $dispviews = substr((string)$views, 0, -3) . "???";
@ -376,15 +376,14 @@
if (filter_bool($meta['noindex'])) if (filter_bool($meta['noindex']))
$metatag .= "<meta name=\"robots\" content=\"noindex,follow\" />"; $metatag .= "<meta name=\"robots\" content=\"noindex,follow\" />";
if (filter_bool($meta['description'])) if (isset($meta['description']))
$metatag .= "<meta name=\"description\" content=\"{$meta['description']}\" />"; $metatag .= "<meta name=\"description\" content=\"{$meta['description']}\" />";
if (filter_bool($x_hacks['smallbrowse']) and false) { if (isset($meta['canonical'])) {
$css = ""; $metatag .= "<link rel='canonical' href='{$meta['canonical']}'";
$css = "<link rel='stylesheet' href='/mobile.css'>";
} }
$header1="<html><head><meta http-equiv='Content-type' content='text/html; charset=utf-8'><title>$windowtitle</title> $header1="<html><head><meta http-equiv='Content-type' content='text/html; charset=utf-8'><meta name='viewport' content='width=device-width, initial-scale=1'><title>$windowtitle</title>
$metatag $metatag
<link rel=\"shortcut icon\" href=\"/favicon". (!$x_hacks['host'] ? rand(1,8) ."" : "" ) .".ico\" type=\"image/x-icon\"> <link rel=\"shortcut icon\" href=\"/favicon". (!$x_hacks['host'] ? rand(1,8) ."" : "" ) .".ico\" type=\"image/x-icon\">
$css $css
@ -400,7 +399,7 @@
</td><tr> </td><tr>
<td width='120px' class='tbl tdbg2 center fonts'><nobr>Views: $dispviews<br><img src=images/_.gif width=120 height=1></td> <td width='120px' class='tbl tdbg2 center fonts'><nobr>Views: $dispviews<br><img src=images/_.gif width=120 height=1></td>
<td width='100%' class='tbl tdbg2 center fonts'>$headlinks2</td> <td width='100%' class='tbl tdbg2 center fonts'>$headlinks2</td>
<td width='120px' class='tbl tdbg2 center fonts'><nobr>". date($dateformat,ctime()+$tzoff) ."<br><img src=images/_.gif width=120 height=1><tr>" <td width='120px' class='tbl tdbg2 center fonts'><nobr>". date($dateformat,ctime()+$tzoff) ."<br><img src=images/_.gif width=120 height=1><tr>"
: "<br>$dispviews views, ". date($dateformat,ctime()+$tzoff) ." : "<br>$dispviews views, ". date($dateformat,ctime()+$tzoff) ."
</td><tr> </td><tr>
<td width=100% class='tbl tdbg2 center fonts' colspan=3>$headlinks2</td><tr>") ." <td width=100% class='tbl tdbg2 center fonts' colspan=3>$headlinks2</td><tr>") ."
@ -422,16 +421,16 @@
$ref=filter_string($_SERVER['HTTP_REFERER']); $ref=filter_string($_SERVER['HTTP_REFERER']);
$url=getenv('SCRIPT_URL'); $url=getenv('SCRIPT_URL');
if(!$url) $url=str_replace('/etc/board','',getenv('SCRIPT_NAME')); if(!$url) $url=str_replace('/etc/board','',getenv('SCRIPT_NAME'));
$q=getenv('QUERY_STRING'); $q=getenv('QUERY_STRING');
if($q) $url.="?$q"; if($q) $url.="?$q";
if($ref && substr($ref,7,7)!="jul.rus") $sql->query("INSERT INTO referer (time,url,ref,ip) VALUES (". ctime() .", '".addslashes($url)."', '".addslashes($ref)."', '". $_SERVER['REMOTE_ADDR'] ."')"); if($ref && substr($ref,7,7)!="jul.rus") $sql->query("INSERT INTO referer (time,url,ref,ip) VALUES (". ctime() .", '".addslashes($url)."', '".addslashes($ref)."', '". $_SERVER['REMOTE_ADDR'] ."')");
$sql->query("DELETE FROM guests WHERE ip='$userip' OR date<".(ctime()-300)); $sql->query("DELETE FROM guests WHERE ip='$userip' OR date<".(ctime()-300));
if($log) { if($log) {
/* /*
$ulastip=mysql_result(mysql_query("SELECT lastip FROM users WHERE id=$loguserid"),0,0); $ulastip=mysql_result(mysql_query("SELECT lastip FROM users WHERE id=$loguserid"),0,0);
@ -467,7 +466,7 @@
} else { } else {
$sql->query("INSERT INTO guests (ip,date,useragent,lasturl) VALUES ('$userip',".ctime().",'".addslashes($_SERVER['HTTP_USER_AGENT']) ."','". addslashes($url) ."')"); $sql->query("INSERT INTO guests (ip,date,useragent,lasturl) VALUES ('$userip',".ctime().",'".addslashes($_SERVER['HTTP_USER_AGENT']) ."','". addslashes($url) ."')");
} }
@ -494,7 +493,7 @@
<td> <td>
{$smallfont} {$smallfont}
Acmlmboard - <a href='https://github.com/Xkeeper0/jul'>". (file_exists('version.txt') ? file_get_contents("version.txt") : shell_exec("git log --format='commit %h [%ad]' --date='short' -n 1")) ."</a> Acmlmboard - <a href='https://github.com/Xkeeper0/jul'>". (file_exists('version.txt') ? file_get_contents("version.txt") : shell_exec("git log --format='commit %h [%ad]' --date='short' -n 1")) ."</a>
<br>&copy;2000-". date("Y") ." Acmlm, Xkeeper, Inuyasha, et al. <br>&copy;2000-". date("Y") ." Acmlm, Xkeeper, Inuyasha, et al.
</font> </font>
</td> </td>
</tr></table> </tr></table>
@ -540,6 +539,3 @@ piwikTracker.enableLinkTracking();
<br> <br>
<br>E-mail: xkeeper@gmail.com <br>E-mail: xkeeper@gmail.com
$tblend$footer"); $tblend$footer");

View File

@ -20,7 +20,7 @@
if ($id && (filter_int($_GET['addvote']) || filter_int($_GET['delvote']))) { if ($id && (filter_int($_GET['addvote']) || filter_int($_GET['delvote']))) {
$option = (($_GET['addvote']) ? 'addvote' : 'delvote'); $option = (($_GET['addvote']) ? 'addvote' : 'delvote');
$choice = filter_int($_GET[$option]); $choice = filter_int($_GET[$option]);
$pollid = $sql->resultq("SELECT poll FROM threads WHERE id='{$id}'"); $pollid = $sql->resultq("SELECT poll FROM threads WHERE id='{$id}'");
if (!$pollid) if (!$pollid)
return header("Location: ?id={$id}#{$id}"); return header("Location: ?id={$id}#{$id}");
@ -56,6 +56,9 @@
} }
$numposts = $sql->resultq("SELECT COUNT(*) FROM `posts` WHERE `thread` = '{$id}' AND `id` < '{$pid}'"); $numposts = $sql->resultq("SELECT COUNT(*) FROM `posts` WHERE `thread` = '{$id}' AND `id` < '{$pid}'");
$page = floor($numposts / $ppp); $page = floor($numposts / $ppp);
// Canonical page w/o ppp link (for bots)
$meta['canonical'] = "thread.php?id=$id&page=$page";
} }
define('E_BADPOSTS', -1); define('E_BADPOSTS', -1);
@ -90,7 +93,7 @@
} }
$thread['title'] = str_replace("<", "&lt;", $thread['title']); $thread['title'] = str_replace("<", "&lt;", $thread['title']);
$forumid = intval($thread['forum']); $forumid = intval($thread['forum']);
$forum = $sql->fetchq("SELECT * FROM forums WHERE id=$forumid"); $forum = $sql->fetchq("SELECT * FROM forums WHERE id=$forumid");
@ -175,7 +178,7 @@
$meta['noindex'] = true; // prevent search engines from indexing what they can't access $meta['noindex'] = true; // prevent search engines from indexing what they can't access
require_once 'lib/layout.php'; require_once 'lib/layout.php';
errorpage("No thread specified.",'the index page',"index.php"); errorpage("No thread specified.",'the index page',"index.php");
} }
//temporary //temporary
if ($windowtitle) $windowtitle = "$boardname -- $windowtitle"; if ($windowtitle) $windowtitle = "$boardname -- $windowtitle";
@ -186,7 +189,7 @@
$fonline = fonlineusers($forumid); $fonline = fonlineusers($forumid);
if (mysql_num_rows($sql->query("SELECT user FROM forummods WHERE forum='$forumid' and user='$loguserid'"))) if (mysql_num_rows($sql->query("SELECT user FROM forummods WHERE forum='$forumid' and user='$loguserid'")))
$ismod = true; $ismod = true;
} }
$modfeats = ''; $modfeats = '';
if ($id && $ismod) { if ($id && $ismod) {
$trashid = 27; $trashid = 27;
@ -354,7 +357,7 @@
$page = max(0, filter_int($page)); $page = max(0, filter_int($page));
$min = $ppp * $page; $min = $ppp * $page;
if ($user) $searchon = "user={$user}"; if ($user) $searchon = "user={$user}";
else $searchon = "thread={$id}"; else $searchon = "thread={$id}";
@ -392,7 +395,7 @@
$pthread = $sql->fetchq("SELECT id,title,forum FROM threads WHERE id=$post[thread]", MYSQL_BOTH, true); $pthread = $sql->fetchq("SELECT id,title,forum FROM threads WHERE id=$post[thread]", MYSQL_BOTH, true);
$pforum = $sql->fetchq("SELECT minpower FROM forums WHERE id=".intval($pthread[forum]), MYSQL_BOTH, true); $pforum = $sql->fetchq("SELECT minpower FROM forums WHERE id=".intval($pthread[forum]), MYSQL_BOTH, true);
} }
$post['act'] = filter_int($act[$post['user']]); $post['act'] = filter_int($act[$post['user']]);
if (!$pforum || $pforum['minpower'] <= $power) if (!$pforum || $pforum['minpower'] <= $power)
@ -430,7 +433,7 @@
$pagelinks .= " ..."; $pagelinks .= " ...";
} }
} }
if ($i == $page) if ($i == $page)
$pagelinks .= " ".($i + 1); $pagelinks .= " ".($i + 1);
else else
@ -455,4 +458,4 @@ function notAuthorizedError() {
$redir = (($log) ? 'index.php' : 'login.php'); $redir = (($log) ? 'index.php' : 'login.php');
$rtext = (($log) ? 'the index page' : 'log in (then try again)'); $rtext = (($log) ? 'the index page' : 'log in (then try again)');
errorpage("Couldn't enter the forum. You don't have access to this restricted forum.", $rtext, $redir); errorpage("Couldn't enter the forum. You don't have access to this restricted forum.", $rtext, $redir);
} }