Merge remote-tracking branch 'upstream/develop' into 1607-performance
This commit is contained in:
commit
fc3c1601b1
1113 changed files with 22748 additions and 167747 deletions
|
@ -428,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),
|
||||
|
@ -478,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
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -652,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;
|
||||
|
@ -802,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."));
|
||||
|
@ -1033,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")
|
||||
|
||||
|
@ -1388,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'),
|
||||
|
|
|
@ -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].
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
||||
|
|
|
@ -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.
|
||||
}}
|
||||
}
|
||||
|
|
13
mod/item.php
13
mod/item.php
|
@ -173,7 +173,8 @@ 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)) {
|
||||
|
@ -718,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...
|
||||
|
@ -744,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));
|
||||
|
@ -812,7 +817,7 @@ 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,
|
||||
|
@ -822,7 +827,7 @@ 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']),
|
||||
|
@ -870,6 +875,8 @@ function item_post(&$a) {
|
|||
dbesc($datarray['file']),
|
||||
dbesc($datarray['rendered-html']),
|
||||
dbesc($datarray['rendered-hash']),
|
||||
intval($datarray['gcontact-id']),
|
||||
dbesc($datarray['object']),
|
||||
intval($datarray['parent']),
|
||||
dbesc($datarray['parent-uri']),
|
||||
dbesc($datarray['plink']),
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -453,6 +453,7 @@ 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)) : '');
|
||||
|
@ -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'));
|
||||
|
@ -503,7 +504,7 @@ function network_content(&$a, $update = 0) {
|
|||
elseif($cid) {
|
||||
|
||||
$r = qu("SELECT `id`,`name`,`network`,`writable`,`nurl`, `forum`, `prv`, `contact-type`, `addr`, `thumb`, `location` FROM `contact` WHERE `id` = %d
|
||||
AND `blocked` = 0 AND `pending` = 0 LIMIT 1",
|
||||
AND (NOT `blocked` OR `pending`) LIMIT 1",
|
||||
intval($cid)
|
||||
);
|
||||
if(count($r)) {
|
||||
|
@ -569,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";
|
||||
|
@ -583,7 +584,7 @@ function network_content(&$a, $update = 0) {
|
|||
}
|
||||
}
|
||||
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";
|
||||
|
@ -601,7 +602,7 @@ function network_content(&$a, $update = 0) {
|
|||
if(get_config('system', 'old_pager')) {
|
||||
$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 ",
|
||||
|
@ -679,7 +680,7 @@ function network_content(&$a, $update = 0) {
|
|||
|
||||
$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
|
||||
|
@ -689,7 +690,7 @@ function network_content(&$a, $update = 0) {
|
|||
} else {
|
||||
$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
|
||||
|
|
|
@ -1,516 +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();
|
||||
|
||||
// Check if the URL does contain a scheme
|
||||
$scheme = parse_url($url, PHP_URL_SCHEME);
|
||||
|
||||
if ($scheme == "") {
|
||||
$url = "http://".trim($url, "/");
|
||||
}
|
||||
|
||||
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";
|
||||
|
||||
$check_cert = get_config('system','verifyssl');
|
||||
|
||||
$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_USERAGENT, $a->get_useragent());
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, (($check_cert) ? true : false));
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, (($check_cert) ? 2 : false));
|
||||
|
||||
$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 (!in_array($oembed_data->type, array("error", "rich"))) {
|
||||
$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());
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, (($check_cert) ? true : false));
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, (($check_cert) ? 2 : false));
|
||||
|
||||
$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("'"), array("’"), $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;
|
||||
}
|
||||
|
|
536
mod/ping.php
536
mod/ping.php
|
@ -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,110 +123,90 @@ 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);
|
||||
$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`, COUNT(*) as `total` FROM `contact` RIGHT JOIN `register` ON `register`.`uid`=`contact`.`uid` WHERE `contact`.`self`=1");
|
||||
if ($regs)
|
||||
$register = $regs[0]['total'];
|
||||
} 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");
|
||||
if ($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') {
|
||||
|
@ -160,7 +216,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 ++;
|
||||
|
@ -171,99 +227,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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -279,68 +306,79 @@ 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();
|
||||
}
|
||||
|
||||
|
@ -350,19 +388,19 @@ function ping_init(&$a) {
|
|||
* @param int $uid User id
|
||||
* @return array Associative array of notifications
|
||||
*/
|
||||
function ping_get_notifications($uid) {
|
||||
|
||||
$result = array();
|
||||
$offset = 0;
|
||||
$seen = false;
|
||||
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))
|
||||
|
@ -422,3 +460,71 @@ function ping_get_notifications($uid) {
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -113,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
|
||||
|
@ -133,6 +134,7 @@ function register_post(&$a) {
|
|||
$admin_mail_list
|
||||
);
|
||||
|
||||
// send notification to admins
|
||||
foreach ($adminlist as $admin) {
|
||||
notification(array(
|
||||
'type' => NOTIFY_SYSTEM,
|
||||
|
@ -149,6 +151,11 @@ function register_post(&$a) {
|
|||
'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,
|
||||
|
|
|
@ -301,6 +301,7 @@ function settings_post(&$a) {
|
|||
$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;
|
||||
|
@ -321,6 +322,7 @@ function settings_post(&$a) {
|
|||
set_pconfig(local_user(),'system','mobile_theme',$mobile_theme);
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -951,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
|
||||
|
@ -995,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')),
|
||||
|
|
|
@ -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']),
|
||||
|
|
54
mod/worker.php
Normal file
54
mod/worker.php
Normal 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();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue