unset($_POST['school']); $comp = filter_var($_POST['comprehensive'], FILTER_SANITIZE_NUMBER_INT); unset($_POST['comprehensive']); $algebra = filter_var($_POST['algebra'], FILTER_SANITIZE_NUMBER_INT); unset($_POST['algebra']); $geometry = filter_var($_POST['geometry'], FILTER_SANITIZE_NUMBER_INT); unset($_POST['geometry']); $total = filter_var($_POST['total'], FILTER_SANITIZE_NUMBER_INT); unset($_POST['total']); //array containing sponsors information $sponsorsInfo = array(); $sponsorsInfo = array_values($_POST); //indexed array $numOfSponsors = count($sponsorsInfo) / 3; //total sponsors addToDB($sponsorsInfo, $numOfSponsors); $message = getMessage($numOfSponsors); sendReciept($message); //email confirmation echo $message; //output receipt to browser /************************************************************************************ This serves as the thank you page and the receipt that gets sent to the sponsors email *************************************************************************************/ function getMessage($numOfSponsors) { global $sponsorsInfo, $division, $testingSite, $school, $comp, $algebra, $geometry, $total; //$sponsors = implode(" ",$sponsorsInfo); $message = "\n\t<DOCTYPE! html>\n\t<head>\n\t<meta charset='utf-8'>\n\t<title>Alabama State High School Math Contest 2015 Registration</title>\n\t<link rel='stylesheet' href='math_contest.css'>\n\t<script src = 'math_contest.js'></script>\n\t</head> \n<body>\n\t<p>Sponsors <br />"; foreach ($sponsorsInfo as $key => $value) { $message = $message . $value . "<br />";
<?php $ip = "{$_SERVER['REMOTE_ADDR']}"; $time = date('Y-m-d H:i:s'); $session = "1"; $message = $_POST['message']; #Används för att lägga till data i databasen. Databasen heter test.db. Valde att använda mig av SQLite3 då jag #Tycker att det är väldigt smidigt. addToDB($ip, $time, $session, $message); class MyDB extends SQLite3 { function __construct() { $this->open('test.db'); } } function addToDB($ip, $time, $session, $message) { $db = new MyDB(); if (!$db) { echo $db->lastErrorMsg(); } else { echo "Opened database successfully\n"; } $sql = <<<EOF INSERT INTO test (ip,time,session,message) VALUES('{$ip}', '{$time}', '{$session}', '{$message}'); EOF; $ret = $db->exec($sql); if (!$ret) {
// in mysql addToDB('6', 'Bodylab', 'Whey Pro', '2,0kg', $bl2kg); // HTML ophalen Powersupplements $html->load_file('http://www.powersupplements.nl/pure-whey-protein-isolate-2500g-38'); // Onnodige info weg, die schrijven wij er zelf bij // array maken voor info die wij er uit gaan laten $pattern = array("/Prijs: /"); // $pattern vervangen door niks $html = preg_replace($pattern, '', $html); // DOM object maken van een string $html = str_get_html($html); // Prijs ophalen van Powersupplements Whey Isolate dmv <td class=main_table> // 2,5kg isolaat $ps25kg = $html->find('td[class=main_table]', 0)->innertext; // in mysql addToDB('7', 'Powersupplements', 'Whey Isolate', '2,5kg', $ps25kg); } catch (PDOException $e) { echo '<pre>'; echo 'Regelnummer: ' . $e->getLine() . '<br>'; echo 'Bestand: ' . $e->getFile() . '<br>'; echo 'Foutmelding: ' . $e->getMessage() . '<br>'; echo '</pre>'; } } elseif (isset($_POST['view'])) { $result = $oPDO->query("SELECT D_id,D_producent,D_product,D_gewicht,D_prijs FROM T_supplementen ORDER BY D_id"); echo <<<END <table align="center" border="1"> <tr> <td><b>ID</b></td> <td><b>Producent</b></td> <td><b>Product</b></td>
<?php include "../../wp-load.php"; include "rss.class.php"; $sql = "select * from " . $table_prefix . "newstracker"; $result = $wpdb->get_results($sql); if (is_array($result) && count($result) >= 1) { foreach ($result as $tracker) { $rss = new RSSReader($tracker->url); while ($rss->hasNext()) { $rssdata = $rss->next(); $url = $rssdata["link"]; $title = $rssdata["title"]; $desc = $rssdata["description"]; $pub = $rssdata["pubDate"]; $hash = sha1($url . $title . $pub); $data = array("hash" => $hash); $sql = "select * from " . $table_prefix . "news_verify WHERE hash ='" . $hash . "'"; $result = $wpdb->get_row($sql); if (!is_array($result) && count($result) <= 0) { $res = $wpdb->insert($table_prefix . "news_verify", $data); $returndata = addToDB($rssdata); /*echo $returndata;*/ } else { /*print_r("0");*/ } unset($hash); } } }