Merge remote-tracking branch 'upstream/develop' into 1612-unused-indexes

This commit is contained in:
Michael 2017-01-04 13:57:27 +00:00
commit 6b6e3e264f
227 changed files with 10841 additions and 9039 deletions

View file

@ -38,7 +38,7 @@ define ( 'FRIENDICA_PLATFORM', 'Friendica');
define ( 'FRIENDICA_CODENAME', 'Asparagus'); define ( 'FRIENDICA_CODENAME', 'Asparagus');
define ( 'FRIENDICA_VERSION', '3.5.1-dev' ); define ( 'FRIENDICA_VERSION', '3.5.1-dev' );
define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
define ( 'DB_UPDATE_VERSION', 1209 ); define ( 'DB_UPDATE_VERSION', 1211 );
/** /**
* @brief Constant with a HTML line break. * @brief Constant with a HTML line break.
@ -670,22 +670,23 @@ class App {
#set_include_path("include/$this->hostname" . PATH_SEPARATOR . get_include_path()); #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); $this->query_string = substr($_SERVER['QUERY_STRING'],9);
// removing trailing / - maybe a nginx problem // removing trailing / - maybe a nginx problem
if (substr($this->query_string, 0, 1) == "/") if (substr($this->query_string, 0, 1) == "/")
$this->query_string = substr($this->query_string, 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); $this->query_string = substr($_SERVER['QUERY_STRING'],2);
// removing trailing / - maybe a nginx problem // removing trailing / - maybe a nginx problem
if (substr($this->query_string, 0, 1) == "/") if (substr($this->query_string, 0, 1) == "/")
$this->query_string = substr($this->query_string, 1); $this->query_string = substr($this->query_string, 1);
} }
if (x($_GET,'pagename')) if (x($_GET,'pagename')) {
$this->cmd = trim($_GET['pagename'],'/\\'); $this->cmd = trim($_GET['pagename'],'/\\');
elseif (x($_GET,'q')) } elseif (x($_GET,'q')) {
$this->cmd = trim($_GET['q'],'/\\'); $this->cmd = trim($_GET['q'],'/\\');
}
// fix query_string // fix query_string
@ -694,13 +695,15 @@ class App {
// unix style "homedir" // unix style "homedir"
if(substr($this->cmd,0,1) === '~') if (substr($this->cmd,0,1) === '~') {
$this->cmd = 'profile/' . substr($this->cmd,1); $this->cmd = 'profile/' . substr($this->cmd,1);
}
// Diaspora style profile url // 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); $this->cmd = 'profile/' . substr($this->cmd,2);
}
/* /*
@ -806,7 +809,7 @@ class App {
function get_baseurl($ssl = false) { function get_baseurl($ssl = false) {
// Is the function called statically? // Is the function called statically?
if (!is_object($this)) { if (!(isset($this) && get_class($this) == __CLASS__)) {
return self::$a->get_baseurl($ssl); return self::$a->get_baseurl($ssl);
} }
@ -1028,7 +1031,7 @@ class App {
} else { } else {
$r = q("SELECT `contact`.`avatar-date` AS picdate FROM `contact` WHERE `contact`.`thumb` like '%%/%s'", $r = q("SELECT `contact`.`avatar-date` AS picdate FROM `contact` WHERE `contact`.`thumb` like '%%/%s'",
$common_filename); $common_filename);
if(! dbm::is_result($r)){ if (! dbm::is_result($r)) {
$this->cached_profile_image[$avatar_image] = $avatar_image; $this->cached_profile_image[$avatar_image] = $avatar_image;
} else { } else {
$this->cached_profile_picdate[$common_filename] = "?rev=".urlencode($r[0]['picdate']); $this->cached_profile_picdate[$common_filename] = "?rev=".urlencode($r[0]['picdate']);
@ -1050,7 +1053,7 @@ class App {
function remove_baseurl($orig_url){ function remove_baseurl($orig_url){
// Is the function called statically? // Is the function called statically?
if (!is_object($this)) { if (!(isset($this) && get_class($this) == __CLASS__)) {
return(self::$a->remove_baseurl($orig_url)); return(self::$a->remove_baseurl($orig_url));
} }
@ -1548,9 +1551,9 @@ function check_url(&$a) {
// We will only change the url to an ip address if there is no existing setting // We will only change the url to an ip address if there is no existing setting
if(! x($url)) if(! x($url))
$url = set_config('system','url',$a->get_baseurl()); $url = set_config('system','url',App::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))) 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',$a->get_baseurl()); $url = set_config('system','url',App::get_baseurl());
return; return;
} }

View file

@ -1,6 +1,6 @@
-- ------------------------------------------ -- ------------------------------------------
-- Friendica 3.5.1-dev (Asparagus) -- Friendica 3.5.1-dev (Asparagus)
-- DB_UPDATE_VERSION 1208 -- DB_UPDATE_VERSION 1211
-- ------------------------------------------ -- ------------------------------------------
@ -54,11 +54,11 @@ CREATE TABLE IF NOT EXISTS `auth_codes` (
-- TABLE cache -- TABLE cache
-- --
CREATE TABLE IF NOT EXISTS `cache` ( CREATE TABLE IF NOT EXISTS `cache` (
`k` varchar(255) NOT NULL, `k` varbinary(255) NOT NULL,
`v` text, `v` text,
`expire_mode` int(11) NOT NULL DEFAULT 0, `expire_mode` int(11) NOT NULL DEFAULT 0,
`updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY(`k`(191)), PRIMARY KEY(`k`),
INDEX `updated` (`updated`), INDEX `updated` (`updated`),
INDEX `expire_mode_updated` (`expire_mode`,`updated`) INDEX `expire_mode_updated` (`expire_mode`,`updated`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT CHARSET=utf8mb4;
@ -94,11 +94,11 @@ CREATE TABLE IF NOT EXISTS `clients` (
-- --
CREATE TABLE IF NOT EXISTS `config` ( CREATE TABLE IF NOT EXISTS `config` (
`id` int(10) unsigned NOT NULL auto_increment, `id` int(10) unsigned NOT NULL auto_increment,
`cat` varchar(255) NOT NULL DEFAULT '', `cat` varbinary(255) NOT NULL DEFAULT '',
`k` varchar(255) NOT NULL DEFAULT '', `k` varbinary(255) NOT NULL DEFAULT '',
`v` text, `v` text,
PRIMARY KEY(`id`), PRIMARY KEY(`id`),
UNIQUE INDEX `cat_k` (`cat`(30),`k`(30)) UNIQUE INDEX `cat_k` (`cat`,`k`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT CHARSET=utf8mb4;
-- --
@ -200,7 +200,7 @@ CREATE TABLE IF NOT EXISTS `conv` (
-- --
CREATE TABLE IF NOT EXISTS `deliverq` ( CREATE TABLE IF NOT EXISTS `deliverq` (
`id` int(10) unsigned NOT NULL auto_increment, `id` int(10) unsigned NOT NULL auto_increment,
`cmd` varchar(32) NOT NULL DEFAULT '', `cmd` varbinary(32) NOT NULL DEFAULT '',
`item` int(11) NOT NULL DEFAULT 0, `item` int(11) NOT NULL DEFAULT 0,
`contact` int(11) NOT NULL DEFAULT 0, `contact` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY(`id`), PRIMARY KEY(`id`),
@ -212,6 +212,7 @@ CREATE TABLE IF NOT EXISTS `deliverq` (
-- --
CREATE TABLE IF NOT EXISTS `event` ( CREATE TABLE IF NOT EXISTS `event` (
`id` int(11) NOT NULL auto_increment, `id` int(11) NOT NULL auto_increment,
`guid` varchar(255) NOT NULL DEFAULT '',
`uid` int(11) NOT NULL DEFAULT 0, `uid` int(11) NOT NULL DEFAULT 0,
`cid` int(11) NOT NULL DEFAULT 0, `cid` int(11) NOT NULL DEFAULT 0,
`uri` varchar(255) NOT NULL DEFAULT '', `uri` varchar(255) NOT NULL DEFAULT '',
@ -682,10 +683,10 @@ CREATE TABLE IF NOT EXISTS `notify-threads` (
-- TABLE oembed -- TABLE oembed
-- --
CREATE TABLE IF NOT EXISTS `oembed` ( CREATE TABLE IF NOT EXISTS `oembed` (
`url` varchar(255) NOT NULL, `url` varbinary(255) NOT NULL,
`content` text, `content` text,
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY(`url`(191)), PRIMARY KEY(`url`),
INDEX `created` (`created`) INDEX `created` (`created`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT CHARSET=utf8mb4;
@ -693,12 +694,12 @@ CREATE TABLE IF NOT EXISTS `oembed` (
-- TABLE parsed_url -- TABLE parsed_url
-- --
CREATE TABLE IF NOT EXISTS `parsed_url` ( CREATE TABLE IF NOT EXISTS `parsed_url` (
`url` varchar(255) NOT NULL, `url` varbinary(255) NOT NULL,
`guessing` tinyint(1) NOT NULL DEFAULT 0, `guessing` tinyint(1) NOT NULL DEFAULT 0,
`oembed` tinyint(1) NOT NULL DEFAULT 0, `oembed` tinyint(1) NOT NULL DEFAULT 0,
`content` text, `content` text,
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY(`url`(191),`guessing`,`oembed`), PRIMARY KEY(`url`,`guessing`,`oembed`),
INDEX `created` (`created`) INDEX `created` (`created`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT CHARSET=utf8mb4;
@ -708,11 +709,11 @@ CREATE TABLE IF NOT EXISTS `parsed_url` (
CREATE TABLE IF NOT EXISTS `pconfig` ( CREATE TABLE IF NOT EXISTS `pconfig` (
`id` int(11) NOT NULL auto_increment, `id` int(11) NOT NULL auto_increment,
`uid` int(11) NOT NULL DEFAULT 0, `uid` int(11) NOT NULL DEFAULT 0,
`cat` varchar(255) NOT NULL DEFAULT '', `cat` varbinary(255) NOT NULL DEFAULT '',
`k` varchar(255) NOT NULL DEFAULT '', `k` varbinary(255) NOT NULL DEFAULT '',
`v` mediumtext, `v` mediumtext,
PRIMARY KEY(`id`), PRIMARY KEY(`id`),
UNIQUE INDEX `uid_cat_k` (`uid`,`cat`(30),`k`(30)) UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT CHARSET=utf8mb4;
-- --
@ -786,7 +787,7 @@ CREATE TABLE IF NOT EXISTS `poll_result` (
-- --
CREATE TABLE IF NOT EXISTS `process` ( CREATE TABLE IF NOT EXISTS `process` (
`pid` int(10) unsigned NOT NULL, `pid` int(10) unsigned NOT NULL,
`command` varchar(32) NOT NULL DEFAULT '', `command` varbinary(32) NOT NULL DEFAULT '',
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY(`pid`), PRIMARY KEY(`pid`),
INDEX `command` (`command`) INDEX `command` (`command`)
@ -920,7 +921,7 @@ CREATE TABLE IF NOT EXISTS `search` (
-- --
CREATE TABLE IF NOT EXISTS `session` ( CREATE TABLE IF NOT EXISTS `session` (
`id` bigint(20) unsigned NOT NULL auto_increment, `id` bigint(20) unsigned NOT NULL auto_increment,
`sid` varchar(255) NOT NULL DEFAULT '', `sid` varbinary(255) NOT NULL DEFAULT '',
`data` text, `data` text,
`expire` int(10) unsigned NOT NULL DEFAULT 0, `expire` int(10) unsigned NOT NULL DEFAULT 0,
PRIMARY KEY(`id`), PRIMARY KEY(`id`),

View file

@ -124,8 +124,9 @@ The selected 1st part will be saved in the database by the theme_post function.
function theme_post(&$a){ function theme_post(&$a){
// non local users shall not pass // non local users shall not pass
if(! local_user()) if (! local_user()) {
return; return;
}
// if the one specific submit button was pressed then proceed // if the one specific submit button was pressed then proceed
if (isset($_POST['duepuntozero-settings-submit'])){ if (isset($_POST['duepuntozero-settings-submit'])){
// and save the selection key into the personal config of the user // and save the selection key into the personal config of the user

View file

@ -8,7 +8,6 @@
function user_remove($uid) { function user_remove($uid) {
if(! $uid) if(! $uid)
return; return;
$a = get_app();
logger('Removing user: ' . $uid); logger('Removing user: ' . $uid);
$r = q("select * from user where uid = %d limit 1", intval($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()) { if($uid == local_user()) {
unset($_SESSION['authenticated']); unset($_SESSION['authenticated']);
unset($_SESSION['uid']); 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) { function terminate_friendship($user,$self,$contact) {
/// @TODO Get rid of this, include/datetime.php should care about by itself
$a = get_app(); $a = get_app();
require_once('include/datetime.php'); require_once('include/datetime.php');
if($contact['network'] === NETWORK_OSTATUS) { if ($contact['network'] === NETWORK_OSTATUS) {
require_once('include/ostatus.php'); require_once('include/ostatus.php');
@ -101,16 +100,14 @@ function terminate_friendship($user,$self,$contact) {
$item['follow'] = $contact["url"]; $item['follow'] = $contact["url"];
$slap = ostatus::salmon($item, $user); $slap = ostatus::salmon($item, $user);
if((x($contact,'notify')) && (strlen($contact['notify']))) { if ((x($contact,'notify')) && (strlen($contact['notify']))) {
require_once('include/salmon.php'); require_once('include/salmon.php');
slapper($user,$contact['notify'],$slap); slapper($user,$contact['notify'],$slap);
} }
} } elseif ($contact['network'] === NETWORK_DIASPORA) {
elseif($contact['network'] === NETWORK_DIASPORA) {
require_once('include/diaspora.php'); require_once('include/diaspora.php');
diaspora::send_unshare($user,$contact); Diaspora::send_unshare($user,$contact);
} } elseif ($contact['network'] === NETWORK_DFRN) {
elseif($contact['network'] === NETWORK_DFRN) {
require_once('include/dfrn.php'); require_once('include/dfrn.php');
dfrn::deliver($user,$contact,'placeholder', 1); dfrn::deliver($user,$contact,'placeholder', 1);
} }
@ -361,7 +358,7 @@ function contact_photo_menu($contact, $uid = 0)
$sparkle = false; $sparkle = false;
if ($contact['network'] === NETWORK_DFRN) { if ($contact['network'] === NETWORK_DFRN) {
$sparkle = true; $sparkle = true;
$profile_link = $a->get_baseurl() . '/redir/' . $contact['id']; $profile_link = App::get_baseurl() . '/redir/' . $contact['id'];
} else { } else {
$profile_link = $contact['url']; $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))) { 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) { 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'; $posts_link = App::get_baseurl() . '/contacts/' . $contact['id'] . '/posts';
$contact_drop_link = $a->get_baseurl() . '/contacts/' . $contact['id'] . '/drop?confirm=1'; $contact_drop_link = App::get_baseurl() . '/contacts/' . $contact['id'] . '/drop?confirm=1';
/** /**
* menu array: * menu array:

View file

@ -198,8 +198,10 @@ class NotificationsManager {
* string 'label' => The type of the notification * string 'label' => The type of the notification
* string 'link' => URL to the source * string 'link' => URL to the source
* string 'image' => The avatar image * string 'image' => The avatar image
* string 'url' => The profile url of the contact
* string 'text' => The notification text * string 'text' => The notification text
* string 'when' => Relative date of the notification * string 'when' => The date of the notification
* string 'ago' => T relative date of the notification
* bool 'seen' => Is the notification marked as "seen" * bool 'seen' => Is the notification marked as "seen"
*/ */
private function formatNotifs($notifs, $ident = "") { private function formatNotifs($notifs, $ident = "") {
@ -223,26 +225,32 @@ class NotificationsManager {
$default_item_label = 'notify'; $default_item_label = 'notify';
$default_item_link = $this->a->get_baseurl(true).'/notify/view/'. $it['id']; $default_item_link = $this->a->get_baseurl(true).'/notify/view/'. $it['id'];
$default_item_image = proxy_url($it['photo'], false, PROXY_SIZE_MICRO); $default_item_image = proxy_url($it['photo'], false, PROXY_SIZE_MICRO);
$default_item_url = $it['url'];
$default_item_text = strip_tags(bbcode($it['msg'])); $default_item_text = strip_tags(bbcode($it['msg']));
$default_item_when = relative_date($it['date']); $default_item_when = datetime_convert('UTC', date_default_timezone_get(), $it['date'], 'r');
$default_item_ago = relative_date($it['date']);
break; break;
case 'home': case 'home':
$default_item_label = 'comment'; $default_item_label = 'comment';
$default_item_link = $this->a->get_baseurl(true).'/display/'.$it['pguid']; $default_item_link = $this->a->get_baseurl(true).'/display/'.$it['pguid'];
$default_item_image = proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO); $default_item_image = proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO);
$default_item_url = $it['author-link'];
$default_item_text = sprintf(t("%s commented on %s's post"), $it['author-name'], $it['pname']); $default_item_text = sprintf(t("%s commented on %s's post"), $it['author-name'], $it['pname']);
$default_item_when = relative_date($it['created']); $default_item_when = datetime_convert('UTC', date_default_timezone_get(), $it['created'], 'r');
$default_item_ago = relative_date($it['created']);
break; break;
default: default:
$default_item_label = (($it['id'] == $it['parent']) ? 'post' : 'comment'); $default_item_label = (($it['id'] == $it['parent']) ? 'post' : 'comment');
$default_item_link = $this->a->get_baseurl(true).'/display/'.$it['pguid']; $default_item_link = $this->a->get_baseurl(true).'/display/'.$it['pguid'];
$default_item_image = proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO); $default_item_image = proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO);
$default_item_url = $it['author-link'];
$default_item_text = (($it['id'] == $it['parent']) $default_item_text = (($it['id'] == $it['parent'])
? sprintf(t("%s created a new post"), $it['author-name']) ? sprintf(t("%s created a new post"), $it['author-name'])
: sprintf(t("%s commented on %s's post"), $it['author-name'], $it['pname'])); : sprintf(t("%s commented on %s's post"), $it['author-name'], $it['pname']));
$default_item_when = relative_date($it['created']); $default_item_when = datetime_convert('UTC', date_default_timezone_get(), $it['created'], 'r');
$default_item_ago = relative_date($it['created']);
} }
@ -253,8 +261,10 @@ class NotificationsManager {
'label' => 'like', 'label' => 'like',
'link' => $this->a->get_baseurl(true).'/display/'.$it['pguid'], 'link' => $this->a->get_baseurl(true).'/display/'.$it['pguid'],
'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO), 'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
'url' => $it['author-link'],
'text' => sprintf(t("%s liked %s's post"), $it['author-name'], $it['pname']), 'text' => sprintf(t("%s liked %s's post"), $it['author-name'], $it['pname']),
'when' => relative_date($it['created']), 'when' => $default_item_when,
'ago' => $default_item_ago,
'seen' => $it['seen'] 'seen' => $it['seen']
); );
break; break;
@ -264,8 +274,10 @@ class NotificationsManager {
'label' => 'dislike', 'label' => 'dislike',
'link' => $this->a->get_baseurl(true).'/display/'.$it['pguid'], 'link' => $this->a->get_baseurl(true).'/display/'.$it['pguid'],
'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO), 'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
'url' => $it['author-link'],
'text' => sprintf(t("%s disliked %s's post"), $it['author-name'], $it['pname']), 'text' => sprintf(t("%s disliked %s's post"), $it['author-name'], $it['pname']),
'when' => relative_date($it['created']), 'when' => $default_item_when,
'ago' => $default_item_ago,
'seen' => $it['seen'] 'seen' => $it['seen']
); );
break; break;
@ -275,8 +287,10 @@ class NotificationsManager {
'label' => 'attend', 'label' => 'attend',
'link' => $this->a->get_baseurl(true).'/display/'.$it['pguid'], 'link' => $this->a->get_baseurl(true).'/display/'.$it['pguid'],
'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO), 'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
'url' => $it['author-link'],
'text' => sprintf(t("%s is attending %s's event"), $it['author-name'], $it['pname']), 'text' => sprintf(t("%s is attending %s's event"), $it['author-name'], $it['pname']),
'when' => relative_date($it['created']), 'when' => $default_item_when,
'ago' => $default_item_ago,
'seen' => $it['seen'] 'seen' => $it['seen']
); );
break; break;
@ -286,8 +300,10 @@ class NotificationsManager {
'label' => 'attendno', 'label' => 'attendno',
'link' => $this->a->get_baseurl(true).'/display/'.$it['pguid'], 'link' => $this->a->get_baseurl(true).'/display/'.$it['pguid'],
'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO), 'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
'url' => $it['author-link'],
'text' => sprintf( t("%s is not attending %s's event"), $it['author-name'], $it['pname']), 'text' => sprintf( t("%s is not attending %s's event"), $it['author-name'], $it['pname']),
'when' => relative_date($it['created']), 'when' => $default_item_when,
'ago' => $default_item_ago,
'seen' => $it['seen'] 'seen' => $it['seen']
); );
break; break;
@ -297,8 +313,10 @@ class NotificationsManager {
'label' => 'attendmaybe', 'label' => 'attendmaybe',
'link' => $this->a->get_baseurl(true).'/display/'.$it['pguid'], 'link' => $this->a->get_baseurl(true).'/display/'.$it['pguid'],
'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO), 'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
'url' => $it['author-link'],
'text' => sprintf(t("%s may attend %s's event"), $it['author-name'], $it['pname']), 'text' => sprintf(t("%s may attend %s's event"), $it['author-name'], $it['pname']),
'when' => relative_date($it['created']), 'when' => $default_item_when,
'ago' => $default_item_ago,
'seen' => $it['seen'] 'seen' => $it['seen']
); );
break; break;
@ -312,8 +330,10 @@ class NotificationsManager {
'label' => 'friend', 'label' => 'friend',
'link' => $this->a->get_baseurl(true).'/display/'.$it['pguid'], 'link' => $this->a->get_baseurl(true).'/display/'.$it['pguid'],
'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO), 'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
'url' => $it['author-link'],
'text' => sprintf(t("%s is now friends with %s"), $it['author-name'], $it['fname']), 'text' => sprintf(t("%s is now friends with %s"), $it['author-name'], $it['fname']),
'when' => relative_date($it['created']), 'when' => $default_item_when,
'ago' => $default_item_ago,
'seen' => $it['seen'] 'seen' => $it['seen']
); );
break; break;
@ -323,8 +343,10 @@ class NotificationsManager {
'label' => $default_item_label, 'label' => $default_item_label,
'link' => $default_item_link, 'link' => $default_item_link,
'image' => $default_item_image, 'image' => $default_item_image,
'url' => $default_item_url,
'text' => $default_item_text, 'text' => $default_item_text,
'when' => $default_item_when, 'when' => $default_item_when,
'ago' => $default_item_ago,
'seen' => $it['seen'] 'seen' => $it['seen']
); );
} }
@ -459,7 +481,7 @@ class NotificationsManager {
if($seen === 0) if($seen === 0)
$sql_seen = " AND `seen` = 0 "; $sql_seen = " AND `seen` = 0 ";
$r = q("SELECT `id`, `photo`, `msg`, `date`, `seen` FROM `notify` $r = q("SELECT `id`, `url`, `photo`, `msg`, `date`, `seen` FROM `notify`
WHERE `uid` = %d $sql_seen ORDER BY `date` DESC LIMIT %d, %d ", WHERE `uid` = %d $sql_seen ORDER BY `date` DESC LIMIT %d, %d ",
intval(local_user()), intval(local_user()),
intval($start), intval($start),
@ -626,9 +648,9 @@ class NotificationsManager {
$sql_seen = " AND `item`.`unseen` = 1 "; $sql_seen = " AND `item`.`unseen` = 1 ";
$r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`, `item`.`unseen`, $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`, `item`.`unseen`,
`item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object` as `object`, `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object` AS `object`,
`pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`, `pitem`.`guid` as `pguid` `pitem`.`author-name` AS `pname`, `pitem`.`author-link` AS `plink`, `pitem`.`guid` AS `pguid`
FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent` FROM `item` INNER JOIN `item` AS `pitem` ON `pitem`.`id`=`item`.`parent`
WHERE `item`.`visible` = 1 AND WHERE `item`.`visible` = 1 AND
`item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 1 `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 1
$sql_seen $sql_seen

View file

@ -794,8 +794,6 @@ function update_contact_avatar($avatar, $uid, $cid, $force = false) {
function import_profile_photo($photo, $uid, $cid, $quit_on_error = 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", $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($uid),
intval($cid) intval($cid)
@ -841,9 +839,9 @@ function import_profile_photo($photo, $uid, $cid, $quit_on_error = false) {
$photo_failure = true; $photo_failure = true;
} }
$photo = $a->get_baseurl() . '/photo/' . $hash . '-4.' . $img->getExt(); $photo = App::get_baseurl() . '/photo/' . $hash . '-4.' . $img->getExt();
$thumb = $a->get_baseurl() . '/photo/' . $hash . '-5.' . $img->getExt(); $thumb = App::get_baseurl() . '/photo/' . $hash . '-5.' . $img->getExt();
$micro = $a->get_baseurl() . '/photo/' . $hash . '-6.' . $img->getExt(); $micro = App::get_baseurl() . '/photo/' . $hash . '-6.' . $img->getExt();
} else { } else {
$photo_failure = true; $photo_failure = true;
} }
@ -853,9 +851,9 @@ function import_profile_photo($photo, $uid, $cid, $quit_on_error = false) {
} }
if ($photo_failure) { if ($photo_failure) {
$photo = $a->get_baseurl() . '/images/person-175.jpg'; $photo = App::get_baseurl() . '/images/person-175.jpg';
$thumb = $a->get_baseurl() . '/images/person-80.jpg'; $thumb = App::get_baseurl() . '/images/person-80.jpg';
$micro = $a->get_baseurl() . '/images/person-48.jpg'; $micro = App::get_baseurl() . '/images/person-48.jpg';
} }
return(array($photo,$thumb,$micro)); return(array($photo,$thumb,$micro));
@ -1044,18 +1042,18 @@ function store_photo($a, $uid, $imagedata = "", $url = "") {
return(array()); return(array());
} }
$image = array("page" => $a->get_baseurl().'/photos/'.$page_owner_nick.'/image/'.$hash, $image = array("page" => App::get_baseurl().'/photos/'.$page_owner_nick.'/image/'.$hash,
"full" => $a->get_baseurl()."/photo/{$hash}-0.".$ph->getExt()); "full" => App::get_baseurl()."/photo/{$hash}-0.".$ph->getExt());
if ($width > 800 || $height > 800) { 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) { if ($width > 640 || $height > 640) {
$ph->scaleImage(640); $ph->scaleImage(640);
$r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 1, 0, $defperm); $r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 1, 0, $defperm);
if ($r) { 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); $ph->scaleImage(320);
$r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 2, 0, $defperm); $r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 2, 0, $defperm);
if ($r) { 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); $r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 3, 0, $defperm);
if ($r) { if ($r) {
$image["thumb"] = $a->get_baseurl()."/photo/{$hash}-3.".$ph->getExt(); $image["thumb"] = App::get_baseurl()."/photo/{$hash}-3.".$ph->getExt();
} }
} }

View file

@ -324,7 +324,7 @@ class Probe {
!isset($parts["path"])) !isset($parts["path"]))
return false; return false;
// todo: Ports? /// @todo: Ports?
$host = $parts["host"]; $host = $parts["host"];
if ($host == 'twitter.com') if ($host == 'twitter.com')

View file

@ -34,7 +34,7 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) {
call_hooks($a->module . '_pre_' . $selname, $arr); call_hooks($a->module . '_pre_' . $selname, $arr);
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) { foreach ($r as $rr) {
if((is_array($preselected)) && in_array($rr['id'], $preselected)) if((is_array($preselected)) && in_array($rr['id'], $preselected))
$selected = " selected=\"selected\" "; $selected = " selected=\"selected\" ";
else else
@ -65,20 +65,24 @@ function contact_selector($selname, $selclass, $preselected = false, $options) {
$exclude = false; $exclude = false;
$size = 4; $size = 4;
if(is_array($options)) { if (is_array($options)) {
if(x($options,'size')) if (x($options,'size'))
$size = $options['size']; $size = $options['size'];
if(x($options,'mutual_friends')) if (x($options,'mutual_friends')) {
$mutual = true; $mutual = true;
if(x($options,'single')) }
if (x($options,'single')) {
$single = true; $single = true;
if(x($options,'multiple')) }
if (x($options,'multiple')) {
$single = false; $single = false;
if(x($options,'exclude')) }
if (x($options,'exclude')) {
$exclude = $options['exclude']; $exclude = $options['exclude'];
}
if(x($options,'networks')) { if (x($options,'networks')) {
switch($options['networks']) { switch($options['networks']) {
case 'DFRN_ONLY': case 'DFRN_ONLY':
$networks = array(NETWORK_DFRN); $networks = array(NETWORK_DFRN);
@ -145,11 +149,12 @@ function contact_selector($selname, $selclass, $preselected = false, $options) {
call_hooks($a->module . '_pre_' . $selname, $arr); call_hooks($a->module . '_pre_' . $selname, $arr);
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) { foreach ($r as $rr) {
if((is_array($preselected)) && in_array($rr['id'], $preselected)) if ((is_array($preselected)) && in_array($rr['id'], $preselected)) {
$selected = " selected=\"selected\" "; $selected = " selected=\"selected\" ";
else } else {
$selected = ''; $selected = '';
}
$trimmed = mb_substr($rr['name'],0,20); $trimmed = mb_substr($rr['name'],0,20);
@ -221,16 +226,19 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
$receiverlist = array(); $receiverlist = array();
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) { foreach ($r as $rr) {
if((is_array($preselected)) && in_array($rr['id'], $preselected)) if ((is_array($preselected)) && in_array($rr['id'], $preselected)) {
$selected = " selected=\"selected\" "; $selected = " selected=\"selected\" ";
else }
else {
$selected = ''; $selected = '';
}
if($privmail) if ($privmail) {
$trimmed = GetProfileUsername($rr['url'], $rr['name'], false); $trimmed = GetProfileUsername($rr['url'], $rr['name'], false);
else } else {
$trimmed = mb_substr($rr['name'],0,20); $trimmed = mb_substr($rr['name'],0,20);
}
$receiverlist[] = $trimmed; $receiverlist[] = $trimmed;
@ -256,16 +264,22 @@ function fixacl(&$item) {
function prune_deadguys($arr) { function prune_deadguys($arr) {
if(! $arr) if (! $arr) {
return $arr; return $arr;
}
$str = dbesc(implode(',',$arr)); $str = dbesc(implode(',',$arr));
$r = q("SELECT `id` FROM `contact` WHERE `id` IN ( " . $str . ") AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 "); $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(); $ret = array();
foreach($r as $rr) foreach ($r as $rr) {
$ret[] = intval($rr['id']); $ret[] = intval($rr['id']);
}
return $ret; return $ret;
} }
return array(); return array();
} }
@ -392,8 +406,9 @@ function construct_acl_data(&$a, $user) {
function acl_lookup(&$a, $out_type = 'json') { function acl_lookup(&$a, $out_type = 'json') {
if(!local_user()) if (!local_user()) {
return ""; return '';
}
$start = (x($_REQUEST,'start') ? $_REQUEST['start'] : 0); $start = (x($_REQUEST,'start') ? $_REQUEST['start'] : 0);
$count = (x($_REQUEST,'count') ? $_REQUEST['count'] : 100); $count = (x($_REQUEST,'count') ? $_REQUEST['count'] : 100);
@ -540,28 +555,26 @@ function acl_lookup(&$a, $out_type = 'json') {
dbesc(NETWORK_ZOT), dbesc(NETWORK_ZOT),
dbesc(NETWORK_DIASPORA) dbesc(NETWORK_DIASPORA)
); );
} } elseif ($type == 'a') {
elseif($type == 'a') {
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `forum`, `prv` FROM `contact` $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `forum`, `prv` FROM `contact`
WHERE `uid` = %d AND `pending` = 0 WHERE `uid` = %d AND `pending` = 0
$sql_extra2 $sql_extra2
ORDER BY `name` ASC ", ORDER BY `name` ASC ",
intval(local_user()) intval(local_user())
); );
} } elseif ($type == 'x') {
elseif($type == 'x') {
// autocomplete for global contact search (e.g. navbar search) // autocomplete for global contact search (e.g. navbar search)
$r = navbar_complete($a); $r = navbar_complete($a);
$contacts = array(); $contacts = array();
if($r) { if ($r) {
foreach($r as $g) { foreach ($r as $g) {
$contacts[] = array( $contacts[] = array(
"photo" => proxy_url($g['photo'], false, PROXY_SIZE_MICRO), 'photo' => proxy_url($g['photo'], false, PROXY_SIZE_MICRO),
"name" => $g['name'], 'name' => $g['name'],
"nick" => (x($g['addr']) ? $g['addr'] : $g['url']), 'nick' => (x($g['addr']) ? $g['addr'] : $g['url']),
"network" => $g['network'], 'network' => $g['network'],
"link" => $g['url'], 'link' => $g['url'],
"forum" => (x($g['community']) ? 1 : 0), 'forum' => (x($g['community']) ? 1 : 0),
); );
} }
} }
@ -578,16 +591,16 @@ function acl_lookup(&$a, $out_type = 'json') {
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $g){ foreach ($r as $g){
$contacts[] = array( $contacts[] = array(
"type" => "c", 'type' => 'c',
"photo" => proxy_url($g['micro'], false, PROXY_SIZE_MICRO), 'photo' => proxy_url($g['micro'], false, PROXY_SIZE_MICRO),
"name" => htmlentities($g['name']), 'name' => htmlentities($g['name']),
"id" => intval($g['id']), 'id' => intval($g['id']),
"network" => $g['network'], 'network' => $g['network'],
"link" => $g['url'], 'link' => $g['url'],
"nick" => htmlentities(($g['attag']) ? $g['attag'] : $g['nick']), 'nick' => htmlentities(($g['attag']) ? $g['attag'] : $g['nick']),
"forum" => ((x($g['forum']) || x($g['prv'])) ? 1 : 0), 'forum' => ((x($g['forum']) || x($g['prv'])) ? 1 : 0),
); );
} }
} }
@ -613,7 +626,7 @@ function acl_lookup(&$a, $out_type = 'json') {
implode("','", $known_contacts) implode("','", $known_contacts)
); );
if (dbm::is_result($r)){ if (dbm::is_result($r)){
foreach($r as $row) { foreach ($r as $row) {
// nickname.. // nickname..
$up = parse_url($row['author-link']); $up = parse_url($row['author-link']);
$nick = explode("/",$up['path']); $nick = explode("/",$up['path']);
@ -621,14 +634,14 @@ function acl_lookup(&$a, $out_type = 'json') {
$nick .= "@".$up['host']; $nick .= "@".$up['host'];
// /nickname // /nickname
$unknow_contacts[] = array( $unknow_contacts[] = array(
"type" => "c", 'type' => 'c',
"photo" => proxy_url($row['author-avatar'], false, PROXY_SIZE_MICRO), 'photo' => proxy_url($row['author-avatar'], false, PROXY_SIZE_MICRO),
"name" => htmlentities($row['author-name']), 'name' => htmlentities($row['author-name']),
"id" => '', 'id' => '',
"network" => "unknown", 'network' => 'unknown',
"link" => $row['author-link'], 'link' => $row['author-link'],
"nick" => htmlentities($nick), 'nick' => htmlentities($nick),
"forum" => false 'forum' => false
); );
} }
} }
@ -638,34 +651,34 @@ function acl_lookup(&$a, $out_type = 'json') {
} }
$results = array( $results = array(
"tot" => $tot, 'tot' => $tot,
"start" => $start, 'start' => $start,
"count" => $count, 'count' => $count,
"groups" => $groups, 'groups' => $groups,
"contacts" => $contacts, 'contacts' => $contacts,
"items" => $items, 'items' => $items,
"type" => $type, 'type' => $type,
"search" => $search, 'search' => $search,
); );
call_hooks('acl_lookup_end', $results); call_hooks('acl_lookup_end', $results);
if($out_type === 'html') { if($out_type === 'html') {
$o = array( $o = array(
'tot' => $results["tot"], 'tot' => $results['tot'],
'start' => $results["start"], 'start' => $results['start'],
'count' => $results["count"], 'count' => $results['count'],
'groups' => $results["groups"], 'groups' => $results['groups'],
'contacts' => $results["contacts"], 'contacts' => $results['contacts'],
); );
return $o; return $o;
} }
$o = array( $o = array(
'tot' => $results["tot"], 'tot' => $results['tot'],
'start' => $results["start"], 'start' => $results['start'],
'count' => $results["count"], 'count' => $results['count'],
'items' => $results["items"], 'items' => $results['items'],
); );
echo json_encode($o); echo json_encode($o);
@ -682,7 +695,7 @@ function navbar_complete(&$a) {
// logger('navbar_complete'); // logger('navbar_complete');
if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) { if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
return; return;
} }
@ -693,28 +706,32 @@ function navbar_complete(&$a) {
$mode = $_REQUEST['smode']; $mode = $_REQUEST['smode'];
// don't search if search term has less than 2 characters // 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(); return array();
}
if(substr($search,0,1) === '@') if (substr($search,0,1) === '@') {
$search = substr($search,1); $search = substr($search,1);
}
if($localsearch) { if ($localsearch) {
$x = DirSearch::global_search_by_name($search, $mode); $x = DirSearch::global_search_by_name($search, $mode);
return $x; return $x;
} }
if(! $localsearch) { if (! $localsearch) {
$p = (($a->pager['page'] != 1) ? '&p=' . $a->pager['page'] : ''); $p = (($a->pager['page'] != 1) ? '&p=' . $a->pager['page'] : '');
$x = z_fetch_url(get_server().'/lsearch?f=' . $p . '&search=' . urlencode($search)); $x = z_fetch_url(get_server().'/lsearch?f=' . $p . '&search=' . urlencode($search));
if($x['success']) { if ($x['success']) {
$t = 0; $t = 0;
$j = json_decode($x['body'],true); $j = json_decode($x['body'],true);
if($j && $j['results']) { if ($j && $j['results']) {
return $j['results']; return $j['results'];
} }
} }
} }
/// @TODO Not needed here?
return; return;
} }

View file

@ -3068,8 +3068,8 @@
'image/gif' => 'gif' 'image/gif' => 'gif'
); );
$data = array('photo'=>array()); $data = array('photo'=>array());
if($r) { if ($r) {
foreach($r as $rr) { foreach ($r as $rr) {
$photo = array(); $photo = array();
$photo['id'] = $rr['resource-id']; $photo['id'] = $rr['resource-id'];
$photo['album'] = $rr['album']; $photo['album'] = $rr['album'];
@ -3218,7 +3218,7 @@
function api_share_as_retweet(&$item) { function api_share_as_retweet(&$item) {
$body = trim($item["body"]); $body = trim($item["body"]);
if (diaspora::is_reshare($body, false)===false) { if (Diaspora::is_reshare($body, false)===false) {
return false; return false;
} }

View file

@ -125,8 +125,7 @@ if (isset($_SESSION) && x($_SESSION,'authenticated') && (!x($_POST,'auth-params'
$openid = new LightOpenID; $openid = new LightOpenID;
$openid->identity = $openid_url; $openid->identity = $openid_url;
$_SESSION['openid'] = $openid_url; $_SESSION['openid'] = $openid_url;
$a = get_app(); $openid->returnUrl = App::get_baseurl(true).'/openid';
$openid->returnUrl = $a->get_baseurl(true).'/openid';
goaway($openid->authUrl()); goaway($openid->authUrl());
} catch (Exception $e) { } 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()); 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());

View file

@ -69,6 +69,28 @@ function diaspora2bb($s) {
return $s; return $s;
} }
/**
* @brief Callback function to replace a Friendica style mention in a mention for Diaspora
*
* @param array $match Matching values for the callback
* @return text Replaced mention
*/
function diaspora_mentions($match) {
$contact = get_contact_details_by_url($match[3]);
if (!isset($contact['addr'])) {
$contact = Probe::uri($match[3]);
}
if (!isset($contact['addr'])) {
return $match[0];
}
$mention = '@{'.$match[2].'; '.$contact['addr'].'}';
return $mention;
}
function bb2diaspora($Text,$preserve_nl = false, $fordiaspora = true) { function bb2diaspora($Text,$preserve_nl = false, $fordiaspora = true) {
$a = get_app(); $a = get_app();
@ -132,6 +154,11 @@ function bb2diaspora($Text,$preserve_nl = false, $fordiaspora = true) {
// the Diaspora signature verification and cause the item to disappear // the Diaspora signature verification and cause the item to disappear
$Text = trim($Text); $Text = trim($Text);
if ($fordiaspora) {
$URLSearchString = "^\[\]";
$Text = preg_replace_callback("/([@]\[(.*?)\])\(([$URLSearchString]*?)\)/ism", 'diaspora_mentions', $Text);
}
call_hooks('bb2diaspora',$Text); call_hooks('bb2diaspora',$Text);
return $Text; return $Text;
@ -144,8 +171,6 @@ function unescape_underscores_in_links($m) {
function format_event_diaspora($ev) { function format_event_diaspora($ev) {
$a = get_app();
if(! ((is_array($ev)) && count($ev))) if(! ((is_array($ev)) && count($ev)))
return ''; return '';
@ -160,7 +185,7 @@ function format_event_diaspora($ev) {
$ev['start'] , $bd_format )) $ev['start'] , $bd_format ))
: day_translate(datetime_convert('UTC', 'UTC', : day_translate(datetime_convert('UTC', 'UTC',
$ev['start'] , $bd_format))) $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']) if(! $ev['nofinish'])
$o .= t('Finishes:') . ' ' . '[' $o .= t('Finishes:') . ' ' . '['
@ -168,7 +193,7 @@ function format_event_diaspora($ev) {
$ev['finish'] , $bd_format )) $ev['finish'] , $bd_format ))
: day_translate(datetime_convert('UTC', 'UTC', : day_translate(datetime_convert('UTC', 'UTC',
$ev['finish'] , $bd_format ))) $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'])) if(strlen($ev['location']))
$o .= t('Location:') . bb2diaspora($ev['location']) $o .= t('Location:') . bb2diaspora($ev['location'])

View file

@ -343,7 +343,7 @@ function bb_replace_images($body, $images) {
$newbody = $body; $newbody = $body;
$cnt = 0; $cnt = 0;
foreach($images as $image) { foreach ($images as $image) {
// We're depending on the property of 'foreach' (specified on the PHP website) that // 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 // it loops over the array starting from the first element and going sequentially
// to the last element // to the last element
@ -613,9 +613,7 @@ function GetProfileUsername($profile, $username, $compact = false, $getnetwork =
} }
function bb_DiasporaLinks($match) { function bb_DiasporaLinks($match) {
$a = get_app(); return "[url=".App::get_baseurl()."/display/".$match[1]."]".$match[2]."[/url]";
return "[url=".$a->get_baseurl()."/display/".$match[1]."]".$match[2]."[/url]";
} }
function bb_RemovePictureLinks($match) { 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 // we may need to restrict this further if it picks up too many strays
// link acct:user@host to a webfinger profile redirector // 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 // Perform MAIL Search
$Text = preg_replace("/\[mail\]([$MAILSearchString]*)\[\/mail\]/", '<a href="mailto:$1">$1</a>', $Text); $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)); return(bb_ShareAttributes($match, $simplehtml));
},$Text); },$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="' .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="' .$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="' . '$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="' . '$1' . ' ' . t('Encrypted content') . '" /><br />', $Text);
// Try to Oembed // Try to Oembed

View file

@ -13,7 +13,7 @@ function contact_profile_assign($current,$foreign_net) {
intval($_SESSION['uid'])); intval($_SESSION['uid']));
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) { foreach ($r as $rr) {
$selected = (($rr['id'] == $current) ? " selected=\"selected\" " : ""); $selected = (($rr['id'] == $current) ? " selected=\"selected\" " : "");
$o .= "<option value=\"{$rr['id']}\" $selected >{$rr['profile-name']}</option>\r\n"; $o .= "<option value=\"{$rr['id']}\" $selected >{$rr['profile-name']}</option>\r\n";
} }
@ -99,7 +99,7 @@ function network_to_name($s, $profile = "") {
$networkname = str_replace($search,$replace,$s); $networkname = str_replace($search,$replace,$s);
if (($s == NETWORK_DIASPORA) AND ($profile != "") AND diaspora::is_redmatrix($profile)) { if (($s == NETWORK_DIASPORA) AND ($profile != "") AND Diaspora::is_redmatrix($profile)) {
$networkname = t("Hubzilla/Redmatrix"); $networkname = t("Hubzilla/Redmatrix");
$r = q("SELECT `gserver`.`platform` FROM `gcontact` $r = q("SELECT `gserver`.`platform` FROM `gcontact`

View file

@ -80,11 +80,13 @@ function networks_widget($baseurl,$selected = '') {
$a = get_app(); $a = get_app();
if(!local_user()) if (!local_user()) {
return ''; return '';
}
if(!feature_enabled(local_user(),'networks')) if (!feature_enabled(local_user(),'networks')) {
return ''; return '';
}
$extra_sql = unavailable_networks(); $extra_sql = unavailable_networks();
@ -95,11 +97,13 @@ function networks_widget($baseurl,$selected = '') {
$nets = array(); $nets = array();
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
require_once('include/contact_selectors.php'); require_once('include/contact_selectors.php');
foreach($r as $rr) { foreach ($r as $rr) {
if($rr['network']) /// @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' : '' )); $nets[] = array('ref' => $rr['network'], 'name' => network_to_name($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' ));
} }
} }
}
if(count($nets) < 2) if(count($nets) < 2)
return ''; return '';
@ -116,16 +120,18 @@ function networks_widget($baseurl,$selected = '') {
} }
function fileas_widget($baseurl,$selected = '') { function fileas_widget($baseurl,$selected = '') {
$a = get_app(); if (! local_user()) {
if(! local_user())
return ''; return '';
}
if(! feature_enabled(local_user(),'filing')) if (! feature_enabled(local_user(),'filing')) {
return ''; return '';
}
$saved = get_pconfig(local_user(),'system','filetags'); $saved = get_pconfig(local_user(),'system','filetags');
if(! strlen($saved)) if (! strlen($saved)) {
return; return;
}
$matches = false; $matches = false;
$terms = array(); $terms = array();
@ -235,7 +241,7 @@ function common_friends_visitor_widget($profile_uid) {
return replace_macros(get_markup_template('remote_friends_common.tpl'), array( return replace_macros(get_markup_template('remote_friends_common.tpl'), array(
'$desc' => sprintf( tt("%d contact in common", "%d contacts in common", $t), $t), '$desc' => sprintf( tt("%d contact in common", "%d contacts in common", $t), $t),
'$base' => $a->get_baseurl(), '$base' => App::get_baseurl(),
'$uid' => $profile_uid, '$uid' => $profile_uid,
'$cid' => (($cid) ? $cid : '0'), '$cid' => (($cid) ? $cid : '0'),
'$linkmore' => (($t > 5) ? 'true' : ''), '$linkmore' => (($t > 5) ? 'true' : ''),

View file

@ -78,7 +78,7 @@ function item_redir_and_replace_images($body, $images, $cid) {
$newbody .= $origbody; $newbody .= $origbody;
$cnt = 0; $cnt = 0;
foreach($images as $image) { foreach ($images as $image) {
// We're depending on the property of 'foreach' (specified on the PHP website) that // 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 // it loops over the array starting from the first element and going sequentially
// to the last element // to the last element
@ -324,12 +324,14 @@ function localize_item(&$item){
// add sparkle links to appropriate permalinks // add sparkle links to appropriate permalinks
$x = stristr($item['plink'],'/display/'); $x = stristr($item['plink'],'/display/');
if($x) { if ($x) {
$sparkle = false; $sparkle = false;
$y = best_link_url($item,$sparkle,true); $y = best_link_url($item,$sparkle,true);
if(strstr($y,'/redir/'))
if (strstr($y,'/redir/')) {
$item['plink'] = $y . '?f=&url=' . $item['plink']; $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( $o = replace_macros($page_template, array(
'$baseurl' => $a->get_baseurl($ssl_state), '$baseurl' => App::get_baseurl($ssl_state),
'$return_path' => $a->query_string, '$return_path' => $a->query_string,
'$live_update' => $live_update_div, '$live_update' => $live_update_div,
'$remove' => t('remove'), '$remove' => t('remove'),
@ -1183,7 +1185,7 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
$tpl = get_markup_template('jot-header.tpl'); $tpl = get_markup_template('jot-header.tpl');
$a->page['htmlhead'] .= replace_macros($tpl, array( $a->page['htmlhead'] .= replace_macros($tpl, array(
'$newpost' => 'true', '$newpost' => 'true',
'$baseurl' => $a->get_baseurl(true), '$baseurl' => App::get_baseurl(true),
'$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
'$geotag' => $geotag, '$geotag' => $geotag,
'$nickname' => $x['nickname'], '$nickname' => $x['nickname'],
@ -1201,7 +1203,7 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
$tpl = get_markup_template('jot-end.tpl'); $tpl = get_markup_template('jot-end.tpl');
$a->page['end'] .= replace_macros($tpl, array( $a->page['end'] .= replace_macros($tpl, array(
'$newpost' => 'true', '$newpost' => 'true',
'$baseurl' => $a->get_baseurl(true), '$baseurl' => App::get_baseurl(true),
'$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
'$geotag' => $geotag, '$geotag' => $geotag,
'$nickname' => $x['nickname'], '$nickname' => $x['nickname'],
@ -1267,7 +1269,7 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
'$ptyp' => (($notes_cid) ? 'note' : 'wall'), '$ptyp' => (($notes_cid) ? 'note' : 'wall'),
'$content' => $x['content'], '$content' => $x['content'],
'$post_id' => $x['post_id'], '$post_id' => $x['post_id'],
'$baseurl' => $a->get_baseurl(true), '$baseurl' => App::get_baseurl(true),
'$defloc' => $x['default_location'], '$defloc' => $x['default_location'],
'$visitor' => $x['visitor'], '$visitor' => $x['visitor'],
'$pvisit' => (($notes_cid) ? 'none' : $x['visitor']), '$pvisit' => (($notes_cid) ? 'none' : $x['visitor']),

View file

@ -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` "); $r = q("SELECT * FROM contact WHERE `bd` != '' AND `bd` != '0000-00-00' AND SUBSTRING(`bd`,1,4) != `bdyear` ");
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) { foreach ($r as $rr) {
logger('update_contact_birthday: ' . $rr['bd']); logger('update_contact_birthday: ' . $rr['bd']);

View file

@ -26,7 +26,6 @@ function update_fail($update_id, $error_message){
} }
// every admin could had different language // every admin could had different language
foreach ($adminlist as $admin) { foreach ($adminlist as $admin) {
$lang = (($admin['language'])?$admin['language']:'en'); $lang = (($admin['language'])?$admin['language']:'en');
push_lang($lang); push_lang($lang);
@ -56,11 +55,11 @@ function update_fail($update_id, $error_message){
$email_tpl = get_intltext_template("update_fail_eml.tpl"); $email_tpl = get_intltext_template("update_fail_eml.tpl");
$email_msg = replace_macros($email_tpl, array( $email_msg = replace_macros($email_tpl, array(
'$sitename' => $a->config['sitename'], '$sitename' => $a->config['sitename'],
'$siteurl' => $a->get_baseurl(), '$siteurl' => App::get_baseurl(),
'$update' => DB_UPDATE_VERSION, '$update' => DB_UPDATE_VERSION,
'$error' => sprintf(t('Update %s failed. See error logs.'), 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'); require_once('include/email.php');
$subject = email_header_encode($subject,'UTF-8'); $subject = email_header_encode($subject,'UTF-8');
mail($a->config['admin_email'], $subject, $email_msg, mail($a->config['admin_email'], $subject, $email_msg,
@ -83,8 +82,9 @@ function table_structure($table) {
if (dbm::is_result($indexes)) if (dbm::is_result($indexes))
foreach ($indexes AS $index) { foreach ($indexes AS $index) {
if ($index["Index_type"] == "FULLTEXT") if ($index["Index_type"] == "FULLTEXT") {
continue; continue;
}
if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) { if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) {
$indexdata[$index["Key_name"]] = array('UNIQUE'); $indexdata[$index["Key_name"]] = array('UNIQUE');
@ -95,28 +95,33 @@ function table_structure($table) {
// To avoid the need to add this to every index definition we just ignore it here. // To avoid the need to add this to every index definition we just ignore it here.
// Exception are primary indexes // Exception are primary indexes
// Since there are some combindex primary indexes we use the limit of 180 here. // 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"].")"; $column .= "(".$index["Sub_part"].")";
}
$indexdata[$index["Key_name"]][] = $column; $indexdata[$index["Key_name"]][] = $column;
} }
if (dbm::is_result($structures)) { if (dbm::is_result($structures)) {
foreach($structures AS $field) { foreach ($structures AS $field) {
$fielddata[$field["Field"]]["type"] = $field["Type"]; $fielddata[$field["Field"]]["type"] = $field["Type"];
if ($field["Null"] == "NO") if ($field["Null"] == "NO") {
$fielddata[$field["Field"]]["not null"] = true; $fielddata[$field["Field"]]["not null"] = true;
}
if (isset($field["Default"])) if (isset($field["Default"])) {
$fielddata[$field["Field"]]["default"] = $field["Default"]; $fielddata[$field["Field"]]["default"] = $field["Default"];
}
if ($field["Extra"] != "") if ($field["Extra"] != "") {
$fielddata[$field["Field"]]["extra"] = $field["Extra"]; $fielddata[$field["Field"]]["extra"] = $field["Extra"];
}
if ($field["Key"] == "PRI") if ($field["Key"] == "PRI") {
$fielddata[$field["Field"]]["primary"] = true; $fielddata[$field["Field"]]["primary"] = true;
} }
} }
}
return(array("fields"=>$fielddata, "indexes"=>$indexdata)); return(array("fields"=>$fielddata, "indexes"=>$indexdata));
} }
@ -138,13 +143,15 @@ function print_structure($database, $charset) {
function update_structure($verbose, $action, $tables=null, $definition=null) { function update_structure($verbose, $action, $tables=null, $definition=null) {
global $a, $db; global $a, $db;
if ($action) if ($action) {
set_config('system', 'maintenance', 1); 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"]; $charset = $a->config["system"]["db_charset"];
else } else {
$charset = "utf8"; $charset = "utf8";
}
$errors = false; $errors = false;
@ -153,8 +160,9 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
// Get the current structure // Get the current structure
$database = array(); $database = array();
if (is_null($tables)) if (is_null($tables)) {
$tables = q("show tables"); $tables = q("SHOW TABLES");
}
foreach ($tables AS $table) { foreach ($tables AS $table) {
$table = current($table); $table = current($table);
@ -164,21 +172,24 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
} }
// Get the definition // Get the definition
if (is_null($definition)) if (is_null($definition)) {
$definition = db_definition($charset); $definition = db_definition($charset);
}
// Ensure index conversion to unique removes duplicates // Ensure index conversion to unique removes duplicates
$sql_config = "SET session old_alter_table=1;"; $sql_config = "SET session old_alter_table=1;";
if ($verbose) if ($verbose) {
echo $sql_config."\n"; 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 // 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 if ((version_compare($db->server_info(), '5.7.4') >= 0) AND
!(strpos($db->server_info(), 'MariaDB') !== false)) { !(strpos($db->server_info(), 'MariaDB') !== false)) {
$ignore = ''; $ignore = '';
}else { } else {
$ignore = ' IGNORE'; $ignore = ' IGNORE';
} }
@ -193,10 +204,12 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
} }
$is_new_table = True; $is_new_table = True;
} else { } else {
// Drop the index if it isn't present in the definition /*
// or the definition differ from current status * Drop the index if it isn't present in the definition
// and index name doesn't start with "local_" * or the definition differ from current status
foreach ($database[$name]["indexes"] AS $indexname => $fieldnames) { * and index name doesn't start with "local_"
*/
foreach ($database[$name]["indexes"] as $indexname => $fieldnames) {
$current_index_definition = implode(",",$fieldnames); $current_index_definition = implode(",",$fieldnames);
if (isset($structure["indexes"][$indexname])) { if (isset($structure["indexes"][$indexname])) {
$new_index_definition = implode(",",$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_') { if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
$sql2=db_drop_index($indexname); $sql2=db_drop_index($indexname);
if ($sql3 == "") if ($sql3 == "") {
$sql3 = "ALTER".$ignore." TABLE `".$name."` ".$sql2; $sql3 = "ALTER".$ignore." TABLE `".$name."` ".$sql2;
else } else {
$sql3 .= ", ".$sql2; $sql3 .= ", ".$sql2;
} }
} }
}
// Compare the field structure field by field // Compare the field structure field by field
foreach ($structure["fields"] AS $fieldname => $parameters) { foreach ($structure["fields"] AS $fieldname => $parameters) {
if (!isset($database[$name]["fields"][$fieldname])) { if (!isset($database[$name]["fields"][$fieldname])) {
$sql2=db_add_table_field($fieldname, $parameters); $sql2=db_add_table_field($fieldname, $parameters);
if ($sql3 == "") if ($sql3 == "") {
$sql3 = "ALTER TABLE `".$name."` ".$sql2; $sql3 = "ALTER TABLE `".$name."` ".$sql2;
else } else {
$sql3 .= ", ".$sql2; $sql3 .= ", ".$sql2;
}
} else { } else {
// Compare the field definition // Compare the field definition
$current_field_definition = implode(",",$database[$name]["fields"][$fieldname]); $current_field_definition = implode(",",$database[$name]["fields"][$fieldname]);
$new_field_definition = implode(",",$parameters); $new_field_definition = implode(",",$parameters);
if ($current_field_definition != $new_field_definition) { if ($current_field_definition != $new_field_definition) {
$sql2=db_modify_table_field($fieldname, $parameters); $sql2=db_modify_table_field($fieldname, $parameters);
if ($sql3 == "") if ($sql3 == "") {
$sql3 = "ALTER TABLE `".$name."` ".$sql2; $sql3 = "ALTER TABLE `".$name."` ".$sql2;
else } else {
$sql3 .= ", ".$sql2; $sql3 .= ", ".$sql2;
} }
}
} }
} }
} }
// Create the index if the index don't exists in database /*
// or the definition differ from the current status. * Create the index if the index don't exists in database
// Don't create keys if table is new * or the definition differ from the current status.
* Don't create keys if table is new
*/
if (!$is_new_table) { if (!$is_new_table) {
foreach ($structure["indexes"] AS $indexname => $fieldnames) { foreach ($structure["indexes"] AS $indexname => $fieldnames) {
if (isset($database[$name]["indexes"][$indexname])) { if (isset($database[$name]["indexes"][$indexname])) {
@ -367,11 +385,12 @@ function db_create_index($indexname, $fieldnames, $method="ADD") {
if ($names != "") if ($names != "")
$names .= ","; $names .= ",";
if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
$names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")"; $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
else } else {
$names .= "`".dbesc($fieldname)."`"; $names .= "`".dbesc($fieldname)."`";
} }
}
if ($indexname == "PRIMARY") { if ($indexname == "PRIMARY") {
return sprintf("%s PRIMARY KEY(%s)", $method, $names); return sprintf("%s PRIMARY KEY(%s)", $method, $names);
@ -383,8 +402,9 @@ function db_create_index($indexname, $fieldnames, $method="ADD") {
} }
function db_index_suffix($charset, $reduce = 0) { function db_index_suffix($charset, $reduce = 0) {
if ($charset != "utf8mb4") if ($charset != "utf8mb4") {
return ""; return "";
}
// On utf8mb4 indexes can only have a length of 191 // On utf8mb4 indexes can only have a length of 191
$indexlength = 191 - $reduce; $indexlength = 191 - $reduce;
@ -444,13 +464,13 @@ function db_definition($charset) {
); );
$database["cache"] = array( $database["cache"] = array(
"fields" => array( "fields" => array(
"k" => array("type" => "varchar(255)", "not null" => "1", "primary" => "1"), "k" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
"v" => array("type" => "text"), "v" => array("type" => "text"),
"expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"), "expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
"updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
), ),
"indexes" => array( "indexes" => array(
"PRIMARY" => array("k".db_index_suffix($charset)), "PRIMARY" => array("k"),
"updated" => array("updated"), "updated" => array("updated"),
"expire_mode_updated" => array("expire_mode", "updated"), "expire_mode_updated" => array("expire_mode", "updated"),
) )
@ -484,13 +504,13 @@ function db_definition($charset) {
$database["config"] = array( $database["config"] = array(
"fields" => array( "fields" => array(
"id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
"cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
"k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
"v" => array("type" => "text"), "v" => array("type" => "text"),
), ),
"indexes" => array( "indexes" => array(
"PRIMARY" => array("id"), "PRIMARY" => array("id"),
"cat_k" => array("UNIQUE", "cat(30)","k(30)"), "cat_k" => array("UNIQUE", "cat", "k"),
) )
); );
$database["contact"] = array( $database["contact"] = array(
@ -590,7 +610,7 @@ function db_definition($charset) {
$database["deliverq"] = array( $database["deliverq"] = array(
"fields" => array( "fields" => array(
"id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
"cmd" => array("type" => "varchar(32)", "not null" => "1", "default" => ""), "cmd" => array("type" => "varbinary(32)", "not null" => "1", "default" => ""),
"item" => array("type" => "int(11)", "not null" => "1", "default" => "0"), "item" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
"contact" => array("type" => "int(11)", "not null" => "1", "default" => "0"), "contact" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
), ),
@ -602,6 +622,7 @@ function db_definition($charset) {
$database["event"] = array( $database["event"] = array(
"fields" => array( "fields" => array(
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
"guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
"cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
"uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
@ -1072,25 +1093,25 @@ function db_definition($charset) {
); );
$database["oembed"] = array( $database["oembed"] = array(
"fields" => array( "fields" => array(
"url" => array("type" => "varchar(255)", "not null" => "1", "primary" => "1"), "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
"content" => array("type" => "text"), "content" => array("type" => "text"),
"created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
), ),
"indexes" => array( "indexes" => array(
"PRIMARY" => array("url".db_index_suffix($charset)), "PRIMARY" => array("url"),
"created" => array("created"), "created" => array("created"),
) )
); );
$database["parsed_url"] = array( $database["parsed_url"] = array(
"fields" => array( "fields" => array(
"url" => array("type" => "varchar(255)", "not null" => "1", "primary" => "1"), "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
"guessing" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"), "guessing" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
"oembed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"), "oembed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
"content" => array("type" => "text"), "content" => array("type" => "text"),
"created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
), ),
"indexes" => array( "indexes" => array(
"PRIMARY" => array("url".db_index_suffix($charset), "guessing", "oembed"), "PRIMARY" => array("url", "guessing", "oembed"),
"created" => array("created"), "created" => array("created"),
) )
); );
@ -1098,13 +1119,13 @@ function db_definition($charset) {
"fields" => array( "fields" => array(
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
"cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
"k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
"v" => array("type" => "mediumtext"), "v" => array("type" => "mediumtext"),
), ),
"indexes" => array( "indexes" => array(
"PRIMARY" => array("id"), "PRIMARY" => array("id"),
"uid_cat_k" => array("UNIQUE", "uid","cat(30)","k(30)"), "uid_cat_k" => array("UNIQUE", "uid", "cat", "k"),
) )
); );
$database["photo"] = array( $database["photo"] = array(
@ -1176,7 +1197,7 @@ function db_definition($charset) {
$database["process"] = array( $database["process"] = array(
"fields" => array( "fields" => array(
"pid" => array("type" => "int(10) unsigned", "not null" => "1", "primary" => "1"), "pid" => array("type" => "int(10) unsigned", "not null" => "1", "primary" => "1"),
"command" => array("type" => "varchar(32)", "not null" => "1", "default" => ""), "command" => array("type" => "varbinary(32)", "not null" => "1", "default" => ""),
"created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
), ),
"indexes" => array( "indexes" => array(
@ -1310,7 +1331,7 @@ function db_definition($charset) {
$database["session"] = array( $database["session"] = array(
"fields" => array( "fields" => array(
"id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
"sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "sid" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
"data" => array("type" => "text"), "data" => array("type" => "text"),
"expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"), "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
), ),
@ -1573,9 +1594,6 @@ function dbstructure_run(&$argv, &$argc) {
echo "dumpsql dump database schema\n"; echo "dumpsql dump database schema\n";
return; return;
} }
if (array_search(__file__,get_included_files())===0){ if (array_search(__file__,get_included_files())===0){

View file

@ -323,7 +323,7 @@ function delivery_run(&$argv, &$argc){
// perform local delivery if we are on the same site // 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']); $nickname = basename($contact['url']);
if ($contact['issued-id']) if ($contact['issued-id'])
@ -508,7 +508,7 @@ function delivery_run(&$argv, &$argc){
break; break;
if ($mail) { if ($mail) {
diaspora::send_mail($item,$owner,$contact); Diaspora::send_mail($item,$owner,$contact);
break; break;
} }
@ -518,34 +518,25 @@ function delivery_run(&$argv, &$argc){
if (!$contact['pubkey'] && !$public_message) if (!$contact['pubkey'] && !$public_message)
break; break;
$unsupported_activities = array(ACTIVITY_DISLIKE, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE);
//don't transmit activities which are not supported by diaspora
foreach($unsupported_activities as $act) {
if (activity_match($target_item['verb'],$act)) {
break 2;
}
}
if (($target_item['deleted']) && (($target_item['uri'] === $target_item['parent-uri']) || $followup)) { if (($target_item['deleted']) && (($target_item['uri'] === $target_item['parent-uri']) || $followup)) {
// top-level retraction // top-level retraction
logger('diaspora retract: '.$loc); logger('diaspora retract: '.$loc);
diaspora::send_retraction($target_item,$owner,$contact,$public_message); Diaspora::send_retraction($target_item,$owner,$contact,$public_message);
break; break;
} elseif ($followup) { } elseif ($followup) {
// send comments and likes to owner to relay // send comments and likes to owner to relay
logger('diaspora followup: '.$loc); logger('diaspora followup: '.$loc);
diaspora::send_followup($target_item,$owner,$contact,$public_message); Diaspora::send_followup($target_item,$owner,$contact,$public_message);
break; break;
} elseif ($target_item['uri'] !== $target_item['parent-uri']) { } elseif ($target_item['uri'] !== $target_item['parent-uri']) {
// we are the relay - send comments, likes and relayable_retractions to our conversants // we are the relay - send comments, likes and relayable_retractions to our conversants
logger('diaspora relay: '.$loc); logger('diaspora relay: '.$loc);
diaspora::send_relay($target_item,$owner,$contact,$public_message); Diaspora::send_relay($target_item,$owner,$contact,$public_message);
break; break;
} elseif ($top_level && !$walltowall) { } elseif ($top_level && !$walltowall) {
// currently no workable solution for sending walltowall // currently no workable solution for sending walltowall
logger('diaspora status: '.$loc); logger('diaspora status: '.$loc);
diaspora::send_status($target_item,$owner,$contact,$public_message); Diaspora::send_status($target_item,$owner,$contact,$public_message);
break; break;
} }

View file

@ -105,8 +105,9 @@ class dfrn {
dbesc($owner_nick) dbesc($owner_nick)
); );
if(! dbm::is_result($r)) if (! dbm::is_result($r)) {
killme(); killme();
}
$owner = $r[0]; $owner = $r[0];
$owner_id = $owner['uid']; $owner_id = $owner['uid'];
@ -139,8 +140,9 @@ class dfrn {
intval($owner_id) intval($owner_id)
); );
if(! dbm::is_result($r)) if (! dbm::is_result($r)) {
killme(); killme();
}
$contact = $r[0]; $contact = $r[0];
require_once('include/security.php'); require_once('include/security.php');

File diff suppressed because it is too large Load diff

View file

@ -96,24 +96,30 @@ function email_get_msg($mbox,$uid, $reply) {
$html = ''; $html = '';
foreach($struc->parts as $ptop => $p) { foreach($struc->parts as $ptop => $p) {
$x = email_get_part($mbox,$uid,$p,$ptop + 1, 'plain'); $x = email_get_part($mbox,$uid,$p,$ptop + 1, 'plain');
if($x) $text .= $x; if ($x) {
$text .= $x;
}
$x = email_get_part($mbox,$uid,$p,$ptop + 1, 'html'); $x = email_get_part($mbox,$uid,$p,$ptop + 1, 'html');
if($x) $html .= $x; if ($x) {
$html .= $x;
} }
if (trim($html) != '') }
if (trim($html) != '') {
$ret['body'] = html2bbcode($html); $ret['body'] = html2bbcode($html);
else } else {
$ret['body'] = $text; $ret['body'] = $text;
} }
}
$ret['body'] = removegpg($ret['body']); $ret['body'] = removegpg($ret['body']);
$msg = removesig($ret['body']); $msg = removesig($ret['body']);
$ret['body'] = $msg['body']; $ret['body'] = $msg['body'];
$ret['body'] = convertquote($ret['body'], $reply); $ret['body'] = convertquote($ret['body'], $reply);
if (trim($html) != '') if (trim($html) != '') {
$ret['body'] = removelinebreak($ret['body']); $ret['body'] = removelinebreak($ret['body']);
}
$ret['body'] = unifyattributionline($ret['body']); $ret['body'] = unifyattributionline($ret['body']);
@ -189,8 +195,9 @@ function email_get_part($mbox,$uid,$p,$partno, $subtype) {
$x = ""; $x = "";
foreach ($p->parts as $partno0=>$p2) { foreach ($p->parts as $partno0=>$p2) {
$x .= email_get_part($mbox,$uid,$p2,$partno . '.' . ($partno0+1), $subtype); // 1.2, 1.2.1, etc. $x .= email_get_part($mbox,$uid,$p2,$partno . '.' . ($partno0+1), $subtype); // 1.2, 1.2.1, etc.
//if($x) //if ($x) {
// return $x; // return $x;
//}
} }
return $x; return $x;
} }

View file

@ -23,7 +23,7 @@ function notification($params) {
$banner = t('Friendica Notification'); $banner = t('Friendica Notification');
$product = FRIENDICA_PLATFORM; $product = FRIENDICA_PLATFORM;
$siteurl = $a->get_baseurl(true); $siteurl = App::get_baseurl(true);
$thanks = t('Thank You,'); $thanks = t('Thank You,');
$sitename = $a->config['sitename']; $sitename = $a->config['sitename'];
if (!x($a->config['admin_name'])) if (!x($a->config['admin_name']))
@ -58,7 +58,7 @@ function notification($params) {
$additional_mail_header .= "X-Friendica-Platform: ".FRIENDICA_PLATFORM."\n"; $additional_mail_header .= "X-Friendica-Platform: ".FRIENDICA_PLATFORM."\n";
$additional_mail_header .= "X-Friendica-Version: ".FRIENDICA_VERSION."\n"; $additional_mail_header .= "X-Friendica-Version: ".FRIENDICA_VERSION."\n";
$additional_mail_header .= "List-ID: <notification.".$hostname.">\n"; $additional_mail_header .= "List-ID: <notification.".$hostname.">\n";
$additional_mail_header .= "List-Archive: <".$a->get_baseurl()."/notifications/system>\n"; $additional_mail_header .= "List-Archive: <".App::get_baseurl()."/notifications/system>\n";
if (array_key_exists('item', $params)) { if (array_key_exists('item', $params)) {
$title = $params['item']['title']; $title = $params['item']['title'];
@ -494,7 +494,7 @@ function notification($params) {
} }
$itemlink = $a->get_baseurl().'/notify/view/'.$notify_id; $itemlink = App::get_baseurl().'/notify/view/'.$notify_id;
$msg = replace_macros($epreamble, array('$itemlink' => $itemlink)); $msg = replace_macros($epreamble, array('$itemlink' => $itemlink));
$msg_cache = format_notification_message($datarray['name_cache'], strip_tags(bbcode($msg))); $msg_cache = format_notification_message($datarray['name_cache'], strip_tags(bbcode($msg)));
$r = q("UPDATE `notify` SET `msg` = '%s', `msg_cache` = '%s' WHERE `id` = %d AND `uid` = %d", $r = q("UPDATE `notify` SET `msg` = '%s', `msg_cache` = '%s' WHERE `id` = %d AND `uid` = %d",
@ -648,8 +648,6 @@ function notification($params) {
* @param str $defaulttype (Optional) Forces a notification with this type. * @param str $defaulttype (Optional) Forces a notification with this type.
*/ */
function check_item_notification($itemid, $uid, $defaulttype = "") { function check_item_notification($itemid, $uid, $defaulttype = "") {
$a = get_app();
$notification_data = array("uid" => $uid, "profiles" => array()); $notification_data = array("uid" => $uid, "profiles" => array());
call_hooks('check_item_notification', $notification_data); call_hooks('check_item_notification', $notification_data);
@ -667,7 +665,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
$profiles[] = $owner[0]["url"]; $profiles[] = $owner[0]["url"];
// Notifications from Diaspora are often with an URL in the Diaspora format // Notifications from Diaspora are often with an URL in the Diaspora format
$profiles[] = $a->get_baseurl()."/u/".$user[0]["nickname"]; $profiles[] = App::get_baseurl()."/u/".$user[0]["nickname"];
$profiles2 = array(); $profiles2 = array();

View file

@ -246,6 +246,7 @@ function event_store($arr) {
$arr['cid'] = ((intval($arr['cid'])) ? intval($arr['cid']) : 0); $arr['cid'] = ((intval($arr['cid'])) ? intval($arr['cid']) : 0);
$arr['uri'] = (x($arr,'uri') ? $arr['uri'] : item_new_uri($a->get_hostname(),$arr['uid'])); $arr['uri'] = (x($arr,'uri') ? $arr['uri'] : item_new_uri($a->get_hostname(),$arr['uid']));
$arr['private'] = ((x($arr,'private')) ? intval($arr['private']) : 0); $arr['private'] = ((x($arr,'private')) ? intval($arr['private']) : 0);
$arr['guid'] = get_guid(32);
if($arr['cid']) if($arr['cid'])
$c = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", $c = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
@ -333,16 +334,16 @@ function event_store($arr) {
call_hooks("event_updated", $arr['id']); call_hooks("event_updated", $arr['id']);
return $item_id; return $item_id;
} } else {
else {
// New event. Store it. // New event. Store it.
$r = q("INSERT INTO `event` ( `uid`,`cid`,`uri`,`created`,`edited`,`start`,`finish`,`summary`, `desc`,`location`,`type`, $r = q("INSERT INTO `event` (`uid`,`cid`,`guid`,`uri`,`created`,`edited`,`start`,`finish`,`summary`, `desc`,`location`,`type`,
`adjust`,`nofinish`,`allow_cid`,`allow_gid`,`deny_cid`,`deny_gid`) `adjust`,`nofinish`,`allow_cid`,`allow_gid`,`deny_cid`,`deny_gid`)
VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', '%s', '%s' ) ", VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', '%s', '%s' ) ",
intval($arr['uid']), intval($arr['uid']),
intval($arr['cid']), intval($arr['cid']),
dbesc($arr['guid']),
dbesc($arr['uri']), dbesc($arr['uri']),
dbesc($arr['created']), dbesc($arr['created']),
dbesc($arr['edited']), dbesc($arr['edited']),
@ -408,7 +409,7 @@ function event_store($arr) {
intval($arr['uid']) intval($arr['uid'])
); );
//if (dbm::is_result($r)) //if (dbm::is_result($r))
// $plink = $a->get_baseurl() . '/display/' . $r[0]['nickname'] . '/' . $item_id; // $plink = App::get_baseurl() . '/display/' . $r[0]['nickname'] . '/' . $item_id;
if($item_id) { if($item_id) {

View file

@ -40,7 +40,7 @@ function expire_run(&$argv, &$argc){
$r = q("SELECT `uid`,`username`,`expire` FROM `user` WHERE `expire` != 0"); $r = q("SELECT `uid`,`username`,`expire` FROM `user` WHERE `expire` != 0");
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) { foreach ($r as $rr) {
logger('Expire: ' . $rr['username'] . ' interval: ' . $rr['expire'], LOGGER_DEBUG); logger('Expire: ' . $rr['username'] . ' interval: ' . $rr['expire'], LOGGER_DEBUG);
item_expire($rr['uid'],$rr['expire']); item_expire($rr['uid'],$rr['expire']);
} }

View file

@ -77,12 +77,12 @@ function new_contact($uid,$url,$interactive = false) {
$url = str_replace('/#!/','/',$url); $url = str_replace('/#!/','/',$url);
if(! allowed_url($url)) { if (! allowed_url($url)) {
$result['message'] = t('Disallowed profile URL.'); $result['message'] = t('Disallowed profile URL.');
return $result; return $result;
} }
if(! $url) { if (! $url) {
$result['message'] = t('Connect URL missing.'); $result['message'] = t('Connect URL missing.');
return $result; return $result;
} }
@ -91,17 +91,21 @@ function new_contact($uid,$url,$interactive = false) {
call_hooks('follow', $arr); call_hooks('follow', $arr);
if(x($arr['contact'],'name')) if (x($arr['contact'],'name')) {
$ret = $arr['contact']; $ret = $arr['contact'];
else }
else {
$ret = probe_url($url); $ret = probe_url($url);
}
if($ret['network'] === NETWORK_DFRN) { if ($ret['network'] === NETWORK_DFRN) {
if($interactive) { if ($interactive) {
if(strlen($a->path)) if (strlen($a->path)) {
$myaddr = bin2hex($a->get_baseurl() . '/profile/' . $a->user['nickname']); $myaddr = bin2hex(App::get_baseurl() . '/profile/' . $a->user['nickname']);
else }
else {
$myaddr = bin2hex($a->user['nickname'] . '@' . $a->get_hostname()); $myaddr = bin2hex($a->user['nickname'] . '@' . $a->get_hostname());
}
goaway($ret['request'] . "&addr=$myaddr"); goaway($ret['request'] . "&addr=$myaddr");
@ -254,7 +258,7 @@ function new_contact($uid,$url,$interactive = false) {
intval($uid) intval($uid)
); );
if(! dbm::is_result($r)) { if (! dbm::is_result($r)) {
$result['message'] .= t('Unable to retrieve contact information.') . EOL; $result['message'] .= t('Unable to retrieve contact information.') . EOL;
return $result; return $result;
} }
@ -289,8 +293,9 @@ function new_contact($uid,$url,$interactive = false) {
$slap = ostatus::salmon($item, $r[0]); $slap = ostatus::salmon($item, $r[0]);
slapper($r[0], $contact['notify'], $slap); slapper($r[0], $contact['notify'], $slap);
} }
if ($contact['network'] == NETWORK_DIASPORA) { if ($contact['network'] == NETWORK_DIASPORA) {
$ret = diaspora::send_share($a->user,$contact); $ret = Diaspora::send_share($a->user,$contact);
logger('share returns: '.$ret); logger('share returns: '.$ret);
} }
} }

View file

@ -53,7 +53,7 @@ function group_rmv($uid,$name) {
$r = q("SELECT def_gid, allow_gid, deny_gid FROM user WHERE uid = %d LIMIT 1", $r = q("SELECT def_gid, allow_gid, deny_gid FROM user WHERE uid = %d LIMIT 1",
intval($uid) intval($uid)
); );
if($r) { if ($r) {
$user_info = $r[0]; $user_info = $r[0];
$change = false; $change = false;
@ -143,13 +143,14 @@ function group_add_member($uid,$name,$member,$gid = 0) {
return true; // You might question this, but return true; // You might question this, but
// we indicate success because the group member was in fact created // we indicate success because the group member was in fact created
// -- It was just created at another time // -- It was just created at another time
if(! dbm::is_result($r)) if (! dbm::is_result($r)) {
$r = q("INSERT INTO `group_member` (`uid`, `gid`, `contact-id`) $r = q("INSERT INTO `group_member` (`uid`, `gid`, `contact-id`)
VALUES( %d, %d, %d ) ", VALUES( %d, %d, %d ) ",
intval($uid), intval($uid),
intval($gid), intval($gid),
intval($member) intval($member)
); );
}
return $r; return $r;
} }
@ -198,7 +199,7 @@ function mini_group_select($uid,$gid = 0, $label = "") {
); );
$grps[] = array('name' => '', 'id' => '0', 'selected' => ''); $grps[] = array('name' => '', 'id' => '0', 'selected' => '');
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) { foreach ($r as $rr) {
$grps[] = array('name' => $rr['name'], 'id' => $rr['id'], 'selected' => (($gid == $rr['id']) ? 'true' : '')); $grps[] = array('name' => $rr['name'], 'id' => $rr['id'], 'selected' => (($gid == $rr['id']) ? 'true' : ''));
} }
@ -233,7 +234,7 @@ function group_side($every="contacts",$each="group",$editmode = "standard", $gro
$o = ''; $o = '';
if(! local_user()) if (! local_user())
return ''; return '';
$groups = array(); $groups = array();
@ -256,7 +257,7 @@ function group_side($every="contacts",$each="group",$editmode = "standard", $gro
} }
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) { foreach ($r as $rr) {
$selected = (($group_id == $rr['id']) ? ' group-selected' : ''); $selected = (($group_id == $rr['id']) ? ' group-selected' : '');
if ($editmode == "full") { if ($editmode == "full") {

View file

@ -229,13 +229,16 @@ function profile_sidebar($profile, $block = 0) {
// Is the local user already connected to that user? // Is the local user already connected to that user?
if ($connect AND local_user()) { if ($connect AND local_user()) {
if (isset($profile["url"])) if (isset($profile["url"])) {
$profile_url = normalise_link($profile["url"]); $profile_url = normalise_link($profile["url"]);
else }
$profile_url = normalise_link($a->get_baseurl()."/profile/".$profile["nickname"]); else {
$profile_url = normalise_link(App::get_baseurl()."/profile/".$profile["nickname"]);
}
$r = q("SELECT * FROM `contact` WHERE NOT `pending` AND `uid` = %d AND `nurl` = '%s'", $r = q("SELECT * FROM `contact` WHERE NOT `pending` AND `uid` = %d AND `nurl` = '%s'",
local_user(), $profile_url); local_user(), $profile_url);
if (dbm::is_result($r)) if (dbm::is_result($r))
$connect = false; $connect = false;
} }
@ -279,7 +282,7 @@ function profile_sidebar($profile, $block = 0) {
// show edit profile to yourself // show edit profile to yourself
if ($profile['uid'] == local_user() && feature_enabled(local_user(),'multi_profiles')) { if ($profile['uid'] == local_user() && feature_enabled(local_user(),'multi_profiles')) {
$profile['edit'] = array($a->get_baseurl(). '/profiles', t('Profiles'),"", t('Manage/edit profiles')); $profile['edit'] = array(App::get_baseurl(). '/profiles', t('Profiles'),"", t('Manage/edit profiles'));
$r = q("SELECT * FROM `profile` WHERE `uid` = %d", $r = q("SELECT * FROM `profile` WHERE `uid` = %d",
local_user()); local_user());
@ -291,7 +294,7 @@ function profile_sidebar($profile, $block = 0) {
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) { foreach ($r as $rr) {
$profile['menu']['entries'][] = array( $profile['menu']['entries'][] = array(
'photo' => $rr['thumb'], 'photo' => $rr['thumb'],
'id' => $rr['id'], 'id' => $rr['id'],
@ -308,7 +311,7 @@ function profile_sidebar($profile, $block = 0) {
} }
} }
if ($profile['uid'] == local_user() && !feature_enabled(local_user(),'multi_profiles')) { if ($profile['uid'] == local_user() && !feature_enabled(local_user(),'multi_profiles')) {
$profile['edit'] = array($a->get_baseurl(). '/profiles/'.$profile['id'], t('Edit profile'),"", t('Edit profile')); $profile['edit'] = array(App::get_baseurl(). '/profiles/'.$profile['id'], t('Edit profile'),"", t('Edit profile'));
$profile['menu'] = array( $profile['menu'] = array(
'chg_photo' => t('Change profile photo'), 'chg_photo' => t('Change profile photo'),
'cr_new' => null, 'cr_new' => null,
@ -349,15 +352,15 @@ function profile_sidebar($profile, $block = 0) {
if ($profile['guid'] != "") if ($profile['guid'] != "")
$diaspora = array( $diaspora = array(
'guid' => $profile['guid'], 'guid' => $profile['guid'],
'podloc' => $a->get_baseurl(), 'podloc' => App::get_baseurl(),
'searchable' => (($profile['publish'] && $profile['net-publish']) ? 'true' : 'false' ), 'searchable' => (($profile['publish'] && $profile['net-publish']) ? 'true' : 'false' ),
'nickname' => $profile['nickname'], 'nickname' => $profile['nickname'],
'fullname' => $profile['name'], 'fullname' => $profile['name'],
'firstname' => $firstname, 'firstname' => $firstname,
'lastname' => $lastname, 'lastname' => $lastname,
'photo300' => $a->get_baseurl() . '/photo/custom/300/' . $profile['uid'] . '.jpg', 'photo300' => App::get_baseurl() . '/photo/custom/300/' . $profile['uid'] . '.jpg',
'photo100' => $a->get_baseurl() . '/photo/custom/100/' . $profile['uid'] . '.jpg', 'photo100' => App::get_baseurl() . '/photo/custom/100/' . $profile['uid'] . '.jpg',
'photo50' => $a->get_baseurl() . '/photo/custom/50/' . $profile['uid'] . '.jpg', 'photo50' => App::get_baseurl() . '/photo/custom/50/' . $profile['uid'] . '.jpg',
); );
else else
$diaspora = false; $diaspora = false;
@ -466,7 +469,7 @@ function get_birthdays() {
$cids = array(); $cids = array();
$istoday = false; $istoday = false;
foreach($r as $rr) { foreach ($r as $rr) {
if(strlen($rr['name'])) if(strlen($rr['name']))
$total ++; $total ++;
if((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now)) if((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now))
@ -489,7 +492,7 @@ function get_birthdays() {
$url = $rr['url']; $url = $rr['url'];
if($rr['network'] === NETWORK_DFRN) { if($rr['network'] === NETWORK_DFRN) {
$sparkle = " sparkle"; $sparkle = " sparkle";
$url = $a->get_baseurl() . '/redir/' . $rr['cid']; $url = App::get_baseurl() . '/redir/' . $rr['cid'];
} }
$rr['link'] = $url; $rr['link'] = $url;
@ -503,7 +506,7 @@ function get_birthdays() {
} }
$tpl = get_markup_template("birthdays_reminder.tpl"); $tpl = get_markup_template("birthdays_reminder.tpl");
return replace_macros($tpl, array( return replace_macros($tpl, array(
'$baseurl' => $a->get_baseurl(), '$baseurl' => App::get_baseurl(),
'$classtoday' => $classtoday, '$classtoday' => $classtoday,
'$count' => $total, '$count' => $total,
'$event_reminders' => t('Birthday Reminders'), '$event_reminders' => t('Birthday Reminders'),
@ -546,7 +549,7 @@ function get_events() {
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
$now = strtotime('now'); $now = strtotime('now');
$istoday = false; $istoday = false;
foreach($r as $rr) { foreach ($r as $rr) {
if(strlen($rr['name'])) if(strlen($rr['name']))
$total ++; $total ++;
@ -587,7 +590,7 @@ function get_events() {
$tpl = get_markup_template("events_reminder.tpl"); $tpl = get_markup_template("events_reminder.tpl");
return replace_macros($tpl, array( return replace_macros($tpl, array(
'$baseurl' => $a->get_baseurl(), '$baseurl' => App::get_baseurl(),
'$classtoday' => $classtoday, '$classtoday' => $classtoday,
'$count' => count($r) - $skip, '$count' => count($r) - $skip,
'$event_reminders' => t('Event Reminders'), '$event_reminders' => t('Event Reminders'),
@ -684,8 +687,9 @@ function advanced_profile(&$a) {
$profile['forumlist'] = array( t('Forums:'), ForumManager::profile_advanced($uid)); $profile['forumlist'] = array( t('Forums:'), ForumManager::profile_advanced($uid));
} }
if ($a->profile['uid'] == local_user()) if ($a->profile['uid'] == local_user()) {
$profile['edit'] = array($a->get_baseurl(). '/profiles/'.$a->profile['id'], t('Edit profile'),"", t('Edit profile')); $profile['edit'] = array(App::get_baseurl(). '/profiles/'.$a->profile['id'], t('Edit profile'),"", t('Edit profile'));
}
return replace_macros($tpl, array( return replace_macros($tpl, array(
'$title' => t('Profile'), '$title' => t('Profile'),
@ -707,7 +711,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
if(x($_GET,'tab')) if(x($_GET,'tab'))
$tab = notags(trim($_GET['tab'])); $tab = notags(trim($_GET['tab']));
$url = $a->get_baseurl() . '/profile/' . $nickname; $url = App::get_baseurl() . '/profile/' . $nickname;
$tabs = array( $tabs = array(
array( array(
@ -728,7 +732,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
), ),
array( array(
'label' => t('Photos'), 'label' => t('Photos'),
'url' => $a->get_baseurl() . '/photos/' . $nickname, 'url' => App::get_baseurl() . '/photos/' . $nickname,
'sel' => ((!isset($tab)&&$a->argv[0]=='photos')?'active':''), 'sel' => ((!isset($tab)&&$a->argv[0]=='photos')?'active':''),
'title' => t('Photo Albums'), 'title' => t('Photo Albums'),
'id' => 'photo-tab', 'id' => 'photo-tab',
@ -736,7 +740,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
), ),
array( array(
'label' => t('Videos'), 'label' => t('Videos'),
'url' => $a->get_baseurl() . '/videos/' . $nickname, 'url' => App::get_baseurl() . '/videos/' . $nickname,
'sel' => ((!isset($tab)&&$a->argv[0]=='videos')?'active':''), 'sel' => ((!isset($tab)&&$a->argv[0]=='videos')?'active':''),
'title' => t('Videos'), 'title' => t('Videos'),
'id' => 'video-tab', 'id' => 'video-tab',
@ -748,7 +752,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
if ($is_owner && $a->theme_events_in_profile) { if ($is_owner && $a->theme_events_in_profile) {
$tabs[] = array( $tabs[] = array(
'label' => t('Events'), 'label' => t('Events'),
'url' => $a->get_baseurl() . '/events', 'url' => App::get_baseurl() . '/events',
'sel' =>((!isset($tab)&&$a->argv[0]=='events')?'active':''), 'sel' =>((!isset($tab)&&$a->argv[0]=='events')?'active':''),
'title' => t('Events and Calendar'), 'title' => t('Events and Calendar'),
'id' => 'events-tab', 'id' => 'events-tab',
@ -759,7 +763,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
} elseif (! $is_owner) { } elseif (! $is_owner) {
$tabs[] = array( $tabs[] = array(
'label' => t('Events'), 'label' => t('Events'),
'url' => $a->get_baseurl() . '/cal/' . $nickname, 'url' => App::get_baseurl() . '/cal/' . $nickname,
'sel' =>((!isset($tab)&&$a->argv[0]=='cal')?'active':''), 'sel' =>((!isset($tab)&&$a->argv[0]=='cal')?'active':''),
'title' => t('Events and Calendar'), 'title' => t('Events and Calendar'),
'id' => 'events-tab', 'id' => 'events-tab',
@ -770,7 +774,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
if ($is_owner){ if ($is_owner){
$tabs[] = array( $tabs[] = array(
'label' => t('Personal Notes'), 'label' => t('Personal Notes'),
'url' => $a->get_baseurl() . '/notes', 'url' => App::get_baseurl() . '/notes',
'sel' =>((!isset($tab)&&$a->argv[0]=='notes')?'active':''), 'sel' =>((!isset($tab)&&$a->argv[0]=='notes')?'active':''),
'title' => t('Only You Can See This'), 'title' => t('Only You Can See This'),
'id' => 'notes-tab', 'id' => 'notes-tab',
@ -781,7 +785,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
if ((! $is_owner) && ((count($a->profile)) || (! $a->profile['hide-friends']))) { if ((! $is_owner) && ((count($a->profile)) || (! $a->profile['hide-friends']))) {
$tabs[] = array( $tabs[] = array(
'label' => t('Contacts'), 'label' => t('Contacts'),
'url' => $a->get_baseurl() . '/viewcontacts/' . $nickname, 'url' => App::get_baseurl() . '/viewcontacts/' . $nickname,
'sel' => ((!isset($tab)&&$a->argv[0]=='viewcontacts')?'active':''), 'sel' => ((!isset($tab)&&$a->argv[0]=='viewcontacts')?'active':''),
'title' => t('Contacts'), 'title' => t('Contacts'),
'id' => 'viewcontacts-tab', 'id' => 'viewcontacts-tab',

View file

@ -208,13 +208,12 @@ function add_page_info_data($data) {
$hashtags = ""; $hashtags = "";
if (isset($data["keywords"]) AND count($data["keywords"])) { if (isset($data["keywords"]) AND count($data["keywords"])) {
$a = get_app();
$hashtags = "\n"; $hashtags = "\n";
foreach ($data["keywords"] AS $keyword) { foreach ($data["keywords"] AS $keyword) {
/// @todo make a positive list of allowed characters /// @todo make a positive list of allowed characters
$hashtag = str_replace(array(" ", "+", "/", ".", "#", "'", "", "`", "(", ")", "", ""), $hashtag = str_replace(array(" ", "+", "/", ".", "#", "'", "", "`", "(", ")", "", ""),
array("","", "", "", "", "", "", "", "", "", "", ""), $keyword); array("","", "", "", "", "", "", "", "", "", "", ""), $keyword);
$hashtags .= "#[url=".$a->get_baseurl()."/search?tag=".rawurlencode($hashtag)."]".$hashtag."[/url] "; $hashtags .= "#[url=".App::get_baseurl()."/search?tag=".rawurlencode($hashtag)."]".$hashtag."[/url] ";
} }
} }
@ -251,7 +250,6 @@ function add_page_keywords($url, $no_photos = false, $photo = "", $keywords = fa
$tags = ""; $tags = "";
if (isset($data["keywords"]) AND count($data["keywords"])) { if (isset($data["keywords"]) AND count($data["keywords"])) {
$a = get_app();
foreach ($data["keywords"] AS $keyword) { foreach ($data["keywords"] AS $keyword) {
$hashtag = str_replace(array(" ", "+", "/", ".", "#", "'"), $hashtag = str_replace(array(" ", "+", "/", ".", "#", "'"),
array("","", "", "", "", ""), $keyword); array("","", "", "", "", ""), $keyword);
@ -259,7 +257,7 @@ function add_page_keywords($url, $no_photos = false, $photo = "", $keywords = fa
if ($tags != "") if ($tags != "")
$tags .= ","; $tags .= ",";
$tags .= "#[url=".$a->get_baseurl()."/search?tag=".rawurlencode($hashtag)."]".$hashtag."[/url]"; $tags .= "#[url=".App::get_baseurl()."/search?tag=".rawurlencode($hashtag)."]".$hashtag."[/url]";
} }
} }
@ -557,8 +555,7 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
logger("Both author-link and owner-link are empty. Called by: ".App::callstack(), LOGGER_DEBUG); logger("Both author-link and owner-link are empty. Called by: ".App::callstack(), LOGGER_DEBUG);
if ($arr['plink'] == "") { if ($arr['plink'] == "") {
$a = get_app(); $arr['plink'] = App::get_baseurl().'/display/'.urlencode($arr['guid']);
$arr['plink'] = $a->get_baseurl().'/display/'.urlencode($arr['guid']);
} }
if ($arr['network'] == "") { if ($arr['network'] == "") {
@ -709,7 +706,7 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
$u = q("SELECT `nickname` FROM `user` WHERE `uid` = %d", intval($arr['uid'])); $u = q("SELECT `nickname` FROM `user` WHERE `uid` = %d", intval($arr['uid']));
if (count($u)) { if (count($u)) {
$a = get_app(); $a = get_app();
$self = normalise_link($a->get_baseurl() . '/profile/' . $u[0]['nickname']); $self = normalise_link(App::get_baseurl() . '/profile/' . $u[0]['nickname']);
logger("item_store: 'myself' is ".$self." for parent ".$parent_id." checking against ".$arr['author-link']." and ".$arr['owner-link'], LOGGER_DEBUG); logger("item_store: 'myself' is ".$self." for parent ".$parent_id." checking against ".$arr['author-link']." and ".$arr['owner-link'], LOGGER_DEBUG);
if ((normalise_link($arr['author-link']) == $self) OR (normalise_link($arr['owner-link']) == $self)) { if ((normalise_link($arr['author-link']) == $self) OR (normalise_link($arr['owner-link']) == $self)) {
q("UPDATE `thread` SET `mention` = 1 WHERE `iid` = %d", intval($parent_id)); q("UPDATE `thread` SET `mention` = 1 WHERE `iid` = %d", intval($parent_id));
@ -1068,10 +1065,10 @@ function item_body_set_hashtags(&$item) {
// All hashtags should point to the home server // All hashtags should point to the home server
//$item["body"] = preg_replace("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", //$item["body"] = preg_replace("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
// "#[url=".$a->get_baseurl()."/search?tag=$2]$2[/url]", $item["body"]); // "#[url=".App::get_baseurl()."/search?tag=$2]$2[/url]", $item["body"]);
//$item["tag"] = preg_replace("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", //$item["tag"] = preg_replace("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
// "#[url=".$a->get_baseurl()."/search?tag=$2]$2[/url]", $item["tag"]); // "#[url=".App::get_baseurl()."/search?tag=$2]$2[/url]", $item["tag"]);
// mask hashtags inside of url, bookmarks and attachments to avoid urls in urls // mask hashtags inside of url, bookmarks and attachments to avoid urls in urls
$item["body"] = preg_replace_callback("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", $item["body"] = preg_replace_callback("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
@ -1103,7 +1100,7 @@ function item_body_set_hashtags(&$item) {
$basetag = str_replace('_',' ',substr($tag,1)); $basetag = str_replace('_',' ',substr($tag,1));
$newtag = '#[url='.$a->get_baseurl().'/search?tag='.rawurlencode($basetag).']'.$basetag.'[/url]'; $newtag = '#[url='.App::get_baseurl().'/search?tag='.rawurlencode($basetag).']'.$basetag.'[/url]';
$item["body"] = str_replace($tag, $newtag, $item["body"]); $item["body"] = str_replace($tag, $newtag, $item["body"]);
@ -1207,12 +1204,12 @@ function tag_deliver($uid,$item_id) {
$item = $i[0]; $item = $i[0];
$link = normalise_link($a->get_baseurl() . '/profile/' . $u[0]['nickname']); $link = normalise_link(App::get_baseurl() . '/profile/' . $u[0]['nickname']);
// Diaspora uses their own hardwired link URL in @-tags // Diaspora uses their own hardwired link URL in @-tags
// instead of the one we supply with webfinger // instead of the one we supply with webfinger
$dlink = normalise_link($a->get_baseurl() . '/u/' . $u[0]['nickname']); $dlink = normalise_link(App::get_baseurl() . '/u/' . $u[0]['nickname']);
$cnt = preg_match_all('/[\@\!]\[url\=(.*?)\](.*?)\[\/url\]/ism',$item['body'],$matches,PREG_SET_ORDER); $cnt = preg_match_all('/[\@\!]\[url\=(.*?)\](.*?)\[\/url\]/ism',$item['body'],$matches,PREG_SET_ORDER);
if ($cnt) { if ($cnt) {
@ -1260,8 +1257,9 @@ function tag_deliver($uid,$item_id) {
$c = q("select name, url, thumb from contact where self = 1 and uid = %d limit 1", $c = q("select name, url, thumb from contact where self = 1 and uid = %d limit 1",
intval($u[0]['uid']) intval($u[0]['uid'])
); );
if (! count($c)) if (! count($c)) {
return; return;
}
// also reset all the privacy bits to the forum default permissions // also reset all the privacy bits to the forum default permissions
@ -1269,8 +1267,8 @@ function tag_deliver($uid,$item_id) {
$forum_mode = (($prvgroup) ? 2 : 1); $forum_mode = (($prvgroup) ? 2 : 1);
q("update item set wall = 1, origin = 1, forum_mode = %d, `owner-name` = '%s', `owner-link` = '%s', `owner-avatar` = '%s', q("UPDATE `item` SET `wall` = 1, `origin` = 1, `forum_mode` = %d, `owner-name` = '%s', `owner-link` = '%s', `owner-avatar` = '%s',
`private` = %d, `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s' where id = %d", `private` = %d, `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s' WHERE `id` = %d",
intval($forum_mode), intval($forum_mode),
dbesc($c[0]['name']), dbesc($c[0]['name']),
dbesc($c[0]['url']), dbesc($c[0]['url']),
@ -1312,16 +1310,16 @@ function tgroup_check($uid,$item) {
$prvgroup = (($u[0]['page-flags'] == PAGE_PRVGROUP) ? true : false); $prvgroup = (($u[0]['page-flags'] == PAGE_PRVGROUP) ? true : false);
$link = normalise_link($a->get_baseurl() . '/profile/' . $u[0]['nickname']); $link = normalise_link(App::get_baseurl() . '/profile/' . $u[0]['nickname']);
// Diaspora uses their own hardwired link URL in @-tags // Diaspora uses their own hardwired link URL in @-tags
// instead of the one we supply with webfinger // instead of the one we supply with webfinger
$dlink = normalise_link($a->get_baseurl() . '/u/' . $u[0]['nickname']); $dlink = normalise_link(App::get_baseurl() . '/u/' . $u[0]['nickname']);
$cnt = preg_match_all('/[\@\!]\[url\=(.*?)\](.*?)\[\/url\]/ism',$item['body'],$matches,PREG_SET_ORDER); $cnt = preg_match_all('/[\@\!]\[url\=(.*?)\](.*?)\[\/url\]/ism',$item['body'],$matches,PREG_SET_ORDER);
if ($cnt) { if ($cnt) {
foreach($matches as $mtch) { foreach ($matches as $mtch) {
if (link_compare($link,$mtch[1]) || link_compare($dlink,$mtch[1])) { if (link_compare($link,$mtch[1]) || link_compare($dlink,$mtch[1])) {
$mention = true; $mention = true;
logger('tgroup_check: mention found: ' . $mtch[2]); logger('tgroup_check: mention found: ' . $mtch[2]);
@ -1329,13 +1327,12 @@ function tgroup_check($uid,$item) {
} }
} }
if (! $mention) if (! $mention) {
return false; return false;
}
if ((! $community_page) && (! $prvgroup)) /// @TODO Combines both return statements into one
return false; return (($community_page) || ($prvgroup));
return true;
} }
/* /*
@ -1353,6 +1350,7 @@ function edited_timestamp_is_newer($existing, $update) {
if (!x($update,'edited') || !$update['edited']) { if (!x($update,'edited') || !$update['edited']) {
return false; return false;
} }
$existing_edited = datetime_convert('UTC', 'UTC', $existing['edited']); $existing_edited = datetime_convert('UTC', 'UTC', $existing['edited']);
$update_edited = datetime_convert('UTC', 'UTC', $update['edited']); $update_edited = datetime_convert('UTC', 'UTC', $update['edited']);
return (strcmp($existing_edited, $update_edited) < 0); return (strcmp($existing_edited, $update_edited) < 0);
@ -1572,7 +1570,7 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
'to_name' => $r[0]['username'], 'to_name' => $r[0]['username'],
'to_email' => $r[0]['email'], 'to_email' => $r[0]['email'],
'uid' => $r[0]['uid'], 'uid' => $r[0]['uid'],
'link' => $a->get_baseurl() . '/notifications/intro', 'link' => App::get_baseurl() . '/notifications/intro',
'source_name' => ((strlen(stripslashes($contact_record['name']))) ? stripslashes($contact_record['name']) : t('[Name Withheld]')), 'source_name' => ((strlen(stripslashes($contact_record['name']))) ? stripslashes($contact_record['name']) : t('[Name Withheld]')),
'source_link' => $contact_record['url'], 'source_link' => $contact_record['url'],
'source_photo' => $contact_record['photo'], 'source_photo' => $contact_record['photo'],
@ -1665,7 +1663,7 @@ function fix_private_photos($s, $uid, $item = null, $cid = 0) {
$a = get_app(); $a = get_app();
logger('fix_private_photos: check for photos', LOGGER_DEBUG); logger('fix_private_photos: check for photos', LOGGER_DEBUG);
$site = substr($a->get_baseurl(),strpos($a->get_baseurl(),'://')); $site = substr(App::get_baseurl(),strpos(App::get_baseurl(),'://'));
$orig_body = $s; $orig_body = $s;
$new_body = ''; $new_body = '';
@ -1929,7 +1927,7 @@ function drop_item($id,$interactive = true) {
if (! $interactive) if (! $interactive)
return 0; return 0;
notice( t('Item not found.') . EOL); notice( t('Item not found.') . EOL);
goaway($a->get_baseurl() . '/' . $_SESSION['return_url']); goaway(App::get_baseurl() . '/' . $_SESSION['return_url']);
} }
$item = $r[0]; $item = $r[0];
@ -1977,7 +1975,7 @@ function drop_item($id,$interactive = true) {
} }
// Now check how the user responded to the confirmation query // Now check how the user responded to the confirmation query
if ($_REQUEST['canceled']) { if ($_REQUEST['canceled']) {
goaway($a->get_baseurl() . '/' . $_SESSION['return_url']); goaway(App::get_baseurl() . '/' . $_SESSION['return_url']);
} }
logger('delete item: ' . $item['id'], LOGGER_DEBUG); logger('delete item: ' . $item['id'], LOGGER_DEBUG);
@ -2127,13 +2125,13 @@ function drop_item($id,$interactive = true) {
if (! $interactive) if (! $interactive)
return $owner; return $owner;
goaway($a->get_baseurl() . '/' . $_SESSION['return_url']); goaway(App::get_baseurl() . '/' . $_SESSION['return_url']);
//NOTREACHED //NOTREACHED
} else { } else {
if (! $interactive) if (! $interactive)
return 0; return 0;
notice( t('Permission denied.') . EOL); notice( t('Permission denied.') . EOL);
goaway($a->get_baseurl() . '/' . $_SESSION['return_url']); goaway(App::get_baseurl() . '/' . $_SESSION['return_url']);
//NOTREACHED //NOTREACHED
} }

View file

@ -48,10 +48,8 @@ function do_like($item_id, $verb) {
break; break;
} }
logger('like: verb ' . $verb . ' item ' . $item_id); logger('like: verb ' . $verb . ' item ' . $item_id);
$r = q("SELECT * FROM `item` WHERE `id` = '%s' OR `uri` = '%s' LIMIT 1", $r = q("SELECT * FROM `item` WHERE `id` = '%s' OR `uri` = '%s' LIMIT 1",
dbesc($item_id), dbesc($item_id),
dbesc($item_id) dbesc($item_id)
@ -66,7 +64,7 @@ function do_like($item_id, $verb) {
$owner_uid = $item['uid']; $owner_uid = $item['uid'];
if(! can_write_wall($a,$owner_uid)) { if (! can_write_wall($a,$owner_uid)) {
return false; return false;
} }
@ -78,11 +76,13 @@ function do_like($item_id, $verb) {
intval($item['contact-id']), intval($item['contact-id']),
intval($item['uid']) intval($item['uid'])
); );
if(! dbm::is_result($r)) if (! dbm::is_result($r)) {
return false; return false;
if(! $r[0]['self']) }
if (! $r[0]['self']) {
$remote_owner = $r[0]; $remote_owner = $r[0];
} }
}
// this represents the post owner on this system. // this represents the post owner on this system.
@ -90,24 +90,24 @@ function do_like($item_id, $verb) {
WHERE `contact`.`self` = 1 AND `contact`.`uid` = %d LIMIT 1", WHERE `contact`.`self` = 1 AND `contact`.`uid` = %d LIMIT 1",
intval($owner_uid) intval($owner_uid)
); );
if (dbm::is_result($r)) if (dbm::is_result($r)) {
$owner = $r[0]; $owner = $r[0];
}
if(! $owner) { if (! $owner) {
logger('like: no owner'); logger('like: no owner');
return false; return false;
} }
if(! $remote_owner) if (! $remote_owner) {
$remote_owner = $owner; $remote_owner = $owner;
}
// This represents the person posting // This represents the person posting
if((local_user()) && (local_user() == $owner_uid)) { if ((local_user()) && (local_user() == $owner_uid)) {
$contact = $owner; $contact = $owner;
} } else {
else {
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($_SESSION['visitor_id']), intval($_SESSION['visitor_id']),
intval($owner_uid) intval($owner_uid)
@ -115,7 +115,7 @@ function do_like($item_id, $verb) {
if (dbm::is_result($r)) if (dbm::is_result($r))
$contact = $r[0]; $contact = $r[0];
} }
if(! $contact) { if (! $contact) {
return false; return false;
} }
@ -124,7 +124,7 @@ function do_like($item_id, $verb) {
// event participation are essentially radio toggles. If you make a subsequent choice, // event participation are essentially radio toggles. If you make a subsequent choice,
// we need to eradicate your first choice. // we need to eradicate your first choice.
if($activity === ACTIVITY_ATTEND || $activity === ACTIVITY_ATTENDNO || $activity === ACTIVITY_ATTENDMAYBE) { if ($activity === ACTIVITY_ATTEND || $activity === ACTIVITY_ATTENDNO || $activity === ACTIVITY_ATTENDMAYBE) {
$verbs = " '" . dbesc(ACTIVITY_ATTEND) . "','" . dbesc(ACTIVITY_ATTENDNO) . "','" . dbesc(ACTIVITY_ATTENDMAYBE) . "' "; $verbs = " '" . dbesc(ACTIVITY_ATTEND) . "','" . dbesc(ACTIVITY_ATTENDNO) . "','" . dbesc(ACTIVITY_ATTENDMAYBE) . "' ";
} }
@ -161,10 +161,11 @@ function do_like($item_id, $verb) {
$uri = item_new_uri($a->get_hostname(),$owner_uid); $uri = item_new_uri($a->get_hostname(),$owner_uid);
$post_type = (($item['resource-id']) ? t('photo') : t('status')); $post_type = (($item['resource-id']) ? t('photo') : t('status'));
if($item['object-type'] === ACTIVITY_OBJ_EVENT) if ($item['object-type'] === ACTIVITY_OBJ_EVENT) {
$post_type = t('event'); $post_type = t('event');
}
$objtype = (($item['resource-id']) ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE ); $objtype = (($item['resource-id']) ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE );
$link = xmlify('<link rel="alternate" type="text/html" href="' . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n") ; $link = xmlify('<link rel="alternate" type="text/html" href="' . App::get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n") ;
$body = $item['body']; $body = $item['body'];
$obj = <<< EOT $obj = <<< EOT
@ -178,20 +179,31 @@ function do_like($item_id, $verb) {
<content>$body</content> <content>$body</content>
</object> </object>
EOT; EOT;
if($verb === 'like') if ($verb === 'like') {
$bodyverb = t('%1$s likes %2$s\'s %3$s'); $bodyverb = t('%1$s likes %2$s\'s %3$s');
if($verb === 'dislike') }
if ($verb === 'dislike') {
$bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s'); $bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s');
if($verb === 'attendyes') }
if ($verb === 'attendyes') {
$bodyverb = t('%1$s is attending %2$s\'s %3$s'); $bodyverb = t('%1$s is attending %2$s\'s %3$s');
if($verb === 'attendno') }
if ($verb === 'attendno') {
$bodyverb = t('%1$s is not attending %2$s\'s %3$s'); $bodyverb = t('%1$s is not attending %2$s\'s %3$s');
if($verb === 'attendmaybe') }
if ($verb === 'attendmaybe') {
$bodyverb = t('%1$s may attend %2$s\'s %3$s'); $bodyverb = t('%1$s may attend %2$s\'s %3$s');
}
if(! isset($bodyverb)) if (! isset($bodyverb)) {
return false; return false;
}
$ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]';
$alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
$plink = '[url=' . App::get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]';
/// @TODO Or rewrite this to multi-line initialization of the array?
$arr = array(); $arr = array();
$arr['guid'] = get_guid(32); $arr['guid'] = get_guid(32);
@ -211,12 +223,7 @@ EOT;
$arr['author-name'] = $contact['name']; $arr['author-name'] = $contact['name'];
$arr['author-link'] = $contact['url']; $arr['author-link'] = $contact['url'];
$arr['author-avatar'] = $contact['thumb']; $arr['author-avatar'] = $contact['thumb'];
$ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]';
$alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
$plink = '[url=' . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]';
$arr['body'] = sprintf( $bodyverb, $ulink, $alink, $plink ); $arr['body'] = sprintf( $bodyverb, $ulink, $alink, $plink );
$arr['verb'] = $activity; $arr['verb'] = $activity;
$arr['object-type'] = $objtype; $arr['object-type'] = $objtype;
$arr['object'] = $obj; $arr['object'] = $obj;
@ -230,7 +237,7 @@ EOT;
$post_id = item_store($arr); $post_id = item_store($arr);
if(! $item['visible']) { if (! $item['visible']) {
$r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d", $r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d",
intval($item['id']), intval($item['id']),
intval($owner_uid) intval($owner_uid)
@ -239,7 +246,7 @@ EOT;
// Save the author information for the like in case we need to relay to Diaspora // Save the author information for the like in case we need to relay to Diaspora
diaspora::store_like_signature($contact, $post_id); Diaspora::store_like_signature($contact, $post_id);
$arr['id'] = $post_id; $arr['id'] = $post_id;

View file

@ -23,7 +23,8 @@ function lock_function($fn_name, $block = true, $wait_sec = 2, $timeout = 30) {
); );
$got_lock = true; $got_lock = true;
} }
elseif(! dbm::is_result($r)) { // the Boolean value for count($r) should be equivalent to the Boolean value of $r elseif (! dbm::is_result($r)) {
/// @TODO the Boolean value for count($r) should be equivalent to the Boolean value of $r
q("INSERT INTO `locks` (`name`, `created`, `locked`) VALUES ('%s', '%s', 1)", q("INSERT INTO `locks` (`name`, `created`, `locked`) VALUES ('%s', '%s', 1)",
dbesc($fn_name), dbesc($fn_name),
dbesc(datetime_convert()) dbesc(datetime_convert())

View file

@ -27,7 +27,7 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
} }
$guid = get_guid(32); $guid = get_guid(32);
$uri = 'urn:X-dfrn:' . $a->get_baseurl() . ':' . local_user() . ':' . $guid; $uri = 'urn:X-dfrn:' . App::get_baseurl() . ':' . local_user() . ':' . $guid;
$convid = 0; $convid = 0;
$reply = false; $reply = false;
@ -53,7 +53,7 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
$recip_host = substr($recip_host,0,strpos($recip_host,'/')); $recip_host = substr($recip_host,0,strpos($recip_host,'/'));
$recip_handle = (($contact[0]['addr']) ? $contact[0]['addr'] : $contact[0]['nick'] . '@' . $recip_host); $recip_handle = (($contact[0]['addr']) ? $contact[0]['addr'] : $contact[0]['nick'] . '@' . $recip_host);
$sender_handle = $a->user['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3); $sender_handle = $a->user['nickname'] . '@' . substr(App::get_baseurl(), strpos(App::get_baseurl(),'://') + 3);
$conv_guid = get_guid(32); $conv_guid = get_guid(32);
$convuri = $recip_handle.':'.$conv_guid; $convuri = $recip_handle.':'.$conv_guid;
@ -130,12 +130,13 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
$match = null; $match = null;
if(preg_match_all("/\[img\](.*?)\[\/img\]/",$body,$match)) { if (preg_match_all("/\[img\](.*?)\[\/img\]/",$body,$match)) {
$images = $match[1]; $images = $match[1];
if(count($images)) { if (count($images)) {
foreach($images as $image) { foreach ($images as $image) {
if(! stristr($image,$a->get_baseurl() . '/photo/')) if (! stristr($image,App::get_baseurl() . '/photo/')) {
continue; continue;
}
$image_uri = substr($image,strrpos($image,'/') + 1); $image_uri = substr($image,strrpos($image,'/') + 1);
$image_uri = substr($image_uri,0, strpos($image_uri,'-')); $image_uri = substr($image_uri,0, strpos($image_uri,'-'));
$r = q("UPDATE `photo` SET `allow_cid` = '%s' $r = q("UPDATE `photo` SET `allow_cid` = '%s'
@ -149,7 +150,7 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
} }
} }
if($post_id) { if ($post_id) {
proc_run(PRIORITY_HIGH, "include/notifier.php", "mail", $post_id); proc_run(PRIORITY_HIGH, "include/notifier.php", "mail", $post_id);
return intval($post_id); return intval($post_id);
} else { } else {
@ -158,22 +159,18 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
} }
function send_wallmessage($recipient='', $body='', $subject='', $replyto=''){ function send_wallmessage($recipient='', $body='', $subject='', $replyto=''){
$a = get_app(); if (! $recipient) {
return -1;
}
if (! strlen($subject)) {
if(! $recipient) return -1;
if(! strlen($subject))
$subject = t('[no subject]'); $subject = t('[no subject]');
}
$guid = get_guid(32); $guid = get_guid(32);
$uri = 'urn:X-dfrn:' . $a->get_baseurl() . ':' . local_user() . ':' . $guid; $uri = 'urn:X-dfrn:' . App::get_baseurl() . ':' . local_user() . ':' . $guid;
$convid = 0; $convid = 0;
$reply = false; $reply = false;
@ -182,12 +179,13 @@ function send_wallmessage($recipient='', $body='', $subject='', $replyto=''){
$me = probe_url($replyto); $me = probe_url($replyto);
if(! $me['name']) if (! $me['name']) {
return -2; return -2;
}
$conv_guid = get_guid(32); $conv_guid = get_guid(32);
$recip_handle = $recipient['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3); $recip_handle = $recipient['nickname'] . '@' . substr(App::get_baseurl(), strpos(App::get_baseurl(),'://') + 3);
$sender_nick = basename($replyto); $sender_nick = basename($replyto);
$sender_host = substr($replyto,strpos($replyto,'://')+3); $sender_host = substr($replyto,strpos($replyto,'://')+3);
@ -196,7 +194,7 @@ function send_wallmessage($recipient='', $body='', $subject='', $replyto=''){
$handles = $recip_handle . ';' . $sender_handle; $handles = $recip_handle . ';' . $sender_handle;
$r = q("insert into conv (uid,guid,creator,created,updated,subject,recips) values(%d, '%s', '%s', '%s', '%s', '%s', '%s') ", $r = q("INSERT INTO `conv` (`uid`,`guid`,`creator`,`created`,`updated`,`subject`,`recips`) values(%d, '%s', '%s', '%s', '%s', '%s', '%s') ",
intval($recipient['uid']), intval($recipient['uid']),
dbesc($conv_guid), dbesc($conv_guid),
dbesc($sender_handle), dbesc($sender_handle),
@ -206,18 +204,19 @@ function send_wallmessage($recipient='', $body='', $subject='', $replyto=''){
dbesc($handles) dbesc($handles)
); );
$r = q("select * from conv where guid = '%s' and uid = %d limit 1", $r = q("SELECT * FROM `conv` WHERE `guid` = '%s' AND `uid` = %d LIMIT 1",
dbesc($conv_guid), dbesc($conv_guid),
intval($recipient['uid']) intval($recipient['uid'])
); );
if (dbm::is_result($r))
$convid = $r[0]['id'];
if(! $convid) {
if (! dbm::is_result($r)) {
logger('send message: conversation not found.'); logger('send message: conversation not found.');
return -4; return -4;
} }
$convid = $r[0]['id'];
$r = q("INSERT INTO `mail` ( `uid`, `guid`, `convid`, `from-name`, `from-photo`, `from-url`, $r = q("INSERT INTO `mail` ( `uid`, `guid`, `convid`, `from-name`, `from-photo`, `from-url`,
`contact-id`, `title`, `body`, `seen`, `reply`, `replied`, `uri`, `parent-uri`, `created`, `unknown`) `contact-id`, `title`, `body`, `seen`, `reply`, `replied`, `uri`, `parent-uri`, `created`, `unknown`)
VALUES ( %d, '%s', %d, '%s', '%s', '%s', %d, '%s', '%s', %d, %d, %d, '%s', '%s', '%s', %d )", VALUES ( %d, '%s', %d, '%s', '%s', '%s', %d, '%s', '%s', %d, %d, %d, '%s', '%s', '%s', %d )",

View file

@ -28,7 +28,7 @@ function nav(&$a) {
$tpl = get_markup_template('nav.tpl'); $tpl = get_markup_template('nav.tpl');
$a->page['nav'] .= replace_macros($tpl, array( $a->page['nav'] .= replace_macros($tpl, array(
'$baseurl' => $a->get_baseurl(), '$baseurl' => App::get_baseurl(),
'$sitelocation' => $nav_info['sitelocation'], '$sitelocation' => $nav_info['sitelocation'],
'$nav' => $nav_info['nav'], '$nav' => $nav_info['nav'],
'$banner' => $nav_info['banner'], '$banner' => $nav_info['banner'],
@ -65,7 +65,7 @@ function nav_info(App $a)
$myident = ((is_array($a->user) && isset($a->user['nickname'])) ? $a->user['nickname'] . '@' : ''); $myident = ((is_array($a->user) && isset($a->user['nickname'])) ? $a->user['nickname'] . '@' : '');
$sitelocation = $myident . substr($a->get_baseurl($ssl_state), strpos($a->get_baseurl($ssl_state), '//') + 2 ); $sitelocation = $myident . substr(App::get_baseurl($ssl_state), strpos(App::get_baseurl($ssl_state), '//') + 2 );
// nav links: array of array('href', 'text', 'extra css classes', 'title') // nav links: array of array('href', 'text', 'extra css classes', 'title')
$nav = array(); $nav = array();

View file

@ -513,8 +513,6 @@ function allowed_email($email) {
function avatar_img($email) { function avatar_img($email) {
$a = get_app();
$avatar['size'] = 175; $avatar['size'] = 175;
$avatar['email'] = $email; $avatar['email'] = $email;
$avatar['url'] = ''; $avatar['url'] = '';
@ -522,8 +520,9 @@ function avatar_img($email) {
call_hooks('avatar_lookup', $avatar); call_hooks('avatar_lookup', $avatar);
if(! $avatar['success']) if (! $avatar['success']) {
$avatar['url'] = $a->get_baseurl() . '/images/person-175.jpg'; $avatar['url'] = App::get_baseurl() . '/images/person-175.jpg';
}
logger('Avatar: ' . $avatar['email'] . ' ' . $avatar['url'], LOGGER_DEBUG); logger('Avatar: ' . $avatar['email'] . ' ' . $avatar['url'], LOGGER_DEBUG);
return $avatar['url']; return $avatar['url'];
@ -569,7 +568,7 @@ function scale_external_images($srctext, $include_link = true, $scale_replace =
foreach($matches as $mtch) { foreach($matches as $mtch) {
logger('scale_external_image: ' . $mtch[1]); logger('scale_external_image: ' . $mtch[1]);
$hostname = str_replace('www.','',substr($a->get_baseurl(),strpos($a->get_baseurl(),'://')+3)); $hostname = str_replace('www.','',substr(App::get_baseurl(),strpos(App::get_baseurl(),'://')+3));
if(stristr($mtch[1],$hostname)) if(stristr($mtch[1],$hostname))
continue; continue;

View file

@ -210,8 +210,9 @@ function notifier_run(&$argv, &$argc){
intval($uid) intval($uid)
); );
if(! dbm::is_result($r)) if (! dbm::is_result($r)) {
return; return;
}
$owner = $r[0]; $owner = $r[0];
@ -557,7 +558,7 @@ function notifier_run(&$argv, &$argc){
if($slap && count($url_recipients) && ($public_message || $push_notify) && $normal_mode) { if($slap && count($url_recipients) && ($public_message || $push_notify) && $normal_mode) {
if(!get_config('system','dfrn_only')) { if(!get_config('system','dfrn_only')) {
foreach($url_recipients as $url) { foreach($url_recipients as $url) {
if($url) { if ($url) {
logger('notifier: urldelivery: ' . $url); logger('notifier: urldelivery: ' . $url);
$deliver_status = slapper($owner,$url,$slap); $deliver_status = slapper($owner,$url,$slap);
/// @TODO Redeliver/queue these items on failure, though there is no contact record /// @TODO Redeliver/queue these items on failure, though there is no contact record
@ -570,7 +571,7 @@ function notifier_run(&$argv, &$argc){
if($public_message) { if($public_message) {
if (!$followup) if (!$followup)
$r0 = diaspora::relay_list(); $r0 = Diaspora::relay_list();
else else
$r0 = array(); $r0 = array();
@ -597,7 +598,7 @@ function notifier_run(&$argv, &$argc){
// throw everything into the queue in case we get killed // throw everything into the queue in case we get killed
foreach($r as $rr) { foreach ($r as $rr) {
if((! $mail) && (! $fsuggest) && (! $followup)) { if((! $mail) && (! $fsuggest) && (! $followup)) {
q("INSERT INTO `deliverq` (`cmd`,`item`,`contact`) VALUES ('%s', %d, %d) q("INSERT INTO `deliverq` (`cmd`,`item`,`contact`) VALUES ('%s', %d, %d)
ON DUPLICATE KEY UPDATE `cmd` = '%s', `item` = %d, `contact` = %d", ON DUPLICATE KEY UPDATE `cmd` = '%s', `item` = %d, `contact` = %d",
@ -607,7 +608,7 @@ function notifier_run(&$argv, &$argc){
} }
} }
foreach($r as $rr) { foreach ($r as $rr) {
// except for Diaspora batch jobs // except for Diaspora batch jobs
// Don't deliver to folks who have already been delivered to // Don't deliver to folks who have already been delivered to
@ -649,7 +650,7 @@ function notifier_run(&$argv, &$argc){
} else { } else {
$params = 'hub.mode=publish&hub.url=' . urlencode( $a->get_baseurl() . '/dfrn_poll/' . $owner['nickname'] ); $params = 'hub.mode=publish&hub.url=' . urlencode( App::get_baseurl() . '/dfrn_poll/' . $owner['nickname'] );
post_url($h,$params); post_url($h,$params);
logger('publish for item '.$item_id.' ' . $h . ' ' . $params . ' returned ' . $a->get_curl_code()); logger('publish for item '.$item_id.' ' . $h . ' ' . $params . ' returned ' . $a->get_curl_code());
} }

View file

@ -148,7 +148,7 @@ class FKOAuth1 extends OAuthServer {
$_SESSION['mobile-theme'] = get_pconfig($record['uid'], 'system', 'mobile_theme'); $_SESSION['mobile-theme'] = get_pconfig($record['uid'], 'system', 'mobile_theme');
$_SESSION['authenticated'] = 1; $_SESSION['authenticated'] = 1;
$_SESSION['page_flags'] = $record['page-flags']; $_SESSION['page_flags'] = $record['page-flags'];
$_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $record['nickname']; $_SESSION['my_url'] = App::get_baseurl() . '/profile/' . $record['nickname'];
$_SESSION['addr'] = $_SERVER['REMOTE_ADDR']; $_SESSION['addr'] = $_SERVER['REMOTE_ADDR'];
$_SESSION["allow_api"] = true; $_SESSION["allow_api"] = true;

View file

@ -143,8 +143,9 @@ function onepoll_run(&$argv, &$argc){
$r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` INNER JOIN `user` on `contact`.`uid` = `user`.`uid` WHERE `user`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1", $r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` INNER JOIN `user` on `contact`.`uid` = `user`.`uid` WHERE `user`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1",
intval($importer_uid) intval($importer_uid)
); );
if(! dbm::is_result($r)) if (! dbm::is_result($r)) {
return; return;
}
$importer = $r[0]; $importer = $r[0];

View file

@ -596,21 +596,25 @@ class ostatus {
$last = get_config('system','ostatus_last_poll'); $last = get_config('system','ostatus_last_poll');
$poll_interval = intval(get_config('system','ostatus_poll_interval')); $poll_interval = intval(get_config('system','ostatus_poll_interval'));
if(! $poll_interval) if (!$poll_interval) {
$poll_interval = OSTATUS_DEFAULT_POLL_INTERVAL; $poll_interval = self::OSTATUS_DEFAULT_POLL_INTERVAL;
}
// Don't poll if the interval is set negative // Don't poll if the interval is set negative
if (($poll_interval < 0) AND !$override) if (($poll_interval < 0) AND !$override) {
return; return;
}
if (!$mentions) { if (!$mentions) {
$poll_timeframe = intval(get_config('system','ostatus_poll_timeframe')); $poll_timeframe = intval(get_config('system','ostatus_poll_timeframe'));
if (!$poll_timeframe) if (!$poll_timeframe) {
$poll_timeframe = OSTATUS_DEFAULT_POLL_TIMEFRAME; $poll_timeframe = self::OSTATUS_DEFAULT_POLL_TIMEFRAME;
}
} else { } else {
$poll_timeframe = intval(get_config('system','ostatus_poll_timeframe')); $poll_timeframe = intval(get_config('system','ostatus_poll_timeframe'));
if (!$poll_timeframe) if (!$poll_timeframe) {
$poll_timeframe = OSTATUS_DEFAULT_POLL_TIMEFRAME_MENTIONS; $poll_timeframe = self::OSTATUS_DEFAULT_POLL_TIMEFRAME_MENTIONS;
}
} }
@ -626,15 +630,16 @@ class ostatus {
$start = date("Y-m-d H:i:s", time() - ($poll_timeframe * 60)); $start = date("Y-m-d H:i:s", time() - ($poll_timeframe * 60));
if ($mentions) if ($mentions) {
$conversations = q("SELECT `term`.`oid`, `term`.`url`, `term`.`uid` FROM `term` $conversations = q("SELECT `term`.`oid`, `term`.`url`, `term`.`uid` FROM `term`
STRAIGHT_JOIN `thread` ON `thread`.`iid` = `term`.`oid` AND `thread`.`uid` = `term`.`uid` STRAIGHT_JOIN `thread` ON `thread`.`iid` = `term`.`oid` AND `thread`.`uid` = `term`.`uid`
WHERE `term`.`type` = 7 AND `term`.`term` > '%s' AND `thread`.`mention` WHERE `term`.`type` = 7 AND `term`.`term` > '%s' AND `thread`.`mention`
GROUP BY `term`.`url`, `term`.`uid` ORDER BY `term`.`term` DESC", dbesc($start)); GROUP BY `term`.`url`, `term`.`uid` ORDER BY `term`.`term` DESC", dbesc($start));
else } else {
$conversations = q("SELECT `oid`, `url`, `uid` FROM `term` $conversations = q("SELECT `oid`, `url`, `uid` FROM `term`
WHERE `type` = 7 AND `term` > '%s' WHERE `type` = 7 AND `term` > '%s'
GROUP BY `url`, `uid` ORDER BY `term` DESC", dbesc($start)); GROUP BY `url`, `uid` ORDER BY `term` DESC", dbesc($start));
}
foreach ($conversations AS $conversation) { foreach ($conversations AS $conversation) {
self::completion($conversation['url'], $conversation['uid']); self::completion($conversation['url'], $conversation['uid']);

View file

@ -187,8 +187,9 @@ function load_hooks() {
$a = get_app(); $a = get_app();
$a->hooks = array(); $a->hooks = array();
$r = q("SELECT * FROM `hook` WHERE 1 ORDER BY `priority` DESC, `file`"); $r = q("SELECT * FROM `hook` WHERE 1 ORDER BY `priority` DESC, `file`");
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) { foreach ($r as $rr) {
if(! array_key_exists($rr['hook'],$a->hooks)) if(! array_key_exists($rr['hook'],$a->hooks))
$a->hooks[$rr['hook']] = array(); $a->hooks[$rr['hook']] = array();
$a->hooks[$rr['hook']][] = array($rr['file'],$rr['function']); $a->hooks[$rr['hook']][] = array($rr['file'],$rr['function']);
@ -410,13 +411,13 @@ function get_theme_info($theme){
* @return string * @return string
*/ */
function get_theme_screenshot($theme) { function get_theme_screenshot($theme) {
$a = get_app();
$exts = array('.png','.jpg'); $exts = array('.png','.jpg');
foreach($exts as $ext) { foreach($exts as $ext) {
if(file_exists('view/theme/' . $theme . '/screenshot' . $ext)) if(file_exists('view/theme/' . $theme . '/screenshot' . $ext)) {
return($a->get_baseurl() . '/view/theme/' . $theme . '/screenshot' . $ext); return(App::get_baseurl() . '/view/theme/' . $theme . '/screenshot' . $ext);
} }
return($a->get_baseurl() . '/images/blank.png'); }
return(App::get_baseurl() . '/images/blank.png');
} }
// install and uninstall theme // install and uninstall theme

View file

@ -484,7 +484,7 @@ function call_worker() {
return; return;
} }
$url = get_app()->get_baseurl()."/worker"; $url = App::get_baseurl()."/worker";
fetch_url($url, false, $redirects, 1); fetch_url($url, false, $redirects, 1);
} }

View file

@ -2,5 +2,5 @@
require_once('include/diaspora.php'); require_once('include/diaspora.php');
function profile_change() { function profile_change() {
diaspora::send_profile(local_user()); Diaspora::send_profile(local_user());
} }

View file

@ -21,7 +21,7 @@ function handle_pubsubhubbub($id) {
$headers = array("Content-type: application/atom+xml", $headers = array("Content-type: application/atom+xml",
sprintf("Link: <%s>;rel=hub,<%s>;rel=self", sprintf("Link: <%s>;rel=hub,<%s>;rel=self",
$a->get_baseurl().'/pubsubhubbub', App::get_baseurl().'/pubsubhubbub',
$rr['topic']), $rr['topic']),
"X-Hub-Signature: sha1=".$hmac_sig); "X-Hub-Signature: sha1=".$hmac_sig);
@ -76,16 +76,19 @@ function pubsubpublish_run(&$argv, &$argc){
load_config('system'); load_config('system');
// Don't check this stuff if the function is called by the poller // Don't check this stuff if the function is called by the poller
if (App::callstack() != "poller_run") if (App::callstack() != "poller_run") {
if (App::is_already_running("pubsubpublish", "include/pubsubpublish.php", 540)) if (App::is_already_running("pubsubpublish", "include/pubsubpublish.php", 540)) {
return; return;
}
}
$a->set_baseurl(get_config('system','url')); $a->set_baseurl(get_config('system','url'));
load_hooks(); load_hooks();
if($argc > 1) if ($argc > 1) {
$pubsubpublish_id = intval($argv[1]); $pubsubpublish_id = intval($argv[1]);
}
else { else {
// We'll push to each subscriber that has push > 0, // We'll push to each subscriber that has push > 0,
// i.e. there has been an update (set in notifier.php). // i.e. there has been an update (set in notifier.php).
@ -95,10 +98,11 @@ function pubsubpublish_run(&$argv, &$argc){
$interval = Config::get("system", "delivery_interval", 2); $interval = Config::get("system", "delivery_interval", 2);
// If we are using the worker we don't need a delivery interval // If we are using the worker we don't need a delivery interval
if (get_config("system", "worker")) if (get_config("system", "worker")) {
$interval = false; $interval = false;
}
foreach($r as $rr) { foreach ($r as $rr) {
logger("Publish feed to ".$rr["callback_url"], LOGGER_DEBUG); logger("Publish feed to ".$rr["callback_url"], LOGGER_DEBUG);
proc_run(PRIORITY_HIGH, 'include/pubsubpublish.php', $rr["id"]); proc_run(PRIORITY_HIGH, 'include/pubsubpublish.php', $rr["id"]);

View file

@ -58,20 +58,21 @@ function queue_run(&$argv, &$argc){
$interval = false; $interval = false;
$r = q("select * from deliverq where 1"); $r = q("select * from deliverq where 1");
if($r) { if ($r) {
foreach($r as $rr) { foreach ($r as $rr) {
logger('queue: deliverq'); logger('queue: deliverq');
proc_run(PRIORITY_HIGH,'include/delivery.php',$rr['cmd'],$rr['item'],$rr['contact']); proc_run(PRIORITY_HIGH,'include/delivery.php',$rr['cmd'],$rr['item'],$rr['contact']);
if($interval) if($interval) {
@time_sleep_until(microtime(true) + (float) $interval); time_sleep_until(microtime(true) + (float) $interval);
}
} }
} }
$r = q("SELECT `queue`.*, `contact`.`name`, `contact`.`uid` FROM `queue` $r = q("SELECT `queue`.*, `contact`.`name`, `contact`.`uid` FROM `queue`
INNER JOIN `contact` ON `queue`.`cid` = `contact`.`id` INNER JOIN `contact` ON `queue`.`cid` = `contact`.`id`
WHERE `queue`.`created` < UTC_TIMESTAMP() - INTERVAL 3 DAY"); WHERE `queue`.`created` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
if($r) { if ($r) {
foreach($r as $rr) { foreach ($r as $rr) {
logger('Removing expired queue item for ' . $rr['name'] . ', uid=' . $rr['uid']); logger('Removing expired queue item for ' . $rr['name'] . ', uid=' . $rr['uid']);
logger('Expired queue data :' . $rr['content'], LOGGER_DATA); logger('Expired queue data :' . $rr['content'], LOGGER_DATA);
} }
@ -195,7 +196,7 @@ function queue_run(&$argv, &$argc){
case NETWORK_DIASPORA: case NETWORK_DIASPORA:
if($contact['notify']) { if($contact['notify']) {
logger('queue: diaspora_delivery: item '.$q_item['id'].' for '.$contact['name'].' <'.$contact['url'].'>'); logger('queue: diaspora_delivery: item '.$q_item['id'].' for '.$contact['name'].' <'.$contact['url'].'>');
$deliver_status = diaspora::transmit($owner,$contact,$data,$public,true); $deliver_status = Diaspora::transmit($owner,$contact,$data,$public,true);
if($deliver_status == (-1)) { if($deliver_status == (-1)) {
update_queue_time($q_item['id']); update_queue_time($q_item['id']);

View file

@ -20,7 +20,7 @@ function auto_redir(&$a, $contact_nick) {
// //
// We also have to make sure that I'm a legitimate contact--I'm not blocked or pending. // We also have to make sure that I'm a legitimate contact--I'm not blocked or pending.
$baseurl = $a->get_baseurl(); $baseurl = App::get_baseurl();
$domain_st = strpos($baseurl, "://"); $domain_st = strpos($baseurl, "://");
if($domain_st === false) if($domain_st === false)
return; return;
@ -36,9 +36,9 @@ function auto_redir(&$a, $contact_nick) {
dbesc($nurl) dbesc($nurl)
); );
if((! dbm::is_result($r)) || $r[0]['id'] == remote_user()) if ((! dbm::is_result($r)) || $r[0]['id'] == remote_user()) {
return; return;
}
$r = q("SELECT * FROM contact WHERE nick = '%s' $r = q("SELECT * FROM contact WHERE nick = '%s'
AND network = '%s' AND uid = %d AND url LIKE '%%%s%%' LIMIT 1", AND network = '%s' AND uid = %d AND url LIKE '%%%s%%' LIMIT 1",
@ -48,8 +48,9 @@ function auto_redir(&$a, $contact_nick) {
dbesc($baseurl) dbesc($baseurl)
); );
if(! dbm::is_result($r)) if (! dbm::is_result($r)) {
return; return;
}
$cid = $r[0]['id']; $cid = $r[0]['id'];

View file

@ -24,22 +24,24 @@ function get_salmon_key($uri,$keyhash) {
// We have found at least one key URL // We have found at least one key URL
// If it's inline, parse it - otherwise get the key // If it's inline, parse it - otherwise get the key
if(count($ret)) { if (count($ret) > 0) {
for($x = 0; $x < count($ret); $x ++) { for ($x = 0; $x < count($ret); $x ++) {
if(substr($ret[$x],0,5) === 'data:') { if (substr($ret[$x],0,5) === 'data:') {
if(strstr($ret[$x],',')) if (strstr($ret[$x],',')) {
$ret[$x] = substr($ret[$x],strpos($ret[$x],',')+1); $ret[$x] = substr($ret[$x],strpos($ret[$x],',')+1);
else } else {
$ret[$x] = substr($ret[$x],5); $ret[$x] = substr($ret[$x],5);
} elseif (normalise_link($ret[$x]) == 'http://') }
} elseif (normalise_link($ret[$x]) == 'http://') {
$ret[$x] = fetch_url($ret[$x]); $ret[$x] = fetch_url($ret[$x]);
} }
} }
}
logger('Key located: ' . print_r($ret,true)); logger('Key located: ' . print_r($ret,true));
if(count($ret) == 1) { if (count($ret) == 1) {
// We only found one one key so we don't care if the hash matches. // We only found one one key so we don't care if the hash matches.
// If it's the wrong key we'll find out soon enough because // If it's the wrong key we'll find out soon enough because
@ -50,12 +52,13 @@ function get_salmon_key($uri,$keyhash) {
return $ret[0]; return $ret[0];
} }
else { else {
foreach($ret as $a) { foreach ($ret as $a) {
$hash = base64url_encode(hash('sha256',$a)); $hash = base64url_encode(hash('sha256',$a));
if($hash == $keyhash) if ($hash == $keyhash) {
return $a; return $a;
} }
} }
}
return ''; return '';
} }

View file

@ -9,8 +9,8 @@ function authenticate_success($user_record, $login_initial = false, $interactive
$_SESSION['mobile-theme'] = get_pconfig($user_record['uid'], 'system', 'mobile_theme'); $_SESSION['mobile-theme'] = get_pconfig($user_record['uid'], 'system', 'mobile_theme');
$_SESSION['authenticated'] = 1; $_SESSION['authenticated'] = 1;
$_SESSION['page_flags'] = $user_record['page-flags']; $_SESSION['page_flags'] = $user_record['page-flags'];
$_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $user_record['nickname']; $_SESSION['my_url'] = App::get_baseurl() . '/profile/' . $user_record['nickname'];
$_SESSION['my_address'] = $user_record['nickname'] . '@' . substr($a->get_baseurl(),strpos($a->get_baseurl(),'://')+3); $_SESSION['my_address'] = $user_record['nickname'] . '@' . substr(App::get_baseurl(),strpos(App::get_baseurl(),'://')+3);
$_SESSION['addr'] = $_SERVER['REMOTE_ADDR']; $_SESSION['addr'] = $_SERVER['REMOTE_ADDR'];
$a->user = $user_record; $a->user = $user_record;
@ -94,11 +94,12 @@ function authenticate_success($user_record, $login_initial = false, $interactive
} }
if($login_initial) { if ($login_initial) {
call_hooks('logged_in', $a->user); call_hooks('logged_in', $a->user);
if(($a->module !== 'home') && isset($_SESSION['return_url'])) if (($a->module !== 'home') && isset($_SESSION['return_url'])) {
goaway($a->get_baseurl() . '/' . $_SESSION['return_url']); goaway(App::get_baseurl() . '/' . $_SESSION['return_url']);
}
} }
} }
@ -109,16 +110,17 @@ function can_write_wall(&$a,$owner) {
static $verified = 0; static $verified = 0;
if((! (local_user())) && (! (remote_user()))) if ((! (local_user())) && (! (remote_user()))) {
return false; return false;
}
$uid = local_user(); $uid = local_user();
if(($uid) && ($uid == $owner)) { if (($uid) && ($uid == $owner)) {
return true; return true;
} }
if(remote_user()) { if (remote_user()) {
// use remembered decision and avoid a DB lookup for each and every display item // use remembered decision and avoid a DB lookup for each and every display item
// DO NOT use this function if there are going to be multiple owners // DO NOT use this function if there are going to be multiple owners
@ -126,25 +128,25 @@ function can_write_wall(&$a,$owner) {
// We have a contact-id for an authenticated remote user, this block determines if the contact // We have a contact-id for an authenticated remote user, this block determines if the contact
// belongs to this page owner, and has the necessary permissions to post content // belongs to this page owner, and has the necessary permissions to post content
if($verified === 2) if ($verified === 2) {
return true; return true;
elseif($verified === 1) } elseif ($verified === 1) {
return false; return false;
else { } else {
$cid = 0; $cid = 0;
if(is_array($_SESSION['remote'])) { if (is_array($_SESSION['remote'])) {
foreach($_SESSION['remote'] as $visitor) { foreach ($_SESSION['remote'] as $visitor) {
if($visitor['uid'] == $owner) { if ($visitor['uid'] == $owner) {
$cid = $visitor['cid']; $cid = $visitor['cid'];
break; break;
} }
} }
} }
if(! $cid) if (! $cid) {
return false; return false;
}
$r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` INNER JOIN `user` on `user`.`uid` = `contact`.`uid` $r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` INNER JOIN `user` on `user`.`uid` = `contact`.`uid`
WHERE `contact`.`uid` = %d AND `contact`.`id` = %d AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 WHERE `contact`.`uid` = %d AND `contact`.`id` = %d AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
@ -378,7 +380,7 @@ function check_form_security_token_redirectOnErr($err_redirect, $typename = '',
logger('check_form_security_token failed: user ' . $a->user['guid'] . ' - form element ' . $typename); logger('check_form_security_token failed: user ' . $a->user['guid'] . ' - form element ' . $typename);
logger('check_form_security_token failed: _REQUEST data: ' . print_r($_REQUEST, true), LOGGER_DATA); logger('check_form_security_token failed: _REQUEST data: ' . print_r($_REQUEST, true), LOGGER_DATA);
notice( check_form_security_std_err_msg() ); notice( check_form_security_std_err_msg() );
goaway($a->get_baseurl() . $err_redirect ); goaway(App::get_baseurl() . $err_redirect );
} }
} }
function check_form_security_token_ForbiddenOnErr($typename = '', $formname = 'form_security_token') { function check_form_security_token_ForbiddenOnErr($typename = '', $formname = 'form_security_token') {

View file

@ -91,50 +91,58 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
$name = $entry->displayName; $name = $entry->displayName;
if(isset($entry->urls)) { if (isset($entry->urls)) {
foreach($entry->urls as $url) { foreach ($entry->urls as $url) {
if($url->type == 'profile') { if ($url->type == 'profile') {
$profile_url = $url->value; $profile_url = $url->value;
continue; continue;
} }
if($url->type == 'webfinger') { if ($url->type == 'webfinger') {
$connect_url = str_replace('acct:' , '', $url->value); $connect_url = str_replace('acct:' , '', $url->value);
continue; continue;
} }
} }
} }
if(isset($entry->photos)) { if (isset($entry->photos)) {
foreach($entry->photos as $photo) { foreach ($entry->photos as $photo) {
if($photo->type == 'profile') { if ($photo->type == 'profile') {
$profile_photo = $photo->value; $profile_photo = $photo->value;
continue; continue;
} }
} }
} }
if(isset($entry->updated)) if (isset($entry->updated)) {
$updated = date("Y-m-d H:i:s", strtotime($entry->updated)); $updated = date("Y-m-d H:i:s", strtotime($entry->updated));
}
if(isset($entry->network)) if (isset($entry->network)) {
$network = $entry->network; $network = $entry->network;
}
if(isset($entry->currentLocation)) if (isset($entry->currentLocation)) {
$location = $entry->currentLocation; $location = $entry->currentLocation;
}
if(isset($entry->aboutMe)) if (isset($entry->aboutMe)) {
$about = html2bbcode($entry->aboutMe); $about = html2bbcode($entry->aboutMe);
}
if(isset($entry->gender)) if (isset($entry->gender)) {
$gender = $entry->gender; $gender = $entry->gender;
}
if(isset($entry->generation) AND ($entry->generation > 0)) if (isset($entry->generation) AND ($entry->generation > 0)) {
$generation = ++$entry->generation; $generation = ++$entry->generation;
}
if(isset($entry->tags)) if (isset($entry->tags)) {
foreach($entry->tags as $tag) foreach($entry->tags as $tag) {
$keywords = implode(", ", $tag); $keywords = implode(", ", $tag);
}
}
if(isset($entry->contactType) AND ($entry->contactType >= 0)) if (isset($entry->contactType) AND ($entry->contactType >= 0))
$contact_type = $entry->contactType; $contact_type = $entry->contactType;
// If you query a Friendica server for its profiles, the network has to be Friendica // If you query a Friendica server for its profiles, the network has to be Friendica
@ -171,8 +179,6 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
function poco_check($profile_url, $name, $network, $profile_photo, $about, $location, $gender, $keywords, $connect_url, $updated, $generation, $cid = 0, $uid = 0, $zcid = 0) { function poco_check($profile_url, $name, $network, $profile_photo, $about, $location, $gender, $keywords, $connect_url, $updated, $generation, $cid = 0, $uid = 0, $zcid = 0) {
$a = get_app();
// Generation: // Generation:
// 0: No definition // 0: No definition
// 1: Profiles on this server // 1: Profiles on this server
@ -207,8 +213,9 @@ function poco_check($profile_url, $name, $network, $profile_photo, $about, $loca
$orig_updated = $updated; $orig_updated = $updated;
// The global contacts should contain the original picture, not the cached one // The global contacts should contain the original picture, not the cached one
if (($generation != 1) AND stristr(normalise_link($profile_photo), normalise_link($a->get_baseurl()."/photo/"))) if (($generation != 1) AND stristr(normalise_link($profile_photo), normalise_link(App::get_baseurl()."/photo/"))) {
$profile_photo = ""; $profile_photo = "";
}
$r = q("SELECT `network` FROM `contact` WHERE `nurl` = '%s' AND `network` != '' AND `network` != '%s' LIMIT 1", $r = q("SELECT `network` FROM `contact` WHERE `nurl` = '%s' AND `network` != '' AND `network` != '%s' LIMIT 1",
dbesc(normalise_link($profile_url)), dbesc(NETWORK_STATUSNET) dbesc(normalise_link($profile_url)), dbesc(NETWORK_STATUSNET)
@ -330,7 +337,7 @@ function poco_check($profile_url, $name, $network, $profile_photo, $about, $loca
intval($gcid), intval($gcid),
intval($zcid) intval($zcid)
); );
if(! dbm::is_result($r)) { if (! dbm::is_result($r)) {
q("INSERT INTO `glink` (`cid`,`uid`,`gcid`,`zcid`, `updated`) VALUES (%d,%d,%d,%d, '%s') ", q("INSERT INTO `glink` (`cid`,`uid`,`gcid`,`zcid`, `updated`) VALUES (%d,%d,%d,%d, '%s') ",
intval($cid), intval($cid),
intval($uid), intval($uid),
@ -1180,27 +1187,28 @@ function update_suggestions() {
$done = array(); $done = array();
/// TODO Check if it is really neccessary to poll the own server /// @TODO Check if it is really neccessary to poll the own server
poco_load(0,0,0,$a->get_baseurl() . '/poco'); poco_load(0,0,0,App::get_baseurl() . '/poco');
$done[] = $a->get_baseurl() . '/poco'; $done[] = App::get_baseurl() . '/poco';
if(strlen(get_config('system','directory'))) { if (strlen(get_config('system','directory'))) {
$x = fetch_url(get_server()."/pubsites"); $x = fetch_url(get_server()."/pubsites");
if($x) { if ($x) {
$j = json_decode($x); $j = json_decode($x);
if($j->entries) { if ($j->entries) {
foreach($j->entries as $entry) { foreach ($j->entries as $entry) {
poco_check_server($entry->url); poco_check_server($entry->url);
$url = $entry->url . '/poco'; $url = $entry->url . '/poco';
if(! in_array($url,$done)) if (! in_array($url,$done)) {
poco_load(0,0,0,$entry->url . '/poco'); poco_load(0,0,0,$entry->url . '/poco');
} }
} }
} }
} }
}
// Query your contacts from Friendica and Redmatrix/Hubzilla for their contacts // Query your contacts from Friendica and Redmatrix/Hubzilla for their contacts
$r = q("SELECT DISTINCT(`poco`) AS `poco` FROM `contact` WHERE `network` IN ('%s', '%s')", $r = q("SELECT DISTINCT(`poco`) AS `poco` FROM `contact` WHERE `network` IN ('%s', '%s')",
@ -1208,7 +1216,7 @@ function update_suggestions() {
); );
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) { foreach ($r as $rr) {
$base = substr($rr['poco'],0,strrpos($rr['poco'],'/')); $base = substr($rr['poco'],0,strrpos($rr['poco'],'/'));
if(! in_array($base,$done)) if(! in_array($base,$done))
poco_load(0,0,0,$base); poco_load(0,0,0,$base);
@ -1219,7 +1227,7 @@ function update_suggestions() {
function poco_discover_federation() { function poco_discover_federation() {
$last = get_config('poco','last_federation_discovery'); $last = get_config('poco','last_federation_discovery');
if($last) { if ($last) {
$next = $last + (24 * 60 * 60); $next = $last + (24 * 60 * 60);
if($next > time()) if($next > time())
return; return;
@ -1333,7 +1341,7 @@ function poco_discover_server_users($data, $server) {
$username = ""; $username = "";
if (isset($entry->urls)) { if (isset($entry->urls)) {
foreach($entry->urls as $url) foreach($entry->urls as $url)
if($url->type == 'profile') { if ($url->type == 'profile') {
$profile_url = $url->value; $profile_url = $url->value;
$urlparts = parse_url($profile_url); $urlparts = parse_url($profile_url);
$username = end(explode("/", $urlparts["path"])); $username = end(explode("/", $urlparts["path"]));
@ -1375,52 +1383,61 @@ function poco_discover_server($data, $default_generation = 0) {
$name = $entry->displayName; $name = $entry->displayName;
if(isset($entry->urls)) { if (isset($entry->urls)) {
foreach($entry->urls as $url) { foreach($entry->urls as $url) {
if($url->type == 'profile') { if ($url->type == 'profile') {
$profile_url = $url->value; $profile_url = $url->value;
continue; continue;
} }
if($url->type == 'webfinger') { if ($url->type == 'webfinger') {
$connect_url = str_replace('acct:' , '', $url->value); $connect_url = str_replace('acct:' , '', $url->value);
continue; continue;
} }
} }
} }
if(isset($entry->photos)) { if (isset($entry->photos)) {
foreach($entry->photos as $photo) { foreach ($entry->photos as $photo) {
if($photo->type == 'profile') { if ($photo->type == 'profile') {
$profile_photo = $photo->value; $profile_photo = $photo->value;
continue; continue;
} }
} }
} }
if(isset($entry->updated)) if (isset($entry->updated)) {
$updated = date("Y-m-d H:i:s", strtotime($entry->updated)); $updated = date("Y-m-d H:i:s", strtotime($entry->updated));
}
if(isset($entry->network)) if(isset($entry->network)) {
$network = $entry->network; $network = $entry->network;
}
if(isset($entry->currentLocation)) if(isset($entry->currentLocation)) {
$location = $entry->currentLocation; $location = $entry->currentLocation;
}
if(isset($entry->aboutMe)) if(isset($entry->aboutMe)) {
$about = html2bbcode($entry->aboutMe); $about = html2bbcode($entry->aboutMe);
}
if(isset($entry->gender)) if(isset($entry->gender)) {
$gender = $entry->gender; $gender = $entry->gender;
}
if(isset($entry->generation) AND ($entry->generation > 0)) if(isset($entry->generation) AND ($entry->generation > 0)) {
$generation = ++$entry->generation; $generation = ++$entry->generation;
}
if(isset($entry->contactType) AND ($entry->contactType >= 0)) if(isset($entry->contactType) AND ($entry->contactType >= 0)) {
$contact_type = $entry->contactType; $contact_type = $entry->contactType;
}
if(isset($entry->tags)) if(isset($entry->tags)) {
foreach($entry->tags as $tag) foreach ($entry->tags as $tag) {
$keywords = implode(", ", $tag); $keywords = implode(", ", $tag);
}
}
if ($generation > 0) { if ($generation > 0) {
$success = true; $success = true;
@ -1771,8 +1788,6 @@ function gs_fetch_users($server) {
logger("Fetching users from GNU Social server ".$server, LOGGER_DEBUG); logger("Fetching users from GNU Social server ".$server, LOGGER_DEBUG);
$a = get_app();
$url = $server."/main/statistics"; $url = $server."/main/statistics";
$result = z_fetch_url($url); $result = z_fetch_url($url);
@ -1811,7 +1826,7 @@ function gs_fetch_users($server) {
"nick" => $user->nickname, "nick" => $user->nickname,
"about" => $user->bio, "about" => $user->bio,
"network" => NETWORK_OSTATUS, "network" => NETWORK_OSTATUS,
"photo" => $a->get_baseurl()."/images/person-175.jpg"); "photo" => App::get_baseurl()."/images/person-175.jpg");
get_gcontact_id($contact); get_gcontact_id($contact);
} }
} }

View file

@ -1,13 +1,11 @@
<?php <?php
function create_tags_from_item($itemid) { function create_tags_from_item($itemid) {
$a = get_app(); $profile_base = App::get_baseurl();
$profile_base = $a->get_baseurl();
$profile_data = parse_url($profile_base); $profile_data = parse_url($profile_base);
$profile_base_friendica = $profile_data['host'].$profile_data['path']."/profile/"; $profile_base_friendica = $profile_data['host'].$profile_data['path']."/profile/";
$profile_base_diaspora = $profile_data['host'].$profile_data['path']."/u/"; $profile_base_diaspora = $profile_data['host'].$profile_data['path']."/u/";
$searchpath = $a->get_baseurl()."/search?tag="; $searchpath = App::get_baseurl()."/search?tag=";
$messages = q("SELECT `guid`, `uid`, `id`, `edited`, `deleted`, `created`, `received`, `title`, `body`, `tag`, `parent` FROM `item` WHERE `id` = %d LIMIT 1", intval($itemid)); $messages = q("SELECT `guid`, `uid`, `id`, `edited`, `deleted`, `created`, `received`, `title`, `body`, `tag`, `parent` FROM `item` WHERE `id` = %d LIMIT 1", intval($itemid));

View file

@ -23,7 +23,7 @@ function replace_macros($s,$r) {
$a = get_app(); $a = get_app();
// pass $baseurl to all templates // pass $baseurl to all templates
$r['$baseurl'] = $a->get_baseurl(); $r['$baseurl'] = App::get_baseurl();
$t = $a->template_engine(); $t = $a->template_engine();
@ -912,7 +912,7 @@ function contact_block() {
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
$contacts = sprintf( tt('%d Contact','%d Contacts', $total),$total); $contacts = sprintf( tt('%d Contact','%d Contacts', $total),$total);
$micropro = Array(); $micropro = Array();
foreach($r as $rr) { foreach ($r as $rr) {
$micropro[] = micropro($rr,true,'mpfriend'); $micropro[] = micropro($rr,true,'mpfriend');
} }
} }
@ -1367,7 +1367,7 @@ function prepare_body(&$item,$attach = false, $preview = false) {
// map // map
if(strpos($s,'<div class="map">') !== false && $item['coord']) { if(strpos($s,'<div class="map">') !== false && $item['coord']) {
$x = generate_map(trim($item['coord'])); $x = generate_map(trim($item['coord']));
if($x) { if ($x) {
$s = preg_replace('/\<div class\=\"map\"\>/','$0' . $x,$s); $s = preg_replace('/\<div class\=\"map\"\>/','$0' . $x,$s);
} }
} }
@ -1717,7 +1717,7 @@ function bb_translate_video($s) {
$matches = null; $matches = null;
$r = preg_match_all("/\[video\](.*?)\[\/video\]/ism",$s,$matches,PREG_SET_ORDER); $r = preg_match_all("/\[video\](.*?)\[\/video\]/ism",$s,$matches,PREG_SET_ORDER);
if($r) { if ($r) {
foreach($matches as $mtch) { foreach($matches as $mtch) {
if((stristr($mtch[1],'youtube')) || (stristr($mtch[1],'youtu.be'))) if((stristr($mtch[1],'youtube')) || (stristr($mtch[1],'youtu.be')))
$s = str_replace($mtch[0],'[youtube]' . $mtch[1] . '[/youtube]',$s); $s = str_replace($mtch[0],'[youtube]' . $mtch[1] . '[/youtube]',$s);
@ -2000,8 +2000,9 @@ function file_tag_unsave_file($uid,$item,$file,$cat = false) {
intval($item), intval($item),
intval($uid) intval($uid)
); );
if(! dbm::is_result($r)) if (! dbm::is_result($r)) {
return false; return false;
}
q("UPDATE `item` SET `file` = '%s' WHERE `id` = %d AND `uid` = %d", q("UPDATE `item` SET `file` = '%s' WHERE `id` = %d AND `uid` = %d",
dbesc(str_replace($pattern,'',$r[0]['file'])), dbesc(str_replace($pattern,'',$r[0]['file'])),
@ -2020,11 +2021,11 @@ function file_tag_unsave_file($uid,$item,$file,$cat = false) {
//$r = q("select file from item where uid = %d and deleted = 0 " . file_tag_file_query('item',$file,(($cat) ? 'category' : 'file')), //$r = q("select file from item where uid = %d and deleted = 0 " . file_tag_file_query('item',$file,(($cat) ? 'category' : 'file')),
//); //);
if(! dbm::is_result($r)) { if (! dbm::is_result($r)) {
$saved = get_pconfig($uid,'system','filetags'); $saved = get_pconfig($uid,'system','filetags');
set_pconfig($uid,'system','filetags',str_replace($pattern,'',$saved)); set_pconfig($uid,'system','filetags',str_replace($pattern,'',$saved));
} }
return true; return true;
} }

View file

@ -267,12 +267,10 @@ function update_threads() {
} }
function update_threads_mention() { function update_threads_mention() {
$a = get_app();
$users = q("SELECT `uid`, `nickname` FROM `user` ORDER BY `uid`"); $users = q("SELECT `uid`, `nickname` FROM `user` ORDER BY `uid`");
foreach ($users AS $user) { foreach ($users AS $user) {
$self = normalise_link($a->get_baseurl() . '/profile/' . $user['nickname']); $self = normalise_link(App::get_baseurl() . '/profile/' . $user['nickname']);
$selfhttps = str_replace("http://", "https://", $self); $selfhttps = str_replace("http://", "https://", $self);
$parents = q("SELECT DISTINCT(`parent`) FROM `item` WHERE `uid` = %d AND $parents = q("SELECT DISTINCT(`parent`) FROM `item` WHERE `uid` = %d AND
((`owner-link` IN ('%s', '%s')) OR (`author-link` IN ('%s', '%s')))", ((`owner-link` IN ('%s', '%s')) OR (`author-link` IN ('%s', '%s')))",

View file

@ -133,7 +133,7 @@ function import_account(&$a, $file) {
} }
$oldbaseurl = $account['baseurl']; $oldbaseurl = $account['baseurl'];
$newbaseurl = $a->get_baseurl(); $newbaseurl = App::get_baseurl();
$olduid = $account['user']['uid']; $olduid = $account['user']['uid'];
unset($account['user']['uid']); unset($account['user']['uid']);
@ -290,5 +290,5 @@ function import_account(&$a, $file) {
proc_run(PRIORITY_HIGH, 'include/notifier.php', 'relocate', $newuid); proc_run(PRIORITY_HIGH, 'include/notifier.php', 'relocate', $newuid);
info(t("Done. You can now login with your username and password")); info(t("Done. You can now login with your username and password"));
goaway($a->get_baseurl() . "/login"); goaway(App::get_baseurl() . "/login");
} }

View file

@ -216,7 +216,7 @@ function create_user($arr) {
dbesc($default_service_class) dbesc($default_service_class)
); );
if($r) { if ($r) {
$r = q("SELECT * FROM `user` $r = q("SELECT * FROM `user`
WHERE `username` = '%s' AND `password` = '%s' LIMIT 1", WHERE `username` = '%s' AND `password` = '%s' LIMIT 1",
dbesc($username), dbesc($username),

View file

@ -60,15 +60,15 @@ if(!$install) {
if ($a->max_processes_reached() OR $a->maxload_reached()) { if ($a->max_processes_reached() OR $a->maxload_reached()) {
header($_SERVER["SERVER_PROTOCOL"].' 503 Service Temporarily Unavailable'); header($_SERVER["SERVER_PROTOCOL"].' 503 Service Temporarily Unavailable');
header('Retry-After: 120'); header('Retry-After: 120');
header('Refresh: 120; url='.$a->get_baseurl()."/".$a->query_string); header('Refresh: 120; url='.App::get_baseurl()."/".$a->query_string);
die("System is currently unavailable. Please try again later"); die("System is currently unavailable. Please try again later");
} }
if (get_config('system','force_ssl') AND ($a->get_scheme() == "http") AND if (get_config('system','force_ssl') AND ($a->get_scheme() == "http") AND
(intval(get_config('system','ssl_policy')) == SSL_POLICY_FULL) AND (intval(get_config('system','ssl_policy')) == SSL_POLICY_FULL) AND
(substr($a->get_baseurl(), 0, 8) == "https://")) { (substr(App::get_baseurl(), 0, 8) == "https://")) {
header("HTTP/1.1 302 Moved Temporarily"); header("HTTP/1.1 302 Moved Temporarily");
header("Location: ".$a->get_baseurl()."/".$a->query_string); header("Location: ".App::get_baseurl()."/".$a->query_string);
exit(); exit();
} }
@ -150,24 +150,28 @@ if((x($_GET,'zrl')) && (!$install && !$maintenance)) {
* *
*/ */
// header('Link: <' . $a->get_baseurl() . '/amcd>; rel="acct-mgmt";'); // header('Link: <' . App::get_baseurl() . '/amcd>; rel="acct-mgmt";');
if(x($_COOKIE["Friendica"]) || (x($_SESSION,'authenticated')) || (x($_POST,'auth-params')) || ($a->module === 'login')) if (x($_COOKIE["Friendica"]) || (x($_SESSION,'authenticated')) || (x($_POST,'auth-params')) || ($a->module === 'login')) {
require("include/auth.php"); require("include/auth.php");
}
if(! x($_SESSION,'authenticated')) if (! x($_SESSION,'authenticated')) {
header('X-Account-Management-Status: none'); header('X-Account-Management-Status: none');
}
/* set up page['htmlhead'] and page['end'] for the modules to use */ /* set up page['htmlhead'] and page['end'] for the modules to use */
$a->page['htmlhead'] = ''; $a->page['htmlhead'] = '';
$a->page['end'] = ''; $a->page['end'] = '';
if(! x($_SESSION,'sysmsg')) if (! x($_SESSION,'sysmsg')) {
$_SESSION['sysmsg'] = array(); $_SESSION['sysmsg'] = array();
}
if(! x($_SESSION,'sysmsg_info')) if (! x($_SESSION,'sysmsg_info')) {
$_SESSION['sysmsg_info'] = array(); $_SESSION['sysmsg_info'] = array();
}
/* /*
* check_config() is responsible for running update scripts. These automatically * check_config() is responsible for running update scripts. These automatically
@ -177,11 +181,11 @@ if(! x($_SESSION,'sysmsg_info'))
// in install mode, any url loads install module // in install mode, any url loads install module
// but we need "view" module for stylesheet // but we need "view" module for stylesheet
if($install && $a->module!="view") if ($install && $a->module!="view") {
$a->module = 'install'; $a->module = 'install';
elseif($maintenance && $a->module!="view") } elseif ($maintenance && $a->module!="view") {
$a->module = 'maintenance'; $a->module = 'maintenance';
else { } else {
check_url($a); check_url($a);
check_db(); check_db();
check_plugins($a); check_plugins($a);
@ -191,8 +195,7 @@ nav_set_selected('nothing');
//Don't populate apps_menu if apps are private //Don't populate apps_menu if apps are private
$privateapps = get_config('config','private_addons'); $privateapps = get_config('config','private_addons');
if((local_user()) || (! $privateapps === "1")) if ((local_user()) || (! $privateapps === "1")) {
{
$arr = array('app_menu' => $a->apps); $arr = array('app_menu' => $a->apps);
call_hooks('app_menu', $arr); call_hooks('app_menu', $arr);
@ -238,9 +241,9 @@ if(strlen($a->module)) {
$privateapps = get_config('config','private_addons'); $privateapps = get_config('config','private_addons');
if(is_array($a->plugins) && in_array($a->module,$a->plugins) && file_exists("addon/{$a->module}/{$a->module}.php")) { if (is_array($a->plugins) && in_array($a->module,$a->plugins) && file_exists("addon/{$a->module}/{$a->module}.php")) {
//Check if module is an app and if public access to apps is allowed or not //Check if module is an app and if public access to apps is allowed or not
if((!local_user()) && plugin_is_app($a->module) && $privateapps === "1") { if ((!local_user()) && plugin_is_app($a->module) && $privateapps === "1") {
info( t("You must be logged in to use addons. ")); info( t("You must be logged in to use addons. "));
} }
else { else {
@ -254,7 +257,7 @@ if(strlen($a->module)) {
* If not, next look for a 'standard' program module in the 'mod' directory * If not, next look for a 'standard' program module in the 'mod' directory
*/ */
if((! $a->module_loaded) && (file_exists("mod/{$a->module}.php"))) { if ((! $a->module_loaded) && (file_exists("mod/{$a->module}.php"))) {
include_once("mod/{$a->module}.php"); include_once("mod/{$a->module}.php");
$a->module_loaded = true; $a->module_loaded = true;
} }
@ -272,16 +275,16 @@ if(strlen($a->module)) {
* *
*/ */
if(! $a->module_loaded) { if (! $a->module_loaded) {
// Stupid browser tried to pre-fetch our Javascript img template. Don't log the event or return anything - just quietly exit. // Stupid browser tried to pre-fetch our Javascript img template. Don't log the event or return anything - just quietly exit.
if((x($_SERVER,'QUERY_STRING')) && preg_match('/{[0-9]}/',$_SERVER['QUERY_STRING']) !== 0) { if ((x($_SERVER,'QUERY_STRING')) && preg_match('/{[0-9]}/',$_SERVER['QUERY_STRING']) !== 0) {
killme(); killme();
} }
if((x($_SERVER,'QUERY_STRING')) && ($_SERVER['QUERY_STRING'] === 'q=internal_error.html') && isset($dreamhost_error_hack)) { if ((x($_SERVER,'QUERY_STRING')) && ($_SERVER['QUERY_STRING'] === 'q=internal_error.html') && isset($dreamhost_error_hack)) {
logger('index.php: dreamhost_error_hack invoked. Original URI =' . $_SERVER['REQUEST_URI']); logger('index.php: dreamhost_error_hack invoked. Original URI =' . $_SERVER['REQUEST_URI']);
goaway($a->get_baseurl() . $_SERVER['REQUEST_URI']); goaway(App::get_baseurl() . $_SERVER['REQUEST_URI']);
} }
logger('index.php: page not found: ' . $_SERVER['REQUEST_URI'] . ' ADDRESS: ' . $_SERVER['REMOTE_ADDR'] . ' QUERY: ' . $_SERVER['QUERY_STRING'], LOGGER_DEBUG); logger('index.php: page not found: ' . $_SERVER['REQUEST_URI'] . ' ADDRESS: ' . $_SERVER['REMOTE_ADDR'] . ' QUERY: ' . $_SERVER['QUERY_STRING'], LOGGER_DEBUG);
@ -304,11 +307,13 @@ if (file_exists($theme_info_file)){
/* initialise content region */ /* initialise content region */
if(! x($a->page,'content')) if (! x($a->page,'content')) {
$a->page['content'] = ''; $a->page['content'] = '';
}
if(!$install && !$maintenance) if (!$install && !$maintenance) {
call_hooks('page_content_top',$a->page['content']); call_hooks('page_content_top',$a->page['content']);
}
/** /**
* Call module functions * Call module functions

View file

@ -161,10 +161,12 @@
// fancyboxes // fancyboxes
$("a.popupbox").colorbox({ $("a.popupbox").colorbox({
'inline' : true, 'inline' : true,
'transition' : 'elastic' 'transition' : 'elastic',
'maxWidth' : '100%'
}); });
$("a.ajax-popupbox").colorbox({ $("a.ajax-popupbox").colorbox({
'transition' : 'elastic' 'transition' : 'elastic',
'maxWidth' : '100%'
}); });
/* notifications template */ /* notifications template */

View file

@ -52,16 +52,26 @@ It's cool, isn't it?
## Install ## Install
#### NPM
The best way to install and use perfect-scrollbar is with NPM. The best way to install and use perfect-scrollbar is with NPM.
It's registered on [npm](https://www.npmjs.org/package/perfect-scrollbar) as `perfect-scrollbar`. It's registered on [npm](https://www.npmjs.com/package/perfect-scrollbar) as `perfect-scrollbar`.
``` ```
$ npm install perfect-scrollbar $ npm install perfect-scrollbar
``` ```
#### Rails
In the case you would like to have perfect-scrollbar in your Rails application, there is the [perfect-scrollbar-rails gem](https://github.com/YourCursus/perfect-scrollbar-rails).
#### Manually
You can download the latest stable version with download links [here](http://noraesae.github.io/perfect-scrollbar/). You can download the latest stable version with download links [here](http://noraesae.github.io/perfect-scrollbar/).
You also can find all releases on [Releases](https://github.com/noraesae/perfect-scrollbar/releases). You also can find all releases on [Releases](https://github.com/noraesae/perfect-scrollbar/releases).
#### From sources
If you want to use the development version of the plugin, use the If you want to use the development version of the plugin, use the
source files which are not minified. They're in the `src` directory. source files which are not minified. They're in the `src` directory.
The development version may be unstable, but some known bugs may The development version may be unstable, but some known bugs may
@ -74,6 +84,7 @@ $ npm install
$ gulp # will lint and build the source code. $ gulp # will lint and build the source code.
``` ```
#### Bower
There is a Bower package for perfect-scrollbar as well. It is managed There is a Bower package for perfect-scrollbar as well. It is managed
under the [perfect-scrollbar-bower](https://github.com/noraesae/perfect-scrollbar-bower) under the [perfect-scrollbar-bower](https://github.com/noraesae/perfect-scrollbar-bower)
@ -83,27 +94,39 @@ repository. The plugin is registered as `perfect-scrollbar`.
$ bower install perfect-scrollbar $ bower install perfect-scrollbar
``` ```
#### CDNs
You can also load it from [cdnjs](http://cdnjs.com/). * [cdnjs](http://www.cdnjs.com/libraries/jquery.perfect-scrollbar)
It is registered as [`jquery.perfect-scrollbar`](http://www.cdnjs.com/libraries/jquery.perfect-scrollbar). * [JSDelivr](https://www.jsdelivr.com/projects/perfect-scrollbar)
## Requirements #### JSFiddle
To make this plugin *perfect*, some requirements were unavoidable. You can fork the following JSFiddles for testing and experimenting purposes:
But, they're all very trivial and there is nothing to worry about.
* [Perfect Scrollbar](https://jsfiddle.net/DanielApt/xv0rrxv3/)
* [Perfect Scrollbar (jQuery)](https://jsfiddle.net/DanielApt/gbfLazpx/)
## Before using perfect-scrollbar
The following requirements should meet. The following requirements should meet.
* the container must have a 'position' css style. * the container must have a 'position' css style.
* the container must be a normal container element.
* PS may not work well in `body`, `textarea`, `iframe` or flexbox.
The following requirements are included in the basic CSS, but please The following requirements are included in the basic CSS, but please
keep in mind when you'd like to change the CSS files. keep in mind when you'd like to change the CSS files.
* the container must have an 'overflow:hidden' css style. * the container must have an 'overflow: hidden' css style.
* the scrollbar's position must be 'absolute'. * the scrollbar's position must be 'absolute'.
* the scrollbar-x must have a 'bottom' css style, and the scrollbar-y * the scrollbar-x must have a 'bottom' css style, and the scrollbar-y
must have a 'right' css style. must have a 'right' css style.
Please keep in mind that perfect-scrollbar won't completely emulate native
scrolls. Scroll hooking is generally considered as bad practice, and
perfect-scrollbar should be used with care. Unless custom scroll is really needed,
please consider using native scrolls.
## How to use ## How to use
First of all, please check if the container element meets the First of all, please check if the container element meets the
@ -155,7 +178,7 @@ If the size of your container or content changes, call `update`.
Ps.update(container); Ps.update(container);
``` ```
If you want to destory the scrollbar, use `destroy`. If you want to destroy the scrollbar, use `destroy`.
```javascript ```javascript
Ps.destroy(container); Ps.destroy(container);
@ -238,12 +261,12 @@ define([
'perfectScrollbarJquery' 'perfectScrollbarJquery'
], ],
function (angular) { function (angular) {
var myApp = angular.module('myApp', []) var app = angular.module('myApp', []);
.run(function() { app.run(function () {
window.Ps = require('perfectScrollbar'); window.Ps = require('perfectScrollbar');
require('perfectScrollbarJQuery'); require('perfectScrollbarJQuery');
}) });
return myApp; return app;
}); });
``` ```
@ -256,7 +279,7 @@ Ps.initialize(container);
Ps.update(container); Ps.update(container);
// or by jQuery: // or by jQuery:
var imgLoader = $("#imgLoader") var imgLoader = $('#imgLoader')
imgLoader.perfectScrollbar(); imgLoader.perfectScrollbar();
``` ```
@ -264,57 +287,80 @@ imgLoader.perfectScrollbar();
perfect-scrollbar supports optional parameters. perfect-scrollbar supports optional parameters.
### handlers
It is a list of handlers to use to scroll the element.
**Default**: `['click-rail', 'drag-scrollbar', 'keyboard', 'wheel', 'touch']`
**Disabled by default**: `'selection'`
### wheelSpeed ### wheelSpeed
The scroll speed applied to mousewheel event. The scroll speed applied to mousewheel event.
**Default: 1** **Default**: `1`
### wheelPropagation ### wheelPropagation
If this option is true, when the scroll reaches the end of the side, mousewheel event will be propagated to parent element. If this option is true, when the scroll reaches the end of the side, mousewheel event will be propagated to parent element.
**Default: false** **Default**: `false`
### swipePropagation ### swipePropagation
If this option is true, when the scroll reaches the end of the side, touch scrolling will be propagated to parent element. If this option is true, when the scroll reaches the end of the side, touch scrolling will be propagated to parent element.
**Default: true** **Default**: `true`
### minScrollbarLength ### minScrollbarLength
When set to an integer value, the thumb part of the scrollbar will not shrink below that number of pixels. When set to an integer value, the thumb part of the scrollbar will not shrink below that number of pixels.
**Default: null** **Default**: `null`
### maxScrollbarLength ### maxScrollbarLength
When set to an integer value, the thumb part of the scrollbar will not expand over that number of pixels. When set to an integer value, the thumb part of the scrollbar will not expand over that number of pixels.
**Default: null** **Default**: `null`
### useBothWheelAxes ### useBothWheelAxes
When set to true, and only one (vertical or horizontal) scrollbar is visible then both vertical and horizontal scrolling will affect the scrollbar. When set to true, and only one (vertical or horizontal) scrollbar is visible then both vertical and horizontal scrolling will affect the scrollbar.
**Default: false** **Default**: `false`
### useKeyboard
When set to true, the scroll works with arrow keys on the keyboard. The element is scrolled only when the mouse cursor hovers the element.
**Default: true**
### suppressScrollX ### suppressScrollX
When set to true, the scroll bar in X axis will not be available, regardless of the content width. When set to true, the scroll bar in X axis will not be available, regardless of the content width.
**Default: false** **Default**: `false`
### suppressScrollY ### suppressScrollY
When set to true, the scroll bar in Y axis will not be available, regardless of the content height. When set to true, the scroll bar in Y axis will not be available, regardless of the content height.
**Default: false** **Default**: `false`
### scrollXMarginOffset ### scrollXMarginOffset
The number of pixels the content width can surpass the container width without enabling the X axis scroll bar. Allows some "wiggle room" or "offset break", so that X axis scroll bar is not enabled just because of a few pixels. The number of pixels the content width can surpass the container width without enabling the X axis scroll bar. Allows some "wiggle room" or "offset break", so that X axis scroll bar is not enabled just because of a few pixels.
**Default: 0** **Default**: `0`
### scrollYMarginOffset ### scrollYMarginOffset
The number of pixels the content height can surpass the container height without enabling the Y axis scroll bar. Allows some "wiggle room" or "offset break", so that Y axis scroll bar is not enabled just because of a few pixels. The number of pixels the content height can surpass the container height without enabling the Y axis scroll bar. Allows some "wiggle room" or "offset break", so that Y axis scroll bar is not enabled just because of a few pixels.
**Default: 0** **Default**: `0`
### stopPropagationOnClick ### theme
When set to false, when clicking on a rail, the click event will be allowed to propagate. A string. It's a class name added to the container element. The class name is prepended with `ps-theme-`. So default theme class name is `ps-theme-default`. In order to create custom themes with scss use `ps-container($theme)` mixin, where `$theme` is a scss map.
**Default: true** **Default**: `'default'`
**Example 1:**
Add `theme` parameter:
```javascript
Ps.initialize(container, {
theme: 'my-theme-name'
});
```
Create a class name prefixed with `.ps-theme-`. Include `ps-container()` mixin. It's recommended to use `map-merge()` to extend `$ps-theme-default` map with your custom styles.
```scss
.ps-theme-my-theme-name {
@include ps-container(map-merge($ps-theme-default, (
border-radius: 0,
scrollbar-x-rail-height: 20px,
scrollbar-x-height: 20px,
scrollbar-y-rail-width: 20px,
scrollbar-y-width: 20px
)));
}
```
**Example 2:**
Alternatively, if you don't want to create your own themes, but only modify the default one, you could simply overwrite `$ps-*` variables with your own values. In this case `theme` parameter is not required when calling `.initialize()` method. Remember do define your own variables before the `theme.scss` file is imported.
### useSelectionScroll
When set to true, you can scroll the container by selecting text and move the cursor.
**Default: false**
## Events ## Events
@ -363,24 +409,20 @@ $(document).on('ps-scroll-x', function () {
}) })
``` ```
## Contribution ## Tips
#### Please read [Contributing](https://github.com/noraesae/perfect-scrollbar/wiki/Contributing) in the wiki before making any contribution. ### Scrolling children inside perfect-scrollbar
You can natively scroll children inside `perfect-scrollbar` with the mouse-wheel. Scrolling automatically works if
I *really* welcome contributions! Please feel free to fork and issue pull requests when... the child is a `textarea`. All other elements need to have the `ps-child` class. This is demonstrated in [`/examples/children-native-scroll.html`](examples/children-native-scroll.html)
* You have a very nice idea to improve this plugin!
* You found a bug!
* You're good at English and can help my bad English!
For IE problems, please refer to [IE Support](https://github.com/noraesae/perfect-scrollbar#ie-support).
## IE Support ## IE Support
The plugin would work in IEs >= IE9 (not well, though). The plugin is designed to work in modern browsers, including the very latest
version of IE and Edge. Specifically, it should work in IEs >= IE10. If there
is any issue in the browsers, please [file it](https://github.com/noraesae/perfect-scrollbar/issues).
**The patches to fix problems in IE<=8 won't be accepted.** **The patches to fix problems in IE<=9 won't be accepted.**
When old IEs should be supported, please fork the project and When old IEs should be supported, please fork the project and
make patches personally. make patches personally.
@ -396,7 +438,7 @@ For common problems there is a
## License ## License
The MIT License (MIT) Copyright (c) 2015 Hyunje Alex Jun and other contributors. The MIT License (MIT) Copyright (c) 2016 Hyunje Alex Jun and other contributors.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

View file

@ -1,7 +1,7 @@
/* perfect-scrollbar v0.6.10 */ /* perfect-scrollbar v0.6.15 */
.ps-container { .ps-container {
-ms-touch-action: none; -ms-touch-action: auto;
touch-action: none; touch-action: auto;
overflow: hidden !important; overflow: hidden !important;
-ms-overflow-style: none; } -ms-overflow-style: none; }
@supports (-ms-overflow-style: none) { @supports (-ms-overflow-style: none) {
@ -14,88 +14,90 @@
.ps-container.ps-active-y > .ps-scrollbar-y-rail { .ps-container.ps-active-y > .ps-scrollbar-y-rail {
display: block; display: block;
background-color: transparent; } background-color: transparent; }
.ps-container.ps-in-scrolling {
pointer-events: none; }
.ps-container.ps-in-scrolling.ps-x > .ps-scrollbar-x-rail { .ps-container.ps-in-scrolling.ps-x > .ps-scrollbar-x-rail {
background-color: #eee; background-color: #eee;
opacity: 0.9; } opacity: 0.9; }
.ps-container.ps-in-scrolling.ps-x > .ps-scrollbar-x-rail > .ps-scrollbar-x { .ps-container.ps-in-scrolling.ps-x > .ps-scrollbar-x-rail > .ps-scrollbar-x {
background-color: #999; } background-color: #999;
height: 11px; }
.ps-container.ps-in-scrolling.ps-y > .ps-scrollbar-y-rail { .ps-container.ps-in-scrolling.ps-y > .ps-scrollbar-y-rail {
background-color: #eee; background-color: #eee;
opacity: 0.9; } opacity: 0.9; }
.ps-container.ps-in-scrolling.ps-y > .ps-scrollbar-y-rail > .ps-scrollbar-y { .ps-container.ps-in-scrolling.ps-y > .ps-scrollbar-y-rail > .ps-scrollbar-y {
background-color: #999; } background-color: #999;
width: 11px; }
.ps-container > .ps-scrollbar-x-rail { .ps-container > .ps-scrollbar-x-rail {
display: none; display: none;
position: absolute; position: absolute;
/* please don't change 'position' */ /* please don't change 'position' */
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
opacity: 0; opacity: 0;
-webkit-transition: background-color .2s linear, opacity .2s linear; -webkit-transition: background-color .2s linear, opacity .2s linear;
-moz-transition: background-color .2s linear, opacity .2s linear;
-o-transition: background-color .2s linear, opacity .2s linear; -o-transition: background-color .2s linear, opacity .2s linear;
-moz-transition: background-color .2s linear, opacity .2s linear;
transition: background-color .2s linear, opacity .2s linear; transition: background-color .2s linear, opacity .2s linear;
bottom: 3px; bottom: 0px;
/* there must be 'bottom' for ps-scrollbar-x-rail */ /* there must be 'bottom' for ps-scrollbar-x-rail */
height: 8px; } height: 15px; }
.ps-container > .ps-scrollbar-x-rail > .ps-scrollbar-x { .ps-container > .ps-scrollbar-x-rail > .ps-scrollbar-x {
position: absolute; position: absolute;
/* please don't change 'position' */ /* please don't change 'position' */
background-color: #aaa; background-color: #aaa;
-webkit-border-radius: 4px; -webkit-border-radius: 6px;
-moz-border-radius: 4px; -moz-border-radius: 6px;
border-radius: 4px; border-radius: 6px;
-webkit-transition: background-color .2s linear; -webkit-transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, -webkit-border-radius .2s ease-in-out;
-moz-transition: background-color .2s linear; transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, -webkit-border-radius .2s ease-in-out;
-o-transition: background-color .2s linear; -o-transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out;
transition: background-color .2s linear; -moz-transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out, -moz-border-radius .2s ease-in-out;
bottom: 0; transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out;
transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out, -webkit-border-radius .2s ease-in-out, -moz-border-radius .2s ease-in-out;
bottom: 2px;
/* there must be 'bottom' for ps-scrollbar-x */ /* there must be 'bottom' for ps-scrollbar-x */
height: 8px; } height: 6px; }
.ps-container > .ps-scrollbar-x-rail:hover > .ps-scrollbar-x, .ps-container > .ps-scrollbar-x-rail:active > .ps-scrollbar-x {
height: 11px; }
.ps-container > .ps-scrollbar-y-rail { .ps-container > .ps-scrollbar-y-rail {
display: none; display: none;
position: absolute; position: absolute;
/* please don't change 'position' */ /* please don't change 'position' */
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
opacity: 0; opacity: 0;
-webkit-transition: background-color .2s linear, opacity .2s linear; -webkit-transition: background-color .2s linear, opacity .2s linear;
-moz-transition: background-color .2s linear, opacity .2s linear;
-o-transition: background-color .2s linear, opacity .2s linear; -o-transition: background-color .2s linear, opacity .2s linear;
-moz-transition: background-color .2s linear, opacity .2s linear;
transition: background-color .2s linear, opacity .2s linear; transition: background-color .2s linear, opacity .2s linear;
right: 3px; right: 0;
/* there must be 'right' for ps-scrollbar-y-rail */ /* there must be 'right' for ps-scrollbar-y-rail */
width: 8px; } width: 15px; }
.ps-container > .ps-scrollbar-y-rail > .ps-scrollbar-y { .ps-container > .ps-scrollbar-y-rail > .ps-scrollbar-y {
position: absolute; position: absolute;
/* please don't change 'position' */ /* please don't change 'position' */
background-color: #aaa; background-color: #aaa;
-webkit-border-radius: 4px; -webkit-border-radius: 6px;
-moz-border-radius: 4px; -moz-border-radius: 6px;
border-radius: 4px; border-radius: 6px;
-webkit-transition: background-color .2s linear; -webkit-transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, -webkit-border-radius .2s ease-in-out;
-moz-transition: background-color .2s linear; transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, -webkit-border-radius .2s ease-in-out;
-o-transition: background-color .2s linear; -o-transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out;
transition: background-color .2s linear; -moz-transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out, -moz-border-radius .2s ease-in-out;
right: 0; transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out;
transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out, -webkit-border-radius .2s ease-in-out, -moz-border-radius .2s ease-in-out;
right: 2px;
/* there must be 'right' for ps-scrollbar-y */ /* there must be 'right' for ps-scrollbar-y */
width: 8px; } width: 6px; }
.ps-container:hover.ps-in-scrolling { .ps-container > .ps-scrollbar-y-rail:hover > .ps-scrollbar-y, .ps-container > .ps-scrollbar-y-rail:active > .ps-scrollbar-y {
pointer-events: none; } width: 11px; }
.ps-container:hover.ps-in-scrolling.ps-x > .ps-scrollbar-x-rail { .ps-container:hover.ps-in-scrolling.ps-x > .ps-scrollbar-x-rail {
background-color: #eee; background-color: #eee;
opacity: 0.9; } opacity: 0.9; }
.ps-container:hover.ps-in-scrolling.ps-x > .ps-scrollbar-x-rail > .ps-scrollbar-x { .ps-container:hover.ps-in-scrolling.ps-x > .ps-scrollbar-x-rail > .ps-scrollbar-x {
background-color: #999; } background-color: #999;
height: 11px; }
.ps-container:hover.ps-in-scrolling.ps-y > .ps-scrollbar-y-rail { .ps-container:hover.ps-in-scrolling.ps-y > .ps-scrollbar-y-rail {
background-color: #eee; background-color: #eee;
opacity: 0.9; } opacity: 0.9; }
.ps-container:hover.ps-in-scrolling.ps-y > .ps-scrollbar-y-rail > .ps-scrollbar-y { .ps-container:hover.ps-in-scrolling.ps-y > .ps-scrollbar-y-rail > .ps-scrollbar-y {
background-color: #999; } background-color: #999;
width: 11px; }
.ps-container:hover > .ps-scrollbar-x-rail, .ps-container:hover > .ps-scrollbar-x-rail,
.ps-container:hover > .ps-scrollbar-y-rail { .ps-container:hover > .ps-scrollbar-y-rail {
opacity: 0.6; } opacity: 0.6; }

View file

@ -1,16 +1,9 @@
/* perfect-scrollbar v0.6.10 /* perfect-scrollbar v0.6.15 */
*
* Copyright (c) 2015 Hyunje Alex Jun and other contributors
* Licensed under the MIT License
*
* Source: https://github.com/noraesae/perfect-scrollbar
*/
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
'use strict'; 'use strict';
var ps = require('../main') var ps = require('../main');
, psInstances = require('../plugin/instances'); var psInstances = require('../plugin/instances');
function mountJQuery(jQuery) { function mountJQuery(jQuery) {
jQuery.fn.perfectScrollbar = function (settingOrCommand) { jQuery.fn.perfectScrollbar = function (settingOrCommand) {
@ -33,8 +26,6 @@ function mountJQuery(jQuery) {
ps.destroy(this); ps.destroy(this);
} }
} }
return jQuery(this);
}); });
}; };
} }
@ -272,20 +263,22 @@ module.exports = (function () {
},{}],6:[function(require,module,exports){ },{}],6:[function(require,module,exports){
'use strict'; 'use strict';
var cls = require('./class') var cls = require('./class');
, d = require('./dom'); var dom = require('./dom');
exports.toInt = function (x) { var toInt = exports.toInt = function (x) {
return parseInt(x, 10) || 0; return parseInt(x, 10) || 0;
}; };
exports.clone = function (obj) { var clone = exports.clone = function (obj) {
if (obj === null) { if (!obj) {
return null; return null;
} else if (obj.constructor === Array) {
return obj.map(clone);
} else if (typeof obj === 'object') { } else if (typeof obj === 'object') {
var result = {}; var result = {};
for (var key in obj) { for (var key in obj) {
result[key] = this.clone(obj[key]); result[key] = clone(obj[key]);
} }
return result; return result;
} else { } else {
@ -294,18 +287,18 @@ exports.clone = function (obj) {
}; };
exports.extend = function (original, source) { exports.extend = function (original, source) {
var result = this.clone(original); var result = clone(original);
for (var key in source) { for (var key in source) {
result[key] = this.clone(source[key]); result[key] = clone(source[key]);
} }
return result; return result;
}; };
exports.isEditable = function (el) { exports.isEditable = function (el) {
return d.matches(el, "input,[contenteditable]") || return dom.matches(el, "input,[contenteditable]") ||
d.matches(el, "select,[contenteditable]") || dom.matches(el, "select,[contenteditable]") ||
d.matches(el, "textarea,[contenteditable]") || dom.matches(el, "textarea,[contenteditable]") ||
d.matches(el, "button,[contenteditable]"); dom.matches(el, "button,[contenteditable]");
}; };
exports.removePsClasses = function (element) { exports.removePsClasses = function (element) {
@ -319,11 +312,11 @@ exports.removePsClasses = function (element) {
}; };
exports.outerWidth = function (element) { exports.outerWidth = function (element) {
return this.toInt(d.css(element, 'width')) + return toInt(dom.css(element, 'width')) +
this.toInt(d.css(element, 'paddingLeft')) + toInt(dom.css(element, 'paddingLeft')) +
this.toInt(d.css(element, 'paddingRight')) + toInt(dom.css(element, 'paddingRight')) +
this.toInt(d.css(element, 'borderLeftWidth')) + toInt(dom.css(element, 'borderLeftWidth')) +
this.toInt(d.css(element, 'borderRightWidth')); toInt(dom.css(element, 'borderRightWidth'));
}; };
exports.startScrolling = function (element, axis) { exports.startScrolling = function (element, axis) {
@ -355,9 +348,9 @@ exports.env = {
},{"./class":2,"./dom":3}],7:[function(require,module,exports){ },{"./class":2,"./dom":3}],7:[function(require,module,exports){
'use strict'; 'use strict';
var destroy = require('./plugin/destroy') var destroy = require('./plugin/destroy');
, initialize = require('./plugin/initialize') var initialize = require('./plugin/initialize');
, update = require('./plugin/update'); var update = require('./plugin/update');
module.exports = { module.exports = {
initialize: initialize, initialize: initialize,
@ -369,17 +362,15 @@ module.exports = {
'use strict'; 'use strict';
module.exports = { module.exports = {
handlers: ['click-rail', 'drag-scrollbar', 'keyboard', 'wheel', 'touch'],
maxScrollbarLength: null, maxScrollbarLength: null,
minScrollbarLength: null, minScrollbarLength: null,
scrollXMarginOffset: 0, scrollXMarginOffset: 0,
scrollYMarginOffset: 0, scrollYMarginOffset: 0,
stopPropagationOnClick: true,
suppressScrollX: false, suppressScrollX: false,
suppressScrollY: false, suppressScrollY: false,
swipePropagation: true, swipePropagation: true,
useBothWheelAxes: false, useBothWheelAxes: false,
useKeyboard: true,
useSelectionScroll: false,
wheelPropagation: false, wheelPropagation: false,
wheelSpeed: 1, wheelSpeed: 1,
theme: 'default' theme: 'default'
@ -388,9 +379,9 @@ module.exports = {
},{}],9:[function(require,module,exports){ },{}],9:[function(require,module,exports){
'use strict'; 'use strict';
var d = require('../lib/dom') var _ = require('../lib/helper');
, h = require('../lib/helper') var dom = require('../lib/dom');
, instances = require('./instances'); var instances = require('./instances');
module.exports = function (element) { module.exports = function (element) {
var i = instances.get(element); var i = instances.get(element);
@ -400,11 +391,11 @@ module.exports = function (element) {
} }
i.event.unbindAll(); i.event.unbindAll();
d.remove(i.scrollbarX); dom.remove(i.scrollbarX);
d.remove(i.scrollbarY); dom.remove(i.scrollbarY);
d.remove(i.scrollbarXRail); dom.remove(i.scrollbarXRail);
d.remove(i.scrollbarYRail); dom.remove(i.scrollbarYRail);
h.removePsClasses(element); _.removePsClasses(element);
instances.remove(element); instances.remove(element);
}; };
@ -412,54 +403,33 @@ module.exports = function (element) {
},{"../lib/dom":3,"../lib/helper":6,"./instances":18}],10:[function(require,module,exports){ },{"../lib/dom":3,"../lib/helper":6,"./instances":18}],10:[function(require,module,exports){
'use strict'; 'use strict';
var h = require('../../lib/helper') var instances = require('../instances');
, instances = require('../instances') var updateGeometry = require('../update-geometry');
, updateGeometry = require('../update-geometry') var updateScroll = require('../update-scroll');
, updateScroll = require('../update-scroll');
function bindClickRailHandler(element, i) { function bindClickRailHandler(element, i) {
function pageOffset(el) { function pageOffset(el) {
return el.getBoundingClientRect(); return el.getBoundingClientRect();
} }
var stopPropagation = window.Event.prototype.stopPropagation.bind; var stopPropagation = function (e) { e.stopPropagation(); };
if (i.settings.stopPropagationOnClick) {
i.event.bind(i.scrollbarY, 'click', stopPropagation); i.event.bind(i.scrollbarY, 'click', stopPropagation);
}
i.event.bind(i.scrollbarYRail, 'click', function (e) { i.event.bind(i.scrollbarYRail, 'click', function (e) {
var halfOfScrollbarLength = h.toInt(i.scrollbarYHeight / 2); var positionTop = e.pageY - window.pageYOffset - pageOffset(i.scrollbarYRail).top;
var positionTop = i.railYRatio * (e.pageY - window.pageYOffset - pageOffset(i.scrollbarYRail).top - halfOfScrollbarLength); var direction = positionTop > i.scrollbarYTop ? 1 : -1;
var maxPositionTop = i.railYRatio * (i.railYHeight - i.scrollbarYHeight);
var positionRatio = positionTop / maxPositionTop;
if (positionRatio < 0) { updateScroll(element, 'top', element.scrollTop + direction * i.containerHeight);
positionRatio = 0;
} else if (positionRatio > 1) {
positionRatio = 1;
}
updateScroll(element, 'top', (i.contentHeight - i.containerHeight) * positionRatio);
updateGeometry(element); updateGeometry(element);
e.stopPropagation(); e.stopPropagation();
}); });
if (i.settings.stopPropagationOnClick) {
i.event.bind(i.scrollbarX, 'click', stopPropagation); i.event.bind(i.scrollbarX, 'click', stopPropagation);
}
i.event.bind(i.scrollbarXRail, 'click', function (e) { i.event.bind(i.scrollbarXRail, 'click', function (e) {
var halfOfScrollbarLength = h.toInt(i.scrollbarXWidth / 2); var positionLeft = e.pageX - window.pageXOffset - pageOffset(i.scrollbarXRail).left;
var positionLeft = i.railXRatio * (e.pageX - window.pageXOffset - pageOffset(i.scrollbarXRail).left - halfOfScrollbarLength); var direction = positionLeft > i.scrollbarXLeft ? 1 : -1;
var maxPositionLeft = i.railXRatio * (i.railXWidth - i.scrollbarXWidth);
var positionRatio = positionLeft / maxPositionLeft;
if (positionRatio < 0) { updateScroll(element, 'left', element.scrollLeft + direction * i.containerWidth);
positionRatio = 0;
} else if (positionRatio > 1) {
positionRatio = 1;
}
updateScroll(element, 'left', ((i.contentWidth - i.containerWidth) * positionRatio) - i.negativeScrollAdjustment);
updateGeometry(element); updateGeometry(element);
e.stopPropagation(); e.stopPropagation();
@ -471,14 +441,14 @@ module.exports = function (element) {
bindClickRailHandler(element, i); bindClickRailHandler(element, i);
}; };
},{"../../lib/helper":6,"../instances":18,"../update-geometry":19,"../update-scroll":20}],11:[function(require,module,exports){ },{"../instances":18,"../update-geometry":19,"../update-scroll":20}],11:[function(require,module,exports){
'use strict'; 'use strict';
var d = require('../../lib/dom') var _ = require('../../lib/helper');
, h = require('../../lib/helper') var dom = require('../../lib/dom');
, instances = require('../instances') var instances = require('../instances');
, updateGeometry = require('../update-geometry') var updateGeometry = require('../update-geometry');
, updateScroll = require('../update-scroll'); var updateScroll = require('../update-scroll');
function bindMouseScrollXHandler(element, i) { function bindMouseScrollXHandler(element, i) {
var currentLeft = null; var currentLeft = null;
@ -496,7 +466,7 @@ function bindMouseScrollXHandler(element, i) {
i.scrollbarXLeft = newLeft; i.scrollbarXLeft = newLeft;
} }
var scrollLeft = h.toInt(i.scrollbarXLeft * (i.contentWidth - i.containerWidth) / (i.containerWidth - (i.railXRatio * i.scrollbarXWidth))) - i.negativeScrollAdjustment; var scrollLeft = _.toInt(i.scrollbarXLeft * (i.contentWidth - i.containerWidth) / (i.containerWidth - (i.railXRatio * i.scrollbarXWidth))) - i.negativeScrollAdjustment;
updateScroll(element, 'left', scrollLeft); updateScroll(element, 'left', scrollLeft);
} }
@ -508,14 +478,14 @@ function bindMouseScrollXHandler(element, i) {
}; };
var mouseUpHandler = function () { var mouseUpHandler = function () {
h.stopScrolling(element, 'x'); _.stopScrolling(element, 'x');
i.event.unbind(i.ownerDocument, 'mousemove', mouseMoveHandler); i.event.unbind(i.ownerDocument, 'mousemove', mouseMoveHandler);
}; };
i.event.bind(i.scrollbarX, 'mousedown', function (e) { i.event.bind(i.scrollbarX, 'mousedown', function (e) {
currentPageX = e.pageX; currentPageX = e.pageX;
currentLeft = h.toInt(d.css(i.scrollbarX, 'left')) * i.railXRatio; currentLeft = _.toInt(dom.css(i.scrollbarX, 'left')) * i.railXRatio;
h.startScrolling(element, 'x'); _.startScrolling(element, 'x');
i.event.bind(i.ownerDocument, 'mousemove', mouseMoveHandler); i.event.bind(i.ownerDocument, 'mousemove', mouseMoveHandler);
i.event.once(i.ownerDocument, 'mouseup', mouseUpHandler); i.event.once(i.ownerDocument, 'mouseup', mouseUpHandler);
@ -541,7 +511,7 @@ function bindMouseScrollYHandler(element, i) {
i.scrollbarYTop = newTop; i.scrollbarYTop = newTop;
} }
var scrollTop = h.toInt(i.scrollbarYTop * (i.contentHeight - i.containerHeight) / (i.containerHeight - (i.railYRatio * i.scrollbarYHeight))); var scrollTop = _.toInt(i.scrollbarYTop * (i.contentHeight - i.containerHeight) / (i.containerHeight - (i.railYRatio * i.scrollbarYHeight)));
updateScroll(element, 'top', scrollTop); updateScroll(element, 'top', scrollTop);
} }
@ -553,14 +523,14 @@ function bindMouseScrollYHandler(element, i) {
}; };
var mouseUpHandler = function () { var mouseUpHandler = function () {
h.stopScrolling(element, 'y'); _.stopScrolling(element, 'y');
i.event.unbind(i.ownerDocument, 'mousemove', mouseMoveHandler); i.event.unbind(i.ownerDocument, 'mousemove', mouseMoveHandler);
}; };
i.event.bind(i.scrollbarY, 'mousedown', function (e) { i.event.bind(i.scrollbarY, 'mousedown', function (e) {
currentPageY = e.pageY; currentPageY = e.pageY;
currentTop = h.toInt(d.css(i.scrollbarY, 'top')) * i.railYRatio; currentTop = _.toInt(dom.css(i.scrollbarY, 'top')) * i.railYRatio;
h.startScrolling(element, 'y'); _.startScrolling(element, 'y');
i.event.bind(i.ownerDocument, 'mousemove', mouseMoveHandler); i.event.bind(i.ownerDocument, 'mousemove', mouseMoveHandler);
i.event.once(i.ownerDocument, 'mouseup', mouseUpHandler); i.event.once(i.ownerDocument, 'mouseup', mouseUpHandler);
@ -579,11 +549,11 @@ module.exports = function (element) {
},{"../../lib/dom":3,"../../lib/helper":6,"../instances":18,"../update-geometry":19,"../update-scroll":20}],12:[function(require,module,exports){ },{"../../lib/dom":3,"../../lib/helper":6,"../instances":18,"../update-geometry":19,"../update-scroll":20}],12:[function(require,module,exports){
'use strict'; 'use strict';
var h = require('../../lib/helper') var _ = require('../../lib/helper');
, d = require('../../lib/dom') var dom = require('../../lib/dom');
, instances = require('../instances') var instances = require('../instances');
, updateGeometry = require('../update-geometry') var updateGeometry = require('../update-geometry');
, updateScroll = require('../update-scroll'); var updateScroll = require('../update-scroll');
function bindKeyboardHandler(element, i) { function bindKeyboardHandler(element, i) {
var hovered = false; var hovered = false;
@ -619,12 +589,12 @@ function bindKeyboardHandler(element, i) {
} }
i.event.bind(i.ownerDocument, 'keydown', function (e) { i.event.bind(i.ownerDocument, 'keydown', function (e) {
if (e.isDefaultPrevented && e.isDefaultPrevented()) { if ((e.isDefaultPrevented && e.isDefaultPrevented()) || e.defaultPrevented) {
return; return;
} }
var focused = d.matches(i.scrollbarX, ':focus') || var focused = dom.matches(i.scrollbarX, ':focus') ||
d.matches(i.scrollbarY, ':focus'); dom.matches(i.scrollbarY, ':focus');
if (!hovered && !focused) { if (!hovered && !focused) {
return; return;
@ -632,11 +602,15 @@ function bindKeyboardHandler(element, i) {
var activeElement = document.activeElement ? document.activeElement : i.ownerDocument.activeElement; var activeElement = document.activeElement ? document.activeElement : i.ownerDocument.activeElement;
if (activeElement) { if (activeElement) {
if (activeElement.tagName === 'IFRAME') {
activeElement = activeElement.contentDocument.activeElement;
} else {
// go deeper if element is a webcomponent // go deeper if element is a webcomponent
while (activeElement.shadowRoot) { while (activeElement.shadowRoot) {
activeElement = activeElement.shadowRoot.activeElement; activeElement = activeElement.shadowRoot.activeElement;
} }
if (h.isEditable(activeElement)) { }
if (_.isEditable(activeElement)) {
return; return;
} }
} }
@ -646,16 +620,40 @@ function bindKeyboardHandler(element, i) {
switch (e.which) { switch (e.which) {
case 37: // left case 37: // left
if (e.metaKey) {
deltaX = -i.contentWidth;
} else if (e.altKey) {
deltaX = -i.containerWidth;
} else {
deltaX = -30; deltaX = -30;
}
break; break;
case 38: // up case 38: // up
if (e.metaKey) {
deltaY = i.contentHeight;
} else if (e.altKey) {
deltaY = i.containerHeight;
} else {
deltaY = 30; deltaY = 30;
}
break; break;
case 39: // right case 39: // right
if (e.metaKey) {
deltaX = i.contentWidth;
} else if (e.altKey) {
deltaX = i.containerWidth;
} else {
deltaX = 30; deltaX = 30;
}
break; break;
case 40: // down case 40: // down
if (e.metaKey) {
deltaY = -i.contentHeight;
} else if (e.altKey) {
deltaY = -i.containerHeight;
} else {
deltaY = -30; deltaY = -30;
}
break; break;
case 33: // page up case 33: // page up
deltaY = 90; deltaY = 90;
@ -707,9 +705,9 @@ module.exports = function (element) {
},{"../../lib/dom":3,"../../lib/helper":6,"../instances":18,"../update-geometry":19,"../update-scroll":20}],13:[function(require,module,exports){ },{"../../lib/dom":3,"../../lib/helper":6,"../instances":18,"../update-geometry":19,"../update-scroll":20}],13:[function(require,module,exports){
'use strict'; 'use strict';
var instances = require('../instances') var instances = require('../instances');
, updateGeometry = require('../update-geometry') var updateGeometry = require('../update-geometry');
, updateScroll = require('../update-scroll'); var updateScroll = require('../update-scroll');
function bindMouseWheelHandler(element, i) { function bindMouseWheelHandler(element, i) {
var shouldPrevent = false; var shouldPrevent = false;
@ -759,23 +757,30 @@ function bindMouseWheelHandler(element, i) {
deltaY = e.wheelDelta; deltaY = e.wheelDelta;
} }
if (e.shiftKey) {
// reverse axis with shift key
return [-deltaY, -deltaX];
}
return [deltaX, deltaY]; return [deltaX, deltaY];
} }
function shouldBeConsumedByTextarea(deltaX, deltaY) { function shouldBeConsumedByChild(deltaX, deltaY) {
var hoveredTextarea = element.querySelector('textarea:hover'); var child = element.querySelector('textarea:hover, select[multiple]:hover, .ps-child:hover');
if (hoveredTextarea) { if (child) {
var maxScrollTop = hoveredTextarea.scrollHeight - hoveredTextarea.clientHeight; if (!window.getComputedStyle(child).overflow.match(/(scroll|auto)/)) {
// if not scrollable
return false;
}
var maxScrollTop = child.scrollHeight - child.clientHeight;
if (maxScrollTop > 0) { if (maxScrollTop > 0) {
if (!(hoveredTextarea.scrollTop === 0 && deltaY > 0) && if (!(child.scrollTop === 0 && deltaY > 0) && !(child.scrollTop === maxScrollTop && deltaY < 0)) {
!(hoveredTextarea.scrollTop === maxScrollTop && deltaY < 0)) {
return true; return true;
} }
} }
var maxScrollLeft = hoveredTextarea.scrollLeft - hoveredTextarea.clientWidth; var maxScrollLeft = child.scrollLeft - child.clientWidth;
if (maxScrollLeft > 0) { if (maxScrollLeft > 0) {
if (!(hoveredTextarea.scrollLeft === 0 && deltaX < 0) && if (!(child.scrollLeft === 0 && deltaX < 0) && !(child.scrollLeft === maxScrollLeft && deltaX > 0)) {
!(hoveredTextarea.scrollLeft === maxScrollLeft && deltaX > 0)) {
return true; return true;
} }
} }
@ -789,7 +794,7 @@ function bindMouseWheelHandler(element, i) {
var deltaX = delta[0]; var deltaX = delta[0];
var deltaY = delta[1]; var deltaY = delta[1];
if (shouldBeConsumedByTextarea(deltaX, deltaY)) { if (shouldBeConsumedByChild(deltaX, deltaY)) {
return; return;
} }
@ -843,8 +848,8 @@ module.exports = function (element) {
},{"../instances":18,"../update-geometry":19,"../update-scroll":20}],14:[function(require,module,exports){ },{"../instances":18,"../update-geometry":19,"../update-scroll":20}],14:[function(require,module,exports){
'use strict'; 'use strict';
var instances = require('../instances') var instances = require('../instances');
, updateGeometry = require('../update-geometry'); var updateGeometry = require('../update-geometry');
function bindNativeScrollHandler(element, i) { function bindNativeScrollHandler(element, i) {
i.event.bind(element, 'scroll', function () { i.event.bind(element, 'scroll', function () {
@ -860,10 +865,10 @@ module.exports = function (element) {
},{"../instances":18,"../update-geometry":19}],15:[function(require,module,exports){ },{"../instances":18,"../update-geometry":19}],15:[function(require,module,exports){
'use strict'; 'use strict';
var h = require('../../lib/helper') var _ = require('../../lib/helper');
, instances = require('../instances') var instances = require('../instances');
, updateGeometry = require('../update-geometry') var updateGeometry = require('../update-geometry');
, updateScroll = require('../update-scroll'); var updateScroll = require('../update-scroll');
function bindSelectionHandler(element, i) { function bindSelectionHandler(element, i) {
function getRangeNode() { function getRangeNode() {
@ -897,7 +902,7 @@ function bindSelectionHandler(element, i) {
clearInterval(scrollingLoop); clearInterval(scrollingLoop);
scrollingLoop = null; scrollingLoop = null;
} }
h.stopScrolling(element); _.stopScrolling(element);
} }
var isSelected = false; var isSelected = false;
@ -915,6 +920,12 @@ function bindSelectionHandler(element, i) {
stopScrolling(); stopScrolling();
} }
}); });
i.event.bind(window, 'keyup', function () {
if (isSelected) {
isSelected = false;
stopScrolling();
}
});
i.event.bind(window, 'mousemove', function (e) { i.event.bind(window, 'mousemove', function (e) {
if (isSelected) { if (isSelected) {
@ -928,10 +939,10 @@ function bindSelectionHandler(element, i) {
if (mousePosition.x < containerGeometry.left + 3) { if (mousePosition.x < containerGeometry.left + 3) {
scrollDiff.left = -5; scrollDiff.left = -5;
h.startScrolling(element, 'x'); _.startScrolling(element, 'x');
} else if (mousePosition.x > containerGeometry.right - 3) { } else if (mousePosition.x > containerGeometry.right - 3) {
scrollDiff.left = 5; scrollDiff.left = 5;
h.startScrolling(element, 'x'); _.startScrolling(element, 'x');
} else { } else {
scrollDiff.left = 0; scrollDiff.left = 0;
} }
@ -942,14 +953,14 @@ function bindSelectionHandler(element, i) {
} else { } else {
scrollDiff.top = -20; scrollDiff.top = -20;
} }
h.startScrolling(element, 'y'); _.startScrolling(element, 'y');
} else if (mousePosition.y > containerGeometry.bottom - 3) { } else if (mousePosition.y > containerGeometry.bottom - 3) {
if (mousePosition.y - containerGeometry.bottom + 3 < 5) { if (mousePosition.y - containerGeometry.bottom + 3 < 5) {
scrollDiff.top = 5; scrollDiff.top = 5;
} else { } else {
scrollDiff.top = 20; scrollDiff.top = 20;
} }
h.startScrolling(element, 'y'); _.startScrolling(element, 'y');
} else { } else {
scrollDiff.top = 0; scrollDiff.top = 0;
} }
@ -971,9 +982,10 @@ module.exports = function (element) {
},{"../../lib/helper":6,"../instances":18,"../update-geometry":19,"../update-scroll":20}],16:[function(require,module,exports){ },{"../../lib/helper":6,"../instances":18,"../update-geometry":19,"../update-scroll":20}],16:[function(require,module,exports){
'use strict'; 'use strict';
var instances = require('../instances') var _ = require('../../lib/helper');
, updateGeometry = require('../update-geometry') var instances = require('../instances');
, updateScroll = require('../update-scroll'); var updateGeometry = require('../update-geometry');
var updateScroll = require('../update-scroll');
function bindTouchHandler(element, i, supportsTouch, supportsIePointer) { function bindTouchHandler(element, i, supportsTouch, supportsIePointer) {
function shouldPreventDefault(deltaX, deltaY) { function shouldPreventDefault(deltaX, deltaY) {
@ -1058,6 +1070,9 @@ function bindTouchHandler(element, i, supportsTouch, supportsIePointer) {
} }
} }
function touchMove(e) { function touchMove(e) {
if (!inLocalTouch && i.settings.swipePropagation) {
touchStart(e);
}
if (!inGlobalTouch && inLocalTouch && shouldHandle(e)) { if (!inGlobalTouch && inLocalTouch && shouldHandle(e)) {
var touch = getTouch(e); var touch = getTouch(e);
@ -1095,6 +1110,11 @@ function bindTouchHandler(element, i, supportsTouch, supportsIePointer) {
return; return;
} }
if (!speed.x && !speed.y) {
clearInterval(easingLoop);
return;
}
if (Math.abs(speed.x) < 0.01 && Math.abs(speed.y) < 0.01) { if (Math.abs(speed.x) < 0.01 && Math.abs(speed.y) < 0.01) {
clearInterval(easingLoop); clearInterval(easingLoop);
return; return;
@ -1133,27 +1153,33 @@ function bindTouchHandler(element, i, supportsTouch, supportsIePointer) {
} }
} }
module.exports = function (element, supportsTouch, supportsIePointer) { module.exports = function (element) {
if (!_.env.supportsTouch && !_.env.supportsIePointer) {
return;
}
var i = instances.get(element); var i = instances.get(element);
bindTouchHandler(element, i, supportsTouch, supportsIePointer); bindTouchHandler(element, i, _.env.supportsTouch, _.env.supportsIePointer);
}; };
},{"../instances":18,"../update-geometry":19,"../update-scroll":20}],17:[function(require,module,exports){ },{"../../lib/helper":6,"../instances":18,"../update-geometry":19,"../update-scroll":20}],17:[function(require,module,exports){
'use strict'; 'use strict';
var cls = require('../lib/class') var _ = require('../lib/helper');
, h = require('../lib/helper') var cls = require('../lib/class');
, instances = require('./instances') var instances = require('./instances');
, updateGeometry = require('./update-geometry'); var updateGeometry = require('./update-geometry');
// Handlers // Handlers
var clickRailHandler = require('./handler/click-rail') var handlers = {
, dragScrollbarHandler = require('./handler/drag-scrollbar') 'click-rail': require('./handler/click-rail'),
, keyboardHandler = require('./handler/keyboard') 'drag-scrollbar': require('./handler/drag-scrollbar'),
, mouseWheelHandler = require('./handler/mouse-wheel') 'keyboard': require('./handler/keyboard'),
, nativeScrollHandler = require('./handler/native-scroll') 'wheel': require('./handler/mouse-wheel'),
, selectionHandler = require('./handler/selection') 'touch': require('./handler/touch'),
, touchHandler = require('./handler/touch'); 'selection': require('./handler/selection')
};
var nativeScrollHandler = require('./handler/native-scroll');
module.exports = function (element, userSettings) { module.exports = function (element, userSettings) {
userSettings = typeof userSettings === 'object' ? userSettings : {}; userSettings = typeof userSettings === 'object' ? userSettings : {};
@ -1163,50 +1189,40 @@ module.exports = function (element, userSettings) {
// Create a plugin instance. // Create a plugin instance.
var i = instances.add(element); var i = instances.add(element);
i.settings = h.extend(i.settings, userSettings); i.settings = _.extend(i.settings, userSettings);
cls.add(element, 'ps-theme-' + i.settings.theme); cls.add(element, 'ps-theme-' + i.settings.theme);
clickRailHandler(element); i.settings.handlers.forEach(function (handlerName) {
dragScrollbarHandler(element); handlers[handlerName](element);
mouseWheelHandler(element); });
nativeScrollHandler(element); nativeScrollHandler(element);
if (i.settings.useSelectionScroll) {
selectionHandler(element);
}
if (h.env.supportsTouch || h.env.supportsIePointer) {
touchHandler(element, h.env.supportsTouch, h.env.supportsIePointer);
}
if (i.settings.useKeyboard) {
keyboardHandler(element);
}
updateGeometry(element); updateGeometry(element);
}; };
},{"../lib/class":2,"../lib/helper":6,"./handler/click-rail":10,"./handler/drag-scrollbar":11,"./handler/keyboard":12,"./handler/mouse-wheel":13,"./handler/native-scroll":14,"./handler/selection":15,"./handler/touch":16,"./instances":18,"./update-geometry":19}],18:[function(require,module,exports){ },{"../lib/class":2,"../lib/helper":6,"./handler/click-rail":10,"./handler/drag-scrollbar":11,"./handler/keyboard":12,"./handler/mouse-wheel":13,"./handler/native-scroll":14,"./handler/selection":15,"./handler/touch":16,"./instances":18,"./update-geometry":19}],18:[function(require,module,exports){
'use strict'; 'use strict';
var cls = require('../lib/class') var _ = require('../lib/helper');
, d = require('../lib/dom') var cls = require('../lib/class');
, defaultSettings = require('./default-setting') var defaultSettings = require('./default-setting');
, EventManager = require('../lib/event-manager') var dom = require('../lib/dom');
, guid = require('../lib/guid') var EventManager = require('../lib/event-manager');
, h = require('../lib/helper'); var guid = require('../lib/guid');
var instances = {}; var instances = {};
function Instance(element) { function Instance(element) {
var i = this; var i = this;
i.settings = h.clone(defaultSettings); i.settings = _.clone(defaultSettings);
i.containerWidth = null; i.containerWidth = null;
i.containerHeight = null; i.containerHeight = null;
i.contentWidth = null; i.contentWidth = null;
i.contentHeight = null; i.contentHeight = null;
i.isRtl = d.css(element, 'direction') === "rtl"; i.isRtl = dom.css(element, 'direction') === "rtl";
i.isNegativeScroll = (function () { i.isNegativeScroll = (function () {
var originalScrollLeft = element.scrollLeft; var originalScrollLeft = element.scrollLeft;
var result = null; var result = null;
@ -1227,67 +1243,55 @@ function Instance(element) {
cls.remove(element, 'ps-focus'); cls.remove(element, 'ps-focus');
} }
i.scrollbarXRail = d.appendTo(d.e('div', 'ps-scrollbar-x-rail'), element); i.scrollbarXRail = dom.appendTo(dom.e('div', 'ps-scrollbar-x-rail'), element);
i.scrollbarX = d.appendTo(d.e('div', 'ps-scrollbar-x'), i.scrollbarXRail); i.scrollbarX = dom.appendTo(dom.e('div', 'ps-scrollbar-x'), i.scrollbarXRail);
i.scrollbarX.setAttribute('tabindex', 0); i.scrollbarX.setAttribute('tabindex', 0);
i.event.bind(i.scrollbarX, 'focus', focus); i.event.bind(i.scrollbarX, 'focus', focus);
i.event.bind(i.scrollbarX, 'blur', blur); i.event.bind(i.scrollbarX, 'blur', blur);
i.scrollbarXActive = null; i.scrollbarXActive = null;
i.scrollbarXWidth = null; i.scrollbarXWidth = null;
i.scrollbarXLeft = null; i.scrollbarXLeft = null;
i.scrollbarXBottom = h.toInt(d.css(i.scrollbarXRail, 'bottom')); i.scrollbarXBottom = _.toInt(dom.css(i.scrollbarXRail, 'bottom'));
i.isScrollbarXUsingBottom = i.scrollbarXBottom === i.scrollbarXBottom; // !isNaN i.isScrollbarXUsingBottom = i.scrollbarXBottom === i.scrollbarXBottom; // !isNaN
i.scrollbarXTop = i.isScrollbarXUsingBottom ? null : h.toInt(d.css(i.scrollbarXRail, 'top')); i.scrollbarXTop = i.isScrollbarXUsingBottom ? null : _.toInt(dom.css(i.scrollbarXRail, 'top'));
i.railBorderXWidth = h.toInt(d.css(i.scrollbarXRail, 'borderLeftWidth')) + h.toInt(d.css(i.scrollbarXRail, 'borderRightWidth')); i.railBorderXWidth = _.toInt(dom.css(i.scrollbarXRail, 'borderLeftWidth')) + _.toInt(dom.css(i.scrollbarXRail, 'borderRightWidth'));
// Set rail to display:block to calculate margins // Set rail to display:block to calculate margins
d.css(i.scrollbarXRail, 'display', 'block'); dom.css(i.scrollbarXRail, 'display', 'block');
i.railXMarginWidth = h.toInt(d.css(i.scrollbarXRail, 'marginLeft')) + h.toInt(d.css(i.scrollbarXRail, 'marginRight')); i.railXMarginWidth = _.toInt(dom.css(i.scrollbarXRail, 'marginLeft')) + _.toInt(dom.css(i.scrollbarXRail, 'marginRight'));
d.css(i.scrollbarXRail, 'display', ''); dom.css(i.scrollbarXRail, 'display', '');
i.railXWidth = null; i.railXWidth = null;
i.railXRatio = null; i.railXRatio = null;
i.scrollbarYRail = d.appendTo(d.e('div', 'ps-scrollbar-y-rail'), element); i.scrollbarYRail = dom.appendTo(dom.e('div', 'ps-scrollbar-y-rail'), element);
i.scrollbarY = d.appendTo(d.e('div', 'ps-scrollbar-y'), i.scrollbarYRail); i.scrollbarY = dom.appendTo(dom.e('div', 'ps-scrollbar-y'), i.scrollbarYRail);
i.scrollbarY.setAttribute('tabindex', 0); i.scrollbarY.setAttribute('tabindex', 0);
i.event.bind(i.scrollbarY, 'focus', focus); i.event.bind(i.scrollbarY, 'focus', focus);
i.event.bind(i.scrollbarY, 'blur', blur); i.event.bind(i.scrollbarY, 'blur', blur);
i.scrollbarYActive = null; i.scrollbarYActive = null;
i.scrollbarYHeight = null; i.scrollbarYHeight = null;
i.scrollbarYTop = null; i.scrollbarYTop = null;
i.scrollbarYRight = h.toInt(d.css(i.scrollbarYRail, 'right')); i.scrollbarYRight = _.toInt(dom.css(i.scrollbarYRail, 'right'));
i.isScrollbarYUsingRight = i.scrollbarYRight === i.scrollbarYRight; // !isNaN i.isScrollbarYUsingRight = i.scrollbarYRight === i.scrollbarYRight; // !isNaN
i.scrollbarYLeft = i.isScrollbarYUsingRight ? null : h.toInt(d.css(i.scrollbarYRail, 'left')); i.scrollbarYLeft = i.isScrollbarYUsingRight ? null : _.toInt(dom.css(i.scrollbarYRail, 'left'));
i.scrollbarYOuterWidth = i.isRtl ? h.outerWidth(i.scrollbarY) : null; i.scrollbarYOuterWidth = i.isRtl ? _.outerWidth(i.scrollbarY) : null;
i.railBorderYWidth = h.toInt(d.css(i.scrollbarYRail, 'borderTopWidth')) + h.toInt(d.css(i.scrollbarYRail, 'borderBottomWidth')); i.railBorderYWidth = _.toInt(dom.css(i.scrollbarYRail, 'borderTopWidth')) + _.toInt(dom.css(i.scrollbarYRail, 'borderBottomWidth'));
d.css(i.scrollbarYRail, 'display', 'block'); dom.css(i.scrollbarYRail, 'display', 'block');
i.railYMarginHeight = h.toInt(d.css(i.scrollbarYRail, 'marginTop')) + h.toInt(d.css(i.scrollbarYRail, 'marginBottom')); i.railYMarginHeight = _.toInt(dom.css(i.scrollbarYRail, 'marginTop')) + _.toInt(dom.css(i.scrollbarYRail, 'marginBottom'));
d.css(i.scrollbarYRail, 'display', ''); dom.css(i.scrollbarYRail, 'display', '');
i.railYHeight = null; i.railYHeight = null;
i.railYRatio = null; i.railYRatio = null;
} }
function getId(element) { function getId(element) {
if (typeof element.dataset === 'undefined') {
return element.getAttribute('data-ps-id'); return element.getAttribute('data-ps-id');
} else {
return element.dataset.psId;
}
} }
function setId(element, id) { function setId(element, id) {
if (typeof element.dataset === 'undefined') {
element.setAttribute('data-ps-id', id); element.setAttribute('data-ps-id', id);
} else {
element.dataset.psId = id;
}
} }
function removeId(element) { function removeId(element) {
if (typeof element.dataset === 'undefined') {
element.removeAttribute('data-ps-id'); element.removeAttribute('data-ps-id');
} else {
delete element.dataset.psId;
}
} }
exports.add = function (element) { exports.add = function (element) {
@ -1309,11 +1313,11 @@ exports.get = function (element) {
},{"../lib/class":2,"../lib/dom":3,"../lib/event-manager":4,"../lib/guid":5,"../lib/helper":6,"./default-setting":8}],19:[function(require,module,exports){ },{"../lib/class":2,"../lib/dom":3,"../lib/event-manager":4,"../lib/guid":5,"../lib/helper":6,"./default-setting":8}],19:[function(require,module,exports){
'use strict'; 'use strict';
var cls = require('../lib/class') var _ = require('../lib/helper');
, d = require('../lib/dom') var cls = require('../lib/class');
, h = require('../lib/helper') var dom = require('../lib/dom');
, instances = require('./instances') var instances = require('./instances');
, updateScroll = require('./update-scroll'); var updateScroll = require('./update-scroll');
function getThumbSize(i, thumbSize) { function getThumbSize(i, thumbSize) {
if (i.settings.minScrollbarLength) { if (i.settings.minScrollbarLength) {
@ -1337,7 +1341,7 @@ function updateCss(element, i) {
} else { } else {
xRailOffset.top = i.scrollbarXTop + element.scrollTop; xRailOffset.top = i.scrollbarXTop + element.scrollTop;
} }
d.css(i.scrollbarXRail, xRailOffset); dom.css(i.scrollbarXRail, xRailOffset);
var yRailOffset = {top: element.scrollTop, height: i.railYHeight}; var yRailOffset = {top: element.scrollTop, height: i.railYHeight};
if (i.isScrollbarYUsingRight) { if (i.isScrollbarYUsingRight) {
@ -1353,10 +1357,10 @@ function updateCss(element, i) {
yRailOffset.left = i.scrollbarYLeft + element.scrollLeft; yRailOffset.left = i.scrollbarYLeft + element.scrollLeft;
} }
} }
d.css(i.scrollbarYRail, yRailOffset); dom.css(i.scrollbarYRail, yRailOffset);
d.css(i.scrollbarX, {left: i.scrollbarXLeft, width: i.scrollbarXWidth - i.railBorderXWidth}); dom.css(i.scrollbarX, {left: i.scrollbarXLeft, width: i.scrollbarXWidth - i.railBorderXWidth});
d.css(i.scrollbarY, {top: i.scrollbarYTop, height: i.scrollbarYHeight - i.railBorderYWidth}); dom.css(i.scrollbarY, {top: i.scrollbarYTop, height: i.scrollbarYHeight - i.railBorderYWidth});
} }
module.exports = function (element) { module.exports = function (element) {
@ -1369,30 +1373,30 @@ module.exports = function (element) {
var existingRails; var existingRails;
if (!element.contains(i.scrollbarXRail)) { if (!element.contains(i.scrollbarXRail)) {
existingRails = d.queryChildren(element, '.ps-scrollbar-x-rail'); existingRails = dom.queryChildren(element, '.ps-scrollbar-x-rail');
if (existingRails.length > 0) { if (existingRails.length > 0) {
existingRails.forEach(function (rail) { existingRails.forEach(function (rail) {
d.remove(rail); dom.remove(rail);
}); });
} }
d.appendTo(i.scrollbarXRail, element); dom.appendTo(i.scrollbarXRail, element);
} }
if (!element.contains(i.scrollbarYRail)) { if (!element.contains(i.scrollbarYRail)) {
existingRails = d.queryChildren(element, '.ps-scrollbar-y-rail'); existingRails = dom.queryChildren(element, '.ps-scrollbar-y-rail');
if (existingRails.length > 0) { if (existingRails.length > 0) {
existingRails.forEach(function (rail) { existingRails.forEach(function (rail) {
d.remove(rail); dom.remove(rail);
}); });
} }
d.appendTo(i.scrollbarYRail, element); dom.appendTo(i.scrollbarYRail, element);
} }
if (!i.settings.suppressScrollX && i.containerWidth + i.settings.scrollXMarginOffset < i.contentWidth) { if (!i.settings.suppressScrollX && i.containerWidth + i.settings.scrollXMarginOffset < i.contentWidth) {
i.scrollbarXActive = true; i.scrollbarXActive = true;
i.railXWidth = i.containerWidth - i.railXMarginWidth; i.railXWidth = i.containerWidth - i.railXMarginWidth;
i.railXRatio = i.containerWidth / i.railXWidth; i.railXRatio = i.containerWidth / i.railXWidth;
i.scrollbarXWidth = getThumbSize(i, h.toInt(i.railXWidth * i.containerWidth / i.contentWidth)); i.scrollbarXWidth = getThumbSize(i, _.toInt(i.railXWidth * i.containerWidth / i.contentWidth));
i.scrollbarXLeft = h.toInt((i.negativeScrollAdjustment + element.scrollLeft) * (i.railXWidth - i.scrollbarXWidth) / (i.contentWidth - i.containerWidth)); i.scrollbarXLeft = _.toInt((i.negativeScrollAdjustment + element.scrollLeft) * (i.railXWidth - i.scrollbarXWidth) / (i.contentWidth - i.containerWidth));
} else { } else {
i.scrollbarXActive = false; i.scrollbarXActive = false;
} }
@ -1401,8 +1405,8 @@ module.exports = function (element) {
i.scrollbarYActive = true; i.scrollbarYActive = true;
i.railYHeight = i.containerHeight - i.railYMarginHeight; i.railYHeight = i.containerHeight - i.railYMarginHeight;
i.railYRatio = i.containerHeight / i.railYHeight; i.railYRatio = i.containerHeight / i.railYHeight;
i.scrollbarYHeight = getThumbSize(i, h.toInt(i.railYHeight * i.containerHeight / i.contentHeight)); i.scrollbarYHeight = getThumbSize(i, _.toInt(i.railYHeight * i.containerHeight / i.contentHeight));
i.scrollbarYTop = h.toInt(element.scrollTop * (i.railYHeight - i.scrollbarYHeight) / (i.contentHeight - i.containerHeight)); i.scrollbarYTop = _.toInt(element.scrollTop * (i.railYHeight - i.scrollbarYHeight) / (i.contentHeight - i.containerHeight));
} else { } else {
i.scrollbarYActive = false; i.scrollbarYActive = false;
} }
@ -1439,29 +1443,14 @@ module.exports = function (element) {
var instances = require('./instances'); var instances = require('./instances');
var upEvent = document.createEvent('Event') var lastTop;
, downEvent = document.createEvent('Event') var lastLeft;
, leftEvent = document.createEvent('Event')
, rightEvent = document.createEvent('Event')
, yEvent = document.createEvent('Event')
, xEvent = document.createEvent('Event')
, xStartEvent = document.createEvent('Event')
, xEndEvent = document.createEvent('Event')
, yStartEvent = document.createEvent('Event')
, yEndEvent = document.createEvent('Event')
, lastTop
, lastLeft;
upEvent.initEvent('ps-scroll-up', true, true); var createDOMEvent = function (name) {
downEvent.initEvent('ps-scroll-down', true, true); var event = document.createEvent("Event");
leftEvent.initEvent('ps-scroll-left', true, true); event.initEvent(name, true, true);
rightEvent.initEvent('ps-scroll-right', true, true); return event;
yEvent.initEvent('ps-scroll-y', true, true); };
xEvent.initEvent('ps-scroll-x', true, true);
xStartEvent.initEvent('ps-x-reach-start', true, true);
xEndEvent.initEvent('ps-x-reach-end', true, true);
yStartEvent.initEvent('ps-y-reach-start', true, true);
yEndEvent.initEvent('ps-y-reach-end', true, true);
module.exports = function (element, axis, value) { module.exports = function (element, axis, value) {
if (typeof element === 'undefined') { if (typeof element === 'undefined') {
@ -1478,24 +1467,38 @@ module.exports = function (element, axis, value) {
if (axis === 'top' && value <= 0) { if (axis === 'top' && value <= 0) {
element.scrollTop = value = 0; // don't allow negative scroll element.scrollTop = value = 0; // don't allow negative scroll
element.dispatchEvent(yStartEvent); element.dispatchEvent(createDOMEvent('ps-y-reach-start'));
} }
if (axis === 'left' && value <= 0) { if (axis === 'left' && value <= 0) {
element.scrollLeft = value = 0; // don't allow negative scroll element.scrollLeft = value = 0; // don't allow negative scroll
element.dispatchEvent(xStartEvent); element.dispatchEvent(createDOMEvent('ps-x-reach-start'));
} }
var i = instances.get(element); var i = instances.get(element);
if (axis === 'top' && value >= i.contentHeight - i.containerHeight) { if (axis === 'top' && value >= i.contentHeight - i.containerHeight) {
element.scrollTop = value = i.contentHeight - i.containerHeight; // don't allow scroll past container // don't allow scroll past container
element.dispatchEvent(yEndEvent); value = i.contentHeight - i.containerHeight;
if (value - element.scrollTop <= 1) {
// mitigates rounding errors on non-subpixel scroll values
value = element.scrollTop;
} else {
element.scrollTop = value;
}
element.dispatchEvent(createDOMEvent('ps-y-reach-end'));
} }
if (axis === 'left' && value >= i.contentWidth - i.containerWidth) { if (axis === 'left' && value >= i.contentWidth - i.containerWidth) {
element.scrollLeft = value = i.contentWidth - i.containerWidth; // don't allow scroll past container // don't allow scroll past container
element.dispatchEvent(xEndEvent); value = i.contentWidth - i.containerWidth;
if (value - element.scrollLeft <= 1) {
// mitigates rounding errors on non-subpixel scroll values
value = element.scrollLeft;
} else {
element.scrollLeft = value;
}
element.dispatchEvent(createDOMEvent('ps-x-reach-end'));
} }
if (!lastTop) { if (!lastTop) {
@ -1507,29 +1510,29 @@ module.exports = function (element, axis, value) {
} }
if (axis === 'top' && value < lastTop) { if (axis === 'top' && value < lastTop) {
element.dispatchEvent(upEvent); element.dispatchEvent(createDOMEvent('ps-scroll-up'));
} }
if (axis === 'top' && value > lastTop) { if (axis === 'top' && value > lastTop) {
element.dispatchEvent(downEvent); element.dispatchEvent(createDOMEvent('ps-scroll-down'));
} }
if (axis === 'left' && value < lastLeft) { if (axis === 'left' && value < lastLeft) {
element.dispatchEvent(leftEvent); element.dispatchEvent(createDOMEvent('ps-scroll-left'));
} }
if (axis === 'left' && value > lastLeft) { if (axis === 'left' && value > lastLeft) {
element.dispatchEvent(rightEvent); element.dispatchEvent(createDOMEvent('ps-scroll-right'));
} }
if (axis === 'top') { if (axis === 'top') {
element.scrollTop = lastTop = value; element.scrollTop = lastTop = value;
element.dispatchEvent(yEvent); element.dispatchEvent(createDOMEvent('ps-scroll-y'));
} }
if (axis === 'left') { if (axis === 'left') {
element.scrollLeft = lastLeft = value; element.scrollLeft = lastLeft = value;
element.dispatchEvent(xEvent); element.dispatchEvent(createDOMEvent('ps-scroll-x'));
} }
}; };
@ -1537,11 +1540,11 @@ module.exports = function (element, axis, value) {
},{"./instances":18}],21:[function(require,module,exports){ },{"./instances":18}],21:[function(require,module,exports){
'use strict'; 'use strict';
var d = require('../lib/dom') var _ = require('../lib/helper');
, h = require('../lib/helper') var dom = require('../lib/dom');
, instances = require('./instances') var instances = require('./instances');
, updateGeometry = require('./update-geometry') var updateGeometry = require('./update-geometry');
, updateScroll = require('./update-scroll'); var updateScroll = require('./update-scroll');
module.exports = function (element) { module.exports = function (element) {
var i = instances.get(element); var i = instances.get(element);
@ -1554,14 +1557,14 @@ module.exports = function (element) {
i.negativeScrollAdjustment = i.isNegativeScroll ? element.scrollWidth - element.clientWidth : 0; i.negativeScrollAdjustment = i.isNegativeScroll ? element.scrollWidth - element.clientWidth : 0;
// Recalculate rail margins // Recalculate rail margins
d.css(i.scrollbarXRail, 'display', 'block'); dom.css(i.scrollbarXRail, 'display', 'block');
d.css(i.scrollbarYRail, 'display', 'block'); dom.css(i.scrollbarYRail, 'display', 'block');
i.railXMarginWidth = h.toInt(d.css(i.scrollbarXRail, 'marginLeft')) + h.toInt(d.css(i.scrollbarXRail, 'marginRight')); i.railXMarginWidth = _.toInt(dom.css(i.scrollbarXRail, 'marginLeft')) + _.toInt(dom.css(i.scrollbarXRail, 'marginRight'));
i.railYMarginHeight = h.toInt(d.css(i.scrollbarYRail, 'marginTop')) + h.toInt(d.css(i.scrollbarYRail, 'marginBottom')); i.railYMarginHeight = _.toInt(dom.css(i.scrollbarYRail, 'marginTop')) + _.toInt(dom.css(i.scrollbarYRail, 'marginBottom'));
// Hide scrollbars not to affect scrollWidth and scrollHeight // Hide scrollbars not to affect scrollWidth and scrollHeight
d.css(i.scrollbarXRail, 'display', 'none'); dom.css(i.scrollbarXRail, 'display', 'none');
d.css(i.scrollbarYRail, 'display', 'none'); dom.css(i.scrollbarYRail, 'display', 'none');
updateGeometry(element); updateGeometry(element);
@ -1569,8 +1572,8 @@ module.exports = function (element) {
updateScroll(element, 'top', element.scrollTop); updateScroll(element, 'top', element.scrollTop);
updateScroll(element, 'left', element.scrollLeft); updateScroll(element, 'left', element.scrollLeft);
d.css(i.scrollbarXRail, 'display', ''); dom.css(i.scrollbarXRail, 'display', '');
d.css(i.scrollbarYRail, 'display', ''); dom.css(i.scrollbarYRail, 'display', '');
}; };
},{"../lib/dom":3,"../lib/helper":6,"./instances":18,"./update-geometry":19,"./update-scroll":20}]},{},[1]); },{"../lib/dom":3,"../lib/helper":6,"./instances":18,"./update-geometry":19,"./update-scroll":20}]},{},[1]);

File diff suppressed because one or more lines are too long

View file

@ -1,2 +1,2 @@
/* perfect-scrollbar v0.6.10 */ /* perfect-scrollbar v0.6.15 */
.ps-container{-ms-touch-action:none;touch-action:none;overflow:hidden !important;-ms-overflow-style:none}@supports (-ms-overflow-style: none){.ps-container{overflow:auto !important}}@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none){.ps-container{overflow:auto !important}}.ps-container.ps-active-x>.ps-scrollbar-x-rail,.ps-container.ps-active-y>.ps-scrollbar-y-rail{display:block;background-color:transparent}.ps-container.ps-in-scrolling{pointer-events:none}.ps-container.ps-in-scrolling.ps-x>.ps-scrollbar-x-rail{background-color:#eee;opacity:0.9}.ps-container.ps-in-scrolling.ps-x>.ps-scrollbar-x-rail>.ps-scrollbar-x{background-color:#999}.ps-container.ps-in-scrolling.ps-y>.ps-scrollbar-y-rail{background-color:#eee;opacity:0.9}.ps-container.ps-in-scrolling.ps-y>.ps-scrollbar-y-rail>.ps-scrollbar-y{background-color:#999}.ps-container>.ps-scrollbar-x-rail{display:none;position:absolute;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;opacity:0;-webkit-transition:background-color .2s linear, opacity .2s linear;-moz-transition:background-color .2s linear, opacity .2s linear;-o-transition:background-color .2s linear, opacity .2s linear;transition:background-color .2s linear, opacity .2s linear;bottom:3px;height:8px}.ps-container>.ps-scrollbar-x-rail>.ps-scrollbar-x{position:absolute;background-color:#aaa;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-transition:background-color .2s linear;-moz-transition:background-color .2s linear;-o-transition:background-color .2s linear;transition:background-color .2s linear;bottom:0;height:8px}.ps-container>.ps-scrollbar-y-rail{display:none;position:absolute;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;opacity:0;-webkit-transition:background-color .2s linear, opacity .2s linear;-moz-transition:background-color .2s linear, opacity .2s linear;-o-transition:background-color .2s linear, opacity .2s linear;transition:background-color .2s linear, opacity .2s linear;right:3px;width:8px}.ps-container>.ps-scrollbar-y-rail>.ps-scrollbar-y{position:absolute;background-color:#aaa;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-transition:background-color .2s linear;-moz-transition:background-color .2s linear;-o-transition:background-color .2s linear;transition:background-color .2s linear;right:0;width:8px}.ps-container:hover.ps-in-scrolling{pointer-events:none}.ps-container:hover.ps-in-scrolling.ps-x>.ps-scrollbar-x-rail{background-color:#eee;opacity:0.9}.ps-container:hover.ps-in-scrolling.ps-x>.ps-scrollbar-x-rail>.ps-scrollbar-x{background-color:#999}.ps-container:hover.ps-in-scrolling.ps-y>.ps-scrollbar-y-rail{background-color:#eee;opacity:0.9}.ps-container:hover.ps-in-scrolling.ps-y>.ps-scrollbar-y-rail>.ps-scrollbar-y{background-color:#999}.ps-container:hover>.ps-scrollbar-x-rail,.ps-container:hover>.ps-scrollbar-y-rail{opacity:0.6}.ps-container:hover>.ps-scrollbar-x-rail:hover{background-color:#eee;opacity:0.9}.ps-container:hover>.ps-scrollbar-x-rail:hover>.ps-scrollbar-x{background-color:#999}.ps-container:hover>.ps-scrollbar-y-rail:hover{background-color:#eee;opacity:0.9}.ps-container:hover>.ps-scrollbar-y-rail:hover>.ps-scrollbar-y{background-color:#999} .ps-container{-ms-touch-action:auto;touch-action:auto;overflow:hidden !important;-ms-overflow-style:none}@supports (-ms-overflow-style: none){.ps-container{overflow:auto !important}}@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none){.ps-container{overflow:auto !important}}.ps-container.ps-active-x>.ps-scrollbar-x-rail,.ps-container.ps-active-y>.ps-scrollbar-y-rail{display:block;background-color:transparent}.ps-container.ps-in-scrolling.ps-x>.ps-scrollbar-x-rail{background-color:#eee;opacity:.9}.ps-container.ps-in-scrolling.ps-x>.ps-scrollbar-x-rail>.ps-scrollbar-x{background-color:#999;height:11px}.ps-container.ps-in-scrolling.ps-y>.ps-scrollbar-y-rail{background-color:#eee;opacity:.9}.ps-container.ps-in-scrolling.ps-y>.ps-scrollbar-y-rail>.ps-scrollbar-y{background-color:#999;width:11px}.ps-container>.ps-scrollbar-x-rail{display:none;position:absolute;opacity:0;-webkit-transition:background-color .2s linear, opacity .2s linear;-o-transition:background-color .2s linear, opacity .2s linear;-moz-transition:background-color .2s linear, opacity .2s linear;transition:background-color .2s linear, opacity .2s linear;bottom:0px;height:15px}.ps-container>.ps-scrollbar-x-rail>.ps-scrollbar-x{position:absolute;background-color:#aaa;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, -webkit-border-radius .2s ease-in-out;transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, -webkit-border-radius .2s ease-in-out;-o-transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out;-moz-transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out, -moz-border-radius .2s ease-in-out;transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out;transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out, -webkit-border-radius .2s ease-in-out, -moz-border-radius .2s ease-in-out;bottom:2px;height:6px}.ps-container>.ps-scrollbar-x-rail:hover>.ps-scrollbar-x,.ps-container>.ps-scrollbar-x-rail:active>.ps-scrollbar-x{height:11px}.ps-container>.ps-scrollbar-y-rail{display:none;position:absolute;opacity:0;-webkit-transition:background-color .2s linear, opacity .2s linear;-o-transition:background-color .2s linear, opacity .2s linear;-moz-transition:background-color .2s linear, opacity .2s linear;transition:background-color .2s linear, opacity .2s linear;right:0;width:15px}.ps-container>.ps-scrollbar-y-rail>.ps-scrollbar-y{position:absolute;background-color:#aaa;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, -webkit-border-radius .2s ease-in-out;transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, -webkit-border-radius .2s ease-in-out;-o-transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out;-moz-transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out, -moz-border-radius .2s ease-in-out;transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out;transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out, -webkit-border-radius .2s ease-in-out, -moz-border-radius .2s ease-in-out;right:2px;width:6px}.ps-container>.ps-scrollbar-y-rail:hover>.ps-scrollbar-y,.ps-container>.ps-scrollbar-y-rail:active>.ps-scrollbar-y{width:11px}.ps-container:hover.ps-in-scrolling.ps-x>.ps-scrollbar-x-rail{background-color:#eee;opacity:.9}.ps-container:hover.ps-in-scrolling.ps-x>.ps-scrollbar-x-rail>.ps-scrollbar-x{background-color:#999;height:11px}.ps-container:hover.ps-in-scrolling.ps-y>.ps-scrollbar-y-rail{background-color:#eee;opacity:.9}.ps-container:hover.ps-in-scrolling.ps-y>.ps-scrollbar-y-rail>.ps-scrollbar-y{background-color:#999;width:11px}.ps-container:hover>.ps-scrollbar-x-rail,.ps-container:hover>.ps-scrollbar-y-rail{opacity:.6}.ps-container:hover>.ps-scrollbar-x-rail:hover{background-color:#eee;opacity:.9}.ps-container:hover>.ps-scrollbar-x-rail:hover>.ps-scrollbar-x{background-color:#999}.ps-container:hover>.ps-scrollbar-y-rail:hover{background-color:#eee;opacity:.9}.ps-container:hover>.ps-scrollbar-y-rail:hover>.ps-scrollbar-y{background-color:#999}

View file

@ -32,13 +32,12 @@ function admin_post(&$a){
// do not allow a page manager to access the admin panel at all. // do not allow a page manager to access the admin panel at all.
if(x($_SESSION,'submanage') && intval($_SESSION['submanage'])) if (x($_SESSION,'submanage') && intval($_SESSION['submanage'])) {
return; return;
}
// urls // urls
if($a->argc > 1) { if ($a->argc > 1) {
switch ($a->argv[1]){ switch ($a->argv[1]){
case 'site': case 'site':
admin_page_site_post($a); admin_page_site_post($a);
@ -134,8 +133,9 @@ function admin_content(&$a) {
return login(false); return login(false);
} }
if(x($_SESSION,'submanage') && intval($_SESSION['submanage'])) if (x($_SESSION,'submanage') && intval($_SESSION['submanage'])) {
return ""; return "";
}
// APC deactivated, since there are problems with PHP 5.5 // APC deactivated, since there are problems with PHP 5.5
//if (function_exists("apc_delete")) { //if (function_exists("apc_delete")) {
@ -285,14 +285,14 @@ function admin_page_federation(&$a) {
// get a total count for the platform, the name and version of the // get a total count for the platform, the name and version of the
// highest version and the protocol tpe // highest version and the protocol tpe
$c = qu('SELECT COUNT(*) AS `total`, `platform`, `network`, `version` FROM `gserver` $c = qu('SELECT COUNT(*) AS `total`, `platform`, `network`, `version` FROM `gserver`
WHERE `platform` LIKE "%s" AND `last_contact` > `last_failure` WHERE `platform` LIKE "%s" AND `last_contact` >= `last_failure`
ORDER BY `version` ASC;', $p); ORDER BY `version` ASC;', $p);
$total = $total + $c[0]['total']; $total = $total + $c[0]['total'];
// what versions for that platform do we know at all? // what versions for that platform do we know at all?
// again only the active nodes // again only the active nodes
$v = qu('SELECT COUNT(*) AS `total`, `version` FROM `gserver` $v = qu('SELECT COUNT(*) AS `total`, `version` FROM `gserver`
WHERE `last_contact` > `last_failure` AND `platform` LIKE "%s" WHERE `last_contact` >= `last_failure` AND `platform` LIKE "%s"
GROUP BY `version` GROUP BY `version`
ORDER BY `version`;', $p); ORDER BY `version`;', $p);
@ -376,7 +376,7 @@ function admin_page_federation(&$a) {
'$counts' => $counts, '$counts' => $counts,
'$version' => FRIENDICA_VERSION, '$version' => FRIENDICA_VERSION,
'$legendtext' => sprintf(t('Currently this node is aware of %d nodes from the following platforms:'), $total), '$legendtext' => sprintf(t('Currently this node is aware of %d nodes from the following platforms:'), $total),
'$baseurl' => $a->get_baseurl(), '$baseurl' => App::get_baseurl(),
)); ));
} }
@ -489,7 +489,7 @@ function admin_page_summary(&$a) {
'$accounts' => $accounts, '$accounts' => $accounts,
'$pending' => array(t('Pending registrations'), $pending), '$pending' => array(t('Pending registrations'), $pending),
'$version' => array(t('Version'), FRIENDICA_VERSION), '$version' => array(t('Version'), FRIENDICA_VERSION),
'$baseurl' => $a->get_baseurl(), '$baseurl' => App::get_baseurl(),
'$platform' => FRIENDICA_PLATFORM, '$platform' => FRIENDICA_PLATFORM,
'$codename' => FRIENDICA_CODENAME, '$codename' => FRIENDICA_CODENAME,
'$build' => get_config('system','build'), '$build' => get_config('system','build'),
@ -527,7 +527,7 @@ function admin_page_site_post(&$a) {
* send relocate for every local user * send relocate for every local user
* */ * */
$old_url = $a->get_baseurl(true); $old_url = App::get_baseurl(true);
// Generate host names for relocation the addresses in the format user@address.tld // Generate host names for relocation the addresses in the format user@address.tld
$new_host = str_replace("http://", "@", normalise_link($new_url)); $new_host = str_replace("http://", "@", normalise_link($new_url));
@ -961,7 +961,7 @@ function admin_page_site(&$a) {
'$performance' => t('Performance'), '$performance' => t('Performance'),
'$worker_title' => t('Worker'), '$worker_title' => t('Worker'),
'$relocate'=> t('Relocate - WARNING: advanced function. Could make this server unreachable.'), '$relocate'=> t('Relocate - WARNING: advanced function. Could make this server unreachable.'),
'$baseurl' => $a->get_baseurl(true), '$baseurl' => App::get_baseurl(true),
// name, label, value, help string, extra data... // name, label, value, help string, extra data...
'$sitename' => array('sitename', t("Site name"), $a->config['sitename'],''), '$sitename' => array('sitename', t("Site name"), $a->config['sitename'],''),
'$hostname' => array('hostname', t("Host name"), $a->config['hostname'], ""), '$hostname' => array('hostname', t("Host name"), $a->config['hostname'], ""),
@ -1043,7 +1043,7 @@ function admin_page_site(&$a) {
'$old_pager' => array('old_pager', t("Enable old style pager"), get_config('system','old_pager'), t("The old style pager has page numbers but slows down massively the page speed.")), '$old_pager' => array('old_pager', t("Enable old style pager"), get_config('system','old_pager'), t("The old style pager has page numbers but slows down massively the page speed.")),
'$only_tag_search' => array('only_tag_search', t("Only search in tags"), get_config('system','only_tag_search'), t("On large systems the text search can slow down the system extremely.")), '$only_tag_search' => array('only_tag_search', t("Only search in tags"), get_config('system','only_tag_search'), t("On large systems the text search can slow down the system extremely.")),
'$relocate_url' => array('relocate_url', t("New base url"), $a->get_baseurl(), t("Change base url for this server. Sends relocate message to all DFRN contacts of all users.")), '$relocate_url' => array('relocate_url', t("New base url"), App::get_baseurl(), t("Change base url for this server. Sends relocate message to all DFRN contacts of all users.")),
'$rino' => array('rino', t("RINO Encryption"), intval(get_config('system','rino_encrypt')), t("Encryption layer between nodes."), array("Disabled", "RINO1 (deprecated)", "RINO2")), '$rino' => array('rino', t("RINO Encryption"), intval(get_config('system','rino_encrypt')), t("Encryption layer between nodes."), array("Disabled", "RINO1 (deprecated)", "RINO2")),
'$embedly' => array('embedly', t("Embedly API key"), get_config('system','embedly'), t("<a href='http://embed.ly'>Embedly</a> is used to fetch additional data for web pages. This is an optional parameter.")), '$embedly' => array('embedly', t("Embedly API key"), get_config('system','embedly'), t("<a href='http://embed.ly'>Embedly</a> is used to fetch additional data for web pages. This is an optional parameter.")),
@ -1122,22 +1122,22 @@ function admin_page_dbsync(&$a) {
$failed = array(); $failed = array();
$r = q("SELECT `k`, `v` FROM `config` WHERE `cat` = 'database' "); $r = q("SELECT `k`, `v` FROM `config` WHERE `cat` = 'database' ");
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) { foreach ($r as $rr) {
$upd = intval(substr($rr['k'],7)); $upd = intval(substr($rr['k'],7));
if($upd < 1139 || $rr['v'] === 'success') if($upd < 1139 || $rr['v'] === 'success')
continue; continue;
$failed[] = $upd; $failed[] = $upd;
} }
} }
if(! count($failed)) { if (! count($failed)) {
$o = replace_macros(get_markup_template('structure_check.tpl'),array( $o = replace_macros(get_markup_template('structure_check.tpl'),array(
'$base' => $a->get_baseurl(true), '$base' => App::get_baseurl(true),
'$banner' => t('No failed updates.'), '$banner' => t('No failed updates.'),
'$check' => t('Check database structure'), '$check' => t('Check database structure'),
)); ));
} else { } else {
$o = replace_macros(get_markup_template('failed_updates.tpl'),array( $o = replace_macros(get_markup_template('failed_updates.tpl'),array(
'$base' => $a->get_baseurl(true), '$base' => App::get_baseurl(true),
'$banner' => t('Failed Updates'), '$banner' => t('Failed Updates'),
'$desc' => t('This does not include updates prior to 1139, which did not return a status.'), '$desc' => t('This does not include updates prior to 1139, which did not return a status.'),
'$mark' => t('Mark success (if update was manually applied)'), '$mark' => t('Mark success (if update was manually applied)'),
@ -1205,7 +1205,7 @@ function admin_page_users_post(&$a){
Thank you and welcome to %4$s.')); Thank you and welcome to %4$s.'));
$preamble = sprintf($preamble, $nu['username'], $a->config['sitename']); $preamble = sprintf($preamble, $nu['username'], $a->config['sitename']);
$body = sprintf($body, $a->get_baseurl(), $nu['email'], $result['password'], $a->config['sitename']); $body = sprintf($body, App::get_baseurl(), $nu['email'], $result['password'], $a->config['sitename']);
notification(array( notification(array(
'type' => "SYSTEM_EMAIL", 'type' => "SYSTEM_EMAIL",
@ -1430,7 +1430,7 @@ function admin_page_users(&$a){
'$form_security_token' => get_form_security_token("admin_users"), '$form_security_token' => get_form_security_token("admin_users"),
// values // // values //
'$baseurl' => $a->get_baseurl(true), '$baseurl' => App::get_baseurl(true),
'$pending' => $pending, '$pending' => $pending,
'deleted' => $deleted, 'deleted' => $deleted,
@ -1522,7 +1522,7 @@ function admin_page_plugins(&$a){
'$page' => t('Plugins'), '$page' => t('Plugins'),
'$toggle' => t('Toggle'), '$toggle' => t('Toggle'),
'$settings' => t('Settings'), '$settings' => t('Settings'),
'$baseurl' => $a->get_baseurl(true), '$baseurl' => App::get_baseurl(true),
'$plugin' => $plugin, '$plugin' => $plugin,
'$status' => $status, '$status' => $status,
@ -1546,35 +1546,38 @@ function admin_page_plugins(&$a){
* List plugins * List plugins
*/ */
if(x($_GET,"a") && $_GET['a']=="r") { if (x($_GET,"a") && $_GET['a']=="r") {
check_form_security_token_redirectOnErr($a->get_baseurl().'/admin/plugins', 'admin_themes', 't'); check_form_security_token_redirectOnErr(App::get_baseurl().'/admin/plugins', 'admin_themes', 't');
reload_plugins(); reload_plugins();
info("Plugins reloaded"); info("Plugins reloaded");
goaway($a->get_baseurl().'/admin/plugins'); goaway(App::get_baseurl().'/admin/plugins');
} }
$plugins = array(); $plugins = array();
$files = glob("addon/*/"); $files = glob("addon/*/");
if($files) { if ($files) {
foreach($files as $file) { foreach ($files as $file) {
if(is_dir($file)) { if (is_dir($file)) {
list($tmp, $id)=array_map("trim", explode("/",$file)); list($tmp, $id)=array_map("trim", explode("/",$file));
$info = get_plugin_info($id); $info = get_plugin_info($id);
$show_plugin = true; $show_plugin = true;
// If the addon is unsupported, then only show it, when it is enabled // If the addon is unsupported, then only show it, when it is enabled
if((strtolower($info["status"]) == "unsupported") AND !in_array($id, $a->plugins)) if ((strtolower($info["status"]) == "unsupported") AND !in_array($id, $a->plugins)) {
$show_plugin = false; $show_plugin = false;
}
// Override the above szenario, when the admin really wants to see outdated stuff // Override the above szenario, when the admin really wants to see outdated stuff
if(get_config("system", "show_unsupported_addons")) if (get_config("system", "show_unsupported_addons")) {
$show_plugin = true; $show_plugin = true;
}
if($show_plugin) if ($show_plugin) {
$plugins[] = array($id, (in_array($id, $a->plugins)?"on":"off") , $info); $plugins[] = array($id, (in_array($id, $a->plugins)?"on":"off") , $info);
} }
} }
} }
}
$t = get_markup_template("admin_plugins.tpl"); $t = get_markup_template("admin_plugins.tpl");
return replace_macros($t, array( return replace_macros($t, array(
@ -1582,7 +1585,7 @@ function admin_page_plugins(&$a){
'$page' => t('Plugins'), '$page' => t('Plugins'),
'$submit' => t('Save Settings'), '$submit' => t('Save Settings'),
'$reload' => t('Reload active plugins'), '$reload' => t('Reload active plugins'),
'$baseurl' => $a->get_baseurl(true), '$baseurl' => App::get_baseurl(true),
'$function' => 'plugins', '$function' => 'plugins',
'$plugins' => $plugins, '$plugins' => $plugins,
'$pcount' => count($plugins), '$pcount' => count($plugins),
@ -1780,7 +1783,7 @@ function admin_page_themes(&$a){
'$page' => t('Themes'), '$page' => t('Themes'),
'$toggle' => t('Toggle'), '$toggle' => t('Toggle'),
'$settings' => t('Settings'), '$settings' => t('Settings'),
'$baseurl' => $a->get_baseurl(true), '$baseurl' => App::get_baseurl(true),
'$plugin' => $theme, '$plugin' => $theme,
'$status' => $status, '$status' => $status,
'$action' => $action, '$action' => $action,
@ -1798,18 +1801,18 @@ function admin_page_themes(&$a){
// reload active themes // reload active themes
if(x($_GET,"a") && $_GET['a']=="r") { if (x($_GET,"a") && $_GET['a']=="r") {
check_form_security_token_redirectOnErr($a->get_baseurl().'/admin/themes', 'admin_themes', 't'); check_form_security_token_redirectOnErr(App::get_baseurl().'/admin/themes', 'admin_themes', 't');
if($themes) { if ($themes) {
foreach($themes as $th) { foreach ($themes as $th) {
if($th['allowed']) { if ($th['allowed']) {
uninstall_theme($th['name']); uninstall_theme($th['name']);
install_theme($th['name']); install_theme($th['name']);
} }
} }
} }
info("Themes reloaded"); info("Themes reloaded");
goaway($a->get_baseurl().'/admin/themes'); goaway(App::get_baseurl().'/admin/themes');
} }
/* /*
@ -1817,7 +1820,7 @@ function admin_page_themes(&$a){
*/ */
$xthemes = array(); $xthemes = array();
if($themes) { if ($themes) {
foreach($themes as $th) { foreach($themes as $th) {
$xthemes[] = array($th['name'],(($th['allowed']) ? "on" : "off"), get_theme_info($th['name'])); $xthemes[] = array($th['name'],(($th['allowed']) ? "on" : "off"), get_theme_info($th['name']));
} }
@ -1830,7 +1833,7 @@ function admin_page_themes(&$a){
'$page' => t('Themes'), '$page' => t('Themes'),
'$submit' => t('Save Settings'), '$submit' => t('Save Settings'),
'$reload' => t('Reload active themes'), '$reload' => t('Reload active themes'),
'$baseurl' => $a->get_baseurl(true), '$baseurl' => App::get_baseurl(true),
'$function' => 'themes', '$function' => 'themes',
'$plugins' => $xthemes, '$plugins' => $xthemes,
'$pcount' => count($themes), '$pcount' => count($themes),
@ -1904,7 +1907,7 @@ function admin_page_logs(&$a){
'$page' => t('Logs'), '$page' => t('Logs'),
'$submit' => t('Save Settings'), '$submit' => t('Save Settings'),
'$clear' => t('Clear'), '$clear' => t('Clear'),
'$baseurl' => $a->get_baseurl(true), '$baseurl' => App::get_baseurl(true),
'$logname' => get_config('system','logfile'), '$logname' => get_config('system','logfile'),
// name, label, value, help string, extra data... // name, label, value, help string, extra data...

View file

@ -8,16 +8,18 @@ require_once('mod/contacts.php');
function allfriends_content(&$a) { function allfriends_content(&$a) {
$o = ''; $o = '';
if(! local_user()) { if (! local_user()) {
notice( t('Permission denied.') . EOL); notice( t('Permission denied.') . EOL);
return; return;
} }
if($a->argc > 1) if ($a->argc > 1) {
$cid = intval($a->argv[1]); $cid = intval($a->argv[1]);
}
if(! $cid) if (! $cid) {
return; return;
}
$uid = $a->user[uid]; $uid = $a->user[uid];
@ -26,8 +28,9 @@ function allfriends_content(&$a) {
intval(local_user()) intval(local_user())
); );
if(! count($c)) if (! count($c)) {
return; return;
}
$a->page['aside'] = ""; $a->page['aside'] = "";
profile_load($a, "", 0, get_contact_details_by_url($c[0]["url"])); profile_load($a, "", 0, get_contact_details_by_url($c[0]["url"]));
@ -39,14 +42,14 @@ function allfriends_content(&$a) {
$r = all_friends(local_user(), $cid, $a->pager['start'], $a->pager['itemspage']); $r = all_friends(local_user(), $cid, $a->pager['start'], $a->pager['itemspage']);
if(! dbm::is_result($r)) { if (! dbm::is_result($r)) {
$o .= t('No friends to display.'); $o .= t('No friends to display.');
return $o; return $o;
} }
$id = 0; $id = 0;
foreach($r as $rr) { foreach ($r as $rr) {
//get further details of the contact //get further details of the contact
$contact_details = get_contact_details_by_url($rr['url'], $uid, $rr); $contact_details = get_contact_details_by_url($rr['url'], $uid, $rr);
@ -60,7 +63,7 @@ function allfriends_content(&$a) {
$photo_menu = contact_photo_menu ($rr); $photo_menu = contact_photo_menu ($rr);
} }
else { else {
$connlnk = $a->get_baseurl() . '/follow/?url=' . $rr['url']; $connlnk = App::get_baseurl() . '/follow/?url=' . $rr['url'];
$photo_menu = array( $photo_menu = array(
'profile' => array(t("View Profile"), zrl($rr['url'])), 'profile' => array(t("View Profile"), zrl($rr['url'])),
'follow' => array(t("Connect/Follow"), $connlnk) 'follow' => array(t("Connect/Follow"), $connlnk)

View file

@ -22,7 +22,7 @@ function oauth_get_client($request){
function api_post(&$a) { function api_post(&$a) {
if(! local_user()) { if (! local_user()) {
notice( t('Permission denied.') . EOL); notice( t('Permission denied.') . EOL);
return; return;
} }
@ -84,7 +84,7 @@ function api_content(&$a) {
} }
if(! local_user()) { if (! local_user()) {
/// @TODO We need login form to redirect to this page /// @TODO We need login form to redirect to this page
notice( t('Please login to continue.') . EOL ); notice( t('Please login to continue.') . EOL );
return login(false,$request->get_parameters()); return login(false,$request->get_parameters());

View file

@ -16,7 +16,7 @@ function attach_init(&$a) {
$r = q("SELECT * FROM `attach` WHERE `id` = %d LIMIT 1", $r = q("SELECT * FROM `attach` WHERE `id` = %d LIMIT 1",
intval($item_id) intval($item_id)
); );
if(! dbm::is_result($r)) { if (! dbm::is_result($r)) {
notice( t('Item was not found.'). EOL); notice( t('Item was not found.'). EOL);
return; return;
} }
@ -29,7 +29,7 @@ function attach_init(&$a) {
dbesc($item_id) dbesc($item_id)
); );
if(! dbm::is_result($r)) { if (! dbm::is_result($r)) {
notice( t('Permission denied.') . EOL); notice( t('Permission denied.') . EOL);
return; return;
} }

View file

@ -8,14 +8,14 @@ function bookmarklet_init(&$a) {
} }
function bookmarklet_content(&$a) { function bookmarklet_content(&$a) {
if(!local_user()) { if (!local_user()) {
$o = '<h2>'.t('Login').'</h2>'; $o = '<h2>'.t('Login').'</h2>';
$o .= login(($a->config['register_policy'] == REGISTER_CLOSED) ? false : true); $o .= login(($a->config['register_policy'] == REGISTER_CLOSED) ? false : true);
return $o; return $o;
} }
$referer = normalise_link($_SERVER["HTTP_REFERER"]); $referer = normalise_link($_SERVER["HTTP_REFERER"]);
$page = normalise_link($a->get_baseurl()."/bookmarklet"); $page = normalise_link(App::get_baseurl()."/bookmarklet");
if (!strstr($referer, $page)) { if (!strstr($referer, $page)) {
$content = add_page_info($_REQUEST["url"]); $content = add_page_info($_REQUEST["url"]);

View file

@ -80,7 +80,7 @@ function cal_content(&$a) {
$htpl = get_markup_template('event_head.tpl'); $htpl = get_markup_template('event_head.tpl');
$a->page['htmlhead'] .= replace_macros($htpl,array( $a->page['htmlhead'] .= replace_macros($htpl,array(
'$baseurl' => $a->get_baseurl(), '$baseurl' => App::get_baseurl(),
'$module_url' => '/cal/' . $a->data['user']['nickname'], '$module_url' => '/cal/' . $a->data['user']['nickname'],
'$modparams' => 2, '$modparams' => 2,
'$i18n' => $i18n, '$i18n' => $i18n,
@ -89,7 +89,7 @@ function cal_content(&$a) {
$etpl = get_markup_template('event_end.tpl'); $etpl = get_markup_template('event_end.tpl');
$a->page['end'] .= replace_macros($etpl,array( $a->page['end'] .= replace_macros($etpl,array(
'$baseurl' => $a->get_baseurl(), '$baseurl' => App::get_baseurl(),
'$editselect' => $editselect '$editselect' => $editselect
)); ));
@ -229,10 +229,11 @@ function cal_content(&$a) {
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
$r = sort_by_date($r); $r = sort_by_date($r);
foreach($r as $rr) { foreach ($r as $rr) {
$j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j')); $j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j'));
if(! x($links,$j)) if (! x($links,$j)) {
$links[$j] = $a->get_baseurl() . '/' . $a->cmd . '#link-' . $j; $links[$j] = App::get_baseurl() . '/' . $a->cmd . '#link-' . $j;
}
} }
} }
@ -270,12 +271,12 @@ function cal_content(&$a) {
} }
$o = replace_macros($tpl, array( $o = replace_macros($tpl, array(
'$baseurl' => $a->get_baseurl(), '$baseurl' => App::get_baseurl(),
'$tabs' => $tabs, '$tabs' => $tabs,
'$title' => t('Events'), '$title' => t('Events'),
'$view' => t('View'), '$view' => t('View'),
'$previus' => array($a->get_baseurl()."/events/$prevyear/$prevmonth",t('Previous'),'',''), '$previus' => array(App::get_baseurl()."/events/$prevyear/$prevmonth",t('Previous'),'',''),
'$next' => array($a->get_baseurl()."/events/$nextyear/$nextmonth",t('Next'),'',''), '$next' => array(App::get_baseurl()."/events/$nextyear/$nextmonth",t('Next'),'',''),
'$calendar' => cal($y,$m,$links, ' eventcal'), '$calendar' => cal($y,$m,$links, ' eventcal'),
'$events' => $events, '$events' => $events,

View file

@ -19,23 +19,27 @@ function common_content(&$a) {
return; return;
} }
if($cmd !== 'loc' && $cmd != 'rem') if ($cmd !== 'loc' && $cmd != 'rem') {
return; return;
}
if(! $uid) if (! $uid) {
return; return;
}
if($cmd === 'loc' && $cid) { if ($cmd === 'loc' && $cid) {
$c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($cid), intval($cid),
intval($uid) intval($uid)
); );
/// @TODO Handle $c with dbm::is_result()
$a->page['aside'] = ""; $a->page['aside'] = "";
profile_load($a, "", 0, get_contact_details_by_url($c[0]["url"])); profile_load($a, "", 0, get_contact_details_by_url($c[0]["url"]));
} else { } else {
$c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1", $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
intval($uid) intval($uid)
); );
/// @TODO Handle $c with dbm::is_result()
$vcard_widget .= replace_macros(get_markup_template("vcard-widget.tpl"),array( $vcard_widget .= replace_macros(get_markup_template("vcard-widget.tpl"),array(
'$name' => htmlentities($c[0]['name']), '$name' => htmlentities($c[0]['name']),
@ -43,8 +47,9 @@ function common_content(&$a) {
'url' => 'contacts/' . $cid 'url' => 'contacts/' . $cid
)); ));
if(! x($a->page,'aside')) if (! x($a->page,'aside')) {
$a->page['aside'] = ''; $a->page['aside'] = '';
}
$a->page['aside'] .= $vcard_widget; $a->page['aside'] .= $vcard_widget;
} }
@ -69,44 +74,45 @@ function common_content(&$a) {
} }
} }
if ($cid == 0 && $zcid == 0) {
if($cid == 0 && $zcid == 0)
return; return;
}
if ($cid) {
if($cid)
$t = count_common_friends($uid, $cid); $t = count_common_friends($uid, $cid);
else } else {
$t = count_common_friends_zcid($uid, $zcid); $t = count_common_friends_zcid($uid, $zcid);
}
if(count($t)) if (count($t)) {
$a->set_pager_total($t); $a->set_pager_total($t);
else { } else {
notice( t('No contacts in common.') . EOL); notice( t('No contacts in common.') . EOL);
return $o; return $o;
} }
if($cid) if ($cid) {
$r = common_friends($uid, $cid, $a->pager['start'], $a->pager['itemspage']); $r = common_friends($uid, $cid, $a->pager['start'], $a->pager['itemspage']);
else } else {
$r = common_friends_zcid($uid, $zcid, $a->pager['start'], $a->pager['itemspage']); $r = common_friends_zcid($uid, $zcid, $a->pager['start'], $a->pager['itemspage']);
}
if(! dbm::is_result($r)) { if (! dbm::is_result($r)) {
return $o; return $o;
} }
$id = 0; $id = 0;
foreach($r as $rr) { foreach ($r as $rr) {
//get further details of the contact //get further details of the contact
$contact_details = get_contact_details_by_url($rr['url'], $uid); $contact_details = get_contact_details_by_url($rr['url'], $uid);
// $rr[id] is needed to use contact_photo_menu() // $rr['id'] is needed to use contact_photo_menu()
$rr[id] = $rr[cid]; /// @TODO Adding '/" here avoids E_NOTICE on missing constants
$rr['id'] = $rr['cid'];
$photo_menu = ''; $photo_menu = '';
$photo_menu = contact_photo_menu($rr); $photo_menu = contact_photo_menu($rr);
@ -128,10 +134,11 @@ function common_content(&$a) {
$entries[] = $entry; $entries[] = $entry;
} }
if($cmd === 'loc' && $cid && $uid == local_user()) { if ($cmd === 'loc' && $cid && $uid == local_user()) {
$tab_str = contacts_tab($a, $cid, 4); $tab_str = contacts_tab($a, $cid, 4);
} else } else {
$title = t('Common Friends'); $title = t('Common Friends');
}
$tpl = get_markup_template('viewcontact_template.tpl'); $tpl = get_markup_template('viewcontact_template.tpl');

View file

@ -1,7 +1,7 @@
<?php <?php
function community_init(&$a) { function community_init(&$a) {
if(! local_user()) { if (! local_user()) {
unset($_SESSION['theme']); unset($_SESSION['theme']);
unset($_SESSION['mobile-theme']); unset($_SESSION['mobile-theme']);
} }
@ -71,7 +71,7 @@ function community_content(&$a, $update = 0) {
$r = community_getitems($a->pager['start'], $a->pager['itemspage']); $r = community_getitems($a->pager['start'], $a->pager['itemspage']);
if(! dbm::is_result($r)) { if (! dbm::is_result($r)) {
info( t('No results.') . EOL); info( t('No results.') . EOL);
return $o; return $o;
} }

View file

@ -5,7 +5,7 @@ require_once('include/group.php');
function contactgroup_content(&$a) { function contactgroup_content(&$a) {
if(! local_user()) { if (! local_user()) {
killme(); killme();
} }
@ -24,7 +24,7 @@ function contactgroup_content(&$a) {
intval($a->argv[1]), intval($a->argv[1]),
intval(local_user()) intval(local_user())
); );
if(! dbm::is_result($r)) { if (! dbm::is_result($r)) {
killme(); killme();
} }

View file

@ -8,8 +8,9 @@ require_once('mod/proxy.php');
require_once('include/Photo.php'); require_once('include/Photo.php');
function contacts_init(&$a) { function contacts_init(&$a) {
if(! local_user()) if (! local_user()) {
return; return;
}
$contact_id = 0; $contact_id = 0;
@ -19,7 +20,7 @@ function contacts_init(&$a) {
intval(local_user()), intval(local_user()),
intval($contact_id) intval($contact_id)
); );
if(! dbm::is_result($r)) { if (! dbm::is_result($r)) {
$contact_id = 0; $contact_id = 0;
} }
} }
@ -78,13 +79,13 @@ function contacts_init(&$a) {
$base = z_root(); $base = z_root();
$tpl = get_markup_template("contacts-head.tpl"); $tpl = get_markup_template("contacts-head.tpl");
$a->page['htmlhead'] .= replace_macros($tpl,array( $a->page['htmlhead'] .= replace_macros($tpl,array(
'$baseurl' => $a->get_baseurl(true), '$baseurl' => App::get_baseurl(true),
'$base' => $base '$base' => $base
)); ));
$tpl = get_markup_template("contacts-end.tpl"); $tpl = get_markup_template("contacts-end.tpl");
$a->page['end'] .= replace_macros($tpl,array( $a->page['end'] .= replace_macros($tpl,array(
'$baseurl' => $a->get_baseurl(true), '$baseurl' => App::get_baseurl(true),
'$base' => $base '$base' => $base
)); ));
@ -128,18 +129,21 @@ function contacts_batch_actions(&$a){
info ( sprintf( tt("%d contact edited.", "%d contacts edited.", $count_actions), $count_actions) ); info ( sprintf( tt("%d contact edited.", "%d contacts edited.", $count_actions), $count_actions) );
} }
if(x($_SESSION,'return_url')) if (x($_SESSION,'return_url')) {
goaway('' . $_SESSION['return_url']); goaway('' . $_SESSION['return_url']);
else }
else {
goaway('contacts'); goaway('contacts');
}
} }
function contacts_post(&$a) { function contacts_post(&$a) {
if(! local_user()) if (! local_user()) {
return; return;
}
if ($a->argv[1]==="batch") { if ($a->argv[1]==="batch") {
contacts_batch_actions($a); contacts_batch_actions($a);
@ -147,15 +151,16 @@ function contacts_post(&$a) {
} }
$contact_id = intval($a->argv[1]); $contact_id = intval($a->argv[1]);
if(! $contact_id) if (! $contact_id) {
return; return;
}
$orig_record = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", $orig_record = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($contact_id), intval($contact_id),
intval(local_user()) intval(local_user())
); );
if(! count($orig_record)) { if (! count($orig_record)) {
notice( t('Could not access contact record.') . EOL); notice( t('Could not access contact record.') . EOL);
goaway('contacts'); goaway('contacts');
return; // NOTREACHED return; // NOTREACHED
@ -164,12 +169,12 @@ function contacts_post(&$a) {
call_hooks('contact_edit_post', $_POST); call_hooks('contact_edit_post', $_POST);
$profile_id = intval($_POST['profile-assign']); $profile_id = intval($_POST['profile-assign']);
if($profile_id) { if ($profile_id) {
$r = q("SELECT `id` FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("SELECT `id` FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($profile_id), intval($profile_id),
intval(local_user()) intval(local_user())
); );
if(! dbm::is_result($r)) { if (! dbm::is_result($r)) {
notice( t('Could not locate selected profile.') . EOL); notice( t('Could not locate selected profile.') . EOL);
return; return;
} }
@ -346,7 +351,7 @@ function contacts_content(&$a) {
nav_set_selected('contacts'); nav_set_selected('contacts');
if(! local_user()) { if (! local_user()) {
notice( t('Permission denied.') . EOL); notice( t('Permission denied.') . EOL);
return; return;
} }
@ -384,7 +389,7 @@ function contacts_content(&$a) {
if($cmd === 'block') { if($cmd === 'block') {
$r = _contact_block($contact_id, $orig_record[0]); $r = _contact_block($contact_id, $orig_record[0]);
if($r) { if ($r) {
$blocked = (($orig_record[0]['blocked']) ? 0 : 1); $blocked = (($orig_record[0]['blocked']) ? 0 : 1);
info((($blocked) ? t('Contact has been blocked') : t('Contact has been unblocked')).EOL); info((($blocked) ? t('Contact has been blocked') : t('Contact has been unblocked')).EOL);
} }
@ -395,7 +400,7 @@ function contacts_content(&$a) {
if($cmd === 'ignore') { if($cmd === 'ignore') {
$r = _contact_ignore($contact_id, $orig_record[0]); $r = _contact_ignore($contact_id, $orig_record[0]);
if($r) { if ($r) {
$readonly = (($orig_record[0]['readonly']) ? 0 : 1); $readonly = (($orig_record[0]['readonly']) ? 0 : 1);
info((($readonly) ? t('Contact has been ignored') : t('Contact has been unignored')).EOL); info((($readonly) ? t('Contact has been ignored') : t('Contact has been unignored')).EOL);
} }
@ -407,7 +412,7 @@ function contacts_content(&$a) {
if($cmd === 'archive') { if($cmd === 'archive') {
$r = _contact_archive($contact_id, $orig_record[0]); $r = _contact_archive($contact_id, $orig_record[0]);
if($r) { if ($r) {
$archived = (($orig_record[0]['archive']) ? 0 : 1); $archived = (($orig_record[0]['archive']) ? 0 : 1);
info((($archived) ? t('Contact has been archived') : t('Contact has been unarchived')).EOL); info((($archived) ? t('Contact has been archived') : t('Contact has been unarchived')).EOL);
} }
@ -446,22 +451,26 @@ function contacts_content(&$a) {
)); ));
} }
// Now check how the user responded to the confirmation query // Now check how the user responded to the confirmation query
if($_REQUEST['canceled']) { if ($_REQUEST['canceled']) {
if(x($_SESSION,'return_url')) if (x($_SESSION,'return_url')) {
goaway('' . $_SESSION['return_url']); goaway('' . $_SESSION['return_url']);
else }
else {
goaway('contacts'); goaway('contacts');
} }
}
_contact_drop($contact_id, $orig_record[0]); _contact_drop($contact_id, $orig_record[0]);
info( t('Contact has been removed.') . EOL ); info( t('Contact has been removed.') . EOL );
if(x($_SESSION,'return_url')) if (x($_SESSION,'return_url')) {
goaway('' . $_SESSION['return_url']); goaway('' . $_SESSION['return_url']);
else }
else {
goaway('contacts'); goaway('contacts');
}
return; // NOTREACHED return; // NOTREACHED
} }
if($cmd === 'posts') { if ($cmd === 'posts') {
return contact_posts($a, $contact_id); return contact_posts($a, $contact_id);
} }
} }
@ -480,11 +489,11 @@ function contacts_content(&$a) {
$editselect = 'exact'; $editselect = 'exact';
$a->page['htmlhead'] .= replace_macros(get_markup_template('contact_head.tpl'), array( $a->page['htmlhead'] .= replace_macros(get_markup_template('contact_head.tpl'), array(
'$baseurl' => $a->get_baseurl(true), '$baseurl' => App::get_baseurl(true),
'$editselect' => $editselect, '$editselect' => $editselect,
)); ));
$a->page['end'] .= replace_macros(get_markup_template('contact_end.tpl'), array( $a->page['end'] .= replace_macros(get_markup_template('contact_end.tpl'), array(
'$baseurl' => $a->get_baseurl(true), '$baseurl' => App::get_baseurl(true),
'$editselect' => $editselect, '$editselect' => $editselect,
)); ));
@ -564,7 +573,7 @@ function contacts_content(&$a) {
if (in_array($contact['network'], array(NETWORK_DIASPORA, NETWORK_OSTATUS)) AND if (in_array($contact['network'], array(NETWORK_DIASPORA, NETWORK_OSTATUS)) AND
($contact['rel'] == CONTACT_IS_FOLLOWER)) ($contact['rel'] == CONTACT_IS_FOLLOWER))
$follow = $a->get_baseurl(true)."/follow?url=".urlencode($contact["url"]); $follow = App::get_baseurl(true)."/follow?url=".urlencode($contact["url"]);
// Load contactact related actions like hide, suggest, delete and others // Load contactact related actions like hide, suggest, delete and others
$contact_actions = contact_actions($contact); $contact_actions = contact_actions($contact);

View file

@ -23,7 +23,7 @@ function content_content(&$a, $update = 0) {
// Currently security is based on the logged in user // Currently security is based on the logged in user
if(! local_user()) { if (! local_user()) {
return; return;
} }
@ -113,11 +113,11 @@ function content_content(&$a, $update = 0) {
intval($group), intval($group),
intval($_SESSION['uid']) intval($_SESSION['uid'])
); );
if(! dbm::is_result($r)) { if (! dbm::is_result($r)) {
if($update) if($update)
killme(); killme();
notice( t('No such group') . EOL ); notice( t('No such group') . EOL );
goaway($a->get_baseurl(true) . '/network'); goaway(App::get_baseurl(true) . '/network');
// NOTREACHED // NOTREACHED
} }
@ -509,8 +509,8 @@ function render_content(&$a, $items, $mode, $update, $preview = false) {
'like' => '', 'like' => '',
'dislike' => '', 'dislike' => '',
'comment' => '', 'comment' => '',
//'conv' => (($preview) ? '' : array('href'=> $a->get_baseurl($ssl_state) . '/display/' . $nickname . '/' . $item['id'], 'title'=> t('View in context'))), //'conv' => (($preview) ? '' : array('href'=> App::get_baseurl($ssl_state) . '/display/' . $nickname . '/' . $item['id'], 'title'=> t('View in context'))),
'conv' => (($preview) ? '' : array('href'=> $a->get_baseurl($ssl_state).'/display/'.$item['guid'], 'title'=> t('View in context'))), 'conv' => (($preview) ? '' : array('href'=> App::get_baseurl($ssl_state).'/display/'.$item['guid'], 'title'=> t('View in context'))),
'previewing' => $previewing, 'previewing' => $previewing,
'wait' => t('Please wait'), 'wait' => t('Please wait'),
); );
@ -742,10 +742,11 @@ function render_content(&$a, $items, $mode, $update, $preview = false) {
} }
} }
if(local_user() && link_compare($a->contact['url'],$item['author-link'])) if (local_user() && link_compare($a->contact['url'],$item['author-link'])) {
$edpost = array($a->get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit")); $edpost = array(App::get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit"));
else } else {
$edpost = false; $edpost = false;
}
$drop = ''; $drop = '';
$dropping = false; $dropping = false;
@ -764,7 +765,7 @@ function render_content(&$a, $items, $mode, $update, $preview = false) {
$isstarred = "unstarred"; $isstarred = "unstarred";
if ($profile_owner == local_user()) { if ($profile_owner == local_user()) {
if($toplevelpost) { if ($toplevelpost) {
$isstarred = (($item['starred']) ? "starred" : "unstarred"); $isstarred = (($item['starred']) ? "starred" : "unstarred");
$star = array( $star = array(
@ -782,6 +783,7 @@ function render_content(&$a, $items, $mode, $update, $preview = false) {
intval($item['uid']), intval($item['uid']),
intval($item['id']) intval($item['id'])
); );
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
$ignore = array( $ignore = array(
'do' => t("ignore thread"), 'do' => t("ignore thread"),
@ -793,7 +795,7 @@ function render_content(&$a, $items, $mode, $update, $preview = false) {
); );
} }
$tagger = ''; $tagger = '';
if(feature_enabled($profile_owner,'commtag')) { if (feature_enabled($profile_owner,'commtag')) {
$tagger = array( $tagger = array(
'add' => t("add tag"), 'add' => t("add tag"),
'class' => "", 'class' => "",
@ -818,19 +820,22 @@ function render_content(&$a, $items, $mode, $update, $preview = false) {
$sp = false; $sp = false;
$profile_link = best_link_url($item,$sp); $profile_link = best_link_url($item,$sp);
if($profile_link === 'mailbox') if ($profile_link === 'mailbox') {
$profile_link = ''; $profile_link = '';
if($sp) }
if ($sp) {
$sparkle = ' sparkle'; $sparkle = ' sparkle';
else } else {
$profile_link = zrl($profile_link); $profile_link = zrl($profile_link);
}
// Don't rely on the author-avatar. It is better to use the data from the contact table // Don't rely on the author-avatar. It is better to use the data from the contact table
$author_contact = get_contact_details_by_url($item['author-link'], $profile_owner); $author_contact = get_contact_details_by_url($item['author-link'], $profile_owner);
if ($author_contact["thumb"]) if ($author_contact["thumb"]) {
$profile_avatar = $author_contact["thumb"]; $profile_avatar = $author_contact["thumb"];
else } else {
$profile_avatar = $item['author-avatar']; $profile_avatar = $item['author-avatar'];
}
$like = ((x($conv_responses['like'],$item['uri'])) ? format_like($conv_responses['like'][$item['uri']],$conv_responses['like'][$item['uri'] . '-l'],'like',$item['uri']) : ''); $like = ((x($conv_responses['like'],$item['uri'])) ? format_like($conv_responses['like'][$item['uri']],$conv_responses['like'][$item['uri'] . '-l'],'like',$item['uri']) : '');
$dislike = ((x($conv_responses['dislike'],$item['uri'])) ? format_like($conv_responses['dislike'][$item['uri']],$conv_responses['dislike'][$item['uri'] . '-l'],'dislike',$item['uri']) : ''); $dislike = ((x($conv_responses['dislike'],$item['uri'])) ? format_like($conv_responses['dislike'][$item['uri']],$conv_responses['dislike'][$item['uri'] . '-l'],'dislike',$item['uri']) : '');

View file

@ -3,8 +3,9 @@ require_once("include/contact_selectors.php");
require_once("mod/contacts.php"); require_once("mod/contacts.php");
function crepair_init(&$a) { function crepair_init(&$a) {
if(! local_user()) if (! local_user()) {
return; return;
}
$contact_id = 0; $contact_id = 0;
@ -14,7 +15,7 @@ function crepair_init(&$a) {
intval(local_user()), intval(local_user()),
intval($contact_id) intval($contact_id)
); );
if(! dbm::is_result($r)) { if (! dbm::is_result($r)) {
$contact_id = 0; $contact_id = 0;
} }
} }
@ -29,10 +30,10 @@ function crepair_init(&$a) {
} }
} }
function crepair_post(&$a) { function crepair_post(&$a) {
if(! local_user()) if (! local_user()) {
return; return;
}
$cid = (($a->argc > 1) ? intval($a->argv[1]) : 0); $cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
@ -43,8 +44,9 @@ function crepair_post(&$a) {
); );
} }
if(! dbm::is_result($r)) if (! dbm::is_result($r)) {
return; return;
}
$contact = $r[0]; $contact = $r[0];
@ -96,7 +98,7 @@ function crepair_post(&$a) {
function crepair_content(&$a) { function crepair_content(&$a) {
if(! local_user()) { if (! local_user()) {
notice( t('Permission denied.') . EOL); notice( t('Permission denied.') . EOL);
return; return;
} }
@ -110,7 +112,7 @@ function crepair_content(&$a) {
); );
} }
if(! dbm::is_result($r)) { if (! dbm::is_result($r)) {
notice( t('Contact not found.') . EOL); notice( t('Contact not found.') . EOL);
return; return;
} }

View file

@ -8,17 +8,18 @@ function delegate_init(&$a) {
function delegate_content(&$a) { function delegate_content(&$a) {
if(! local_user()) { if (! local_user()) {
notice( t('Permission denied.') . EOL); notice( t('Permission denied.') . EOL);
return; return;
} }
if($a->argc > 2 && $a->argv[1] === 'add' && intval($a->argv[2])) { if ($a->argc > 2 && $a->argv[1] === 'add' && intval($a->argv[2])) {
// delegated admins can view but not change delegation permissions // delegated admins can view but not change delegation permissions
if(x($_SESSION,'submanage') && intval($_SESSION['submanage'])) if (x($_SESSION,'submanage') && intval($_SESSION['submanage'])) {
goaway($a->get_baseurl() . '/delegate'); goaway(App::get_baseurl() . '/delegate');
}
$id = $a->argv[2]; $id = $a->argv[2];
@ -29,7 +30,7 @@ function delegate_content(&$a) {
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
$r = q("select id from contact where uid = %d and nurl = '%s' limit 1", $r = q("select id from contact where uid = %d and nurl = '%s' limit 1",
intval(local_user()), intval(local_user()),
dbesc(normalise_link($a->get_baseurl() . '/profile/' . $r[0]['nickname'])) dbesc(normalise_link(App::get_baseurl() . '/profile/' . $r[0]['nickname']))
); );
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
q("insert into manage ( uid, mid ) values ( %d , %d ) ", q("insert into manage ( uid, mid ) values ( %d , %d ) ",
@ -38,21 +39,22 @@ function delegate_content(&$a) {
); );
} }
} }
goaway($a->get_baseurl() . '/delegate'); goaway(App::get_baseurl() . '/delegate');
} }
if($a->argc > 2 && $a->argv[1] === 'remove' && intval($a->argv[2])) { if ($a->argc > 2 && $a->argv[1] === 'remove' && intval($a->argv[2])) {
// delegated admins can view but not change delegation permissions // delegated admins can view but not change delegation permissions
if(x($_SESSION,'submanage') && intval($_SESSION['submanage'])) if (x($_SESSION,'submanage') && intval($_SESSION['submanage'])) {
goaway($a->get_baseurl() . '/delegate'); goaway(App::get_baseurl() . '/delegate');
}
q("delete from manage where uid = %d and mid = %d limit 1", q("delete from manage where uid = %d and mid = %d limit 1",
intval($a->argv[2]), intval($a->argv[2]),
intval(local_user()) intval(local_user())
); );
goaway($a->get_baseurl() . '/delegate'); goaway(App::get_baseurl() . '/delegate');
} }
@ -92,12 +94,12 @@ function delegate_content(&$a) {
$r = q("select nurl from contact where substring_index(contact.nurl,'/',3) = '%s' $r = q("select nurl from contact where substring_index(contact.nurl,'/',3) = '%s'
and contact.uid = %d and contact.self = 0 and network = '%s' ", and contact.uid = %d and contact.self = 0 and network = '%s' ",
dbesc(normalise_link($a->get_baseurl())), dbesc(normalise_link(App::get_baseurl())),
intval(local_user()), intval(local_user()),
dbesc(NETWORK_DFRN) dbesc(NETWORK_DFRN)
); );
if(! dbm::is_result($r)) { if (! dbm::is_result($r)) {
notice( t('No potential page delegates located.') . EOL); notice( t('No potential page delegates located.') . EOL);
return; return;
} }
@ -105,7 +107,7 @@ function delegate_content(&$a) {
$nicknames = array(); $nicknames = array();
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) { foreach ($r as $rr) {
$nicknames[] = "'" . dbesc(basename($rr['nurl'])) . "'"; $nicknames[] = "'" . dbesc(basename($rr['nurl'])) . "'";
} }
} }
@ -128,7 +130,7 @@ function delegate_content(&$a) {
$o = replace_macros(get_markup_template('delegate.tpl'),array( $o = replace_macros(get_markup_template('delegate.tpl'),array(
'$header' => t('Delegate Page Management'), '$header' => t('Delegate Page Management'),
'$base' => $a->get_baseurl(), '$base' => App::get_baseurl(),
'$desc' => t('Delegates are able to manage all aspects of this account/page except for basic account settings. Please do not delegate your personal account to anybody that you do not trust completely.'), '$desc' => t('Delegates are able to manage all aspects of this account/page except for basic account settings. Please do not delegate your personal account to anybody that you do not trust completely.'),
'$head_managers' => t('Existing Page Managers'), '$head_managers' => t('Existing Page Managers'),
'$managers' => $full_managers, '$managers' => $full_managers,

View file

@ -121,7 +121,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
intval($uid) intval($uid)
); );
if(! dbm::is_result($r)) { if (! dbm::is_result($r)) {
logger('Contact not found in DB.'); logger('Contact not found in DB.');
notice( t('Contact not found.') . EOL ); notice( t('Contact not found.') . EOL );
notice( t('This may occasionally happen if contact was requested by both persons and it has already been approved.') . EOL ); notice( t('This may occasionally happen if contact was requested by both persons and it has already been approved.') . EOL );
@ -194,7 +194,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
$params['public_key'] = $public_key; $params['public_key'] = $public_key;
$my_url = $a->get_baseurl() . '/profile/' . $user[0]['nickname']; $my_url = App::get_baseurl() . '/profile/' . $user[0]['nickname'];
openssl_public_encrypt($my_url, $params['source_url'], $site_pubkey); openssl_public_encrypt($my_url, $params['source_url'], $site_pubkey);
$params['source_url'] = bin2hex($params['source_url']); $params['source_url'] = bin2hex($params['source_url']);
@ -433,7 +433,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
if(($contact) && ($contact['network'] === NETWORK_DIASPORA)) { if(($contact) && ($contact['network'] === NETWORK_DIASPORA)) {
require_once('include/diaspora.php'); require_once('include/diaspora.php');
$ret = diaspora::send_share($user[0],$r[0]); $ret = Diaspora::send_share($user[0],$r[0]);
logger('share returns: ' . $ret); logger('share returns: ' . $ret);
} }
@ -503,10 +503,11 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
// Let's send our user to the contact editor in case they want to // Let's send our user to the contact editor in case they want to
// do anything special with this new friend. // do anything special with this new friend.
if($handsfree === null) if ($handsfree === null) {
goaway($a->get_baseurl() . '/contacts/' . intval($contact_id)); goaway(App::get_baseurl() . '/contacts/' . intval($contact_id));
else } else {
return; return;
}
//NOTREACHED //NOTREACHED
} }
@ -522,7 +523,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
* *
*/ */
if(x($_POST,'source_url')) { if (x($_POST,'source_url')) {
// We are processing an external confirmation to an introduction created by our user. // We are processing an external confirmation to an introduction created by our user.
@ -543,7 +544,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
// If $aes_key is set, both of these items require unpacking from the hex transport encoding. // If $aes_key is set, both of these items require unpacking from the hex transport encoding.
if(x($aes_key)) { if (x($aes_key)) {
$aes_key = hex2bin($aes_key); $aes_key = hex2bin($aes_key);
$public_key = hex2bin($public_key); $public_key = hex2bin($public_key);
} }
@ -553,7 +554,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
$r = q("SELECT * FROM `user` WHERE `nickname` = '%s' LIMIT 1", $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' LIMIT 1",
dbesc($node)); dbesc($node));
if(! dbm::is_result($r)) { if (! dbm::is_result($r)) {
$message = sprintf(t('No user record found for \'%s\' '), $node); $message = sprintf(t('No user record found for \'%s\' '), $node);
xml_status(3,$message); // failure xml_status(3,$message); // failure
// NOTREACHED // NOTREACHED
@ -640,7 +641,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
dbesc($dfrn_pubkey), dbesc($dfrn_pubkey),
intval($dfrn_record) intval($dfrn_record)
); );
if(! dbm::is_result($r)) { if (! dbm::is_result($r)) {
$message = t('Unable to set your contact credentials on our system.'); $message = t('Unable to set your contact credentials on our system.');
xml_status(3,$message); xml_status(3,$message);
} }
@ -661,10 +662,11 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
$r = q("SELECT `photo` FROM `contact` WHERE `id` = %d LIMIT 1", $r = q("SELECT `photo` FROM `contact` WHERE `id` = %d LIMIT 1",
intval($dfrn_record)); intval($dfrn_record));
if (dbm::is_result($r)) if (dbm::is_result($r)) {
$photo = $r[0]['photo']; $photo = $r[0]['photo'];
else } else {
$photo = $a->get_baseurl() . '/images/person-175.jpg'; $photo = App::get_baseurl() . '/images/person-175.jpg';
}
require_once("include/Photo.php"); require_once("include/Photo.php");
@ -673,11 +675,13 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
logger('dfrn_confirm: request - photos imported'); logger('dfrn_confirm: request - photos imported');
$new_relation = CONTACT_IS_SHARING; $new_relation = CONTACT_IS_SHARING;
if(($relation == CONTACT_IS_FOLLOWER) || ($duplex)) if (($relation == CONTACT_IS_FOLLOWER) || ($duplex)) {
$new_relation = CONTACT_IS_FRIEND; $new_relation = CONTACT_IS_FRIEND;
}
if(($relation == CONTACT_IS_FOLLOWER) && ($duplex)) if (($relation == CONTACT_IS_FOLLOWER) && ($duplex)) {
$duplex = 0; $duplex = 0;
}
$r = q("UPDATE `contact` SET $r = q("UPDATE `contact` SET
`rel` = %d, `rel` = %d,
@ -699,7 +703,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
dbesc(NETWORK_DFRN), dbesc(NETWORK_DFRN),
intval($dfrn_record) intval($dfrn_record)
); );
if($r === false) { // indicates schema is messed up or total db failure if ($r === false) { // indicates schema is messed up or total db failure
$message = t('Unable to update your contact profile details on our system'); $message = t('Unable to update your contact profile details on our system');
xml_status(3,$message); xml_status(3,$message);
} }
@ -726,7 +730,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
'to_name' => $r[0]['username'], 'to_name' => $r[0]['username'],
'to_email' => $r[0]['email'], 'to_email' => $r[0]['email'],
'uid' => $r[0]['uid'], 'uid' => $r[0]['uid'],
'link' => $a->get_baseurl() . '/contacts/' . $dfrn_record, 'link' => App::get_baseurl() . '/contacts/' . $dfrn_record,
'source_name' => ((strlen(stripslashes($r[0]['name']))) ? stripslashes($r[0]['name']) : t('[Name Withheld]')), 'source_name' => ((strlen(stripslashes($r[0]['name']))) ? stripslashes($r[0]['name']) : t('[Name Withheld]')),
'source_link' => $r[0]['url'], 'source_link' => $r[0]['url'],
'source_photo' => $r[0]['photo'], 'source_photo' => $r[0]['photo'],

View file

@ -42,7 +42,7 @@ function dfrn_notify_post(&$a) {
dbesc($dfrn_id), dbesc($dfrn_id),
dbesc($challenge) dbesc($challenge)
); );
if(! dbm::is_result($r)) { if (! dbm::is_result($r)) {
logger('dfrn_notify: could not match challenge to dfrn_id ' . $dfrn_id . ' challenge=' . $challenge); logger('dfrn_notify: could not match challenge to dfrn_id ' . $dfrn_id . ' challenge=' . $challenge);
xml_status(3); xml_status(3);
} }
@ -88,7 +88,7 @@ function dfrn_notify_post(&$a) {
dbesc($a->argv[1]) dbesc($a->argv[1])
); );
if(! dbm::is_result($r)) { if (! dbm::is_result($r)) {
logger('dfrn_notify: contact not found for dfrn_id ' . $dfrn_id); logger('dfrn_notify: contact not found for dfrn_id ' . $dfrn_id);
xml_status(3); xml_status(3);
//NOTREACHED //NOTREACHED
@ -284,8 +284,9 @@ function dfrn_notify_content(&$a) {
dbesc($a->argv[1]) dbesc($a->argv[1])
); );
if(! dbm::is_result($r)) if (! dbm::is_result($r)) {
$status = 1; $status = 1;
}
logger("Remote rino version: ".$rino_remote." for ".$r[0]["url"], LOGGER_DEBUG); logger("Remote rino version: ".$rino_remote." for ".$r[0]["url"], LOGGER_DEBUG);

View file

@ -112,7 +112,7 @@ function dfrn_poll_init(&$a) {
} }
} }
$profile = $r[0]['nickname']; $profile = $r[0]['nickname'];
goaway((strlen($destination_url)) ? $destination_url : $a->get_baseurl() . '/profile/' . $profile); goaway((strlen($destination_url)) ? $destination_url : App::get_baseurl() . '/profile/' . $profile);
} }
goaway(z_root()); goaway(z_root());
@ -126,7 +126,7 @@ function dfrn_poll_init(&$a) {
$r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1", $r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1",
dbesc($sec) dbesc($sec)
); );
if(! dbm::is_result($r)) { if (! dbm::is_result($r)) {
xml_status(3, 'No ticket'); xml_status(3, 'No ticket');
// NOTREACHED // NOTREACHED
} }
@ -223,7 +223,7 @@ function dfrn_poll_post(&$a) {
$r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1", $r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1",
dbesc($sec) dbesc($sec)
); );
if(! dbm::is_result($r)) { if (! dbm::is_result($r)) {
xml_status(3, 'No ticket'); xml_status(3, 'No ticket');
// NOTREACHED // NOTREACHED
} }
@ -284,8 +284,9 @@ function dfrn_poll_post(&$a) {
dbesc($challenge) dbesc($challenge)
); );
if(! dbm::is_result($r)) if (! dbm::is_result($r)) {
killme(); killme();
}
$type = $r[0]['type']; $type = $r[0]['type'];
$last_update = $r[0]['last_update']; $last_update = $r[0]['last_update'];
@ -319,8 +320,9 @@ function dfrn_poll_post(&$a) {
$r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 $sql_extra LIMIT 1"); $r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 $sql_extra LIMIT 1");
if(! dbm::is_result($r)) if (! dbm::is_result($r)) {
killme(); killme();
}
$contact = $r[0]; $contact = $r[0];
$owner_uid = $r[0]['uid']; $owner_uid = $r[0]['uid'];
@ -499,14 +501,14 @@ function dfrn_poll_content(&$a) {
switch($destination_url) { switch($destination_url) {
case 'profile': case 'profile':
$dest = $a->get_baseurl() . '/profile/' . $profile . '?f=&tab=profile'; $dest = App::get_baseurl() . '/profile/' . $profile . '?f=&tab=profile';
break; break;
case 'photos': case 'photos':
$dest = $a->get_baseurl() . '/photos/' . $profile; $dest = App::get_baseurl() . '/photos/' . $profile;
break; break;
case 'status': case 'status':
case '': case '':
$dest = $a->get_baseurl() . '/profile/' . $profile; $dest = App::get_baseurl() . '/profile/' . $profile;
break; break;
default: default:
$dest = $destination_url . '?f=&redir=1'; $dest = $destination_url . '?f=&redir=1';

View file

@ -120,17 +120,19 @@ function dfrn_request_post(&$a) {
$parms = Probe::profile($dfrn_url); $parms = Probe::profile($dfrn_url);
if(! count($parms)) { if (! count($parms)) {
notice( t('Profile location is not valid or does not contain profile information.') . EOL ); notice( t('Profile location is not valid or does not contain profile information.') . EOL );
return; return;
} }
else { else {
if(! x($parms,'fn')) if (! x($parms,'fn')) {
notice( t('Warning: profile location has no identifiable owner name.') . EOL ); notice( t('Warning: profile location has no identifiable owner name.') . EOL );
if(! x($parms,'photo')) }
if (! x($parms,'photo')) {
notice( t('Warning: profile location has no profile photo.') . EOL ); notice( t('Warning: profile location has no profile photo.') . EOL );
}
$invalid = Probe::valid_dfrn($parms); $invalid = Probe::valid_dfrn($parms);
if($invalid) { if ($invalid) {
notice( sprintf( tt("%d required parameter was not found at the given location", notice( sprintf( tt("%d required parameter was not found at the given location",
"%d required parameters were not found at the given location", "%d required parameters were not found at the given location",
$invalid), $invalid) . EOL ); $invalid), $invalid) . EOL );
@ -176,7 +178,7 @@ function dfrn_request_post(&$a) {
); );
} }
if($r) { if ($r) {
info( t("Introduction complete.") . EOL); info( t("Introduction complete.") . EOL);
} }
@ -193,19 +195,22 @@ function dfrn_request_post(&$a) {
if (isset($photo)) if (isset($photo))
update_contact_avatar($photo, local_user(), $r[0]["id"], true); update_contact_avatar($photo, local_user(), $r[0]["id"], true);
$forwardurl = $a->get_baseurl()."/contacts/".$r[0]['id']; $forwardurl = App::get_baseurl()."/contacts/".$r[0]['id'];
} else } else {
$forwardurl = $a->get_baseurl()."/contacts"; $forwardurl = App::get_baseurl()."/contacts";
}
/* /*
* Allow the blocked remote notification to complete * Allow the blocked remote notification to complete
*/ */
if(is_array($contact_record)) if (is_array($contact_record)) {
$dfrn_request = $contact_record['request']; $dfrn_request = $contact_record['request'];
}
if(strlen($dfrn_request) && strlen($confirm_key)) if (strlen($dfrn_request) && strlen($confirm_key)) {
$s = fetch_url($dfrn_request . '?confirm_key=' . $confirm_key); $s = fetch_url($dfrn_request . '?confirm_key=' . $confirm_key);
}
// (ignore reply, nothing we can do it failed) // (ignore reply, nothing we can do it failed)
@ -296,7 +301,7 @@ function dfrn_request_post(&$a) {
dbesc(NETWORK_MAIL2) dbesc(NETWORK_MAIL2)
); );
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) { foreach ($r as $rr) {
if(! $rr['rel']) { if(! $rr['rel']) {
q("DELETE FROM `contact` WHERE `id` = %d", q("DELETE FROM `contact` WHERE `id` = %d",
intval($rr['cid']) intval($rr['cid'])
@ -321,7 +326,7 @@ function dfrn_request_post(&$a) {
dbesc(NETWORK_MAIL2) dbesc(NETWORK_MAIL2)
); );
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) { foreach ($r as $rr) {
if(! $rr['rel']) { if(! $rr['rel']) {
q("DELETE FROM `contact` WHERE `id` = %d", q("DELETE FROM `contact` WHERE `id` = %d",
intval($rr['cid']) intval($rr['cid'])
@ -371,7 +376,7 @@ function dfrn_request_post(&$a) {
intval($uid) intval($uid)
); );
if(! dbm::is_result($r)) { if (! dbm::is_result($r)) {
notice( t('This account has not been configured for email. Request failed.') . EOL); notice( t('This account has not been configured for email. Request failed.') . EOL);
return; return;
} }
@ -499,15 +504,15 @@ function dfrn_request_post(&$a) {
); );
} }
else { else {
if(! validate_url($url)) { if (! validate_url($url)) {
notice( t('Invalid profile URL.') . EOL); notice( t('Invalid profile URL.') . EOL);
goaway($a->get_baseurl() . '/' . $a->cmd); goaway(App::get_baseurl() . '/' . $a->cmd);
return; // NOTREACHED return; // NOTREACHED
} }
if(! allowed_url($url)) { if (! allowed_url($url)) {
notice( t('Disallowed profile URL.') . EOL); notice( t('Disallowed profile URL.') . EOL);
goaway($a->get_baseurl() . '/' . $a->cmd); goaway(App::get_baseurl() . '/' . $a->cmd);
return; // NOTREACHED return; // NOTREACHED
} }
@ -516,17 +521,19 @@ function dfrn_request_post(&$a) {
$parms = Probe::profile(($hcard) ? $hcard : $url); $parms = Probe::profile(($hcard) ? $hcard : $url);
if(! count($parms)) { if (! count($parms)) {
notice( t('Profile location is not valid or does not contain profile information.') . EOL ); notice( t('Profile location is not valid or does not contain profile information.') . EOL );
goaway($a->get_baseurl() . '/' . $a->cmd); goaway(App::get_baseurl() . '/' . $a->cmd);
} }
else { else {
if(! x($parms,'fn')) if (! x($parms,'fn')) {
notice( t('Warning: profile location has no identifiable owner name.') . EOL ); notice( t('Warning: profile location has no identifiable owner name.') . EOL );
if(! x($parms,'photo')) }
if (! x($parms,'photo')) {
notice( t('Warning: profile location has no profile photo.') . EOL ); notice( t('Warning: profile location has no profile photo.') . EOL );
}
$invalid = Probe::valid_dfrn($parms); $invalid = Probe::valid_dfrn($parms);
if($invalid) { if ($invalid) {
notice( sprintf( tt("%d required parameter was not found at the given location", notice( sprintf( tt("%d required parameter was not found at the given location",
"%d required parameters were not found at the given location", "%d required parameters were not found at the given location",
$invalid), $invalid) . EOL ); $invalid), $invalid) . EOL );
@ -565,7 +572,7 @@ function dfrn_request_post(&$a) {
); );
// find the contact record we just created // find the contact record we just created
if($r) { if ($r) {
$r = q("SELECT `id` FROM `contact` $r = q("SELECT `id` FROM `contact`
WHERE `uid` = %d AND `url` = '%s' AND `issued-id` = '%s' LIMIT 1", WHERE `uid` = %d AND `url` = '%s' AND `issued-id` = '%s' LIMIT 1",
intval($uid), intval($uid),
@ -579,14 +586,14 @@ function dfrn_request_post(&$a) {
} }
} }
if($r === false) { if ($r === false) {
notice( t('Failed to update contact record.') . EOL ); notice( t('Failed to update contact record.') . EOL );
return; return;
} }
$hash = random_string() . (string) time(); // Generate a confirm_key $hash = random_string() . (string) time(); // Generate a confirm_key
if(is_array($contact_record)) { if (is_array($contact_record)) {
$ret = q("INSERT INTO `intro` ( `uid`, `contact-id`, `blocked`, `knowyou`, `note`, `hash`, `datetime`) $ret = q("INSERT INTO `intro` ( `uid`, `contact-id`, `blocked`, `knowyou`, `note`, `hash`, `datetime`)
VALUES ( %d, %d, 1, %d, '%s', '%s', '%s' )", VALUES ( %d, %d, 1, %d, '%s', '%s', '%s' )",
intval($uid), intval($uid),
@ -600,12 +607,13 @@ function dfrn_request_post(&$a) {
// This notice will only be seen by the requestor if the requestor and requestee are on the same server. // This notice will only be seen by the requestor if the requestor and requestee are on the same server.
if(! $failed) if (! $failed) {
info( t('Your introduction has been sent.') . EOL ); info( t('Your introduction has been sent.') . EOL );
}
// "Homecoming" - send the requestor back to their site to record the introduction. // "Homecoming" - send the requestor back to their site to record the introduction.
$dfrn_url = bin2hex($a->get_baseurl() . '/profile/' . $nickname); $dfrn_url = bin2hex(App::get_baseurl() . '/profile/' . $nickname);
$aes_allow = ((function_exists('openssl_encrypt')) ? 1 : 0); $aes_allow = ((function_exists('openssl_encrypt')) ? 1 : 0);
goaway($parms['dfrn-request'] . "?dfrn_url=$dfrn_url" goaway($parms['dfrn-request'] . "?dfrn_url=$dfrn_url"
@ -633,8 +641,9 @@ function dfrn_request_post(&$a) {
$uri .= '/'.$a->get_path(); $uri .= '/'.$a->get_path();
$uri = urlencode($uri); $uri = urlencode($uri);
} else } else {
$uri = $a->get_baseurl().'/profile/'.$nickname; $uri = App::get_baseurl().'/profile/'.$nickname;
}
$url = str_replace('{uri}', $uri, $url); $url = str_replace('{uri}', $uri, $url);
goaway($url); goaway($url);
@ -651,16 +660,17 @@ function dfrn_request_post(&$a) {
function dfrn_request_content(&$a) { function dfrn_request_content(&$a) {
if(($a->argc != 2) || (! count($a->profile))) if (($a->argc != 2) || (! count($a->profile))) {
return ""; return "";
}
// "Homecoming". Make sure we're logged in to this site as the correct user. Then offer a confirm button // "Homecoming". Make sure we're logged in to this site as the correct user. Then offer a confirm button
// to send us to the post section to record the introduction. // to send us to the post section to record the introduction.
if(x($_GET,'dfrn_url')) { if (x($_GET,'dfrn_url')) {
if(! local_user()) { if (! local_user()) {
info( t("Please login to confirm introduction.") . EOL ); info( t("Please login to confirm introduction.") . EOL );
/* setup the return URL to come back to this page if they use openid */ /* setup the return URL to come back to this page if they use openid */
$_SESSION['return_url'] = $a->query_string; $_SESSION['return_url'] = $a->query_string;
@ -742,7 +752,7 @@ function dfrn_request_content(&$a) {
'to_name' => $r[0]['username'], 'to_name' => $r[0]['username'],
'to_email' => $r[0]['email'], 'to_email' => $r[0]['email'],
'uid' => $r[0]['uid'], 'uid' => $r[0]['uid'],
'link' => $a->get_baseurl() . '/notifications/intros', 'link' => App::get_baseurl() . '/notifications/intros',
'source_name' => ((strlen(stripslashes($r[0]['name']))) ? stripslashes($r[0]['name']) : t('[Name Withheld]')), 'source_name' => ((strlen(stripslashes($r[0]['name']))) ? stripslashes($r[0]['name']) : t('[Name Withheld]')),
'source_link' => $r[0]['url'], 'source_link' => $r[0]['url'],
'source_photo' => $r[0]['photo'], 'source_photo' => $r[0]['photo'],
@ -804,15 +814,18 @@ function dfrn_request_content(&$a) {
$myaddr = hex2bin($_GET['addr']); $myaddr = hex2bin($_GET['addr']);
elseif (x($_GET,'address') AND ($_GET['address'] != "")) elseif (x($_GET,'address') AND ($_GET['address'] != ""))
$myaddr = $_GET['address']; $myaddr = $_GET['address'];
elseif(local_user()) { elseif (local_user()) {
if(strlen($a->path)) { if (strlen($a->path)) {
$myaddr = $a->get_baseurl() . '/profile/' . $a->user['nickname']; $myaddr = App::get_baseurl() . '/profile/' . $a->user['nickname'];
} }
else { else {
$myaddr = $a->user['nickname'] . '@' . substr(z_root(), strpos(z_root(),'://') + 3 ); $myaddr = $a->user['nickname'] . '@' . substr(z_root(), strpos(z_root(),'://') + 3 );
} }
} else // last, try a zrl }
else {
// last, try a zrl
$myaddr = get_my_url(); $myaddr = get_my_url();
}
$target_addr = $a->profile['nickname'] . '@' . substr(z_root(), strpos(z_root(),'://') + 3 ); $target_addr = $a->profile['nickname'] . '@' . substr(z_root(), strpos(z_root(),'://') + 3 );
@ -825,10 +838,12 @@ function dfrn_request_content(&$a) {
* *
*/ */
if($a->profile['page-flags'] == PAGE_NORMAL) if ($a->profile['page-flags'] == PAGE_NORMAL) {
$tpl = get_markup_template('dfrn_request.tpl'); $tpl = get_markup_template('dfrn_request.tpl');
else }
else {
$tpl = get_markup_template('auto_request.tpl'); $tpl = get_markup_template('auto_request.tpl');
}
$page_desc = t("Please enter your 'Identity Address' from one of the following supported communications networks:"); $page_desc = t("Please enter your 'Identity Address' from one of the following supported communications networks:");
@ -842,9 +857,10 @@ function dfrn_request_content(&$a) {
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
intval($a->profile['uid']) intval($a->profile['uid'])
); );
if(! dbm::is_result($r)) if (! dbm::is_result($r)) {
$mail_disabled = 1; $mail_disabled = 1;
} }
}
// "coming soon" is disabled for now // "coming soon" is disabled for now
//$emailnet = (($mail_disabled) ? '' : t("<strike>Connect as an email follower</strike> \x28Coming soon\x29")); //$emailnet = (($mail_disabled) ? '' : t("<strike>Connect as an email follower</strike> \x28Coming soon\x29"));

View file

@ -92,12 +92,14 @@ function directory_content(&$a) {
WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 AND `contact`.`self` $sql_extra $order LIMIT ".$limit); WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 AND `contact`.`self` $sql_extra $order LIMIT ".$limit);
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
if(in_array('small', $a->argv)) if (in_array('small', $a->argv)) {
$photo = 'thumb'; $photo = 'thumb';
else }
else {
$photo = 'photo'; $photo = 'photo';
}
foreach($r as $rr) { foreach ($r as $rr) {
$itemurl= ''; $itemurl= '';

View file

@ -7,13 +7,14 @@ require_once('mod/contacts.php');
function dirfind_init(&$a) { function dirfind_init(&$a) {
if(! local_user()) { if (! local_user()) {
notice( t('Permission denied.') . EOL ); notice( t('Permission denied.') . EOL );
return; return;
} }
if(! x($a->page,'aside')) if (! x($a->page,'aside')) {
$a->page['aside'] = ''; $a->page['aside'] = '';
}
$a->page['aside'] .= findpeople_widget(); $a->page['aside'] .= findpeople_widget();
@ -31,7 +32,7 @@ function dirfind_content(&$a, $prefix = "") {
$search = $prefix.notags(trim($_REQUEST['search'])); $search = $prefix.notags(trim($_REQUEST['search']));
if(strpos($search,'@') === 0) { if (strpos($search,'@') === 0) {
$search = substr($search,1); $search = substr($search,1);
$header = sprintf( t('People Search - %s'), $search); $header = sprintf( t('People Search - %s'), $search);
if ((valid_email($search) AND validate_email($search)) OR if ((valid_email($search) AND validate_email($search)) OR
@ -41,7 +42,7 @@ function dirfind_content(&$a, $prefix = "") {
} }
} }
if(strpos($search,'!') === 0) { if (strpos($search,'!') === 0) {
$search = substr($search,1); $search = substr($search,1);
$community = true; $community = true;
$header = sprintf( t('Forum Search - %s'), $search); $header = sprintf( t('Forum Search - %s'), $search);
@ -49,7 +50,7 @@ function dirfind_content(&$a, $prefix = "") {
$o = ''; $o = '';
if($search) { if ($search) {
if ($discover_user) { if ($discover_user) {
$j = new stdClass(); $j = new stdClass();
@ -85,18 +86,21 @@ function dirfind_content(&$a, $prefix = "") {
$perpage = 80; $perpage = 80;
$startrec = (($a->pager['page']) * $perpage) - $perpage; $startrec = (($a->pager['page']) * $perpage) - $perpage;
if (get_config('system','diaspora_enabled')) if (get_config('system','diaspora_enabled')) {
$diaspora = NETWORK_DIASPORA; $diaspora = NETWORK_DIASPORA;
else } else {
$diaspora = NETWORK_DFRN; $diaspora = NETWORK_DFRN;
}
if (!get_config('system','ostatus_disabled')) if (!get_config('system','ostatus_disabled')) {
$ostatus = NETWORK_OSTATUS; $ostatus = NETWORK_OSTATUS;
else } else {
$ostatus = NETWORK_DFRN; $ostatus = NETWORK_DFRN;
}
$search2 = "%".$search."%"; $search2 = "%".$search."%";
/// @TODO These 2 SELECTs are not checked on validity with dbm::is_result()
$count = q("SELECT count(*) AS `total` FROM `gcontact` $count = q("SELECT count(*) AS `total` FROM `gcontact`
LEFT JOIN `contact` ON `contact`.`nurl` = `gcontact`.`nurl` LEFT JOIN `contact` ON `contact`.`nurl` = `gcontact`.`nurl`
AND `contact`.`network` = `gcontact`.`network` AND `contact`.`network` = `gcontact`.`network`
@ -133,8 +137,9 @@ function dirfind_content(&$a, $prefix = "") {
$j->items_page = $perpage; $j->items_page = $perpage;
$j->page = $a->pager['page']; $j->page = $a->pager['page'];
foreach ($results AS $result) { foreach ($results AS $result) {
if (poco_alternate_ostatus_url($result["url"])) if (poco_alternate_ostatus_url($result["url"])) {
continue; continue;
}
$result = get_contact_details_by_url($result["url"], local_user(), $result); $result = get_contact_details_by_url($result["url"], local_user(), $result);
@ -167,16 +172,16 @@ function dirfind_content(&$a, $prefix = "") {
$j = json_decode($x); $j = json_decode($x);
} }
if($j->total) { if ($j->total) {
$a->set_pager_total($j->total); $a->set_pager_total($j->total);
$a->set_pager_itemspage($j->items_page); $a->set_pager_itemspage($j->items_page);
} }
if(count($j->results)) { if (count($j->results)) {
$id = 0; $id = 0;
foreach($j->results as $jj) { foreach ($j->results as $jj) {
$alt_text = ""; $alt_text = "";
@ -194,10 +199,11 @@ function dirfind_content(&$a, $prefix = "") {
$photo_menu = contact_photo_menu($contact[0]); $photo_menu = contact_photo_menu($contact[0]);
$details = _contact_detail_for_template($contact[0]); $details = _contact_detail_for_template($contact[0]);
$alt_text = $details['alt_text']; $alt_text = $details['alt_text'];
} else
$photo_menu = array();
} else { } else {
$connlnk = $a->get_baseurl().'/follow/?url='.(($jj->connect) ? $jj->connect : $jj->url); $photo_menu = array();
}
} else {
$connlnk = App::get_baseurl().'/follow/?url='.(($jj->connect) ? $jj->connect : $jj->url);
$conntxt = t('Connect'); $conntxt = t('Connect');
$photo_menu = array( $photo_menu = array(
'profile' => array(t("View Profile"), zrl($jj->url)), 'profile' => array(t("View Profile"), zrl($jj->url)),
@ -235,8 +241,7 @@ function dirfind_content(&$a, $prefix = "") {
'$paginate' => paginate($a), '$paginate' => paginate($a),
)); ));
} } else {
else {
info( t('No matches') . EOL); info( t('No matches') . EOL);
} }

View file

@ -81,8 +81,8 @@ function display_init(&$a) {
$profiledata = display_fetchauthor($a, $r[0]); $profiledata = display_fetchauthor($a, $r[0]);
if (strstr(normalise_link($profiledata["url"]), normalise_link($a->get_baseurl()))) { if (strstr(normalise_link($profiledata["url"]), normalise_link(App::get_baseurl()))) {
$nickname = str_replace(normalise_link($a->get_baseurl())."/profile/", "", normalise_link($profiledata["url"])); $nickname = str_replace(normalise_link(App::get_baseurl())."/profile/", "", normalise_link($profiledata["url"]));
if (($nickname != $a->user["nickname"])) { if (($nickname != $a->user["nickname"])) {
$r = qu("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile` $r = qu("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile`
@ -184,7 +184,7 @@ function display_fetchauthor($a, $item) {
if (local_user()) { if (local_user()) {
if (in_array($profiledata["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) { if (in_array($profiledata["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) {
$profiledata["remoteconnect"] = $a->get_baseurl()."/follow?url=".urlencode($profiledata["url"]); $profiledata["remoteconnect"] = App::get_baseurl()."/follow?url=".urlencode($profiledata["url"]);
} }
} elseif ($profiledata["network"] == NETWORK_DFRN) { } elseif ($profiledata["network"] == NETWORK_DFRN) {
$connect = str_replace("/profile/", "/dfrn_request/", $profiledata["url"]); $connect = str_replace("/profile/", "/dfrn_request/", $profiledata["url"]);

View file

@ -6,14 +6,14 @@ function editpost_content(&$a) {
$o = ''; $o = '';
if(! local_user()) { if (! local_user()) {
notice( t('Permission denied.') . EOL); notice( t('Permission denied.') . EOL);
return; return;
} }
$post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0); $post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
if(! $post_id) { if (! $post_id) {
notice( t('Item not found') . EOL); notice( t('Item not found') . EOL);
return; return;
} }
@ -23,7 +23,7 @@ function editpost_content(&$a) {
intval(local_user()) intval(local_user())
); );
if(! count($itm)) { if (! count($itm)) {
notice( t('Item not found') . EOL); notice( t('Item not found') . EOL);
return; return;
} }
@ -42,7 +42,7 @@ function editpost_content(&$a) {
$tpl = get_markup_template('jot-header.tpl'); $tpl = get_markup_template('jot-header.tpl');
$a->page['htmlhead'] .= replace_macros($tpl, array( $a->page['htmlhead'] .= replace_macros($tpl, array(
'$baseurl' => $a->get_baseurl(), '$baseurl' => App::get_baseurl(),
'$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
'$ispublic' => '&nbsp;', // t('Visible to <strong>everybody</strong>'), '$ispublic' => '&nbsp;', // t('Visible to <strong>everybody</strong>'),
'$geotag' => $geotag, '$geotag' => $geotag,
@ -51,7 +51,7 @@ function editpost_content(&$a) {
$tpl = get_markup_template('jot-end.tpl'); $tpl = get_markup_template('jot-end.tpl');
$a->page['end'] .= replace_macros($tpl, array( $a->page['end'] .= replace_macros($tpl, array(
'$baseurl' => $a->get_baseurl(), '$baseurl' => App::get_baseurl(),
'$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
'$ispublic' => '&nbsp;', // t('Visible to <strong>everybody</strong>'), '$ispublic' => '&nbsp;', // t('Visible to <strong>everybody</strong>'),
'$geotag' => $geotag, '$geotag' => $geotag,
@ -126,7 +126,7 @@ function editpost_content(&$a) {
'$ptyp' => $itm[0]['type'], '$ptyp' => $itm[0]['type'],
'$content' => undo_post_tagging($itm[0]['body']), '$content' => undo_post_tagging($itm[0]['body']),
'$post_id' => $post_id, '$post_id' => $post_id,
'$baseurl' => $a->get_baseurl(), '$baseurl' => App::get_baseurl(),
'$defloc' => $a->user['default-location'], '$defloc' => $a->user['default-location'],
'$visitor' => 'none', '$visitor' => 'none',
'$pvisit' => 'none', '$pvisit' => 'none',

View file

@ -9,18 +9,19 @@ require_once('include/event.php');
require_once('include/items.php'); require_once('include/items.php');
function events_init(&$a) { function events_init(&$a) {
if(! local_user()) if (! local_user()) {
return; return;
}
if($a->argc == 1) { if ($a->argc == 1) {
// if it's a json request abort here becaus we don't // if it's a json request abort here becaus we don't
// need the widget data // need the widget data
if($a->argv[1] === 'json') if ($a->argv[1] === 'json')
return; return;
$cal_widget = widget_events(); $cal_widget = widget_events();
if(! x($a->page,'aside')) if (! x($a->page,'aside'))
$a->page['aside'] = ''; $a->page['aside'] = '';
$a->page['aside'] .= $cal_widget; $a->page['aside'] .= $cal_widget;
@ -33,8 +34,9 @@ function events_post(&$a) {
logger('post: ' . print_r($_REQUEST,true)); logger('post: ' . print_r($_REQUEST,true));
if(! local_user()) if (! local_user()) {
return; return;
}
$event_id = ((x($_POST,'event_id')) ? intval($_POST['event_id']) : 0); $event_id = ((x($_POST,'event_id')) ? intval($_POST['event_id']) : 0);
$cid = ((x($_POST,'cid')) ? intval($_POST['cid']) : 0); $cid = ((x($_POST,'cid')) ? intval($_POST['cid']) : 0);
@ -49,34 +51,36 @@ function events_post(&$a) {
// The default setting for the `private` field in event_store() is false, so mirror that // The default setting for the `private` field in event_store() is false, so mirror that
$private_event = false; $private_event = false;
if($start_text) { if ($start_text) {
$start = $start_text; $start = $start_text;
} }
else { else {
$start = sprintf('%d-%d-%d %d:%d:0',$startyear,$startmonth,$startday,$starthour,$startminute); $start = sprintf('%d-%d-%d %d:%d:0',$startyear,$startmonth,$startday,$starthour,$startminute);
} }
if($nofinish) { if ($nofinish) {
$finish = '0000-00-00 00:00:00'; $finish = '0000-00-00 00:00:00';
} }
if($finish_text) { if ($finish_text) {
$finish = $finish_text; $finish = $finish_text;
} }
else { else {
$finish = sprintf('%d-%d-%d %d:%d:0',$finishyear,$finishmonth,$finishday,$finishhour,$finishminute); $finish = sprintf('%d-%d-%d %d:%d:0',$finishyear,$finishmonth,$finishday,$finishhour,$finishminute);
} }
if($adjust) { if ($adjust) {
$start = datetime_convert(date_default_timezone_get(),'UTC',$start); $start = datetime_convert(date_default_timezone_get(),'UTC',$start);
if(! $nofinish) if (! $nofinish) {
$finish = datetime_convert(date_default_timezone_get(),'UTC',$finish); $finish = datetime_convert(date_default_timezone_get(),'UTC',$finish);
} }
}
else { else {
$start = datetime_convert('UTC','UTC',$start); $start = datetime_convert('UTC','UTC',$start);
if(! $nofinish) if (! $nofinish) {
$finish = datetime_convert('UTC','UTC',$finish); $finish = datetime_convert('UTC','UTC',$finish);
} }
}
// Don't allow the event to finish before it begins. // Don't allow the event to finish before it begins.
// It won't hurt anything, but somebody will file a bug report // It won't hurt anything, but somebody will file a bug report
@ -89,11 +93,11 @@ function events_post(&$a) {
$type = 'event'; $type = 'event';
$action = ($event_id == '') ? 'new' : "event/" . $event_id; $action = ($event_id == '') ? 'new' : "event/" . $event_id;
$onerror_url = $a->get_baseurl() . "/events/" . $action . "?summary=$summary&description=$desc&location=$location&start=$start_text&finish=$finish_text&adjust=$adjust&nofinish=$nofinish"; $onerror_url = App::get_baseurl() . "/events/" . $action . "?summary=$summary&description=$desc&location=$location&start=$start_text&finish=$finish_text&adjust=$adjust&nofinish=$nofinish";
if(strcmp($finish,$start) < 0 && !$nofinish) { if (strcmp($finish,$start) < 0 && !$nofinish) {
notice( t('Event can not end before it has started.') . EOL); notice( t('Event can not end before it has started.') . EOL);
if(intval($_REQUEST['preview'])) { if (intval($_REQUEST['preview'])) {
echo( t('Event can not end before it has started.')); echo( t('Event can not end before it has started.'));
killme(); killme();
} }
@ -186,43 +190,46 @@ function events_post(&$a) {
function events_content(&$a) { function events_content(&$a) {
if(! local_user()) { if (! local_user()) {
notice( t('Permission denied.') . EOL); notice( t('Permission denied.') . EOL);
return; return;
} }
if($a->argc == 1) if ($a->argc == 1) {
$_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd; $_SESSION['return_url'] = App::get_baseurl() . '/' . $a->cmd;
}
if(($a->argc > 2) && ($a->argv[1] === 'ignore') && intval($a->argv[2])) { if (($a->argc > 2) && ($a->argv[1] === 'ignore') && intval($a->argv[2])) {
$r = q("update event set ignore = 1 where id = %d and uid = %d", $r = q("update event set ignore = 1 where id = %d and uid = %d",
intval($a->argv[2]), intval($a->argv[2]),
intval(local_user()) intval(local_user())
); );
} }
if(($a->argc > 2) && ($a->argv[1] === 'unignore') && intval($a->argv[2])) { if (($a->argc > 2) && ($a->argv[1] === 'unignore') && intval($a->argv[2])) {
$r = q("update event set ignore = 0 where id = %d and uid = %d", $r = q("update event set ignore = 0 where id = %d and uid = %d",
intval($a->argv[2]), intval($a->argv[2]),
intval(local_user()) intval(local_user())
); );
} }
if ($a->theme_events_in_profile) if ($a->theme_events_in_profile) {
nav_set_selected('home'); nav_set_selected('home');
else } else {
nav_set_selected('events'); nav_set_selected('events');
}
$editselect = 'none'; $editselect = 'none';
if( feature_enabled(local_user(), 'richtext') ) if ( feature_enabled(local_user(), 'richtext') ) {
$editselect = 'textareas'; $editselect = 'textareas';
}
// get the translation strings for the callendar // get the translation strings for the callendar
$i18n = get_event_strings(); $i18n = get_event_strings();
$htpl = get_markup_template('event_head.tpl'); $htpl = get_markup_template('event_head.tpl');
$a->page['htmlhead'] .= replace_macros($htpl,array( $a->page['htmlhead'] .= replace_macros($htpl,array(
'$baseurl' => $a->get_baseurl(), '$baseurl' => App::get_baseurl(),
'$module_url' => '/events', '$module_url' => '/events',
'$modparams' => 1, '$modparams' => 1,
'$i18n' => $i18n, '$i18n' => $i18n,
@ -231,7 +238,7 @@ function events_content(&$a) {
$etpl = get_markup_template('event_end.tpl'); $etpl = get_markup_template('event_end.tpl');
$a->page['end'] .= replace_macros($etpl,array( $a->page['end'] .= replace_macros($etpl,array(
'$baseurl' => $a->get_baseurl(), '$baseurl' => App::get_baseurl(),
'$editselect' => $editselect '$editselect' => $editselect
)); ));
@ -248,15 +255,15 @@ function events_content(&$a) {
$ignored = ((x($_REQUEST,'ignored')) ? intval($_REQUEST['ignored']) : 0); $ignored = ((x($_REQUEST,'ignored')) ? intval($_REQUEST['ignored']) : 0);
if($a->argc > 1) { if($a->argc > 1) {
if($a->argc > 2 && $a->argv[1] == 'event') { if ($a->argc > 2 && $a->argv[1] == 'event') {
$mode = 'edit'; $mode = 'edit';
$event_id = intval($a->argv[2]); $event_id = intval($a->argv[2]);
} }
if($a->argv[1] === 'new') { if ($a->argv[1] === 'new') {
$mode = 'new'; $mode = 'new';
$event_id = 0; $event_id = 0;
} }
if($a->argc > 2 && intval($a->argv[1]) && intval($a->argv[2])) { if ($a->argc > 2 && intval($a->argv[1]) && intval($a->argv[2])) {
$mode = 'view'; $mode = 'view';
$y = intval($a->argv[1]); $y = intval($a->argv[1]);
$m = intval($a->argv[2]); $m = intval($a->argv[2]);
@ -264,23 +271,27 @@ function events_content(&$a) {
} }
// The view mode part is similiar to /mod/cal.php // The view mode part is similiar to /mod/cal.php
if($mode == 'view') { if ($mode == 'view') {
$thisyear = datetime_convert('UTC',date_default_timezone_get(),'now','Y'); $thisyear = datetime_convert('UTC',date_default_timezone_get(),'now','Y');
$thismonth = datetime_convert('UTC',date_default_timezone_get(),'now','m'); $thismonth = datetime_convert('UTC',date_default_timezone_get(),'now','m');
if(! $y) if (! $y) {
$y = intval($thisyear); $y = intval($thisyear);
if(! $m) }
if (! $m) {
$m = intval($thismonth); $m = intval($thismonth);
}
// Put some limits on dates. The PHP date functions don't seem to do so well before 1900. // Put some limits on dates. The PHP date functions don't seem to do so well before 1900.
// An upper limit was chosen to keep search engines from exploring links millions of years in the future. // An upper limit was chosen to keep search engines from exploring links millions of years in the future.
if($y < 1901) if ($y < 1901) {
$y = 1900; $y = 1900;
if($y > 2099) }
if ($y > 2099) {
$y = 2100; $y = 2100;
}
$nextyear = $y; $nextyear = $y;
$nextmonth = $m + 1; $nextmonth = $m + 1;
@ -334,10 +345,11 @@ function events_content(&$a) {
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
$r = sort_by_date($r); $r = sort_by_date($r);
foreach($r as $rr) { foreach ($r as $rr) {
$j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j')); $j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j'));
if(! x($links,$j)) if (! x($links,$j)) {
$links[$j] = $a->get_baseurl() . '/' . $a->cmd . '#link-' . $j; $links[$j] = App::get_baseurl() . '/' . $a->cmd . '#link-' . $j;
}
} }
} }
@ -375,13 +387,13 @@ function events_content(&$a) {
} }
$o = replace_macros($tpl, array( $o = replace_macros($tpl, array(
'$baseurl' => $a->get_baseurl(), '$baseurl' => App::get_baseurl(),
'$tabs' => $tabs, '$tabs' => $tabs,
'$title' => t('Events'), '$title' => t('Events'),
'$view' => t('View'), '$view' => t('View'),
'$new_event' => array($a->get_baseurl().'/events/new',t('Create New Event'),'',''), '$new_event' => array(App::get_baseurl().'/events/new',t('Create New Event'),'',''),
'$previus' => array($a->get_baseurl()."/events/$prevyear/$prevmonth",t('Previous'),'',''), '$previus' => array(App::get_baseurl()."/events/$prevyear/$prevmonth",t('Previous'),'',''),
'$next' => array($a->get_baseurl()."/events/$nextyear/$nextmonth",t('Next'),'',''), '$next' => array(App::get_baseurl()."/events/$nextyear/$nextmonth",t('Next'),'',''),
'$calendar' => cal($y,$m,$links, ' eventcal'), '$calendar' => cal($y,$m,$links, ' eventcal'),
'$events' => $events, '$events' => $events,
@ -475,7 +487,7 @@ function events_content(&$a) {
$tpl = get_markup_template('event_form.tpl'); $tpl = get_markup_template('event_form.tpl');
$o .= replace_macros($tpl,array( $o .= replace_macros($tpl,array(
'$post' => $a->get_baseurl() . '/events', '$post' => App::get_baseurl() . '/events',
'$eid' => $eid, '$eid' => $eid,
'$cid' => $cid, '$cid' => $cid,
'$uri' => $uri, '$uri' => $uri,

View file

@ -10,6 +10,7 @@ require_once('include/Photo.php');
/** /**
* @param App $a * @param App $a
*/ */
/// @TODO & is missing or App ?
function fbrowser_content($a){ function fbrowser_content($a){
if (!local_user()) if (!local_user())
@ -83,9 +84,9 @@ function fbrowser_content($a){
$scale = $rr['loq']; $scale = $rr['loq'];
return array( return array(
$a->get_baseurl() . '/photos/' . $a->user['nickname'] . '/image/' . $rr['resource-id'], App::get_baseurl() . '/photos/' . $a->user['nickname'] . '/image/' . $rr['resource-id'],
$filename_e, $filename_e,
$a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $scale . '.'. $ext App::get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $scale . '.'. $ext
); );
} }
$files = array_map("_map_files1", $r); $files = array_map("_map_files1", $r);
@ -94,10 +95,10 @@ function fbrowser_content($a){
$o = replace_macros($tpl, array( $o = replace_macros($tpl, array(
'$type' => 'image', '$type' => 'image',
'$baseurl' => $a->get_baseurl(), '$baseurl' => App::get_baseurl(),
'$path' => $path, '$path' => $path,
'$folders' => $albums, '$folders' => $albums,
'$files' =>$files, '$files' => $files,
'$cancel' => t('Cancel'), '$cancel' => t('Cancel'),
'$nickname' => $a->user['nickname'], '$nickname' => $a->user['nickname'],
)); ));
@ -105,7 +106,7 @@ function fbrowser_content($a){
break; break;
case "file": case "file":
if ($a->argc==2){ if ($a->argc==2) {
$files = q("SELECT `id`, `filename`, `filetype` FROM `attach` WHERE `uid` = %d ", $files = q("SELECT `id`, `filename`, `filetype` FROM `attach` WHERE `uid` = %d ",
intval(local_user()) intval(local_user())
); );
@ -115,14 +116,13 @@ function fbrowser_content($a){
list($m1,$m2) = explode("/",$rr['filetype']); list($m1,$m2) = explode("/",$rr['filetype']);
$filetype = ( (file_exists("images/icons/$m1.png"))?$m1:"zip"); $filetype = ( (file_exists("images/icons/$m1.png"))?$m1:"zip");
if($a->theme['template_engine'] === 'internal') { if ($a->theme['template_engine'] === 'internal') {
$filename_e = template_escape($rr['filename']); $filename_e = template_escape($rr['filename']);
} } else {
else {
$filename_e = $rr['filename']; $filename_e = $rr['filename'];
} }
return array( $a->get_baseurl() . '/attach/' . $rr['id'], $filename_e, $a->get_baseurl() . '/images/icons/16/' . $filetype . '.png'); return array( App::get_baseurl() . '/attach/' . $rr['id'], $filename_e, App::get_baseurl() . '/images/icons/16/' . $filetype . '.png');
} }
$files = array_map("_map_files2", $files); $files = array_map("_map_files2", $files);
@ -130,7 +130,7 @@ function fbrowser_content($a){
$tpl = get_markup_template($template_file); $tpl = get_markup_template($template_file);
$o = replace_macros($tpl, array( $o = replace_macros($tpl, array(
'$type' => 'file', '$type' => 'file',
'$baseurl' => $a->get_baseurl(), '$baseurl' => App::get_baseurl(),
'$path' => array( array( "", t("Files")) ), '$path' => array( array( "", t("Files")) ),
'$folders' => false, '$folders' => false,
'$files' =>$files, '$files' =>$files,

View file

@ -52,12 +52,12 @@ function fetch_init(&$a){
} }
$user = $r[0]; $user = $r[0];
$status = diaspora::build_status($item[0], $user); $status = Diaspora::build_status($item[0], $user);
$xml = diaspora::build_post_xml($status["type"], $status["message"]); $xml = Diaspora::build_post_xml($status["type"], $status["message"]);
// Send the envelope // Send the envelope
header("Content-Type: application/magic-envelope+xml; charset=utf-8"); header("Content-Type: application/magic-envelope+xml; charset=utf-8");
echo diaspora::build_magic_envelope($xml, $user); echo Diaspora::build_magic_envelope($xml, $user);
killme(); killme();
} }

View file

@ -7,7 +7,7 @@ require_once('include/items.php');
function filer_content(&$a) { function filer_content(&$a) {
if(! local_user()) { if (! local_user()) {
killme(); killme();
} }

View file

@ -2,7 +2,7 @@
function filerm_content(&$a) { function filerm_content(&$a) {
if(! local_user()) { if (! local_user()) {
killme(); killme();
} }
@ -10,18 +10,21 @@ function filerm_content(&$a) {
$cat = unxmlify(trim($_GET['cat'])); $cat = unxmlify(trim($_GET['cat']));
$category = (($cat) ? true : false); $category = (($cat) ? true : false);
if($category) if ($category) {
$term = $cat; $term = $cat;
}
$item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0); $item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
logger('filerm: tag ' . $term . ' item ' . $item_id); logger('filerm: tag ' . $term . ' item ' . $item_id);
if($item_id && strlen($term)) if ($item_id && strlen($term)) {
file_tag_unsave_file(local_user(),$item_id,$term, $category); file_tag_unsave_file(local_user(),$item_id,$term, $category);
}
if(x($_SESSION,'return_url')) if (x($_SESSION,'return_url')) {
goaway($a->get_baseurl() . '/' . $_SESSION['return_url']); goaway(App::get_baseurl() . '/' . $_SESSION['return_url']);
}
killme(); killme();
} }

View file

@ -7,7 +7,7 @@ require_once('include/contact_selectors.php');
function follow_content(&$a) { function follow_content(&$a) {
if(! local_user()) { if (! local_user()) {
notice( t('Permission denied.') . EOL); notice( t('Permission denied.') . EOL);
goaway($_SESSION['return_url']); goaway($_SESSION['return_url']);
// NOTREACHED // NOTREACHED
@ -56,14 +56,15 @@ function follow_content(&$a) {
// NOTREACHED // NOTREACHED
} }
if ($ret["network"] == NETWORK_MAIL) if ($ret["network"] == NETWORK_MAIL) {
$ret["url"] = $ret["addr"]; $ret["url"] = $ret["addr"];
}
if($ret['network'] === NETWORK_DFRN) { if ($ret['network'] === NETWORK_DFRN) {
$request = $ret["request"]; $request = $ret["request"];
$tpl = get_markup_template('dfrn_request.tpl'); $tpl = get_markup_template('dfrn_request.tpl');
} else { } else {
$request = $a->get_baseurl()."/follow"; $request = App::get_baseurl()."/follow";
$tpl = get_markup_template('auto_request.tpl'); $tpl = get_markup_template('auto_request.tpl');
} }
@ -84,20 +85,22 @@ function follow_content(&$a) {
$r = q("SELECT `id`, `location`, `about`, `keywords` FROM `gcontact` WHERE `nurl` = '%s'", $r = q("SELECT `id`, `location`, `about`, `keywords` FROM `gcontact` WHERE `nurl` = '%s'",
normalise_link($ret["url"])); normalise_link($ret["url"]));
if (!$r) if (!$r) {
$r = array(array("location" => "", "about" => "", "keywords" => "")); $r = array(array("location" => "", "about" => "", "keywords" => ""));
else } else {
$gcontact_id = $r[0]["id"]; $gcontact_id = $r[0]["id"];
}
if($ret['network'] === NETWORK_DIASPORA) { if ($ret['network'] === NETWORK_DIASPORA) {
$r[0]["location"] = ""; $r[0]["location"] = "";
$r[0]["about"] = ""; $r[0]["about"] = "";
} }
$header = $ret["name"]; $header = $ret["name"];
if ($ret["addr"] != "") if ($ret["addr"] != "") {
$header .= " <".$ret["addr"].">"; $header .= " <".$ret["addr"].">";
}
//$header .= " (".network_to_name($ret['network'], $ret['url']).")"; //$header .= " (".network_to_name($ret['network'], $ret['url']).")";
$header = t("Connect/Follow"); $header = t("Connect/Follow");
@ -151,14 +154,15 @@ function follow_content(&$a) {
function follow_post(&$a) { function follow_post(&$a) {
if(! local_user()) { if (! local_user()) {
notice( t('Permission denied.') . EOL); notice( t('Permission denied.') . EOL);
goaway($_SESSION['return_url']); goaway($_SESSION['return_url']);
// NOTREACHED // NOTREACHED
} }
if ($_REQUEST['cancel']) if ($_REQUEST['cancel']) {
goaway($_SESSION['return_url']); goaway($_SESSION['return_url']);
}
$uid = local_user(); $uid = local_user();
$url = notags(trim($_REQUEST['url'])); $url = notags(trim($_REQUEST['url']));
@ -170,17 +174,20 @@ function follow_post(&$a) {
$result = new_contact($uid,$url,true); $result = new_contact($uid,$url,true);
if($result['success'] == false) { if ($result['success'] == false) {
if($result['message']) if ($result['message']) {
notice($result['message']); notice($result['message']);
}
goaway($return_url); goaway($return_url);
} elseif ($result['cid']) } elseif ($result['cid']) {
goaway($a->get_baseurl().'/contacts/'.$result['cid']); goaway(App::get_baseurl().'/contacts/'.$result['cid']);
}
info( t('Contact added').EOL); info( t('Contact added').EOL);
if(strstr($return_url,'contacts')) if (strstr($return_url,'contacts')) {
goaway($a->get_baseurl().'/contacts/'.$contact_id); goaway(App::get_baseurl().'/contacts/'.$contact_id);
}
goaway($return_url); goaway($return_url);
// NOTREACHED // NOTREACHED

View file

@ -15,7 +15,7 @@ function friendica_init(&$a) {
$r = q("SELECT username, nickname FROM user WHERE email='%s' $sql_extra", dbesc($adminlist[0])); $r = q("SELECT username, nickname FROM user WHERE email='%s' $sql_extra", dbesc($adminlist[0]));
$admin = array( $admin = array(
'name' => $r[0]['username'], 'name' => $r[0]['username'],
'profile'=> $a->get_baseurl().'/profile/'.$r[0]['nickname'], 'profile'=> App::get_baseurl().'/profile/'.$r[0]['nickname'],
); );
} else { } else {
$admin = false; $admin = false;
@ -49,7 +49,7 @@ function friendica_init(&$a) {
'site_name' => $a->config['sitename'], 'site_name' => $a->config['sitename'],
'platform' => FRIENDICA_PLATFORM, 'platform' => FRIENDICA_PLATFORM,
'info' => ((x($a->config,'info')) ? $a->config['info'] : ''), 'info' => ((x($a->config,'info')) ? $a->config['info'] : ''),
'no_scrape_url' => $a->get_baseurl().'/noscrape' 'no_scrape_url' => App::get_baseurl().'/noscrape'
); );
echo json_encode($data); echo json_encode($data);

View file

@ -3,12 +3,13 @@
function fsuggest_post(&$a) { function fsuggest_post(&$a) {
if(! local_user()) { if (! local_user()) {
return; return;
} }
if($a->argc != 2) if ($a->argc != 2) {
return; return;
}
$contact_id = intval($a->argv[1]); $contact_id = intval($a->argv[1]);
@ -16,7 +17,7 @@ function fsuggest_post(&$a) {
intval($contact_id), intval($contact_id),
intval(local_user()) intval(local_user())
); );
if(! dbm::is_result($r)) { if (! dbm::is_result($r)) {
notice( t('Contact not found.') . EOL); notice( t('Contact not found.') . EOL);
return; return;
} }
@ -74,7 +75,7 @@ function fsuggest_content(&$a) {
require_once('include/acl_selectors.php'); require_once('include/acl_selectors.php');
if(! local_user()) { if (! local_user()) {
notice( t('Permission denied.') . EOL); notice( t('Permission denied.') . EOL);
return; return;
} }
@ -88,7 +89,7 @@ function fsuggest_content(&$a) {
intval($contact_id), intval($contact_id),
intval(local_user()) intval(local_user())
); );
if(! dbm::is_result($r)) { if (! dbm::is_result($r)) {
notice( t('Contact not found.') . EOL); notice( t('Contact not found.') . EOL);
return; return;
} }

View file

@ -15,7 +15,7 @@ function group_init(&$a) {
function group_post(&$a) { function group_post(&$a) {
if(! local_user()) { if (! local_user()) {
notice( t('Permission denied.') . EOL); notice( t('Permission denied.') . EOL);
return; return;
} }
@ -25,40 +25,45 @@ function group_post(&$a) {
$name = notags(trim($_POST['groupname'])); $name = notags(trim($_POST['groupname']));
$r = group_add(local_user(),$name); $r = group_add(local_user(),$name);
if($r) { if ($r) {
info( t('Group created.') . EOL ); info( t('Group created.') . EOL );
$r = group_byname(local_user(),$name); $r = group_byname(local_user(),$name);
if($r) if ($r) {
goaway($a->get_baseurl() . '/group/' . $r); goaway(App::get_baseurl() . '/group/' . $r);
} }
else }
else {
notice( t('Could not create group.') . EOL ); notice( t('Could not create group.') . EOL );
goaway($a->get_baseurl() . '/group'); }
goaway(App::get_baseurl() . '/group');
return; // NOTREACHED return; // NOTREACHED
} }
if(($a->argc == 2) && (intval($a->argv[1]))) {
if (($a->argc == 2) && (intval($a->argv[1]))) {
check_form_security_token_redirectOnErr('/group', 'group_edit'); check_form_security_token_redirectOnErr('/group', 'group_edit');
$r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($a->argv[1]), intval($a->argv[1]),
intval(local_user()) intval(local_user())
); );
if(! dbm::is_result($r)) { if (! dbm::is_result($r)) {
notice( t('Group not found.') . EOL ); notice( t('Group not found.') . EOL );
goaway($a->get_baseurl() . '/contacts'); goaway(App::get_baseurl() . '/contacts');
return; // NOTREACHED return; // NOTREACHED
} }
$group = $r[0]; $group = $r[0];
$groupname = notags(trim($_POST['groupname'])); $groupname = notags(trim($_POST['groupname']));
if((strlen($groupname)) && ($groupname != $group['name'])) { if ((strlen($groupname)) && ($groupname != $group['name'])) {
$r = q("UPDATE `group` SET `name` = '%s' WHERE `uid` = %d AND `id` = %d", $r = q("UPDATE `group` SET `name` = '%s' WHERE `uid` = %d AND `id` = %d",
dbesc($groupname), dbesc($groupname),
intval(local_user()), intval(local_user()),
intval($group['id']) intval($group['id'])
); );
if($r)
if ($r) {
info( t('Group name changed.') . EOL ); info( t('Group name changed.') . EOL );
} }
}
$a->page['aside'] = group_side(); $a->page['aside'] = group_side();
} }
@ -68,7 +73,7 @@ function group_post(&$a) {
function group_content(&$a) { function group_content(&$a) {
$change = false; $change = false;
if(! local_user()) { if (! local_user()) {
notice( t('Permission denied') . EOL); notice( t('Permission denied') . EOL);
return; return;
} }
@ -99,26 +104,32 @@ function group_content(&$a) {
} }
if(($a->argc == 3) && ($a->argv[1] === 'drop')) { if (($a->argc == 3) && ($a->argv[1] === 'drop')) {
check_form_security_token_redirectOnErr('/group', 'group_drop', 't'); check_form_security_token_redirectOnErr('/group', 'group_drop', 't');
if(intval($a->argv[2])) { if (intval($a->argv[2])) {
$r = q("SELECT `name` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("SELECT `name` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($a->argv[2]), intval($a->argv[2]),
intval(local_user()) intval(local_user())
); );
if (dbm::is_result($r))
$result = null;
if (dbm::is_result($r)) {
$result = group_rmv(local_user(),$r[0]['name']); $result = group_rmv(local_user(),$r[0]['name']);
if($result) }
if ($result) {
info( t('Group removed.') . EOL); info( t('Group removed.') . EOL);
else } else {
notice( t('Unable to remove group.') . EOL); notice( t('Unable to remove group.') . EOL);
} }
goaway($a->get_baseurl() . '/group'); }
goaway(App::get_baseurl() . '/group');
// NOTREACHED // NOTREACHED
} }
if(($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) { if (($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) {
check_form_security_token_ForbiddenOnErr('group_member_change', 't'); check_form_security_token_ForbiddenOnErr('group_member_change', 't');
$r = q("SELECT `id` FROM `contact` WHERE `id` = %d AND `uid` = %d and `self` = 0 and `blocked` = 0 AND `pending` = 0 LIMIT 1", $r = q("SELECT `id` FROM `contact` WHERE `id` = %d AND `uid` = %d and `self` = 0 and `blocked` = 0 AND `pending` = 0 LIMIT 1",
@ -129,16 +140,16 @@ function group_content(&$a) {
$change = intval($a->argv[2]); $change = intval($a->argv[2]);
} }
if(($a->argc > 1) && (intval($a->argv[1]))) { if (($a->argc > 1) && (intval($a->argv[1]))) {
require_once('include/acl_selectors.php'); require_once('include/acl_selectors.php');
$r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d AND `deleted` = 0 LIMIT 1", $r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d AND `deleted` = 0 LIMIT 1",
intval($a->argv[1]), intval($a->argv[1]),
intval(local_user()) intval(local_user())
); );
if(! dbm::is_result($r)) { if (! dbm::is_result($r)) {
notice( t('Group not found.') . EOL ); notice( t('Group not found.') . EOL );
goaway($a->get_baseurl() . '/contacts'); goaway(App::get_baseurl() . '/contacts');
} }
$group = $r[0]; $group = $r[0];
$members = group_get_members($group['id']); $members = group_get_members($group['id']);

View file

@ -4,8 +4,9 @@ function hcard_init(&$a) {
$blocked = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false); $blocked = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false);
if($a->argc > 1) if ($a->argc > 1) {
$which = $a->argv[1]; $which = $a->argv[1];
}
else { else {
notice( t('No profile') . EOL ); notice( t('No profile') . EOL );
$a->error = 404; $a->error = 404;
@ -13,39 +14,42 @@ function hcard_init(&$a) {
} }
$profile = 0; $profile = 0;
if((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) { if ((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) {
$which = $a->user['nickname']; $which = $a->user['nickname'];
$profile = $a->argv[1]; $profile = $a->argv[1];
} }
profile_load($a,$which,$profile); profile_load($a,$which,$profile);
if((x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY)) { if ((x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY)) {
$a->page['htmlhead'] .= '<meta name="friendica.community" content="true" />'; $a->page['htmlhead'] .= '<meta name="friendica.community" content="true" />';
} }
if(x($a->profile,'openidserver')) if (x($a->profile,'openidserver')) {
$a->page['htmlhead'] .= '<link rel="openid.server" href="' . $a->profile['openidserver'] . '" />' . "\r\n"; $a->page['htmlhead'] .= '<link rel="openid.server" href="' . $a->profile['openidserver'] . '" />' . "\r\n";
if(x($a->profile,'openid')) { }
if (x($a->profile,'openid')) {
$delegate = ((strstr($a->profile['openid'],'://')) ? $a->profile['openid'] : 'http://' . $a->profile['openid']); $delegate = ((strstr($a->profile['openid'],'://')) ? $a->profile['openid'] : 'http://' . $a->profile['openid']);
$a->page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\r\n"; $a->page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\r\n";
} }
if(! $blocked) { if (! $blocked) {
$keywords = ((x($a->profile,'pub_keywords')) ? $a->profile['pub_keywords'] : ''); $keywords = ((x($a->profile,'pub_keywords')) ? $a->profile['pub_keywords'] : '');
$keywords = str_replace(array(',',' ',',,'),array(' ',',',','),$keywords); $keywords = str_replace(array(',',' ',',,'),array(' ',',',','),$keywords);
if(strlen($keywords)) if (strlen($keywords)) {
$a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n" ; $a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n" ;
} }
}
$a->page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . (($a->profile['net-publish']) ? 'true' : 'false') . '" />' . "\r\n" ; $a->page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . (($a->profile['net-publish']) ? 'true' : 'false') . '" />' . "\r\n" ;
$a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $a->get_baseurl() . '/dfrn_poll/' . $which .'" />' . "\r\n" ; $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . App::get_baseurl() . '/dfrn_poll/' . $which .'" />' . "\r\n" ;
$uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->get_hostname() . (($a->path) ? '/' . $a->path : '')); $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->get_hostname() . (($a->path) ? '/' . $a->path : ''));
$a->page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . $a->get_baseurl() . '/xrd/?uri=' . $uri . '" />' . "\r\n"; $a->page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . App::get_baseurl() . '/xrd/?uri=' . $uri . '" />' . "\r\n";
header('Link: <' . $a->get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false); header('Link: <' . App::get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
$dfrn_pages = array('request', 'confirm', 'notify', 'poll'); $dfrn_pages = array('request', 'confirm', 'notify', 'poll');
foreach($dfrn_pages as $dfrn) foreach ($dfrn_pages as $dfrn) {
$a->page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"".$a->get_baseurl()."/dfrn_{$dfrn}/{$which}\" />\r\n"; $a->page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"".App::get_baseurl()."/dfrn_{$dfrn}/{$which}\" />\r\n";
}
} }

View file

@ -77,7 +77,7 @@ function help_content(&$a) {
if ($level>$lastlevel) $toc.="<ul>"; if ($level>$lastlevel) $toc.="<ul>";
$idnum[$level]++; $idnum[$level]++;
$id = implode("_", array_slice($idnum,1,$level)); $id = implode("_", array_slice($idnum,1,$level));
$href = $a->get_baseurl()."/help/{$filename}#{$id}"; $href = App::get_baseurl()."/help/{$filename}#{$id}";
$toc .= "<li><a href='{$href}'>".strip_tags($line)."</a></li>"; $toc .= "<li><a href='{$href}'>".strip_tags($line)."</a></li>";
$line = "<a name='{$id}'></a>".$line; $line = "<a name='{$id}'></a>".$line;
$lastlevel = $level; $lastlevel = $level;

View file

@ -6,33 +6,38 @@ function home_init(&$a) {
$ret = array(); $ret = array();
call_hooks('home_init',$ret); call_hooks('home_init',$ret);
if(local_user() && ($a->user['nickname'])) if (local_user() && ($a->user['nickname'])) {
goaway($a->get_baseurl()."/network"); goaway(App::get_baseurl()."/network");
//goaway($a->get_baseurl()."/profile/".$a->user['nickname']); }
if(strlen(get_config('system','singleuser'))) if (strlen(get_config('system','singleuser'))) {
goaway($a->get_baseurl()."/profile/" . get_config('system','singleuser')); goaway(App::get_baseurl()."/profile/" . get_config('system','singleuser'));
}
}} }}
if(! function_exists('home_content')) { if(! function_exists('home_content')) {
function home_content(&$a) { function home_content(&$a) {
$o = ''; $o = '';
if(x($_SESSION,'theme')) if (x($_SESSION,'theme')) {
unset($_SESSION['theme']); unset($_SESSION['theme']);
if(x($_SESSION,'mobile-theme')) }
if (x($_SESSION,'mobile-theme')) {
unset($_SESSION['mobile-theme']); unset($_SESSION['mobile-theme']);
}
if(file_exists('home.html')){ /// @TODO No absolute path used, maybe risky (security)
if(file_exists('home.css')){ if (file_exists('home.html')) {
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="'.$a->get_baseurl().'/home.css'.'" media="all" />';} if (file_exists('home.css')) {
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="'.App::get_baseurl().'/home.css'.'" media="all" />';
}
$o .= file_get_contents('home.html');} $o .= file_get_contents('home.html');
} else {
else $o .= '<h1>'.((x($a->config,'sitename')) ? sprintf(t("Welcome to %s"), $a->config['sitename']) : "").'</h1>'; $o .= '<h1>'.((x($a->config,'sitename')) ? sprintf(t("Welcome to %s"), $a->config['sitename']) : "").'</h1>';
}
$o .= login(($a->config['register_policy'] == REGISTER_CLOSED) ? 0 : 1); $o .= login(($a->config['register_policy'] == REGISTER_CLOSED) ? 0 : 1);
@ -41,5 +46,4 @@ function home_content(&$a) {
return $o; return $o;
}} }}

View file

@ -5,22 +5,27 @@ function ignored_init(&$a) {
$ignored = 0; $ignored = 0;
if(! local_user()) if (! local_user()) {
killme(); killme();
if($a->argc > 1) }
if ($a->argc > 1) {
$message_id = intval($a->argv[1]); $message_id = intval($a->argv[1]);
if(! $message_id) }
if (! $message_id) {
killme(); killme();
}
$r = q("SELECT `ignored` FROM `thread` WHERE `uid` = %d AND `iid` = %d LIMIT 1", $r = q("SELECT `ignored` FROM `thread` WHERE `uid` = %d AND `iid` = %d LIMIT 1",
intval(local_user()), intval(local_user()),
intval($message_id) intval($message_id)
); );
if(! dbm::is_result($r)) if (! dbm::is_result($r)) {
killme(); killme();
}
if(! intval($r[0]['ignored'])) if (! intval($r[0]['ignored'])) {
$ignored = 1; $ignored = 1;
}
$r = q("UPDATE `thread` SET `ignored` = %d WHERE `uid` = %d and `iid` = %d", $r = q("UPDATE `thread` SET `ignored` = %d WHERE `uid` = %d and `iid` = %d",
intval($ignored), intval($ignored),
@ -30,12 +35,12 @@ function ignored_init(&$a) {
// See if we've been passed a return path to redirect to // See if we've been passed a return path to redirect to
$return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : ''); $return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
if($return_path) { if ($return_path) {
$rand = '_=' . time(); $rand = '_=' . time();
if(strpos($return_path, '?')) $rand = "&$rand"; if(strpos($return_path, '?')) $rand = "&$rand";
else $rand = "?$rand"; else $rand = "?$rand";
goaway($a->get_baseurl() . "/" . $return_path . $rand); goaway(App::get_baseurl() . "/" . $return_path . $rand);
} }
// the json doesn't really matter, it will either be 0 or 1 // the json doesn't really matter, it will either be 0 or 1

View file

@ -15,13 +15,12 @@ function install_init(&$a){
// We overwrite current theme css, because during install we could not have a working mod_rewrite // We overwrite current theme css, because during install we could not have a working mod_rewrite
// so we could not have a css at all. Here we set a static css file for the install procedure pages // so we could not have a css at all. Here we set a static css file for the install procedure pages
$a->config['system']['theme'] = "../install"; $a->config['system']['theme'] = "../install";
$a->theme['stylesheet'] = $a->get_baseurl()."/view/install/style.css"; $a->theme['stylesheet'] = App::get_baseurl()."/view/install/style.css";
global $install_wizard_pass; global $install_wizard_pass;
if (x($_POST,'pass')) if (x($_POST,'pass')) {
$install_wizard_pass = intval($_POST['pass']); $install_wizard_pass = intval($_POST['pass']);
}
} }
@ -52,7 +51,7 @@ function install_post(&$a) {
$r = q("CREATE DATABASE '%s'", $r = q("CREATE DATABASE '%s'",
dbesc($dbdata) dbesc($dbdata)
); );
if($r) { if ($r) {
unset($db); unset($db);
$db = new dba($dbhost, $dbuser, $dbpass, $dbdata, true); $db = new dba($dbhost, $dbuser, $dbpass, $dbdata, true);
} else { } else {
@ -63,7 +62,7 @@ function install_post(&$a) {
return; return;
} }
}*/ }*/
if(get_db_errno()) { if (get_db_errno()) {
$a->data['db_conn_failed']=true; $a->data['db_conn_failed']=true;
} }
@ -107,17 +106,18 @@ function install_post(&$a) {
$result = file_put_contents('.htconfig.php', $txt); $result = file_put_contents('.htconfig.php', $txt);
if(! $result) { if (! $result) {
$a->data['txt'] = $txt; $a->data['txt'] = $txt;
} }
$errors = load_database($db); $errors = load_database($db);
if($errors) if ($errors) {
$a->data['db_failed'] = $errors; $a->data['db_failed'] = $errors;
else } else {
$a->data['db_installed'] = true; $a->data['db_installed'] = true;
}
return; return;
break; break;
@ -125,10 +125,11 @@ function install_post(&$a) {
} }
function get_db_errno() { function get_db_errno() {
if(class_exists('mysqli')) if (class_exists('mysqli')) {
return mysqli_connect_errno(); return mysqli_connect_errno();
else } else {
return mysql_errno(); return mysql_errno();
}
} }
function install_content(&$a) { function install_content(&$a) {
@ -140,23 +141,23 @@ function install_content(&$a) {
if(x($a->data,'db_conn_failed')) { if (x($a->data,'db_conn_failed')) {
$install_wizard_pass = 2; $install_wizard_pass = 2;
$wizard_status = t('Could not connect to database.'); $wizard_status = t('Could not connect to database.');
} }
if(x($a->data,'db_create_failed')) { if (x($a->data,'db_create_failed')) {
$install_wizard_pass = 2; $install_wizard_pass = 2;
$wizard_status = t('Could not create table.'); $wizard_status = t('Could not create table.');
} }
$db_return_text=""; $db_return_text="";
if(x($a->data,'db_installed')) { if (x($a->data,'db_installed')) {
$txt = '<p style="font-size: 130%;">'; $txt = '<p style="font-size: 130%;">';
$txt .= t('Your Friendica site database has been installed.') . EOL; $txt .= t('Your Friendica site database has been installed.') . EOL;
$db_return_text .= $txt; $db_return_text .= $txt;
} }
if(x($a->data,'db_failed')) { if (x($a->data,'db_failed')) {
$txt = t('You may need to import the file "database.sql" manually using phpmyadmin or mysql.') . EOL; $txt = t('You may need to import the file "database.sql" manually using phpmyadmin or mysql.') . EOL;
$txt .= t('Please see the file "INSTALL.txt".') . EOL ."<hr>" ; $txt .= t('Please see the file "INSTALL.txt".') . EOL ."<hr>" ;
$txt .= "<pre>".$a->data['db_failed'] . "</pre>". EOL ; $txt .= "<pre>".$a->data['db_failed'] . "</pre>". EOL ;
@ -176,7 +177,7 @@ function install_content(&$a) {
} }
} }
if(x($a->data,'txt') && strlen($a->data['txt'])) { if (x($a->data,'txt') && strlen($a->data['txt'])) {
$db_return_text .= manual_config($a); $db_return_text .= manual_config($a);
} }
@ -205,16 +206,19 @@ function install_content(&$a) {
check_keys($checks); check_keys($checks);
if(x($_POST,'phpath')) if (x($_POST,'phpath')) {
$phpath = notags(trim($_POST['phpath'])); $phpath = notags(trim($_POST['phpath']));
}
check_php($phpath, $checks); check_php($phpath, $checks);
check_htaccess($checks); check_htaccess($checks);
/// @TODO Maybe move this out?
function check_passed($v, $c){ function check_passed($v, $c){
if ($c['required']) if ($c['required']) {
$v = $v && $c['status']; $v = $v && $c['status'];
}
return $v; return $v;
} }
$checkspassed = array_reduce($checks, "check_passed", true); $checkspassed = array_reduce($checks, "check_passed", true);
@ -231,7 +235,7 @@ function install_content(&$a) {
'$next' => t('Next'), '$next' => t('Next'),
'$reload' => t('Check again'), '$reload' => t('Check again'),
'$phpath' => $phpath, '$phpath' => $phpath,
'$baseurl' => $a->get_baseurl(), '$baseurl' => App::get_baseurl(),
)); ));
return $o; return $o;
}; break; }; break;
@ -265,7 +269,7 @@ function install_content(&$a) {
'$lbl_10' => t('Please select a default timezone for your website'), '$lbl_10' => t('Please select a default timezone for your website'),
'$baseurl' => $a->get_baseurl(), '$baseurl' => App::get_baseurl(),
'$phpath' => $phpath, '$phpath' => $phpath,
@ -305,7 +309,7 @@ function install_content(&$a) {
'$timezone' => field_timezone('timezone', t('Please select a default timezone for your website'), $timezone, ''), '$timezone' => field_timezone('timezone', t('Please select a default timezone for your website'), $timezone, ''),
'$language' => array('language', t('System Language:'), 'en', t('Set the default language for your Friendica installation interface and to send emails.'), $lang_choices), '$language' => array('language', t('System Language:'), 'en', t('Set the default language for your Friendica installation interface and to send emails.'), $lang_choices),
'$baseurl' => $a->get_baseurl(), '$baseurl' => App::get_baseurl(),
@ -343,7 +347,7 @@ function check_php(&$phpath, &$checks) {
$passed = strlen($phpath); $passed = strlen($phpath);
} }
$help = ""; $help = "";
if(!$passed) { if (!$passed) {
$help .= t('Could not find a command line version of PHP in the web server PATH.'). EOL; $help .= t('Could not find a command line version of PHP in the web server PATH.'). EOL;
$help .= t("If you don't have a command line version of PHP installed on server, you will not be able to run background polling via cron. See <a href='https://github.com/friendica/friendica/blob/master/doc/Install.md#set-up-the-poller'>'Setup the poller'</a>") . EOL ; $help .= t("If you don't have a command line version of PHP installed on server, you will not be able to run background polling via cron. See <a href='https://github.com/friendica/friendica/blob/master/doc/Install.md#set-up-the-poller'>'Setup the poller'</a>") . EOL ;
$help .= EOL . EOL ; $help .= EOL . EOL ;
@ -370,7 +374,7 @@ function check_php(&$phpath, &$checks) {
} }
if($passed2) { if ($passed2) {
$str = autoname(8); $str = autoname(8);
$cmd = "$phpath testargs.php $str"; $cmd = "$phpath testargs.php $str";
$result = trim(shell_exec($cmd)); $result = trim(shell_exec($cmd));
@ -392,15 +396,17 @@ function check_keys(&$checks) {
$res = false; $res = false;
if(function_exists('openssl_pkey_new')) if (function_exists('openssl_pkey_new')) {
$res=openssl_pkey_new(array( $res = openssl_pkey_new(array(
'digest_alg' => 'sha1', 'digest_alg' => 'sha1',
'private_key_bits' => 4096, 'private_key_bits' => 4096,
'encrypt_key' => false )); 'encrypt_key' => false
));
}
// Get private key // Get private key
if(! $res) { if (! $res) {
$help .= t('Error: the "openssl_pkey_new" function on this system is not able to generate encryption keys'). EOL; $help .= t('Error: the "openssl_pkey_new" function on this system is not able to generate encryption keys'). EOL;
$help .= t('If running under Windows, please see "http://www.php.net/manual/en/openssl.installation.php".'); $help .= t('If running under Windows, please see "http://www.php.net/manual/en/openssl.installation.php".');
} }
@ -420,7 +426,7 @@ function check_funcs(&$checks) {
check_add($ck_funcs, t('XML PHP module'), true, true, ""); check_add($ck_funcs, t('XML PHP module'), true, true, "");
check_add($ck_funcs, t('iconv module'), true, true, ""); check_add($ck_funcs, t('iconv module'), true, true, "");
if(function_exists('apache_get_modules')){ if (function_exists('apache_get_modules')){
if (! in_array('mod_rewrite',apache_get_modules())) { if (! in_array('mod_rewrite',apache_get_modules())) {
check_add($ck_funcs, t('Apache mod_rewrite module'), false, true, t('Error: Apache webserver mod-rewrite module is required but not installed.')); check_add($ck_funcs, t('Apache mod_rewrite module'), false, true, t('Error: Apache webserver mod-rewrite module is required but not installed.'));
} else { } else {
@ -428,31 +434,31 @@ function check_funcs(&$checks) {
} }
} }
if(! function_exists('curl_init')){ if (! function_exists('curl_init')){
$ck_funcs[0]['status']= false; $ck_funcs[0]['status']= false;
$ck_funcs[0]['help']= t('Error: libCURL PHP module required but not installed.'); $ck_funcs[0]['help']= t('Error: libCURL PHP module required but not installed.');
} }
if(! function_exists('imagecreatefromjpeg')){ if (! function_exists('imagecreatefromjpeg')){
$ck_funcs[1]['status']= false; $ck_funcs[1]['status']= false;
$ck_funcs[1]['help']= t('Error: GD graphics PHP module with JPEG support required but not installed.'); $ck_funcs[1]['help']= t('Error: GD graphics PHP module with JPEG support required but not installed.');
} }
if(! function_exists('openssl_public_encrypt')) { if (! function_exists('openssl_public_encrypt')) {
$ck_funcs[2]['status']= false; $ck_funcs[2]['status']= false;
$ck_funcs[2]['help']= t('Error: openssl PHP module required but not installed.'); $ck_funcs[2]['help']= t('Error: openssl PHP module required but not installed.');
} }
if(! function_exists('mysqli_connect')){ if (! function_exists('mysqli_connect')){
$ck_funcs[3]['status']= false; $ck_funcs[3]['status']= false;
$ck_funcs[3]['help']= t('Error: mysqli PHP module required but not installed.'); $ck_funcs[3]['help']= t('Error: mysqli PHP module required but not installed.');
} }
if(! function_exists('mb_strlen')){ if (! function_exists('mb_strlen')){
$ck_funcs[4]['status']= false; $ck_funcs[4]['status']= false;
$ck_funcs[4]['help']= t('Error: mb_string PHP module required but not installed.'); $ck_funcs[4]['help']= t('Error: mb_string PHP module required but not installed.');
} }
if(! function_exists('mcrypt_create_iv')){ if (! function_exists('mcrypt_create_iv')){
$ck_funcs[5]['status']= false; $ck_funcs[5]['status']= false;
$ck_funcs[5]['help']= t('Error: mcrypt PHP module required but not installed.'); $ck_funcs[5]['help']= t('Error: mcrypt PHP module required but not installed.');
} }
if(! function_exists('iconv_strlen')){ if (! function_exists('iconv_strlen')){
$ck_funcs[7]['status']= false; $ck_funcs[7]['status']= false;
$ck_funcs[7]['help']= t('Error: iconv PHP module required but not installed.'); $ck_funcs[7]['help']= t('Error: iconv PHP module required but not installed.');
} }
@ -487,7 +493,7 @@ function check_funcs(&$checks) {
function check_htconfig(&$checks) { function check_htconfig(&$checks) {
$status = true; $status = true;
$help = ""; $help = "";
if( (file_exists('.htconfig.php') && !is_writable('.htconfig.php')) || if ((file_exists('.htconfig.php') && !is_writable('.htconfig.php')) ||
(!file_exists('.htconfig.php') && !is_writable('.')) ) { (!file_exists('.htconfig.php') && !is_writable('.')) ) {
$status=false; $status=false;
@ -504,7 +510,7 @@ function check_htconfig(&$checks) {
function check_smarty3(&$checks) { function check_smarty3(&$checks) {
$status = true; $status = true;
$help = ""; $help = "";
if( !is_writable('view/smarty3') ) { if (!is_writable('view/smarty3') ) {
$status=false; $status=false;
$help = t('Friendica uses the Smarty3 template engine to render its web views. Smarty3 compiles templates to PHP to speed up rendering.') .EOL; $help = t('Friendica uses the Smarty3 template engine to render its web views. Smarty3 compiles templates to PHP to speed up rendering.') .EOL;
@ -518,14 +524,14 @@ function check_smarty3(&$checks) {
} }
function check_htaccess(&$checks) { function check_htaccess(&$checks) {
$a = get_app();
$status = true; $status = true;
$help = ""; $help = "";
if (function_exists('curl_init')){ if (function_exists('curl_init')) {
$test = fetch_url($a->get_baseurl()."/install/testrewrite"); $test = fetch_url(App::get_baseurl()."/install/testrewrite");
if ($test!="ok") if ($test!="ok") {
$test = fetch_url(normalise_link($a->get_baseurl()."/install/testrewrite")); $test = fetch_url(normalise_link(App::get_baseurl()."/install/testrewrite"));
}
if ($test!="ok") { if ($test!="ok") {
$status = false; $status = false;
@ -534,6 +540,7 @@ function check_htaccess(&$checks) {
check_add($checks, t('Url rewrite is working'), $status, true, $help); check_add($checks, t('Url rewrite is working'), $status, true, $help);
} else { } else {
// cannot check modrewrite if libcurl is not installed // cannot check modrewrite if libcurl is not installed
/// @TODO Maybe issue warning here?
} }
} }
@ -550,8 +557,7 @@ function check_imagik(&$checks) {
} }
if ($imagick == false) { if ($imagick == false) {
check_add($checks, t('ImageMagick PHP extension is not installed'), $imagick, false, ""); check_add($checks, t('ImageMagick PHP extension is not installed'), $imagick, false, "");
} } else {
else {
check_add($checks, t('ImageMagick PHP extension is installed'), $imagick, false, ""); check_add($checks, t('ImageMagick PHP extension is installed'), $imagick, false, "");
if ($imagick) { if ($imagick) {
check_add($checks, t('ImageMagick supports GIF'), $gif, false, ""); check_add($checks, t('ImageMagick supports GIF'), $gif, false, "");
@ -559,8 +565,6 @@ function check_imagik(&$checks) {
} }
} }
function manual_config(&$a) { function manual_config(&$a) {
$data = htmlentities($a->data['txt'],ENT_COMPAT,'UTF-8'); $data = htmlentities($a->data['txt'],ENT_COMPAT,'UTF-8');
$o = t('The database configuration file ".htconfig.php" could not be written. Please use the enclosed text to create a configuration file in your web server root.'); $o = t('The database configuration file ".htconfig.php" could not be written. Please use the enclosed text to create a configuration file in your web server root.');
@ -599,8 +603,7 @@ function load_database($db) {
} }
function what_next() { function what_next() {
$a = get_app(); $baseurl = App::get_baseurl();
$baseurl = $a->get_baseurl();
return return
t('<h1>What next</h1>') t('<h1>What next</h1>')
."<p>".t('IMPORTANT: You will need to [manually] setup a scheduled task for the poller.') ."<p>".t('IMPORTANT: You will need to [manually] setup a scheduled task for the poller.')

View file

@ -11,7 +11,7 @@ require_once('include/email.php');
function invite_post(&$a) { function invite_post(&$a) {
if(! local_user()) { if (! local_user()) {
notice( t('Permission denied.') . EOL); notice( t('Permission denied.') . EOL);
return; return;
} }
@ -19,14 +19,15 @@ function invite_post(&$a) {
check_form_security_token_redirectOnErr('/', 'send_invite'); check_form_security_token_redirectOnErr('/', 'send_invite');
$max_invites = intval(get_config('system','max_invites')); $max_invites = intval(get_config('system','max_invites'));
if(! $max_invites) if (! $max_invites) {
$max_invites = 50; $max_invites = 50;
}
$current_invites = intval(get_pconfig(local_user(),'system','sent_invites')); $current_invites = intval(get_pconfig(local_user(),'system','sent_invites'));
if($current_invites > $max_invites) { if ($current_invites > $max_invites) {
notice( t('Total invitation limit exceeded.') . EOL); notice( t('Total invitation limit exceeded.') . EOL);
return; return;
}; }
$recips = ((x($_POST,'recipients')) ? explode("\n",$_POST['recipients']) : array()); $recips = ((x($_POST,'recipients')) ? explode("\n",$_POST['recipients']) : array());
@ -34,23 +35,24 @@ function invite_post(&$a) {
$total = 0; $total = 0;
if(get_config('system','invitation_only')) { if (get_config('system','invitation_only')) {
$invonly = true; $invonly = true;
$x = get_pconfig(local_user(),'system','invites_remaining'); $x = get_pconfig(local_user(),'system','invites_remaining');
if((! $x) && (! is_site_admin())) if ((! $x) && (! is_site_admin())) {
return; return;
} }
}
foreach($recips as $recip) { foreach ($recips as $recip) {
$recip = trim($recip); $recip = trim($recip);
if(! valid_email($recip)) { if (! valid_email($recip)) {
notice( sprintf( t('%s : Not a valid email address.'), $recip) . EOL); notice( sprintf( t('%s : Not a valid email address.'), $recip) . EOL);
continue; continue;
} }
if($invonly && ($x || is_site_admin())) { if ($invonly && ($x || is_site_admin())) {
$code = autoname(8) . srand(1000,9999); $code = autoname(8) . srand(1000,9999);
$nmessage = str_replace('$invite_code',$code,$message); $nmessage = str_replace('$invite_code',$code,$message);
@ -59,16 +61,17 @@ function invite_post(&$a) {
dbesc(datetime_convert()) dbesc(datetime_convert())
); );
if(! is_site_admin()) { if (! is_site_admin()) {
$x --; $x --;
if($x >= 0) if ($x >= 0) {
set_pconfig(local_user(),'system','invites_remaining',$x); set_pconfig(local_user(),'system','invites_remaining',$x);
else } else {
return; return;
} }
} }
else } else {
$nmessage = $message; $nmessage = $message;
}
$res = mail($recip, email_header_encode( t('Please join us on Friendica'),'UTF-8'), $res = mail($recip, email_header_encode( t('Please join us on Friendica'),'UTF-8'),
$nmessage, $nmessage,
@ -76,7 +79,7 @@ function invite_post(&$a) {
. 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n"
. 'Content-transfer-encoding: 8bit' ); . 'Content-transfer-encoding: 8bit' );
if($res) { if ($res) {
$total ++; $total ++;
$current_invites ++; $current_invites ++;
set_pconfig(local_user(),'system','sent_invites',$current_invites); set_pconfig(local_user(),'system','sent_invites',$current_invites);
@ -84,8 +87,7 @@ function invite_post(&$a) {
notice( t('Invitation limit exceeded. Please contact your site administrator.') . EOL); notice( t('Invitation limit exceeded. Please contact your site administrator.') . EOL);
return; return;
} }
} } else {
else {
notice( sprintf( t('%s : Message delivery failed.'), $recip) . EOL); notice( sprintf( t('%s : Message delivery failed.'), $recip) . EOL);
} }
@ -97,7 +99,7 @@ function invite_post(&$a) {
function invite_content(&$a) { function invite_content(&$a) {
if(! local_user()) { if (! local_user()) {
notice( t('Permission denied.') . EOL); notice( t('Permission denied.') . EOL);
return; return;
} }
@ -105,24 +107,24 @@ function invite_content(&$a) {
$tpl = get_markup_template('invite.tpl'); $tpl = get_markup_template('invite.tpl');
$invonly = false; $invonly = false;
if(get_config('system','invitation_only')) { if (get_config('system','invitation_only')) {
$invonly = true; $invonly = true;
$x = get_pconfig(local_user(),'system','invites_remaining'); $x = get_pconfig(local_user(),'system','invites_remaining');
if((! $x) && (! is_site_admin())) { if ((! $x) && (! is_site_admin())) {
notice( t('You have no more invitations available') . EOL); notice( t('You have no more invitations available') . EOL);
return ''; return '';
} }
} }
$dirloc = get_config('system','directory'); $dirloc = get_config('system','directory');
if(strlen($dirloc)) { if (strlen($dirloc)) {
if($a->config['register_policy'] == REGISTER_CLOSED) if ($a->config['register_policy'] == REGISTER_CLOSED) {
$linktxt = sprintf( t('Visit %s for a list of public sites that you can join. Friendica members on other sites can all connect with each other, as well as with members of many other social networks.'), $dirloc . '/siteinfo'); $linktxt = sprintf( t('Visit %s for a list of public sites that you can join. Friendica members on other sites can all connect with each other, as well as with members of many other social networks.'), $dirloc . '/siteinfo');
elseif($a->config['register_policy'] != REGISTER_CLOSED) } elseif($a->config['register_policy'] != REGISTER_CLOSED) {
$linktxt = sprintf( t('To accept this invitation, please visit and register at %s or any other public Friendica website.'), $a->get_baseurl()) $linktxt = sprintf( t('To accept this invitation, please visit and register at %s or any other public Friendica website.'), App::get_baseurl())
. "\r\n" . "\r\n" . sprintf( t('Friendica sites all inter-connect to create a huge privacy-enhanced social web that is owned and controlled by its members. They can also connect with many traditional social networks. See %s for a list of alternate Friendica sites you can join.'),$dirloc . '/siteinfo'); . "\r\n" . "\r\n" . sprintf( t('Friendica sites all inter-connect to create a huge privacy-enhanced social web that is owned and controlled by its members. They can also connect with many traditional social networks. See %s for a list of alternate Friendica sites you can join.'),$dirloc . '/siteinfo');
} }
else { } else {
$o = t('Our apologies. This system is not currently configured to connect with other public sites or invite members.'); $o = t('Our apologies. This system is not currently configured to connect with other public sites or invite members.');
return $o; return $o;
} }
@ -135,7 +137,7 @@ function invite_content(&$a) {
'$default_message' => t('You are cordially invited to join me and other close friends on Friendica - and help us to create a better social web.') . "\r\n" . "\r\n" '$default_message' => t('You are cordially invited to join me and other close friends on Friendica - and help us to create a better social web.') . "\r\n" . "\r\n"
. $linktxt . $linktxt
. "\r\n" . "\r\n" . (($invonly) ? t('You will need to supply this invitation code: $invite_code') . "\r\n" . "\r\n" : '') .t('Once you have registered, please connect with me via my profile page at:') . "\r\n" . "\r\n" . (($invonly) ? t('You will need to supply this invitation code: $invite_code') . "\r\n" . "\r\n" : '') .t('Once you have registered, please connect with me via my profile page at:')
. "\r\n" . "\r\n" . $a->get_baseurl() . '/profile/' . $a->user['nickname'] . "\r\n" . "\r\n" . App::get_baseurl() . '/profile/' . $a->user['nickname']
. "\r\n" . "\r\n" . t('For more information about the Friendica project and why we feel it is important, please visit http://friendica.com') . "\r\n" . "\r\n" , . "\r\n" . "\r\n" . t('For more information about the Friendica project and why we feel it is important, please visit http://friendica.com') . "\r\n" . "\r\n" ,
'$submit' => t('Submit') '$submit' => t('Submit')
)); ));

View file

@ -59,14 +59,15 @@ function item_post(&$a) {
// Check for doubly-submitted posts, and reject duplicates // Check for doubly-submitted posts, and reject duplicates
// Note that we have to ignore previews, otherwise nothing will post // Note that we have to ignore previews, otherwise nothing will post
// after it's been previewed // after it's been previewed
if(!$preview && x($_REQUEST['post_id_random'])) { if (!$preview && x($_REQUEST['post_id_random'])) {
if(x($_SESSION['post-random']) && $_SESSION['post-random'] == $_REQUEST['post_id_random']) { if (x($_SESSION['post-random']) && $_SESSION['post-random'] == $_REQUEST['post_id_random']) {
logger("item post: duplicate post", LOGGER_DEBUG); logger("item post: duplicate post", LOGGER_DEBUG);
item_post_return($a->get_baseurl(), $api_source, $return_path); item_post_return(App::get_baseurl(), $api_source, $return_path);
} }
else else {
$_SESSION['post-random'] = $_REQUEST['post_id_random']; $_SESSION['post-random'] = $_REQUEST['post_id_random'];
} }
}
/** /**
* Is this a reply to something? * Is this a reply to something?
@ -82,18 +83,19 @@ function item_post(&$a) {
$r = false; $r = false;
$objecttype = null; $objecttype = null;
if($parent || $parent_uri) { if ($parent || $parent_uri) {
$objecttype = ACTIVITY_OBJ_COMMENT; $objecttype = ACTIVITY_OBJ_COMMENT;
if(! x($_REQUEST,'type')) if (! x($_REQUEST,'type')) {
$_REQUEST['type'] = 'net-comment'; $_REQUEST['type'] = 'net-comment';
}
if($parent) { if ($parent) {
$r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1", $r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1",
intval($parent) intval($parent)
); );
} elseif($parent_uri && local_user()) { } elseif ($parent_uri && local_user()) {
// This is coming from an API source, and we are logged in // This is coming from an API source, and we are logged in
$r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($parent_uri), dbesc($parent_uri),
@ -105,17 +107,18 @@ function item_post(&$a) {
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
$parid = $r[0]['parent']; $parid = $r[0]['parent'];
$parent_uri = $r[0]['uri']; $parent_uri = $r[0]['uri'];
if($r[0]['id'] != $r[0]['parent']) { if ($r[0]['id'] != $r[0]['parent']) {
$r = q("SELECT * FROM `item` WHERE `id` = `parent` AND `parent` = %d LIMIT 1", $r = q("SELECT * FROM `item` WHERE `id` = `parent` AND `parent` = %d LIMIT 1",
intval($parid) intval($parid)
); );
} }
} }
if(! dbm::is_result($r)) { if (! dbm::is_result($r)) {
notice( t('Unable to locate original post.') . EOL); notice( t('Unable to locate original post.') . EOL);
if(x($_REQUEST,'return')) if (x($_REQUEST,'return')) {
goaway($return_path); goaway($return_path);
}
killme(); killme();
} }
$parent_item = $r[0]; $parent_item = $r[0];
@ -125,7 +128,7 @@ function item_post(&$a) {
//if(($parid) && ($parid != $parent)) //if(($parid) && ($parid != $parent))
$thr_parent = $parent_uri; $thr_parent = $parent_uri;
if($parent_item['contact-id'] && $uid) { if ($parent_item['contact-id'] && $uid) {
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($parent_item['contact-id']), intval($parent_item['contact-id']),
intval($uid) intval($uid)
@ -137,16 +140,7 @@ function item_post(&$a) {
$thrparent = q("SELECT `author-link`, `network` FROM `item` WHERE `uri` = '%s' LIMIT 1", dbesc($thr_parent)); $thrparent = q("SELECT `author-link`, `network` FROM `item` WHERE `uri` = '%s' LIMIT 1", dbesc($thr_parent));
if (count($thrparent) AND ($thrparent[0]["network"] === NETWORK_OSTATUS) if (count($thrparent) AND ($thrparent[0]["network"] === NETWORK_OSTATUS)
AND (normalise_link($parent_contact["url"]) != normalise_link($thrparent[0]["author-link"]))) { AND (normalise_link($parent_contact["url"]) != normalise_link($thrparent[0]["author-link"]))) {
$parent_contact = null; $parent_contact = get_contact_details_by_url($thrparent[0]["author-link"]);
$r = q("SELECT * FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
dbesc(normalise_link($thrparent[0]["author-link"])));
if (dbm::is_result($r)) {
$parent_contact = $r[0];
$parent_contact["thumb"] = $parent_contact["photo"];
$parent_contact["micro"] = $parent_contact["photo"];
unset($parent_contact["id"]);
}
if (!isset($parent_contact["nick"])) { if (!isset($parent_contact["nick"])) {
require_once("include/Scrape.php"); require_once("include/Scrape.php");
@ -448,13 +442,15 @@ function item_post(&$a) {
$objecttype = ACTIVITY_OBJ_IMAGE; $objecttype = ACTIVITY_OBJ_IMAGE;
foreach($images as $image) { foreach ($images as $image) {
if(! stristr($image,$a->get_baseurl() . '/photo/')) if (! stristr($image,App::get_baseurl() . '/photo/')) {
continue; continue;
}
$image_uri = substr($image,strrpos($image,'/') + 1); $image_uri = substr($image,strrpos($image,'/') + 1);
$image_uri = substr($image_uri,0, strpos($image_uri,'-')); $image_uri = substr($image_uri,0, strpos($image_uri,'-'));
if(! strlen($image_uri)) if (! strlen($image_uri)) {
continue; continue;
}
$srch = '<' . intval($contact_id) . '>'; $srch = '<' . intval($contact_id) . '>';
$r = q("SELECT `id` FROM `photo` WHERE `allow_cid` = '%s' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = '' $r = q("SELECT `id` FROM `photo` WHERE `allow_cid` = '%s' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = ''
@ -464,8 +460,9 @@ function item_post(&$a) {
intval($profile_uid) intval($profile_uid)
); );
if(! dbm::is_result($r)) if (! dbm::is_result($r)) {
continue; continue;
}
$r = q("UPDATE `photo` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s' $r = q("UPDATE `photo` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s'
WHERE `resource-id` = '%s' AND `uid` = %d AND `album` = '%s' ", WHERE `resource-id` = '%s' AND `uid` = %d AND `album` = '%s' ",
@ -561,11 +558,7 @@ function item_post(&$a) {
* add a statusnet style reply tag if the original post was from there * add a statusnet style reply tag if the original post was from there
* and we are replying, and there isn't one already * and we are replying, and there isn't one already
*/ */
if ($parent AND ($parent_contact['network'] == NETWORK_OSTATUS)) {
if($parent AND ($parent_contact['network'] === NETWORK_OSTATUS)) {
if ($parent_contact['id'] != "")
$contact = '@'.$parent_contact['nick'].'+'.$parent_contact['id'];
else
$contact = '@[url='.$parent_contact['url'].']'.$parent_contact['nick'].'[/url]'; $contact = '@[url='.$parent_contact['url'].']'.$parent_contact['nick'].'[/url]';
if (!in_array($contact,$tags)) { if (!in_array($contact,$tags)) {
@ -638,9 +631,10 @@ function item_post(&$a) {
intval($mtch) intval($mtch)
); );
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
if(strlen($attachments)) if (strlen($attachments)) {
$attachments .= ','; $attachments .= ',';
$attachments .= '[attach]href="' . $a->get_baseurl() . '/attach/' . $r[0]['id'] . '" length="' . $r[0]['filesize'] . '" type="' . $r[0]['filetype'] . '" title="' . (($r[0]['filename']) ? $r[0]['filename'] : '') . '"[/attach]'; }
$attachments .= '[attach]href="' . App::get_baseurl() . '/attach/' . $r[0]['id'] . '" length="' . $r[0]['filesize'] . '" type="' . $r[0]['filetype'] . '" title="' . (($r[0]['filename']) ? $r[0]['filename'] : '') . '"[/attach]';
} }
$body = str_replace($match[1],'',$body); $body = str_replace($match[1],'',$body);
} }
@ -648,14 +642,17 @@ function item_post(&$a) {
$wall = 0; $wall = 0;
if($post_type === 'wall' || $post_type === 'wall-comment') if ($post_type === 'wall' || $post_type === 'wall-comment') {
$wall = 1; $wall = 1;
}
if(! strlen($verb)) if (! strlen($verb)) {
$verb = ACTIVITY_POST ; $verb = ACTIVITY_POST ;
}
if ($network == "") if ($network == "") {
$network = NETWORK_DFRN; $network = NETWORK_DFRN;
}
$gravity = (($parent) ? 6 : 0 ); $gravity = (($parent) ? 6 : 0 );
@ -669,8 +666,9 @@ function item_post(&$a) {
$uri = (($message_id) ? $message_id : item_new_uri($a->get_hostname(),$profile_uid, $guid)); $uri = (($message_id) ? $message_id : item_new_uri($a->get_hostname(),$profile_uid, $guid));
// Fallback so that we alway have a thr-parent // Fallback so that we alway have a thr-parent
if(!$thr_parent) if (!$thr_parent) {
$thr_parent = $uri; $thr_parent = $uri;
}
$datarray = array(); $datarray = array();
$datarray['uid'] = $profile_uid; $datarray['uid'] = $profile_uid;
@ -732,7 +730,7 @@ function item_post(&$a) {
// $datarray['prvnets'] = $user['prvnets']; // $datarray['prvnets'] = $user['prvnets'];
$datarray['parent-uri'] = ($parent == 0) ? $uri : $parent_item['uri']; $datarray['parent-uri'] = ($parent == 0) ? $uri : $parent_item['uri'];
$datarray['plink'] = $a->get_baseurl().'/display/'.urlencode($datarray['guid']); $datarray['plink'] = App::get_baseurl().'/display/'.urlencode($datarray['guid']);
$datarray['last-child'] = 1; $datarray['last-child'] = 1;
$datarray['visible'] = 1; $datarray['visible'] = 1;
@ -765,8 +763,9 @@ function item_post(&$a) {
} }
$json = array('cancel' => 1); $json = array('cancel' => 1);
if(x($_REQUEST,'jsreload') && strlen($_REQUEST['jsreload'])) if (x($_REQUEST,'jsreload') && strlen($_REQUEST['jsreload'])) {
$json['reload'] = $a->get_baseurl() . '/' . $_REQUEST['jsreload']; $json['reload'] = App::get_baseurl() . '/' . $_REQUEST['jsreload'];
}
echo json_encode($json); echo json_encode($json);
killme(); killme();
@ -938,7 +937,7 @@ function item_post(&$a) {
'to_email' => $user['email'], 'to_email' => $user['email'],
'uid' => $user['uid'], 'uid' => $user['uid'],
'item' => $datarray, 'item' => $datarray,
'link' => $a->get_baseurl().'/display/'.urlencode($datarray['guid']), 'link' => App::get_baseurl().'/display/'.urlencode($datarray['guid']),
'source_name' => $datarray['author-name'], 'source_name' => $datarray['author-name'],
'source_link' => $datarray['author-link'], 'source_link' => $datarray['author-link'],
'source_photo' => $datarray['author-avatar'], 'source_photo' => $datarray['author-avatar'],
@ -952,7 +951,7 @@ function item_post(&$a) {
// Store the comment signature information in case we need to relay to Diaspora // Store the comment signature information in case we need to relay to Diaspora
diaspora::store_comment_signature($datarray, $author, ($self ? $user['prvkey'] : false), $post_id); Diaspora::store_comment_signature($datarray, $author, ($self ? $user['prvkey'] : false), $post_id);
} else { } else {
$parent = $post_id; $parent = $post_id;
@ -970,7 +969,7 @@ function item_post(&$a) {
'to_email' => $user['email'], 'to_email' => $user['email'],
'uid' => $user['uid'], 'uid' => $user['uid'],
'item' => $datarray, 'item' => $datarray,
'link' => $a->get_baseurl().'/display/'.urlencode($datarray['guid']), 'link' => App::get_baseurl().'/display/'.urlencode($datarray['guid']),
'source_name' => $datarray['author-name'], 'source_name' => $datarray['author-name'],
'source_link' => $datarray['author-link'], 'source_link' => $datarray['author-link'],
'source_photo' => $datarray['author-avatar'], 'source_photo' => $datarray['author-avatar'],
@ -991,14 +990,14 @@ function item_post(&$a) {
continue; continue;
$disclaimer = '<hr />' . sprintf( t('This message was sent to you by %s, a member of the Friendica social network.'),$a->user['username']) $disclaimer = '<hr />' . sprintf( t('This message was sent to you by %s, a member of the Friendica social network.'),$a->user['username'])
. '<br />'; . '<br />';
$disclaimer .= sprintf( t('You may visit them online at %s'), $a->get_baseurl() . '/profile/' . $a->user['nickname']) . EOL; $disclaimer .= sprintf( t('You may visit them online at %s'), App::get_baseurl() . '/profile/' . $a->user['nickname']) . EOL;
$disclaimer .= t('Please contact the sender by replying to this post if you do not wish to receive these messages.') . EOL; $disclaimer .= t('Please contact the sender by replying to this post if you do not wish to receive these messages.') . EOL;
if (!$datarray['title']=='') { if (!$datarray['title']=='') {
$subject = email_header_encode($datarray['title'],'UTF-8'); $subject = email_header_encode($datarray['title'],'UTF-8');
} else { } else {
$subject = email_header_encode('[Friendica]' . ' ' . sprintf( t('%s posted an update.'),$a->user['username']),'UTF-8'); $subject = email_header_encode('[Friendica]' . ' ' . sprintf( t('%s posted an update.'),$a->user['username']),'UTF-8');
} }
$link = '<a href="' . $a->get_baseurl() . '/profile/' . $a->user['nickname'] . '"><img src="' . $author['thumb'] . '" alt="' . $a->user['username'] . '" /></a><br /><br />'; $link = '<a href="' . App::get_baseurl() . '/profile/' . $a->user['nickname'] . '"><img src="' . $author['thumb'] . '" alt="' . $a->user['username'] . '" /></a><br /><br />';
$html = prepare_body($datarray); $html = prepare_body($datarray);
$message = '<html><body>' . $link . $html . $disclaimer . '</body></html>'; $message = '<html><body>' . $link . $html . $disclaimer . '</body></html>';
include_once('include/html2plain.php'); include_once('include/html2plain.php');
@ -1038,7 +1037,7 @@ function item_post(&$a) {
logger('post_complete'); logger('post_complete');
item_post_return($a->get_baseurl(), $api_source, $return_path); item_post_return(App::get_baseurl(), $api_source, $return_path);
// NOTREACHED // NOTREACHED
} }
@ -1048,13 +1047,14 @@ function item_post_return($baseurl, $api_source, $return_path) {
if($api_source) if($api_source)
return; return;
if($return_path) { if ($return_path) {
goaway($return_path); goaway($return_path);
} }
$json = array('success' => 1); $json = array('success' => 1);
if(x($_REQUEST,'jsreload') && strlen($_REQUEST['jsreload'])) if (x($_REQUEST,'jsreload') && strlen($_REQUEST['jsreload'])) {
$json['reload'] = $baseurl . '/' . $_REQUEST['jsreload']; $json['reload'] = $baseurl . '/' . $_REQUEST['jsreload'];
}
logger('post_json: ' . print_r($json,true), LOGGER_DEBUG); logger('post_json: ' . print_r($json,true), LOGGER_DEBUG);
@ -1066,15 +1066,16 @@ function item_post_return($baseurl, $api_source, $return_path) {
function item_content(&$a) { function item_content(&$a) {
if((! local_user()) && (! remote_user())) if ((! local_user()) && (! remote_user())) {
return; return;
}
require_once('include/security.php'); require_once('include/security.php');
$o = ''; $o = '';
if(($a->argc == 3) && ($a->argv[1] === 'drop') && intval($a->argv[2])) { if (($a->argc == 3) && ($a->argv[1] === 'drop') && intval($a->argv[2])) {
$o = drop_item($a->argv[2], !is_ajax()); $o = drop_item($a->argv[2], !is_ajax());
if (is_ajax()){ if (is_ajax()) {
// ajax return: [<item id>, 0 (no perm) | <owner id>] // ajax return: [<item id>, 0 (no perm) | <owner id>]
echo json_encode(array(intval($a->argv[2]), intval($o))); echo json_encode(array(intval($a->argv[2]), intval($o)));
killme(); killme();
@ -1087,6 +1088,7 @@ function item_content(&$a) {
* This function removes the tag $tag from the text $body and replaces it with * This function removes the tag $tag from the text $body and replaces it with
* the appropiate link. * the appropiate link.
* *
* @param App $a Application instance @TODO is unused in this function's scope (excluding included files)
* @param unknown_type $body the text to replace the tag in * @param unknown_type $body the text to replace the tag in
* @param string $inform a comma-seperated string containing everybody to inform * @param string $inform a comma-seperated string containing everybody to inform
* @param string $str_tags string to add the tag to * @param string $str_tags string to add the tag to
@ -1104,13 +1106,14 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $netwo
$r = null; $r = null;
//is it a person tag? //is it a person tag?
if(strpos($tag,'@') === 0) { if (strpos($tag,'@') === 0) {
//is it already replaced? //is it already replaced?
if(strpos($tag,'[url=')) { if (strpos($tag,'[url=')) {
//append tag to str_tags //append tag to str_tags
if(!stristr($str_tags,$tag)) { if (!stristr($str_tags,$tag)) {
if(strlen($str_tags)) if (strlen($str_tags)) {
$str_tags .= ','; $str_tags .= ',';
}
$str_tags .= $tag; $str_tags .= $tag;
} }

View file

@ -24,7 +24,7 @@ function like_content(&$a) {
// See if we've been passed a return path to redirect to // See if we've been passed a return path to redirect to
$return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : ''); $return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
like_content_return($a->get_baseurl(), $return_path); like_content_return(App::get_baseurl(), $return_path);
killme(); // NOTREACHED killme(); // NOTREACHED
// return; // NOTREACHED // return; // NOTREACHED
} }

View file

@ -36,7 +36,7 @@ function localtime_content(&$a) {
$o .= '<p>' . sprintf( t('Converted localtime: %s'),$a->data['mod-localtime']) . '</p>'; $o .= '<p>' . sprintf( t('Converted localtime: %s'),$a->data['mod-localtime']) . '</p>';
$o .= '<form action ="' . $a->get_baseurl() . '/localtime?f=&time=' . $t . '" method="post" >'; $o .= '<form action ="' . App::get_baseurl() . '/localtime?f=&time=' . $t . '" method="post" >';
$o .= '<p>' . t('Please select your timezone:') . '</p>'; $o .= '<p>' . t('Please select your timezone:') . '</p>';

View file

@ -21,8 +21,9 @@ function lockview_content(&$a) {
dbesc($type), dbesc($type),
intval($item_id) intval($item_id)
); );
if(! dbm::is_result($r)) if (! dbm::is_result($r)) {
killme(); killme();
}
$item = $r[0]; $item = $r[0];
call_hooks('lockview_content', $item); call_hooks('lockview_content', $item);

View file

@ -15,7 +15,7 @@ function lostpass_post(&$a) {
dbesc($loginame) dbesc($loginame)
); );
if(! dbm::is_result($r)) { if (! dbm::is_result($r)) {
notice( t('No valid account found.') . EOL); notice( t('No valid account found.') . EOL);
goaway(z_root()); goaway(z_root());
} }
@ -36,8 +36,7 @@ function lostpass_post(&$a) {
$sitename = $a->config['sitename']; $sitename = $a->config['sitename'];
$siteurl = $a->get_baseurl(); $resetlink = App::get_baseurl() . '/lostpass?verify=' . $new_password;
$resetlink = $a->get_baseurl() . '/lostpass?verify=' . $new_password;
$preamble = deindent(t(' $preamble = deindent(t('
Dear %1$s, Dear %1$s,
@ -64,7 +63,7 @@ function lostpass_post(&$a) {
Login Name: %3$s')); Login Name: %3$s'));
$preamble = sprintf($preamble, $username, $sitename); $preamble = sprintf($preamble, $username, $sitename);
$body = sprintf($body, $resetlink, $siteurl, $email); $body = sprintf($body, $resetlink, App::get_baseurl(), $email);
notification(array( notification(array(
'type' => "SYSTEM_EMAIL", 'type' => "SYSTEM_EMAIL",
@ -88,7 +87,7 @@ function lostpass_content(&$a) {
$r = q("SELECT * FROM `user` WHERE `pwdreset` = '%s' LIMIT 1", $r = q("SELECT * FROM `user` WHERE `pwdreset` = '%s' LIMIT 1",
dbesc($hash) dbesc($hash)
); );
if(! dbm::is_result($r)) { if (! dbm::is_result($r)) {
$o = t("Request could not be verified. \x28You may have previously submitted it.\x29 Password reset failed."); $o = t("Request could not be verified. \x28You may have previously submitted it.\x29 Password reset failed.");
return $o; return $o;
} }
@ -103,24 +102,23 @@ function lostpass_content(&$a) {
dbesc($new_password_encoded), dbesc($new_password_encoded),
intval($uid) intval($uid)
); );
if($r) { if ($r) {
$tpl = get_markup_template('pwdreset.tpl'); $tpl = get_markup_template('pwdreset.tpl');
$o .= replace_macros($tpl,array( $o .= replace_macros($tpl,array(
'$lbl1' => t('Password Reset'), '$lbl1' => t('Password Reset'),
'$lbl2' => t('Your password has been reset as requested.'), '$lbl2' => t('Your password has been reset as requested.'),
'$lbl3' => t('Your new password is'), '$lbl3' => t('Your new password is'),
'$lbl4' => t('Save or copy your new password - and then'), '$lbl4' => t('Save or copy your new password - and then'),
'$lbl5' => '<a href="' . $a->get_baseurl() . '">' . t('click here to login') . '</a>.', '$lbl5' => '<a href="' . App::get_baseurl() . '">' . t('click here to login') . '</a>.',
'$lbl6' => t('Your password may be changed from the <em>Settings</em> page after successful login.'), '$lbl6' => t('Your password may be changed from the <em>Settings</em> page after successful login.'),
'$newpass' => $new_password, '$newpass' => $new_password,
'$baseurl' => $a->get_baseurl() '$baseurl' => App::get_baseurl()
)); ));
info("Your password has been reset." . EOL); info("Your password has been reset." . EOL);
$sitename = $a->config['sitename']; $sitename = $a->config['sitename'];
$siteurl = $a->get_baseurl();
// $username, $email, $new_password // $username, $email, $new_password
$preamble = deindent(t(' $preamble = deindent(t('
Dear %1$s, Dear %1$s,
@ -139,7 +137,7 @@ function lostpass_content(&$a) {
')); '));
$preamble = sprintf($preamble, $username); $preamble = sprintf($preamble, $username);
$body = sprintf($body, $siteurl, $email, $new_password); $body = sprintf($body, App::get_baseurl(), $email, $new_password);
notification(array( notification(array(
'type' => "SYSTEM_EMAIL", 'type' => "SYSTEM_EMAIL",

View file

@ -5,8 +5,9 @@ require_once("include/text.php");
function manage_post(&$a) { function manage_post(&$a) {
if(! local_user()) if (! local_user()) {
return; return;
}
$uid = local_user(); $uid = local_user();
$orig_record = $a->user; $orig_record = $a->user;
@ -56,8 +57,9 @@ function manage_post(&$a) {
); );
} }
if(! dbm::is_result($r)) if (! dbm::is_result($r)) {
return; return;
}
unset($_SESSION['authenticated']); unset($_SESSION['authenticated']);
unset($_SESSION['uid']); unset($_SESSION['uid']);
@ -84,7 +86,7 @@ function manage_post(&$a) {
$ret = array(); $ret = array();
call_hooks('home_init',$ret); call_hooks('home_init',$ret);
goaway( $a->get_baseurl() . "/profile/" . $a->user['nickname'] ); goaway( App::get_baseurl() . "/profile/" . $a->user['nickname'] );
// NOTREACHED // NOTREACHED
} }
@ -92,7 +94,7 @@ function manage_post(&$a) {
function manage_content(&$a) { function manage_content(&$a) {
if(! local_user()) { if (! local_user()) {
notice( t('Permission denied.') . EOL); notice( t('Permission denied.') . EOL);
return; return;
} }

Some files were not shown because too many files have changed in this diff Show more