- global $itemid, $blogid, $memberid, $query, $amount, $archivelist, $maxresults;\r
- global $archive, $skinid, $blog, $memberinfo, $CONF, $member;\r
- global $imagepopup, $catid, $special;\r
- global $manager;\r
-\r
- $actionNames = array('addcomment', 'sendmessage', 'createaccount', 'forgotpassword', 'votepositive', 'votenegative', 'plugin');\r
- $action = requestVar('action');\r
-\r
- if (in_array($action, $actionNames) ) {\r
- global $DIR_LIBS, $errormessage;\r
- include_once($DIR_LIBS . 'ACTION.php');\r
- $a = new ACTION();\r
- $errorInfo = $a->doAction($action);\r
-\r
- if ($errorInfo) {\r
- $errormessage = $errorInfo['message'];\r
- }\r
- }\r
-\r
- // show error when headers already sent out\r
- if (headers_sent() && $CONF['alertOnHeadersSent']) {\r
-\r
- // try to get line number/filename (extra headers_sent params only exists in PHP 4.3+)\r
- if (function_exists('version_compare') && version_compare('4.3.0', phpversion(), '<=') ) {\r
- headers_sent($hsFile, $hsLine);\r
- $extraInfo = sprintf(_GFUNCTIONS_HEADERSALREADYSENT_FILE,$hsFile,$hsLine);\r
- } else {\r
- $extraInfo = '';\r
- }\r
-\r
- startUpError(\r
- sprintf(_GFUNCTIONS_HEADERSALREADYSENT_TXT,$extraInfo),\r
- _GFUNCTIONS_HEADERSALREADYSENT_TITLE\r
- );\r
- exit;\r
- }\r
-\r
- // make is so ?archivelist without blogname or blogid shows the archivelist\r
- // for the default weblog\r
- if (serverVar('QUERY_STRING') == 'archivelist') {\r
- $archivelist = $CONF['DefaultBlog'];\r
- }\r
-\r
- // now decide which type of skin we need\r
- if ($itemid) {\r
- // itemid given -> only show that item\r
- $type = 'item';\r
-\r
- if (!$manager->existsItem($itemid,0,0) ) {\r
- doError(_ERROR_NOSUCHITEM);\r
- }\r
-\r
- global $itemidprev, $itemidnext, $catid, $itemtitlenext, $itemtitleprev;\r
-\r
- // 1. get timestamp, blogid and catid for item\r
- $query = 'SELECT itime, iblog, icat FROM ' . sql_table('item') . ' WHERE inumber=' . intval($itemid);\r
- $res = sql_query($query);\r
- $obj = sql_fetch_object($res);\r
-\r
- // if a different blog id has been set through the request or selectBlog(),\r
- // deny access\r
-// if ($blogid && (intval($blogid) != $obj->iblog) ) {\r
-// doError(_ERROR_NOSUCHITEM);\r
-// }\r
- if ($blogid && (intval($blogid) != $obj->iblog) ) {\r
- if (!headers_sent()) {\r
- $b =& $manager->getBlog($obj->iblog);\r
- $CONF['ItemURL'] = $b->getURL();\r
- if ($CONF['URLMode'] == 'pathinfo' and substr($CONF['ItemURL'],-1) == '/')\r
- $CONF['ItemURL'] = substr($CONF['ItemURL'], 0, -1);\r
- $correctURL = createItemLink($itemid, '');\r
- redirect($correctURL);\r
- exit;\r
- } else {\r
- doError(_ERROR_NOSUCHITEM);\r
- }\r
- }\r
-\r
- // if a category has been selected which doesn't match the item, ignore the\r
- // category. #85\r
- if (($catid != 0) && ($catid != $obj->icat) ) {\r
- $catid = 0;\r
- }\r
-\r
- $blogid = $obj->iblog;\r
- $timestamp = strtotime($obj->itime);\r
-\r
- $b =& $manager->getBlog($blogid);\r
-\r
- if ($b->isValidCategory($catid) ) {\r
- $catextra = ' and icat=' . $catid;\r
- } else {\r
- $catextra = '';\r
- }\r
-\r
- // get previous itemid and title\r
- $query = 'SELECT inumber, ititle FROM ' . sql_table('item') . ' WHERE itime<' . mysqldate($timestamp) . ' and idraft=0 and iblog=' . $blogid . $catextra . ' ORDER BY itime DESC LIMIT 1';\r
- $res = sql_query($query);\r
-\r
- $obj = sql_fetch_object($res);\r
-\r
- if ($obj) {\r
- $itemidprev = $obj->inumber;\r
- $itemtitleprev = $obj->ititle;\r
- }\r
-\r
- // get next itemid and title\r
- $query = 'SELECT inumber, ititle FROM ' . sql_table('item') . ' WHERE itime>' . mysqldate($timestamp) . ' and itime <= ' . mysqldate($b->getCorrectTime()) . ' and idraft=0 and iblog=' . $blogid . $catextra . ' ORDER BY itime ASC LIMIT 1';\r
- $res = sql_query($query);\r
-\r
- $obj = sql_fetch_object($res);\r
-\r
- if ($obj) {\r
- $itemidnext = $obj->inumber;\r
- $itemtitlenext = $obj->ititle;\r
- }\r
-\r
- } elseif ($archive) {\r
- // show archive\r
- $type = 'archive';\r
-\r
- // get next and prev month links ...\r
- global $archivenext, $archiveprev, $archivetype, $archivenextexists, $archiveprevexists;\r
-\r
- // sql queries for the timestamp of the first and the last published item\r
- $query = "SELECT UNIX_TIMESTAMP(itime) as result FROM ".sql_table('item')." WHERE idraft=0 AND iblog=".(int)($blogid ? $blogid : $CONF['DefaultBlog'])." ORDER BY itime ASC";\r
- $first_timestamp=quickQuery ($query);\r
- $query = "SELECT UNIX_TIMESTAMP(itime) as result FROM ".sql_table('item')." WHERE idraft=0 AND iblog=".(int)($blogid ? $blogid : $CONF['DefaultBlog'])." ORDER BY itime DESC";\r
- $last_timestamp=quickQuery ($query);\r
-\r
- sscanf($archive, '%d-%d-%d', $y, $m, $d);\r
-\r
- if ($d != 0) {\r
- $archivetype = _ARCHIVETYPE_DAY;\r
- $t = mktime(0, 0, 0, $m, $d, $y);\r
- // one day has 24 * 60 * 60 = 86400 seconds\r
- $archiveprev = strftime('%Y-%m-%d', $t - 86400 );\r
- // check for published items\r
- if ($t > $first_timestamp) {\r
- $archiveprevexists = true;\r
- }\r
- else {\r
- $archiveprevexists = false;\r
- }\r
-\r
- // one day later\r
- $t += 86400;\r
- $archivenext = strftime('%Y-%m-%d', $t);\r
- if ($t < $last_timestamp) {\r
- $archivenextexists = true;\r
- }\r
- else {\r
- $archivenextexists = false;\r
- }\r
-\r
- } elseif ($m == 0) {\r
- $archivetype = _ARCHIVETYPE_YEAR;\r
- $t = mktime(0, 0, 0, 12, 31, $y - 1);\r
- // one day before is in the previous year\r
- $archiveprev = strftime('%Y', $t);\r
- if ($t > $first_timestamp) {\r
- $archiveprevexists = true;\r
- }\r
- else {\r
- $archiveprevexists = false;\r
- }\r
-\r
- // timestamp for the next year\r
- $t = mktime(0, 0, 0, 1, 1, $y + 1);\r
- $archivenext = strftime('%Y', $t);\r
- if ($t < $last_timestamp) {\r
- $archivenextexists = true;\r
- }\r
- else {\r
- $archivenextexists = false;\r
- }\r
- } else {\r
- $archivetype = _ARCHIVETYPE_MONTH;\r
- $t = mktime(0, 0, 0, $m, 1, $y);\r
- // one day before is in the previous month\r
- $archiveprev = strftime('%Y-%m', $t - 86400);\r
- if ($t > $first_timestamp) {\r
- $archiveprevexists = true;\r
- }\r
- else {\r
- $archiveprevexists = false;\r
- }\r
-\r
- // timestamp for the next month\r
- $t = mktime(0, 0, 0, $m+1, 1, $y);\r
- $archivenext = strftime('%Y-%m', $t);\r
- if ($t < $last_timestamp) {\r
- $archivenextexists = true;\r
- }\r
- else {\r
- $archivenextexists = false;\r
- }\r
- }\r
-\r
- } elseif ($archivelist) {\r
- $type = 'archivelist';\r
-\r
- if (is_numeric($archivelist)) {\r
- $blogid = intVal($archivelist);\r
- } else {\r
- $blogid = getBlogIDFromName($archivelist);\r
- }\r
-\r
- if (!$blogid) {\r
- doError(_ERROR_NOSUCHBLOG);\r
- }\r
-\r
- } elseif ($query) {\r
- global $startpos;\r
- $type = 'search';\r
- $query = stripslashes($query);\r
- if(preg_match("/^(\xA1{2}|\xe3\x80{2}|\x20)+$/", $query)){\r
- $type = 'index';\r
- }\r
+ global $itemid, $blogid, $memberid, $query, $amount, $archivelist, $maxresults;\r
+ global $archive, $skinid, $blog, $memberinfo, $CONF, $member;\r
+ global $imagepopup, $catid, $special;\r
+ global $manager;\r
+\r
+ $actionNames = array('addcomment', 'sendmessage', 'createaccount', 'forgotpassword', 'votepositive', 'votenegative', 'plugin');\r
+ $action = requestVar('action');\r
+\r
+ if (in_array($action, $actionNames) ) {\r
+ global $DIR_LIBS, $errormessage;\r
+ include_once($DIR_LIBS . 'ACTION.php');\r
+ $a = new ACTION();\r
+ $errorInfo = $a->doAction($action);\r
+\r
+ if ($errorInfo) {\r
+ $errormessage = $errorInfo['message'];\r
+ }\r
+ }\r
+\r
+ // show error when headers already sent out\r
+ if (headers_sent() && $CONF['alertOnHeadersSent']) {\r
+\r
+ // try to get line number/filename (extra headers_sent params only exists in PHP 4.3+)\r
+ if (function_exists('version_compare') && version_compare('4.3.0', phpversion(), '<=') ) {\r
+ headers_sent($hsFile, $hsLine);\r
+ $extraInfo = sprintf(_GFUNCTIONS_HEADERSALREADYSENT_FILE,$hsFile,$hsLine);\r
+ } else {\r
+ $extraInfo = '';\r
+ }\r
+\r
+ startUpError(\r
+ sprintf(_GFUNCTIONS_HEADERSALREADYSENT_TXT,$extraInfo),\r
+ _GFUNCTIONS_HEADERSALREADYSENT_TITLE\r
+ );\r
+ exit;\r
+ }\r
+\r
+ // make is so ?archivelist without blogname or blogid shows the archivelist\r
+ // for the default weblog\r
+ if (serverVar('QUERY_STRING') == 'archivelist') {\r
+ $archivelist = $CONF['DefaultBlog'];\r
+ }\r
+\r
+ // now decide which type of skin we need\r
+ if ($itemid) {\r
+ // itemid given -> only show that item\r
+ $type = 'item';\r
+\r
+ if (!$manager->existsItem($itemid,intval($CONF['allowFuture']),intval($CONF['allowDrafts']))) {\r
+ doError(_ERROR_NOSUCHITEM);\r
+ }\r
+\r
+ global $itemidprev, $itemidnext, $catid, $itemtitlenext, $itemtitleprev;\r
+\r
+ // 1. get timestamp, blogid and catid for item\r
+ $query = 'SELECT itime, iblog, icat FROM ' . sql_table('item') . ' WHERE inumber=' . intval($itemid);\r
+ $res = sql_query($query);\r
+ $obj = sql_fetch_object($res);\r
+\r
+ // if a different blog id has been set through the request or selectBlog(),\r
+ // deny access\r
+ \r
+ if ($blogid && (intval($blogid) != $obj->iblog) ) {\r
+ if (!headers_sent()) {\r
+ $b =& $manager->getBlog($obj->iblog);\r
+ $CONF['ItemURL'] = $b->getURL();\r
+ if ($CONF['URLMode'] == 'pathinfo' and substr($CONF['ItemURL'],-1) == '/')\r
+ $CONF['ItemURL'] = substr($CONF['ItemURL'], 0, -1);\r
+ $correctURL = createItemLink($itemid, '');\r
+ redirect($correctURL);\r
+ exit;\r
+ } else {\r
+ doError(_ERROR_NOSUCHITEM);\r
+ }\r
+ }\r
+\r
+ // if a category has been selected which doesn't match the item, ignore the\r
+ // category. #85\r
+ if (($catid != 0) && ($catid != $obj->icat) ) {\r
+ $catid = 0;\r
+ }\r
+\r
+ $blogid = $obj->iblog;\r
+ $timestamp = strtotime($obj->itime);\r
+\r
+ $b =& $manager->getBlog($blogid);\r
+\r
+ if ($b->isValidCategory($catid) ) {\r
+ $catextra = ' and icat=' . $catid;\r
+ } else {\r
+ $catextra = '';\r
+ }\r
+\r
+ // get previous itemid and title\r
+ $query = 'SELECT inumber, ititle FROM ' . sql_table('item') . ' WHERE itime<' . mysqldate($timestamp) . ' and idraft=0 and iblog=' . $blogid . $catextra . ' ORDER BY itime DESC LIMIT 1';\r
+ $res = sql_query($query);\r
+\r
+ $obj = sql_fetch_object($res);\r
+\r
+ if ($obj) {\r
+ $itemidprev = $obj->inumber;\r
+ $itemtitleprev = $obj->ititle;\r
+ }\r
+\r
+ // get next itemid and title\r
+ $query = 'SELECT inumber, ititle FROM ' . sql_table('item') . ' WHERE itime>' . mysqldate($timestamp) . ' and itime <= ' . mysqldate($b->getCorrectTime()) . ' and idraft=0 and iblog=' . $blogid . $catextra . ' ORDER BY itime ASC LIMIT 1';\r
+ $res = sql_query($query);\r
+\r
+ $obj = sql_fetch_object($res);\r
+\r
+ if ($obj) {\r
+ $itemidnext = $obj->inumber;\r
+ $itemtitlenext = $obj->ititle;\r
+ }\r
+\r
+ } elseif ($archive) {\r
+ // show archive\r
+ $type = 'archive';\r
+\r
+ // get next and prev month links ...\r
+ global $archivenext, $archiveprev, $archivetype, $archivenextexists, $archiveprevexists;\r
+\r
+ // sql queries for the timestamp of the first and the last published item\r
+ $query = "SELECT UNIX_TIMESTAMP(itime) as result FROM ".sql_table('item')." WHERE idraft=0 AND iblog=".(int)($blogid ? $blogid : $CONF['DefaultBlog'])." ORDER BY itime ASC";\r
+ $first_timestamp=quickQuery ($query);\r
+ $query = "SELECT UNIX_TIMESTAMP(itime) as result FROM ".sql_table('item')." WHERE idraft=0 AND iblog=".(int)($blogid ? $blogid : $CONF['DefaultBlog'])." ORDER BY itime DESC";\r
+ $last_timestamp=quickQuery ($query);\r
+\r
+ sscanf($archive, '%d-%d-%d', $y, $m, $d);\r
+\r
+ if ($d != 0) {\r
+ $archivetype = _ARCHIVETYPE_DAY;\r
+ $t = mktime(0, 0, 0, $m, $d, $y);\r
+ // one day has 24 * 60 * 60 = 86400 seconds\r
+ $archiveprev = strftime('%Y-%m-%d', $t - 86400 );\r
+ // check for published items\r
+ if ($t > $first_timestamp) {\r
+ $archiveprevexists = true;\r
+ }\r
+ else {\r
+ $archiveprevexists = false;\r
+ }\r
+\r
+ // one day later\r
+ $t += 86400;\r
+ $archivenext = strftime('%Y-%m-%d', $t);\r
+ if ($t < $last_timestamp) {\r
+ $archivenextexists = true;\r
+ }\r
+ else {\r
+ $archivenextexists = false;\r
+ }\r
+\r
+ } elseif ($m == 0) {\r
+ $archivetype = _ARCHIVETYPE_YEAR;\r
+ $t = mktime(0, 0, 0, 12, 31, $y - 1);\r
+ // one day before is in the previous year\r
+ $archiveprev = strftime('%Y', $t);\r
+ if ($t > $first_timestamp) {\r
+ $archiveprevexists = true;\r
+ }\r
+ else {\r
+ $archiveprevexists = false;\r
+ }\r
+\r
+ // timestamp for the next year\r
+ $t = mktime(0, 0, 0, 1, 1, $y + 1);\r
+ $archivenext = strftime('%Y', $t);\r
+ if ($t < $last_timestamp) {\r
+ $archivenextexists = true;\r
+ }\r
+ else {\r
+ $archivenextexists = false;\r
+ }\r
+ } else {\r
+ $archivetype = _ARCHIVETYPE_MONTH;\r
+ $t = mktime(0, 0, 0, $m, 1, $y);\r
+ // one day before is in the previous month\r
+ $archiveprev = strftime('%Y-%m', $t - 86400);\r
+ if ($t > $first_timestamp) {\r
+ $archiveprevexists = true;\r
+ }\r
+ else {\r
+ $archiveprevexists = false;\r
+ }\r
+\r
+ // timestamp for the next month\r
+ $t = mktime(0, 0, 0, $m+1, 1, $y);\r
+ $archivenext = strftime('%Y-%m', $t);\r
+ if ($t < $last_timestamp) {\r
+ $archivenextexists = true;\r
+ }\r
+ else {\r
+ $archivenextexists = false;\r
+ }\r
+ }\r
+\r
+ } elseif ($archivelist) {\r
+ $type = 'archivelist';\r
+\r
+ if (is_numeric($archivelist)) {\r
+ $blogid = intVal($archivelist);\r
+ } else {\r
+ $blogid = getBlogIDFromName($archivelist);\r
+ }\r
+\r
+ if (!$blogid) {\r
+ doError(_ERROR_NOSUCHBLOG);\r
+ }\r
+\r
+ } elseif ($query) {\r
+ global $startpos;\r
+ $type = 'search';\r
+ $query = stripslashes($query);\r
+ if(preg_match("/^(\xA1{2}|\xe3\x80{2}|\x20)+$/", $query)){\r
+ $type = 'index';\r
+ }\r