Example #1
0
function readCSVfile($filename)
{
    $column = array();
    $file = fopen($filename, "r");
    $i = 0;
    while (!feof($file)) {
        global $column;
        $column[$i] = fgetcsv($file);
        $i++;
    }
    $i = 0;
    foreach ($column as $array) {
        # code...
        if ($i != 0) {
            insertIntoDatabase($string, $array);
            $i++;
        } else {
            setColumnNames($string, $array);
            $i++;
        }
    }
}
        $query .= " VALUES (?, ?, ?, ?, ?, ?)";
        confirm_query($query);
        /* create a prepared statement */
        if ($stmt = $connection->prepare($query)) {
            global $firstname, $lastname, $orgname, $email, $password, $user_role;
            /* bind parameters for markers */
            $stmt->bind_param("ssssss", $firstname, $lastname, $orgname, $email, $password, $user_role);
            /* execute query */
            if ($stmt->execute()) {
                echo "successfully executed";
            } else {
                echo "Failed to execute" . $connection->error;
            }
        }
    }
    insertIntoDatabase();
}
?>

    <br>
	<form  id="register-form" action="<?php 
echo htmlspecialchars($_SERVER["PHP_SELF"]);
?>
" method="post" style="margin:0px auto;width:800px">
    	<div class="form-group">
            <h4>Register As:</h4> 
                <select id="selectBox" name="selectuser" class="form-control input-lg" placeholder="-- SELECT --">
                        <option value="normaluser">Normal User</option>
                        <option value="organizer">Organizer</option>
                </select>
        </div>
    }
}
// SUBMIT BUTTON PRESSED
if (!empty($_POST)) {
    // database connection
    include_once "config.php";
    require_once 'php/databaseConnection.php';
    //check to see if ip hasn't submitted too many times today
    $ip = dailyLimit($con);
    //remove excess space from before first word and after last word before we start anything
    $t = trim($_POST['thing']);
    //take out html or php tags
    $t = strip_tags($t, '');
    // go through different filters based on submission type
    if (isset($_POST['choose']) and $_POST['choose'] !== "") {
        $choose = $_POST['choose'];
        // things to do and suggestions for the site need filters
        if ($choose === "things" or $choose === "suggestions") {
            //check for filtered words
            $reason = filteredWords($t);
            $t = replaceText($t);
        } else {
            if ($choose !== "spam") {
                exit;
            }
        }
        insertIntoDatabase($t, $choose, $ip, $con);
    }
    // end type filters
}
//end submission post
Example #4
0
function getDataSince($timestamp, $eggid, $identifier)
{
    global $chemical_weights;
    // database date format: Y-m-d\TH:i:s
    // http://www.lanuv.nrw.de/luft/temes/0326/VMS2.htm
    // http://www.lanuv.nrw.de/luft/temes/0326/MSGE.htm
    $day = date("md", $timestamp);
    echo "Fetch " . $day . "<br>";
    $url = "http://www.lanuv.nrw.de/luft/temes/" . $day . "/" . $identifier . ".htm";
    $content = file_get_contents($url);
    $dom = new DOMDocument();
    @$dom->loadHTML($content);
    // suppress parsing/invalid html errors
    $table = $dom->getElementsByTagName('table')->item(0);
    // first table = data value table
    $tbody = $table->getElementsByTagName('tbody')->item(0);
    $rows = $tbody->getElementsByTagName('tr');
    for ($i = 0; $i < $rows->length; $i++) {
        $cols = $rows->item($i)->getElementsByTagName('td');
        if (!$cols->item(1)) {
        } else {
            // skip rows with less than two columns
            $time = trim(utf8_decode($cols->item(0)->nodeValue));
            $datetime = date("Y-m-d", $timestamp) . " " . $time;
            $ozon = trim(utf8_decode($cols->item(3)->nodeValue));
            if ($ozon != "") {
                insertIntoDatabase($eggid, "o3", microgramPerMeterToPPB($ozon, $chemical_weights["o3"]), $datetime);
            }
            $no2 = trim(utf8_decode($cols->item(4)->nodeValue));
            if ($no2 != "") {
                insertIntoDatabase($eggid, "no2", microgramPerMeterToPPB($no2, $chemical_weights["no2"]), $datetime);
            }
            echo $datetime . " " . $ozon . " " . $no2 . "<br>";
        }
    }
}
Example #5
0
// create 2 tables
$sql = "SHOW TABLES LIKE meaning";
if (!mysqli_query($link, $sql)) {
    $sql = "CREATE TABLE meaning (tag int(4) unsigned NOT NULL, satMeaning TEXT NOT NULL)";
    if (mysqli_query($link, $sql)) {
        insertIntoDatabase($dict, "meaning", $link);
        //	echo "Table 'meaning' created successfully";
    } else {
        //	echo "Error creating table: " . mysqli_error($link);
    }
}
$sql = "SHOW TABLES LIKE word";
if (!mysqli_query($link, $sql)) {
    $sql = "CREATE TABLE word (tag int(4) unsigned NOT NULL, satWord varchar(20) NOT NULL)";
    if (mysqli_query($link, $sql)) {
        insertIntoDatabase($dict, "word", $link);
        //	echo mysqli_query($link, $sql);
        // echo "Table 'word' created successfully";
    } else {
        //   echo "Error creating table: " . mysqli_error($link);
    }
}
$satWordArr = array();
$satMeaningArr = array();
$sql = "SELECT tag, satWord FROM word";
$result = mysqli_query($link, $sql);
if (mysqli_num_rows($result) > 0) {
    // output data of each row
    while ($row = mysqli_fetch_assoc($result)) {
        $satWordArr[$row["tag"]] = $row["satWord"];
    }
Example #6
0
function parseEntry($entry)
{
    $entry['EditXML'] = destringify($entry['EditXML']);
    $xml = gzuncompress($entry['EditXML']);
    $xml = new SimpleXMLElement($xml);
    //print_r( $xml );
    insertIntoDatabase($entry['EditSource'], $entry['IsVandalism'], $xml);
}
        if ($cosmdata = fetchJsonFromCosm($row["cosmid"], $stream, $start)) {
            echo "JSON Download: <b>" . $start . "</b> - <b>" . $end . "</b><br>" . PHP_EOL;
            if (!isset($cosmdata['datapoints'])) {
                // if there are no datapoints and it's not "today",
                // then there's likely a data gap = no data from cosm for this day
                // guess where the next data could be by querying every day until today, or until data found
                $i = 0;
                while (!isset($cosmdata_['datapoints'])) {
                    $newstart = date("Y-m-d\\TH:i:s", strtotime($start) + 3600 * 24 * $i);
                    $newend = date("Y-m-d\\TH:i:s", strtotime($newstart) + 3600 * 24);
                    // +1 day
                    echo $i . ": " . $newstart . " - " . $newend . "<br>";
                    $i++;
                    flush();
                    if (strtotime($newstart) > time()) {
                        break;
                    }
                    $cosmdata_ = fetchJsonFromCosm($row["cosmid"], $stream, $newstart);
                }
                $cosmdata = $cosmdata_;
            }
            foreach ($cosmdata['datapoints'] as $datapoint) {
                insertIntoDatabase($row['eggid'], $stream, $datapoint['value'], $datapoint['at']);
            }
        } else {
            echo "Cosm API error." . PHP_EOL;
        }
        echo "<hr>";
    }
}
pg_close($dbconn);