function processInput() { global $myga; if (isset($_REQUEST["action"])) { switch ($_REQUEST["action"]) { case "createuser": // "users_id" INTEGER PRIMARY KEY AUTOINCREMENT,"users_username" TEXT,"users_fullname" TEXT,"users_tokendata" TEXT $username = $_REQUEST["username"]; $fullname = $_REQUEST["fullname"]; $password = sha1($_REQUEST["password"]); $sql = "insert into users values (NULL, '{$username}', '{$fullname}', '{$password}','0')"; $db = getDatabase(); $db->query($sql); closeDatabase($db); header("Location: index.php?success=created"); break; case "provision": $username = $_REQUEST["user"]; $tokentype = $_REQUEST["tokentype"]; $myga->setUser($username, $tokentype); header("Location: index.php?success=Provisioned"); break; case "auth": $username = $_REQUEST["user"]; $tokencode = $_REQUEST["tokencode"]; if ($myga->authenticateUser($username, $tokencode)) { header("Location: index.php?success=Passed"); } else { header("Location: index.php?failure=wrongcode"); } break; } } }
function updateUserField($email, $value, $procName, &$errMsg = "") { $returnVal = true; $conn = connectDatabase(); $stmt = $conn->prepare("Call {$procName}(?,?)"); $stmt->bind_param("ss", $email, $value); $stmt->execute(); if ($stmt->errno !== 0) { $returnVal = false; } $errMsg = $stmt->error; $stmt->close(); closeDatabase($conn); return $returnVal; }
function connectToDatabase() { global $_MGM; if (isset($_MGM['DBConnection'])) { closeDatabase(); } $_MGM['DBConnection'] = NULL; $_MGM['DBConnection'] = new PDO("sqlite:" . $_MGM['DBName']); $_MGM['DBConnection']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); if ($_MGM['DBPersistent']) { $_MGM['DBConnection']->setAttribute(PDO::ATTR_PERSISTENT, TRUE); } if ($_MGM['DBConnection'] == NULL) { error("Database Connection Failed"); } }
function queryMySQLData($query) { $database = openDatabase(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME, DB_CHARSET); if (strpos($query, 'UPDATE') || strpos($query, 'INSERT')) { $database->query($query); closeDatabase($database); return true; } $ergebnis = $database->query($query); closeDatabase($database); if (is_object($ergebnis)) { return $ergebnis; } elseif ($ergebnis == true) { return true; } return false; }
function connectToDatabase() { global $_MGM; if (isset($_MGM['DBConnection'])) { closeDatabase(); } $_MGM['DBConnection'] = NULL; $options = array(); if ($_MGM['DBPersistent']) { $options = array(PDO::ATTR_PERSISTENT => true); } try { $_MGM['DBConnection'] = new PDO("mysql:host={$_MGM['DBHost']};dbname={$_MGM['DBName']};charset=utf8", $_MGM['DBUser'], $_MGM['DBPassword'], $options); $_MGM['DBConnection']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (Exception $e) { mail("Server Admin <{$_SU['adminEmail']}>", "MySQL Error", "URL: " . $_SERVER['SERVER_NAME'] . $_SU['installPath'] . $_SU['fullPath'] . "\n\nError " . $e->getMessage() . ": " . mysql_error()); //echo $e->getMessage()."<br />\n"; error("Failed to connect to database"); } if ($_MGM['DBConnection'] == NULL) { error("Database Connection Failed"); } }
//セッション使用開始 session_start(); //インクルード require_once '../lib/mysql.inc'; require_once '../lib/db.inc'; require_once '../lib/util.inc'; require_once 'settingRestTime_model.inc'; //データベース接続 if (!connectDatabase($db)) { $errmsg = "DB接続エラーが発生しました。"; //エラー画面へ遷移 callErrorPage($errMsg, "logout"); exit; } //セッションチェック if (!isset($_SESSION['userinfo'])) { //セッション切れの場合、エラー画面に遷移 callErrorPage("セッション切れのためメインメニュー画面を表示できませんでした。再度ログインしてください。", "logout"); exit; } //クラスをインスタンス化 $model = new settingRestTime_model(); //画面項目取得 $model->getForm(); //処理 $model->prosessing($db); //画面呼び出し require_once 'settingRestTime.phtml'; //データベース切断 closeDatabase($db);
<?php require "../php/header.php"; ob_start(); $name = $HTTP_GET_VARS['name']; if ($name == null) { header("Location: index.php"); exit; } openDatabase(false); $players = getPlayers($name, 50); if (count($players) == 1) { if (getPid($name) != 0) { header("Location: playerinfo.php?name=" . urlencode($name)); closeDatabase(); exit; } } ob_end_flush(); $html_title = "WinBolo.net: Search Results for {$name}"; include "{$BASE_FILES}/inc_top.php"; $error_heading = "Search Results"; if (count($players) == 0) { $error_body = "Sorry, no matches to your query."; } else { $error_body = "Search Results (Limit 50 matches)<P>"; $count = 0; while ($count < count($players)) { $error_body .= "<a href=\"playerinfo.php?name=" . urlencode($players[$count]) . "\">" . $players[$count] . "</A><BR>"; $count++; }
function searchFor($procFunc, $keyword, $sort, $by) { $email = ""; $firstName = ""; $lastName = ""; $result = []; $resultArray = array(); $conn = connectDatabase(); $stmt = $conn->prepare($procFunc); $stmt->bind_param("sss", $keyword, $sort, $by); $stmt->execute(); $stmt->bind_result($email, $firstName, $lastName); while ($stmt->fetch()) { $result['email'] = $email; $result['firstName'] = $firstName; $result['lastName'] = $lastName; array_push($resultArray, $result); } closeDatabase($conn); return $resultArray; }
function processServerKeyRequest($data) { $ip = getenv("REMOTE_ADDR"); $gameType = ord($data[0]); $ai = ord($data[1]); $mines = ord($data[2]); $password = ord($data[3]); $freeBases = ord($data[4]); $freePills = ord($data[5]); $numPlayers = ord($data[6]); $numBases = ord($data[7]); $numPills = ord($data[8]); $mapLen = ord($data[9]); $mapName = substr($data, 10, $mapLen); $pos = 10 + $mapLen; $port = unpack("nid", substr($data, $pos, 2)); $port = $port[id]; $pos += 2; $startTime = time(); //$startTime = unpack("Nid", $startTime); //$startTime = $startTime[id]; openDatabase(true); $now = time(); srand($now); $key = getNewServerKey(md5($now . rand() . $ip . rand() . $port . $mapName . rand() . $password . $mines . $startTime . time() . rand())); $mapName = mysql_escape_string($mapName); $ipAddress = $ip; $ip = gethostbyaddr($ip); if (gethostbyname($ip) != $ipAddress) { $ip = $ipAddress; } # Fix for west if ($ip == "gatekeeper.nt4.com") { $ip = "west.winbolo.com"; } #Fix for sheeps if ($ip == "ool-4351bf05.dyn.optonline.net") { $ip = "sheeps.winbolo.us"; } #Fix for fermat if ($ip == "c-69-136-99-180.hsd1.pa.comcast.net") { $ip = "fermat.winbolo.us"; } #Fix for canuck if ($ip == "CPE0002446032e4-CM000039fbb861.cpe.net.cable.rogers.com") { $ip = "winbolo.dhs.org"; } #Fix for paniq if ($ipAddress == "207.88.53.107") { $ip = "paniq.winbolo.us"; } #Fix for bluebot if ($ip == "pool-141-154-115-77.bos.east.verizon.net") { $ip = "bluebot.winbolo.us"; } #Fix for renbot if ($ip == "dsl092-218-111.sfo2.dsl.speakeasy.net") { $ip = "renbot.winbolo.us"; } if ($ip == "12.39.4.70") { $ip = "pawnyBot.winbolo.us"; } #CCBot if ($ipAddress == "24.4.42.190") { $ip = "ccbot.winbolo.us"; } #NYCBot if ($ip == "cpe-68-173-217-129.nyc.res.rr.com") { $ip = "nycbot.winbolo.us"; } # Acrobot if ($ip == "cpe-24-195-41-47.nycap.res.rr.com") { $ip = "acrobot.winbolo.us"; } # Alexmbot if ($ip == "chanxmail.swmc.org") { $ip = "alexmbot.winbolo.us"; } #me if ($ip == "johnmorrison.name") { $ip = "winbolo.net"; } $ip = mysql_escape_string($ip); $sql = "insert into game_server (gs_key, gs_ip, gs_port, gs_mapname, gs_password, gs_mines, gs_numbases, gs_numpills, gs_freebases, gs_freepills, gs_numtanks, gs_starttime, gs_firstheard, gs_lastheard, gs_ai, gs_gametype) values ('{$key}', '{$ip}', '{$port}', '{$mapName}', '{$password}', '{$mines}', '{$numBases}', '{$numPills}', '{$freeBases}', '{$freePills}', '{$numPlayers}', '{$startTime}', '{$now}', '{$now}', '{$ai}', '{$gameType}')"; $result = mysql_query($sql); if (mysql_affected_rows() != 1) { writeError("Database error. "); } closeDatabase(); return $key; }
$pid = mysql_escape_string($HTTP_GET_VARS['u']); if ($userdata['session_logged_in'] == true && !isset($HTTP_GET_VARS['u'])) { header("Location: /playermodify.php"); exit; } openDatabase(false); $sql = "select username from users where user_id = '{$pid}'"; $result = mysql_query($sql); $name = ""; if ($result) { if (mysql_num_rows($result) > 0) { $name = mysql_result($result, 0, 0); } } header("Location: /playerinfo.php?name=" . urlencode($name)); closeDatabase(database); exit; } unset($mode); define('IN_PHPBB', true); $phpbb_root_path = './'; include $phpbb_root_path . 'extension.inc'; include $phpbb_root_path . 'common.' . $phpEx; // // Start session management // $userdata = session_pagestart($user_ip, PAGE_PROFILE); init_userprefs($userdata); // // End session management //
<?php //get data for specified UserID include 'database.php'; $UserID = $_GET["UserID"]; //echo "UserID: ".$UserID."<br>"; $con = connectToDatabase(); $query = "SELECT * FROM GameData WHERE UserID=" . $UserID; $result = mysqli_query($con, $query); $numrows = mysqli_num_rows($result); if ($numrows == 0) { echo "Player"; } else { echo "NonPlayer"; } closeDatabase($con); ?>