Ejemplo n.º 1
0
function getDetails($db, $id, $type, $langs, $offset)
{
    global $format;
    global $callback;
    // request
    $request = "SELECT\n\t\t\t\ttags->'addr:street' AS \"street\",\n\t\t\t\ttags->'addr:housenumber' AS \"housenumber\",\n\t\t\t\ttags->'addr:country' AS \"country\",\n\t\t\t\ttags->'addr:postcode' AS \"postcode\",\n\t\t\t\ttags->'addr:city' AS \"city\",\n\t\t\t\ttags->'addr:housename' AS \"housename\",\n\t\t\t\ttags->'addr:suburb' AS \"suburb\",\n\t\t\t\ttags->'addr:province' AS \"province\",\n\t\t\t\ttags->'addr:unit' AS \"unit\",\n\t\t\t\ttags->'addr:floor' AS \"floor\",\n\t\t\t\ttags->'addr:door' AS \"door\",\n\t\t\t\ttags->'wikipedia' AS \"wikipedia\",\n\t\t\t\ttags->'phone' AS \"phone1\",\n\t\t\t\ttags->'contact:phone' AS \"phone2\",\n\t\t\t\ttags->'addr:phone' AS \"phone3\",\n\t\t\t\ttags->'phone:mobile' AS \"mobilephone1\",\n\t\t\t\ttags->'contact:mobile' AS \"mobilephone2\",\n\t\t\t\ttags->'fax' AS \"fax1\",\n\t\t\t\ttags->'contact:fax' AS \"fax2\",\n\t\t\t\ttags->'addr:fax' AS \"fax3\",\n\t\t\t\ttags->'website' AS \"website1\",\n\t\t\t\ttags->'url' AS \"website2\",\n\t\t\t\ttags->'url:official' AS \"website3\",\n\t\t\t\ttags->'contact:website' AS \"website4\",\n\t\t\t\ttags->'operator' AS \"operator\",\n\t\t\t\ttags->'email' AS \"email1\",\n\t\t\t\ttags->'contact:email' AS \"email2\",\n\t\t\t\ttags->'addr:email' AS \"email3\",\n\t\t\t\ttags->'opening_hours' AS \"openinghours\",\n\t\t\t\ttags->'service_times' AS \"servicetimes\",\n\t\t\t\ttags->'fee' AS \"fee\",\n\t\t\t\ttags->'toll' AS \"toll\",\n\t\t\t\ttags->'ref' AS \"ref\",\n\t\t\t\ttags->'capacity' AS \"capacity\",\n\t\t\t\ttags->'internet_access' AS \"internet_access\",\n\t\t\t\ttags->'image' AS \"image\",\n\t\t\t\ttags->'image:panorama' AS \"panorama\",\n\t\t\t\ttags->'description' AS \"description\",\n\t\t\t\ttags->'stars' AS \"stars\",\n\t\t\t\ttags->'cuisine' AS \"cuisine\",\n\t\t\t\ttags->'smoking' AS \"smoking\",\n\t\t\t\ttags->'biergarten' AS \"biergarten\",\n\t\t\t\ttags->'beer_garden' AS \"beer_garden\",\n\t\t\t\ttags->'brewery' AS \"beer\",\n\t\t\t\ttags->'microbrewery' AS \"microbrewery\",\n\t\t\t\ttags->'fuel:diesel' AS \"diesel\",\n\t\t\t\ttags->'fuel:GTL_diesel' AS \"gtldiesel\",\n\t\t\t\ttags->'fuel:HGV_diesel' AS \"hgvdiesel\",\n\t\t\t\ttags->'fuel:biodiesel' AS \"biodiesel\",\n\t\t\t\ttags->'fuel_octane_91' AS \"octane91\",\n\t\t\t\ttags->'fuel:octane_95' AS \"octane95\",\n\t\t\t\ttags->'fuel:octane_98' AS \"octane98\",\n\t\t\t\ttags->'fuel:octane_100' AS \"octane100\",\n\t\t\t\ttags->'fuel:octane_98_leaded' AS \"octane98l\",\n\t\t\t\ttags->'fuel:1_25' AS \"fuel25\",\n\t\t\t\ttags->'fuel:1_50' AS \"fuel50\",\n\t\t\t\ttags->'fuel:alcohol' AS \"alcohol\",\n\t\t\t\ttags->'fuel:ethanol' AS \"ethanol\",\n\t\t\t\ttags->'fuel:methanol' AS \"methanol\",\n\t\t\t\ttags->'fuel:svo' AS \"svo\",\n\t\t\t\ttags->'fuel:e85' AS \"e85\",\n\t\t\t\ttags->'fuel:biogas' AS \"biogas\",\n\t\t\t\ttags->'fuel:lpg' AS \"lpg\",\n\t\t\t\ttags->'fuel:cng' AS \"cng\",\n\t\t\t\ttags->'fuel:LH2' AS \"lh2\",\n\t\t\t\ttags->'fuel:electricity' AS \"electro\",\n\t\t\t\ttags->'fuel:adblue' AS \"adblue\",\n\t\t\t\ttags->'car_wash' AS \"carwash\",\n\t\t\t\ttags->'car_repair' AS \"carrepair\",\n\t\t\t\ttags->'shop' AS \"shop\",\n\t\t\t\ttags->'kiosk' AS \"kiosk\",\n\t\t\t\ttags->'ele' AS \"ele\",\n\t\t\t\ttags->'population' AS \"population\",\n\t\t\t\ttags->'iata' AS \"iata\",\n\t\t\t\ttags->'icao' AS \"icao\",\n\t\t\t\ttags->'disused' AS \"disused\",\n\t\t\t\ttags->'wheelchair' AS \"wheelchair\",\n\t\t\t\ttags->'wheelchair:toilets' AS \"wheelchair:toilets\",\n\t\t\t\ttags->'wheelchair:rooms' AS \"wheelchair:rooms\",\n\t\t\t\ttags->'wheelchair:access' AS \"wheelchair:access\",\n\t\t\t\ttags->'wheelchair:places' AS \"wheelchair:places\"\n\t\t\tFROM " . $type . "s WHERE (id = " . $id . ");";
    $wikipediarequest = "SELECT\n\t\t\t\t\t\t\t\tfoo.keys, foo.values\n\t\t\t\t\t\t\tFROM (\n\t\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t\tskeys(tags) AS keys,\n\t\t\t\t\t\t\t\t\tsvals(tags) AS values\n\t\t\t\t\t\t\t\tFROM " . $type . "s\n\t\t\t\t\t\t\t\tWHERE (id = " . $id . ")\n\t\t\t\t\t\t\t) AS foo\n\t\t\t\t\t\t\tWHERE substring(foo.keys from 1 for 9) = 'wikipedia';";
    $namerequest = "SELECT\n\t\t\t\t\t\t\t\tfoo.keys, foo.values\n\t\t\t\t\t\t\tFROM (\n\t\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t\tskeys(tags) AS keys,\n\t\t\t\t\t\t\t\t\tsvals(tags) AS values\n\t\t\t\t\t\t\t\tFROM " . $type . "s\n\t\t\t\t\t\t\t\tWHERE (id = " . $id . ")\n\t\t\t\t\t\t\t) AS foo\n\t\t\t\t\t\t\tWHERE substring(foo.keys from 1 for 4) = 'name';";
    // connnecting to database
    $connection = connectToDatabase($db);
    // if there is no connection
    if (!$connection) {
        exit;
    }
    $response = requestDetails($request, $connection);
    $wikipediaresponse = requestDetails($wikipediarequest, $connection);
    $nameresponse = requestDetails($namerequest, $connection);
    pg_close($connection);
    if ($response) {
        if ($format == "text") {
            echo textMoredetailsOut($response[0], $nameresponse, $wikipediaresponse, $langs, $offset);
        } else {
            if ($format == "json") {
                echo jsonMoredetailsOut($response[0], $nameresponse, $wikipediaresponse, $langs, $offset, $id, $type, $callback);
            } else {
                echo xmlMoredetailsOut($response[0], $nameresponse, $wikipediaresponse, $langs, $offset, $id, $type);
            }
        }
        return true;
    } else {
        return false;
    }
}
function returnResultForQuery($query)
{
    $connection = connectToDatabase();
    $result = $connection->query($query);
    $connection->close();
    return $result;
}
Ejemplo n.º 3
0
function getUser($username)
{
    $mysql = connectToDatabase();
    $query = $mysql->prepare("SELECT * FROM accounts  WHERE username = :username LIMIT 1");
    $query->execute(array('username' => $username));
    return $query->fetch(PDO::FETCH_OBJ);
}
Ejemplo n.º 4
0
function importOsmFile($filename, $db)
{
    global $offset, $offsetfactorrels, $connection;
    $connection = connectToDatabase($db);
    // if there is no connection
    if (!$connection) {
        reportError("Cannot connect to database.");
        return false;
    }
    $result = pg_query($connection, "TRUNCATE nodes");
    $result = pg_query($connection, "TRUNCATE ways");
    $result = pg_query($connection, "TRUNCATE relations");
    $xml_parser = xml_parser_create();
    xml_set_element_handler($xml_parser, "startElement", "endElement");
    if (!($fp = fopen($filename, "r"))) {
        reportError("Cannot open file.");
        return false;
    }
    while ($data = fread($fp, 4096)) {
        if (!xml_parse($xml_parser, $data, feof($fp))) {
            reportError("XML-Error.");
            return false;
        }
    }
    xml_parser_free($xml_parser);
    fclose($fp);
    pg_close($connection);
    echo "Finished " . $db . "...\n";
    return true;
}
Ejemplo n.º 5
0
function doGet()
{
    global $smarty;
    global $db;
    require_once "./config.php";
    $db = connectToDatabase();
    smartysetup();
    $mvname = $_GET['mvn'];
    $query = 'movie = ?';
    $mvm = new Moviemains();
    $infos = $mvm->Find($query, $mvname);
    /**single movie*/
    $mcomms = array();
    $mpics = array();
    $querys = 'fk_movie = ?';
    $mvs = new Moviesupps();
    $supinfos = array();
    $supinfos = $mvs->Find($querys, $infos[0]->id);
    foreach ($supinfos as $supin) {
        $mcomms[] = $supin->photocomment;
        $mpics[] = $supin->photo;
    }
    $snums = count($mpics) - 1;
    $smarty->assign('num', $snums);
    $smarty->assign('name', $mvname);
    $smarty->assign('cat', $infos[0]->mgroup);
    $smarty->assign('info', $infos[0]->info);
    $smarty->assign('comms', $mcomms);
    $smarty->assign('pics', $mpics);
    $smarty->display('SearchResult.tpl');
}
Ejemplo n.º 6
0
function displayConfigForm()
{
    $query = "SELECT * FROM vars_text";
    $query_2 = "SELECT * FROM vars_numeric";
    $database = connectToDatabase();
    $result = mysqlQuery($query, $database);
    $result_2 = mysqlQuery($query_2, $database);
    echo "<form method='post'><table>";
    while ($result_array = mysql_fetch_array($result)) {
        //debugArray( "text", $result_array );
        echo "<tr>";
        echo "<td>";
        echo "<input type='text' name='text_" . $result_array['name'] . "' value='" . $result_array['value'] . "' size='50' />";
        echo "</td>";
        echo "<td>";
        echo $result_array['description'];
        echo "</td>";
        echo "</tr>";
    }
    while ($result_array_2 = mysql_fetch_array($result_2)) {
        echo "<tr>";
        echo "<td>";
        echo "<input type='text' name='" . $result_array_2['name'] . "' value='" . $result_array_2['value'] . "' size='50' />";
        echo "</td>";
        echo "<td>";
        echo $result_array_2['description'];
        echo "</td>";
        echo "</tr>";
    }
    echo "<tr>";
    echo "<td><input type='submit' value='Submit' /></td><td><input type='hidden' name='submitted' value='1' /></td></tr>";
    echo "</table></form>";
}
Ejemplo n.º 7
0
function getDetails($ptdb, $id, $type, $langs, $offset)
{
    global $format, $callback;
    // request
    $wikipediarequest = "SELECT\n\t\t\t\t\t\t\t\tfoo.keys, foo.values\n\t\t\t\t\t\t\tFROM (\n\t\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t\tskeys(tags) AS keys,\n\t\t\t\t\t\t\t\t\tsvals(tags) AS values\n\t\t\t\t\t\t\t\tFROM " . $type . "s\n\t\t\t\t\t\t\t\tWHERE (id = " . $id . ")\n\t\t\t\t\t\t\t) AS foo\n\t\t\t\t\t\t\tWHERE substring(foo.keys from 1 for 9) = 'wikipedia';";
    $namerequest = "SELECT\n\t\t\t\t\t\t\t\tfoo.keys, foo.values\n\t\t\t\t\t\t\tFROM (\n\t\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t\tskeys(tags) AS keys,\n\t\t\t\t\t\t\t\t\tsvals(tags) AS values\n\t\t\t\t\t\t\t\tFROM " . $type . "s\n\t\t\t\t\t\t\t\tWHERE (id = " . $id . ")\n\t\t\t\t\t\t\t) AS foo\n\t\t\t\t\t\t\tWHERE substring(foo.keys from 1 for 4) = 'name';";
    // connnecting to database
    $connection = connectToDatabase($ptdb);
    // if there is no connection
    if (!$connection) {
        exit;
    }
    $wikipediaresponse = requestDetails($wikipediarequest, $connection);
    $nameresponse = requestDetails($namerequest, $connection);
    pg_close($connection);
    $response = tagTransform("../locales/departures.xml", getTags($ptdb, $id, $type), $type);
    if ($response) {
        if ($format == "text") {
            echo textDetailsOut($response, $nameresponse, $wikipediaresponse, $langs, $offset);
        } else {
            if ($format == "json") {
                echo jsonDetailsOut($response, $nameresponse, $wikipediaresponse, $langs, $offset, $id, $type, $callback);
            } else {
                echo xmlDetailsOut($response, $nameresponse, $wikipediaresponse, $langs, $offset, $id, $type);
            }
        }
        return true;
    } else {
        return false;
    }
}
Ejemplo n.º 8
0
function doLogin($referer_in, $post)
{
    extract($post);
    if ($submit_login) {
        if (!recaptchaCheck()) {
            return 0;
        }
        $database = connectToDatabase();
        $account = new Account($username);
        if ($account->checkPassword($password)) {
            session_name($username);
            $_SESSION['username'] = $username;
            $_SESSION['id'] = $account->getDatabaseID();
            if ($referer) {
                doRedirect($referer);
            } else {
                renderError("Cannot redirect you to the proper place.  Please press the back button and try again.");
                return 0;
            }
        } else {
            renderError("Your password is incorrect.  Please try again");
            return 0;
        }
    } else {
        renderError("You need to login to do that.");
        displayLoginForm($referer_in);
        return 0;
    }
}
Ejemplo n.º 9
0
function getDetails($db, $id, $type, $langs, $offset)
{
    global $format, $callback;
    // request
    $request = "SELECT\n\t\t\t\ttags->'addr:street' AS \"street\",\n\t\t\t\ttags->'addr:housenumber' AS \"housenumber\",\n\t\t\t\ttags->'addr:housename' AS \"housename\",\n\t\t\t\ttags->'addr:country' AS \"country\",\n\t\t\t\ttags->'addr:postcode' AS \"postcode\",\n\t\t\t\ttags->'addr:city' AS \"city\",\n\t\t\t\ttags->'addr:suburb' AS \"suburb\",\n\t\t\t\ttags->'addr:province' AS \"province\",\n\t\t\t\ttags->'addr:unit' AS \"unit\",\n\t\t\t\ttags->'addr:floor' AS \"floor\",\n\t\t\t\ttags->'addr:door' AS \"door\",\n\t\t\t\ttags->'phone' AS \"phone1\",\n\t\t\t\ttags->'contact:phone' AS \"phone2\",\n\t\t\t\ttags->'addr:phone' AS \"phone3\",\n\t\t\t\ttags->'fax' AS \"fax1\",\n\t\t\t\ttags->'contact:fax' AS \"fax2\",\n\t\t\t\ttags->'addr:fax' AS \"fax3\",\n\t\t\t\ttags->'website' AS \"website1\",\n\t\t\t\ttags->'url' AS \"website2\",\n\t\t\t\ttags->'url:official' AS \"website3\",\n\t\t\t\ttags->'contact:website' AS \"website4\",\n\t\t\t\ttags->'operator' AS \"operator\",\n\t\t\t\ttags->'email' AS \"email1\",\n\t\t\t\ttags->'contact:email' AS \"email2\",\n\t\t\t\ttags->'addr:email' AS \"email3\",\n\t\t\t\ttags->'opening_hours' AS \"openinghours\",\n\t\t\t\ttags->'service_times' AS \"servicetimes\",\n\t\t\t\ttags->'image' AS \"image\"\n\t\t\tFROM " . $type . "s WHERE (id = " . $id . ");";
    $wikipediarequest = "SELECT\n\t\t\t\t\t\t\t\tfoo.keys, foo.values\n\t\t\t\t\t\t\tFROM (\n\t\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t\tskeys(tags) AS keys,\n\t\t\t\t\t\t\t\t\tsvals(tags) AS values\n\t\t\t\t\t\t\t\tFROM " . $type . "s\n\t\t\t\t\t\t\t\tWHERE (id = " . $id . ")\n\t\t\t\t\t\t\t) AS foo\n\t\t\t\t\t\t\tWHERE substring(foo.keys from 1 for 9) = 'wikipedia';";
    $namerequest = "SELECT\n\t\t\t\t\t\t\t\tfoo.keys, foo.values\n\t\t\t\t\t\t\tFROM (\n\t\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t\tskeys(tags) AS keys,\n\t\t\t\t\t\t\t\t\tsvals(tags) AS values\n\t\t\t\t\t\t\t\tFROM " . $type . "s\n\t\t\t\t\t\t\t\tWHERE (id = " . $id . ")\n\t\t\t\t\t\t\t) AS foo\n\t\t\t\t\t\t\tWHERE substring(foo.keys from 1 for 4) = 'name';";
    // connnecting to database
    $connection = connectToDatabase($db);
    // if there is no connection
    if (!$connection) {
        exit;
    }
    $response = requestDetails($request, $connection);
    $wikipediaresponse = requestDetails($wikipediarequest, $connection);
    $nameresponse = requestDetails($namerequest, $connection);
    pg_close($connection);
    if ($response) {
        if ($format == "text") {
            echo textDetailsOut($response[0], $nameresponse, $wikipediaresponse, $langs, $offset);
        } else {
            if ($format == "json") {
                echo jsonDetailsOut($response[0], $nameresponse, $wikipediaresponse, $langs, $offset, $id, $type, $callback);
            } else {
                echo xmlDetailsOut($response[0], $nameresponse, $wikipediaresponse, $langs, $offset, $id, $type);
            }
        }
        return true;
    } else {
        return false;
    }
}
Ejemplo n.º 10
0
function execute($sql)
{
    global $invalidQueryInputError;
    $connection = connectToDatabase();
    $result = mysqli_query($connection, $sql);
    closeConnection($connection);
    $rows = array();
    if (mysqli_num_rows($result) > 0) {
        $i = 0;
        while ($row = mysqli_fetch_assoc($result)) {
            $rows[$i] = $row;
            $i++;
        }
    }
    if ($invalidQueryInputError != "") {
        $rows["PHP_ERROR"] = $invalidQueryInputError;
        //This is not safe [Security Flow]
        $invalidQueryInputError = "";
    }
    if (mysqli_error($connection) != null) {
        $rows["SQL_ERROR"] = mysqli_connect_error();
        //This is not safe [Security Flow]
    }
    return $rows;
}
Ejemplo n.º 11
0
function comparePermission($userName)
{
    $db = connectToDatabase();
    foreach ($db->query("SELECT * FROM cred WHERE userName ='******'") as $row) {
        $row;
        return $row;
    }
}
Ejemplo n.º 12
0
function getPage($action)
{
    $db = connectToDatabase();
    foreach ($db->query("SELECT * FROM " . $action) as $row) {
        $row;
        return $row;
    }
}
function printPlayersReport($report, $showTop, $orderBy)
{
    $conn = connectToDatabase();
    $query = 'SELECT * FROM Player_Stats, Players where Player_Stats.Player_ID = Players.Player_ID and Player_Stats.' . $report . ' > 0 ORDER BY Player_Stats.' . $report . ' ' . $orderBy . ' LIMIT ' . $showTop . ';';
    $result = $conn->query($query);
    printPlayers($report, $result);
    $conn->close();
}
function printBallPopularity($orderBy, $showTop)
{
    $conn = connectToDatabase();
    $query = "SELECT roll.Ball_ID, Count(roll.Ball_ID) as numOfRolls, ball.Color, ball.Weight, ball.Size\n                FROM roll, ball\n                WHERE roll.Ball_ID = ball.Ball_ID\n                GROUP by Ball_ID\n                ORDER BY COUNT(Ball_ID) {$orderBy} LIMIT {$showTop}";
    $result = $conn->query($query);
    printTable($result);
    $conn->close();
}
Ejemplo n.º 15
0
function search($input)
{
    $db = connectToDatabase();
    $gem = $input;
    foreach ($db->query("SELECT * FROM stones WHERE name ='" . $gem . "'") as $row) {
        $row;
        return $row;
    }
}
Ejemplo n.º 16
0
function processPost()
{
    connectToDatabase();
    $id = createInitialTask();
    $xml = generateXml($id);
    addRequestXml($id, $xml);
    $response = postXml($xml);
    addResponse($id, $response);
}
function leaveTeam($teamID, $playerPosition)
{
    $conn = connectToDatabase();
    $sql = "UPDATE TEAM SET " . $playerPosition . " = NULL where Team_ID = {$teamID}";
    if (mysqli_query($conn, $sql) == TRUE) {
        echo '<br>Boo hoo! Your team members will miss you. <a href=team.php>Click Here</a> to go back to the team page.';
    } else {
        echo '<br>For some reason you were unable to leave your team. The error is ' . $conn->error . '<a href=team.php>Click Here</a> to go back to the team page.';
    }
}
function getRollInformation($rollID)
{
    $conn = connectToDatabase();
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }
    $sql = "SELECT * FROM ROLL, BALL WHERE Roll_ID= {$rollID} and Roll.Ball_ID = Ball.Ball_ID";
    $result = $conn->query($sql);
    if ($result->num_rows > 0) {
        $row = $result->fetch_assoc();
        $gameID = $_GET['gameID'];
        echo "<form action='viewGame.php?gameID={$gameID} method='post' onsubmit=\"return confirm('Are you sure the information is correct?');\">";
        //get data from checkboxes
        $isChecked = "";
        $isStrike = 0;
        $isSpare = 0;
        $isFoul = 0;
        if ($row["Is_Strike"] == 1) {
            $isChecked = "checked";
            $isStrike = 1;
        } else {
            $isChecked = "";
        }
        echo "<br>Strike:<a type='checkbox' name='isStrike' {$isChecked}></a>";
        if ($row["Is_Spare"] == 1) {
            $isChecked = "checked";
            $isSpare = 1;
        } else {
            $isChecked = "";
        }
        echo "<br>Spare:<input type='checkbox' name='isSpare' {$isChecked}>";
        if ($row["Is_Foul"] == 1) {
            $isChecked = "checked";
            $isFoul = 1;
        } else {
            $isChecked = "";
        }
        echo "<br>Foul:<input type='checkbox' name='isFoul' {$isChecked}>";
        echo "<br><br>";
        //get data from pins
        $pinHit = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
        for ($pin = 1; $pin < 10; $pin++) {
            $pinHit[$pin] = $row["Hit_Pin_{$pin}"];
            //            echo $pinHit[$pin];
            if ($row["Hit_Pin_{$pin}"] == 1) {
                $isChecked = "checked";
            } else {
                $isChecked = "";
            }
            echo "Pin {$pin} : <input type='checkbox' name='pin{$pin}' {$isChecked}><br>";
        }
        echo "<input type='submit' value='Enter'>\n            </form>";
    }
}
 function retrieveAndPrintAllFromTable($table)
 {
     $conn = connectToDatabase();
     if ($conn->connect_error) {
         die("Connection failed: " . $conn->connect_error);
     }
     $queryAllColumns = "SELECT distinct Column_name FROM Information_schema.columns WHERE Table_name LIKE '{$table}';";
     $allColumns = $conn->query($queryAllColumns);
     createTableOnWebpage($allColumns);
     $conn->close();
 }
function printAllEventTypes()
{
    $query = "select distinct Event_Type from Game";
    $conn = connectToDatabase();
    $result = $conn->query($query);
    if ($result->num_rows > 0) {
        while ($row = $result->fetch_assoc()) {
            echo '<option value=' . $row['Event_Type'] . '>' . $row['Event_Type'] . '</option>';
        }
    }
}
Ejemplo n.º 21
0
function getGem()
{
    $db = connectToDatabase();
    $query = $db->prepare("SELECT * FROM  stones");
    $query->execute();
    $result = $query->fetchAll();
    foreach ($result as $row) {
        $gemy = $row["name"];
        echo "<option>\n                    {$gemy}\n                </option>";
    }
}
Ejemplo n.º 22
0
function getEndings($fen)
{
    $db = connectToDatabase();
    try {
        $moves = $db->prepare("SELECT move, probatowin, probatonull, nb FROM endings WHERE fen LIKE ?");
        $moves->execute(array($fen));
    } catch (PDOException $e) {
        exit('Error: ' . $e->getMessage());
    }
    $arrayMoves = $moves->fetchAll();
    return json_encode($arrayMoves);
}
Ejemplo n.º 23
0
function executeReportStatements($dbConn, $sql, $description)
{
    $dbConn = connectToDatabase($host, $dbname, $username, $password);
    //Create SQL Prepared Statement (Preventing SQL Injection)
    $statement = $dbConn->prepare($sql);
    //Execute SQL Statement
    $statement->execute();
    //Retrieve all records in on array
    $records = $statement->fetchAll();
    //Create Table
    createOutput($records, $sql, $description);
}
 function retrieveAndPrintAllFromTable($tableName, $id_column, $rowid)
 {
     $conn = connectToDatabase();
     if ($conn->connect_error) {
         die("Connection failed: " . $conn->connect_error);
     }
     $queryAllColumns = "SELECT distinct Column_name FROM Information_schema.columns WHERE Table_name LIKE '{$tableName}';";
     $allColumns = $conn->query($queryAllColumns);
     $queryToGetAllDataOfATable = "SELECT * FROM {$tableName} WHERE {$id_column} = {$rowid}";
     $result = $conn->query($queryToGetAllDataOfATable);
     createTableOnWebpage($allColumns, $result);
     $conn->close();
 }
function createEmailToPlayerIDList()
{
    $conn = connectToDatabase();
    $sql = "SELECT Player_ID, Email from Players";
    $result = $conn->query($sql);
    $emailToID = array();
    if ($result->num_rows > 0) {
        while ($row = $result->fetch_assoc()) {
            $emailToID[$row['Email']] = $row['Player_ID'];
        }
    }
    return $emailToID;
}
Ejemplo n.º 26
0
function check($user)
{
    $base_handler = connectToDatabase();
    if ($base_handler) {
        $result = doInDatabase("SELECT IDu FROM USERS WHERE NICKNAME = \"{$user}\"");
        if (mysql_fetch_assoc($result)) {
            return 1;
        }
    } else {
        echo "Nie mozna polaczyc sie z baza </br>";
        return 0;
    }
}
Ejemplo n.º 27
0
function check($user, $pass)
{
    $pass = hash("sha256", $pass);
    echo $user . " " . $pass . "</br>";
    $base_handler = connectToDatabase();
    if ($base_handler) {
        $result = checkInDatabase("SELECT IDu FROM USERS WHERE NICKNAME = \"{$user}\" AND PASSWORD  = \"{$pass}\"");
        $resultk = mysql_fetch_assoc($result);
        return $resultk["IDu"];
    } else {
        echo "Nie mozna polaczyc sie z baza </br>";
        return 0;
    }
}
function getAllBallsForColor($colorOfBall)
{
    $conn = connectToDatabase();
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }
    $query = "SELECT * FROM BALL WHERE Ball.Color = '{$colorOfBall}'";
    $result = $conn->query($query);
    if (!$result) {
        die('Invalid query' . mysql_error());
    } else {
        echo "You searched for the color {$colorOfBall} and got {$result->num_rows} rows!";
        printAll($result);
    }
    $conn->close();
}
function createPlayerEmailArray()
{
    $conn = connectToDatabase();
    $sql = "SELECT Email, Player_ID from Players";
    $result = $conn->query($sql);
    $teams = array();
    if ($result->num_rows > 0) {
        // output data of each row
        while ($row = $result->fetch_assoc()) {
            $teams[$row['Player_ID']] = $row['Email'];
        }
    } else {
        echo "0 results";
    }
    return $teams;
}
 function changePasswordForPlayerWithResetKey($resetKey, $password)
 {
     $conn = connectToDatabase();
     $newPassword = password_hash($password, PASSWORD_DEFAULT);
     $resetKey = explode("<", $resetKey, 2)[0];
     $sql = "update Players set Players.Password = '******', Players.Reset_Key = null";
     $sql = $sql . " where Players.Reset_Key = '{$resetKey}'";
     if (mysqli_query($conn, $sql)) {
         $alertMessage = "Password Update successful! Taking you back to the login screen.";
         echo "<script type='text/javascript'>\n            alert('{$alertMessage}');\n            window.location.href = 'loginForm.php';\n        </script>";
     } else {
         $alertMessage = "Sorry! Please try resetting your password again. Make sure you have clicked the right link in the email.";
     }
     $conn->close();
     return $alertMessage;
 }