Index: aetherlibs/DB.php =================================================================== --- /dev/null +++ aetherlibs/DB.php @@ -0,0 +1,38 @@ +. + */ + +require_once('db_auth.inc'); + +// Set the default timezone to use. +date_default_timezone_set('UTC'); + +/** + * Interface to the database + * @extends PDO + */ +class DB extends PDO { + + public function __construct() + { + // This global variables are imported from db_auth.inc + global $db_username; + global $db_password; + global $db_database; + + parent::__construct('mysql:host=localhost;dbname=' . $db_database, $db_username, $db_password); + } +} Index: aetherlibs/feeds.php =================================================================== --- aetherlibs/feeds.php +++ aetherlibs/feeds.php @@ -1,78 +1,109 @@ - * - * @author Ken Vermette - * @copyright 2017 Ken Vermette - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE - * License as published by the Free Software Foundation; either - * version 3 of the License, or any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU AFFERO GENERAL PUBLIC LICENSE for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - * - */ +/** +* News Lib +* +* @author Frank Karlitschek +* @copyright 2010 Frank Karlitschek karlitschek@kde.org +* +* @modifications Added default image fallback +* Improve code readability +* @author Sayak Banerjee +* @copyright 2010 Sayak Banerjee +* +* @author Ken Vermette +* @copyright 2017 Ken Vermette +* @copyright 2019 Carl Schwan +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE +* License as published by the Free Software Foundation; either +* version 3 of the License, or any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU AFFERO GENERAL PUBLIC LICENSE for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library. If not, see . +* +*/ +/** + * Extract feeds from database + */ +class Feeds +{ + /** + * @params int $count Number of news that need to be fetched + * @return array an array of news + */ + static function news(int $count): array + { + $output = []; + try { + $db = new DB(); + $stmt = $db->prepare('SELECT title, url, timestamp FROM news ORDER BY timestamp DESC LIMIT :count'); + $stmt->execute(['count' => $count]); + while ($row = $stmt->fetch()) { + $output[] = [ + 'title' => $row['title'], + 'time' => $row['timestamp'], + 'url' => $row['url'], + 'source' => 'news', + 'user' => 'KDE Community', + ]; + } + } catch (PDOException $e) { + print "Error!: " . $e->getMessage() . "
"; + } + return $output; + } -class Feeds -{ - static function news ($count) - { - $output = []; - $request = DB::query('SELECT title, url, timestamp FROM news ORDER BY timestamp DESC LIMIT '.$count); - $num = DB::numrows($request); - - for($x = 0; $x < $num; $x++) { - $data = DB::fetch_assoc($request); - $output[] = [ - 'title' => $data['title'], - 'time' => $data['timestamp'], - 'url' => $data['url'], - 'source' => 'news', - 'user' => 'KDE Community', - ]; - } - - DB::free_result($request); - return $output; - } - - - static function blog($count) - { - $output = []; - $request = DB::query('SELECT user, title, url, timestamp FROM blog ORDER BY timestamp DESC LIMIT ' . $count); - $num = DB::numrows($request); - - for($x = 0; $x < $num; $x++) { - $data = DB::fetch_assoc($request); - $output[] = [ - 'title' => $data['title'], - 'time' => $data['timestamp'], - 'url' => $data['url'], - 'source' => 'blog', - 'user' => $data['user'] - ]; - } - - DB::free_result($request); - return $output; - } + + /** + * @params int $count Number of blog posts that need to be fetched + * @return array an array of blog posts + * @deprecated + */ + static function blog(int $count): array + { + $output = []; + try { + $db = new DB(); + $stmt = $db->prepare('SELECT title, url, timestamp FROM blog ORDER BY timestamp DESC LIMIT :count'); + $stmt->execute(['count' => $count]); + + while ($row = $stmt->fetch()) { + $output[] = [ + 'title' => $row['title'], + 'time' => $row['timestamp'], + 'url' => $row['url'], + 'source' => 'blog', + 'user' => $row['user'], + ]; + } + } catch (PDOException $e) { + print "Error!: " . $e->getMessage() . "
"; + } + return $output; + } + + static function planet(int $count): array + { + $feed = simplexml_load_file('https://planet.kde.org/rss20.xml'); + $output = []; + if ($feed) { + for($i = 0 ; $i <= $count ; $i++) { + $item = $feed->channel->item[$i]; + $output[] = [ + 'title' => (string) $item->title, + 'url' => (string) $item->link, + ]; + } + } + return $output; + } } Index: community/donations/graph.php =================================================================== --- community/donations/graph.php +++ community/donations/graph.php @@ -2,7 +2,7 @@ require("donations_auth.inc"); -$year = mysql_real_escape_string( $_GET["year"] ); +$year = (int)$_GET["year"]; if ($year < 2001 || $year > 2020) { echo "year check failed"; exit(1); @@ -14,11 +14,11 @@ $data[ $year."-".$i_s ] = 0; } -$query = "select sum(amount) as don, DATE_FORMAT(date,\"%Y-%m\") as month from donations "; -$query .= "where year(date) = '".$_GET["year"]."' "; -$query .= "group by month order by month desc"; -$q = mysql_query($query,$sq); -while ($row = mysql_fetch_array($q)) { +$stmt = $dbConnection->prepare("SELECT SUM(amount) as don, DATE_FORMAT(date,\"%Y-%m\") as month from donations WHERE year(date) = ':year' GROUP BY month ORDER BY month DESC"; +$stmt->execute([ + 'year' => $year, +]); +while ($row = $stmt->fetch()) { $data[ $row["month"] ] = $row["don"]; } Index: community/donations/notify.php =================================================================== --- community/donations/notify.php +++ community/donations/notify.php @@ -60,7 +60,7 @@ } curl_close($ch); -if (strcmp ($res, "VERIFIED") == 0) { +if (strcmp ($res, "VERIFIED") === 0) { // assign posted variables to local variables $item_name = $_POST['item_name']; $item_number = $_POST['item_number']; @@ -85,15 +85,15 @@ */ // check the payment_status is Completed - if ( $payment_status != "Completed") { + if ( $payment_status !== "Completed") { if ($do_debug) { fwrite($debug, "Unexpected payment status: ".$payment_status."\n"); } die("Payment status is ".$payment_status); } // check that receiver_email is your Primary PayPal email - if ( $receiver_email != "kde-ev-board@kde.org") { + if ( $receiver_email !== "kde-ev-board@kde.org") { if ($do_debug) { fwrite($debug, "Unexpected receiver email: ".$receiver_email."\n"); } @@ -110,25 +110,28 @@ // sanitise date $date = strtotime( $_POST["payment_date"] ); - if ( $date === false ) { + if (!$date) { echo "Date parsing failed, assuming now()"; $date = time(); } $date = date("Y-m-d H:i:s", $date); // process payment - $query = "REPLACE into donations VALUES( '', \"".$date."\""; - $query .= ", ".$payment_amount.", \"".addslashes( $memo )."\""; - $query .= ",\"".$txn_id."\", \"".addslashes( $donate_url )."\" )"; - mysql_query($query, $sq); - + $stmt = $dbConnection->prepare("REPLACE into donations VALUES( '', \":date\", :payment_amount, \":memo\", \":txn_id\", \":donate_url\")"); + $stmt->execute([ + 'date' => $date, + 'payment_amount' => $payment_amount, + 'memo' => addslashes($memo), + 'txn_id' => $txn_id, + 'donate_url' => addslashes($donate_url), + ]); + if ($do_debug) { - fwrite( $debug, "\nQuery:".$query."\n" ); - fwrite( $debug, "Error:".mysql_error()."\n" ); + fwrite( $debug, "\nQuery:".$stmt->debugDumpParams()."\n" ); } -} else if (strcmp ($res, "INVALID") == 0) { +} else if (strcmp ($res, "INVALID") === 0) { if ($do_debug) { fwrite($debug, "Invalid transaction\n"); } Index: community/donations/previousdonations.php =================================================================== --- community/donations/previousdonations.php +++ community/donations/previousdonations.php @@ -28,29 +28,33 @@ prepare("SELECT *, UNIX_TIMESTAMP(date) AS date_t FROM donations WHERE date >= ':year-:month_s-01' AND date <= ':year-:month_s-31 23:59:59' ORDER BY date DESC;"); +$count = $dbConnection->prepare("SELECT COUNT(*) WHERE date >= ':year-:month_s-01' AND date <= ':year-:month_s-31 23:59:59';"); for ($year = date("Y", time()); $year > 2001; $year--) { echo "

$year

"; - echo "
"; + echo "
"; echo ""; echo "
"; echo "

"; for ($month = 12; $month >=1 ; $month--) { - $month < 10 ? $month_s = "0".$month : $month_s = $month; - $query = "select *,unix_timestamp(date) as date_t from donations "; - $query .= "where date >= '".$year."-".$month_s."-01' and "; - $query .= "date <= '".$year."-".$month_s."-31 23:59:59' order by date desc"; - # echo "
".$query."

"; - $q = mysql_query($query,$sq); - echo mysql_error(); - if (mysql_num_rows($q) == 0) { - continue; - } + # echo "
".$query."

"; + $count->execute([ + 'year' => $year, + 'month_s' => $month_s, + ]); + if ($count->fetchColumn() === 0) { + continue; + } + $q = $query->execute([ + 'year' => $year, + 'month_s' => $month_s, + ]); $total = 0; echo ""; echo ""; echo ""; - while ($row = mysql_fetch_array($q)) { + while ($row = $q->fetch()) { $msg = htmlentities($row["message"]); if ($msg == "") { $msg = "Anonymous donation"; Index: fundraisers/kdesprints2015/index.php =================================================================== --- fundraisers/kdesprints2015/index.php +++ fundraisers/kdesprints2015/index.php @@ -20,14 +20,13 @@ require("donations_auth.inc"); - $query = "select *,unix_timestamp(date) as date_t from randameetings2015donations order by date desc;"; - $q = mysql_query($query,$sq); - echo mysql_error(); + $res = $db->prepare("SELECT *, UNIX_TIMESTAMP(date) AS date_t FROM randameetings2015donations ORDER BY date DESC;"); + $res->execute(); $total = 0; $count = 0; $table = "
".date("Y - F", mktime(0,0,0,$month,1,$year))."
DateAmountMessage
"; $table.=""; - while ($row = mysql_fetch_array($q)) { + while ($row = $res->fetch()) { $msg = htmlspecialchars($row["message"]); if ($msg == "") { $msg = "Anonymous donation"; @@ -55,16 +54,16 @@

KDE Sprints 2015 fundraising

- + --> */ ?> €$total raised of a €$goal goal

"; echo "
"; echo "
" -?> - + -->*/ +?> The Randa Meetings 2015 Fundraiser has finished. Thank you everybody who supported us in this fundraiser. We didn't reach the set goal but we collected quite some money and that means there will be more KDE Sprints thanks to your support! See http://planet.kde.org for more information to come and go to the KDE donation page if you want to support us further. Index: fundraisers/kdesprints2015/notify.php =================================================================== --- fundraisers/kdesprints2015/notify.php +++ fundraisers/kdesprints2015/notify.php @@ -1,5 +1,7 @@ prepare("SELECT *, UNIX_TIMESTAMP(date) AS date_t FROM randameetings2014donations ORDER BY date DESC;"); + $res->execute(); $query = "select *,unix_timestamp(date) as date_t from randameetings2014donations order by date desc;"; - $q = mysql_query($query,$sq); - echo mysql_error(); $total = 0; $count = 0; $table = "
No.DateAmountDonor Name
"; $table.=""; - while ($row = mysql_fetch_array($q)) { + while ($row = $res->fetch()) { $msg = htmlspecialchars($row["message"]); if ($msg == "") { $msg = "Anonymous donation"; @@ -55,16 +55,15 @@

Randa Meetings 2014 fundraising

- +--> */ ?> €$total raised of a €$goal goal

"; echo "
"; echo "
" -?> - +--> */ ?> The Randa Meetings 2014 Fundraiser has finished. Thank you everybody who supported us in this fundraiser. We didn't reach the set goal but we collected quite some money and that means there is going to be Randa Meetings in August 2014. See http://planet.kde.org for more information to come and go to the KDE donation page if you want to support us further. Index: fundraisers/randameetings2014/notify.php =================================================================== --- fundraisers/randameetings2014/notify.php +++ fundraisers/randameetings2014/notify.php @@ -2,6 +2,8 @@ $do_debug = true; +die("Donation to the Randa Meeting 2014 are not supported anymore. See Donnations"); + // STEP 1: read POST data // Reading POSTed data directly from $_POST causes serialization issues with array data in the POST. Index: fundraisers/randameetings2016/index.php =================================================================== --- fundraisers/randameetings2016/index.php +++ fundraisers/randameetings2016/index.php @@ -30,13 +30,12 @@ require("donations_auth.inc"); - $query = "select *,unix_timestamp(date) as date_t from randameetings2016donations order by date desc;"; - $q = mysql_query($query,$sq); - echo mysql_error(); + $res = $db->prepare("SELECT *, UNIX_TIMESTAMP(date) AS date_t FROM randameetings2016donations ORDER BY date DESC;"); + $res->execute(); $total = 0; $count = 0; $table = ""; - while ($row = mysql_fetch_array($q)) { + while ($row = $res->fetch()) { $msg = htmlspecialchars($row["message"]); if ($msg == "") { $msg = "Anonymous donation"; @@ -164,7 +163,7 @@ "; ?> - + */ ?> Index: fundraisers/randameetings2016/notify.php =================================================================== --- fundraisers/randameetings2016/notify.php +++ fundraisers/randameetings2016/notify.php @@ -1,6 +1,7 @@ Donnations"); // STEP 1: read POST data Index: fundraisers/randameetings2016/stats.php =================================================================== --- fundraisers/randameetings2016/stats.php +++ fundraisers/randameetings2016/stats.php @@ -225,18 +225,17 @@ require("donations_auth.inc"); - $query = "select sum(amount) as amount_sum, count(*) donations, DATE_FORMAT(date, '%m%d') as date_fmt from randameetings2016donations group by DATE_FORMAT(date, '%m%d') ORDER BY DATE_FORMAT(date, '%m%d');"; - $q = mysql_query($query,$sq); - echo mysql_error(); + $stmt = $dbConnection->prepare("select sum(amount) as amount_sum, count(*) donations, DATE_FORMAT(date, '%m%d') as date_fmt from randameetings2016donations group by DATE_FORMAT(date, '%m%d') ORDER BY DATE_FORMAT(date, '%m%d');"); + $stmt->execute(); $labels2016 = ""; $values2016 = ""; $cumulativeAmount2016 = ""; $cumulativeAmount2016Value = 0; $cumulativeDonations2016 = ""; $cumulativeDonations2016Value = 0; $donations2016 = ""; $count = 1; - while ($row = mysql_fetch_array($q)) { + while ($row = $stmt->fetch()) { //$labels2016.=", ".$row["date_fmt"]; $labels2016.=", ".$count; $count++; @@ -253,18 +252,17 @@ $cumulativeDonations2016.=""; $donations2016.=""; - $query = "select sum(amount) as amount_sum, count(*) donations, DATE_FORMAT(date, '%m%d') as date_fmt from randameetings2015donations group by DATE_FORMAT(date, '%m%d') ORDER BY DATE_FORMAT(date, '%m%d');"; - $q = mysql_query($query,$sq); - echo mysql_error(); + $stmt = $dbConnection->prepare("select sum(amount) as amount_sum, count(*) donations, DATE_FORMAT(date, '%m%d') as date_fmt from randameetings2015donations group by DATE_FORMAT(date, '%m%d') ORDER BY DATE_FORMAT(date, '%m%d');"); + $stmt->execute(); $labels2015 = ""; $values2015 = ""; $cumulativeAmount2015 = ""; $cumulativeAmount2015Value = 0; $cumulativeDonations2015 = ""; $cumulativeDonations2015Value = 0; $donations2015 = ""; $count = 1; - while ($row = mysql_fetch_array($q)) { + while ($row = $stmt->fetch()) { //$labels2015.=", ".$row["date_fmt"]; $labels2015.=", ".$count; $count++; Index: fundraisers/randameetings2017/index.php =================================================================== --- fundraisers/randameetings2017/index.php +++ fundraisers/randameetings2017/index.php @@ -30,15 +30,17 @@ require_once("config.php"); - $stmt = $dbConnection->prepare("SELECT *, UNIX_TIMESTAMP(CREATED_AT) AS date_t FROM randameetings2017donations ORDER BY CREATED_AT DESC;") or die ($dbConnection->error); - $stmt->execute(); - $result = $stmt->get_result(); - $stmt->close(); + $countStmt = $dbConnection->prepare("SELECT COUNT(*) FROM randameetings2017donations ORDER BY CREATED_AT DESC;"); + $countStmt->execute(); + $n = $countStmt->fetchColumn(); + + $res = $dbConnection->prepare("SELECT *, UNIX_TIMESTAMP(CREATED_AT) AS date_t FROM randameetings2017donations ORDER BY CREATED_AT DESC;"); + $res->execute(); $total = 0; - $count = $result->num_rows; + $count = $n; $n = $count; $table = ""; - while ($row = mysqli_fetch_array($result)) { + while ($row = $res->fetch()) { $name = htmlspecialchars($row["donor_name"]); if ($name == "") $name = "Anonymous donation"; @@ -53,7 +55,7 @@ $n--; } $table.=""; - mysqli_close($dbConnection); + $dbConnection = null; $percent=round($total * 100 / $goal); $percent=min($percent, 100); $graph_style = "width: 100%; height: 30px; border: 1px solid #888; background: rgb(204,204,204); Index: fundraisers/randameetings2017/notify.php =================================================================== --- fundraisers/randameetings2017/notify.php +++ fundraisers/randameetings2017/notify.php @@ -1,6 +1,7 @@ Donnations"); require('paypalIPN.php'); Index: fundraisers/randameetings2017/stats.php =================================================================== --- fundraisers/randameetings2017/stats.php +++ fundraisers/randameetings2017/stats.php @@ -223,10 +223,8 @@ $daystogo=floor((strtotime($enddate)-time())/(60*60*24)); require("config.php"); - $stmt = $dbConnection->prepare("SELECT SUM(amount) AS amount_sum, count(*) donations, DATE_FORMAT(CREATED_AT, '%m%d') AS date_fmt FROM randameetings2017donations ORDER BY DATE_FORMAT(CREATED_AT, '%m%d');") or die ($dbConnection->error); + $stmt = $dbConnection->prepare("SELECT SUM(amount) AS amount_sum, count(*) donations, DATE_FORMAT(CREATED_AT, '%m%d') AS date_fmt FROM randameetings2017donations ORDER BY DATE_FORMAT(CREATED_AT, '%m%d');"); $stmt->execute(); - $result = $stmt->get_result(); - $stmt->close(); $labels2017 = ""; $values2017 = ""; @@ -236,7 +234,7 @@ $cumulativeDonations2017Value = 0; $donations2017 = ""; $count = 1; - while ($row = mysqli_fetch_array($result)) { + while ($row = $stmt->fetch()) { //$labels2017.=", ".$row["date_fmt"]; $labels2017.=", ".$count; $count++; @@ -255,8 +253,6 @@ $stmt = $dbConnection->prepare("SELECT SUM(amount) AS amount_sum, count(*) donations, DATE_FORMAT(date, '%m%d') AS date_fmt FROM randameetings2016donations ORDER BY DATE_FORMAT(date, '%m%d');") or die ($dbConnection->error); $stmt->execute(); - $result = $stmt->get_result(); - $stmt->close(); $labels2016 = ""; $values2016 = ""; @@ -266,7 +262,7 @@ $cumulativeDonations2016Value = 0; $donations2016 = ""; $count = 1; - while ($row = mysqli_fetch_array($result)) { + while ($row = $stmt->fetch()) { //$labels2016.=", ".$row["date_fmt"]; $labels2016.=", ".$count; $count++; Index: fundraisers/yearend2014/index.php =================================================================== --- fundraisers/yearend2014/index.php +++ fundraisers/yearend2014/index.php @@ -20,19 +20,16 @@ require("donations_auth.inc"); - $query = "select count(*) from yearend2014donations;"; - $q = mysql_query($query,$sq); - echo mysql_error(); - $row = mysql_fetch_array($q); - $index = $row[0]; - - $query = "select *,unix_timestamp(date) as date_t from yearend2014donations order by date desc;"; - $q = mysql_query($query,$sq); - echo mysql_error(); + $countStmt = $dbConnection->prepare("SELECT COUNT(*) FROM yearend2014donations ORDER BY CREATED_AT DESC;"); + $countStmt->execute(); + $n = $countStmt->fetchColumn(); + + $res = $dbConnection->prepare("SELECT *, UNIX_TIMESTAMP(CREATED_AT) AS date_t FROM yearend2014donations ORDER BY CREATED_AT DESC;"); + $res->execute(); $total = 0; $table = "
No.DateAmountDonor Name
"; $table.=""; - while ($row = mysql_fetch_array($q)) { + while ($row = $res->fetch()) { $msg = htmlspecialchars($row["message"]); if ($msg == "") { $msg = "".i18n_var("Anonymous donation").""; Index: fundraisers/yearend2016/index.php =================================================================== --- fundraisers/yearend2016/index.php +++ fundraisers/yearend2016/index.php @@ -18,19 +18,17 @@ require("donations_auth.inc"); + $countStmt = $dbConnection->prepare("SELECT COUNT(*) FROM yearend2016donations ORDER BY CREATED_AT DESC;"); + $countStmt->execute(); + $n = $countStmt->fetchColumn(); + + $res = $dbConnection->prepare("SELECT *, UNIX_TIMESTAMP(CREATED_AT) AS date_t FROM yearend2016donations ORDER BY CREATED_AT DESC;"); $query = "select count(*) from yearend2016donations;"; - $q = mysql_query($query,$sq); - echo mysql_error(); - $row = mysql_fetch_array($q); - $index = $row[0]; - - $query = "select *,unix_timestamp(date) as date_t from yearend2016donations order by date desc;"; - $q = mysql_query($query,$sq); - echo mysql_error(); + $total = 0; $table = "
".i18n_var("Date")."".i18n_var("Amount")."".i18n_var("Donor Name")."
"; $table.=""; - while ($row = mysql_fetch_array($q)) { + while ($row = $res->fetch()) { $msg = htmlspecialchars($row["message"]); if ($msg == "") { $msg = "".i18n_var("Anonymous donation").""; @@ -50,27 +48,26 @@ // This is select from select seems mysql specific? $query = "select MIN(sum_amount) from ( select sum(amount) as sum_amount from yearend2016donations group by email order by sum_amount DESC LIMIT 9 ) as tops;"; - $q = mysql_query($query,$sq); - echo mysql_error(); - $limit_amount = mysql_fetch_array($q)[0]; - - $query = "select * from ( select email, sum(amount) as sum_amount from yearend2016donations group by email order by sum_amount ) as tops where sum_amount >= ".$limit_amount." order by sum_amount DESC;"; - $q = mysql_query($query,$sq); - echo mysql_error(); + $limitStmt = $dbConnection->prepare($query); + $limitStmt->execute(); + $limit_amount = $limitStmt->fetchColumn(); + + $query = "select * from ( select email, sum(amount) as sum_amount from yearend2016donations group by email order by sum_amount ) as tops where sum_amount >= :limit_amount order by sum_amount DESC;"; + $q = $dbConnection->prepare($query); + $q->execute(['limit_amount' => $limit_amount]); $top9table = "
".i18n_var("Date")."".i18n_var("Amount")."".i18n_var("Donor Name")."
"; $top9table.=""; $count = 0; $last_amount = -1; $last_was_same_amount = false; - while ($row = mysql_fetch_array($q)) { + $q2 = $dbConnection->prepare('select distinct message as name from yearend2016donations where email=:email'); + while ($row = $q->fetch()) { $amount = $row["sum_amount"]; $email = $row['email']; - $query2 = "select distinct message as name from yearend2016donations where email='".$email."';"; - $q2 = mysql_query($query2,$sq); - echo mysql_error(); + $q2->execute(['email' => $email]); $donation_count = 0; - while ($row2 = mysql_fetch_array($q2)) { + while ($row2 = $q2-fetch()) { $msg = $row2["name"]; $donation_count++; } Index: fundraisers/yearend2017/config.php.dist =================================================================== --- fundraisers/yearend2017/config.php.dist +++ fundraisers/yearend2017/config.php.dist @@ -5,6 +5,11 @@ $dbuser = 'root'; $dbpass = 'root'; $dbname = 'endofyear'; -$dbConnection = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname) or die (mysqli_connect_error()); +try { + $dbConnection = new PDO('mysql:host=' . $dbhost . ';dbname=' . $dbname, $dbuser, $dbpass); +} catch (PDOException $e) { + print "Error!: " . $e->getMessage() . "
"; + die(); +} ?> Index: fundraisers/yearend2017/index.php =================================================================== --- fundraisers/yearend2017/index.php +++ fundraisers/yearend2017/index.php @@ -88,17 +88,15 @@ prepare("SELECT *, UNIX_TIMESTAMP(CREATED_AT) AS date_t FROM endofyear2017donations ORDER BY CREATED_AT DESC;") or die($dbConnection->error); - $stmt->execute(); - $result = $stmt->get_result(); - $stmt->close(); - $count = $result->num_rows; - ?> - prepare("SELECT COUNT(*) FROM endofyear2017donations ORDER BY CREATED_AT DESC;"); + $countStmt->execute(); + $n = $countStmt->fetchColumn(); + + $res = $dbConnection->prepare("SELECT *, UNIX_TIMESTAMP(CREATED_AT) AS date_t FROM endofyear2017donations ORDER BY CREATED_AT DESC;"); + $res->execute(); $total = 0; - $n = $count; $table = ""; - while ($row = mysqli_fetch_array($result)) { + while ($row = $res->fetch()) { $name = htmlspecialchars($row["donor_name"]); if ($name == "") { $name = "Anonymous donation"; @@ -113,8 +111,7 @@ $table.=""; $n--; } - $table.=""; - mysqli_close($dbConnection); + $dbConnection = null; $goal_fmt=number_format(20000); $goal=20000; $percent=round($total * 100 / $goal); Index: index.php =================================================================== --- index.php +++ index.php @@ -8,11 +8,8 @@ require('aether/header.php'); - if (@include_once("libs/class_db.php")) { + if (@include_once("aetherlibs/DB.php")) { define("FRONTPAGE_LIVE_FEED", true); - } - - if (defined("FRONTPAGE_LIVE_FEED")) { require_once('users_conf.php'); require_once('aetherlibs/functions.php'); require_once("aetherlibs/feeds.php"); @@ -155,7 +152,7 @@

News

-
    +

      Community Blog Posts

      - - '; - for( $i= 0 ; $i <= 3 ; $i++ ) { - $item = $feed->channel->item[$i]; - $title = (string) $item->title; - $url = (string) $item->link; - - printf( - '
    • %s
    • ', - $url, - $title - ); - }; - print '
    '; - } - ?> +
      + %s', + htmlspecialchars($item['url']), + htmlspecialchars($item['title']) + ); + } + ?> +
    🌍 Read our blogs on Planet KDE
".i18n_var("Total Amount")."".i18n_var("Donor Name")."