Пример #1
0
<?php

include_once 'helper.php';
include_once 'gamedata.php';
echo "start backup database:\r\n";
$gameData = new GameData();
echo "gameData ready!\r\n";
$allUserId = $gameData->getAllUserId();
/*
echo "allUserId ready!\r\n";
foreach ($allUserId as $key => $value) {
	$userId = $value;
	//$scoreRank = $gameData->getScoreRank($userId);
	//$thisDayRank = json_encode($scoreRank);helper_log($thisDayRank);
	//$mysql_real_escape_string($thisDayRank);
	echo $userId . "\r\n";
	$gameData->backupScoreRank($userId);
	
}
//delete today rank
echo "backup data done\r\n";
*/
$gameData->backupScoreRank_redis();
date_default_timezone_set("Asia/Shanghai");
$backup_file = "/home/www/ramboat/backup/" . date("Y-m-d");
$backup_content = "rank_num:" . count($allUserId);
file_put_contents($backup_file, $backup_content);
$gameData->clearTodayRank();
Пример #2
0
 /**
  * 
  * Show All engines result including HTML5 games
  * @return string
  */
 public function actionAllenginesdata()
 {
     $this->logincheck();
     $levelId = '';
     $native = $this->getUserInfo()->native;
     if ($native == 'no' && !empty($this->getUserInfo()->level_id)) {
         $levelId = $this->getUserInfo()->level_id;
     }
     $this->layout = 'homepage';
     Yii::app()->user->setFlash('snow', null);
     $slug = Yii::app()->request->getQuery('slug');
     $game = new Game();
     $result = $game->findByAttributes(array('status' => 'active', 'slug' => $slug), ' find_in_set(' . $this->getUserInfo()->student_grade_id . ',grade_id) <> 0 and hide_from_main_site="no"');
     // start level data
     if (!empty($levelId)) {
         $result = $game->findByAttributes(array('status' => 'active', 'slug' => $slug), ' find_in_set(' . $levelId . ',show_in_level) <> 0');
     }
     // end level data
     $Permission = $game->findByAttributes(array('status' => 'active', 'slug' => $slug));
     $breadcrumb = '';
     $breadcrumb = '<a href="' . yii::app()->request->baseUrl . '/games">' . Yii::t('zii', 'Game') . '</a>';
     $link = yii::app()->request->baseUrl . '/games';
     if (!empty($result)) {
         if ($result->parent_id != null) {
             $SubEvent = $result->findByPk($result->parent_id);
             $breadcrumb .= ' > <a href="' . yii::app()->request->baseUrl . '/games/gameinfo/' . $SubEvent->slug . '">' . $SubEvent->title . '</a>';
             $link = yii::app()->request->baseUrl . '/games/gameinfo/' . $SubEvent->slug;
         }
         $breadcrumb .= ' > ' . $result->title;
         $condition = 'hide_from_main_site="no" and status="active" and game_id=' . $result->game_id;
         // start level data
         if (!empty($levelId)) {
             $condition = 'find_in_set(' . $levelId . ',show_in_level) <> 0 and status="active" and game_id=' . $result->game_id;
         }
         // end level data
         $games = array();
         // get all engine1(matching) data
         $engine1 = Engine1::model()->findAll(array('condition' => $condition));
         if (!empty($engine1)) {
             foreach ($engine1 as $eng1Data) {
                 $games[] = $eng1Data->engine1_id . '&engine=1';
             }
         }
         // get all engine2(Multiple choice) data
         $engine2 = Engine2::model()->findAll(array('condition' => $condition));
         if (!empty($engine2)) {
             foreach ($engine2 as $eng2Data) {
                 $games[] = $eng2Data->engine2_id . '&engine=2';
             }
         }
         // get all engine3(Drag Drop) data
         $engine3 = Engine3::model()->findAll(array('condition' => $condition));
         if (!empty($engine3)) {
             foreach ($engine3 as $eng3Data) {
                 $games[] = $eng3Data->engine3_id . '&engine=3';
             }
         }
         // get all engine4(Color matching) data
         $engine4 = Engine4::model()->findAll(array('condition' => $condition));
         if (!empty($engine4)) {
             foreach ($engine4 as $eng4Data) {
                 $games[] = $eng4Data->engine4_id . '&engine=4';
             }
         }
         // get all engine5(Image Drop down) data
         $engine5 = Engine5::model()->findAll(array('condition' => $condition));
         if (!empty($engine5)) {
             foreach ($engine5 as $eng5Data) {
                 $games[] = $eng5Data->engine5_id . '&engine=5';
             }
         }
         // get all HTML5 games data
         $gameDataModel = new GameData();
         $iframeGames = $gameDataModel->findAll(array('condition' => $condition));
         if (!empty($iframeGames)) {
             foreach ($iframeGames as $iframeGame) {
                 $games[] = $iframeGame->gamedata_id . '&engine=0';
             }
         }
         // count all engines and html5 games data
         $TotalGames = $this->countAllEnginesData($result->game_id);
         // start level data
         if (!empty($levelId)) {
             $TotalGames = $this->countAllLevelEnginesData($result->game_id, $levelId);
         }
         // end level data
         // get games instructions
         $imagesmodel = new Animaltype();
         $condition = 'hide_from_main_site="no" and game_id = ' . $result->game_id . '';
         // start level data
         if (!empty($levelId)) {
             $condition = 'find_in_set(' . $levelId . ',show_in_level) <> 0 and game_id = ' . $result->game_id . '';
         }
         // end level data
         $imagesData = $imagesmodel->findAll(array('condition' => $condition));
         $this->render('allenginedata1', array('breadcrumb' => $breadcrumb, 'link' => $link, 'TotalGames' => $TotalGames, 'games' => json_encode($games), 'slug' => $slug, 'imagesData' => $imagesData));
     } elseif (!empty($Permission)) {
         $this->render('//site/error', array('code' => Yii::t('zii', 'Page Not Found'), 'message' => Yii::t('zii', 'You don\'t have permission to view this page')));
     } else {
         $this->render('//site/error', array('code' => Yii::t('zii', 'Page Not Found'), 'message' => Yii::t('zii', 'The requested page not found')));
     }
 }
Пример #3
0
<?php 
include_once 'helper.php';
include_once 'gamedata.php';
// date_default_timezone_set("Asia/Shanghai");
// $backup_file = Config::BACKUP_BASE_PATH . "rank_" . date("Y-m-d");
// $backup_content = "";
// $totalScoreRank = $gameData->getTotalScoreRank();
// $ranknum = 0;
// foreach ($totalScoreRank as $key => $value) {
// 	if (!$key) {continue;}
// 	$ranknum = $ranknum + 1;
// 	$backup_content = $backup_content . $ranknum . ", " . $key . ", " . $value . "\r\n";
// }
// file_put_contents($backup_file, $backup_content);
$gameData = new GameData();
date_default_timezone_set("Asia/Shanghai");
$backup_file = getcwd() . '/../ramboat_rank/' . 'rank_' . date('Y-m-d');
$backup_content = "";
$totalScoreRank = $gameData->getTotalScoreRank();
$ranknum = 0;
foreach ($totalScoreRank as $key => $value) {
    if (!$key) {
        continue;
    }
    $ranknum = $ranknum + 1;
    $backup_content = $backup_content . $ranknum . ", " . $key . ", " . $value . "\r\n";
}
file_put_contents($backup_file, $backup_content);
?>
Пример #4
0
<?php

include_once 'helper.php';
include_once 'gamedata.php';
$gameData = new GameData();
$gameData->clearWeekRank();
?>

Пример #5
0
<?php

include_once 'helper.php';
include_once 'gamedata.php';
$registerInfo = helper_receiveMsg();
$userId = $registerInfo['userId'];
$pw = $registerInfo['pw'];
$name = $registerInfo['name'];
$icon = $registerInfo['icon'];
//helper_sendMsg(array('ret' => 'GameData configuration error'));exit();
$gameData = new GameData();
if (!$gameData) {
    helper_sendMsg(array('ret' => 'GameData configuration error'));
    helper_log('gameData init fail');
    exit;
}
//helper_sendMsg(array('ret' => 'GameData configuration error 2'));exit();
$userInfo = $gameData->getUserInfo($userId);
// not exist, create a new user
$reward = null;
if (!$userInfo) {
    $returnCode = $gameData->userNameCheck($name);
    if ($returnCode) {
        helper_sendMsg(array('ret' => 'error', 'code' => $returnCode['code'], 'msg' => $returnCode['msg']));
        exit;
    }
    $gameData->addNewUser(array('userId' => $userId, 'pw' => $pw, 'name' => $name, 'icon' => $icon));
    $reward = array('item' => 'coin', 'count' => 1000);
} else {
    helper_sendMsg(array('ret' => 'error', 'code' => 1000));
    exit;
Пример #6
0
<?php

include_once 'helper.php';
include_once 'gamedata.php';
$gameData = new GameData();
// $rows = $gameData->getAllUserId();
// $rows = $gameData->getReward('sjy0079');
$gameData->clearTodayRank();
print_r($rows);
Пример #7
0
<?php

include_once 'helper.php';
include_once 'gamedata.php';
$registerInfo = helper_receiveMsg();
if (!$registerInfo) {
    helper_sendMsg(array('ret' => 'error', 'code' => 3000));
    exit;
}
$userId = $registerInfo['userId'];
// $pw = $registerInfo['pw'];
$gameData = new GameData();
$userInfo = $gameData->getUserInfo($userId);
if (!$userInfo) {
    helper_sendMsg(array('ret' => 'error', 'code' => 3001));
    exit;
}
// if ($userInfo['PW'] != $pw) {
// 	helper_sendMsg(array ('ret' => 'pw_not_right'));
// 	exit();
// }
// update continual login times
// $timeStamp = intval(date("w"));
// if ($userInfo['LOGINSTAMP'] != $timeStamp) {
// 	$loginTimes = $userInfo['LOGINTIMES'];
// 	if ($timeStamp == $userInfo['LOGINSTAMP'] + 1) {
// 		$loginTimes = $loginTimes + 1;
// 	} else {
// 		$loginTimes = 1;
// 	}
// 	$gameData->updateLoginInfo($userId, $timeStamp, $loginTimes);
Пример #8
0
<?php 
include_once 'helper.php';
include_once 'gamedata.php';
$userId = "RamboatRamboatRamboat2222";
$gameData = new GameData();
$day = intval(date("w"));
if ($day == 0) {
    $day = 7;
}
//$yesterdayRank = $gameData->getLastDayRank_redis($userId);
$yesterdayRank = $gameData->getScoreRank($userId);
if (!$yesterdayRank) {
    helper_sendMsg(array('ret' => 'error'));
    exit;
}
$retMsg = array('ret' => 'ok', 'rank' => $yesterdayRank);
echo json_encode($retMsg);
?>


Пример #9
0
<?php

include_once 'helper.php';
include_once 'gamedata.php';
$registerInfo = helper_receiveMsg();
$userId = $registerInfo['userId'];
$gameData = new GameData();
$day = intval(date("w"));
$yesterdayRank = $gameData->getLastRank($userId, $day);
if (!$yesterdayRank) {
    helper_sendMsg(array('ret' => 'error'));
    exit;
}
$retMsg = array('ret' => 'ok', 'rank' => $yesterdayRank);
helper_sendMsg($retMsg);
Пример #10
0
<?php

include_once 'helper.php';
include_once 'gamedata.php';
$msg = helper_receiveMsg();
$userId = $msg['userId'];
$userIcon = $msg['icon'];
$newscore = $msg['score'];
$military = $msg['military'];
$shipType = $msg['ship'];
$gameData = new GameData();
$userInfo = $gameData->getUserInfo($userId);
if (!$userInfo) {
    helper_sendMsg(array('ret' => 'error', 'code' => '2000'));
    exit;
}
$returnCode = $gameData->updateUserScore($userId, $newscore, $userIcon, $military, $shipType);
if (!$returnCode) {
    helper_sendMsg(array('ret' => 'error', 'code' => '0000'));
    exit;
} elseif ($returnCode != 1) {
    helper_sendMsg(array('ret' => 'error', 'code' => $returnCode));
    exit;
}
// $scoreRank = $gameData->getScoreRank($userId);
$selfScoreRank = $gameData->getSelfScoreRank($userId);
helper_sendMsg(array('ret' => 'ok', 'info' => $selfScoreRank));
Пример #11
0
<?php

include_once 'helper.php';
include_once 'gamedata.php';
$msg = helper_receiveMsg();
$userId = $msg['userId'];
$newname = $msg['name'];
$newicon = $msg['icon'];
$gameData = new GameData();
$userInfo = $gameData->getUserInfo($userId);
if (!$userInfo) {
    helper_sendMsg(array('ret' => 'user_not_exist'));
    exit;
}
$gameData->modifyUserInfo($userId, $newname, $newicon);
helper_sendMsg(array('ret' => 'ok'));
Пример #12
0
<?php

include_once 'helper.php';
include_once 'gamedata.php';
$msg = helper_receiveMsg();
$userId = $msg['userId'];
$userIcon = $msg['icon'];
$newscore = $msg['score'];
$gameData = new GameData();
$userInfo = $gameData->getUserInfo($userId);
if (!$userInfo) {
    helper_sendMsg(array('ret' => 'error', 'code' => '2000'));
    exit;
}
$returnCode = $gameData->updateUserScore($userId, $newscore, $userIcon);
if (!$returnCode) {
    helper_sendMsg(array('ret' => 'error', 'code' => '0000'));
    exit;
} elseif ($returnCode != 1) {
    helper_sendMsg(array('ret' => 'error', 'code' => $returnCode));
    exit;
}
// $scoreRank = $gameData->getScoreRank($userId);
$selfScoreRank = $gameData->getSelfScoreRank($userId);
helper_sendMsg(array('ret' => 'ok', 'info' => $selfScoreRank));
Пример #13
0
<?php

include_once 'helper.php';
include_once 'gamedata.php';
$registerInfo = helper_receiveMsg();
$userId = $registerInfo['userId'];
$gameData = new GameData();
$totalrank = $gameData->getTotalScoreRank($userId);
if (!$totalrank) {
    helper_sendMsg(array('ret' => 'get_totalrank_failed'));
    exit;
}
$retMsg = array('ret' => 'ok', 'rank' => $totalrank);
helper_sendMsg($retMsg);
Пример #14
0
<?php

include_once 'helper.php';
include_once 'gamedata.php';
$registerInfo = helper_receiveMsg();
$userId = $registerInfo['userId'];
$gameData = new GameData();
$lastRank = $gameData->getLastScoreRank($userId);
if (!$lastRank) {
    helper_sendMsg(array('ret' => 'error'));
    exit;
}
$retMsg = array('ret' => 'ok', 'rank' => $lastRank);
helper_sendMsg($retMsg);
Пример #15
0
<?php

include_once 'helper.php';
include_once 'gamedata.php';
$registerInfo = helper_receiveMsg();
$userId = $registerInfo['userId'];
$gameData = new GameData();
$dairyRank = $gameData->getScoreRank($userId);
if (!$dairyRank) {
    helper_sendMsg(array('ret' => 'get_rank_failed'));
    exit;
}
$retMsg = array('ret' => 'ok', 'rank' => $dairyRank);
helper_sendMsg($retMsg);
Пример #16
0
<?php

include_once 'helper.php';
include_once 'gamedata.php';
$registerInfo = helper_receiveMsg();
$userId = $registerInfo['userId'];
$gameData = new GameData();
$todayRank = $gameData->getScoreRank($userId);
if (!$todayRank) {
    helper_sendMsg(array('ret' => 'error'));
    exit;
}
$retMsg = array('ret' => 'ok', 'rank' => $todayRank);
helper_sendMsg($retMsg);
Пример #17
0
<?php

include_once 'helper.php';
include_once 'gamedata.php';
$registerInfo = helper_receiveMsg();
$userId = $registerInfo['userId'];
$gameData = new GameData();
$yesterdayRank = $gameData->getLastDayRank($userId);
if (!$yesterdayRank) {
    helper_sendMsg(array('ret' => 'error'));
    exit;
}
foreach ($yesterdayRank as $key => $value) {
    if (!isset($value['military'])) {
        $yesterdayRank[$key]['military'] = -1;
    }
    if (!isset($value['ship'])) {
        $yesterdayRank[$key]['ship'] = -1;
    }
}
$retMsg = array('ret' => 'ok', 'rank' => $yesterdayRank);
helper_sendMsg($retMsg);
Пример #18
0
<?php

include_once 'helper.php';
include_once 'gamedata.php';
$gameData = new GameData();
$allUserId = $gameData->getAllUserId();
foreach ($allUserId as $key => $value) {
    $userId = $value;
    $scoreRank = $gameData->getScoreRank($userId);
    $thisDayRank = json_encode($scoreRank);
    $gameData->backupScoreRank($userId);
}
//delete today rank
$gameData->clearTodayRank();