heres my code page nav works etc just need to get the counter working can i show me with the full code $count is the varible i will be using to add a number to the front of each thread.
thx in advance :P
PHP Code:
<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'index'); // change this depending on your filename
// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array(
);
// get special data templates from the datastore
$specialtemplates = array(
'userstats'
);
// pre-cache templates used by all actions
$globaltemplates = array(
'INDEX',
'index_threadbit'
);
// pre-cache templates used by specific actions
$actiontemplates = array(
);
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
require_once(DIR . '/includes/functions_bigthree.php');
function timeDiff($timestamp,$detailed=false){
$now = time();
$diff = ($action == 'away' ? $timestamp - $now : $now - $timestamp);
# Set the periods of time
$periods = array("s", "m", "h", "d", "w");
$lengths = array(1, 60, 3600, 86400, 604800);
# Go from decades backwards to seconds
$i = sizeof($lengths) - 1; # Size of the lengths / periods in case you change them
$time = ""; # The string we will hold our times in
while($i >= 0) {
if($diff > $lengths[$i-1]) { # if the difference is greater than the length we are checking... continue
$val = floor($diff / $lengths[$i-1]); # 65 / 60 = 1. That means one minute. 130 / 60 = 2. Two minutes.. etc
$time .= $val ."". $periods[$i-1].($val > 1 ? '' : ' '); # The value, then the name associated, then add 's' if plural
$diff -= ($val * $lengths[$i-1]); # subtract the values we just used from the overall diff so we can find the rest of the information
if(!$detailed) { $i = 0; } # if detailed is turn off (default) only show the first set found, else show all information
}
$i--;
}
# Basic error checking.
if($time == "") {
return "Error-- Unable to calculate time.";
} else {
return $time.$action;
}
}
// ###################################################################
// ######################## START MAIN SCRIPT ########################
// ###################################################################
$array = "59,63,64,69,72";
// Default page variables
$perpage = $vbulletin->input->clean_gpc('r', 'perpage', TYPE_UINT);
$pagenumber = $vbulletin->input->clean_gpc('r', 'pagenumber', TYPE_UINT);
$sortfield = $vbulletin->input->clean_gpc('r', 'sortfield', TYPE_STR);
$sortorder = $vbulletin->input->clean_gpc('r', 'sortorder', TYPE_STR);
// set defaults and sensible values
if ($sortfield == '')
{
$sortfield = 'age';
}
if ($sortorder == '')
{
$sortorder = 'desc';
}
$sortorder = strtolower($sortorder);
// Count all log entries
$count = $db->query_first("
SELECT COUNT(*) AS `count`
FROM " . TABLE_PREFIX . "thread AS thread
WHERE thread.forumid IN($array)
");
// Make sure all these variables are cool
sanitize_pageresults($count['count'], $pagenumber, $perpage, 100, 40);
switch ($sortfield)
{
case 'username':
$sqlsort = 'thread.postusername';
break;
case 'subject':
$sqlsort = 'thread.title';
break;
case 'type':
$sqlsort = 'thread.iconid';
break;
default:
$sqlsort = 'thread.dateline';
$sortfield = 'age';
}
if ($sortorder != 'asc')
{
$sortorder = 'desc';
$oppositesort = 'asc';
}
else
{ // $sortorder = 'ASC'
$oppositesort = 'desc';
}
$sorturl = 'index.php?' . $vbulletin->session->vars['sessionurl'] . '';
eval('$sortarrow[' . $sortfield . '] = "' . fetch_template('forumdisplay_sortarrow') . '";');
// Default lower and upper limit variables
$limitlower = ($pagenumber - 1) * $perpage + 1;
$limitupper = $pagenumber * $perpage;
if ($limitupper > $count['count'])
{
// Too many for upper limit
$limitupper = $count['count'];
if ($limitlower > $count['count'])
{
// Too many for lower limit
$limitlower = $count['count'] - $perpage;
}
}
if ($limitlower <= 0)
{
// Can't have negative or null lower limit
$limitlower = 1;
}
$threadarray = $vbulletin->db->query_read("
SELECT thread.*, icon.title AS icontitle, icon.iconpath AS iconpath, user.username, user.userid, user.usergroupid, IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid
FROM " . TABLE_PREFIX . "thread AS thread
LEFT JOIN " . TABLE_PREFIX . "icon AS icon ON(icon.iconid = thread.iconid)
LEFT JOIN " . TABLE_PREFIX . "user AS user ON (user.username = thread.postusername)
WHERE $typequery
thread.forumid IN($array)
ORDER BY $sqlsort $sortorder $secondarysortsql
LIMIT " . ($limitlower - 1) . ", $perpage ");
while($thread = $vbulletin->db->fetch_array($threadarray))
{
$thread[musername] = fetch_musername($thread);
$thread['lastpostdate'] = timeDiff($thread['dateline']);
// Finally construct the page nav
$pagenav = construct_page_nav($pagenumber, $perpage, $count['count'], 'index.php?' . $vbulletin->session->vars['sessionurl'] . '');
if($count['count'] != 0)
{
$startfrom = $perpage * ($count['count'] - 1);
}
else
{
$startfrom = 1;
}
$images = $db->query("
SELECT img FROM " . TABLE_PREFIX . "post
WHERE threadid = $thread[threadid]
");
while ($image = $db->fetch_array($images))
{
$image_url = $image['img'];
}
eval('$threadbits .= "' . fetch_template('index_threadbit') . '";');
}
$navbits = array();
$navbits[$parent] = 'Thread Index';
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('INDEX') . '");');
?>