會寫程式的貓
2009年3月19日
目前時間 半夜 4 點 03 分
User:
MY BLOG
Class:
雜項
是誰!到底是誰說要做 WebGame 給我滾出來!!
timeDate = date("Y-m-d H:i:s"); $this->timeY = date("Y"); $this->timeM = date("m"); $this->timeD = date("d"); $this->timeHour = date("H"); $this->timeMinute = date("i"); $this->timeSec = date("s"); } function sec_gap($ID){//取得新舊日期相差秒數 $SQLcode = "select * from user_time where User_ID = '$ID'"; $rs= mysql_query($SQLcode,$this->MySQL_login()) or die(mysql_error()); $row = mysql_fetch_assoc($rs); $time1 = $row['year']."".$row['month']."".$row['day']."". $row['hour']."".$row['minute']."".$row['sec']; $time2 = $this->timeY."".$this->timeM."".$this->timeD."". $this->timeHour."".$this->timeMinute."".$this->timeSec; $oldTime = unpack('A4y/A2m/A2d/A2H/A2i/A2s', $time1); $newTime = unpack('A4y/A2m/A2d/A2H/A2i/A2s', $time2); $sec = date( mktime($newTime[H],$newTime[i],$newTime[s], $newTime[m],$newTime[d],$newTime[y]) - mktime($oldTime[H],$oldTime[i],$oldTime[s], $oldTime[m],$oldTime[d],$oldTime[y])); return $sec; } function setTime($ID){//更新資料庫時間 $SQLcode ="UPDATE `webtd`.`user_time` SET `User_ID` = '".$ID."', `date` = '".$this->timeDate."', `year` = '".$this->timeY."',`month` = '".$this->timeM."',`day` = '".$this->timeD."', `hour` = '".$this->timeHour."',`minute` = '".$this->timeMinute."', `sec` = '".$this->timeSec."' WHERE CONVERT( `user_time`.`User_ID` USING utf8 ) = '".$ID."' LIMIT 1"; mysql_query($SQLcode,$this->MySQL_login()) or die(mysql_error()); } function updataR($ID,$sec){//更新資源 $SQLcode = "select * from user_data where User_ID = '$ID'"; $rs= mysql_query($SQLcode,$this->MySQL_login()) or die(mysql_error()); $row = mysql_fetch_assoc($rs); $this->r1 = $row['User_Resources01'] + $sec; $this->r2 = $row['User_Resources02'] + $sec; $this->r3 = $row['User_Resources03'] + $sec; $SQLcode ="UPDATE `webtd`.`user_data` SET `User_Resources01` = '$this->r1', `User_Resources02` = '$this->r2', `User_Resources03` = '$this->r3' WHERE CONVERT( `user_data`.`User_ID` USING utf8 ) = '$ID' LIMIT 1 "; mysql_query($SQLcode,$this->MySQL_login()) or die(mysql_error()); } function ResourcesUpData($ID){ $SQLcode = "select * from user_data where User_ID = '$ID'"; $rs= mysql_query($SQLcode,$this->MySQL_login()) or die(mysql_error()); $row = mysql_fetch_assoc($rs); $this->r1 = $row['User_Resources01']; $this->r2 = $row['User_Resources02']; $this->r3 = $row['User_Resources03']; $this->b1 = $row['User_Building01']; $this->b2 = $row['User_Building02']; $this->b3 = $row['User_Building03']; $this->b4 = $row['User_Building04']; $this->b5 = $row['User_Building05']; $this->getTime();//取得現在時間 $this->updataR($ID,$this->sec_gap($ID));//更新資源數 並且 取得相差秒數資料 再傳入 $this->setTime($ID);//更新資料庫時間 } } ?>
沒有留言:
張貼留言
較新的文章
較舊的文章
首頁
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言