function getPlayerID($gameName, $clanID) { $db = new BaseDB(); $records = $db->dbQuery("SELECT PlayerID from Player WHERE GameName = '{$gameName}' AND ClanID = {$clanID}"); if (sqlsrv_has_rows($records)) { $record = sqlsrv_fetch_array($records, SQLSRV_FETCH_BOTH); return $record['PlayerID']; } else { return null; } }
function SendNotificationToNextAttacker($clanID) { $db = new BaseDB(); $sql = "\n SELECT p.GameName, gcmu.gcm_regid\n FROM dbo.OurParticipant AS op INNER JOIN\n dbo.Player AS p ON op.PlayerID = p.PlayerID INNER JOIN\n dbo.gcm_users AS gcmu ON p.GameName = gcmu.game_name\n WHERE op.NextAttacker = 1 AND ClanID = {$clanID}\n "; $result = $db->dbQuery($sql); while ($record = sqlsrv_fetch_array($result, SQLSRV_FETCH_BOTH)) { $registatoin_ids[0] = $record['gcm_regid']; $msg = array("data" => "cal" . $record['GameName'] . " it is your turn to attack!"); send_push_notification($registatoin_ids, $msg); } $db->Free($result); $db->close(); }
/** * 紀錄管理者登入IP * * @param string 管理者帳號 * @param string IP Address * @return int * @access public */ public function updateLoginIp($account, $ip) { $now = date('Y-m-d H:i:s'); if (!is_object($this->pdo)) { $this->connect($DBConfig["Master"]); } try { $query = "UPDATE {$this->_name} \n SET `first_ip` = `last_ip`, `first_time` = `last_time`, `last_ip` = :ip, `last_time` = :now \n WHERE `account` = :account LIMIT 1"; $stmt = $this->pdo->prepare($query); $stmt->bindParam(":account", $account); $stmt->bindParam(":ip", $ip); $stmt->bindParam(":now", $now); $res = $stmt->execute(); if ($res === true) { $result = $stmt->rowCount(); } else { // log it parent::logResError($this->_name, "updateLoginIp", $res); return false; } } catch (PDOException $e) { // log it parent::logPDOError($this->_name, "updateLoginIp", $e); return false; } return $result; }
function __construct($id = NULL) { $fields = array('label' => new Type\CharField(), 'cat' => new Type\CharField(), 'active' => new Type\BooleanField(), 'parent' => new Type\ForeignKey('FelixOnline\\Core\\Category'), 'email' => new Type\CharField(), 'twitter' => new Type\CharField(), 'description' => new Type\TextField(), 'order' => new Type\IntegerField(), 'hidden' => new Type\BooleanField(), 'secret' => new Type\BooleanField()); parent::__construct($fields, $id); $currentuser = new CurrentUser(); if ($this->getSecret() && !$currentuser->isLoggedIn() && !Utility::isInCollege()) { throw new \FelixOnline\Exceptions\ModelNotFoundException("This is a secret category and you don't have permission to access it", "Category", $id); } }
/** * 取得某日的 LOG 數 * * @param string $date * @return int $counts * @access public */ public function countLikeLogByDate($date) { if (!is_object($this->pdo)) { $this->connect($DBConfig["Master"]); } try { $query = "SELECT COUNT(*) AS `Counts` FROM {$this->_name} \n WHERE `log_date` = :log_date LIMIT 1"; $stmt = $this->pdo->prepare($query); $stmt->bindParam(":log_date", $date); $res = $stmt->execute(); if ($res === true) { $result = $stmt->fetch(PDO::FETCH_ASSOC); } else { // log it parent::logResError($this->_name, "countLikeLogByDate", $res); return false; } } catch (PDOException $e) { // log it parent::logPDOError($this->_name, "countLikeLogByDate", $e); return false; } return $result['Counts']; }
/** * 使用者功能權限 * * @param array $param_array * @return boolean * @access public */ public function getPermissionById($admin_id) { if (!is_object($this->pdo)) { $this->connect($DBConfig["Master"]); } try { $query = "SELECT * FROM {$this->_name} WHERE `admin_id` = :admin_id LIMIT 1"; $stmt = $this->pdo->prepare($query); $stmt->bindParam(":admin_id", $admin_id); $res = $stmt->execute(); if ($res === true) { $result = $stmt->fetch(PDO::FETCH_ASSOC); } else { // log it parent::logResError($this->_name, "getPermissionById", $res); return false; } } catch (PDOException $e) { // log it parent::logPDOError($this->_name, "getPermissionById", $e); return false; } return $result; }
/** * 刪除已經發出的酷朋券 * * @return int $affectedRow * @access public */ public function deleteEmailCoupon($coupon) { if (!is_object($this->pdo)) { $this->connect($DBConfig["Master"]); } try { $query = "DELETE FROM {$this->_name} WHERE `coupon` = :coupon"; $stmt = $this->pdo->prepare($query); $stmt->bindParam(":coupon", $coupon); $res = $stmt->execute(); if ($res === true) { $result = $stmt->rowCount(); } else { // log it parent::logResError($this->_name, "deleteEmailCoupon", $res); return false; } } catch (PDOException $e) { // log it parent::logPDOError($this->_name, "deleteEmailCoupon", $e); return false; } return $result; }
function PW_UsercacheDB() { parent::BaseDB(); $this->now = $GLOBALS['timestamp']; }
<?php session_start(); $clanID = $_SESSION['selectedClanID']; include_once "BaseClasses/BaseDB.class.php"; include_once "BaseClasses/Database.class.php"; $warDate = $_REQUEST['wardate']; $NumberOfParticipants = $_REQUEST['numberofparticipants']; $WarsWeWon = $_REQUEST['warswewon']; $WarsTheyWon = $_REQUEST['warstheywon']; $active = $_REQUEST['active']; $db = new BaseDB(); $sql = "insert into War(ClanId, date, NumberOfParticipants, WarsWeWon, WarsTheyWon, active) values(\n {$clanID}, '{$warDate}','{$NumberOfParticipants}', '{$WarsWeWon}', '{$WarsTheyWon}', '{$active}')"; $result = $db->dbQuery($sql); if ($result == false) { echo json_encode(['errorMsg' => 'An error occured: ' . dbGetErrorMsg()]); } else { echo json_encode(['success' => 'success']); } // if ($result == false) { // echo json_encode([ // 'errorMsg' => 'An error occured: ' . dbGetErrorMsg() // ]); // } else { // $sqlIdentity = "select @@identity as EntityId"; // $resultWarID = sqlsrv_query(Database::getInstance()->getConnection(), $sqlIdentity); // $rowIdentity = sqlsrv_fetch_array($resultWarID); // $WarID = $rowIdentity["EntityId"]; // }
function __construct($id = NULL) { $fields = array('poll' => new Type\ForeignKey('FelixOnline\\Core\\Poll'), 'option' => new Type\ForeignKey('FelixOnline\\Core\\PollOption'), 'ip' => new Type\TextField(), 'useragent' => new Type\TextField()); parent::__construct($fields, $id, null, true); }
<?php session_start(); $selectedWarID = $_SESSION["selectedWarID"]; include_once "BaseClasses/BaseDB.class.php"; include_once "BaseClasses/Database.class.php"; $i = 0; $dbBaseClass = new BaseDB(); $sql = "\n SELECT atk.AttackID, atk.OurAttack, atk.FirstAttack, atk.OurParticipantID,\n atk.TheirParticipantID, atk.StarsTaken, dbo.Player.GameName,\n dbo.TheirParticipant.Rank,\n CONCAT(dbo.Player.GameName, ' (#', part.Rank, ')') As OurParticipant,\n CONCAT('Rank (#', dbo.TheirParticipant.Rank, ')') As TheirParticipant\n FROM dbo.TheirParticipant RIGHT OUTER JOIN\n dbo.Attack AS atk ON dbo.TheirParticipant.TheirParticipantID = atk.TheirParticipantID LEFT OUTER JOIN\n dbo.Player INNER JOIN\n dbo.OurParticipant AS part ON dbo.Player.PlayerID = part.PlayerID ON atk.OurParticipantID = part.OurParticipantID\n WHERE (atk.OurAttack = 0) AND (atk.WarID = {$selectedWarID})\n ORDER BY atk.TimeOfAttack DESC\n "; $records = $dbBaseClass->dbQuery($sql); while ($record = sqlsrv_fetch_array($records, SQLSRV_FETCH_BOTH)) { $data[$i++] = array('ourparticipant' => $record['OurParticipant'], 'theirparticipant' => $record['TheirParticipant'], 'attackid' => $record['AttackID'], 'ourattack' => 0, 'firstattack' => $record['FirstAttack'], 'ourparticipantid' => $record['OurParticipantID'], 'theirparticipantid' => $record['TheirParticipantID'], 'starstaken' => $record['StarsTaken'], 'gamename' => $record['GameName']); } echo json_encode($data);
/** * Public: Save new comment into database * * Returns id of new comment */ public function save() { // Email address validation tests are NOT handled here as different workflows may have different rules for auto validation $app = App::getInstance(); // If an update if ($this->pk && $this->fields[$this->pk]->getValue()) { return parent::save(); } $this->setIp($app['env']['REMOTE_ADDR']); $this->setUseragent($app['env']['HTTP_USER_AGENT']); $this->setReferer($app['env']['HTTP_REFERER']); if (!$this->getUser()) { // check key $key_check = $app['akismet']->keyCheck($app->getOption('akismet_api_key', ''), $app->getOption('base_url')); if ($key_check == false) { throw new \FelixOnline\Exceptions\InternalException('Akismet key is invalid'); } // check spam using akismet $check = $app['akismet']->check(array('permalink' => $this->getArticle()->getURL(), 'comment_type' => 'comment', 'comment_author' => $this->fields['name']->getValue(), 'comment_content' => $this->getComment(), 'comment_author_email' => $this->getEmail(), 'user_ip' => $this->getIp(), 'user_agent' => $this->getUseragent(), 'referrer' => $this->getReferer())); // check for akismet errors if (!is_null($app['akismet']->getError())) { throw new \FelixOnline\Exceptions\InternalException($app['akismet']->getError()); } if ($check == true) { // if comment is spam $this->setActive(0); $this->setPending(0); $this->setSpam(1); } else { // Not spam $this->setActive(1); $this->setPending(1); $this->setSpam(0); } } else { $this->setActive(1); $this->setPending(0); $this->setSpam(0); } parent::save(); if (!$this->getSpam()) { // Send emails if (!$this->getUser()) { $log_entry = new \FelixOnline\Core\AkismetLog(); $log_entry->setCommentId($this)->setAction('check')->setIsSpam($check)->setError($app['akismet']->getError())->save(); // If pending comment if (!$this->getSpam() && $this->getPending() && $this->getActive()) { $this->emailComment(); } } } return $this->getId(); // return new comment id }
<?php include_once "BaseClasses/BaseDB.class.php"; include_once "BaseClasses/Database.class.php"; $warID = $_REQUEST['selectedWarID']; $db = new BaseDB(); $sql = "\n select GameName,\n CASE FirstAttack\n WHEN 1 THEN 'First'\n WHEN 0 THEN 'Second'\n END AS Attack,\n StarsTaken,\n OurRank,\n TheirRank\n FROM View_WarProgress\n WHERE WarID = {$warID} AND OurAttack = 1 ORDER BY OurRank ASC, FirstAttack DESC\n "; $records = $db->dbQuery($sql); $data = array(); $i = 0; if (!$records) { $data['stats'][0] = array('GameName' => '', 'Attack' => '', 'StarsTaken' => 0, 'OurRank' => 0, 'TheirRank' => 0); } else { while ($record = sqlsrv_fetch_array($records, SQLSRV_FETCH_BOTH)) { $data['stats'][$i] = array('GameName' => $record['GameName'], 'Attack' => $record['Attack'], 'StarsTaken' => $record['StarsTaken'], 'OurRank' => $record['OurRank'], 'TheirRank' => $record['TheirRank']); $i++; } } $db->Free($records); $db->close(); echo json_encode($data);
* @package * @author Danie du |Toit * @license * @link */ session_start(); ?> <?php if (isset($_POST['Return'])) { header("Location: BranchDisplayGrid.php"); } require_once "Header.inc.php"; $action = ''; $selectList = ''; $dbBaseClass = new BaseDB(); $companyName = ''; $divisionId = ''; if (isset($_POST['Create']) === false) { if (isset($_GET['id']) === false || isset($_GET['action']) === false) { header("Location: BranchDisplayGrid.php"); } $id = (int) $_GET['id']; $action = $_GET['action']; sanitizeString($id); // Get the Division EntityId $divisionStmnt = $dbBaseClass->getFieldsForAll("BusinessEntity", array('BusinessEntityParentId'), "WHERE id = {$_GET['entityId']}"); if ($divisionStmnt == false) { $_SESSION['error'] = "The branch does not have a related division."; header("Location: BranchDisplayGrid.php"); exit;
/** * 更新使用者加入進戲資訊 * * @param array $param_array * @return boolean * @access public */ public function updateUserJoin($fbId) { if (!is_object($this->pdo)) { $this->connect($DBConfig["Master"]); } try { $query = "UPDATE {$this->_name} SET game_join = 1 WHERE fb_id = :fbId"; $stmt = $this->pdo->prepare($query); $stmt->bindParam(":fbId", $fbId); $res = $stmt->execute(); if ($res === true) { $result = $stmt->rowCount(); } else { // log it parent::logResError($this->_name, "updateUserJoin", $res); return false; } } catch (PDOException $e) { // log it parent::logPDOError($this->_name, "updateUserJoin", $e); return false; } return $result; }
function __construct($id = NULL) { $fields = array('email' => new Type\CharField(), 'code' => new Type\CharField(), 'confirmed' => new Type\BooleanField()); parent::__construct($fields, $id, null, true); }
<?php require_once 'GCM_Loader.php'; $selectedWarID = $_REQUEST['selectedWarID']; $ownRank = $_REQUEST['rank']; $db = new BaseDB(); //TODO Remember to change the hardcoded '0' (RankByExperience) below -> BIT $sql_callFunc = "SELECT (SELECT dbo.[PlayersNextBestAttack]({$selectedWarID}, {$ownRank}, 0) AS RankToAttack) AS RankToAttack"; $result = $db->dbQuery($sql_callFunc); $rankToAttack = 0; $err = ""; $record = sqlsrv_fetch_array($result, SQLSRV_FETCH_BOTH); if ($record == false) { $err = dbGetErrorMsg(); } $db->Free($result); $db->close(); $data['rankToAttack'][0] = array('rank' => $record['RankToAttack']); echo json_encode($data);
if ($businessEntity['Id'] == $businessEntityParentId) { $selectList .= "<option selected=selected value='{$businessEntity['Id']}'>{$businessEntity['Name']}</option>"; } else { $selectList .= "<option value='{$businessEntity['Id']}'>{$businessEntity['Name']}</option>"; } } } else { while ($businessEntity = sqlsrv_fetch_array($businessEntityRecords, SQLSRV_FETCH_ASSOC)) { $selectList .= "<option value='{$businessEntity['Id']}'>{$businessEntity['Name']}</option>"; } $action = 'c'; $id = -1; } sanitizeString($action); // Set up DB connection $dbBaseClass = new BaseDB(); if (Database::getConnection() === false) { $_SESSION['error'] = "ERROR: Could not connect. " . printf('%s', dbGetErrorMsg()); header("Location: DivisionDisplayGrid.php"); exit; } // An existing record is expected when the action is not "Create" if ($action != 'c') { // Read the record $records = $dbBaseClass->getAllByFieldName('BusinessEntity', 'id', $id); if ($records === false) { $_SESSION['error'] = dbGetErrorMsg(); header("Location: DivisionDisplayGrid.php"); exit; } // Get the specific record
function __construct($id = NULL) { $fields = array('topic' => new Type\ForeignKey('FelixOnline\\Core\\Topic'), 'article' => new Type\ForeignKey('FelixOnline\\Core\\Article')); parent::__construct($fields, $id); }
/** * 新增 LOG * * @param array $param * @return int $LastInsertId * @access public */ public function addShareLog($param) { if (!is_object($this->pdo)) { $this->connect($DBConfig["Master"]); } try { $query = "INSERT INTO {$this->_name}(`fb_id`, `ip`, `log_date`) VALUES(?, ?, ?)"; $stmt = $this->pdo->prepare($query); $stmt->bindParam(1, $param["fb_id"]); $stmt->bindParam(2, $param["ip"]); $stmt->bindParam(3, $param["today"]); $res = $stmt->execute(); if ($res === true) { $result = $this->pdo->lastInsertId(); } else { // log it parent::logResError($this->_name, "addShareLog", $res); return false; } } catch (PDOException $e) { // log it parent::logPDOError($this->_name, "addShareLog", $e); return false; } return $result; }
<td class="noBorder"> <form name="form2" action="Company.php" method="post"> <input type="submit" value="Create" name="Create" id="Create"> </form> </td> <td class="noBorder"> <form name="form3" action="CompanyDisplayGrid.php" method="post"> <input type="submit" value="Return" name="Return" id="Return"> </form> </td> </tr> </table> </div> <br> <?php $dbBaseClass = new BaseDB(); if (Database::getConnection() === false) { $_SESSION['error'] = dbGetErrorMsg(); header("Location: Default.php"); exit; } if (isset($_POST["Search"])) { $bc = $_POST['SearchN']; // echo $bc; $records = $dbBaseClass->getFieldsByFilter('Company', array('id', 'Name', 'CompanyCode', 'Active', 'ShortName'), "WHERE Name LIKE '%{$bc}%'"); } else { $records = $dbBaseClass->getFieldsForAll('Company', array('id', 'Name', 'CompanyCode', 'Active', 'ShortName')); } if ($records === false) { $_SESSION['error'] = dbGetErrorMsg(); header("Location: Default.php");
/** * 取出該FB_ID的電子信箱 * * @return array * @access public */ public function getByLotteryEmail($fbId) { if (!is_object($this->pdo)) { $this->connect($DBConfig["Master"]); } try { $query = "SELECT * FROM {$this->_name} WHERE fb_id = :fbId "; $stmt = $this->pdo->prepare($query); $stmt->bindParam(":fbId", $fbId); $res = $stmt->execute(); if ($res === true) { $result = $stmt->fetch(PDO::FETCH_ASSOC); } else { // log it parent::logResError($this->_name, "getByLotteryEmail", $res); return false; } } catch (PDOException $e) { // log it parent::logPDOError($this->_name, "getByLotteryEmail", $e); return false; } return $result; }
include "Header.inc.php"; $action = ''; if (!isset($_POST['Create'])) { if (isset($_GET['id']) === false || isset($_GET['action']) === false) { header("Location: CompanyDisplayGrid.php"); } $id = (int) $_GET['id']; $action = $_GET['action']; sanitizeString($id); } else { $action = 'c'; $id = -1; } sanitizeString($action); // Set up DB connection $dbBaseClass = new BaseDB(); $recordBase = BaseCompany::$company; if (Database::getConnection() === false) { $_SESSION['error'] = "ERROR: Could not connect. " . printf('%s', dbGetErrorMsg()); header("Location: BranchDisplayGrid.php"); exit; } // An existing record is expected when the action is not "Create" if ($action != 'c') { // Read the record $records = $dbBaseClass->getAll('Company', "WHERE id = {$id}"); if ($records === false) { $_SESSION['error'] = dbGetErrorMsg(); header("Location: BranchDisplayGrid.php"); exit; }
function __construct($id = NULL) { $fields = array('comment_id' => new Type\ForeignKey('FelixOnline\\Core\\Comment'), 'timestamp' => new Type\DateTimeField(), 'action' => new Type\CharField(), 'is_spam' => new Type\BooleanField(), 'error' => new Type\TextField()); parent::__construct($fields, $id, null, true); }
function __construct($id = NULL) { $fields = array('details' => new Type\CharField(), 'image' => new Type\ForeignKey('FelixOnline\\Core\\Image'), 'url' => new Type\CharField(), 'start_date' => new Type\DateTimeField(), 'end_date' => new Type\DateTimeField(), 'max_impressions' => new Type\IntegerField(), 'views' => new Type\IntegerField(), 'clicks' => new Type\IntegerField(), 'frontpage' => new Type\BooleanField(), 'categories' => new Type\BooleanField(), 'articles' => new Type\BooleanField(), 'sidebar' => new Type\BooleanField()); parent::__construct($fields, $id); }
/** * 新增 LOGIN 點擊 LOG * * @return int * @access public */ public function addLoginClickLog() { $today = date("Y-m-d"); if (!is_object($this->pdo)) { $this->connect($DBConfig["Master"]); } try { $query = "INSERT INTO {$this->_name} (`log_date`, `login_click`) VALUES (:today, 1) \n ON DUPLICATE KEY UPDATE `login_click` = `login_click` + 1 "; $stmt = $this->pdo->prepare($query); $stmt->bindParam(":today", $today); $res = $stmt->execute(); if ($res === true) { $result = $stmt->rowCount(); } else { // log it parent::logResError($this->_name, "addLoginClickLog", $res); return false; } } catch (PDOException $e) { // log it parent::logPDOError($this->_name, "addLoginClickLog", $e); return false; } return $result; }
<?php require_once 'GCM_Loader.php'; $db = new BaseDB(); $message = $_REQUEST["message"]; $clanID = $_REQUEST["clanID"]; $i = 0; $sql = "\n SELECT gcm_regid, game_name FROM dbo.gcm_users WHERE Active = 1 AND clanID = {$clanID}\n "; $result = $db->dbQuery($sql); $data = array(); $registatoin_ids = array(); $i = 0; while ($record = sqlsrv_fetch_array($result, SQLSRV_FETCH_BOTH)) { $registatoin_ids[$i++] = $record['gcm_regid']; } $msg = array("data" => $message); send_push_notification($registatoin_ids, $msg); $db->close();
function __construct($id = NULL) { $fields = array('advert' => new Type\ForeignKey('FelixOnline\\Core\\Advert'), 'category' => new Type\ForeignKey('FelixOnline\\Core\\Category')); parent::__construct($fields, $id); }
function __construct($id = NULL) { $fields = array('poll' => new Type\ForeignKey('FelixOnline\\Core\\Poll'), 'text' => new Type\TextField()); parent::__construct($fields, $id); }
<?php include_once "BaseClasses/BaseDB.class.php"; include_once "BaseClasses/Database.class.php"; $warID = $_REQUEST['selectedWarID']; $db = new BaseDB(); $sql = "\n SELECT TOP (1) dbo.Attack.BusyAttackingRank, dbo.Player.GameName\n FROM dbo.Attack INNER JOIN\n dbo.OurParticipant ON dbo.Attack.OurParticipantID = dbo.OurParticipant.OurParticipantID INNER JOIN\n dbo.Player ON dbo.OurParticipant.PlayerID = dbo.Player.PlayerID\n WHERE (ISNULL(dbo.Attack.BusyAttackingRank, - 1) <> - 1) AND (dbo.Attack.OurAttack = 1) AND (dbo.Attack.WarID = {$warID}) AND (dbo.Attack.BusyAttackingRank > 0)\n GROUP BY dbo.Attack.BusyAttackingRank, dbo.Attack.AttackID, dbo.Attack.OurAttack, dbo.Attack.WarID, dbo.Player.GameName\n "; $result = $db->dbQuery($sql); $record = sqlsrv_fetch_array($result, SQLSRV_FETCH_BOTH); $data = array(); if (!$record) { $data['busyAttackingRank'][0] = array('rank' => 0); } else { $data['busyAttackingRank'][0] = array('rank' => $record['BusyAttackingRank'], 'gameName' => $record['GameName']); } $db->Free($result); $db->close(); echo json_encode($data);