mirror of
https://github.com/friendica/friendica
synced 2025-01-19 09:47:03 +01:00
Merge pull request #3036 from Quix0r/rewrites/app_get_baseurl_static
$a->get_baseurl() rewritten to App::get_baseurl() - 2nd PR
This commit is contained in:
commit
ca734f168c
162 changed files with 2201 additions and 1825 deletions
23
boot.php
23
boot.php
|
@ -670,22 +670,23 @@ class App {
|
|||
|
||||
#set_include_path("include/$this->hostname" . PATH_SEPARATOR . get_include_path());
|
||||
|
||||
if((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,9) === "pagename=") {
|
||||
if ((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,9) === "pagename=") {
|
||||
$this->query_string = substr($_SERVER['QUERY_STRING'],9);
|
||||
// removing trailing / - maybe a nginx problem
|
||||
if (substr($this->query_string, 0, 1) == "/")
|
||||
$this->query_string = substr($this->query_string, 1);
|
||||
} elseif((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,2) === "q=") {
|
||||
} elseif ((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,2) === "q=") {
|
||||
$this->query_string = substr($_SERVER['QUERY_STRING'],2);
|
||||
// removing trailing / - maybe a nginx problem
|
||||
if (substr($this->query_string, 0, 1) == "/")
|
||||
$this->query_string = substr($this->query_string, 1);
|
||||
}
|
||||
|
||||
if (x($_GET,'pagename'))
|
||||
if (x($_GET,'pagename')) {
|
||||
$this->cmd = trim($_GET['pagename'],'/\\');
|
||||
elseif (x($_GET,'q'))
|
||||
} elseif (x($_GET,'q')) {
|
||||
$this->cmd = trim($_GET['q'],'/\\');
|
||||
}
|
||||
|
||||
|
||||
// fix query_string
|
||||
|
@ -694,13 +695,15 @@ class App {
|
|||
|
||||
// unix style "homedir"
|
||||
|
||||
if(substr($this->cmd,0,1) === '~')
|
||||
if (substr($this->cmd,0,1) === '~') {
|
||||
$this->cmd = 'profile/' . substr($this->cmd,1);
|
||||
}
|
||||
|
||||
// Diaspora style profile url
|
||||
|
||||
if(substr($this->cmd,0,2) === 'u/')
|
||||
if (substr($this->cmd,0,2) === 'u/') {
|
||||
$this->cmd = 'profile/' . substr($this->cmd,2);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
@ -1028,7 +1031,7 @@ class App {
|
|||
} else {
|
||||
$r = q("SELECT `contact`.`avatar-date` AS picdate FROM `contact` WHERE `contact`.`thumb` like '%%/%s'",
|
||||
$common_filename);
|
||||
if(! dbm::is_result($r)){
|
||||
if (! dbm::is_result($r)) {
|
||||
$this->cached_profile_image[$avatar_image] = $avatar_image;
|
||||
} else {
|
||||
$this->cached_profile_picdate[$common_filename] = "?rev=".urlencode($r[0]['picdate']);
|
||||
|
@ -1548,9 +1551,9 @@ function check_url(&$a) {
|
|||
// We will only change the url to an ip address if there is no existing setting
|
||||
|
||||
if(! x($url))
|
||||
$url = set_config('system','url',$a->get_baseurl());
|
||||
if((! link_compare($url,$a->get_baseurl())) && (! preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/",$a->get_hostname)))
|
||||
$url = set_config('system','url',$a->get_baseurl());
|
||||
$url = set_config('system','url',App::get_baseurl());
|
||||
if((! link_compare($url,App::get_baseurl())) && (! preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/",$a->get_hostname)))
|
||||
$url = set_config('system','url',App::get_baseurl());
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -124,8 +124,9 @@ The selected 1st part will be saved in the database by the theme_post function.
|
|||
|
||||
function theme_post(&$a){
|
||||
// non local users shall not pass
|
||||
if(! local_user())
|
||||
if (! local_user()) {
|
||||
return;
|
||||
}
|
||||
// if the one specific submit button was pressed then proceed
|
||||
if (isset($_POST['duepuntozero-settings-submit'])){
|
||||
// and save the selection key into the personal config of the user
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
function user_remove($uid) {
|
||||
if(! $uid)
|
||||
return;
|
||||
$a = get_app();
|
||||
logger('Removing user: ' . $uid);
|
||||
|
||||
$r = q("select * from user where uid = %d limit 1", intval($uid));
|
||||
|
@ -54,7 +53,7 @@ function user_remove($uid) {
|
|||
if($uid == local_user()) {
|
||||
unset($_SESSION['authenticated']);
|
||||
unset($_SESSION['uid']);
|
||||
goaway($a->get_baseurl());
|
||||
goaway(App::get_baseurl());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,12 +85,12 @@ function contact_remove($id) {
|
|||
|
||||
function terminate_friendship($user,$self,$contact) {
|
||||
|
||||
|
||||
/// @TODO Get rid of this, include/datetime.php should care about by itself
|
||||
$a = get_app();
|
||||
|
||||
require_once('include/datetime.php');
|
||||
|
||||
if($contact['network'] === NETWORK_OSTATUS) {
|
||||
if ($contact['network'] === NETWORK_OSTATUS) {
|
||||
|
||||
require_once('include/ostatus.php');
|
||||
|
||||
|
@ -101,16 +100,14 @@ function terminate_friendship($user,$self,$contact) {
|
|||
$item['follow'] = $contact["url"];
|
||||
$slap = ostatus::salmon($item, $user);
|
||||
|
||||
if((x($contact,'notify')) && (strlen($contact['notify']))) {
|
||||
if ((x($contact,'notify')) && (strlen($contact['notify']))) {
|
||||
require_once('include/salmon.php');
|
||||
slapper($user,$contact['notify'],$slap);
|
||||
}
|
||||
}
|
||||
elseif($contact['network'] === NETWORK_DIASPORA) {
|
||||
} elseif ($contact['network'] === NETWORK_DIASPORA) {
|
||||
require_once('include/diaspora.php');
|
||||
Diaspora::send_unshare($user,$contact);
|
||||
}
|
||||
elseif($contact['network'] === NETWORK_DFRN) {
|
||||
} elseif ($contact['network'] === NETWORK_DFRN) {
|
||||
require_once('include/dfrn.php');
|
||||
dfrn::deliver($user,$contact,'placeholder', 1);
|
||||
}
|
||||
|
@ -361,7 +358,7 @@ function contact_photo_menu($contact, $uid = 0)
|
|||
$sparkle = false;
|
||||
if ($contact['network'] === NETWORK_DFRN) {
|
||||
$sparkle = true;
|
||||
$profile_link = $a->get_baseurl() . '/redir/' . $contact['id'];
|
||||
$profile_link = App::get_baseurl() . '/redir/' . $contact['id'];
|
||||
} else {
|
||||
$profile_link = $contact['url'];
|
||||
}
|
||||
|
@ -377,17 +374,17 @@ function contact_photo_menu($contact, $uid = 0)
|
|||
}
|
||||
|
||||
if (in_array($contact['network'], array(NETWORK_DFRN, NETWORK_DIASPORA))) {
|
||||
$pm_url = $a->get_baseurl() . '/message/new/' . $contact['id'];
|
||||
$pm_url = App::get_baseurl() . '/message/new/' . $contact['id'];
|
||||
}
|
||||
|
||||
if ($contact['network'] == NETWORK_DFRN) {
|
||||
$poke_link = $a->get_baseurl() . '/poke/?f=&c=' . $contact['id'];
|
||||
$poke_link = App::get_baseurl() . '/poke/?f=&c=' . $contact['id'];
|
||||
}
|
||||
|
||||
$contact_url = $a->get_baseurl() . '/contacts/' . $contact['id'];
|
||||
$contact_url = App::get_baseurl() . '/contacts/' . $contact['id'];
|
||||
|
||||
$posts_link = $a->get_baseurl() . '/contacts/' . $contact['id'] . '/posts';
|
||||
$contact_drop_link = $a->get_baseurl() . '/contacts/' . $contact['id'] . '/drop?confirm=1';
|
||||
$posts_link = App::get_baseurl() . '/contacts/' . $contact['id'] . '/posts';
|
||||
$contact_drop_link = App::get_baseurl() . '/contacts/' . $contact['id'] . '/drop?confirm=1';
|
||||
|
||||
/**
|
||||
* menu array:
|
||||
|
|
|
@ -794,8 +794,6 @@ function update_contact_avatar($avatar, $uid, $cid, $force = false) {
|
|||
|
||||
function import_profile_photo($photo, $uid, $cid, $quit_on_error = false) {
|
||||
|
||||
$a = get_app();
|
||||
|
||||
$r = q("SELECT `resource-id` FROM `photo` WHERE `uid` = %d AND `contact-id` = %d AND `scale` = 4 AND `album` = 'Contact Photos' LIMIT 1",
|
||||
intval($uid),
|
||||
intval($cid)
|
||||
|
@ -841,9 +839,9 @@ function import_profile_photo($photo, $uid, $cid, $quit_on_error = false) {
|
|||
$photo_failure = true;
|
||||
}
|
||||
|
||||
$photo = $a->get_baseurl() . '/photo/' . $hash . '-4.' . $img->getExt();
|
||||
$thumb = $a->get_baseurl() . '/photo/' . $hash . '-5.' . $img->getExt();
|
||||
$micro = $a->get_baseurl() . '/photo/' . $hash . '-6.' . $img->getExt();
|
||||
$photo = App::get_baseurl() . '/photo/' . $hash . '-4.' . $img->getExt();
|
||||
$thumb = App::get_baseurl() . '/photo/' . $hash . '-5.' . $img->getExt();
|
||||
$micro = App::get_baseurl() . '/photo/' . $hash . '-6.' . $img->getExt();
|
||||
} else {
|
||||
$photo_failure = true;
|
||||
}
|
||||
|
@ -853,9 +851,9 @@ function import_profile_photo($photo, $uid, $cid, $quit_on_error = false) {
|
|||
}
|
||||
|
||||
if ($photo_failure) {
|
||||
$photo = $a->get_baseurl() . '/images/person-175.jpg';
|
||||
$thumb = $a->get_baseurl() . '/images/person-80.jpg';
|
||||
$micro = $a->get_baseurl() . '/images/person-48.jpg';
|
||||
$photo = App::get_baseurl() . '/images/person-175.jpg';
|
||||
$thumb = App::get_baseurl() . '/images/person-80.jpg';
|
||||
$micro = App::get_baseurl() . '/images/person-48.jpg';
|
||||
}
|
||||
|
||||
return(array($photo,$thumb,$micro));
|
||||
|
@ -1044,18 +1042,18 @@ function store_photo($a, $uid, $imagedata = "", $url = "") {
|
|||
return(array());
|
||||
}
|
||||
|
||||
$image = array("page" => $a->get_baseurl().'/photos/'.$page_owner_nick.'/image/'.$hash,
|
||||
"full" => $a->get_baseurl()."/photo/{$hash}-0.".$ph->getExt());
|
||||
$image = array("page" => App::get_baseurl().'/photos/'.$page_owner_nick.'/image/'.$hash,
|
||||
"full" => App::get_baseurl()."/photo/{$hash}-0.".$ph->getExt());
|
||||
|
||||
if ($width > 800 || $height > 800) {
|
||||
$image["large"] = $a->get_baseurl()."/photo/{$hash}-0.".$ph->getExt();
|
||||
$image["large"] = App::get_baseurl()."/photo/{$hash}-0.".$ph->getExt();
|
||||
}
|
||||
|
||||
if ($width > 640 || $height > 640) {
|
||||
$ph->scaleImage(640);
|
||||
$r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 1, 0, $defperm);
|
||||
if ($r) {
|
||||
$image["medium"] = $a->get_baseurl()."/photo/{$hash}-1.".$ph->getExt();
|
||||
$image["medium"] = App::get_baseurl()."/photo/{$hash}-1.".$ph->getExt();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1063,7 +1061,7 @@ function store_photo($a, $uid, $imagedata = "", $url = "") {
|
|||
$ph->scaleImage(320);
|
||||
$r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 2, 0, $defperm);
|
||||
if ($r) {
|
||||
$image["small"] = $a->get_baseurl()."/photo/{$hash}-2.".$ph->getExt();
|
||||
$image["small"] = App::get_baseurl()."/photo/{$hash}-2.".$ph->getExt();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1088,7 +1086,7 @@ function store_photo($a, $uid, $imagedata = "", $url = "") {
|
|||
|
||||
$r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 3, 0, $defperm);
|
||||
if ($r) {
|
||||
$image["thumb"] = $a->get_baseurl()."/photo/{$hash}-3.".$ph->getExt();
|
||||
$image["thumb"] = App::get_baseurl()."/photo/{$hash}-3.".$ph->getExt();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) {
|
|||
call_hooks($a->module . '_pre_' . $selname, $arr);
|
||||
|
||||
if (dbm::is_result($r)) {
|
||||
foreach($r as $rr) {
|
||||
foreach ($r as $rr) {
|
||||
if((is_array($preselected)) && in_array($rr['id'], $preselected))
|
||||
$selected = " selected=\"selected\" ";
|
||||
else
|
||||
|
@ -65,20 +65,24 @@ function contact_selector($selname, $selclass, $preselected = false, $options) {
|
|||
$exclude = false;
|
||||
$size = 4;
|
||||
|
||||
if(is_array($options)) {
|
||||
if(x($options,'size'))
|
||||
if (is_array($options)) {
|
||||
if (x($options,'size'))
|
||||
$size = $options['size'];
|
||||
|
||||
if(x($options,'mutual_friends'))
|
||||
if (x($options,'mutual_friends')) {
|
||||
$mutual = true;
|
||||
if(x($options,'single'))
|
||||
}
|
||||
if (x($options,'single')) {
|
||||
$single = true;
|
||||
if(x($options,'multiple'))
|
||||
}
|
||||
if (x($options,'multiple')) {
|
||||
$single = false;
|
||||
if(x($options,'exclude'))
|
||||
}
|
||||
if (x($options,'exclude')) {
|
||||
$exclude = $options['exclude'];
|
||||
}
|
||||
|
||||
if(x($options,'networks')) {
|
||||
if (x($options,'networks')) {
|
||||
switch($options['networks']) {
|
||||
case 'DFRN_ONLY':
|
||||
$networks = array(NETWORK_DFRN);
|
||||
|
@ -145,11 +149,12 @@ function contact_selector($selname, $selclass, $preselected = false, $options) {
|
|||
call_hooks($a->module . '_pre_' . $selname, $arr);
|
||||
|
||||
if (dbm::is_result($r)) {
|
||||
foreach($r as $rr) {
|
||||
if((is_array($preselected)) && in_array($rr['id'], $preselected))
|
||||
foreach ($r as $rr) {
|
||||
if ((is_array($preselected)) && in_array($rr['id'], $preselected)) {
|
||||
$selected = " selected=\"selected\" ";
|
||||
else
|
||||
} else {
|
||||
$selected = '';
|
||||
}
|
||||
|
||||
$trimmed = mb_substr($rr['name'],0,20);
|
||||
|
||||
|
@ -221,16 +226,19 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
|
|||
$receiverlist = array();
|
||||
|
||||
if (dbm::is_result($r)) {
|
||||
foreach($r as $rr) {
|
||||
if((is_array($preselected)) && in_array($rr['id'], $preselected))
|
||||
foreach ($r as $rr) {
|
||||
if ((is_array($preselected)) && in_array($rr['id'], $preselected)) {
|
||||
$selected = " selected=\"selected\" ";
|
||||
else
|
||||
}
|
||||
else {
|
||||
$selected = '';
|
||||
}
|
||||
|
||||
if($privmail)
|
||||
if ($privmail) {
|
||||
$trimmed = GetProfileUsername($rr['url'], $rr['name'], false);
|
||||
else
|
||||
} else {
|
||||
$trimmed = mb_substr($rr['name'],0,20);
|
||||
}
|
||||
|
||||
$receiverlist[] = $trimmed;
|
||||
|
||||
|
@ -256,16 +264,22 @@ function fixacl(&$item) {
|
|||
|
||||
function prune_deadguys($arr) {
|
||||
|
||||
if(! $arr)
|
||||
if (! $arr) {
|
||||
return $arr;
|
||||
}
|
||||
|
||||
$str = dbesc(implode(',',$arr));
|
||||
|
||||
$r = q("SELECT `id` FROM `contact` WHERE `id` IN ( " . $str . ") AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 ");
|
||||
if($r) {
|
||||
|
||||
if ($r) {
|
||||
$ret = array();
|
||||
foreach($r as $rr)
|
||||
foreach ($r as $rr) {
|
||||
$ret[] = intval($rr['id']);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
|
@ -392,8 +406,9 @@ function construct_acl_data(&$a, $user) {
|
|||
|
||||
function acl_lookup(&$a, $out_type = 'json') {
|
||||
|
||||
if(!local_user())
|
||||
return "";
|
||||
if (!local_user()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$start = (x($_REQUEST,'start') ? $_REQUEST['start'] : 0);
|
||||
$count = (x($_REQUEST,'count') ? $_REQUEST['count'] : 100);
|
||||
|
@ -540,35 +555,33 @@ function acl_lookup(&$a, $out_type = 'json') {
|
|||
dbesc(NETWORK_ZOT),
|
||||
dbesc(NETWORK_DIASPORA)
|
||||
);
|
||||
}
|
||||
elseif($type == 'a') {
|
||||
} elseif ($type == 'a') {
|
||||
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `forum`, `prv` FROM `contact`
|
||||
WHERE `uid` = %d AND `pending` = 0
|
||||
$sql_extra2
|
||||
ORDER BY `name` ASC ",
|
||||
intval(local_user())
|
||||
);
|
||||
}
|
||||
elseif($type == 'x') {
|
||||
} elseif ($type == 'x') {
|
||||
// autocomplete for global contact search (e.g. navbar search)
|
||||
$r = navbar_complete($a);
|
||||
$contacts = array();
|
||||
if($r) {
|
||||
foreach($r as $g) {
|
||||
if ($r) {
|
||||
foreach ($r as $g) {
|
||||
$contacts[] = array(
|
||||
"photo" => proxy_url($g['photo'], false, PROXY_SIZE_MICRO),
|
||||
"name" => $g['name'],
|
||||
"nick" => (x($g['addr']) ? $g['addr'] : $g['url']),
|
||||
"network" => $g['network'],
|
||||
"link" => $g['url'],
|
||||
"forum" => (x($g['community']) ? 1 : 0),
|
||||
'photo' => proxy_url($g['photo'], false, PROXY_SIZE_MICRO),
|
||||
'name' => $g['name'],
|
||||
'nick' => (x($g['addr']) ? $g['addr'] : $g['url']),
|
||||
'network' => $g['network'],
|
||||
'link' => $g['url'],
|
||||
'forum' => (x($g['community']) ? 1 : 0),
|
||||
);
|
||||
}
|
||||
}
|
||||
$o = array(
|
||||
'start' => $start,
|
||||
'count' => $count,
|
||||
'items' => $contacts,
|
||||
'count' => $count,
|
||||
'items' => $contacts,
|
||||
);
|
||||
echo json_encode($o);
|
||||
killme();
|
||||
|
@ -578,16 +591,16 @@ function acl_lookup(&$a, $out_type = 'json') {
|
|||
|
||||
|
||||
if (dbm::is_result($r)) {
|
||||
foreach($r as $g){
|
||||
foreach ($r as $g){
|
||||
$contacts[] = array(
|
||||
"type" => "c",
|
||||
"photo" => proxy_url($g['micro'], false, PROXY_SIZE_MICRO),
|
||||
"name" => htmlentities($g['name']),
|
||||
"id" => intval($g['id']),
|
||||
"network" => $g['network'],
|
||||
"link" => $g['url'],
|
||||
"nick" => htmlentities(($g['attag']) ? $g['attag'] : $g['nick']),
|
||||
"forum" => ((x($g['forum']) || x($g['prv'])) ? 1 : 0),
|
||||
'type' => 'c',
|
||||
'photo' => proxy_url($g['micro'], false, PROXY_SIZE_MICRO),
|
||||
'name' => htmlentities($g['name']),
|
||||
'id' => intval($g['id']),
|
||||
'network' => $g['network'],
|
||||
'link' => $g['url'],
|
||||
'nick' => htmlentities(($g['attag']) ? $g['attag'] : $g['nick']),
|
||||
'forum' => ((x($g['forum']) || x($g['prv'])) ? 1 : 0),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -613,7 +626,7 @@ function acl_lookup(&$a, $out_type = 'json') {
|
|||
implode("','", $known_contacts)
|
||||
);
|
||||
if (dbm::is_result($r)){
|
||||
foreach($r as $row) {
|
||||
foreach ($r as $row) {
|
||||
// nickname..
|
||||
$up = parse_url($row['author-link']);
|
||||
$nick = explode("/",$up['path']);
|
||||
|
@ -621,14 +634,14 @@ function acl_lookup(&$a, $out_type = 'json') {
|
|||
$nick .= "@".$up['host'];
|
||||
// /nickname
|
||||
$unknow_contacts[] = array(
|
||||
"type" => "c",
|
||||
"photo" => proxy_url($row['author-avatar'], false, PROXY_SIZE_MICRO),
|
||||
"name" => htmlentities($row['author-name']),
|
||||
"id" => '',
|
||||
"network" => "unknown",
|
||||
"link" => $row['author-link'],
|
||||
"nick" => htmlentities($nick),
|
||||
"forum" => false
|
||||
'type' => 'c',
|
||||
'photo' => proxy_url($row['author-avatar'], false, PROXY_SIZE_MICRO),
|
||||
'name' => htmlentities($row['author-name']),
|
||||
'id' => '',
|
||||
'network' => 'unknown',
|
||||
'link' => $row['author-link'],
|
||||
'nick' => htmlentities($nick),
|
||||
'forum' => false
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -638,34 +651,34 @@ function acl_lookup(&$a, $out_type = 'json') {
|
|||
}
|
||||
|
||||
$results = array(
|
||||
"tot" => $tot,
|
||||
"start" => $start,
|
||||
"count" => $count,
|
||||
"groups" => $groups,
|
||||
"contacts" => $contacts,
|
||||
"items" => $items,
|
||||
"type" => $type,
|
||||
"search" => $search,
|
||||
'tot' => $tot,
|
||||
'start' => $start,
|
||||
'count' => $count,
|
||||
'groups' => $groups,
|
||||
'contacts' => $contacts,
|
||||
'items' => $items,
|
||||
'type' => $type,
|
||||
'search' => $search,
|
||||
);
|
||||
|
||||
call_hooks('acl_lookup_end', $results);
|
||||
|
||||
if($out_type === 'html') {
|
||||
$o = array(
|
||||
'tot' => $results["tot"],
|
||||
'start' => $results["start"],
|
||||
'count' => $results["count"],
|
||||
'groups' => $results["groups"],
|
||||
'contacts' => $results["contacts"],
|
||||
'tot' => $results['tot'],
|
||||
'start' => $results['start'],
|
||||
'count' => $results['count'],
|
||||
'groups' => $results['groups'],
|
||||
'contacts' => $results['contacts'],
|
||||
);
|
||||
return $o;
|
||||
}
|
||||
|
||||
$o = array(
|
||||
'tot' => $results["tot"],
|
||||
'start' => $results["start"],
|
||||
'count' => $results["count"],
|
||||
'items' => $results["items"],
|
||||
'tot' => $results['tot'],
|
||||
'start' => $results['start'],
|
||||
'count' => $results['count'],
|
||||
'items' => $results['items'],
|
||||
);
|
||||
|
||||
echo json_encode($o);
|
||||
|
@ -682,7 +695,7 @@ function navbar_complete(&$a) {
|
|||
|
||||
// logger('navbar_complete');
|
||||
|
||||
if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
|
||||
if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -693,28 +706,32 @@ function navbar_complete(&$a) {
|
|||
$mode = $_REQUEST['smode'];
|
||||
|
||||
// don't search if search term has less than 2 characters
|
||||
if(! $search || mb_strlen($search) < 2)
|
||||
if (! $search || mb_strlen($search) < 2) {
|
||||
return array();
|
||||
}
|
||||
|
||||
if(substr($search,0,1) === '@')
|
||||
if (substr($search,0,1) === '@') {
|
||||
$search = substr($search,1);
|
||||
}
|
||||
|
||||
if($localsearch) {
|
||||
if ($localsearch) {
|
||||
$x = DirSearch::global_search_by_name($search, $mode);
|
||||
return $x;
|
||||
}
|
||||
|
||||
if(! $localsearch) {
|
||||
if (! $localsearch) {
|
||||
$p = (($a->pager['page'] != 1) ? '&p=' . $a->pager['page'] : '');
|
||||
|
||||
$x = z_fetch_url(get_server().'/lsearch?f=' . $p . '&search=' . urlencode($search));
|
||||
if($x['success']) {
|
||||
if ($x['success']) {
|
||||
$t = 0;
|
||||
$j = json_decode($x['body'],true);
|
||||
if($j && $j['results']) {
|
||||
if ($j && $j['results']) {
|
||||
return $j['results'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// @TODO Not needed here?
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -3068,8 +3068,8 @@
|
|||
'image/gif' => 'gif'
|
||||
);
|
||||
$data = array('photo'=>array());
|
||||
if($r) {
|
||||
foreach($r as $rr) {
|
||||
if ($r) {
|
||||
foreach ($r as $rr) {
|
||||
$photo = array();
|
||||
$photo['id'] = $rr['resource-id'];
|
||||
$photo['album'] = $rr['album'];
|
||||
|
|
|
@ -125,8 +125,7 @@ if (isset($_SESSION) && x($_SESSION,'authenticated') && (!x($_POST,'auth-params'
|
|||
$openid = new LightOpenID;
|
||||
$openid->identity = $openid_url;
|
||||
$_SESSION['openid'] = $openid_url;
|
||||
$a = get_app();
|
||||
$openid->returnUrl = $a->get_baseurl(true).'/openid';
|
||||
$openid->returnUrl = App::get_baseurl(true).'/openid';
|
||||
goaway($openid->authUrl());
|
||||
} catch (Exception $e) {
|
||||
notice(t('We encountered a problem while logging in with the OpenID you provided. Please check the correct spelling of the ID.').'<br /><br >'.t('The error message was:').' '.$e->getMessage());
|
||||
|
|
|
@ -144,8 +144,6 @@ function unescape_underscores_in_links($m) {
|
|||
|
||||
function format_event_diaspora($ev) {
|
||||
|
||||
$a = get_app();
|
||||
|
||||
if(! ((is_array($ev)) && count($ev)))
|
||||
return '';
|
||||
|
||||
|
@ -160,7 +158,7 @@ function format_event_diaspora($ev) {
|
|||
$ev['start'] , $bd_format ))
|
||||
: day_translate(datetime_convert('UTC', 'UTC',
|
||||
$ev['start'] , $bd_format)))
|
||||
. '](' . $a->get_baseurl() . '/localtime/?f=&time=' . urlencode(datetime_convert('UTC','UTC',$ev['start'])) . ")\n";
|
||||
. '](' . App::get_baseurl() . '/localtime/?f=&time=' . urlencode(datetime_convert('UTC','UTC',$ev['start'])) . ")\n";
|
||||
|
||||
if(! $ev['nofinish'])
|
||||
$o .= t('Finishes:') . ' ' . '['
|
||||
|
@ -168,7 +166,7 @@ function format_event_diaspora($ev) {
|
|||
$ev['finish'] , $bd_format ))
|
||||
: day_translate(datetime_convert('UTC', 'UTC',
|
||||
$ev['finish'] , $bd_format )))
|
||||
. '](' . $a->get_baseurl() . '/localtime/?f=&time=' . urlencode(datetime_convert('UTC','UTC',$ev['finish'])) . ")\n";
|
||||
. '](' . App::get_baseurl() . '/localtime/?f=&time=' . urlencode(datetime_convert('UTC','UTC',$ev['finish'])) . ")\n";
|
||||
|
||||
if(strlen($ev['location']))
|
||||
$o .= t('Location:') . bb2diaspora($ev['location'])
|
||||
|
|
|
@ -343,7 +343,7 @@ function bb_replace_images($body, $images) {
|
|||
$newbody = $body;
|
||||
|
||||
$cnt = 0;
|
||||
foreach($images as $image) {
|
||||
foreach ($images as $image) {
|
||||
// We're depending on the property of 'foreach' (specified on the PHP website) that
|
||||
// it loops over the array starting from the first element and going sequentially
|
||||
// to the last element
|
||||
|
@ -613,9 +613,7 @@ function GetProfileUsername($profile, $username, $compact = false, $getnetwork =
|
|||
}
|
||||
|
||||
function bb_DiasporaLinks($match) {
|
||||
$a = get_app();
|
||||
|
||||
return "[url=".$a->get_baseurl()."/display/".$match[1]."]".$match[2]."[/url]";
|
||||
return "[url=".App::get_baseurl()."/display/".$match[1]."]".$match[2]."[/url]";
|
||||
}
|
||||
|
||||
function bb_RemovePictureLinks($match) {
|
||||
|
@ -894,7 +892,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
|
|||
// we may need to restrict this further if it picks up too many strays
|
||||
// link acct:user@host to a webfinger profile redirector
|
||||
|
||||
$Text = preg_replace('/acct:([^@]+)@((?!\-)(?:[a-zA-Z\d\-]{0,62}[a-zA-Z\d]\.){1,126}(?!\d+)[a-zA-Z\d]{1,63})/', '<a href="' . $a->get_baseurl() . '/acctlink?addr=$1@$2" target="extlink">acct:$1@$2</a>',$Text);
|
||||
$Text = preg_replace('/acct:([^@]+)@((?!\-)(?:[a-zA-Z\d\-]{0,62}[a-zA-Z\d]\.){1,126}(?!\d+)[a-zA-Z\d]{1,63})/', '<a href="' . App::get_baseurl() . '/acctlink?addr=$1@$2" target="extlink">acct:$1@$2</a>',$Text);
|
||||
|
||||
// Perform MAIL Search
|
||||
$Text = preg_replace("/\[mail\]([$MAILSearchString]*)\[\/mail\]/", '<a href="mailto:$1">$1</a>', $Text);
|
||||
|
@ -1063,9 +1061,9 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
|
|||
return(bb_ShareAttributes($match, $simplehtml));
|
||||
},$Text);
|
||||
|
||||
$Text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism",'<br/><img src="' .$a->get_baseurl() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . t('Encrypted content') . '" /><br />', $Text);
|
||||
$Text = preg_replace("/\[crypt(.*?)\](.*?)\[\/crypt\]/ism",'<br/><img src="' .$a->get_baseurl() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . '$1' . ' ' . t('Encrypted content') . '" /><br />', $Text);
|
||||
//$Text = preg_replace("/\[crypt=(.*?)\](.*?)\[\/crypt\]/ism",'<br/><img src="' .$a->get_baseurl() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . '$1' . ' ' . t('Encrypted content') . '" /><br />', $Text);
|
||||
$Text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism",'<br/><img src="' .App::get_baseurl() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . t('Encrypted content') . '" /><br />', $Text);
|
||||
$Text = preg_replace("/\[crypt(.*?)\](.*?)\[\/crypt\]/ism",'<br/><img src="' .App::get_baseurl() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . '$1' . ' ' . t('Encrypted content') . '" /><br />', $Text);
|
||||
//$Text = preg_replace("/\[crypt=(.*?)\](.*?)\[\/crypt\]/ism",'<br/><img src="' .App::get_baseurl() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . '$1' . ' ' . t('Encrypted content') . '" /><br />', $Text);
|
||||
|
||||
|
||||
// Try to Oembed
|
||||
|
|
|
@ -13,7 +13,7 @@ function contact_profile_assign($current,$foreign_net) {
|
|||
intval($_SESSION['uid']));
|
||||
|
||||
if (dbm::is_result($r)) {
|
||||
foreach($r as $rr) {
|
||||
foreach ($r as $rr) {
|
||||
$selected = (($rr['id'] == $current) ? " selected=\"selected\" " : "");
|
||||
$o .= "<option value=\"{$rr['id']}\" $selected >{$rr['profile-name']}</option>\r\n";
|
||||
}
|
||||
|
|
|
@ -80,11 +80,13 @@ function networks_widget($baseurl,$selected = '') {
|
|||
|
||||
$a = get_app();
|
||||
|
||||
if(!local_user())
|
||||
if (!local_user()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if(!feature_enabled(local_user(),'networks'))
|
||||
if (!feature_enabled(local_user(),'networks')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$extra_sql = unavailable_networks();
|
||||
|
||||
|
@ -95,9 +97,11 @@ function networks_widget($baseurl,$selected = '') {
|
|||
$nets = array();
|
||||
if (dbm::is_result($r)) {
|
||||
require_once('include/contact_selectors.php');
|
||||
foreach($r as $rr) {
|
||||
if($rr['network'])
|
||||
$nets[] = array('ref' => $rr['network'], 'name' => network_to_name($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' ));
|
||||
foreach ($r as $rr) {
|
||||
/// @TODO If 'network' is not there, this triggers an E_NOTICE
|
||||
if ($rr['network']) {
|
||||
$nets[] = array('ref' => $rr['network'], 'name' => network_to_name($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' ));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,16 +120,18 @@ function networks_widget($baseurl,$selected = '') {
|
|||
}
|
||||
|
||||
function fileas_widget($baseurl,$selected = '') {
|
||||
$a = get_app();
|
||||
if(! local_user())
|
||||
if (! local_user()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if(! feature_enabled(local_user(),'filing'))
|
||||
if (! feature_enabled(local_user(),'filing')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$saved = get_pconfig(local_user(),'system','filetags');
|
||||
if(! strlen($saved))
|
||||
if (! strlen($saved)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$matches = false;
|
||||
$terms = array();
|
||||
|
@ -235,7 +241,7 @@ function common_friends_visitor_widget($profile_uid) {
|
|||
|
||||
return replace_macros(get_markup_template('remote_friends_common.tpl'), array(
|
||||
'$desc' => sprintf( tt("%d contact in common", "%d contacts in common", $t), $t),
|
||||
'$base' => $a->get_baseurl(),
|
||||
'$base' => App::get_baseurl(),
|
||||
'$uid' => $profile_uid,
|
||||
'$cid' => (($cid) ? $cid : '0'),
|
||||
'$linkmore' => (($t > 5) ? 'true' : ''),
|
||||
|
|
|
@ -78,7 +78,7 @@ function item_redir_and_replace_images($body, $images, $cid) {
|
|||
$newbody .= $origbody;
|
||||
|
||||
$cnt = 0;
|
||||
foreach($images as $image) {
|
||||
foreach ($images as $image) {
|
||||
// We're depending on the property of 'foreach' (specified on the PHP website) that
|
||||
// it loops over the array starting from the first element and going sequentially
|
||||
// to the last element
|
||||
|
@ -324,11 +324,13 @@ function localize_item(&$item){
|
|||
// add sparkle links to appropriate permalinks
|
||||
|
||||
$x = stristr($item['plink'],'/display/');
|
||||
if($x) {
|
||||
if ($x) {
|
||||
$sparkle = false;
|
||||
$y = best_link_url($item,$sparkle,true);
|
||||
if(strstr($y,'/redir/'))
|
||||
|
||||
if (strstr($y,'/redir/')) {
|
||||
$item['plink'] = $y . '?f=&url=' . $item['plink'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -864,7 +866,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
|
|||
}
|
||||
|
||||
$o = replace_macros($page_template, array(
|
||||
'$baseurl' => $a->get_baseurl($ssl_state),
|
||||
'$baseurl' => App::get_baseurl($ssl_state),
|
||||
'$return_path' => $a->query_string,
|
||||
'$live_update' => $live_update_div,
|
||||
'$remove' => t('remove'),
|
||||
|
@ -1183,7 +1185,7 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
|
|||
$tpl = get_markup_template('jot-header.tpl');
|
||||
$a->page['htmlhead'] .= replace_macros($tpl, array(
|
||||
'$newpost' => 'true',
|
||||
'$baseurl' => $a->get_baseurl(true),
|
||||
'$baseurl' => App::get_baseurl(true),
|
||||
'$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
|
||||
'$geotag' => $geotag,
|
||||
'$nickname' => $x['nickname'],
|
||||
|
@ -1201,7 +1203,7 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
|
|||
$tpl = get_markup_template('jot-end.tpl');
|
||||
$a->page['end'] .= replace_macros($tpl, array(
|
||||
'$newpost' => 'true',
|
||||
'$baseurl' => $a->get_baseurl(true),
|
||||
'$baseurl' => App::get_baseurl(true),
|
||||
'$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
|
||||
'$geotag' => $geotag,
|
||||
'$nickname' => $x['nickname'],
|
||||
|
@ -1267,7 +1269,7 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
|
|||
'$ptyp' => (($notes_cid) ? 'note' : 'wall'),
|
||||
'$content' => $x['content'],
|
||||
'$post_id' => $x['post_id'],
|
||||
'$baseurl' => $a->get_baseurl(true),
|
||||
'$baseurl' => App::get_baseurl(true),
|
||||
'$defloc' => $x['default_location'],
|
||||
'$visitor' => $x['visitor'],
|
||||
'$pvisit' => (($notes_cid) ? 'none' : $x['visitor']),
|
||||
|
|
|
@ -553,7 +553,7 @@ function update_contact_birthdays() {
|
|||
|
||||
$r = q("SELECT * FROM contact WHERE `bd` != '' AND `bd` != '0000-00-00' AND SUBSTRING(`bd`,1,4) != `bdyear` ");
|
||||
if (dbm::is_result($r)) {
|
||||
foreach($r as $rr) {
|
||||
foreach ($r as $rr) {
|
||||
|
||||
logger('update_contact_birthday: ' . $rr['bd']);
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@ function update_fail($update_id, $error_message){
|
|||
}
|
||||
|
||||
// every admin could had different language
|
||||
|
||||
foreach ($adminlist as $admin) {
|
||||
$lang = (($admin['language'])?$admin['language']:'en');
|
||||
push_lang($lang);
|
||||
|
@ -56,11 +55,11 @@ function update_fail($update_id, $error_message){
|
|||
$email_tpl = get_intltext_template("update_fail_eml.tpl");
|
||||
$email_msg = replace_macros($email_tpl, array(
|
||||
'$sitename' => $a->config['sitename'],
|
||||
'$siteurl' => $a->get_baseurl(),
|
||||
'$siteurl' => App::get_baseurl(),
|
||||
'$update' => DB_UPDATE_VERSION,
|
||||
'$error' => sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION)
|
||||
));
|
||||
$subject=sprintf(t('Update Error at %s'), $a->get_baseurl());
|
||||
$subject=sprintf(t('Update Error at %s'), App::get_baseurl());
|
||||
require_once('include/email.php');
|
||||
$subject = email_header_encode($subject,'UTF-8');
|
||||
mail($a->config['admin_email'], $subject, $email_msg,
|
||||
|
@ -83,8 +82,9 @@ function table_structure($table) {
|
|||
|
||||
if (dbm::is_result($indexes))
|
||||
foreach ($indexes AS $index) {
|
||||
if ($index["Index_type"] == "FULLTEXT")
|
||||
if ($index["Index_type"] == "FULLTEXT") {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) {
|
||||
$indexdata[$index["Key_name"]] = array('UNIQUE');
|
||||
|
@ -95,26 +95,31 @@ function table_structure($table) {
|
|||
// To avoid the need to add this to every index definition we just ignore it here.
|
||||
// Exception are primary indexes
|
||||
// Since there are some combindex primary indexes we use the limit of 180 here.
|
||||
if (($index["Sub_part"] != "") AND (($index["Sub_part"] < 180) OR ($index["Key_name"] == "PRIMARY")))
|
||||
if (($index["Sub_part"] != "") AND (($index["Sub_part"] < 180) OR ($index["Key_name"] == "PRIMARY"))) {
|
||||
$column .= "(".$index["Sub_part"].")";
|
||||
}
|
||||
|
||||
$indexdata[$index["Key_name"]][] = $column;
|
||||
}
|
||||
|
||||
if (dbm::is_result($structures)) {
|
||||
foreach($structures AS $field) {
|
||||
foreach ($structures AS $field) {
|
||||
$fielddata[$field["Field"]]["type"] = $field["Type"];
|
||||
if ($field["Null"] == "NO")
|
||||
if ($field["Null"] == "NO") {
|
||||
$fielddata[$field["Field"]]["not null"] = true;
|
||||
}
|
||||
|
||||
if (isset($field["Default"]))
|
||||
if (isset($field["Default"])) {
|
||||
$fielddata[$field["Field"]]["default"] = $field["Default"];
|
||||
}
|
||||
|
||||
if ($field["Extra"] != "")
|
||||
if ($field["Extra"] != "") {
|
||||
$fielddata[$field["Field"]]["extra"] = $field["Extra"];
|
||||
}
|
||||
|
||||
if ($field["Key"] == "PRI")
|
||||
if ($field["Key"] == "PRI") {
|
||||
$fielddata[$field["Field"]]["primary"] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return(array("fields"=>$fielddata, "indexes"=>$indexdata));
|
||||
|
@ -138,13 +143,15 @@ function print_structure($database, $charset) {
|
|||
function update_structure($verbose, $action, $tables=null, $definition=null) {
|
||||
global $a, $db;
|
||||
|
||||
if ($action)
|
||||
if ($action) {
|
||||
set_config('system', 'maintenance', 1);
|
||||
}
|
||||
|
||||
if (isset($a->config["system"]["db_charset"]))
|
||||
if (isset($a->config["system"]["db_charset"])) {
|
||||
$charset = $a->config["system"]["db_charset"];
|
||||
else
|
||||
} else {
|
||||
$charset = "utf8";
|
||||
}
|
||||
|
||||
$errors = false;
|
||||
|
||||
|
@ -153,8 +160,9 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
|
|||
// Get the current structure
|
||||
$database = array();
|
||||
|
||||
if (is_null($tables))
|
||||
$tables = q("show tables");
|
||||
if (is_null($tables)) {
|
||||
$tables = q("SHOW TABLES");
|
||||
}
|
||||
|
||||
foreach ($tables AS $table) {
|
||||
$table = current($table);
|
||||
|
@ -164,21 +172,24 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
|
|||
}
|
||||
|
||||
// Get the definition
|
||||
if (is_null($definition))
|
||||
if (is_null($definition)) {
|
||||
$definition = db_definition($charset);
|
||||
}
|
||||
|
||||
// Ensure index conversion to unique removes duplicates
|
||||
$sql_config = "SET session old_alter_table=1;";
|
||||
if ($verbose)
|
||||
if ($verbose) {
|
||||
echo $sql_config."\n";
|
||||
if ($action)
|
||||
@$db->q($sql_config);
|
||||
}
|
||||
if ($action) {
|
||||
$db->q($sql_config);
|
||||
}
|
||||
|
||||
// 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)) {
|
||||
$ignore = '';
|
||||
}else {
|
||||
} else {
|
||||
$ignore = ' IGNORE';
|
||||
}
|
||||
|
||||
|
@ -193,10 +204,12 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
|
|||
}
|
||||
$is_new_table = True;
|
||||
} else {
|
||||
// Drop the index if it isn't present in the definition
|
||||
// or the definition differ from current status
|
||||
// and index name doesn't start with "local_"
|
||||
foreach ($database[$name]["indexes"] AS $indexname => $fieldnames) {
|
||||
/*
|
||||
* Drop the index if it isn't present in the definition
|
||||
* or the definition differ from current status
|
||||
* and index name doesn't start with "local_"
|
||||
*/
|
||||
foreach ($database[$name]["indexes"] as $indexname => $fieldnames) {
|
||||
$current_index_definition = implode(",",$fieldnames);
|
||||
if (isset($structure["indexes"][$indexname])) {
|
||||
$new_index_definition = implode(",",$structure["indexes"][$indexname]);
|
||||
|
@ -205,39 +218,44 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
|
|||
}
|
||||
if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
|
||||
$sql2=db_drop_index($indexname);
|
||||
if ($sql3 == "")
|
||||
if ($sql3 == "") {
|
||||
$sql3 = "ALTER".$ignore." TABLE `".$name."` ".$sql2;
|
||||
else
|
||||
} else {
|
||||
$sql3 .= ", ".$sql2;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Compare the field structure field by field
|
||||
foreach ($structure["fields"] AS $fieldname => $parameters) {
|
||||
if (!isset($database[$name]["fields"][$fieldname])) {
|
||||
$sql2=db_add_table_field($fieldname, $parameters);
|
||||
if ($sql3 == "")
|
||||
if ($sql3 == "") {
|
||||
$sql3 = "ALTER TABLE `".$name."` ".$sql2;
|
||||
else
|
||||
} else {
|
||||
$sql3 .= ", ".$sql2;
|
||||
}
|
||||
} else {
|
||||
// Compare the field definition
|
||||
$current_field_definition = implode(",",$database[$name]["fields"][$fieldname]);
|
||||
$new_field_definition = implode(",",$parameters);
|
||||
if ($current_field_definition != $new_field_definition) {
|
||||
$sql2=db_modify_table_field($fieldname, $parameters);
|
||||
if ($sql3 == "")
|
||||
if ($sql3 == "") {
|
||||
$sql3 = "ALTER TABLE `".$name."` ".$sql2;
|
||||
else
|
||||
} else {
|
||||
$sql3 .= ", ".$sql2;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create the index if the index don't exists in database
|
||||
// or the definition differ from the current status.
|
||||
// Don't create keys if table is new
|
||||
/*
|
||||
* Create the index if the index don't exists in database
|
||||
* or the definition differ from the current status.
|
||||
* Don't create keys if table is new
|
||||
*/
|
||||
if (!$is_new_table) {
|
||||
foreach ($structure["indexes"] AS $indexname => $fieldnames) {
|
||||
if (isset($database[$name]["indexes"][$indexname])) {
|
||||
|
@ -367,10 +385,11 @@ function db_create_index($indexname, $fieldnames, $method="ADD") {
|
|||
if ($names != "")
|
||||
$names .= ",";
|
||||
|
||||
if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches))
|
||||
if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
|
||||
$names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
|
||||
else
|
||||
} else {
|
||||
$names .= "`".dbesc($fieldname)."`";
|
||||
}
|
||||
}
|
||||
|
||||
if ($indexname == "PRIMARY") {
|
||||
|
@ -383,8 +402,9 @@ function db_create_index($indexname, $fieldnames, $method="ADD") {
|
|||
}
|
||||
|
||||
function db_index_suffix($charset, $reduce = 0) {
|
||||
if ($charset != "utf8mb4")
|
||||
if ($charset != "utf8mb4") {
|
||||
return "";
|
||||
}
|
||||
|
||||
// On utf8mb4 indexes can only have a length of 191
|
||||
$indexlength = 191 - $reduce;
|
||||
|
@ -1573,9 +1593,6 @@ function dbstructure_run(&$argv, &$argc) {
|
|||
echo "dumpsql dump database schema\n";
|
||||
return;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (array_search(__file__,get_included_files())===0){
|
||||
|
|
|
@ -323,7 +323,7 @@ function delivery_run(&$argv, &$argc){
|
|||
|
||||
// perform local delivery if we are on the same site
|
||||
|
||||
if (link_compare($basepath,$a->get_baseurl())) {
|
||||
if (link_compare($basepath,App::get_baseurl())) {
|
||||
|
||||
$nickname = basename($contact['url']);
|
||||
if ($contact['issued-id'])
|
||||
|
|
|
@ -105,8 +105,9 @@ class dfrn {
|
|||
dbesc($owner_nick)
|
||||
);
|
||||
|
||||
if(! dbm::is_result($r))
|
||||
if (! dbm::is_result($r)) {
|
||||
killme();
|
||||
}
|
||||
|
||||
$owner = $r[0];
|
||||
$owner_id = $owner['uid'];
|
||||
|
@ -139,8 +140,9 @@ class dfrn {
|
|||
intval($owner_id)
|
||||
);
|
||||
|
||||
if(! dbm::is_result($r))
|
||||
if (! dbm::is_result($r)) {
|
||||
killme();
|
||||
}
|
||||
|
||||
$contact = $r[0];
|
||||
require_once('include/security.php');
|
||||
|
|
|
@ -319,8 +319,8 @@ class Diaspora {
|
|||
dbesc(NETWORK_DIASPORA),
|
||||
dbesc($msg["author"])
|
||||
);
|
||||
if($r) {
|
||||
foreach($r as $rr) {
|
||||
if ($r) {
|
||||
foreach ($r as $rr) {
|
||||
logger("delivering to: ".$rr["username"]);
|
||||
self::dispatch($rr,$msg);
|
||||
}
|
||||
|
@ -832,7 +832,7 @@ class Diaspora {
|
|||
dbesc($guid)
|
||||
);
|
||||
|
||||
if($r) {
|
||||
if ($r) {
|
||||
logger("message ".$guid." already exists for user ".$uid);
|
||||
return $r[0]["id"];
|
||||
}
|
||||
|
@ -1906,20 +1906,23 @@ class Diaspora {
|
|||
$author = unxmlify($data->author);
|
||||
$recipient = unxmlify($data->recipient);
|
||||
|
||||
if (!$author || !$recipient)
|
||||
if (!$author || !$recipient) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// the current protocol version doesn't know these fields
|
||||
// That means that we will assume their existance
|
||||
if (isset($data->following))
|
||||
if (isset($data->following)) {
|
||||
$following = (unxmlify($data->following) == "true");
|
||||
else
|
||||
} else {
|
||||
$following = true;
|
||||
}
|
||||
|
||||
if (isset($data->sharing))
|
||||
if (isset($data->sharing)) {
|
||||
$sharing = (unxmlify($data->sharing) == "true");
|
||||
else
|
||||
} else {
|
||||
$sharing = true;
|
||||
}
|
||||
|
||||
$contact = self::contact_by_handle($importer["uid"],$author);
|
||||
|
||||
|
@ -1937,7 +1940,7 @@ class Diaspora {
|
|||
// Normally we needn't to do so, but the first message could have been vanished.
|
||||
if (in_array($contact["rel"], array(CONTACT_IS_FRIEND, CONTACT_IS_FOLLOWER))) {
|
||||
$u = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval($importer["uid"]));
|
||||
if($u) {
|
||||
if ($u) {
|
||||
logger("Sending share message to author ".$author." - Contact: ".$contact["id"]." - User: ".$importer["uid"], LOGGER_DEBUG);
|
||||
$ret = self::send_share($u[0], $contact);
|
||||
}
|
||||
|
@ -2160,16 +2163,19 @@ class Diaspora {
|
|||
$created_at = datetime_convert("UTC", "UTC", notags(unxmlify($data->created_at)));
|
||||
|
||||
$contact = self::allowed_contact_by_handle($importer, $author, false);
|
||||
if (!$contact)
|
||||
if (!$contact) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$message_id = self::message_exists($importer["uid"], $guid);
|
||||
if ($message_id)
|
||||
if ($message_id) {
|
||||
return $message_id;
|
||||
}
|
||||
|
||||
$original_item = self::original_item($root_guid, $root_author, $author);
|
||||
if (!$original_item)
|
||||
if (!$original_item) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$orig_url = App::get_baseurl()."/display/".$original_item["guid"];
|
||||
|
||||
|
@ -2211,8 +2217,9 @@ class Diaspora {
|
|||
self::fetch_guid($datarray);
|
||||
$message_id = item_store($datarray);
|
||||
|
||||
if ($message_id)
|
||||
if ($message_id) {
|
||||
logger("Stored reshare ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG);
|
||||
|