require("../inc/apodhead.php");
include("../inc/fmtdate.php");
include("../inc/writepages.php");
require("../inc/db.php");
$db = mysql_connect($dbserver,$dbuser,$dbpw);
mysql_select_db($dbname,$db);
if( ($id=trim($_GET['id']))!=""){
$gametitle="";
if(display_details($id)){
print('');
print('');
print('');
print('');
}
else print("
Download No Longer Exist");
}
mysql_close($db);
require("../inc/apodfoot2.php");
//===========================================================
function display_details($gid){
global $db,$gametitle;
$gotm="";
if( ($rs_rev = mysql_query("select dt from ap_awarded where data_type=0 and data_id=".$gid,$db)) ){
if( ($rs= mysql_fetch_array($rs_rev)) ){ $gotm=$rs['dt'];}
mysql_free_result($rs_rev);
}
$rval=true;
$result = mysql_query("select d.url,d.url_download,d.url_buy,d.data_id,d.title,d.des,d.des_ctrl,d.picture,d.filesize,d.cat_id,d.created_dt,d.z3d,d.zmulti,d.has_hiscore,d.member_id,".
"(TO_DAYS(now())-TO_DAYS(d.hit_dt)+1) numdays".
",(d.hit_null) as total".
",((d.hit_null)/(TO_DAYS(now())-TO_DAYS(d.hit_dt)+1)) as avgcnt".
",(d.hit_cnt) as totalplay".
",((d.hit_cnt)/(TO_DAYS(now())-TO_DAYS(d.hit_dt)+1)) as avgplay".
",author_name as name,author_url as website,author_cp_name as cp_name,author_cp_url as cp_website".
",cat_string,f.format_name,r.rating_name,d.rate_avg,d.rate_cnt,d.cat_id".
" from ap_game_data d,ap_game_cat c,ref_format f,ref_rating r".
" where d.status=1 and d.cat_id=c.cat_id and d.format_id=f.format_id and d.rating_id=r.rating_id".
" and d.data_id=".$gid,$db);
if( ($row = mysql_fetch_array($result))){
$lnk='/games/gotogame.php?id='.$gid;
$lnkDetail='details.php?id='.$gid;
$gametitle=$row['title'];
$mid=$row['member_id'];
$cat_id=$row['cat_id'];
//-- GET AUTHOR ----------------------------
$author='';
if($row['name']!=''){
if($row['website']!='') $author=''.$row['name'].'';
else $author=$row['name'];
}
if($row['cp_name']!='' && $row['name']!=$row['cp_name']){
if($row['cp_website']!='')$author.=' ['.$row['cp_name'].']';
else $author.=' ['.$row['cp_name'].']';
}
$author.=" - view all downloads by author";
$fsize='';
$avghit=number_format($row['avgcnt'],0);
$avgplay=number_format($row['avgplay'],0);
//if($row['numdays']!=0)$avghit=1+floor($row['total']/$row['numdays']);
if($row['filesize']>0)$fsize='('.$row['filesize'].'kb)';
$catname=$row['cat_string'];
//---------------------------------------------
$des_ct="";
if($row['des_ctrl']<>''){$des_ct.=str_replace("\n","
",$row['des_ctrl'])."
"; }
//---------------------------------------------
$des_hiscore="";
$url=trim($row['url']);
$url_dl=trim($row['url_download']);
$url_buy=trim($row['url_buy']);
//if($row['has_hiscore']<>0){$des_hiscore='
'; }
if($url_buy!=""){$des_hiscore.=('

');}
if($url_dl!="")$des_hiscore.=('

');
if(($url_dl.$url_buy)!="")$des_hiscore.=('
');
if($url!=""){
$des_hiscore.='

';
$des_hiscore.='

';
}
//---------------------------------------------
$tstr="";
if($row['z3d']<>0)$tstr.=" | 3D";
if($row['zmulti']<>0){ $tstr.=" | Multi-Player"; }
if($gotm!=""){$tstr.=" | Game of the Month - ".fmtdate("F Y",$gotm)."
"; }
if($tstr!="")$tstr="
".substr($tstr,3);
//---------------------------------------------
$av=$row['rate_avg'];
$av_cnt=$row['rate_cnt'];
if($av_cnt>0)$av_str="
Average Rating: ".number_format($av,2)." of 5.00 (from ".$av_cnt." ratings)
";
else $av_str="
Average Rating: None
";
//-- CREATE STRING ---------------------------- onClick="this.href=FCx(this.href);"
if($row['picture']=="none")$gamepix="none";
else $gamepix="a/".(substr($row['picture'],0,1).'/'.$row['picture']);
print(''.
'
'.$des_hiscore.'


| '.
''.$row['title'].' '.$fsize.''.
' by '.$author.' '.
' Category: '.str_replace("games/","downloads/",$row['cat_string']).
' Average Download: '.$avghit.' / '.$row['total'].' (per day / total)');
if($url!="")print(' Average Play: '.$avgplay.' / '.$row['totalplay'].' (per day / total)');
print($av_str.' '.str_replace("\n"," ",$row['des']).' submitted on '.fmtdate('m/j/y',$row['created_dt']).' '.$tstr.' ');
include("../inc/ads/detail_468x60_google.php");
print(' |
');
print('');
if($des_ct!=""){
print('');
print('| Controls: | ');
print('| '.$des_ct.' | ');
}
similargames($gid,$mid,$cat_id);
print(' |  | ');
print('| ');
//include("../inc/ad/300x250.inc");
print('');
print(' | ');
print(' |
');
}
else $rval=false;
mysql_free_result($result);
return $rval;
}
//===========================================================
function similargames($gid,$mem_id,$cat_id){
global $db;
$str="";
$result = mysql_query("select similar_data_id,similar_title,similar_picture from ap_game_similar where data_id=".$gid." and similar_type=1 order by similar_sort LIMIT 0,5",$db);
while( ($rs = mysql_fetch_array($result))){
$pix=$rs['similar_picture'];
if($pix=="none" || $pix=="")$gamepix="none";
else $gamepix="a/".(substr($pix,0,1).'/'.$pix);
$str.=(' '.$rs['similar_title']." | ");
}
if($str!=""){
print('');
print('| If you like this game, you might also like: |
');
print(" ");
print(' |
');
}
}
//===========================================================
?>