diff --git a/dwpost/dwpost.php b/dwpost/dwpost.php index 24bdcdbb..b0d68e84 100644 --- a/dwpost/dwpost.php +++ b/dwpost/dwpost.php @@ -13,6 +13,7 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\L10n; use Friendica\Core\PConfig; +use Friendica\Database\DBM; use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; @@ -170,17 +171,19 @@ function dwpost_send(App $a, array &$b) { $tz = 'UTC'; - $x = q("select timezone from user where uid = %d limit 1", + $x = q("SELECT `timezone` FROM `user` WHERE `uid`=%d LIMIT 1", intval($b['uid']) ); - if($x && strlen($x[0]['timezone'])) + + if (DBM::is_result($x) && strlen($x[0]['timezone'])) { $tz = $x[0]['timezone']; + } $dw_username = PConfig::get($b['uid'],'dwpost','dw_username'); $dw_password = PConfig::get($b['uid'],'dwpost','dw_password'); $dw_blog = 'http://www.dreamwidth.org/interface/xmlrpc'; - if($dw_username && $dw_password && $dw_blog) { + if ($dw_username && $dw_password && $dw_blog) { $title = $b['title']; $post = BBCode::convert($b['body']); $post = xmlify($post); diff --git a/geocoordinates/geocoordinates.php b/geocoordinates/geocoordinates.php index 9b70e19b..1df5bbe5 100644 --- a/geocoordinates/geocoordinates.php +++ b/geocoordinates/geocoordinates.php @@ -28,7 +28,7 @@ function geocoordinates_uninstall() function geocoordinates_resolve_item(array &$item) { - if (!isset($item['coord']) || isset($item['location'])) { + if (empty($item['coord']) || !empty($item['location'])) { return; } @@ -38,7 +38,7 @@ function geocoordinates_resolve_item(array &$item) return; } - $language = Config::get("geocoordinates", "language"); + $language = Config::get("geocoordinates", "language", "de"); if ($language == "") { $language = "de"; @@ -62,7 +62,7 @@ function geocoordinates_resolve_item(array &$item) $s = Network::fetchUrl("https://api.opencagedata.com/geocode/v1/json?q=".$coords[0].",".$coords[1]."&key=".$key."&language=".$language); - if ($s === FALSE) { + if ($s === FALSE || empty($s)) { logger("API could not be queried", LOGGER_DEBUG); return; } @@ -83,8 +83,9 @@ function geocoordinates_resolve_item(array &$item) logger("Got location for coordinates ".$coords[0]."-".$coords[1].": ".$item["location"], LOGGER_DEBUG); - if ($item["location"] != "") + if ($item["location"] != "") { Cache::set("geocoordinates:".$language.":".$coords[0]."-".$coords[1], $item["location"]); + } } function geocoordinates_post_hook(App $a, array &$item) diff --git a/ijpost/ijpost.php b/ijpost/ijpost.php index 0957bb91..e6eff3d8 100644 --- a/ijpost/ijpost.php +++ b/ijpost/ijpost.php @@ -13,6 +13,7 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\L10n; use Friendica\Core\PConfig; +use Friendica\Database\DBM; use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; @@ -168,17 +169,19 @@ function ijpost_send(App $a, array &$b) { $tz = 'UTC'; - $x = q("select timezone from user where uid = %d limit 1", + $x = q("SELECT `timezone` FROM `user` WHERE `uid`=%d LIMIT 1", intval($b['uid']) ); - if($x && strlen($x[0]['timezone'])) + + if (DBM::is_result($x) && strlen($x[0]['timezone'])) { $tz = $x[0]['timezone']; + } $ij_username = PConfig::get($b['uid'],'ijpost','ij_username'); $ij_password = PConfig::get($b['uid'],'ijpost','ij_password'); $ij_blog = 'http://www.insanejournal.com/interface/xmlrpc'; - if($ij_username && $ij_password && $ij_blog) { + if ($ij_username && $ij_password && $ij_blog) { $title = $b['title']; $post = BBCode::convert($b['body']); $post = xmlify($post); diff --git a/ljpost/ljpost.php b/ljpost/ljpost.php index cb4f3f23..e9821544 100644 --- a/ljpost/ljpost.php +++ b/ljpost/ljpost.php @@ -13,6 +13,7 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\L10n; use Friendica\Core\PConfig; +use Friendica\Database\DBM; use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; @@ -163,11 +164,13 @@ function ljpost_send(App $a, array &$b) { $tz = 'UTC'; - $x = q("select timezone from user where uid = %d limit 1", + $x = q("SELECT `timezone` FROM `user` WHERE `uid` = %d LIMIT 1", intval($b['uid']) ); - if($x && strlen($x[0]['timezone'])) + + if (DBM::is_result($x) && strlen($x[0]['timezone'])) { $tz = $x[0]['timezone']; + } $lj_username = xmlify(PConfig::get($b['uid'],'ljpost','lj_username')); $lj_password = xmlify(PConfig::get($b['uid'],'ljpost','lj_password')); @@ -176,10 +179,11 @@ function ljpost_send(App $a, array &$b) { // $lj_journal = $lj_username; $lj_blog = xmlify(PConfig::get($b['uid'],'ljpost','lj_blog')); - if(! strlen($lj_blog)) + if (! strlen($lj_blog)) { $lj_blog = xmlify('http://www.livejournal.com/interface/xmlrpc'); + } - if($lj_username && $lj_password && $lj_blog) { + if ($lj_username && $lj_password && $lj_blog) { $title = xmlify($b['title']); $post = BBCode::convert($b['body']); $post = xmlify($post); diff --git a/testdrive/testdrive.php b/testdrive/testdrive.php index 8ec5703e..16c21554 100644 --- a/testdrive/testdrive.php +++ b/testdrive/testdrive.php @@ -63,8 +63,8 @@ function testdrive_register_account($a,$b) { function testdrive_cron($a,$b) { require_once('include/enotify.php'); - $r = q("select * from user where account_expires_on < UTC_TIMESTAMP() + INTERVAL 5 DAY and - expire_notification_sent = '0000-00-00 00:00:00' "); + $r = q("SELECT * FROM `user` WHERE `account_expires_on` < UTC_TIMESTAMP() + INTERVAL 5 DAY AND + `expire_notification_sent` = '0000-00-00 00:00:00'"); if (DBM::is_result($r)) { foreach($r as $rr) { @@ -80,15 +80,14 @@ function testdrive_cron($a,$b) { 'source_photo' => $a->get_baseurl() . '/images/person-80.jpg', ]); - q("update user set expire_notification_sent = '%s' where uid = %d", + q("UPDATE `user` SET `expire_notification_sent`='%s' WHERE `uid`=%d", dbesc(DateTimeFormat::utcNow()), intval($rr['uid']) ); - } } - $r = q("select * from user where account_expired = 1 and account_expires_on < UTC_TIMESTAMP() - INTERVAL 5 DAY "); + $r = q("SELECT * FROM `user` WHERE `account_expired`=1 AND `account_expires_on` < UTC_TIMESTAMP() - INTERVAL 5 DAY"); if (DBM::is_result($r)) { foreach($r as $rr) {