Browse Source

Merge pull request #3254 from Quix0r/rewrites/coding-convention-split2

Rewrites/coding convention split2
pull/3286/head
Hypolite Petovan 4 years ago
committed by GitHub
parent
commit
48dde02e75
18 changed files with 1866 additions and 1537 deletions
  1. +359
    -300
      boot.php
  2. +534
    -314
      include/dfrn.php
  3. +11
    -10
      include/items.php
  4. +7
    -5
      include/update_gcontact.php
  5. +71
    -100
      index.php
  6. +8
    -8
      mod/admin.php
  7. +7
    -6
      mod/dfrn_confirm.php
  8. +64
    -64
      mod/dfrn_notify.php
  9. +0
    -3
      mod/install.php
  10. +254
    -237
      mod/item.php
  11. +28
    -18
      mod/manage.php
  12. +16
    -12
      mod/network.php
  13. +257
    -238
      mod/photos.php
  14. +111
    -113
      mod/profiles.php
  15. +3
    -2
      testargs.php
  16. +16
    -15
      update.php
  17. +80
    -57
      util/po2php.php
  18. +40
    -35
      view/theme/vier/theme.php

+ 359
- 300
boot.php
File diff suppressed because it is too large
View File


+ 534
- 314
include/dfrn.php
File diff suppressed because it is too large
View File


+ 11
- 10
include/items.php View File

@ -1496,17 +1496,19 @@ function item_is_remote_self($contact, &$datarray) {
return true;
}
function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
function new_follower($importer, $contact, $datarray, $item, $sharing = false) {
$url = notags(trim($datarray['author-link']));
$name = notags(trim($datarray['author-name']));
$photo = notags(trim($datarray['author-avatar']));
if (is_object($item)) {
$rawtag = $item->get_item_tags(NAMESPACE_ACTIVITY,'actor');
if ($rawtag && $rawtag[0]['child'][NAMESPACE_POCO]['preferredUsername'][0]['data'])
if ($rawtag && $rawtag[0]['child'][NAMESPACE_POCO]['preferredUsername'][0]['data']) {
$nick = $rawtag[0]['child'][NAMESPACE_POCO]['preferredUsername'][0]['data'];
} else
}
} else {
$nick = $item;
}
if (is_array($contact)) {
if (($contact['network'] == NETWORK_OSTATUS && $contact['rel'] == CONTACT_IS_SHARING)
@ -1544,11 +1546,9 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
update_contact_avatar($photo, $importer["uid"], $contact_record["id"], true);
}
$r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
intval($importer['uid'])
);
$a = get_app();
if (dbm::is_result($r) AND !in_array($r[0]['page-flags'], array(PAGE_SOAPBOX, PAGE_FREELOVE))) {
@ -1567,8 +1567,9 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
$def_gid = get_default_group($importer['uid'], $contact_record["network"]);
if (intval($def_gid))
group_add_member($importer['uid'],'',$contact_record['id'],$def_gid);
if (intval($def_gid)) {
group_add_member($importer['uid'], '', $contact_record['id'], $def_gid);
}
if (($r[0]['notify-flags'] & NOTIFY_INTRO) &&
in_array($r[0]['page-flags'], array(PAGE_NORMAL))) {
@ -1599,7 +1600,7 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
}
}
function lose_follower($importer,$contact,$datarray = array(),$item = "") {
function lose_follower($importer, $contact, array $datarray = array(), $item = "") {
if (($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_SHARING)) {
q("UPDATE `contact` SET `rel` = %d WHERE `id` = %d",
@ -1611,7 +1612,7 @@ function lose_follower($importer,$contact,$datarray = array(),$item = "") {
}
}
function lose_sharer($importer,$contact,$datarray = array(),$item = "") {
function lose_sharer($importer, $contact, array $datarray = array(), $item = "") {
if (($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_FOLLOWER)) {
q("UPDATE `contact` SET `rel` = %d WHERE `id` = %d",
@ -1623,7 +1624,7 @@ function lose_sharer($importer,$contact,$datarray = array(),$item = "") {
}
}
function subscribe_to_hub($url,$importer,$contact,$hubmode = 'subscribe') {
function subscribe_to_hub($url, $importer, $contact, $hubmode = 'subscribe') {
$a = get_app();


+ 7
- 5
include/update_gcontact.php View File

@ -2,11 +2,11 @@
use \Friendica\Core\Config;
function update_gcontact_run(&$argv, &$argc){
function update_gcontact_run(&$argv, &$argc) {
global $a;
require_once('include/Scrape.php');
require_once('include/socgraph.php');
require_once 'include/Scrape.php';
require_once 'include/socgraph.php';
logger('update_gcontact: start');
@ -21,11 +21,13 @@ function update_gcontact_run(&$argv, &$argc){
$r = q("SELECT * FROM `gcontact` WHERE `id` = %d", intval($contact_id));
if (!$r)
if (!dbm::_is_result($r)) {
return;
}
if (!in_array($r[0]["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS)))
if (!in_array($r[0]["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) {
return;
}
$data = probe_url($r[0]["url"]);


+ 71
- 100
index.php View File

@ -28,17 +28,17 @@ $a->backend = false;
/**
*
* Load the configuration file which contains our DB credentials.
* Ignore errors. If the file doesn't exist or is empty, we are running in installation mode.
* Ignore errors. If the file doesn't exist or is empty, we are running in
* installation mode.
*
*/
$install = ((file_exists('.htconfig.php') && filesize('.htconfig.php')) ? false : true);
@include(".htconfig.php");
// Only load config if found, don't surpress errors
if (!$install) {
include ".htconfig.php";
}
/**
*
@ -46,11 +46,11 @@ $install = ((file_exists('.htconfig.php') && filesize('.htconfig.php')) ? false
*
*/
require_once("include/dba.php");
require_once "include/dba.php";
if(!$install) {
if (!$install) {
$db = new dba($db_host, $db_user, $db_pass, $db_data, $install);
unset($db_host, $db_user, $db_pass, $db_data);
unset($db_host, $db_user, $db_pass, $db_data);
/**
* Load configs from db. Overwrite configs from .htconfig.php
@ -59,17 +59,17 @@ if(!$install) {
Config::load();
if ($a->max_processes_reached() OR $a->maxload_reached()) {
header($_SERVER["SERVER_PROTOCOL"].' 503 Service Temporarily Unavailable');
header($_SERVER["SERVER_PROTOCOL"] . ' 503 Service Temporarily Unavailable');
header('Retry-After: 120');
header('Refresh: 120; url='.App::get_baseurl()."/".$a->query_string);
header('Refresh: 120; url=' . App::get_baseurl() . "/" . $a->query_string);
die("System is currently unavailable. Please try again later");
}
if (get_config('system','force_ssl') AND ($a->get_scheme() == "http") AND
(intval(get_config('system','ssl_policy')) == SSL_POLICY_FULL) AND
if (get_config('system', 'force_ssl') AND ($a->get_scheme() == "http") AND
(intval(get_config('system', 'ssl_policy')) == SSL_POLICY_FULL) AND
(substr(App::get_baseurl(), 0, 8) == "https://")) {
header("HTTP/1.1 302 Moved Temporarily");
header("Location: ".App::get_baseurl()."/".$a->query_string);
header("Location: " . App::get_baseurl() . "/" . $a->query_string);
exit();
}
@ -117,12 +117,12 @@ if (x($_SESSION,'authenticated') && !x($_SESSION,'language')) {
if (dbm::is_result($r)) $_SESSION['language'] = $r[0]['language'];
}
if((x($_SESSION,'language')) && ($_SESSION['language'] !== $lang)) {
if ((x($_SESSION,'language')) && ($_SESSION['language'] !== $lang)) {
$lang = $_SESSION['language'];
load_translation_table($lang);
}
if((x($_GET,'zrl')) && (!$install && !$maintenance)) {
if ((x($_GET,'zrl')) && (!$install && !$maintenance)) {
// Only continue when the given profile link seems valid
// Valid profile links contain a path with "/profile/" and no query parameters
if ((parse_url($_GET['zrl'], PHP_URL_QUERY) == "") AND
@ -223,7 +223,7 @@ if ((local_user()) || (! $privateapps === "1")) {
* further processing.
*/
if(strlen($a->module)) {
if (strlen($a->module)) {
/**
*
@ -233,12 +233,14 @@ if(strlen($a->module)) {
*/
// Compatibility with the Android Diaspora client
if ($a->module == "stream")
if ($a->module == "stream") {
$a->module = "network";
}
// Compatibility with the Firefox App
if (($a->module == "users") AND ($a->cmd == "users/sign_in"))
if (($a->module == "users") AND ($a->cmd == "users/sign_in")) {
$a->module = "login";
}
$privateapps = get_config('config','private_addons');
@ -246,11 +248,11 @@ if(strlen($a->module)) {
//Check if module is an app and if public access to apps is allowed or not
if ((!local_user()) && plugin_is_app($a->module) && $privateapps === "1") {
info( t("You must be logged in to use addons. "));
}
else {
} else {
include_once("addon/{$a->module}/{$a->module}.php");
if(function_exists($a->module . '_module'))
if (function_exists($a->module . '_module')) {
$a->module_loaded = true;
}
}
}
@ -320,29 +322,22 @@ if (!$install && !$maintenance) {
* Call module functions
*/
if($a->module_loaded) {
if ($a->module_loaded) {
$a->page['page_title'] = $a->module;
$placeholder = '';
if(function_exists($a->module . '_init')) {
if (function_exists($a->module . '_init')) {
call_hooks($a->module . '_mod_init', $placeholder);
$func = $a->module . '_init';
$func($a);
}
if(function_exists(str_replace('-','_',current_theme()) . '_init')) {
if (function_exists(str_replace('-','_',current_theme()) . '_init')) {
$func = str_replace('-','_',current_theme()) . '_init';
$func($a);
}
// elseif (x($a->theme_info,"extends") && file_exists("view/theme/".$a->theme_info["extends"]."/theme.php")) {
// require_once("view/theme/".$a->theme_info["extends"]."/theme.php");
// if(function_exists(str_replace('-','_',$a->theme_info["extends"]) . '_init')) {
// $func = str_replace('-','_',$a->theme_info["extends"]) . '_init';
// $func($a);
// }
// }
if(($_SERVER['REQUEST_METHOD'] === 'POST') && (! $a->error)
if (($_SERVER['REQUEST_METHOD'] === 'POST') && (! $a->error)
&& (function_exists($a->module . '_post'))
&& (! x($_POST,'auth-params'))) {
call_hooks($a->module . '_mod_post', $_POST);
@ -350,13 +345,13 @@ if($a->module_loaded) {
$func($a);
}
if((! $a->error) && (function_exists($a->module . '_afterpost'))) {
if ((! $a->error) && (function_exists($a->module . '_afterpost'))) {
call_hooks($a->module . '_mod_afterpost',$placeholder);
$func = $a->module . '_afterpost';
$func($a);
}
if((! $a->error) && (function_exists($a->module . '_content'))) {
if ((! $a->error) && (function_exists($a->module . '_content'))) {
$arr = array('content' => $a->page['content']);
call_hooks($a->module . '_mod_content', $arr);
$a->page['content'] = $arr['content'];
@ -366,7 +361,7 @@ if($a->module_loaded) {
$a->page['content'] .= $arr['content'];
}
if(function_exists(str_replace('-','_',current_theme()) . '_content_loaded')) {
if (function_exists(str_replace('-','_',current_theme()) . '_content_loaded')) {
$func = str_replace('-','_',current_theme()) . '_content_loaded';
$func($a);
}
@ -374,98 +369,76 @@ if($a->module_loaded) {
/*
* Create the page head after setting the language
* and getting any auth credentials
* and getting any auth credentials.
*
* Moved init_pagehead() and init_page_end() to after
* all the module functions have executed so that all
* theme choices made by the modules can take effect
* theme choices made by the modules can take effect.
*/
$a->init_pagehead();
/**
/*
* Build the page ending -- this is stuff that goes right before
* the closing </body> tag
*/
$a->init_page_end();
// If you're just visiting, let javascript take you home
if(x($_SESSION,'visitor_home'))
if (x($_SESSION, 'visitor_home')) {
$homebase = $_SESSION['visitor_home'];
elseif(local_user())
} elseif (local_user()) {
$homebase = 'profile/' . $a->user['nickname'];
}
if(isset($homebase))
if (isset($homebase)) {
$a->page['content'] .= '<script>var homebase="' . $homebase . '" ; </script>';
}
// now that we've been through the module content, see if the page reported
// a permission problem and if so, a 403 response would seem to be in order.
if(stristr( implode("",$_SESSION['sysmsg']), t('Permission denied'))) {
/*
* now that we've been through the module content, see if the page reported
* a permission problem and if so, a 403 response would seem to be in order.
*/
if (stristr(implode("", $_SESSION['sysmsg']), t('Permission denied'))) {
header($_SERVER["SERVER_PROTOCOL"] . ' 403 ' . t('Permission denied.'));
}
/**
*
/*
* Report anything which needs to be communicated in the notification area (before the main body)
*
*/
/*if(x($_SESSION,'sysmsg')) {
$a->page['content'] = "<div id=\"sysmsg\" class=\"error-message\">{$_SESSION['sysmsg']}</div>\r\n"
. ((x($a->page,'content')) ? $a->page['content'] : '');
$_SESSION['sysmsg']="";
unset($_SESSION['sysmsg']);
}
if(x($_SESSION,'sysmsg_info')) {
$a->page['content'] = "<div id=\"sysmsg_info\" class=\"info-message\">{$_SESSION['sysmsg_info']}</div>\r\n"
. ((x($a->page,'content')) ? $a->page['content'] : '');
$_SESSION['sysmsg_info']="";
unset($_SESSION['sysmsg_info']);
}*/
call_hooks('page_end', $a->page['content']);
/**
*
/*
* Add the navigation (menu) template
*
*/
if($a->module != 'install' && $a->module != 'maintenance') {
if ($a->module != 'install' && $a->module != 'maintenance') {
nav($a);
}
/**
/*
* Add a "toggle mobile" link if we're using a mobile device
*/
if($a->is_mobile || $a->is_tablet) {
if(isset($_SESSION['show-mobile']) && !$_SESSION['show-mobile']) {
if ($a->is_mobile || $a->is_tablet) {
if (isset($_SESSION['show-mobile']) && !$_SESSION['show-mobile']) {
$link = 'toggle_mobile?address=' . curPageURL();
}
else {
} else {
$link = 'toggle_mobile?off=1&address=' . curPageURL();
}
$a->page['footer'] = replace_macros(get_markup_template("toggle_mobile_footer.tpl"), array(
'$toggle_link' => $link,
'$toggle_text' => t('toggle mobile')
));
'$toggle_link' => $link,
'$toggle_text' => t('toggle mobile')
));
}
/**
* Build the page - now that we have all the components
*/
if(!$a->theme['stylesheet'])
if (!$a->theme['stylesheet']) {
$stylesheet = current_theme_url();
else
} else {
$stylesheet = $a->theme['stylesheet'];
}
$a->page['htmlhead'] = str_replace('{{$stylesheet}}',$stylesheet,$a->page['htmlhead']);
//$a->page['htmlhead'] = replace_macros($a->page['htmlhead'], array('$stylesheet' => $stylesheet));
@ -478,6 +451,7 @@ if (isset($_GET["mode"]) AND (($_GET["mode"] == "raw") OR ($_GET["mode"] == "min
$content = mb_convert_encoding($a->page["content"], 'HTML-ENTITIES', "UTF-8");
/// @TODO one day, kill those error-surpressing @ stuff, or PHP should ban it
@$doc->loadHTML($content);
$xpath = new DomXPath($doc);
@ -485,7 +459,6 @@ if (isset($_GET["mode"]) AND (($_GET["mode"] == "raw") OR ($_GET["mode"] == "min
$list = $xpath->query("//*[contains(@id,'tread-wrapper-')]"); /* */
foreach ($list as $item) {
$item = $target->importNode($item, true);
// And then append it to the target
@ -499,32 +472,30 @@ if (isset($_GET["mode"]) AND ($_GET["mode"] == "raw")) {
echo substr($target->saveHTML(), 6, -8);
if (!$a->is_backend())
session_write_close();
exit;
killme();
}
$page = $a->page;
$profile = $a->profile;
header("X-Friendica-Version: ".FRIENDICA_VERSION);
header("X-Friendica-Version: " . FRIENDICA_VERSION);
header("Content-type: text/html; charset=utf-8");
// We use $_GET["mode"] for special page templates. So we will check if we have
// to load another page template than the default one
// The page templates are located in /view/php/ or in the theme directory
/*
* We use $_GET["mode"] for special page templates. So we will check if we have
* to load another page template than the default one.
* The page templates are located in /view/php/ or in the theme directory.
*/
if (isset($_GET["mode"])) {
$template = theme_include($_GET["mode"].'.php');
$template = theme_include($_GET["mode"] . '.php');
}
// If there is no page template use the default page template
if(!$template) {
if (!$template) {
$template = theme_include("default.php");
}
require_once($template);
/// @TODO Looks unsafe (remote-inclusion), is maybe not but theme_include() uses file_exists() but does not escape anything
require_once $template;
if (!$a->is_backend())
session_write_close();
exit;
killme();

+ 8
- 8
mod/admin.php View File

@ -2004,22 +2004,22 @@ function admin_page_features_post(App $a) {
$features = get_features(false);
foreach ($features as $fname => $fdata) {
foreach (array_slice($fdata,1) as $f) {
foreach (array_slice($fdata, 1) as $f) {
$feature = $f[0];
$feature_state = 'feature_'.$feature;
$featurelock = 'featurelock_'.$feature;
$feature_state = 'feature_' . $feature;
$featurelock = 'featurelock_' . $feature;
if (x($_POST[$feature_state])) {
$val = intval($_POST['feature_'.$feature]);
if (x($_POST, $feature_state)) {
$val = intval($_POST[$feature_state]);
} else {
$val = 0;
}
set_config('feature',$feature,$val);
if (x($_POST[$featurelock])) {
set_config('feature_lock',$feature,$val);
if (x($_POST, $featurelock)) {
set_config('feature_lock', $feature, $val);
} else {
del_config('feature_lock',$feature);
del_config('feature_lock', $feature);
}
}
}


+ 7
- 6
mod/dfrn_confirm.php View File

@ -586,17 +586,18 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
dbesc($decrypted_source_url),
intval($local_uid)
);
if(! count($ret)) {
if(strstr($decrypted_source_url,'http:'))
if (!dbm::is_result($ret)) {
if (strstr($decrypted_source_url,'http:')) {
$newurl = str_replace('http:','https:',$decrypted_source_url);
else
} else {
$newurl = str_replace('https:','http:',$decrypted_source_url);
}
$ret = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d LIMIT 1",
dbesc($newurl),
intval($local_uid)
);
if(! count($ret)) {
if (!dbm::is_result($ret)) {
// this is either a bogus confirmation (?) or we deleted the original introduction.
$message = t('Contact record was not found for you on our site.');
xml_status(3,$message);
@ -611,7 +612,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
$foreign_pubkey = $ret[0]['site-pubkey'];
$dfrn_record = $ret[0]['id'];
if(! $foreign_pubkey) {
if (! $foreign_pubkey) {
$message = sprintf( t('Site public key not available in contact record for URL %s.'), $newurl);
xml_status(3,$message);
}
@ -619,7 +620,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
$decrypted_dfrn_id = "";
openssl_public_decrypt($dfrn_id,$decrypted_dfrn_id,$foreign_pubkey);
if(strlen($aes_key)) {
if (strlen($aes_key)) {
$decrypted_aes_key = "";
openssl_private_decrypt($aes_key,$decrypted_aes_key,$my_prvkey);
$dfrn_pubkey = openssl_decrypt($public_key,'AES-256-CBC',$decrypted_aes_key);


+ 64
- 64
mod/dfrn_notify.php View File

@ -28,14 +28,14 @@ function dfrn_notify_post(App $a) {
$prv = (($page == 2) ? 1 : 0);
$writable = (-1);
if($dfrn_version >= 2.21) {
if ($dfrn_version >= 2.21) {
$writable = (($perm === 'rw') ? 1 : 0);
}
$direction = (-1);
if(strpos($dfrn_id,':') == 1) {
$direction = intval(substr($dfrn_id,0,1));
$dfrn_id = substr($dfrn_id,2);
if (strpos($dfrn_id, ':') == 1) {
$direction = intval(substr($dfrn_id, 0, 1));
$dfrn_id = substr($dfrn_id, 2);
}
$r = q("SELECT * FROM `challenge` WHERE `dfrn-id` = '%s' AND `challenge` = '%s' LIMIT 1",
@ -70,9 +70,11 @@ function dfrn_notify_post(App $a) {
break; // NOTREACHED
}
// be careful - $importer will contain both the contact information for the contact
// sending us the post, and also the user information for the person receiving it.
// since they are mixed together, it is easy to get them confused.
/*
* be careful - $importer will contain both the contact information for the contact
* sending us the post, and also the user information for the person receiving it.
* since they are mixed together, it is easy to get them confused.
*/
$r = q("SELECT `contact`.*, `contact`.`uid` AS `importer_uid`,
`contact`.`pubkey` AS `cpubkey`,
@ -100,15 +102,16 @@ function dfrn_notify_post(App $a) {
logger("Remote rino version: ".$rino_remote." for ".$importer["url"], LOGGER_DEBUG);
if((($writable != (-1)) && ($writable != $importer['writable'])) || ($importer['forum'] != $forum) || ($importer['prv'] != $prv)) {
if ((($writable != (-1)) && ($writable != $importer['writable'])) || ($importer['forum'] != $forum) || ($importer['prv'] != $prv)) {
q("UPDATE `contact` SET `writable` = %d, forum = %d, prv = %d WHERE `id` = %d",
intval(($writable == (-1)) ? $importer['writable'] : $writable),
intval($forum),
intval($prv),
intval($importer['id'])
);
if($writable != (-1))
if ($writable != (-1)) {
$importer['writable'] = $writable;
}
$importer['forum'] = $page;
}
@ -120,7 +123,7 @@ function dfrn_notify_post(App $a) {
logger('dfrn_notify: received notify from ' . $importer['name'] . ' for ' . $importer['username']);
logger('dfrn_notify: data: ' . $data, LOGGER_DATA);
if($dissolve == 1) {
if ($dissolve == 1) {
/*
* Relationship is dissolved permanently
@ -133,19 +136,12 @@ function dfrn_notify_post(App $a) {
}
// If we are setup as a soapbox we aren't accepting input from this person
// This behaviour is deactivated since it really doesn't make sense to even disallow comments
// The check if someone is a friend or simply a follower is done in a later place so it needn't to be done here
//if($importer['page-flags'] == PAGE_SOAPBOX)
// xml_status(0);
$rino = get_config('system','rino_encrypt');
$rino = get_config('system', 'rino_encrypt');
$rino = intval($rino);
logger("Local rino version: ". $rino, LOGGER_DEBUG);
logger("Local rino version: " . $rino, LOGGER_DEBUG);
if(strlen($key)) {
if (strlen($key)) {
// if local rino is lower than remote rino, abort: should not happen!
// but only for $remote_rino > 1, because old code did't send rino version
@ -158,20 +154,17 @@ function dfrn_notify_post(App $a) {
logger('rino: md5 raw key: ' . md5($rawkey));
$final_key = '';
if($dfrn_version >= 2.1) {
if((($importer['duplex']) && strlen($importer['cprvkey'])) || (! strlen($importer['cpubkey']))) {
openssl_private_decrypt($rawkey,$final_key,$importer['cprvkey']);
if ($dfrn_version >= 2.1) {
if ((($importer['duplex']) && strlen($importer['cprvkey'])) || (! strlen($importer['cpubkey']))) {
openssl_private_decrypt($rawkey, $final_key, $importer['cprvkey']);
} else {
openssl_public_decrypt($rawkey, $final_key, $importer['cpubkey']);
}
else {
openssl_public_decrypt($rawkey,$final_key,$importer['cpubkey']);
}
}
else {
if((($importer['duplex']) && strlen($importer['cpubkey'])) || (! strlen($importer['cprvkey']))) {
openssl_public_decrypt($rawkey,$final_key,$importer['cpubkey']);
}
else {
openssl_private_decrypt($rawkey,$final_key,$importer['cprvkey']);
} else {
if ((($importer['duplex']) && strlen($importer['cpubkey'])) || (! strlen($importer['cprvkey']))) {
openssl_public_decrypt($rawkey, $final_key, $importer['cpubkey']);
} else {
openssl_private_decrypt($rawkey, $final_key, $importer['cprvkey']);
}
}
@ -180,27 +173,31 @@ function dfrn_notify_post(App $a) {
switch($rino_remote) {
case 0:
case 1:
// we got a key. old code send only the key, without RINO version.
// we assume RINO 1 if key and no RINO version
$data = dfrn::aes_decrypt(hex2bin($data),$final_key);
/*
*we got a key. old code send only the key, without RINO version.
* we assume RINO 1 if key and no RINO version
*/
$data = dfrn::aes_decrypt(hex2bin($data), $final_key);
break;
case 2:
try {
$data = Crypto::decrypt(hex2bin($data),$final_key);
$data = Crypto::decrypt(hex2bin($data), $final_key);
} catch (InvalidCiphertext $ex) { // VERY IMPORTANT
// Either:
// 1. The ciphertext was modified by the attacker,
// 2. The key is wrong, or
// 3. $ciphertext is not a valid ciphertext or was corrupted.
// Assume the worst.
/*
* Either:
* 1. The ciphertext was modified by the attacker,
* 2. The key is wrong, or
* 3. $ciphertext is not a valid ciphertext or was corrupted.
* Assume the worst.
*/
logger('The ciphertext has been tampered with!');
xml_status(0,'The ciphertext has been tampered with!');
xml_status(0, 'The ciphertext has been tampered with!');
} catch (Ex\CryptoTestFailed $ex) {
logger('Cannot safely perform dencryption');
xml_status(0,'CryptoTestFailed');
xml_status(0, 'CryptoTestFailed');
} catch (Ex\CannotPerformOperation $ex) {
logger('Cannot safely perform decryption');
xml_status(0,'Cannot safely perform decryption');
xml_status(0, 'Cannot safely perform decryption');
}
break;
default:
@ -223,8 +220,10 @@ function dfrn_notify_content(App $a) {
if(x($_GET,'dfrn_id')) {
// initial communication from external contact, $direction is their direction.
// If this is a duplex communication, ours will be the opposite.
/*
* initial communication from external contact, $direction is their direction.
* If this is a duplex communication, ours will be the opposite.
*/
$dfrn_id = notags(trim($_GET['dfrn_id']));
$dfrn_version = (float) $_GET['dfrn_version'];
@ -288,42 +287,43 @@ function dfrn_notify_content(App $a) {
logger("Remote rino version: ".$rino_remote." for ".$r[0]["url"], LOGGER_DEBUG);
$challenge = '';
$challenge = '';
$encrypted_id = '';
$id_str = $my_id . '.' . mt_rand(1000,9999);
$id_str = $my_id . '.' . mt_rand(1000,9999);
$prv_key = trim($r[0]['prvkey']);
$pub_key = trim($r[0]['pubkey']);
$dplx = intval($r[0]['duplex']);
if((($dplx) && (strlen($prv_key))) || ((strlen($prv_key)) && (!(strlen($pub_key))))) {
openssl_private_encrypt($hash,$challenge,$prv_key);
openssl_private_encrypt($id_str,$encrypted_id,$prv_key);
}
elseif(strlen($pub_key)) {
openssl_public_encrypt($hash,$challenge,$pub_key);
openssl_public_encrypt($id_str,$encrypted_id,$pub_key);
}
else
$dplx = intval($r[0]['duplex']);
if ((($dplx) && (strlen($prv_key))) || ((strlen($prv_key)) && (!(strlen($pub_key))))) {
openssl_private_encrypt($hash, $challenge, $prv_key);
openssl_private_encrypt($id_str, $encrypted_id, $prv_key);
} elseif (strlen($pub_key)) {
openssl_public_encrypt($hash, $challenge, $pub_key);
openssl_public_encrypt($id_str, $encrypted_id, $pub_key);
} else {
/// @TODO these kind of else-blocks are making the code harder to understand
$status = 1;
}
$challenge = bin2hex($challenge);
$encrypted_id = bin2hex($encrypted_id);
$rino = get_config('system','rino_encrypt');
$rino = get_config('system', 'rino_encrypt');
$rino = intval($rino);
logger("Local rino version: ". $rino, LOGGER_DEBUG);
// if requested rino is lower than enabled local rino, lower local rino version
// if requested rino is higher than enabled local rino, reply with local rino
if ($rino_remote < $rino) $rino = $rino_remote;
if ($rino_remote < $rino) {
$rino = $rino_remote;
}
if((($r[0]['rel']) && ($r[0]['rel'] != CONTACT_IS_SHARING)) || ($r[0]['page-flags'] == PAGE_COMMUNITY)) {
$perm = 'rw';
}
else {
} else {
$perm = 'r';
}


+ 0
- 3
mod/install.php View File

@ -460,9 +460,6 @@ function check_funcs(&$checks) {
$ck_funcs[6]['status'] = false;
$ck_funcs[6]['help'] = t('Error, XML PHP module required but not installed.');
}
/*if((x($_SESSION,'sysmsg')) && is_array($_SESSION['sysmsg']) && count($_SESSION['sysmsg']))
notice( t('Please see the file "INSTALL.txt".') . EOL);*/
}


+ 254
- 237
mod/item.php
File diff suppressed because it is too large
View File


+ 28
- 18
mod/manage.php View File

@ -22,34 +22,34 @@ function manage_post(App $a) {
}
}
$r = q("select * from manage where uid = %d",
$r = q("SELECT * FROM `manage` WHERE `uid` = %d",
intval($uid)
);
$submanage = $r;
$identity = ((x($_POST['identity'])) ? intval($_POST['identity']) : 0);
if(! $identity)
if (! $identity) {
return;
}
$limited_id = 0;
$original_id = $uid;
if(count($submanage)) {
foreach($submanage as $m) {
if($identity == $m['mid']) {
if (dbm::is_result($submanage)) {
foreach ($submanage as $m) {
if ($identity == $m['mid']) {
$limited_id = $m['mid'];
break;
}
}
}
if($limited_id) {
if ($limited_id) {
$r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
intval($limited_id)
);
}
else {
} else {
$r = q("SELECT * FROM `user` WHERE `uid` = %d AND `email` = '%s' AND `password` = '%s' LIMIT 1",
intval($identity),
dbesc($orig_record['email']),
@ -70,18 +70,22 @@ function manage_post(App $a) {
unset($_SESSION['mobile-theme']);
unset($_SESSION['page_flags']);
unset($_SESSION['return_url']);
if(x($_SESSION,'submanage'))
if (x($_SESSION, 'submanage')) {
unset($_SESSION['submanage']);
if(x($_SESSION,'sysmsg'))
}
if (x($_SESSION, 'sysmsg')) {
unset($_SESSION['sysmsg']);
if(x($_SESSION,'sysmsg_info'))
}
if (x($_SESSION, 'sysmsg_info')) {
unset($_SESSION['sysmsg_info']);
}
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;
}
$ret = array();
call_hooks('home_init',$ret);
@ -113,26 +117,32 @@ function manage_content(App $a) {
dbesc($id['uid'])
);
$identities[$key][thumb] = $thumb[0][thumb];
$identities[$key]['thumb'] = $thumb[0]['thumb'];
$identities[$key]['selected'] = (($id['nickname'] === $a->user['nickname']) ? true : false);
$identities[$key]['selected'] = ($id['nickname'] === $a->user['nickname']);
$notifications = 0;
$r = q("SELECT DISTINCT(`parent`) FROM `notify` WHERE `uid` = %d AND NOT `seen` AND NOT (`type` IN (%d, %d))",
intval($id['uid']), intval(NOTIFY_INTRO), intval(NOTIFY_MAIL));
if ($r)
if (dbm::is_result($r)) {
$notifications = sizeof($r);
}
$r = q("SELECT DISTINCT(`convid`) FROM `mail` WHERE `uid` = %d AND NOT `seen`",
intval($id['uid']));
if ($r)
if (dbm::is_result($r)) {
$notifications = $notifications + sizeof($r);
}
$r = q("SELECT COUNT(*) AS `introductions` FROM `intro` WHERE NOT `blocked` AND NOT `ignore` AND `uid` = %d",
intval($id['uid']));
if ($r)
if (dbm::is_result($r)) {
$notifications = $notifications + $r[0]["introductions"];
}
$identities[$key]['notifications'] = $notifications;
}


+ 16
- 12
mod/network.php View File

@ -6,7 +6,7 @@ function network_init(App $a) {
}
$is_a_date_query = false;
if (x($_GET['cid']) && intval($_GET['cid']) != 0) {
if (x($_GET, 'cid') && intval($_GET['cid']) != 0) {
$cid = $_GET['cid'];
}
@ -103,24 +103,27 @@ function network_init(App $a) {
}
}
if(x($_GET['nets']) && $_GET['nets'] === 'all')
// If nets is set to all, unset it
if (x($_GET, 'nets') && $_GET['nets'] === 'all') {
unset($_GET['nets']);
}
$group_id = (($a->argc > 1 && is_numeric($a->argv[1])) ? intval($a->argv[1]) : 0);
set_pconfig(local_user(), 'network.view', 'group.selected', $group_id);
require_once('include/group.php');
require_once('include/contact_widgets.php');
require_once('include/items.php');
require_once('include/ForumManager.php');
require_once 'include/group.php';
require_once 'include/contact_widgets.php';
require_once 'include/items.php';
require_once 'include/ForumManager.php';
if(! x($a->page,'aside'))
if (! x($a->page, 'aside')) {
$a->page['aside'] = '';
}
$search = ((x($_GET,'search')) ? escape_tags($_GET['search']) : '');
$search = ((x($_GET, 'search')) ? escape_tags($_GET['search']) : '');
if(x($_GET,'save')) {
if (x($_GET, 'save')) {
$r = qu("SELECT * FROM `search` WHERE `uid` = %d AND `term` = '%s' LIMIT 1",
intval(local_user()),
dbesc($search)
@ -132,7 +135,7 @@ function network_init(App $a) {
);
}
}
if(x($_GET,'remove')) {
if (x($_GET, 'remove')) {
q("DELETE FROM `search` WHERE `uid` = %d AND `term` = '%s'",
intval(local_user()),
dbesc($search)
@ -140,7 +143,7 @@ function network_init(App $a) {
}
// search terms header
if(x($_GET,'search')) {
if (x($_GET, 'search')) {
$a->page['content'] .= replace_macros(get_markup_template("section_title.tpl"),array(
'$title' => sprintf( t('Results for: %s'), $search)
));
@ -157,8 +160,9 @@ function network_init(App $a) {
function saved_searches($search) {
if(! feature_enabled(local_user(),'savedsearch'))
if (! feature_enabled(local_user(),'savedsearch')) {
return '';
}
$a = get_app();


+ 257
- 238
mod/photos.php
File diff suppressed because it is too large
View File


+ 111
- 113
mod/profiles.php View File

@ -10,7 +10,7 @@ function profiles_init(App $a) {
return;
}
if(($a->argc > 2) && ($a->argv[1] === "drop") && intval($a->argv[2])) {
if (($a->argc > 2) && ($a->argv[1] === "drop") && intval($a->argv[2])) {
$r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d AND `is-default` = 0 LIMIT 1",
intval($a->argv[2]),
intval(local_user())
@ -34,24 +34,22 @@ function profiles_init(App $a) {
intval($a->argv[2]),
intval(local_user())
);
if($r)
if (dbm::is_result($r)) {
info(t('Profile deleted.').EOL);
}
goaway('profiles');
return; // NOTREACHED
}
if(($a->argc > 1) && ($a->argv[1] === 'new')) {
if (($a->argc > 1) && ($a->argv[1] === 'new')) {
check_form_security_token_redirectOnErr('/profiles', 'profile_new', 't');
$r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d",
intval(local_user()));
$num_profiles = count($r0);
$num_profiles = (dbm::is_result($r0) ? count($r0) : 0);
$name = t('Profile-') . ($num_profiles + 1);
@ -73,19 +71,21 @@ function profiles_init(App $a) {
);
info( t('New profile created.') . EOL);
if(count($r3) == 1)
goaway('profiles/'.$r3[0]['id']);
if (dbm::is_result($r3) && count($r3) == 1) {
goaway('profiles/' . $r3[0]['id']);
}
goaway('profiles');
}
if(($a->argc > 2) && ($a->argv[1] === 'clone')) {
if (($a->argc > 2) && ($a->argv[1] === 'clone')) {
check_form_security_token_redirectOnErr('/profiles', 'profile_clone', 't');
$r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d",
intval(local_user()));
$num_profiles = count($r0);
$num_profiles = (dbm::is_result($r0) ? count($r0) : 0);
$name = t('Profile-') . ($num_profiles + 1);
$r1 = q("SELECT * FROM `profile` WHERE `uid` = %d AND `id` = %d LIMIT 1",
@ -116,8 +116,9 @@ function profiles_init(App $a) {
dbesc($name)
);
info( t('New profile created.') . EOL);
if ((dbm::is_result($r3)) && (count($r3) == 1))
if ((dbm::is_result($r3)) && (count($r3) == 1)) {
goaway('profiles/'.$r3[0]['id']);
}
goaway('profiles');
@ -125,7 +126,7 @@ function profiles_init(App $a) {
}
if(($a->argc > 1) && (intval($a->argv[1]))) {
if (($a->argc > 1) && (intval($a->argv[1]))) {
$r = q("SELECT id FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($a->argv[1]),
intval(local_user())
@ -136,7 +137,7 @@ function profiles_init(App $a) {
return;
}
profile_load($a,$a->user['nickname'],$r[0]['id']);
profile_load($a,$a->user['nickname'], $r[0]['id']);
}
@ -144,15 +145,16 @@ function profiles_init(App $a) {
}
function profile_clean_keywords($keywords) {
$keywords = str_replace(","," ",$keywords);
$keywords = str_replace(",", " ", $keywords);
$keywords = explode(" ", $keywords);
$cleaned = array();
foreach ($keywords as $keyword) {
$keyword = trim(strtolower($keyword));
$keyword = trim($keyword, "#");
if ($keyword != "")
if ($keyword != "") {
$cleaned[] = $keyword;
}
}
$keywords = implode(", ", $cleaned);
@ -171,12 +173,12 @@ function profiles_post(App $a) {
call_hooks('profile_post', $_POST);
if(($a->argc > 1) && ($a->argv[1] !== "new") && intval($a->argv[1])) {
if (($a->argc > 1) && ($a->argv[1] !== "new") && intval($a->argv[1])) {
$orig = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($a->argv[1]),
intval(local_user())
);
if(! count($orig)) {
if (! dbm::is_result($orig)) {
notice( t('Profile not found.') . EOL);
return;
}
@ -186,38 +188,40 @@ function profiles_post(App $a) {
$is_default = (($orig[0]['is-default']) ? 1 : 0);
$profile_name = notags(trim($_POST['profile_name']));
if(! strlen($profile_name)) {
if (! strlen($profile_name)) {
notice( t('Profile Name is required.') . EOL);
return;
}
$dob = $_POST['dob'] ? escape_tags(trim($_POST['dob'])) : '0000-00-00'; // FIXME: Needs to be validated?
$y = substr($dob,0,4);
if((! ctype_digit($y)) || ($y < 1900))
$y = substr($dob, 0, 4);
if ((! ctype_digit($y)) || ($y < 1900)) {
$ignore_year = true;
else
} else {
$ignore_year = false;
if($dob != '0000-00-00') {
if(strpos($dob,'0000-') === 0) {
}
if ($dob != '0000-00-00') {
if (strpos($dob, '0000-') === 0) {
$ignore_year = true;
$dob = substr($dob,5);
$dob = substr($dob, 5);
}
$dob = datetime_convert('UTC','UTC',(($ignore_year) ? '1900-' . $dob : $dob),(($ignore_year) ? 'm-d' : 'Y-m-d'));
if($ignore_year)
$dob = datetime_convert('UTC', 'UTC', (($ignore_year) ? '1900-' . $dob : $dob), (($ignore_year) ? 'm-d' : 'Y-m-d'));
if ($ignore_year) {
$dob = '0000-' . $dob;
}
}
$name = notags(trim($_POST['name']));
if(! strlen($name)) {
if (! strlen($name)) {
$name = '[No Name]';
}
if($orig[0]['name'] != $name)
if ($orig[0]['name'] != $name) {
$namechanged = true;
}
$pdesc = notags(trim($_POST['pdesc']));
$gender = notags(trim($_POST['gender']));
@ -233,54 +237,42 @@ function profiles_post(App $a) {
$with = ((x($_POST,'with')) ? notags(trim($_POST['with'])) : '');
if(! strlen($howlong)) {
if (! strlen($howlong)) {
$howlong = NULL_DATE;
} else {
$howlong = datetime_convert(date_default_timezone_get(),'UTC',$howlong);
$howlong = datetime_convert(date_default_timezone_get(), 'UTC', $howlong);
}
// linkify the relationship target if applicable
$withchanged = false;
if(strlen($with)) {
if($with != strip_tags($orig[0]['with'])) {
if (strlen($with)) {
if ($with != strip_tags($orig[0]['with'])) {
$withchanged = true;
$prf = '';
$lookup = $with;
if(strpos($lookup,'@') === 0)
$lookup = substr($lookup,1);
if (strpos($lookup, '@') === 0) {
$lookup = substr($lookup, 1);
}
$lookup = str_replace('_',' ', $lookup);
if(strpos($lookup,'@') || (strpos($lookup,'http://'))) {
if (strpos($lookup, '@') || (strpos($lookup, 'http://'))) {
$newname = $lookup;
$links = @Probe::lrdd($lookup);
if(count($links)) {
foreach($links as $link) {
if($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page') {
if (count($links)) {
foreach ($links as $link) {
if ($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page') {
$prf = $link['@attributes']['href'];
}
}
}
}
else {
} else {
$newname = $lookup;
/* if(strstr($lookup,' ')) {
$r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
dbesc($newname),
intval(local_user())
);
}
else {
$r = q("SELECT * FROM `contact` WHERE `nick` = '%s' AND `uid` = %d LIMIT 1",
dbesc($lookup),
intval(local_user())
);
}*/
$r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
dbesc($newname),
intval(local_user())
);
if(! $r) {
if (! dbm::is_result($r)) {
$r = q("SELECT * FROM `contact` WHERE `nick` = '%s' AND `uid` = %d LIMIT 1",
dbesc($lookup),
intval(local_user())
@ -292,16 +284,18 @@ function profiles_post(App $a) {
}
}
if($prf) {
$with = str_replace($lookup,'<a href="' . $prf . '">' . $newname . '</a>', $with);
if(strpos($with,'@') === 0)
$with = substr($with,1);
if ($prf) {
$with = str_replace($lookup, '<a href="' . $prf . '">' . $newname . '</a>', $with);
if (strpos($with, '@') === 0) {
$with = substr($with, 1);
}
}
}
else
} else {
$with = $orig[0]['with'];
}
}
/// @TODO Not flexible enough for later expansion, let's have more OOP here
$sexual = notags(trim($_POST['sexual']));
$xmpp = notags(trim($_POST['xmpp']));
$homepage = notags(trim($_POST['homepage']));
@ -329,65 +323,65 @@ function profiles_post(App $a) {
$hide_friends = (($_POST['hide-friends'] == 1) ? 1: 0);
set_pconfig(local_user(),'system','detailled_profile', (($_POST['detailled_profile'] == 1) ? 1: 0));
set_pconfig(local_user(), 'system', 'detailled_profile', (($_POST['detailled_profile'] == 1) ? 1: 0));
$changes = array();
$value = '';
if($is_default) {
if($marital != $orig[0]['marital']) {
if ($is_default) {
if ($marital != $orig[0]['marital']) {
$changes[] = '[color=#ff0000]&hearts;[/color] ' . t('Marital Status');
$value = $marital;
}
if($withchanged) {
if ($withchanged) {
$changes[] = '[color=#ff0000]&hearts;[/color] ' . t('Romantic Partner');
$value = strip_tags($with);
}
if($likes != $orig[0]['likes']) {
if ($likes != $orig[0]['likes']) {
$changes[] = t('Likes');
$value = $likes;
}
if($dislikes != $orig[0]['dislikes']) {
if ($dislikes != $orig[0]['dislikes']) {
$changes[] = t('Dislikes');
$value = $dislikes;
}
if($work != $orig[0]['work']) {
if ($work != $orig[0]['work']) {
$changes[] = t('Work/Employment');
}
if($religion != $orig[0]['religion']) {
if ($religion != $orig[0]['religion']) {
$changes[] = t('Religion');
$value = $religion;
}
if($politic != $orig[0]['politic']) {
if ($politic != $orig[0]['politic']) {
$changes[] = t('Political Views');
$value = $politic;
}
if($gender != $orig[0]['gender']) {
if ($gender != $orig[0]['gender']) {
$changes[] = t('Gender');
$value = $gender;
}
if($sexual != $orig[0]['sexual']) {
if ($sexual != $orig[0]['sexual']) {
$changes[] = t('Sexual Preference');
$value = $sexual;
}
if($xmpp != $orig[0]['xmpp']) {
if ($xmpp != $orig[0]['xmpp']) {
$changes[] = t('XMPP');
$value = $xmpp;
}
if($homepage != $orig[0]['homepage']) {
if ($homepage != $orig[0]['homepage']) {
$changes[] = t('Homepage');
$value = $homepage;
}
if($interest != $orig[0]['interest']) {
if ($interest != $orig[0]['interest']) {
$changes[] = t('Interests');
$value = $interest;
}
if($address != $orig[0]['address']) {
if ($address != $orig[0]['address']) {
$changes[] = t('Address');
// New address not sent in notifications, potential privacy issues
// in case this leaks to unintended recipients. Yes, it's in the public
// profile but that doesn't mean we have to broadcast it to everybody.
}
if($locality != $orig[0]['locality'] || $region != $orig[0]['region']
if ($locality != $orig[0]['locality'] || $region != $orig[0]['region']
|| $country_name != $orig[0]['country-name']) {
$changes[] = t('Location');
$comma1 = ((($locality) && ($region || $country_name)) ? ', ' : ' ');
@ -473,11 +467,12 @@ function profiles_post(App $a) {
intval(local_user())
);
if($r)
info( t('Profile updated.') . EOL);
if ($r) {
info(t('Profile updated.') . EOL);
}
if($namechanged && $is_default) {
if ($namechanged && $is_default) {
$r = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `self` = 1 AND `uid` = %d",
dbesc($name),
dbesc(datetime_convert()),
@ -489,7 +484,7 @@ function profiles_post(App $a) {
);
}
if($is_default) {
if ($is_default) {
$location = formatted_location(array("locality" => $locality, "region" => $region, "country-name" => $country_name));
q("UPDATE `contact` SET `about` = '%s', `location` = '%s', `keywords` = '%s', `gender` = '%s' WHERE `self` AND `uid` = %d",
@ -502,7 +497,7 @@ function profiles_post(App $a) {
// Update global directory in background
$url = $_SESSION['my_url'];
if ($url && strlen(get_config('system','directory'))) {
if ($url && strlen(get_config('system', 'directory'))) {
proc_run(PRIORITY_LOW, "include/directory.php", $url);
}
@ -519,14 +514,17 @@ function profiles_post(App $a) {
function profile_activity($changed, $value) {
$a = get_app();
if(! local_user() || ! is_array($changed) || ! count($changed))
if (! local_user() || ! is_array($changed) || ! count($changed)) {
return;
}
if($a->user['hidewall'] || get_config('system','block_public'))
if ($a->user['hidewall'] || get_config('system', 'block_public')) {
return;
}
if(! get_pconfig(local_user(),'system','post_profilechange'))
if (! get_pconfig(local_user(), 'system', 'post_profilechange')) {
return;
}
require_once('include/items.php');
@ -534,8 +532,9 @@ function profile_activity($changed, $value) {
intval(local_user())
);
if(! count($self))
if (! dbm::is_result($self)) {
return;
}
$arr = array();
@ -559,12 +558,13 @@ function profile_activity($changed, $value) {
$changes = '';
$t = count($changed);
$z = 0;
foreach($changed as $ch) {
if(strlen($changes)) {
if ($z == ($t - 1))
foreach ($changed as $ch) {
if (strlen($changes)) {
if ($z == ($t - 1)) {
$changes .= t(' and ');
else
} else {
$changes .= ', ';
}