Merge remote-tracking branch 'upstream/master'
Conflicts: mod/admin.php
This commit is contained in:
commit
de75d8ca7f
9 changed files with 5829 additions and 5627 deletions
2
boot.php
2
boot.php
|
@ -12,7 +12,7 @@ require_once('library/Mobile_Detect/Mobile_Detect.php');
|
|||
require_once('include/features.php');
|
||||
|
||||
define ( 'FRIENDICA_PLATFORM', 'Friendica');
|
||||
define ( 'FRIENDICA_VERSION', '3.2.1751' );
|
||||
define ( 'FRIENDICA_VERSION', '3.2.1753' );
|
||||
define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
|
||||
define ( 'DB_UPDATE_VERSION', 1170 );
|
||||
define ( 'EOL', "<br />\r\n" );
|
||||
|
|
|
@ -2311,6 +2311,48 @@
|
|||
api_register_func('api/oauth/request_token', 'api_oauth_request_token', false);
|
||||
api_register_func('api/oauth/access_token', 'api_oauth_access_token', false);
|
||||
|
||||
|
||||
function api_fr_photos_list(&$a,$type) {
|
||||
if (api_user()===false) return false;
|
||||
$r = q("select distinct `resource-id` from photo where uid = %d and album != 'Contact Photos' ",
|
||||
intval(local_user())
|
||||
);
|
||||
if($r) {
|
||||
$ret = array();
|
||||
foreach($r as $rr)
|
||||
$ret[] = $rr['resource-id'];
|
||||
header("Content-type: application/json");
|
||||
echo json_encode($ret);
|
||||
}
|
||||
killme();
|
||||
}
|
||||
|
||||
function api_fr_photo_detail(&$a,$type) {
|
||||
if (api_user()===false) return false;
|
||||
if(! $_REQUEST['photo_id']) return false;
|
||||
$scale = ((array_key_exists('scale',$_REQUEST)) ? intval($_REQUEST['scale']) : 0);
|
||||
$r = q("select * from photo where uid = %d and `resource-id` = '%s' and scale = %d limit 1",
|
||||
intval(local_user()),
|
||||
dbesc($_REQUEST['photo_id']),
|
||||
intval($scale)
|
||||
);
|
||||
if($r) {
|
||||
header("Content-type: application/json");
|
||||
$r[0]['data'] = base64_encode($r[0]['data']);
|
||||
echo json_encode($r[0]);
|
||||
}
|
||||
|
||||
killme();
|
||||
}
|
||||
|
||||
api_register_func('api/friendica/photos/list', 'api_fr_photos_list', true);
|
||||
api_register_func('api/friendica/photo', 'api_fr_photo_detail', true);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function api_share_as_retweet($a, $uid, &$item) {
|
||||
$body = trim($item["body"]);
|
||||
|
||||
|
|
|
@ -1473,6 +1473,13 @@ function prepare_body(&$item,$attach = false, $preview = false) {
|
|||
$s = substr($s, 0, $pos).$authorreplace.substr($s, $pos+strlen($authorsearch));
|
||||
}
|
||||
|
||||
// replace friendica image url size with theme preference
|
||||
if (x($a->theme_info,'item_image_size')){
|
||||
$ps = $a->theme_info['item_image_size'];
|
||||
|
||||
$s = preg_replace('|(<img[^>]+src="[^"]+/photo/[0-9a-f]+)-[0-9]|',"$1-".$ps, $s);
|
||||
}
|
||||
|
||||
$prep_arr = array('item' => $item, 'html' => $s);
|
||||
call_hooks('prepare_body_final', $prep_arr);
|
||||
|
||||
|
|
|
@ -362,6 +362,7 @@ function admin_page_site_post(&$a){
|
|||
$basepath = ((x($_POST,'basepath')) ? notags(trim($_POST['basepath'])) : '');
|
||||
$singleuser = ((x($_POST,'singleuser')) ? notags(trim($_POST['singleuser'])) : '');
|
||||
$proxy_disabled = ((x($_POST,'proxy_disabled')) ? True : False);
|
||||
$enable_noscrape = ((x($_POST,'enable_noscrape')) ? true : false);
|
||||
if($ssl_policy != intval(get_config('system','ssl_policy'))) {
|
||||
if($ssl_policy == SSL_POLICY_FULL) {
|
||||
q("update `contact` set
|
||||
|
@ -486,6 +487,7 @@ function admin_page_site_post(&$a){
|
|||
set_config('system','temppath', $temppath);
|
||||
set_config('system','basepath', $basepath);
|
||||
set_config('system','proxy_disabled', $proxy_disabled);
|
||||
set_config('system','enable_noscrape', $enable_noscrape);
|
||||
|
||||
info( t('Site settings updated.') . EOL);
|
||||
goaway($a->get_baseurl(true) . '/admin/site' );
|
||||
|
@ -648,7 +650,8 @@ function admin_page_site(&$a) {
|
|||
|
||||
'$relocate_url' => array('relocate_url', t("New base url"), $a->get_baseurl(), "Change base url for this server. Sends relocate message to all DFRN contacts of all users."),
|
||||
|
||||
'$form_security_token' => get_form_security_token("admin_site"),
|
||||
'$enable_noscrape'=> array('enable_noscrape', t("Enable noscrape"), get_config('system','enable_noscrape'), t("The noscrape feature speeds up directory submissions by using JSON data instead of HTML scraping.")),
|
||||
'$form_security_token' => get_form_security_token("admin_site")
|
||||
|
||||
));
|
||||
|
||||
|
|
|
@ -37,9 +37,13 @@ function friendica_init(&$a) {
|
|||
'admin' => $admin,
|
||||
'site_name' => $a->config['sitename'],
|
||||
'platform' => FRIENDICA_PLATFORM,
|
||||
'info' => ((x($a->config,'info')) ? $a->config['info'] : '')
|
||||
'info' => ((x($a->config,'info')) ? $a->config['info'] : ''),
|
||||
);
|
||||
|
||||
//Enable noscrape?
|
||||
if(!!get_config('system','enable_noscrape'))
|
||||
$data['no_scrape_url'] = $a->get_baseurl().'/noscrape';
|
||||
|
||||
echo json_encode($data);
|
||||
killme();
|
||||
}
|
||||
|
|
51
mod/noscrape.php
Normal file
51
mod/noscrape.php
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
function noscrape_init(&$a) {
|
||||
|
||||
if(!get_config('system','enable_noscrape'))
|
||||
killme();
|
||||
|
||||
if($a->argc > 1)
|
||||
$which = $a->argv[1];
|
||||
else
|
||||
killme();
|
||||
|
||||
$profile = 0;
|
||||
if((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) {
|
||||
$which = $a->user['nickname'];
|
||||
$profile = $a->argv[1];
|
||||
}
|
||||
|
||||
profile_load($a,$which,$profile);
|
||||
|
||||
if(!$a->profile['net-publish'])
|
||||
killme();
|
||||
|
||||
$keywords = ((x($a->profile,'pub_keywords')) ? $a->profile['pub_keywords'] : '');
|
||||
$keywords = str_replace(array('#',',',' ',',,'),array('',' ',',',','),$keywords);
|
||||
$keywords = explode(',', $keywords);
|
||||
|
||||
$json_info = array(
|
||||
'fn' => $a->profile['name'],
|
||||
'key' => $a->profile['pubkey'],
|
||||
'homepage' => $a->get_baseurl()."/profile/{$which}",
|
||||
'comm' => (x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY),
|
||||
'photo' => $a->profile['photo'],
|
||||
'tags' => $keywords
|
||||
);
|
||||
|
||||
//These are optional fields.
|
||||
$profile_fields = array('pdesc', 'locality', 'region', 'postal-code', 'country-name', 'gender', 'marital');
|
||||
foreach($profile_fields as $field)
|
||||
if(!empty($a->profile[$field])) $json_info["$field"] = $a->profile[$field];
|
||||
|
||||
$dfrn_pages = array('request', 'confirm', 'notify', 'poll');
|
||||
foreach($dfrn_pages as $dfrn)
|
||||
$json_info["dfrn-{$dfrn}"] = $a->get_baseurl()."/dfrn_{$dfrn}/{$which}";
|
||||
|
||||
//Output all the JSON!
|
||||
header('Content-type: application/json; charset=utf-8');
|
||||
echo json_encode($json_info);
|
||||
exit;
|
||||
|
||||
}
|
|
@ -101,7 +101,8 @@ function photo_init(&$a) {
|
|||
$photo = substr($photo,0,-2);
|
||||
}
|
||||
|
||||
$r = q("SELECT `uid` FROM `photo` WHERE `resource-id` = '%s' AND `scale` = %d LIMIT 1",
|
||||
// check if the photo exists and get the owner of the photo
|
||||
$r = q("SELECT `uid` FROM `photo` WHERE `resource-id` = '%s' LIMIT 1",
|
||||
dbesc($photo),
|
||||
intval($resolution)
|
||||
);
|
||||
|
@ -111,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 LIMIT 1",
|
||||
$r = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' AND `scale` <= %d $sql_extra ORDER BY scale DESC LIMIT 1",
|
||||
dbesc($photo),
|
||||
intval($resolution)
|
||||
);
|
||||
|
@ -119,31 +120,19 @@ function photo_init(&$a) {
|
|||
$public = ($r[0]['allow_cid'] == '') AND ($r[0]['allow_gid'] == '') AND ($r[0]['deny_cid'] == '') AND ($r[0]['deny_gid'] == '');
|
||||
|
||||
if(count($r)) {
|
||||
$resolution = $r[0]['scale'];
|
||||
$data = $r[0]['data'];
|
||||
$mimetype = $r[0]['type'];
|
||||
}
|
||||
else {
|
||||
|
||||
// Does the picture exist? It may be a remote person with no credentials,
|
||||
// but who should otherwise be able to view it. Show a default image to let
|
||||
// them know permissions was denied. It may be possible to view the image
|
||||
// through an authenticated profile visit.
|
||||
// There won't be many completely unauthorised people seeing this because
|
||||
// they won't have the photo link, so there's a reasonable chance that the person
|
||||
// might be able to obtain permission to view it.
|
||||
|
||||
$r = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' AND `scale` = %d LIMIT 1",
|
||||
dbesc($photo),
|
||||
intval($resolution)
|
||||
);
|
||||
if(count($r)) {
|
||||
// The picure exists. We already checked with the first query.
|
||||
// obviously, this is not an authorized viev!
|
||||
$data = file_get_contents('images/nosign.jpg');
|
||||
$mimetype = 'image/jpeg';
|
||||
$prvcachecontrol = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(! isset($data)) {
|
||||
if(isset($resolution)) {
|
||||
|
|
11053
util/messages.po
11053
util/messages.po
File diff suppressed because it is too large
Load diff
|
@ -108,6 +108,7 @@
|
|||
{{include file="field_checkbox.tpl" field=$suppress_language}}
|
||||
|
||||
<h3>{{$performance}}</h3>
|
||||
{{include file="field_checkbox.tpl" field=$enable_noscrape}}
|
||||
{{include file="field_checkbox.tpl" field=$use_fulltext_engine}}
|
||||
{{include file="field_input.tpl" field=$itemcache}}
|
||||
{{include file="field_input.tpl" field=$itemcache_duration}}
|
||||
|
|
Loading…
Reference in a new issue