Ejemplo n.º 1
0
 public function insertUserBank($userID, $activityName = 'register')
 {
     $bankBalance = 0;
     if (!empty($activityName)) {
         $activityReward = new ActivityReward($activityName);
         $bankBalance = isset($activityReward) ? $activityReward->getActivityRewardAmount() : 0;
     }
     $link = @mysqli_connect(Config::getDatabaseServer(), Config::getDatabaseUser(), Config::getDatabasePassword(), Config::getDatabase());
     if (!$link) {
         return GAMEON_ERROR;
     }
     $sql = sprintf("insert into go_userBank (userID, bankBalance ) values ('%u','%u')", mysqli_real_escape_string($link, $userID), mysqli_real_escape_string($link, $bankBalance));
     if (Config::getDebug()) {
         $this->LOG->log("{$sql}", PEAR_LOG_INFO);
     }
     $rc = @mysqli_query($link, $sql);
     $affectedRows = mysqli_affected_rows($link);
     if ($affectedRows > 0) {
         return GAMEON_OK;
     } else {
         return GAMEON_ERROR;
     }
 }
 public function getPublicGames()
 {
     $sql = goPublicGame::getSql();
     $link = @mysqli_connect(Config::getDatabaseServer(), Config::getDatabaseUser(), Config::getDatabasePassword(), Config::getDatabase());
     if (!$link) {
         mydie("Error connecting to Database");
     }
     if (Config::getDebug()) {
         $this->LOG->log("{$sql}", PEAR_LOG_INFO);
     }
     $cursor = @mysqli_query($link, $sql);
     if (!$cursor) {
         $this->mydie(mysqli_error($link), $link);
     }
     $record = 0;
     while ($row = @mysqli_fetch_assoc($cursor)) {
         $game = new goPublicgame();
         //$game->setGameID($row['gameID']);
         $game->setDescription($row['description']);
         $game->setTitle($row['title']);
         $game->setEventName($row['eventName']);
         $game->setEventDate($row['eventDate']);
         $game->setSportID($row['sport']);
         $game->setSportName($row['sportName']);
         $game->setLeagueName($row['leagueName']);
         $game->setFavorite($row['favorite']);
         $game->setTypeID($row['type']);
         $game->setTypeName($row['typeName']);
         /*** temp explicit treatment as array storage***/
         $this->publicGames[$record] = $game;
         $record++;
         /*** end temp ***/
     }
     //while
     $link->close();
 }
 public function getActivityReward($activityReward)
 {
     $link = @mysqli_connect(Config::getDatabaseServer(), Config::getDatabaseUser(), Config::getDatabasePassword(), Config::getDatabase());
     if (!$link) {
         return GAMEON_ERROR;
     }
     $sql = sprintf("select * from go_activityRewards  where activityName= '%s'", mysqli_real_escape_string($link, $activityReward));
     if (Config::getDebug()) {
         $this->LOG->log("{$sql}", PEAR_LOG_INFO);
     }
     $cursor = @mysqli_query($link, $sql);
     if (isset($cursor)) {
         $row = @mysqli_fetch_assoc($cursor);
         if (isset($row) && count($row) > 0) {
             $this->setActivityRewardID($row['activityID']);
             $this->setActivityRewardName($row['activityName']);
             $this->setActivityRewardType($row['rewardType']);
             $this->setActivityRewardAmount($row['amount']);
             $rv = GAMEON_OK;
             $this->setStatusCode(GAMEON_OK);
         } else {
             $rv = GAMEON_NORECORD;
         }
     } else {
         //if
         $rv = GAMEON_ERROR;
     }
     //else
     if (isset($cursor)) {
         $cursor->close();
     }
     if (isset($link)) {
         $link->close();
     }
     return $rv;
 }
Ejemplo n.º 4
0
$operation = $_GET['operation'];
$querySort = $_GET['sort'];
//default if empty
if (empty($operation)) {
    $operation = 'friends';
}
/* verify have enough to continue - set defaults for missing parameters as long as they are not
   mandatory
*/
if (!isset($userID)) {
    mydie("paramaters not complete");
}
$params['userid'] = $userID;
$params['operation'] = strtolower($operation);
$params['query'] = $query;
$link = mysqli_connect(Config::getDatabaseServer(), Config::getDatabaseUser(), Config::getDatabasePassword(), Config::getDatabase());
if (!$link) {
    // Server error
    header('HTTP/1.1 500 Internal Server Error');
    mydie("Error connecting to Database");
}
$sql = getQuery($params, $link);
if (Config::getDebug()) {
    $LOG->log("{$sql}", PEAR_LOG_INFO);
}
$cursor = mysqli_query($link, $sql);
if (!$cursor) {
    // Server error
    mydie(mysqli_error($link), "500", $link);
}
$numberOfFriends = $cursor->num_rows;
Ejemplo n.º 5
0
//define constants
define("FIELD_DELIMITER", ",");
define("FIELD_WEEK_NUMBER", 0);
define("FIELD_GAME_DATE", 1);
define("FIELD_GAME_TIME", 2);
define("FIELD_GAME_VISITING_TEAM", 3);
define("FIELD_GAME_HOME_TEAM", 4);
define("TYPE_ID", 2);
//from go_types_lu - team sport
$recordsProcessed = 0;
//open input file
$fileHandle = fopen($inputFile, 'r');
$link = @mysqli_connect(Config::getDatabaseServer(), Config::getDatabaseUser(), Config::getDatabasePassword(), Config::getDatabase());
//$link = @mysqli_connect('.',Config::getDatabaseUser(), Config::getDatabasePassword(),Config::getDatabase(),null,'mysql');
if (!$link) {
    mydie("Error connecting to Database \n" . "Error No:" . mysqli_connect_errno() . "\n Error = " . mysqli_connect_error() . "\n using database server = " . Config::getDatabaseServer() . "\n Database User = "******"\n Database Password = "******"\n Database = " . Config::getDatabase() . "\n");
}
//start by deleting existing records  first from go_publicgames_combatants then from go_publicgames
$sql = sprintf("delete from go_publicgames_combatants where gameID in (select gameID from go_publicgames where leagueName='%s' and season='%u')", LEAGUE_NAME, SEASON);
$rc = mysqli_query($link, $sql);
if (!$rc) {
    // Server error
    mydie(mysqli_error($link) . " executing sql {$sql}");
}
//if
$sql = sprintf("delete from go_publicgames where leagueName='%s' and season='%u'", LEAGUE_NAME, SEASON);
$rc = mysqli_query($link, $sql);
if (!$rc) {
    // Server error
    mydie(mysqli_error($link) . " executing sql {$sql}");
}
Ejemplo n.º 6
0
 public function updateFacebookOAuth($userID, $facebookID, $imageUrl, $sec, $tok)
 {
     $link = mysqli_connect(Config::getDatabaseServer(), Config::getDatabaseUser(), Config::getDatabasePassword(), Config::getDatabase());
     if (!$link) {
         die("Error connecting to Database");
     }
     if (Config::getDebug()) {
         $LOG->log("{$sql}", PEAR_LOG_INFO);
     }
     $cursor = mysqli_query($link, $sql);
     if (!$cursor) {
         die(mysqli_error($link));
     }
     $link->close();
     return true;
 }
Ejemplo n.º 7
0
function getTeams($sportID = null, $selected = null)
{
    global $LOG;
    $link = @mysqli_connect(Config::getDatabaseServer(), Config::getDatabaseUser(), Config::getDatabasePassword(), Config::getDatabase());
    if (!$link) {
        mydie("Error connecting to Database");
    }
    $sql = "select * from go_teams_lu ";
    if (!empty($sportID)) {
        if (is_numeric($sportID)) {
            $where = " where sportID = {$sportID}";
        } else {
            $where = ' where leagueName ="' . $sportID . '"';
        }
    }
    //if
    $sql .= $where . " order by teamName";
    if (Config::getDebug()) {
        $LOG->log("{$sql}", PEAR_LOG_INFO);
    }
    $cursor = @mysqli_query($link, $sql);
    if (!$cursor) {
        mydie(mysqli_error($link), $link);
    }
    echo '<select id="teamlistbox" name="teamname">';
    while (($row = @mysqli_fetch_assoc($cursor)) != null) {
        $selectedFlag = strtolower($selected) == strtolower($row['teamName']) ? ' SELECTED' : null;
        echo '<option value="' . $row['teamName'] . '"' . $selectedFlag . '>' . $row['teamName'] . '</option>';
    }
    $link->close();
    echo '</select>';
}
Ejemplo n.º 8
0
function generateTypeListbox($typeName = null)
{
    global $LOG;
    $link = @mysqli_connect(Config::getDatabaseServer(), Config::getDatabaseUser(), Config::getDatabasePassword(), Config::getDatabase());
    if (!$link) {
        mydie("Error connecting to Database");
    }
    $sql = "select * from go_types_lu order by typeName";
    if (Config::getDebug()) {
        $LOG->log("{$sql}", PEAR_LOG_INFO);
    }
    $cursor = @mysqli_query($link, $sql);
    if (!$cursor) {
        $this->mydie(mysqli_error($link), $link);
    }
    echo '<select id="typelistbox" name="typename">';
    while (($row = @mysqli_fetch_assoc($cursor)) != null) {
        $selected = strtoupper($typeName) == strtoupper($row['typeName']) ? ' SELECTED' : null;
        echo '<option value="' . $row['id'] . '"' . $selected . '>' . $row['typeName'] . '</option>';
    }
    $link->close();
    echo '</select>';
}
Ejemplo n.º 9
0
 public function getGame($gameID)
 {
     $link = @mysqli_connect(Config::getDatabaseServer(), Config::getDatabaseUser(), Config::getDatabasePassword(), Config::getDatabase());
     if (!$link) {
         mydie("Error connecting to Database");
     }
     $sql = sprintf("select g.*,t.typeName,s.id,s.sportName, l.leagueName from go_publicgames g LEFT JOIN go_types_lu t on g.type=t.id LEFT JOIN  go_sports_lu s on g.sportID=s.id LEFT JOIN go_leagues_lu l on g.leagueID = l.id where g.gameID='%u'", mysqli_real_escape_string($link, $gameID));
     if (Config::getDebug()) {
         $this->LOG->log("{$sql}", PEAR_LOG_INFO);
     }
     $cursor = @mysqli_query($link, $sql);
     if (!$cursor) {
         $this->mydie(mysqli_error($link), $link);
     }
     if (Config::getDebug()) {
         $this->LOG->log($row, PEAR_LOG_DEBUG);
     }
     $row = @mysqli_fetch_assoc($cursor);
     if (!$row) {
         return false;
     }
     //if
     $this->setGameID($row['gameID']);
     $this->setDescription($row['description']);
     $this->setTitle($row['title']);
     $this->setEventName($row['eventName']);
     //$this->setEventDate($row['eventDate']);
     $this->setEventDate($row['date']);
     $this->setSportID($row['id']);
     $this->setSportName($row['sportName']);
     $this->setLeagueName($row['leagueName']);
     $this->setLeagueID($row['leagueID']);
     $this->setFavorite($row['favorite']);
     $this->setTypeID($row['type']);
     $this->setTypeName($row['typeName']);
     //     $this->setSubscriptionClose($row['subscriptionClose']);
     //a little cleanup for properties that may be empty
     if (empty($this->eventName)) {
         $this->setEventName($this->getTitle());
     }
     if (empty($this->description)) {
         $this->setDescription($this->getTitle());
     }
     $rc = $this->getPublicGameCombatants($gameID, $link);
     if ($rc) {
         $this->setStatusCode("200");
         $this->setStatusMessage("Ok");
     }
     return $rc;
 }
Ejemplo n.º 10
0
 public static function getTeamIDOrTeamName($param, $type = 'id')
 {
     $LOG = Config::getLogObject();
     $link = mysqli_connect(Config::getDatabaseServer(), Config::getDatabaseUser(), Config::getDatabasePassword(), Config::getDatabase());
     if (!$link) {
         // Server error
         // mydie("Error connecting to Database");
         return GAMEON_ERROR;
     }
     if ($type == 'id') {
         $sql = sprintf("select * from go_teams_lu where id='%u'", mysqli_real_escape_string($link, $param));
     } else {
         $sql = sprintf("select * from go_teams_lu where teamName='%s'", mysqli_real_escape_string($link, $param));
     }
     if (Config::getDebug()) {
         $LOG->log("{$sql}", PEAR_LOG_INFO);
     }
     $cursor = mysqli_query($link, $sql);
     if ($cursor) {
         $row = mysqli_fetch_assoc($cursor);
         $rv = GAMEON_OK . GAMEON_DELIMITER . ($type == 'id' ? 'teamname' . GAMEON_DELIMITER . $row['teamName'] : 'teamid' . GAMEON_DELIMITER . $row['id']);
     } else {
         $rv = GAMEON_NORECORD;
     }
     if (isset($cursor)) {
         $cursor->close();
     }
     if (isset($link)) {
         $link->close();
     }
     return $rv;
 }
Ejemplo n.º 11
0
 public function getGame($gameID, $type = 'game')
 {
     $link = @mysqli_connect(Config::getDatabaseServer(), Config::getDatabaseUser(), Config::getDatabasePassword(), Config::getDatabase());
     if (!$link) {
         mydie("Error connecting to Database");
     }
     //added JHM 8/19/2010
     $sql = $this->getQuery($gameID, $type, $link);
     if (Config::getDebug()) {
         $this->LOG->log("{$sql}", PEAR_LOG_INFO);
     }
     $cursor = @mysqli_query($link, $sql);
     if (!$cursor) {
         $this->mydie(mysqli_error($link), $link);
     }
     $row = @mysqli_fetch_assoc($cursor);
     if (Config::getDebug()) {
         $this->LOG->log("{$row}", PEAR_LOG_DEBUG);
     }
     if (!row) {
         return false;
     }
     $this->setGameID($row['gameID']);
     $this->setPublicGameID($row['publicGameID']);
     $this->setDescription($row['description']);
     $this->setCreatedByUserID($row['createdByUserID']);
     $this->setCreatedByUserName($row['createdByUserName']);
     $this->setTitle($row['title']);
     $this->setSportID($row['sport']);
     $this->setSportName($row['sportName']);
     $this->setTypeID($row['type']);
     $this->setTypeName($row['typeName']);
     $this->setWagerUnits($row['wagerUnits']);
     $this->setWagerTypeID($row['wagerTypeID']);
     $this->setWagerType($row['wagerType']);
     $this->setSubscriptionCloseDate($row['subscriptionClose']);
     $this->setSubscriptionOpen($row['subscriptionOpen']);
     $this->setSyndicationUrl($row['syndicationUrl']);
     $this->setPivotDate($row['pivotDate']);
     $this->setPivotCondition($row['pivotCondition']);
     /*Add JHM - public Games */
     $this->setHomeTeamID($row['team1ID']);
     $this->setVisitingTeamID($row['team2ID']);
     $this->setHomeTeam($row['teamName1']);
     $this->setVisitingTeam($row['teamName2']);
     /*Finish add */
 }