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

Rewrites/coding convention split2
This commit is contained in:
Hypolite Petovan 2017-04-03 06:38:10 -04:00 committed by GitHub
commit 48dde02e75
18 changed files with 1866 additions and 1537 deletions

659
boot.php

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

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

View File

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

169
index.php
View File

@ -28,17 +28,17 @@ $a->backend = false;
/** /**
* *
* Load the configuration file which contains our DB credentials. * 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); $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); $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 * Load configs from db. Overwrite configs from .htconfig.php
@ -59,17 +59,17 @@ if(!$install) {
Config::load(); Config::load();
if ($a->max_processes_reached() OR $a->maxload_reached()) { 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('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"); die("System is currently unavailable. Please try again later");
} }
if (get_config('system','force_ssl') AND ($a->get_scheme() == "http") AND if (get_config('system', 'force_ssl') AND ($a->get_scheme() == "http") AND
(intval(get_config('system','ssl_policy')) == SSL_POLICY_FULL) AND (intval(get_config('system', 'ssl_policy')) == SSL_POLICY_FULL) AND
(substr(App::get_baseurl(), 0, 8) == "https://")) { (substr(App::get_baseurl(), 0, 8) == "https://")) {
header("HTTP/1.1 302 Moved Temporarily"); header("HTTP/1.1 302 Moved Temporarily");
header("Location: ".App::get_baseurl()."/".$a->query_string); header("Location: " . App::get_baseurl() . "/" . $a->query_string);
exit(); exit();
} }
@ -117,12 +117,12 @@ if (x($_SESSION,'authenticated') && !x($_SESSION,'language')) {
if (dbm::is_result($r)) $_SESSION['language'] = $r[0]['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']; $lang = $_SESSION['language'];
load_translation_table($lang); 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 // Only continue when the given profile link seems valid
// Valid profile links contain a path with "/profile/" and no query parameters // Valid profile links contain a path with "/profile/" and no query parameters
if ((parse_url($_GET['zrl'], PHP_URL_QUERY) == "") AND if ((parse_url($_GET['zrl'], PHP_URL_QUERY) == "") AND
@ -223,7 +223,7 @@ if ((local_user()) || (! $privateapps === "1")) {
* further processing. * further processing.
*/ */
if(strlen($a->module)) { if (strlen($a->module)) {
/** /**
* *
@ -233,12 +233,14 @@ if(strlen($a->module)) {
*/ */
// Compatibility with the Android Diaspora client // Compatibility with the Android Diaspora client
if ($a->module == "stream") if ($a->module == "stream") {
$a->module = "network"; $a->module = "network";
}
// Compatibility with the Firefox App // 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"; $a->module = "login";
}
$privateapps = get_config('config','private_addons'); $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 //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") { if ((!local_user()) && plugin_is_app($a->module) && $privateapps === "1") {
info( t("You must be logged in to use addons. ")); info( t("You must be logged in to use addons. "));
} } else {
else {
include_once("addon/{$a->module}/{$a->module}.php"); include_once("addon/{$a->module}/{$a->module}.php");
if(function_exists($a->module . '_module')) if (function_exists($a->module . '_module')) {
$a->module_loaded = true; $a->module_loaded = true;
}
} }
} }
@ -320,29 +322,22 @@ if (!$install && !$maintenance) {
* Call module functions * Call module functions
*/ */
if($a->module_loaded) { if ($a->module_loaded) {
$a->page['page_title'] = $a->module; $a->page['page_title'] = $a->module;
$placeholder = ''; $placeholder = '';
if(function_exists($a->module . '_init')) { if (function_exists($a->module . '_init')) {
call_hooks($a->module . '_mod_init', $placeholder); call_hooks($a->module . '_mod_init', $placeholder);
$func = $a->module . '_init'; $func = $a->module . '_init';
$func($a); $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 = str_replace('-','_',current_theme()) . '_init';
$func($a); $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')) && (function_exists($a->module . '_post'))
&& (! x($_POST,'auth-params'))) { && (! x($_POST,'auth-params'))) {
call_hooks($a->module . '_mod_post', $_POST); call_hooks($a->module . '_mod_post', $_POST);
@ -350,13 +345,13 @@ if($a->module_loaded) {
$func($a); $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); call_hooks($a->module . '_mod_afterpost',$placeholder);
$func = $a->module . '_afterpost'; $func = $a->module . '_afterpost';
$func($a); $func($a);
} }
if((! $a->error) && (function_exists($a->module . '_content'))) { if ((! $a->error) && (function_exists($a->module . '_content'))) {
$arr = array('content' => $a->page['content']); $arr = array('content' => $a->page['content']);
call_hooks($a->module . '_mod_content', $arr); call_hooks($a->module . '_mod_content', $arr);
$a->page['content'] = $arr['content']; $a->page['content'] = $arr['content'];
@ -366,7 +361,7 @@ if($a->module_loaded) {
$a->page['content'] .= $arr['content']; $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 = str_replace('-','_',current_theme()) . '_content_loaded';
$func($a); $func($a);
} }
@ -374,98 +369,76 @@ if($a->module_loaded) {
/* /*
* Create the page head after setting the language * 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 * Moved init_pagehead() and init_page_end() to after
* all the module functions have executed so that all * 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(); $a->init_pagehead();
/** /*
* Build the page ending -- this is stuff that goes right before * Build the page ending -- this is stuff that goes right before
* the closing </body> tag * the closing </body> tag
*/ */
$a->init_page_end(); $a->init_page_end();
// If you're just visiting, let javascript take you home // If you're just visiting, let javascript take you home
if (x($_SESSION, 'visitor_home')) {
if(x($_SESSION,'visitor_home'))
$homebase = $_SESSION['visitor_home']; $homebase = $_SESSION['visitor_home'];
elseif(local_user()) } elseif (local_user()) {
$homebase = 'profile/' . $a->user['nickname']; $homebase = 'profile/' . $a->user['nickname'];
}
if(isset($homebase)) if (isset($homebase)) {
$a->page['content'] .= '<script>var homebase="' . $homebase . '" ; </script>'; $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. * 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'))) { */
if (stristr(implode("", $_SESSION['sysmsg']), t('Permission denied'))) {
header($_SERVER["SERVER_PROTOCOL"] . ' 403 ' . 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) * 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']); call_hooks('page_end', $a->page['content']);
/*
/**
*
* Add the navigation (menu) template * Add the navigation (menu) template
*
*/ */
if ($a->module != 'install' && $a->module != 'maintenance') {
if($a->module != 'install' && $a->module != 'maintenance') {
nav($a); nav($a);
} }
/** /*
* Add a "toggle mobile" link if we're using a mobile device * Add a "toggle mobile" link if we're using a mobile device
*/ */
if ($a->is_mobile || $a->is_tablet) {
if($a->is_mobile || $a->is_tablet) { if (isset($_SESSION['show-mobile']) && !$_SESSION['show-mobile']) {
if(isset($_SESSION['show-mobile']) && !$_SESSION['show-mobile']) {
$link = 'toggle_mobile?address=' . curPageURL(); $link = 'toggle_mobile?address=' . curPageURL();
} } else {
else {
$link = 'toggle_mobile?off=1&address=' . curPageURL(); $link = 'toggle_mobile?off=1&address=' . curPageURL();
} }
$a->page['footer'] = replace_macros(get_markup_template("toggle_mobile_footer.tpl"), array( $a->page['footer'] = replace_macros(get_markup_template("toggle_mobile_footer.tpl"), array(
'$toggle_link' => $link, '$toggle_link' => $link,
'$toggle_text' => t('toggle mobile') '$toggle_text' => t('toggle mobile')
)); ));
} }
/** /**
* Build the page - now that we have all the components * Build the page - now that we have all the components
*/ */
if(!$a->theme['stylesheet']) if (!$a->theme['stylesheet']) {
$stylesheet = current_theme_url(); $stylesheet = current_theme_url();
else } else {
$stylesheet = $a->theme['stylesheet']; $stylesheet = $a->theme['stylesheet'];
}
$a->page['htmlhead'] = str_replace('{{$stylesheet}}',$stylesheet,$a->page['htmlhead']); $a->page['htmlhead'] = str_replace('{{$stylesheet}}',$stylesheet,$a->page['htmlhead']);
//$a->page['htmlhead'] = replace_macros($a->page['htmlhead'], array('$stylesheet' => $stylesheet)); //$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"); $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); @$doc->loadHTML($content);
$xpath = new DomXPath($doc); $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-')]"); /* */ $list = $xpath->query("//*[contains(@id,'tread-wrapper-')]"); /* */
foreach ($list as $item) { foreach ($list as $item) {
$item = $target->importNode($item, true); $item = $target->importNode($item, true);
// And then append it to the target // 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); echo substr($target->saveHTML(), 6, -8);
if (!$a->is_backend()) killme();
session_write_close();
exit;
} }
$page = $a->page; $page = $a->page;
$profile = $a->profile; $profile = $a->profile;
header("X-Friendica-Version: ".FRIENDICA_VERSION); header("X-Friendica-Version: " . FRIENDICA_VERSION);
header("Content-type: text/html; charset=utf-8"); 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 * We use $_GET["mode"] for special page templates. So we will check if we have
// The page templates are located in /view/php/ or in the theme directory * 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"])) { 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 there is no page template use the default page template
if(!$template) { if (!$template) {
$template = theme_include("default.php"); $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()) killme();
session_write_close();
exit;

View File

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

View File

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

View File

@ -28,14 +28,14 @@ function dfrn_notify_post(App $a) {
$prv = (($page == 2) ? 1 : 0); $prv = (($page == 2) ? 1 : 0);
$writable = (-1); $writable = (-1);
if($dfrn_version >= 2.21) { if ($dfrn_version >= 2.21) {
$writable = (($perm === 'rw') ? 1 : 0); $writable = (($perm === 'rw') ? 1 : 0);
} }
$direction = (-1); $direction = (-1);
if(strpos($dfrn_id,':') == 1) { if (strpos($dfrn_id, ':') == 1) {
$direction = intval(substr($dfrn_id,0,1)); $direction = intval(substr($dfrn_id, 0, 1));
$dfrn_id = substr($dfrn_id,2); $dfrn_id = substr($dfrn_id, 2);
} }
$r = q("SELECT * FROM `challenge` WHERE `dfrn-id` = '%s' AND `challenge` = '%s' LIMIT 1", $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 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. * be careful - $importer will contain both the contact information for the contact
// since they are mixed together, it is easy to get them confused. * 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`, $r = q("SELECT `contact`.*, `contact`.`uid` AS `importer_uid`,
`contact`.`pubkey` AS `cpubkey`, `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); 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", q("UPDATE `contact` SET `writable` = %d, forum = %d, prv = %d WHERE `id` = %d",
intval(($writable == (-1)) ? $importer['writable'] : $writable), intval(($writable == (-1)) ? $importer['writable'] : $writable),
intval($forum), intval($forum),
intval($prv), intval($prv),
intval($importer['id']) intval($importer['id'])
); );
if($writable != (-1)) if ($writable != (-1)) {
$importer['writable'] = $writable; $importer['writable'] = $writable;
}
$importer['forum'] = $page; $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: received notify from ' . $importer['name'] . ' for ' . $importer['username']);
logger('dfrn_notify: data: ' . $data, LOGGER_DATA); logger('dfrn_notify: data: ' . $data, LOGGER_DATA);
if($dissolve == 1) { if ($dissolve == 1) {
/* /*
* Relationship is dissolved permanently * Relationship is dissolved permanently
@ -133,19 +136,12 @@ function dfrn_notify_post(App $a) {
} }
$rino = get_config('system', 'rino_encrypt');
// 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 = intval($rino); $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! // 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 // 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)); logger('rino: md5 raw key: ' . md5($rawkey));
$final_key = ''; $final_key = '';
if($dfrn_version >= 2.1) { if ($dfrn_version >= 2.1) {
if((($importer['duplex']) && strlen($importer['cprvkey'])) || (! strlen($importer['cpubkey']))) { if ((($importer['duplex']) && strlen($importer['cprvkey'])) || (! strlen($importer['cpubkey']))) {
openssl_private_decrypt($rawkey,$final_key,$importer['cprvkey']); openssl_private_decrypt($rawkey, $final_key, $importer['cprvkey']);
} else {
openssl_public_decrypt($rawkey, $final_key, $importer['cpubkey']);
} }
else { } else {
openssl_public_decrypt($rawkey,$final_key,$importer['cpubkey']); if ((($importer['duplex']) && strlen($importer['cpubkey'])) || (! strlen($importer['cprvkey']))) {
} openssl_public_decrypt($rawkey, $final_key, $importer['cpubkey']);
} } else {
else { openssl_private_decrypt($rawkey, $final_key, $importer['cprvkey']);
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) { switch($rino_remote) {
case 0: case 0:
case 1: 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 *we got a key. old code send only the key, without RINO version.
$data = dfrn::aes_decrypt(hex2bin($data),$final_key); * we assume RINO 1 if key and no RINO version
*/
$data = dfrn::aes_decrypt(hex2bin($data), $final_key);
break; break;
case 2: case 2:
try { try {
$data = Crypto::decrypt(hex2bin($data),$final_key); $data = Crypto::decrypt(hex2bin($data), $final_key);
} catch (InvalidCiphertext $ex) { // VERY IMPORTANT } catch (InvalidCiphertext $ex) { // VERY IMPORTANT
// Either: /*
// 1. The ciphertext was modified by the attacker, * Either:
// 2. The key is wrong, or * 1. The ciphertext was modified by the attacker,
// 3. $ciphertext is not a valid ciphertext or was corrupted. * 2. The key is wrong, or
// Assume the worst. * 3. $ciphertext is not a valid ciphertext or was corrupted.
* Assume the worst.
*/
logger('The ciphertext has been tampered with!'); 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) { } catch (Ex\CryptoTestFailed $ex) {
logger('Cannot safely perform dencryption'); logger('Cannot safely perform dencryption');
xml_status(0,'CryptoTestFailed'); xml_status(0, 'CryptoTestFailed');
} catch (Ex\CannotPerformOperation $ex) { } catch (Ex\CannotPerformOperation $ex) {
logger('Cannot safely perform decryption'); logger('Cannot safely perform decryption');
xml_status(0,'Cannot safely perform decryption'); xml_status(0, 'Cannot safely perform decryption');
} }
break; break;
default: default:
@ -223,8 +220,10 @@ function dfrn_notify_content(App $a) {
if(x($_GET,'dfrn_id')) { 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_id = notags(trim($_GET['dfrn_id']));
$dfrn_version = (float) $_GET['dfrn_version']; $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); logger("Remote rino version: ".$rino_remote." for ".$r[0]["url"], LOGGER_DEBUG);
$challenge = ''; $challenge = '';
$encrypted_id = ''; $encrypted_id = '';
$id_str = $my_id . '.' . mt_rand(1000,9999); $id_str = $my_id . '.' . mt_rand(1000,9999);
$prv_key = trim($r[0]['prvkey']); $prv_key = trim($r[0]['prvkey']);
$pub_key = trim($r[0]['pubkey']); $pub_key = trim($r[0]['pubkey']);
$dplx = intval($r[0]['duplex']); $dplx = intval($r[0]['duplex']);
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 {
} /// @TODO these kind of else-blocks are making the code harder to understand
else
$status = 1; $status = 1;
}
$challenge = bin2hex($challenge); $challenge = bin2hex($challenge);
$encrypted_id = bin2hex($encrypted_id); $encrypted_id = bin2hex($encrypted_id);
$rino = get_config('system','rino_encrypt'); $rino = get_config('system', 'rino_encrypt');
$rino = intval($rino); $rino = intval($rino);
logger("Local rino version: ". $rino, LOGGER_DEBUG); logger("Local rino version: ". $rino, LOGGER_DEBUG);
// if requested rino is lower than enabled local rino, lower local rino version // 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 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)) { 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

@ -460,9 +460,6 @@ function check_funcs(&$checks) {
$ck_funcs[6]['status'] = false; $ck_funcs[6]['status'] = false;
$ck_funcs[6]['help'] = t('Error, XML PHP module required but not installed.'); $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);*/
} }

File diff suppressed because it is too large Load Diff

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) 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;
if(count($submanage)) { if (dbm::is_result($submanage)) {
foreach($submanage as $m) { foreach ($submanage as $m) {
if($identity == $m['mid']) { if ($identity == $m['mid']) {
$limited_id = $m['mid']; $limited_id = $m['mid'];
break; break;
} }
} }
} }
if($limited_id) { if ($limited_id) {
$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);
@ -113,26 +117,32 @@ function manage_content(App $a) {
dbesc($id['uid']) 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; $notifications = 0;
$r = q("SELECT DISTINCT(`parent`) FROM `notify` WHERE `uid` = %d AND NOT `seen` AND NOT (`type` IN (%d, %d))", $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)); intval($id['uid']), intval(NOTIFY_INTRO), intval(NOTIFY_MAIL));
if ($r)
if (dbm::is_result($r)) {
$notifications = sizeof($r); $notifications = sizeof($r);
}
$r = q("SELECT DISTINCT(`convid`) FROM `mail` WHERE `uid` = %d AND NOT `seen`", $r = q("SELECT DISTINCT(`convid`) FROM `mail` WHERE `uid` = %d AND NOT `seen`",
intval($id['uid'])); intval($id['uid']));
if ($r)
if (dbm::is_result($r)) {
$notifications = $notifications + sizeof($r); $notifications = $notifications + sizeof($r);
}
$r = q("SELECT COUNT(*) AS `introductions` FROM `intro` WHERE NOT `blocked` AND NOT `ignore` AND `uid` = %d", $r = q("SELECT COUNT(*) AS `introductions` FROM `intro` WHERE NOT `blocked` AND NOT `ignore` AND `uid` = %d",
intval($id['uid'])); intval($id['uid']));
if ($r)
if (dbm::is_result($r)) {
$notifications = $notifications + $r[0]["introductions"]; $notifications = $notifications + $r[0]["introductions"];
}
$identities[$key]['notifications'] = $notifications; $identities[$key]['notifications'] = $notifications;
} }

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -10,7 +10,7 @@ function profiles_init(App $a) {
return; 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", $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d AND `is-default` = 0 LIMIT 1",
intval($a->argv[2]), intval($a->argv[2]),
intval(local_user()) intval(local_user())
@ -34,24 +34,22 @@ function profiles_init(App $a) {
intval($a->argv[2]), intval($a->argv[2]),
intval(local_user()) intval(local_user())
); );
if($r) if (dbm::is_result($r)) {
info(t('Profile deleted.').EOL); info(t('Profile deleted.').EOL);
}
goaway('profiles'); goaway('profiles');
return; // NOTREACHED 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'); check_form_security_token_redirectOnErr('/profiles', 'profile_new', 't');
$r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d", $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d",
intval(local_user())); intval(local_user()));
$num_profiles = count($r0);
$num_profiles = (dbm::is_result($r0) ? count($r0) : 0);
$name = t('Profile-') . ($num_profiles + 1); $name = t('Profile-') . ($num_profiles + 1);
@ -73,19 +71,21 @@ function profiles_init(App $a) {
); );
info( t('New profile created.') . EOL); info( t('New profile created.') . EOL);
if(count($r3) == 1) if (dbm::is_result($r3) && count($r3) == 1) {
goaway('profiles/'.$r3[0]['id']); goaway('profiles/' . $r3[0]['id']);
}
goaway('profiles'); 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'); check_form_security_token_redirectOnErr('/profiles', 'profile_clone', 't');
$r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d", $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d",
intval(local_user())); intval(local_user()));
$num_profiles = count($r0);
$num_profiles = (dbm::is_result($r0) ? count($r0) : 0);
$name = t('Profile-') . ($num_profiles + 1); $name = t('Profile-') . ($num_profiles + 1);
$r1 = q("SELECT * FROM `profile` WHERE `uid` = %d AND `id` = %d LIMIT 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) dbesc($name)
); );
info( t('New profile created.') . EOL); 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/'.$r3[0]['id']);
}
goaway('profiles'); 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", $r = q("SELECT id FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($a->argv[1]), intval($a->argv[1]),
intval(local_user()) intval(local_user())
@ -136,7 +137,7 @@ function profiles_init(App $a) {
return; 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) { function profile_clean_keywords($keywords) {
$keywords = str_replace(","," ",$keywords); $keywords = str_replace(",", " ", $keywords);
$keywords = explode(" ", $keywords); $keywords = explode(" ", $keywords);
$cleaned = array(); $cleaned = array();
foreach ($keywords as $keyword) { foreach ($keywords as $keyword) {
$keyword = trim(strtolower($keyword)); $keyword = trim(strtolower($keyword));
$keyword = trim($keyword, "#"); $keyword = trim($keyword, "#");
if ($keyword != "") if ($keyword != "") {
$cleaned[] = $keyword; $cleaned[] = $keyword;
}
} }
$keywords = implode(", ", $cleaned); $keywords = implode(", ", $cleaned);
@ -171,12 +173,12 @@ function profiles_post(App $a) {
call_hooks('profile_post', $_POST); 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", $orig = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($a->argv[1]), intval($a->argv[1]),
intval(local_user()) intval(local_user())
); );
if(! count($orig)) { if (! dbm::is_result($orig)) {
notice( t('Profile not found.') . EOL); notice( t('Profile not found.') . EOL);
return; return;
} }
@ -186,38 +188,40 @@ function profiles_post(App $a) {
$is_default = (($orig[0]['is-default']) ? 1 : 0); $is_default = (($orig[0]['is-default']) ? 1 : 0);
$profile_name = notags(trim($_POST['profile_name'])); $profile_name = notags(trim($_POST['profile_name']));
if(! strlen($profile_name)) { if (! strlen($profile_name)) {
notice( t('Profile Name is required.') . EOL); notice( t('Profile Name is required.') . EOL);
return; return;
} }
$dob = $_POST['dob'] ? escape_tags(trim($_POST['dob'])) : '0000-00-00'; // FIXME: Needs to be validated? $dob = $_POST['dob'] ? escape_tags(trim($_POST['dob'])) : '0000-00-00'; // FIXME: Needs to be validated?
$y = substr($dob,0,4); $y = substr($dob, 0, 4);
if((! ctype_digit($y)) || ($y < 1900)) if ((! ctype_digit($y)) || ($y < 1900)) {
$ignore_year = true; $ignore_year = true;
else } else {
$ignore_year = false; $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; $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')); $dob = datetime_convert('UTC', 'UTC', (($ignore_year) ? '1900-' . $dob : $dob), (($ignore_year) ? 'm-d' : 'Y-m-d'));
if($ignore_year)
if ($ignore_year) {
$dob = '0000-' . $dob; $dob = '0000-' . $dob;
}
} }
$name = notags(trim($_POST['name'])); $name = notags(trim($_POST['name']));
if(! strlen($name)) { if (! strlen($name)) {
$name = '[No Name]'; $name = '[No Name]';
} }
if($orig[0]['name'] != $name) if ($orig[0]['name'] != $name) {
$namechanged = true; $namechanged = true;
}
$pdesc = notags(trim($_POST['pdesc'])); $pdesc = notags(trim($_POST['pdesc']));
$gender = notags(trim($_POST['gender'])); $gender = notags(trim($_POST['gender']));
@ -233,54 +237,42 @@ function profiles_post(App $a) {
$with = ((x($_POST,'with')) ? notags(trim($_POST['with'])) : ''); $with = ((x($_POST,'with')) ? notags(trim($_POST['with'])) : '');
if(! strlen($howlong)) { if (! strlen($howlong)) {
$howlong = NULL_DATE; $howlong = NULL_DATE;
} else { } 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 // linkify the relationship target if applicable
$withchanged = false; $withchanged = false;
if(strlen($with)) { if (strlen($with)) {
if($with != strip_tags($orig[0]['with'])) { if ($with != strip_tags($orig[0]['with'])) {
$withchanged = true; $withchanged = true;
$prf = ''; $prf = '';
$lookup = $with; $lookup = $with;
if(strpos($lookup,'@') === 0) if (strpos($lookup, '@') === 0) {
$lookup = substr($lookup,1); $lookup = substr($lookup, 1);
}
$lookup = str_replace('_',' ', $lookup); $lookup = str_replace('_',' ', $lookup);
if(strpos($lookup,'@') || (strpos($lookup,'http://'))) { if (strpos($lookup, '@') || (strpos($lookup, 'http://'))) {
$newname = $lookup; $newname = $lookup;
$links = @Probe::lrdd($lookup); $links = @Probe::lrdd($lookup);
if(count($links)) { if (count($links)) {
foreach($links as $link) { foreach ($links as $link) {
if($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page') { if ($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page') {
$prf = $link['@attributes']['href']; $prf = $link['@attributes']['href'];
} }
} }
} }
} } else {
else {
$newname = $lookup; $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", $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
dbesc($newname), dbesc($newname),
intval(local_user()) intval(local_user())
); );
if(! $r) { if (! dbm::is_result($r)) {
$r = q("SELECT * FROM `contact` WHERE `nick` = '%s' AND `uid` = %d LIMIT 1", $r = q("SELECT * FROM `contact` WHERE `nick` = '%s' AND `uid` = %d LIMIT 1",
dbesc($lookup), dbesc($lookup),
intval(local_user()) intval(local_user())
@ -292,16 +284,18 @@ function profiles_post(App $a) {
} }
} }
if($prf) { if ($prf) {
$with = str_replace($lookup,'<a href="' . $prf . '">' . $newname . '</a>', $with); $with = str_replace($lookup, '<a href="' . $prf . '">' . $newname . '</a>', $with);
if(strpos($with,'@') === 0) if (strpos($with, '@') === 0) {
$with = substr($with,1); $with = substr($with, 1);
}
} }
} } else {
else
$with = $orig[0]['with']; $with = $orig[0]['with'];
}
} }
/// @TODO Not flexible enough for later expansion, let's have more OOP here
$sexual = notags(trim($_POST['sexual'])); $sexual = notags(trim($_POST['sexual']));
$xmpp = notags(trim($_POST['xmpp'])); $xmpp = notags(trim($_POST['xmpp']));
$homepage = notags(trim($_POST['homepage'])); $homepage = notags(trim($_POST['homepage']));
@ -329,65 +323,65 @@ function profiles_post(App $a) {
$hide_friends = (($_POST['hide-friends'] == 1) ? 1: 0); $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(); $changes = array();
$value = ''; $value = '';
if($is_default) { if ($is_default) {
if($marital != $orig[0]['marital']) { if ($marital != $orig[0]['marital']) {
$changes[] = '[color=#ff0000]&hearts;[/color] ' . t('Marital Status'); $changes[] = '[color=#ff0000]&hearts;[/color] ' . t('Marital Status');
$value = $marital; $value = $marital;
} }
if($withchanged) { if ($withchanged) {
$changes[] = '[color=#ff0000]&hearts;[/color] ' . t('Romantic Partner'); $changes[] = '[color=#ff0000]&hearts;[/color] ' . t('Romantic Partner');
$value = strip_tags($with); $value = strip_tags($with);
} }
if($likes != $orig[0]['likes']) { if ($likes != $orig[0]['likes']) {
$changes[] = t('Likes'); $changes[] = t('Likes');
$value = $likes; $value = $likes;
} }
if($dislikes != $orig[0]['dislikes']) { if ($dislikes != $orig[0]['dislikes']) {
$changes[] = t('Dislikes'); $changes[] = t('Dislikes');
$value = $dislikes; $value = $dislikes;
} }
if($work != $orig[0]['work']) { if ($work != $orig[0]['work']) {
$changes[] = t('Work/Employment'); $changes[] = t('Work/Employment');
} }
if($religion != $orig[0]['religion']) { if ($religion != $orig[0]['religion']) {
$changes[] = t('Religion'); $changes[] = t('Religion');
$value = $religion; $value = $religion;
} }
if($politic != $orig[0]['politic']) { if ($politic != $orig[0]['politic']) {
$changes[] = t('Political Views'); $changes[] = t('Political Views');
$value = $politic; $value = $politic;
} }
if($gender != $orig[0]['gender']) { if ($gender != $orig[0]['gender']) {
$changes[] = t('Gender'); $changes[] = t('Gender');
$value = $gender; $value = $gender;
} }
if($sexual != $orig[0]['sexual']) { if ($sexual != $orig[0]['sexual']) {
$changes[] = t('Sexual Preference'); $changes[] = t('Sexual Preference');
$value = $sexual; $value = $sexual;
} }
if($xmpp != $orig[0]['xmpp']) { if ($xmpp != $orig[0]['xmpp']) {
$changes[] = t('XMPP'); $changes[] = t('XMPP');
$value = $xmpp; $value = $xmpp;
} }
if($homepage != $orig[0]['homepage']) { if ($homepage != $orig[0]['homepage']) {
$changes[] = t('Homepage'); $changes[] = t('Homepage');
$value = $homepage; $value = $homepage;
} }
if($interest != $orig[0]['interest']) { if ($interest != $orig[0]['interest']) {
$changes[] = t('Interests'); $changes[] = t('Interests');
$value = $interest; $value = $interest;
} }
if($address != $orig[0]['address']) { if ($address != $orig[0]['address']) {
$changes[] = t('Address'); $changes[] = t('Address');
// New address not sent in notifications, potential privacy issues // New address not sent in notifications, potential privacy issues
// in case this leaks to unintended recipients. Yes, it's in the public // 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. // 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']) { || $country_name != $orig[0]['country-name']) {
$changes[] = t('Location'); $changes[] = t('Location');
$comma1 = ((($locality) && ($region || $country_name)) ? ', ' : ' '); $comma1 = ((($locality) && ($region || $country_name)) ? ', ' : ' ');
@ -473,11 +467,12 @@ function profiles_post(App $a) {
intval(local_user()) intval(local_user())
); );
if($r) if ($r) {
info( t('Profile updated.') . EOL); 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", $r = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `self` = 1 AND `uid` = %d",
dbesc($name), dbesc($name),
dbesc(datetime_convert()), 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)); $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", 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 // Update global directory in background
$url = $_SESSION['my_url']; $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); proc_run(PRIORITY_LOW, "include/directory.php", $url);
} }
@ -519,14 +514,17 @@ function profiles_post(App $a) {
function profile_activity($changed, $value) { function profile_activity($changed, $value) {
$a = get_app(); $a = get_app();
if(! local_user() || ! is_array($changed) || ! count($changed)) if (! local_user() || ! is_array($changed) || ! count($changed)) {
return; return;
}
if($a->user['hidewall'] || get_config('system','block_public')) if ($a->user['hidewall'] || get_config('system', 'block_public')) {
return; return;
}
if(! get_pconfig(local_user(),'system','post_profilechange')) if (! get_pconfig(local_user(), 'system', 'post_profilechange')) {
return; return;
}
require_once('include/items.php'); require_once('include/items.php');
@ -534,8 +532,9 @@ function profile_activity($changed, $value) {
intval(local_user()) intval(local_user())
); );
if(! count($self)) if (! dbm::is_result($self)) {
return; return;
}
$arr = array(); $arr = array();
@ -559,12 +558,13 @@ function profile_activity($changed, $value) {
$changes = ''; $changes = '';
$t = count($changed); $t = count($changed);
$z = 0; $z = 0;
foreach($changed as $ch) { foreach ($changed as $ch) {
if(strlen($changes)) { if (strlen($changes)) {
if ($z == ($t - 1)) if ($z == ($t - 1)) {
$changes .= t(' and '); $changes .= t(' and ');
else } else {
$changes .= ', '; $changes .= ', ';
}
} }
$z ++; $z ++;
$changes .= $ch; $changes .= $ch;
@ -572,12 +572,12 @@ function profile_activity($changed, $value) {
$prof = '[url=' . $self[0]['url'] . '?tab=profile' . ']' . t('public profile') . '[/url]'; $prof = '[url=' . $self[0]['url'] . '?tab=profile' . ']' . t('public profile') . '[/url]';
if($t == 1 && strlen($value)) { if ($t == 1 && strlen($value)) {
$message = sprintf( t('%1$s changed %2$s to &ldquo;%3$s&rdquo;'), $A, $changes, $value); $message = sprintf( t('%1$s changed %2$s to &ldquo;%3$s&rdquo;'), $A, $changes, $value);
$message .= "\n\n" . sprintf( t(' - Visit %1$s\'s %2$s'), $A, $prof); $message .= "\n\n" . sprintf( t(' - Visit %1$s\'s %2$s'), $A, $prof);
} } else {
else
$message = sprintf( t('%1$s has an updated %2$s, changing %3$s.'), $A, $prof, $changes); $message = sprintf( t('%1$s has an updated %2$s, changing %3$s.'), $A, $prof, $changes);
}
$arr['body'] = $message; $arr['body'] = $message;
@ -610,7 +610,7 @@ function profiles_content(App $a) {
$o = ''; $o = '';
if(($a->argc > 1) && (intval($a->argv[1]))) { if (($a->argc > 1) && (intval($a->argv[1]))) {
$r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($a->argv[1]), intval($a->argv[1]),
intval(local_user()) intval(local_user())
@ -649,15 +649,16 @@ function profiles_content(App $a) {
$personal_account = !(in_array($a->user["page-flags"], $personal_account = !(in_array($a->user["page-flags"],
array(PAGE_COMMUNITY, PAGE_PRVGROUP))); array(PAGE_COMMUNITY, PAGE_PRVGROUP)));
$detailled_profile = (get_pconfig(local_user(),'system','detailled_profile') AND $personal_account); $detailled_profile = (get_pconfig(local_user(), 'system', 'detailled_profile') AND $personal_account);
$f = get_config('system','birthday_input_format'); $f = get_config('system', 'birthday_input_format');
if(! $f) if (! $f) {
$f = 'ymd'; $f = 'ymd';
}
$is_default = (($r[0]['is-default']) ? 1 : 0); $is_default = (($r[0]['is-default']) ? 1 : 0);
$tpl = get_markup_template("profile_edit.tpl"); $tpl = get_markup_template("profile_edit.tpl");
$o .= replace_macros($tpl,array( $o .= replace_macros($tpl, array(
'$personal_account' => $personal_account, '$personal_account' => $personal_account,
'$detailled_profile' => $detailled_profile, '$detailled_profile' => $detailled_profile,
@ -666,13 +667,13 @@ function profiles_content(App $a) {
t('Show more profile fields:'), //Label t('Show more profile fields:'), //Label
$detailled_profile, //Value $detailled_profile, //Value
'', //Help string '', //Help string
array(t('No'),t('Yes')) //Off - On strings array(t('No'), t('Yes')) //Off - On strings
), ),
'$multi_profiles' => feature_enabled(local_user(),'multi_profiles'), '$multi_profiles' => feature_enabled(local_user(), 'multi_profiles'),
'$form_security_token' => get_form_security_token("profile_edit"), '$form_security_token' => get_form_security_token("profile_edit"),
'$form_security_token_photo' => get_form_security_token("profile_photo"), '$form_security_token_photo' => get_form_security_token("profile_photo"),
'$profile_clone_link' => ((feature_enabled(local_user(),'multi_profiles')) ? 'profiles/clone/' . $r[0]['id'] . '?t=' . get_form_security_token("profile_clone") : ""), '$profile_clone_link' => ((feature_enabled(local_user(), 'multi_profiles')) ? 'profiles/clone/' . $r[0]['id'] . '?t=' . get_form_security_token("profile_clone") : ""),
'$profile_drop_link' => 'profiles/drop/' . $r[0]['id'] . '?t=' . get_form_security_token("profile_drop"), '$profile_drop_link' => 'profiles/drop/' . $r[0]['id'] . '?t=' . get_form_security_token("profile_drop"),
'$profile_action' => t('Profile Actions'), '$profile_action' => t('Profile Actions'),
@ -748,25 +749,22 @@ function profiles_content(App $a) {
call_hooks('profile_edit', $arr); call_hooks('profile_edit', $arr);
return $o; return $o;
} } else {
//Profiles list. // If we don't support multi profiles, don't display this list.
else { if (!feature_enabled(local_user(), 'multi_profiles')) {
$r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default`=1",
//If we don't support multi profiles, don't display this list.
if(!feature_enabled(local_user(),'multi_profiles')){
$r = q(
"SELECT * FROM `profile` WHERE `uid` = %d AND `is-default`=1",
local_user() local_user()
); );
if (dbm::is_result($r)){ if (dbm::is_result($r)) {
//Go to the default profile. //Go to the default profile.
goaway('profiles/'.$r[0]['id']); goaway('profiles/' . $r[0]['id']);
} }
} }
$r = q("SELECT * FROM `profile` WHERE `uid` = %d", $r = q("SELECT * FROM `profile` WHERE `uid` = %d",
local_user()); local_user());
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
$tpl = get_markup_template('profile_entry.tpl'); $tpl = get_markup_template('profile_entry.tpl');

View File

@ -15,7 +15,8 @@
*/ */
if(($_SERVER["argc"] > 1) && isset($_SERVER["argv"][1])) if (($_SERVER["argc"] > 1) && isset($_SERVER["argv"][1])) {
echo $_SERVER["argv"][1]; echo $_SERVER["argv"][1];
else } else {
echo ''; echo '';
}

View File

@ -148,7 +148,7 @@ function update_1014() {
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach ($r as $rr) { foreach ($r as $rr) {
$ph = new Photo($rr['data']); $ph = new Photo($rr['data']);
if($ph->is_valid()) { if ($ph->is_valid()) {
$ph->scaleImage(48); $ph->scaleImage(48);
$ph->store($rr['uid'],$rr['contact-id'],$rr['resource-id'],$rr['filename'],$rr['album'],6,(($rr['profile']) ? 1 : 0)); $ph->store($rr['uid'],$rr['contact-id'],$rr['resource-id'],$rr['filename'],$rr['album'],6,(($rr['profile']) ? 1 : 0));
} }
@ -308,9 +308,9 @@ function update_1030() {
function update_1031() { function update_1031() {
// Repair any bad links that slipped into the item table // Repair any bad links that slipped into the item table
$r = q("SELECT `id`, `object` FROM `item` WHERE `object` != '' "); $r = q("SELECT `id`, `object` FROM `item` WHERE `object` != '' ");
if($r && dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach ($r as $rr) { foreach ($r as $rr) {
if(strstr($rr['object'],'type=&quot;http')) { if (strstr($rr['object'],'type=&quot;http')) {
q("UPDATE `item` SET `object` = '%s' WHERE `id` = %d", q("UPDATE `item` SET `object` = '%s' WHERE `id` = %d",
dbesc(str_replace('type=&quot;http','href=&quot;http',$rr['object'])), dbesc(str_replace('type=&quot;http','href=&quot;http',$rr['object'])),
intval($rr['id']) intval($rr['id'])
@ -326,22 +326,23 @@ function update_1032() {
function update_1033() { function update_1033() {
q("CREATE TABLE IF NOT EXISTS `cache` ( q("CREATE TABLE IF NOT EXISTS `cache` (
`k` CHAR( 255 ) NOT NULL PRIMARY KEY , `k` CHAR( 255 ) NOT NULL PRIMARY KEY ,
`v` TEXT NOT NULL, `v` TEXT NOT NULL,
`updated` DATETIME NOT NULL `updated` DATETIME NOT NULL
) ENGINE = MYISAM DEFAULT CHARSET=utf8 "); ) DEFAULT CHARSET=utf8 ");
} }
function update_1034() { function update_1034() {
// If you have any of these parent-less posts they can cause problems, and /*
// we need to delete them. You can't see them anyway. * If you have any of these parent-less posts they can cause problems, and
// Legitimate items will usually get re-created on the next * we need to delete them. You can't see them anyway.
// pull from the hub. * Legitimate items will usually get re-created on the next
// But don't get rid of a post that may have just come in * pull from the hub.
// and may not yet have the parent id set. * But don't get rid of a post that may have just come in
* and may not yet have the parent id set.
*/
q("DELETE FROM `item` WHERE `parent` = 0 AND `created` < UTC_TIMESTAMP() - INTERVAL 2 MINUTE"); q("DELETE FROM `item` WHERE `parent` = 0 AND `created` < UTC_TIMESTAMP() - INTERVAL 2 MINUTE");
} }
@ -1671,7 +1672,7 @@ function update_1190() {
$plugins = get_config('system','addon'); $plugins = get_config('system','addon');
$plugins_arr = array(); $plugins_arr = array();
if($plugins) { if ($plugins) {
$plugins_arr = explode(",",str_replace(" ", "",$plugins)); $plugins_arr = explode(",",str_replace(" ", "",$plugins));
$idx = array_search($plugin, $plugins_arr); $idx = array_search($plugin, $plugins_arr);

View File

@ -12,117 +12,140 @@ function po2php_run(&$argv, &$argc) {
$pofile = $argv[1]; $pofile = $argv[1];
$outfile = dirname($pofile)."/strings.php"; $outfile = dirname($pofile)."/strings.php";
if(strstr($outfile,'util')) if (strstr($outfile, 'util')) {
$lang = 'en'; $lang = 'en';
else } else {
$lang = str_replace('-','_',basename(dirname($pofile))); $lang = str_replace('-','_',basename(dirname($pofile)));
}
if (!file_exists($pofile)) {
if (!file_exists($pofile)){
print "Unable to find '$pofile'\n"; print "Unable to find '$pofile'\n";
return; return;
} }
print "Out to '$outfile'\n"; print "Out to '$outfile'\n";
$out="<?php\n\n"; $out = "<?php\n\n";
$infile = file($pofile); $infile = file($pofile);
$k=""; $k = "";
$v=""; $v = "";
$arr = False; $arr = false;
$ink = False; $ink = false;
$inv = False; $inv = false;
$escape_s_exp = '|[^\\\\]\$[a-z]|'; $escape_s_exp = '|[^\\\\]\$[a-z]|';
function escape_s($match){ function escape_s($match) {
return str_replace('$','\$',$match[0]); return str_replace('$','\$',$match[0]);
} }
foreach ($infile as $l) { foreach ($infile as $l) {
$l = str_replace('\"', DQ_ESCAPE, $l); $l = str_replace('\"', DQ_ESCAPE, $l);
$len = strlen($l); $len = strlen($l);
if ($l[0]=="#") $l=""; if ($l[0] == "#") {
if (substr($l,0,15)=='"Plural-Forms: '){ $l = "";
$match=Array(); }
if (substr($l, 0, 15) == '"Plural-Forms: ') {
$match = array();
preg_match("|nplurals=([0-9]*); *plural=(.*)[;\\\\]|", $l, $match); preg_match("|nplurals=([0-9]*); *plural=(.*)[;\\\\]|", $l, $match);
$cond = str_replace('n','$n',$match[2]); $cond = str_replace('n', '$n', $match[2]);
// define plural select function if not already defined // define plural select function if not already defined
$fnname = 'string_plural_select_' . $lang; $fnname = 'string_plural_select_' . $lang;
$out .= 'if(! function_exists("'.$fnname.'")) {'."\n"; $out .= 'if(! function_exists("' . $fnname . '")) {' . "\n";
$out .= 'function '. $fnname . '($n){'."\n"; $out .= 'function '. $fnname . '($n){' . "\n";
$out .= ' return '.$cond.';'."\n"; $out .= ' return ' . $cond . ';' . "\n";
$out .= '}}'."\n"; $out .= '}}' . "\n";
} }
if ($k != "" && substr($l, 0, 7) == "msgstr ") {
if ($ink) {
$ink = false;
$out .= '$a->strings["' . $k . '"] = ';
}
if ($inv) {
$inv = false;
$out .= '"' . $v . '"';
}
$v = substr($l, 8, $len - 10);
$v = preg_replace_callback($escape_s_exp, 'escape_s', $v);
if ($k!="" && substr($l,0,7)=="msgstr "){ $inv = true;
if ($ink) { $ink = False; $out .= '$a->strings["'.$k.'"] = '; }
if ($inv) { $inv = False; $out .= '"'.$v.'"'; }
$v = substr($l,8,$len-10);
$v = preg_replace_callback($escape_s_exp,'escape_s',$v);
$inv = True;
//$out .= $v; //$out .= $v;
} }
if ($k!="" && substr($l,0,7)=="msgstr["){ if ($k != "" && substr($l, 0, 7) == "msgstr[") {
if ($ink) { $ink = False; $out .= '$a->strings["'.$k.'"] = '; } if ($ink) {
if ($inv) { $inv = False; $out .= '"'.$v.'"'; } $ink = false;
$out .= '$a->strings["' . $k . '"] = ';
}
if ($inv) {
$inv = false;
$out .= '"' . $v . '"';
}
if (!$arr) { if (!$arr) {
$arr=True; $arr=True;
$out .= "array(\n"; $out .= "array(\n";
} }
$match=Array(); $match = array();
preg_match("|\[([0-9]*)\] (.*)|", $l, $match); preg_match("|\[([0-9]*)\] (.*)|", $l, $match);
$out .= "\t". $out .= "\t"
preg_replace_callback($escape_s_exp,'escape_s',$match[1]) . preg_replace_callback($escape_s_exp, 'escape_s', $match[1])
." => " . " => "
.preg_replace_callback($escape_s_exp,'escape_s',$match[2]) .",\n"; . preg_replace_callback($escape_s_exp, 'escape_s', $match[2])
. ",\n";
} }
if (substr($l,0,6)=="msgid_") { $ink = False; $out .= '$a->strings["'.$k.'"] = '; }; if (substr($l, 0, 6) == "msgid_") {
$ink = false;
$out .= '$a->strings["' . $k . '"] = ';
}
if ($ink) { if ($ink) {
$k .= trim($l,"\"\r\n"); $k .= trim($l, "\"\r\n");
$k = preg_replace_callback($escape_s_exp,'escape_s',$k); $k = preg_replace_callback($escape_s_exp, 'escape_s', $k);
//$out .= '$a->strings['.$k.'] = '; //$out .= '$a->strings['.$k.'] = ';
} }
if (substr($l,0,6)=="msgid "){ if (substr($l, 0, 6) == "msgid ") {
if ($inv) { $inv = False; $out .= '"'.$v.'"'; } if ($inv) {
if ($k!="") $out .= $arr?");\n":";\n"; $inv = false;
$arr=False; $out .= '"' . $v . '"';
$k = str_replace("msgid ","",$l); }
if ($k != '""' ) { if ($k != "") {
$k = trim($k,"\"\r\n"); $out .= ($arr) ? ");\n" : ";\n";
}
$arr = false;
$k = str_replace("msgid ", "", $l);
if ($k != '""') {
$k = trim($k, "\"\r\n");
} else { } else {
$k = ""; $k = "";
} }
$k = preg_replace_callback($escape_s_exp,'escape_s',$k); $k = preg_replace_callback($escape_s_exp, 'escape_s', $k);
$ink = True; $ink = true;
} }
if ($inv && substr($l,0,6)!="msgstr") { if ($inv && substr($l, 0, 6) != "msgstr") {
$v .= trim($l,"\"\r\n"); $v .= trim($l, "\"\r\n");
$v = preg_replace_callback($escape_s_exp,'escape_s',$v); $v = preg_replace_callback($escape_s_exp, 'escape_s', $v);
//$out .= '$a->strings['.$k.'] = '; //$out .= '$a->strings['.$k.'] = ';
} }
} }
if ($inv) { $inv = False; $out .= '"'.$v.'"'; } if ($inv) {
if ($k!="") $out .= $arr?");\n":";\n"; $inv = false;
$out .= '"' . $v . '"';
}
if ($k != "") {
$out .= ($arr ? ");\n" : ";\n");
}
$out = str_replace(DQ_ESCAPE, '\"', $out); $out = str_replace(DQ_ESCAPE, '\"', $out);
file_put_contents($outfile, $out); file_put_contents($outfile, $out);
} }
if (array_search(__file__,get_included_files())===0){ if (array_search(__FILE__, get_included_files()) === 0) {
po2php_run($_SERVER["argv"],$_SERVER["argc"]); po2php_run($_SERVER["argv"],$_SERVER["argc"]);
} }

View File

@ -9,9 +9,9 @@
* Description: "Vier" is a very compact and modern theme. It uses the font awesome font library: http://fortawesome.github.com/Font-Awesome/ * Description: "Vier" is a very compact and modern theme. It uses the font awesome font library: http://fortawesome.github.com/Font-Awesome/
*/ */
require_once("include/plugin.php"); require_once "include/plugin.php";
require_once("include/socgraph.php"); require_once "include/socgraph.php";
require_once("mod/proxy.php"); require_once "mod/proxy.php";
function vier_init(App $a) { function vier_init(App $a) {
@ -101,8 +101,9 @@ EOT;
} }
// Hide the left menu bar // Hide the left menu bar
/// @TODO maybe move this static array out where it should belong?
if (($a->page['aside'] == "") AND in_array($a->argv[0], array("community", "events", "help", "manage", "notifications", if (($a->page['aside'] == "") AND in_array($a->argv[0], array("community", "events", "help", "manage", "notifications",
"probe", "webfinger", "login", "invite", "credits"))) { "probe", "webfinger", "login", "invite", "credits"))) {
$a->page['htmlhead'] .= "<link rel='stylesheet' href='view/theme/vier/hide.css' />"; $a->page['htmlhead'] .= "<link rel='stylesheet' href='view/theme/vier/hide.css' />";
} }
} }
@ -110,13 +111,15 @@ EOT;
function get_vier_config($key, $default = false, $admin = false) { function get_vier_config($key, $default = false, $admin = false) {
if (local_user() AND !$admin) { if (local_user() AND !$admin) {
$result = get_pconfig(local_user(), "vier", $key); $result = get_pconfig(local_user(), "vier", $key);
if ($result !== false) if ($result !== false) {
return $result; return $result;
}
} }
$result = get_config("vier", $key); $result = get_config("vier", $key);
if ($result !== false) if ($result !== false) {
return $result; return $result;
}
return $default; return $default;
} }
@ -131,7 +134,7 @@ function vier_community_info() {
$show_friends = get_vier_config("show_friends", 1); $show_friends = get_vier_config("show_friends", 1);
$show_lastusers = get_vier_config("show_lastusers", 1); $show_lastusers = get_vier_config("show_lastusers", 1);
//get_baseurl // get_baseurl
$url = App::get_baseurl($ssl_state); $url = App::get_baseurl($ssl_state);
$aside['$url'] = $url; $aside['$url'] = $url;
@ -161,7 +164,7 @@ function vier_community_info() {
// last 9 users // last 9 users
if ($show_lastusers) { if ($show_lastusers) {
$publish = (get_config('system','publish_all') ? '' : " AND `publish` = 1 "); $publish = (get_config('system', 'publish_all') ? '' : " AND `publish` = 1 ");
$order = " ORDER BY `register_date` DESC "; $order = " ORDER BY `register_date` DESC ";
$tpl = get_markup_template('ch_directory_item.tpl'); $tpl = get_markup_template('ch_directory_item.tpl');
@ -191,12 +194,12 @@ function vier_community_info() {
//right_aside FIND FRIENDS //right_aside FIND FRIENDS
if ($show_friends AND local_user()) { if ($show_friends AND local_user()) {
$nv = array(); $nv = array();
$nv['title'] = Array("", t('Find Friends'), "", ""); $nv['title'] = array("", t('Find Friends'), "", "");
$nv['directory'] = Array('directory', t('Local Directory'), "", ""); $nv['directory'] = array('directory', t('Local Directory'), "", "");
$nv['global_directory'] = Array(get_server(), t('Global Directory'), "", ""); $nv['global_directory'] = Array(get_server(), t('Global Directory'), "", "");
$nv['match'] = Array('match', t('Similar Interests'), "", ""); $nv['match'] = array('match', t('Similar Interests'), "", "");
$nv['suggest'] = Array('suggest', t('Friend Suggestions'), "", ""); $nv['suggest'] = array('suggest', t('Friend Suggestions'), "", "");
$nv['invite'] = Array('invite', t('Invite Friends'), "", ""); $nv['invite'] = array('invite', t('Invite Friends'), "", "");
$nv['search'] = '<form name="simple_bar" method="get" action="dirfind"> $nv['search'] = '<form name="simple_bar" method="get" action="dirfind">
<span class="sbox_l"></span> <span class="sbox_l"></span>
@ -211,10 +214,11 @@ function vier_community_info() {
//Community_Pages at right_aside //Community_Pages at right_aside
if ($show_pages AND local_user()) { if ($show_pages AND local_user()) {
require_once('include/ForumManager.php'); require_once 'include/ForumManager.php';
if (x($_GET['cid']) && intval($_GET['cid']) != 0) if (x($_GET, 'cid') && intval($_GET['cid']) != 0) {
$cid = $_GET['cid']; $cid = $_GET['cid'];
}
//sort by last updated item //sort by last updated item
$lastitem = true; $lastitem = true;
@ -227,18 +231,18 @@ function vier_community_info() {
$id = 0; $id = 0;
foreach($contacts as $contact) { foreach ($contacts as $contact) {
$selected = (($cid == $contact['id']) ? ' forum-selected' : ''); $selected = (($cid == $contact['id']) ? ' forum-selected' : '');
$entry = array( $entry = array(
'url' => 'network?f=&cid=' . $contact['id'], 'url' => 'network?f=&cid=' . $contact['id'],
'external_url' => 'redir/' . $contact['id'], 'external_url' => 'redir/' . $contact['id'],
'name' => $contact['name'], 'name' => $contact['name'],
'cid' => $contact['id'], 'cid' => $contact['id'],
'selected' => $selected, 'selected' => $selected,
'micro' => App::remove_baseurl(proxy_url($contact['micro'], false, PROXY_SIZE_MICRO)), 'micro' => App::remove_baseurl(proxy_url($contact['micro'], false, PROXY_SIZE_MICRO)),
'id' => ++$id, 'id' => ++$id,
); );
$entries[] = $entry; $entries[] = $entry;
} }
@ -246,21 +250,21 @@ function vier_community_info() {
$tpl = get_markup_template('widget_forumlist_right.tpl'); $tpl = get_markup_template('widget_forumlist_right.tpl');
$page .= replace_macros($tpl,array( $page .= replace_macros($tpl, array(
'$title' => t('Forums'), '$title' => t('Forums'),
'$forums' => $entries, '$forums' => $entries,
'$link_desc' => t('External link to forum'), '$link_desc' => t('External link to forum'),
'$total' => $total, '$total' => $total,
'$visible_forums' => $visible_forums, '$visible_forums' => $visible_forums,
'$showmore' => t('show more'), '$showmore' => t('show more'),
)); ));
$aside['$page'] = $page; $aside['$page'] = $page;
} }
} }
//END Community Page // END Community Page
//helpers // helpers
if ($show_helpers) { if ($show_helpers) {
$r = array(); $r = array();
@ -283,14 +287,14 @@ function vier_community_info() {
foreach ($r AS $index => $helper) foreach ($r AS $index => $helper)
$r[$index]["url"] = zrl($helper["url"]); $r[$index]["url"] = zrl($helper["url"]);
$r[] = Array("url" => "help/Quick-Start-guide", "name" => t("Quick Start")); $r[] = array("url" => "help/Quick-Start-guide", "name" => t("Quick Start"));
$tpl = get_markup_template('ch_helpers.tpl'); $tpl = get_markup_template('ch_helpers.tpl');
if ($r) { if ($r) {
$helpers = array(); $helpers = array();
$helpers['title'] = Array("", t('Help'), "", ""); $helpers['title'] = array("", t('Help'), "", "");
$aside['$helpers_items'] = array(); $aside['$helpers_items'] = array();
@ -305,9 +309,9 @@ function vier_community_info() {
$aside['$helpers'] = $helpers; $aside['$helpers'] = $helpers;
} }
} }
//end helpers // end helpers
//connectable services // connectable services
if ($show_services) { if ($show_services) {
/// @TODO This whole thing is hard-coded, better rewrite to Intercepting Filter Pattern (future-todo) /// @TODO This whole thing is hard-coded, better rewrite to Intercepting Filter Pattern (future-todo)
@ -345,6 +349,7 @@ function vier_community_info() {
$r[] = array("photo" => "images/googleplus.png", "name" => "Google+"); $r[] = array("photo" => "images/googleplus.png", "name" => "Google+");
} }
/// @TODO old-lost code (and below)?
//if (plugin_enabled("ijpost")) { //if (plugin_enabled("ijpost")) {
// $r[] = array("photo" => "images/", "name" => ""); // $r[] = array("photo" => "images/", "name" => "");
//} //}
@ -382,7 +387,7 @@ function vier_community_info() {
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
$con_services = array(); $con_services = array();
$con_services['title'] = Array("", t('Connect Services'), "", ""); $con_services['title'] = array("", t('Connect Services'), "", "");
$aside['$con_services'] = $con_services; $aside['$con_services'] = $con_services;
foreach ($r as $rr) { foreach ($r as $rr) {