<?php

##############################################################
### vB Easy Archive Final - Released on January 16th, 2003 ###
## Scripts created by Xenon and modified/released by SkuZZy ##
### Copyright info MUST stay on the bottom of all scripts ####
#### Visit http://www.vbulletin.org for updated versions! ####
##############################################################

error_reporting(7);

require('config.php');
$temp=strrpos($scriptpath,"/");
$threadid=intval(substr($scriptpath,$temp+1));
$pagenumber=intval(substr($scriptpath,strrpos($scriptpath,"-")+1));
if ($pagenumber==0) $pagenumber=1;

$thread = verifyid("thread",$threadid,1,1);
if (!$thread['visible']) {
  $idname="thread";
  exit;
}

if ($thread['open'] == 10) {
   // send them to their correct thread    
    header("Location: show/$thread[pollid]");
    exit;
}
$forum=getforuminfo($thread['forumid']);

$getperms=getpermissions($thread['forumid'],-1,-1,$forum['parentlist']);
if (!$getperms['canview']) {
  show_nopermission();
}
if (!$getperms['canviewothers'] and ($thread['postuserid']!=$bbuserinfo['userid'] or $bbuserinfo['userid']==0)) {
  show_nopermission();
}

$bbcodeon=iif($forum[allowbbcode],$ontext,$offtext);
$imgcodeon=iif($forum[allowimages],$ontext,$offtext);
$htmlcodeon=iif($forum[allowhtml],$ontext,$offtext);
$forum[allowsmilies]=0;
$smilieson=iif($forum[allowsmilies],$ontext,$offtext);

echo "<html><body><head><title>[$thread[title]] - $title</title></head><base href=\"$forumurl/\">";

include "$archiveurl/header.php";

$counter=0;
$postcount = $DB_site->query_first("SELECT COUNT(*) as posts FROM post WHERE threadid='$threadid' AND visible=1");
echo "Pages:";
$pagelink = "";
for($i = 1; $i <= intval($postcount[posts] / 200) + 1; $i++) {
  $pagelink .= "<a href=$archiveurl/topic/" . $threadid . "-" . $i . ".html>$i</a> ";
}
echo $pagelink;

// can do it this way or use a strstr() for each post but I feel this will be quicker overall
unset($ignore);
$getpostids=$DB_site->query("
	SELECT post.postid,user.username,pagetext,post.userid,post.username AS postusername FROM post LEFT JOIN user USING (userid)
	WHERE post.threadid='$threadid' AND post.visible=1
	ORDER BY dateline LIMIT ".(($pagenumber-1)*200).",200
");


echo "<center><br><hr><br><b><h1><font color=red>$thread[title]</font></h1></b><font size=3 color=red><a href=$forumurl/showthread.php?s=&threadid=$thread[threadid]>(Click here to view the original thread with full colors/images)</a></a></center></font><br><hr><br></center>";

while ($post=$DB_site->fetch_array($getpostids)) {
if($post[userid]==0) $post[username]=$post[postusername];
echo "Posted by: <b>$post[username]</b><br><br>";
echo bbcodeparse($post[pagetext]);
echo "<br><br><hr><br>";
}

include "$archiveurl/footer.php";

echo '<b>vB Easy Archive Final</b> - Created by <a href="http://www.strategy-forum.de/">Xenon</a> and modified/released by SkuZZy from the <a href="http://www.scriptz.com/">Web Scripts Directory</a><br></font></center></body></html>';

?>