Merge remote-tracking branch 'upstream/develop' into develop

Also removed <<<<< as this interfers (a bit) with searching for merge conflicts
with a more simplier editor.

Signed-off-by: Roland Häder <roland@mxchange.org>

Conflicts:
	mod/ping.php
	view/lang/fr/messages.po
	view/lang/fr/strings.php
This commit is contained in:
Roland Häder 2016-12-13 09:59:43 +01:00
commit d489ba1510
1261 changed files with 66596 additions and 191430 deletions

View file

@ -269,34 +269,43 @@ function admin_page_federation(&$a) {
// off one % two of them are needed in the query
// Add more platforms if you like, when one returns 0 known nodes it is not
// displayed on the stats page.
$platforms = array('Friendica', 'Diaspora', '%%red%%', 'Hubzilla', 'GNU Social', 'StatusNet');
$platforms = array('Friendica', 'Diaspora', '%%red%%', 'Hubzilla', 'BlaBlaNet', 'GNU Social', 'StatusNet', 'Mastodon');
$colors = array('Friendica' => '#ffc018', // orange from the logo
'Diaspora' => '#a1a1a1', // logo is black and white, makes a gray
'Diaspora' => '#a1a1a1', // logo is black and white, makes a gray
'%%red%%' => '#c50001', // fire red from the logo
'Hubzilla' => '#43488a', // blue from the logo
'BlaBlaNet' => '#3B5998', // blue from the navbar at blablanet-dot-com
'GNU Social'=> '#a22430', // dark red from the logo
'StatusNet' => '#789240'); // the green from the logo (red and blue have already others
'StatusNet' => '#789240', // the green from the logo (red and blue have already others
'Mastodon' => '#1a9df9'); // blue from the Mastodon logo
$counts = array();
$total = 0;
foreach ($platforms as $p) {
// get a total count for the platform, the name and version of the
// highest version and the protocol tpe
$c = q('SELECT COUNT(*) AS `total`, `platform`, `network`, `version` FROM `gserver`
WHERE `platform` LIKE "%s" AND `last_contact` > `last_failure` AND `version` != ""
$c = qu('SELECT COUNT(*) AS `total`, `platform`, `network`, `version` FROM `gserver`
WHERE `platform` LIKE "%s" AND `last_contact` > `last_failure`
ORDER BY `version` ASC;', $p);
$total = $total + $c[0]['total'];
// what versions for that platform do we know at all?
// again only the active nodes
$v = q('SELECT COUNT(*) AS `total`, `version` FROM `gserver`
WHERE `last_contact` > `last_failure` AND `platform` LIKE "%s" AND `version` != ""
$v = qu('SELECT COUNT(*) AS `total`, `version` FROM `gserver`
WHERE `last_contact` > `last_failure` AND `platform` LIKE "%s"
GROUP BY `version`
ORDER BY `version`;', $p);
//
// clean up version numbers
//
// some platforms do not provide version information, add a unkown there
// to the version string for the displayed list.
foreach ($v as $key => $value) {
if ($v[$key]['version'] == '') {
$v[$key] = array('total'=>$v[$key]['total'], 'version'=>t('unknown'));
}
}
// in the DB the Diaspora versions have the format x.x.x.x-xx the last
// part (-xx) should be removed to clean up the versions from the "head
// commit" information and combined into a single entry for x.x.x.x
@ -419,6 +428,21 @@ function admin_page_queue(&$a) {
* @return string
*/
function admin_page_summary(&$a) {
global $db;
// are there MyISAM tables in the DB? If so, trigger a warning message
$r = q("SELECT `engine` FROM `information_schema`.`tables` WHERE `engine` = 'myisam' AND `table_schema` = '%s' LIMIT 1",
dbesc($db->database_name()));
$showwarning = false;
$warningtext = array();
if (dbm::is_result($r)) {
$showwarning = true;
$warningtext[] = sprintf(t('Your DB still runs with MyISAM tables. You should change the engine type to InnoDB. As Friendica will use InnoDB only features in the future, you should change this! See <a href="%s">here</a> for a guide that may be helpful converting the table engines. You may also use the <tt>convert_innodb.sql</tt> in the <tt>/util</tt> directory of your Friendica installation.<br />'), 'https://dev.mysql.com/doc/refman/5.7/en/converting-tables-to-innodb.html');
}
// MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
if ((version_compare($db->server_info(), '5.7.4') >= 0) AND
!(strpos($db->server_info(), 'MariaDB') !== false)) {
$warningtext[] = t('You are using a MySQL version which does not support all features that Friendica uses. You should consider switching to MariaDB.');
}
$r = q("SELECT `page-flags`, COUNT(`uid`) AS `count` FROM `user` GROUP BY `page-flags`");
$accounts = array(
array(t('Normal Account'), 0),
@ -434,17 +458,17 @@ function admin_page_summary(&$a) {
logger('accounts: '.print_r($accounts,true),LOGGER_DATA);
$r = q("SELECT COUNT(`id`) AS `count` FROM `register`");
$r = qu("SELECT COUNT(`id`) AS `count` FROM `register`");
$pending = $r[0]['count'];
$r = q("SELECT COUNT(*) AS `total` FROM `deliverq` WHERE 1");
$r = qu("SELECT COUNT(*) AS `total` FROM `deliverq` WHERE 1");
$deliverq = (($r) ? $r[0]['total'] : 0);
$r = q("SELECT COUNT(*) AS `total` FROM `queue` WHERE 1");
$r = qu("SELECT COUNT(*) AS `total` FROM `queue` WHERE 1");
$queue = (($r) ? $r[0]['total'] : 0);
if (get_config('system','worker')) {
$r = q("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE 1");
$r = qu("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE 1");
$workerqueue = (($r) ? $r[0]['total'] : 0);
} else {
$workerqueue = 0;
@ -460,6 +484,7 @@ function admin_page_summary(&$a) {
'$title' => t('Administration'),
'$page' => t('Summary'),
'$queues' => $queues,
'$workeractive' => get_config('system','worker'),
'$users' => array(t('Registered users'), $users),
'$accounts' => $accounts,
'$pending' => array(t('Pending registrations'), $pending),
@ -468,7 +493,9 @@ function admin_page_summary(&$a) {
'$platform' => FRIENDICA_PLATFORM,
'$codename' => FRIENDICA_CODENAME,
'$build' => get_config('system','build'),
'$plugins' => array(t('Active plugins'), $a->plugins)
'$plugins' => array(t('Active plugins'), $a->plugins),
'$showwarning' => $showwarning,
'$warningtext' => $warningtext
));
}
@ -642,6 +669,7 @@ function admin_page_site_post(&$a) {
$worker_queues = ((x($_POST,'worker_queues')) ? intval($_POST['worker_queues']) : 4);
$worker_dont_fork = ((x($_POST,'worker_dont_fork')) ? True : False);
$worker_fastlane = ((x($_POST,'worker_fastlane')) ? True : False);
$worker_frontend = ((x($_POST,'worker_frontend')) ? True : False);
if($a->get_path() != "")
$diaspora_enabled = false;
@ -792,6 +820,7 @@ function admin_page_site_post(&$a) {
set_config('system','worker_queues', $worker_queues);
set_config('system','worker_dont_fork', $worker_dont_fork);
set_config('system','worker_fastlane', $worker_fastlane);
set_config('system','frontend_worker', $worker_frontend);
if($rino==2 and !function_exists('mcrypt_create_iv')) {
notice(t("RINO2 needs mcrypt php extension to work."));
@ -819,7 +848,7 @@ function admin_page_site_post(&$a) {
function admin_page_site(&$a) {
/* Installed langs */
$lang_choices = get_avaiable_languages();
$lang_choices = get_available_languages();
if(strlen(get_config('system','directory_submit_url')) AND
!strlen(get_config('system','directory'))) {
@ -1023,6 +1052,7 @@ function admin_page_site(&$a) {
'$worker_queues' => array('worker_queues', t("Maximum number of parallel workers"), get_config('system','worker_queues'), t("On shared hosters set this to 2. On larger systems, values of 10 are great. Default value is 4.")),
'$worker_dont_fork' => array('worker_dont_fork', t("Don't use 'proc_open' with the worker"), get_config('system','worker_dont_fork'), t("Enable this if your system doesn't allow the use of 'proc_open'. This can happen on shared hosters. If this is enabled you should increase the frequency of poller calls in your crontab.")),
'$worker_fastlane' => array('worker_fastlane', t("Enable fastlane"), get_config('system','worker_fastlane'), t("When enabed, the fastlane mechanism starts an additional worker if processes with higher priority are blocked by processes of lower priority.")),
'$worker_frontend' => array('worker_frontend', t('Enable frontend worker'), get_config('system','frontend_worker'), t('When enabled the Worker process is triggered when backend access is performed (e.g. messages being delivered). On smaller sites you might want to call yourdomain.tld/worker on a regular basis via an external cron job. You should only enable this option if you cannot utilize cron/scheduled jobs on your server. The worker background process needs to be activated for this.')),
'$form_security_token' => get_form_security_token("admin_site")
@ -1126,18 +1156,20 @@ function admin_page_dbsync(&$a) {
* @param App $a
*/
function admin_page_users_post(&$a){
$pending = (x($_POST, 'pending') ? $_POST['pending'] : array());
$users = (x($_POST, 'user') ? $_POST['user'] : array());
$nu_name = (x($_POST, 'new_user_name') ? $_POST['new_user_name'] : '');
$nu_nickname = (x($_POST, 'new_user_nickname') ? $_POST['new_user_nickname'] : '');
$nu_email = (x($_POST, 'new_user_email') ? $_POST['new_user_email'] : '');
$pending = (x($_POST, 'pending') ? $_POST['pending'] : array());
$users = (x($_POST, 'user') ? $_POST['user'] : array());
$nu_name = (x($_POST, 'new_user_name') ? $_POST['new_user_name'] : '');
$nu_nickname = (x($_POST, 'new_user_nickname') ? $_POST['new_user_nickname'] : '');
$nu_email = (x($_POST, 'new_user_email') ? $_POST['new_user_email'] : '');
$nu_language = get_config('system', 'language');
check_form_security_token_redirectOnErr('/admin/users', 'admin_users');
if(!($nu_name==="") && !($nu_email==="") && !($nu_nickname==="")) {
require_once('include/user.php');
$result = create_user(array('username'=>$nu_name, 'email'=>$nu_email, 'nickname'=>$nu_nickname, 'verified'=>1));
$result = create_user(array('username'=>$nu_name, 'email'=>$nu_email,
'nickname'=>$nu_nickname, 'verified'=>1, 'language'=>$nu_language));
if(! $result['success']) {
notice($result['message']);
return;
@ -1268,7 +1300,7 @@ function admin_page_users(&$a){
/* get users */
$total = q("SELECT COUNT(*) AS `total` FROM `user` WHERE 1");
$total = qu("SELECT COUNT(*) AS `total` FROM `user` WHERE 1");
if(count($total)) {
$a->set_pager_total($total[0]['total']);
$a->set_pager_itemspage(100);
@ -1276,14 +1308,14 @@ function admin_page_users(&$a){
/* ordering */
$valid_orders = array(
'contact.name',
'contact.name',
'user.email',
'user.register_date',
'user.login_date',
'lastitem.lastitem_date',
'lastitem_date',
'user.page-flags'
);
$order = "contact.name";
$order_direction = "+";
if (x($_GET,'o')){
@ -1292,38 +1324,28 @@ function admin_page_users(&$a){
$order_direction = "-";
$new_order = substr($new_order,1);
}
if (in_array($new_order, $valid_orders)){
$order = $new_order;
}
if (x($_GET,'d')){
$new_direction = $_GET['d'];
}
}
$sql_order = "`".str_replace('.','`.`',$order)."`";
$sql_order_direction = ($order_direction==="+")?"ASC":"DESC";
$users = q("SELECT `user`.* , `contact`.`name` , `contact`.`url` , `contact`.`micro`, `lastitem`.`lastitem_date`, `user`.`account_expired`
FROM
(SELECT MAX(`item`.`changed`) as `lastitem_date`, `item`.`uid`
FROM `item`
WHERE `item`.`type` = 'wall'
GROUP BY `item`.`uid`) AS `lastitem`
RIGHT OUTER JOIN `user` ON `user`.`uid` = `lastitem`.`uid`,
`contact`
WHERE
`user`.`uid` = `contact`.`uid`
AND `user`.`verified` =1
AND `contact`.`self` =1
ORDER BY $sql_order $sql_order_direction LIMIT %d, %d
",
$users = qu("SELECT `user`.*, `contact`.`name`, `contact`.`url`, `contact`.`micro`, `user`.`account_expired`, `contact`.`last-item` AS `lastitem_date`
FROM `user`
INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
WHERE `user`.`verified`
ORDER BY $sql_order $sql_order_direction LIMIT %d, %d",
intval($a->pager['start']),
intval($a->pager['itemspage'])
);
//echo "<pre>$users"; killme();
$adminlist = explode(",", str_replace(" ", "", $a->config['admin_email']));
$_setup_users = function ($e) use ($adminlist){
$accounts = array(
@ -1386,6 +1408,7 @@ function admin_page_users(&$a){
'$h_deleted' => t('User waiting for permanent deletion'),
'$th_pending' => array(t('Request date'), t('Name'), t('Email')),
'$no_pending' => t('No registrations.'),
'$pendingnotetext' => t('Note from the user'),
'$approve' => t('Approve'),
'$deny' => t('Deny'),
'$delete' => t('Delete'),
@ -1867,6 +1890,12 @@ function admin_page_logs(&$a){
LOGGER_DATA => 'Data',
LOGGER_ALL => 'All'
);
if (ini_get('log_errors')) {
$phplogenabled = t('PHP log currently enabled.');
} else {
$phplogenabled = t('PHP log currently disabled.');
}
$t = get_markup_template("admin_logs.tpl");
@ -1887,6 +1916,7 @@ function admin_page_logs(&$a){
'$phpheader' => t("PHP logging"),
'$phphint' => t("To enable logging of PHP errors and warnings you can add the following to the .htconfig.php file of your installation. The filename set in the 'error_log' line is relative to the friendica top-level directory and must be writeable by the web server. The option '1' for 'log_errors' and 'display_errors' is to enable these options, set to '0' to disable them."),
'$phplogcode' => "error_reporting(E_ERROR | E_WARNING | E_PARSE);\nini_set('error_log','php.out');\nini_set('log_errors','1');\nini_set('display_errors', '1');",
'$phplogenabled' => $phplogenabled,
));
}

View file

@ -76,7 +76,7 @@ function allfriends_content(&$a) {
'details' => $contact_details['location'],
'tags' => $contact_details['keywords'],
'about' => $contact_details['about'],
'account_type' => (($contact_details['community']) ? t('Forum') : ''),
'account_type' => account_type($contact_details),
'network' => network_to_name($contact_details['network'], $contact_details['url']),
'photo_menu' => $photo_menu,
'conntxt' => t('Connect'),

View file

@ -40,10 +40,7 @@ function cal_init(&$a) {
$profile = get_profiledata_by_nick($nick, $a->profile_uid);
if((intval($profile['page-flags']) == PAGE_COMMUNITY) || (intval($profile['page-flags']) == PAGE_PRVGROUP))
$account_type = t('Forum');
else
$account_type = "";
$account_type = account_type($profile);
$tpl = get_markup_template("vcard-widget.tpl");
@ -201,8 +198,8 @@ function cal_content(&$a) {
if ($a->argv[2] === 'json'){
if (x($_GET,'start')) $start = date("Y-m-d h:i:s", $_GET['start']);
if (x($_GET,'end')) $finish = date("Y-m-d h:i:s", $_GET['end']);
if (x($_GET,'start')) $start = $_GET['start'];
if (x($_GET,'end')) $finish = $_GET['end'];
}
$start = datetime_convert('UTC','UTC',$start);
@ -256,7 +253,7 @@ function cal_content(&$a) {
$tpl = get_markup_template("event.tpl");
} else {
// if (get_config('experimentals','new_calendar')==1){
$tpl = get_markup_template("events-js.tpl");
$tpl = get_markup_template("events_js.tpl");
// } else {
// $tpl = get_markup_template("events.tpl");
// }
@ -287,8 +284,7 @@ function cal_content(&$a) {
"month" => t("month"),
"week" => t("week"),
"day" => t("day"),
"list" => t("list"),
));
if (x($_GET,'id')){ echo $o; killme(); }

View file

@ -120,7 +120,7 @@ function common_content(&$a) {
'details' => $contact_details['location'],
'tags' => $contact_details['keywords'],
'about' => $contact_details['about'],
'account_type' => (($contact_details['community']) ? t('Forum') : ''),
'account_type' => account_type($contact_details),
'network' => network_to_name($contact_details['network'], $contact_details['url']),
'photo_menu' => $photo_menu,
'id' => ++$id,

View file

@ -49,7 +49,7 @@ function community_content(&$a, $update = 0) {
// OR your own posts if you are a logged in member
if(get_config('system', 'old_pager')) {
$r = q("SELECT COUNT(distinct(`item`.`uri`)) AS `total`
$r = qu("SELECT COUNT(distinct(`item`.`uri`)) AS `total`
FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
INNER JOIN `user` ON `user`.`uid` = `item`.`uid` AND `user`.`hidewall` = 0
@ -120,7 +120,7 @@ function community_getitems($start, $itemspage) {
if (get_config('system','community_page_style') == CP_GLOBAL_COMMUNITY)
return(community_getpublicitems($start, $itemspage));
$r = q("SELECT %s
$r = qu("SELECT %s
FROM `thread` FORCE INDEX (`wall_private_received`)
INNER JOIN `user` ON `user`.`uid` = `thread`.`uid` AND NOT `user`.`hidewall`
INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
@ -140,7 +140,7 @@ function community_getitems($start, $itemspage) {
function community_getpublicitems($start, $itemspage) {
$r = q("SELECT %s
$r = qu("SELECT %s
FROM `thread`
INNER JOIN `item` ON `item`.`id` = `thread`.`iid` %s
WHERE `thread`.`uid` = 0

View file

@ -38,7 +38,7 @@ function contacts_init(&$a) {
if (($a->data['contact']['network'] != "") AND ($a->data['contact']['network'] != NETWORK_DFRN)) {
$networkname = format_network_name($a->data['contact']['network'],$a->data['contact']['url']);
} else
} else
$networkname = '';
$vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"),array(
@ -48,7 +48,7 @@ function contacts_init(&$a) {
'$addr' => (($a->data['contact']['addr'] != "") ? ($a->data['contact']['addr']) : ""),
'$network_name' => $networkname,
'$network' => t('Network:'),
'account_type' => (($a->data['contact']['forum'] || $a->data['contact']['prv']) ? t('Forum') : '')
'$account_type' => account_type($a->data['contact'])
));
$finpeople_widget = '';
$follow_widget = '';
@ -237,7 +237,7 @@ function _contact_update($contact_id) {
intval($contact_id));
} else
// pull feed and consume it, which should subscribe to the hub.
proc_run(PRIORITY_MEDIUM, "include/onepoll.php", $contact_id, "force");
proc_run(PRIORITY_HIGH, "include/onepoll.php", $contact_id, "force");
}
function _contact_update_profile($contact_id) {
@ -623,9 +623,11 @@ function contacts_content(&$a) {
'$url' => $url,
'$profileurllabel' => t('Profile URL'),
'$profileurl' => $contact['url'],
'account_type' => (($contact['forum'] || $contact['prv']) ? t('Forum') : ''),
'$account_type' => account_type($contact),
'$location' => bbcode($contact["location"]),
'$location_label' => t("Location:"),
'$xmpp' => bbcode($contact["xmpp"]),
'$xmpp_label' => t("XMPP:"),
'$about' => bbcode($contact["about"], false, false),
'$about_label' => t("About:"),
'$keywords' => $contact["keywords"],
@ -892,24 +894,13 @@ function contact_posts($a, $contact_id) {
$o .= $tab_str;
$r = q("SELECT `id` FROM `item` WHERE `contact-id` = %d LIMIT 1", intval($contact_id));
if ($r)
$o .= posts_from_contact($a, $contact_id);
elseif ($contact["url"]) {
$r = q("SELECT `id` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
dbesc(normalise_link($contact["url"])));
if ($r[0]["id"] <> 0)
$o .= posts_from_gcontact($a, $r[0]["id"]);
}
$o .= posts_from_contact_url($a, $contact["url"]);
return $o;
}
function _contact_detail_for_template($rr){
$community = '';
switch($rr['rel']) {
case CONTACT_IS_FRIEND:
$dir_icon = 'images/lrarrow.gif';
@ -935,11 +926,6 @@ function _contact_detail_for_template($rr){
$sparkle = '';
}
//test if contact is a forum page
if (isset($rr['forum']) OR isset($rr['prv']))
$community = ($rr['forum'] OR $rr['prv']);
return array(
'img_hover' => sprintf( t('Visit %s\'s profile [%s]'),$rr['name'],$rr['url']),
'edit_hover' => t('Edit contact'),
@ -950,7 +936,7 @@ function _contact_detail_for_template($rr){
'thumb' => proxy_url($rr['thumb'], false, PROXY_SIZE_THUMB),
'name' => htmlentities($rr['name']),
'username' => htmlentities($rr['name']),
'account_type' => ($community ? t('Forum') : ''),
'account_type' => account_type($rr),
'sparkle' => $sparkle,
'itemurl' => (($rr['addr'] != "") ? $rr['addr'] : $rr['url']),
'url' => $url,

View file

@ -1,17 +1,21 @@
<?php
/*
* Module: dfrn_confirm
/**
* @file mod/dfrn_confirm.php
* @brief Module: dfrn_confirm
* Purpose: Friendship acceptance for DFRN contacts
*
*.
* There are two possible entry points and three scenarios.
*
*.
* 1. A form was submitted by our user approving a friendship that originated elsewhere.
* This may also be called from dfrn_request to automatically approve a friendship.
*
* 2. We may be the target or other side of the conversation to scenario 1, and will
* interact with that process on our own user's behalf.
*
*.
* @see PDF with dfrn specs: https://github.com/friendica/friendica/blob/master/spec/dfrn2.pdf
* You also find a graphic which describes the confirmation process at
* https://github.com/friendica/friendica/blob/master/spec/dfrn2_contact_confirmation.png
*/
require_once('include/enotify.php');
@ -22,7 +26,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
if(is_array($handsfree)) {
/**
/*
* We were called directly from dfrn_request due to automatic friend acceptance.
* Any $_POST parameters we may require are supplied in the $handsfree array.
*
@ -37,7 +41,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
$node = $a->argv[1];
}
/**
/*
*
* Main entry point. Scenario 1. Our user received a friend request notification (perhaps
* from another site) and clicked 'Approve'.
@ -87,7 +91,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
$activity = ((x($_POST,'activity')) ? intval($_POST['activity']) : 0 );
}
/**
/*
*
* Ensure that dfrn_id has precedence when we go to find the contact record.
* We only want to search based on contact id if there is no dfrn_id,
@ -103,7 +107,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
logger('Confirming follower with contact_id: ' . $cid);
/**
/*
*
* The other person will have been issued an ID when they first requested friendship.
* Locate their record. At this time, their record will have both pending and blocked set to 1.
@ -139,7 +143,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
if($network === NETWORK_DFRN) {
/**
/*
*
* Generate a key pair for all further communications with this person.
* We have a keypair for every contact, and a site key for unknown people.
@ -166,7 +170,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
$params = array();
/**
/*
*
* Per the DFRN protocol, we will verify both ends by encrypting the dfrn_id with our
* site private key (person on the other end can decrypt it with our site public key).
@ -212,7 +216,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
logger('Confirm: posting data to ' . $dfrn_confirm . ': ' . print_r($params,true), LOGGER_DATA);
/**
/*
*
* POST all this stuff to the other site.
* Temporarily raise the network timeout to 120 seconds because the default 60
@ -506,7 +510,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
//NOTREACHED
}
/**
/*
*
*
* End of Scenario 1. [Local confirmation of remote friend request].

View file

@ -1,5 +1,10 @@
<?php
/**
* @file mod/dfrn_notify.php
* @brief The dfrn notify endpoint
* @see PDF with dfrn specs: https://github.com/friendica/friendica/blob/master/spec/dfrn2.pdf
*/
require_once('include/items.php');
require_once('include/dfrn.php');
require_once('include/event.php');
@ -7,7 +12,7 @@ require_once('include/event.php');
require_once('library/defuse/php-encryption-1.2.1/Crypto.php');
function dfrn_notify_post(&$a) {
logger(__function__, LOGGER_TRACE);
logger(__function__, LOGGER_TRACE);
$dfrn_id = ((x($_POST,'dfrn_id')) ? notags(trim($_POST['dfrn_id'])) : '');
$dfrn_version = ((x($_POST,'dfrn_version')) ? (float) $_POST['dfrn_version'] : 2.0);
$challenge = ((x($_POST,'challenge')) ? notags(trim($_POST['challenge'])) : '');
@ -117,7 +122,7 @@ function dfrn_notify_post(&$a) {
if($dissolve == 1) {
/**
/*
* Relationship is dissolved permanently
*/

View file

@ -1,12 +1,15 @@
<?php
/**
*
* Module: dfrn_request
* @file mod/dfrn_request.php
* @brief Module: dfrn_request
*
* Purpose: Handles communication associated with the issuance of
* friend requests.
*
* @see PDF with dfrn specs: https://github.com/friendica/friendica/blob/master/spec/dfrn2.pdf
* You also find a graphic which describes the confirmation process at
* https://github.com/friendica/friendica/blob/master/spec/dfrn2_contact_request.png
*/
require_once('include/enotify.php');
@ -14,7 +17,6 @@ require_once('include/Scrape.php');
require_once('include/Probe.php');
require_once('include/group.php');
if(! function_exists('dfrn_request_init')) {
function dfrn_request_init(&$a) {
if($a->argc > 1)
@ -22,7 +24,7 @@ function dfrn_request_init(&$a) {
profile_load($a,$which);
return;
}}
}
/**
@ -40,8 +42,6 @@ function dfrn_request_init(&$a) {
* After logging in, we click 'submit' to approve the linkage.
*
*/
if(! function_exists('dfrn_request_post')) {
function dfrn_request_post(&$a) {
if(($a->argc != 2) || (! count($a->profile))) {
@ -55,7 +55,7 @@ function dfrn_request_post(&$a) {
}
/**
/*
*
* Scenario 2: We've introduced ourself to another cell, then have been returned to our own cell
* to confirm the request, and then we've clicked submit (perhaps after logging in).
@ -65,7 +65,7 @@ function dfrn_request_post(&$a) {
if((x($_POST,'localconfirm')) && ($_POST['localconfirm'] == 1)) {
/**
/*
* Ensure this is a valid request
*/
@ -77,23 +77,24 @@ function dfrn_request_post(&$a) {
$confirm_key = ((x($_POST,'confirm_key')) ? $_POST['confirm_key'] : "");
$hidden = ((x($_POST,'hidden-contact')) ? intval($_POST['hidden-contact']) : 0);
$contact_record = null;
$blocked = 1;
$pending = 1;
if(x($dfrn_url)) {
/**
/*
* Lookup the contact based on their URL (which is the only unique thing we have at the moment)
*/
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND (`url` = '%s' OR `nurl` = '%s') AND `self` = 0 LIMIT 1",
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND NOT `self` LIMIT 1",
intval(local_user()),
dbesc($dfrn_url),
dbesc(normalise_link($dfrn_url))
);
if(count($r)) {
if(strlen($r[0]['dfrn-id'])) {
/**
/*
* We don't need to be here. It has already happened.
*/
@ -113,7 +114,7 @@ function dfrn_request_post(&$a) {
}
else {
/**
/*
* Scrape the other site's profile page to pick up the dfrn links, key, fn, and photo
*/
@ -141,19 +142,18 @@ function dfrn_request_post(&$a) {
$photo = $parms["photo"];
/********* Escape the entire array ********/
// Escape the entire array
dbesc_array($parms);
/******************************************/
/**
/*
* Create a contact record on our site for the other person
*/
$r = q("INSERT INTO `contact` ( `uid`, `created`,`url`, `nurl`, `addr`, `name`, `nick`, `photo`, `site-pubkey`,
`request`, `confirm`, `notify`, `poll`, `poco`, `network`, `aes_allow`, `hidden`)
VALUES ( %d, '%s', '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d)",
`request`, `confirm`, `notify`, `poll`, `poco`, `network`, `aes_allow`, `hidden`, `blocked`, `pending`)
VALUES ( %d, '%s', '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d)",
intval(local_user()),
datetime_convert(),
dbesc($dfrn_url),
@ -170,7 +170,9 @@ function dfrn_request_post(&$a) {
$parms['dfrn-poco'],
dbesc(NETWORK_DFRN),
intval($aes_allow),
intval($hidden)
intval($hidden),
intval($blocked),
intval($pending)
);
}
@ -195,7 +197,7 @@ function dfrn_request_post(&$a) {
} else
$forwardurl = $a->get_baseurl()."/contacts";
/**
/*
* Allow the blocked remote notification to complete
*/
@ -222,7 +224,7 @@ function dfrn_request_post(&$a) {
return; // NOTREACHED
}
/**
/*
* Otherwise:
*
* Scenario 1:
@ -256,11 +258,13 @@ function dfrn_request_post(&$a) {
$contact_record = null;
$failed = false;
$parms = null;
$blocked = 1;
$pending = 1;
if( x($_POST,'dfrn_url')) {
/**
/*
* Block friend request spam
*/
@ -277,7 +281,7 @@ function dfrn_request_post(&$a) {
}
}
/**
/*
*
* Cleanup old introductions that remain blocked.
* Also remove the contact record, but only if there is no existing relationship
@ -304,7 +308,7 @@ function dfrn_request_post(&$a) {
}
}
/**
/*
*
* Cleanup any old email intros - which will have a greater lifetime
*/
@ -354,8 +358,6 @@ function dfrn_request_post(&$a) {
$nurl = normalise_url($host);
$poll = 'email ' . random_string();
$notify = 'smtp ' . random_string();
$blocked = 1;
$pending = 1;
$network = NETWORK_MAIL2;
$rel = CONTACT_IS_FOLLOWER;
@ -540,8 +542,8 @@ function dfrn_request_post(&$a) {
dbesc_array($parms);
$r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `name`, `nick`, `issued-id`, `photo`, `site-pubkey`,
`request`, `confirm`, `notify`, `poll`, `poco`, `network` )
VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )",
`request`, `confirm`, `notify`, `poll`, `poco`, `network`, `blocked`, `pending` )
VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d )",
intval($uid),
dbesc(datetime_convert()),
$parms['url'],
@ -557,7 +559,9 @@ function dfrn_request_post(&$a) {
$parms['dfrn-notify'],
$parms['dfrn-poll'],
$parms['dfrn-poco'],
dbesc(NETWORK_DFRN)
dbesc(NETWORK_DFRN),
intval($blocked),
intval($pending)
);
// find the contact record we just created
@ -613,7 +617,7 @@ function dfrn_request_post(&$a) {
// END $network === NETWORK_DFRN
} elseif (($network != NETWORK_PHANTOM) AND ($url != "")) {
/**
/*
*
* Substitute our user's feed URL into $url template
* Send the subscriber home to subscribe
@ -642,12 +646,9 @@ function dfrn_request_post(&$a) {
}
} return;
}}
}
if(! function_exists('dfrn_request_content')) {
function dfrn_request_content(&$a) {
if(($a->argc != 2) || (! count($a->profile)))
@ -781,7 +782,7 @@ function dfrn_request_content(&$a) {
}
else {
/**
/*
* Normal web request. Display our user's introduction form.
*/
@ -793,7 +794,7 @@ function dfrn_request_content(&$a) {
}
/**
/*
* Try to auto-fill the profile address
*/
@ -816,7 +817,7 @@ function dfrn_request_content(&$a) {
$target_addr = $a->profile['nickname'] . '@' . substr(z_root(), strpos(z_root(),'://') + 3 );
/**
/*
*
* The auto_request form only has the profile address
* because nobody is going to read the comments and
@ -881,4 +882,4 @@ function dfrn_request_content(&$a) {
}
return; // Somebody is fishing.
}}
}

View file

@ -99,7 +99,6 @@ function directory_content(&$a) {
foreach($r as $rr) {
$community = '';
$itemurl= '';
$itemurl = (($rr['addr'] != "") ? $rr['addr'] : $rr['profile_url']);
@ -128,13 +127,6 @@ function directory_content(&$a) {
// if(strlen($rr['gender']))
// $details .= '<br />' . t('Gender: ') . $rr['gender'];
// show if account is a community account
/// @TODO The other page types should be also respected, but first we need a good
/// translatiion and systemwide consistency for displaying the page type
if((intval($rr['page-flags']) == PAGE_COMMUNITY) OR (intval($rr['page-flags']) == PAGE_PRVGROUP))
$community = true;
$profile = $rr;
if((x($profile,'address') == 1)
@ -171,7 +163,7 @@ function directory_content(&$a) {
'img_hover' => $rr['name'],
'name' => $rr['name'],
'details' => $details,
'account_type' => ($community ? t('Forum') : ''),
'account_type' => account_type($rr),
'profile' => $profile,
'location' => $location_e,
'tags' => $rr['pub_keywords'],

View file

@ -220,7 +220,7 @@ function dirfind_content(&$a, $prefix = "") {
'details' => $contact_details['location'],
'tags' => $contact_details['keywords'],
'about' => $contact_details['about'],
'account_type' => (($contact_details['community']) ? t('Forum') : ''),
'account_type' => account_type($contact_details),
'network' => network_to_name($jj->network, $jj->url),
'id' => ++$id,
);

View file

@ -2,7 +2,7 @@
function display_init(&$a) {
if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
return;
}
@ -16,10 +16,10 @@ function display_init(&$a) {
// Does the local user have this item?
if (local_user()) {
$r = q("SELECT `id`, `parent`, `author-name`, `author-link`, `author-avatar`, `network`, `body`, `uid`, `owner-link` FROM `item`
$r = qu("SELECT `id`, `parent`, `author-name`, `author-link`, `author-avatar`, `network`, `body`, `uid`, `owner-link` FROM `item`
WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
AND `guid` = '%s' AND `uid` = %d", dbesc($a->argv[1]), local_user());
if (count($r)) {
if (dbm::is_result($r)) {
$nick = $a->user["nickname"];
$itemuid = local_user();
}
@ -27,16 +27,15 @@ function display_init(&$a) {
// Or is it anywhere on the server?
if ($nick == "") {
$r = q("SELECT `user`.`nickname`, `item`.`id`, `item`.`parent`, `item`.`author-name`,
$r = qu("SELECT `user`.`nickname`, `item`.`id`, `item`.`parent`, `item`.`author-name`,
`item`.`author-link`, `item`.`author-avatar`, `item`.`network`, `item`.`uid`, `item`.`owner-link`, `item`.`body`
FROM `item` INNER JOIN `user` ON `user`.`uid` = `item`.`uid`
FROM `item` STRAIGHT_JOIN `user` ON `user`.`uid` = `item`.`uid`
WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
AND NOT `item`.`private` AND NOT `user`.`hidewall`
AND `item`.`guid` = '%s'", dbesc($a->argv[1]));
// AND NOT `item`.`private` AND `item`.`wall`
if (count($r)) {
if (dbm::is_result($r)) {
$nick = $r[0]["nickname"];
$itemuid = $r[0]["uid"];
}
@ -44,33 +43,32 @@ function display_init(&$a) {
// Is it an item with uid=0?
if ($nick == "") {
$r = q("SELECT `item`.`id`, `item`.`parent`, `item`.`author-name`, `item`.`author-link`,
$r = qu("SELECT `item`.`id`, `item`.`parent`, `item`.`author-name`, `item`.`author-link`,
`item`.`author-avatar`, `item`.`network`, `item`.`uid`, `item`.`owner-link`, `item`.`body`
FROM `item` WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
AND NOT `item`.`private` AND `item`.`uid` = 0
AND `item`.`guid` = '%s'", dbesc($a->argv[1]));
// AND NOT `item`.`private` AND `item`.`wall`
}
if (count($r)) {
if ($r[0]["id"] != $r[0]["parent"])
$r = q("SELECT `id`, `author-name`, `author-link`, `author-avatar`, `network`, `body`, `uid`, `owner-link` FROM `item`
if (dbm::is_result($r)) {
if ($r[0]["id"] != $r[0]["parent"]) {
$r = qu("SELECT `id`, `author-name`, `author-link`, `author-avatar`, `network`, `body`, `uid`, `owner-link` FROM `item`
WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
AND `id` = %d", $r[0]["parent"]);
}
if (($itemuid != local_user()) AND local_user()) {
// Do we know this contact but we haven't got this item?
// Copy the wohle thread to our local storage so that we can interact.
// We really should change this need for the future since it scales very bad.
$contactid = get_contact($r[0]['owner-link'], local_user());
if ($contactid) {
$items = q("SELECT * FROM `item` WHERE `parent` = %d ORDER BY `id`", intval($r[0]["id"]));
$items = qu("SELECT * FROM `item` WHERE `parent` = %d ORDER BY `id`", intval($r[0]["id"]));
foreach ($items AS $item) {
$itemcontactid = get_contact($item['owner-link'], local_user());
if (!$itemcontactid)
if (!$itemcontactid) {
$itemcontactid = $contactid;
}
unset($item['id']);
$item['uid'] = local_user();
$item['origin'] = 0;
@ -87,21 +85,22 @@ function display_init(&$a) {
$nickname = str_replace(normalise_link($a->get_baseurl())."/profile/", "", normalise_link($profiledata["url"]));
if (($nickname != $a->user["nickname"])) {
$r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile`
$r = qu("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile`
INNER JOIN `contact` on `contact`.`uid` = `profile`.`uid` INNER JOIN `user` ON `profile`.`uid` = `user`.`uid`
WHERE `user`.`nickname` = '%s' AND `profile`.`is-default` AND `contact`.`self` LIMIT 1",
dbesc($nickname)
);
if (count($r))
if (dbm::is_result($r)) {
$profiledata = $r[0];
}
$profiledata["network"] = NETWORK_DFRN;
} else
} else {
$profiledata = array();
}
}
} else {
$a->error = 404;
notice( t('Item not found.') . EOL);
notice(t('Item not found.') . EOL);
return;
}
}
@ -129,48 +128,49 @@ function display_fetchauthor($a, $item) {
// Skip if it isn't a pure repeated messages
// Does it start with a share?
if (!$skip AND strpos($body, "[share") > 0)
if (!$skip AND strpos($body, "[share") > 0) {
$skip = true;
}
// Does it end with a share?
if (!$skip AND (strlen($body) > (strrpos($body, "[/share]") + 8)))
if (!$skip AND (strlen($body) > (strrpos($body, "[/share]") + 8))) {
$skip = true;
}
if (!$skip) {
$attributes = preg_replace("/\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism","$1",$body);
// Skip if there is no shared message in there
if ($body == $attributes)
if ($body == $attributes) {
$skip = true;
}
}
if (!$skip) {
$author = "";
preg_match("/author='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "")
if ($matches[1] != "") {
$profiledata["name"] = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8');
}
preg_match('/author="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "")
if ($matches[1] != "") {
$profiledata["name"] = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8');
}
$profile = "";
preg_match("/profile='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "")
if ($matches[1] != "") {
$profiledata["url"] = $matches[1];
}
preg_match('/profile="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "")
if ($matches[1] != "") {
$profiledata["url"] = $matches[1];
}
$avatar = "";
preg_match("/avatar='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "")
if ($matches[1] != "") {
$profiledata["photo"] = $matches[1];
}
preg_match('/avatar="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "")
if ($matches[1] != "") {
$profiledata["photo"] = $matches[1];
}
$profiledata["nickname"] = $profiledata["name"];
$profiledata["network"] = GetProfileUsername($profiledata["url"], "", false, true);
@ -183,8 +183,9 @@ function display_fetchauthor($a, $item) {
$profiledata["photo"] = App::remove_baseurl($profiledata["photo"]);
if (local_user()) {
if (in_array($profiledata["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS)))
if (in_array($profiledata["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) {
$profiledata["remoteconnect"] = $a->get_baseurl()."/follow?url=".urlencode($profiledata["url"]);
}
} elseif ($profiledata["network"] == NETWORK_DFRN) {
$connect = str_replace("/profile/", "/dfrn_request/", $profiledata["url"]);
$profiledata["remoteconnect"] = $connect;
@ -195,8 +196,8 @@ function display_fetchauthor($a, $item) {
function display_content(&$a, $update = 0) {
if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
notice( t('Public access denied.') . EOL);
if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
notice(t('Public access denied.') . EOL);
return;
}
@ -210,55 +211,53 @@ function display_content(&$a, $update = 0) {
$a->page['htmlhead'] .= replace_macros(get_markup_template('display-head.tpl'), array());
if($update) {
if ($update) {
$nick = $_REQUEST['nick'];
}
else {
} else {
$nick = (($a->argc > 1) ? $a->argv[1] : '');
}
if($update) {
if ($update) {
$item_id = $_REQUEST['item_id'];
$a->profile = array('uid' => intval($update), 'profile_uid' => intval($update));
}
else {
} else {
$item_id = (($a->argc > 2) ? $a->argv[2] : 0);
if ($a->argc == 2) {
$nick = "";
if (local_user()) {
$r = q("SELECT `id` FROM `item`
$r = qu("SELECT `id` FROM `item`
WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
AND `guid` = '%s' AND `uid` = %d", dbesc($a->argv[1]), local_user());
if (count($r)) {
if (dbm::is_result($r)) {
$item_id = $r[0]["id"];
$nick = $a->user["nickname"];
}
}
if ($nick == "") {
$r = q("SELECT `user`.`nickname`, `item`.`id` FROM `item` INNER JOIN `user` ON `user`.`uid` = `item`.`uid`
$r = qu("SELECT `user`.`nickname`, `item`.`id` FROM `item` STRAIGHT_JOIN `user` ON `user`.`uid` = `item`.`uid`
WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
AND NOT `item`.`private` AND NOT `user`.`hidewall`
AND `item`.`guid` = '%s'", dbesc($a->argv[1]));
// AND NOT `item`.`private` AND `item`.`wall`
if (count($r)) {
if (dbm::is_result($r)) {
$item_id = $r[0]["id"];
$nick = $r[0]["nickname"];
}
}
if ($nick == "") {
$r = q("SELECT `item`.`id` FROM `item`
$r = qu("SELECT `item`.`id` FROM `item`
WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
AND NOT `item`.`private` AND `item`.`uid` = 0
AND `item`.`guid` = '%s'", dbesc($a->argv[1]));
// AND NOT `item`.`private` AND `item`.`wall`
if (count($r)) {
if (dbm::is_result($r)) {
$item_id = $r[0]["id"];
}
}
@ -266,12 +265,13 @@ function display_content(&$a, $update = 0) {
}
if ($item_id AND !is_numeric($item_id)) {
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
$r = qu("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($item_id), intval($a->profile['uid']));
if ($r)
if (dbm::is_result($r)) {
$item_id = $r[0]["id"];
else
} else {
$item_id = false;
}
}
if (!$item_id) {
@ -288,44 +288,44 @@ function display_content(&$a, $update = 0) {
$contact_id = 0;
if(is_array($_SESSION['remote'])) {
foreach($_SESSION['remote'] as $v) {
if($v['uid'] == $a->profile['uid']) {
if (is_array($_SESSION['remote'])) {
foreach ($_SESSION['remote'] as $v) {
if ($v['uid'] == $a->profile['uid']) {
$contact_id = $v['cid'];
break;
}
}
}
if($contact_id) {
if ($contact_id) {
$groups = init_groups_visitor($contact_id);
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
$r = qu("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($contact_id),
intval($a->profile['uid'])
);
if(count($r)) {
if (dbm::is_result($r)) {
$contact = $r[0];
$remote_contact = true;
}
}
if(! $remote_contact) {
if(local_user()) {
if (!$remote_contact) {
if (local_user()) {
$contact_id = $_SESSION['cid'];
$contact = $a->contact;
}
}
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1",
$r = qu("SELECT * FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1",
intval($a->profile['uid'])
);
if(count($r))
if (dbm::is_result($r)) {
$a->page_contact = $r[0];
}
$is_owner = ((local_user()) && (local_user() == $a->profile['profile_uid']) ? true : false);
if($a->profile['hidewall'] && (! $is_owner) && (! $remote_contact)) {
notice( t('Access to this profile has been restricted.') . EOL);
if ($a->profile['hidewall'] && (! $is_owner) && (! $remote_contact)) {
notice(t('Access to this profile has been restricted.') . EOL);
return;
}
@ -349,20 +349,21 @@ function display_content(&$a, $update = 0) {
$sql_extra = item_permissions_sql($a->profile['uid'],$remote_contact,$groups);
if($update) {
if ($update) {
$r = q("SELECT `id` FROM `item` WHERE `item`.`uid` = %d
$r = qu("SELECT `id` FROM `item` WHERE `item`.`uid` = %d
AND `item`.`parent` = (SELECT `parent` FROM `item` WHERE `id` = %d)
$sql_extra AND `unseen`",
intval($a->profile['uid']),
intval($item_id)
);
if(!$r)
if (!$r) {
return '';
}
}
$r = q(item_query()." AND `item`.`uid` = %d
$r = qu(item_query()." AND `item`.`uid` = %d
AND `item`.`parent` = (SELECT `parent` FROM `item` WHERE `id` = %d)
$sql_extra
ORDER BY `parent` DESC, `gravity` ASC, `id` ASC",
@ -371,18 +372,18 @@ function display_content(&$a, $update = 0) {
);
if(!$r && local_user()) {
if (!$r && local_user()) {
// Check if this is another person's link to a post that we have
$r = q("SELECT `item`.uri FROM `item`
$r = qu("SELECT `item`.uri FROM `item`
WHERE (`item`.`id` = %d OR `item`.`uri` = '%s')
LIMIT 1",
intval($item_id),
dbesc($item_id)
);
if($r) {
if (dbm::is_result($r)) {
$item_uri = $r[0]['uri'];
$r = q(item_query()." AND `item`.`uid` = %d
$r = qu(item_query()." AND `item`.`uid` = %d
AND `item`.`parent` = (SELECT `parent` FROM `item` WHERE `uri` = '%s' AND uid = %d)
ORDER BY `parent` DESC, `gravity` ASC, `id` ASC ",
intval(local_user()),
@ -392,23 +393,24 @@ function display_content(&$a, $update = 0) {
}
}
if($r) {
if ($r) {
if((local_user()) && (local_user() == $a->profile['uid'])) {
if ((local_user()) && (local_user() == $a->profile['uid'])) {
$unseen = q("SELECT `id` FROM `item` WHERE `unseen` AND `parent` = %d",
intval($r[0]['parent']));
if ($unseen)
q("UPDATE `item` SET `unseen` = 0
WHERE `parent` = %d AND `unseen`",
if ($unseen) {
q("UPDATE `item` SET `unseen` = 0 WHERE `parent` = %d AND `unseen`",
intval($r[0]['parent'])
);
}
}
$items = conv_sort($r,"`commented`");
if(!$update)
if (!$update) {
$o .= "<script> var netargs = '?f=&nick=" . $nick . "&item_id=" . $item_id . "'; </script>";
}
$o .= conversation($a,$items,'display', $update);
// Preparing the meta header
@ -420,9 +422,9 @@ function display_content(&$a, $update = 0) {
$image = $a->remove_baseurl($r[0]["thumb"]);
if ($title == "")
if ($title == "") {
$title = $author_name;
}
$description = htmlspecialchars($description, ENT_COMPAT, 'UTF-8', true); // allow double encoding here
$title = htmlspecialchars($title, ENT_COMPAT, 'UTF-8', true); // allow double encoding here
$author_name = htmlspecialchars($author_name, ENT_COMPAT, 'UTF-8', true); // allow double encoding here
@ -462,20 +464,18 @@ function display_content(&$a, $update = 0) {
return $o;
}
$r = q("SELECT `id`,`deleted` FROM `item` WHERE `id` = '%s' OR `uri` = '%s' LIMIT 1",
$r = qu("SELECT `id`,`deleted` FROM `item` WHERE `id` = '%s' OR `uri` = '%s' LIMIT 1",
dbesc($item_id),
dbesc($item_id)
);
if($r) {
if($r[0]['deleted']) {
notice( t('Item has been removed.') . EOL );
if ($r) {
if ($r[0]['deleted']) {
notice(t('Item has been removed.') . EOL );
} else {
notice(t('Permission denied.') . EOL );
}
else {
notice( t('Permission denied.') . EOL );
}
}
else {
notice( t('Item not found.') . EOL );
} else {
notice(t('Item not found.') . EOL );
}
return $o;

View file

@ -303,8 +303,8 @@ function events_content(&$a) {
if ($a->argv[1] === 'json'){
if (x($_GET,'start')) $start = date("Y-m-d h:i:s", $_GET['start']);
if (x($_GET,'end')) $finish = date("Y-m-d h:i:s", $_GET['end']);
if (x($_GET,'start')) $start = $_GET['start'];
if (x($_GET,'end')) $finish = $_GET['end'];
}
$start = datetime_convert('UTC','UTC',$start);
@ -357,7 +357,7 @@ function events_content(&$a) {
$tpl = get_markup_template("event.tpl");
} else {
// if (get_config('experimentals','new_calendar')==1){
$tpl = get_markup_template("events-js.tpl");
$tpl = get_markup_template("events_js.tpl");
// } else {
// $tpl = get_markup_template("events.tpl");
// }
@ -378,10 +378,10 @@ function events_content(&$a) {
'$tabs' => $tabs,
'$title' => t('Events'),
'$view' => t('View'),
'$new_event'=> array($a->get_baseurl().'/events/new',t('Create New Event'),'',''),
'$new_event' => array($a->get_baseurl().'/events/new',t('Create New Event'),'',''),
'$previus' => array($a->get_baseurl()."/events/$prevyear/$prevmonth",t('Previous'),'',''),
'$next' => array($a->get_baseurl()."/events/$nextyear/$nextmonth",t('Next'),'',''),
'$calendar' => cal($y,$m,$links, ' eventcal'),
'$calendar' => cal($y,$m,$links, ' eventcal'),
'$events' => $events,
@ -389,8 +389,7 @@ function events_content(&$a) {
"month" => t("month"),
"week" => t("week"),
"day" => t("day"),
"list" => t("list"),
));
if (x($_GET,'id')){ echo $o; killme(); }

View file

@ -137,13 +137,13 @@ function follow_content(&$a) {
$a->page['aside'] = "";
profile_load($a, "", 0, get_contact_details_by_url($ret["url"]));
// Show last public posts
if ($gcontact_id <> 0) {
$o .= replace_macros(get_markup_template('section_title.tpl'),
array('$title' => t('Status Messages and Posts')
));
$o .= posts_from_gcontact($a, $gcontact_id);
// Show last public posts
$o .= posts_from_contact_url($a, $ret["url"]);
}
return $o;

View file

@ -77,10 +77,9 @@ function hovercard_content() {
// 'server_url' => $contact["server_url"],
'bd' => (($contact["birthday"] == "0000-00-00") ? "" : $contact["birthday"]),
// 'generation' => $contact["generation"],
'account_type' => ($contact['community'] ? t("Forum") : ""),
'account_type' => account_type($contact),
'actions' => $actions,
);
if($datatype == "html") {
$t = get_markup_template("hovercard.tpl");

View file

@ -285,7 +285,7 @@ function install_content(&$a) {
$adminmail = notags(trim($_POST['adminmail']));
$timezone = ((x($_POST,'timezone')) ? ($_POST['timezone']) : 'America/Los_Angeles');
/* Installed langs */
$lang_choices = get_avaiable_languages();
$lang_choices = get_available_languages();
$tpl = get_markup_template('install_settings.tpl');
$o .= replace_macros($tpl, array(

View file

@ -115,7 +115,7 @@ function item_post(&$a) {
if(($r === false) || (! count($r))) {
notice( t('Unable to locate original post.') . EOL);
if(x($_REQUEST,'return'))
goaway($a->get_baseurl() . "/" . $return_path );
goaway($return_path);
killme();
}
$parent_item = $r[0];
@ -130,7 +130,7 @@ function item_post(&$a) {
intval($parent_item['contact-id']),
intval($uid)
);
if(count($r))
if (dbm::is_result($r))
$parent_contact = $r[0];
// If the contact id doesn't fit with the contact, then set the contact to null
@ -173,7 +173,21 @@ function item_post(&$a) {
$profile_uid = ((x($_REQUEST,'profile_uid')) ? intval($_REQUEST['profile_uid']) : 0);
$post_id = ((x($_REQUEST,'post_id')) ? intval($_REQUEST['post_id']) : 0);
$app = ((x($_REQUEST,'source')) ? strip_tags($_REQUEST['source']) : '');
$extid = ((x($_REQUEST,'extid')) ? strip_tags($_REQUEST['extid']) : '');
$extid = ((x($_REQUEST,'extid')) ? strip_tags($_REQUEST['extid']) : '');
$object = ((x($_REQUEST,'object')) ? $_REQUEST['object'] : '');
// Check for multiple posts with the same message id (when the post was created via API)
if (($message_id != '') AND ($profile_uid != 0)) {
$r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($message_id),
intval($profile_uid)
);
if (dbm::is_result($r)) {
logger("Message with URI ".$message_id." already exists for user ".$profile_uid, LOGGER_DEBUG);
return;
}
}
$allow_moderated = false;
@ -184,7 +198,7 @@ function item_post(&$a) {
if((x($_REQUEST,'commenter')) && ((! $parent) || (! $parent_item['wall']))) {
notice( t('Permission denied.') . EOL) ;
if(x($_REQUEST,'return'))
goaway($a->get_baseurl() . "/" . $return_path );
goaway($return_path);
killme();
}
@ -196,7 +210,7 @@ function item_post(&$a) {
if((! can_write_wall($a,$profile_uid)) && (! $allow_moderated)) {
notice( t('Permission denied.') . EOL) ;
if(x($_REQUEST,'return'))
goaway($a->get_baseurl() . "/" . $return_path );
goaway($return_path);
killme();
}
@ -220,7 +234,7 @@ function item_post(&$a) {
$r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
intval($profile_uid)
);
if(count($r))
if (dbm::is_result($r))
$user = $r[0];
if($orig_post) {
@ -292,7 +306,6 @@ function item_post(&$a) {
// If this is a comment, set the permissions from the parent.
if($parent_item) {
$private = 0;
// for non native networks use the network of the original post as network of the item
if (($parent_item['network'] != NETWORK_DIASPORA)
@ -300,19 +313,13 @@ function item_post(&$a) {
AND ($network == ""))
$network = $parent_item['network'];
if(($parent_item['private'])
|| strlen($parent_item['allow_cid'])
|| strlen($parent_item['allow_gid'])
|| strlen($parent_item['deny_cid'])
|| strlen($parent_item['deny_gid'])) {
$private = (($parent_item['private']) ? $parent_item['private'] : 1);
}
$str_contact_allow = $parent_item['allow_cid'];
$str_group_allow = $parent_item['allow_gid'];
$str_contact_deny = $parent_item['deny_cid'];
$str_group_deny = $parent_item['deny_gid'];
$private = $parent_item['private'];
}
$pubmail_enable = ((x($_REQUEST,'pubmail_enable') && intval($_REQUEST['pubmail_enable']) && (! $private)) ? 1 : 0);
// if using the API, we won't see pubmail_enable - figure out if it should be set
@ -333,7 +340,7 @@ function item_post(&$a) {
killme();
info( t('Empty post discarded.') . EOL );
if(x($_REQUEST,'return'))
goaway($a->get_baseurl() . "/" . $return_path );
goaway($return_path);
killme();
}
}
@ -392,7 +399,7 @@ function item_post(&$a) {
}
}
if(count($r)) {
if (dbm::is_result($r)) {
$author = $r[0];
$contact_id = $author['id'];
}
@ -406,7 +413,7 @@ function item_post(&$a) {
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
intval($profile_uid)
);
if(count($r))
if (dbm::is_result($r))
$contact_record = $r[0];
}
@ -460,7 +467,6 @@ function item_post(&$a) {
if(! count($r))
continue;
$r = q("UPDATE `photo` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s'
WHERE `resource-id` = '%s' AND `uid` = %d AND `album` = '%s' ",
dbesc($str_contact_allow),
@ -471,7 +477,6 @@ function item_post(&$a) {
intval($profile_uid),
dbesc( t('Wall Photos'))
);
}
}
}
@ -491,7 +496,7 @@ function item_post(&$a) {
intval($profile_uid),
intval($attach)
);
if(count($r)) {
if (dbm::is_result($r)) {
$r = q("UPDATE `attach` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s'
WHERE `uid` = %d AND `id` = %d",
dbesc($str_contact_allow),
@ -632,7 +637,7 @@ function item_post(&$a) {
intval($profile_uid),
intval($mtch)
);
if(count($r)) {
if (dbm::is_result($r)) {
if(strlen($attachments))
$attachments .= ',';
$attachments .= '[attach]href="' . $a->get_baseurl() . '/attach/' . $r[0]['id'] . '" length="' . $r[0]['filesize'] . '" type="' . $r[0]['filetype'] . '" title="' . (($r[0]['filename']) ? $r[0]['filename'] : '') . '"[/attach]';
@ -714,6 +719,7 @@ function item_post(&$a) {
$datarray['moderated'] = $allow_moderated;
$datarray['gcontact-id'] = get_gcontact_id(array("url" => $datarray['author-link'], "network" => $datarray['network'],
"photo" => $datarray['author-avatar'], "name" => $datarray['author-name']));
$datarray['object'] = $object;
/**
* These fields are for the convenience of plugins...
@ -725,6 +731,11 @@ function item_post(&$a) {
$datarray['self'] = $self;
// $datarray['prvnets'] = $user['prvnets'];
$datarray['parent-uri'] = ($parent == 0) ? $uri : $parent_item['uri'];
$datarray['plink'] = $a->get_baseurl().'/display/'.urlencode($datarray['guid']);
$datarray['last-child'] = 1;
$datarray['visible'] = 1;
if($orig_post)
$datarray['edit'] = true;
@ -735,6 +746,9 @@ function item_post(&$a) {
if($preview) {
require_once('include/conversation.php');
// We set the datarray ID to -1 because in preview mode the dataray
// doesn't have an ID.
$datarray["id"] = -1;
$o = conversation($a,array(array_merge($contact_record,$datarray)),'search', false, true);
logger('preview: ' . $o);
echo json_encode(array('preview' => $o));
@ -747,7 +761,7 @@ function item_post(&$a) {
if(x($datarray,'cancel')) {
logger('mod_item: post cancelled by plugin.');
if($return_path) {
goaway($a->get_baseurl() . "/" . $return_path);
goaway($return_path);
}
$json = array('cancel' => 1);
@ -786,13 +800,14 @@ function item_post(&$a) {
proc_run(PRIORITY_HIGH, "include/notifier.php", 'edit_post', $post_id);
if((x($_REQUEST,'return')) && strlen($return_path)) {
logger('return: ' . $return_path);
goaway($a->get_baseurl() . "/" . $return_path );
goaway($return_path);
}
killme();
}
else
} else
$post_id = 0;
q("COMMIT");
q("START TRANSACTION;");
$r = q("INSERT INTO `item` (`guid`, `extid`, `uid`,`type`,`wall`,`gravity`, `network`, `contact-id`,
`owner-name`,`owner-link`,`owner-avatar`, `owner-id`,
@ -802,7 +817,8 @@ function item_post(&$a) {
`tag`, `inform`, `verb`, `object-type`, `postopts`,
`allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `private`,
`pubmail`, `attach`, `bookmark`,`origin`, `moderated`, `file`,
`rendered-html`, `rendered-hash`)
`rendered-html`, `rendered-hash`, `gcontact-id`, `object`,
`parent`, `parent-uri`, `plink`, `last-child`, `visible`)
VALUES('%s', '%s', %d, '%s', %d, %d, '%s', %d,
'%s', '%s', '%s', %d,
'%s', '%s', '%s', %d,
@ -811,7 +827,8 @@ function item_post(&$a) {
'%s', '%s', '%s', '%s', '%s',
'%s', '%s', '%s', '%s', %d,
%d, '%s', %d, %d, %d, '%s',
'%s', '%s')",
'%s', '%s', %d, '%s',
%d, '%s', '%s', %d, %d)",
dbesc($datarray['guid']),
dbesc($datarray['extid']),
intval($datarray['uid']),
@ -857,23 +874,41 @@ function item_post(&$a) {
intval($datarray['moderated']),
dbesc($datarray['file']),
dbesc($datarray['rendered-html']),
dbesc($datarray['rendered-hash'])
dbesc($datarray['rendered-hash']),
intval($datarray['gcontact-id']),
dbesc($datarray['object']),
intval($datarray['parent']),
dbesc($datarray['parent-uri']),
dbesc($datarray['plink']),
intval($datarray['last-child']),
intval($datarray['visible'])
);
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1",
dbesc($datarray['uri']));
if(!count($r)) {
if (dbm::is_result($r)) {
$r = q("SELECT LAST_INSERT_ID() AS `item-id`");
if (dbm::is_result($r)) {
$post_id = $r[0]['item-id'];
} else {
$post_id = 0;
}
} else {
logger('mod_item: unable to create post.');
$post_id = 0;
}
if ($post_id == 0) {
q("COMMIT");
logger('mod_item: unable to retrieve post that was just stored.');
notice( t('System error. Post not saved.') . EOL);
goaway($a->get_baseurl() . "/" . $return_path );
notice(t('System error. Post not saved.') . EOL);
goaway($return_path);
// NOTREACHED
}
$post_id = $r[0]['id'];
logger('mod_item: saved item ' . $post_id);
$datarray["id"] = $post_id;
$datarray["plink"] = $a->get_baseurl().'/display/'.urlencode($datarray["guid"]);
item_set_last_item($datarray);
// update filetags in pconfig
file_tag_update_pconfig($uid,$categories_old,$categories_new,'category');
@ -881,23 +916,18 @@ function item_post(&$a) {
if($parent) {
// This item is the last leaf and gets the comment box, clear any ancestors
$r = q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent` = %d ",
$r = q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent` = %d AND `last-child` AND `id` != %d",
dbesc(datetime_convert()),
intval($parent),
intval($post_id)
);
// update the commented timestamp on the parent
q("UPDATE `item` SET `visible` = 1, `commented` = '%s', `changed` = '%s' WHERE `id` = %d",
dbesc(datetime_convert()),
dbesc(datetime_convert()),
intval($parent)
);
update_thread($parent, true);
// Inherit ACLs from the parent item.
$r = q("UPDATE `item` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `private` = %d
WHERE `id` = %d",
dbesc($parent_item['allow_cid']),
dbesc($parent_item['allow_gid']),
dbesc($parent_item['deny_cid']),
dbesc($parent_item['deny_gid']),
intval($parent_item['private']),
intval($post_id)
);
if($contact_record != $author) {
notification(array(
@ -927,6 +957,10 @@ function item_post(&$a) {
} else {
$parent = $post_id;
$r = q("UPDATE `item` SET `parent` = %d WHERE `id` = %d",
intval($parent),
intval($post_id));
if($contact_record != $author) {
notification(array(
'type' => NOTIFY_WALL,
@ -946,41 +980,6 @@ function item_post(&$a) {
}
}
// fallback so that parent always gets set to non-zero.
if(! $parent)
$parent = $post_id;
$r = q("UPDATE `item` SET `parent` = %d, `parent-uri` = '%s', `plink` = '%s', `changed` = '%s', `last-child` = 1, `visible` = 1
WHERE `id` = %d",
intval($parent),
dbesc(($parent == $post_id) ? $uri : $parent_item['uri']),
dbesc($a->get_baseurl().'/display/'.urlencode($datarray['guid'])),
dbesc(datetime_convert()),
intval($post_id)
);
// photo comments turn the corresponding item visible to the profile wall
// This way we don't see every picture in your new photo album posted to your wall at once.
// They will show up as people comment on them.
if(! $parent_item['visible']) {
$r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d",
intval($parent_item['id'])
);
update_thread($parent_item['id']);
}
// update the commented timestamp on the parent
q("UPDATE `item` set `commented` = '%s', `changed` = '%s' WHERE `id` = %d",
dbesc(datetime_convert()),
dbesc(datetime_convert()),
intval($parent)
);
if ($post_id != $parent)
update_thread($parent);
call_hooks('post_local_end', $datarray);
if(strlen($emailcc) && $profile_uid == local_user()) {
@ -1017,21 +1016,24 @@ function item_post(&$a) {
}
}
if ($post_id == $parent) {
add_thread($post_id);
} else {
update_thread($parent, true);
}
q("COMMIT");
create_tags_from_item($post_id);
create_files_from_item($post_id);
if ($post_id == $parent)
add_thread($post_id);
// This is a real juggling act on shared hosting services which kill your processes
// e.g. dreamhost. We used to start delivery to our native delivery agents in the background
// and then run our plugin delivery from the foreground. We're now doing plugin delivery first,
// because as soon as you start loading up a bunch of remote delivey processes, *this* page is
// likely to get killed off. If you end up looking at an /item URL and a blank page,
// it's very likely the delivery got killed before all your friends could be notified.
// Currently the only realistic fixes are to use a reliable server - which precludes shared hosting,
// or cut back on plugins which do remote deliveries.
// Insert an item entry for UID=0 for global entries.
// We now do it in the background to save some time.
// This is important in interactive environments like the frontend or the API.
// We don't fork a new process since this is done anyway with the following command
proc_run(array('priority' => PRIORITY_HIGH, 'dont_fork' => true), "include/create_shadowentry.php", $post_id);
// Call the background process that is delivering the item to the receivers
proc_run(PRIORITY_HIGH, "include/notifier.php", $notify_type, $post_id);
logger('post_complete');
@ -1047,7 +1049,7 @@ function item_post_return($baseurl, $api_source, $return_path) {
return;
if($return_path) {
goaway($baseurl . "/" . $return_path);
goaway($return_path);
}
$json = array('success' => 1);

View file

@ -1,6 +1,10 @@
<?php
function maintenance_content(&$a) {
header('HTTP/1.1 503 Service Temporarily Unavailable');
header('Status: 503 Service Temporarily Unavailable');
header('Retry-After: 600');
return replace_macros(get_markup_template('maintenance.tpl'), array(
'$sysdown' => t('System down for maintenance')
));

View file

@ -81,7 +81,7 @@ function match_content(&$a) {
'details' => $contact_details['location'],
'tags' => $contact_details['keywords'],
'about' => $contact_details['about'],
'account_type' => (($contact_details['community']) ? t('Forum') : ''),
'account_type' => account_type($contact_details),
'thumb' => proxy_url($jj->photo, false, PROXY_SIZE_THUMB),
'inttxt' => ' ' . t('is interested in:'),
'conntxt' => t('Connect'),

View file

@ -122,7 +122,7 @@ function network_init(&$a) {
$search = ((x($_GET,'search')) ? escape_tags($_GET['search']) : '');
if(x($_GET,'save')) {
$r = q("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()),
dbesc($search)
);
@ -176,7 +176,7 @@ function saved_searches($search) {
$o = '';
$r = q("SELECT `id`,`term` FROM `search` WHERE `uid` = %d",
$r = qu("SELECT `id`,`term` FROM `search` WHERE `uid` = %d",
intval(local_user())
);
@ -375,7 +375,7 @@ function network_content(&$a, $update = 0) {
$def_acl = array('allow_cid' => '<' . intval($cid) . '>');
if($nets) {
$r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND network = '%s' AND `self` = 0",
$r = qu("SELECT `id` FROM `contact` WHERE `uid` = %d AND network = '%s' AND `self` = 0",
intval(local_user()),
dbesc($nets)
);
@ -395,10 +395,10 @@ function network_content(&$a, $update = 0) {
if($group) {
if(($t = group_public_members($group)) && (! get_pconfig(local_user(),'system','nowarn_insecure'))) {
notice( sprintf( tt('Warning: This group contains %s member from an insecure network.',
'Warning: This group contains %s members from an insecure network.',
$t), $t ) . EOL);
notice( t('Private messages to this group are at risk of public disclosure.') . EOL);
notice(sprintf(tt("Warning: This group contains %s member from a network that doesn't allow non public messages.",
"Warning: This group contains %s members from a network that doesn't allow non public messages.",
$t), $t).EOL);
notice(t("Messages in this group won't be send to these receivers.").EOL);
}
}
@ -408,7 +408,7 @@ function network_content(&$a, $update = 0) {
if ($cid) {
// If $cid belongs to a communitity forum or a privat goup,.add a mention to the status editor
$contact = q("SELECT `nick` FROM `contact` WHERE `id` = %d AND `uid` = %d AND (`forum` OR `prv`) ",
$contact = qu("SELECT `nick` FROM `contact` WHERE `id` = %d AND `uid` = %d AND (`forum` OR `prv`) ",
intval($cid),
intval(local_user())
);
@ -442,8 +442,8 @@ function network_content(&$a, $update = 0) {
// desired.
$sql_post_table = "";
$sql_options = (($star) ? " and starred = 1 " : '');
$sql_options .= (($bmark) ? " and bookmark = 1 " : '');
$sql_options = (($star) ? " AND `thread`.`starred` " : '');
$sql_options .= (($bmark) ? " AND `thread`.`bookmark` " : '');
$sql_extra = $sql_options;
$sql_extra2 = "";
$sql_extra3 = "";
@ -453,12 +453,13 @@ function network_content(&$a, $update = 0) {
if ($nouveau OR strlen($file) OR $update) {
$sql_table = "`item`";
$sql_parent = "`parent`";
$sql_post_table = " INNER JOIN `thread` ON `thread`.`iid` = `item`.`parent`";
}
$sql_nets = (($nets) ? sprintf(" and $sql_table.`network` = '%s' ", dbesc($nets)) : '');
if($group) {
$r = q("SELECT `name`, `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1",
$r = qu("SELECT `name`, `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($group),
intval($_SESSION['uid'])
);
@ -479,7 +480,7 @@ function network_content(&$a, $update = 0) {
$contact_str = implode(',',$contacts);
$gcontact_str = implode(',',$gcontacts);
$self = q("SELECT `contact`.`id`, `gcontact`.`id` AS `gid` FROM `contact`
$self = qu("SELECT `contact`.`id`, `gcontact`.`id` AS `gid` FROM `contact`
INNER JOIN `gcontact` ON `gcontact`.`nurl` = `contact`.`nurl`
WHERE `uid` = %d AND `self`", intval($_SESSION['uid']));
if (count($self)) {
@ -487,9 +488,9 @@ function network_content(&$a, $update = 0) {
$gcontact_str_self = $self[0]["gid"];
}
$sql_post_table = " INNER JOIN `item` AS `temp1` ON `temp1`.`id` = ".$sql_table.".".$sql_parent;
$sql_extra3 .= " AND ($sql_table.`contact-id` IN ($contact_str) ";
$sql_extra3 .= " OR ($sql_table.`contact-id` = '$contact_str_self' AND `temp1`.`allow_gid` LIKE '".protect_sprintf('%<'.intval($group).'>%')."' AND `temp1`.`private`))";
$sql_post_table .= " INNER JOIN `item` AS `temp1` ON `temp1`.`id` = ".$sql_table.".".$sql_parent;
$sql_extra3 .= " AND (`thread`.`contact-id` IN ($contact_str) ";
$sql_extra3 .= " OR (`thread`.`contact-id` = '$contact_str_self' AND `temp1`.`allow_gid` LIKE '".protect_sprintf('%<'.intval($group).'>%')."' AND `temp1`.`private`))";
} else {
$sql_extra3 .= " AND false ";
info( t('Group is empty'));
@ -502,8 +503,8 @@ function network_content(&$a, $update = 0) {
}
elseif($cid) {
$r = q("SELECT `id`,`name`,`network`,`writable`,`nurl`, `forum`, `prv`, `addr`, `thumb`, `location` FROM `contact` WHERE `id` = %d
AND `blocked` = 0 AND `pending` = 0 LIMIT 1",
$r = qu("SELECT `id`,`name`,`network`,`writable`,`nurl`, `forum`, `prv`, `contact-type`, `addr`, `thumb`, `location` FROM `contact` WHERE `id` = %d
AND (NOT `blocked` OR `pending`) LIMIT 1",
intval($cid)
);
if(count($r)) {
@ -514,10 +515,11 @@ function network_content(&$a, $update = 0) {
'name' => htmlentities($r[0]['name']),
'itemurl' => (($r[0]['addr']) ? ($r[0]['addr']) : ($r[0]['nurl'])),
'thumb' => proxy_url($r[0]['thumb'], false, PROXY_SIZE_THUMB),
'account_type' => (($r[0]['forum']) || ($r[0]['prv']) ? t('Forum') : ''),
'details' => $r[0]['location'],
);
$entries[0]["account_type"] = account_type($r[0]);
$o = replace_macros(get_markup_template("viewcontact_template.tpl"),array(
'contacts' => $entries,
'id' => 'network',
@ -568,7 +570,7 @@ function network_content(&$a, $update = 0) {
if($tag) {
$sql_extra = "";
$sql_post_table = sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
$sql_post_table .= sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG), intval(local_user()));
$sql_order = "`item`.`id`";
$order_mode = "id";
@ -577,12 +579,12 @@ function network_content(&$a, $update = 0) {
$sql_extra = sprintf(" AND MATCH (`item`.`body`, `item`.`title`) AGAINST ('%s' in boolean mode) ", dbesc(protect_sprintf($search)));
else
$sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search))));
$sql_order = "`item`.`received`";
$order_mode = "received";
$sql_order = "`item`.`id`";
$order_mode = "id";
}
}
if(strlen($file)) {
$sql_post_table = sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
$sql_post_table .= sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
dbesc(protect_sprintf($file)), intval(TERM_OBJ_POST), intval(TERM_FILE), intval(local_user()));
$sql_order = "`item`.`id`";
$order_mode = "id";
@ -596,12 +598,11 @@ function network_content(&$a, $update = 0) {
// only setup pagination on initial page view
$pager_sql = '';
}
else {
} else {
if(get_config('system', 'old_pager')) {
$r = q("SELECT COUNT(*) AS `total`
$r = qu("SELECT COUNT(*) AS `total`
FROM $sql_table $sql_post_table INNER JOIN `contact` ON `contact`.`id` = $sql_table.`contact-id`
AND NOT `contact`.`blocked` AND NOT `contact`.`pending`
AND (NOT `contact`.`blocked` OR `contact`.`pending`)
WHERE $sql_table.`uid` = %d AND $sql_table.`visible` AND NOT $sql_table.`deleted`
$sql_extra2 $sql_extra3
$sql_extra $sql_nets ",
@ -636,10 +637,10 @@ function network_content(&$a, $update = 0) {
$simple_update = (($update) ? " AND `item`.`unseen` " : '');
if ($sql_order == "")
$sql_order = "`item`.`received`";
$sql_order = "`item`.`id`";
// "New Item View" - show all items unthreaded in reverse created date order
$items = q("SELECT %s FROM $sql_table $sql_post_table %s
$items = qu("SELECT %s FROM $sql_table $sql_post_table %s
WHERE %s AND `item`.`uid` = %d
$simple_update
$sql_extra $sql_nets
@ -677,9 +678,9 @@ function network_content(&$a, $update = 0) {
else
$sql_extra4 = "";
$r = q("SELECT `item`.`parent` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`uid` AS `contact_uid`
$r = qu("SELECT `item`.`parent` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`uid` AS `contact_uid`
FROM $sql_table $sql_post_table INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
AND NOT `contact`.`blocked` AND NOT `contact`.`pending`
AND (NOT `contact`.`blocked` OR `contact`.`pending`)
WHERE `item`.`uid` = %d AND `item`.`visible` AND NOT `item`.`deleted` $sql_extra4
AND NOT `item`.`moderated` AND `item`.`unseen`
$sql_extra3 $sql_extra $sql_nets
@ -687,9 +688,9 @@ function network_content(&$a, $update = 0) {
intval(local_user())
);
} else {
$r = q("SELECT `thread`.`iid` AS `item_id`, `thread`.`network` AS `item_network`, `contact`.`uid` AS `contact_uid`
$r = qu("SELECT `thread`.`iid` AS `item_id`, `thread`.`network` AS `item_network`, `contact`.`uid` AS `contact_uid`
FROM $sql_table $sql_post_table STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
AND NOT `contact`.`blocked` AND NOT `contact`.`pending`
AND (NOT `contact`.`blocked` OR `contact`.`pending`)
WHERE `thread`.`uid` = %d AND `thread`.`visible` AND NOT `thread`.`deleted`
AND NOT `thread`.`moderated`
$sql_extra2 $sql_extra3 $sql_extra $sql_nets
@ -721,7 +722,7 @@ function network_content(&$a, $update = 0) {
$items = array();
foreach ($parents_arr AS $parents) {
$thread_items = q(item_query()." AND `item`.`uid` = %d
$thread_items = qu(item_query()." AND `item`.`uid` = %d
AND `item`.`parent` = %d
ORDER BY `item`.`commented` DESC LIMIT %d",
intval(local_user()),

View file

@ -185,20 +185,13 @@ function nodeinfo_cron() {
}
logger("cron_start");
$users = q("SELECT profile.*, `user`.`login_date`, `lastitem`.`lastitem_date`
FROM (SELECT MAX(`item`.`changed`) as `lastitem_date`, `item`.`uid`
FROM `item`
WHERE `item`.`type` = 'wall'
GROUP BY `item`.`uid`) AS `lastitem`
RIGHT OUTER JOIN `user` ON `user`.`uid` = `lastitem`.`uid`, `contact`, `profile`
WHERE
`user`.`uid` = `contact`.`uid` AND `profile`.`uid` = `user`.`uid`
AND `profile`.`is-default` AND (`profile`.`publish` OR `profile`.`net-publish`)
AND `user`.`verified` AND `contact`.`self`
AND NOT `user`.`blocked`
AND NOT `user`.`account_removed`
AND NOT `user`.`account_expired`");
$users = qu("SELECT `user`.`uid`, `user`.`login_date`, `contact`.`last-item`
FROM `user`
INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid` AND `profile`.`is-default`
INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
WHERE (`profile`.`publish` OR `profile`.`net-publish`) AND `user`.`verified`
AND NOT `user`.`blocked` AND NOT `user`.`account_removed`
AND NOT `user`.`account_expired`");
if (is_array($users)) {
$total_users = count($users);
$active_users_halfyear = 0;
@ -209,11 +202,11 @@ function nodeinfo_cron() {
foreach ($users AS $user) {
if ((strtotime($user['login_date']) > $halfyear) OR
(strtotime($user['lastitem_date']) > $halfyear))
(strtotime($user['last-item']) > $halfyear))
++$active_users_halfyear;
if ((strtotime($user['login_date']) > $month) OR
(strtotime($user['lastitem_date']) > $month))
(strtotime($user['last-item']) > $month))
++$active_users_monthly;
}
@ -224,11 +217,7 @@ function nodeinfo_cron() {
set_config('nodeinfo','active_users_monthly', $active_users_monthly);
}
//$posts = q("SELECT COUNT(*) AS local_posts FROM `item` WHERE `wall` AND `uid` != 0 AND `id` = `parent` AND left(body, 6) != '[share'");
$posts = q("SELECT COUNT(*) AS `local_posts` FROM `item`
INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `contact`.`self` and `item`.`id` = `item`.`parent` AND left(body, 6) != '[share' AND `item`.`network` IN ('%s', '%s', '%s')",
dbesc(NETWORK_OSTATUS), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_DFRN));
$posts = qu("SELECT COUNT(*) AS local_posts FROM `thread` WHERE `thread`.`wall` AND `thread`.`uid` != 0");
if (!is_array($posts))
$local_posts = -1;
@ -239,7 +228,7 @@ function nodeinfo_cron() {
logger("local_posts: ".$local_posts, LOGGER_DEBUG);
$posts = q("SELECT COUNT(*) AS `local_comments` FROM `item`
$posts = qu("SELECT COUNT(*) AS `local_comments` FROM `item`
INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `contact`.`self` and `item`.`id` != `item`.`parent` AND `item`.`network` IN ('%s', '%s', '%s')",
dbesc(NETWORK_OSTATUS), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_DFRN));

View file

@ -1,503 +1,176 @@
<?php
/**
* @file mod/parse_url.php
* @brief The parse_url module
*
* @todo https://developers.google.com/+/plugins/snippet/
* This module does parse an url for embedable content (audio, video, image files or link)
* information and does format this information to BBCode or html (this depends
* on the user settings - default is BBCode output).
* If the user has enabled the richtext editor setting the output will be in html
* (Note: This is not always possible and in some case not useful because
* the richtext editor doesn't support all kind of html).
* Otherwise the output will be constructed BBCode.
*
* @verbatim
* <meta itemprop="name" content="Toller Titel">
* <meta itemprop="description" content="Eine tolle Beschreibung">
* <meta itemprop="image" content="http://maple.libertreeproject.org/images/tree-icon.png">
*
* <body itemscope itemtype="http://schema.org/Product">
* <h1 itemprop="name">Shiny Trinket</h1>
* <img itemprop="image" src="{image-url}" />
* <p itemprop="description">Shiny trinkets are shiny.</p>
* </body>
* @endverbatim
* @see ParseUrl::getSiteinfo() for more information about scraping embeddable content
*/
if(!function_exists('deletenode')) {
function deletenode(&$doc, $node)
{
$xpath = new DomXPath($doc);
$list = $xpath->query("//".$node);
foreach ($list as $child)
$child->parentNode->removeChild($child);
}
}
use \Friendica\ParseUrl;
function completeurl($url, $scheme) {
$urlarr = parse_url($url);
if (isset($urlarr["scheme"]))
return($url);
$schemearr = parse_url($scheme);
$complete = $schemearr["scheme"]."://".$schemearr["host"];
if (@$schemearr["port"] != "")
$complete .= ":".$schemearr["port"];
if(strpos($urlarr['path'],'/') !== 0)
$complete .= '/';
$complete .= $urlarr["path"];
if (@$urlarr["query"] != "")
$complete .= "?".$urlarr["query"];
if (@$urlarr["fragment"] != "")
$complete .= "#".$urlarr["fragment"];
return($complete);
}
function parseurl_getsiteinfo_cached($url, $no_guessing = false, $do_oembed = true) {
if ($url == "")
return false;
$r = q("SELECT * FROM `parsed_url` WHERE `url` = '%s' AND `guessing` = %d AND `oembed` = %d",
dbesc(normalise_link($url)), intval(!$no_guessing), intval($do_oembed));
if ($r)
$data = $r[0]["content"];
if (!is_null($data)) {
$data = unserialize($data);
return $data;
}
$data = parseurl_getsiteinfo($url, $no_guessing, $do_oembed);
q("INSERT INTO `parsed_url` (`url`, `guessing`, `oembed`, `content`, `created`) VALUES ('%s', %d, %d, '%s', '%s')
ON DUPLICATE KEY UPDATE `content` = '%s', `created` = '%s'",
dbesc(normalise_link($url)), intval(!$no_guessing), intval($do_oembed),
dbesc(serialize($data)), dbesc(datetime_convert()),
dbesc(serialize($data)), dbesc(datetime_convert()));
return $data;
}
function parseurl_getsiteinfo($url, $no_guessing = false, $do_oembed = true, $count = 1) {
require_once("include/network.php");
require_once("include/Photo.php");
$a = get_app();
$siteinfo = array();
if ($count > 10) {
logger("parseurl_getsiteinfo: Endless loop detected for ".$url, LOGGER_DEBUG);
return($siteinfo);
}
$url = trim($url, "'");
$url = trim($url, '"');
$url = original_url($url);
$siteinfo["url"] = $url;
$siteinfo["type"] = "link";
$stamp1 = microtime(true);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $a->get_useragent());
$header = curl_exec($ch);
$curl_info = @curl_getinfo($ch);
$http_code = $curl_info['http_code'];
curl_close($ch);
$a->save_timestamp($stamp1, "network");
if ((($curl_info['http_code'] == "301") OR ($curl_info['http_code'] == "302") OR ($curl_info['http_code'] == "303") OR ($curl_info['http_code'] == "307"))
AND (($curl_info['redirect_url'] != "") OR ($curl_info['location'] != ""))) {
if ($curl_info['redirect_url'] != "")
$siteinfo = parseurl_getsiteinfo($curl_info['redirect_url'], $no_guessing, $do_oembed, ++$count);
else
$siteinfo = parseurl_getsiteinfo($curl_info['location'], $no_guessing, $do_oembed, ++$count);
return($siteinfo);
}
// if the file is too large then exit
if ($curl_info["download_content_length"] > 1000000)
return($siteinfo);
// if it isn't a HTML file then exit
if (($curl_info["content_type"] != "") AND !strstr(strtolower($curl_info["content_type"]),"html"))
return($siteinfo);
if ($do_oembed) {
require_once("include/oembed.php");
$oembed_data = oembed_fetch_url($url);
if ($oembed_data->type != "error")
$siteinfo["type"] = $oembed_data->type;
if (($oembed_data->type == "link") AND ($siteinfo["type"] != "photo")) {
if (isset($oembed_data->title))
$siteinfo["title"] = $oembed_data->title;
if (isset($oembed_data->description))
$siteinfo["text"] = trim($oembed_data->description);
if (isset($oembed_data->thumbnail_url))
$siteinfo["image"] = $oembed_data->thumbnail_url;
}
}
$stamp1 = microtime(true);
// Now fetch the body as well
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, $a->get_useragent());
$header = curl_exec($ch);
$curl_info = @curl_getinfo($ch);
$http_code = $curl_info['http_code'];
curl_close($ch);
$a->save_timestamp($stamp1, "network");
// Fetch the first mentioned charset. Can be in body or header
$charset = "";
if (preg_match('/charset=(.*?)['."'".'"\s\n]/', $header, $matches))
$charset = trim(trim(trim(array_pop($matches)), ';,'));
if ($charset == "")
$charset = "utf-8";
$pos = strpos($header, "\r\n\r\n");
if ($pos)
$body = trim(substr($header, $pos));
else
$body = $header;
if (($charset != '') AND (strtoupper($charset) != "UTF-8")) {
logger("parseurl_getsiteinfo: detected charset ".$charset, LOGGER_DEBUG);
//$body = mb_convert_encoding($body, "UTF-8", $charset);
$body = iconv($charset, "UTF-8//TRANSLIT", $body);
}
$body = mb_convert_encoding($body, 'HTML-ENTITIES', "UTF-8");
$doc = new DOMDocument();
@$doc->loadHTML($body);
deletenode($doc, 'style');
deletenode($doc, 'script');
deletenode($doc, 'option');
deletenode($doc, 'h1');
deletenode($doc, 'h2');
deletenode($doc, 'h3');
deletenode($doc, 'h4');
deletenode($doc, 'h5');
deletenode($doc, 'h6');
deletenode($doc, 'ol');
deletenode($doc, 'ul');
$xpath = new DomXPath($doc);
$list = $xpath->query("//meta[@content]");
foreach ($list as $node) {
$attr = array();
if ($node->attributes->length)
foreach ($node->attributes as $attribute)
$attr[$attribute->name] = $attribute->value;
if (@$attr["http-equiv"] == 'refresh') {
$path = $attr["content"];
$pathinfo = explode(";", $path);
$content = "";
foreach ($pathinfo AS $value) {
if (substr(strtolower($value), 0, 4) == "url=")
$content = substr($value, 4);
}
if ($content != "") {
$siteinfo = parseurl_getsiteinfo($content, $no_guessing, $do_oembed, ++$count);
return($siteinfo);
}
}
}
$list = $xpath->query("//title");
if ($list->length > 0)
$siteinfo["title"] = $list->item(0)->nodeValue;
//$list = $xpath->query("head/meta[@name]");
$list = $xpath->query("//meta[@name]");
foreach ($list as $node) {
$attr = array();
if ($node->attributes->length)
foreach ($node->attributes as $attribute)
$attr[$attribute->name] = $attribute->value;
$attr["content"] = trim(html_entity_decode($attr["content"], ENT_QUOTES, "UTF-8"));
if ($attr["content"] != "")
switch (strtolower($attr["name"])) {
case "fulltitle":
$siteinfo["title"] = $attr["content"];
break;
case "description":
$siteinfo["text"] = $attr["content"];
break;
case "thumbnail":
$siteinfo["image"] = $attr["content"];
break;
case "twitter:image":
$siteinfo["image"] = $attr["content"];
break;
case "twitter:image:src":
$siteinfo["image"] = $attr["content"];
break;
case "twitter:card":
if (($siteinfo["type"] == "") OR ($attr["content"] == "photo"))
$siteinfo["type"] = $attr["content"];
break;
case "twitter:description":
$siteinfo["text"] = $attr["content"];
break;
case "twitter:title":
$siteinfo["title"] = $attr["content"];
break;
case "dc.title":
$siteinfo["title"] = $attr["content"];
break;
case "dc.description":
$siteinfo["text"] = $attr["content"];
break;
case "keywords":
$keywords = explode(",", $attr["content"]);
break;
case "news_keywords":
$keywords = explode(",", $attr["content"]);
break;
}
if ($siteinfo["type"] == "summary")
$siteinfo["type"] = "link";
}
if (isset($keywords)) {
$siteinfo["keywords"] = array();
foreach ($keywords as $keyword)
if (!in_array(trim($keyword), $siteinfo["keywords"]))
$siteinfo["keywords"][] = trim($keyword);
}
//$list = $xpath->query("head/meta[@property]");
$list = $xpath->query("//meta[@property]");
foreach ($list as $node) {
$attr = array();
if ($node->attributes->length)
foreach ($node->attributes as $attribute)
$attr[$attribute->name] = $attribute->value;
$attr["content"] = trim(html_entity_decode($attr["content"], ENT_QUOTES, "UTF-8"));
if ($attr["content"] != "")
switch (strtolower($attr["property"])) {
case "og:image":
$siteinfo["image"] = $attr["content"];
break;
case "og:title":
$siteinfo["title"] = $attr["content"];
break;
case "og:description":
$siteinfo["text"] = $attr["content"];
break;
}
}
if ((@$siteinfo["image"] == "") AND !$no_guessing) {
$list = $xpath->query("//img[@src]");
foreach ($list as $node) {
$attr = array();
if ($node->attributes->length)
foreach ($node->attributes as $attribute)
$attr[$attribute->name] = $attribute->value;
$src = completeurl($attr["src"], $url);
$photodata = get_photo_info($src);
if (($photodata) && ($photodata[0] > 150) and ($photodata[1] > 150)) {
if ($photodata[0] > 300) {
$photodata[1] = round($photodata[1] * (300 / $photodata[0]));
$photodata[0] = 300;
}
if ($photodata[1] > 300) {
$photodata[0] = round($photodata[0] * (300 / $photodata[1]));
$photodata[1] = 300;
}
$siteinfo["images"][] = array("src"=>$src,
"width"=>$photodata[0],
"height"=>$photodata[1]);
}
}
} elseif ($siteinfo["image"] != "") {
$src = completeurl($siteinfo["image"], $url);
unset($siteinfo["image"]);
$photodata = get_photo_info($src);
if (($photodata) && ($photodata[0] > 10) and ($photodata[1] > 10))
$siteinfo["images"][] = array("src"=>$src,
"width"=>$photodata[0],
"height"=>$photodata[1]);
}
if ((@$siteinfo["text"] == "") AND (@$siteinfo["title"] != "") AND !$no_guessing) {
$text = "";
$list = $xpath->query("//div[@class='article']");
foreach ($list as $node)
if (strlen($node->nodeValue) > 40)
$text .= " ".trim($node->nodeValue);
if ($text == "") {
$list = $xpath->query("//div[@class='content']");
foreach ($list as $node)
if (strlen($node->nodeValue) > 40)
$text .= " ".trim($node->nodeValue);
}
// If none text was found then take the paragraph content
if ($text == "") {
$list = $xpath->query("//p");
foreach ($list as $node)
if (strlen($node->nodeValue) > 40)
$text .= " ".trim($node->nodeValue);
}
if ($text != "") {
$text = trim(str_replace(array("\n", "\r"), array(" ", " "), $text));
while (strpos($text, " "))
$text = trim(str_replace(" ", " ", $text));
$siteinfo["text"] = trim(html_entity_decode(substr($text,0,350), ENT_QUOTES, "UTF-8").'...');
}
}
logger("parseurl_getsiteinfo: Siteinfo for ".$url." ".print_r($siteinfo, true), LOGGER_DEBUG);
call_hooks('getsiteinfo', $siteinfo);
return($siteinfo);
}
function arr_add_hashes(&$item,$k) {
$item = '#' . $item;
}
require_once("include/items.php");
function parse_url_content(&$a) {
require_once("include/items.php");
$text = null;
$str_tags = '';
$str_tags = "";
$textmode = false;
if(local_user() && (! feature_enabled(local_user(),'richtext')))
if (local_user() && (!feature_enabled(local_user(), "richtext"))) {
$textmode = true;
}
//if($textmode)
$br = (($textmode) ? "\n" : '<br />');
$br = (($textmode) ? "\n" : "<br />");
if(x($_GET,'binurl'))
$url = trim(hex2bin($_GET['binurl']));
else
$url = trim($_GET['url']);
if (x($_GET,"binurl")) {
$url = trim(hex2bin($_GET["binurl"]));
} else {
$url = trim($_GET["url"]);
}
if($_GET['title'])
$title = strip_tags(trim($_GET['title']));
if ($_GET["title"]) {
$title = strip_tags(trim($_GET["title"]));
}
if($_GET['description'])
$text = strip_tags(trim($_GET['description']));
if ($_GET["description"]) {
$text = strip_tags(trim($_GET["description"]));
}
if($_GET['tags']) {
$arr_tags = str_getcsv($_GET['tags']);
if(count($arr_tags)) {
array_walk($arr_tags,'arr_add_hashes');
$str_tags = $br . implode(' ',$arr_tags) . $br;
if ($_GET["tags"]) {
$arr_tags = ParseUrl::convertTagsToArray($_GET["tags"]);
if (count($arr_tags)) {
$str_tags = $br . implode(" ", $arr_tags) . $br;
}
}
// add url scheme if missing
// Add url scheme if it is missing
$arrurl = parse_url($url);
if (!x($arrurl, 'scheme')) {
if (x($arrurl, 'host'))
if (!x($arrurl, "scheme")) {
if (x($arrurl, "host")) {
$url = "http:".$url;
else
} else {
$url = "http://".$url;
}
}
logger('parse_url: ' . $url);
logger("prse_url: " . $url);
if($textmode)
$template = '[bookmark=%s]%s[/bookmark]%s';
else
// Check if the URL is an image, video or audio file. If so format
// the URL with the corresponding BBCode media tag
$redirects = 0;
// Fetch the header of the URL
$result = z_fetch_url($url, false, $redirects, array("novalidate" => true, "nobody" => true));
if($result["success"]) {
// Convert the header fields into an array
$hdrs = array();
$h = explode("\n", $result["header"]);
foreach ($h as $l) {
list($k,$v) = array_map("trim", explode(":", trim($l), 2));
$hdrs[$k] = $v;
}
if (array_key_exists("Content-Type", $hdrs)) {
$type = $hdrs["Content-Type"];
}
if ($type) {
if(stripos($type, "image/") !== false) {
echo $br . "[img]" . $url . "[/img]" . $br;
killme();
}
if (stripos($type, "video/") !== false) {
echo $br . "[video]" . $url . "[/video]" . $br;
killme();
}
if (stripos($type, "audio/") !== false) {
echo $br . "[audio]" . $url . "[/audio]" . $br;
killme();
}
}
}
if ($textmode) {
$template = "[bookmark=%s]%s[/bookmark]%s";
} else {
$template = "<a class=\"bookmark\" href=\"%s\" >%s</a>%s";
}
$arr = array('url' => $url, 'text' => '');
$arr = array("url" => $url, "text" => "");
call_hooks('parse_link', $arr);
call_hooks("parse_link", $arr);
if(strlen($arr['text'])) {
echo $arr['text'];
if (strlen($arr["text"])) {
echo $arr["text"];
killme();
}
// If there is allready some content information submitted we don't
// need to parse the url for content.
if ($url && $title && $text) {
if($url && $title && $text) {
$title = str_replace(array("\r","\n"),array("",""),$title);
$title = str_replace(array("\r","\n"),array('',''),$title);
if($textmode)
$text = '[quote]' . trim($text) . '[/quote]' . $br;
else {
$text = '<blockquote>' . htmlspecialchars(trim($text)) . '</blockquote><br />';
if ($textmode) {
$text = "[quote]" . trim($text) . "[/quote]" . $br;
} else {
$text = "<blockquote>" . htmlspecialchars(trim($text)) . "</blockquote><br />";
$title = htmlspecialchars($title);
}
$result = sprintf($template,$url,($title) ? $title : $url,$text) . $str_tags;
$result = sprintf($template, $url, ($title) ? $title : $url, $text) . $str_tags;
logger('parse_url (unparsed): returns: ' . $result);
logger("parse_url (unparsed): returns: " . $result);
echo $result;
killme();
}
$siteinfo = parseurl_getsiteinfo($url);
// Fetch the information directly from the webpage
$siteinfo = ParseUrl::getSiteinfo($url);
unset($siteinfo["keywords"]);
// Format it as BBCode attachment
$info = add_page_info_data($siteinfo);
if (!$textmode)
if (!$textmode) {
// Replace ' with - not perfect - but the richtext editor has problems otherwise
$info = str_replace(array("&#039;"), array("&#8217;"), $info);
}
echo $info;
killme();
}
?>
/**
* @brief Legacy function to call ParseUrl::getSiteinfoCached
*
* Note: We have moved the function to ParseUrl.php. This function is only for
* legacy support and will be remove in the future
*
* @param type $url The url of the page which should be scraped
* @param type $no_guessing If true the parse doens't search for
* preview pictures
* @param type $do_oembed The false option is used by the function fetch_oembed()
* to avoid endless loops
*
* @return array which contains needed data for embedding
*
* @see ParseUrl::getSiteinfoCached()
*
* @todo Remove this function after all Addons has been changed to use
* ParseUrl::getSiteinfoCached
*/
function parseurl_getsiteinfo_cached($url, $no_guessing = false, $do_oembed = true) {
$siteinfo = ParseUrl::getSiteinfoCached($url, $no_guessing, $do_oembed);
return $siteinfo;
}

View file

@ -72,7 +72,7 @@ function photo_init(&$a) {
$uid = str_replace(array('.jpg','.png'),array('',''), $person);
$r = q("SELECT * FROM `photo` WHERE `scale` = %d AND `uid` = %d AND `profile` = 1 LIMIT 1",
$r = qu("SELECT * FROM `photo` WHERE `scale` = %d AND `uid` = %d AND `profile` = 1 LIMIT 1",
intval($resolution),
intval($uid)
);
@ -102,7 +102,7 @@ function photo_init(&$a) {
}
// check if the photo exists and get the owner of the photo
$r = q("SELECT `uid` FROM `photo` WHERE `resource-id` = '%s' LIMIT 1",
$r = qu("SELECT `uid` FROM `photo` WHERE `resource-id` = '%s' LIMIT 1",
dbesc($photo),
intval($resolution)
);
@ -112,7 +112,7 @@ function photo_init(&$a) {
// Now we'll see if we can access the photo
$r = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' AND `scale` <= %d $sql_extra ORDER BY scale DESC LIMIT 1",
$r = qu("SELECT * FROM `photo` WHERE `resource-id` = '%s' AND `scale` <= %d $sql_extra ORDER BY scale DESC LIMIT 1",
dbesc($photo),
intval($resolution)
);

File diff suppressed because it is too large Load diff

View file

@ -3,43 +3,119 @@ require_once("include/datetime.php");
require_once('include/bbcode.php');
require_once('include/ForumManager.php');
require_once('include/group.php');
require_once("mod/proxy.php");
require_once('mod/proxy.php');
require_once('include/xml.php');
function ping_init(&$a) {
/**
* @brief Outputs the counts and the lists of various notifications
*
* The output format can be controlled via the GET parameter 'format'. It can be
* - xml (deprecated legacy default)
* - json (outputs JSONP with the 'callback' GET parameter)
*
* Expected JSON structure:
* {
* "result": {
* "intro": 0,
* "mail": 0,
* "net": 0,
* "home": 0,
* "register": 0,
* "all-events": 0,
* "all-events-today": 0,
* "events": 0,
* "events-today": 0,
* "birthdays": 0,
* "birthdays-today": 0,
* "groups": [ ],
* "forums": [ ],
* "notify": 0,
* "notifications": [ ],
* "sysmsgs": {
* "notice": [ ],
* "info": [ ]
* }
* }
* }
*
* @param App $a The Friendica App instance
*/
function ping_init(App $a)
{
$format = 'xml';
$xmlhead = "<"."?xml version='1.0' encoding='UTF-8' ?".">";
if (isset($_GET['format']) && $_GET['format'] == 'json') {
$format = 'json';
}
$tags = array();
$comments = array();
$likes = array();
$dislikes = array();
$friends = array();
$posts = array();
$regs = array();
$mails = array();
$notifications = array();
$intro_count = 0;
$mail_count = 0;
$home_count = 0;
$network_count = 0;
$register_count = 0;
$sysnotify_count = 0;
$groups_unseen = array();
$forums_unseen = array();
$all_events = 0;
$all_events_today = 0;
$events = 0;
$events_today = 0;
$birthdays = 0;
$birthdays_today = 0;
$data = array();
$data['intro'] = $intro_count;
$data['mail'] = $mail_count;
$data['net'] = $network_count;
$data['home'] = $home_count;
$data['register'] = $register_count;
$data['all-events'] = $all_events;
$data['all-events-today'] = $all_events_today;
$data['events'] = $events;
$data['events-today'] = $events_today;
$data['birthdays'] = $birthdays;
$data['birthdays-today'] = $birthdays_today;
if (local_user()){
// Different login session than the page that is calling us.
if (intval($_GET['uid']) && intval($_GET['uid']) != local_user()) {
$data = array("invalid" => 1);
header("Content-type: text/xml");
echo xml::from_array(array("result" => $data), $xml);
$data = array('result' => array('invalid' => 1));
if ($format == 'json') {
if (isset($_GET['callback'])) {
// JSONP support
header("Content-type: application/javascript");
echo $_GET['callback'] . '(' . json_encode($data) . ')';
} else {
header("Content-type: application/json");
echo json_encode($data);
}
} else {
header("Content-type: text/xml");
echo xml::from_array($data, $xml);
}
killme();
}
$notifs = ping_get_notifications(local_user());
$sysnotify = 0; // we will update this in a moment
$tags = array();
$comments = array();
$likes = array();
$dislikes = array();
$friends = array();
$posts = array();
$regs = array();
$mails = array();
$home = 0;
$network = 0;
$groups_unseen = array();
$forums_unseen = array();
$r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`wall`, `item`.`author-name`,
$items_unseen = qu("SELECT `item`.`id`, `item`.`parent`, `item`.`verb`, `item`.`wall`, `item`.`author-name`,
`item`.`contact-id`, `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`,
`pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`
FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`
`pitem`.`author-name` AS `pname`, `pitem`.`author-link` AS `plink`
FROM `item` INNER JOIN `item` AS `pitem` ON `pitem`.`id` = `item`.`parent`
WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND
`item`.`deleted` = 0 AND `item`.`uid` = %d AND `pitem`.`parent` != 0
AND `item`.`contact-id` != %d
@ -47,109 +123,93 @@ function ping_init(&$a) {
intval(local_user()), intval(local_user())
);
if (dbm::is_result($r)) {
$arr = array('items' => $r);
if (dbm::is_result($items_unseen)) {
$arr = array('items' => $items_unseen);
call_hooks('network_ping', $arr);
foreach ($r as $it) {
if ($it['wall'])
$home ++;
else
$network ++;
switch($it['verb']){
case ACTIVITY_TAG:
$obj = parse_xml_string($xmlhead.$it['object']);
$it['tname'] = $obj->content;
$tags[] = $it;
break;
case ACTIVITY_LIKE:
$likes[] = $it;
break;
case ACTIVITY_DISLIKE:
$dislikes[] = $it;
break;
case ACTIVITY_FRIEND:
$obj = parse_xml_string($xmlhead.$it['object']);
$it['fname'] = $obj->title;
$friends[] = $it;
break;
default:
if ($it['parent']!=$it['id']) {
$comments[] = $it;
} else {
if (!$it['wall'])
$posts[] = $it;
}
foreach ($items_unseen as $item) {
if ($item['wall']) {
$home_count++;
} else {
$network_count++;
}
}
}
if ($network) {
if (intval(feature_enabled(local_user(),'groups'))) {
if ($network_count) {
if (intval(feature_enabled(local_user(), 'groups'))) {
// Find out how unseen network posts are spread across groups
$groups_unseen = groups_count_unseen();
$group_counts = groups_count_unseen();
if (dbm::is_result($group_counts)) {
foreach ($group_counts as $group_count) {
if ($group_count['count'] > 0) {
$groups_unseen[] = $group_count;
}
}
}
}
if (intval(feature_enabled(local_user(),'forumlist_widget'))) {
$forums_unseen = ForumManager::count_unseen_items();
if (intval(feature_enabled(local_user(), 'forumlist_widget'))) {
$forum_counts = ForumManager::count_unseen_items();
if (dbm::is_result($forums_counts)) {
foreach ($forums_counts as $forum_count) {
if ($forum_count['count'] > 0) {
$forums_unseen[] = $forum_count;
}
}
}
}
}
$intros1 = q("SELECT `intro`.`id`, `intro`.`datetime`,
$intros1 = qu("SELECT `intro`.`id`, `intro`.`datetime`,
`fcontact`.`name`, `fcontact`.`url`, `fcontact`.`photo`
FROM `intro` LEFT JOIN `fcontact` ON `intro`.`fid` = `fcontact`.`id`
WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`fid`!=0",
WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`fid` != 0",
intval(local_user())
);
$intros2 = q("SELECT `intro`.`id`, `intro`.`datetime`,
$intros2 = qu("SELECT `intro`.`id`, `intro`.`datetime`,
`contact`.`name`, `contact`.`url`, `contact`.`photo`
FROM `intro` LEFT JOIN `contact` ON `intro`.`contact-id` = `contact`.`id`
WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`contact-id`!=0",
WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`contact-id` != 0",
intval(local_user())
);
$intro = count($intros1) + count($intros2);
$intros = $intros1+$intros2;
$intro_count = count($intros1) + count($intros2);
$intros = $intros1 + $intros2;
$myurl = $a->get_baseurl() . '/profile/' . $a->user['nickname'] ;
$mails = q("SELECT * FROM `mail`
$mails = qu("SELECT `id`, `from-name`, `from-url`, `from-photo`, `created` FROM `mail`
WHERE `uid` = %d AND `seen` = 0 AND `from-url` != '%s' ",
intval(local_user()),
dbesc($myurl)
);
$mail = count($mails);
$mail_count = count($mails);
if ($a->config['register_policy'] == REGISTER_APPROVE && is_site_admin()){
$regs = q("SELECT `contact`.`name`, `contact`.`url`, `contact`.`micro`, `register`.`created` FROM `contact` RIGHT JOIN `register` ON `register`.`uid`=`contact`.`uid` WHERE `contact`.`self`=1");
$register = count($regs);
} else {
$register = 0;
$regs = qu("SELECT `contact`.`name`, `contact`.`url`, `contact`.`micro`, `register`.`created`, COUNT(*) AS `total`
FROM `contact` RIGHT JOIN `register` ON `register`.`uid` = `contact`.`uid`
WHERE `contact`.`self` = 1");
$register_count = 0;
if (dbm::is_result($regs)) {
$register_count = $regs[0]['total'];
}
}
$all_events = 0;
$all_events_today = 0;
$events = 0;
$events_today = 0;
$birthdays = 0;
$birthdays_today = 0;
$ev = q("SELECT count(`event`.`id`) as total, type, start, adjust FROM `event`
$ev = qu("SELECT count(`event`.`id`) AS total, type, start, adjust FROM `event`
WHERE `event`.`uid` = %d AND `start` < '%s' AND `finish` > '%s' and `ignore` = 0
ORDER BY `start` ASC ",
intval(local_user()),
dbesc(datetime_convert('UTC','UTC','now + 7 days')),
dbesc(datetime_convert('UTC','UTC','now'))
dbesc(datetime_convert('UTC', 'UTC', 'now + 7 days')),
dbesc(datetime_convert('UTC', 'UTC', 'now'))
);
if (dbm::is_result($ev)) {
$all_events = intval($ev[0]['total']);
if ($all_events) {
$str_now = datetime_convert('UTC',$a->timezone,'now','Y-m-d');
$str_now = datetime_convert('UTC', $a->timezone, 'now', 'Y-m-d');
foreach($ev as $x) {
$bd = false;
if ($x['type'] === 'birthday') {
@ -159,7 +219,7 @@ function ping_init(&$a) {
else {
$events ++;
}
if (datetime_convert('UTC',((intval($x['adjust'])) ? $a->timezone : 'UTC'), $x['start'],'Y-m-d') === $str_now) {
if (datetime_convert('UTC', ((intval($x['adjust'])) ? $a->timezone : 'UTC'), $x['start'], 'Y-m-d') === $str_now) {
$all_events_today ++;
if ($bd)
$birthdays_today ++;
@ -170,99 +230,70 @@ function ping_init(&$a) {
}
}
$data = array();
$data["intro"] = $intro;
$data["mail"] = $mail;
$data["net"] = $network;
$data["home"] = $home;
$data['intro'] = $intro_count;
$data['mail'] = $mail_count;
$data['net'] = $network_count;
$data['home'] = $home_count;
$data['register'] = $register_count;
if ($register!=0)
$data["register"] = $register;
$data['all-events'] = $all_events;
$data['all-events-today'] = $all_events_today;
$data['events'] = $events;
$data['events-today'] = $events_today;
$data['birthdays'] = $birthdays;
$data['birthdays-today'] = $birthdays_today;
$groups = array();
if (dbm::is_result($groups_unseen)) {
$count = 0;
foreach ($groups_unseen as $it)
if ($it['count'] > 0) {
$count++;
$groups[$count.":group"] = $it['count'];
$groups[$count.":@attributes"] = array("id" => $it['id']);
if (dbm::is_result($notifs)) {
foreach ($notifs as $notif) {
if ($notif['seen'] == 0) {
$sysnotify_count ++;
}
$data["groups"] = $groups;
}
$forums = array();
if (dbm::is_result($forums_unseen)) {
$count = 0;
foreach ($forums_unseen as $it)
if ($it['count'] > 0) {
$count++;
$forums[$count.":forum"] = $it['count'];
$forums[$count.":@attributes"] = array("id" => $it['id']);
}
$data["forums"] = $forums;
}
$data["all-events"] = $all_events;
$data["all-events-today"] = $all_events_today;
$data["events"] = $events;
$data["events-today"] = $events_today;
$data["birthdays"] = $birthdays;
$data["birthdays-today"] = $birthdays_today;
if (dbm::is_result($notifs) && !$sysnotify) {
foreach ($notifs as $zz) {
if ($zz['seen'] == 0)
$sysnotify ++;
}
}
// merge all notification types in one array
if (dbm::is_result($intros)) {
foreach ($intros as $i) {
$n = array(
'href' => $a->get_baseurl().'/notifications/intros/'.$i['id'],
'name' => $i['name'],
'url' => $i['url'],
'photo' => $i['photo'],
'date' => $i['datetime'],
'seen' => false,
'message' => t("{0} wants to be your friend"),
foreach ($intros as $intro) {
$notif = array(
'href' => $a->get_baseurl() . '/notifications/intros/' . $intro['id'],
'name' => $intro['name'],
'url' => $intro['url'],
'photo' => $intro['photo'],
'date' => $intro['datetime'],
'seen' => false,
'message' => t('{0} wants to be your friend'),
);
$notifs[] = $n;
$notifs[] = $notif;
}
}
if (dbm::is_result($mails)) {
foreach ($mails as $i) {
$n = array(
'href' => $a->get_baseurl().'/message/'.$i['id'],
'name' => $i['from-name'],
'url' => $i['from-url'],
'photo' => $i['from-photo'],
'date' => $i['created'],
'seen' => false,
'message' => t("{0} sent you a message"),
foreach ($mails as $mail) {
$notif = array(
'href' => $a->get_baseurl() . '/message/' . $mail['id'],
'name' => $mail['from-name'],
'url' => $mail['from-url'],
'photo' => $mail['from-photo'],
'date' => $mail['created'],
'seen' => false,
'message' => t('{0} sent you a message'),
);
$notifs[] = $n;
$notifs[] = $notif;
}
}
if (dbm::is_result($regs)) {
foreach ($regs as $i) {
$n = array(
'href' => $a->get_baseurl().'/admin/users/',
'name' => $i['name'],
'url' => $i['url'],
'photo' => $i['micro'],
'date' => $i['created'],
'seen' => false,
'message' => t("{0} requested registration"),
foreach ($regs as $reg) {
$notif = array(
'href' => $a->get_baseurl() . '/admin/users/',
'name' => $reg['name'],
'url' => $reg['url'],
'photo' => $reg['micro'],
'date' => $reg['created'],
'seen' => false,
'message' => t('{0} requested registration'),
);
$notifs[] = $n;
$notifs[] = $notif;
}
}
@ -278,84 +309,101 @@ function ping_init(&$a) {
usort($notifs, $sort_function);
if (dbm::is_result($notifs)) {
// Are the nofications calles from the regular process or via the friendica app?
// Are the nofications called from the regular process or via the friendica app?
$regularnotifications = (intval($_GET['uid']) AND intval($_GET['_']));
$count = 0;
foreach($notifs as $n) {
$count++;
if ($a->is_friendica_app() OR !$regularnotifications)
$n['message'] = str_replace("{0}", $n['name'], $n['message']);
foreach ($notifs as $notif) {
if ($a->is_friendica_app() OR !$regularnotifications) {
$notif['message'] = str_replace("{0}", $notif['name'], $notif['message']);
}
$notifications[$count.":note"] = $n['message'];
$contact = get_contact_details_by_url($notif['url']);
if (isset($contact['micro'])) {
$notif['photo'] = proxy_url($contact['micro'], false, PROXY_SIZE_MICRO);
} else {
$notif['photo'] = proxy_url($notif['photo'], false, PROXY_SIZE_MICRO);
}
$contact = get_contact_details_by_url($n['url']);
if (isset($contact["micro"]))
$n['photo'] = proxy_url($contact["micro"], false, PROXY_SIZE_MICRO);
else
$n['photo'] = proxy_url($n['photo'], false, PROXY_SIZE_MICRO);
$local_time = datetime_convert('UTC',date_default_timezone_get(),$n['date']);
call_hooks('ping_xmlize', $n);
$notifications[$count.":@attributes"] = array("id" => $n["id"],
"href" => $n['href'],
"name" => $n['name'],
"url" => $n['url'],
"photo" => $n['photo'],
"date" => relative_date($n['date']),
"seen" => $n['seen'],
"timestamp" => strtotime($local_time));
$local_time = datetime_convert('UTC', date_default_timezone_get(), $notif['date']);
$notifications[] = array(
'id' => $notif['id'],
'href' => $notif['href'],
'name' => $notif['name'],
'url' => $notif['url'],
'photo' => $notif['photo'],
'date' => relative_date($notif['date']),
'message' => $notif['message'],
'seen' => $notif['seen'],
'timestamp' => strtotime($local_time)
);
}
}
$data["notif"] = $notifications;
$data["@attributes"] = array("count" => $sysnotify + $intro + $mail + $register);
}
$sysmsg = array();
$sysmsgs = array();
$sysmsgs_info = array();
if (x($_SESSION,'sysmsg')){
$count = 0;
foreach ($_SESSION['sysmsg'] as $m){
$count++;
$sysmsg[$count.":notice"] = $m;
}
if (x($_SESSION, 'sysmsg')) {
$sysmsgs = $_SESSION['sysmsg'];
unset($_SESSION['sysmsg']);
}
if (x($_SESSION,'sysmsg_info')){
$count = 0;
foreach ($_SESSION['sysmsg_info'] as $m){
$count++;
$sysmsg[$count.":info"] = $m;
}
if (x($_SESSION, 'sysmsg_info')) {
$sysmsgs_info = $_SESSION['sysmsg_info'];
unset($_SESSION['sysmsg_info']);
}
$data["sysmsgs"] = $sysmsg;
if ($format == 'json') {
$data['groups'] = $groups_unseen;
$data['forums'] = $forums_unseen;
$data['notify'] = $sysnotify_count + $intro_count + $mail_count + $register_count;
$data['notifications'] = $notifications;
$data['sysmsgs'] = array(
'notice' => $sysmsgs,
'info' => $sysmsgs_info
);
$json_payload = json_encode(array("result" => $data));
if (isset($_GET['callback'])) {
// JSONP support
header("Content-type: application/javascript");
echo $_GET['callback'] . '(' . $json_payload . ')';
} else {
header("Content-type: application/json");
echo $json_payload;
}
} else {
// Legacy slower XML format output
$data = ping_format_xml_data($data, $sysnotify_count, $notifications, $sysmsgs, $sysmsgs_info, $groups_unseen, $forums_unseen);
header("Content-type: text/xml");
echo xml::from_array(array("result" => $data), $xml);
}
header("Content-type: text/xml");
echo xml::from_array(array("result" => $data), $xml);
killme();
}
function ping_get_notifications($uid) {
$result = array();
$offset = 0;
$seen = false;
/**
* @brief Retrieves the notifications array for the given user ID
*
* @param int $uid User id
* @return array Associative array of notifications
*/
function ping_get_notifications($uid)
{
$result = array();
$offset = 0;
$seen = false;
$seensql = "NOT";
$order = "DESC";
$quit = false;
$order = "DESC";
$quit = false;
$a = get_app();
do {
$r = q("SELECT `notify`.*, `item`.`visible`, `item`.`spam`, `item`.`deleted`
$r = qu("SELECT `notify`.*, `item`.`visible`, `item`.`spam`, `item`.`deleted`
FROM `notify` LEFT JOIN `item` ON `item`.`id` = `notify`.`iid`
WHERE `notify`.`uid` = %d AND `notify`.`msg` != ''
AND NOT (`notify`.`type` IN (%d, %d))
@ -371,46 +419,115 @@ function ping_get_notifications($uid) {
$seensql = "";
$order = "DESC";
$offset = 0;
} elseif (!$r)
} elseif (!$r) {
$quit = true;
else
} else {
$offset += 50;
}
foreach ($r AS $notification) {
if (is_null($notification["visible"]))
if (is_null($notification["visible"])) {
$notification["visible"] = true;
}
if (is_null($notification["spam"]))
if (is_null($notification["spam"])) {
$notification["spam"] = 0;
}
if (is_null($notification["deleted"]))
if (is_null($notification["deleted"])) {
$notification["deleted"] = 0;
}
$notification["message"] = strip_tags(bbcode($notification["msg"]));
$notification["name"] = strip_tags(bbcode($notification["name"]));
if ($notification["msg_cache"]) {
$notification["name"] = $notification["name_cache"];
$notification["message"] = $notification["msg_cache"];
} else {
$notification["name"] = strip_tags(bbcode($notification["name"]));
$notification["message"] = format_notification_message($notification["name"], strip_tags(bbcode($notification["msg"])));
// Replace the name with {0} but ensure to make that only once
// The {0} is used later and prints the name in bold.
q("UPDATE `notify` SET `name_cache` = '%s', `msg_cache` = '%s' WHERE `id` = %d",
dbesc($notification["name"]),
dbesc($notification["message"]),
intval($notification["id"])
);
}
if ($notification['name'] != "")
$pos = strpos($notification["message"],$notification['name']);
else
$pos = false;
if ($pos !== false)
$notification["message"] = substr_replace($notification["message"],"{0}",$pos,strlen($notification["name"]));
$notification['href'] = $a->get_baseurl() . '/notify/view/' . $notification['id'];
$notification["href"] = $a->get_baseurl() . "/notify/view/" . $notification["id"];
if ($notification["visible"] AND !$notification["spam"] AND
!$notification["deleted"] AND !is_array($result[$notification["parent"]])) {
$result[$notification["parent"]] = $notification;
}
}
} while ((count($result) < 50) AND !$quit);
return($result);
}
/**
* @brief Backward-compatible XML formatting for ping.php output
* @deprecated
*
* @param array $data The initial ping data array
* @param int $sysnotify_count Number of unseen system notifications
* @param array $notifs Complete list of notification
* @param array $sysmsgs List of system notice messages
* @param array $sysmsgs_info List of system info messages
* @param int $groups_unseen Number of unseen group items
* @param int $forums_unseen Number of unseen forum items
* @return array XML-transform ready data array
*/
function ping_format_xml_data($data, $sysnotify, $notifs, $sysmsgs, $sysmsgs_info, $groups_unseen, $forums_unseen)
{
$notifications = array();
foreach($notifs as $key => $notif) {
$notifications[$key . ':note'] = $notif['message'];
$notifications[$key . ':@attributes'] = array(
'id' => $notif['id'],
'href' => $notif['href'],
'name' => $notif['name'],
'url' => $notif['url'],
'photo' => $notif['photo'],
'date' => $notif['date'],
'seen' => $notif['seen'],
'timestamp' => $notif['timestamp']
);
}
$sysmsg = array();
foreach ($sysmsgs as $key => $m){
$sysmsg[$key . ':notice'] = $m;
}
foreach ($sysmsgs_info as $key => $m){
$sysmsg[$key . ':info'] = $m;
}
$data['notif'] = $notifications;
$data['@attributes'] = array('count' => $sysnotify_count + $data['intro'] + $data['mail'] + $data['register']);
$data['sysmsgs'] = $sysmsg;
if ($data['register'] == 0) {
unset($data['register']);
}
$groups = array();
if (count($groups_unseen)) {
foreach ($groups_unseen as $key => $item) {
$groups[$key . ':group'] = $item['count'];
$groups[$key . ':@attributes'] = array('id' => $item['id']);
}
$data['groups'] = $groups;
}
$forums = array();
if (count($forums_unseen)) {
foreach ($forums_unseen as $key => $item) {
$forums[$count . ':forum'] = $item['count'];
$forums[$count . ':@attributes'] = array('id' => $item['id']);
}
$data['forums'] = $forums;
}
return $data;
}

View file

@ -1,4 +1,6 @@
<?php
// See here for a documentation for portable contacts:
// https://web.archive.org/web/20160405005550/http://portablecontacts.net/draft-spec.html
function poco_init(&$a) {
require_once("include/bbcode.php");
@ -104,9 +106,11 @@ function poco_init(&$a) {
);
} elseif($system_mode) {
logger("Start system mode query", LOGGER_DEBUG);
$r = q("SELECT `contact`.*, `profile`.`about` AS `pabout`, `profile`.`locality` AS `plocation`, `profile`.`pub_keywords`, `profile`.`gender` AS `pgender`,
`profile`.`address` AS `paddress`, `profile`.`region` AS `pregion`, `profile`.`postal-code` AS `ppostalcode`, `profile`.`country-name` AS `pcountry`
$r = q("SELECT `contact`.*, `profile`.`about` AS `pabout`, `profile`.`locality` AS `plocation`, `profile`.`pub_keywords`,
`profile`.`gender` AS `pgender`, `profile`.`address` AS `paddress`, `profile`.`region` AS `pregion`,
`profile`.`postal-code` AS `ppostalcode`, `profile`.`country-name` AS `pcountry`, `user`.`account-type`
FROM `contact` INNER JOIN `profile` ON `profile`.`uid` = `contact`.`uid`
INNER JOIN `user` ON `user`.`uid` = `contact`.`uid`
WHERE `self` = 1 AND `profile`.`is-default`
AND `contact`.`uid` IN (SELECT `uid` FROM `pconfig` WHERE `cat` = 'system' AND `k` = 'suggestme' AND `v` = 1) LIMIT %d, %d",
intval($startIndex),
@ -155,6 +159,7 @@ function poco_init(&$a) {
'gender' => false,
'tags' => false,
'address' => false,
'contactType' => false,
'generation' => false
);
@ -207,6 +212,9 @@ function poco_init(&$a) {
if (($rr['keywords'] == "") AND isset($rr['pub_keywords']))
$rr['keywords'] = $rr['pub_keywords'];
if (isset($rr['account-type']))
$rr['contact-type'] = $rr['account-type'];
$about = Cache::get("about:".$rr['updated'].":".$rr['nurl']);
if (is_null($about)) {
$about = bbcode($rr['about'], false, false);
@ -300,6 +308,9 @@ function poco_init(&$a) {
$entry['address']['country'] = $rr['pcountry'];
}
if($fields_ret['contactType'])
$entry['contactType'] = intval($rr['contact-type']);
$ret['entry'][] = $entry;
}
}

View file

@ -10,7 +10,7 @@ function profile_init(&$a) {
$a->page['aside'] = '';
if($a->argc > 1)
$which = $a->argv[1];
$which = htmlspecialchars($a->argv[1]);
else {
$r = q("select nickname from user where blocked = 0 and account_expired = 0 and account_removed = 0 and verified = 1 order by rand() limit 1");
if(count($r)) {
@ -27,7 +27,7 @@ function profile_init(&$a) {
$profile = 0;
if((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) {
$which = $a->user['nickname'];
$profile = $a->argv[1];
$profile = htmlspecialchars($a->argv[1]);
}
else {
auto_redir($a, $which);
@ -282,16 +282,20 @@ function profile_content(&$a, $update = 0) {
$pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
$r = q("SELECT `thread`.`iid` AS `item_id`, `thread`.`network` AS `item_network`
FROM `thread` FORCE INDEX (`uid_created`) INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
$sql_post_table INNER JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
WHERE `thread`.`uid` = %d AND `thread`.`visible` = 1 AND `thread`.`deleted` = 0
and `thread`.`moderated` = 0
AND `thread`.`wall` = 1
$sql_extra $sql_extra2
ORDER BY `thread`.`created` DESC $pager_sql ",
intval($a->profile['profile_uid'])
FROM `thread`
STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
$sql_post_table
STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
AND NOT `contact`.`blocked` AND NOT `contact`.`pending`
WHERE `thread`.`uid` = %d AND `thread`.`visible`
AND `thread`.`contact-id` = %d
AND NOT `thread`.`deleted`
AND NOT `thread`.`moderated`
AND `thread`.`wall`
$sql_extra $sql_extra2
ORDER BY `thread`.`created` DESC $pager_sql",
intval($a->profile['profile_uid']),
intval($a->profile['contact_id'])
);
}

View file

@ -303,6 +303,7 @@ function profiles_post(&$a) {
}
$sexual = notags(trim($_POST['sexual']));
$xmpp = notags(trim($_POST['xmpp']));
$homepage = notags(trim($_POST['homepage']));
if ((strpos($homepage, 'http') !== 0) && (strlen($homepage))) {
// neither http nor https in URL, add them
@ -368,6 +369,10 @@ function profiles_post(&$a) {
$changes[] = t('Sexual Preference');
$value = $sexual;
}
if($xmpp != $orig[0]['xmpp']) {
$changes[] = t('XMPP');
$value = $xmpp;
}
if($homepage != $orig[0]['homepage']) {
$changes[] = t('Homepage');
$value = $homepage;
@ -409,6 +414,7 @@ function profiles_post(&$a) {
`with` = '%s',
`howlong` = '%s',
`sexual` = '%s',
`xmpp` = '%s',
`homepage` = '%s',
`hometown` = '%s',
`politic` = '%s',
@ -443,6 +449,7 @@ function profiles_post(&$a) {
dbesc($with),
dbesc($howlong),
dbesc($sexual),
dbesc($xmpp),
dbesc($homepage),
dbesc($hometown),
dbesc($politic),
@ -725,6 +732,7 @@ function profiles_content(&$a) {
'$howlong' => array('howlong', t('Since [date]:'), ($r[0]['howlong'] === '0000-00-00 00:00:00' ? '' : datetime_convert('UTC',date_default_timezone_get(),$r[0]['howlong']))),
'$sexual' => sexpref_selector($r[0]['sexual']),
'$about' => array('about', t('Tell us about yourself...'), $r[0]['about']),
'$xmpp' => array('xmpp', t('XMPP (Jabber) address:'), $r[0]['xmpp'], t("The XMPP address will be propagated to your contacts so that they can follow you.")),
'$homepage' => array('homepage', t('Homepage URL:'), $r[0]['homepage']),
'$hometown' => array('hometown', t('Hometown:'), $r[0]['hometown']),
'$politic' => array('politic', t('Political Views:'), $r[0]['politic']),

View file

@ -135,7 +135,7 @@ function proxy_init() {
$valid = true;
if (!$direct_cache AND ($cachefile == "")) {
$r = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' LIMIT 1", $urlhash);
$r = qu("SELECT * FROM `photo` WHERE `resource-id` = '%s' LIMIT 1", $urlhash);
if (count($r)) {
$img_str = $r[0]['data'];
$mime = $r[0]["desc"];
@ -233,66 +233,87 @@ function proxy_init() {
killme();
}
function proxy_url($url, $writemode = false, $size = "") {
global $_SERVER;
/**
* @brief Transform a remote URL into a local one
*
* This function only performs the URL replacement on http URL and if the
* provided URL isn't local, "the isn't deactivated" (sic) and if the config
* system.proxy_disabled is set to false.
*
* @param string $url The URL to proxyfy
* @param bool $writemode Returns a local path the remote URL should be saved to
* @param string $size One of the PROXY_SIZE_* constants
*
* @return string The proxyfied URL or relative path
*/
function proxy_url($url, $writemode = false, $size = '') {
$a = get_app();
if (substr($url, 0, strlen('http')) !== 'http') {
return($url);
return $url;
}
// Only continue if it isn't a local image and the isn't deactivated
if (proxy_is_local_image($url)) {
$url = str_replace(normalise_link($a->get_baseurl())."/", $a->get_baseurl()."/", $url);
return($url);
$url = str_replace(normalise_link($a->get_baseurl()) . '/', $a->get_baseurl() . '/', $url);
return $url;
}
if (get_config("system", "proxy_disabled"))
return($url);
if (get_config('system', 'proxy_disabled')) {
return $url;
}
// Image URL may have encoded ampersands for display which aren't desirable for proxy
$url = html_entity_decode($url, ENT_NOQUOTES, 'utf-8');
// Creating a sub directory to reduce the amount of files in the cache directory
$basepath = $a->get_basepath()."/proxy";
$basepath = $a->get_basepath() . '/proxy';
$path = substr(hash("md5", $url), 0, 2);
$shortpath = hash('md5', $url);
$longpath = substr($shortpath, 0, 2);
if (is_dir($basepath) and $writemode)
if (!is_dir($basepath."/".$path)) {
mkdir($basepath."/".$path);
chmod($basepath."/".$path, 0777);
if (is_dir($basepath) and $writemode) {
if (!is_dir($basepath . '/' . $longpath)) {
mkdir($basepath . '/' . $longpath);
chmod($basepath . '/' . $longpath, 0777);
}
$path .= "/".strtr(base64_encode($url), '+/', '-_');
// Checking for valid extensions. Only add them if they are safe
$pos = strrpos($url, ".");
if ($pos) {
$extension = strtolower(substr($url, $pos+1));
$pos = strpos($extension, "?");
if ($pos)
$extension = substr($extension, 0, $pos);
}
$extensions = array("jpg", "jpeg", "gif", "png");
$longpath .= '/' . strtr(base64_encode($url), '+/', '-_');
if (in_array($extension, $extensions))
$path .= ".".$extension;
// Checking for valid extensions. Only add them if they are safe
$pos = strrpos($url, '.');
if ($pos) {
$extension = strtolower(substr($url, $pos + 1));
$pos = strpos($extension, '?');
if ($pos) {
$extension = substr($extension, 0, $pos);
}
}
$proxypath = $a->get_baseurl()."/proxy/".$path;
$extensions = array('jpg', 'jpeg', 'gif', 'png');
if (in_array($extension, $extensions)) {
$shortpath .= '.' . $extension;
$longpath .= '.' . $extension;
}
if ($size != "")
$size = ":".$size;
$proxypath = $a->get_baseurl() . '/proxy/' . $longpath;
if ($size != '') {
$size = ':' . $size;
}
// Too long files aren't supported by Apache
// Writemode in combination with long files shouldn't be possible
if ((strlen($proxypath) > 250) AND $writemode)
return (hash("md5", $url));
elseif (strlen($proxypath) > 250)
return ($a->get_baseurl()."/proxy/".hash("md5", $url)."?url=".urlencode($url));
elseif ($writemode)
return ($path);
else
return ($proxypath.$size);
if ((strlen($proxypath) > 250) AND $writemode) {
return $shortpath;
} elseif (strlen($proxypath) > 250) {
return $a->get_baseurl() . '/proxy/' . $shortpath . '?url=' . urlencode($url);
} elseif ($writemode) {
return $longpath;
} else {
return $proxypath . $size;
}
}
/**

View file

@ -52,6 +52,7 @@ function register_post(&$a) {
$arr['blocked'] = $blocked;
$arr['verified'] = $verified;
$arr['language'] = get_browser_language();
$result = create_user($arr);
@ -112,12 +113,13 @@ function register_post(&$a) {
}
$hash = random_string();
$r = q("INSERT INTO `register` ( `hash`, `created`, `uid`, `password`, `language` ) VALUES ( '%s', '%s', %d, '%s', '%s' ) ",
$r = q("INSERT INTO `register` ( `hash`, `created`, `uid`, `password`, `language`, `note` ) VALUES ( '%s', '%s', %d, '%s', '%s', '%s' ) ",
dbesc($hash),
dbesc(datetime_convert()),
intval($user['uid']),
dbesc($result['password']),
dbesc($lang)
dbesc($lang),
dbesc($_POST['permonlybox'])
);
// invite system
@ -132,7 +134,7 @@ function register_post(&$a) {
$admin_mail_list
);
// send notification to admins
foreach ($adminlist as $admin) {
notification(array(
'type' => NOTIFY_SYSTEM,
@ -145,10 +147,15 @@ function register_post(&$a) {
'source_photo' => $a->get_baseurl() . "/photo/avatar/".$user['uid'].".jpg",
'to_email' => $admin['email'],
'uid' => $admin['uid'],
'language' => ($admin['language']?$admin['language']:'en'))
);
'language' => ($admin['language']?$admin['language']:'en'),
'show_in_notification_page' => false
));
}
// send notification to the user, that the registration is pending
send_register_pending_eml(
$user['email'],
$a->config['sitename'],
$user['username']);
info( t('Your registration is pending approval by the site owner.') . EOL ) ;
goaway(z_root());
@ -256,6 +263,8 @@ function register_content(&$a) {
$o = replace_macros($o, array(
'$oidhtml' => $oidhtml,
'$invitations' => get_config('system','invitation_only'),
'$permonly' => $a->config['register_policy'] == REGISTER_APPROVE,
'$permonlybox' => array('permonlybox', t('Note for the admin'), '', t('Leave a message for the admin, why you want to join this node')),
'$invite_desc' => t('Membership on this site is by invitation only.'),
'$invite_label' => t('Your invitation ID: '),
'$invite_id' => $invite_id,

View file

@ -279,7 +279,7 @@ function settings_post(&$a) {
return;
}
if(($a->argc > 1) && ($a->argv[1] === 'features')) {
if (($a->argc > 1) && ($a->argv[1] === 'features')) {
check_form_security_token_redirectOnErr('/settings/features', 'settings_features');
foreach($_POST as $k => $v) {
if(strpos($k,'feature_') === 0) {
@ -290,49 +290,52 @@ function settings_post(&$a) {
return;
}
if(($a->argc > 1) && ($a->argv[1] === 'display')) {
if (($a->argc > 1) && ($a->argv[1] === 'display')) {
check_form_security_token_redirectOnErr('/settings/display', 'settings_display');
$theme = ((x($_POST,'theme')) ? notags(trim($_POST['theme'])) : $a->user['theme']);
$mobile_theme = ((x($_POST,'mobile_theme')) ? notags(trim($_POST['mobile_theme'])) : '');
$nosmile = ((x($_POST,'nosmile')) ? intval($_POST['nosmile']) : 0);
$first_day_of_week = ((x($_POST,'first_day_of_week')) ? intval($_POST['first_day_of_week']) : 0);
$noinfo = ((x($_POST,'noinfo')) ? intval($_POST['noinfo']) : 0);
$infinite_scroll = ((x($_POST,'infinite_scroll')) ? intval($_POST['infinite_scroll']) : 0);
$no_auto_update = ((x($_POST,'no_auto_update')) ? intval($_POST['no_auto_update']) : 0);
$browser_update = ((x($_POST,'browser_update')) ? intval($_POST['browser_update']) : 0);
$theme = x($_POST, 'theme') ? notags(trim($_POST['theme'])) : $a->user['theme'];
$mobile_theme = x($_POST, 'mobile_theme') ? notags(trim($_POST['mobile_theme'])) : '';
$nosmile = x($_POST, 'nosmile') ? intval($_POST['nosmile']) : 0;
$first_day_of_week = x($_POST, 'first_day_of_week') ? intval($_POST['first_day_of_week']) : 0;
$noinfo = x($_POST, 'noinfo') ? intval($_POST['noinfo']) : 0;
$infinite_scroll = x($_POST, 'infinite_scroll') ? intval($_POST['infinite_scroll']) : 0;
$no_auto_update = x($_POST, 'no_auto_update') ? intval($_POST['no_auto_update']) : 0;
$bandwidth_saver = x($_POST, 'bandwidth_saver') ? intval($_POST['bandwidth_saver']) : 0;
$nowarn_insecure = x($_POST, 'nowarn_insecure') ? intval($_POST['nowarn_insecure']) : 0;
$browser_update = x($_POST, 'browser_update') ? intval($_POST['browser_update']) : 0;
if ($browser_update != -1) {
$browser_update = $browser_update * 1000;
$browser_update = $browser_update * 1000;
if ($browser_update < 10000)
$browser_update = 10000;
}
$itemspage_network = ((x($_POST,'itemspage_network')) ? intval($_POST['itemspage_network']) : 40);
if($itemspage_network > 100)
$itemspage_network = x($_POST,'itemspage_network') ? intval($_POST['itemspage_network']) : 40;
if ($itemspage_network > 100) {
$itemspage_network = 100;
$itemspage_mobile_network = ((x($_POST,'itemspage_mobile_network')) ? intval($_POST['itemspage_mobile_network']) : 20);
if($itemspage_mobile_network > 100)
}
$itemspage_mobile_network = x($_POST,'itemspage_mobile_network') ? intval($_POST['itemspage_mobile_network']) : 20;
if ($itemspage_mobile_network > 100) {
$itemspage_mobile_network = 100;
}
if($mobile_theme !== '') {
set_pconfig(local_user(),'system','mobile_theme',$mobile_theme);
}
set_pconfig(local_user(),'system','update_interval', $browser_update);
set_pconfig(local_user(),'system','itemspage_network', $itemspage_network);
set_pconfig(local_user(),'system','itemspage_mobile_network', $itemspage_mobile_network);
set_pconfig(local_user(),'system','no_smilies',$nosmile);
set_pconfig(local_user(),'system','first_day_of_week',$first_day_of_week);
set_pconfig(local_user(),'system','ignore_info',$noinfo);
set_pconfig(local_user(),'system','infinite_scroll',$infinite_scroll);
set_pconfig(local_user(),'system','no_auto_update',$no_auto_update);
set_pconfig(local_user(), 'system', 'nowarn_insecure' , $nowarn_insecure);
set_pconfig(local_user(), 'system', 'update_interval' , $browser_update);
set_pconfig(local_user(), 'system', 'itemspage_network' , $itemspage_network);
set_pconfig(local_user(), 'system', 'itemspage_mobile_network', $itemspage_mobile_network);
set_pconfig(local_user(), 'system', 'no_smilies' , $nosmile);
set_pconfig(local_user(), 'system', 'first_day_of_week' , $first_day_of_week);
set_pconfig(local_user(), 'system', 'ignore_info' , $noinfo);
set_pconfig(local_user(), 'system', 'infinite_scroll' , $infinite_scroll);
set_pconfig(local_user(), 'system', 'no_auto_update' , $no_auto_update);
set_pconfig(local_user(), 'system', 'bandwidth_saver' , $bandwidth_saver);
if ($theme == $a->user['theme']){
if ($theme == $a->user['theme']) {
// call theme_post only if theme has not been changed
if( ($themeconfigfile = get_theme_config_file($theme)) != null){
if (($themeconfigfile = get_theme_config_file($theme)) != null) {
require_once($themeconfigfile);
theme_post($a);
}
@ -420,6 +423,7 @@ function settings_post(&$a) {
$publish = (((x($_POST,'profile_in_directory')) && (intval($_POST['profile_in_directory']) == 1)) ? 1: 0);
$net_publish = (((x($_POST,'profile_in_netdirectory')) && (intval($_POST['profile_in_netdirectory']) == 1)) ? 1: 0);
$old_visibility = (((x($_POST,'visibility')) && (intval($_POST['visibility']) == 1)) ? 1 : 0);
$account_type = (((x($_POST,'account-type')) && (intval($_POST['account-type']))) ? intval($_POST['account-type']) : 0);
$page_flags = (((x($_POST,'page-flags')) && (intval($_POST['page-flags']))) ? intval($_POST['page-flags']) : 0);
$blockwall = (((x($_POST,'blockwall')) && (intval($_POST['blockwall']) == 1)) ? 0: 1); // this setting is inverted!
$blocktags = (((x($_POST,'blocktags')) && (intval($_POST['blocktags']) == 1)) ? 0: 1); // this setting is inverted!
@ -453,6 +457,16 @@ function settings_post(&$a) {
if(x($_POST,'notify8'))
$notify += intval($_POST['notify8']);
// Adjust the page flag if the account type doesn't fit to the page flag.
if (($account_type == ACCOUNT_TYPE_PERSON) AND !in_array($page_flags, array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE)))
$page_flags = PAGE_NORMAL;
elseif (($account_type == ACCOUNT_TYPE_ORGANISATION) AND !in_array($page_flags, array(PAGE_SOAPBOX)))
$page_flags = PAGE_SOAPBOX;
elseif (($account_type == ACCOUNT_TYPE_NEWS) AND !in_array($page_flags, array(PAGE_SOAPBOX)))
$page_flags = PAGE_SOAPBOX;
elseif (($account_type == ACCOUNT_TYPE_COMMUNITY) AND !in_array($page_flags, array(PAGE_COMMUNITY, PAGE_PRVGROUP)))
$page_flags = PAGE_COMMUNITY;
$email_changed = false;
$err = '';
@ -553,7 +567,7 @@ function settings_post(&$a) {
$r = q("UPDATE `user` SET `username` = '%s', `email` = '%s',
`openid` = '%s', `timezone` = '%s',
`allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s',
`notify-flags` = %d, `page-flags` = %d, `default-location` = '%s',
`notify-flags` = %d, `page-flags` = %d, `account-type` = %d, `default-location` = '%s',
`allow_location` = %d, `maxreq` = %d, `expire` = %d, `openidserver` = '%s',
`def_gid` = %d, `blockwall` = %d, `hidewall` = %d, `blocktags` = %d,
`unkmail` = %d, `cntunkmail` = %d, `language` = '%s'
@ -568,6 +582,7 @@ function settings_post(&$a) {
dbesc($str_group_deny),
intval($notify),
intval($page_flags),
intval($account_type),
dbesc($defloc),
intval($allow_location),
intval($maxreq),
@ -938,6 +953,8 @@ function settings_content(&$a) {
$theme_selected = (!x($_SESSION,'theme')? $default_theme : $_SESSION['theme']);
$mobile_theme_selected = (!x($_SESSION,'mobile-theme')? $default_mobile_theme : $_SESSION['mobile-theme']);
$nowarn_insecure = intval(get_pconfig(local_user(), 'system', 'nowarn_insecure'));
$browser_update = intval(get_pconfig(local_user(), 'system','update_interval'));
if (intval($browser_update) != -1)
$browser_update = (($browser_update == 0) ? 40 : $browser_update / 1000); // default if not set: 40 seconds
@ -963,8 +980,11 @@ function settings_content(&$a) {
$no_auto_update = get_pconfig(local_user(),'system','no_auto_update');
$no_auto_update = (($no_auto_update===false)? '0': $no_auto_update); // default if not set: 0
$bandwidth_saver = get_pconfig(local_user(), 'system', 'bandwidth_saver');
$bandwidth_saver = (($bandwidth_saver === false) ? '0' : $bandwidth_saver); // default if not set: 0
$theme_config = "";
if( ($themeconfigfile = get_theme_config_file($theme_selected)) != null){
if (($themeconfigfile = get_theme_config_file($theme_selected)) != null) {
require_once($themeconfigfile);
$theme_config = theme_content($a);
}
@ -979,6 +999,7 @@ function settings_content(&$a) {
'$theme' => array('theme', t('Display Theme:'), $theme_selected, '', $themes, true),
'$mobile_theme' => array('mobile_theme', t('Mobile Theme:'), $mobile_theme_selected, '', $mobile_themes, false),
'$nowarn_insecure' => array('nowarn_insecure', t('Suppress warning of insecure networks'), $nowarn_insecure, t("Should the system suppress the warning that the current group contains members of networks that can't receive non public postings.")),
'$ajaxint' => array('browser_update', t("Update browser every xx seconds"), $browser_update, t('Minimum of 10 seconds. Enter -1 to disable it.')),
'$itemspage_network' => array('itemspage_network', t("Number of items to display per page:"), $itemspage_network, t('Maximum of 100 items')),
'$itemspage_mobile_network' => array('itemspage_mobile_network', t("Number of items to display per page when viewed from mobile device:"), $itemspage_mobile_network, t('Maximum of 100 items')),
@ -988,6 +1009,7 @@ function settings_content(&$a) {
'$noinfo' => array('noinfo', t("Don't show notices"), $noinfo, ''),
'$infinite_scroll' => array('infinite_scroll', t("Infinite scroll"), $infinite_scroll, ''),
'$no_auto_update' => array('no_auto_update', t("Automatic updates only at the top of the network page"), $no_auto_update, 'When disabled, the network page is updated all the time, which could be confusing while reading.'),
'$bandwidth_saver' => array('bandwidth_saver', t('Bandwith Saver Mode'), $bandwidth_saver, t('When enabled, embedded content is not displayed on automatic updates, they only show on page reload.')),
'$d_tset' => t('General Theme Settings'),
'$d_ctset' => t('Custom Theme Settings'),
@ -1065,13 +1087,41 @@ function settings_content(&$a) {
if(! strlen($a->user['timezone']))
$timezone = date_default_timezone_get();
// Set the account type to "Community" when the page is a community page but the account type doesn't fit
// This is only happening on the first visit after the update
if (in_array($a->user['page-flags'], array(PAGE_COMMUNITY, PAGE_PRVGROUP)) AND
($a->user['account-type'] != ACCOUNT_TYPE_COMMUNITY))
$a->user['account-type'] = ACCOUNT_TYPE_COMMUNITY;
$pageset_tpl = get_markup_template('settings_pagetypes.tpl');
$pageset_tpl = get_markup_template('pagetypes.tpl');
$pagetype = replace_macros($pageset_tpl, array(
'$user' => t("User Types"),
'$community' => t("Community Types"),
'$page_normal' => array('page-flags', t('Normal Account Page'), PAGE_NORMAL,
'$account_types' => t("Account Types"),
'$user' => t("Personal Page Subtypes"),
'$community' => t("Community Forum Subtypes"),
'$account_type' => $a->user['account-type'],
'$type_person' => ACCOUNT_TYPE_PERSON,
'$type_organisation' => ACCOUNT_TYPE_ORGANISATION,
'$type_news' => ACCOUNT_TYPE_NEWS,
'$type_community' => ACCOUNT_TYPE_COMMUNITY,
'$account_person' => array('account-type', t('Personal Page'), ACCOUNT_TYPE_PERSON,
t('This account is a regular personal profile'),
($a->user['account-type'] == ACCOUNT_TYPE_PERSON)),
'$account_organisation' => array('account-type', t('Organisation Page'), ACCOUNT_TYPE_ORGANISATION,
t('This account is a profile for an organisation'),
($a->user['account-type'] == ACCOUNT_TYPE_ORGANISATION)),
'$account_news' => array('account-type', t('News Page'), ACCOUNT_TYPE_NEWS,
t('This account is a news account/reflector'),
($a->user['account-type'] == ACCOUNT_TYPE_NEWS)),
'$account_community' => array('account-type', t('Community Forum'), ACCOUNT_TYPE_COMMUNITY,
t('This account is a community forum where people can discuss with each other'),
($a->user['account-type'] == ACCOUNT_TYPE_COMMUNITY)),
'$page_normal' => array('page-flags', t('Normal Account Page'), PAGE_NORMAL,
t('This account is a normal personal profile'),
($a->user['page-flags'] == PAGE_NORMAL)),
@ -1079,8 +1129,8 @@ function settings_content(&$a) {
t('Automatically approve all connection/friend requests as read-only fans'),
($a->user['page-flags'] == PAGE_SOAPBOX)),
'$page_community' => array('page-flags', t('Community Forum/Celebrity Account'), PAGE_COMMUNITY,
t('Automatically approve all connection/friend requests as read-write fans'),
'$page_community' => array('page-flags', t('Public Forum'), PAGE_COMMUNITY,
t('Automatically approve all contact requests'),
($a->user['page-flags'] == PAGE_COMMUNITY)),
'$page_freelove' => array('page-flags', t('Automatic Friend Page'), PAGE_FREELOVE,
@ -1206,7 +1256,7 @@ function settings_content(&$a) {
$public_post_link = '&public=1';
/* Installed langs */
$lang_choices = get_avaiable_languages();
$lang_choices = get_available_languages();
$o .= replace_macros($stpl, array(
'$ptitle' => t('Account Settings'),
@ -1307,4 +1357,3 @@ function settings_content(&$a) {
return $o;
}

View file

@ -95,7 +95,7 @@ function suggest_content(&$a) {
'details' => $contact_details['location'],
'tags' => $contact_details['keywords'],
'about' => $contact_details['about'],
'account_type' => (($contact_details['community']) ? t('Forum') : ''),
'account_type' => account_type($contact_details),
'ignlnk' => $ignlnk,
'ignid' => $rr['id'],
'conntxt' => t('Connect'),
@ -113,7 +113,6 @@ function suggest_content(&$a) {
$o .= replace_macros($tpl,array(
'$title' => t('Friend Suggestions'),
'$contacts' => $entries,
));
return $o;

View file

@ -2,7 +2,7 @@
// See update_profile.php for documentation
require_once('mod/community.php');
require_once("mod/community.php");
function update_community_content(&$a) {
@ -10,24 +10,25 @@ function update_community_content(&$a) {
echo "<!DOCTYPE html><html><body>\r\n";
echo "<section>";
$text = community_content($a,true);
$pattern = "/<img([^>]*) src=\"([^\"]*)\"/";
$replace = "<img\${1} dst=\"\${2}\"";
$text = preg_replace($pattern, $replace, $text);
$text = community_content($a, true);
$pattern = "/<img([^>]*) src=\"([^\"]*)\"/";
$replace = "<img\${1} dst=\"\${2}\"";
$text = preg_replace($pattern, $replace, $text);
$replace = '<br />' . t('[Embedded content - reload page to view]') . '<br />';
$pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*video[^>]*>(.*?)<\s*\/\s*video>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*embed[^>]*>(.*?)<\s*\/\s*embed>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i";
$text = preg_replace($pattern, $replace, $text);
if (get_pconfig(local_user(), "system", "bandwith_saver")) {
$replace = "<br />".t("[Embedded content - reload page to view]")."<br />";
$pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*video[^>]*>(.*?)<\s*\/\s*video>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*embed[^>]*>(.*?)<\s*\/\s*embed>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i";
$text = preg_replace($pattern, $replace, $text);
}
echo str_replace("\t",' ',$text);
echo str_replace("\t", " ", $text);
echo "</section>";
echo "</body></html>\r\n";
killme();
}

View file

@ -2,12 +2,12 @@
// See update_profile.php for documentation
require_once('mod/display.php');
require_once('include/group.php');
require_once("mod/display.php");
require_once("include/group.php");
function update_display_content(&$a) {
$profile_uid = intval($_GET['p']);
$profile_uid = intval($_GET["p"]);
header("Content-type: text/html");
echo "<!DOCTYPE html><html><body>\r\n";
@ -19,20 +19,20 @@ function update_display_content(&$a) {
$replace = "<img\${1} dst=\"\${2}\"";
$text = preg_replace($pattern, $replace, $text);
$replace = '<br />' . t('[Embedded content - reload page to view]') . '<br />';
$pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*video[^>]*>(.*?)<\s*\/\s*video>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*embed[^>]*>(.*?)<\s*\/\s*embed>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i";
$text = preg_replace($pattern, $replace, $text);
if (get_pconfig(local_user(), "system", "bandwith_saver")) {
$replace = "<br />".t("[Embedded content - reload page to view]")."<br />";
$pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*video[^>]*>(.*?)<\s*\/\s*video>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*embed[^>]*>(.*?)<\s*\/\s*embed>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i";
$text = preg_replace($pattern, $replace, $text);
}
echo str_replace("\t",' ',$text);
echo str_replace("\t", " ", $text);
echo "</section>";
echo "</body></html>\r\n";
killme();
}

View file

@ -2,40 +2,41 @@
// See update_profile.php for documentation
require_once('mod/network.php');
require_once('include/group.php');
require_once("mod/network.php");
require_once("include/group.php");
function update_network_content(&$a) {
$profile_uid = intval($_GET['p']);
$profile_uid = intval($_GET["p"]);
header("Content-type: text/html");
echo "<!DOCTYPE html><html><body>\r\n";
echo "<section>";
if (!get_pconfig($profile_uid, "system", "no_auto_update") OR ($_GET['force'] == 1))
$text = network_content($a,$profile_uid);
else
if (!get_pconfig($profile_uid, "system", "no_auto_update") OR ($_GET["force"] == 1)) {
$text = network_content($a, $profile_uid);
} else {
$text = "";
}
$pattern = "/<img([^>]*) src=\"([^\"]*)\"/";
$replace = "<img\${1} dst=\"\${2}\"";
$text = preg_replace($pattern, $replace, $text);
$replace = '<br />' . t('[Embedded content - reload page to view]') . '<br />';
$pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*video[^>]*>(.*?)<\s*\/\s*video>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*embed[^>]*>(.*?)<\s*\/\s*embed>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i";
$text = preg_replace($pattern, $replace, $text);
if (get_pconfig(local_user(), "system", "bandwith_saver")) {
$replace = "<br />".t("[Embedded content - reload page to view]")."<br />";
$pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*video[^>]*>(.*?)<\s*\/\s*video>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*embed[^>]*>(.*?)<\s*\/\s*embed>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i";
$text = preg_replace($pattern, $replace, $text);
}
echo str_replace("\t",' ',$text);
echo str_replace("\t", " ", $text);
echo "</section>";
echo "</body></html>\r\n";
killme();
}

View file

@ -1,17 +1,15 @@
<?php
/**
* Module: update_profile
* Purpose: AJAX synchronisation of profile page
*
* Module: update_notes
* Purpose: AJAX synchronisation of notes page
*/
require_once('mod/notes.php');
require_once("mod/notes.php");
function update_notes_content(&$a) {
$profile_uid = intval($_GET['p']);
$profile_uid = intval($_GET["p"]);
header("Content-type: text/html");
echo "<!DOCTYPE html><html><body>\r\n";
@ -20,37 +18,35 @@ function update_notes_content(&$a) {
/**
*
* Grab the page inner contents by calling the content function from the profile module directly,
* but move any image src attributes to another attribute name. This is because
* Grab the page inner contents by calling the content function from the profile module directly,
* but move any image src attributes to another attribute name. This is because
* some browsers will prefetch all the images for the page even if we don't need them.
* The only ones we need to fetch are those for new page additions, which we'll discover
* on the client side and then swap the image back.
*
*/
$text = notes_content($a,$profile_uid);
$text = notes_content($a, $profile_uid);
$pattern = "/<img([^>]*) src=\"([^\"]*)\"/";
$replace = "<img\${1} dst=\"\${2}\"";
$text = preg_replace($pattern, $replace, $text);
$replace = '<br />' . t('[Embedded content - reload page to view]') . '<br />';
$pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*video[^>]*>(.*?)<\s*\/\s*video>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*embed[^>]*>(.*?)<\s*\/\s*embed>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i";
$text = preg_replace($pattern, $replace, $text);
if (get_pconfig(local_user(), "system", "bandwith_saver")) {
$replace = "<br />".t("[Embedded content - reload page to view]")."<br />";
$pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*video[^>]*>(.*?)<\s*\/\s*video>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*embed[^>]*>(.*?)<\s*\/\s*embed>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i";
$text = preg_replace($pattern, $replace, $text);
}
/**
* reportedly some versions of MSIE don't handle tabs in XMLHttpRequest documents very well
*/
echo str_replace("\t",' ',$text);
// reportedly some versions of MSIE don't handle tabs in XMLHttpRequest documents very well
echo str_replace("\t", " ", $text);
echo "</section>";
echo "</body></html>\r\n";
killme();
}

View file

@ -3,58 +3,49 @@
/**
* Module: update_profile
* Purpose: AJAX synchronisation of profile page
*
*/
require_once('mod/profile.php');
require_once("mod/profile.php");
function update_profile_content(&$a) {
$profile_uid = intval($_GET['p']);
$profile_uid = intval($_GET["p"]);
header("Content-type: text/html");
echo "<!DOCTYPE html><html><body>\r\n";
/**
* We can remove this hack once Internet Explorer recognises HTML5 natively
*/
// We can remove this hack once Internet Explorer recognises HTML5 natively
echo "<section>";
/**
*
* Grab the page inner contents by calling the content function from the profile module directly,
* but move any image src attributes to another attribute name. This is because
* Grab the page inner contents by calling the content function from the profile module directly,
* but move any image src attributes to another attribute name. This is because
* some browsers will prefetch all the images for the page even if we don't need them.
* The only ones we need to fetch are those for new page additions, which we'll discover
* on the client side and then swap the image back.
*
*/
$text = profile_content($a,$profile_uid);
$text = profile_content($a, $profile_uid);
$pattern = "/<img([^>]*) src=\"([^\"]*)\"/";
$replace = "<img\${1} dst=\"\${2}\"";
$text = preg_replace($pattern, $replace, $text);
$replace = '<br />' . t('[Embedded content - reload page to view]') . '<br />';
$pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*video[^>]*>(.*?)<\s*\/\s*video>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*embed[^>]*>(.*?)<\s*\/\s*embed>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i";
$text = preg_replace($pattern, $replace, $text);
if (get_pconfig(local_user(), "system", "bandwith_saver")) {
$replace = "<br />".t("[Embedded content - reload page to view]")."<br />";
$pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*video[^>]*>(.*?)<\s*\/\s*video>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*embed[^>]*>(.*?)<\s*\/\s*embed>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i";
$text = preg_replace($pattern, $replace, $text);
}
/**
* reportedly some versions of MSIE don't handle tabs in XMLHttpRequest documents very well
*/
echo str_replace("\t",' ',$text);
// reportedly some versions of MSIE don't handle tabs in XMLHttpRequest documents very well
echo str_replace("\t", " ", $text);
echo "</section>";
echo "</body></html>\r\n";
killme();
}

View file

@ -33,10 +33,7 @@ function videos_init(&$a) {
$profile = get_profiledata_by_nick($nick, $a->profile_uid);
if((intval($profile['page-flags']) == PAGE_COMMUNITY) || (intval($profile['page-flags']) == PAGE_PRVGROUP))
$account_type = t('Forum');
else
$account_type = "";
$account_type = account_type($profile);
$tpl = get_markup_template("vcard-widget.tpl");
@ -266,7 +263,7 @@ function videos_content(&$a) {
$can_post = true;
$contact = $r[0];
$remote_contact = true;
$visitor = $cid;
$visitor = $contact_id;
}
}
}

View file

@ -47,7 +47,7 @@ function viewcontacts_content(&$a) {
}
$r = q("SELECT COUNT(*) AS `total` FROM `contact`
WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0
WHERE `uid` = %d AND (NOT `blocked` OR `pending`) AND NOT `hidden` AND NOT `archive`
AND `network` IN ('%s', '%s', '%s')",
intval($a->profile['uid']),
dbesc(NETWORK_DFRN),
@ -58,7 +58,7 @@ function viewcontacts_content(&$a) {
$a->set_pager_total($r[0]['total']);
$r = q("SELECT * FROM `contact`
WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0
WHERE `uid` = %d AND (NOT `blocked` OR `pending`) AND NOT `hidden` AND NOT `archive`
AND `network` IN ('%s', '%s', '%s')
ORDER BY `name` ASC LIMIT %d, %d",
intval($a->profile['uid']),
@ -102,7 +102,7 @@ function viewcontacts_content(&$a) {
'details' => $contact_details['location'],
'tags' => $contact_details['keywords'],
'about' => $contact_details['about'],
'account_type' => (($contact_details['community']) ? t('Forum') : ''),
'account_type' => account_type($contact_details),
'url' => $url,
'sparkle' => '',
'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),

View file

@ -14,19 +14,19 @@ function wall_attach_post(&$a) {
);
if(! count($r)){
if ($r_json) {
echo json_encode(array('error'=>t('Invalid request.')));
killme();
}
echo json_encode(array('error'=>t('Invalid request.')));
killme();
}
return;
}
}
} else {
if ($r_json) {
echo json_encode(array('error'=>t('Invalid request.')));
killme();
}
echo json_encode(array('error'=>t('Invalid request.')));
killme();
}
return;
}
}
$can_post = false;
$visitor = 0;
@ -40,41 +40,41 @@ function wall_attach_post(&$a) {
$can_post = true;
else {
if($community_page && remote_user()) {
$cid = 0;
$contact_id = 0;
if(is_array($_SESSION['remote'])) {
foreach($_SESSION['remote'] as $v) {
if($v['uid'] == $page_owner_uid) {
$cid = $v['cid'];
$contact_id = $v['cid'];
break;
}
}
}
if($cid) {
if($contact_id) {
$r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
intval($cid),
intval($contact_id),
intval($page_owner_uid)
);
if(count($r)) {
$can_post = true;
$visitor = $cid;
$visitor = $contact_id;
}
}
}
}
if(! $can_post) {
if ($r_json) {
echo json_encode(array('error'=>t('Permission denied.')));
killme();
}
echo json_encode(array('error'=>t('Permission denied.')));
killme();
}
notice( t('Permission denied.') . EOL );
killme();
}
if(! x($_FILES,'userfile')) {
if ($r_json) {
echo json_encode(array('error'=>t('Invalid request.')));
}
echo json_encode(array('error'=>t('Invalid request.')));
}
killme();
}
@ -179,9 +179,9 @@ function wall_attach_post(&$a) {
}
if ($r_json) {
echo json_encode(array('ok'=>true));
killme();
}
echo json_encode(array('ok'=>true));
killme();
}
$lf = "\n";

View file

@ -17,8 +17,8 @@ function wall_upload_post(&$a, $desktopmode = true) {
if(! count($r)){
if ($r_json) {
echo json_encode(array('error'=>t('Invalid request.')));
killme();
echo json_encode(array('error'=>t('Invalid request.')));
killme();
}
return;
}
@ -30,8 +30,8 @@ function wall_upload_post(&$a, $desktopmode = true) {
}
} else {
if ($r_json) {
echo json_encode(array('error'=>t('Invalid request.')));
killme();
echo json_encode(array('error'=>t('Invalid request.')));
killme();
}
return;
}
@ -48,24 +48,24 @@ function wall_upload_post(&$a, $desktopmode = true) {
$can_post = true;
else {
if($community_page && remote_user()) {
$cid = 0;
$contact_id = 0;
if(is_array($_SESSION['remote'])) {
foreach($_SESSION['remote'] as $v) {
if($v['uid'] == $page_owner_uid) {
$cid = $v['cid'];
$contact_id = $v['cid'];
break;
}
}
}
if($cid) {
if($contact_id) {
$r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
intval($cid),
intval($contact_id),
intval($page_owner_uid)
);
if(count($r)) {
$can_post = true;
$visitor = $cid;
$visitor = $contact_id;
}
}
}
@ -74,8 +74,8 @@ function wall_upload_post(&$a, $desktopmode = true) {
if(! $can_post) {
if ($r_json) {
echo json_encode(array('error'=>t('Permission denied.')));
killme();
echo json_encode(array('error'=>t('Permission denied.')));
killme();
}
notice( t('Permission denied.') . EOL );
killme();
@ -83,7 +83,7 @@ function wall_upload_post(&$a, $desktopmode = true) {
if(! x($_FILES,'userfile') && ! x($_FILES,'media')){
if ($r_json) {
echo json_encode(array('error'=>t('Invalid request.')));
echo json_encode(array('error'=>t('Invalid request.')));
}
killme();
}
@ -119,8 +119,8 @@ function wall_upload_post(&$a, $desktopmode = true) {
if ($src=="") {
if ($r_json) {
echo json_encode(array('error'=>t('Invalid request.')));
killme();
echo json_encode(array('error'=>t('Invalid request.')));
killme();
}
notice(t('Invalid request.').EOL);
killme();
@ -248,8 +248,8 @@ function wall_upload_post(&$a, $desktopmode = true) {
$r = q("SELECT `id`, `datasize`, `width`, `height`, `type` FROM `photo` WHERE `resource-id` = '%s' ORDER BY `width` DESC LIMIT 1", $hash);
if (!$r){
if ($r_json) {
echo json_encode(array('error'=>''));
killme();
echo json_encode(array('error'=>''));
killme();
}
return false;
}
@ -265,16 +265,16 @@ function wall_upload_post(&$a, $desktopmode = true) {
$picture["preview"] = $a->get_baseurl()."/photo/{$hash}-{$smallest}.".$ph->getExt();
if ($r_json) {
echo json_encode(array('picture'=>$picture));
killme();
echo json_encode(array('picture'=>$picture));
killme();
}
return $picture;
}
if ($r_json) {
echo json_encode(array('ok'=>true));
killme();
echo json_encode(array('ok'=>true));
killme();
}
/* mod Waitman Gobble NO WARRANTY */

54
mod/worker.php Normal file
View file

@ -0,0 +1,54 @@
<?php
/**
* @file mod/worker.php
* @brief Module for running the poller as frontend process
*/
require_once("include/poller.php");
use \Friendica\Core\Config;
use \Friendica\Core\PConfig;
function worker_init($a){
if (!Config::get("system", "frontend_worker") OR !Config::get("system", "worker")) {
return;
}
// We don't need the following lines if we can execute background jobs.
// So we just wake up the worker if it sleeps.
if (function_exists("proc_open")) {
call_worker_if_idle();
return;
}
clear_worker_processes();
$workers = q("SELECT COUNT(*) AS `processes` FROM `process` WHERE `command` = 'worker.php'");
if ($workers[0]["processes"] > Config::get("system", "worker_queues", 4)) {
return;
}
$a->start_process();
logger("Front end worker started: ".getmypid());
call_worker();
if ($r = poller_worker_process()) {
// On most configurations this parameter wouldn't have any effect.
// But since it doesn't destroy anything, we just try to get more execution time in any way.
set_time_limit(0);
poller_execute($r[0]);
}
call_worker();
$a->end_process();
logger("Front end worker ended: ".getmypid());
killme();
}