1
0
Fork 0

Continued with coding convention:

- added curly braces around conditional code blocks
- added space between if/foreach/... and brace
- rewrote a code block so if dbm::is_result() fails it will abort, else the id
  is fetched from INSERT statement
- made some SQL keywords upper-cased and added back-ticks to columns/table names

Signed-off-by: Roland Haeder <roland@mxchange.org>
This commit is contained in:
Roland Häder 2016-12-20 21:15:53 +01:00
parent af2909bf8f
commit 6e44acfed6
No known key found for this signature in database
GPG key ID: B72F8185C6C7BD78
31 changed files with 173 additions and 127 deletions

View file

@ -1122,7 +1122,7 @@ function admin_page_dbsync(App &$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 (dbm::is_result($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')
continue; continue;

View file

@ -49,7 +49,7 @@ function allfriends_content(App &$a) {
$id = 0; $id = 0;
foreach($r as $rr) { foreach ($r as $rr) {
//get further details of the contact //get further details of the contact
$contact_details = get_contact_details_by_url($rr['url'], $uid, $rr); $contact_details = get_contact_details_by_url($rr['url'], $uid, $rr);

View file

@ -229,7 +229,7 @@ function cal_content(App &$a) {
if (dbm::is_result($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'));
if (! x($links,$j)) { if (! x($links,$j)) {
$links[$j] = App::get_baseurl() . '/' . $a->cmd . '#link-' . $j; $links[$j] = App::get_baseurl() . '/' . $a->cmd . '#link-' . $j;

View file

@ -101,7 +101,7 @@ function common_content(App &$a) {
$id = 0; $id = 0;
foreach($r as $rr) { foreach ($r as $rr) {
//get further details of the contact //get further details of the contact
$contact_details = get_contact_details_by_url($rr['url'], $uid); $contact_details = get_contact_details_by_url($rr['url'], $uid);

View file

@ -129,10 +129,12 @@ function contacts_batch_actions(App &$a){
info ( sprintf( tt("%d contact edited.", "%d contacts edited.", $count_actions), $count_actions) ); info ( sprintf( tt("%d contact edited.", "%d contacts edited.", $count_actions), $count_actions) );
} }
if(x($_SESSION,'return_url')) if (x($_SESSION,'return_url')) {
goaway('' . $_SESSION['return_url']); goaway('' . $_SESSION['return_url']);
else }
else {
goaway('contacts'); goaway('contacts');
}
} }
@ -387,7 +389,7 @@ function contacts_content(App &$a) {
if($cmd === 'block') { if($cmd === 'block') {
$r = _contact_block($contact_id, $orig_record[0]); $r = _contact_block($contact_id, $orig_record[0]);
if($r) { if ($r) {
$blocked = (($orig_record[0]['blocked']) ? 0 : 1); $blocked = (($orig_record[0]['blocked']) ? 0 : 1);
info((($blocked) ? t('Contact has been blocked') : t('Contact has been unblocked')).EOL); info((($blocked) ? t('Contact has been blocked') : t('Contact has been unblocked')).EOL);
} }
@ -398,7 +400,7 @@ function contacts_content(App &$a) {
if($cmd === 'ignore') { if($cmd === 'ignore') {
$r = _contact_ignore($contact_id, $orig_record[0]); $r = _contact_ignore($contact_id, $orig_record[0]);
if($r) { if ($r) {
$readonly = (($orig_record[0]['readonly']) ? 0 : 1); $readonly = (($orig_record[0]['readonly']) ? 0 : 1);
info((($readonly) ? t('Contact has been ignored') : t('Contact has been unignored')).EOL); info((($readonly) ? t('Contact has been ignored') : t('Contact has been unignored')).EOL);
} }
@ -410,7 +412,7 @@ function contacts_content(App &$a) {
if($cmd === 'archive') { if($cmd === 'archive') {
$r = _contact_archive($contact_id, $orig_record[0]); $r = _contact_archive($contact_id, $orig_record[0]);
if($r) { if ($r) {
$archived = (($orig_record[0]['archive']) ? 0 : 1); $archived = (($orig_record[0]['archive']) ? 0 : 1);
info((($archived) ? t('Contact has been archived') : t('Contact has been unarchived')).EOL); info((($archived) ? t('Contact has been archived') : t('Contact has been unarchived')).EOL);
} }
@ -449,22 +451,26 @@ function contacts_content(App &$a) {
)); ));
} }
// Now check how the user responded to the confirmation query // Now check how the user responded to the confirmation query
if($_REQUEST['canceled']) { if ($_REQUEST['canceled']) {
if(x($_SESSION,'return_url')) if (x($_SESSION,'return_url')) {
goaway('' . $_SESSION['return_url']); goaway('' . $_SESSION['return_url']);
else }
else {
goaway('contacts'); goaway('contacts');
}
} }
_contact_drop($contact_id, $orig_record[0]); _contact_drop($contact_id, $orig_record[0]);
info( t('Contact has been removed.') . EOL ); info( t('Contact has been removed.') . EOL );
if(x($_SESSION,'return_url')) if (x($_SESSION,'return_url')) {
goaway('' . $_SESSION['return_url']); goaway('' . $_SESSION['return_url']);
else }
else {
goaway('contacts'); goaway('contacts');
}
return; // NOTREACHED return; // NOTREACHED
} }
if($cmd === 'posts') { if ($cmd === 'posts') {
return contact_posts($a, $contact_id); return contact_posts($a, $contact_id);
} }
} }

View file

@ -107,7 +107,7 @@ function delegate_content(App &$a) {
$nicknames = array(); $nicknames = array();
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) { foreach ($r as $rr) {
$nicknames[] = "'" . dbesc(basename($rr['nurl'])) . "'"; $nicknames[] = "'" . dbesc(basename($rr['nurl'])) . "'";
} }
} }

View file

@ -178,7 +178,7 @@ function dfrn_request_post(App &$a) {
); );
} }
if($r) { if ($r) {
info( t("Introduction complete.") . EOL); info( t("Introduction complete.") . EOL);
} }
@ -301,7 +301,7 @@ function dfrn_request_post(App &$a) {
dbesc(NETWORK_MAIL2) dbesc(NETWORK_MAIL2)
); );
if (dbm::is_result($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",
intval($rr['cid']) intval($rr['cid'])
@ -326,7 +326,7 @@ function dfrn_request_post(App &$a) {
dbesc(NETWORK_MAIL2) dbesc(NETWORK_MAIL2)
); );
if (dbm::is_result($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",
intval($rr['cid']) intval($rr['cid'])

View file

@ -92,12 +92,14 @@ function directory_content(App &$a) {
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 (dbm::is_result($r)) { if (dbm::is_result($r)) {
if(in_array('small', $a->argv)) if (in_array('small', $a->argv)) {
$photo = 'thumb'; $photo = 'thumb';
else }
else {
$photo = 'photo'; $photo = 'photo';
}
foreach($r as $rr) { foreach ($r as $rr) {
$itemurl= ''; $itemurl= '';

View file

@ -344,7 +344,7 @@ function events_content(App &$a) {
if (dbm::is_result($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'));
if (! x($links,$j)) { if (! x($links,$j)) {
$links[$j] = App::get_baseurl() . '/' . $a->cmd . '#link-' . $j; $links[$j] = App::get_baseurl() . '/' . $a->cmd . '#link-' . $j;

View file

@ -10,18 +10,21 @@ function filerm_content(App &$a) {
$cat = unxmlify(trim($_GET['cat'])); $cat = unxmlify(trim($_GET['cat']));
$category = (($cat) ? true : false); $category = (($cat) ? true : false);
if($category) if ($category) {
$term = $cat; $term = $cat;
}
$item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0); $item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
logger('filerm: tag ' . $term . ' item ' . $item_id); logger('filerm: tag ' . $term . ' item ' . $item_id);
if($item_id && strlen($term)) if ($item_id && strlen($term)) {
file_tag_unsave_file(local_user(),$item_id,$term, $category); file_tag_unsave_file(local_user(),$item_id,$term, $category);
}
if(x($_SESSION,'return_url')) if (x($_SESSION,'return_url')) {
goaway(App::get_baseurl() . '/' . $_SESSION['return_url']); goaway(App::get_baseurl() . '/' . $_SESSION['return_url']);
}
killme(); killme();
} }

View file

@ -157,8 +157,9 @@ function follow_post(App &$a) {
// NOTREACHED // NOTREACHED
} }
if ($_REQUEST['cancel']) if ($_REQUEST['cancel']) {
goaway($_SESSION['return_url']); goaway($_SESSION['return_url']);
}
$uid = local_user(); $uid = local_user();
$url = notags(trim($_REQUEST['url'])); $url = notags(trim($_REQUEST['url']));
@ -170,17 +171,21 @@ function follow_post(App &$a) {
$result = new_contact($uid,$url,true); $result = new_contact($uid,$url,true);
if($result['success'] == false) { if ($result['success'] == false) {
if($result['message']) if ($result['message']) {
notice($result['message']); notice($result['message']);
}
goaway($return_url); goaway($return_url);
} elseif ($result['cid']) }
elseif ($result['cid']) {
goaway(App::get_baseurl().'/contacts/'.$result['cid']); goaway(App::get_baseurl().'/contacts/'.$result['cid']);
}
info( t('Contact added').EOL); info( t('Contact added').EOL);
if(strstr($return_url,'contacts')) if (strstr($return_url,'contacts')) {
goaway(App::get_baseurl().'/contacts/'.$contact_id); goaway(App::get_baseurl().'/contacts/'.$contact_id);
}
goaway($return_url); goaway($return_url);
// NOTREACHED // NOTREACHED

View file

@ -25,7 +25,7 @@ function group_post(App &$a) {
$name = notags(trim($_POST['groupname'])); $name = notags(trim($_POST['groupname']));
$r = group_add(local_user(),$name); $r = group_add(local_user(),$name);
if($r) { if ($r) {
info( t('Group created.') . EOL ); info( t('Group created.') . EOL );
$r = group_byname(local_user(),$name); $r = group_byname(local_user(),$name);
if ($r) { if ($r) {

View file

@ -4,8 +4,9 @@ function hcard_init(App &$a) {
$blocked = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false); $blocked = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false);
if($a->argc > 1) if ($a->argc > 1) {
$which = $a->argv[1]; $which = $a->argv[1];
}
else { else {
notice( t('No profile') . EOL ); notice( t('No profile') . EOL );
$a->error = 404; $a->error = 404;
@ -13,28 +14,30 @@ function hcard_init(App &$a) {
} }
$profile = 0; $profile = 0;
if((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) { if ((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) {
$which = $a->user['nickname']; $which = $a->user['nickname'];
$profile = $a->argv[1]; $profile = $a->argv[1];
} }
profile_load($a,$which,$profile); profile_load($a,$which,$profile);
if((x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY)) { if ((x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY)) {
$a->page['htmlhead'] .= '<meta name="friendica.community" content="true" />'; $a->page['htmlhead'] .= '<meta name="friendica.community" content="true" />';
} }
if(x($a->profile,'openidserver')) if (x($a->profile,'openidserver')) {
$a->page['htmlhead'] .= '<link rel="openid.server" href="' . $a->profile['openidserver'] . '" />' . "\r\n"; $a->page['htmlhead'] .= '<link rel="openid.server" href="' . $a->profile['openidserver'] . '" />' . "\r\n";
if(x($a->profile,'openid')) { }
if (x($a->profile,'openid')) {
$delegate = ((strstr($a->profile['openid'],'://')) ? $a->profile['openid'] : 'http://' . $a->profile['openid']); $delegate = ((strstr($a->profile['openid'],'://')) ? $a->profile['openid'] : 'http://' . $a->profile['openid']);
$a->page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\r\n"; $a->page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\r\n";
} }
if(! $blocked) { if (! $blocked) {
$keywords = ((x($a->profile,'pub_keywords')) ? $a->profile['pub_keywords'] : ''); $keywords = ((x($a->profile,'pub_keywords')) ? $a->profile['pub_keywords'] : '');
$keywords = str_replace(array(',',' ',',,'),array(' ',',',','),$keywords); $keywords = str_replace(array(',',' ',',,'),array(' ',',',','),$keywords);
if(strlen($keywords)) if (strlen($keywords)) {
$a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n" ; $a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n" ;
}
} }
$a->page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . (($a->profile['net-publish']) ? 'true' : 'false') . '" />' . "\r\n" ; $a->page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . (($a->profile['net-publish']) ? 'true' : 'false') . '" />' . "\r\n" ;
@ -44,7 +47,7 @@ function hcard_init(App &$a) {
header('Link: <' . App::get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false); header('Link: <' . App::get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
$dfrn_pages = array('request', 'confirm', 'notify', 'poll'); $dfrn_pages = array('request', 'confirm', 'notify', 'poll');
foreach($dfrn_pages as $dfrn) { foreach ($dfrn_pages as $dfrn) {
$a->page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"".App::get_baseurl()."/dfrn_{$dfrn}/{$which}\" />\r\n"; $a->page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"".App::get_baseurl()."/dfrn_{$dfrn}/{$which}\" />\r\n";
} }

View file

@ -52,7 +52,7 @@ function install_post(App &$a) {
$r = q("CREATE DATABASE '%s'", $r = q("CREATE DATABASE '%s'",
dbesc($dbdata) dbesc($dbdata)
); );
if($r) { if ($r) {
unset($db); unset($db);
$db = new dba($dbhost, $dbuser, $dbpass, $dbdata, true); $db = new dba($dbhost, $dbuser, $dbpass, $dbdata, true);
} else { } else {
@ -520,19 +520,22 @@ function check_smarty3(&$checks) {
function check_htaccess(&$checks) { function check_htaccess(&$checks) {
$status = true; $status = true;
$help = ""; $help = "";
if (function_exists('curl_init')){ if (function_exists('curl_init')) {
$test = fetch_url(App::get_baseurl()."/install/testrewrite"); $test = fetch_url(App::get_baseurl()."/install/testrewrite");
if ($test!="ok") if ($test!="ok") {
$test = fetch_url(normalise_link(App::get_baseurl()."/install/testrewrite")); $test = fetch_url(normalise_link(App::get_baseurl()."/install/testrewrite"));
}
if ($test!="ok") { if ($test!="ok") {
$status = false; $status = false;
$help = t('Url rewrite in .htaccess is not working. Check your server configuration.'); $help = t('Url rewrite in .htaccess is not working. Check your server configuration.');
} }
check_add($checks, t('Url rewrite is working'), $status, true, $help); check_add($checks, t('Url rewrite is working'), $status, true, $help);
} else { }
else {
// cannot check modrewrite if libcurl is not installed // cannot check modrewrite if libcurl is not installed
/// @TODO Maybe issue warning here?
} }
} }
@ -549,7 +552,7 @@ function check_imagik(&$checks) {
} }
if ($imagick == false) { if ($imagick == false) {
check_add($checks, t('ImageMagick PHP extension is not installed'), $imagick, false, ""); check_add($checks, t('ImageMagick PHP extension is not installed'), $imagick, false, "");
} }
else { else {
check_add($checks, t('ImageMagick PHP extension is installed'), $imagick, false, ""); check_add($checks, t('ImageMagick PHP extension is installed'), $imagick, false, "");
if ($imagick) { if ($imagick) {

View file

@ -116,11 +116,13 @@ function invite_content(App &$a) {
$dirloc = get_config('system','directory'); $dirloc = get_config('system','directory');
if(strlen($dirloc)) { if(strlen($dirloc)) {
if($a->config['register_policy'] == REGISTER_CLOSED) if ($a->config['register_policy'] == REGISTER_CLOSED) {
$linktxt = sprintf( t('Visit %s for a list of public sites that you can join. Friendica members on other sites can all connect with each other, as well as with members of many other social networks.'), $dirloc . '/siteinfo'); $linktxt = sprintf( t('Visit %s for a list of public sites that you can join. Friendica members on other sites can all connect with each other, as well as with members of many other social networks.'), $dirloc . '/siteinfo');
elseif($a->config['register_policy'] != REGISTER_CLOSED) }
elseif($a->config['register_policy'] != REGISTER_CLOSED) {
$linktxt = sprintf( t('To accept this invitation, please visit and register at %s or any other public Friendica website.'), App::get_baseurl()) $linktxt = sprintf( t('To accept this invitation, please visit and register at %s or any other public Friendica website.'), App::get_baseurl())
. "\r\n" . "\r\n" . sprintf( t('Friendica sites all inter-connect to create a huge privacy-enhanced social web that is owned and controlled by its members. They can also connect with many traditional social networks. See %s for a list of alternate Friendica sites you can join.'),$dirloc . '/siteinfo'); . "\r\n" . "\r\n" . sprintf( t('Friendica sites all inter-connect to create a huge privacy-enhanced social web that is owned and controlled by its members. They can also connect with many traditional social networks. See %s for a list of alternate Friendica sites you can join.'),$dirloc . '/siteinfo');
}
} }
else { else {
$o = t('Our apologies. This system is not currently configured to connect with other public sites or invite members.'); $o = t('Our apologies. This system is not currently configured to connect with other public sites or invite members.');
@ -129,15 +131,15 @@ function invite_content(App &$a) {
$o = replace_macros($tpl, array( $o = replace_macros($tpl, array(
'$form_security_token' => get_form_security_token("send_invite"), '$form_security_token' => get_form_security_token("send_invite"),
'$invite' => t('Send invitations'), '$invite' => t('Send invitations'),
'$addr_text' => t('Enter email addresses, one per line:'), '$addr_text' => t('Enter email addresses, one per line:'),
'$msg_text' => t('Your message:'), '$msg_text' => t('Your message:'),
'$default_message' => t('You are cordially invited to join me and other close friends on Friendica - and help us to create a better social web.') . "\r\n" . "\r\n" '$default_message' => t('You are cordially invited to join me and other close friends on Friendica - and help us to create a better social web.') . "\r\n" . "\r\n"
. $linktxt . $linktxt
. "\r\n" . "\r\n" . (($invonly) ? t('You will need to supply this invitation code: $invite_code') . "\r\n" . "\r\n" : '') .t('Once you have registered, please connect with me via my profile page at:') . "\r\n" . "\r\n" . (($invonly) ? t('You will need to supply this invitation code: $invite_code') . "\r\n" . "\r\n" : '') .t('Once you have registered, please connect with me via my profile page at:')
. "\r\n" . "\r\n" . App::get_baseurl() . '/profile/' . $a->user['nickname'] . "\r\n" . "\r\n" . App::get_baseurl() . '/profile/' . $a->user['nickname']
. "\r\n" . "\r\n" . t('For more information about the Friendica project and why we feel it is important, please visit http://friendica.com') . "\r\n" . "\r\n" , . "\r\n" . "\r\n" . t('For more information about the Friendica project and why we feel it is important, please visit http://friendica.com') . "\r\n" . "\r\n" ,
'$submit' => t('Submit') '$submit' => t('Submit')
)); ));
return $o; return $o;

View file

@ -59,13 +59,14 @@ function item_post(App &$a) {
// Check for doubly-submitted posts, and reject duplicates // Check for doubly-submitted posts, and reject duplicates
// Note that we have to ignore previews, otherwise nothing will post // Note that we have to ignore previews, otherwise nothing will post
// after it's been previewed // after it's been previewed
if(!$preview && x($_REQUEST['post_id_random'])) { if (!$preview && x($_REQUEST['post_id_random'])) {
if(x($_SESSION['post-random']) && $_SESSION['post-random'] == $_REQUEST['post_id_random']) { if (x($_SESSION['post-random']) && $_SESSION['post-random'] == $_REQUEST['post_id_random']) {
logger("item post: duplicate post", LOGGER_DEBUG); logger("item post: duplicate post", LOGGER_DEBUG);
item_post_return(App::get_baseurl(), $api_source, $return_path); item_post_return(App::get_baseurl(), $api_source, $return_path);
} }
else else {
$_SESSION['post-random'] = $_REQUEST['post_id_random']; $_SESSION['post-random'] = $_REQUEST['post_id_random'];
}
} }
/** /**
@ -82,18 +83,20 @@ function item_post(App &$a) {
$r = false; $r = false;
$objecttype = null; $objecttype = null;
if($parent || $parent_uri) { if ($parent || $parent_uri) {
$objecttype = ACTIVITY_OBJ_COMMENT; $objecttype = ACTIVITY_OBJ_COMMENT;
if(! x($_REQUEST,'type')) if (! x($_REQUEST,'type')) {
$_REQUEST['type'] = 'net-comment'; $_REQUEST['type'] = 'net-comment';
}
if($parent) { if ($parent) {
$r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1", $r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1",
intval($parent) intval($parent)
); );
} elseif($parent_uri && local_user()) { }
elseif ($parent_uri && local_user()) {
// This is coming from an API source, and we are logged in // This is coming from an API source, and we are logged in
$r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($parent_uri), dbesc($parent_uri),
@ -105,7 +108,7 @@ function item_post(App &$a) {
if (dbm::is_result($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']) {
$r = q("SELECT * FROM `item` WHERE `id` = `parent` AND `parent` = %d LIMIT 1", $r = q("SELECT * FROM `item` WHERE `id` = `parent` AND `parent` = %d LIMIT 1",
intval($parid) intval($parid)
); );
@ -114,8 +117,9 @@ function item_post(App &$a) {
if (! dbm::is_result($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);
}
killme(); killme();
} }
$parent_item = $r[0]; $parent_item = $r[0];
@ -125,7 +129,7 @@ function item_post(App &$a) {
//if(($parid) && ($parid != $parent)) //if(($parid) && ($parid != $parent))
$thr_parent = $parent_uri; $thr_parent = $parent_uri;
if($parent_item['contact-id'] && $uid) { if ($parent_item['contact-id'] && $uid) {
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($parent_item['contact-id']), intval($parent_item['contact-id']),
intval($uid) intval($uid)
@ -449,13 +453,15 @@ function item_post(App &$a) {
$objecttype = ACTIVITY_OBJ_IMAGE; $objecttype = ACTIVITY_OBJ_IMAGE;
foreach($images as $image) { foreach ($images as $image) {
if(! stristr($image,App::get_baseurl() . '/photo/')) if (! stristr($image,App::get_baseurl() . '/photo/')) {
continue; continue;
}
$image_uri = substr($image,strrpos($image,'/') + 1); $image_uri = substr($image,strrpos($image,'/') + 1);
$image_uri = substr($image_uri,0, strpos($image_uri,'-')); $image_uri = substr($image_uri,0, strpos($image_uri,'-'));
if(! strlen($image_uri)) if (! strlen($image_uri)) {
continue; continue;
}
$srch = '<' . intval($contact_id) . '>'; $srch = '<' . intval($contact_id) . '>';
$r = q("SELECT `id` FROM `photo` WHERE `allow_cid` = '%s' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = '' $r = q("SELECT `id` FROM `photo` WHERE `allow_cid` = '%s' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = ''

View file

@ -102,7 +102,7 @@ function lostpass_content(App &$a) {
dbesc($new_password_encoded), dbesc($new_password_encoded),
intval($uid) intval($uid)
); );
if($r) { if ($r) {
$tpl = get_markup_template('pwdreset.tpl'); $tpl = get_markup_template('pwdreset.tpl');
$o .= replace_macros($tpl,array( $o .= replace_macros($tpl,array(
'$lbl1' => t('Password Reset'), '$lbl1' => t('Password Reset'),

View file

@ -160,7 +160,7 @@ function item_redir_and_replace_images($body, $images, $cid) {
$newbody = $newbody . $origbody; $newbody = $newbody . $origbody;
$cnt = 0; $cnt = 0;
foreach($images as $image) { foreach ($images as $image) {
// We're depending on the property of 'foreach' (specified on the PHP website) that // We're depending on the property of 'foreach' (specified on the PHP website) that
// it loops over the array starting from the first element and going sequentially // it loops over the array starting from the first element and going sequentially
// to the last element // to the last element
@ -231,7 +231,7 @@ function message_content(App &$a) {
intval($a->argv[2]), intval($a->argv[2]),
intval(local_user()) intval(local_user())
); );
if($r) { if ($r) {
info( t('Message deleted.') . EOL ); info( t('Message deleted.') . EOL );
} }
//goaway(App::get_baseurl(true) . '/message' ); //goaway(App::get_baseurl(true) . '/message' );

View file

@ -183,13 +183,13 @@ function saved_searches($search) {
$saved = array(); $saved = array();
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) { foreach ($r as $rr) {
$saved[] = array( $saved[] = array(
'id' => $rr['id'], 'id' => $rr['id'],
'term' => $rr['term'], 'term' => $rr['term'],
'encodedterm' => urlencode($rr['term']), 'encodedterm' => urlencode($rr['term']),
'delete' => t('Remove term'), 'delete' => t('Remove term'),
'selected' => ($search==$rr['term']), 'selected' => ($search==$rr['term']),
); );
} }
} }
@ -197,10 +197,10 @@ function saved_searches($search) {
$tpl = get_markup_template("saved_searches_aside.tpl"); $tpl = get_markup_template("saved_searches_aside.tpl");
$o = replace_macros($tpl, array( $o = replace_macros($tpl, array(
'$title' => t('Saved Searches'), '$title' => t('Saved Searches'),
'$add' => t('add'), '$add' => t('add'),
'$searchbox' => search($search,'netsearch-box',$srchurl,true), '$searchbox' => search($search,'netsearch-box',$srchurl,true),
'$saved' => $saved, '$saved' => $saved,
)); ));
return $o; return $o;

View file

@ -35,7 +35,7 @@ function nogroup_content(App &$a) {
} }
$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 (dbm::is_result($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

@ -31,21 +31,22 @@ function noscrape_init(App &$a) {
intval($a->profile['uid'])); intval($a->profile['uid']));
$json_info = array( $json_info = array(
'fn' => $a->profile['name'], 'fn' => $a->profile['name'],
'addr' => $a->profile['addr'], 'addr' => $a->profile['addr'],
'nick' => $which, 'nick' => $which,
'key' => $a->profile['pubkey'], 'key' => $a->profile['pubkey'],
'homepage' => App::get_baseurl()."/profile/{$which}", 'homepage' => App::get_baseurl()."/profile/{$which}",
'comm' => (x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY), 'comm' => (x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY),
'photo' => $r[0]["photo"], 'photo' => $r[0]["photo"],
'tags' => $keywords 'tags' => $keywords
); );
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 (dbm::is_result($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
AND `network` IN ('%s', '%s', '%s', '')", AND `network` IN ('%s', '%s', '%s', '')",
@ -54,20 +55,21 @@ function noscrape_init(App &$a) {
dbesc(NETWORK_DIASPORA), dbesc(NETWORK_DIASPORA),
dbesc(NETWORK_OSTATUS) dbesc(NETWORK_OSTATUS)
); );
if (dbm::is_result($r)) if (dbm::is_result($r)) {
$json_info["contacts"] = intval($r[0]['total']); $json_info["contacts"] = intval($r[0]['total']);
}
} }
//These are optional fields. //These are optional fields.
$profile_fields = array('pdesc', 'locality', 'region', 'postal-code', 'country-name', 'gender', 'marital', 'about'); $profile_fields = array('pdesc', 'locality', 'region', 'postal-code', 'country-name', 'gender', 'marital', 'about');
foreach($profile_fields as $field) { foreach ($profile_fields as $field) {
if(!empty($a->profile[$field])) { if (!empty($a->profile[$field])) {
$json_info["$field"] = $a->profile[$field]; $json_info["$field"] = $a->profile[$field];
} }
} }
$dfrn_pages = array('request', 'confirm', 'notify', 'poll'); $dfrn_pages = array('request', 'confirm', 'notify', 'poll');
foreach($dfrn_pages as $dfrn) { foreach ($dfrn_pages as $dfrn) {
$json_info["dfrn-{$dfrn}"] = App::get_baseurl()."/dfrn_{$dfrn}/{$which}"; $json_info["dfrn-{$dfrn}"] = App::get_baseurl()."/dfrn_{$dfrn}/{$which}";
} }

View file

@ -56,7 +56,7 @@ function openid_content(App &$a) {
// Successful OpenID login - but we can't match it to an existing account. // Successful OpenID login - but we can't match it to an existing account.
// New registration? // New registration?
if($a->config['register_policy'] == REGISTER_CLOSED) { if ($a->config['register_policy'] == REGISTER_CLOSED) {
notice( t('Account not found and OpenID registration is not permitted on this site.') . EOL); notice( t('Account not found and OpenID registration is not permitted on this site.') . EOL);
goaway(z_root()); goaway(z_root());
} }
@ -64,31 +64,41 @@ function openid_content(App &$a) {
unset($_SESSION['register']); unset($_SESSION['register']);
$args = ''; $args = '';
$attr = $openid->getAttributes(); $attr = $openid->getAttributes();
if(is_array($attr) && count($attr)) { if (is_array($attr) && count($attr)) {
foreach($attr as $k => $v) { foreach ($attr as $k => $v) {
if($k === 'namePerson/friendly') if ($k === 'namePerson/friendly') {
$nick = notags(trim($v)); $nick = notags(trim($v));
if($k === 'namePerson/first') }
if($k === 'namePerson/first') {
$first = notags(trim($v)); $first = notags(trim($v));
if($k === 'namePerson') }
if($k === 'namePerson') {
$args .= '&username=' . notags(trim($v)); $args .= '&username=' . notags(trim($v));
if($k === 'contact/email') }
if ($k === 'contact/email') {
$args .= '&email=' . notags(trim($v)); $args .= '&email=' . notags(trim($v));
if($k === 'media/image/aspect11') }
if ($k === 'media/image/aspect11') {
$photosq = bin2hex(trim($v)); $photosq = bin2hex(trim($v));
if($k === 'media/image/default') }
if ($k === 'media/image/default') {
$photo = bin2hex(trim($v)); $photo = bin2hex(trim($v));
}
} }
} }
if($nick) if ($nick) {
$args .= '&nickname=' . $nick; $args .= '&nickname=' . $nick;
elseif($first) }
elseif ($first) {
$args .= '&nickname=' . $first; $args .= '&nickname=' . $first;
}
if($photosq) if ($photosq) {
$args .= '&photo=' . $photosq; $args .= '&photo=' . $photosq;
elseif($photo) }
elseif ($photo) {
$args .= '&photo=' . $photo; $args .= '&photo=' . $photo;
}
$args .= '&openid_url=' . notags(trim($authid)); $args .= '&openid_url=' . notags(trim($authid));

View file

@ -255,7 +255,7 @@ function photos_post(App &$a) {
); );
} }
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) { foreach ($r as $rr) {
$res[] = "'" . dbesc($rr['rid']) . "'" ; $res[] = "'" . dbesc($rr['rid']) . "'" ;
} }
} else { } else {
@ -277,7 +277,7 @@ function photos_post(App &$a) {
intval($page_owner_uid) intval($page_owner_uid)
); );
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) { foreach ($r as $rr) {
q("UPDATE `item` SET `deleted` = 1, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d", q("UPDATE `item` SET `deleted` = 1, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d",
dbesc(datetime_convert()), dbesc(datetime_convert()),
dbesc($rr['parent-uri']), dbesc($rr['parent-uri']),

View file

@ -175,7 +175,7 @@ function poco_init(App &$a) {
if(is_array($r)) { if(is_array($r)) {
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) { foreach ($r as $rr) {
if (!isset($rr['generation'])) { if (!isset($rr['generation'])) {
if ($global) if ($global)
$rr['generation'] = 3; $rr['generation'] = 3;

View file

@ -62,7 +62,7 @@ function profile_init(App &$a) {
header('Link: <' . App::get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false); header('Link: <' . App::get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
$dfrn_pages = array('request', 'confirm', 'notify', 'poll'); $dfrn_pages = array('request', 'confirm', 'notify', 'poll');
foreach($dfrn_pages as $dfrn) { foreach ($dfrn_pages as $dfrn) {
$a->page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"".App::get_baseurl()."/dfrn_{$dfrn}/{$which}\" />\r\n"; $a->page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"".App::get_baseurl()."/dfrn_{$dfrn}/{$which}\" />\r\n";
} }
$a->page['htmlhead'] .= "<link rel=\"dfrn-poco\" href=\"".App::get_baseurl()."/poco/{$which}\" />\r\n"; $a->page['htmlhead'] .= "<link rel=\"dfrn-poco\" href=\"".App::get_baseurl()."/poco/{$which}\" />\r\n";

View file

@ -204,7 +204,7 @@ function profile_photo_content(App &$a) {
return; return;
} }
$havescale = false; $havescale = false;
foreach($r as $rr) { foreach ($r as $rr) {
if($rr['scale'] == 5) if($rr['scale'] == 5)
$havescale = true; $havescale = true;
} }

View file

@ -780,24 +780,26 @@ function profiles_content(App &$a) {
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
$tpl = get_markup_template('profile_entry.tpl'); $tpl = get_markup_template('profile_entry.tpl');
foreach($r as $rr) {
$profiles = '';
foreach ($r as $rr) {
$profiles .= replace_macros($tpl, array( $profiles .= replace_macros($tpl, array(
'$photo' => $a->remove_baseurl($rr['thumb']), '$photo' => $a->remove_baseurl($rr['thumb']),
'$id' => $rr['id'], '$id' => $rr['id'],
'$alt' => t('Profile Image'), '$alt' => t('Profile Image'),
'$profile_name' => $rr['profile-name'], '$profile_name' => $rr['profile-name'],
'$visible' => (($rr['is-default']) ? '<strong>' . t('visible to everybody') . '</strong>' '$visible' => (($rr['is-default']) ? '<strong>' . t('visible to everybody') . '</strong>'
: '<a href="'.'profperm/'.$rr['id'].'" />' . t('Edit visibility') . '</a>') : '<a href="'.'profperm/'.$rr['id'].'" />' . t('Edit visibility') . '</a>')
)); ));
} }
$tpl_header = get_markup_template('profile_listing_header.tpl'); $tpl_header = get_markup_template('profile_listing_header.tpl');
$o .= replace_macros($tpl_header,array( $o .= replace_macros($tpl_header,array(
'$header' => t('Edit/Manage Profiles'), '$header' => t('Edit/Manage Profiles'),
'$chg_photo' => t('Change profile photo'), '$chg_photo' => t('Change profile photo'),
'$cr_new' => t('Create New Profile'), '$cr_new' => t('Create New Profile'),
'$cr_new_link' => 'profiles/new?t=' . get_form_security_token("profile_new"), '$cr_new_link' => 'profiles/new?t=' . get_form_security_token("profile_new"),
'$profiles' => $profiles '$profiles' => $profiles
)); ));
} }
return $o; return $o;

View file

@ -17,7 +17,7 @@ function search_saved_searches() {
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
$saved = array(); $saved = array();
foreach($r as $rr) { foreach ($r as $rr) {
$saved[] = array( $saved[] = array(
'id' => $rr['id'], 'id' => $rr['id'],
'term' => $rr['term'], 'term' => $rr['term'],

View file

@ -75,7 +75,7 @@ function suggest_content(App &$a) {
require_once 'include/contact_selectors.php'; require_once 'include/contact_selectors.php';
foreach($r as $rr) { foreach ($r as $rr) {
$connlnk = App::get_baseurl() . '/follow/?url=' . (($rr['connect']) ? $rr['connect'] : $rr['url']); $connlnk = App::get_baseurl() . '/follow/?url=' . (($rr['connect']) ? $rr['connect'] : $rr['url']);
$ignlnk = App::get_baseurl() . '/suggest?ignore=' . $rr['id']; $ignlnk = App::get_baseurl() . '/suggest?ignore=' . $rr['id'];

View file

@ -368,8 +368,8 @@ function videos_content(App &$a) {
$videos = array(); $videos = array();
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) { foreach ($r as $rr) {
if($a->theme['template_engine'] === 'internal') { if ($a->theme['template_engine'] === 'internal') {
$alt_e = template_escape($rr['filename']); $alt_e = template_escape($rr['filename']);
$name_e = template_escape($rr['album']); $name_e = template_escape($rr['album']);
} }

View file

@ -76,9 +76,11 @@ function viewcontacts_content(App &$a) {
$contacts = array(); $contacts = array();
foreach($r as $rr) { foreach ($r as $rr) {
if($rr['self']) /// @TODO This triggers an E_NOTICE if 'self' is not there
if ($rr['self']) {
continue; continue;
}
$url = $rr['url']; $url = $rr['url'];