More usage of dbm::is_result($r) instead of count($r):

- count() returns very different results and never a boolean (not even false on
  error condition).
- therefore you should NOT use it in boolean expressions. This still *can* be
  done in PHP because of its lazyness. But it is discouraged if it comes to
  more clean code.

Signed-off-by: Roland Häder <roland@mxchange.org>
This commit is contained in:
Roland Häder 2016-12-13 10:44:13 +01:00
parent 293436e5fd
commit 6a8a36f12d
115 changed files with 439 additions and 437 deletions

View File

@ -64,7 +64,7 @@ function contact_remove($id) {
$r = q("select uid from contact where id = %d limit 1", $r = q("select uid from contact where id = %d limit 1",
intval($id) intval($id)
); );
if((! count($r)) || (! intval($r[0]['uid']))) if((! dbm::is_result($r)) || (! intval($r[0]['uid'])))
return; return;
$archive = get_pconfig($r[0]['uid'], 'system','archive_removed_contacts'); $archive = get_pconfig($r[0]['uid'], 'system','archive_removed_contacts');
@ -249,7 +249,7 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) {
FROM `gcontact` WHERE `nurl` = '%s'", FROM `gcontact` WHERE `nurl` = '%s'",
dbesc(normalise_link($url))); dbesc(normalise_link($url)));
if ($r) { if (dbm::is_result($r)) {
// If there is more than one entry we filter out the connector networks // If there is more than one entry we filter out the connector networks
if (count($r) > 1) { if (count($r) > 1) {
foreach ($r AS $id => $result) { foreach ($r AS $id => $result) {
@ -435,7 +435,7 @@ function random_profile() {
ORDER BY rand() LIMIT 1", ORDER BY rand() LIMIT 1",
dbesc(NETWORK_DFRN)); dbesc(NETWORK_DFRN));
if(count($r)) if(dbm::is_result($r))
return dirname($r[0]['url']); return dirname($r[0]['url']);
return ''; return '';
} }

View File

@ -33,7 +33,7 @@ class Config {
$a = get_app(); $a = get_app();
$r = q("SELECT `v`, `k` FROM `config` WHERE `cat` = '%s' ORDER BY `cat`, `k`, `id`", dbesc($family)); $r = q("SELECT `v`, `k` FROM `config` WHERE `cat` = '%s' ORDER BY `cat`, `k`, `id`", dbesc($family));
if (count($r)) { if (dbm::is_result($r)) {
foreach ($r as $rr) { foreach ($r as $rr) {
$k = $rr['k']; $k = $rr['k'];
if ($family === 'config') { if ($family === 'config') {

View File

@ -33,7 +33,7 @@ class PConfig {
dbesc($family), dbesc($family),
intval($uid) intval($uid)
); );
if (count($r)) { if (dbm::is_result($r)) {
foreach ($r as $rr) { foreach ($r as $rr) {
$k = $rr['k']; $k = $rr['k'];
$a->config[$uid][$family][$k] = $rr['v']; $a->config[$uid][$family][$k] = $rr['v'];

View File

@ -1084,7 +1084,7 @@ class Probe {
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1", intval($uid)); $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1", intval($uid));
if(count($x) && count($r)) { if(dbm::is_result($x) && dbm::is_result($r)) {
$mailbox = construct_mailbox_name($r[0]); $mailbox = construct_mailbox_name($r[0]);
$password = ''; $password = '';
openssl_private_decrypt(hex2bin($r[0]['pass']), $password,$x[0]['prvkey']); openssl_private_decrypt(hex2bin($r[0]['pass']), $password,$x[0]['prvkey']);

View File

@ -33,7 +33,7 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) {
call_hooks($a->module . '_pre_' . $selname, $arr); call_hooks($a->module . '_pre_' . $selname, $arr);
if(count($r)) { if(dbm::is_result($r)) {
foreach($r as $rr) { foreach($r as $rr) {
if((is_array($preselected)) && in_array($rr['id'], $preselected)) if((is_array($preselected)) && in_array($rr['id'], $preselected))
$selected = " selected=\"selected\" "; $selected = " selected=\"selected\" ";
@ -144,7 +144,7 @@ function contact_selector($selname, $selclass, $preselected = false, $options) {
call_hooks($a->module . '_pre_' . $selname, $arr); call_hooks($a->module . '_pre_' . $selname, $arr);
if(count($r)) { if(dbm::is_result($r)) {
foreach($r as $rr) { foreach($r as $rr) {
if((is_array($preselected)) && in_array($rr['id'], $preselected)) if((is_array($preselected)) && in_array($rr['id'], $preselected))
$selected = " selected=\"selected\" "; $selected = " selected=\"selected\" ";
@ -220,7 +220,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
$receiverlist = array(); $receiverlist = array();
if(count($r)) { if(dbm::is_result($r)) {
foreach($r as $rr) { foreach($r as $rr) {
if((is_array($preselected)) && in_array($rr['id'], $preselected)) if((is_array($preselected)) && in_array($rr['id'], $preselected))
$selected = " selected=\"selected\" "; $selected = " selected=\"selected\" ";
@ -314,7 +314,7 @@ function populate_acl($user = null, $show_jotnets = false) {
$r = q("SELECT `pubmail` FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1", $r = q("SELECT `pubmail` FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1",
intval(local_user()) intval(local_user())
); );
if(count($r)) { if(dbm::is_result($r)) {
$mail_enabled = true; $mail_enabled = true;
if(intval($r[0]['pubmail'])) if(intval($r[0]['pubmail']))
$pubmail_enabled = true; $pubmail_enabled = true;
@ -577,7 +577,7 @@ function acl_lookup(&$a, $out_type = 'json') {
$r = array(); $r = array();
if(count($r)) { if(dbm::is_result($r)) {
foreach($r as $g){ foreach($r as $g){
$contacts[] = array( $contacts[] = array(
"type" => "c", "type" => "c",
@ -612,7 +612,7 @@ function acl_lookup(&$a, $out_type = 'json') {
dbesc($search), dbesc($search),
implode("','", $known_contacts) implode("','", $known_contacts)
); );
if (is_array($r) && count($r)){ if (dbm::is_result($r)){
foreach($r as $row) { foreach($r as $row) {
// nickname.. // nickname..
$up = parse_url($row['author-link']); $up = parse_url($row['author-link']);

View File

@ -208,7 +208,7 @@
dbesc(trim($user)), dbesc(trim($user)),
dbesc($encrypted) dbesc($encrypted)
); );
if(count($r)) if(dbm::is_result($r))
$record = $r[0]; $record = $r[0];
} }
@ -1326,10 +1326,10 @@
if (isset($_GET["q"])) { if (isset($_GET["q"])) {
$r = q("SELECT id FROM `contact` WHERE `uid` = 0 AND `name` = '%s'", dbesc($_GET["q"])); $r = q("SELECT id FROM `contact` WHERE `uid` = 0 AND `name` = '%s'", dbesc($_GET["q"]));
if (!count($r)) if (!dbm::is_result($r))
$r = q("SELECT `id` FROM `contact` WHERE `uid` = 0 AND `nick` = '%s'", dbesc($_GET["q"])); $r = q("SELECT `id` FROM `contact` WHERE `uid` = 0 AND `nick` = '%s'", dbesc($_GET["q"]));
if (count($r)) { if (dbm::is_result($r)) {
$k = 0; $k = 0;
foreach ($r AS $user) { foreach ($r AS $user) {
$user_info = api_get_user($a, $user["id"], "json"); $user_info = api_get_user($a, $user["id"], "json");
@ -3174,7 +3174,7 @@
intval(api_user()) intval(api_user())
); );
if ((! count($r)) || ($r[0]['network'] !== NETWORK_DFRN)) if ((! dbm::is_result($r)) || ($r[0]['network'] !== NETWORK_DFRN))
throw new BadRequestException("Unknown contact"); throw new BadRequestException("Unknown contact");
$cid = $r[0]['id']; $cid = $r[0]['id'];
@ -3526,7 +3526,7 @@
intval($uid), intval($uid),
intval($gid)); intval($gid));
// error message if specified gid is not in database // error message if specified gid is not in database
if (count($r) == 0) if (!dbm::is_result($r))
throw new BadRequestException("gid not available"); throw new BadRequestException("gid not available");
} }
else else
@ -3581,7 +3581,7 @@
intval($uid), intval($uid),
intval($gid)); intval($gid));
// error message if specified gid is not in database // error message if specified gid is not in database
if (count($r) == 0) if (!dbm::is_result($r))
throw new BadRequestException('gid not available'); throw new BadRequestException('gid not available');
// get data of the specified group id and group name // get data of the specified group id and group name
@ -3919,7 +3919,9 @@
$profile_url = $user_info["url"]; $profile_url = $user_info["url"];
// message if nothing was found // message if nothing was found
if (count($r) == 0) if (!dbm::is_result($r))
$success = array('success' => false, 'search_results' => 'problem with query');
else if (count($r) == 0)
$success = array('success' => false, 'search_results' => 'nothing found'); $success = array('success' => false, 'search_results' => 'nothing found');
else { else {
$ret = Array(); $ret = Array();
@ -3966,7 +3968,7 @@
intval(api_user()), intval(api_user()),
intval($profileid)); intval($profileid));
// error message if specified gid is not in database // error message if specified gid is not in database
if (count($r) == 0) if (!dbm::is_result($r))
throw new BadRequestException("profile_id not available"); throw new BadRequestException("profile_id not available");
} }
else else

View File

@ -50,7 +50,7 @@ if (isset($_SESSION) && x($_SESSION,'authenticated') && (!x($_POST,'auth-params'
$r = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1", $r = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
intval($_SESSION['visitor_id']) intval($_SESSION['visitor_id'])
); );
if (count($r)) { if (dbm::is_result($r)) {
$a->contact = $r[0]; $a->contact = $r[0];
} }
} }
@ -73,7 +73,7 @@ if (isset($_SESSION) && x($_SESSION,'authenticated') && (!x($_POST,'auth-params'
intval($_SESSION['uid']) intval($_SESSION['uid'])
); );
if (!count($r)) { if (!dbm::is_result($r)) {
nuke_session(); nuke_session();
goaway(z_root()); goaway(z_root());
} }
@ -169,7 +169,7 @@ if (isset($_SESSION) && x($_SESSION,'authenticated') && (!x($_POST,'auth-params'
dbesc(trim($_POST['username'])), dbesc(trim($_POST['username'])),
dbesc($encrypted) dbesc($encrypted)
); );
if (count($r)) if (dbm::is_result($r))
$record = $r[0]; $record = $r[0];
} }

View File

@ -12,7 +12,7 @@ function contact_profile_assign($current,$foreign_net) {
$r = q("SELECT `id`, `profile-name` FROM `profile` WHERE `uid` = %d", $r = q("SELECT `id`, `profile-name` FROM `profile` WHERE `uid` = %d",
intval($_SESSION['uid'])); intval($_SESSION['uid']));
if(count($r)) { if(dbm::is_result($r)) {
foreach($r as $rr) { foreach($r as $rr) {
$selected = (($rr['id'] == $current) ? " selected=\"selected\" " : ""); $selected = (($rr['id'] == $current) ? " selected=\"selected\" " : "");
$o .= "<option value=\"{$rr['id']}\" $selected >{$rr['profile-name']}</option>\r\n"; $o .= "<option value=\"{$rr['id']}\" $selected >{$rr['profile-name']}</option>\r\n";

View File

@ -93,7 +93,7 @@ function networks_widget($baseurl,$selected = '') {
); );
$nets = array(); $nets = array();
if(count($r)) { if(dbm::is_result($r)) {
require_once('include/contact_selectors.php'); require_once('include/contact_selectors.php');
foreach($r as $rr) { foreach($r as $rr) {
if($rr['network']) if($rr['network'])
@ -204,13 +204,13 @@ function common_friends_visitor_widget($profile_uid) {
dbesc(normalise_link(get_my_url())), dbesc(normalise_link(get_my_url())),
intval($profile_uid) intval($profile_uid)
); );
if(count($r)) if(dbm::is_result($r))
$cid = $r[0]['id']; $cid = $r[0]['id'];
else { else {
$r = q("select id from gcontact where nurl = '%s' limit 1", $r = q("select id from gcontact where nurl = '%s' limit 1",
dbesc(normalise_link(get_my_url())) dbesc(normalise_link(get_my_url()))
); );
if(count($r)) if(dbm::is_result($r))
$zcid = $r[0]['id']; $zcid = $r[0]['id'];
} }
} }

View File

@ -109,7 +109,7 @@ function localize_item(&$item){
$r = q("SELECT * from `item`,`contact` WHERE $r = q("SELECT * from `item`,`contact` WHERE
`item`.`contact-id`=`contact`.`id` AND `item`.`uri`='%s';", `item`.`contact-id`=`contact`.`id` AND `item`.`uri`='%s';",
dbesc($item['parent-uri'])); dbesc($item['parent-uri']));
if(count($r)==0) return; if(!dbm::is_result($r)) return;
$obj=$r[0]; $obj=$r[0];
$author = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]'; $author = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
@ -245,7 +245,7 @@ function localize_item(&$item){
$r = q("SELECT * from `item`,`contact` WHERE $r = q("SELECT * from `item`,`contact` WHERE
`item`.`contact-id`=`contact`.`id` AND `item`.`uri`='%s';", `item`.`contact-id`=`contact`.`id` AND `item`.`uri`='%s';",
dbesc($item['parent-uri'])); dbesc($item['parent-uri']));
if(count($r)==0) return; if(!dbm::is_result($r)) return;
$obj=$r[0]; $obj=$r[0];
$author = '[url=' . zrl($item['author-link']) . ']' . $item['author-name'] . '[/url]'; $author = '[url=' . zrl($item['author-link']) . ']' . $item['author-name'] . '[/url]';
@ -294,7 +294,7 @@ function localize_item(&$item){
dbesc($obj->id), dbesc($obj->id),
intval($item['uid']) intval($item['uid'])
); );
if(count($r) && $r[0]['plink']) { if(dbm::is_result($r) && $r[0]['plink']) {
$target = $r[0]; $target = $r[0];
$Bname = $target['author-name']; $Bname = $target['author-name'];
$Blink = $target['author-link']; $Blink = $target['author-link'];

View File

@ -552,7 +552,7 @@ function update_contact_birthdays() {
// In-network birthdays are handled within local_delivery // In-network birthdays are handled within local_delivery
$r = q("SELECT * FROM contact WHERE `bd` != '' AND `bd` != '0000-00-00' AND SUBSTRING(`bd`,1,4) != `bdyear` "); $r = q("SELECT * FROM contact WHERE `bd` != '' AND `bd` != '0000-00-00' AND SUBSTRING(`bd`,1,4) != `bdyear` ");
if(count($r)) { if(dbm::is_result($r)) {
foreach($r as $rr) { foreach($r as $rr) {
logger('update_contact_birthday: ' . $rr['bd']); logger('update_contact_birthday: ' . $rr['bd']);

View File

@ -53,7 +53,7 @@ function delivery_run(&$argv, &$argc){
dbesc($item_id), dbesc($item_id),
dbesc($contact_id) dbesc($contact_id)
); );
if (!count($r)) { if (!dbm::is_result($r)) {
continue; continue;
} }
@ -131,7 +131,7 @@ function delivery_run(&$argv, &$argc){
intval($item_id) intval($item_id)
); );
if ((!count($r)) || (!intval($r[0]['parent']))) { if ((!dbm::is_result($r)) || (!intval($r[0]['parent']))) {
continue; continue;
} }
@ -184,7 +184,7 @@ function delivery_run(&$argv, &$argc){
intval($uid) intval($uid)
); );
if (!count($r)) if (!dbm::is_result($r))
continue; continue;
$owner = $r[0]; $owner = $r[0];
@ -254,7 +254,7 @@ function delivery_run(&$argv, &$argc){
intval($contact_id) intval($contact_id)
); );
if (count($r)) if (dbm::is_result($r))
$contact = $r[0]; $contact = $r[0];
if ($contact['self']) if ($contact['self'])
@ -423,7 +423,7 @@ function delivery_run(&$argv, &$argc){
intval($argv[2]), intval($argv[2]),
intval($uid) intval($uid)
); );
if (count($r)) if (dbm::is_result($r))
$it = $r[0]; $it = $r[0];
} }
if (!$it) if (!$it)
@ -478,14 +478,14 @@ function delivery_run(&$argv, &$argc){
dbesc($it['parent-uri']), dbesc($it['parent-uri']),
intval($uid)); intval($uid));
if (count($r) AND ($r[0]['title'] != '')) if (dbm::is_result($r) AND ($r[0]['title'] != ''))
$subject = $r[0]['title']; $subject = $r[0]['title'];
else { else {
$r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d LIMIT 1", $r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($it['parent-uri']), dbesc($it['parent-uri']),
intval($uid)); intval($uid));
if (count($r) AND ($r[0]['title'] != '')) if (dbm::is_result($r) AND ($r[0]['title'] != ''))
$subject = $r[0]['title']; $subject = $r[0]['title'];
} }
} }

View File

@ -105,7 +105,7 @@ class dfrn {
dbesc($owner_nick) dbesc($owner_nick)
); );
if(! count($r)) if(! dbm::is_result($r))
killme(); killme();
$owner = $r[0]; $owner = $r[0];
@ -139,7 +139,7 @@ class dfrn {
intval($owner_id) intval($owner_id)
); );
if(! count($r)) if(! dbm::is_result($r))
killme(); killme();
$contact = $r[0]; $contact = $r[0];
@ -1463,7 +1463,7 @@ class dfrn {
dbesc(normalise_link($suggest["url"])), dbesc(normalise_link($suggest["url"])),
intval($suggest["uid"]) intval($suggest["uid"])
); );
if(count($r)) if(dbm::is_result($r))
return false; return false;
// Do we already have an fcontact record for this person? // Do we already have an fcontact record for this person?
@ -1474,7 +1474,7 @@ class dfrn {
dbesc($suggest["name"]), dbesc($suggest["name"]),
dbesc($suggest["request"]) dbesc($suggest["request"])
); );
if(count($r)) { if(dbm::is_result($r)) {
$fid = $r[0]["id"]; $fid = $r[0]["id"];
// OK, we do. Do we already have an introduction for this person ? // OK, we do. Do we already have an introduction for this person ?
@ -1482,7 +1482,7 @@ class dfrn {
intval($suggest["uid"]), intval($suggest["uid"]),
intval($fid) intval($fid)
); );
if(count($r)) if(dbm::is_result($r))
return false; return false;
} }
if(!$fid) if(!$fid)
@ -1497,7 +1497,7 @@ class dfrn {
dbesc($suggest["name"]), dbesc($suggest["name"]),
dbesc($suggest["request"]) dbesc($suggest["request"])
); );
if(count($r)) if(dbm::is_result($r))
$fid = $r[0]["id"]; $fid = $r[0]["id"];
else else
// database record did not get created. Quietly give up. // database record did not get created. Quietly give up.
@ -1746,7 +1746,7 @@ class dfrn {
LIMIT 1", LIMIT 1",
dbesc($item["parent-uri"]) dbesc($item["parent-uri"])
); );
if($r && count($r)) { if(dbm::is_result($r)) {
$r = q("SELECT `item`.`forum_mode`, `item`.`wall` FROM `item` $r = q("SELECT `item`.`forum_mode`, `item`.`wall` FROM `item`
INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`uri` = '%s' AND (`item`.`parent-uri` = '%s' OR `item`.`thr-parent` = '%s') WHERE `item`.`uri` = '%s' AND (`item`.`parent-uri` = '%s' OR `item`.`thr-parent` = '%s')
@ -1758,7 +1758,7 @@ class dfrn {
dbesc($r[0]["parent-uri"]), dbesc($r[0]["parent-uri"]),
intval($importer["importer_uid"]) intval($importer["importer_uid"])
); );
if($r && count($r)) if(dbm::is_result($r))
$is_a_remote_action = true; $is_a_remote_action = true;
} }
@ -1898,7 +1898,7 @@ class dfrn {
dbesc($item["verb"]), dbesc($item["verb"]),
dbesc($item["parent-uri"]) dbesc($item["parent-uri"])
); );
if($r && count($r)) if(dbm::is_result($r))
return false; return false;
$r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `author-link` = '%s' AND `verb` = '%s' AND `thr-parent` = '%s' AND NOT `deleted` LIMIT 1", $r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `author-link` = '%s' AND `verb` = '%s' AND `thr-parent` = '%s' AND NOT `deleted` LIMIT 1",
@ -1907,7 +1907,7 @@ class dfrn {
dbesc($item["verb"]), dbesc($item["verb"]),
dbesc($item["parent-uri"]) dbesc($item["parent-uri"])
); );
if($r && count($r)) if(dbm::is_result($r))
return false; return false;
} else } else
$is_like = false; $is_like = false;
@ -1923,7 +1923,7 @@ class dfrn {
intval($importer["importer_uid"]) intval($importer["importer_uid"])
); );
if(!count($r)) if(!dbm::is_result($r))
return false; return false;
// extract tag, if not duplicate, add to parent item // extract tag, if not duplicate, add to parent item
@ -2195,7 +2195,7 @@ class dfrn {
dbesc($item["uri"]), dbesc($item["uri"]),
intval($importer["uid"]) intval($importer["uid"])
); );
if(count($r)) if(dbm::is_result($r))
$ev["id"] = $r[0]["id"]; $ev["id"] = $r[0]["id"];
$event_id = event_store($ev); $event_id = event_store($ev);
@ -2216,7 +2216,7 @@ class dfrn {
} }
// Update content if 'updated' changes // Update content if 'updated' changes
if(count($r)) { if(dbm::is_result($r)) {
if (self::update_content($r[0], $item, $importer, $entrytype)) if (self::update_content($r[0], $item, $importer, $entrytype))
logger("Item ".$item["uri"]." was updated.", LOGGER_DEBUG); logger("Item ".$item["uri"]." was updated.", LOGGER_DEBUG);
else else
@ -2238,7 +2238,7 @@ class dfrn {
intval($posted_id), intval($posted_id),
intval($importer["importer_uid"]) intval($importer["importer_uid"])
); );
if(count($r)) { if(dbm::is_result($r)) {
$parent = $r[0]["parent"]; $parent = $r[0]["parent"];
$parent_uri = $r[0]["parent-uri"]; $parent_uri = $r[0]["parent-uri"];
} }
@ -2326,7 +2326,7 @@ class dfrn {
intval($importer["uid"]), intval($importer["uid"]),
intval($importer["id"]) intval($importer["id"])
); );
if(!count($r)) { if(!dbm::is_result($r)) {
logger("Item with uri ".$uri." from contact ".$importer["id"]." for user ".$importer["uid"]." wasn't found.", LOGGER_DEBUG); logger("Item with uri ".$uri." from contact ".$importer["id"]." for user ".$importer["uid"]." wasn't found.", LOGGER_DEBUG);
return; return;
} else { } else {
@ -2420,7 +2420,7 @@ class dfrn {
dbesc($item["parent-uri"]), dbesc($item["parent-uri"]),
intval($importer["uid"]) intval($importer["uid"])
); );
if(count($r)) { if(dbm::is_result($r)) {
q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d", q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d",
intval($r[0]["id"]) intval($r[0]["id"])
); );

View File

@ -411,7 +411,7 @@ function notification($params) {
$hash = random_string(); $hash = random_string();
$r = q("SELECT `id` FROM `notify` WHERE `hash` = '%s' LIMIT 1", $r = q("SELECT `id` FROM `notify` WHERE `hash` = '%s' LIMIT 1",
dbesc($hash)); dbesc($hash));
if (count($r)) if (dbm::is_result($r))
$dups = true; $dups = true;
} while($dups == true); } while($dups == true);
@ -733,7 +733,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
intval($item[0]['contact-id']), intval($item[0]['contact-id']),
intval($uid) intval($uid)
); );
$send_notification = count($r); $send_notification = dbm::is_result($r);
if (!$send_notification) { if (!$send_notification) {
$tags = q("SELECT `url` FROM `term` WHERE `otype` = %d AND `oid` = %d AND `type` = %d AND `uid` = %d", $tags = q("SELECT `url` FROM `term` WHERE `otype` = %d AND `oid` = %d AND `type` = %d AND `uid` = %d",
@ -743,7 +743,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
foreach ($tags AS $tag) { foreach ($tags AS $tag) {
$r = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `notify_new_posts`", $r = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `notify_new_posts`",
normalise_link($tag["url"]), intval($uid)); normalise_link($tag["url"]), intval($uid));
if (count($r)) if (dbm::is_result($r))
$send_notification = true; $send_notification = true;
} }
} }

View File

@ -271,7 +271,7 @@ function event_store($arr) {
intval($arr['id']), intval($arr['id']),
intval($arr['uid']) intval($arr['uid'])
); );
if((! count($r)) || ($r[0]['edited'] === $arr['edited'])) { if((! dbm::is_result($r)) || ($r[0]['edited'] === $arr['edited'])) {
// Nothing has changed. Grab the item id to return. // Nothing has changed. Grab the item id to return.
@ -279,7 +279,7 @@ function event_store($arr) {
intval($arr['id']), intval($arr['id']),
intval($arr['uid']) intval($arr['uid'])
); );
return((count($r)) ? $r[0]['id'] : 0); return((dbm::is_result($r)) ? $r[0]['id'] : 0);
} }
// The event changed. Update it. // The event changed. Update it.
@ -312,7 +312,7 @@ function event_store($arr) {
intval($arr['id']), intval($arr['id']),
intval($arr['uid']) intval($arr['uid'])
); );
if(count($r)) { if(dbm::is_result($r)) {
$object = '<object><type>' . xmlify(ACTIVITY_OBJ_EVENT) . '</type><title></title><id>' . xmlify($arr['uri']) . '</id>'; $object = '<object><type>' . xmlify(ACTIVITY_OBJ_EVENT) . '</type><title></title><id>' . xmlify($arr['uri']) . '</id>';
$object .= '<content>' . xmlify(format_event_bbcode($arr)) . '</content>'; $object .= '<content>' . xmlify(format_event_bbcode($arr)) . '</content>';
$object .= '</object>' . "\n"; $object .= '</object>' . "\n";
@ -365,7 +365,7 @@ function event_store($arr) {
dbesc($arr['uri']), dbesc($arr['uri']),
intval($arr['uid']) intval($arr['uid'])
); );
if(count($r)) if(dbm::is_result($r))
$event = $r[0]; $event = $r[0];
$item_arr = array(); $item_arr = array();
@ -407,7 +407,7 @@ function event_store($arr) {
$r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
intval($arr['uid']) intval($arr['uid'])
); );
//if(count($r)) //if(dbm::is_result($r))
// $plink = $a->get_baseurl() . '/display/' . $r[0]['nickname'] . '/' . $item_id; // $plink = $a->get_baseurl() . '/display/' . $r[0]['nickname'] . '/' . $item_id;
@ -515,7 +515,7 @@ function event_by_id($owner_uid = 0, $event_params, $sql_extra = '') {
intval($event_params["event_id"]) intval($event_params["event_id"])
); );
if(count($r)) if(dbm::is_result($r))
return $r; return $r;
} }
@ -557,7 +557,7 @@ function events_by_date($owner_uid = 0, $event_params, $sql_extra = '') {
dbesc($event_params["adjust_finish"]) dbesc($event_params["adjust_finish"])
); );
if(count($r)) if(dbm::is_result($r))
return $r; return $r;
} }
@ -750,7 +750,7 @@ function events_by_uid($uid = 0, $sql_extra = '') {
); );
} }
if(count($r)) if(dbm::is_result($r))
return $r; return $r;
} }
@ -773,7 +773,7 @@ function event_export($uid, $format = 'ical') {
// we are allowed to show events // we are allowed to show events
// get the timezone the user is in // get the timezone the user is in
$r = q("SELECT `timezone` FROM `user` WHERE `uid` = %d LIMIT 1", intval($uid)); $r = q("SELECT `timezone` FROM `user` WHERE `uid` = %d LIMIT 1", intval($uid));
if (count($r)) if (dbm::is_result($r))
$timezone = $r[0]['timezone']; $timezone = $r[0]['timezone'];
// get all events which are owned by a uid (respects permissions); // get all events which are owned by a uid (respects permissions);

View File

@ -39,7 +39,7 @@ function expire_run(&$argv, &$argc){
logger('expire: start'); logger('expire: start');
$r = q("SELECT `uid`,`username`,`expire` FROM `user` WHERE `expire` != 0"); $r = q("SELECT `uid`,`username`,`expire` FROM `user` WHERE `expire` != 0");
if(count($r)) { if(dbm::is_result($r)) {
foreach($r as $rr) { foreach($r as $rr) {
logger('Expire: ' . $rr['username'] . ' interval: ' . $rr['expire'], LOGGER_DEBUG); logger('Expire: ' . $rr['username'] . ' interval: ' . $rr['expire'], LOGGER_DEBUG);
item_expire($rr['uid'],$rr['expire']); item_expire($rr['uid'],$rr['expire']);

View File

@ -10,7 +10,7 @@ function fcontact_store($url,$name,$photo) {
dbesc($nurl) dbesc($nurl)
); );
if(count($r)) if(dbm::is_result($r))
return $r[0]['id']; return $r[0]['id'];
$r = q("INSERT INTO `fcontact` ( `url`, `name`, `photo` ) VALUES ( '%s', '%s', '%s' ) ", $r = q("INSERT INTO `fcontact` ( `url`, `name`, `photo` ) VALUES ( '%s', '%s', '%s' ) ",
@ -19,11 +19,11 @@ function fcontact_store($url,$name,$photo) {
dbesc($photo) dbesc($photo)
); );
if($r) { if(dbm::is_result($r)) {
$r = q("SELECT `id` FROM `fcontact` WHERE `url` = '%s' LIMIT 1", $r = q("SELECT `id` FROM `fcontact` WHERE `url` = '%s' LIMIT 1",
dbesc($nurl) dbesc($nurl)
); );
if(count($r)) if(dbm::is_result($r))
return $r[0]['id']; return $r[0]['id'];
} }

View File

@ -173,12 +173,12 @@ function new_contact($uid,$url,$interactive = false) {
dbesc($ret['network']) dbesc($ret['network'])
); );
if(!count($r)) if(!dbm::is_result($r))
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND `network` = '%s' LIMIT 1", $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND `network` = '%s' LIMIT 1",
intval($uid), dbesc(normalise_link($url)), dbesc($ret['network']) intval($uid), dbesc(normalise_link($url)), dbesc($ret['network'])
); );
if(count($r)) { if(dbm::is_result($r)) {
// update contact // update contact
if($r[0]['rel'] == CONTACT_IS_FOLLOWER || ($network === NETWORK_DIASPORA && $r[0]['rel'] == CONTACT_IS_SHARING)) { if($r[0]['rel'] == CONTACT_IS_FOLLOWER || ($network === NETWORK_DIASPORA && $r[0]['rel'] == CONTACT_IS_SHARING)) {
q("UPDATE `contact` SET `rel` = %d , `subhub` = %d, `readonly` = 0 WHERE `id` = %d AND `uid` = %d", q("UPDATE `contact` SET `rel` = %d , `subhub` = %d, `readonly` = 0 WHERE `id` = %d AND `uid` = %d",
@ -196,7 +196,7 @@ function new_contact($uid,$url,$interactive = false) {
$r = q("select count(*) as total from contact where uid = %d and pending = 0 and self = 0", $r = q("select count(*) as total from contact where uid = %d and pending = 0 and self = 0",
intval($uid) intval($uid)
); );
if(count($r)) if(dbm::is_result($r))
$total_contacts = $r[0]['total']; $total_contacts = $r[0]['total'];
if(! service_class_allows($uid,'total_contacts',$total_contacts)) { if(! service_class_allows($uid,'total_contacts',$total_contacts)) {
@ -208,7 +208,7 @@ function new_contact($uid,$url,$interactive = false) {
intval($uid), intval($uid),
dbesc($network) dbesc($network)
); );
if(count($r)) if(dbm::is_result($r))
$total_network = $r[0]['total']; $total_network = $r[0]['total'];
if(! service_class_allows($uid,'total_contacts_' . $network,$total_network)) { if(! service_class_allows($uid,'total_contacts_' . $network,$total_network)) {
@ -250,7 +250,7 @@ function new_contact($uid,$url,$interactive = false) {
intval($uid) intval($uid)
); );
if(! count($r)) { if(! dbm::is_result($r)) {
$result['message'] .= t('Unable to retrieve contact information.') . EOL; $result['message'] .= t('Unable to retrieve contact information.') . EOL;
return $result; return $result;
} }
@ -295,7 +295,7 @@ function new_contact($uid,$url,$interactive = false) {
intval($uid) intval($uid)
); );
if(count($r)) { if(dbm::is_result($r)) {
if(($contact['network'] == NETWORK_OSTATUS) && (strlen($contact['notify']))) { if(($contact['network'] == NETWORK_OSTATUS) && (strlen($contact['notify']))) {
require_once('include/salmon.php'); require_once('include/salmon.php');
slapper($r[0],$contact['notify'],$slap); slapper($r[0],$contact['notify'],$slap);

View File

@ -44,7 +44,7 @@ function group_rmv($uid,$name) {
intval($uid), intval($uid),
dbesc($name) dbesc($name)
); );
if(count($r)) if(dbm::is_result($r))
$group_id = $r[0]['id']; $group_id = $r[0]['id'];
if(! $group_id) if(! $group_id)
return false; return false;
@ -106,7 +106,7 @@ function group_byname($uid,$name) {
intval($uid), intval($uid),
dbesc($name) dbesc($name)
); );
if(count($r)) if(dbm::is_result($r))
return $r[0]['id']; return $r[0]['id'];
return false; return false;
} }
@ -139,11 +139,11 @@ function group_add_member($uid,$name,$member,$gid = 0) {
intval($gid), intval($gid),
intval($member) intval($member)
); );
if(count($r)) if(dbm::is_result($r))
return true; // You might question this, but return true; // You might question this, but
// we indicate success because the group member was in fact created // we indicate success because the group member was in fact created
// -- It was just created at another time // -- It was just created at another time
if(! count($r)) if(! dbm::is_result($r))
$r = q("INSERT INTO `group_member` (`uid`, `gid`, `contact-id`) $r = q("INSERT INTO `group_member` (`uid`, `gid`, `contact-id`)
VALUES( %d, %d, %d ) ", VALUES( %d, %d, %d ) ",
intval($uid), intval($uid),
@ -164,7 +164,7 @@ function group_get_members($gid) {
intval($gid), intval($gid),
intval(local_user()) intval(local_user())
); );
if(count($r)) if(dbm::is_result($r))
$ret = $r; $ret = $r;
} }
return $ret; return $ret;
@ -181,7 +181,7 @@ function group_public_members($gid) {
intval(local_user()), intval(local_user()),
dbesc(NETWORK_OSTATUS) dbesc(NETWORK_OSTATUS)
); );
if(count($r)) if(dbm::is_result($r))
$ret = count($r); $ret = count($r);
} }
return $ret; return $ret;
@ -197,7 +197,7 @@ function mini_group_select($uid,$gid = 0, $label = "") {
intval($uid) intval($uid)
); );
$grps[] = array('name' => '', 'id' => '0', 'selected' => ''); $grps[] = array('name' => '', 'id' => '0', 'selected' => '');
if(count($r)) { if(dbm::is_result($r)) {
foreach($r as $rr) { foreach($r as $rr) {
$grps[] = array('name' => $rr['name'], 'id' => $rr['id'], 'selected' => (($gid == $rr['id']) ? 'true' : '')); $grps[] = array('name' => $rr['name'], 'id' => $rr['id'], 'selected' => (($gid == $rr['id']) ? 'true' : ''));
} }
@ -255,7 +255,7 @@ function group_side($every="contacts",$each="group",$editmode = "standard", $gro
$member_of = groups_containing(local_user(),$cid); $member_of = groups_containing(local_user(),$cid);
} }
if(count($r)) { if(dbm::is_result($r)) {
foreach($r as $rr) { foreach($r as $rr) {
$selected = (($group_id == $rr['id']) ? ' group-selected' : ''); $selected = (($group_id == $rr['id']) ? ' group-selected' : '');
@ -316,7 +316,7 @@ function expand_groups($a,$check_dead = false, $use_gcontact = false) {
$ret = array(); $ret = array();
if(count($r)) if(dbm::is_result($r))
foreach($r as $rr) foreach($r as $rr)
$ret[] = $rr['contact-id']; $ret[] = $rr['contact-id'];
if($check_dead AND !$use_gcontact) { if($check_dead AND !$use_gcontact) {
@ -345,7 +345,7 @@ function groups_containing($uid,$c) {
); );
$ret = array(); $ret = array();
if(count($r)) { if(dbm::is_result($r)) {
foreach($r as $rr) foreach($r as $rr)
$ret[] = $rr['gid']; $ret[] = $rr['gid'];
} }

View File

@ -138,7 +138,7 @@ function get_profiledata_by_nick($nickname, $uid = 0, $profile = 0) {
$r = q("SELECT `profile-id` FROM `contact` WHERE `id` = %d LIMIT 1", $r = q("SELECT `profile-id` FROM `contact` WHERE `id` = %d LIMIT 1",
intval($visitor['cid']) intval($visitor['cid'])
); );
if(count($r)) if(dbm::is_result($r))
$profile = $r[0]['profile-id']; $profile = $r[0]['profile-id'];
break; break;
} }
@ -159,7 +159,7 @@ function get_profiledata_by_nick($nickname, $uid = 0, $profile = 0) {
intval($profile_int) intval($profile_int)
); );
} }
if((!$r) && (!count($r))) { if(!dbm::is_result($r)) {
$r = q("SELECT `contact`.`id` AS `contact_id`, `profile`.`uid` AS `profile_uid`, `profile`.*, $r = q("SELECT `contact`.`id` AS `contact_id`, `profile`.`uid` AS `profile_uid`, `profile`.*,
`contact`.`avatar-date` AS picdate, `contact`.`addr`, `user`.* `contact`.`avatar-date` AS picdate, `contact`.`addr`, `user`.*
FROM `profile` FROM `profile`
@ -236,7 +236,7 @@ function profile_sidebar($profile, $block = 0) {
$r = q("SELECT * FROM `contact` WHERE NOT `pending` AND `uid` = %d AND `nurl` = '%s'", $r = q("SELECT * FROM `contact` WHERE NOT `pending` AND `uid` = %d AND `nurl` = '%s'",
local_user(), $profile_url); local_user(), $profile_url);
if (count($r)) if (dbm::is_result($r))
$connect = false; $connect = false;
} }
@ -289,7 +289,7 @@ function profile_sidebar($profile, $block = 0) {
'entries' => array(), 'entries' => array(),
); );
if(count($r)) { if(dbm::is_result($r)) {
foreach($r as $rr) { foreach($r as $rr) {
$profile['menu']['entries'][] = array( $profile['menu']['entries'][] = array(
@ -368,7 +368,7 @@ function profile_sidebar($profile, $block = 0) {
if(is_array($a->profile) AND !$a->profile['hide-friends']) { if(is_array($a->profile) AND !$a->profile['hide-friends']) {
$r = q("SELECT `gcontact`.`updated` FROM `contact` INNER JOIN `gcontact` WHERE `gcontact`.`nurl` = `contact`.`nurl` AND `self` AND `uid` = %d LIMIT 1", $r = q("SELECT `gcontact`.`updated` FROM `contact` INNER JOIN `gcontact` WHERE `gcontact`.`nurl` = `contact`.`nurl` AND `self` AND `uid` = %d LIMIT 1",
intval($a->profile['uid'])); intval($a->profile['uid']));
if(count($r)) if(dbm::is_result($r))
$updated = date("c", strtotime($r[0]['updated'])); $updated = date("c", strtotime($r[0]['updated']));
$r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `hidden` AND NOT `archive` $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `hidden` AND NOT `archive`
@ -378,7 +378,7 @@ function profile_sidebar($profile, $block = 0) {
dbesc(NETWORK_DIASPORA), dbesc(NETWORK_DIASPORA),
dbesc(NETWORK_OSTATUS) dbesc(NETWORK_OSTATUS)
); );
if(count($r)) if(dbm::is_result($r))
$contacts = intval($r[0]['total']); $contacts = intval($r[0]['total']);
} }
} }
@ -460,7 +460,7 @@ function get_birthdays() {
dbesc(datetime_convert('UTC','UTC','now')) dbesc(datetime_convert('UTC','UTC','now'))
); );
if($r && count($r)) { if(dbm::is_result($r)) {
$total = 0; $total = 0;
$now = strtotime('now'); $now = strtotime('now');
$cids = array(); $cids = array();
@ -543,7 +543,7 @@ function get_events() {
dbesc(datetime_convert('UTC','UTC','now - 1 days')) dbesc(datetime_convert('UTC','UTC','now - 1 days'))
); );
if($r && count($r)) { if(dbm::is_result($r)) {
$now = strtotime('now'); $now = strtotime('now');
$istoday = false; $istoday = false;
foreach($r as $rr) { foreach($r as $rr) {

View File

@ -451,7 +451,7 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
/* check for create date and expire time */ /* check for create date and expire time */
$uid = intval($arr['uid']); $uid = intval($arr['uid']);
$r = q("SELECT expire FROM user WHERE uid = %d", intval($uid)); $r = q("SELECT expire FROM user WHERE uid = %d", intval($uid));
if (count($r)) { if (dbm::is_result($r)) {
$expire_interval = $r[0]['expire']; $expire_interval = $r[0]['expire'];
if ($expire_interval>0) { if ($expire_interval>0) {
$expire_date = new DateTime( '- '.$expire_interval.' days', new DateTimeZone('UTC')); $expire_date = new DateTime( '- '.$expire_interval.' days', new DateTimeZone('UTC'));
@ -568,19 +568,19 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
intval($arr['uid']) intval($arr['uid'])
); );
if (!count($r)) if (!dbm::is_result($r))
$r = q("SELECT `network` FROM `gcontact` WHERE `network` IN ('%s', '%s', '%s') AND `nurl` = '%s' LIMIT 1", $r = q("SELECT `network` FROM `gcontact` WHERE `network` IN ('%s', '%s', '%s') AND `nurl` = '%s' LIMIT 1",
dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_OSTATUS), dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_OSTATUS),
dbesc(normalise_link($arr['author-link'])) dbesc(normalise_link($arr['author-link']))
); );
if (!count($r)) if (!dbm::is_result($r))
$r = q("SELECT `network` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("SELECT `network` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($arr['contact-id']), intval($arr['contact-id']),
intval($arr['uid']) intval($arr['uid'])
); );
if (count($r)) if (dbm::is_result($r))
$arr['network'] = $r[0]["network"]; $arr['network'] = $r[0]["network"];
// Fallback to friendica (why is it empty in some cases?) // Fallback to friendica (why is it empty in some cases?)
@ -634,7 +634,7 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
$r = q("SELECT `guid` FROM `item` WHERE `guid` = '%s' AND `network` = '%s' AND `uid` = '%d' LIMIT 1", $r = q("SELECT `guid` FROM `item` WHERE `guid` = '%s' AND `network` = '%s' AND `uid` = '%d' LIMIT 1",
dbesc($arr['guid']), dbesc($arr['network']), intval($arr['uid'])); dbesc($arr['guid']), dbesc($arr['network']), intval($arr['uid']));
if (count($r)) { if (dbm::is_result($r)) {
logger('found item with guid '.$arr['guid'].' for user '.$arr['uid'].' on network '.$arr['network'], LOGGER_DEBUG); logger('found item with guid '.$arr['guid'].' for user '.$arr['uid'].' on network '.$arr['network'], LOGGER_DEBUG);
return 0; return 0;
} }
@ -662,7 +662,7 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
intval($arr['uid']) intval($arr['uid'])
); );
if (count($r)) { if (dbm::is_result($r)) {
// is the new message multi-level threaded? // is the new message multi-level threaded?
// even though we don't support it now, preserve the info // even though we don't support it now, preserve the info
@ -1120,7 +1120,7 @@ function item_body_set_hashtags(&$item) {
function get_item_guid($id) { function get_item_guid($id) {
$r = q("SELECT `guid` FROM `item` WHERE `id` = %d LIMIT 1", intval($id)); $r = q("SELECT `guid` FROM `item` WHERE `id` = %d LIMIT 1", intval($id));
if (count($r)) if (dbm::is_result($r))
return($r[0]["guid"]); return($r[0]["guid"]);
else else
return(""); return("");
@ -1139,7 +1139,7 @@ function get_item_id($guid, $uid = 0) {
$r = q("SELECT `item`.`id`, `user`.`nickname` FROM `item` INNER JOIN `user` ON `user`.`uid` = `item`.`uid` $r = q("SELECT `item`.`id`, `user`.`nickname` FROM `item` INNER JOIN `user` ON `user`.`uid` = `item`.`uid`
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
AND `item`.`guid` = '%s' AND `item`.`uid` = %d", dbesc($guid), intval($uid)); AND `item`.`guid` = '%s' AND `item`.`uid` = %d", dbesc($guid), intval($uid));
if (count($r)) { if (dbm::is_result($r)) {
$id = $r[0]["id"]; $id = $r[0]["id"];
$nick = $r[0]["nickname"]; $nick = $r[0]["nickname"];
} }
@ -1153,7 +1153,7 @@ function get_item_id($guid, $uid = 0) {
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
AND `item`.`private` = 0 AND `item`.`wall` = 1 AND `item`.`private` = 0 AND `item`.`wall` = 1
AND `item`.`guid` = '%s'", dbesc($guid)); AND `item`.`guid` = '%s'", dbesc($guid));
if (count($r)) { if (dbm::is_result($r)) {
$id = $r[0]["id"]; $id = $r[0]["id"];
$nick = $r[0]["nickname"]; $nick = $r[0]["nickname"];
} }
@ -1454,7 +1454,7 @@ function item_is_remote_self($contact, &$datarray) {
if ($contact['remote_self'] == 2) { if ($contact['remote_self'] == 2) {
$r = q("SELECT `id`,`url`,`name`,`thumb` FROM `contact` WHERE `uid` = %d AND `self`", $r = q("SELECT `id`,`url`,`name`,`thumb` FROM `contact` WHERE `uid` = %d AND `self`",
intval($contact['uid'])); intval($contact['uid']));
if (count($r)) { if (dbm::is_result($r)) {
$datarray['contact-id'] = $r[0]["id"]; $datarray['contact-id'] = $r[0]["id"];
$datarray['owner-name'] = $r[0]["name"]; $datarray['owner-name'] = $r[0]["name"];
@ -1531,7 +1531,7 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
intval($importer['uid']), intval($importer['uid']),
dbesc($url) dbesc($url)
); );
if (count($r)) { if (dbm::is_result($r)) {
$contact_record = $r[0]; $contact_record = $r[0];
update_contact_avatar($photo, $importer["uid"], $contact_record["id"], true); update_contact_avatar($photo, $importer["uid"], $contact_record["id"], true);
} }
@ -1541,7 +1541,7 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
intval($importer['uid']) intval($importer['uid'])
); );
$a = get_app(); $a = get_app();
if (count($r) AND !in_array($r[0]['page-flags'], array(PAGE_SOAPBOX, PAGE_FREELOVE))) { if (dbm::is_result($r) AND !in_array($r[0]['page-flags'], array(PAGE_SOAPBOX, PAGE_FREELOVE))) {
// create notification // create notification
$hash = random_string(); $hash = random_string();
@ -1580,7 +1580,7 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
)); ));
} }
} elseif (count($r) AND in_array($r[0]['page-flags'], array(PAGE_SOAPBOX, PAGE_FREELOVE))) { } elseif (dbm::is_result($r) AND in_array($r[0]['page-flags'], array(PAGE_SOAPBOX, PAGE_FREELOVE))) {
$r = q("UPDATE `contact` SET `pending` = 0 WHERE `uid` = %d AND `url` = '%s' AND `pending` LIMIT 1", $r = q("UPDATE `contact` SET `pending` = 0 WHERE `uid` = %d AND `url` = '%s' AND `pending` LIMIT 1",
intval($importer['uid']), intval($importer['uid']),
dbesc($url) dbesc($url)
@ -1628,7 +1628,7 @@ function subscribe_to_hub($url,$importer,$contact,$hubmode = 'subscribe') {
// through the direct Diaspora protocol. If we try and use // through the direct Diaspora protocol. If we try and use
// the feed, we'll get duplicates. So don't. // the feed, we'll get duplicates. So don't.
if ((! count($r)) || $contact['network'] === NETWORK_DIASPORA) if ((! dbm::is_result($r)) || $contact['network'] === NETWORK_DIASPORA)
return; return;
$push_url = get_config('system','url') . '/pubsub/' . $r[0]['nickname'] . '/' . $contact['id']; $push_url = get_config('system','url') . '/pubsub/' . $r[0]['nickname'] . '/' . $contact['id'];
@ -1846,7 +1846,7 @@ function item_expire($uid, $days, $network = "", $force = false) {
intval($days) intval($days)
); );
if (! count($r)) if (! dbm::is_result($r))
return; return;
$expire_items = get_pconfig($uid, 'expire','items'); $expire_items = get_pconfig($uid, 'expire','items');
@ -1924,7 +1924,7 @@ function drop_item($id,$interactive = true) {
intval($id) intval($id)
); );
if (! count($r)) { if (! dbm::is_result($r)) {
if (! $interactive) if (! $interactive)
return 0; return 0;
notice( t('Item not found.') . EOL); notice( t('Item not found.') . EOL);
@ -2111,7 +2111,7 @@ function drop_item($id,$interactive = true) {
dbesc($item['parent-uri']), dbesc($item['parent-uri']),
intval($item['uid']) intval($item['uid'])
); );
if (count($r)) { if (dbm::is_result($r)) {
q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d", q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d",
intval($r[0]['id']) intval($r[0]['id'])
); );
@ -2147,7 +2147,7 @@ function first_post_date($uid,$wall = false) {
intval($uid), intval($uid),
intval($wall ? 1 : 0) intval($wall ? 1 : 0)
); );
if (count($r)) { if (dbm::is_result($r)) {
// logger('first_post_date: ' . $r[0]['id'] . ' ' . $r[0]['created'], LOGGER_DATA); // logger('first_post_date: ' . $r[0]['id'] . ' ' . $r[0]['created'], LOGGER_DATA);
return substr(datetime_convert('',date_default_timezone_get(),$r[0]['created']),0,10); return substr(datetime_convert('',date_default_timezone_get(),$r[0]['created']),0,10);
} }

View File

@ -57,7 +57,7 @@ function do_like($item_id, $verb) {
dbesc($item_id) dbesc($item_id)
); );
if(! $item_id || (! count($r))) { if(! $item_id || (! dbm::is_result($r))) {
logger('like: no item ' . $item_id); logger('like: no item ' . $item_id);
return false; return false;
} }
@ -78,7 +78,7 @@ function do_like($item_id, $verb) {
intval($item['contact-id']), intval($item['contact-id']),
intval($item['uid']) intval($item['uid'])
); );
if(! count($r)) if(! dbm::is_result($r))
return false; return false;
if(! $r[0]['self']) if(! $r[0]['self'])
$remote_owner = $r[0]; $remote_owner = $r[0];
@ -90,7 +90,7 @@ function do_like($item_id, $verb) {
WHERE `contact`.`self` = 1 AND `contact`.`uid` = %d LIMIT 1", WHERE `contact`.`self` = 1 AND `contact`.`uid` = %d LIMIT 1",
intval($owner_uid) intval($owner_uid)
); );
if(count($r)) if(dbm::is_result($r))
$owner = $r[0]; $owner = $r[0];
if(! $owner) { if(! $owner) {
@ -112,7 +112,7 @@ function do_like($item_id, $verb) {
intval($_SESSION['visitor_id']), intval($_SESSION['visitor_id']),
intval($owner_uid) intval($owner_uid)
); );
if(count($r)) if(dbm::is_result($r))
$contact = $r[0]; $contact = $r[0];
} }
if(! $contact) { if(! $contact) {
@ -135,7 +135,7 @@ function do_like($item_id, $verb) {
dbesc($item_id), dbesc($item_id), dbesc($item['uri']) dbesc($item_id), dbesc($item_id), dbesc($item['uri'])
); );
if(count($r)) { if(dbm::is_result($r)) {
$like_item = $r[0]; $like_item = $r[0];
// Already voted, undo it // Already voted, undo it

View File

@ -16,14 +16,14 @@ function lock_function($fn_name, $block = true, $wait_sec = 2, $timeout = 30) {
dbesc($fn_name) dbesc($fn_name)
); );
if((count($r)) AND (!$r[0]['locked'] OR (strtotime($r[0]['created']) < time() - 3600))) { if((dbm::is_result($r)) AND (!$r[0]['locked'] OR (strtotime($r[0]['created']) < time() - 3600))) {
q("UPDATE `locks` SET `locked` = 1, `created` = '%s' WHERE `name` = '%s'", q("UPDATE `locks` SET `locked` = 1, `created` = '%s' WHERE `name` = '%s'",
dbesc(datetime_convert()), dbesc(datetime_convert()),
dbesc($fn_name) dbesc($fn_name)
); );
$got_lock = true; $got_lock = true;
} }
elseif(! $r) { // the Boolean value for count($r) should be equivalent to the Boolean value of $r elseif(! dbm::is_result($r)) { // the Boolean value for count($r) should be equivalent to the Boolean value of $r
q("INSERT INTO `locks` (`name`, `created`, `locked`) VALUES ('%s', '%s', 1)", q("INSERT INTO `locks` (`name`, `created`, `locked`) VALUES ('%s', '%s', 1)",
dbesc($fn_name), dbesc($fn_name),
dbesc(datetime_convert()) dbesc(datetime_convert())
@ -56,10 +56,10 @@ function block_on_function_lock($fn_name, $wait_sec = 2, $timeout = 30) {
dbesc($fn_name) dbesc($fn_name)
); );
if(count($r) && $r[0]['locked']) if(dbm::is_result($r) && $r[0]['locked'])
sleep($wait_sec); sleep($wait_sec);
} while(count($r) && $r[0]['locked'] && ((time() - $start) < $timeout)); } while(dbm::is_result($r) && $r[0]['locked'] && ((time() - $start) < $timeout));
return; return;
}} }}

View File

@ -41,7 +41,7 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
dbesc($replyto), dbesc($replyto),
dbesc($replyto) dbesc($replyto)
); );
if(count($r)) if(dbm::is_result($r))
$convid = $r[0]['convid']; $convid = $r[0]['convid'];
} }
@ -74,7 +74,7 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
dbesc($conv_guid), dbesc($conv_guid),
intval(local_user()) intval(local_user())
); );
if(count($r)) if(dbm::is_result($r))
$convid = $r[0]['id']; $convid = $r[0]['id'];
} }
@ -113,7 +113,7 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
dbesc($uri), dbesc($uri),
intval(local_user()) intval(local_user())
); );
if(count($r)) if(dbm::is_result($r))
$post_id = $r[0]['id']; $post_id = $r[0]['id'];
/** /**
@ -210,7 +210,7 @@ function send_wallmessage($recipient='', $body='', $subject='', $replyto=''){
dbesc($conv_guid), dbesc($conv_guid),
intval($recipient['uid']) intval($recipient['uid'])
); );
if(count($r)) if(dbm::is_result($r))
$convid = $r[0]['id']; $convid = $r[0]['id'];
if(! $convid) { if(! $convid) {

View File

@ -88,7 +88,7 @@ function nav_info(App $a)
// user info // user info
$r = q("SELECT `micro` FROM `contact` WHERE `uid` = %d AND `self` = 1", intval($a->user['uid'])); $r = q("SELECT `micro` FROM `contact` WHERE `uid` = %d AND `self` = 1", intval($a->user['uid']));
$userinfo = array( $userinfo = array(
'icon' => (count($r) ? $a->remove_baseurl($r[0]['micro']) : 'images/person-48.jpg'), 'icon' => (dbm::is_result($r) ? $a->remove_baseurl($r[0]['micro']) : 'images/person-48.jpg'),
'name' => $a->user['username'], 'name' => $a->user['username'],
); );
} else { } else {

View File

@ -170,7 +170,7 @@ function notifier_run(&$argv, &$argc){
intval($item_id) intval($item_id)
); );
if((! count($r)) || (! intval($r[0]['parent']))) { if((! dbm::is_result($r)) || (! intval($r[0]['parent']))) {
return; return;
} }
@ -210,7 +210,7 @@ function notifier_run(&$argv, &$argc){
intval($uid) intval($uid)
); );
if(! count($r)) if(! dbm::is_result($r))
return; return;
$owner = $r[0]; $owner = $r[0];
@ -321,7 +321,7 @@ function notifier_run(&$argv, &$argc){
intval($uid), intval($uid),
dbesc(NETWORK_DFRN) dbesc(NETWORK_DFRN)
); );
if(count($r)) if(dbm::is_result($r))
foreach($r as $rr) foreach($r as $rr)
$recipients_followup[] = $rr['id']; $recipients_followup[] = $rr['id'];
} }
@ -445,7 +445,7 @@ function notifier_run(&$argv, &$argc){
$r = q("SELECT * FROM `contact` WHERE `id` IN ($conversant_str) AND NOT `blocked` AND NOT `pending` AND NOT `archive`".$sql_extra); $r = q("SELECT * FROM `contact` WHERE `id` IN ($conversant_str) AND NOT `blocked` AND NOT `pending` AND NOT `archive`".$sql_extra);
if(count($r)) if(dbm::is_result($r))
$contacts = $r; $contacts = $r;
} else } else
@ -463,7 +463,7 @@ function notifier_run(&$argv, &$argc){
intval($uid), intval($uid),
dbesc(NETWORK_MAIL) dbesc(NETWORK_MAIL)
); );
if(count($r)) { if(dbm::is_result($r)) {
foreach($r as $rr) foreach($r as $rr)
$recipients[] = $rr['id']; $recipients[] = $rr['id'];
} }
@ -491,7 +491,7 @@ function notifier_run(&$argv, &$argc){
// delivery loop // delivery loop
if(count($r)) { if(dbm::is_result($r)) {
foreach($r as $contact) { foreach($r as $contact) {
if(!$contact['self']) { if(!$contact['self']) {
@ -592,7 +592,7 @@ function notifier_run(&$argv, &$argc){
$r = array_merge($r2,$r1,$r0); $r = array_merge($r2,$r1,$r0);
if(count($r)) { if(dbm::is_result($r)) {
logger('pubdeliver '.$target_item["guid"].': '.print_r($r,true), LOGGER_DEBUG); logger('pubdeliver '.$target_item["guid"].': '.print_r($r,true), LOGGER_DEBUG);
// throw everything into the queue in case we get killed // throw everything into the queue in case we get killed

View File

@ -23,7 +23,7 @@ class FKOAuthDataStore extends OAuthDataStore {
$r = q("SELECT client_id, pw, redirect_uri FROM clients WHERE client_id='%s'", $r = q("SELECT client_id, pw, redirect_uri FROM clients WHERE client_id='%s'",
dbesc($consumer_key) dbesc($consumer_key)
); );
if (count($r)) if (dbm::is_result($r))
return new OAuthConsumer($r[0]['client_id'],$r[0]['pw'],$r[0]['redirect_uri']); return new OAuthConsumer($r[0]['client_id'],$r[0]['pw'],$r[0]['redirect_uri']);
return null; return null;
} }
@ -35,7 +35,7 @@ class FKOAuthDataStore extends OAuthDataStore {
dbesc($token_type), dbesc($token_type),
dbesc($token) dbesc($token)
); );
if (count($r)){ if (dbm::is_result($r)){
$ot=new OAuthToken($r[0]['id'],$r[0]['secret']); $ot=new OAuthToken($r[0]['id'],$r[0]['secret']);
$ot->scope=$r[0]['scope']; $ot->scope=$r[0]['scope'];
$ot->expires = $r[0]['expires']; $ot->expires = $r[0]['expires'];
@ -52,7 +52,7 @@ class FKOAuthDataStore extends OAuthDataStore {
dbesc($nonce), dbesc($nonce),
intval($timestamp) intval($timestamp)
); );
if (count($r)) if (dbm::is_result($r))
return new OAuthToken($r[0]['id'],$r[0]['secret']); return new OAuthToken($r[0]['id'],$r[0]['secret']);
return null; return null;
} }
@ -136,7 +136,7 @@ class FKOAuth1 extends OAuthServer {
$r = q("SELECT * FROM `user` WHERE uid=%d AND `blocked` = 0 AND `account_expired` = 0 AND `account_removed` = 0 AND `verified` = 1 LIMIT 1", $r = q("SELECT * FROM `user` WHERE uid=%d AND `blocked` = 0 AND `account_expired` = 0 AND `account_removed` = 0 AND `verified` = 1 LIMIT 1",
intval($uid) intval($uid)
); );
if(count($r)){ if(dbm::is_result($r)){
$record = $r[0]; $record = $r[0];
} else { } else {
logger('FKOAuth1::loginUser failure: ' . print_r($_SERVER,true), LOGGER_DEBUG); logger('FKOAuth1::loginUser failure: ' . print_r($_SERVER,true), LOGGER_DEBUG);
@ -162,7 +162,7 @@ class FKOAuth1 extends OAuthServer {
$r = q("SELECT * FROM `contact` WHERE `uid` = %s AND `self` = 1 LIMIT 1", $r = q("SELECT * FROM `contact` WHERE `uid` = %s AND `self` = 1 LIMIT 1",
intval($_SESSION['uid'])); intval($_SESSION['uid']));
if(count($r)) { if(dbm::is_result($r)) {
$a->contact = $r[0]; $a->contact = $r[0];
$a->cid = $r[0]['id']; $a->cid = $r[0]['id'];
$_SESSION['cid'] = $a->cid; $_SESSION['cid'] = $a->cid;
@ -219,7 +219,7 @@ class FKOAuth2 extends OAuth2 {
$r = q("SELECT client_id, expires, scope FROM tokens WHERE id = '%s'", $r = q("SELECT client_id, expires, scope FROM tokens WHERE id = '%s'",
dbesc($oauth_token)); dbesc($oauth_token));
if (count($r)) if (dbm::is_result($r))
return $r[0]; return $r[0];
return null; return null;
} }
@ -247,7 +247,7 @@ class FKOAuth2 extends OAuth2 {
$r = q("SELECT id, client_id, redirect_uri, expires, scope FROM auth_codes WHERE id = '%s'", $r = q("SELECT id, client_id, redirect_uri, expires, scope FROM auth_codes WHERE id = '%s'",
dbesc($code)); dbesc($code));
if (count($r)) if (dbm::is_result($r))
return $r[0]; return $r[0];
return null; return null;
} }

View File

@ -93,7 +93,7 @@ function onepoll_run(&$argv, &$argc){
where `cid` = %d and updated > UTC_TIMESTAMP() - INTERVAL 1 DAY", where `cid` = %d and updated > UTC_TIMESTAMP() - INTERVAL 1 DAY",
intval($contact['id']) intval($contact['id'])
); );
if (count($r)) if (dbm::is_result($r))
if (!$r[0]['total']) if (!$r[0]['total'])
poco_load($contact['id'],$importer_uid,0,$contact['poco']); poco_load($contact['id'],$importer_uid,0,$contact['poco']);
} }
@ -143,7 +143,7 @@ function onepoll_run(&$argv, &$argc){
$r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` INNER JOIN `user` on `contact`.`uid` = `user`.`uid` WHERE `user`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1", $r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` INNER JOIN `user` on `contact`.`uid` = `user`.`uid` WHERE `user`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1",
intval($importer_uid) intval($importer_uid)
); );
if(! count($r)) if(! dbm::is_result($r))
return; return;
$importer = $r[0]; $importer = $r[0];
@ -393,7 +393,7 @@ function onepoll_run(&$argv, &$argc){
dbesc($datarray['uri']) dbesc($datarray['uri'])
); );
if(count($r)) { if(dbm::is_result($r)) {
logger("Mail: Seen before ".$msg_uid." for ".$mailconf[0]['user']." UID: ".$importer_uid." URI: ".$datarray['uri'],LOGGER_DEBUG); logger("Mail: Seen before ".$msg_uid." for ".$mailconf[0]['user']." UID: ".$importer_uid." URI: ".$datarray['uri'],LOGGER_DEBUG);
// Only delete when mails aren't automatically moved or deleted // Only delete when mails aren't automatically moved or deleted
@ -446,7 +446,7 @@ function onepoll_run(&$argv, &$argc){
$r = q("SELECT `uri` , `parent-uri` FROM `item` USE INDEX (`uid_uri`) WHERE `uri` IN ($qstr) AND `uid` = %d LIMIT 1", $r = q("SELECT `uri` , `parent-uri` FROM `item` USE INDEX (`uid_uri`) WHERE `uri` IN ($qstr) AND `uid` = %d LIMIT 1",
intval($importer_uid) intval($importer_uid)
); );
if(count($r)) if(dbm::is_result($r))
$datarray['parent-uri'] = $r[0]['parent-uri']; // Set the parent as the top-level item $datarray['parent-uri'] = $r[0]['parent-uri']; // Set the parent as the top-level item
// $datarray['parent-uri'] = $r[0]['uri']; // $datarray['parent-uri'] = $r[0]['uri'];
} }
@ -479,7 +479,7 @@ function onepoll_run(&$argv, &$argc){
dbesc(protect_sprintf($datarray['title'])), dbesc(protect_sprintf($datarray['title'])),
intval($importer_uid), intval($importer_uid),
dbesc(NETWORK_MAIL)); dbesc(NETWORK_MAIL));
if(count($r)) if(dbm::is_result($r))
$datarray['parent-uri'] = $r[0]['parent-uri']; $datarray['parent-uri'] = $r[0]['parent-uri'];
} }

View File

@ -79,7 +79,7 @@ function reload_plugins() {
if(strlen($plugins)) { if(strlen($plugins)) {
$r = q("SELECT * FROM `addon` WHERE `installed` = 1"); $r = q("SELECT * FROM `addon` WHERE `installed` = 1");
if(count($r)) if(dbm::is_result($r))
$installed = $r; $installed = $r;
else else
$installed = array(); $installed = array();
@ -150,7 +150,7 @@ function register_hook($hook,$file,$function,$priority=0) {
dbesc($file), dbesc($file),
dbesc($function) dbesc($function)
); );
if(count($r)) if(dbm::is_result($r))
return true; return true;
$r = q("INSERT INTO `hook` (`hook`, `file`, `function`, `priority`) VALUES ( '%s', '%s', '%s', '%s' ) ", $r = q("INSERT INTO `hook` (`hook`, `file`, `function`, `priority`) VALUES ( '%s', '%s', '%s', '%s' ) ",
@ -187,7 +187,7 @@ function load_hooks() {
$a = get_app(); $a = get_app();
$a->hooks = array(); $a->hooks = array();
$r = q("SELECT * FROM `hook` WHERE 1 ORDER BY `priority` DESC, `file`"); $r = q("SELECT * FROM `hook` WHERE 1 ORDER BY `priority` DESC, `file`");
if(count($r)) { if(dbm::is_result($r)) {
foreach($r as $rr) { foreach($r as $rr) {
if(! array_key_exists($rr['hook'],$a->hooks)) if(! array_key_exists($rr['hook'],$a->hooks))
$a->hooks[$rr['hook']] = array(); $a->hooks[$rr['hook']] = array();
@ -473,7 +473,7 @@ function service_class_allows($uid,$property,$usage = false) {
$r = q("SELECT `service_class` FROM `user` WHERE `uid` = %d LIMIT 1", $r = q("SELECT `service_class` FROM `user` WHERE `uid` = %d LIMIT 1",
intval($uid) intval($uid)
); );
if($r !== false and count($r)) { if(dbm::is_result($r)) {
$service_class = $r[0]['service_class']; $service_class = $r[0]['service_class'];
} }
} }
@ -503,7 +503,7 @@ function service_class_fetch($uid,$property) {
$r = q("SELECT `service_class` FROM `user` WHERE `uid` = %d LIMIT 1", $r = q("SELECT `service_class` FROM `user` WHERE `uid` = %d LIMIT 1",
intval($uid) intval($uid)
); );
if($r !== false and count($r)) { if(dbm::is_result($r)) {
$service_class = $r[0]['service_class']; $service_class = $r[0]['service_class'];
} }
} }

View File

@ -61,7 +61,7 @@ function add_to_queue($cid,$network,$msg,$batch = false) {
WHERE `queue`.`cid` = %d AND `contact`.`self` = 0 ", WHERE `queue`.`cid` = %d AND `contact`.`self` = 0 ",
intval($cid) intval($cid)
); );
if($r && count($r)) { if(dbm::is_result($r)) {
if($batch && ($r[0]['total'] > $batch_queue)) { if($batch && ($r[0]['total'] > $batch_queue)) {
logger('add_to_queue: too many queued items for batch server ' . $cid . ' - discarding message'); logger('add_to_queue: too many queued items for batch server ' . $cid . ' - discarding message');
return; return;

View File

@ -36,7 +36,7 @@ function auto_redir(&$a, $contact_nick) {
dbesc($nurl) dbesc($nurl)
); );
if((!$r) || (! count($r)) || $r[0]['id'] == remote_user()) if((! dbm::is_result($r)) || $r[0]['id'] == remote_user())
return; return;
@ -48,7 +48,7 @@ function auto_redir(&$a, $contact_nick) {
dbesc($baseurl) dbesc($baseurl)
); );
if(! ($r && count($r))) if(! dbm::is_result($r))
return; return;
$cid = $r[0]['id']; $cid = $r[0]['id'];

View File

@ -42,7 +42,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive
$r = q("select * from user where uid = %d limit 1", $r = q("select * from user where uid = %d limit 1",
intval($_SESSION['submanage']) intval($_SESSION['submanage'])
); );
if(count($r)) if(dbm::is_result($r))
$master_record = $r[0]; $master_record = $r[0];
} }
@ -50,7 +50,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive
dbesc($master_record['password']), dbesc($master_record['password']),
dbesc($master_record['email']) dbesc($master_record['email'])
); );
if($r && count($r)) if(dbm::is_result($r))
$a->identities = $r; $a->identities = $r;
else else
$a->identities = array(); $a->identities = array();
@ -60,7 +60,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive
and `manage`.`uid` = %d", and `manage`.`uid` = %d",
intval($master_record['uid']) intval($master_record['uid'])
); );
if($r && count($r)) if(dbm::is_result($r))
$a->identities = array_merge($a->identities,$r); $a->identities = array_merge($a->identities,$r);
if($login_initial) if($login_initial)
@ -70,7 +70,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1", $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
intval($_SESSION['uid'])); intval($_SESSION['uid']));
if(count($r)) { if(dbm::is_result($r)) {
$a->contact = $r[0]; $a->contact = $r[0];
$a->cid = $r[0]['id']; $a->cid = $r[0]['id'];
$_SESSION['cid'] = $a->cid; $_SESSION['cid'] = $a->cid;
@ -156,7 +156,7 @@ function can_write_wall(&$a,$owner) {
intval(PAGE_COMMUNITY) intval(PAGE_COMMUNITY)
); );
if(count($r)) { if(dbm::is_result($r)) {
$verified = 2; $verified = 2;
return true; return true;
} }
@ -210,7 +210,7 @@ function permissions_sql($owner_id,$remote_verified = false,$groups = null) {
intval($remote_user), intval($remote_user),
intval($owner_id) intval($owner_id)
); );
if(count($r)) { if(dbm::is_result($r)) {
$remote_verified = true; $remote_verified = true;
$groups = init_groups_visitor($remote_user); $groups = init_groups_visitor($remote_user);
} }
@ -292,7 +292,7 @@ function item_permissions_sql($owner_id,$remote_verified = false,$groups = null)
intval($remote_user), intval($remote_user),
intval($owner_id) intval($owner_id)
); );
if(count($r)) { if(dbm::is_result($r)) {
$remote_verified = true; $remote_verified = true;
$groups = init_groups_visitor($remote_user); $groups = init_groups_visitor($remote_user);
} }
@ -403,7 +403,7 @@ function init_groups_visitor($contact_id) {
WHERE `contact-id` = %d ", WHERE `contact-id` = %d ",
intval($contact_id) intval($contact_id)
); );
if(count($r)) { if(dbm::is_result($r)) {
foreach($r as $rr) foreach($r as $rr)
$groups[] = $rr['gid']; $groups[] = $rr['gid'];
} }

View File

@ -40,7 +40,7 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
$r = q("select `poco`, `uid` from `contact` where `id` = %d limit 1", $r = q("select `poco`, `uid` from `contact` where `id` = %d limit 1",
intval($cid) intval($cid)
); );
if(count($r)) { if(dbm::is_result($r)) {
$url = $r[0]['poco']; $url = $r[0]['poco'];
$uid = $r[0]['uid']; $uid = $r[0]['uid'];
} }
@ -213,14 +213,14 @@ function poco_check($profile_url, $name, $network, $profile_photo, $about, $loca
$r = q("SELECT `network` FROM `contact` WHERE `nurl` = '%s' AND `network` != '' AND `network` != '%s' LIMIT 1", $r = q("SELECT `network` FROM `contact` WHERE `nurl` = '%s' AND `network` != '' AND `network` != '%s' LIMIT 1",
dbesc(normalise_link($profile_url)), dbesc(NETWORK_STATUSNET) dbesc(normalise_link($profile_url)), dbesc(NETWORK_STATUSNET)
); );
if(count($r)) if(dbm::is_result($r))
$network = $r[0]["network"]; $network = $r[0]["network"];
if (($network == "") OR ($network == NETWORK_OSTATUS)) { if (($network == "") OR ($network == NETWORK_OSTATUS)) {
$r = q("SELECT `network`, `url` FROM `contact` WHERE `alias` IN ('%s', '%s') AND `network` != '' AND `network` != '%s' LIMIT 1", $r = q("SELECT `network`, `url` FROM `contact` WHERE `alias` IN ('%s', '%s') AND `network` != '' AND `network` != '%s' LIMIT 1",
dbesc($profile_url), dbesc(normalise_link($profile_url)), dbesc(NETWORK_STATUSNET) dbesc($profile_url), dbesc(normalise_link($profile_url)), dbesc(NETWORK_STATUSNET)
); );
if(count($r)) { if(dbm::is_result($r)) {
$network = $r[0]["network"]; $network = $r[0]["network"];
//$profile_url = $r[0]["url"]; //$profile_url = $r[0]["url"];
} }
@ -330,7 +330,7 @@ function poco_check($profile_url, $name, $network, $profile_photo, $about, $loca
intval($gcid), intval($gcid),
intval($zcid) intval($zcid)
); );
if(! count($r)) { if(! dbm::is_result($r)) {
q("INSERT INTO `glink` (`cid`,`uid`,`gcid`,`zcid`, `updated`) VALUES (%d,%d,%d,%d, '%s') ", q("INSERT INTO `glink` (`cid`,`uid`,`gcid`,`zcid`, `updated`) VALUES (%d,%d,%d,%d, '%s') ",
intval($cid), intval($cid),
intval($uid), intval($uid),
@ -976,7 +976,7 @@ function count_common_friends($uid,$cid) {
); );
// logger("count_common_friends: $uid $cid {$r[0]['total']}"); // logger("count_common_friends: $uid $cid {$r[0]['total']}");
if(count($r)) if(dbm::is_result($r))
return $r[0]['total']; return $r[0]['total'];
return 0; return 0;
@ -1022,7 +1022,7 @@ function count_common_friends_zcid($uid,$zcid) {
intval($uid) intval($uid)
); );
if(count($r)) if(dbm::is_result($r))
return $r[0]['total']; return $r[0]['total'];
return 0; return 0;
@ -1061,7 +1061,7 @@ function count_all_friends($uid,$cid) {
intval($uid) intval($uid)
); );
if(count($r)) if(dbm::is_result($r))
return $r[0]['total']; return $r[0]['total'];
return 0; return 0;
@ -1133,7 +1133,7 @@ function suggestion_query($uid, $start = 0, $limit = 80) {
intval($limit) intval($limit)
); );
if (count($r) && count($r) >= ($limit -1)) { if (dbm::is_result($r) && count($r) >= ($limit -1)) {
// Uncommented because the result of the queries are to big to store it in the cache. // Uncommented because the result of the queries are to big to store it in the cache.
// We need to decide if we want to change the db column type or if we want to delete it. // We need to decide if we want to change the db column type or if we want to delete it.
// Cache::set("suggestion_query:".$uid.":".$start.":".$limit, $r, CACHE_FIVE_MINUTES); // Cache::set("suggestion_query:".$uid.":".$start.":".$limit, $r, CACHE_FIVE_MINUTES);
@ -1207,7 +1207,7 @@ function update_suggestions() {
dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA) dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA)
); );
if(count($r)) { if(dbm::is_result($r)) {
foreach($r as $rr) { foreach($r as $rr) {
$base = substr($rr['poco'],0,strrpos($rr['poco'],'/')); $base = substr($rr['poco'],0,strrpos($rr['poco'],'/'));
if(! in_array($base,$done)) if(! in_array($base,$done))

View File

@ -491,7 +491,7 @@ function item_new_uri($hostname,$uid, $guid = "") {
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1", $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1",
dbesc($uri)); dbesc($uri));
if(count($r)) if(dbm::is_result($r))
$dups = true; $dups = true;
} while($dups == true); } while($dups == true);
return $uri; return $uri;
@ -515,7 +515,7 @@ function photo_new_resource() {
$r = q("SELECT `id` FROM `photo` WHERE `resource-id` = '%s' LIMIT 1", $r = q("SELECT `id` FROM `photo` WHERE `resource-id` = '%s' LIMIT 1",
dbesc($resource) dbesc($resource)
); );
if(count($r)) if(dbm::is_result($r))
$found = true; $found = true;
} while($found == true); } while($found == true);
return $resource; return $resource;
@ -882,7 +882,7 @@ function contact_block() {
dbesc(NETWORK_OSTATUS), dbesc(NETWORK_OSTATUS),
dbesc(NETWORK_DIASPORA) dbesc(NETWORK_DIASPORA)
); );
if(count($r)) { if(dbm::is_result($r)) {
$total = intval($r[0]['total']); $total = intval($r[0]['total']);
} }
if(! $total) { if(! $total) {
@ -908,7 +908,7 @@ function contact_block() {
$r = q("SELECT `id`, `uid`, `addr`, `url`, `name`, `thumb`, `network` FROM `contact` WHERE `id` IN (%s)", $r = q("SELECT `id`, `uid`, `addr`, `url`, `name`, `thumb`, `network` FROM `contact` WHERE `id` IN (%s)",
dbesc(implode(",", $contacts))); dbesc(implode(",", $contacts)));
if(count($r)) { if(dbm::is_result($r)) {
$contacts = sprintf( tt('%d Contact','%d Contacts', $total),$total); $contacts = sprintf( tt('%d Contact','%d Contacts', $total),$total);
$micropro = Array(); $micropro = Array();
foreach($r as $rr) { foreach($r as $rr) {
@ -1931,7 +1931,7 @@ function file_tag_update_pconfig($uid,$file_old,$file_new,$type = 'file') {
// intval($uid) // intval($uid)
//); //);
if(count($r)) { if(dbm::is_result($r)) {
unset($deleted_tags[$key]); unset($deleted_tags[$key]);
} }
else { else {
@ -1961,7 +1961,7 @@ function file_tag_save_file($uid,$item,$file) {
intval($item), intval($item),
intval($uid) intval($uid)
); );
if(count($r)) { if(dbm::is_result($r)) {
if(! stristr($r[0]['file'],'[' . file_tag_encode($file) . ']')) if(! stristr($r[0]['file'],'[' . file_tag_encode($file) . ']'))
q("UPDATE `item` SET `file` = '%s' WHERE `id` = %d AND `uid` = %d", q("UPDATE `item` SET `file` = '%s' WHERE `id` = %d AND `uid` = %d",
dbesc($r[0]['file'] . '[' . file_tag_encode($file) . ']'), dbesc($r[0]['file'] . '[' . file_tag_encode($file) . ']'),
@ -1999,7 +1999,7 @@ function file_tag_unsave_file($uid,$item,$file,$cat = false) {
intval($item), intval($item),
intval($uid) intval($uid)
); );
if(! count($r)) if(! dbm::is_result($r))
return false; return false;
q("UPDATE `item` SET `file` = '%s' WHERE `id` = %d AND `uid` = %d", q("UPDATE `item` SET `file` = '%s' WHERE `id` = %d AND `uid` = %d",
@ -2019,7 +2019,7 @@ function file_tag_unsave_file($uid,$item,$file,$cat = false) {
//$r = q("select file from item where uid = %d and deleted = 0 " . file_tag_file_query('item',$file,(($cat) ? 'category' : 'file')), //$r = q("select file from item where uid = %d and deleted = 0 " . file_tag_file_query('item',$file,(($cat) ? 'category' : 'file')),
//); //);
if(! count($r)) { if(! dbm::is_result($r)) {
$saved = get_pconfig($uid,'system','filetags'); $saved = get_pconfig($uid,'system','filetags');
set_pconfig($uid,'system','filetags',str_replace($pattern,'',$saved)); set_pconfig($uid,'system','filetags',str_replace($pattern,'',$saved));

View File

@ -142,12 +142,12 @@ function add_shadow_entry($itemid) {
// Is there a shadow parent? // Is there a shadow parent?
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = 0 LIMIT 1", dbesc($item['parent-uri'])); $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = 0 LIMIT 1", dbesc($item['parent-uri']));
if (!count($r)) if (!dbm::is_result($r))
return; return;
// Is there already a shadow entry? // Is there already a shadow entry?
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = 0 LIMIT 1", dbesc($item['uri'])); $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = 0 LIMIT 1", dbesc($item['uri']));
if (count($r)) if (dbm::is_result($r))
return; return;
// Preparing public shadow (removing user specific data) // Preparing public shadow (removing user specific data)
@ -241,7 +241,7 @@ function delete_thread($itemid, $itemuri = "") {
dbesc($itemuri), dbesc($itemuri),
intval($item["uid"]) intval($item["uid"])
); );
if (!count($r)) { if (!dbm::is_result($r)) {
$r = q("DELETE FROM `item` WHERE `uri` = '%s' AND `uid` = 0", $r = q("DELETE FROM `item` WHERE `uri` = '%s' AND `uid` = 0",
dbesc($itemuri) dbesc($itemuri)
); );

View File

@ -116,7 +116,7 @@ function import_account(&$a, $file) {
notice(t('Error! Cannot check nickname')); notice(t('Error! Cannot check nickname'));
return; return;
} }
if (count($r) > 0) { if (dbm::is_result($r) > 0) {
notice(sprintf(t("User '%s' already exists on this server!"), $account['user']['nickname'])); notice(sprintf(t("User '%s' already exists on this server!"), $account['user']['nickname']));
return; return;
} }
@ -127,7 +127,7 @@ function import_account(&$a, $file) {
notice(t('Error! Cannot check nickname')); notice(t('Error! Cannot check nickname'));
return; return;
} }
if (count($r) > 0) { if (dbm::is_result($r) > 0) {
notice(sprintf(t("User '%s' already exists on this server!"), $account['user']['nickname'])); notice(sprintf(t("User '%s' already exists on this server!"), $account['user']['nickname']));
return; return;
} }

View File

@ -130,7 +130,7 @@ function create_user($arr) {
$r = q("SELECT * FROM `user` WHERE `email` = '%s' LIMIT 1", $r = q("SELECT * FROM `user` WHERE `email` = '%s' LIMIT 1",
dbesc($email) dbesc($email)
); );
if(count($r)) if(dbm::is_result($r))
$result['message'] .= t('Cannot use that email.') . EOL; $result['message'] .= t('Cannot use that email.') . EOL;
} }
@ -143,7 +143,7 @@ function create_user($arr) {
WHERE `nickname` = '%s' LIMIT 1", WHERE `nickname` = '%s' LIMIT 1",
dbesc($nickname) dbesc($nickname)
); );
if(count($r)) if(dbm::is_result($r))
$result['message'] .= t('Nickname is already registered. Please choose another.') . EOL; $result['message'] .= t('Nickname is already registered. Please choose another.') . EOL;
// Check deleted accounts that had this nickname. Doesn't matter to us, // Check deleted accounts that had this nickname. Doesn't matter to us,
@ -153,7 +153,7 @@ function create_user($arr) {
WHERE `username` = '%s' LIMIT 1", WHERE `username` = '%s' LIMIT 1",
dbesc($nickname) dbesc($nickname)
); );
if(count($r)) if(dbm::is_result($r))
$result['message'] .= t('Nickname was once registered here and may not be re-used. Please choose another.') . EOL; $result['message'] .= t('Nickname was once registered here and may not be re-used. Please choose another.') . EOL;
if(strlen($result['message'])) { if(strlen($result['message'])) {
@ -222,7 +222,7 @@ function create_user($arr) {
dbesc($username), dbesc($username),
dbesc($new_password_encoded) dbesc($new_password_encoded)
); );
if($r !== false && count($r)) { if(dbm::is_result($r)) {
$u = $r[0]; $u = $r[0];
$newuid = intval($r[0]['uid']); $newuid = intval($r[0]['uid']);
} }
@ -302,7 +302,7 @@ function create_user($arr) {
intval($newuid), intval($newuid),
dbesc(t('Friends')) dbesc(t('Friends'))
); );
if($r && count($r)) { if(dbm::is_result($r)) {
$def_gid = $r[0]['id']; $def_gid = $r[0]['id'];
q("UPDATE `user` SET `def_gid` = %d WHERE `uid` = %d", q("UPDATE `user` SET `def_gid` = %d WHERE `uid` = %d",

View File

@ -1121,7 +1121,7 @@ function admin_page_dbsync(&$a) {
$failed = array(); $failed = array();
$r = q("SELECT `k`, `v` FROM `config` WHERE `cat` = 'database' "); $r = q("SELECT `k`, `v` FROM `config` WHERE `cat` = 'database' ");
if(count($r)) { if(dbm::is_result($r)) {
foreach($r as $rr) { foreach($r as $rr) {
$upd = intval(substr($rr['k'],7)); $upd = intval(substr($rr['k'],7));
if($upd < 1139 || $rr['v'] === 'success') if($upd < 1139 || $rr['v'] === 'success')

View File

@ -39,7 +39,7 @@ function allfriends_content(&$a) {
$r = all_friends(local_user(), $cid, $a->pager['start'], $a->pager['itemspage']); $r = all_friends(local_user(), $cid, $a->pager['start'], $a->pager['itemspage']);
if(! count($r)) { if(! dbm::is_result($r)) {
$o .= t('No friends to display.'); $o .= t('No friends to display.');
return $o; return $o;
} }

View File

@ -14,7 +14,7 @@ function oauth_get_client($request){
AND `tokens`.`id`='%s' AND `tokens`.`scope`='request'", AND `tokens`.`id`='%s' AND `tokens`.`scope`='request'",
dbesc($token)); dbesc($token));
if (!count($r)) if (!dbm::is_result($r))
return null; return null;
return $r[0]; return $r[0];

View File

@ -16,7 +16,7 @@ function attach_init(&$a) {
$r = q("SELECT * FROM `attach` WHERE `id` = %d LIMIT 1", $r = q("SELECT * FROM `attach` WHERE `id` = %d LIMIT 1",
intval($item_id) intval($item_id)
); );
if(! count($r)) { if(! dbm::is_result($r)) {
notice( t('Item was not found.'). EOL); notice( t('Item was not found.'). EOL);
return; return;
} }
@ -29,7 +29,7 @@ function attach_init(&$a) {
dbesc($item_id) dbesc($item_id)
); );
if(! count($r)) { if(! dbm::is_result($r)) {
notice( t('Permission denied.') . EOL); notice( t('Permission denied.') . EOL);
return; return;
} }

View File

@ -132,7 +132,7 @@ function cal_content(&$a) {
intval($contact_id), intval($contact_id),
intval($a->profile['profile_uid']) intval($a->profile['profile_uid'])
); );
if(count($r)) { if(dbm::is_result($r)) {
$contact = $r[0]; $contact = $r[0];
$remote_contact = true; $remote_contact = true;
} }
@ -227,7 +227,7 @@ function cal_content(&$a) {
$links = array(); $links = array();
if(count($r)) { if(dbm::is_result($r)) {
$r = sort_by_date($r); $r = sort_by_date($r);
foreach($r as $rr) { foreach($r as $rr) {
$j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j')); $j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j'));
@ -240,7 +240,7 @@ function cal_content(&$a) {
$events=array(); $events=array();
// transform the event in a usable array // transform the event in a usable array
if(count($r)) if(dbm::is_result($r))
$r = sort_by_date($r); $r = sort_by_date($r);
$events = process_events($r); $events = process_events($r);

View File

@ -57,13 +57,13 @@ function common_content(&$a) {
dbesc(normalise_link(get_my_url())), dbesc(normalise_link(get_my_url())),
intval($profile_uid) intval($profile_uid)
); );
if(count($r)) if(dbm::is_result($r))
$cid = $r[0]['id']; $cid = $r[0]['id'];
else { else {
$r = q("SELECT `id` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1", $r = q("SELECT `id` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
dbesc(normalise_link(get_my_url())) dbesc(normalise_link(get_my_url()))
); );
if(count($r)) if(dbm::is_result($r))
$zcid = $r[0]['id']; $zcid = $r[0]['id'];
} }
} }
@ -94,7 +94,7 @@ function common_content(&$a) {
$r = common_friends_zcid($uid, $zcid, $a->pager['start'], $a->pager['itemspage']); $r = common_friends_zcid($uid, $zcid, $a->pager['start'], $a->pager['itemspage']);
if(! count($r)) { if(! dbm::is_result($r)) {
return $o; return $o;
} }

View File

@ -59,7 +59,7 @@ function community_content(&$a, $update = 0) {
AND `item`.`private` = 0 AND `item`.`wall` = 1" AND `item`.`private` = 0 AND `item`.`wall` = 1"
); );
if(count($r)) if(dbm::is_result($r))
$a->set_pager_total($r[0]['total']); $a->set_pager_total($r[0]['total']);
if(! $r[0]['total']) { if(! $r[0]['total']) {
@ -71,7 +71,7 @@ function community_content(&$a, $update = 0) {
$r = community_getitems($a->pager['start'], $a->pager['itemspage']); $r = community_getitems($a->pager['start'], $a->pager['itemspage']);
if(! count($r)) { if(! dbm::is_result($r)) {
info( t('No results.') . EOL); info( t('No results.') . EOL);
return $o; return $o;
} }

View File

@ -14,7 +14,7 @@ function contactgroup_content(&$a) {
intval($a->argv[2]), intval($a->argv[2]),
intval(local_user()) intval(local_user())
); );
if(count($r)) if(dbm::is_result($r))
$change = intval($a->argv[2]); $change = intval($a->argv[2]);
} }
@ -24,7 +24,7 @@ function contactgroup_content(&$a) {
intval($a->argv[1]), intval($a->argv[1]),
intval(local_user()) intval(local_user())
); );
if(! count($r)) { if(! dbm::is_result($r)) {
killme(); killme();
} }

View File

@ -19,7 +19,7 @@ function contacts_init(&$a) {
intval(local_user()), intval(local_user()),
intval($contact_id) intval($contact_id)
); );
if(! count($r)) { if(! dbm::is_result($r)) {
$contact_id = 0; $contact_id = 0;
} }
} }
@ -169,7 +169,7 @@ function contacts_post(&$a) {
intval($profile_id), intval($profile_id),
intval(local_user()) intval(local_user())
); );
if(! count($r)) { if(! dbm::is_result($r)) {
notice( t('Could not locate selected profile.') . EOL); notice( t('Could not locate selected profile.') . EOL);
return; return;
} }
@ -211,7 +211,7 @@ function contacts_post(&$a) {
intval($contact_id), intval($contact_id),
intval(local_user()) intval(local_user())
); );
if($r && count($r)) if($r && dbm::is_result($r))
$a->data['contact'] = $r[0]; $a->data['contact'] = $r[0];
return; return;
@ -765,7 +765,7 @@ function contacts_content(&$a) {
$r = q("SELECT COUNT(*) AS `total` FROM `contact` $r = q("SELECT COUNT(*) AS `total` FROM `contact`
WHERE `uid` = %d AND `self` = 0 AND `pending` = 0 $sql_extra $sql_extra2 ", WHERE `uid` = %d AND `self` = 0 AND `pending` = 0 $sql_extra $sql_extra2 ",
intval($_SESSION['uid'])); intval($_SESSION['uid']));
if(count($r)) { if(dbm::is_result($r)) {
$a->set_pager_total($r[0]['total']); $a->set_pager_total($r[0]['total']);
$total = $r[0]['total']; $total = $r[0]['total'];
} }
@ -780,7 +780,7 @@ function contacts_content(&$a) {
$contacts = array(); $contacts = array();
if(count($r)) { if(dbm::is_result($r)) {
foreach($r as $rr) { foreach($r as $rr) {
$contacts[] = _contact_detail_for_template($rr); $contacts[] = _contact_detail_for_template($rr);
} }

View File

@ -93,7 +93,7 @@ function content_content(&$a, $update = 0) {
); );
$str = ''; $str = '';
if(count($r)) if(dbm::is_result($r))
foreach($r as $rr) foreach($r as $rr)
$str .= '<' . $rr['id'] . '>'; $str .= '<' . $rr['id'] . '>';
if(strlen($str)) if(strlen($str))
@ -113,7 +113,7 @@ function content_content(&$a, $update = 0) {
intval($group), intval($group),
intval($_SESSION['uid']) intval($_SESSION['uid'])
); );
if(! count($r)) { if(! dbm::is_result($r)) {
if($update) if($update)
killme(); killme();
notice( t('No such group') . EOL ); notice( t('No such group') . EOL );
@ -141,7 +141,7 @@ function content_content(&$a, $update = 0) {
AND `blocked` = 0 AND `pending` = 0 LIMIT 1", AND `blocked` = 0 AND `pending` = 0 LIMIT 1",
intval($cid) intval($cid)
); );
if(count($r)) { if(dbm::is_result($r)) {
$sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $sql_options AND `contact-id` = " . intval($cid) . " and deleted = 0 ) "; $sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $sql_options AND `contact-id` = " . intval($cid) . " and deleted = 0 ) ";
} }
@ -259,7 +259,7 @@ function content_content(&$a, $update = 0) {
$parents_arr = array(); $parents_arr = array();
$parents_str = ''; $parents_str = '';
if(count($r)) { if(dbm::is_result($r)) {
foreach($r as $rr) foreach($r as $rr)
if(! in_array($rr['item_id'],$parents_arr)) if(! in_array($rr['item_id'],$parents_arr))
$parents_arr[] = $rr['item_id']; $parents_arr[] = $rr['item_id'];
@ -782,7 +782,7 @@ function render_content(&$a, $items, $mode, $update, $preview = false) {
intval($item['uid']), intval($item['uid']),
intval($item['id']) intval($item['id'])
); );
if (count($r)) { if (dbm::is_result($r)) {
$ignore = array( $ignore = array(
'do' => t("ignore thread"), 'do' => t("ignore thread"),
'undo' => t("unignore thread"), 'undo' => t("unignore thread"),

View File

@ -14,7 +14,7 @@ function crepair_init(&$a) {
intval(local_user()), intval(local_user()),
intval($contact_id) intval($contact_id)
); );
if(! count($r)) { if(! dbm::is_result($r)) {
$contact_id = 0; $contact_id = 0;
} }
} }
@ -43,7 +43,7 @@ function crepair_post(&$a) {
); );
} }
if(! count($r)) if(! dbm::is_result($r))
return; return;
$contact = $r[0]; $contact = $r[0];
@ -110,7 +110,7 @@ function crepair_content(&$a) {
); );
} }
if(! count($r)) { if(! dbm::is_result($r)) {
notice( t('Contact not found.') . EOL); notice( t('Contact not found.') . EOL);
return; return;
} }

View File

@ -26,12 +26,12 @@ function delegate_content(&$a) {
$r = q("select `nickname` from user where uid = %d limit 1", $r = q("select `nickname` from user where uid = %d limit 1",
intval($id) intval($id)
); );
if(count($r)) { if(dbm::is_result($r)) {
$r = q("select id from contact where uid = %d and nurl = '%s' limit 1", $r = q("select id from contact where uid = %d and nurl = '%s' limit 1",
intval(local_user()), intval(local_user()),
dbesc(normalise_link($a->get_baseurl() . '/profile/' . $r[0]['nickname'])) dbesc(normalise_link($a->get_baseurl() . '/profile/' . $r[0]['nickname']))
); );
if(count($r)) { if(dbm::is_result($r)) {
q("insert into manage ( uid, mid ) values ( %d , %d ) ", q("insert into manage ( uid, mid ) values ( %d , %d ) ",
intval($a->argv[2]), intval($a->argv[2]),
intval(local_user()) intval(local_user())
@ -64,7 +64,7 @@ function delegate_content(&$a) {
dbesc($a->user['email']), dbesc($a->user['email']),
dbesc($a->user['password']) dbesc($a->user['password'])
); );
if(count($r)) if(dbm::is_result($r))
$full_managers = $r; $full_managers = $r;
$delegates = array(); $delegates = array();
@ -75,7 +75,7 @@ function delegate_content(&$a) {
intval(local_user()) intval(local_user())
); );
if(count($r)) if(dbm::is_result($r))
$delegates = $r; $delegates = $r;
$uids = array(); $uids = array();
@ -97,14 +97,14 @@ function delegate_content(&$a) {
dbesc(NETWORK_DFRN) dbesc(NETWORK_DFRN)
); );
if(! count($r)) { if(! dbm::is_result($r)) {
notice( t('No potential page delegates located.') . EOL); notice( t('No potential page delegates located.') . EOL);
return; return;
} }
$nicknames = array(); $nicknames = array();
if(count($r)) { if(dbm::is_result($r)) {
foreach($r as $rr) { foreach($r as $rr) {
$nicknames[] = "'" . dbesc(basename($rr['nurl'])) . "'"; $nicknames[] = "'" . dbesc(basename($rr['nurl'])) . "'";
} }
@ -118,7 +118,7 @@ function delegate_content(&$a) {
$r = q("select `uid`, `username`, `nickname` from user where nickname in ( $nicks )"); $r = q("select `uid`, `username`, `nickname` from user where nickname in ( $nicks )");
if(count($r)) if(dbm::is_result($r))
foreach($r as $rr) foreach($r as $rr)
if(! in_array($rr['uid'],$uids)) if(! in_array($rr['uid'],$uids))
$potentials[] = $rr; $potentials[] = $rr;

View File

@ -121,7 +121,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
intval($uid) intval($uid)
); );
if(! count($r)) { if(! dbm::is_result($r)) {
logger('Contact not found in DB.'); logger('Contact not found in DB.');
notice( t('Contact not found.') . EOL ); notice( t('Contact not found.') . EOL );
notice( t('This may occasionally happen if contact was requested by both persons and it has already been approved.') . EOL ); notice( t('This may occasionally happen if contact was requested by both persons and it has already been approved.') . EOL );
@ -423,7 +423,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
$r = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1", $r = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
intval($contact_id) intval($contact_id)
); );
if(count($r)) if(dbm::is_result($r))
$contact = $r[0]; $contact = $r[0];
else else
$contact = null; $contact = null;
@ -443,7 +443,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
intval($uid) intval($uid)
); );
if((count($r)) && ($r[0]['hide-friends'] == 0) && ($activity) && (! $hidden)) { if((dbm::is_result($r)) && ($r[0]['hide-friends'] == 0) && ($activity) && (! $hidden)) {
require_once('include/items.php'); require_once('include/items.php');
@ -553,7 +553,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
$r = q("SELECT * FROM `user` WHERE `nickname` = '%s' LIMIT 1", $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' LIMIT 1",
dbesc($node)); dbesc($node));
if(! count($r)) { if(! dbm::is_result($r)) {
$message = sprintf(t('No user record found for \'%s\' '), $node); $message = sprintf(t('No user record found for \'%s\' '), $node);
xml_status(3,$message); // failure xml_status(3,$message); // failure
// NOTREACHED // NOTREACHED
@ -629,7 +629,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
$r = q("SELECT * FROM `contact` WHERE `dfrn-id` = '%s' LIMIT 1", $r = q("SELECT * FROM `contact` WHERE `dfrn-id` = '%s' LIMIT 1",
dbesc($decrypted_dfrn_id) dbesc($decrypted_dfrn_id)
); );
if(count($r)) { if(dbm::is_result($r)) {
$message = t('The ID provided by your system is a duplicate on our system. It should work if you try again.'); $message = t('The ID provided by your system is a duplicate on our system. It should work if you try again.');
xml_status(1,$message); // Birthday paradox - duplicate dfrn-id xml_status(1,$message); // Birthday paradox - duplicate dfrn-id
// NOTREACHED // NOTREACHED
@ -640,7 +640,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
dbesc($dfrn_pubkey), dbesc($dfrn_pubkey),
intval($dfrn_record) intval($dfrn_record)
); );
if(! count($r)) { if(! dbm::is_result($r)) {
$message = t('Unable to set your contact credentials on our system.'); $message = t('Unable to set your contact credentials on our system.');
xml_status(3,$message); xml_status(3,$message);
} }
@ -661,7 +661,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
$r = q("SELECT `photo` FROM `contact` WHERE `id` = %d LIMIT 1", $r = q("SELECT `photo` FROM `contact` WHERE `id` = %d LIMIT 1",
intval($dfrn_record)); intval($dfrn_record));
if(count($r)) if(dbm::is_result($r))
$photo = $r[0]['photo']; $photo = $r[0]['photo'];
else else
$photo = $a->get_baseurl() . '/images/person-175.jpg'; $photo = $a->get_baseurl() . '/images/person-175.jpg';
@ -714,10 +714,10 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
intval($dfrn_record) intval($dfrn_record)
); );
if(count($r)) if(dbm::is_result($r))
$combined = $r[0]; $combined = $r[0];
if((count($r)) && ($r[0]['notify-flags'] & NOTIFY_CONFIRM)) { if((dbm::is_result($r)) && ($r[0]['notify-flags'] & NOTIFY_CONFIRM)) {
$mutual = ($new_relation == CONTACT_IS_FRIEND); $mutual = ($new_relation == CONTACT_IS_FRIEND);
notification(array( notification(array(
'type' => NOTIFY_CONFIRM, 'type' => NOTIFY_CONFIRM,
@ -742,7 +742,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
intval($local_uid) intval($local_uid)
); );
if((count($r)) && ($r[0]['hide-friends'] == 0)) { if((dbm::is_result($r)) && ($r[0]['hide-friends'] == 0)) {
require_once('include/items.php'); require_once('include/items.php');

View File

@ -42,7 +42,7 @@ function dfrn_notify_post(&$a) {
dbesc($dfrn_id), dbesc($dfrn_id),
dbesc($challenge) dbesc($challenge)
); );
if(! count($r)) { if(! dbm::is_result($r)) {
logger('dfrn_notify: could not match challenge to dfrn_id ' . $dfrn_id . ' challenge=' . $challenge); logger('dfrn_notify: could not match challenge to dfrn_id ' . $dfrn_id . ' challenge=' . $challenge);
xml_status(3); xml_status(3);
} }
@ -88,7 +88,7 @@ function dfrn_notify_post(&$a) {
dbesc($a->argv[1]) dbesc($a->argv[1])
); );
if(! count($r)) { if(! dbm::is_result($r)) {
logger('dfrn_notify: contact not found for dfrn_id ' . $dfrn_id); logger('dfrn_notify: contact not found for dfrn_id ' . $dfrn_id);
xml_status(3); xml_status(3);
//NOTREACHED //NOTREACHED
@ -284,7 +284,7 @@ function dfrn_notify_content(&$a) {
dbesc($a->argv[1]) dbesc($a->argv[1])
); );
if(! count($r)) if(! dbm::is_result($r))
$status = 1; $status = 1;
logger("Remote rino version: ".$rino_remote." for ".$r[0]["url"], LOGGER_DEBUG); logger("Remote rino version: ".$rino_remote." for ".$r[0]["url"], LOGGER_DEBUG);

View File

@ -79,7 +79,7 @@ function dfrn_poll_init(&$a) {
dbesc($a->argv[1]) dbesc($a->argv[1])
); );
if(count($r)) { if(dbm::is_result($r)) {
$s = fetch_url($r[0]['poll'] . '?dfrn_id=' . $my_id . '&type=profile-check'); $s = fetch_url($r[0]['poll'] . '?dfrn_id=' . $my_id . '&type=profile-check');
@ -126,7 +126,7 @@ function dfrn_poll_init(&$a) {
$r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1", $r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1",
dbesc($sec) dbesc($sec)
); );
if(! count($r)) { if(! dbm::is_result($r)) {
xml_status(3, 'No ticket'); xml_status(3, 'No ticket');
// NOTREACHED // NOTREACHED
} }
@ -190,7 +190,7 @@ function dfrn_poll_init(&$a) {
q("DELETE FROM `profile_check` WHERE `expire` < " . intval(time())); q("DELETE FROM `profile_check` WHERE `expire` < " . intval(time()));
$r = q("SELECT * FROM `profile_check` WHERE `dfrn_id` = '%s' ORDER BY `expire` DESC", $r = q("SELECT * FROM `profile_check` WHERE `dfrn_id` = '%s' ORDER BY `expire` DESC",
dbesc($dfrn_id)); dbesc($dfrn_id));
if(count($r)) { if(dbm::is_result($r)) {
xml_status(1); xml_status(1);
return; // NOTREACHED return; // NOTREACHED
} }
@ -223,7 +223,7 @@ function dfrn_poll_post(&$a) {
$r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1", $r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1",
dbesc($sec) dbesc($sec)
); );
if(! count($r)) { if(! dbm::is_result($r)) {
xml_status(3, 'No ticket'); xml_status(3, 'No ticket');
// NOTREACHED // NOTREACHED
} }
@ -284,7 +284,7 @@ function dfrn_poll_post(&$a) {
dbesc($challenge) dbesc($challenge)
); );
if(! count($r)) if(! dbm::is_result($r))
killme(); killme();
$type = $r[0]['type']; $type = $r[0]['type'];
@ -319,7 +319,7 @@ function dfrn_poll_post(&$a) {
$r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 $sql_extra LIMIT 1"); $r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 $sql_extra LIMIT 1");
if(! count($r)) if(! dbm::is_result($r))
killme(); killme();
$contact = $r[0]; $contact = $r[0];
@ -335,7 +335,7 @@ function dfrn_poll_post(&$a) {
$reputation = 0; $reputation = 0;
$text = ''; $text = '';
if(count($r)) { if(dbm::is_result($r)) {
$reputation = $r[0]['rating']; $reputation = $r[0]['rating'];
$text = $r[0]['reason']; $text = $r[0]['reason'];
@ -448,7 +448,7 @@ function dfrn_poll_content(&$a) {
dbesc($nickname) dbesc($nickname)
); );
if(count($r)) { if(dbm::is_result($r)) {
$challenge = ''; $challenge = '';
$encrypted_id = ''; $encrypted_id = '';
@ -495,7 +495,7 @@ function dfrn_poll_content(&$a) {
)); ));
} }
$profile = ((count($r) && $r[0]['nickname']) ? $r[0]['nickname'] : $nickname); $profile = ((dbm::is_result($r) && $r[0]['nickname']) ? $r[0]['nickname'] : $nickname);
switch($destination_url) { switch($destination_url) {
case 'profile': case 'profile':

View File

@ -91,7 +91,7 @@ function dfrn_request_post(&$a) {
dbesc(normalise_link($dfrn_url)) dbesc(normalise_link($dfrn_url))
); );
if(count($r)) { if(dbm::is_result($r)) {
if(strlen($r[0]['dfrn-id'])) { if(strlen($r[0]['dfrn-id'])) {
/* /*
@ -185,7 +185,7 @@ function dfrn_request_post(&$a) {
dbesc($dfrn_url), dbesc($dfrn_url),
$parms['key'] // this was already escaped $parms['key'] // this was already escaped
); );
if(count($r)) { if(dbm::is_result($r)) {
$def_gid = get_default_group(local_user(), $r[0]["network"]); $def_gid = get_default_group(local_user(), $r[0]["network"]);
if(intval($def_gid)) if(intval($def_gid))
group_add_member(local_user(), '', $r[0]['id'], $def_gid); group_add_member(local_user(), '', $r[0]['id'], $def_gid);
@ -273,7 +273,7 @@ function dfrn_request_post(&$a) {
dbesc(datetime_convert('UTC','UTC','now - 24 hours')), dbesc(datetime_convert('UTC','UTC','now - 24 hours')),
intval($uid) intval($uid)
); );
if(count($r) > $maxreq) { if(dbm::is_result($r) > $maxreq) {
notice( sprintf( t('%s has received too many connection requests today.'), $a->profile['name']) . EOL); notice( sprintf( t('%s has received too many connection requests today.'), $a->profile['name']) . EOL);
notice( t('Spam protection measures have been invoked.') . EOL); notice( t('Spam protection measures have been invoked.') . EOL);
notice( t('Friends are advised to please try again in 24 hours.') . EOL); notice( t('Friends are advised to please try again in 24 hours.') . EOL);
@ -295,7 +295,7 @@ function dfrn_request_post(&$a) {
AND `intro`.`datetime` < UTC_TIMESTAMP() - INTERVAL 30 MINUTE ", AND `intro`.`datetime` < UTC_TIMESTAMP() - INTERVAL 30 MINUTE ",
dbesc(NETWORK_MAIL2) dbesc(NETWORK_MAIL2)
); );
if(count($r)) { if(dbm::is_result($r)) {
foreach($r as $rr) { foreach($r as $rr) {
if(! $rr['rel']) { if(! $rr['rel']) {
q("DELETE FROM `contact` WHERE `id` = %d", q("DELETE FROM `contact` WHERE `id` = %d",
@ -320,7 +320,7 @@ function dfrn_request_post(&$a) {
AND `intro`.`datetime` < UTC_TIMESTAMP() - INTERVAL 3 DAY ", AND `intro`.`datetime` < UTC_TIMESTAMP() - INTERVAL 3 DAY ",
dbesc(NETWORK_MAIL2) dbesc(NETWORK_MAIL2)
); );
if(count($r)) { if(dbm::is_result($r)) {
foreach($r as $rr) { foreach($r as $rr) {
if(! $rr['rel']) { if(! $rr['rel']) {
q("DELETE FROM `contact` WHERE `id` = %d", q("DELETE FROM `contact` WHERE `id` = %d",
@ -370,7 +370,7 @@ function dfrn_request_post(&$a) {
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
intval($uid) intval($uid)
); );
if(! count($r)) { if(! dbm::is_result($r)) {
notice( t('This account has not been configured for email. Request failed.') . EOL); notice( t('This account has not been configured for email. Request failed.') . EOL);
return; return;
@ -398,7 +398,7 @@ function dfrn_request_post(&$a) {
dbesc($poll), dbesc($poll),
intval($uid) intval($uid)
); );
if(count($r)) { if(dbm::is_result($r)) {
$contact_id = $r[0]['id']; $contact_id = $r[0]['id'];
$def_gid = get_default_group($uid, $r[0]["network"]); $def_gid = get_default_group($uid, $r[0]["network"]);
@ -572,7 +572,7 @@ function dfrn_request_post(&$a) {
$parms['url'], $parms['url'],
$parms['issued-id'] $parms['issued-id']
); );
if(count($r)) { if(dbm::is_result($r)) {
$contact_record = $r[0]; $contact_record = $r[0];
update_contact_avatar($photo, $uid, $contact_record["id"], true); update_contact_avatar($photo, $uid, $contact_record["id"], true);
} }
@ -729,7 +729,7 @@ function dfrn_request_content(&$a) {
$auto_confirm = false; $auto_confirm = false;
if(count($r)) { if(dbm::is_result($r)) {
if(($r[0]['page-flags'] != PAGE_NORMAL) && ($r[0]['page-flags'] != PAGE_PRVGROUP)) if(($r[0]['page-flags'] != PAGE_NORMAL) && ($r[0]['page-flags'] != PAGE_PRVGROUP))
$auto_confirm = true; $auto_confirm = true;
@ -842,7 +842,7 @@ function dfrn_request_content(&$a) {
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
intval($a->profile['uid']) intval($a->profile['uid'])
); );
if(! count($r)) if(! dbm::is_result($r))
$mail_disabled = 1; $mail_disabled = 1;
} }

View File

@ -78,7 +78,7 @@ function directory_content(&$a) {
$r = $db->q("SELECT COUNT(*) AS `total` FROM `profile` $r = $db->q("SELECT COUNT(*) AS `total` FROM `profile`
LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra "); WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra ");
if(count($r)) if(dbm::is_result($r))
$a->set_pager_total($r[0]['total']); $a->set_pager_total($r[0]['total']);
$order = " ORDER BY `name` ASC "; $order = " ORDER BY `name` ASC ";
@ -90,7 +90,7 @@ function directory_content(&$a) {
LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
LEFT JOIN `contact` ON `contact`.`uid` = `user`.`uid` LEFT JOIN `contact` ON `contact`.`uid` = `user`.`uid`
WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 AND `contact`.`self` $sql_extra $order LIMIT ".$limit); WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 AND `contact`.`self` $sql_extra $order LIMIT ".$limit);
if(count($r)) { if(dbm::is_result($r)) {
if(in_array('small', $a->argv)) if(in_array('small', $a->argv))
$photo = 'thumb'; $photo = 'thumb';

View File

@ -78,7 +78,7 @@ function editpost_content(&$a) {
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1", $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1",
intval(local_user()) intval(local_user())
); );
if(count($r)) { if(dbm::is_result($r)) {
$mail_enabled = true; $mail_enabled = true;
if(intval($r[0]['pubmail'])) if(intval($r[0]['pubmail']))
$pubmail_enabled = true; $pubmail_enabled = true;

View File

@ -332,7 +332,7 @@ function events_content(&$a) {
$links = array(); $links = array();
if(count($r)) { if(dbm::is_result($r)) {
$r = sort_by_date($r); $r = sort_by_date($r);
foreach($r as $rr) { foreach($r as $rr) {
$j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j')); $j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j'));
@ -344,7 +344,7 @@ function events_content(&$a) {
$events=array(); $events=array();
// transform the event in a usable array // transform the event in a usable array
if(count($r)) if(dbm::is_result($r))
$r = sort_by_date($r); $r = sort_by_date($r);
$events = process_events($r); $events = process_events($r);
@ -403,7 +403,7 @@ function events_content(&$a) {
intval($event_id), intval($event_id),
intval(local_user()) intval(local_user())
); );
if(count($r)) if(dbm::is_result($r))
$orig_event = $r[0]; $orig_event = $r[0];
} }

View File

@ -24,7 +24,7 @@ function friendica_init(&$a) {
$visible_plugins = array(); $visible_plugins = array();
if(is_array($a->plugins) && count($a->plugins)) { if(is_array($a->plugins) && count($a->plugins)) {
$r = q("select * from addon where hidden = 0"); $r = q("select * from addon where hidden = 0");
if(count($r)) if(dbm::is_result($r))
foreach($r as $rr) foreach($r as $rr)
$visible_plugins[] = $rr['name']; $visible_plugins[] = $rr['name'];
} }
@ -80,7 +80,7 @@ function friendica_content(&$a) {
$visible_plugins = array(); $visible_plugins = array();
if(is_array($a->plugins) && count($a->plugins)) { if(is_array($a->plugins) && count($a->plugins)) {
$r = q("select * from addon where hidden = 0"); $r = q("select * from addon where hidden = 0");
if(count($r)) if(dbm::is_result($r))
foreach($r as $rr) foreach($r as $rr)
$visible_plugins[] = $rr['name']; $visible_plugins[] = $rr['name'];
} }

View File

@ -16,7 +16,7 @@ function fsuggest_post(&$a) {
intval($contact_id), intval($contact_id),
intval(local_user()) intval(local_user())
); );
if(! count($r)) { if(! dbm::is_result($r)) {
notice( t('Contact not found.') . EOL); notice( t('Contact not found.') . EOL);
return; return;
} }
@ -33,7 +33,7 @@ function fsuggest_post(&$a) {
intval($new_contact), intval($new_contact),
intval(local_user()) intval(local_user())
); );
if(count($r)) { if(dbm::is_result($r)) {
$x = q("INSERT INTO `fsuggest` ( `uid`,`cid`,`name`,`url`,`request`,`photo`,`note`,`created`) $x = q("INSERT INTO `fsuggest` ( `uid`,`cid`,`name`,`url`,`request`,`photo`,`note`,`created`)
VALUES ( %d, %d, '%s','%s','%s','%s','%s','%s')", VALUES ( %d, %d, '%s','%s','%s','%s','%s','%s')",
@ -50,7 +50,7 @@ function fsuggest_post(&$a) {
dbesc($hash), dbesc($hash),
intval(local_user()) intval(local_user())
); );
if(count($r)) { if(dbm::is_result($r)) {
$fsuggest_id = $r[0]['id']; $fsuggest_id = $r[0]['id'];
q("UPDATE `fsuggest` SET `note` = '%s' WHERE `id` = %d AND `uid` = %d", q("UPDATE `fsuggest` SET `note` = '%s' WHERE `id` = %d AND `uid` = %d",
dbesc($note), dbesc($note),
@ -88,7 +88,7 @@ function fsuggest_content(&$a) {
intval($contact_id), intval($contact_id),
intval(local_user()) intval(local_user())
); );
if(! count($r)) { if(! dbm::is_result($r)) {
notice( t('Contact not found.') . EOL); notice( t('Contact not found.') . EOL);
return; return;
} }

View File

@ -43,7 +43,7 @@ function group_post(&$a) {
intval($a->argv[1]), intval($a->argv[1]),
intval(local_user()) intval(local_user())
); );
if(! count($r)) { if(! dbm::is_result($r)) {
notice( t('Group not found.') . EOL ); notice( t('Group not found.') . EOL );
goaway($a->get_baseurl() . '/contacts'); goaway($a->get_baseurl() . '/contacts');
return; // NOTREACHED return; // NOTREACHED
@ -107,7 +107,7 @@ function group_content(&$a) {
intval($a->argv[2]), intval($a->argv[2]),
intval(local_user()) intval(local_user())
); );
if(count($r)) if(dbm::is_result($r))
$result = group_rmv(local_user(),$r[0]['name']); $result = group_rmv(local_user(),$r[0]['name']);
if($result) if($result)
info( t('Group removed.') . EOL); info( t('Group removed.') . EOL);
@ -125,7 +125,7 @@ function group_content(&$a) {
intval($a->argv[2]), intval($a->argv[2]),
intval(local_user()) intval(local_user())
); );
if(count($r)) if(dbm::is_result($r))
$change = intval($a->argv[2]); $change = intval($a->argv[2]);
} }
@ -136,7 +136,7 @@ function group_content(&$a) {
intval($a->argv[1]), intval($a->argv[1]),
intval(local_user()) intval(local_user())
); );
if(! count($r)) { if(! dbm::is_result($r)) {
notice( t('Group not found.') . EOL ); notice( t('Group not found.') . EOL );
goaway($a->get_baseurl() . '/contacts'); goaway($a->get_baseurl() . '/contacts');
} }
@ -209,7 +209,7 @@ function group_content(&$a) {
intval(local_user()) intval(local_user())
); );
if(count($r)) { if(dbm::is_result($r)) {
$textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : false); $textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : false);
foreach($r as $member) { foreach($r as $member) {
if(! in_array($member['id'],$preselected)) { if(! in_array($member['id'],$preselected)) {

View File

@ -16,7 +16,7 @@ function ignored_init(&$a) {
intval(local_user()), intval(local_user()),
intval($message_id) intval($message_id)
); );
if(! count($r)) if(! dbm::is_result($r))
killme(); killme();
if(! intval($r[0]['ignored'])) if(! intval($r[0]['ignored']))

View File

@ -165,7 +165,7 @@ function install_content(&$a) {
if($db && $db->connected) { if($db && $db->connected) {
$r = q("SELECT COUNT(*) as `total` FROM `user`"); $r = q("SELECT COUNT(*) as `total` FROM `user`");
if($r && count($r) && $r[0]['total']) { if(dbm::is_result($r) && $r[0]['total']) {
$tpl = get_markup_template('install.tpl'); $tpl = get_markup_template('install.tpl');
return replace_macros($tpl, array( return replace_macros($tpl, array(
'$title' => $install_title, '$title' => $install_title,

View File

@ -102,7 +102,7 @@ function item_post(&$a) {
} }
// if this isn't the real parent of the conversation, find it // if this isn't the real parent of the conversation, find it
if($r !== false && count($r)) { if(dbm::is_result($r)) {
$parid = $r[0]['parent']; $parid = $r[0]['parent'];
$parent_uri = $r[0]['uri']; $parent_uri = $r[0]['uri'];
if($r[0]['id'] != $r[0]['parent']) { if($r[0]['id'] != $r[0]['parent']) {
@ -112,7 +112,7 @@ function item_post(&$a) {
} }
} }
if(($r === false) || (! count($r))) { if(! dbm::is_result($r)) {
notice( t('Unable to locate original post.') . EOL); notice( t('Unable to locate original post.') . EOL);
if(x($_REQUEST,'return')) if(x($_REQUEST,'return'))
goaway($return_path); goaway($return_path);
@ -141,7 +141,7 @@ function item_post(&$a) {
$r = q("SELECT * FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1", $r = q("SELECT * FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
dbesc(normalise_link($thrparent[0]["author-link"]))); dbesc(normalise_link($thrparent[0]["author-link"])));
if (count($r)) { if (dbm::is_result($r)) {
$parent_contact = $r[0]; $parent_contact = $r[0];
$parent_contact["thumb"] = $parent_contact["photo"]; $parent_contact["thumb"] = $parent_contact["photo"];
$parent_contact["micro"] = $parent_contact["photo"]; $parent_contact["micro"] = $parent_contact["photo"];
@ -330,7 +330,7 @@ function item_post(&$a) {
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1", $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1",
intval(local_user()) intval(local_user())
); );
if(count($r) && intval($r[0]['pubmail'])) if(dbm::is_result($r) && intval($r[0]['pubmail']))
$pubmail_enabled = true; $pubmail_enabled = true;
} }
} }
@ -464,7 +464,7 @@ function item_post(&$a) {
intval($profile_uid) intval($profile_uid)
); );
if(! count($r)) if(! dbm::is_result($r))
continue; continue;
$r = q("UPDATE `photo` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s' $r = q("UPDATE `photo` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s'

View File

@ -21,7 +21,7 @@ function lockview_content(&$a) {
dbesc($type), dbesc($type),
intval($item_id) intval($item_id)
); );
if(! count($r)) if(! dbm::is_result($r))
killme(); killme();
$item = $r[0]; $item = $r[0];
@ -52,7 +52,7 @@ function lockview_content(&$a) {
$r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )", $r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
dbesc(implode(', ', $allowed_groups)) dbesc(implode(', ', $allowed_groups))
); );
if(count($r)) if(dbm::is_result($r))
foreach($r as $rr) foreach($r as $rr)
$l[] = '<b>' . $rr['name'] . '</b>'; $l[] = '<b>' . $rr['name'] . '</b>';
} }
@ -60,7 +60,7 @@ function lockview_content(&$a) {
$r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )", $r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
dbesc(implode(', ',$allowed_users)) dbesc(implode(', ',$allowed_users))
); );
if(count($r)) if(dbm::is_result($r))
foreach($r as $rr) foreach($r as $rr)
$l[] = $rr['name']; $l[] = $rr['name'];
@ -70,7 +70,7 @@ function lockview_content(&$a) {
$r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )", $r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
dbesc(implode(', ', $deny_groups)) dbesc(implode(', ', $deny_groups))
); );
if(count($r)) if(dbm::is_result($r))
foreach($r as $rr) foreach($r as $rr)
$l[] = '<b><strike>' . $rr['name'] . '</strike></b>'; $l[] = '<b><strike>' . $rr['name'] . '</strike></b>';
} }
@ -78,7 +78,7 @@ function lockview_content(&$a) {
$r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )", $r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
dbesc(implode(', ',$deny_users)) dbesc(implode(', ',$deny_users))
); );
if(count($r)) if(dbm::is_result($r))
foreach($r as $rr) foreach($r as $rr)
$l[] = '<strike>' . $rr['name'] . '</strike>'; $l[] = '<strike>' . $rr['name'] . '</strike>';

View File

@ -15,7 +15,7 @@ function lostpass_post(&$a) {
dbesc($loginame) dbesc($loginame)
); );
if(! count($r)) { if(! dbm::is_result($r)) {
notice( t('No valid account found.') . EOL); notice( t('No valid account found.') . EOL);
goaway(z_root()); goaway(z_root());
} }
@ -88,7 +88,7 @@ function lostpass_content(&$a) {
$r = q("SELECT * FROM `user` WHERE `pwdreset` = '%s' LIMIT 1", $r = q("SELECT * FROM `user` WHERE `pwdreset` = '%s' LIMIT 1",
dbesc($hash) dbesc($hash)
); );
if(! count($r)) { if(! dbm::is_result($r)) {
$o = t("Request could not be verified. \x28You may have previously submitted it.\x29 Password reset failed."); $o = t("Request could not be verified. \x28You may have previously submitted it.\x29 Password reset failed.");
return $o; return $o;
} }

View File

@ -15,7 +15,7 @@ function manage_post(&$a) {
$r = q("select * from user where uid = %d limit 1", $r = q("select * from user where uid = %d limit 1",
intval($_SESSION['submanage']) intval($_SESSION['submanage'])
); );
if(count($r)) { if(dbm::is_result($r)) {
$uid = intval($r[0]['uid']); $uid = intval($r[0]['uid']);
$orig_record = $r[0]; $orig_record = $r[0];
} }
@ -56,7 +56,7 @@ function manage_post(&$a) {
); );
} }
if(! count($r)) if(! dbm::is_result($r))
return; return;
unset($_SESSION['authenticated']); unset($_SESSION['authenticated']);

View File

@ -27,7 +27,7 @@ function match_content(&$a) {
$r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1", $r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
intval(local_user()) intval(local_user())
); );
if(! count($r)) if(! dbm::is_result($r))
return; return;
if(! $r[0]['pub_keywords'] && (! $r[0]['prv_keywords'])) { if(! $r[0]['pub_keywords'] && (! $r[0]['prv_keywords'])) {
notice( t('No keywords to match. Please add keywords to your default profile.') . EOL); notice( t('No keywords to match. Please add keywords to your default profile.') . EOL);

View File

@ -242,7 +242,7 @@ function message_content(&$a) {
intval($a->argv[2]), intval($a->argv[2]),
intval(local_user()) intval(local_user())
); );
if(count($r)) { if(dbm::is_result($r)) {
$parent = $r[0]['parent-uri']; $parent = $r[0]['parent-uri'];
$convid = $r[0]['convid']; $convid = $r[0]['convid'];
@ -321,7 +321,7 @@ function message_content(&$a) {
dbesc(base64_decode($a->argv[2])) dbesc(base64_decode($a->argv[2]))
); );
} }
if(count($r)) { if(dbm::is_result($r)) {
$prename = $r[0]['name']; $prename = $r[0]['name'];
$preurl = $r[0]['url']; $preurl = $r[0]['url'];
$preid = $r[0]['id']; $preid = $r[0]['id'];
@ -405,7 +405,7 @@ function message_content(&$a) {
intval(local_user()), intval(local_user()),
intval($a->argv[1]) intval($a->argv[1])
); );
if(count($r)) { if(dbm::is_result($r)) {
$contact_id = $r[0]['contact-id']; $contact_id = $r[0]['contact-id'];
$convid = $r[0]['convid']; $convid = $r[0]['convid'];

View File

@ -12,7 +12,7 @@ function modexp_init(&$a) {
dbesc($nick) dbesc($nick)
); );
if(! count($r)) if(! dbm::is_result($r))
killme(); killme();
$lines = explode("\n",$r[0]['spubkey']); $lines = explode("\n",$r[0]['spubkey']);

View File

@ -36,7 +36,7 @@ function mood_init(&$a) {
intval($parent), intval($parent),
intval($uid) intval($uid)
); );
if(count($r)) { if(dbm::is_result($r)) {
$parent_uri = $r[0]['uri']; $parent_uri = $r[0]['uri'];
$private = $r[0]['private']; $private = $r[0]['private'];
$allow_cid = $r[0]['allow_cid']; $allow_cid = $r[0]['allow_cid'];

View File

@ -13,7 +13,7 @@ function msearch_post(&$a) {
$r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 AND `user`.`hidewall` = 0 AND MATCH `pub_keywords` AGAINST ('%s') ", $r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 AND `user`.`hidewall` = 0 AND MATCH `pub_keywords` AGAINST ('%s') ",
dbesc($search) dbesc($search)
); );
if(count($r)) if(dbm::is_result($r))
$total = $r[0]['total']; $total = $r[0]['total'];
$r = q("SELECT `pub_keywords`, `username`, `nickname`, `user`.`uid` FROM `user` LEFT JOIN `profile` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 AND `user`.`hidewall` = 0 AND MATCH `pub_keywords` AGAINST ('%s') LIMIT %d , %d ", $r = q("SELECT `pub_keywords`, `username`, `nickname`, `user`.`uid` FROM `user` LEFT JOIN `profile` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 AND `user`.`hidewall` = 0 AND MATCH `pub_keywords` AGAINST ('%s') LIMIT %d , %d ",
@ -23,7 +23,7 @@ function msearch_post(&$a) {
); );
$results = array(); $results = array();
if(count($r)) { if(dbm::is_result($r)) {
foreach($r as $rr) foreach($r as $rr)
$results[] = array( $results[] = array(
'name' => $rr['name'], 'name' => $rr['name'],

View File

@ -126,7 +126,7 @@ function network_init(&$a) {
intval(local_user()), intval(local_user()),
dbesc($search) dbesc($search)
); );
if(! count($r)) { if(! dbm::is_result($r)) {
q("INSERT INTO `search` ( `uid`,`term` ) VALUES ( %d, '%s') ", q("INSERT INTO `search` ( `uid`,`term` ) VALUES ( %d, '%s') ",
intval(local_user()), intval(local_user()),
dbesc($search) dbesc($search)
@ -182,7 +182,7 @@ function saved_searches($search) {
$saved = array(); $saved = array();
if(count($r)) { if(dbm::is_result($r)) {
foreach($r as $rr) { foreach($r as $rr) {
$saved[] = array( $saved[] = array(
'id' => $rr['id'], 'id' => $rr['id'],
@ -381,7 +381,7 @@ function network_content(&$a, $update = 0) {
); );
$str = ''; $str = '';
if(count($r)) if(dbm::is_result($r))
foreach($r as $rr) foreach($r as $rr)
$str .= '<' . $rr['id'] . '>'; $str .= '<' . $rr['id'] . '>';
if(strlen($str)) if(strlen($str))
@ -463,7 +463,7 @@ function network_content(&$a, $update = 0) {
intval($group), intval($group),
intval($_SESSION['uid']) intval($_SESSION['uid'])
); );
if(! count($r)) { if(! dbm::is_result($r)) {
if($update) if($update)
killme(); killme();
notice( t('No such group') . EOL ); notice( t('No such group') . EOL );
@ -507,7 +507,7 @@ function network_content(&$a, $update = 0) {
AND (NOT `blocked` OR `pending`) LIMIT 1", AND (NOT `blocked` OR `pending`) LIMIT 1",
intval($cid) intval($cid)
); );
if(count($r)) { if(dbm::is_result($r)) {
$sql_extra = " AND ".$sql_table.".`contact-id` = ".intval($cid); $sql_extra = " AND ".$sql_table.".`contact-id` = ".intval($cid);
$entries[0] = array( $entries[0] = array(
@ -609,7 +609,7 @@ function network_content(&$a, $update = 0) {
intval($_SESSION['uid']) intval($_SESSION['uid'])
); );
if(count($r)) { if(dbm::is_result($r)) {
$a->set_pager_total($r[0]['total']); $a->set_pager_total($r[0]['total']);
} }
} }

View File

@ -28,11 +28,11 @@ function nogroup_content(&$a) {
require_once('include/Contact.php'); require_once('include/Contact.php');
$r = contacts_not_grouped(local_user()); $r = contacts_not_grouped(local_user());
if(count($r)) { if(dbm::is_result($r)) {
$a->set_pager_total($r[0]['total']); $a->set_pager_total($r[0]['total']);
} }
$r = contacts_not_grouped(local_user(),$a->pager['start'],$a->pager['itemspage']); $r = contacts_not_grouped(local_user(),$a->pager['start'],$a->pager['itemspage']);
if(count($r)) { if(dbm::is_result($r)) {
foreach($r as $rr) { foreach($r as $rr) {
$contact_details = get_contact_details_by_url($rr['url'], local_user(), $rr); $contact_details = get_contact_details_by_url($rr['url'], local_user(), $rr);

View File

@ -43,7 +43,7 @@ function noscrape_init(&$a) {
if(is_array($a->profile) AND !$a->profile['hide-friends']) { if(is_array($a->profile) AND !$a->profile['hide-friends']) {
$r = q("SELECT `gcontact`.`updated` FROM `contact` INNER JOIN `gcontact` WHERE `gcontact`.`nurl` = `contact`.`nurl` AND `self` AND `uid` = %d LIMIT 1", $r = q("SELECT `gcontact`.`updated` FROM `contact` INNER JOIN `gcontact` WHERE `gcontact`.`nurl` = `contact`.`nurl` AND `self` AND `uid` = %d LIMIT 1",
intval($a->profile['uid'])); intval($a->profile['uid']));
if(count($r)) if(dbm::is_result($r))
$json_info["updated"] = date("c", strtotime($r[0]['updated'])); $json_info["updated"] = date("c", strtotime($r[0]['updated']));
$r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0 AND `hidden` = 0 AND `archive` = 0 $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0 AND `hidden` = 0 AND `archive` = 0
@ -53,7 +53,7 @@ function noscrape_init(&$a) {
dbesc(NETWORK_DIASPORA), dbesc(NETWORK_DIASPORA),
dbesc(NETWORK_OSTATUS) dbesc(NETWORK_OSTATUS)
); );
if(count($r)) if(dbm::is_result($r))
$json_info["contacts"] = intval($r[0]['total']); $json_info["contacts"] = intval($r[0]['total']);
} }

View File

@ -82,7 +82,7 @@ function notes_content(&$a,$update = false) {
); );
if(count($r)) { if(dbm::is_result($r)) {
$a->set_pager_total($r[0]['total']); $a->set_pager_total($r[0]['total']);
$a->set_pager_itemspage(40); $a->set_pager_itemspage(40);
} }
@ -102,7 +102,7 @@ function notes_content(&$a,$update = false) {
$parents_arr = array(); $parents_arr = array();
$parents_str = ''; $parents_str = '';
if(count($r)) { if(dbm::is_result($r)) {
foreach($r as $rr) foreach($r as $rr)
$parents_arr[] = $rr['item_id']; $parents_arr[] = $rr['item_id'];
$parents_str = implode(', ', $parents_arr); $parents_str = implode(', ', $parents_arr);
@ -116,7 +116,7 @@ function notes_content(&$a,$update = false) {
dbesc($parents_str) dbesc($parents_str)
); );
if(count($r)) { if(dbm::is_result($r)) {
$items = conv_sort($r,"`commented`"); $items = conv_sort($r,"`commented`");
$o .= conversation($a,$items,'notes',$update); $o .= conversation($a,$items,'notes',$update);

View File

@ -6,7 +6,7 @@
$r = q("SELECT user.nickname FROM user LEFT JOIN item ON item.uid=user.uid WHERE item.id=%d", $r = q("SELECT user.nickname FROM user LEFT JOIN item ON item.uid=user.uid WHERE item.id=%d",
intval($id) intval($id)
); );
if (count($r)){ if (dbm::is_result($r)){
$nick = $r[0]['nickname']; $nick = $r[0]['nickname'];
$url = $a->get_baseurl()."/display/$nick/$id"; $url = $a->get_baseurl()."/display/$nick/$id";
goaway($url); goaway($url);

View File

@ -27,7 +27,7 @@ function notifications_post(&$a) {
intval(local_user()) intval(local_user())
); );
if(count($r)) { if(dbm::is_result($r)) {
$intro_id = $r[0]['id']; $intro_id = $r[0]['id'];
$contact_id = $r[0]['contact-id']; $contact_id = $r[0]['contact-id'];
} }

View File

@ -47,7 +47,7 @@ function notify_content(&$a) {
require_once('include/bbcode.php'); require_once('include/bbcode.php');
$r = $nm->getAll(array('seen'=>0)); $r = $nm->getAll(array('seen'=>0));
if ($r!==false && count($r) > 0) { if (dbm::is_result($r) > 0) {
foreach ($r as $it) { foreach ($r as $it) {
$notif_content .= replace_macros($not_tpl,array( $notif_content .= replace_macros($not_tpl,array(
'$item_link' => $a->get_baseurl(true).'/notify/view/'. $it['id'], '$item_link' => $a->get_baseurl(true).'/notify/view/'. $it['id'],

View File

@ -38,7 +38,7 @@ function openid_content(&$a) {
dbesc($authid), dbesc(normalise_openid($authid)) dbesc($authid), dbesc(normalise_openid($authid))
); );
if($r && count($r)) { if(dbm::is_result($r)) {
// successful OpenID login // successful OpenID login

View File

@ -76,7 +76,7 @@ function photo_init(&$a) {
intval($resolution), intval($resolution),
intval($uid) intval($uid)
); );
if(count($r)) { if(dbm::is_result($r)) {
$data = $r[0]['data']; $data = $r[0]['data'];
$mimetype = $r[0]['type']; $mimetype = $r[0]['type'];
} }
@ -106,7 +106,7 @@ function photo_init(&$a) {
dbesc($photo), dbesc($photo),
intval($resolution) intval($resolution)
); );
if(count($r)) { if(dbm::is_result($r)) {
$sql_extra = permissions_sql($r[0]['uid']); $sql_extra = permissions_sql($r[0]['uid']);
@ -119,7 +119,7 @@ function photo_init(&$a) {
$public = ($r[0]['allow_cid'] == '') AND ($r[0]['allow_gid'] == '') AND ($r[0]['deny_cid'] == '') AND ($r[0]['deny_gid'] == ''); $public = ($r[0]['allow_cid'] == '') AND ($r[0]['allow_gid'] == '') AND ($r[0]['deny_cid'] == '') AND ($r[0]['deny_gid'] == '');
if(count($r)) { if(dbm::is_result($r)) {
$resolution = $r[0]['scale']; $resolution = $r[0]['scale'];
$data = $r[0]['data']; $data = $r[0]['data'];
$mimetype = $r[0]['type']; $mimetype = $r[0]['type'];

View File

@ -165,7 +165,7 @@ function photos_post(&$a) {
intval($page_owner_uid) intval($page_owner_uid)
); );
if (! count($r)) { if (! dbm::is_result($r)) {
notice( t('Contact information unavailable') . EOL); notice( t('Contact information unavailable') . EOL);
logger('photos_post: unable to locate contact record for page owner. uid=' . $page_owner_uid); logger('photos_post: unable to locate contact record for page owner. uid=' . $page_owner_uid);
killme(); killme();
@ -186,7 +186,7 @@ function photos_post(&$a) {
dbesc($album), dbesc($album),
intval($page_owner_uid) intval($page_owner_uid)
); );
if (! count($r)) { if (! dbm::is_result($r)) {
notice( t('Album not found.') . EOL); notice( t('Album not found.') . EOL);
goaway($_SESSION['photo_return']); goaway($_SESSION['photo_return']);
return; // NOTREACHED return; // NOTREACHED
@ -748,7 +748,7 @@ function photos_post(&$a) {
dbesc($album), dbesc($album),
intval($page_owner_uid) intval($page_owner_uid)
); );
if ((! count($r)) || ($album == t('Profile Photos'))) if ((! dbm::is_result($r)) || ($album == t('Profile Photos')))
$visible = 1; $visible = 1;
else else
$visible = 0; $visible = 0;
@ -1573,7 +1573,7 @@ function photos_content(&$a) {
} }
$comments = ''; $comments = '';
if (! count($r)) { if (! dbm::is_result($r)) {
if ($can_post || can_write_wall($a,$owner_uid)) { if ($can_post || can_write_wall($a,$owner_uid)) {
if ($link_item['last-child']) { if ($link_item['last-child']) {
$comments .= replace_macros($cmnt_tpl,array( $comments .= replace_macros($cmnt_tpl,array(

View File

@ -45,7 +45,7 @@ function poco_init(&$a) {
where `user`.`nickname` = '%s' and `profile`.`is-default` = 1 limit 1", where `user`.`nickname` = '%s' and `profile`.`is-default` = 1 limit 1",
dbesc($user) dbesc($user)
); );
if(! count($r) || $r[0]['hidewall'] || $r[0]['hide-friends']) if(! dbm::is_result($r) || $r[0]['hidewall'] || $r[0]['hide-friends'])
http_status_exit(404); http_status_exit(404);
$user = $r[0]; $user = $r[0];
@ -83,7 +83,7 @@ function poco_init(&$a) {
dbesc(NETWORK_STATUSNET) dbesc(NETWORK_STATUSNET)
); );
} }
if(count($r)) if(dbm::is_result($r))
$totalResults = intval($r[0]['total']); $totalResults = intval($r[0]['total']);
else else
$totalResults = 0; $totalResults = 0;
@ -173,7 +173,7 @@ function poco_init(&$a) {
} }
if(is_array($r)) { if(is_array($r)) {
if(count($r)) { if(count($r) > 0) {
foreach($r as $rr) { foreach($r as $rr) {
if (!isset($rr['generation'])) { if (!isset($rr['generation'])) {
if ($global) if ($global)

View File

@ -52,7 +52,7 @@ function poke_init(&$a) {
intval($uid) intval($uid)
); );
if(! count($r)) { if(! dbm::is_result($r)) {
logger('poke: no contact ' . $contact_id); logger('poke: no contact ' . $contact_id);
return; return;
} }
@ -66,7 +66,7 @@ function poke_init(&$a) {
intval($parent), intval($parent),
intval($uid) intval($uid)
); );
if(count($r)) { if(dbm::is_result($r)) {
$parent_uri = $r[0]['uri']; $parent_uri = $r[0]['uri'];
$private = $r[0]['private']; $private = $r[0]['private'];
$allow_cid = $r[0]['allow_cid']; $allow_cid = $r[0]['allow_cid'];
@ -159,7 +159,7 @@ function poke_content(&$a) {
intval($_GET['c']), intval($_GET['c']),
intval(local_user()) intval(local_user())
); );
if(count($r)) { if(dbm::is_result($r)) {
$name = $r[0]['name']; $name = $r[0]['name'];
$id = $r[0]['id']; $id = $r[0]['id'];
} }

View File

@ -23,7 +23,7 @@ function post_post(&$a) {
AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1", AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1",
dbesc($nickname) dbesc($nickname)
); );
if(! count($r)) if(! dbm::is_result($r))
http_status_exit(500); http_status_exit(500);
$importer = $r[0]; $importer = $r[0];

View File

@ -13,7 +13,7 @@ function profile_init(&$a) {
$which = htmlspecialchars($a->argv[1]); $which = htmlspecialchars($a->argv[1]);
else { else {
$r = q("select nickname from user where blocked = 0 and account_expired = 0 and account_removed = 0 and verified = 1 order by rand() limit 1"); $r = q("select nickname from user where blocked = 0 and account_expired = 0 and account_removed = 0 and verified = 1 order by rand() limit 1");
if(count($r)) { if(dbm::is_result($r)) {
goaway($a->get_baseurl() . '/profile/' . $r[0]['nickname']); goaway($a->get_baseurl() . '/profile/' . $r[0]['nickname']);
} }
else { else {
@ -136,7 +136,7 @@ function profile_content(&$a, $update = 0) {
intval($contact_id), intval($contact_id),
intval($a->profile['profile_uid']) intval($a->profile['profile_uid'])
); );
if(count($r)) { if(dbm::is_result($r)) {
$contact = $r[0]; $contact = $r[0];
$remote_contact = true; $remote_contact = true;
} }
@ -258,7 +258,7 @@ function profile_content(&$a, $update = 0) {
intval($a->profile['profile_uid']) intval($a->profile['profile_uid'])
); );
if(count($r)) { if(dbm::is_result($r)) {
$a->set_pager_total($r[0]['total']); $a->set_pager_total($r[0]['total']);
} }
} }

View File

@ -32,7 +32,7 @@ function profile_photo_post(&$a) {
intval($_REQUEST['profile']), intval($_REQUEST['profile']),
intval(local_user()) intval(local_user())
); );
if(count($r) && (! intval($r[0]['is-default']))) if(dbm::is_result($r) && (! intval($r[0]['is-default'])))
$is_default_profile = 0; $is_default_profile = 0;
} }
@ -63,7 +63,7 @@ function profile_photo_post(&$a) {
dbesc(local_user()), dbesc(local_user()),
intval($scale)); intval($scale));
if(count($r)) { if(dbm::is_result($r)) {
$base_image = $r[0]; $base_image = $r[0];
@ -195,7 +195,7 @@ function profile_photo_content(&$a) {
intval(local_user()), intval(local_user()),
dbesc($resource_id) dbesc($resource_id)
); );
if (!count($r)){ if (!dbm::is_result($r)){
notice( t('Permission denied.') . EOL ); notice( t('Permission denied.') . EOL );
return; return;
} }

View File

@ -15,7 +15,7 @@ function profiles_init(&$a) {
intval($a->argv[2]), intval($a->argv[2]),
intval(local_user()) intval(local_user())
); );
if(! count($r)) { if(! dbm::is_result($r)) {
notice( t('Profile not found.') . EOL); notice( t('Profile not found.') . EOL);
goaway('profiles'); goaway('profiles');
return; // NOTREACHED return; // NOTREACHED
@ -130,7 +130,7 @@ function profiles_init(&$a) {
intval($a->argv[1]), intval($a->argv[1]),
intval(local_user()) intval(local_user())
); );
if(! count($r)) { if(! dbm::is_result($r)) {
notice( t('Profile not found.') . EOL); notice( t('Profile not found.') . EOL);
killme(); killme();
return; return;
@ -286,7 +286,7 @@ function profiles_post(&$a) {
intval(local_user()) intval(local_user())
); );
} }
if(count($r)) { if(dbm::is_result($r)) {
$prf = $r[0]['url']; $prf = $r[0]['url'];
$newname = $r[0]['name']; $newname = $r[0]['name'];
} }
@ -613,7 +613,7 @@ function profiles_content(&$a) {
intval($a->argv[1]), intval($a->argv[1]),
intval(local_user()) intval(local_user())
); );
if(! count($r)) { if(! dbm::is_result($r)) {
notice( t('Profile not found.') . EOL); notice( t('Profile not found.') . EOL);
return; return;
} }
@ -767,7 +767,7 @@ function profiles_content(&$a) {
"SELECT * FROM `profile` WHERE `uid` = %d AND `is-default`=1", "SELECT * FROM `profile` WHERE `uid` = %d AND `is-default`=1",
local_user() local_user()
); );
if(count($r)){ if(dbm::is_result($r)){
//Go to the default profile. //Go to the default profile.
goaway('profiles/'.$r[0]['id']); goaway('profiles/'.$r[0]['id']);
} }
@ -775,7 +775,7 @@ function profiles_content(&$a) {
$r = q("SELECT * FROM `profile` WHERE `uid` = %d", $r = q("SELECT * FROM `profile` WHERE `uid` = %d",
local_user()); local_user());
if(count($r)) { if(dbm::is_result($r)) {
$tpl = get_markup_template('profile_entry.tpl'); $tpl = get_markup_template('profile_entry.tpl');
foreach($r as $rr) { foreach($r as $rr) {

View File

@ -42,7 +42,7 @@ function profperm_content(&$a) {
intval($a->argv[2]), intval($a->argv[2]),
intval(local_user()) intval(local_user())
); );
if(count($r)) if(dbm::is_result($r))
$change = intval($a->argv[2]); $change = intval($a->argv[2]);
} }
@ -52,7 +52,7 @@ function profperm_content(&$a) {
intval($a->argv[1]), intval($a->argv[1]),
intval(local_user()) intval(local_user())
); );
if(! count($r)) { if(! dbm::is_result($r)) {
notice( t('Invalid profile identifier.') . EOL ); notice( t('Invalid profile identifier.') . EOL );
return; return;
} }
@ -64,7 +64,7 @@ function profperm_content(&$a) {
); );
$ingroup = array(); $ingroup = array();
if(count($r)) if(dbm::is_result($r))
foreach($r as $member) foreach($r as $member)
$ingroup[] = $member['id']; $ingroup[] = $member['id'];
@ -94,7 +94,7 @@ function profperm_content(&$a) {
$members = $r; $members = $r;
$ingroup = array(); $ingroup = array();
if(count($r)) if(dbm::is_result($r))
foreach($r as $member) foreach($r as $member)
$ingroup[] = $member['id']; $ingroup[] = $member['id'];
} }
@ -138,7 +138,7 @@ function profperm_content(&$a) {
dbesc(NETWORK_DFRN) dbesc(NETWORK_DFRN)
); );
if(count($r)) { if(dbm::is_result($r)) {
$textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : false); $textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : false);
foreach($r as $member) { foreach($r as $member) {
if(! in_array($member['id'],$ingroup)) { if(! in_array($member['id'],$ingroup)) {

View File

@ -136,7 +136,7 @@ function proxy_init() {
if (!$direct_cache AND ($cachefile == "")) { if (!$direct_cache AND ($cachefile == "")) {
$r = qu("SELECT * FROM `photo` WHERE `resource-id` = '%s' LIMIT 1", $urlhash); $r = qu("SELECT * FROM `photo` WHERE `resource-id` = '%s' LIMIT 1", $urlhash);
if (count($r)) { if (dbm::is_result($r)) {
$img_str = $r[0]['data']; $img_str = $r[0]['data'];
$mime = $r[0]["desc"]; $mime = $r[0]["desc"];
if ($mime == "") $mime = "image/jpeg"; if ($mime == "") $mime = "image/jpeg";
@ -144,7 +144,7 @@ function proxy_init() {
} else } else
$r = array(); $r = array();
if (!count($r)) { if (!dbm::is_result($r)) {
// It shouldn't happen but it does - spaces in URL // It shouldn't happen but it does - spaces in URL
$_REQUEST['url'] = str_replace(" ", "+", $_REQUEST['url']); $_REQUEST['url'] = str_replace(" ", "+", $_REQUEST['url']);
$redirects = 0; $redirects = 0;

View File

@ -47,7 +47,7 @@ function pubsub_init(&$a) {
$r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1", $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1",
dbesc($nick) dbesc($nick)
); );
if(! count($r)) { if(! dbm::is_result($r)) {
logger('pubsub: local account not found: ' . $nick); logger('pubsub: local account not found: ' . $nick);
hub_return(false, ''); hub_return(false, '');
} }
@ -62,7 +62,7 @@ function pubsub_init(&$a) {
intval($contact_id), intval($contact_id),
intval($owner['uid']) intval($owner['uid'])
); );
if(! count($r)) { if(! dbm::is_result($r)) {
logger('pubsub: contact '.$contact_id.' not found.'); logger('pubsub: contact '.$contact_id.' not found.');
hub_return(false, ''); hub_return(false, '');
} }
@ -117,7 +117,7 @@ function pubsub_post(&$a) {
$r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1", $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1",
dbesc($nick) dbesc($nick)
); );
if(! count($r)) if(! dbm::is_result($r))
hub_post_return(); hub_post_return();
$importer = $r[0]; $importer = $r[0];
@ -131,7 +131,7 @@ function pubsub_post(&$a) {
dbesc(NETWORK_FEED) dbesc(NETWORK_FEED)
); );
if(! count($r)) { if(! dbm::is_result($r)) {
logger('pubsub: no contact record for "'.$nick.' ('.$contact_id.')" - ignored. '.$xml); logger('pubsub: no contact record for "'.$nick.' ('.$contact_id.')" - ignored. '.$xml);
hub_post_return(); hub_post_return();
} }

View File

@ -55,7 +55,7 @@ function pubsubhubbub_init(&$a) {
" AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1", " AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1",
dbesc($nick)); dbesc($nick));
if(!count($r)) { if(!dbm::is_result($r)) {
logger('pubsubhubbub: local account not found: ' . $nick); logger('pubsubhubbub: local account not found: ' . $nick);
http_status_exit(404); http_status_exit(404);
} }
@ -73,7 +73,7 @@ function pubsubhubbub_init(&$a) {
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND NOT `blocked`". $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND NOT `blocked`".
" AND NOT `pending` AND `self` LIMIT 1", " AND NOT `pending` AND `self` LIMIT 1",
intval($owner['uid'])); intval($owner['uid']));
if(!count($r)) { if(!dbm::is_result($r)) {
logger('pubsubhubbub: contact not found.'); logger('pubsubhubbub: contact not found.');
http_status_exit(404); http_status_exit(404);
} }
@ -132,7 +132,7 @@ function pubsubhubbub_init(&$a) {
// if we are just updating an old subscription, keep the // if we are just updating an old subscription, keep the
// old values for push and last_update // old values for push and last_update
if (count($r)) { if (dbm::is_result($r)) {
$last_update = $r[0]['last_update']; $last_update = $r[0]['last_update'];
$push_flag = $r[0]['push']; $push_flag = $r[0]['push'];
} }

View File

@ -23,7 +23,7 @@ function qsearch_init(&$a) {
intval($limit) intval($limit)
); );
if(count($r)) { if(dbm::is_result($r)) {
foreach($r as $rr) foreach($r as $rr)
$results[] = array( 0, (int) $rr['id'], $rr['name'], '', ''); $results[] = array( 0, (int) $rr['id'], $rr['name'], '', '');
@ -38,7 +38,7 @@ function qsearch_init(&$a) {
); );
if(count($r)) { if(dbm::is_result($r)) {
foreach($r as $rr) foreach($r as $rr)
$results[] = array( (int) $rr['id'], 0, $rr['name'],$rr['url'],$rr['photo']); $results[] = array( (int) $rr['id'], 0, $rr['name'],$rr['url'],$rr['photo']);

View File

@ -34,7 +34,7 @@ function receive_post(&$a) {
$r = q("SELECT * FROM `user` WHERE `guid` = '%s' AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1", $r = q("SELECT * FROM `user` WHERE `guid` = '%s' AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1",
dbesc($guid) dbesc($guid)
); );
if(! count($r)) if(! dbm::is_result($r))
http_status_exit(500); http_status_exit(500);
$importer = $r[0]; $importer = $r[0];

View File

@ -18,7 +18,7 @@ function redir_init(&$a) {
intval(local_user()) intval(local_user())
); );
if((! count($r)) || ($r[0]['network'] !== NETWORK_DFRN)) if((! dbm::is_result($r)) || ($r[0]['network'] !== NETWORK_DFRN))
goaway(z_root()); goaway(z_root());
$cid = $r[0]['id']; $cid = $r[0]['id'];
@ -31,7 +31,7 @@ function redir_init(&$a) {
intval(local_user()) intval(local_user())
); );
if((! count($r)) || ($r[0]['network'] !== NETWORK_DFRN)) if((! dbm::is_result($r)) || ($r[0]['network'] !== NETWORK_DFRN))
goaway(z_root()); goaway(z_root());
} }

View File

@ -34,7 +34,7 @@ function user_allow($hash) {
$r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default` = 1", $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default` = 1",
intval($user[0]['uid']) intval($user[0]['uid'])
); );
if(count($r) && $r[0]['net-publish']) { if(dbm::is_result($r) && $r[0]['net-publish']) {
$url = $a->get_baseurl() . '/profile/' . $user[0]['nickname']; $url = $a->get_baseurl() . '/profile/' . $user[0]['nickname'];
if($url && strlen(get_config('system','directory'))) if($url && strlen(get_config('system','directory')))
proc_run(PRIORITY_LOW, "include/directory.php", $url); proc_run(PRIORITY_LOW, "include/directory.php", $url);

View File

@ -31,7 +31,7 @@ function salmon_post(&$a) {
$r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1", $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1",
dbesc($nick) dbesc($nick)
); );
if(! count($r)) if(! dbm::is_result($r))
http_status_exit(500); http_status_exit(500);
$importer = $r[0]; $importer = $r[0];
@ -150,7 +150,7 @@ function salmon_post(&$a) {
dbesc(normalise_link($author_link)), dbesc(normalise_link($author_link)),
intval($importer['uid']) intval($importer['uid'])
); );
if(! count($r)) { if(! dbm::is_result($r)) {
logger('mod-salmon: Author unknown to us.'); logger('mod-salmon: Author unknown to us.');
if(get_pconfig($importer['uid'],'system','ostatus_autofriend')) { if(get_pconfig($importer['uid'],'system','ostatus_autofriend')) {
$result = new_contact($importer['uid'],$author_link); $result = new_contact($importer['uid'],$author_link);
@ -169,8 +169,8 @@ function salmon_post(&$a) {
// Have we ignored the person? // Have we ignored the person?
// If so we can not accept this post. // If so we can not accept this post.
//if((count($r)) && (($r[0]['readonly']) || ($r[0]['rel'] == CONTACT_IS_FOLLOWER) || ($r[0]['blocked']))) { //if((dbm::is_result($r)) && (($r[0]['readonly']) || ($r[0]['rel'] == CONTACT_IS_FOLLOWER) || ($r[0]['blocked']))) {
if(count($r) && $r[0]['blocked']) { if(dbm::is_result($r) && $r[0]['blocked']) {
logger('mod-salmon: Ignoring this author.'); logger('mod-salmon: Ignoring this author.');
http_status_exit(202); http_status_exit(202);
// NOTREACHED // NOTREACHED
@ -179,7 +179,7 @@ function salmon_post(&$a) {
// Placeholder for hub discovery. // Placeholder for hub discovery.
$hub = ''; $hub = '';
$contact_rec = ((count($r)) ? $r[0] : null); $contact_rec = ((dbm::is_result($r)) ? $r[0] : null);
ostatus::import($data,$importer,$contact_rec, $hub); ostatus::import($data,$importer,$contact_rec, $hub);

View File

@ -15,7 +15,7 @@ function search_saved_searches() {
intval(local_user()) intval(local_user())
); );
if(count($r)) { if(dbm::is_result($r)) {
$saved = array(); $saved = array();
foreach($r as $rr) { foreach($r as $rr) {
$saved[] = array( $saved[] = array(
@ -53,7 +53,7 @@ function search_init(&$a) {
intval(local_user()), intval(local_user()),
dbesc($search) dbesc($search)
); );
if(! count($r)) { if(! dbm::is_result($r)) {
q("INSERT INTO `search` (`uid`,`term`) VALUES ( %d, '%s')", q("INSERT INTO `search` (`uid`,`term`) VALUES ( %d, '%s')",
intval(local_user()), intval(local_user()),
dbesc($search) dbesc($search)
@ -220,7 +220,7 @@ function search_content(&$a) {
intval($a->pager['start']), intval($a->pager['itemspage'])); intval($a->pager['start']), intval($a->pager['itemspage']));
} }
if(! count($r)) { if(! dbm::is_result($r)) {
info( t('No results.') . EOL); info( t('No results.') . EOL);
return $o; return $o;
} }

View File

@ -225,7 +225,7 @@ function settings_post(&$a) {
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
intval(local_user()) intval(local_user())
); );
if(! count($r)) { if(! dbm::is_result($r)) {
q("INSERT INTO `mailacct` (`uid`) VALUES (%d)", q("INSERT INTO `mailacct` (`uid`) VALUES (%d)",
intval(local_user()) intval(local_user())
); );
@ -255,7 +255,7 @@ function settings_post(&$a) {
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
intval(local_user()) intval(local_user())
); );
if(count($r)) { if(dbm::is_result($r)) {
$eacct = $r[0]; $eacct = $r[0];
require_once('include/email.php'); require_once('include/email.php');
$mb = construct_mailbox_name($eacct); $mb = construct_mailbox_name($eacct);
@ -691,7 +691,7 @@ function settings_content(&$a) {
dbesc($a->argv[3]), dbesc($a->argv[3]),
local_user()); local_user());
if (!count($r)){ if (!dbm::is_result($r)){
notice(t("You can't edit this application.")); notice(t("You can't edit this application."));
return; return;
} }
@ -752,7 +752,7 @@ function settings_content(&$a) {
$settings_addons = ""; $settings_addons = "";
$r = q("SELECT * FROM `hook` WHERE `hook` = 'plugin_settings' "); $r = q("SELECT * FROM `hook` WHERE `hook` = 'plugin_settings' ");
if(! count($r)) if(! dbm::is_result($r))
$settings_addons = t('No Plugin settings configured'); $settings_addons = t('No Plugin settings configured');
call_hooks('plugin_settings', $settings_addons); call_hooks('plugin_settings', $settings_addons);
@ -859,15 +859,15 @@ function settings_content(&$a) {
$r = null; $r = null;
} }
$mail_server = ((count($r)) ? $r[0]['server'] : ''); $mail_server = ((dbm::is_result($r)) ? $r[0]['server'] : '');
$mail_port = ((count($r) && intval($r[0]['port'])) ? intval($r[0]['port']) : ''); $mail_port = ((dbm::is_result($r) && intval($r[0]['port'])) ? intval($r[0]['port']) : '');
$mail_ssl = ((count($r)) ? $r[0]['ssltype'] : ''); $mail_ssl = ((dbm::is_result($r)) ? $r[0]['ssltype'] : '');
$mail_user = ((count($r)) ? $r[0]['user'] : ''); $mail_user = ((dbm::is_result($r)) ? $r[0]['user'] : '');
$mail_replyto = ((count($r)) ? $r[0]['reply_to'] : ''); $mail_replyto = ((dbm::is_result($r)) ? $r[0]['reply_to'] : '');
$mail_pubmail = ((count($r)) ? $r[0]['pubmail'] : 0); $mail_pubmail = ((dbm::is_result($r)) ? $r[0]['pubmail'] : 0);
$mail_action = ((count($r)) ? $r[0]['action'] : 0); $mail_action = ((dbm::is_result($r)) ? $r[0]['action'] : 0);
$mail_movetofolder = ((count($r)) ? $r[0]['movetofolder'] : ''); $mail_movetofolder = ((dbm::is_result($r)) ? $r[0]['movetofolder'] : '');
$mail_chk = ((count($r)) ? $r[0]['last_check'] : '0000-00-00 00:00:00'); $mail_chk = ((dbm::is_result($r)) ? $r[0]['last_check'] : '0000-00-00 00:00:00');
$tpl = get_markup_template("settings_connectors.tpl"); $tpl = get_markup_template("settings_connectors.tpl");

View File

@ -12,7 +12,7 @@ function share_init(&$a) {
intval($post_id), intval($post_id),
intval(local_user()) intval(local_user())
); );
if(! count($r) || ($r[0]['private'] == 1)) if(! dbm::is_result($r) || ($r[0]['private'] == 1))
killme(); killme();
if (!intval(get_config('system','old_share'))) { if (!intval(get_config('system','old_share'))) {

View File

@ -18,7 +18,7 @@ function starred_init(&$a) {
intval(local_user()), intval(local_user()),
intval($message_id) intval($message_id)
); );
if(! count($r)) if(! dbm::is_result($r))
killme(); killme();
if(! intval($r[0]['starred'])) if(! intval($r[0]['starred']))

View File

@ -20,7 +20,7 @@ function subthread_content(&$a) {
dbesc($item_id) dbesc($item_id)
); );
if(! $item_id || (! count($r))) { if(! $item_id || (! dbm::is_result($r))) {
logger('subthread: no item ' . $item_id); logger('subthread: no item ' . $item_id);
return; return;
} }
@ -41,7 +41,7 @@ function subthread_content(&$a) {
intval($item['contact-id']), intval($item['contact-id']),
intval($item['uid']) intval($item['uid'])
); );
if(! count($r)) if(! dbm::is_result($r))
return; return;
if(! $r[0]['self']) if(! $r[0]['self'])
$remote_owner = $r[0]; $remote_owner = $r[0];
@ -53,7 +53,7 @@ function subthread_content(&$a) {
WHERE `contact`.`self` = 1 AND `contact`.`uid` = %d LIMIT 1", WHERE `contact`.`self` = 1 AND `contact`.`uid` = %d LIMIT 1",
intval($owner_uid) intval($owner_uid)
); );
if(count($r)) if(dbm::is_result($r))
$owner = $r[0]; $owner = $r[0];
if(! $owner) { if(! $owner) {
@ -75,7 +75,7 @@ function subthread_content(&$a) {
intval($_SESSION['visitor_id']), intval($_SESSION['visitor_id']),
intval($owner_uid) intval($owner_uid)
); );
if(count($r)) if(dbm::is_result($r))
$contact = $r[0]; $contact = $r[0];
} }
if(! $contact) { if(! $contact) {

Some files were not shown because too many files have changed in this diff Show More