added spaces + some curly braces + some usage of dbm::is_result()

Signed-off-by: Roland Häder <roland@mxchange.org>
This commit is contained in:
Roland Häder 2017-01-26 15:23:30 +01:00 committed by Roland Haeder
parent 720e7d6034
commit 0cd241bcbe
No known key found for this signature in database
GPG Key ID: B72F8185C6C7BD78
92 changed files with 1190 additions and 1087 deletions

View File

@ -861,6 +861,7 @@ function admin_page_site(App $a) {
foreach ($files as $file) { foreach ($files as $file) {
if (intval(file_exists($file.'/unsupported'))) if (intval(file_exists($file.'/unsupported')))
continue; continue;
}
$f = basename($file); $f = basename($file);
@ -1274,7 +1275,7 @@ function admin_page_users(App $a) {
if ($a->argc>2) { if ($a->argc>2) {
$uid = $a->argv[3]; $uid = $a->argv[3];
$user = q("SELECT `username`, `blocked` FROM `user` WHERE `uid` = %d", intval($uid)); $user = q("SELECT `username`, `blocked` FROM `user` WHERE `uid` = %d", intval($uid));
if (count($user) == 0) { if (!dbm::is_result($user)) {
notice('User not found'.EOL); notice('User not found'.EOL);
goaway('admin/users'); goaway('admin/users');
return ''; // NOTREACHED return ''; // NOTREACHED
@ -1761,7 +1762,7 @@ function admin_page_themes(App $a) {
$status="off"; $action= t("Enable"); $status="off"; $action= t("Enable");
} }
$readme = Null; $readme = null;
if (is_file("view/theme/$theme/README.md")) { if (is_file("view/theme/$theme/README.md")) {
$readme = file_get_contents("view/theme/$theme/README.md"); $readme = file_get_contents("view/theme/$theme/README.md");
$readme = Markdown($readme); $readme = Markdown($readme);

View File

@ -37,8 +37,9 @@ function allfriends_content(App $a) {
$total = count_all_friends(local_user(), $cid); $total = count_all_friends(local_user(), $cid);
if(count($total)) if (count($total)) {
$a->set_pager_total($total); $a->set_pager_total($total);
}
$r = all_friends(local_user(), $cid, $a->pager['start'], $a->pager['itemspage']); $r = all_friends(local_user(), $cid, $a->pager['start'], $a->pager['itemspage']);

View File

@ -5,21 +5,19 @@ function apps_content(App $a) {
if ($privateaddons === "1") { if ($privateaddons === "1") {
if ((! (local_user()))) { if ((! (local_user()))) {
info( t("You must be logged in to use addons. ")); info( t("You must be logged in to use addons. "));
return;}; return;
}
} }
$title = t('Applications'); $title = t('Applications');
if(count($a->apps)==0) if (count($a->apps) == 0) {
notice( t('No installed applications.') . EOL); notice( t('No installed applications.') . EOL);
}
$tpl = get_markup_template("apps.tpl"); $tpl = get_markup_template("apps.tpl");
return replace_macros($tpl, array( return replace_macros($tpl, array(
'$title' => $title, '$title' => $title,
'$apps' => $a->apps, '$apps' => $a->apps,
)); ));
} }

View File

@ -69,6 +69,7 @@ function cal_content(App $a) {
// First day of the week (0 = Sunday) // First day of the week (0 = Sunday)
$firstDay = get_pconfig(local_user(),'system','first_day_of_week'); $firstDay = get_pconfig(local_user(),'system','first_day_of_week');
/// @TODO Convert all these to with curly braces
if ($firstDay === false) $firstDay=0; if ($firstDay === false) $firstDay=0;
// get the translation strings for the callendar // get the translation strings for the callendar
@ -94,6 +95,7 @@ function cal_content(App $a) {
$m = 0; $m = 0;
$ignored = ((x($_REQUEST,'ignored')) ? intval($_REQUEST['ignored']) : 0); $ignored = ((x($_REQUEST,'ignored')) ? intval($_REQUEST['ignored']) : 0);
/// @TODO Convert to one if() statement
if ($a->argc == 4) { if ($a->argc == 4) {
if ($a->argv[2] == 'export') { if ($a->argv[2] == 'export') {
$mode = 'export'; $mode = 'export';
@ -235,9 +237,10 @@ function cal_content(App $a) {
$events=array(); $events=array();
// transform the event in a usable array // transform the event in a usable array
if (dbm::is_result($r)) if (dbm::is_result($r)) {
$r = sort_by_date($r); $r = sort_by_date($r);
$events = process_events($r); $events = process_events($r);
}
if ($a->argv[2] === 'json'){ if ($a->argv[2] === 'json'){
echo json_encode($events); killme(); echo json_encode($events); killme();

View File

@ -63,17 +63,18 @@ function common_content(App $a) {
dbesc(normalise_link(get_my_url())), dbesc(normalise_link(get_my_url())),
intval($profile_uid) intval($profile_uid)
); );
if (dbm::is_result($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 (dbm::is_result($r)) if (dbm::is_result($r)) {
$zcid = $r[0]['id']; $zcid = $r[0]['id'];
} }
} }
} }
}
if ($cid == 0 && $zcid == 0) { if ($cid == 0 && $zcid == 0) {
return; return;

View File

@ -79,8 +79,9 @@ function community_content(App $a, $update = 0) {
$r = community_getitems($a->pager['start'] + ($count * $a->pager['itemspage']), $a->pager['itemspage']); $r = community_getitems($a->pager['start'] + ($count * $a->pager['itemspage']), $a->pager['itemspage']);
} while ((sizeof($s) < $a->pager['itemspage']) AND (++$count < 50) AND (sizeof($r) > 0)); } while ((sizeof($s) < $a->pager['itemspage']) AND (++$count < 50) AND (sizeof($r) > 0));
} else } else {
$s = $r; $s = $r;
}
// we behave the same in message lists as the search module // we behave the same in message lists as the search module

View File

@ -14,9 +14,10 @@ function contactgroup_content(App $a) {
intval($a->argv[2]), intval($a->argv[2]),
intval(local_user()) intval(local_user())
); );
if (dbm::is_result($r)) if (dbm::is_result($r)) {
$change = intval($a->argv[2]); $change = intval($a->argv[2]);
} }
}
if (($a->argc > 1) && (intval($a->argv[1]))) { if (($a->argc > 1) && (intval($a->argv[1]))) {
@ -32,15 +33,15 @@ function contactgroup_content(App $a) {
$members = group_get_members($group['id']); $members = group_get_members($group['id']);
$preselected = array(); $preselected = array();
if (count($members)) { if (count($members)) {
foreach($members as $member) foreach ($members as $member) {
$preselected[] = $member['id']; $preselected[] = $member['id'];
} }
}
if ($change) { if ($change) {
if (in_array($change,$preselected)) { if (in_array($change,$preselected)) {
group_rmv_member(local_user(),$group['name'],$change); group_rmv_member(local_user(),$group['name'],$change);
} } else {
else {
group_add_member(local_user(),$group['name'],$change); group_add_member(local_user(),$group['name'],$change);
} }
} }

View File

@ -41,17 +41,15 @@ function content_content(App $a, $update = 0) {
if ($a->argc > 1) { if ($a->argc > 1) {
for ($x = 1; $x < $a->argc; $x ++) { for ($x = 1; $x < $a->argc; $x ++) {
if (is_a_date_arg($a->argv[$x])) { if (is_a_date_arg($a->argv[$x])) {
if($datequery) if ($datequery) {
$datequery2 = escape_tags($a->argv[$x]); $datequery2 = escape_tags($a->argv[$x]);
else { } else {
$datequery = escape_tags($a->argv[$x]); $datequery = escape_tags($a->argv[$x]);
$_GET['order'] = 'post'; $_GET['order'] = 'post';
} }
} } elseif ($a->argv[$x] === 'new') {
elseif($a->argv[$x] === 'new') {
$nouveau = true; $nouveau = true;
} } elseif (intval($a->argv[$x])) {
elseif(intval($a->argv[$x])) {
$group = intval($a->argv[$x]); $group = intval($a->argv[$x]);
$def_acl = array('allow_gid' => '<' . $group . '>'); $def_acl = array('allow_gid' => '<' . $group . '>');
} }
@ -842,8 +840,9 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
// process action responses - e.g. like/dislike/attend/agree/whatever // process action responses - e.g. like/dislike/attend/agree/whatever
$response_verbs = array('like'); $response_verbs = array('like');
if(feature_enabled($profile_owner,'dislike')) if (feature_enabled($profile_owner,'dislike')) {
$response_verbs[] = 'dislike'; $response_verbs[] = 'dislike';
}
if ($item['object-type'] === ACTIVITY_OBJ_EVENT) { if ($item['object-type'] === ACTIVITY_OBJ_EVENT) {
$response_verbs[] = 'attendyes'; $response_verbs[] = 'attendyes';
$response_verbs[] = 'attendno'; $response_verbs[] = 'attendno';
@ -863,8 +862,9 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
$indent = (($toplevelpost) ? '' : ' comment'); $indent = (($toplevelpost) ? '' : ' comment');
$shiny = ""; $shiny = "";
if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0) if (strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0) {
$shiny = 'shiny'; $shiny = 'shiny';
}
// //
localize_item($item); localize_item($item);
@ -873,7 +873,9 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
$tags=array(); $tags=array();
foreach (explode(',',$item['tag']) as $tag){ foreach (explode(',',$item['tag']) as $tag){
$tag = trim($tag); $tag = trim($tag);
if ($tag!="") $tags[] = bbcode($tag); if ($tag!="") {
$tags[] = bbcode($tag);
}
} }
// Build the HTML // Build the HTML
@ -888,8 +890,7 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
$title_e = template_escape($item['title']); $title_e = template_escape($item['title']);
$location_e = template_escape($location); $location_e = template_escape($location);
$owner_name_e = template_escape($owner_name); $owner_name_e = template_escape($owner_name);
} } else {
else {
$body_e = $body; $body_e = $body;
$text_e = strip_tags($body); $text_e = strip_tags($body);
$name_e = $profile_name; $name_e = $profile_name;

View File

@ -23,16 +23,16 @@ function delegate_content(App $a) {
$id = $a->argv[2]; $id = $a->argv[2];
$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 (dbm::is_result($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(App::get_baseurl() . '/profile/' . $r[0]['nickname'])) dbesc(normalise_link(App::get_baseurl() . '/profile/' . $r[0]['nickname']))
); );
if (dbm::is_result($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,34 +64,40 @@ function delegate_content(App $a) {
dbesc($a->user['email']), dbesc($a->user['email']),
dbesc($a->user['password']) dbesc($a->user['password'])
); );
if (dbm::is_result($r)) if (dbm::is_result($r)) {
$full_managers = $r; $full_managers = $r;
}
$delegates = array(); $delegates = array();
// find everybody that currently has delegated management to this account/page // find everybody that currently has delegated management to this account/page
$r = q("select * from user where uid in ( select uid from manage where mid = %d ) ", $r = q("SELECT * FROM `user` WHERE `uid` IN ( SELECT `uid` FROM `manage` WHERE `mid` = %d ) ",
intval(local_user()) intval(local_user())
); );
if (dbm::is_result($r)) if (dbm::is_result($r)) {
$delegates = $r; $delegates = $r;
}
$uids = array(); $uids = array();
if(count($full_managers)) if (count($full_managers)) {
foreach($full_managers as $rr) foreach ($full_managers as $rr) {
$uids[] = $rr['uid']; $uids[] = $rr['uid'];
}
}
if(count($delegates)) if (count($delegates)) {
foreach($delegates as $rr) foreach ($delegates as $rr) {
$uids[] = $rr['uid']; $uids[] = $rr['uid'];
}
}
// find every contact who might be a candidate for delegation // find every contact who might be a candidate for delegation
$r = q("select nurl from contact where substring_index(contact.nurl,'/',3) = '%s' $r = q("SELECT `nurl` FROM `contact` WHERE SUBSTRING_INDEX(`contact`.`nurl`,'/',3) = '%s'
and contact.uid = %d and contact.self = 0 and network = '%s' ", AND `contact`.`uid` = %d AND `contact`.`self` = 0 AND `network` = '%s' ",
dbesc(normalise_link(App::get_baseurl())), dbesc(normalise_link(App::get_baseurl())),
intval(local_user()), intval(local_user()),
dbesc(NETWORK_DFRN) dbesc(NETWORK_DFRN)
@ -116,12 +122,15 @@ function delegate_content(App $a) {
// get user records for all potential page delegates who are not already delegates or managers // get user records for all potential page delegates who are not already delegates or managers
$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 (dbm::is_result($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;
}
}
}
require_once("mod/settings.php"); require_once("mod/settings.php");
settings_init($a); settings_init($a);

View File

@ -349,8 +349,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
dbesc(NETWORK_DFRN), dbesc(NETWORK_DFRN),
intval($contact_id) intval($contact_id)
); );
} } else {
else {
// $network !== NETWORK_DFRN // $network !== NETWORK_DFRN
@ -756,7 +755,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
intval($local_uid) intval($local_uid)
); );
if(count($self)) { if (dbm::is_result($self)) {
$arr = array(); $arr = array();
$arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), $local_uid); $arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), $local_uid);
@ -793,8 +792,9 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
$arr['deny_gid'] = $user[0]['deny_gid']; $arr['deny_gid'] = $user[0]['deny_gid'];
$i = item_store($arr); $i = item_store($arr);
if($i) if ($i) {
proc_run(PRIORITY_HIGH, "include/notifier.php", "activity", $i); proc_run(PRIORITY_HIGH, "include/notifier.php", "activity", $i);
}
} }
} }

View File

@ -301,13 +301,12 @@ function dfrn_notify_content(App $a) {
if ((($dplx) && (strlen($prv_key))) || ((strlen($prv_key)) && (!(strlen($pub_key))))) { if ((($dplx) && (strlen($prv_key))) || ((strlen($prv_key)) && (!(strlen($pub_key))))) {
openssl_private_encrypt($hash,$challenge,$prv_key); openssl_private_encrypt($hash,$challenge,$prv_key);
openssl_private_encrypt($id_str,$encrypted_id,$prv_key); openssl_private_encrypt($id_str,$encrypted_id,$prv_key);
} } elseif (strlen($pub_key)) {
elseif(strlen($pub_key)) {
openssl_public_encrypt($hash,$challenge,$pub_key); openssl_public_encrypt($hash,$challenge,$pub_key);
openssl_public_encrypt($id_str,$encrypted_id,$pub_key); openssl_public_encrypt($id_str,$encrypted_id,$pub_key);
} } else {
else
$status = 1; $status = 1;
}
$challenge = bin2hex($challenge); $challenge = bin2hex($challenge);
$encrypted_id = bin2hex($encrypted_id); $encrypted_id = bin2hex($encrypted_id);
@ -326,8 +325,7 @@ function dfrn_notify_content(App $a) {
if ((($r[0]['rel']) && ($r[0]['rel'] != CONTACT_IS_SHARING)) || ($r[0]['page-flags'] == PAGE_COMMUNITY)) { if ((($r[0]['rel']) && ($r[0]['rel'] != CONTACT_IS_SHARING)) || ($r[0]['page-flags'] == PAGE_COMMUNITY)) {
$perm = 'rw'; $perm = 'rw';
} } else {
else {
$perm = 'r'; $perm = 'r';
} }

View File

@ -185,8 +185,9 @@ function directory_content(App $a) {
unset($profile); unset($profile);
unset($location); unset($location);
if(! $arr['entry']) if (! $arr['entry']) {
continue; continue;
}
$entries[] = $arr['entry']; $entries[] = $arr['entry'];

View File

@ -166,8 +166,9 @@ function dirfind_content(App $a, $prefix = "") {
$p = (($a->pager['page'] != 1) ? '&p=' . $a->pager['page'] : ''); $p = (($a->pager['page'] != 1) ? '&p=' . $a->pager['page'] : '');
if(strlen(get_config('system','directory'))) if (strlen(get_config('system','directory'))) {
$x = fetch_url(get_server().'/lsearch?f=' . $p . '&search=' . urlencode($search)); $x = fetch_url(get_server().'/lsearch?f=' . $p . '&search=' . urlencode($search));
}
$j = json_decode($x); $j = json_decode($x);
} }

View File

@ -439,21 +439,24 @@ function events_content(App $a) {
$uri = ((x($orig_event)) ? $orig_event['uri'] : ''); $uri = ((x($orig_event)) ? $orig_event['uri'] : '');
if(! x($orig_event)) if (! x($orig_event)) {
$sh_checked = ''; $sh_checked = '';
else } else {
$sh_checked = (($orig_event['allow_cid'] === '<' . local_user() . '>' && (! $orig_event['allow_gid']) && (! $orig_event['deny_cid']) && (! $orig_event['deny_gid'])) ? '' : ' checked="checked" ' ); $sh_checked = (($orig_event['allow_cid'] === '<' . local_user() . '>' && (! $orig_event['allow_gid']) && (! $orig_event['deny_cid']) && (! $orig_event['deny_gid'])) ? '' : ' checked="checked" ' );
}
if($cid OR ($mode !== 'new')) if ($cid OR ($mode !== 'new')) {
$sh_checked .= ' disabled="disabled" '; $sh_checked .= ' disabled="disabled" ';
}
$sdt = ((x($orig_event)) ? $orig_event['start'] : 'now'); $sdt = ((x($orig_event)) ? $orig_event['start'] : 'now');
$fdt = ((x($orig_event)) ? $orig_event['finish'] : 'now'); $fdt = ((x($orig_event)) ? $orig_event['finish'] : 'now');
$tz = date_default_timezone_get(); $tz = date_default_timezone_get();
if(x($orig_event)) if (x($orig_event)) {
$tz = (($orig_event['adjust']) ? date_default_timezone_get() : 'UTC'); $tz = (($orig_event['adjust']) ? date_default_timezone_get() : 'UTC');
}
$syear = datetime_convert('UTC', $tz, $sdt, 'Y'); $syear = datetime_convert('UTC', $tz, $sdt, 'Y');
$smonth = datetime_convert('UTC', $tz, $sdt, 'm'); $smonth = datetime_convert('UTC', $tz, $sdt, 'm');
@ -470,8 +473,9 @@ function events_content(App $a) {
$fminute = ((x($orig_event)) ? datetime_convert('UTC', $tz, $fdt, 'i') : 0); $fminute = ((x($orig_event)) ? datetime_convert('UTC', $tz, $fdt, 'i') : 0);
$f = get_config('system','event_input_format'); $f = get_config('system','event_input_format');
if(! $f) if (! $f) {
$f = 'ymd'; $f = 'ymd';
}
require_once('include/acl_selectors.php'); require_once('include/acl_selectors.php');

View File

@ -68,8 +68,7 @@ function fbrowser_content(App $a) {
if ($a->theme['template_engine'] === 'internal') { if ($a->theme['template_engine'] === 'internal') {
$filename_e = template_escape($rr['filename']); $filename_e = template_escape($rr['filename']);
} } else {
else {
$filename_e = $rr['filename']; $filename_e = $rr['filename'];
} }

View File

@ -95,7 +95,9 @@ function friendica_content(App $a) {
sort($sorted); sort($sorted);
foreach ($sorted as $p) { foreach ($sorted as $p) {
if (strlen($p)) { if (strlen($p)) {
if(strlen($s)) $s .= ', '; if (strlen($s)) {
$s .= ', ';
}
$s .= $p; $s .= $p;
} }
} }

View File

@ -80,8 +80,9 @@ function fsuggest_content(App $a) {
return; return;
} }
if($a->argc != 2) if ($a->argc != 2) {
return; return;
}
$contact_id = intval($a->argv[1]); $contact_id = intval($a->argv[1]);

View File

@ -80,10 +80,12 @@ function group_content(App $a) {
// Switch to text mode interface if we have more than 'n' contacts or group members // Switch to text mode interface if we have more than 'n' contacts or group members
$switchtotext = get_pconfig(local_user(),'system','groupedit_image_limit'); $switchtotext = get_pconfig(local_user(),'system','groupedit_image_limit');
if($switchtotext === false) if ($switchtotext === false) {
$switchtotext = get_config('system','groupedit_image_limit'); $switchtotext = get_config('system','groupedit_image_limit');
if($switchtotext === false) }
if ($switchtotext === false) {
$switchtotext = 400; $switchtotext = 400;
}
$tpl = get_markup_template('group_edit.tpl'); $tpl = get_markup_template('group_edit.tpl');
@ -99,8 +101,6 @@ function group_content(App $a) {
'$gid' => 'new', '$gid' => 'new',
'$form_security_token' => get_form_security_token("group_edit"), '$form_security_token' => get_form_security_token("group_edit"),
)); ));
} }
if (($a->argc == 3) && ($a->argv[1] === 'drop')) { if (($a->argc == 3) && ($a->argv[1] === 'drop')) {
@ -135,9 +135,10 @@ function group_content(App $a) {
intval($a->argv[2]), intval($a->argv[2]),
intval(local_user()) intval(local_user())
); );
if (dbm::is_result($r)) if (dbm::is_result($r)) {
$change = intval($a->argv[2]); $change = intval($a->argv[2]);
} }
}
if (($a->argc > 1) && (intval($a->argv[1]))) { if (($a->argc > 1) && (intval($a->argv[1]))) {
@ -154,15 +155,15 @@ function group_content(App $a) {
$members = group_get_members($group['id']); $members = group_get_members($group['id']);
$preselected = array(); $preselected = array();
if (count($members)) { if (count($members)) {
foreach($members as $member) foreach ($members as $member) {
$preselected[] = $member['id']; $preselected[] = $member['id'];
} }
}
if ($change) { if ($change) {
if (in_array($change,$preselected)) { if (in_array($change,$preselected)) {
group_rmv_member(local_user(),$group['name'],$change); group_rmv_member(local_user(),$group['name'],$change);
} } else {
else {
group_add_member(local_user(),$group['name'],$change); group_add_member(local_user(),$group['name'],$change);
} }
@ -193,8 +194,9 @@ function group_content(App $a) {
} }
if(! isset($group)) if (! isset($group)) {
return; return;
}
$groupeditor = array( $groupeditor = array(
'label_members' => t('Members'), 'label_members' => t('Members'),
@ -210,10 +212,10 @@ function group_content(App $a) {
if ($member['url']) { if ($member['url']) {
$member['click'] = 'groupChangeMember(' . $group['id'] . ',' . $member['id'] . ',\'' . $sec_token . '\'); return true;'; $member['click'] = 'groupChangeMember(' . $group['id'] . ',' . $member['id'] . ',\'' . $sec_token . '\'); return true;';
$groupeditor['members'][] = micropro($member,true,'mpgroup', $textmode); $groupeditor['members'][] = micropro($member,true,'mpgroup', $textmode);
} } else {
else
group_rmv_member(local_user(),$group['name'],$member['id']); group_rmv_member(local_user(),$group['name'],$member['id']);
} }
}
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND NOT `blocked` AND NOT `pending` AND NOT `self` ORDER BY `name` ASC", $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND NOT `blocked` AND NOT `pending` AND NOT `self` ORDER BY `name` ASC",
intval(local_user()) intval(local_user())

View File

@ -31,8 +31,9 @@ function help_content(App $a) {
// looping through the argv keys bigger than 0 to build // looping through the argv keys bigger than 0 to build
// a path relative to /help // a path relative to /help
for ($x = 1; $x < argc(); $x ++) { for ($x = 1; $x < argc(); $x ++) {
if(strlen($path)) if (strlen($path)) {
$path .= '/'; $path .= '/';
}
$path .= argv($x); $path .= argv($x);
} }
$title = basename($path); $title = basename($path);
@ -71,10 +72,16 @@ function help_content(App $a) {
if ($level!="r") { if ($level!="r") {
$level = intval($level); $level = intval($level);
if ($level<$lastlevel) { if ($level<$lastlevel) {
for($k=$level;$k<$lastlevel; $k++) $toc.="</ul>"; for ($k=$level;$k<$lastlevel; $k++) {
for($k=$level+1;$k<count($idnum);$k++) $idnum[$k]=0; $toc.="</ul>";
}
for ($k=$level+1;$k<count($idnum);$k++) {
$idnum[$k]=0;
}
}
if ($level>$lastlevel) {
$toc.="<ul>";
} }
if ($level>$lastlevel) $toc.="<ul>";
$idnum[$level]++; $idnum[$level]++;
$id = implode("_", array_slice($idnum,1,$level)); $id = implode("_", array_slice($idnum,1,$level));
$href = App::get_baseurl()."/help/{$filename}#{$id}"; $href = App::get_baseurl()."/help/{$filename}#{$id}";

View File

@ -37,8 +37,11 @@ function ignored_init(App $a) {
$return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : ''); $return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
if ($return_path) { if ($return_path) {
$rand = '_=' . time(); $rand = '_=' . time();
if(strpos($return_path, '?')) $rand = "&$rand"; if (strpos($return_path, '?')) {
else $rand = "?$rand"; $rand = "&$rand";
} else {
$rand = "?$rand";
}
goaway(App::get_baseurl() . "/" . $return_path . $rand); goaway(App::get_baseurl() . "/" . $return_path . $rand);
} }

View File

@ -575,8 +575,9 @@ function item_post(App $a) {
if (count($tags)) { if (count($tags)) {
foreach ($tags as $tag) { foreach ($tags as $tag) {
if(strpos($tag,'#') === 0) if (strpos($tag,'#') === 0) {
continue; continue;
}
// If we already tagged 'Robert Johnson', don't try and tag 'Robert'. // If we already tagged 'Robert Johnson', don't try and tag 'Robert'.
// Robert Johnson should be first in the $tags array // Robert Johnson should be first in the $tags array
@ -588,8 +589,9 @@ function item_post(App $a) {
break; break;
} }
} }
if($fullnametagged) if ($fullnametagged) {
continue; continue;
}
$success = handle_tag($a, $body, $inform, $str_tags, (local_user()) ? local_user() : $profile_uid , $tag, $network); $success = handle_tag($a, $body, $inform, $str_tags, (local_user()) ? local_user() : $profile_uid , $tag, $network);
if ($success['replaced']) { if ($success['replaced']) {
@ -722,8 +724,9 @@ function item_post(App $a) {
$datarray['last-child'] = 1; $datarray['last-child'] = 1;
$datarray['visible'] = 1; $datarray['visible'] = 1;
if($orig_post) if ($orig_post) {
$datarray['edit'] = true; $datarray['edit'] = true;
}
// Search for hashtags // Search for hashtags
item_body_set_hashtags($datarray); item_body_set_hashtags($datarray);
@ -1032,8 +1035,9 @@ function item_post(App $a) {
function item_post_return($baseurl, $api_source, $return_path) { function item_post_return($baseurl, $api_source, $return_path) {
// figure out how to return, depending on from whence we came // figure out how to return, depending on from whence we came
if($api_source) if ($api_source) {
return; return;
}
if ($return_path) { if ($return_path) {
goaway($return_path); goaway($return_path);
@ -1111,19 +1115,24 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $netwo
$r = q("SELECT `alias`, `name` FROM `contact` WHERE `nurl` = '%s' AND `alias` != '' AND `uid` = 0", $r = q("SELECT `alias`, `name` FROM `contact` WHERE `nurl` = '%s' AND `alias` != '' AND `uid` = 0",
normalise_link($matches[1])); normalise_link($matches[1]));
if (!$r)
if (!dbm::is_result($r)) {
$r = q("SELECT `alias`, `name` FROM `gcontact` WHERE `nurl` = '%s' AND `alias` != ''", $r = q("SELECT `alias`, `name` FROM `gcontact` WHERE `nurl` = '%s' AND `alias` != ''",
normalise_link($matches[1])); normalise_link($matches[1]));
if ($r)
}
if (dbm::is_result($r)) {
$data = $r[0]; $data = $r[0];
else } else {
$data = probe_url($matches[1]); $data = probe_url($matches[1]);
}
if ($data["alias"] != "") { if ($data["alias"] != "") {
$newtag = '@[url='.$data["alias"].']'.$data["name"].'[/url]'; $newtag = '@[url='.$data["alias"].']'.$data["name"].'[/url]';
if (!stristr($str_tags,$newtag)) { if (!stristr($str_tags,$newtag)) {
if(strlen($str_tags)) if (strlen($str_tags)) {
$str_tags .= ','; $str_tags .= ',';
}
$str_tags .= $newtag; $str_tags .= $newtag;
} }
} }
@ -1155,7 +1164,7 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $netwo
); );
// Then check in the contact table for the url // Then check in the contact table for the url
if (!$r) if (!dbm::is_result($r)) {
$r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network`, `notify` FROM `contact` $r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network`, `notify` FROM `contact`
WHERE `nurl` = '%s' AND `uid` = %d AND WHERE `nurl` = '%s' AND `uid` = %d AND
(`network` != '%s' OR (`notify` != '' AND `alias` != '')) (`network` != '%s' OR (`notify` != '' AND `alias` != ''))
@ -1164,6 +1173,7 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $netwo
intval($profile_uid), intval($profile_uid),
dbesc(NETWORK_OSTATUS) dbesc(NETWORK_OSTATUS)
); );
}
// Then check in the global contacts for the address // Then check in the global contacts for the address
if (!$r) if (!$r)
@ -1175,15 +1185,16 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $netwo
); );
// Then check in the global contacts for the url // Then check in the global contacts for the url
if (!$r) if (!dbm::is_result($r)) {
$r = q("SELECT `url`, `nick`, `name`, `alias`, `network`, `notify` FROM `gcontact` $r = q("SELECT `url`, `nick`, `name`, `alias`, `network`, `notify` FROM `gcontact`
WHERE `nurl` = '%s' AND (`network` != '%s' OR (`notify` != '' AND `alias` != '')) WHERE `nurl` = '%s' AND (`network` != '%s' OR (`notify` != '' AND `alias` != ''))
LIMIT 1", LIMIT 1",
dbesc(normalise_link($name)), dbesc(normalise_link($name)),
dbesc(NETWORK_OSTATUS) dbesc(NETWORK_OSTATUS)
); );
}
if (!$r) { if (!dbm::is_result($r)) {
$probed = probe_url($name); $probed = probe_url($name);
if ($result['network'] != NETWORK_PHANTOM) { if ($result['network'] != NETWORK_PHANTOM) {
update_gcontact($probed); update_gcontact($probed);
@ -1204,55 +1215,61 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $netwo
} }
//select someone by attag or nick and the name passed in the current network //select someone by attag or nick and the name passed in the current network
if(!$r AND ($network != "")) if (!dbm::is_result($r) AND ($network != "")) {
$r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `attag` = '%s' OR `nick` = '%s' AND `network` = '%s' AND `uid` = %d ORDER BY `attag` DESC LIMIT 1", $r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `attag` = '%s' OR `nick` = '%s' AND `network` = '%s' AND `uid` = %d ORDER BY `attag` DESC LIMIT 1",
dbesc($name), dbesc($name),
dbesc($name), dbesc($name),
dbesc($network), dbesc($network),
intval($profile_uid) intval($profile_uid)
); );
}
//select someone from this user's contacts by name in the current network //select someone from this user's contacts by name in the current network
if (!$r AND ($network != "")) if (!dbm::is_result($r) AND ($network != "")) {
$r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `name` = '%s' AND `network` = '%s' AND `uid` = %d LIMIT 1", $r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `name` = '%s' AND `network` = '%s' AND `uid` = %d LIMIT 1",
dbesc($name), dbesc($name),
dbesc($network), dbesc($network),
intval($profile_uid) intval($profile_uid)
); );
}
//select someone by attag or nick and the name passed in //select someone by attag or nick and the name passed in
if(!$r) if (!dbm::is_result($r)) {
$r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `attag` = '%s' OR `nick` = '%s' AND `uid` = %d ORDER BY `attag` DESC LIMIT 1", $r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `attag` = '%s' OR `nick` = '%s' AND `uid` = %d ORDER BY `attag` DESC LIMIT 1",
dbesc($name), dbesc($name),
dbesc($name), dbesc($name),
intval($profile_uid) intval($profile_uid)
); );
}
//select someone from this user's contacts by name //select someone from this user's contacts by name
if(!$r) if (!dbm::is_result($r)) {
$r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1", $r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
dbesc($name), dbesc($name),
intval($profile_uid) intval($profile_uid)
); );
} }
}
if ($r) { if (dbm::is_result($r)) {
if(strlen($inform) AND (isset($r[0]["notify"]) OR isset($r[0]["id"]))) if (strlen($inform) AND (isset($r[0]["notify"]) OR isset($r[0]["id"]))) {
$inform .= ','; $inform .= ',';
}
if (isset($r[0]["id"])) if (isset($r[0]["id"])) {
$inform .= 'cid:' . $r[0]["id"]; $inform .= 'cid:' . $r[0]["id"];
elseif (isset($r[0]["notify"])) } elseif (isset($r[0]["notify"])) {
$inform .= $r[0]["notify"]; $inform .= $r[0]["notify"];
}
$profile = $r[0]["url"]; $profile = $r[0]["url"];
$alias = $r[0]["alias"]; $alias = $r[0]["alias"];
$newname = $r[0]["nick"]; $newname = $r[0]["nick"];
if (($newname == "") OR (($r[0]["network"] != NETWORK_OSTATUS) AND ($r[0]["network"] != NETWORK_TWITTER) if (($newname == "") OR (($r[0]["network"] != NETWORK_OSTATUS) AND ($r[0]["network"] != NETWORK_TWITTER)
AND ($r[0]["network"] != NETWORK_STATUSNET) AND ($r[0]["network"] != NETWORK_APPNET))) AND ($r[0]["network"] != NETWORK_STATUSNET) AND ($r[0]["network"] != NETWORK_APPNET))) {
$newname = $r[0]["name"]; $newname = $r[0]["name"];
} }
}
//if there is an url for this persons profile //if there is an url for this persons profile
if (isset($profile) AND ($newname != "")) { if (isset($profile) AND ($newname != "")) {
@ -1264,8 +1281,9 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $netwo
$body = str_replace('@'.$name, $newtag, $body); $body = str_replace('@'.$name, $newtag, $body);
//append tag to str_tags //append tag to str_tags
if (! stristr($str_tags,$newtag)) { if (! stristr($str_tags,$newtag)) {
if(strlen($str_tags)) if (strlen($str_tags)) {
$str_tags .= ','; $str_tags .= ',';
}
$str_tags .= $newtag; $str_tags .= $newtag;
} }
@ -1275,8 +1293,9 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $netwo
if (strlen($alias)) { if (strlen($alias)) {
$newtag = '@[url='.$alias.']'.$newname.'[/url]'; $newtag = '@[url='.$alias.']'.$newname.'[/url]';
if (! stristr($str_tags,$newtag)) { if (! stristr($str_tags,$newtag)) {
if(strlen($str_tags)) if (strlen($str_tags)) {
$str_tags .= ','; $str_tags .= ',';
}
$str_tags .= $newtag; $str_tags .= $newtag;
} }
} }

View File

@ -13,13 +13,16 @@ function like_content(App $a) {
$verb = notags(trim($_GET['verb'])); $verb = notags(trim($_GET['verb']));
if(! $verb) if (! $verb) {
$verb = 'like'; $verb = 'like';
}
$item_id = (($a->argc > 1) ? notags(trim($a->argv[1])) : 0); $item_id = (($a->argc > 1) ? notags(trim($a->argv[1])) : 0);
$r = do_like($item_id, $verb); $r = do_like($item_id, $verb);
if (!$r) return; if (!$r) {
return;
}
// See if we've been passed a return path to redirect to // See if we've been passed a return path to redirect to
$return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : ''); $return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
@ -37,8 +40,11 @@ function like_content_return($baseurl, $return_path) {
if ($return_path) { if ($return_path) {
$rand = '_=' . time(); $rand = '_=' . time();
if(strpos($return_path, '?')) $rand = "&$rand"; if (strpos($return_path, '?')) {
else $rand = "?$rand"; $rand = "&$rand";
} else {
$rand = "?$rand";
}
goaway($baseurl . "/" . $return_path . $rand); goaway($baseurl . "/" . $return_path . $rand);
} }

View File

@ -6,20 +6,23 @@ require_once('include/datetime.php');
function localtime_post(App $a) { function localtime_post(App $a) {
$t = $_REQUEST['time']; $t = $_REQUEST['time'];
if(! $t) if (! $t) {
$t = 'now'; $t = 'now';
}
$bd_format = t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8 AM $bd_format = t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8 AM
if($_POST['timezone']) if ($_POST['timezone']) {
$a->data['mod-localtime'] = datetime_convert('UTC',$_POST['timezone'],$t,$bd_format); $a->data['mod-localtime'] = datetime_convert('UTC',$_POST['timezone'],$t,$bd_format);
}
} }
function localtime_content(App $a) { function localtime_content(App $a) {
$t = $_REQUEST['time']; $t = $_REQUEST['time'];
if(! $t) if (! $t) {
$t = 'now'; $t = 'now';
}
$o .= '<h3>' . t('Time Conversion') . '</h3>'; $o .= '<h3>' . t('Time Conversion') . '</h3>';
@ -29,11 +32,13 @@ function localtime_content(App $a) {
$o .= '<p>' . sprintf( t('UTC time: %s'), $t) . '</p>'; $o .= '<p>' . sprintf( t('UTC time: %s'), $t) . '</p>';
if($_REQUEST['timezone']) if ($_REQUEST['timezone']) {
$o .= '<p>' . sprintf( t('Current timezone: %s'), $_REQUEST['timezone']) . '</p>'; $o .= '<p>' . sprintf( t('Current timezone: %s'), $_REQUEST['timezone']) . '</p>';
}
if(x($a->data,'mod-localtime')) if (x($a->data,'mod-localtime')) {
$o .= '<p>' . sprintf( t('Converted localtime: %s'),$a->data['mod-localtime']) . '</p>'; $o .= '<p>' . sprintf( t('Converted localtime: %s'),$a->data['mod-localtime']) . '</p>';
}
$o .= '<form action ="' . App::get_baseurl() . '/localtime?f=&time=' . $t . '" method="post" >'; $o .= '<form action ="' . App::get_baseurl() . '/localtime?f=&time=' . $t . '" method="post" >';

View File

@ -53,17 +53,21 @@ function lockview_content(App $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 (dbm::is_result($r)) if (dbm::is_result($r)) {
foreach($r as $rr) foreach ($r as $rr) {
$l[] = '<b>' . $rr['name'] . '</b>'; $l[] = '<b>' . $rr['name'] . '</b>';
} }
}
}
if (count($allowed_users)) { if (count($allowed_users)) {
$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 (dbm::is_result($r)) if (dbm::is_result($r)) {
foreach($r as $rr) foreach ($r as $rr) {
$l[] = $rr['name']; $l[] = $rr['name'];
}
}
} }
@ -71,17 +75,21 @@ function lockview_content(App $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 (dbm::is_result($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>';
} }
}
}
if (count($deny_users)) { if (count($deny_users)) {
$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 (dbm::is_result($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

@ -1,13 +1,16 @@
<?php <?php
function login_content(App $a) { function login_content(App $a) {
if(x($_SESSION,'theme')) if (x($_SESSION,'theme')) {
unset($_SESSION['theme']); unset($_SESSION['theme']);
if(x($_SESSION,'mobile-theme')) }
if (x($_SESSION,'mobile-theme')) {
unset($_SESSION['mobile-theme']); unset($_SESSION['mobile-theme']);
}
if(local_user()) if (local_user()) {
goaway(z_root()); goaway(z_root());
}
return login(($a->config['register_policy'] == REGISTER_CLOSED) ? false : true); return login(($a->config['register_policy'] == REGISTER_CLOSED) ? false : true);
} }

View File

@ -79,7 +79,6 @@ function lostpass_post(App $a) {
function lostpass_content(App $a) { function lostpass_content(App $a) {
if (x($_GET,'verify')) { if (x($_GET,'verify')) {
$verify = $_GET['verify']; $verify = $_GET['verify'];
$hash = hash('whirlpool', $verify); $hash = hash('whirlpool', $verify);

View File

@ -13,7 +13,7 @@ function manage_post(App $a) {
$orig_record = $a->user; $orig_record = $a->user;
if ((x($_SESSION,'submanage')) && intval($_SESSION['submanage'])) { if ((x($_SESSION,'submanage')) && intval($_SESSION['submanage'])) {
$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 (dbm::is_result($r)) { if (dbm::is_result($r)) {
@ -22,15 +22,16 @@ function manage_post(App $a) {
} }
} }
$r = q("select * from manage where uid = %d", $r = q("SELECT * FROM `manage` WHERE `uid` = %d",
intval($uid) intval($uid)
); );
$submanage = $r; $submanage = $r;
$identity = ((x($_POST['identity'])) ? intval($_POST['identity']) : 0); $identity = ((x($_POST['identity'])) ? intval($_POST['identity']) : 0);
if(! $identity) if (! $identity) {
return; return;
}
$limited_id = 0; $limited_id = 0;
$original_id = $uid; $original_id = $uid;
@ -48,8 +49,7 @@ function manage_post(App $a) {
$r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
intval($limited_id) intval($limited_id)
); );
} } else {
else {
$r = q("SELECT * FROM `user` WHERE `uid` = %d AND `email` = '%s' AND `password` = '%s' LIMIT 1", $r = q("SELECT * FROM `user` WHERE `uid` = %d AND `email` = '%s' AND `password` = '%s' LIMIT 1",
intval($identity), intval($identity),
dbesc($orig_record['email']), dbesc($orig_record['email']),
@ -70,18 +70,22 @@ function manage_post(App $a) {
unset($_SESSION['mobile-theme']); unset($_SESSION['mobile-theme']);
unset($_SESSION['page_flags']); unset($_SESSION['page_flags']);
unset($_SESSION['return_url']); unset($_SESSION['return_url']);
if(x($_SESSION,'submanage')) if (x($_SESSION,'submanage')) {
unset($_SESSION['submanage']); unset($_SESSION['submanage']);
if(x($_SESSION,'sysmsg')) }
if (x($_SESSION,'sysmsg')) {
unset($_SESSION['sysmsg']); unset($_SESSION['sysmsg']);
if(x($_SESSION,'sysmsg_info')) }
if (x($_SESSION,'sysmsg_info')) {
unset($_SESSION['sysmsg_info']); unset($_SESSION['sysmsg_info']);
}
require_once('include/security.php'); require_once('include/security.php');
authenticate_success($r[0],true,true); authenticate_success($r[0],true,true);
if($limited_id) if ($limited_id) {
$_SESSION['submanage'] = $original_id; $_SESSION['submanage'] = $original_id;
}
$ret = array(); $ret = array();
call_hooks('home_init',$ret); call_hooks('home_init',$ret);

View File

@ -78,9 +78,9 @@ function message_post(App $a) {
if ($norecip) { if ($norecip) {
$a->argc = 2; $a->argc = 2;
$a->argv[1] = 'new'; $a->argv[1] = 'new';
} } else {
else
goaway($_SESSION['return_url']); goaway($_SESSION['return_url']);
}
} }
@ -109,14 +109,15 @@ function item_extract_images($body) {
$new_body = $new_body . substr($orig_body, 0, $img_start) . '[!#saved_image' . $cnt . '#!]'; $new_body = $new_body . substr($orig_body, 0, $img_start) . '[!#saved_image' . $cnt . '#!]';
$cnt++; $cnt++;
} } else {
else
$new_body = $new_body . substr($orig_body, 0, $img_end + strlen('[/img]')); $new_body = $new_body . substr($orig_body, 0, $img_end + strlen('[/img]'));
}
$orig_body = substr($orig_body, $img_end + strlen('[/img]')); $orig_body = substr($orig_body, $img_end + strlen('[/img]'));
if($orig_body === false) // in case the body ends on a closing image tag if ($orig_body === false) {// in case the body ends on a closing image tag
$orig_body = ''; $orig_body = '';
}
$img_start = strpos($orig_body, '[img'); $img_start = strpos($orig_body, '[img');
$img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false); $img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
@ -431,8 +432,9 @@ function message_content(App $a) {
$unknown = false; $unknown = false;
foreach ($messages as $message) { foreach ($messages as $message) {
if($message['unknown']) if ($message['unknown']) {
$unknown = true; $unknown = true;
}
if ($message['from-url'] == $myprofile) { if ($message['from-url'] == $myprofile) {
$from_url = $myprofile; $from_url = $myprofile;
$sparkle = ''; $sparkle = '';
@ -446,8 +448,9 @@ function message_content(App $a) {
$extracted = item_extract_images($message['body']); $extracted = item_extract_images($message['body']);
if($extracted['images']) if ($extracted['images']) {
$message['body'] = item_redir_and_replace_images($extracted['body'], $extracted['images'], $message['contact-id']); $message['body'] = item_redir_and_replace_images($extracted['body'], $extracted['images'], $message['contact-id']);
}
if ($a->theme['template_engine'] === 'internal') { if ($a->theme['template_engine'] === 'internal') {
$from_name_e = template_escape($message['from-name']); $from_name_e = template_escape($message['from-name']);
@ -462,10 +465,11 @@ function message_content(App $a) {
} }
$contact = get_contact_details_by_url($message['from-url']); $contact = get_contact_details_by_url($message['from-url']);
if (isset($contact["thumb"])) if (isset($contact["thumb"])) {
$from_photo = $contact["thumb"]; $from_photo = $contact["thumb"];
else } else {
$from_photo = $message['from-photo']; $from_photo = $message['from-photo'];
}
$mails[] = array( $mails[] = array(
'id' => $message['id'], 'id' => $message['id'],
@ -492,8 +496,7 @@ function message_content(App $a) {
if ($a->theme['template_engine'] === 'internal') { if ($a->theme['template_engine'] === 'internal') {
$subjtxt_e = template_escape($message['title']); $subjtxt_e = template_escape($message['title']);
} } else {
else {
$subjtxt_e = $message['title']; $subjtxt_e = $message['title'];
} }

View File

@ -123,9 +123,11 @@ function mood_content(App $a) {
$verbs = get_mood_verbs(); $verbs = get_mood_verbs();
$shortlist = array(); $shortlist = array();
foreach($verbs as $k => $v) foreach ($verbs as $k => $v) {
if($v !== 'NOTRANSLATION') if ($v !== 'NOTRANSLATION') {
$shortlist[] = array($k,$v); $shortlist[] = array($k,$v);
}
}
$tpl = get_markup_template('mood_content.tpl'); $tpl = get_markup_template('mood_content.tpl');

View File

@ -329,17 +329,15 @@ function network_content(App $a, $update = 0) {
if ($a->argc > 1) { if ($a->argc > 1) {
for ($x = 1; $x < $a->argc; $x ++) { for ($x = 1; $x < $a->argc; $x ++) {
if (is_a_date_arg($a->argv[$x])) { if (is_a_date_arg($a->argv[$x])) {
if($datequery) if ($datequery) {
$datequery2 = escape_tags($a->argv[$x]); $datequery2 = escape_tags($a->argv[$x]);
else { } else {
$datequery = escape_tags($a->argv[$x]); $datequery = escape_tags($a->argv[$x]);
$_GET['order'] = 'post'; $_GET['order'] = 'post';
} }
} } elseif ($a->argv[$x] === 'new') {
elseif($a->argv[$x] === 'new') {
$nouveau = true; $nouveau = true;
} } elseif (intval($a->argv[$x])) {
elseif(intval($a->argv[$x])) {
$group = intval($a->argv[$x]); $group = intval($a->argv[$x]);
$def_acl = array('allow_gid' => '<' . $group . '>'); $def_acl = array('allow_gid' => '<' . $group . '>');
} }

View File

@ -47,8 +47,9 @@ function newmember_content(App $a) {
$mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1); $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
if(! $mail_disabled) if (! $mail_disabled) {
$o .= '<li>' . '<a target="newmember" href="settings/connectors">' . t('Importing Emails') . '</a><br />' . t('Enter your email access information on your Connector Settings page if you wish to import and interact with friends or mailing lists from your email INBOX') . '</li>' . EOL; $o .= '<li>' . '<a target="newmember" href="settings/connectors">' . t('Importing Emails') . '</a><br />' . t('Enter your email access information on your Connector Settings page if you wish to import and interact with friends or mailing lists from your email INBOX') . '</li>' . EOL;
}
$o .= '<li>' . '<a target="newmember" href="contacts">' . t('Go to Your Contacts Page') . '</a><br />' . t('Your Contacts page is your gateway to managing friendships and connecting with friends on other networks. Typically you enter their address or site URL in the <em>Add New Contact</em> dialog.') . '</li>' . EOL; $o .= '<li>' . '<a target="newmember" href="contacts">' . t('Go to Your Contacts Page') . '</a><br />' . t('Your Contacts page is your gateway to managing friendships and connecting with friends on other networks. Typically you enter their address or site URL in the <em>Add New Contact</em> dialog.') . '</li>' . EOL;

View File

@ -2,10 +2,11 @@
function noscrape_init(App $a) { function noscrape_init(App $a) {
if($a->argc > 1) if ($a->argc > 1) {
$which = $a->argv[1]; $which = $a->argv[1];
else } else {
killme(); killme();
}
$profile = 0; $profile = 0;
if ((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) { if ((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) {

View File

@ -104,8 +104,9 @@ function notes_content(App $a, $update = false) {
$parents_str = ''; $parents_str = '';
if (dbm::is_result($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);
$r = q("SELECT %s FROM `item` %s $r = q("SELECT %s FROM `item` %s

View File

@ -309,9 +309,10 @@ function notifications_content(App $a) {
} }
// Output if there aren't any notifications available // Output if there aren't any notifications available
if($notifs['total'] == 0) if ($notifs['total'] == 0) {
$notif_nocontent = sprintf( t('No more %s notifications.'), $notifs['ident']); $notif_nocontent = sprintf( t('No more %s notifications.'), $notifs['ident']);
} }
}
$o .= replace_macros($notif_tpl, array( $o .= replace_macros($notif_tpl, array(
'$notif_header' => $notif_header, '$notif_header' => $notif_header,

View File

@ -84,8 +84,7 @@ function photo_init(App $a) {
$data = file_get_contents($default); $data = file_get_contents($default);
$mimetype = 'image/jpeg'; $mimetype = 'image/jpeg';
} }
} } else {
else {
/** /**
* Other photos * Other photos

View File

@ -1356,7 +1356,7 @@ function photos_content(App $a) {
intval($owner_uid) intval($owner_uid)
); );
if (count($prvnxt)) { if (dbm::is_result($prvnxt)) {
for($z = 0; $z < count($prvnxt); $z++) { for($z = 0; $z < count($prvnxt); $z++) {
if ($prvnxt[$z]['resource-id'] == $ph[0]['resource-id']) { if ($prvnxt[$z]['resource-id'] == $ph[0]['resource-id']) {
$prv = $z - 1; $prv = $z - 1;
@ -1374,8 +1374,9 @@ function photos_content(App $a) {
} }
} }
if (count($ph) == 1) if (count($ph) == 1) {
$hires = $lores = $ph[0]; $hires = $lores = $ph[0];
}
if (count($ph) > 1) { if (count($ph) > 1) {
if ($ph[1]['scale'] == 2) { if ($ph[1]['scale'] == 2) {
// original is 640 or less, we can display it directly // original is 640 or less, we can display it directly

View File

@ -157,12 +157,12 @@ function poco_init(App $a) {
if (x($_GET,'updatedSince') AND !$global) { if (x($_GET,'updatedSince') AND !$global) {
$ret['updatedSince'] = false; $ret['updatedSince'] = false;
} }
$ret['startIndex'] = (int) $startIndex; $ret['startIndex'] = (int) $startIndex;
$ret['itemsPerPage'] = (int) $itemsPerPage; $ret['itemsPerPage'] = (int) $itemsPerPage;
$ret['totalResults'] = (int) $totalResults; $ret['totalResults'] = (int) $totalResults;
$ret['entry'] = array(); $ret['entry'] = array();
$fields_ret = array( $fields_ret = array(
'id' => false, 'id' => false,
'displayName' => false, 'displayName' => false,
@ -207,14 +207,17 @@ function poco_init(App $a) {
if (($rr['about'] == "") AND isset($rr['pabout'])) { if (($rr['about'] == "") AND isset($rr['pabout'])) {
$rr['about'] = $rr['pabout']; $rr['about'] = $rr['pabout'];
} }
if ($rr['location'] == "") { if ($rr['location'] == "") {
if (isset($rr['plocation'])) { if (isset($rr['plocation'])) {
$rr['location'] = $rr['plocation']; $rr['location'] = $rr['plocation'];
} }
if (isset($rr['pregion']) AND ($rr['pregion'] != "")) { if (isset($rr['pregion']) AND ($rr['pregion'] != "")) {
if ($rr['location'] != "") { if ($rr['location'] != "") {
$rr['location'] .= ", "; $rr['location'] .= ", ";
} }
$rr['location'] .= $rr['pregion']; $rr['location'] .= $rr['pregion'];
} }
@ -292,6 +295,7 @@ function poco_init(App $a) {
} else { } else {
$entry['updated'] = $rr['updated']; $entry['updated'] = $rr['updated'];
} }
$entry['updated'] = date("c", strtotime($entry['updated'])); $entry['updated'] = date("c", strtotime($entry['updated']));
} }
if ($fields_ret['photos']) { if ($fields_ret['photos']) {
@ -345,6 +349,7 @@ function poco_init(App $a) {
if ($fields_ret['contactType']) { if ($fields_ret['contactType']) {
$entry['contactType'] = intval($rr['contact-type']); $entry['contactType'] = intval($rr['contact-type']);
} }
$ret['entry'][] = $entry; $ret['entry'][] = $entry;
} }
} else { } else {
@ -353,6 +358,7 @@ function poco_init(App $a) {
} else { } else {
http_status_exit(500); http_status_exit(500);
} }
logger("End of poco", LOGGER_DEBUG); logger("End of poco", LOGGER_DEBUG);
if ($format === 'xml') { if ($format === 'xml') {
@ -367,4 +373,5 @@ function poco_init(App $a) {
} else { } else {
http_status_exit(500); http_status_exit(500);
} }
} }

View File

@ -185,9 +185,11 @@ function poke_content(App $a) {
$verbs = get_poke_verbs(); $verbs = get_poke_verbs();
$shortlist = array(); $shortlist = array();
foreach($verbs as $k => $v) foreach ($verbs as $k => $v) {
if($v[1] !== 'NOTRANSLATION') if ($v[1] !== 'NOTRANSLATION') {
$shortlist[] = array($k,$v[1]); $shortlist[] = array($k,$v[1]);
}
}
$tpl = get_markup_template('poke_content.tpl'); $tpl = get_markup_template('poke_content.tpl');

View File

@ -16,8 +16,7 @@ function post_post(App $a) {
if ($a->argc == 1) { if ($a->argc == 1) {
$bulk_delivery = true; $bulk_delivery = true;
} } else {
else {
$nickname = $a->argv[2]; $nickname = $a->argv[2];
$r = q("SELECT * FROM `user` WHERE `nickname` = '%s' $r = q("SELECT * FROM `user` WHERE `nickname` = '%s'
AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1", AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1",
@ -34,15 +33,17 @@ function post_post(App $a) {
logger('mod-post: new zot: ' . $xml, LOGGER_DATA); logger('mod-post: new zot: ' . $xml, LOGGER_DATA);
if(! $xml) if (! $xml) {
http_status_exit(500); http_status_exit(500);
}
$msg = zot_decode($importer,$xml); $msg = zot_decode($importer,$xml);
logger('mod-post: decoded msg: ' . print_r($msg,true), LOGGER_DATA); logger('mod-post: decoded msg: ' . print_r($msg,true), LOGGER_DATA);
if(! is_array($msg)) if (! is_array($msg)) {
http_status_exit(500); http_status_exit(500);
}
$ret = 0; $ret = 0;
$ret = zot_incoming($bulk_delivery, $importer,$msg); $ret = zot_incoming($bulk_delivery, $importer,$msg);

View File

@ -10,8 +10,7 @@ function pretheme_init(App $a) {
$desc = $info['description']; $desc = $info['description'];
$version = $info['version']; $version = $info['version'];
$credits = $info['credits']; $credits = $info['credits'];
} } else {
else {
$desc = ''; $desc = '';
$version = ''; $version = '';
$credits = ''; $credits = '';

View File

@ -6,17 +6,17 @@ require_once('include/redir.php');
function profile_init(App $a) { function profile_init(App $a) {
if(! x($a->page,'aside')) if (! x($a->page,'aside')) {
$a->page['aside'] = ''; $a->page['aside'] = '';
}
if($a->argc > 1) if ($a->argc > 1) {
$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 (dbm::is_result($r)) { if (dbm::is_result($r)) {
goaway(App::get_baseurl() . '/profile/' . $r[0]['nickname']); goaway(App::get_baseurl() . '/profile/' . $r[0]['nickname']);
} } else {
else {
logger('profile error: mod_profile ' . $a->query_string, LOGGER_DEBUG); logger('profile error: mod_profile ' . $a->query_string, LOGGER_DEBUG);
notice( t('Requested profile is not available.') . EOL ); notice( t('Requested profile is not available.') . EOL );
$a->error = 404; $a->error = 404;
@ -28,8 +28,7 @@ function profile_init(App $a) {
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 = htmlspecialchars($a->argv[1]); $profile = htmlspecialchars($a->argv[1]);
} } else {
else {
auto_redir($a, $which); auto_redir($a, $which);
} }
@ -289,8 +288,9 @@ function profile_content(App $a, $update = 0) {
$parents_str = ''; $parents_str = '';
if (dbm::is_result($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);
$items = q(item_query()." AND `item`.`uid` = %d $items = q(item_query()." AND `item`.`uid` = %d

View File

@ -623,7 +623,6 @@ function profiles_content(App $a) {
require_once('include/profile_selectors.php'); require_once('include/profile_selectors.php');
$a->page['htmlhead'] .= replace_macros(get_markup_template('profed_head.tpl'), array( $a->page['htmlhead'] .= replace_macros(get_markup_template('profed_head.tpl'), array(
'$baseurl' => App::get_baseurl(true), '$baseurl' => App::get_baseurl(true),
)); ));

View File

@ -142,8 +142,9 @@ function pubsub_post(App $a) {
// we have no way to match Diaspora guid's with atom post id's and could get duplicates. // we have no way to match Diaspora guid's with atom post id's and could get duplicates.
// we'll assume that direct delivery is robust (and this is a bad assumption, but the duplicates are messy). // we'll assume that direct delivery is robust (and this is a bad assumption, but the duplicates are messy).
if($r[0]['network'] === NETWORK_DIASPORA) if ($r[0]['network'] === NETWORK_DIASPORA) {
hub_post_return(); hub_post_return();
}
$feedhub = ''; $feedhub = '';

View File

@ -10,12 +10,14 @@ function qsearch_init(App $a) {
$search = ((x($_GET,'s')) ? notags(trim(urldecode($_GET['s']))) : ''); $search = ((x($_GET,'s')) ? notags(trim(urldecode($_GET['s']))) : '');
if(! strlen($search)) if (! strlen($search)) {
killme(); killme();
}
if($search) if ($search) {
$search = dbesc($search); $search = dbesc($search);
}
$results = array(); $results = array();
@ -25,10 +27,10 @@ function qsearch_init(App $a) {
); );
if (dbm::is_result($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'], '', '');
} }
}
$sql_extra = ((strlen($search)) ? " AND (`name` REGEXP '$search' OR `nick` REGEXP '$search') " : ""); $sql_extra = ((strlen($search)) ? " AND (`name` REGEXP '$search' OR `nick` REGEXP '$search') " : "");
@ -40,10 +42,10 @@ function qsearch_init(App $a) {
if (dbm::is_result($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']);
} }
}
echo json_encode((object) $results); echo json_encode((object) $results);
killme(); killme();

View File

@ -72,8 +72,9 @@ function user_deny($hash) {
dbesc($hash) dbesc($hash)
); );
if(! dbm::is_result($register)) if (! dbm::is_result($register)) {
return false; return false;
}
$user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
intval($register[0]['uid']) intval($register[0]['uid'])

View File

@ -14,8 +14,7 @@ function smilies_content(App $a) {
$results[] = array('text' => $tmp['texts'][$i], 'icon' => $tmp['icons'][$i]); $results[] = array('text' => $tmp['texts'][$i], 'icon' => $tmp['icons'][$i]);
} }
json_return_and_die($results); json_return_and_die($results);
} } else {
else {
return Smilies::replace('',true); return Smilies::replace('',true);
} }
} }

View File

@ -25,8 +25,9 @@ function videos_init(App $a) {
dbesc($nick) dbesc($nick)
); );
if(! count($user)) if (!dbm::is_result($user)) {
return; return;
}
$a->data['user'] = $user[0]; $a->data['user'] = $user[0];
$a->profile_uid = $user[0]['uid']; $a->profile_uid = $user[0]['uid'];

View File

@ -9,9 +9,10 @@ function view_init($a){
if ($a->argc == 4){ if ($a->argc == 4){
$theme = $a->argv[2]; $theme = $a->argv[2];
$THEMEPATH = "view/theme/$theme"; $THEMEPATH = "view/theme/$theme";
if(file_exists("view/theme/$theme/style.php")) if (file_exists("view/theme/$theme/style.php")) {
require_once("view/theme/$theme/style.php"); require_once("view/theme/$theme/style.php");
} }
}
killme(); killme();
} }

View File

@ -90,10 +90,11 @@ function viewcontacts_content(App $a) {
$is_owner = ((local_user() && ($a->profile['profile_uid'] == local_user())) ? true : false); $is_owner = ((local_user() && ($a->profile['profile_uid'] == local_user())) ? true : false);
if($is_owner && ($rr['network'] === NETWORK_DFRN) && ($rr['rel'])) if ($is_owner && ($rr['network'] === NETWORK_DFRN) && ($rr['rel'])) {
$url = 'redir/' . $rr['id']; $url = 'redir/' . $rr['id'];
else } else {
$url = zrl($url); $url = zrl($url);
}
$contact_details = get_contact_details_by_url($rr['url'], $a->profile['uid'], $rr); $contact_details = get_contact_details_by_url($rr['url'], $a->profile['uid'], $rr);

View File

@ -98,11 +98,14 @@ function wallmessage_content(App $a) {
return; return;
} }
$r = q("select count(*) as total from mail where uid = %d and created > UTC_TIMESTAMP() - INTERVAL 1 day and unknown = 1", $r = q("SELECT COUNT(*) AS `total` FROM `mail` WHERE `uid` = %d AND `created` > UTC_TIMESTAMP() - INTERVAL 1 DAY AND `unknown` = 1",
intval($user['uid']) intval($user['uid'])
); );
if($r[0]['total'] > $user['cntunkmail']) { if (!dbm::is_result($r)) {
///@TODO Output message to use of failed query
return;
} elseif ($r[0]['total'] > $user['cntunkmail']) {
notice( sprintf( t('Number of daily wall messages for %s exceeded. Message failed.', $user['username']))); notice( sprintf( t('Number of daily wall messages for %s exceeded. Message failed.', $user['username'])));
return; return;
} }

View File

@ -12,8 +12,9 @@ function xrd_init(App $a) {
} else { } else {
$acct = true; $acct = true;
$local = str_replace('acct:', '', $uri); $local = str_replace('acct:', '', $uri);
if(substr($local,0,2) == '//') if (substr($local,0,2) == '//') {
$local = substr($local,2); $local = substr($local,2);
}
$name = substr($local,0,strpos($local,'@')); $name = substr($local,0,strpos($local,'@'));
} }