function resourceGet($api, $tools, $param) { $param["fbId"] = $tools->sql_injection_anti($_SESSION['fbId']); $param["stage"] = $tools->sql_injection_anti($_POST['stage']); if ($param["fbId"] == "" or $param["stage"] == "") { $api->setError("資料不齊全,請重新輸入。"); return; } include_once "../../library/Table/User.class.php"; $user = new User(); include_once "../../library/Table/Friend.class.php"; $friend = new Friend(); $userData = $user->getByFbId($param['fbId']); if (empty($userData)) { $api->setError("查無玩家資料!"); return; } else { switch ($param['stage']) { case "F": if ($userData['act6'] == 0) { $api->setError("不符合獎勵條件!"); return; } case "E": if ($userData['act5'] == 0) { $api->setError("不符合獎勵條件!"); return; } case "D": if ($userData['act4'] == 0) { $api->setError("不符合獎勵條件!"); return; } case "C": if ($userData['act3'] == 0) { $api->setError("不符合獎勵條件!"); return; } case "B": if ($userData['act2'] == 0) { $api->setError("不符合獎勵條件!"); return; } case "A": if ($userData['act1'] == 0) { $api->setError("不符合獎勵條件!"); return; } break; default: $api->setError("無此關卡獎勵!"); break; } include_once "../../library/Table/AwardSn.class.php"; $awardSn = new AwardSn(); $award = $awardSn->getAwardSn($param['stage'], $param['fbId']); if (empty($award)) { $awardSn->receiveAwardSn($param['stage'], $param['fbId']); $award = $awardSn->getAwardSn($param['stage'], $param['fbId']); } $extra = array(); if ($param['stage'] == "C") { $extra = $awardSn->getAwardSn("G", $param['fbId']); if (empty($extra)) { $extra = $awardSn->getAwardSn("H", $param['fbId']); if (empty($extra)) { if (intval($userData['act3']) % 100 == 0 and intval($userData['act3']) > 3425) { $awardSn->receiveAwardSn("G", $param['fbId']); $extra = $awardSn->getAwardSn("G", $param['fbId']); if (empty($extra)) { $awardSn->receiveAwardSn("H", $param['fbId']); $extra = $awardSn->getAwardSn("H", $param['fbId']); } } } } } if ($param['stage'] == "E") { $extra = $awardSn->getAwardSn("I", $param['fbId']); if (empty($extra)) { $extra = $awardSn->getAwardSn("I", $param['fbId']); if (empty($extra)) { if (intval($userData['act5']) % 100 == 0 and intval($userData['act5']) > 1160) { $awardSn->receiveAwardSn("I", $param['fbId']); $extra = $awardSn->getAwardSn("I", $param['fbId']); if (empty($extra)) { $awardSn->receiveAwardSn("J", $param['fbId']); $extra = $awardSn->getAwardSn("J", $param['fbId']); } } } } } $api->setOutput("取得獎勵資料", array("award" => $award, "extra" => $extra)); } return; }
try { $sn_array = array(); for ($row = 1; $row <= $highestRow; $row++) { $ary["sn"] = $sheet->getCellByColumnAndRow(0, $row)->getValue(); if (!empty($ary["sn"])) { array_push($sn_array, $ary); } else { echo "<script>alert('第" . $row . "行資料不齊全'); location.href='index.php?page=award/edit';</script>"; exit; } } } catch (Exception $e) { // 若有錯誤就要回覆 echo "<script>alert('上傳文件格式不符'); location.href='index.php?page=award/edit';</script>"; exit; } include_once LIB_PATH . "Table/AwardSn.class.php"; $tb_award_sn = new AwardSn(); if (!empty($sn_array)) { foreach ($sn_array as $key => $value) { $affectedRow = $tb_award_sn->addAwardSn($param['stage'], $value["sn"], $param['account']); if (empty($affectedRow)) { echo "<script>alert('訊息儲存發生錯誤'); location.href='index.php?page=award/edit';</script>"; exit; } } } // 取得目前數量 $counts = $tb_award_sn->countAwardSnByStage($param['stage']); echo "<script>alert('資料儲存完成,共" . $counts . "筆。'); location.href='index.php?page=award/list';</script>"; exit;
case "F": // no break; // no break; case "G": // no break; // no break; case "H": // no break; // no break; case "I": // no break; // no break; case "J": break; default: echo "<script>alert('關卡設定錯誤'); location.href='index.php?page=award/list';</script>"; exit; } include_once LIB_PATH . "Table/AwardSn.class.php"; $tb_award_sn = new AwardSn(); $counts = $tb_award_sn->countAwardSnByStage($param['stage']); $pageBar['url'] = "index.php?page=award/show&stage=A&at="; $pageBar['current'] = floor($param["at"]); // 當前頁數 $pageBar['pageNums'] = ceil($counts / $param["limit"]); // 總頁數 $pageBar['rowNums'] = floor($counts); // 總筆數 // $tpl->pageBar = $pageBar; $list = $tb_award_sn->listAwardSnByStage($param['stage']); $tpl->list = $list;
<?php $stage = array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J"); include_once LIB_PATH . "Table/AwardSn.class.php"; $tb_award_sn = new AwardSn(); $stageTitle = array(); $stageTitle["A"] = "關卡 I - 送10萬銀幣"; $stageTitle["B"] = "關卡 II - 送10萬祝福"; $stageTitle["C"] = "關卡 III - 送2個屬性刷新水晶"; $stageTitle["D"] = "關卡 IV - 送全家39元早餐兌換券"; $stageTitle["E"] = "關卡 V - 送1級隨機寶石"; $stageTitle["F"] = "關卡 VI - 「HTC New One」抽獎機會"; $stageTitle["G"] = "限量虛寶 - 九藏"; $stageTitle["H"] = "限量虛寶 - 森野樹"; $stageTitle["I"] = "限量虛寶 - 龍魂"; $stageTitle["J"] = "限量虛寶 - 黑鬍子祕寶"; $tpl->stageTitle = $stageTitle; $stageCounts = array(); foreach ($stage as $value) { $stageCounts[$value] = $tb_award_sn->countAwardSnByStage($value); $stageCountsUserGet[$value] = $tb_award_sn->countAwardSnByStageUserGet($value); } $tpl->list = $stageCounts; $tpl->stageCountsUserGet = $stageCountsUserGet;