header("Content-Type: text/html; charset=UTF-8");
$title = "moTions Treasure Hunter";
include_once("../inc/adodb/adodb.inc.php");
$host = "localhost";
$user = "root";
$password = "mysql";
$database = "MOTIONS";
$DB = &NewADOConnection("mysql");
$DB->Connect($host,$user,$password,$database);
$maxCount = 16;
$clearUserCount = 0;
$allUsers = getUserProduct();
?>
=$title?>
 |
=date("Y/m/d H:i")?>現在、=getMemberCount()?>人のユーザーが参加されています。
if($clearUserCount > 0){
?>
参加ユーザーのうち、=$clearUserCount?>人がコンプリート!しています。
} else {
?>
まだコンプリートしているユーザーはいません! あなたが一番目のコンプリートユーザーになれるかも?!
}
?>
現在までの総獲得アイテム数は、=getProductCount()?>個です。
今から参加する方も頑張って探してみましょう!!
moTions スタッフ一同
|
// 参加者数
function getMemberCount(){
global $DB;
$SQL = "SELECT DISTINCT user FROM `Logs`";
$ret = $DB->GetAll($SQL);
return count($ret);
}
function getProductCount(){
global $DB;
$SQL = "SELECT * FROM `Logs`";
$ret = $DB->GetAll($SQL);
return count($ret);
}
function getUserProduct(){
global $DB, $clearUserCount,$maxCount;
$ret = "";
$user = "";
$userList = array();
$SQL = "SELECT user, product, MIN(time) time FROM `Logs` group by user, product ORDER BY user, time";
$result = $DB->GetAll($SQL);
foreach($result as $line){
$u = $line["user"];
$userList[$u]["products"][] = array("name" => $line["product"], "time" => $line["time"]);
$user = $line["user"];
$product = $line["product"];
}
foreach($userList as $key => $val){
$user = $key;
$products = $val["products"];
if(count($products) >= $maxCount){
$clearUserCount++;
}
$get = count($products);
$gc = "#FFFFFF";
if($get == $maxCount){
$gc = "#FF5555";
}
$ret .= "\n";
$ret .= " ".$user." (GET数:".$get.")\n";
$ret .= "
\n";
$ret .= "\n";
$ret .= "
\n";
$cnt = 0;
foreach($products as $vv){
$color = "#FFFFFF";
if($cnt % 2 == 0){
$color = "#CCFFFF";
}
$ret .= " \n";
$ret .= " | ".$vv["name"]." | \n";
$ret .= " ".date('Y/m/d H:i:s', strtotime($vv["time"]))." | \n";
$ret .= "
\n";
$cnt++;
}
$ret .= " \n";
$ret .= "
\n";
$ret .= "
\n";
}
return $ret;
}
?>
=$title?> by Masaki Axel