require ("./global.php");
unset ($comp);
unset ($where);
unset($editbutton2);
unset ($url);
unset ($sortx);
if($action == "") $action = "viewcomps";
if($action == "viewcomps")
{
$join = $select = "";
$order = "userid, cpudb_comp.compid, cpudb_ocing.isbase DESC, cpudb_ocing.ocingid"; // default order
if($userid>0);
else unset($userid);
switch ($sortfield)
{
case 'mhz':
case 'fsb':
case 'vcore':
case 'graka_gpu':
case 'graka_mem':
case 'vmem':
case 'cpu_brand':
case 'cpu_family':
case 'cpu_stepping':
break;
default: $sortfield="";
}
if($sortorder !="desc") {$sortx = "desc"; $sortorder="";}
else $sortx = "";
$url = "cpudb.php?userid=$userid&sortorder=$sortx&pagenumber=$pagenumber";
if($sortfield)
$order = "$sortfield $sortorder";
if($ocingid>0) // computer details
{
$temp="detail";
$benchesid = "all";
$where = "and cpudb_ocing.ocingid = $ocingid ";
}
else $temp = "list";
if(!$benchesid) $showbenches = "0";
else
{
$showbenches = "yes";
}
$bencheslinks ="";
if($username)
{
list($userid) = $DB_site->query_first("select userid from user where username = '".addslashes($username)."'",false);
$userid = intval($userid);
}
debug("laaaa".$benches[sdesc]);
if(isset($userid)) $where .= " and cpudb_comp.userid = ".intval($userid);
if(isset($coolid)) $where .= " and cpudb_ocing.coolid = ".intval($coolid);
if(isset($showbenches) && $showbenches == "yes")
{
$join .= "left join cpudb_bench on (cpudb_bench.ocingid = cpudb_ocing.ocingid) left join cpudb_benches using(benchesid)";
$select .= "cpudb_benches.title as benchtitle, cpudb_benches.url as benchesurl, cpudb_bench.*, ";
$order .= ", cpudb_benches.title";
}
list($results) = $DB_site->query_first("select count(*) from cpudb_comp left join cpudb_ocing using (compid) $join where 1=1 $where and hidden=0",false);
$perpage = 20;
if($pagenumber<1) $pagenumber =1;
if(isset($userid))
$nav= getpagenav($results,"cpudb.php?action=viewcomps&userid=$userid&sortfield=$sortfield&sortorder=$sortx&pagenumber=");
elseif(isset($benchesid))
$nav= getpagenav($results,"cpudb.php?action=viewcomps&benchesid=$benchesid&sortfield=$sortfield&sortorder=$sortx&pagenumber=");
else
$nav= getpagenav($results,"cpudb.php?action=viewcomps&sortfield=$sortfield&sortorder=$sortx&pagenumber=");
$res = $DB_site->query("select cpudb_cool.title as cooltitle, cpudb_ocing.*, cpudb_ocing.comment as ccomment, cpudb_comp.*, oc2.mhz as basemhz, $select user.username from cpudb_comp
left join user using(userid) left join cpudb_ocing on (cpudb_comp.compid = cpudb_ocing.compid) left join cpudb_cool using (coolid) $join left join cpudb_ocing as oc2 on (oc2.compid = cpudb_ocing.compid and oc2.isbase =1)
where 1=1 $where and cpudb_ocing.hidden=0
order by $order
LIMIT ".($pagenumber-1)*$perpage.", $perpage");
$cpubits = "";
eval("\$body .= \"".gettemplate("cpudb_${temp}_header")."\";");
$count =0;
while ($_ = $DB_site->fetch_array($res))
{
if(!$_[isbase])
$baseclock = $_[basemhz]." @ ";
else
$baseclock = "";
// if($_[isbase]) $baseclock = "";
// if($_[ocingid] =="") $baseclock = "---";
$editbutton = "";
if($_[userid] == $bbuserinfo[userid] || $bbuserinfo[usergroupid] == 6)
{
if($temp=="list")
if($_[ocingid] >0 && $_[isbase])
{
$editbutton = " Overclock! ";
$editbutton .= " | Edit |";
}
else
{
if($_[ocingid] >0)
$editbutton = "Edit |";
else
$editbutton = "Edit |";
}
else
$editbutton2 = "";
if($_[ocingid] >0)
{
$editbutton .= " Add Benchmark";
if($_[benchid] >0)
$editbutton .= " | Edit this Benchmark";
}
}
if(isset($showbenches) && $showbenches == "yes")
{
if($_[benchtitle])
$_[benchmark] = " $_[benchtitle]: $_[result]";// (details)";
else $_[benchmark] = "-";
}
else
$_[benchmark] = "details";
if($_[hidden]==0)
{
$color = ($num++ % 2) ? '{secondaltcolor}' : '{firstaltcolor}';
if($num ==1)
eval("\$body .= \"".gettemplate("cpudb_${temp}_cpubit_first")."\";");
eval("\$body .= \"".gettemplate("cpudb_${temp}_cpubit")."\";");
}
// if($_[isbase]) $baseclock = "$_[mhz]@";
}
$window = pagewindow("Computers",$body,"{contenttablewidth}",'left','main_pagewindow_multi');
eval("dooutput(\"".gettemplate("cpudb_$temp")."\");");
}
/************ BENCHMARKING ***************************/
if($_POST[deletebench] == "yes" && $SUBMIT == "Delete Now")
{
// delete bench
if(isset($benchid) && $deletebench == "yes")
{
$benchid = intval($benchid);
$comp_ = $DB_site->query_first("select cpudb_bench.* from cpudb_bench
left join cpudb_ocing using(ocingid)
left join cpudb_comp using(compid)
where benchid = $benchid and (userid = $bbuserinfo[userid] or $bbuserinfo[usergroupid] = 6)");
if($comp_[benchid] == $benchid)
{
$DB_site->query("DELETE from cpudb_bench where benchid = $benchid");
// Update cache for mainpage
$benches = $DB_site->query_first("select * from cpudb_benches where benchesid = '$comp_[benchesid]'");
$DB_site->query("replace into cpudb_cache select benchid,cpudb_benches.benchesid, cpudb_benches.title as benchestitle, cpudb_bench.ocingid, result, cpudb_bench.comment, cpudb_ocing.compid, coolid, mhz, fsb, vcore, ram, cpudb_comp.title, cpu_brand, cpu_family, cpu_stepping, username from cpudb_comp left join user using(userid) left join cpudb_ocing on (cpudb_comp.compid = cpudb_ocing.compid) left join cpudb_bench using(ocingid) left join cpudb_benches on (cpudb_benches.benchesid = cpudb_bench.benchesid) where cpudb_bench.benchesid = $benches[benchesid] and cpudb_comp.userid >0 order by result ".(($benches[sdesc]) ? "DESC":"")." LIMIT 1");
}
else
show_nopermission();
}
standardredirect("Delete complete - you are now taken to the Stats page","cpudb.php");
exit;
}
if($action == "editbench")
{
if(! $bbuserinfo[userid]>0)
{
show_nopermission();
exit;
}
// display editcomp
if(isset($benchid))
{
$benchid = intval($benchid);
$comp = $DB_site->query_first("select cpudb_comp.*, cpudb_ocing.comment as ccomment,cpudb_ocing.*, cpudb_bench.* from cpudb_bench left join cpudb_ocing using(ocingid) left join cpudb_comp using(compid) where benchid = $benchid and (userid = $bbuserinfo[userid] or $bbuserinfo[usergroupid] = 6)");
$compid = $comp[compid];
$ocingid = $ocing[ocingid];
if($comp[benchid] == $benchid) $addedit = "Edit";
else show_nopermission();
}
else
{
$ocingid = intval($ocingid);
$comp = $DB_site->query_first("select cpudb_comp.*, cpudb_ocing.comment as ccomment, cpudb_ocing.*, '' as comment from cpudb_ocing left join cpudb_comp using(compid) where ocingid = $ocingid and (userid = $bbuserinfo[userid] or $bbuserinfo[usergroupid] = 6)");
if($comp[ocingid] == $ocingid) $addedit = "New";
else show_nopermission();
}
$formdata = "";
$formdata .= gethiddencode("compid",$compid);
$formdata .= gethiddencode("s",$session[sessionid]);
$formdata .= gethiddencode("action","doeditbench");
$formdata .= getlabelcode("General Information");
$formdata .= gettextcode("Name of your computer","Many g33ks tend to give their computers names - do you","comp[title]",$comp[title]);
$formdata .= gettextcode("Brand of your CPU","Intel, Amd, ...","comp[cpu_brand]",$comp[cpu_brand]);
$formdata .= gettextcode("Family of your CPU","e.g. Athlon XP, Pentium 4, ...","comp[cpu_family]",$comp[cpu_family]);
$formdata .= gettextcode("Stepping / FPO#","e.g. AXIA (AMD), 3149A787 (Intel)","comp[cpu_stepping]",$comp[cpu_stepping]);
$formdata .= gettextcode("Graphics Card","","comp[graka]",$comp[graka]);
$formdata .= gettextcode("Motherboard","","comp[mobo]",$comp[mobo]);
$formdata .= gettextcode("Power Supply","","comp[netzteil]",$comp[netzteil]);
$formdata .= gettextcode("Memory","","comp[ram]",$comp[ram]);
$formdata .= gethiddencode("ocingid",$ocingid);
if(($comp[ocingid] >0 && $comp[isbase]==0))
$formdata .= getlabelcode("Overclocking");
else
$formdata .= getlabelcode("Stock Speed");
$formdata .= gettextcode("Clock Speed","in MHz","ocing[mhz]",$comp[mhz]);
$formdata .= gettextcode("Voltage (VCore)","in volts","ocing[vcore]",$comp[vcore]);
$formdata .= gettextcode("FSB (Frontsidebus)","in MHz","ocing[fsb]",$comp[fsb]);
$formdata .= gettextcode("RAM Voltage (VMem)","in volts","ocing[vmem]",$comp[vmem]);
$formdata .= gettextcode("Graphic Chip","in MHz","ocing[graka_gpu]",$comp[graka_gpu]);
$formdata .= gettextcode("Graphic Memory","in MHz","ocing[graka_mem]",$comp[graka_mem]);
$formdata .= gettextcode("FSB (Frontsidebus)","in mhz","ocing[fsb]",$comp[fsb]);
$formdata .= getchoosercode ("Cooling","ocing[coolid]","cpudb_cool",$comp[coolid],"",0,"coolid");
$formdata .= gettextcode("Comments","","ocing[ccomment]", $comp[ccomment]);
/* if(!$comp[isbase] && $comp[ocingid])
$formdata .= "
Delete?
To delete this Clocking, check the box to the left and then click the button to the right. Note: deleting this clocking will result in the deletion of the entire benchmarking information.
To delete this Benchmark, check the box to the left and then click the button to the right.
";
eval("dooutput(\"".gettemplate("cpudb_editbench")."\");");
}
if($action == "doeditbench")
{
if(! $bbuserinfo[userid]>0)
{
show_nopermission();
exit;
}
$bench = $_POST[bench];
$benchid = intval($benchid);
// strip html
foreach ($bench as $key => $_)
{
$bench[$key] = htmlentities($_);
}
$bench[result] = str_replace(",",".",$bench[result]);
$bench[result] = str_replace(":",".",$bench[result]);
///// insert ocing
if($benchid>0) //// EDIT
{
$benchid = intval($benchid);
$comp_ = $DB_site->query_first("select benchid from cpudb_bench left join cpudb_ocing using(ocingid) left join cpudb_comp using(compid) where benchid = $benchid and (userid = $bbuserinfo[userid] or $bbuserinfo[usergroupid] = 6)");
if($comp_[benchid] == $benchid)
$DB_site->query("UPDATE cpudb_bench SET benchesid = '$bench[benchesid]', result='$bench[result]', comment='$bench[comment]' where benchid = $benchid");
else
show_nopermission();
}
else //// INSERT
{
$ocingid = intval($ocingid);
if($ocingid >0)
$DB_site->query("INSERT into cpudb_bench (benchid, benchesid, result, comment, ocingid) VALUES (NULL, '$bench[benchesid]', '$bench[result]', '$bench[comment]', $ocingid)");
else
show_nopermission();
}
// Update cache for mainpage
$benches = $DB_site->query_first("select * from cpudb_benches where benchesid = $bench[benchesid]");
$DB_site->query("replace into cpudb_cache select benchid,cpudb_benches.benchesid, cpudb_benches.title as benchestitle, cpudb_bench.ocingid, result, cpudb_bench.comment, cpudb_ocing.compid, coolid, mhz, fsb, vcore, ram, cpudb_comp.title, cpu_brand, cpu_family, cpu_stepping, username from cpudb_comp left join user using(userid) left join cpudb_ocing on (cpudb_comp.compid = cpudb_ocing.compid) left join cpudb_bench using(ocingid) left join cpudb_benches on (cpudb_benches.benchesid = cpudb_bench.benchesid) where cpudb_bench.benchesid = $benches[benchesid] order by result ".(($benches[sdesc]) ? "DESC":"")." LIMIT 1");
standardredirect("Edit complete - you are now taken to the Stats page","cpudb.php?ocingid=$ocingid");
}
/*********** COMP & CLOCKING **********************/
if(($_POST[deletecomp] == "yes" || $_POST[deleteocing] == "yes") && $SUBMIT == "Delete Now")
{
$action = "";
if(! $bbuserinfo[userid]>0)
{
show_nopermission();
exit;
}
if(isset($compid) && $deletecomp == "yes")
{
$compid = intval($compid);
$comp_ = $DB_site->query_first("select * from cpudb_comp where compid = $compid and (userid = $bbuserinfo[userid] or $bbuserinfo[usergroupid] = 6)");
if($comp_[compid] == $compid)
{
$DB_site->query("DELETE from cpudb_ocing where compid = $compid");
$DB_site->query("DELETE from cpudb_comp where compid = $compid");
}
else
show_nopermission();
}
if(isset($ocingid) && $deleteocing == "yes")
{
$ocingid = intval($ocingid);
$comp_ = $DB_site->query_first("select * from cpudb_ocing left join cpudb_comp using(compid) where ocingid = $ocingid and (userid = $bbuserinfo[userid] or $bbuserinfo[usergroupid] = 6)");
if($comp_[compid] == $compid)
{
$DB_site->query("DELETE from cpudb_ocing where ocingid = $ocingid");
$DB_site->query("DELETE from cpudb_bench where ocingid = $ocingid");
}
else
show_nopermission();
}
// Update cache for mainpage
$DB_site->query("delete from cpudb_cache");
$_ = $DB_site->query("select * from cpudb_benches");
while ($benches = $DB_site->fetch_array($_))
{
$DB_site->query("replace into cpudb_cache select benchid,cpudb_benches.benchesid, cpudb_benches.title as benchestitle, cpudb_bench.ocingid, result, cpudb_bench.comment, cpudb_ocing.compid, coolid, mhz, fsb, vcore, ram, cpudb_comp.title, cpu_brand, cpu_family, cpu_stepping, username from cpudb_comp left join user using(userid) left join cpudb_ocing on (cpudb_comp.compid = cpudb_ocing.compid) left join cpudb_bench using(ocingid) left join cpudb_benches on (cpudb_benches.benchesid = cpudb_bench.benchesid) where cpudb_bench.benchesid = $benches[benchesid] order by result ".(($benches[sdesc]) ? "DESC":"")." LIMIT 1");
}
standardredirect("Delete complete - you are now taken to the Stats page","cpudb.php");
exit;
}
if($action == "editcomp")
{
if(! $bbuserinfo[userid]>0)
{
show_nopermission();
exit;
}
// display editcomp
if(isset($ocingid))
{
$ocingid = intval($ocingid);
$comp = $DB_site->query_first("select cpudb_comp.*, cpudb_ocing.* from cpudb_ocing left join cpudb_comp using(compid) where ocingid = $ocingid and (userid = $bbuserinfo[userid] or $bbuserinfo[usergroupid] = 6)");
$compid = $comp[compid];
if($comp[ocingid] == $ocingid) $addedit = "Edit";
else show_nopermission();
}
elseif(isset($compid))
{
$compid = intval($compid);
$comp = $DB_site->query_first("select * from cpudb_comp where compid = $compid and (userid = $bbuserinfo[userid] or $bbuserinfo[usergroupid] = 6)");
if($comp[compid] == $compid) $addedit = "Edit";
else show_nopermission();
}
else
{
$addedit = "New";
}
$formdata = "";
$formdata .= gethiddencode("compid",$compid);
$formdata .= gethiddencode("s",$session[sessionid]);
$formdata .= gethiddencode("action","doeditcomp");
$formdata .= getlabelcode("General Information");
$formdata .= getinputcode("Name of your computer","Many g33ks tend to give their computers names - do you","comp[title]",$comp[title]);
$formdata .= getinputcode("Brand of your CPU","Intel, Amd, ...","comp[cpu_brand]",$comp[cpu_brand]);
$formdata .= getinputcode("Family of your CPU","e.g. Athlon XP, Pentium 4, ...","comp[cpu_family]",$comp[cpu_family]);
$formdata .= getinputcode("Stepping / FPO#","e.g. AXIA (AMD), 3149A787 (Intel)","comp[cpu_stepping]",$comp[cpu_stepping]);
$formdata .= getinputcode("Graphics Card","","comp[graka]",$comp[graka]);
$formdata .= getinputcode("Motherboard","","comp[mobo]",$comp[mobo]);
$formdata .= getinputcode("Power Supply","","comp[netzteil]",$comp[netzteil]);
$formdata .= getinputcode("Memory","","comp[ram]",$comp[ram]);
list($comp[hidden]) = $DB_site->query_first("select hidden from cpudb_ocing where compid = '$compid' and isbase =1",false);
// $formdata .= getyesnocode("Stock Speed is Disabled","Set this to yes if you don't use your computer at stock speed.","ocing[hidden]",!$hidden);
$formdata .= getyesnocode("Show Stock and O/C-Settings as seperate entries","Set this to no if you don't use your computer at stock speed.","ocing[hidden]",!$comp[hidden]);
if($compid)
$formdata .= "
Delete?
To delete this Computer, check the box to the left and then click the button to the right. Note: deleting this post will result in the deletion of the entire thread if this post is the first post in the thread.
To delete this Clocking, check the box to the left and then click the button to the right. Note: deleting this post will result in the deletion of the entire thread if this post is the first post in the thread.
";
else // can't delete, so it must be an non-overclocked cpu
{
$formdata .= getlabelcode("Overclocking");
$formdata .= getyesnocode("Is overclocked","Select yes if this Computer is overclocked and fill in the Fields below","ocing2[isoced]","0");
$formdata .= getinputcode("Clock Speed","in MHz","ocing2[mhz]","");
$formdata .= getinputcode("Voltage (VCore)","in volts","ocing2[vcore]","");
$formdata .= getinputcode("FSB (Frontsidebus)","in mhz","ocing2[fsb]","");
$formdata .= getinputcode("RAM Voltage (VMem)","in volts","ocing2[vmem]","");
$formdata .= getinputcode("Graphic Chip","in MHz","ocing2[graka_gpu]","");
$formdata .= getinputcode("Graphic Memory","in MHz","ocing2[graka_mem]","");
$formdata .= getchoosercode ("Cooling","ocing2[coolid]","cpudb_cool",1,"",0,"coolid");
$formdata .= gettextareacode ("Comments","ocing2[comment]", "");
}
eval("dooutput(\"".gettemplate("cpudb_editcomp")."\");");
}
if($action == "doeditcomp")
{
if(! $bbuserinfo[userid]>0)
{
show_nopermission();
exit;
}
$comp = $_POST[comp];
$ocing2 = $_POST[ocing2];
$compid = intval($compid);
// strip html
foreach ($comp as $key => $_)
{
$comp[$key] = htmlentities($_);
}
foreach ($ocing as $key => $_)
{
$ocing[$key] = htmlentities($_);
}
$isbase =0;
if($compid>0) //// EDIT
{
$comp_ = $DB_site->query_first("select * from cpudb_comp where compid = $compid and (userid = $bbuserinfo[userid] or $bbuserinfo[usergroupid] = 6)");
if($comp_[compid] == $compid)
$DB_site->query("UPDATE cpudb_comp SET title = '$comp[title]', cpu_brand = '$comp[cpu_brand]', cpu_family = '$comp[cpu_family]', cpu_stepping = '$comp[cpu_stepping]', graka = '$comp[graka]', mobo= '$comp[mobo]', netzteil='$comp[netzteil]', ram='$comp[ram]' where compid=$compid");
else
show_nopermission();
}
else //// INSERT
{
$DB_site->query("INSERT into cpudb_comp (compid, userid, title, cpu_brand, cpu_family, cpu_stepping, graka, mobo,netzteil,ram) VALUES (NULL, $bbuserinfo[userid], '$comp[title]','$comp[cpu_brand]','$comp[cpu_family]','$comp[cpu_stepping]', '$comp[graka]', '$comp[mobo]', '$comp[netzteil]','$comp[ram]')");
$compid = $DB_site->insert_id();
$isbase = 1;
}
$ocing[mhz] = str_replace(",",".",$ocing[mhz]);
$ocing[fsb] = str_replace(",",".",$ocing[fsb]);
$ocing[vcore] = str_replace(",",".",$ocing[vcore]);
$ocing[vmem] = str_replace(",",".",$ocing[vmem]);
///// insert ocing
if($ocingid>0) //// EDIT
{
$ocingid = intval($ocingid);
$comp_ = $DB_site->query_first("select * from cpudb_ocing left join cpudb_comp using(compid) where ocingid = $ocingid and (userid = $bbuserinfo[userid] or $bbuserinfo[usergroupid] = 6)");
if($comp_[compid] == $compid)
$DB_site->query("UPDATE cpudb_ocing SET mhz = '$ocing[mhz]', fsb= '$ocing[fsb]', vcore= '$ocing[vcore]', comment= '$ocing[comment]', coolid='$ocing[coolid]',graka_gpu='$ocing[graka_gpu]',graka_mem='$ocing[graka_mem]',vmem='$ocing[vmem]' where ocingid = $ocingid");
else
show_nopermission();
}
else //// INSERT
{
$DB_site->query("INSERT into cpudb_ocing (ocingid, compid, mhz, fsb, vcore, comment, coolid, isbase, graka_gpu, graka_mem,vmem) VALUES (NULL, $compid, '$ocing[mhz]','$ocing[fsb]','$ocing[vcore]','$ocing[comment]', '$ocing[coolid]', $isbase, '$ocing[graka_gpu]','$ocing[graka_mem]','$ocing[vmem]')");
$ocingid = $DB_site->insert_id();
}
// insert ocing2 :eek:
if(isset($ocing2))
foreach ($ocing2 as $key => $_)
{
$ocing2[$key] = htmlentities($_);
}
$ocing2[mhz] = str_replace(",",".",$ocing2[mhz]);
$ocing2[fsb] = str_replace(",",".",$ocing2[fsb]);
$ocing2[vcore] = str_replace(",",".",$ocing2[vcore]);
$ocing2[vmem] = str_replace(",",".",$ocing2[vmem]);
$ocing2[mhz] = str_replace(":",".",$ocing2[mhz]);
$ocing2[fsb] = str_replace(":",".",$ocing2[fsb]);
$ocing2[vcore] = str_replace(":",".",$ocing2[vcore]);
$ocing2[vmem] = str_replace(":",".",$ocing2[vmem]);
if($compid>0 && $ocing2[isoced] == "1")
{
$DB_site->query("INSERT into cpudb_ocing (ocingid, compid, mhz, fsb, vcore, comment, coolid, isbase, graka_gpu, graka_mem,vmem) VALUES (NULL, $compid, '$ocing2[mhz]','$ocing2[fsb]','$ocing2[vcore]','$ocing2[comment]', '$ocing2[coolid]', 0, '$ocing2[graka_gpu]','$ocing2[graka_mem]','$ocing2[vmem]')");
$ocingid = $DB_site->insert_id();
}
// do base hiding
// echo "$ocinghidden - ".!$hidden; exit;
//
// if($hidden !="")
// {
list($count) = $DB_site->query_first("select count(*) from cpudb_ocing where isbase = 0 and compid= '$compid'",false);
if($count <1) $ocing[hidden] =1;
$DB_site->query("UPDATE cpudb_ocing set hidden = '".!$ocing[hidden]."' where isbase=1 and compid='$compid'");
standardredirect("Edit complete - you are now taken to the Stats page","cpudb.php?ocingid=$ocingid");
}
?>