Merge remote-tracking branch 'upstream/master'

Conflicts:
	mod/admin.php
This commit is contained in:
Michael Vogel 2014-08-13 00:18:05 +02:00
commit de75d8ca7f
9 changed files with 5829 additions and 5627 deletions

View file

@ -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' );
@ -647,8 +649,9 @@ function admin_page_site(&$a) {
'$proxy_disabled' => array('proxy_disabled', t("Disable picture proxy"), get_config('system','proxy_disabled'), t("The picture proxy increases performance and privacy. It shouldn't be used on systems with very low bandwith.")),
'$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")
));

View file

@ -37,8 +37,12 @@ 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
View 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;
}

View file

@ -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,28 +120,16 @@ 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)) {
$data = file_get_contents('images/nosign.jpg');
$mimetype = 'image/jpeg';
$prvcachecontrol = true;
}
// 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;
}
}
}