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();
 }
Beispiel #2
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 */
 }
Beispiel #3
0
 public function get_google()
 {
     $this->check_agent();
     $this->check_input();
     $scopes = "openid profile email";
     $prompt = $this->_getParam('prompt') ?: 'none';
     $config = Bootstrap::$main->getConfig();
     $uri = $config['protocol'] . '://' . $_SERVER['HTTP_HOST'] . Bootstrap::$main->getRoot() . 'user/google';
     $realm = $config['protocol'] . '://' . $_SERVER['HTTP_HOST'] . Bootstrap::$main->getRoot() . 'user/google';
     if ($this->_getParam('redirect')) {
         Bootstrap::$main->session('auth_redirect', $this->_getParam('redirect'));
     } elseif (!Bootstrap::$main->session('auth_redirect')) {
         mydie('redirect parameter missing', 'error');
     }
     if (isset($_GET['state']) && $_GET['state'] == Bootstrap::$main->session('oauth2_state')) {
         if (isset($_GET['code'])) {
             $data = array('code' => $_GET['code'], 'client_id' => $config['oauth2.client_id'], 'client_secret' => $config['oauth2.client_secret'], 'redirect_uri' => $uri, 'grant_type' => 'authorization_code');
             $response = $this->req("https://accounts.google.com/o/oauth2/token", $data);
             $token = json_decode($response, true);
             if (isset($token['access_token'])) {
                 $auth = json_decode(file_get_contents('https://www.googleapis.com/oauth2/v1/userinfo?access_token=' . $token['access_token']), true);
                 if (isset($auth['given_name'])) {
                     $auth['first_name'] = $auth['given_name'];
                 }
                 if (isset($auth['family_name'])) {
                     $auth['last_name'] = $auth['family_name'];
                 }
                 if (isset($auth['id']) && isset($auth['email'])) {
                     $email = $this->standarize_email($auth['email'], false);
                     $user = $this->user()->find_one_by_email($email);
                     if (!$user) {
                         $user = $this->add(array('firstname' => $auth['first_name'], 'lastname' => $auth['last_name'], 'md5hash' => $this->md5hash($email), 'email' => $email, 'ref_login' => 'gplus'), false);
                     }
                     $model = new userModel($user['id']);
                     if (!$model->firstname) {
                         $model->firstname = $auth['first_name'];
                     }
                     if (!$model->lastname) {
                         $model->lastname = $auth['last_name'];
                     }
                     if (isset($auth['picture'])) {
                         if (!$model->photo || strstr($model->photo, 'googleusercontent')) {
                             $model->photo = $auth['picture'];
                         }
                     }
                     if (isset($auth['link'])) {
                         if (!$model->social || strstr($model->social, 'plus.google.com')) {
                             $model->social = $auth['link'];
                         }
                     }
                     if (isset($auth['gender'])) {
                         $model->gender = strtoupper(substr($auth['gender'], 0, 1));
                     }
                     if (!$model->cover && isset($auth['link'])) {
                         $person = @end(explode('/', $auth['link']));
                         $url = "https://www.googleapis.com/plus/v1/people/" . urlencode($person) . "?fields=cover%2FcoverPhoto%2Furl&access_token=" . $token['access_token'];
                         $cover = json_decode(file_get_contents($url), true);
                         if (isset($cover['cover']['coverPhoto']['url'])) {
                             $model->cover = preg_replace('/s[0-9]+-fcrop/', 's' . $config['image_size'] . '-fcrop', $cover['cover']['coverPhoto']['url']);
                         }
                     }
                     $this->beautify($model);
                     $model->save();
                     $data = $model->data();
                     unset($data['password']);
                     Bootstrap::$main->session('user', $data);
                     Bootstrap::$main->session('auth', $auth);
                     if ($model->lang) {
                         Bootstrap::$main->session('lang', $model->lang);
                     }
                     $this->redirect(Bootstrap::$main->session('auth_redirect'));
                 } else {
                     if (isset($auth['error'])) {
                         Bootstrap::$main->session('error', $auth['error']['message']);
                     }
                     $this->redirect(Bootstrap::$main->session('auth_redirect'));
                 }
             } else {
                 $this->redirect(Bootstrap::$main->session('auth_redirect'));
             }
         } elseif (isset($_GET['error']) && $_GET['error'] == 'immediate_failed') {
             $this->redirect($uri . '?prompt=select_account');
         } else {
             $this->redirect(Bootstrap::$main->session('auth_redirect'));
         }
     } elseif (isset($_GET['state'])) {
         $this->redirect($uri);
     } else {
         $state = md5(rand(90000, 1000000) . time());
         Bootstrap::$main->session('oauth2_state', $state);
         $url = 'https://accounts.google.com/o/oauth2/auth?client_id=' . urlencode($config['oauth2.client_id']);
         $url .= '&response_type=code';
         $url .= '&scope=' . urlencode($scopes);
         $url .= '&redirect_uri=' . urlencode($uri);
         $url .= '&openid.realm=' . urlencode($realm);
         $url .= '&state=' . $state;
         $url .= '&prompt=' . $prompt;
         //$url.='&access_type=offline';
         //mydie("<a href='$url'>$url</a>");
         $this->redirect($url);
     }
 }
Beispiel #4
0
            echo mysqli_error($link) . " Using Sql = {$sql}\n";
            $LOG->log(mysqli_error($link) . " Using Sql = {$sql}\n");
        }
        //else
    }
    //if
    //insert home team
    $sql = sprintf("insert into go_publicgames_combatants (gameID,teamID,homeTeam) values ('%u','%u','%u')", $gameID, $homeTeamID, 1);
    if (Config::getDebug()) {
        $LOG->log($sql, PEAR_DEBUG);
    }
    $rc = mysqli_query($link, $sql);
    if (!$rc) {
        // Server error
        if (!ERROR_TOLERANCE) {
            mydie(mysqli_error($link) . " Using Sql - {$sql}\n");
        } else {
            echo mysqli_error($link) . " Using Sql = {$sql}\n";
            $LOG->log(mysqli_error($link) . " Using Sql = {$sql}\n");
        }
        //else
    }
    //if
}
//while
//close
fclose($fileHandle);
//close input file
$link->close();
//close database
exit;
//if
$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($link, $userID);
if (Config::getDebug()) {
    $LOG->log("{$sql}", PEAR_LOG_INFO);
}
$cursor = mysqli_query($link, $sql);
if (!$cursor) {
    // Server error
    header('HTTP/1.1 500 Internal Server Error');
    mydie(mysqli_error($link), 500, $link);
}
header('HTTP/1.1 200 OK');
header("Content-Type: text/xml");
echo '<?xml version="1.0" encoding="UTF-8"?>';
/* Fetch the results of the query */
Utility::emitXML("", 'game_invites', 0);
Utility::emitXML('200', 'status_code');
Utility::emitXML('Ok', 'status_message');
Utility::emitXML("{$userID}", 'userID');
Utility::emitXML("{$userName}", 'username');
Utility::emitXML($cursor->num_rows, 'openinvites');
$recordsEmitted = 0;
while ($row = mysqli_fetch_assoc($cursor)) {
    $recordsEmitted++;
    Utility::emitXML("", 'gameinvite', 0);
 public function get_offer()
 {
     $config = $this->getConfig();
     $offer = $this->merlin->getOfferOnToken($this->id);
     $offer['stars'] = '';
     if (isset($offer['obj']['category'])) {
         for ($i = 0; $i < $offer['obj']['category']; $i += 10) {
             $offer['stars'] .= Bootstrap::$main->getConfig('star');
         }
     }
     if (isset($offer['obj']['info']['desc'])) {
         $desc = $offer['obj']['info']['desc'];
         $desc2 = [];
         foreach ($desc as $d) {
             if (is_array($d['subject'])) {
                 continue;
             }
             if (is_array($d['content'])) {
                 continue;
             }
             if (!in_array(strtolower(trim($d['subject'])), ['category', 'kategoria', 'region', 'kraj', 'kategoria lokalna'])) {
                 $pm = [];
                 if (preg_match_all('~<b>([^<]+)</b>([^<]+)~i', $d['content'], $pm)) {
                     for ($i = 0; $i < count($pm[1]); $i++) {
                         $desc2[] = ['subject' => str_replace(':', '', $pm[1][$i]), 'content' => trim($pm[2][$i])];
                     }
                 } else {
                     $desc2[] = $d;
                 }
             }
         }
         $offer['obj']['info']['desc'] = $desc2;
         $offer['dep_from'] = $config['dep_from'][$offer['trp']['depCode']];
         $offer['adt'] = Bootstrap::$main->session('adt');
         $offer['chd'] = Bootstrap::$main->session('chd');
         //mydie($offer['obj']['info']);
     }
     if ($this->data('debug')) {
         $ret = [$offer];
         if ($this->data('debug') == 2) {
             $ret[1] = $this->merlin->debug;
         }
         mydie($ret);
     }
     return $this->status($offer);
 }
Beispiel #7
0
            $nextnumber = $tmp;
        }
    }
}
closedir($dh);
$fnprefix = sprintf("PMI%08.0f.", $nextnumber);
$initialname = $fnprefix . "creating";
$finalname = $fnprefix . "DEM";
$initialpath = "{$EXPORT_PATH}/{$initialname}";
$finalpath = "{$EXPORT_PATH}/{$finalname}";
// Write the file locally with a temporary version of the name.
@touch($initialpath);
// work around possible php bug
$fh = @fopen($initialpath, "w");
if (!$fh) {
    mydie("Unable to open {$initialpath} for writing");
}
fwrite($fh, $out);
fclose($fh);
// Rename the local file.
rename($initialpath, $finalpath);
// Delete old stuff to avoid uncontrolled growth.
if ($nextnumber > 5) {
    @unlink("{$EXPORT_PATH}/PMI%08.0f.DEM", $nextnumber - 5);
}
// End of serialized code.
rename("{$EXPORT_PATH}/locked", "{$EXPORT_PATH}/unlocked");
// If we have an ftp server, send it there and then rename it.
if ($FTP_SERVER) {
    $ftpconn = ftp_connect($FTP_SERVER) or die("FTP connection failed");
    ftp_login($ftpconn, $FTP_USER, $FTP_PASS) or die("FTP login failed");
Beispiel #8
0
$LOG = Config::getLogObject();
$programName = array_shift($argv);
/*i//if (count($argv) != 4)  {
   mydie("Usage: $programName inputFile, , sportID, sportName, LeagueName\n");
}
*/
$recordsProcessed = 0;
$link = @mysqli_connect(Config::getDatabaseServer(), Config::getDatabaseUser(), Config::getDatabasePassword(), Config::getDatabase());
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");
}
$sql = "select * from go_teams_lu where stadiumAddress is not null and stadiumCity is not null";
$cursor = mysqli_query($link, $sql);
if (!$cursor) {
    // Server error
    mydie(mysqli_error($link) . " executing sql {$sql}");
}
//if
$apiUrl = "http://maps.google.com/maps/api/geocode/xml?address=";
while ($row = mysqli_fetch_assoc($cursor)) {
    $teamID = $row['id'];
    $address = $row['stadiumName'] . " " . $row['stadiumAddress'] . " " . $row['stadiumCity'] . " " . $row['stadiumState'];
    $address = urlencode(htmlentities($address));
    $url = $apiUrl . $address . "&sensor=false";
    //echo $url . "\n";
    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    $result = curl_exec($curl);
    curl_close($curl);
    $document = simplexml_load_string($result);
    if (!$document) {
Beispiel #9
0
    $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
    $graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
    $graph->yaxis->SetColor("black");
    // Create the data plot
    $plot = new LinePlot($data['values']);
    $color = $options['graph_color'];
    $plot->SetColor($color);
    $plot->SetWeight(2);
    $plot->mark->SetType(MARK_FILLEDCIRCLE);
    $plot->mark->SetColor('blue');
    if (!empty($options['graph_point_legend'])) {
        $plot->SetLegend($options['graph_point_legend']);
    }
    if (!empty($options['graph_show_values'])) {
        if (!isset($plot->value) || !method_exists($plot->value, 'show')) {
            mydie("This JPGraph version does not support 'Show values'");
        }
        $plot->value->HideZero();
        $plot->value->SetFormat('%u');
        $plot->value->SetFont(FF_FONT1, FS_BOLD);
        $plot->value->SetColor('blue');
        $plot->value->SetMargin(10);
        $plot->value->Show();
    }
    // Add the data plot to the graph
    $graph->Add($plot);
} elseif ($options['graph_type'] == 'radar') {
    require_once "{$jpgraph}/jpgraph_radar.php";
    $background = "white";
    $incref = false;
    // Setup graph
//Filtering
$params = array();
$params['userid'] = $_GET['userid'];
//open connect to database
$link = mysqli_connect(Config::getDatabaseServer(), Config::getDatabaseUser(), Config::getDatabasePassword(), Config::getDatabase());
if (!$link) {
    header('HTTP/1.1 500 Internal Server Error');
    mydie("Error connecting to Database");
}
$sql = getQuery($params);
$LOG->log($sql, PEAR_DEBUG);
$cursor = mysqli_query($link, $sql);
if (!$cursor) {
    // Server error
    header('HTTP/1.1 500 Internal Server Error');
    mydie(mysqli_error($link) . " executing {$sql}", $link);
}
header("content-type: text/xml");
echo '<?xml version="1.0"?>';
Utility::emitXML("", 'userdashboard', 0);
Utility::emitXML("200", 'statuscode');
Utility::emitXML("OK", 'statusmessage');
$recordsEmitted = 0;
$totalBets = 0;
$totalBets = 0;
$totalBetsInitiated = 0;
$totalBetsAccepted = 0;
$totalWins = 0;
$totalLoses = 0;
// while records to read/ retrieve and emit xml
if ($row = mysqli_fetch_assoc($cursor)) {
Beispiel #11
0
 public static function getUserIDOrName($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");
     }
     if ($type == 'id') {
         $sql = sprintf("select * from go_user where userID='%u'", mysqli_real_escape_string($link, $param));
     } else {
         $sql = sprintf("select * from go_user where userName='******'", mysqli_real_escape_string($link, $param));
     }
     if (Config::getDebug()) {
         $LOG->log("{$sql}", PEAR_LOG_INFO);
     }
     $cursor = mysqli_query($link, $sql);
     if (!$cursor) {
         // Server error
         mydie(mysqli_error($link), 500, $link);
     }
     //if
     $row = mysqli_fetch_assoc($cursor);
     if (isset($cursor)) {
         $cursor->close();
     }
     if (isset($link)) {
         $link->close();
     }
     return $type == 'id' ? $row['userName'] : $row['userID'];
 }
if (!$row) {
    // Server error
    header('HTTP/1.1 500 Internal Server Error');
    mydie("GameID {$gameID} does not exist");
}
$subscriptionClose = $row['subscriptionClose'];
//is a mysql timestamp
$sql = sprintf("insert into go_gamesSubscribers (gameID,userID,wagerUnits) values ('%u','%u','%u')", mysqli_real_escape_string($link, $gameID), mysqli_real_escape_string($link, $userID), mysqli_real_escape_string($link, $wagerUnits));
if (Config::getDebug()) {
    $LOG->log("{$sql}", PEAR_LOG_INFO);
}
$rc = mysqli_query($link, $sql);
if (!$rc) {
    // Server error
    header('HTTP/1.1 500 Internal Server Error');
    mydie(mysqli_error($link));
}
header('HTTP/1.1 200 OK');
$link->close();
/* Close Database */
//return xml
Utility::emitXML("", "insert_game_subscriber", 0);
Utility::emitXML("200", "status_code");
Utility::emitXML("ok", "status_message");
Utility::emitXML("{$gameID}", "gameid");
Utility::emitXML("{$userID}", "userid");
Utility::emitXML("{$numberOfSubscribers}", "numberofsubscribers");
Utility::emitXML("", "insert_game_subscriber", 0);
ob_end_flush();
exit;
function mydie($message, $statusCode = 500)
Beispiel #13
0
<?php

require "header.inc.php";
if (isset($_POST['submitButton'])) {
    if (!isset($_POST['username']) || empty($_POST['username'])) {
        mydie("Error: The username field was not set <br>");
    }
    if (!isset($_POST['password']) || empty($_POST['password'])) {
        mydie("Error: The password field was not set <br>");
    }
    $username = $_POST['username'];
    $password = $_POST['password'];
    $hash = hash("sha512", $password);
    $query = mysql_query("SELECT id FROM users WHERE email = '" . mysql_real_escape_string($username) . "' AND password = '******'");
    if (mysql_num_rows($query)) {
        $sessID = mysql_real_escape_string(session_id());
        $hashsession = mysql_real_escape_string(hash("sha512", $sessID . $_SERVER['HTTP_USER_AGENT']));
        $expires = time() + 60 * 3;
        $userdata = mysql_fetch_assoc($query);
        $userdataid = $userdata['id'];
        $insert = "INSERT INTO active_users (id, user, session_id, hash, expires) \n\t\t\tVALUES(\n\t\t\t''\n\t\t\t,{$userdataid}\n\t\t\t,'{$sessID}'\n\t\t\t,'{$hashsession}'\n\t\t\t,{$expires})";
        mysql_query($insert) or die("Active User SQL Insert failed");
        Header("Location: ./home.php");
    } else {
        mydie("Error: Incorrect password or email address");
    }
}
function mydie($msg)
{
    die($msg);
}
Beispiel #14
0
function insertGameInvites($link, $gameID, $inviteKey, $closeDateTime, $createdByUserID, $createdByUserName, $gameInvitees)
{
    global $LOG;
    $sql = sprintf("insert into go_gameInvite (gameID,inviteKey) values ('%s','%s')", mysqli_real_escape_string($link, $gameID), mysqli_real_escape_string($link, $inviteKey));
    if (Config::getDebug()) {
        $LOG->log("{$sql}", PEAR_LOG_INFO);
    }
    $rc = mysqli_query($link, $sql);
    if (!$rc) {
        // Server error
        header('HTTP/1.1 500 Internal Server Error');
        mydie(mysqli_error($link), 500, $link);
    }
    //if
    //TODO - Remove temporary automatic insert into invite Detail
    $gameInviteesArray = explode(" ", trim($gameInvitees));
    $count = count($gameInviteesArray);
    for ($x = 0; $x < $count; $x++) {
        $inviteeUserID = $gameInviteesArray[$x];
        $sql = sprintf("insert into go_gameInviteDetail (gameID, inviteKey, createdByUserID,createdByUserName, closeDateTime,inviteeUserID) values ('%s','%s','%u','%s','%s','%u')", mysqli_real_escape_string($link, $gameID), mysqli_real_escape_string($link, $inviteKey), mysqli_real_escape_string($link, $createdByUserID), mysqli_real_escape_string($link, $createdByUserName), mysqli_real_escape_string($link, $closeDateTime), mysqli_real_escape_string($link, $inviteeUserID));
        if (Config::getDebug()) {
            $LOG->log("{$sql}", PEAR_LOG_INFO);
        }
        $rc = mysqli_query($link, $sql);
    }
    //for
}
function userNameAvailable($userName, $link)
{
    global $LOG;
    $userName = strtolower($userName);
    //   $sql = sprintf("select count(*) as countOfUserName from go_user where userName = '******'",
    //        mysqli_real_escape_string($link,$userName));
    $sql = sprintf("select userName from go_user where userName = '******'", mysqli_real_escape_string($link, $userName));
    if (Config::getDebug()) {
        $LOG->log("{$sql}", PEAR_LOG_INFO);
    }
    $cursor = mysqli_query($link, $sql);
    if (!$cursor) {
        // Server error
        mydie(mysqli_error($link) . "  executing sql {$sql}");
    }
    //if
    $countOfUserName = $cursor->num_rows;
    //   if ($row = @mysqli_fetch_assoc($cursor) == null) mydie(mysqli_error($link) . " executing sql $sql");
    //   $countOfUserName = $row['countOfUserName'];
    $cursor->close();
    if ($countOfUserName > 0) {
        return false;
    } else {
        return true;
    }
}
Beispiel #16
0
        $extension = pathinfo($_FILES['image_map']['name'], PATHINFO_EXTENSION);
        if (in_array(strtolower($extension), $tabExt)) {
            if (filesize($_FILES['image_map']['tmp_name']) <= $MAX_SIZE) {
                if (isset($_FILES['image_map']['error']) && UPLOAD_ERR_OK === $_FILES['image_map']['error']) {
                    $rel_path = '/img/map/' . $map . '.' . $extension;
                    if (move_uploaded_file($_FILES['image_map']['tmp_name'], dirname(__FILE__) . '/../' . $rel_path)) {
                        $vals = $vals . ', imgpath';
                        $insert = $insert . ', "' . $rel_path . '"';
                        $update = $update . ', imgpath="' . $rel_path . '"';
                    } else {
                        mydie("can't move");
                    }
                } else {
                    mydie("errors");
                }
            } else {
                mydie("too big");
            }
        } else {
            mydie("wrong ext");
        }
    }
    $vals = $vals . ')';
    $insert = $insert . ')';
    $query = 'INSERT INTO map ' . $vals . ' VALUES ' . $insert . ' ON DUPLICATE KEY UPDATE ' . $update . ';';
    if (!$db->query($query)) {
        mydie($query);
    }
}
header('Location: /');
exit;
Beispiel #17
0
 protected function mercadopage_check($topic, $id)
 {
     require_once __DIR__ . '/../class/mercadopago.php';
     $config = Bootstrap::$main->getConfig();
     try {
         $mp = new MP($config['mercadopago.client_id'], $config['mercadopago.client_secret']);
         $merchant_order_info = null;
         switch ($topic) {
             case 'payment':
                 $payment_info = $mp->get("/collections/notifications/" . $id);
                 $merchant_order_info = $mp->get("/merchant_orders/" . $payment_info["response"]["collection"]["merchant_order_id"]);
                 break;
             case 'merchant_order':
                 $merchant_order_info = $mp->get("/merchant_orders/" . $id);
                 break;
             default:
                 $merchant_order_info = null;
         }
         return $merchant_order_info;
     } catch (Exception $e) {
         mydie($e);
     }
 }
Beispiel #18
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>';
}
 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;
 }
Beispiel #20
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>';
}
Beispiel #21
0
} else {
    $errorMsg .= empty($inviteeBSUserID) ? "inviteeUserID missing " : null;
}
//if
//if (isset($errorMsg)) mydie($errorMsg);
if (Config::getDebug()) {
    $LOG->log($_REQUEST['invites'], PEAR_LOG_INFO);
}
if (Config::getDebug()) {
    $LOG->log($_SERVER['QUERY_STRING'], PEAR_LOG_INFO);
}
$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");
}
//if
header("Cache-Control: no-cache, must-revalidate");
header("Content-Type: text/xml");
Utility::emitXML("", 'friend_invite', 0);
Utility::emitXML("^STATUS_CODE", 'status_code');
Utility::emitXML("^STATUS_MESSAGE", 'status_message');
Utility::emitXML("^NUMBEROFINVITES", 'numberofinvites');
$invitesArr = explode('^', $_REQUEST['invites']);
//invites records are separated by ^ (caret)
$noOfInvites = count($invitesArr);
$failureCount = 0;
$successCount = 0;
for ($index = 0; $index < $noOfInvites; $index++) {
    $params = null;
 public function getUserSettings($user, $isName = null)
 {
     $rv = false;
     //default to not found
     $link = mysqli_connect(Config::getDatabaseServer(), Config::getDatabaseUser(), Config::getDatabasePassword(), Config::getDatabase());
     if (!$link) {
         $this - mydie("Error connecting to Database");
     }
     if (empty($isName)) {
         //retrieve by userID
         $sql = sprintf("select g.*,s.*,b.bankBalance as duckettBankBalanceAvailable ,b.overDraftLine as duckettOverDraftLimit, b.overDraftLineUsed as duckettOverDraftLineAvailable, b.currentInPlayWagers as duckettsInPlay from go_user g LEFT JOIN  go_userSettings s on g.userID=s.userID LEFT JOIN go_userBank b on b.userID=g.userID  where g.userID='%u'", mysqli_real_escape_string($link, $user));
     } else {
         //retrieve by userName
         $sql = sprintf("select g.*,s.* from go_user g, go_userSettings s where g.userName='******' and g.userID=s.userID ", mysqli_real_escape_string($link, $user));
     }
     if (Config::getDebug()) {
         $this->LOG->log("{$sql}", PEAR_LOG_INFO);
     }
     $cursor = mysqli_query($link, $sql);
     if (!$cursor) {
         $this->mydie(mysqli_error($link) . " executing sql {$sql}", $link);
     }
     $row = mysqli_fetch_assoc($cursor);
     if ($row) {
         $this->setUserID($row['userID']);
         $this->setPrimaryNetworkID($row['primaryNetworkID']);
         $this->setPrimaryNetworkName($row['primaryNetworkName']);
         $this->setUserName($row['userName']);
         $this->setFirstName($row['firstName']);
         $this->setLastName($row['lastName']);
         $this->setEmail($row['email']);
         $this->setFacebookUserID($row['facebookID']);
         $this->setTwitterUserID($row['twitterID']);
         $this->setFoursquareUserID($row['foursquareID']);
         $this->setFacebookDefault($row['facebookDefault']);
         $this->setTwitterDefault($row['twitterDefault']);
         $this->setFoursquareDefault($row['foursquareDefault']);
         $this->setTwitterOAuthToken($row['twitterOAuthToken']);
         $this->setTwitterOAuthTokenSecret($row['twitterOAuthTokenSecret']);
         $this->setTwitterProfileImageUrl($row['twitterImageUrl']);
         $this->setFoursquareOAuthToken($row['foursquareOAuthToken']);
         $this->setFoursquareOAuthTokenSecret($row['foursquareOAuthTokenSecret']);
         $this->setFoursquareProfileImageUrl($row['foursquareImageUrl']);
         $this->setFacebookOAuthToken($row['facebookOAuthToken']);
         $this->setFacebookOAuthTokenSecret($row['facebookOAuthTokenSecret']);
         $this->setFacebookProfileImageUrl($row['facebookImageUrl']);
         //duckett balance fields
         $this->setDuckettBankBalanceAvailable($row['duckettBankBalanceAvailable']);
         $this->setDuckettsInPlay($row['duckettsInPlay']);
         $this->setDuckettOverDraftLimit($row['duckettOverDraftLimit']);
         $this->setDuckettOverDraftAvailable($row['duckettOverDraftAvailable']);
         $rv = true;
     }
     $link->close();
     $cursor->close();
     return $rv;
 }
 if (count($h) == 1) {
     $desc = new descModel();
     $d = $desc->find('en', $book->id, $remedium->id);
     if (!$d) {
         $desc->add($h[0], 'en', $book->id, $remedium->id);
     } else {
         $dict = new dictModel($d);
         $dict->body = $h[0];
         $dict->save();
     }
 }
 if (count($h) == 2) {
     $complaint = new complaintModel();
     $complaint_name = strtolower($h[0]);
     if (strlen($complaint_name) > 25) {
         mydie($complaint_name);
     }
     switch ($complaint_name) {
         case 'relationship':
             break;
         case 'dose':
             break;
         case 'modalities':
             foreach (explode('.', $h[1]) as $modal) {
                 $modal = trim($modal);
                 $mod = '';
                 if (strtolower(substr($modal, 0, 5)) == 'worse') {
                     $modal = trim(substr($modal, 5));
                     $mod = 'W';
                 }
                 if (strtolower(substr($modal, 0, 6)) == 'better') {
 protected function getConfig()
 {
     $token = 'config.' . Bootstrap::$main->getConfig('site');
     $config = Tools::memcache($token);
     if ($config && !$this->data('debug')) {
         return $config;
     }
     $config = json_config(__DIR__ . '/../config/merlin.json', false, false);
     $config['words'] = [];
     $config['words-with-space'] = [];
     $extended = ['number'];
     foreach ($config['dict'] as $field => $fields) {
         foreach ($fields as $code => $values) {
             foreach ($values['words'] as $d) {
                 $w = [];
                 if ($field != 'extended') {
                     $w['field'] = $field;
                 }
                 foreach ($extended as $f) {
                     if (isset($values[$f])) {
                         $w[$f] = $values[$f];
                     }
                 }
                 $value = 'value';
                 if (isset($values['name'])) {
                     $value = $values['name'];
                 }
                 if (isset($values['evalue'])) {
                     $w[$value] = '~' . $values['evalue'];
                 } elseif (isset($values['value'])) {
                     $w[$value] = $values['value'];
                 } elseif (!in_array($field, $extended)) {
                     $w[$value] = $code;
                 }
                 $config['words'][$d] = $w;
             }
         }
     }
     unset($config['dict']);
     //mydie($config['words']);
     $reg = $this->merlin->getRegions('F', null, $this->data('debug') ? false : true, true);
     $dest = [];
     $i = 0;
     $far = [];
     foreach ($reg as $r) {
         if (!isset($r['region'])) {
             $r['region'] = '';
         }
         if (!isset($r['country'])) {
             continue;
         }
         $country = trim(mb_strtolower($r['country'], 'utf-8'));
         $region = trim(mb_strtolower($r['region'], 'utf-8'));
         if ($r['price'] >= Bootstrap::$main->getConfig('merlin.far.price') && !in_array($country, ['bułgaria', 'portugalia', 'hiszpania', 'włochy', 'grecja', 'francja', 'niemcy', 'cypr', 'chorwacja'])) {
             $far[] = $r['id'];
         }
         foreach ($config['dest_shit'] as $shit) {
             for ($ii = 0; $ii < 2; $ii++) {
                 if (strstr($country, ' ') && strstr($country, $shit)) {
                     $country = trim(str_replace($shit, '', $country));
                 }
                 if (strstr($region, ' ') && strstr($region, $shit)) {
                     $region = trim(str_replace($shit, '', $region));
                 }
             }
         }
         $i++;
         if (strstr($country, ' ') || strstr($region, ' ')) {
             continue;
             mydie($r, "{$country}:{$region}:{$i}/" . count($reg));
         }
         foreach ([$country, $region] as $w) {
             if (!$w) {
                 continue;
             }
             if (!isset($dest[$w])) {
                 $dest[$w] = ['field' => 'dest', 'value' => $r['id']];
             } else {
                 $dest[$w]['value'] .= ',' . $r['id'];
             }
             $w2 = Tools::str_to_url($w);
             if ($w2 == $w) {
                 continue;
             }
             $w = $w2;
             if (!isset($dest[$w])) {
                 $dest[$w] = ['field' => 'dest', 'value' => $r['id']];
             } else {
                 $dest[$w]['value'] .= ',' . $r['id'];
             }
         }
     }
     foreach (['dest'] as $field) {
         foreach ($config[$field] as $code => $dep) {
             foreach ($dep as $d) {
                 if (isset($dest[$d])) {
                     $dest[$d]['value'] .= ',' . $code;
                 } else {
                     $dest[$d] = ['field' => 'dest', 'value' => $code];
                 }
             }
         }
     }
     foreach ($dest as $w => $r) {
         if (!isset($config['words'][$w])) {
             $config['words'][$w] = $r;
         }
     }
     $config['far'] = $far;
     if ($this->data('debug') == 1) {
         $hotels = $this->merlin->getFilters(['ofr_type' => 'F'], 'obj_xCode', $this->data('debug') ? false : true);
         Tools::log('hotels-' . $token, $hotels);
         $words = array_keys($config['words']);
         $hotel_map = [];
         foreach ($hotels as $hotel) {
             $hotel = str_replace(['+', ',', ';', '~', '(', ')', '"'], ' ', $hotel);
             $hotel = str_replace(["'"], '"', $hotel);
             $hotel = preg_replace('/\\s+/', ' ', trim($hotel));
             $hotel = mb_strtolower($hotel, 'utf-8');
             foreach (explode(' ', $hotel) as $h) {
                 $h = Tools::str_to_url($h);
                 if (strlen($h) < 4) {
                     continue;
                 }
                 if (isset($config['words'][$h])) {
                     continue;
                 }
                 if (isset($hotel_map[$h])) {
                     continue;
                 }
                 $lev = false;
                 foreach ($words as $w) {
                     if (levenshtein($h, $w) <= 2) {
                         $lev = true;
                         break;
                     }
                 }
                 if ($lev) {
                     continue;
                 }
                 $hotel_map[$h] = ['field' => 'ftsName', 'value' => $h];
             }
         }
         $config['hotels'] = $hotel_map;
     }
     //mydie($config,count($config['words']));
     foreach (array_keys($config['words']) as $word) {
         if (strstr($word, ' ')) {
             $config['words-with-space'][] = $word;
         }
     }
     Tools::log('get-config', [$token]);
     return Tools::memcache($token, $config, 4 * 3600);
 }
Beispiel #25
0
 public function getFilters($cond = array(), $what = '*', $cache = true)
 {
     if ($this->operator_code) {
         $cond['ofr_tourOp'] = $this->operator_code;
     }
     $cond['filters'] = 'obj_xServiceId,trp_depName,trp_durationM,ofr_type,ofr_tourOp,trp_depCode';
     if (!isset($cond['trp_retDate'])) {
         $cond['trp_retDate'] = date('Ymd', time() + 365 * 24 * 3600);
     }
     if ($what == 'obj_xCode') {
         $cond['filters'] = 'obj_xCode,obj_xServiceId';
     }
     if (isset($cond['obj_code']) || isset($cond['obj_xCode'])) {
         $cond['filters'] .= ',obj_room';
     }
     $md5 = md5(serialize($cond));
     $token = 'filters.' . $md5;
     $filters = null;
     if ($cache) {
         $filters = Tools::memcache($token);
     }
     if (!$filters) {
         $xml = $this->request('filters', $cond);
         $filters = $this->post_xml($xml, 'filters');
         if (isset($filters['fdef'])) {
             Tools::memcache($token, $filters, 3 * 3600);
         }
     }
     $result = array();
     foreach ($filters['fdef'] as $fdef) {
         if (isset($fdef['@attributes']['id']) && $fdef['@attributes']['id'] == $what) {
             if (!is_array($fdef['f'])) {
                 continue;
             }
             if (count($fdef['f']) && !isset($fdef['f'][0])) {
                 $fdef['f'] = array($fdef['f']);
             }
             foreach ($fdef['f'] as $f) {
                 if (!isset($f['@attributes'])) {
                     mydie($fdef);
                 }
                 foreach ($f['@attributes'] as $id => $val) {
                     if (count($f['@attributes']) == 1) {
                         if ($id == 'id') {
                             $result[] = "{$val}";
                         }
                     } else {
                         if ($id == 'id') {
                             $key = "{$val}";
                         }
                         if ($id == 'v') {
                             $result[$key] = "{$val}";
                         }
                     }
                 }
             }
         }
     }
     return $result;
 }
Beispiel #26
0
$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;
header('HTTP/1.1 200 OK');
//   Fetch the results of the query
header("Cache-Control: no-cache, must-revalidate");
header("content-type: text/xml");
echo '<?xml version="1.0"?>';
Utility::emitXML("", 'go_friends', 0);
Utility::emitXML("200", 'status_code');
Utility::emitXML("Ok", 'status_message');
Utility::emitXML($userID, 'userid');
Utility::emitXML($numberOfFriends, 'numberoffriends');
$recordsEmitted = 0;
while ($row = mysqli_fetch_assoc($cursor)) {
    Utility::emitXML("", 'friend', 0);
function lookupHash($link)
{
    $lookup = array();
    $sql = "select * from go_teams_lu";
    $cursor = mysqli_query($link, $sql);
    if (!$cursor) {
        // Server error
        mydie(mysqli_error($link) . " executing {$sql}", $link);
    }
    // while records to read/ retrieve and emit xml
    while ($row = mysqli_fetch_assoc($cursor)) {
        $keyID = $row['id'];
        $teamName = $row['teamName'];
        $nickName = $row['nickName'];
        $teamNameNormalized = $row['teamNameNormalized'];
        $teamLogoURL = $row['teamLogoURL'];
        $stadiumName = $row['stadiumName'];
        $address = $row['stadiumAddress'];
        $city = $row['stadiumCity'];
        $state = $row['stadiumState'];
        $latitude = $row['latitude'];
        $longitude = $row['longitude'];
        $fsvenueID = $row['foursquareVenueID'];
        $arr = array('teamName' => $teamName, 'teamNameNormalized' => $teamNameNormalized, 'teamLogoURL' => $teamLogoURL, 'stadiumName' => $stadiumName, 'address' => $address, 'city' => $city, 'state' => $state, 'latitude' => $latitude, 'longitude' => $longitude, 'fsvenueID' => $fsvenueID);
        $lookup[$keyID] = $arr;
        $lookup[$teamName] = $keyID;
        $lookup[$nickName] = $keyID;
    }
    //while
    return $lookup;
}
Beispiel #28
0
    //mydie(sprintf(_("No RRD available for: '%s' at '%s'") , $ip, $rrdpath));
    $norrdfile = "../../pixmaps/norrd.png";
    if (!($fp = @fopen($norrdfile, 'r'))) {
        mydie(_("Could not read {$norrdfile} file"));
    }
    header("Content-Type: image/png");
    header("Content-Length: " . filesize($norrdfile));
    fpassthru($fp);
    fclose($fp);
    exit;
}
$_cmd = '? graph ? -s ? -e ? -t ? --font ? --font ? -r --zoom ? --vertical-label=EPS --lower-limit=0 ? ? ?';
$_params = array($rrdtool_bin, $tmpfile, $start, $end, $hostname . ' ' . _('Metrics'), 'TITLE:12:' . $font, 'AXIS:7:' . $font, $zoom, "DEF:obs={$rrdpath}/{$id}.rrd:ds0:AVERAGE", "CDEF:bp=obs,obs,+,2,/", "AREA:bp{$color1}: {$hostname} ");
try {
    $output = Util::execute_command($_cmd, $_params, 'array');
    if (preg_match('/^ERROR/i', $output[0])) {
        mydie(_("rrdtool cmd failed with error"));
    }
} catch (Exception $e) {
    mydie(_("rrdtool cmd failed with error"));
}
//
// Output generated image
//
if (!($fp = @fopen($tmpfile, 'r'))) {
    mydie(sprintf(_("Could not read rrdtool created image: '%s'"), $tmpfile));
}
header("Content-Type: image/png");
header("Content-Length: " . filesize($tmpfile));
fpassthru($fp);
fclose($fp);
Beispiel #29
0
require_once '../classes/config.class.php';
$LOG = Config::getLogObject();
$programName = array_shift($argv);
if (count($argv) != 4) {
    mydie("Usage: {$programName} inputFile, , sportID, sportName, LeagueName\n");
}
$inputFile = array_shift($argv);
define("ERROR_TOLERANCE", 1);
define("IMAGE_RAW_DIRECTORY", "../images/raw");
define("FIELD_DELIMITER", ",");
$recordsProcessed = 0;
//open input file
$fileHandle = fopen($inputFile, 'r');
$link = @mysqli_connect(Config::getDatabaseServer(), Config::getDatabaseUser(), Config::getDatabasePassword(), Config::getDatabase());
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");
}
while (!feof($fileHandle)) {
    $recordsProcessed++;
    //read a record and parse into array
    $line = fgets($fileHandle, 4096);
    $lineArray = split(FIELD_DELIMITER, $line);
    $teamName = $lineArray[0];
    $imageURL = $lineArray[1];
    $fullSavePath = saveImage($teamName, $imageURL);
    //echo $line;
}
fclose($fileHandle);
//close input file
$link->close();
//close database