function save() { if (isset($this->homeGoals) && isset($this->awayGoals)) { DB::insertUpdate("fixture", array("gameweek" => $this->get_round(), "kickoff_time" => $this->get_kickoff(), "home_team" => $this->get_home_team(), "away_team" => $this->get_away_team(), "home_goals" => $this->get_home_goals(), "away_goals" => $this->get_away_goals(), "played" => $this->get_played())); } else { parent::save(); } }
function create_fixtures() { echo "Bootstraping Fixtures...\n"; $clubs = Club::get_clubs(); while (sizeof($clubs) > 1) { $club = array_pop($clubs); echo "Processing " . $club["name"] . "\n"; foreach ($clubs as $c) { DB::insertUpdate('fixture', array("home_team" => $club["id"], "away_team" => $c["id"])); DB::insertUpdate('fixture', array("home_team" => $c["id"], "away_team" => $club["id"])); } } echo "Processing " . $clubs[0]["name"] . "\n"; echo "Initial fixtures created.\n"; }
public static function authorize($data, $publicApiKey, $hash) { $newToken = ""; $row = DB::queryFirstRow("SELECT * FROM CWM_ApiKey as ak JOIN CWM_UserApiKey uak ON ak.Id = uak.ApiKeyId WHERE PublicKey=%s", $publicApiKey); if (!is_null($row) && strlen(trim($publicApiKey)) > 0) { $userId = $row['UserId']; $privateApiKey = $row['PrivateKey']; $apiKeyIndex = $row['Id']; $hashCheck = sha1($data . $privateApiKey . $publicApiKey); $result = $hashCheck == $hash; if ($result) { $oldToken = DB::queryOneField('TokenValue', 'SELECT * FROM CWM_ApiKeySession WHERE UserId=%?', $userId); if (!CWM_API::isTokenValid($oldToken)) { $newToken = sha1($userId . $privateApiKey . $hashCheck . CWM_API::getDateTime(time())); DB::insertUpdate('CWM_ApiKeySession', array('ApiKeyId' => $apiKeyIndex, 'LastAccess' => CWM_API::getDateTime(time()), 'UserId' => $userId, 'TokenValue' => $newToken)); } else { $newToken = $oldToken; } } } return $newToken; }
$terrain = (int) $cache->terrain; $country = (string) $cache->country; $url = (string) $wpt->url; foreach ($cache->logs->log as $log) { $gc = (string) $wpt->name; $name = (string) $cache->name; $username = (string) $log->finder; $logtext = (string) $log->text; $logType = (string) $log->type; $logDate = substr((string) $log->date, 0, 10); if ($inserted == 0) { DB::insertIgnore('user', array('username' => $username)); $inserted = 1; $userId = DB::queryFirstField("SELECT id FROM user WHERE username=%s LIMIT 1", $username); $logIds = DB::queryFirstColumn("SELECT log.id FROM image, log WHERE image.log = log.id AND log.user = %i", $userId); foreach ($logIds as $logId) { DB::delete('image', "log=%i", $logId); } DB::delete('log', "user=%i", $userId); } DB::insertUpdate('geocache', array('gc' => $gc, 'name' => $name, 'type' => $typeId, 'lat' => $lat, 'lon' => $lon, 'difficulty' => $difficulty, 'terrain' => $terrain, 'country' => $country, 'url' => $url)); $geocacheId = DB::queryFirstField("SELECT id FROM geocache WHERE gc = %s LIMIT 1", $gc); $logTypeId = DB::queryFirstField("SELECT id FROM logtype WHERE type = %s LIMIT 1", $logType); DB::insert('log', array('user' => $userId, 'geocache' => $geocacheId, 'created' => $logDate, 'type' => $logTypeId, 'log' => $logtext)); } $finds++; } DB::update('user', array('finds' => $finds), "username=%s", $username); // echo "</div>"; unlink(realpath(dirname(__FILE__)) . "/pocketquery.gpx"); Header('Location: map.php');
function test_7_insert_update() { $true = DB::insertUpdate('accounts', array('id' => 2, 'username' => 'gonesoon', 'password' => 'something', 'age' => 61, 'height' => 199.194), 'age = age + %i', 1); $this->assert($true === true); $this->assert(DB::affectedRows() === 2); // a quirk of MySQL, even though only 1 row was updated $result = DB::query("SELECT * FROM accounts WHERE age = %i", 16); $this->assert(count($result) === 1); $this->assert($result[0]['height'] === '10.371'); DB::insertUpdate('accounts', array('id' => 2, 'username' => 'blahblahdude', 'age' => 233, 'height' => 199.194)); $result = DB::query("SELECT * FROM accounts WHERE age = %i", 233); $this->assert(count($result) === 1); $this->assert($result[0]['height'] === '199.194'); $this->assert($result[0]['username'] === 'blahblahdude'); DB::insertUpdate('accounts', array('id' => 2, 'username' => 'gonesoon', 'password' => 'something', 'age' => 61, 'height' => 199.194), array('age' => 74)); $result = DB::query("SELECT * FROM accounts WHERE age = %i", 74); $this->assert(count($result) === 1); $this->assert($result[0]['height'] === '199.194'); $this->assert($result[0]['username'] === 'blahblahdude'); $multiples[] = array('id' => 3, 'username' => 'gonesoon', 'password' => 'something', 'age' => 61, 'height' => 199.194); $multiples[] = array('id' => 1, 'username' => 'gonesoon', 'password' => 'something', 'age' => 61, 'height' => 199.194); DB::insertUpdate('accounts', $multiples, array('age' => 914)); $this->assert(DB::affectedRows() === 4); $result = DB::query("SELECT * FROM accounts WHERE age=914 ORDER BY id ASC"); $this->assert(count($result) === 2); $this->assert($result[0]['username'] === 'Abe'); $this->assert($result[1]['username'] === 'Charlie\'s Friend'); $true = DB::query("UPDATE accounts SET age=15, username='******' WHERE age=%i", 74); $this->assert($true === true); $this->assert(DB::affectedRows() === 1); }
function save() { DB::insertUpdate('player_history', array("player_id" => $this->get_playerId(), "season" => $this->get_season(), "minutes_played" => $this->get_minutesPlayed(), "goals" => $this->get_goals(), "assists" => $this->get_assists(), "clean_sheet" => $this->get_cleanSheet(), "goals_conceded" => $this->get_goalsConceded(), "own_goals" => $this->get_ownGoals(), "penalties_saved" => $this->get_penaltiesSaved(), "penalties_missed" => $this->get_penaltiesMissed(), "yellow_card" => $this->get_yellowCard(), "red_card" => $this->get_redCard(), "saves" => $this->get_saves(), "bonus" => $this->get_bonus(), "esp" => $this->get_esp(), "bps" => $this->get_bps(), "value" => $this->get_value(), "points" => $this->get_points())); }
$enjin->syncRanks(); #// get first page of apps $applist = $enjin->execute('Applications.getList', array('session_id' => $sessionID, 'type' => $appType)); #// find out how many pages there are... $perPage = count($applist["items"]); $totapps = $applist['total']; $totpages = $perPage > 0 ? ceil($totapps / $perPage) : 0; for ($curPage = 1; $curPage <= $totpages; $curPage++) { foreach ($applist["items"] as $app) { echo "Processing app for " . $app["username"] . " [AppID: " . $app["application_id"] . "]... "; $appDetails = $enjin->execute('Applications.getApplication', array('session_id' => $sessionID, 'application_id' => $app["application_id"])); #// extract the extra user information from the application, and save it $UserInfo[$app["user_id"]] = array("TS3 Username" => $appDetails["user_data"]["goqjf6cp8w"], "Account ID" => $appDetails["user_data"]["7bts17biho"]); DB::update("users", array("account_id" => $UserInfo[$app["user_id"]]["Account ID"]), "user_id=%i and account_id is null or account_id = ''", $app["user_id"]); # #DB::update("users", array( #"ts3_username" =>$UserInfo[$app["user_id"]]["TS3 Username"] #), "user_id=%i and ts3_username is null or ts3_username = ''", $app["user_id"]); DB::insertUpdate("users", array("user_id" => $app["user_id"], "account_id" => $appDetails["user_data"]["7bts17biho"], "ts3_username" => $appDetails["user_data"]["goqjf6cp8w"], "enjin_username" => $app["username"], "application_id" => $app["application_id"], "application_submitdate" => date("Y-m-d", $app["created"]), "avatar" => $app["avatar"]), array("enjin_username" => $app["username"], "application_id" => $app["application_id"], "application_submitdate" => date("Y-m-d", $app["created"]), "ts3_username" => $UserInfo[$app["user_id"]]["TS3 Username"], "avatar" => $app["avatar"])); try { $enjin->execute('Stats.saveUserStats', array('api_key' => $apiKey, 'stats' => $UserInfo)); #// archive application $enjin->execute('Applications.archive', array('session_id' => $sessionID, 'application_id' => $app["application_id"])); echo "Done\n"; } catch (Exception $e) { echo "Error\n"; } } #// get next page of apps $applist = $enjin->execute('Applications.getList', array('session_id' => $sessionID, 'type' => $appType, 'page' => $curPage + 1)); }
<?php require_once __DIR__ . '/../all.php'; $cookies = new Cookies(); $user = $cookies->user_from_cookie(); $vars = array("item_id", "side_id", "service_id"); if (set_vars($_POST, $vars)) { if ($user->data["permission"] === "4" || $user->data["permission"] === "3" && $user->data["service_id"] === $_POST["service_id"]) { // DB::insert("menu_sides", array("name"=>$_POST["name"], "price"=>$_POST["price"], "required"=>$_POST["req"], "service_id"=>$_POST["service_id"])); DB::insertUpdate("menu_sides_item_link", array("item_id" => $_POST["item_id"], "sides_id" => $_POST["side_id"])); echo DB::affectedRows(); } else { echo "-1"; } } else { echo "-1"; }
public function place_order($cid, $pmt, $amount) { // DB::insertUpdate("account_address", $address, "account_id=%s", $this->data["uid"]); $catitem = DB::queryOneRow("SELECT * FROM category_items WHERE id=%s", $cid); $now = DB::sqleval("NOW()"); $data = array("service_id" => $catitem["category_id"], "category_id" => $cid, "time" => $now, "user_id" => $this->id, "payment_cc" => $pmt == "credit_card" ? "1" : "0"); DB::insertUpdate("orders", $data); $oid = DB::insertId(); DB::update("carts", array("order_id" => $oid, "active" => "0"), "user_id=%s AND active=1", $this->id); if ($pmt === 'credit_card' && $this->data['stripe_cust_id']) { \Stripe\Stripe::setApiKey(env('STRIPE_API_SECRET')); if ($customer = \Stripe\Customer::retrieve($this->data['stripe_cust_id'])) { \Stripe\Charge::create(['amount' => $amount, 'currency' => 'usd', 'source' => $pmt, 'customer' => $this->data['stripe_cust_id'], 'description' => 'Order from ' . $catitem['name']]); } } return $oid; }
<?php require_once 'general.php'; require_once 'connection.php'; require_once 'logger.php'; require_once 'checkLogin.php'; if (isset($_GET['addUser'])) { DB::insertUpdate('user', array('username' => $_GET['addUser'])); DB::insertIgnore('feed', array('user' => DB::queryFirstField("SELECT id FROM user WHERE username = %s", getSessionUser()), 'feeduser' => DB::queryFirstField("SELECT id FROM user WHERE username = %s", $_GET['addUser']))); } else { if (isset($_GET['removeUser'])) { $user = DB::queryFirstField("SELECT id FROM user WHERE username = %s", getSessionUser()); $feedUser = DB::queryFirstField("SELECT id FROM user WHERE username = %s", $_GET['removeUser']); DB::delete('feed', 'user=%s AND feeduser='******'components/head.html'; printBodyTag(); showNavigation(); ?> <div class="panel-body"> <div class='panel panel-info'> <div class='panel-heading'>Add user to feed and index</div> <div class='panel-body'> <form class="form-inline"> <div class="form-group"> <input class="form-control" name="addUser" placeholder="Username">
function save() { DB::insertUpdate("player_fixture", array("player_id" => $this->get_playerId(), "fixture_id" => $this->get_fixtureId(), "minutes_played" => $this->get_minutesPlayed(), "goals" => $this->get_goals(), "assists" => $this->get_assists(), "clean_sheet" => $this->get_cleanSheet(), "goals_conceded" => $this->get_goalsConceded(), "own_goals" => $this->get_ownGoals(), "penalties_saved" => $this->get_penaltiesSaved(), "penalties_missed" => $this->get_penaltiesMissed(), "yellow_card" => $this->get_yellowCard(), "red_card" => $this->get_redCard(), "saves" => $this->get_saves(), "bonus" => $this->get_bonus(), "ea_sports_ppi" => $this->get_eaSportsPPI(), "bonus_point_system" => $this->get_bonusPointSystem(), "net_transfers" => $this->get_netTransfers(), "cost_value" => $this->get_costValue(), "points" => $this->get_points())); }
public function save() { DB::insertUpdate("fixture", array("gameweek" => $this->get_round(), "kickoff_time" => $this->get_kickoff(), "home_team" => $this->get_home_team(), "away_team" => $this->get_away_team(), "home_goals" => $this->get_home_goals(), "away_goals" => $this->get_away_goals(), "played" => $this->get_played() ? $this->get_played() : 0)); }
public function save() { echo $this->get_firstName() . "\n"; DB::insertUpdate('player', array("fpl_id" => $this->get_id(), "fpl_code" => $this->get_playerCode(), "club_id" => $this->get_teamId(), "squad_number" => $this->get_squadNumber(), "first_name" => $this->get_firstName(), "second_name" => $this->get_secondName(), "web_name" => $this->get_webName(), "in_dreamteam" => $this->get_inDreamTeam(), "shirt_image_url" => $this->get_shirtImageUrl(), "shirt_mobile_image_url" => $this->get_shirtMobileImageUrl(), "photo_mobile_url" => $this->get_photoMobileUrl(), "type" => $this->get_player_type_id($this->get_typeName()), "total_points" => $this->get_totalPoints(), "points_per_game" => $this->get_pointsPerGame(), "last_season_points" => $this->get_lastSeasonPoints(), "fpl_added" => $this->get_lastSeasonPoints())); DB::insertUpdate('player_news', array("player_id" => $this->get_id(), "status" => $this->get_status(), "news_updated" => $this->get_newsUpdated(), "news_added" => $this->get_newsAdded(), "news" => $this->get_news(), "news_return" => $this->get_newsReturn())); DB::insertUpdate('player_event', array("player_id" => $this->get_id(), "event_total" => $this->get_eventTotal(), "event_points" => $this->get_eventPoints())); DB::insertUpdate('player_cost', array("player_id" => $this->get_id(), "event_cost" => $this->get_eventCost(), "max_cost" => $this->get_maxCost(), "min_cost" => $this->get_minCost(), "now_cost" => $this->get_nowCost(), "original_cost" => $this->get_originalCost())); foreach ($this->get_seasonHistory() as $season) { $season->save(); } foreach ($this->get_fixtures() as $fixture) { $fixture->save(); } foreach ($this->get_fixtureHistory() as $playerFixture) { $playerFixture->save(); } }
<?php require_once __DIR__ . '/../all.php'; $cookies = new Cookies(); $user = $cookies->user_from_cookie(); //$vars = array("name","category_id","service_id"); //if (set_vars($_POST, $vars)){ if ($user->data["permission"] === "4" || $user->data["permission"] === "3" && $user->data["service_id"] === $_POST["service_id"]) { $id = $_POST["id"]; $arr = array_filter($_POST, function ($v) { return $v !== ''; }); DB::insertUpdate("menu_items", $arr); $iid = DB::insertId(); $old_iid = intval(DB::queryOneRow("SELECT value FROM settings WHERE name='lastitem'")["value"]); if ($iid > $old_iid) { DB::update("settings", array("value" => $iid), "name=%s", "lastitem"); } echo DB::insertId(); } else { echo "-1"; } //} //else{ // echo "-1"; //}
function map_commit() { global $map_values, $map_values_changed; if ($map_values === NULL || !$map_values_changed) { return; } //If we haven't loaded anything, or we haven't changed anything, nothing happens. $insertions = array(); foreach ($map_values as $key => $value) { $insertions[] = array('map_key' => $key, 'map_value' => $value); } DB::insertUpdate('map', $insertions, 'map_value=VALUES(map_value)'); $map_values_changed = false; }
$decoded = json_decode(substr(substr($line, 13), 0, -2), true); foreach ($decoded['data'] as $data) { $images = array(); if ($data['UserName'] == $username) { $created = transformDate($data['Visited']); $finds = $data['GeocacheFindCount']; $log = $data['LogText']; $logType = $data['LogType']; if (!empty($data['Images'])) { foreach ($data['Images'] as $image) { l('<img style="width: 100px;" src="https://img.geocaching.com/cache/log/large/' . $image['FileName'] . '" />'); array_push($images, 'https://img.geocaching.com/cache/log/large/' . $image['FileName']); } } DB::update('user', array('finds' => $finds), "username=%s", $username); DB::insertUpdate('geocache', array('gc' => $gc, 'type' => DB::queryFirstField("SELECT id FROM type WHERE type=%s LIMIT 1", $geocacheType), 'name' => $cacheName, 'difficulty' => $difficulty, 'terrain' => $terrain, 'favorites' => $fp, 'finds' => $totalFinds, 'country' => $country, 'country_iso' => $country_iso, 'lat' => $lat, 'lon' => $lon, 'url' => $url)); l("geocache: {$gc}, {$cacheName}, {$difficulty} (d), {$terrain} (t), {$fp} (fp), {$totalFinds} (total finds), {$country}, {$lat}, {$lon}, <a href=\"{$url}\">{$url}</a>"); l("log: {$username}, {$gc}, {$created}, {$logType}"); $geocacheId = DB::queryFirstField("SELECT id FROM geocache WHERE gc=%s LIMIT 1", $gc); $logTypeId = DB::queryFirstField("SELECT id FROM logtype WHERE type=%s LIMIT 1", $logType); $logIdWithDate = getLogIdFromToday($geocacheId, $userId, $created, $logTypeId); if (isset($logIdWithDate)) { DB::query("UPDATE log SET log=%s WHERE id=%i", $log, $logIdWithDate); DB::query("DELETE FROM image WHERE log=%i", $logIdWithDate); foreach ($images as $image) { $image = httpsifyUrl($image); DB::insert('image', array('log' => $logIdWithDate, 'url' => $image)); } } else { DB::insert('log', array('user' => $userId, 'geocache' => $geocacheId, 'created' => $created, 'type' => $logTypeId, 'log' => $log)); $logIdWithDate = getLogIdFromToday($geocacheId, $userId, $created, $logTypeId);