Merge remote-tracking branch 'upstream/dev' into dev

This commit is contained in:
zottel 2016-06-01 16:28:44 +02:00
commit 1f5529752f
456 changed files with 3890 additions and 59466 deletions

2
.gitignore vendored
View file

@ -14,6 +14,8 @@
*.rej *.rej
# OSX .DS_Store files # OSX .DS_Store files
.DS_Store .DS_Store
# version scripts (repo master only)
.version*
Thumbs.db Thumbs.db

View file

@ -1,4 +1,4 @@
Copyright (c) 2010-2016 Hubzilla Copyright (c) 2010-2016 the Hubzilla Community
All rights reserved. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy

View file

@ -62,11 +62,6 @@ class Poller {
$d = datetime_convert(); $d = datetime_convert();
// TODO check to see if there are any cronhooks before wasting a process
if(! $restart)
Master::Summon(array('Cronhooks'));
// Only poll from those with suitable relationships // Only poll from those with suitable relationships
$abandon_sql = (($abandon_days) $abandon_sql = (($abandon_days)

View file

@ -6,6 +6,7 @@ require_once('include/queue_fn.php');
require_once('include/zot.php'); require_once('include/zot.php');
class Queue { class Queue {
static public function run($argc,$argv) { static public function run($argc,$argv) {
require_once('include/items.php'); require_once('include/items.php');

View file

@ -10,7 +10,7 @@ class Hook {
$function = serialize($function); $function = serialize($function);
} }
$r = q("SELECT * FROM `hook` WHERE `hook` = '%s' AND `file` = '%s' AND `function` = '%s' and priority = %d and hook_version = %d LIMIT 1", $r = q("SELECT * FROM `hook` WHERE `hook` = '%s' AND `file` = '%s' AND `fn` = '%s' and priority = %d and hook_version = %d LIMIT 1",
dbesc($hook), dbesc($hook),
dbesc($file), dbesc($file),
dbesc($function), dbesc($function),
@ -23,13 +23,13 @@ class Hook {
// To aid in upgrade and transition, remove old settings for any registered hooks that match in all respects except // To aid in upgrade and transition, remove old settings for any registered hooks that match in all respects except
// for priority or hook_version // for priority or hook_version
$r = q("DELETE FROM `hook` where `hook` = '%s' and `file` = '%s' and `function` = '%s'", $r = q("DELETE FROM `hook` where `hook` = '%s' and `file` = '%s' and `fn` = '%s'",
dbesc($hook), dbesc($hook),
dbesc($file), dbesc($file),
dbesc($function) dbesc($function)
); );
$r = q("INSERT INTO `hook` (`hook`, `file`, `function`, `priority`, `hook_version`) VALUES ( '%s', '%s', '%s', %d, %d )", $r = q("INSERT INTO `hook` (`hook`, `file`, `fn`, `priority`, `hook_version`) VALUES ( '%s', '%s', '%s', %d, %d )",
dbesc($hook), dbesc($hook),
dbesc($file), dbesc($file),
dbesc($function), dbesc($function),
@ -44,7 +44,7 @@ class Hook {
if(is_array($function)) { if(is_array($function)) {
$function = serialize($function); $function = serialize($function);
} }
$r = q("DELETE FROM hook WHERE hook = '%s' AND `file` = '%s' AND `function` = '%s' and priority = %d and hook_version = %d", $r = q("DELETE FROM hook WHERE hook = '%s' AND `file` = '%s' AND `fn` = '%s' and priority = %d and hook_version = %d",
dbesc($hook), dbesc($hook),
dbesc($file), dbesc($file),
dbesc($function), dbesc($function),

166
Zotlabs/Lib/Config.php Normal file
View file

@ -0,0 +1,166 @@
<?php /** @file */
namespace Zotlabs\Lib;
class Config {
/**
* @brief Loads the hub's configuration from database to a cached storage.
*
* Retrieve a category ($family) of config variables from database to a cached
* storage in the global App::$config[$family].
*
* @param string $family
* The category of the configuration value
*/
static public function Load($family) {
if(! array_key_exists($family, \App::$config))
\App::$config[$family] = array();
if(! array_key_exists('config_loaded', \App::$config[$family])) {
$r = q("SELECT * FROM config WHERE cat = '%s'", dbesc($family));
if($r !== false) {
if($r) {
foreach($r as $rr) {
$k = $rr['k'];
\App::$config[$family][$k] = $rr['v'];
}
}
\App::$config[$family]['config_loaded'] = true;
}
}
}
/**
* @brief Sets a configuration value for the hub.
*
* Stores a config value ($value) in the category ($family) under the key ($key).
*
* @param string $family
* The category of the configuration value
* @param string $key
* The configuration key to set
* @param mixed $value
* The value to store in the configuration
* @return mixed
* Return the set value, or false if the database update failed
*/
static public function Set($family,$key,$value) {
// manage array value
$dbvalue = ((is_array($value)) ? serialize($value) : $value);
$dbvalue = ((is_bool($dbvalue)) ? intval($dbvalue) : $dbvalue);
if(get_config($family, $key) === false || (! self::get_from_storage($family, $key))) {
$ret = q("INSERT INTO config ( cat, k, v ) VALUES ( '%s', '%s', '%s' ) ",
dbesc($family),
dbesc($key),
dbesc($dbvalue)
);
if($ret) {
\App::$config[$family][$key] = $value;
$ret = $value;
}
return $ret;
}
$ret = q("UPDATE config SET v = '%s' WHERE cat = '%s' AND k = '%s'",
dbesc($dbvalue),
dbesc($family),
dbesc($key)
);
if($ret) {
\App::$config[$family][$key] = $value;
$ret = $value;
}
return $ret;
}
/**
* @brief Get a particular config variable given the category name ($family)
* and a key.
*
* Get a particular config variable from the given category ($family) and the
* $key from a cached storage in App::$config[$family]. If a key is found in the
* DB but does not exist in local config cache, pull it into the cache so we
* do not have to hit the DB again for this item.
*
* Returns false if not set.
*
* @param string $family
* The category of the configuration value
* @param string $key
* The configuration key to query
* @return mixed Return value or false on error or if not set
*/
static public function Get($family,$key) {
if((! array_key_exists($family, \App::$config)) || (! array_key_exists('config_loaded', \App::$config[$family])))
self::Load($family);
if(array_key_exists('config_loaded', \App::$config[$family])) {
if(! array_key_exists($key, \App::$config[$family])) {
return false;
}
return ((! is_array(\App::$config[$family][$key])) && (preg_match('|^a:[0-9]+:{.*}$|s', \App::$config[$family][$key]))
? unserialize(\App::$config[$family][$key])
: \App::$config[$family][$key]
);
}
return false;
}
/**
* @brief Deletes the given key from the hub's configuration database.
*
* Removes the configured value from the stored cache in App::$config[$family]
* and removes it from the database.
*
* @param string $family
* The category of the configuration value
* @param string $key
* The configuration key to delete
* @return mixed
*/
static public function Delete($family,$key) {
$ret = false;
if(array_key_exists($family, \App::$config) && array_key_exists($key, \App::$config[$family]))
unset(\App::$config[$family][$key]);
$ret = q("DELETE FROM config WHERE cat = '%s' AND k = '%s'",
dbesc($family),
dbesc($key)
);
return $ret;
}
/**
* @brief Returns a value directly from the database configuration storage.
*
* This function queries directly the database and bypasses the chached storage
* from get_config($family, $key).
*
* @param string $family
* The category of the configuration value
* @param string $key
* The configuration key to query
* @return mixed
*/
static private function get_from_storage($family,$key) {
$ret = q("SELECT * FROM config WHERE cat = '%s' AND k = '%s' LIMIT 1",
dbesc($family),
dbesc($key)
);
return $ret;
}
}

View file

@ -1,10 +1,14 @@
<?php <?php
namespace Zotlabs\Lib;
/** /**
* @file include/enotify.php * @brief File with functions and a class for generating system and email notifications.
*
* @brief File with functions and a class for email notifications.
*/ */
class Enotify {
/** /**
* @brief * @brief
* *
@ -19,16 +23,15 @@
* * \e string \b verb * * \e string \b verb
* * \e string \b activity * * \e string \b activity
*/ */
function notification($params) {
static public function submit($params) {
logger('notification: entry', LOGGER_DEBUG); logger('notification: entry', LOGGER_DEBUG);
// throw a small amount of entropy into the system to breakup duplicates arriving at the same precise instant. // throw a small amount of entropy into the system to breakup duplicates arriving at the same precise instant.
usleep(mt_rand(0, 10000)); usleep(mt_rand(0, 10000));
$a = get_app();
if ($params['from_xchan']) { if ($params['from_xchan']) {
$x = q("select * from xchan where xchan_hash = '%s' limit 1", $x = q("select * from xchan where xchan_hash = '%s' limit 1",
dbesc($params['from_xchan']) dbesc($params['from_xchan'])
@ -62,7 +65,7 @@ function notification($params) {
$site_admin = sprintf( t('%s Administrator'), $sitename); $site_admin = sprintf( t('%s Administrator'), $sitename);
$sender_name = $product; $sender_name = $product;
$hostname = App::get_hostname(); $hostname = \App::get_hostname();
if(strpos($hostname,':')) if(strpos($hostname,':'))
$hostname = substr($hostname,0,strpos($hostname,':')); $hostname = substr($hostname,0,strpos($hostname,':'));
@ -87,7 +90,8 @@ function notification($params) {
$title = $params['item']['title']; $title = $params['item']['title'];
$body = $params['item']['body']; $body = $params['item']['body'];
} }
} else { }
else {
$title = $body = ''; $title = $body = '';
} }
@ -424,7 +428,7 @@ function notification($params) {
// wretched hack, but we don't want to duplicate all the preamble variations and we also don't want to screw up a translation // wretched hack, but we don't want to duplicate all the preamble variations and we also don't want to screw up a translation
if ((App::$language === 'en' || (! App::$language)) && strpos($msg,', ')) if ((\App::$language === 'en' || (! \App::$language)) && strpos($msg,', '))
$msg = substr($msg,strpos($msg,', ')+1); $msg = substr($msg,strpos($msg,', ')+1);
$r = q("update notify set msg = '%s' where id = %d and uid = %d", $r = q("update notify set msg = '%s' where id = %d and uid = %d",
@ -441,7 +445,7 @@ function notification($params) {
logger('notification: sending notification email'); logger('notification: sending notification email');
$hn = get_pconfig($recip['channel_id'],'system','email_notify_host'); $hn = get_pconfig($recip['channel_id'],'system','email_notify_host');
if($hn && (! stristr(App::get_hostname(),$hn))) { if($hn && (! stristr(\App::get_hostname(),$hn))) {
// this isn't the email notification host // this isn't the email notification host
pop_lang(); pop_lang();
return; return;
@ -455,7 +459,7 @@ function notification($params) {
// use $_SESSION['zid_override'] to force zid() to use // use $_SESSION['zid_override'] to force zid() to use
// the recipient address instead of the current observer // the recipient address instead of the current observer
$_SESSION['zid_override'] = $recip['channel_address'] . '@' . App::get_hostname(); $_SESSION['zid_override'] = $recip['channel_address'] . '@' . \App::get_hostname();
$_SESSION['zrl_override'] = z_root() . '/channel/' . $recip['channel_address']; $_SESSION['zrl_override'] = z_root() . '/channel/' . $recip['channel_address'];
$textversion = zidify_links($textversion); $textversion = zidify_links($textversion);
@ -529,7 +533,7 @@ function notification($params) {
$tpl = get_markup_template('email_notify_html.tpl'); $tpl = get_markup_template('email_notify_html.tpl');
$email_html_body = replace_macros($tpl,array( $email_html_body = replace_macros($tpl,array(
'$banner' => $datarray['banner'], '$banner' => $datarray['banner'],
'$notify_icon' => Zotlabs\Lib\System::get_notify_icon(), '$notify_icon' => \Zotlabs\Lib\System::get_notify_icon(),
'$product' => $datarray['product'], '$product' => $datarray['product'],
'$preamble' => $datarray['preamble'], '$preamble' => $datarray['preamble'],
'$sitename' => $datarray['sitename'], '$sitename' => $datarray['sitename'],
@ -570,7 +574,7 @@ function notification($params) {
// use the EmailNotification library to send the message // use the EmailNotification library to send the message
enotify::send(array( self::send(array(
'fromName' => $sender_name, 'fromName' => $sender_name,
'fromEmail' => $sender_email, 'fromEmail' => $sender_email,
'replyTo' => $sender_email, 'replyTo' => $sender_email,
@ -587,12 +591,6 @@ function notification($params) {
} }
/**
* @brief A class for sending email notifications.
*
* @fixme Class names start mostly with capital letter to distinguish them easier.
*/
class enotify {
/** /**
* @brief Send a multipart/alternative message with Text and HTML versions. * @brief Send a multipart/alternative message with Text and HTML versions.
* *
@ -649,4 +647,39 @@ class enotify {
); );
logger("notification: enotify::send returns " . $res, LOGGER_DEBUG); logger("notification: enotify::send returns " . $res, LOGGER_DEBUG);
} }
static public function format($item) {
$ret = '';
require_once('include/conversation.php');
// Call localize_item with the "brief" flag to get a one line status for activities.
// This should set $item['localized'] to indicate we have a brief summary.
localize_item($item);
if($item_localize) {
$itemem_text = $item['localize'];
}
else {
$itemem_text = (($item['item_thread_top'])
? t('created a new post')
: sprintf( t('commented on %s\'s post'), $item['owner']['xchan_name']));
}
// convert this logic into a json array just like the system notifications
return array(
'notify_link' => $item['llink'],
'name' => $item['author']['xchan_name'],
'url' => $item['author']['xchan_url'],
'photo' => $item['author']['xchan_photo_s'],
'when' => relative_date($item['created']),
'class' => (intval($item['item_unseen']) ? 'notify-unseen' : 'notify-seen'),
'message' => strip_tags(bbcode($itemem_text))
);
}
} }

View file

@ -53,13 +53,13 @@ class Acl extends \Zotlabs\Web\Controller {
if ($type=='' || $type=='g'){ if ($type=='' || $type=='g'){
$r = q("SELECT `groups`.`id`, `groups`.`hash`, `groups`.`name` $r = q("SELECT `groups`.`id`, `groups`.`hash`, `groups`.`gname`
FROM `groups`,`group_member` FROM `groups`,`group_member`
WHERE `groups`.`deleted` = 0 AND `groups`.`uid` = %d WHERE `groups`.`deleted` = 0 AND `groups`.`uid` = %d
AND `group_member`.`gid`=`groups`.`id` AND `group_member`.`gid`=`groups`.`id`
$sql_extra $sql_extra
GROUP BY `groups`.`id` GROUP BY `groups`.`id`
ORDER BY `groups`.`name` ORDER BY `groups`.`gname`
LIMIT %d OFFSET %d", LIMIT %d OFFSET %d",
intval(local_channel()), intval(local_channel()),
intval($count), intval($count),
@ -67,11 +67,11 @@ class Acl extends \Zotlabs\Web\Controller {
); );
foreach($r as $g){ foreach($r as $g){
// logger('acl: group: ' . $g['name'] . ' members: ' . group_get_members_xchan($g['id'])); // logger('acl: group: ' . $g['gname'] . ' members: ' . group_get_members_xchan($g['id']));
$groups[] = array( $groups[] = array(
"type" => "g", "type" => "g",
"photo" => "images/twopeople.png", "photo" => "images/twopeople.png",
"name" => $g['name'], "name" => $g['gname'],
"id" => $g['id'], "id" => $g['id'],
"xid" => $g['hash'], "xid" => $g['hash'],
"uids" => group_get_members_xchan($g['id']), "uids" => group_get_members_xchan($g['id']),

View file

@ -1291,7 +1291,7 @@ class Admin extends \Zotlabs\Web\Controller {
$admin_form = ''; $admin_form = '';
$r = q("select * from addon where plugin_admin = 1 and name = '%s' limit 1", $r = q("select * from addon where plugin_admin = 1 and aname = '%s' limit 1",
dbesc($plugin) dbesc($plugin)
); );
@ -1421,6 +1421,7 @@ class Admin extends \Zotlabs\Web\Controller {
function listAddonRepos() { function listAddonRepos() {
$addonrepos = []; $addonrepos = [];
$addonDir = __DIR__ . '/../../extend/addon/'; $addonDir = __DIR__ . '/../../extend/addon/';
if(is_dir($addonDir)) {
if ($handle = opendir($addonDir)) { if ($handle = opendir($addonDir)) {
while (false !== ($entry = readdir($handle))) { while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") { if ($entry != "." && $entry != "..") {
@ -1429,6 +1430,7 @@ class Admin extends \Zotlabs\Web\Controller {
} }
closedir($handle); closedir($handle);
} }
}
return $addonrepos; return $addonrepos;
} }

View file

@ -107,7 +107,7 @@ class Api extends \Zotlabs\Web\Controller {
$r = q("SELECT `clients`.* $r = q("SELECT `clients`.*
FROM `clients`, `tokens` FROM `clients`, `tokens`
WHERE `clients`.`client_id`=`tokens`.`client_id` WHERE `clients`.`client_id`=`tokens`.`client_id`
AND `tokens`.`id`='%s' AND `tokens`.`scope`='request'", AND `tokens`.`id`='%s' AND `tokens`.`auth_scope`='request'",
dbesc($token)); dbesc($token));
if (!count($r)) if (!count($r))

View file

@ -243,7 +243,7 @@ class Chat extends \Zotlabs\Web\Controller {
$rooms = Zlib\Chatroom::roomlist(\App::$profile['profile_uid']); $rooms = Zlib\Chatroom::roomlist(\App::$profile['profile_uid']);
$o .= replace_macros(get_markup_template('chatrooms.tpl'), array( $o .= replace_macros(get_markup_template('chatrooms.tpl'), array(
'$header' => sprintf( t('%1$s\'s Chatrooms'), \App::$profile['name']), '$header' => sprintf( t('%1$s\'s Chatrooms'), \App::$profile['fullname']),
'$name' => t('Name'), '$name' => t('Name'),
'$baseurl' => z_root(), '$baseurl' => z_root(),
'$nickname' => \App::$profile['channel_address'], '$nickname' => \App::$profile['channel_address'],

View file

@ -100,9 +100,12 @@ class Cloud extends \Zotlabs\Web\Controller {
// require_once('\Zotlabs\Storage/QuotaPlugin.php'); // require_once('\Zotlabs\Storage/QuotaPlugin.php');
// $server->addPlugin(new \Zotlabs\Storage\\QuotaPlugin($auth)); // $server->addPlugin(new \Zotlabs\Storage\\QuotaPlugin($auth));
ob_start();
// All we need to do now, is to fire up the server // All we need to do now, is to fire up the server
$server->exec(); $server->exec();
ob_end_flush();
killme(); killme();
} }

View file

@ -230,7 +230,7 @@ class Connedit extends \Zotlabs\Web\Controller {
if(\App::$poi && \App::$poi['abook_my_perms'] != $abook_my_perms if(\App::$poi && \App::$poi['abook_my_perms'] != $abook_my_perms
&& (! intval(\App::$poi['abook_self']))) { && (! intval(\App::$poi['abook_self']))) {
\Zotlabs\Daemon\Master(array('Notifier', (($new_friend) ? 'permission_create' : 'permission_update'), $contact_id)); \Zotlabs\Daemon\Master::Summon(array('Notifier', (($new_friend) ? 'permission_create' : 'permission_update'), $contact_id));
} }
if($new_friend) { if($new_friend) {

View file

@ -41,10 +41,10 @@ class Contactgroup extends \Zotlabs\Web\Controller {
if($change) { if($change) {
if(in_array($change,$preselected)) { if(in_array($change,$preselected)) {
group_rmv_member(local_channel(),$group['name'],$change); group_rmv_member(local_channel(),$group['gname'],$change);
} }
else { else {
group_add_member(local_channel(),$group['name'],$change); group_add_member(local_channel(),$group['gname'],$change);
} }
} }
} }

View file

@ -341,7 +341,7 @@ class Cover_photo extends \Zotlabs\Web\Controller {
} }
} }
cover_photo_crop_ui_head($a, $ph, $hash, $smallest); $this->cover_photo_crop_ui_head($a, $ph, $hash, $smallest);
} }

View file

@ -171,7 +171,7 @@ class Events extends \Zotlabs\Web\Controller {
foreach($cats as $cat) { foreach($cats as $cat) {
$post_tags[] = array( $post_tags[] = array(
'uid' => $profile_uid, 'uid' => $profile_uid,
'type' => TERM_CATEGORY, 'ttype' => TERM_CATEGORY,
'otype' => TERM_OBJ_POST, 'otype' => TERM_OBJ_POST,
'term' => trim($cat), 'term' => trim($cat),
'url' => $channel['xchan_url'] . '?f=&cat=' . urlencode(trim($cat)) 'url' => $channel['xchan_url'] . '?f=&cat=' . urlencode(trim($cat))
@ -232,7 +232,7 @@ class Events extends \Zotlabs\Web\Controller {
} }
if($share) if($share)
\Zotlabs\Daemon\Master(array('Notifier','event',$item_id)); \Zotlabs\Daemon\Master::Summon(array('Notifier','event',$item_id));
} }

View file

@ -39,7 +39,7 @@ class Filer extends \Zotlabs\Web\Controller {
} }
else { else {
$filetags = array(); $filetags = array();
$r = q("select distinct(term) from term where uid = %d and type = %d order by term asc", $r = q("select distinct(term) from term where uid = %d and ttype = %d order by term asc",
intval(local_channel()), intval(local_channel()),
intval(TERM_FILE) intval(TERM_FILE)
); );

View file

@ -22,7 +22,7 @@ class Filerm extends \Zotlabs\Web\Controller {
logger('filerm: tag ' . $term . ' item ' . $item_id); logger('filerm: tag ' . $term . ' item ' . $item_id);
if($item_id && strlen($term)) { if($item_id && strlen($term)) {
$r = q("delete from term where uid = %d and type = %d and oid = %d and term = '%s'", $r = q("delete from term where uid = %d and ttype = %d and oid = %d and term = '%s'",
intval(local_channel()), intval(local_channel()),
intval(($category) ? TERM_CATEGORY : TERM_FILE), intval(($category) ? TERM_CATEGORY : TERM_FILE),
intval($item_id), intval($item_id),

View file

@ -1,117 +0,0 @@
<?php
namespace Zotlabs\Module;
class Fsuggest extends \Zotlabs\Web\Controller {
function post() {
if(! local_channel()) {
return;
}
if(\App::$argc != 2)
return;
$contact_id = intval(\App::$argv[1]);
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($contact_id),
intval(local_channel())
);
if(! count($r)) {
notice( t('Contact not found.') . EOL);
return;
}
$contact = $r[0];
$new_contact = intval($_POST['suggest']);
$hash = random_string();
$note = escape_tags(trim($_POST['note']));
if($new_contact) {
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($new_contact),
intval(local_channel())
);
if(count($r)) {
$x = q("INSERT INTO `fsuggest` ( `uid`,`cid`,`name`,`url`,`request`,`photo`,`note`,`created`)
VALUES ( %d, %d, '%s','%s','%s','%s','%s','%s')",
intval(local_channel()),
intval($contact_id),
dbesc($r[0]['name']),
dbesc($r[0]['url']),
dbesc($r[0]['request']),
dbesc($r[0]['photo']),
dbesc($hash),
dbesc(datetime_convert())
);
$r = q("SELECT `id` FROM `fsuggest` WHERE `note` = '%s' AND `uid` = %d LIMIT 1",
dbesc($hash),
intval(local_channel())
);
if(count($r)) {
$fsuggest_id = $r[0]['id'];
q("UPDATE `fsuggest` SET `note` = '%s' WHERE `id` = %d AND `uid` = %d",
dbesc($note),
intval($fsuggest_id),
intval(local_channel())
);
\Zotlabs\Daemon\Master::Summon(array('Notifier', 'suggest' , $fsuggest_id));
}
info( t('Friend suggestion sent.') . EOL);
}
}
}
function get() {
require_once('include/acl_selectors.php');
if(! local_channel()) {
notice( t('Permission denied.') . EOL);
return;
}
if(\App::$argc != 2)
return;
$contact_id = intval(\App::$argv[1]);
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($contact_id),
intval(local_channel())
);
if(! count($r)) {
notice( t('Contact not found.') . EOL);
return;
}
$contact = $r[0];
$o = '<h3>' . t('Suggest Friends') . '</h3>';
$o .= '<div id="fsuggest-desc" >' . sprintf( t('Suggest a friend for %s'), $contact['name']) . '</div>';
$o .= '<form id="fsuggest-form" action="fsuggest/' . $contact_id . '" method="post" >';
// FIXME contact_selector deprecated, removed
// $o .= contact_selector('suggest','suggest-select', false,
// array('size' => 4, 'exclude' => $contact_id, 'networks' => 'DFRN_ONLY', 'single' => true));
$o .= '<div id="fsuggest-submit-wrapper"><input id="fsuggest-submit" type="submit" name="submit" value="' . t('Submit') . '" /></div>';
$o .= '</form>';
return $o;
}
}

View file

@ -47,8 +47,8 @@ class Group extends \Zotlabs\Web\Controller {
$groupname = notags(trim($_POST['groupname'])); $groupname = notags(trim($_POST['groupname']));
$public = intval($_POST['public']); $public = intval($_POST['public']);
if((strlen($groupname)) && (($groupname != $group['name']) || ($public != $group['visible']))) { if((strlen($groupname)) && (($groupname != $group['gname']) || ($public != $group['visible']))) {
$r = q("UPDATE `groups` SET `name` = '%s', visible = %d WHERE `uid` = %d AND `id` = %d", $r = q("UPDATE `groups` SET `gname` = '%s', visible = %d WHERE `uid` = %d AND `id` = %d",
dbesc($groupname), dbesc($groupname),
intval($public), intval($public),
intval(local_channel()), intval(local_channel()),
@ -106,7 +106,7 @@ class Group extends \Zotlabs\Web\Controller {
intval(local_channel()) intval(local_channel())
); );
if($r) if($r)
$result = group_rmv(local_channel(),$r[0]['name']); $result = group_rmv(local_channel(),$r[0]['gname']);
if($result) if($result)
info( t('Privacy group removed.') . EOL); info( t('Privacy group removed.') . EOL);
else else
@ -156,10 +156,10 @@ class Group extends \Zotlabs\Web\Controller {
if($change) { if($change) {
if(in_array($change,$preselected)) { if(in_array($change,$preselected)) {
group_rmv_member(local_channel(),$group['name'],$change); group_rmv_member(local_channel(),$group['gname'],$change);
} }
else { else {
group_add_member(local_channel(),$group['name'],$change); group_add_member(local_channel(),$group['gname'],$change);
} }
$members = group_get_members($group['id']); $members = group_get_members($group['id']);
@ -181,7 +181,7 @@ class Group extends \Zotlabs\Web\Controller {
$context = $context + array( $context = $context + array(
'$title' => t('Privacy group editor'), '$title' => t('Privacy group editor'),
'$gname' => array('groupname',t('Privacy group name: '),$group['name'], ''), '$gname' => array('groupname',t('Privacy group name: '),$group['gname'], ''),
'$gid' => $group['id'], '$gid' => $group['id'],
'$drop' => $drop_txt, '$drop' => $drop_txt,
'$public' => array('public',t('Members are visible to other channels'), $group['visible'], ''), '$public' => array('public',t('Members are visible to other channels'), $group['visible'], ''),
@ -209,7 +209,7 @@ class Group extends \Zotlabs\Web\Controller {
$groupeditor['members'][] = micropro($member,true,'mpgroup', $textmode); $groupeditor['members'][] = micropro($member,true,'mpgroup', $textmode);
} }
else else
group_rmv_member(local_channel(),$group['name'],$member['xchan_hash']); group_rmv_member(local_channel(),$group['gname'],$member['xchan_hash']);
} }
$r = q("SELECT abook.*, xchan.* FROM `abook` left join xchan on abook_xchan = xchan_hash WHERE `abook_channel` = %d AND abook_self = 0 and abook_blocked = 0 and abook_pending = 0 and xchan_deleted = 0 order by xchan_name asc", $r = q("SELECT abook.*, xchan.* FROM `abook` left join xchan on abook_xchan = xchan_hash WHERE `abook_channel` = %d AND abook_self = 0 and abook_blocked = 0 and abook_pending = 0 and xchan_deleted = 0 order by xchan_name asc",

View file

@ -408,6 +408,10 @@ class Import extends \Zotlabs\Web\Controller {
$saved = array(); $saved = array();
foreach($groups as $group) { foreach($groups as $group) {
$saved[$group['hash']] = array('old' => $group['id']); $saved[$group['hash']] = array('old' => $group['id']);
if(array_key_exists('name',$group)) {
$group['gname'] = $group['name'];
unset($group['name']);
}
unset($group['id']); unset($group['id']);
$group['uid'] = $channel['channel_id']; $group['uid'] = $channel['channel_id'];
dbesc_array($group); dbesc_array($group);

View file

@ -17,10 +17,10 @@ namespace Zotlabs\Module;
*/ */
require_once('include/crypto.php'); require_once('include/crypto.php');
require_once('include/enotify.php');
require_once('include/items.php'); require_once('include/items.php');
require_once('include/attach.php'); require_once('include/attach.php');
use \Zotlabs\Lib as Zlib;
class Item extends \Zotlabs\Web\Controller { class Item extends \Zotlabs\Web\Controller {
@ -581,7 +581,7 @@ class Item extends \Zotlabs\Web\Controller {
if($success['replaced']) { if($success['replaced']) {
$post_tags[] = array( $post_tags[] = array(
'uid' => $profile_uid, 'uid' => $profile_uid,
'type' => $success['termtype'], 'ttype' => $success['termtype'],
'otype' => TERM_OBJ_POST, 'otype' => TERM_OBJ_POST,
'term' => $success['term'], 'term' => $success['term'],
'url' => $success['url'] 'url' => $success['url']
@ -666,7 +666,7 @@ class Item extends \Zotlabs\Web\Controller {
foreach($cats as $cat) { foreach($cats as $cat) {
$post_tags[] = array( $post_tags[] = array(
'uid' => $profile_uid, 'uid' => $profile_uid,
'type' => TERM_CATEGORY, 'ttype' => TERM_CATEGORY,
'otype' => TERM_OBJ_POST, 'otype' => TERM_OBJ_POST,
'term' => trim($cat), 'term' => trim($cat),
'url' => $owner_xchan['xchan_url'] . '?f=&cat=' . urlencode(trim($cat)) 'url' => $owner_xchan['xchan_url'] . '?f=&cat=' . urlencode(trim($cat))
@ -676,7 +676,7 @@ class Item extends \Zotlabs\Web\Controller {
if($orig_post) { if($orig_post) {
// preserve original tags // preserve original tags
$t = q("select * from term where oid = %d and otype = %d and uid = %d and type in ( %d, %d, %d )", $t = q("select * from term where oid = %d and otype = %d and uid = %d and ttype in ( %d, %d, %d )",
intval($orig_post['id']), intval($orig_post['id']),
intval(TERM_OBJ_POST), intval(TERM_OBJ_POST),
intval($profile_uid), intval($profile_uid),
@ -688,7 +688,7 @@ class Item extends \Zotlabs\Web\Controller {
foreach($t as $t1) { foreach($t as $t1) {
$post_tags[] = array( $post_tags[] = array(
'uid' => $profile_uid, 'uid' => $profile_uid,
'type' => $t1['type'], 'ttype' => $t1['type'],
'otype' => TERM_OBJ_POST, 'otype' => TERM_OBJ_POST,
'term' => $t1['term'], 'term' => $t1['term'],
'url' => $t1['url'], 'url' => $t1['url'],
@ -925,7 +925,7 @@ class Item extends \Zotlabs\Web\Controller {
// otherwise it will happen during delivery // otherwise it will happen during delivery
if(($datarray['owner_xchan'] != $datarray['author_xchan']) && (intval($parent_item['item_wall']))) { if(($datarray['owner_xchan'] != $datarray['author_xchan']) && (intval($parent_item['item_wall']))) {
notification(array( Zlib\Enotify::submit(array(
'type' => NOTIFY_COMMENT, 'type' => NOTIFY_COMMENT,
'from_xchan' => $datarray['author_xchan'], 'from_xchan' => $datarray['author_xchan'],
'to_xchan' => $datarray['owner_xchan'], 'to_xchan' => $datarray['owner_xchan'],
@ -943,7 +943,7 @@ class Item extends \Zotlabs\Web\Controller {
$parent = $post_id; $parent = $post_id;
if(($datarray['owner_xchan'] != $datarray['author_xchan']) && ($datarray['item_type'] == ITEM_TYPE_POST)) { if(($datarray['owner_xchan'] != $datarray['author_xchan']) && ($datarray['item_type'] == ITEM_TYPE_POST)) {
notification(array( Zlib\Enotify::submit(array(
'type' => NOTIFY_WALL, 'type' => NOTIFY_WALL,
'from_xchan' => $datarray['author_xchan'], 'from_xchan' => $datarray['author_xchan'],
'to_xchan' => $datarray['owner_xchan'], 'to_xchan' => $datarray['owner_xchan'],

View file

@ -88,10 +88,10 @@ class Lockview extends \Zotlabs\Web\Controller {
stringify_array_elms($deny_users,true); stringify_array_elms($deny_users,true);
if(count($allowed_groups)) { if(count($allowed_groups)) {
$r = q("SELECT name FROM `groups` WHERE hash IN ( " . implode(', ', $allowed_groups) . " )"); $r = q("SELECT gname FROM `groups` WHERE hash IN ( " . implode(', ', $allowed_groups) . " )");
if($r) if($r)
foreach($r as $rr) foreach($r as $rr)
$l[] = '<li><b>' . $rr['name'] . '</b></li>'; $l[] = '<li><b>' . $rr['gname'] . '</b></li>';
} }
if(count($allowed_users)) { if(count($allowed_users)) {
$r = q("SELECT xchan_name FROM xchan WHERE xchan_hash IN ( " . implode(', ',$allowed_users) . " )"); $r = q("SELECT xchan_name FROM xchan WHERE xchan_hash IN ( " . implode(', ',$allowed_users) . " )");
@ -100,10 +100,10 @@ class Lockview extends \Zotlabs\Web\Controller {
$l[] = '<li>' . $rr['xchan_name'] . '</li>'; $l[] = '<li>' . $rr['xchan_name'] . '</li>';
} }
if(count($deny_groups)) { if(count($deny_groups)) {
$r = q("SELECT name FROM `groups` WHERE hash IN ( " . implode(', ', $deny_groups) . " )"); $r = q("SELECT gname FROM `groups` WHERE hash IN ( " . implode(', ', $deny_groups) . " )");
if($r) if($r)
foreach($r as $rr) foreach($r as $rr)
$l[] = '<li><b><strike>' . $rr['name'] . '</strike></b></li>'; $l[] = '<li><b><strike>' . $rr['gname'] . '</strike></b></li>';
} }
if(count($deny_users)) { if(count($deny_users)) {
$r = q("SELECT xchan_name FROM xchan WHERE xchan_hash IN ( " . implode(', ', $deny_users) . " )"); $r = q("SELECT xchan_name FROM xchan WHERE xchan_hash IN ( " . implode(', ', $deny_users) . " )");

View file

@ -223,7 +223,7 @@ class Network extends \Zotlabs\Web\Controller {
if($x) { if($x) {
$title = replace_macros(get_markup_template("section_title.tpl"),array( $title = replace_macros(get_markup_template("section_title.tpl"),array(
'$title' => t('Privacy group: ') . $x['name'] '$title' => t('Privacy group: ') . $x['gname']
)); ));
} }

View file

@ -440,7 +440,7 @@ class Photos extends \Zotlabs\Web\Controller {
if($success['replaced']) { if($success['replaced']) {
$post_tags[] = array( $post_tags[] = array(
'uid' => $profile_uid, 'uid' => $profile_uid,
'type' => $success['termtype'], 'ttype' => $success['termtype'],
'otype' => TERM_OBJ_POST, 'otype' => TERM_OBJ_POST,
'term' => $success['term'], 'term' => $success['term'],
'url' => $success['url'] 'url' => $success['url']

View file

@ -1,12 +1,13 @@
<?php <?php
namespace Zotlabs\Module; namespace Zotlabs\Module;
/** /**
* @file mod/ping.php * @file mod/ping.php
* *
*/ */
require_once('include/bbcode.php'); require_once('include/bbcode.php');
require_once('include/notify.php');
/** /**
* @brief do several updates when pinged. * @brief do several updates when pinged.
@ -285,7 +286,7 @@ class Ping extends \Zotlabs\Web\Controller {
foreach($r as $item) { foreach($r as $item) {
if((argv(1) === 'home') && (! intval($item['item_wall']))) if((argv(1) === 'home') && (! intval($item['item_wall'])))
continue; continue;
$result[] = format_notification($item); $result[] = \Zotlabs\Lib\Enotify::format($item);
} }
} }
// logger('ping (network||home): ' . print_r($result, true), LOGGER_DATA); // logger('ping (network||home): ' . print_r($result, true), LOGGER_DATA);

View file

@ -67,16 +67,16 @@ class Profiles extends \Zotlabs\Web\Controller {
$name = t('Profile-') . ($num_profiles + 1); $name = t('Profile-') . ($num_profiles + 1);
$r1 = q("SELECT `name`, `photo`, `thumb` FROM `profile` WHERE `uid` = %d AND `is_default` = 1 LIMIT 1", $r1 = q("SELECT `fullname`, `photo`, `thumb` FROM `profile` WHERE `uid` = %d AND `is_default` = 1 LIMIT 1",
intval(local_channel())); intval(local_channel()));
$r2 = q("INSERT INTO `profile` (`aid`, `uid` , `profile_guid`, `profile_name` , `name`, `photo`, `thumb`) $r2 = q("INSERT INTO `profile` (`aid`, `uid` , `profile_guid`, `profile_name` , `fullname`, `photo`, `thumb`)
VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s' )", VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s' )",
intval(get_account_id()), intval(get_account_id()),
intval(local_channel()), intval(local_channel()),
dbesc(random_string()), dbesc(random_string()),
dbesc($name), dbesc($name),
dbesc($r1[0]['name']), dbesc($r1[0]['fullname']),
dbesc($r1[0]['photo']), dbesc($r1[0]['photo']),
dbesc($r1[0]['thumb']) dbesc($r1[0]['thumb'])
); );
@ -277,14 +277,14 @@ class Profiles extends \Zotlabs\Web\Controller {
$name = escape_tags(trim($_POST['name'])); $name = escape_tags(trim($_POST['name']));
if($orig[0]['name'] != $name) { if($orig[0]['fullname'] != $name) {
$namechanged = true; $namechanged = true;
$v = validate_channelname($name); $v = validate_channelname($name);
if($v) { if($v) {
notice($v); notice($v);
$namechanged = false; $namechanged = false;
$name = $orig[0]['name']; $name = $orig[0]['fullname'];
} }
} }
@ -350,7 +350,7 @@ class Profiles extends \Zotlabs\Web\Controller {
$withchanged = false; $withchanged = false;
if(strlen($with)) { if(strlen($with)) {
if($with != strip_tags($orig[0]['with'])) { if($with != strip_tags($orig[0]['partner'])) {
$withchanged = true; $withchanged = true;
$prf = ''; $prf = '';
$lookup = $with; $lookup = $with;
@ -382,7 +382,7 @@ class Profiles extends \Zotlabs\Web\Controller {
} }
} }
else else
$with = $orig[0]['with']; $with = $orig[0]['partner'];
} }
$profile_fields_basic = get_profile_fields_basic(); $profile_fields_basic = get_profile_fields_basic();
@ -439,7 +439,7 @@ class Profiles extends \Zotlabs\Web\Controller {
$changes[] = t('Dislikes'); $changes[] = t('Dislikes');
$value = $dislikes; $value = $dislikes;
} }
if($work != $orig[0]['work']) { if($work != $orig[0]['employment']) {
$changes[] = t('Work/Employment'); $changes[] = t('Work/Employment');
} }
if($religion != $orig[0]['religion']) { if($religion != $orig[0]['religion']) {
@ -486,7 +486,7 @@ class Profiles extends \Zotlabs\Web\Controller {
$r = q("UPDATE `profile` $r = q("UPDATE `profile`
SET `profile_name` = '%s', SET `profile_name` = '%s',
`name` = '%s', `fullname` = '%s',
`pdesc` = '%s', `pdesc` = '%s',
`gender` = '%s', `gender` = '%s',
`dob` = '%s', `dob` = '%s',
@ -496,7 +496,7 @@ class Profiles extends \Zotlabs\Web\Controller {
`postal_code` = '%s', `postal_code` = '%s',
`country_name` = '%s', `country_name` = '%s',
`marital` = '%s', `marital` = '%s',
`with` = '%s', `partner` = '%s',
`howlong` = '%s', `howlong` = '%s',
`sexual` = '%s', `sexual` = '%s',
`homepage` = '%s', `homepage` = '%s',
@ -515,7 +515,7 @@ class Profiles extends \Zotlabs\Web\Controller {
`tv` = '%s', `tv` = '%s',
`film` = '%s', `film` = '%s',
`romance` = '%s', `romance` = '%s',
`work` = '%s', `employment` = '%s',
`education` = '%s', `education` = '%s',
`hide_friends` = %d `hide_friends` = %d
WHERE `id` = %d AND `uid` = %d", WHERE `id` = %d AND `uid` = %d",
@ -627,8 +627,6 @@ class Profiles extends \Zotlabs\Web\Controller {
} }
$editselect = 'none'; $editselect = 'none';
// if(feature_enabled(local_channel(),'richtext'))
// $editselect = 'textareas';
\App::$page['htmlhead'] .= replace_macros(get_markup_template('profed_head.tpl'), array( \App::$page['htmlhead'] .= replace_macros(get_markup_template('profed_head.tpl'), array(
'$baseurl' => z_root(), '$baseurl' => z_root(),
@ -712,7 +710,7 @@ class Profiles extends \Zotlabs\Web\Controller {
'$is_default' => $is_default, '$is_default' => $is_default,
'$default' => t('This is your default profile.') . EOL . translate_scope(map_scope($channel['channel_r_profile'])), '$default' => t('This is your default profile.') . EOL . translate_scope(map_scope($channel['channel_r_profile'])),
'$advanced' => $advanced, '$advanced' => $advanced,
'$name' => array('name', t('Your full name'), $r[0]['name'], t('Required'), '*'), '$name' => array('name', t('Your full name'), $r[0]['fullname'], t('Required'), '*'),
'$pdesc' => array('pdesc', t('Title/Description'), $r[0]['pdesc']), '$pdesc' => array('pdesc', t('Title/Description'), $r[0]['pdesc']),
'$dob' => dob($r[0]['dob']), '$dob' => dob($r[0]['dob']),
'$hide_friends' => $hide_friends, '$hide_friends' => $hide_friends,
@ -725,7 +723,7 @@ class Profiles extends \Zotlabs\Web\Controller {
'$gender_min' => gender_selector_min($r[0]['gender']), '$gender_min' => gender_selector_min($r[0]['gender']),
'$marital' => marital_selector($r[0]['marital']), '$marital' => marital_selector($r[0]['marital']),
'$marital_min' => marital_selector_min($r[0]['marital']), '$marital_min' => marital_selector_min($r[0]['marital']),
'$with' => array('with', t("Who (if applicable)"), $r[0]['with'], t('Examples: cathy123, Cathy Williams, cathy@example.com')), '$with' => array('with', t("Who (if applicable)"), $r[0]['partner'], t('Examples: cathy123, Cathy Williams, cathy@example.com')),
'$howlong' => array('howlong', t('Since (date)'), ($r[0]['howlong'] === NULL_DATE ? '' : datetime_convert('UTC',date_default_timezone_get(),$r[0]['howlong']))), '$howlong' => array('howlong', t('Since (date)'), ($r[0]['howlong'] === NULL_DATE ? '' : datetime_convert('UTC',date_default_timezone_get(),$r[0]['howlong']))),
'$sexual' => sexpref_selector($r[0]['sexual']), '$sexual' => sexpref_selector($r[0]['sexual']),
'$sexual_min' => sexpref_selector_min($r[0]['sexual']), '$sexual_min' => sexpref_selector_min($r[0]['sexual']),
@ -743,7 +741,7 @@ class Profiles extends \Zotlabs\Web\Controller {
'$film' => array('film', t('Film/Dance/Culture/Entertainment'), $r[0]['film']), '$film' => array('film', t('Film/Dance/Culture/Entertainment'), $r[0]['film']),
'$interest' => array('interest', t('Hobbies/Interests'), $r[0]['interest']), '$interest' => array('interest', t('Hobbies/Interests'), $r[0]['interest']),
'$romance' => array('romance',t('Love/Romance'), $r[0]['romance']), '$romance' => array('romance',t('Love/Romance'), $r[0]['romance']),
'$work' => array('work', t('Work/Employment'), $r[0]['work']), '$work' => array('work', t('Work/Employment'), $r[0]['employment']),
'$education' => array('education', t('School/Education'), $r[0]['education']), '$education' => array('education', t('School/Education'), $r[0]['education']),
'$contact' => array('contact', t('Contact information and social networks'), $r[0]['contact']), '$contact' => array('contact', t('Contact information and social networks'), $r[0]['contact']),
'$channels' => array('channels', t('My other channels'), $r[0]['channels']), '$channels' => array('channels', t('My other channels'), $r[0]['channels']),
@ -759,7 +757,7 @@ class Profiles extends \Zotlabs\Web\Controller {
$r = q("SELECT * FROM `profile` WHERE `uid` = %d", $r = q("SELECT * FROM `profile` WHERE `uid` = %d",
local_channel()); local_channel());
if(count($r)) { if($r) {
$tpl = get_markup_template('profile_entry.tpl'); $tpl = get_markup_template('profile_entry.tpl');
foreach($r as $rr) { foreach($r as $rr) {
@ -782,9 +780,6 @@ class Profiles extends \Zotlabs\Web\Controller {
'$profiles' => $profiles '$profiles' => $profiles
)); ));
} }
return $o; return $o;
} }

View file

@ -28,9 +28,10 @@ class Pubsites extends \Zotlabs\Web\Controller {
if($ret['success']) { if($ret['success']) {
$j = json_decode($ret['body'],true); $j = json_decode($ret['body'],true);
if($j) { if($j) {
$o .= '<table class="table table-striped table-hover"><tr><td>' . t('Hub URL') . '</td><td>' . t('Access Type') . '</td><td>' . t('Registration Policy') . '</td><td>' . t('Software') . '</td><td colspan="2">' . t('Ratings') . '</td></tr>'; $o .= '<table class="table table-striped table-hover"><tr><td>' . t('Hub URL') . '</td><td>' . t('Access Type') . '</td><td>' . t('Registration Policy') . '</td><td>' . t('Stats') . '</td><td>' . t('Software') . '</td><td colspan="2">' . t('Ratings') . '</td></tr>';
if($j['sites']) { if($j['sites']) {
foreach($j['sites'] as $jj) { foreach($j['sites'] as $jj) {
$m = parse_url($jj['url']);
if(strpos($jj['project'],\Zotlabs\Lib\System::get_platform_name()) === false) if(strpos($jj['project'],\Zotlabs\Lib\System::get_platform_name()) === false)
continue; continue;
$host = strtolower(substr($jj['url'],strpos($jj['url'],'://')+3)); $host = strtolower(substr($jj['url'],strpos($jj['url'],'://')+3));
@ -43,7 +44,7 @@ class Pubsites extends \Zotlabs\Web\Controller {
$location = '<br />&nbsp;'; $location = '<br />&nbsp;';
} }
$urltext = str_replace(array('https://'), '', $jj['url']); $urltext = str_replace(array('https://'), '', $jj['url']);
$o .= '<tr><td><a href="'. (($jj['sellpage']) ? $jj['sellpage'] : $jj['url'] . '/register' ) . '" ><i class="fa fa-link"></i> ' . $urltext . '</a>' . $location . '</td><td>' . $jj['access'] . '</td><td>' . $jj['register'] . '</td><td>' . ucwords($jj['project']) . '</td><td><a href="ratings/' . $host . '" class="btn-btn-default"><i class="fa fa-eye"></i> ' . t('View') . '</a></td>' . $rate_links . '</tr>'; $o .= '<tr><td><a href="'. (($jj['sellpage']) ? $jj['sellpage'] : $jj['url'] . '/register' ) . '" ><i class="fa fa-link"></i> ' . $urltext . '</a>' . $location . '</td><td>' . $jj['access'] . '</td><td>' . $jj['register'] . '</td><td>' . '<a target="stats" href="https://hubchart-tarine.rhcloud.com/hub.jsp?hubFqdn=' . $m['host'] . '"><i class="fa fa-area-chart"></i></a></td><td>' . ucwords($jj['project']) . '</td><td><a href="ratings/' . $host . '" class="btn-btn-default"><i class="fa fa-eye"></i> ' . t('View') . '</a></td>' . $rate_links . '</tr>';
} }
} }

View file

@ -79,7 +79,7 @@ class Search extends \Zotlabs\Web\Controller {
return $o; return $o;
if($tag) { if($tag) {
$sql_extra = sprintf(" AND `item`.`id` IN (select `oid` from term where otype = %d and type in ( %d , %d) and term = '%s') ", $sql_extra = sprintf(" AND `item`.`id` IN (select `oid` from term where otype = %d and ttype in ( %d , %d) and term = '%s') ",
intval(TERM_OBJ_POST), intval(TERM_OBJ_POST),
intval(TERM_HASHTAG), intval(TERM_HASHTAG),
intval(TERM_COMMUNITYTAG), intval(TERM_COMMUNITYTAG),

View file

@ -46,7 +46,7 @@ class Search_ac extends \Zotlabs\Web\Controller {
} }
} }
$r = q("select distinct term, tid, url from term where type in ( %d, %d ) $tag_sql_extra group by term order by term asc", $r = q("select distinct term, tid, url from term where ttype in ( %d, %d ) $tag_sql_extra group by term order by term asc",
intval(TERM_HASHTAG), intval(TERM_HASHTAG),
intval(TERM_COMMUNITYTAG) intval(TERM_COMMUNITYTAG)
); );

View file

@ -78,7 +78,7 @@ class Settings extends \Zotlabs\Web\Controller {
$r = q("UPDATE clients SET $r = q("UPDATE clients SET
client_id='%s', client_id='%s',
pw='%s', pw='%s',
name='%s', clname='%s',
redirect_uri='%s', redirect_uri='%s',
icon='%s', icon='%s',
uid=%d uid=%d
@ -91,7 +91,7 @@ class Settings extends \Zotlabs\Web\Controller {
intval(local_channel()), intval(local_channel()),
dbesc($key)); dbesc($key));
} else { } else {
$r = q("INSERT INTO clients (client_id, pw, name, redirect_uri, icon, uid) $r = q("INSERT INTO clients (client_id, pw, clname, redirect_uri, icon, uid)
VALUES ('%s','%s','%s','%s','%s',%d)", VALUES ('%s','%s','%s','%s','%s',%d)",
dbesc($key), dbesc($key),
dbesc($secret), dbesc($secret),
@ -337,7 +337,7 @@ class Settings extends \Zotlabs\Web\Controller {
} }
$hide_presence = 1 - (intval($role_permissions['online'])); $hide_presence = 1 - (intval($role_permissions['online']));
if($role_permissions['default_collection']) { if($role_permissions['default_collection']) {
$r = q("select hash from groups where uid = %d and name = '%s' limit 1", $r = q("select hash from groups where uid = %d and gname = '%s' limit 1",
intval(local_channel()), intval(local_channel()),
dbesc( t('Friends') ) dbesc( t('Friends') )
); );
@ -345,7 +345,7 @@ class Settings extends \Zotlabs\Web\Controller {
require_once('include/group.php'); require_once('include/group.php');
group_add(local_channel(), t('Friends')); group_add(local_channel(), t('Friends'));
group_add_member(local_channel(),t('Friends'),$channel['channel_hash']); group_add_member(local_channel(),t('Friends'),$channel['channel_hash']);
$r = q("select hash from groups where uid = %d and name = '%s' limit 1", $r = q("select hash from groups where uid = %d and gname = '%s' limit 1",
intval(local_channel()), intval(local_channel()),
dbesc( t('Friends') ) dbesc( t('Friends') )
); );
@ -537,7 +537,7 @@ class Settings extends \Zotlabs\Web\Controller {
dbesc(datetime_convert()), dbesc(datetime_convert()),
dbesc($channel['channel_hash']) dbesc($channel['channel_hash'])
); );
$r = q("update profile set name = '%s' where uid = %d and is_default = 1", $r = q("update profile set fullname = '%s' where uid = %d and is_default = 1",
dbesc($username), dbesc($username),
intval($channel['channel_id']) intval($channel['channel_id'])
); );
@ -615,7 +615,7 @@ class Settings extends \Zotlabs\Web\Controller {
'$title' => t('Add application'), '$title' => t('Add application'),
'$submit' => t('Update'), '$submit' => t('Update'),
'$cancel' => t('Cancel'), '$cancel' => t('Cancel'),
'$name' => array('name', t('Name'), $app['name'] , ''), '$name' => array('name', t('Name'), $app['clname'] , ''),
'$key' => array('key', t('Consumer Key'), $app['client_id'], ''), '$key' => array('key', t('Consumer Key'), $app['client_id'], ''),
'$secret' => array('secret', t('Consumer Secret'), $app['pw'], ''), '$secret' => array('secret', t('Consumer Secret'), $app['pw'], ''),
'$redirect' => array('redirect', t('Redirect'), $app['redirect_uri'], ''), '$redirect' => array('redirect', t('Redirect'), $app['redirect_uri'], ''),

View file

@ -12,7 +12,6 @@ namespace Zotlabs\Module;
/** /**
* @brief Initialisation for the setup module. * @brief Initialisation for the setup module.
* *
* @param[in,out] App &$a
*/ */
class Setup extends \Zotlabs\Web\Controller { class Setup extends \Zotlabs\Web\Controller {
@ -54,16 +53,15 @@ class Setup extends \Zotlabs\Web\Controller {
/** /**
* @brief Handle the actions of the different setup steps. * @brief Handle the actions of the different setup steps.
* *
* @param[in,out] App &$a
*/ */
function post() { function post() {
global $db;
switch($this->install_wizard_pass) { switch($this->install_wizard_pass) {
case 1: case 1:
case 2: case 2:
return; return;
break; // just in case return don't return :) // implied break;
case 3: case 3:
$urlpath = \App::get_path(); $urlpath = \App::get_path();
$dbhost = trim($_POST['dbhost']); $dbhost = trim($_POST['dbhost']);
@ -82,39 +80,15 @@ class Setup extends \Zotlabs\Web\Controller {
$siteurl = rtrim($siteurl,'/'); $siteurl = rtrim($siteurl,'/');
require_once('include/dba/dba_driver.php'); require_once('include/dba/dba_driver.php');
unset($db);
$db = dba_factory($dbhost, $dbport, $dbuser, $dbpass, $dbdata, $dbtype, true);
if(! $db->connected) { $db = \DBA::dba_factory($dbhost, $dbport, $dbuser, $dbpass, $dbdata, $dbtype, true);
echo 'Database Connect failed: ' . $db->error;
if(! \DBA::$dba->connected) {
echo 'Database Connect failed: ' . DBA::$dba->error;
killme(); killme();
\App::$data['db_conn_failed']=true;
} }
/*if(get_db_errno()) {
unset($db);
$db = dba_factory($dbhost, $dbport, $dbuser, $dbpass, '', true);
if(! get_db_errno()) {
$r = q("CREATE DATABASE '%s'",
dbesc($dbdata)
);
if($r) {
unset($db);
$db = new dba($dbhost, $dbport, $dbuser, $dbpass, $dbdata, true);
} else {
\App::$data['db_create_failed']=true;
}
} else {
\App::$data['db_conn_failed']=true;
return; return;
} // implied break;
}*/
//if(get_db_errno()) {
//}
return;
break;
case 4: case 4:
$urlpath = \App::get_path(); $urlpath = \App::get_path();
$dbhost = notags(trim($_POST['dbhost'])); $dbhost = notags(trim($_POST['dbhost']));
@ -138,10 +112,12 @@ class Setup extends \Zotlabs\Web\Controller {
} }
} }
if(! \DBA::$dba->connected) {
// connect to db // connect to db
$db = dba_factory($dbhost, $dbport, $dbuser, $dbpass, $dbdata, $dbtype, true); $db = \DBA::dba_factory($dbhost, $dbport, $dbuser, $dbpass, $dbdata, $dbtype, true);
}
if(! $db->connected) { if(! \DBA::$dba->connected) {
echo 'CRITICAL: DB not connected.'; echo 'CRITICAL: DB not connected.';
killme(); killme();
} }
@ -175,6 +151,8 @@ class Setup extends \Zotlabs\Web\Controller {
\App::$data['db_installed'] = true; \App::$data['db_installed'] = true;
return; return;
// implied break;
default:
break; break;
} }
} }
@ -191,11 +169,10 @@ class Setup extends \Zotlabs\Web\Controller {
* *
* Depending on the state we are currently in it returns different content. * Depending on the state we are currently in it returns different content.
* *
* @param App &$a
* @return string parsed HTML output * @return string parsed HTML output
*/ */
function get() { function get() {
global $db;
$o = ''; $o = '';
$wizard_status = ''; $wizard_status = '';
@ -228,7 +205,7 @@ class Setup extends \Zotlabs\Web\Controller {
$txt .= "<pre>".\App::$data['db_failed'] . "</pre>". EOL ; $txt .= "<pre>".\App::$data['db_failed'] . "</pre>". EOL ;
$db_return_text .= $txt; $db_return_text .= $txt;
} }
if($db && $db->connected) { if(\DBA::$dba && \DBA::$dba->connected) {
$r = q("SELECT COUNT(*) as `total` FROM `account`"); $r = q("SELECT COUNT(*) as `total` FROM `account`");
if($r && count($r) && $r[0]['total']) { if($r && count($r) && $r[0]['total']) {
$tpl = get_markup_template('install.tpl'); $tpl = get_markup_template('install.tpl');
@ -407,8 +384,8 @@ class Setup extends \Zotlabs\Web\Controller {
function check_php(&$phpath, &$checks) { function check_php(&$phpath, &$checks) {
$help = ''; $help = '';
if(version_compare(PHP_VERSION, '5.4') < 0) { if(version_compare(PHP_VERSION, '5.5') < 0) {
$help .= t('PHP version 5.4 or greater is required.'); $help .= t('PHP version 5.5 or greater is required.');
$this->check_add($checks, t('PHP version'), false, false, $help); $this->check_add($checks, t('PHP version'), false, false, $help);
} }
@ -598,7 +575,7 @@ class Setup extends \Zotlabs\Web\Controller {
if(! is_writable(TEMPLATE_BUILD_PATH) ) { if(! is_writable(TEMPLATE_BUILD_PATH) ) {
$status = false; $status = false;
$help = t('Red uses the Smarty3 template engine to render its web views. Smarty3 compiles templates to PHP to speed up rendering.') .EOL; $help = t('Red uses the Smarty3 template engine to render its web views. Smarty3 compiles templates to PHP to speed up rendering.') .EOL;
$help .= sprintf( t('In order to store these compiled templates, the web server needs to have write access to the directory %s under the Red top level folder.'), TEMPLATE_BUILD_PATH) . EOL; $help .= sprintf( t('In order to store these compiled templates, the web server needs to have write access to the directory %s under the top level web folder.'), TEMPLATE_BUILD_PATH) . EOL;
$help .= t('Please ensure that the user that your web server runs as (e.g. www-data) has write access to this folder.').EOL; $help .= t('Please ensure that the user that your web server runs as (e.g. www-data) has write access to this folder.').EOL;
$help .= sprintf( t('Note: as a security measure, you should give the web server write access to %s only--not the template files (.tpl) that it contains.'), TEMPLATE_BUILD_PATH) . EOL; $help .= sprintf( t('Note: as a security measure, you should give the web server write access to %s only--not the template files (.tpl) that it contains.'), TEMPLATE_BUILD_PATH) . EOL;
} }
@ -698,12 +675,12 @@ class Setup extends \Zotlabs\Web\Controller {
function load_database($db) { function load_database($db) {
$str = file_get_contents($db->get_install_script()); $str = file_get_contents(\DBA::$dba->get_install_script());
$arr = explode(';',$str); $arr = explode(';',$str);
$errors = false; $errors = false;
foreach($arr as $a) { foreach($arr as $a) {
if(strlen(trim($a))) { if(strlen(trim($a))) {
$r = @$db->q(trim($a)); $r = dbq(trim($a));
if(! $r) { if(! $r) {
$errors .= t('Errors encountered creating database tables.') . $a . EOL; $errors .= t('Errors encountered creating database tables.') . $a . EOL;
} }

View file

@ -256,6 +256,7 @@ class Browser extends DAV\Browser\Plugin {
$func($a); $func($a);
} }
} }
$this->server->httpResponse->setHeader('Content-Security-Policy', "script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'");
construct_page($a); construct_page($a);
} }

View file

@ -18,10 +18,10 @@ class SessionHandler implements \SessionHandlerInterface {
function read ($id) { function read ($id) {
if($id) { if($id) {
$r = q("SELECT `data` FROM `session` WHERE `sid`= '%s'", dbesc($id)); $r = q("SELECT `sess_data` FROM `session` WHERE `sid`= '%s'", dbesc($id));
if($r) { if($r) {
return $r[0]['data']; return $r[0]['sess_data'];
} }
else { else {
q("INSERT INTO `session` (sid, expire) values ('%s', '%s')", q("INSERT INTO `session` (sid, expire) values ('%s', '%s')",
@ -59,7 +59,7 @@ class SessionHandler implements \SessionHandlerInterface {
} }
q("UPDATE `session` q("UPDATE `session`
SET `data` = '%s', `expire` = '%s' WHERE `sid` = '%s'", SET `sess_data` = '%s', `expire` = '%s' WHERE `sid` = '%s'",
dbesc($data), dbesc($data),
dbesc($expire), dbesc($expire),
dbesc($id) dbesc($id)

130
Zotlabs/Web/WebServer.php Normal file
View file

@ -0,0 +1,130 @@
<?php /** @file */
namespace Zotlabs\Web;
class WebServer {
public function run() {
/*
* Bootstrap the application, load configuration, load modules, load theme, etc.
*/
require_once('boot.php');
sys_boot();
\App::$language = get_best_language();
load_translation_table(\App::$language,\App::$install);
/**
*
* Important stuff we always need to do.
*
* The order of these may be important so use caution if you think they're all
* intertwingled with no logical order and decide to sort it out. Some of the
* dependencies have changed, but at least at one time in the recent past - the
* order was critical to everything working properly
*
*/
if(\App::$session) {
\App::$session->start();
}
else {
session_start();
register_shutdown_function('session_write_close');
}
/**
* Language was set earlier, but we can over-ride it in the session.
* We have to do it here because the session was just now opened.
*/
if(array_key_exists('system_language',$_POST)) {
if(strlen($_POST['system_language']))
$_SESSION['language'] = $_POST['system_language'];
else
unset($_SESSION['language']);
}
if((x($_SESSION, 'language')) && ($_SESSION['language'] !== $lang)) {
\App::$language = $_SESSION['language'];
load_translation_table(\App::$language);
}
if((x($_GET,'zid')) && (! \App::$install)) {
\App::$query_string = strip_zids(\App::$query_string);
if(! local_channel()) {
$_SESSION['my_address'] = $_GET['zid'];
zid_init($a);
}
}
if((x($_SESSION, 'authenticated')) || (x($_POST, 'auth-params')) || (\App::$module === 'login'))
require('include/auth.php');
if(! x($_SESSION, 'sysmsg'))
$_SESSION['sysmsg'] = array();
if(! x($_SESSION, 'sysmsg_info'))
$_SESSION['sysmsg_info'] = array();
/*
* check_config() is responsible for running update scripts. These automatically
* update the DB schema whenever we push a new one out. It also checks to see if
* any plugins have been added or removed and reacts accordingly.
*/
if(\App::$install) {
/* Allow an exception for the view module so that pcss will be interpreted during installation */
if(\App::$module != 'view')
\App::$module = 'setup';
}
else
check_config($a);
nav_set_selected('nothing');
$Router = new Router($a);
/* initialise content region */
if(! x(\App::$page, 'content'))
\App::$page['content'] = '';
call_hooks('page_content_top', \App::$page['content']);
$Router->Dispatch($a);
// If you're just visiting, let javascript take you home
if(x($_SESSION, 'visitor_home')) {
$homebase = $_SESSION['visitor_home'];
} elseif(local_channel()) {
$homebase = z_root() . '/channel/' . \App::$channel['channel_address'];
}
if(isset($homebase)) {
\App::$page['content'] .= '<script>var homebase = "' . $homebase . '";</script>';
}
// now that we've been through the module content, see if the page reported
// a permission problem and if so, a 403 response would seem to be in order.
if(stristr(implode("", $_SESSION['sysmsg']), t('Permission denied'))) {
header($_SERVER['SERVER_PROTOCOL'] . ' 403 ' . t('Permission denied.'));
}
call_hooks('page_end', \App::$page['content']);
construct_page($a);
killme();
}
}

View file

@ -112,12 +112,12 @@ class Finger {
if($signed_token) { if($signed_token) {
$valid = rsa_verify('token.' . self::$token,base64url_decode($signed_token),$x['key']); $valid = rsa_verify('token.' . self::$token,base64url_decode($signed_token),$x['key']);
if(! $valid) { if(! $valid) {
logger('invalid signed token: ' . $url . $rhs, LOGGER_NORMAL, LOG_WARN); logger('invalid signed token: ' . $url . $rhs, LOGGER_NORMAL, LOG_ERR);
return $ret; return $ret;
} }
} }
else { else {
logger('No signed token from ' . $url . $rhs, LOGGER_NORMAL, LOG_WARN); logger('No signed token from ' . $url . $rhs, LOGGER_NORMAL, LOG_WARNING);
// after 2017-01-01 this will be a hard error unless you over-ride it. // after 2017-01-01 this will be a hard error unless you over-ride it.
if((time() > 1483228800) && (! get_config('system','allow_unsigned_zotfinger'))) if((time() > 1483228800) && (! get_config('system','allow_unsigned_zotfinger')))
return $ret; return $ret;

View file

@ -6,7 +6,7 @@ namespace Zotlabs\Zot;
class Verify { class Verify {
function create($type,$channel_id,$token,$meta) { function create($type,$channel_id,$token,$meta) {
return q("insert into verify ( type, channel, token, meta, created ) values ( '%s', %d, '%s', '%s', '%s' )", return q("insert into verify ( vtype, channel, token, meta, created ) values ( '%s', %d, '%s', '%s', '%s' )",
dbesc($type), dbesc($type),
intval($channel_id), intval($channel_id),
dbesc($token), dbesc($token),
@ -16,7 +16,7 @@ class Verify {
} }
function match($type,$channel_id,$token,$meta) { function match($type,$channel_id,$token,$meta) {
$r = q("select id from verify where type = '%s' and channel = %d and token = '%s' and meta = '%s' limit 1", $r = q("select id from verify where vtype = '%s' and channel = %d and token = '%s' and meta = '%s' limit 1",
dbesc($type), dbesc($type),
intval($channel_id), intval($channel_id),
dbesc($token), dbesc($token),
@ -32,7 +32,7 @@ class Verify {
} }
function purge($type,$interval) { function purge($type,$interval) {
q("delete from verify where type = '%s' and created < %s - INTERVAL %s", q("delete from verify where vtype = '%s' and created < %s - INTERVAL %s",
dbesc($type), dbesc($type),
db_utcnow(), db_utcnow(),
db_quoteinterval($interval) db_quoteinterval($interval)

152
boot.php
View file

@ -45,10 +45,10 @@ require_once('include/account.php');
define ( 'PLATFORM_NAME', 'hubzilla' ); define ( 'PLATFORM_NAME', 'hubzilla' );
define ( 'STD_VERSION', '1.7.1' ); define ( 'STD_VERSION', '1.7.2' );
define ( 'ZOT_REVISION', 1.1 ); define ( 'ZOT_REVISION', 1.1 );
define ( 'DB_UPDATE_VERSION', 1168 ); define ( 'DB_UPDATE_VERSION', 1173 );
/** /**
@ -579,6 +579,72 @@ define ( 'ITEM_IS_STICKY', 1000 );
define ( 'DBTYPE_MYSQL', 0 ); define ( 'DBTYPE_MYSQL', 0 );
define ( 'DBTYPE_POSTGRES', 1 ); define ( 'DBTYPE_POSTGRES', 1 );
function sys_boot() {
// our central App object
App::init();
/*
* Load the configuration file which contains our DB credentials.
* Ignore errors. If the file doesn't exist or is empty, we are running in
* installation mode.
*/
// miniApp is a conversion object from old style .htconfig.php files
$a = new miniApp;
App::$install = ((file_exists('.htconfig.php') && filesize('.htconfig.php')) ? false : true);
@include('.htconfig.php');
if(! defined('UNO'))
define('UNO', 0);
if(array_key_exists('default_timezone',get_defined_vars())) {
App::$config['system']['timezone'] = $default_timezone;
}
$a->convert();
App::$timezone = ((App::$config['system']['timezone']) ? App::$config['system']['timezone'] : 'UTC');
date_default_timezone_set(App::$timezone);
/*
* Try to open the database;
*/
require_once('include/dba/dba_driver.php');
if(! App::$install) {
DBA::dba_factory($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type, App::$install);
if(! DBA::$dba->connected) {
system_unavailable();
}
unset($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type);
/**
* Load configs from db. Overwrite configs from .htconfig.php
*/
load_config('config');
load_config('system');
load_config('feature');
App::$session = new Zotlabs\Web\Session();
App::$session->init();
load_hooks();
call_hooks('init_1');
}
}
/** /**
* *
* Reverse the effect of magic_quotes_gpc if it is enabled. * Reverse the effect of magic_quotes_gpc if it is enabled.
@ -1197,7 +1263,6 @@ class App {
* @return App * @return App
*/ */
function get_app() { function get_app() {
global $a;
return $a; return $a;
} }
@ -1247,7 +1312,6 @@ function system_unavailable() {
function clean_urls() { function clean_urls() {
global $a;
// if(App::$config['system']['clean_urls']) // if(App::$config['system']['clean_urls'])
return true; return true;
@ -1255,8 +1319,6 @@ function clean_urls() {
} }
function z_path() { function z_path() {
global $a;
$base = z_root(); $base = z_root();
if(! clean_urls()) if(! clean_urls())
$base .= '/?q='; $base .= '/?q=';
@ -1272,7 +1334,6 @@ function z_path() {
* @return string * @return string
*/ */
function z_root() { function z_root() {
global $a;
return App::get_baseurl(); return App::get_baseurl();
} }
@ -1461,11 +1522,11 @@ function check_config(&$a) {
if(count($installed)) { if(count($installed)) {
foreach($installed as $i) { foreach($installed as $i) {
if(! in_array($i['name'], $plugins_arr)) { if(! in_array($i['aname'], $plugins_arr)) {
unload_plugin($i['name']); unload_plugin($i['aname']);
} }
else { else {
$installed_arr[] = $i['name']; $installed_arr[] = $i['aname'];
} }
} }
} }
@ -1604,7 +1665,6 @@ function fix_system_urls($oldurl, $newurl) {
// returns the complete html for inserting into the page // returns the complete html for inserting into the page
function login($register = false, $form_id = 'main-login', $hiddens=false) { function login($register = false, $form_id = 'main-login', $hiddens=false) {
$a = get_app();
$o = ''; $o = '';
$reg = false; $reg = false;
$reglink = get_config('system', 'register_link'); $reglink = get_config('system', 'register_link');
@ -1674,9 +1734,7 @@ function goaway($s) {
} }
function shutdown() { function shutdown() {
global $db;
if(is_object($db) && $db->connected)
$db->close();
} }
/** /**
@ -1710,7 +1768,9 @@ function get_account_id() {
* @return int|bool channel_id or false * @return int|bool channel_id or false
*/ */
function local_channel() { function local_channel() {
if((x($_SESSION, 'authenticated')) && (x($_SESSION, 'uid'))) if(session_id()
&& array_key_exists('authenticated',$_SESSION) && $_SESSION['authenticated']
&& array_key_exists('uid',$_SESSION) && intval($_SESSION['uid']))
return intval($_SESSION['uid']); return intval($_SESSION['uid']);
return false; return false;
@ -1741,7 +1801,9 @@ function local_user() {
* @return string|bool visitor_id or false * @return string|bool visitor_id or false
*/ */
function remote_channel() { function remote_channel() {
if((x($_SESSION, 'authenticated')) && (x($_SESSION, 'visitor_id'))) if(session_id()
&& array_key_exists('authenticated',$_SESSION) && $_SESSION['authenticated']
&& array_key_exists('visitor_id',$_SESSION) && $_SESSION['visitor_id'])
return $_SESSION['visitor_id']; return $_SESSION['visitor_id'];
return false; return false;
@ -1766,7 +1828,9 @@ function remote_user() {
* @param string $s Text to display * @param string $s Text to display
*/ */
function notice($s) { function notice($s) {
$a = get_app(); if(! session_id())
return;
if(! x($_SESSION, 'sysmsg')) $_SESSION['sysmsg'] = array(); if(! x($_SESSION, 'sysmsg')) $_SESSION['sysmsg'] = array();
// ignore duplicated error messages which haven't yet been displayed // ignore duplicated error messages which haven't yet been displayed
@ -1790,8 +1854,10 @@ function notice($s) {
* @param string $s Text to display * @param string $s Text to display
*/ */
function info($s) { function info($s) {
$a = get_app(); if(! session_id())
if(! x($_SESSION, 'sysmsg_info')) $_SESSION['sysmsg_info'] = array(); return;
if(! x($_SESSION, 'sysmsg_info'))
$_SESSION['sysmsg_info'] = array();
if(App::$interactive) if(App::$interactive)
$_SESSION['sysmsg_info'][] = $s; $_SESSION['sysmsg_info'][] = $s;
} }
@ -1877,6 +1943,10 @@ function proc_run(){
* @brief Checks if we are running on M$ Windows. * @brief Checks if we are running on M$ Windows.
* *
* @return bool true if we run on M$ Windows * @return bool true if we run on M$ Windows
*
* It's possible you might be able to run on WAMP or XAMPP, and this
* has been accomplished, but is not officially supported. Good luck.
*
*/ */
function is_windows() { function is_windows() {
return ((strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? true : false); return ((strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? true : false);
@ -1891,7 +1961,9 @@ function is_windows() {
*/ */
function is_site_admin() { function is_site_admin() {
$a = get_app();
if(! session_id())
return false;
if($_SESSION['delegate']) if($_SESSION['delegate'])
return false; return false;
@ -1912,7 +1984,10 @@ function is_site_admin() {
* @return bool true if user is a developer * @return bool true if user is a developer
*/ */
function is_developer() { function is_developer() {
$a = get_app();
if(! session_id())
return false;
if((intval($_SESSION['authenticated'])) if((intval($_SESSION['authenticated']))
&& (is_array(App::$account)) && (is_array(App::$account))
&& (App::$account['account_roles'] & ACCOUNT_ROLE_DEVELOPER)) && (App::$account['account_roles'] & ACCOUNT_ROLE_DEVELOPER))
@ -1923,7 +1998,6 @@ function is_developer() {
function load_contact_links($uid) { function load_contact_links($uid) {
$a = get_app();
$ret = array(); $ret = array();
@ -1932,7 +2006,7 @@ function load_contact_links($uid) {
// logger('load_contact_links'); // logger('load_contact_links');
$r = q("SELECT abook_id, abook_flags, abook_my_perms, abook_their_perms, xchan_hash, xchan_photo_m, xchan_name, xchan_url from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d ", $r = q("SELECT abook_id, abook_flags, abook_my_perms, abook_their_perms, xchan_hash, xchan_photo_m, xchan_name, xchan_url, xchan_network from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d ",
intval($uid) intval($uid)
); );
if($r) { if($r) {
@ -1955,6 +2029,7 @@ function load_contact_links($uid) {
* *
* @return string * @return string
*/ */
function build_querystring($params, $name = null) { function build_querystring($params, $name = null) {
$ret = ''; $ret = '';
foreach($params as $key => $val) { foreach($params as $key => $val) {
@ -1997,8 +2072,9 @@ function dba_timer() {
/** /**
* @brief Returns xchan_hash from the observer. * @brief Returns xchan_hash from the observer.
* *
* @return string Empty if no observer, otherwise xchan_hash from observer * @return empty string if no observer, otherwise xchan_hash from observer
*/ */
function get_observer_hash() { function get_observer_hash() {
$observer = App::get_observer(); $observer = App::get_observer();
if(is_array($observer)) if(is_array($observer))
@ -2055,8 +2131,6 @@ function load_pdl(&$a) {
App::$comanche = new Zotlabs\Render\Comanche(); App::$comanche = new Zotlabs\Render\Comanche();
// require_once('include/comanche.php');
if (! count(App::$layout)) { if (! count(App::$layout)) {
$arr = array('module' => App::$module, 'layout' => ''); $arr = array('module' => App::$module, 'layout' => '');
@ -2077,13 +2151,10 @@ function load_pdl(&$a) {
App::$pdl = $s; App::$pdl = $s;
} }
} }
} }
function exec_pdl(&$a) { function exec_pdl(&$a) {
// require_once('include/comanche.php');
if(App::$pdl) { if(App::$pdl) {
App::$comanche->parse(App::$pdl,1); App::$comanche->parse(App::$pdl,1);
} }
@ -2241,7 +2312,6 @@ function appdirpath() {
* @param string $icon * @param string $icon
*/ */
function head_set_icon($icon) { function head_set_icon($icon) {
global $a;
App::$data['pageicon'] = $icon; App::$data['pageicon'] = $icon;
// logger('head_set_icon: ' . $icon); // logger('head_set_icon: ' . $icon);
@ -2253,7 +2323,6 @@ function head_set_icon($icon) {
* @return string absolut path to pageicon * @return string absolut path to pageicon
*/ */
function head_get_icon() { function head_get_icon() {
global $a;
$icon = App::$data['pageicon']; $icon = App::$data['pageicon'];
if(! strpos($icon, '://')) if(! strpos($icon, '://'))
@ -2319,7 +2388,7 @@ function z_get_temp_dir() {
} }
function z_check_cert() { function z_check_cert() {
$a = get_app();
if(strpos(z_root(),'https://') !== false) { if(strpos(z_root(),'https://') !== false) {
$x = z_fetch_url(z_root() . '/siteinfo/json'); $x = z_fetch_url(z_root() . '/siteinfo/json');
if(! $x['success']) { if(! $x['success']) {
@ -2340,8 +2409,6 @@ function z_check_cert() {
*/ */
function cert_bad_email() { function cert_bad_email() {
$a = get_app();
$email_tpl = get_intltext_template("cert_bad_eml.tpl"); $email_tpl = get_intltext_template("cert_bad_eml.tpl");
$email_msg = replace_macros($email_tpl, array( $email_msg = replace_macros($email_tpl, array(
'$sitename' => App::$config['system']['sitename'], '$sitename' => App::$config['system']['sitename'],
@ -2362,26 +2429,30 @@ function cert_bad_email() {
*/ */
function check_cron_broken() { function check_cron_broken() {
$t = get_config('system','lastpollcheck'); $d = get_config('system','lastcron');
if((! $d) || ($d < datetime_convert('UTC','UTC','now - 4 hours'))) {
Zotlabs\Daemon\Master::Summon(array('Cron'));
}
$t = get_config('system','lastcroncheck');
if(! $t) { if(! $t) {
// never checked before. Start the timer. // never checked before. Start the timer.
set_config('system','lastpollcheck',datetime_convert()); set_config('system','lastcroncheck',datetime_convert());
return; return;
} }
if($t > datetime_convert('UTC','UTC','now - 3 days')) { if($t > datetime_convert('UTC','UTC','now - 3 days')) {
// Wait for 3 days before we do anything so as not to swamp the admin with messages // Wait for 3 days before we do anything so as not to swamp the admin with messages
return; return;
} }
$d = get_config('system','lastpoll');
if(($d) && ($d > datetime_convert('UTC','UTC','now - 3 days'))) { if(($d) && ($d > datetime_convert('UTC','UTC','now - 3 days'))) {
// Scheduled tasks have run successfully in the last 3 days. // Scheduled tasks have run successfully in the last 3 days.
set_config('system','lastpollcheck',datetime_convert()); set_config('system','lastcroncheck',datetime_convert());
return; return;
} }
$a = get_app();
$email_tpl = get_intltext_template("cron_bad_eml.tpl"); $email_tpl = get_intltext_template("cron_bad_eml.tpl");
$email_msg = replace_macros($email_tpl, array( $email_msg = replace_macros($email_tpl, array(
'$sitename' => App::$config['system']['sitename'], '$sitename' => App::$config['system']['sitename'],
@ -2395,7 +2466,6 @@ function check_cron_broken() {
'From: Administrator' . '@' . App::get_hostname() . "\n" 'From: Administrator' . '@' . App::get_hostname() . "\n"
. 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n"
. 'Content-transfer-encoding: 8bit' ); . 'Content-transfer-encoding: 8bit' );
set_config('system','lastpollcheck',datetime_convert());
return; return;
} }

View file

@ -42,11 +42,11 @@ You MAY additionally provide other profile information. Any information which yo
Content you provide (status posts, photos, files, etc.) belongs to you. The $Projectname default is to publish content openly and visible to anybody on the internet (PUBLIC). You MAY control this in your channel settings and restrict the default permissions or you MAY restrict the visibility of any single published item separately (PRIVATE). $Projectname developers will ensure that restricted content is ONLY visible to those in the restriction list - to the best of their ability. Content you provide (status posts, photos, files, etc.) belongs to you. The $Projectname default is to publish content openly and visible to anybody on the internet (PUBLIC). You MAY control this in your channel settings and restrict the default permissions or you MAY restrict the visibility of any single published item separately (PRIVATE). $Projectname developers will ensure that restricted content is ONLY visible to those in the restriction list - to the best of their ability.
Content (especially status posts) that you share with other networks or that you have made visible to anybody on the internet (PUBLIC) cannot easily be taken back once it has been published. It MAY be shared with other networks and made available through RSS/Atom feeds. It may also be syndicated on other $Projectname sites. It MAY appear on spy networks and internet searches. If you do not wish this default behaviour please adjust your channel settings and restrict who can see your content. Content (especially status posts) that you share with other networks or that you have made visible to anybody on the internet (PUBLIC) cannot easily be taken back once it has been published. It MAY be shared with other networks and made available through RSS/Atom feeds. It may also be syndicated on other $Projectname sites. It MAY appear on other networks and websites and be visible in internet searches. If you do not wish this default behaviour please adjust your channel settings and restrict who can see your content.
**Comments and Forum posts** **Comments and Forum posts**
Comments to posts that were created by others and posts which are designated as forum posts belong to you as the creator/author, but the distribution of these posts is not under your direct control. These posts/comments MAY be re-distributed to others, and MAY be visible to anybody on the internet. In the case of comments, the creator of the "first message" in the thread to which you are replying controls the distribution of all comments and replies to that message. Comments to posts that were created by others and posts which are designated as forum posts belong to you as the creator/author, but the distribution of these posts is not under your direct control, and you relinquish SOME rights to these items. These posts/comments MAY be re-distributed to others, and MAY be visible to anybody on the internet. In the case of comments, the creator of the "first message" in the thread (conversation) to which you are replying controls the distribution of all comments and replies to that message. They "own" and therefore have certain rights with regard to the entire conversation (including all comments contained within it). You can still edit or delete the comment, but the conversation owner also has rights to edit, delete, re-distribute, and backup/restore any or all the content from the conversation.
**Private Information** **Private Information**

View file

@ -5,11 +5,6 @@
Hubzilla Community Server is open source software which is maintained by "the community" - essentially unpaid volunteers. Hubzilla Community Server is open source software which is maintained by "the community" - essentially unpaid volunteers.
[b]Hubzilla Enterprise Server[/b]
Hubzilla Enterprise Server is commercial software with a variety of support plans depending on the specific license terms.
The first thing you need to do is talk to your hub administrator - the person who runs and manages your site. They are in the unique position of having access to the internal software and database and [b]logfiles[/b] and will need to be involved in fixing your problem. Other people "on the net" can't really help with this. The first thing the hub administrator needs to do is look at their logs and/or try to reproduce the problem. So try to be as helpful and courteous as possible in helping them look into the problem. The first thing you need to do is talk to your hub administrator - the person who runs and manages your site. They are in the unique position of having access to the internal software and database and [b]logfiles[/b] and will need to be involved in fixing your problem. Other people "on the net" can't really help with this. The first thing the hub administrator needs to do is look at their logs and/or try to reproduce the problem. So try to be as helpful and courteous as possible in helping them look into the problem.
To find your hub administrator (if you don't know who they are) please look at [url=[baseurl]/siteinfo]this page[/url]. If they have not provided any contact info on that page or provided an "Impressum" there, see [url=[baseurl]/siteinfo/json]this site info summary[/url] under the heading "admin:". To find your hub administrator (if you don't know who they are) please look at [url=[baseurl]/siteinfo]this page[/url]. If they have not provided any contact info on that page or provided an "Impressum" there, see [url=[baseurl]/siteinfo/json]this site info summary[/url] under the heading "admin:".
@ -24,13 +19,6 @@ If you get a blank white screen when doing something, this is almost always a co
[h3]I'm stumped. I can't figure out what is wrong.[/h3] [h3]I'm stumped. I can't figure out what is wrong.[/h3]
[b]Hubzilla Enterprise Server[/b]
Please make contact with the vendor - who will have provided you with support contact details. Preferably this contact will be made by the hub administrator so that he/she can assist us in collecting the necessary issue details. We will assign a ticket and notify you of progress.
[b]Hubzilla Community Server[/b]
At this point it might be worthwhile discussing the issue on one of the online forums. There may be several of these and some may be more suited to your spoken language. As a last resort, try "Channel One", which is in English. At this point it might be worthwhile discussing the issue on one of the online forums. There may be several of these and some may be more suited to your spoken language. As a last resort, try "Channel One", which is in English.
If the community developers can't help you right away, understand that they are volunteers and may have a lot of other work and demands on their time. At this point you need to file a bug report. You will need an account on github.com to do this. So register, and then visit https://github.com/redmatrix/hubzilla/issues If the community developers can't help you right away, understand that they are volunteers and may have a lot of other work and demands on their time. At this point you need to file a bug report. You will need an account on github.com to do this. So register, and then visit https://github.com/redmatrix/hubzilla/issues
@ -39,7 +27,5 @@ If the community developers can't help you right away, understand that they are
Then you wait. If it's a high profile issue, it may get fixed quickly. But nobody is in charge of fixing bugs. If it lingers without resolution, please spend some more time investigating the problem. Ask about anything you don't understand related to the behaviour. You will learn more about how the software works and quite possibly figure out why it isn't working now. Ultimately it is somebody in the community who is going to fix this and you are a member of the community; and this is how the open source process works. Then you wait. If it's a high profile issue, it may get fixed quickly. But nobody is in charge of fixing bugs. If it lingers without resolution, please spend some more time investigating the problem. Ask about anything you don't understand related to the behaviour. You will learn more about how the software works and quite possibly figure out why it isn't working now. Ultimately it is somebody in the community who is going to fix this and you are a member of the community; and this is how the open source process works.
[b]In either case[/b] Other developers working to fix the problem may need to find out more, so do your homework and document what is happening and everything you've tried. Don't say "I did xyz and it didn't work." That doesn't tell us anything. Tell us precisely what steps you took and what you expected the result to be, and precisely what happened as a result. If there were any error messages, don't say "there was an error message". Tell us exactly what the message said. Tell us what version you're running and any other details that may be unique about your site configuration.
Other developers working to fix the problem may need to find out more, so do your homework and document what is happening and everything you've tried. Don't say "I did xyz and it didn't work." That doesn't tell us anything. Tell us precisely what steps you took and what you expected the result to be, and precisely what happened as a result. If there were any error messages, don't say "there was an error message". Tell us exactly what the message said.

View file

@ -26,9 +26,6 @@
[zrl=[baseurl]/help/git_for_non_developers]Git per a No-Desenvolupadors[/zrl] [zrl=[baseurl]/help/git_for_non_developers]Git per a No-Desenvolupadors[/zrl]
[zrl=[baseurl]/help/dev_beginner]Manual pas-a-pas per a desenvolupadors principiants[/zrl] [zrl=[baseurl]/help/dev_beginner]Manual pas-a-pas per a desenvolupadors principiants[/zrl]
[h3]Preguntes Més Freqüents (FAQ) Per Desenvolupadors[/h3]
[zrl=[baseurl]/help/faq_developers]FAQ Per Desenvoupadors[/zrl]
[h3]Recursos Externs[/h3] [h3]Recursos Externs[/h3]
[url=https://zothub.com/channel/one]Development Channel[/url] [url=https://zothub.com/channel/one]Development Channel[/url]
[url=https://federated.social/channel/postgres]Postgres-specific $Projectname Admin Support Channel[/url] [url=https://federated.social/channel/postgres]Postgres-specific $Projectname Admin Support Channel[/url]

View file

@ -25,9 +25,6 @@
[zrl=[baseurl]/help/git_for_non_developers]Git für Nicht-Entwickler[/zrl] [zrl=[baseurl]/help/git_for_non_developers]Git für Nicht-Entwickler[/zrl]
[zrl=[baseurl]/help/dev_beginner]Schritt-für-Schritt-Einführung für neue Entwickler[/zrl] [zrl=[baseurl]/help/dev_beginner]Schritt-für-Schritt-Einführung für neue Entwickler[/zrl]
[h3]Häufig gestellte Fragen für Entwickler[/h3]
[zrl=[baseurl]/help/faq_developers]FAQ für Entwickler[/zrl]
[h3]Externe Ressourcen[/h3] [h3]Externe Ressourcen[/h3]
[url=https://zothub.com/channel/one]Entwickler-Kanal[/url] [url=https://zothub.com/channel/one]Entwickler-Kanal[/url]
[url=https://federated.social/channel/postgres]Postgres-spezifischer Admin-Support-Kanal[/url] [url=https://federated.social/channel/postgres]Postgres-spezifischer Admin-Support-Kanal[/url]

View file

@ -26,9 +26,6 @@
[zrl=[baseurl]/help/git_for_non_developers]Git for Non-Developers[/zrl] [zrl=[baseurl]/help/git_for_non_developers]Git for Non-Developers[/zrl]
[zrl=[baseurl]/help/dev_beginner]Step-for-step manual for beginning developers[/zrl] [zrl=[baseurl]/help/dev_beginner]Step-for-step manual for beginning developers[/zrl]
[h3]Frequently Asked Questions For Developers[/h3]
[zrl=[baseurl]/help/faq_developers]FAQ For Developers[/zrl]
[h3]External Resources[/h3] [h3]External Resources[/h3]
[url=https://zothub.com/channel/one]Development Channel[/url] [url=https://zothub.com/channel/one]Development Channel[/url]
[url=https://federated.social/channel/postgres]Postgres-specific $Projectname Admin Support Channel[/url] [url=https://federated.social/channel/postgres]Postgres-specific $Projectname Admin Support Channel[/url]

View file

@ -12,10 +12,6 @@ Returns authenticated numeric channel_id if authenticated and connected to a cha
Returns authenticated string hash of Red global identifier, if authenticated via remote auth, or an empty string. Returns authenticated string hash of Red global identifier, if authenticated via remote auth, or an empty string.
[b]get_app()[/b]
Returns the global app structure ($a).
[b]App::get_observer()[/b] [b]App::get_observer()[/b]
returns an xchan structure representing the current viewer if authenticated (locally or remotely). returns an xchan structure representing the current viewer if authenticated (locally or remotely).

File diff suppressed because one or more lines are too long

View file

@ -67,9 +67,6 @@ Zot är en fantastisk ny kommunikationsprotokoll uppfunnit speciellt för $Proje
[zrl=[baseurl]/help/git_for_non_developers]Git for Non-Developers[/zrl] [zrl=[baseurl]/help/git_for_non_developers]Git for Non-Developers[/zrl]
[zrl=[baseurl]/help/dev_beginner]Sep-for-step manual for beginning developers[/zrl] [zrl=[baseurl]/help/dev_beginner]Sep-for-step manual for beginning developers[/zrl]
[h3]FAQ för utvecklare[/h3]
[zrl=[baseurl]/help/faq_developers]FAQ For Developers[/zrl]
[h3]Externa resurser[/h3] [h3]Externa resurser[/h3]
[zrl=[baseurl]/help/external-resource-links]External Resource Links[/zrl] [zrl=[baseurl]/help/external-resource-links]External Resource Links[/zrl]
[url=https://github.com/friendica/red]Main Website[/url] [url=https://github.com/friendica/red]Main Website[/url]

View file

@ -6,7 +6,6 @@ require_once('include/follow.php');
require_once('include/photo/photo_driver.php'); require_once('include/photo/photo_driver.php');
function import_diaspora($data) { function import_diaspora($data) {
$a = get_app();
$account = App::get_account(); $account = App::get_account();
if(! $account) if(! $account)

View file

@ -229,7 +229,7 @@ function verify_email_address($arr) {
$hash = random_string(); $hash = random_string();
$r = q("INSERT INTO register ( hash, created, uid, password, language ) VALUES ( '%s', '%s', %d, '%s', '%s' ) ", $r = q("INSERT INTO register ( hash, created, uid, password, lang ) VALUES ( '%s', '%s', %d, '%s', '%s' ) ",
dbesc($hash), dbesc($hash),
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval($arr['account']['account_id']), intval($arr['account']['account_id']),
@ -283,7 +283,7 @@ function send_reg_approval_email($arr) {
$hash = random_string(); $hash = random_string();
$r = q("INSERT INTO register ( hash, created, uid, password, language ) VALUES ( '%s', '%s', %d, '%s', '%s' ) ", $r = q("INSERT INTO register ( hash, created, uid, password, lang ) VALUES ( '%s', '%s', %d, '%s', '%s' ) ",
dbesc($hash), dbesc($hash),
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval($arr['account']['account_id']), intval($arr['account']['account_id']),
@ -387,7 +387,7 @@ function account_allow($hash) {
intval($register[0]['uid']) intval($register[0]['uid'])
); );
push_lang($register[0]['language']); push_lang($register[0]['lang']);
$email_tpl = get_intltext_template("register_open_eml.tpl"); $email_tpl = get_intltext_template("register_open_eml.tpl");
$email_tpl = replace_macros($email_tpl, array( $email_tpl = replace_macros($email_tpl, array(
@ -656,7 +656,8 @@ function account_service_class_allows($aid, $property, $usage = false) {
* @todo Should we merge this with account_service_class_fetch()? * @todo Should we merge this with account_service_class_fetch()?
*/ */
function service_class_fetch($uid, $property) { function service_class_fetch($uid, $property) {
$a = get_app();
if($uid == local_channel()) { if($uid == local_channel()) {
$service_class = App::$account['account_service_class']; $service_class = App::$account['account_service_class'];
} }

View file

@ -11,13 +11,11 @@ require_once("include/PermissionDescription.php");
function group_select($selname,$selclass,$preselected = false,$size = 4) { function group_select($selname,$selclass,$preselected = false,$size = 4) {
$a = get_app();
$o = ''; $o = '';
$o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\" >\r\n"; $o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\" >\r\n";
$r = q("SELECT * FROM `groups` WHERE `deleted` = 0 AND `uid` = %d ORDER BY `name` ASC", $r = q("SELECT * FROM `groups` WHERE `deleted` = 0 AND `uid` = %d ORDER BY `gname` ASC",
intval(local_channel()) intval(local_channel())
); );
@ -34,7 +32,7 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) {
$selected = " selected=\"selected\" "; $selected = " selected=\"selected\" ";
else else
$selected = ''; $selected = '';
$trimmed = mb_substr($rr['name'],0,12); $trimmed = mb_substr($rr['gname'],0,12);
$o .= "<option value=\"{$rr['id']}\" $selected title=\"{$rr['name']}\" >$trimmed</option>\r\n"; $o .= "<option value=\"{$rr['id']}\" $selected title=\"{$rr['name']}\" >$trimmed</option>\r\n";
} }
@ -51,7 +49,6 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) {
/* MicMee 20130114 function contact_selector no longer in use, sql table contact does no longer exist /* MicMee 20130114 function contact_selector no longer in use, sql table contact does no longer exist
function contact_selector($selname, $selclass, $preselected = false, $options) { function contact_selector($selname, $selclass, $preselected = false, $options) {
$a = get_app();
$mutual = false; $mutual = false;
$networks = null; $networks = null;
@ -157,7 +154,6 @@ function contact_selector($selname, $selclass, $preselected = false, $options) {
function contact_select($selname, $selclass, $preselected = false, $size = 4, $privmail = false, $celeb = false, $privatenet = false, $tabindex = null) { function contact_select($selname, $selclass, $preselected = false, $size = 4, $privmail = false, $celeb = false, $privatenet = false, $tabindex = null) {
$a = get_app();
$o = ''; $o = '';
@ -270,7 +266,6 @@ function populate_acl($defaults = null,$show_jotnets = true, $emptyACL_descripti
$o = replace_macros($tpl, array( $o = replace_macros($tpl, array(
'$showall' => $showall_caption, '$showall' => $showall_caption,
'$onlyme' => t('Only me'), '$onlyme' => t('Only me'),
'$add_others' => t('Add others'),
'$showallOrigin' => $showall_origin, '$showallOrigin' => $showall_origin,
'$showallIcon' => $showall_icon, '$showallIcon' => $showall_icon,
'$select_label' => t('Who can see this?'), '$select_label' => t('Who can see this?'),

View file

@ -1,7 +1,6 @@
<?php /** @file */ <?php /** @file */
function profile_activity($changed, $value) { function profile_activity($changed, $value) {
$a = get_app();
if(! local_channel() || ! is_array($changed) || ! count($changed)) if(! local_channel() || ! is_array($changed) || ! count($changed))
return; return;

View file

@ -368,7 +368,7 @@ require_once('include/api_auth.php');
else else
$redirect = trim($_REQUEST['redirect_uris']); $redirect = trim($_REQUEST['redirect_uris']);
$icon = trim($_REQUEST['logo_uri']); $icon = trim($_REQUEST['logo_uri']);
$r = q("INSERT INTO clients (client_id, pw, name, redirect_uri, icon, uid) $r = q("INSERT INTO clients (client_id, pw, clname, redirect_uri, icon, uid)
VALUES ('%s','%s','%s','%s','%s',%d)", VALUES ('%s','%s','%s','%s','%s',%d)",
dbesc($key), dbesc($key),
dbesc($secret), dbesc($secret),
@ -451,8 +451,6 @@ require_once('include/api_auth.php');
*/ */
function api_apply_template($templatename, $type, $data){ function api_apply_template($templatename, $type, $data){
$a = get_app();
switch($type){ switch($type){
case "atom": case "atom":
case "rss": case "rss":
@ -1904,7 +1902,6 @@ require_once('include/api_auth.php');
//logger('api_format_items: ' . print_r($user_info,true)); //logger('api_format_items: ' . print_r($user_info,true));
$a = get_app();
$ret = array(); $ret = array();
if(! $r) if(! $r)

View file

@ -479,8 +479,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 '';

View file

@ -168,7 +168,7 @@ function bb_parse_app($match) {
$app = Zotlabs\Lib\Apps::app_decode($match[1]); $app = Zotlabs\Lib\Apps::app_decode($match[1]);
if ($app) if ($app)
return Zotlab\Lib\Apps::app_render($app); return Zotlabs\Lib\Apps::app_render($app);
} }
function bb_parse_element($match) { function bb_parse_element($match) {
@ -275,7 +275,6 @@ function bb_location($match) {
* @return string HTML iframe with content of $match[1] * @return string HTML iframe with content of $match[1]
*/ */
function bb_iframe($match) { function bb_iframe($match) {
$a = get_app();
$sandbox = ((strpos($match[1], App::get_hostname())) ? ' sandbox="allow-scripts" ' : ''); $sandbox = ((strpos($match[1], App::get_hostname())) ? ' sandbox="allow-scripts" ' : '');
@ -449,8 +448,6 @@ function bb_sanitize_style($input) {
function bb_observer($Text) { function bb_observer($Text) {
$a = get_app();
$observer = App::get_observer(); $observer = App::get_observer();
if ((strpos($Text,'[/observer]') !== false) || (strpos($Text,'[/rpost]') !== false)) { if ((strpos($Text,'[/observer]') !== false) || (strpos($Text,'[/rpost]') !== false)) {
@ -480,9 +477,12 @@ function bb_observer($Text) {
return $Text; return $Text;
} }
function bb_code($match) {
if(strpos($match[0], "<br />"))
return '<code>' . trim($match[1]) . '</code>';
else
return '<code class="inline-code">' . trim($match[1]) . '</code>';
}
@ -788,12 +788,9 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false)
$Text = preg_replace("/\[font=(.*?)\](.*?)\[\/font\]/sm", "<span style=\"font-family: $1;\">$2</span>", $Text); $Text = preg_replace("/\[font=(.*?)\](.*?)\[\/font\]/sm", "<span style=\"font-family: $1;\">$2</span>", $Text);
} }
// Declare the format for [code] layout
$CodeLayout = '<code>$1</code>';
// Check for [code] text // Check for [code] text
if (strpos($Text,'[code]') !== false) { if (strpos($Text,'[code]') !== false) {
$Text = preg_replace("/\[code\](.*?)\[\/code\]/ism", "$CodeLayout", $Text); $Text = preg_replace_callback("/\[code\](.*?)\[\/code\]/ism", 'bb_code', $Text);
} }
// Check for [spoiler] text // Check for [spoiler] text
@ -984,6 +981,7 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false)
$Text = preg_replace("/\[event\-summary\](.*?)\[\/event\-summary\]/ism",'',$Text); $Text = preg_replace("/\[event\-summary\](.*?)\[\/event\-summary\]/ism",'',$Text);
$Text = preg_replace("/\[event\-description\](.*?)\[\/event\-description\]/ism",'',$Text); $Text = preg_replace("/\[event\-description\](.*?)\[\/event\-description\]/ism",'',$Text);
$Text = preg_replace("/\[event\-finish\](.*?)\[\/event\-finish\]/ism",'',$Text); $Text = preg_replace("/\[event\-finish\](.*?)\[\/event\-finish\]/ism",'',$Text);
$Text = preg_replace("/\[event\-id\](.*?)\[\/event\-id\]/ism",'',$Text);
$Text = preg_replace("/\[event\-location\](.*?)\[\/event\-location\]/ism",'',$Text); $Text = preg_replace("/\[event\-location\](.*?)\[\/event\-location\]/ism",'',$Text);
$Text = preg_replace("/\[event\-adjust\](.*?)\[\/event\-adjust\]/ism",'',$Text); $Text = preg_replace("/\[event\-adjust\](.*?)\[\/event\-adjust\]/ism",'',$Text);

View file

@ -337,7 +337,7 @@ function create_identity($arr) {
// Not checking return value. // Not checking return value.
// It's ok for this to fail if it's an imported channel, and therefore the hash is a duplicate // It's ok for this to fail if it's an imported channel, and therefore the hash is a duplicate
$r = q("INSERT INTO profile ( aid, uid, profile_guid, profile_name, is_default, publish, name, photo, thumb) $r = q("INSERT INTO profile ( aid, uid, profile_guid, profile_name, is_default, publish, fullname, photo, thumb)
VALUES ( %d, %d, '%s', '%s', %d, %d, '%s', '%s', '%s') ", VALUES ( %d, %d, '%s', '%s', %d, %d, '%s', '%s', '%s') ",
intval($ret['channel']['channel_account_id']), intval($ret['channel']['channel_account_id']),
intval($newuid), intval($newuid),
@ -392,7 +392,7 @@ function create_identity($arr) {
// if our role_permissions indicate that we're using a default collection ACL, add it. // if our role_permissions indicate that we're using a default collection ACL, add it.
if(is_array($role_permissions) && $role_permissions['default_collection']) { if(is_array($role_permissions) && $role_permissions['default_collection']) {
$r = q("select hash from groups where uid = %d and name = '%s' limit 1", $r = q("select hash from groups where uid = %d and gname = '%s' limit 1",
intval($newuid), intval($newuid),
dbesc( t('Friends') ) dbesc( t('Friends') )
); );
@ -561,7 +561,7 @@ function identity_basic_export($channel_id, $items = false) {
// All other term types will be included in items, if requested. // All other term types will be included in items, if requested.
$r = q("select * from term where type in (%d,%d) and uid = %d", $r = q("select * from term where ttype in (%d,%d) and uid = %d",
intval(TERM_SAVEDSEARCH), intval(TERM_SAVEDSEARCH),
intval(TERM_THING), intval(TERM_THING),
intval($channel_id) intval($channel_id)
@ -1257,7 +1257,7 @@ function advanced_profile(&$a) {
if(! perm_is_allowed(App::$profile['profile_uid'],get_observer_hash(),'view_profile')) if(! perm_is_allowed(App::$profile['profile_uid'],get_observer_hash(),'view_profile'))
return ''; return '';
if(App::$profile['name']) { if(App::$profile['fullname']) {
$profile_fields_basic = get_profile_fields_basic(); $profile_fields_basic = get_profile_fields_basic();
$profile_fields_advanced = get_profile_fields_advanced(); $profile_fields_advanced = get_profile_fields_advanced();
@ -1281,7 +1281,7 @@ function advanced_profile(&$a) {
$profile = array(); $profile = array();
$profile['fullname'] = array( t('Full Name:'), App::$profile['name'] ) ; $profile['fullname'] = array( t('Full Name:'), App::$profile['fullname'] ) ;
if(App::$profile['gender']) $profile['gender'] = array( t('Gender:'), App::$profile['gender'] ); if(App::$profile['gender']) $profile['gender'] = array( t('Gender:'), App::$profile['gender'] );
@ -1329,8 +1329,8 @@ function advanced_profile(&$a) {
if(App::$profile['marital']) if(App::$profile['marital'])
$profile['marital'] = array( t('Status:'), App::$profile['marital']); $profile['marital'] = array( t('Status:'), App::$profile['marital']);
if(App::$profile['with']) if(App::$profile['partner'])
$profile['marital']['with'] = bbcode(App::$profile['with']); $profile['marital']['partner'] = bbcode(App::$profile['partner']);
if(strlen(App::$profile['howlong']) && App::$profile['howlong'] !== NULL_DATE) { if(strlen(App::$profile['howlong']) && App::$profile['howlong'] !== NULL_DATE) {
$profile['howlong'] = relative_date(App::$profile['howlong'], t('for %1$d %2$s')); $profile['howlong'] = relative_date(App::$profile['howlong'], t('for %1$d %2$s'));
@ -1370,7 +1370,7 @@ function advanced_profile(&$a) {
if($txt = prepare_text(App::$profile['romance'])) $profile['romance'] = array( t('Love/Romance:'), $txt); if($txt = prepare_text(App::$profile['romance'])) $profile['romance'] = array( t('Love/Romance:'), $txt);
if($txt = prepare_text(App::$profile['work'])) $profile['work'] = array( t('Work/employment:'), $txt); if($txt = prepare_text(App::$profile['employment'])) $profile['employment'] = array( t('Work/employment:'), $txt);
if($txt = prepare_text(App::$profile['education'])) $profile['education'] = array( t('School/education:'), $txt ); if($txt = prepare_text(App::$profile['education'])) $profile['education'] = array( t('School/education:'), $txt );
@ -1658,7 +1658,7 @@ function get_profile_fields_basic($filter = 0) {
$profile_fields_basic = (($filter == 0) ? get_config('system','profile_fields_basic') : null); $profile_fields_basic = (($filter == 0) ? get_config('system','profile_fields_basic') : null);
if(! $profile_fields_basic) if(! $profile_fields_basic)
$profile_fields_basic = array('name','pdesc','chandesc','gender','dob','dob_tz','address','locality','region','postal_code','country_name','marital','sexual','homepage','hometown','keywords','about','contact'); $profile_fields_basic = array('fullname','pdesc','chandesc','gender','dob','dob_tz','address','locality','region','postal_code','country_name','marital','sexual','homepage','hometown','keywords','about','contact');
$x = array(); $x = array();
if($profile_fields_basic) if($profile_fields_basic)
@ -1673,7 +1673,7 @@ function get_profile_fields_advanced($filter = 0) {
$basic = get_profile_fields_basic($filter); $basic = get_profile_fields_basic($filter);
$profile_fields_advanced = (($filter == 0) ? get_config('system','profile_fields_advanced') : null); $profile_fields_advanced = (($filter == 0) ? get_config('system','profile_fields_advanced') : null);
if(! $profile_fields_advanced) if(! $profile_fields_advanced)
$profile_fields_advanced = array('with','howlong','politic','religion','likes','dislikes','interest','channels','music','book','film','tv','romance','work','education'); $profile_fields_advanced = array('partner','howlong','politic','religion','likes','dislikes','interest','channels','music','book','film','tv','romance','employment','education');
$x = array(); $x = array();
if($basic) if($basic)
@ -1945,3 +1945,26 @@ function get_zcard_embed($channel,$observer_hash = '',$args = array()) {
return $o; return $o;
} }
function channelx_by_nick($nick) {
$r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_address = '%s' and channel_removed = 0 LIMIT 1",
dbesc($nick)
);
return(($r) ? $r[0] : false);
}
function channelx_by_hash($hash) {
$r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_hash = '%s' and channel_removed = 0 LIMIT 1",
dbesc($hash)
);
return(($r) ? $r[0] : false);
}
function channelx_by_n($id) {
$r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_id = %d and channel_removed = 0 LIMIT 1",
dbesc($id)
);
return(($r) ? $r[0] : false);
}

View file

@ -6,37 +6,7 @@ require_once('boot.php');
function cli_startup() { function cli_startup() {
global $a, $db, $default_timezone; sys_boot();
if(is_null($a)) {
$a = new miniApp;
}
App::init();
if(is_null($db)) {
@include(".htconfig.php");
$a->convert();
if(! defined('UNO'))
define('UNO', 0);
App::$timezone = ((x($default_timezone)) ? $default_timezone : 'UTC');
date_default_timezone_set(App::$timezone);
require_once('include/dba/dba_driver.php');
$db = dba_factory($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type);
unset($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type);
};
App::$session = new Zotlabs\Web\Session();
App::$session->init();
load_config('system');
App::set_baseurl(get_config('system','baseurl')); App::set_baseurl(get_config('system','baseurl'));
load_hooks();
} }

View file

@ -1,17 +1,13 @@
<?php <?php
/** /**
* @file include/config.php * @file include/config.php
* @brief Arbitrary configuration storage. * @brief Arbitrary configuration storage.
* *
* @note Please do not store booleans - convert to 0/1 integer values. * Arrays get stored as serialized strings.
* The get_?config() functions return boolean false for keys that are unset, * Booleans are stored as integer 0/1.
* and this could lead to subtle bugs.
*
* Arrays get stored as serialize strings.
*
* @todo There are a few places in the code (such as the admin panel) where
* boolean configurations need to be fixed as of 10/08/2011.
* *
* - <b>config</b> is used for hub specific configurations. It overrides the * - <b>config</b> is used for hub specific configurations. It overrides the
* configurations from .htconfig file. The storage is of size TEXT. * configurations from .htconfig file. The storage is of size TEXT.
* - <b>pconfig</b> is used for channel specific configurations and takes a * - <b>pconfig</b> is used for channel specific configurations and takes a
@ -34,165 +30,39 @@
* *
*/ */
/**
* @brief Loads the hub's configuration from database to a cached storage. use Zotlabs\Lib as Zlib;
*
* Retrieve a category ($family) of config variables from database to a cached
* storage in the global App::$config[$family].
*
* @param string $family
* The category of the configuration value
*/
function load_config($family) { function load_config($family) {
global $a;
if(! array_key_exists($family, App::$config)) Zlib\Config::Load($family);
App::$config[$family] = array();
if(! array_key_exists('config_loaded', App::$config[$family])) {
$r = q("SELECT * FROM config WHERE cat = '%s'", dbesc($family));
if($r !== false) {
if($r) {
foreach($r as $rr) {
$k = $rr['k'];
App::$config[$family][$k] = $rr['v'];
}
}
App::$config[$family]['config_loaded'] = true;
}
}
} }
/**
* @brief Get a particular config variable given the category name ($family)
* and a key.
*
* Get a particular config variable from the given category ($family) and the
* $key from a cached storage in App::$config[$family]. If a key is found in the
* DB but does not exist in local config cache, pull it into the cache so we
* do not have to hit the DB again for this item.
*
* Returns false if not set.
*
* @param string $family
* The category of the configuration value
* @param string $key
* The configuration key to query
* @return mixed Return value or false on error or if not set
*/
function get_config($family, $key) { function get_config($family, $key) {
global $a;
if((! array_key_exists($family, App::$config)) || (! array_key_exists('config_loaded', App::$config[$family]))) return Zlib\Config::Get($family,$key);
load_config($family);
if(array_key_exists('config_loaded', App::$config[$family])) {
if(! array_key_exists($key, App::$config[$family])) {
return false;
}
return ((! is_array(App::$config[$family][$key])) && (preg_match('|^a:[0-9]+:{.*}$|s', App::$config[$family][$key]))
? unserialize(App::$config[$family][$key])
: App::$config[$family][$key]
);
}
return false;
} }
/**
* @brief Returns a value directly from the database configuration storage.
*
* This function queries directly the database and bypasses the chached storage
* from get_config($family, $key).
*
* @param string $family
* The category of the configuration value
* @param string $key
* The configuration key to query
* @return mixed
*/
function get_config_from_storage($family, $key) {
$ret = q("SELECT * FROM config WHERE cat = '%s' AND k = '%s' LIMIT 1",
dbesc($family),
dbesc($key)
);
return $ret;
}
/**
* @brief Sets a configuration value for the hub.
*
* Stores a config value ($value) in the category ($family) under the key ($key).
*
* @note Please do not store booleans - convert to 0/1 integer values!
*
* @param string $family
* The category of the configuration value
* @param string $key
* The configuration key to set
* @param mixed $value
* The value to store in the configuration
* @return mixed
* Return the set value, or false if the database update failed
*/
function set_config($family, $key, $value) { function set_config($family, $key, $value) {
global $a;
// manage array value return Zlib\Config::Set($family,$key,$value);
$dbvalue = ((is_array($value)) ? serialize($value) : $value);
$dbvalue = ((is_bool($dbvalue)) ? intval($dbvalue) : $dbvalue);
if(get_config($family, $key) === false || (! get_config_from_storage($family, $key))) {
$ret = q("INSERT INTO config ( cat, k, v ) VALUES ( '%s', '%s', '%s' ) ",
dbesc($family),
dbesc($key),
dbesc($dbvalue)
);
if($ret) {
App::$config[$family][$key] = $value;
$ret = $value;
}
return $ret;
} }
$ret = q("UPDATE config SET v = '%s' WHERE cat = '%s' AND k = '%s'",
dbesc($dbvalue),
dbesc($family),
dbesc($key)
);
if($ret) {
App::$config[$family][$key] = $value;
$ret = $value;
}
return $ret;
}
/**
* @brief Deletes the given key from the hub's configuration database.
*
* Removes the configured value from the stored cache in App::$config[$family]
* and removes it from the database.
*
* @param string $family
* The category of the configuration value
* @param string $key
* The configuration key to delete
* @return mixed
*/
function del_config($family, $key) { function del_config($family, $key) {
global $a;
$ret = false;
if(array_key_exists($family, App::$config) && array_key_exists($key, App::$config[$family])) return Zlib\Config::Delete($family,$key);
unset(App::$config[$family][$key]);
$ret = q("DELETE FROM config WHERE cat = '%s' AND k = '%s'",
dbesc($family),
dbesc($key)
);
return $ret;
} }
/** /**
* @brief Loads all configuration values of a channel into a cached storage. * @brief Loads all configuration values of a channel into a cached storage.
* *
@ -203,8 +73,8 @@ function del_config($family, $key) {
* The channel_id * The channel_id
* @return void|false Nothing or false if $uid is false * @return void|false Nothing or false if $uid is false
*/ */
function load_pconfig($uid) { function load_pconfig($uid) {
global $a;
if($uid === false) if($uid === false)
return false; return false;
@ -249,7 +119,6 @@ function load_pconfig($uid) {
*/ */
function get_pconfig($uid, $family, $key, $instore = false) { function get_pconfig($uid, $family, $key, $instore = false) {
// logger('include/config.php: get_pconfig() deprecated instore param used', LOGGER_DEBUG); // logger('include/config.php: get_pconfig() deprecated instore param used', LOGGER_DEBUG);
global $a;
if($uid === false) if($uid === false)
return false; return false;
@ -285,7 +154,6 @@ function get_pconfig($uid, $family, $key, $instore = false) {
* @return mixed Stored $value or false * @return mixed Stored $value or false
*/ */
function set_pconfig($uid, $family, $key, $value) { function set_pconfig($uid, $family, $key, $value) {
global $a;
// this catches subtle errors where this function has been called // this catches subtle errors where this function has been called
// with local_channel() when not logged in (which returns false) // with local_channel() when not logged in (which returns false)
@ -372,7 +240,7 @@ function set_pconfig($uid, $family, $key, $value) {
* @return mixed * @return mixed
*/ */
function del_pconfig($uid, $family, $key) { function del_pconfig($uid, $family, $key) {
global $a;
$ret = false; $ret = false;
if (x(App::$config[$uid][$family], $key)) if (x(App::$config[$uid][$family], $key))
@ -398,7 +266,6 @@ function del_pconfig($uid, $family, $key) {
* @return void|false Returns false if xchan is not set * @return void|false Returns false if xchan is not set
*/ */
function load_xconfig($xchan) { function load_xconfig($xchan) {
global $a;
if(! $xchan) if(! $xchan)
return false; return false;
@ -441,7 +308,6 @@ function load_xconfig($xchan) {
* @return mixed Stored $value or false if it does not exist * @return mixed Stored $value or false if it does not exist
*/ */
function get_xconfig($xchan, $family, $key) { function get_xconfig($xchan, $family, $key) {
global $a;
if(! $xchan) if(! $xchan)
return false; return false;
@ -477,7 +343,6 @@ function get_xconfig($xchan, $family, $key) {
* @return mixed Stored $value or false * @return mixed Stored $value or false
*/ */
function set_xconfig($xchan, $family, $key, $value) { function set_xconfig($xchan, $family, $key, $value) {
global $a;
// manage array value // manage array value
$dbvalue = ((is_array($value)) ? serialize($value) : $value); $dbvalue = ((is_array($value)) ? serialize($value) : $value);
@ -530,7 +395,7 @@ function set_xconfig($xchan, $family, $key, $value) {
* @return mixed * @return mixed
*/ */
function del_xconfig($xchan, $family, $key) { function del_xconfig($xchan, $family, $key) {
global $a;
$ret = false; $ret = false;
if(x(App::$config[$xchan][$family], $key)) if(x(App::$config[$xchan][$family], $key))

View file

@ -48,32 +48,9 @@ function abook_self($channel_id) {
return(($r) ? $r[0] : array()); return(($r) ? $r[0] : array());
} }
function channelx_by_nick($nick) {
$r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_address = '%s' and channel_removed = 0 LIMIT 1",
dbesc($nick)
);
return(($r) ? $r[0] : false);
}
function channelx_by_hash($hash) {
$r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_hash = '%s' and channel_removed = 0 LIMIT 1",
dbesc($hash)
);
return(($r) ? $r[0] : false);
}
function channelx_by_n($id) {
$r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_id = %d and channel_removed = 0 LIMIT 1",
dbesc($id)
);
return(($r) ? $r[0] : false);
}
function vcard_from_xchan($xchan, $observer = null, $mode = '') { function vcard_from_xchan($xchan, $observer = null, $mode = '') {
$a = get_app();
if(! $xchan) { if(! $xchan) {
if(App::$poi) { if(App::$poi) {
$xchan = App::$poi; $xchan = App::$poi;
@ -267,7 +244,7 @@ function channel_remove($channel_id, $local = true, $unset_session=false) {
if(! $channel_id) if(! $channel_id)
return; return;
$a = get_app();
logger('Removing channel: ' . $channel_id); logger('Removing channel: ' . $channel_id);
logger('channel_remove: local only: ' . intval($local)); logger('channel_remove: local only: ' . intval($local));

View file

@ -39,7 +39,7 @@ function fileas_widget($baseurl,$selected = '') {
return ''; return '';
$terms = array(); $terms = array();
$r = q("select distinct(term) from term where uid = %d and type = %d order by term asc", $r = q("select distinct(term) from term where uid = %d and ttype = %d order by term asc",
intval(local_channel()), intval(local_channel()),
intval(TERM_FILE) intval(TERM_FILE)
); );
@ -72,7 +72,7 @@ function categories_widget($baseurl,$selected = '') {
from term join item on term.oid = item.id from term join item on term.oid = item.id
where item.uid = %d where item.uid = %d
and term.uid = item.uid and term.uid = item.uid
and term.type = %d and term.ttype = %d
and term.otype = %d and term.otype = %d
and item.owner_xchan = '%s' and item.owner_xchan = '%s'
and item.item_wall = 1 and item.item_wall = 1

View file

@ -858,8 +858,6 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
function best_link_url($item) { function best_link_url($item) {
$a = get_app();
$best_url = ''; $best_url = '';
$sparkle = false; $sparkle = false;
@ -888,7 +886,7 @@ function best_link_url($item) {
function item_photo_menu($item){ function item_photo_menu($item){
$a = get_app();
$contact = null; $contact = null;
$ssl_state = false; $ssl_state = false;
@ -1408,7 +1406,7 @@ function render_location_default($item) {
function prepare_page($item) { function prepare_page($item) {
$a = get_app();
$naked = 1; $naked = 1;
// $naked = ((get_pconfig($item['uid'],'system','nakedpage')) ? 1 : 0); // $naked = ((get_pconfig($item['uid'],'system','nakedpage')) ? 1 : 0);
$observer = App::get_observer(); $observer = App::get_observer();
@ -1442,7 +1440,7 @@ function prepare_page($item) {
function network_tabs() { function network_tabs() {
$a = get_app();
$no_active=''; $no_active='';
$starred_active = ''; $starred_active = '';
$new_active = ''; $new_active = '';

View file

@ -46,27 +46,15 @@ function pkcs5_unpad($text)
} }
function AES256CBC_encrypt($data,$key,$iv) { function AES256CBC_encrypt($data,$key,$iv) {
if(get_config('system','openssl_encrypt')) {
return openssl_encrypt($data,'aes-256-cbc',str_pad($key,32,"\0"),OPENSSL_RAW_DATA,str_pad($iv,16,"\0")); return openssl_encrypt($data,'aes-256-cbc',str_pad($key,32,"\0"),OPENSSL_RAW_DATA,str_pad($iv,16,"\0"));
}
return mcrypt_encrypt(
MCRYPT_RIJNDAEL_128,
str_pad($key,32,"\0"),
pkcs5_pad($data,16),
MCRYPT_MODE_CBC,
str_pad($iv,16,"\0"));
} }
function AES256CBC_decrypt($data,$key,$iv) { function AES256CBC_decrypt($data,$key,$iv) {
if(get_config('system','openssl_encrypt')) {
return openssl_decrypt($data,'aes-256-cbc',str_pad($key,32,"\0"),OPENSSL_RAW_DATA,str_pad($iv,16,"\0")); return openssl_decrypt($data,'aes-256-cbc',str_pad($key,32,"\0"),OPENSSL_RAW_DATA,str_pad($iv,16,"\0"));
}
return pkcs5_unpad(mcrypt_decrypt(
MCRYPT_RIJNDAEL_128,
str_pad($key,32,"\0"),
$data,
MCRYPT_MODE_CBC,
str_pad($iv,16,"\0")));
} }
function crypto_encapsulate($data,$pubkey,$alg='aes256cbc') { function crypto_encapsulate($data,$pubkey,$alg='aes256cbc') {

View file

@ -119,7 +119,6 @@ function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d
* @return string * @return string
*/ */
function dob($dob) { function dob($dob) {
$a = get_app();
list($year, $month, $day) = sscanf($dob, '%4d-%2d-%2d'); list($year, $month, $day) = sscanf($dob, '%4d-%2d-%2d');
$f = get_config('system', 'birthday_input_format'); $f = get_config('system', 'birthday_input_format');

View file

@ -1,4 +1,7 @@
<?php <?php
class DBA {
/** /**
* @file dba_driver.php * @file dba_driver.php
* @brief some database related functions and abstract driver class. * @brief some database related functions and abstract driver class.
@ -7,6 +10,10 @@
* functions for working with databases. * functions for working with databases.
*/ */
static public $dba = null;
static public $dbtype = null;
static public $logging = false;
/** /**
* @brief Returns the database driver object. * @brief Returns the database driver object.
* *
@ -21,27 +28,30 @@
* @param bool $install Defaults to false * @param bool $install Defaults to false
* @return null|dba_driver A database driver object (dba_mysql|dba_mysqli) or null if no driver found. * @return null|dba_driver A database driver object (dba_mysql|dba_mysqli) or null if no driver found.
*/ */
function dba_factory($server, $port,$user,$pass,$db,$dbtype,$install = false) {
$dba = null;
$dbtype = intval($dbtype); static public function dba_factory($server, $port,$user,$pass,$db,$dbtype,$install = false) {
self::$dba = null;
self::$dbtype = intval($dbtype);
$set_port = $port; $set_port = $port;
if($dbtype == DBTYPE_POSTGRES) { if(self::$dbtype == DBTYPE_POSTGRES) {
require_once('include/dba/dba_postgres.php'); require_once('include/dba/dba_postgres.php');
if(is_null($port)) $set_port = 5432; if(is_null($port)) $set_port = 5432;
$dba = new dba_postgres($server, $set_port, $user, $pass, $db, $install); self::$dba = new dba_postgres($server, $set_port, $user, $pass, $db, $install);
} else { }
else {
// Highly experimental at the present time. // Highly experimental at the present time.
// require_once('include/dba/dba_pdo.php'); // require_once('include/dba/dba_pdo.php');
// $dba = new dba_pdo($server, $set_port,$user,$pass,$db,$install); // self::$dba = new dba_pdo($server, $set_port,$user,$pass,$db,$install);
// } // }
if(class_exists('mysqli')) { if(class_exists('mysqli')) {
if (is_null($port)) $set_port = ini_get("mysqli.default_port"); if (is_null($port)) $set_port = ini_get("mysqli.default_port");
require_once('include/dba/dba_mysqli.php'); require_once('include/dba/dba_mysqli.php');
$dba = new dba_mysqli($server, $set_port,$user,$pass,$db,$install); self::$dba = new dba_mysqli($server, $set_port,$user,$pass,$db,$install);
} }
} }
@ -51,16 +61,18 @@ function dba_factory($server, $port,$user,$pass,$db,$dbtype,$install = false) {
// third-party interfaces that are working and well tested. // third-party interfaces that are working and well tested.
if(is_object($dba) && $dba->connected) { if(is_object(self::$dba) && self::$dba->connected) {
$dns = (($dbtype == DBTYPE_POSTGRES) ? 'postgres' : 'mysql') $dns = ((self::$dbtype == DBTYPE_POSTGRES) ? 'postgres' : 'mysql')
. ':host=' . $server . (is_null($port) ? '' : ';port=' . $port) . ':host=' . $server . (is_null($port) ? '' : ';port=' . $port)
. ';dbname=' . $db; . ';dbname=' . $db;
$dba->pdo_set(array($dns,$user,$pass)); self::$dba->pdo_set(array($dns,$user,$pass));
}
define('NULL_DATE', self::$dba->get_null_date());
define('ACTIVE_DBTYPE', self::$dbtype);
return self::$dba;
} }
define('NULL_DATE', $dba->get_null_date());
define('ACTIVE_DBTYPE', $dbtype);
return $dba;
} }
/** /**
@ -232,8 +244,8 @@ function printable($s) {
function dbg($state) { function dbg($state) {
global $db; global $db;
if($db) if(\DBA::$dba)
$db->dbg($state); \DBA::$dba->dbg($state);
} }
/** /**
@ -247,21 +259,18 @@ function dbg($state) {
* @return Return an escaped string of the value to pass to a DB query. * @return Return an escaped string of the value to pass to a DB query.
*/ */
function dbesc($str) { function dbesc($str) {
global $db;
if($db && $db->connected) if(\DBA::$dba && \DBA::$dba->connected)
return($db->escape($str)); return(\DBA::$dba->escape($str));
else else
return(str_replace("'", "\\'", $str)); return(str_replace("'", "\\'", $str));
} }
function dbescbin($str) { function dbescbin($str) {
global $db; return \DBA::$dba->escapebin($str);
return $db->escapebin($str);
} }
function dbunescbin($str) { function dbunescbin($str) {
global $db; return \DBA::$dba->unescapebin($str);
return $db->unescapebin($str);
} }
function dbescdate($date) { function dbescdate($date) {
@ -274,36 +283,25 @@ function dbescdate($date) {
} }
function db_quoteinterval($txt) { function db_quoteinterval($txt) {
global $db; return \DBA::$dba->quote_interval($txt);
return $db->quote_interval($txt);
} }
function dbesc_identifier($str) { function dbesc_identifier($str) {
global $db; return \DBA::$dba->escape_identifier($str);
return $db->escape_identifier($str);
} }
function db_utcnow() { function db_utcnow() {
global $db; return \DBA::$dba->utcnow();
return $db->utcnow();
} }
function db_optimizetable($table) { function db_optimizetable($table) {
global $db; \DBA::$dba->optimize_table($table);
$db->optimize_table($table);
} }
function db_concat($fld, $sep) { function db_concat($fld, $sep) {
global $db; return \DBA::$dba->concat($fld, $sep);
return $db->concat($fld, $sep);
} }
// Function: q($sql,$args);
// Description: execute SQL query with printf style args.
// Example: $r = q("SELECT * FROM `%s` WHERE `uid` = %d",
// 'user', 1);
/** /**
* @brief Execute a SQL query with printf style args. * @brief Execute a SQL query with printf style args.
* *
@ -319,13 +317,13 @@ function db_concat($fld, $sep) {
* @param string $sql The SQL query to execute * @param string $sql The SQL query to execute
* @return bool|array * @return bool|array
*/ */
function q($sql) { function q($sql) {
global $db;
$args = func_get_args(); $args = func_get_args();
unset($args[0]); unset($args[0]);
if($db && $db->connected) { if(\DBA::$dba && \DBA::$dba->connected) {
$stmt = vsprintf($sql, $args); $stmt = vsprintf($sql, $args);
if($stmt === false) { if($stmt === false) {
if(version_compare(PHP_VERSION, '5.4.0') >= 0) if(version_compare(PHP_VERSION, '5.4.0') >= 0)
@ -334,13 +332,14 @@ function q($sql) {
else else
db_logger('dba: vsprintf error: ' . print_r(debug_backtrace(), true),LOGGER_NORMAL,LOG_CRIT); db_logger('dba: vsprintf error: ' . print_r(debug_backtrace(), true),LOGGER_NORMAL,LOG_CRIT);
} }
return $db->q($stmt); return \DBA::$dba->q($stmt);
} }
/* /*
* This will happen occasionally trying to store the * This will happen occasionally trying to store the
* session data after abnormal program termination * session data after abnormal program termination
*/ */
db_logger('dba: no database: ' . print_r($args,true),LOGGER_NORMAL,LOG_CRIT); db_logger('dba: no database: ' . print_r($args,true),LOGGER_NORMAL,LOG_CRIT);
return false; return false;
@ -354,10 +353,9 @@ function q($sql) {
* @param string $sql The SQL query to execute * @param string $sql The SQL query to execute
*/ */
function dbq($sql) { function dbq($sql) {
global $db;
if($db && $db->connected) if(\DBA::$dba && \DBA::$dba->connected)
$ret = $db->q($sql); $ret = \DBA::$dba->q($sql);
else else
$ret = false; $ret = false;
@ -418,13 +416,18 @@ function db_getfunc($f) {
// The logger function may make DB calls internally to query the system logging parameters. // The logger function may make DB calls internally to query the system logging parameters.
// This can cause a recursion if database debugging is enabled. // This can cause a recursion if database debugging is enabled.
// So this function preserves the current database debugging state and then turns it off while // So this function preserves the current database debugging state and then turns it off
// doing the logger() call // temporarily while doing the logger() call
function db_logger($s,$level = LOGGER_NORMAL,$syslog = LOG_INFO) { function db_logger($s,$level = LOGGER_NORMAL,$syslog = LOG_INFO) {
global $db;
$saved = $db->debug; if(\DBA::$logging)
$db->debug = false; return;
$saved = \DBA::$dba->debug;
\DBA::$dba->debug = false;
\DBA::$logging = true;
logger($s,$level,$syslog); logger($s,$level,$syslog);
$db->debug = $saved; \DBA::$logging = false;
\DBA::$dba->debug = $saved;
} }

View file

@ -94,6 +94,9 @@ function get_directory_setting($observer, $setting) {
if($ret === false) if($ret === false)
$ret = get_config('directory', $setting); $ret = get_config('directory', $setting);
// 'safemode' is the default if there is no observer or no established preference.
if($setting == 'safemode' && $ret === false) if($setting == 'safemode' && $ret === false)
$ret = 1; $ret = 1;

View file

@ -175,6 +175,9 @@ function format_event_bbcode($ev) {
if($ev['location']) if($ev['location'])
$o .= '[event-location]' . $ev['location'] . '[/event-location]'; $o .= '[event-location]' . $ev['location'] . '[/event-location]';
if($ev['event_hash'])
$o .= '[event-id]' . $ev['event_hash'] . '[/event-id]';
if($ev['adjust']) if($ev['adjust'])
$o .= '[event-adjust]' . $ev['adjust'] . '[/event-adjust]'; $o .= '[event-adjust]' . $ev['adjust'] . '[/event-adjust]';
@ -212,6 +215,9 @@ function bbtoevent($s) {
if(preg_match("/\[event\-location\](.*?)\[\/event\-location\]/is",$s,$match)) if(preg_match("/\[event\-location\](.*?)\[\/event\-location\]/is",$s,$match))
$ev['location'] = $match[1]; $ev['location'] = $match[1];
$match = ''; $match = '';
if(preg_match("/\[event\-id\](.*?)\[\/event\-id\]/is",$s,$match))
$ev['event_hash'] = $match[1];
$match = '';
if(preg_match("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is",$s,$match)) if(preg_match("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is",$s,$match))
$ev['adjust'] = $match[1]; $ev['adjust'] = $match[1];
if(array_key_exists('start',$ev)) { if(array_key_exists('start',$ev)) {
@ -278,34 +284,41 @@ function event_store_event($arr) {
else else
$arr['event_status_date'] = NULL_DATE; $arr['event_status_date'] = NULL_DATE;
// Existing event being modified
if($arr['id'] || $arr['event_hash']) { $existing_event = null;
// has the event actually changed?
if($arr['event_hash']) { if($arr['event_hash']) {
$r = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1", $r = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1",
dbesc($arr['event_hash']), dbesc($arr['event_hash']),
intval($arr['uid']) intval($arr['uid'])
); );
if($r) {
$existing_event = $r[0];
} }
else { }
if($arr['id']) {
$r = q("SELECT * FROM event WHERE id = %d AND uid = %d LIMIT 1", $r = q("SELECT * FROM event WHERE id = %d AND uid = %d LIMIT 1",
intval($arr['id']), intval($arr['id']),
intval($arr['uid']) intval($arr['uid'])
); );
if($r) {
$existing_event = $r[0];
} }
else {
if(! $r)
return false; return false;
}
if($r[0]['edited'] === $arr['edited']) {
// Nothing has changed. Return the ID.
return $r[0];
} }
$hash = $r[0]['event_hash'];
if($existing_event) {
if($existing_event['edited'] >= $arr['edited']) {
// Nothing has changed.
return $existing_event;
}
$hash = $existing_event['event_hash'];
// The event changed. Update it. // The event changed. Update it.
@ -350,7 +363,7 @@ function event_store_event($arr) {
dbesc($arr['allow_gid']), dbesc($arr['allow_gid']),
dbesc($arr['deny_cid']), dbesc($arr['deny_cid']),
dbesc($arr['deny_gid']), dbesc($arr['deny_gid']),
intval($r[0]['id']), intval($existing_event['id']),
intval($arr['uid']) intval($arr['uid'])
); );
} else { } else {
@ -360,6 +373,8 @@ function event_store_event($arr) {
if(array_key_exists('external_id',$arr)) if(array_key_exists('external_id',$arr))
$hash = $arr['external_id']; $hash = $arr['external_id'];
elseif(array_key_exists('event_hash',$arr))
$hash = $arr['event_hash'];
else else
$hash = random_string() . '@' . App::get_hostname(); $hash = random_string() . '@' . App::get_hostname();
@ -436,7 +451,7 @@ function event_addtocal($item_id, $uid) {
// is this an edit? // is this an edit?
if($item['resource_type'] === 'event') { if($item['resource_type'] === 'event' && (! $ev['event_hash'])) {
$ev['event_hash'] = $item['resource_id']; $ev['event_hash'] = $item['resource_id'];
} }
@ -472,7 +487,6 @@ function event_addtocal($item_id, $uid) {
if($z) { if($z) {
build_sync_packet($channel['channel_id'],array('event_item' => array(encode_item($sync_item[0],true)),'event' => $z)); build_sync_packet($channel['channel_id'],array('event_item' => array(encode_item($sync_item[0],true)),'event' => $z));
} }
return true; return true;
} }
} }
@ -764,6 +778,9 @@ function event_store_item($arr, $event) {
$prefix = ''; $prefix = '';
// $birthday = false; // $birthday = false;
if(($event) && array_key_exists('event_hash',$event) && (! array_key_exists('event_hash',$arr)))
$arr['event_hash'] = $event['event_hash'];
if($event['type'] === 'birthday') { if($event['type'] === 'birthday') {
if(! is_sys_channel($arr['uid'])) if(! is_sys_channel($arr['uid']))
$prefix = t('This event has been added to your calendar.'); $prefix = t('This event has been added to your calendar.');
@ -837,12 +854,12 @@ function event_store_item($arr, $event) {
if(($arr['term']) && (is_array($arr['term']))) { if(($arr['term']) && (is_array($arr['term']))) {
foreach($arr['term'] as $t) { foreach($arr['term'] as $t) {
q("insert into term (uid,oid,otype,type,term,url) q("insert into term (uid,oid,otype,ttype,term,url)
values(%d,%d,%d,%d,'%s','%s') ", values(%d,%d,%d,%d,'%s','%s') ",
intval($arr['uid']), intval($arr['uid']),
intval($r[0]['id']), intval($r[0]['id']),
intval(TERM_OBJ_POST), intval(TERM_OBJ_POST),
intval($t['type']), intval($t['ttype']),
dbesc($t['term']), dbesc($t['term']),
dbesc($t['url']) dbesc($t['url'])
); );

View file

@ -515,7 +515,7 @@ function get_atom_elements($feed, $item, &$author) {
if($termterm) { if($termterm) {
$terms[] = array( $terms[] = array(
'otype' => TERM_OBJ_POST, 'otype' => TERM_OBJ_POST,
'type' => $termtype, 'ttype' => $termtype,
'url' => $termurl, 'url' => $termurl,
'term' => $termterm, 'term' => $termterm,
); );

View file

@ -17,7 +17,6 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
$result = array('success' => false,'message' => ''); $result = array('success' => false,'message' => '');
$a = get_app();
$is_red = false; $is_red = false;
$is_http = ((strpos($url,'://') !== false) ? true : false); $is_http = ((strpos($url,'://') !== false) ? true : false);

View file

@ -18,7 +18,7 @@ function group_add($uid,$name,$public = 0) {
intval($r) intval($r)
); );
if(count($z) && $z[0]['deleted']) { if(count($z) && $z[0]['deleted']) {
/*$r = q("UPDATE `groups` SET `deleted` = 0 WHERE `uid` = %d AND `name` = '%s' LIMIT 1", /*$r = q("UPDATE `groups` SET `deleted` = 0 WHERE `uid` = %d AND `gname` = '%s' LIMIT 1",
intval($uid), intval($uid),
dbesc($name) dbesc($name)
);*/ );*/
@ -38,7 +38,7 @@ function group_add($uid,$name,$public = 0) {
} while($dups == true); } while($dups == true);
$r = q("INSERT INTO `groups` ( hash, uid, visible, name ) $r = q("INSERT INTO `groups` ( hash, uid, visible, gname )
VALUES( '%s', %d, %d, '%s' ) ", VALUES( '%s', %d, %d, '%s' ) ",
dbesc($hash), dbesc($hash),
intval($uid), intval($uid),
@ -57,7 +57,7 @@ function group_add($uid,$name,$public = 0) {
function group_rmv($uid,$name) { function group_rmv($uid,$name) {
$ret = false; $ret = false;
if(x($uid) && x($name)) { if(x($uid) && x($name)) {
$r = q("SELECT id, hash FROM `groups` WHERE `uid` = %d AND `name` = '%s' LIMIT 1", $r = q("SELECT id, hash FROM `groups` WHERE `uid` = %d AND `gname` = '%s' LIMIT 1",
intval($uid), intval($uid),
dbesc($name) dbesc($name)
); );
@ -108,7 +108,7 @@ function group_rmv($uid,$name) {
); );
// remove group // remove group
$r = q("UPDATE `groups` SET `deleted` = 1 WHERE `uid` = %d AND `name` = '%s'", $r = q("UPDATE `groups` SET `deleted` = 1 WHERE `uid` = %d AND `gname` = '%s'",
intval($uid), intval($uid),
dbesc($name) dbesc($name)
); );
@ -125,7 +125,7 @@ function group_rmv($uid,$name) {
function group_byname($uid,$name) { function group_byname($uid,$name) {
if((! $uid) || (! strlen($name))) if((! $uid) || (! strlen($name)))
return false; return false;
$r = q("SELECT * FROM `groups` WHERE `uid` = %d AND `name` = '%s' LIMIT 1", $r = q("SELECT * FROM `groups` WHERE `uid` = %d AND `gname` = '%s' LIMIT 1",
intval($uid), intval($uid),
dbesc($name) dbesc($name)
); );
@ -232,13 +232,13 @@ function mini_group_select($uid,$group = '') {
$grps = array(); $grps = array();
$o = ''; $o = '';
$r = q("SELECT * FROM `groups` WHERE `deleted` = 0 AND `uid` = %d ORDER BY `name` ASC", $r = q("SELECT * FROM `groups` WHERE `deleted` = 0 AND `uid` = %d ORDER BY `gname` ASC",
intval($uid) intval($uid)
); );
$grps[] = array('name' => '', 'hash' => '0', 'selected' => ''); $grps[] = array('name' => '', 'hash' => '0', 'selected' => '');
if(count($r)) { if(count($r)) {
foreach($r as $rr) { foreach($r as $rr) {
$grps[] = array('name' => $rr['name'], 'id' => $rr['hash'], 'selected' => (($group == $rr['hash']) ? 'true' : '')); $grps[] = array('name' => $rr['gname'], 'id' => $rr['hash'], 'selected' => (($group == $rr['hash']) ? 'true' : ''));
} }
} }
@ -271,7 +271,7 @@ function group_side($every="connections",$each="group",$edit = false, $group_id
); );
$r = q("SELECT * FROM `groups` WHERE `deleted` = 0 AND `uid` = %d ORDER BY `name` ASC", $r = q("SELECT * FROM `groups` WHERE `deleted` = 0 AND `uid` = %d ORDER BY `gname` ASC",
intval($_SESSION['uid']) intval($_SESSION['uid'])
); );
$member_of = array(); $member_of = array();
@ -296,7 +296,7 @@ function group_side($every="connections",$each="group",$edit = false, $group_id
'id' => $rr['id'], 'id' => $rr['id'],
'enc_cid' => base64url_encode($cid), 'enc_cid' => base64url_encode($cid),
'cid' => $cid, 'cid' => $cid,
'text' => $rr['name'], 'text' => $rr['gname'],
'selected' => $selected, 'selected' => $selected,
'href' => (($mode == 0) ? $each.'?f=&gid='.$rr['id'] : $each."/".$rr['id']) . ((x($_GET,'new')) ? '&new=' . $_GET['new'] : '') . ((x($_GET,'order')) ? '&order=' . $_GET['order'] : ''), 'href' => (($mode == 0) ? $each.'?f=&gid='.$rr['id'] : $each."/".$rr['id']) . ((x($_GET,'new')) ? '&new=' . $_GET['new'] : '') . ((x($_GET,'order')) ? '&order=' . $_GET['order'] : ''),
'edit' => $groupedit, 'edit' => $groupedit,
@ -340,7 +340,7 @@ function expand_groups($a) {
function member_of($c) { function member_of($c) {
$r = q("SELECT `groups`.`name`, `groups`.`id` FROM `groups` LEFT JOIN `group_member` ON `group_member`.`gid` = `groups`.`id` WHERE `group_member`.`xchan` = '%s' AND `groups`.`deleted` = 0 ORDER BY `groups`.`name` ASC ", $r = q("SELECT `groups`.`gname`, `groups`.`id` FROM `groups` LEFT JOIN `group_member` ON `group_member`.`gid` = `groups`.`id` WHERE `group_member`.`xchan` = '%s' AND `groups`.`deleted` = 0 ORDER BY `groups`.`gname` ASC ",
dbesc($c) dbesc($c)
); );

View file

@ -24,8 +24,6 @@ function find_doc_file($s) {
function search_doc_files($s) { function search_doc_files($s) {
$a = get_app();
$itemspage = get_pconfig(local_channel(),'system','itemspage'); $itemspage = get_pconfig(local_channel(),'system','itemspage');
\App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20)); \App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20));
$pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(\App::$pager['itemspage']), intval(\App::$pager['start'])); $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(\App::$pager['itemspage']), intval(\App::$pager['start']));

View file

@ -20,6 +20,8 @@ function import_channel($channel, $account_id, $seize) {
dbesc($channel['channel_hash']), dbesc($channel['channel_hash']),
dbesc($channel['channel_address']) dbesc($channel['channel_address'])
); );
if($r && $r[0]['channel_guid'] == $channel['channel_guid'] && $r[0]['channel_pubkey'] === $channel['channel_pubkey'] && $r[0]['channel_hash'] === $channel['channel_hash'])
return $r[0];
if(($r) || (check_webbie(array($channel['channel_address'])) !== $channel['channel_address'])) { if(($r) || (check_webbie(array($channel['channel_address'])) !== $channel['channel_address'])) {
if($r[0]['channel_guid'] === $channel['channel_guid'] || $r[0]['channel_hash'] === $channel['channel_hash']) { if($r[0]['channel_guid'] === $channel['channel_guid'] || $r[0]['channel_hash'] === $channel['channel_hash']) {
@ -330,7 +332,9 @@ function import_apps($channel,$apps) {
); );
if($x) { if($x) {
foreach($term as $t) { foreach($term as $t) {
store_item_tag($channel['channel_id'],$x[0]['id'],TERM_OBJ_APP,$t['type'],escape_tags($t['term']),escape_tags($t['url'])); if(array_key_exists('type',$t))
$t['ttype'] = $t['type'];
store_item_tag($channel['channel_id'],$x[0]['id'],TERM_OBJ_APP,$t['ttype'],escape_tags($t['term']),escape_tags($t['url']));
} }
} }
} }
@ -398,7 +402,9 @@ function sync_apps($channel,$apps) {
if($exists && $term) { if($exists && $term) {
foreach($term as $t) { foreach($term as $t) {
store_item_tag($channel['channel_id'],$exists['id'],TERM_OBJ_APP,$t['type'],escape_tags($t['term']),escape_tags($t['url'])); if(array_key_exists('type',$t))
$t['ttype'] = $t['type'];
store_item_tag($channel['channel_id'],$exists['id'],TERM_OBJ_APP,$t['ttype'],escape_tags($t['term']),escape_tags($t['url']));
} }
} }
@ -434,7 +440,9 @@ function sync_apps($channel,$apps) {
); );
if($x) { if($x) {
foreach($term as $t) { foreach($term as $t) {
store_item_tag($channel['channel_id'],$x[0]['id'],TERM_OBJ_APP,$t['type'],escape_tags($t['term']),escape_tags($t['url'])); if(array_key_exists('type',$t))
$t['ttype'] = $t['type'];
store_item_tag($channel['channel_id'],$x[0]['id'],TERM_OBJ_APP,$t['ttype'],escape_tags($t['term']),escape_tags($t['url']));
} }
} }
} }

View file

@ -6,6 +6,8 @@
// uncertain if this line is needed and why // uncertain if this line is needed and why
use Sabre\HTTP\URLUtil; use Sabre\HTTP\URLUtil;
use Zotlabs\Lib as Zlib;
require_once('include/bbcode.php'); require_once('include/bbcode.php');
require_once('include/oembed.php'); require_once('include/oembed.php');
require_once('include/crypto.php'); require_once('include/crypto.php');
@ -1180,8 +1182,8 @@ function encode_item_terms($terms,$mirror = false) {
if($terms) { if($terms) {
foreach($terms as $term) { foreach($terms as $term) {
if(in_array($term['type'],$allowed_export_terms)) if(in_array($term['ttype'],$allowed_export_terms))
$ret[] = array('tag' => $term['term'], 'url' => $term['url'], 'type' => termtype($term['type'])); $ret[] = array('tag' => $term['term'], 'url' => $term['url'], 'ttype' => termtype($term['type']));
} }
} }
@ -1238,39 +1240,41 @@ function decode_tags($t) {
$ret = array(); $ret = array();
foreach($t as $x) { foreach($t as $x) {
$tag = array(); $tag = array();
if(array_key_exists('type',$x))
$x['ttype'] = $x['type'];
$tag['term'] = htmlspecialchars($x['tag'], ENT_COMPAT, 'UTF-8', false); $tag['term'] = htmlspecialchars($x['tag'], ENT_COMPAT, 'UTF-8', false);
$tag['url'] = htmlspecialchars($x['url'], ENT_COMPAT, 'UTF-8', false); $tag['url'] = htmlspecialchars($x['url'], ENT_COMPAT, 'UTF-8', false);
switch($x['type']) { switch($x['ttype']) {
case 'hashtag': case 'hashtag':
$tag['type'] = TERM_HASHTAG; $tag['ttype'] = TERM_HASHTAG;
break; break;
case 'mention': case 'mention':
$tag['type'] = TERM_MENTION; $tag['ttype'] = TERM_MENTION;
break; break;
case 'category': case 'category':
$tag['type'] = TERM_CATEGORY; $tag['ttype'] = TERM_CATEGORY;
break; break;
case 'private_category': case 'private_category':
$tag['type'] = TERM_PCATEGORY; $tag['ttype'] = TERM_PCATEGORY;
break; break;
case 'file': case 'file':
$tag['type'] = TERM_FILE; $tag['ttype'] = TERM_FILE;
break; break;
case 'search': case 'search':
$tag['type'] = TERM_SEARCH; $tag['ttype'] = TERM_SEARCH;
break; break;
case 'thing': case 'thing':
$tag['type'] = TERM_THING; $tag['ttype'] = TERM_THING;
break; break;
case 'bookmark': case 'bookmark':
$tag['type'] = TERM_BOOKMARK; $tag['ttype'] = TERM_BOOKMARK;
break; break;
case 'communitytag': case 'communitytag':
$tag['type'] = TERM_COMMUNITYTAG; $tag['ttype'] = TERM_COMMUNITYTAG;
break; break;
default: default:
case 'unknown': case 'unknown':
$tag['type'] = TERM_UNKNOWN; $tag['ttype'] = TERM_UNKNOWN;
break; break;
} }
$ret[] = $tag; $ret[] = $tag;
@ -1853,12 +1857,12 @@ function item_store($arr, $allow_exec = false, $deliver = true) {
if(($terms) && (is_array($terms))) { if(($terms) && (is_array($terms))) {
foreach($terms as $t) { foreach($terms as $t) {
q("insert into term (uid,oid,otype,type,term,url) q("insert into term (uid,oid,otype,ttype,term,url)
values(%d,%d,%d,%d,'%s','%s') ", values(%d,%d,%d,%d,'%s','%s') ",
intval($arr['uid']), intval($arr['uid']),
intval($current_post), intval($current_post),
intval(TERM_OBJ_POST), intval(TERM_OBJ_POST),
intval($t['type']), intval($t['ttype']),
dbesc($t['term']), dbesc($t['term']),
dbesc($t['url']) dbesc($t['url'])
); );
@ -2132,12 +2136,12 @@ function item_store_update($arr,$allow_exec = false, $deliver = true) {
if(is_array($terms)) { if(is_array($terms)) {
foreach($terms as $t) { foreach($terms as $t) {
q("insert into term (uid,oid,otype,type,term,url) q("insert into term (uid,oid,otype,ttype,term,url)
values(%d,%d,%d,%d,'%s','%s') ", values(%d,%d,%d,%d,'%s','%s') ",
intval($uid), intval($uid),
intval($orig_post_id), intval($orig_post_id),
intval(TERM_OBJ_POST), intval(TERM_OBJ_POST),
intval($t['type']), intval($t['ttype']),
dbesc($t['term']), dbesc($t['term']),
dbesc($t['url']) dbesc($t['url'])
); );
@ -2284,8 +2288,8 @@ function send_status_notifications($post_id,$item) {
if(! $notify) if(! $notify)
return; return;
require_once('include/enotify.php');
notification(array( Zlib\Enotify::submit(array(
'type' => NOTIFY_COMMENT, 'type' => NOTIFY_COMMENT,
'from_xchan' => $item['author_xchan'], 'from_xchan' => $item['author_xchan'],
'to_xchan' => $r[0]['channel_hash'], 'to_xchan' => $r[0]['channel_hash'],
@ -2378,8 +2382,7 @@ function tag_deliver($uid, $item_id) {
$verb = urldecode(substr($item['verb'],strpos($item['verb'],'#')+1)); $verb = urldecode(substr($item['verb'],strpos($item['verb'],'#')+1));
if($poke_notify) { if($poke_notify) {
require_once('include/enotify.php'); Zlib\Enotify::submit(array(
notification(array(
'to_xchan' => $u[0]['channel_hash'], 'to_xchan' => $u[0]['channel_hash'],
'from_xchan' => $item['author_xchan'], 'from_xchan' => $item['author_xchan'],
'type' => NOTIFY_POKE, 'type' => NOTIFY_POKE,
@ -2544,8 +2547,7 @@ function tag_deliver($uid, $item_id) {
* Kill two birds with one stone. As long as we're here, send a mention notification. * Kill two birds with one stone. As long as we're here, send a mention notification.
*/ */
require_once('include/enotify.php'); Zlib\Enotify::submit(array(
notification(array(
'to_xchan' => $u[0]['channel_hash'], 'to_xchan' => $u[0]['channel_hash'],
'from_xchan' => $item['author_xchan'], 'from_xchan' => $item['author_xchan'],
'type' => NOTIFY_TAGSELF, 'type' => NOTIFY_TAGSELF,
@ -2720,7 +2722,7 @@ function start_delivery_chain($channel, $item, $item_id, $parent) {
foreach($tags as $tt) { foreach($tags as $tt) {
$tt = trim($tt); $tt = trim($tt);
if($tt) { if($tt) {
q("insert into term (uid,oid,otype,type,term,url) q("insert into term (uid,oid,otype,ttype,term,url)
values(%d,%d,%d,%d,'%s','%s') ", values(%d,%d,%d,%d,'%s','%s') ",
intval($channel['channel_id']), intval($channel['channel_id']),
intval($item_id), intval($item_id),
@ -2863,7 +2865,7 @@ function check_item_source($uid, $item) {
foreach($words as $word) { foreach($words as $word) {
if(substr($word,0,1) === '#' && $tags) { if(substr($word,0,1) === '#' && $tags) {
foreach($tags as $t) foreach($tags as $t)
if((($t['type'] == TERM_HASHTAG) || ($t['type'] == TERM_COMMUNITYTAG)) && (($t['term'] === substr($word,1)) || (substr($word,1) === '*'))) if((($t['ttype'] == TERM_HASHTAG) || ($t['ttype'] == TERM_COMMUNITYTAG)) && (($t['term'] === substr($word,1)) || (substr($word,1) === '*')))
return true; return true;
} }
elseif((strpos($word,'/') === 0) && preg_match($word,$text)) elseif((strpos($word,'/') === 0) && preg_match($word,$text))
@ -2916,7 +2918,7 @@ function post_is_importable($item,$abook) {
continue; continue;
if(substr($word,0,1) === '#' && $tags) { if(substr($word,0,1) === '#' && $tags) {
foreach($tags as $t) foreach($tags as $t)
if((($t['type'] == TERM_HASHTAG) || ($t['type'] == TERM_COMMUNITYTAG)) && (($t['term'] === substr($word,1)) || (substr($word,1) === '*'))) if((($t['ttype'] == TERM_HASHTAG) || ($t['ttype'] == TERM_COMMUNITYTAG)) && (($t['term'] === substr($word,1)) || (substr($word,1) === '*')))
return false; return false;
} }
elseif((strpos($word,'/') === 0) && preg_match($word,$text)) elseif((strpos($word,'/') === 0) && preg_match($word,$text))
@ -2937,7 +2939,7 @@ function post_is_importable($item,$abook) {
continue; continue;
if(substr($word,0,1) === '#' && $tags) { if(substr($word,0,1) === '#' && $tags) {
foreach($tags as $t) foreach($tags as $t)
if((($t['type'] == TERM_HASHTAG) || ($t['type'] == TERM_COMMUNITYTAG)) && (($t['term'] === substr($word,1)) || (substr($word,1) === '*'))) if((($t['ttype'] == TERM_HASHTAG) || ($t['ttype'] == TERM_COMMUNITYTAG)) && (($t['term'] === substr($word,1)) || (substr($word,1) === '*')))
return true; return true;
} }
elseif((strpos($word,'/') === 0) && preg_match($word,$text)) elseif((strpos($word,'/') === 0) && preg_match($word,$text))
@ -3046,7 +3048,6 @@ function mail_store($arr) {
); );
} }
else { else {
require_once('include/enotify.php');
$notif_params = array( $notif_params = array(
'from_xchan' => $arr['from_xchan'], 'from_xchan' => $arr['from_xchan'],
@ -3057,7 +3058,7 @@ function mail_store($arr) {
'otype' => 'mail' 'otype' => 'mail'
); );
notification($notif_params); Zlib\Enotify::submit($notif_params);
} }
call_hooks('post_mail_end',$arr); call_hooks('post_mail_end',$arr);
@ -3215,7 +3216,7 @@ function item_getfeedtags($item) {
if(count($terms)) { if(count($terms)) {
foreach($terms as $term) { foreach($terms as $term) {
if(($term['type'] == TERM_HASHTAG) || ($term['type'] == TERM_COMMUNITYTAG)) if(($term['ttype'] == TERM_HASHTAG) || ($term['ttype'] == TERM_COMMUNITYTAG))
$ret[] = array('#',$term['url'],$term['term']); $ret[] = array('#',$term['url'],$term['term']);
else else
$ret[] = array('@',$term['url'],$term['term']); $ret[] = array('@',$term['url'],$term['term']);
@ -3686,7 +3687,7 @@ function fetch_post_tags($items,$link = false) {
for($x = 0; $x < count($items); $x ++) { for($x = 0; $x < count($items); $x ++) {
if($tags) { if($tags) {
foreach($tags as $t) { foreach($tags as $t) {
if(($link) && ($t['type'] == TERM_MENTION)) if(($link) && ($t['ttype'] == TERM_MENTION))
$t['url'] = chanlink_url($t['url']); $t['url'] = chanlink_url($t['url']);
if(array_key_exists('item_id',$items[$x])) { if(array_key_exists('item_id',$items[$x])) {
if($t['oid'] == $items[$x]['item_id']) { if($t['oid'] == $items[$x]['item_id']) {
@ -3896,8 +3897,8 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C
} }
$contact_str = ''; $contact_str = '';
/** @FIXME $group is undefined */
$contacts = group_get_members($group); $contacts = group_get_members($r[0]['id']);
if ($contacts) { if ($contacts) {
foreach($contacts as $c) { foreach($contacts as $c) {
if($contact_str) if($contact_str)
@ -3914,7 +3915,7 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C
$sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND (( author_xchan IN ( $contact_str ) OR owner_xchan in ( $contact_str)) or allow_gid like '" . protect_sprintf('%<' . dbesc($r[0]['hash']) . '>%') . "' ) and id = parent $item_normal ) "; $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND (( author_xchan IN ( $contact_str ) OR owner_xchan in ( $contact_str)) or allow_gid like '" . protect_sprintf('%<' . dbesc($r[0]['hash']) . '>%') . "' ) and id = parent $item_normal ) ";
$x = group_rec_byhash($uid,$r[0]['hash']); $x = group_rec_byhash($uid,$r[0]['hash']);
$result['headline'] = sprintf( t('Privacy group: %s'),$x['name']); $result['headline'] = sprintf( t('Privacy group: %s'),$x['gname']);
} }
elseif($arr['cid'] && $uid) { elseif($arr['cid'] && $uid) {

View file

@ -82,13 +82,11 @@ function get_best_language() {
if($arr['preferred'] !== 'unset') if($arr['preferred'] !== 'unset')
return $arr['preferred']; return $arr['preferred'];
$a = get_app();
return ((isset(App::$config['system']['language'])) ? App::$config['system']['language'] : 'en'); return ((isset(App::$config['system']['language'])) ? App::$config['system']['language'] : 'en');
} }
function push_lang($language) { function push_lang($language) {
global $a;
App::$langsave = App::$language; App::$langsave = App::$language;
@ -104,7 +102,6 @@ function push_lang($language) {
} }
function pop_lang() { function pop_lang() {
global $a;
if(App::$language === App::$langsave) if(App::$language === App::$langsave)
return; return;
@ -124,7 +121,6 @@ function pop_lang() {
* @param boolean $install (optional) default false * @param boolean $install (optional) default false
*/ */
function load_translation_table($lang, $install = false) { function load_translation_table($lang, $install = false) {
global $a;
App::$strings = array(); App::$strings = array();
@ -136,10 +132,10 @@ function load_translation_table($lang, $install = false) {
} }
if(! $install) { if(! $install) {
$plugins = q("SELECT name FROM addon WHERE installed=1;"); $plugins = q("SELECT aname FROM addon WHERE installed=1;");
if ($plugins !== false) { if ($plugins !== false) {
foreach($plugins as $p) { foreach($plugins as $p) {
$name = $p['name']; $name = $p['aname'];
if(file_exists("addon/$name/lang/$lang/hstrings.php")) { if(file_exists("addon/$name/lang/$lang/hstrings.php")) {
include("addon/$name/lang/$lang/hstrings.php"); include("addon/$name/lang/$lang/hstrings.php");
} }
@ -170,7 +166,6 @@ function load_translation_table($lang, $install = false) {
* *
*/ */
function t($s, $ctx = '') { function t($s, $ctx = '') {
global $a;
$cs = $ctx ? '__ctx:' . $ctx . '__ ' . $s : $s; $cs = $ctx ? '__ctx:' . $ctx . '__ ' . $s : $s;
if (x(App::$strings, $cs)) { if (x(App::$strings, $cs)) {
@ -205,7 +200,6 @@ function translate_projectname($s) {
* @return string * @return string
*/ */
function tt($singular, $plural, $count, $ctx = ''){ function tt($singular, $plural, $count, $ctx = ''){
$a = get_app();
$cs = $ctx ? "__ctx:" . $ctx . "__ " . $singular : $singular; $cs = $ctx ? "__ctx:" . $ctx . "__ " . $singular : $singular;
if (x(App::$strings,$cs)) { if (x(App::$strings,$cs)) {

View file

@ -595,8 +595,6 @@ function parse_xml_string($s,$strict = true) {
function scale_external_images($s, $include_link = true, $scale_replace = false) { function scale_external_images($s, $include_link = true, $scale_replace = false) {
$a = get_app();
// Picture addresses can contain special characters // Picture addresses can contain special characters
$s = htmlspecialchars_decode($s, ENT_COMPAT); $s = htmlspecialchars_decode($s, ENT_COMPAT);
@ -1618,8 +1616,6 @@ function fetch_xrd_links($url) {
function scrape_vcard($url) { function scrape_vcard($url) {
$a = get_app();
$ret = array(); $ret = array();
logger('scrape_vcard: url=' . $url); logger('scrape_vcard: url=' . $url);
@ -1699,8 +1695,6 @@ function scrape_vcard($url) {
function scrape_feed($url) { function scrape_feed($url) {
$a = get_app();
$ret = array(); $ret = array();
$level = 0; $level = 0;
$x = z_fetch_url($url,false,$level,array('novalidate' => true)); $x = z_fetch_url($url,false,$level,array('novalidate' => true));
@ -1819,8 +1813,6 @@ function service_plink($contact, $guid) {
function format_and_send_email($sender,$xchan,$item) { function format_and_send_email($sender,$xchan,$item) {
require_once('include/enotify.php');
$title = $item['title']; $title = $item['title'];
$body = $item['body']; $body = $item['body'];
@ -1885,7 +1877,7 @@ function format_and_send_email($sender,$xchan,$item) {
// use the EmailNotification library to send the message // use the EmailNotification library to send the message
enotify::send(array( Zotlabs\Lib\Enotify::send(array(
'fromName' => $product, 'fromName' => $product,
'fromEmail' => $sender_email, 'fromEmail' => $sender_email,
'replyTo' => $sender_email, 'replyTo' => $sender_email,
@ -1940,9 +1932,6 @@ function do_delivery($deliveries) {
function get_site_info() { function get_site_info() {
global $db;
global $a;
$register_policy = Array('REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN'); $register_policy = Array('REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN');
$directory_mode = Array('DIRECTORY_MODE_NORMAL', 'DIRECTORY_MODE_PRIMARY', 'DIRECTORY_MODE_SECONDARY', 256 => 'DIRECTORY_MODE_STANDALONE'); $directory_mode = Array('DIRECTORY_MODE_NORMAL', 'DIRECTORY_MODE_PRIMARY', 'DIRECTORY_MODE_SECONDARY', 256 => 'DIRECTORY_MODE_STANDALONE');
@ -1978,7 +1967,7 @@ function get_site_info() {
$r = q("select * from addon where hidden = 0"); $r = q("select * from addon where hidden = 0");
if(count($r)) if(count($r))
foreach($r as $rr) foreach($r as $rr)
$visible_plugins[] = $rr['name']; $visible_plugins[] = $rr['aname'];
} }
sort($visible_plugins); sort($visible_plugins);
@ -2042,7 +2031,7 @@ function get_site_info() {
'admin' => $admin, 'admin' => $admin,
'site_name' => (($site_name) ? $site_name : ''), 'site_name' => (($site_name) ? $site_name : ''),
'platform' => Zotlabs\Lib\System::get_platform_name(), 'platform' => Zotlabs\Lib\System::get_platform_name(),
'dbdriver' => $db->getdriver(), 'dbdriver' => DBA::$dba->getdriver(),
'lastpoll' => get_config('system','lastpoll'), 'lastpoll' => get_config('system','lastpoll'),
'info' => (($site_info) ? $site_info : ''), 'info' => (($site_info) ? $site_info : ''),
'channels_total' => $channels_total_stat, 'channels_total' => $channels_total_stat,

View file

@ -1,37 +0,0 @@
<?php /** @file */
function format_notification($item) {
$ret = '';
require_once('include/conversation.php');
// Call localize_item with the "brief" flag to get a one line status for activities.
// This should set $item['localized'] to indicate we have a brief summary.
localize_item($item);
if($item_localize) {
$itemem_text = $item['localize'];
}
else {
$itemem_text = (($item['item_thread_top'])
? t('created a new post')
: sprintf( t('commented on %s\'s post'), $item['owner']['xchan_name']));
}
// convert this logic into a json array just like the system notifications
return array(
'notify_link' => $item['llink'],
'name' => $item['author']['xchan_name'],
'url' => $item['author']['xchan_url'],
'photo' => $item['author']['xchan_photo_s'],
'when' => relative_date($item['created']),
'class' => (intval($item['item_unseen']) ? 'notify-unseen' : 'notify-seen'),
'message' => strip_tags(bbcode($itemem_text))
);
}

View file

@ -37,7 +37,7 @@ class ZotOAuth1DataStore extends OAuth1DataStore {
logger(__function__.":".$consumer.", ". $token_type.", ".$token, LOGGER_DEBUG); logger(__function__.":".$consumer.", ". $token_type.", ".$token, LOGGER_DEBUG);
$r = q("SELECT id, secret, scope, expires, uid FROM tokens WHERE client_id = '%s' AND scope = '%s' AND id = '%s'", $r = q("SELECT id, secret, auth_scope, expires, uid FROM tokens WHERE client_id = '%s' AND auth_scope = '%s' AND id = '%s'",
dbesc($consumer->key), dbesc($consumer->key),
dbesc($token_type), dbesc($token_type),
dbesc($token) dbesc($token)
@ -45,7 +45,7 @@ class ZotOAuth1DataStore extends OAuth1DataStore {
if (count($r)){ if (count($r)){
$ot=new OAuth1Token($r[0]['id'],$r[0]['secret']); $ot=new OAuth1Token($r[0]['id'],$r[0]['secret']);
$ot->scope=$r[0]['scope']; $ot->scope=$r[0]['auth_scope'];
$ot->expires = $r[0]['expires']; $ot->expires = $r[0]['expires'];
$ot->uid = $r[0]['uid']; $ot->uid = $r[0]['uid'];
return $ot; return $ot;
@ -79,7 +79,7 @@ class ZotOAuth1DataStore extends OAuth1DataStore {
$k = $consumer; $k = $consumer;
} }
$r = q("INSERT INTO tokens (id, secret, client_id, scope, expires) VALUES ('%s','%s','%s','%s', %d)", $r = q("INSERT INTO tokens (id, secret, client_id, auth_scope, expires) VALUES ('%s','%s','%s','%s', %d)",
dbesc($key), dbesc($key),
dbesc($sec), dbesc($sec),
dbesc($k), dbesc($k),
@ -110,7 +110,7 @@ class ZotOAuth1DataStore extends OAuth1DataStore {
$key = $this->gen_token(); $key = $this->gen_token();
$sec = $this->gen_token(); $sec = $this->gen_token();
$r = q("INSERT INTO tokens (id, secret, client_id, scope, expires, uid) VALUES ('%s','%s','%s','%s', %d, %d)", $r = q("INSERT INTO tokens (id, secret, client_id, auth_scope, expires, uid) VALUES ('%s','%s','%s','%s', %d, %d)",
dbesc($key), dbesc($key),
dbesc($sec), dbesc($sec),
dbesc($consumer->key), dbesc($consumer->key),
@ -249,7 +249,7 @@ class FKOAuth2 extends OAuth2 {
protected function getAuthCode($code) { protected function getAuthCode($code) {
$r = q("SELECT id, client_id, redirect_uri, expires, scope FROM auth_codes WHERE id = '%s'", $r = q("SELECT id, client_id, redirect_uri, expires, auth_scope FROM auth_codes WHERE id = '%s'",
dbesc($code)); dbesc($code));
if (count($r)) if (count($r))
@ -259,7 +259,7 @@ class FKOAuth2 extends OAuth2 {
protected function setAuthCode($code, $client_id, $redirect_uri, $expires, $scope = NULL) { protected function setAuthCode($code, $client_id, $redirect_uri, $expires, $scope = NULL) {
$r = q("INSERT INTO auth_codes $r = q("INSERT INTO auth_codes
(id, client_id, redirect_uri, expires, scope) VALUES (id, client_id, redirect_uri, expires, auth_scope) VALUES
('%s', '%s', '%s', %d, '%s')", ('%s', '%s', '%s', %d, '%s')",
dbesc($code), dbesc($code),
dbesc($client_id), dbesc($client_id),

View file

@ -227,7 +227,7 @@ function oembed_fetch_url($embedurl){
} }
function oembed_format_object($j){ function oembed_format_object($j){
$a = get_app();
$embedurl = $j->embedurl; $embedurl = $j->embedurl;
// logger('format: ' . print_r($j,true)); // logger('format: ' . print_r($j,true));

View file

@ -521,7 +521,7 @@ function guess_image_type($filename, $headers = '') {
logger('Photo: guess_image_type: '.$filename . ($headers?' from curl headers':''), LOGGER_DEBUG); logger('Photo: guess_image_type: '.$filename . ($headers?' from curl headers':''), LOGGER_DEBUG);
$type = null; $type = null;
if ($headers) { if ($headers) {
$a = get_app();
$hdrs=array(); $hdrs=array();
$h = explode("\n",$headers); $h = explode("\n",$headers);
foreach ($h as $l) { foreach ($h as $l) {
@ -580,8 +580,6 @@ function guess_image_type($filename, $headers = '') {
function import_xchan_photo($photo,$xchan,$thing = false) { function import_xchan_photo($photo,$xchan,$thing = false) {
$a = get_app();
$flags = (($thing) ? PHOTO_THING : PHOTO_XCHAN); $flags = (($thing) ? PHOTO_THING : PHOTO_XCHAN);
$album = (($thing) ? 'Things' : 'Contact Photos'); $album = (($thing) ? 'Things' : 'Contact Photos');
@ -703,8 +701,6 @@ function import_xchan_photo($photo,$xchan,$thing = false) {
function import_channel_photo($photo,$type,$aid,$uid) { function import_channel_photo($photo,$type,$aid,$uid) {
$a = get_app();
logger('import_channel_photo: importing channel photo for ' . $uid, LOGGER_DEBUG); logger('import_channel_photo: importing channel photo for ' . $uid, LOGGER_DEBUG);
$hash = photo_new_resource(); $hash = photo_new_resource();

View file

@ -19,8 +19,6 @@ require_once('include/text.php');
*/ */
function photo_upload($channel, $observer, $args) { function photo_upload($channel, $observer, $args) {
$a = get_app();
$ret = array('success' => false); $ret = array('success' => false);
$channel_id = $channel['channel_id']; $channel_id = $channel['channel_id'];
$account_id = $channel['channel_account_id']; $account_id = $channel['channel_account_id'];

View file

@ -41,7 +41,7 @@ function uninstall_plugin($plugin) {
$func(); $func();
} }
q("DELETE FROM `addon` WHERE `name` = '%s' ", q("DELETE FROM `addon` WHERE `aname` = '%s' ",
dbesc($plugin) dbesc($plugin)
); );
} }
@ -66,7 +66,7 @@ function install_plugin($plugin) {
$plugin_admin = (function_exists($plugin . '_plugin_admin') ? 1 : 0); $plugin_admin = (function_exists($plugin . '_plugin_admin') ? 1 : 0);
q("INSERT INTO `addon` (`name`, `installed`, `timestamp`, `plugin_admin`) VALUES ( '%s', 1, %d , %d ) ", q("INSERT INTO `addon` (`aname`, `installed`, `tstamp`, `plugin_admin`) VALUES ( '%s', 1, %d , %d ) ",
dbesc($plugin), dbesc($plugin),
intval($t), intval($t),
$plugin_admin $plugin_admin
@ -111,7 +111,7 @@ function load_plugin($plugin) {
} }
function plugin_is_installed($name) { function plugin_is_installed($name) {
$r = q("select name from addon where name = '%s' and installed = 1 limit 1", $r = q("select aname from addon where aname = '%s' and installed = 1 limit 1",
dbesc($name) dbesc($name)
); );
if($r) if($r)
@ -143,8 +143,8 @@ function reload_plugins() {
if(file_exists($fname)) { if(file_exists($fname)) {
$t = @filemtime($fname); $t = @filemtime($fname);
foreach($installed as $i) { foreach($installed as $i) {
if(($i['name'] == $pl) && ($i['timestamp'] != $t)) { if(($i['aname'] == $pl) && ($i['tstamp'] != $t)) {
logger('Reloading plugin: ' . $i['name']); logger('Reloading plugin: ' . $i['aname']);
@include_once($fname); @include_once($fname);
if(function_exists($pl . '_unload')) { if(function_exists($pl . '_unload')) {
@ -155,7 +155,7 @@ function reload_plugins() {
$func = $pl . '_load'; $func = $pl . '_load';
$func(); $func();
} }
q("UPDATE `addon` SET `timestamp` = %d WHERE `id` = %d", q("UPDATE `addon` SET `tstamp` = %d WHERE `id` = %d",
intval($t), intval($t),
intval($i['id']) intval($i['id'])
); );
@ -178,7 +178,7 @@ function reload_plugins() {
* @return mixed|bool * @return mixed|bool
*/ */
function register_hook($hook, $file, $function, $priority = 0) { function register_hook($hook, $file, $function, $priority = 0) {
$r = q("SELECT * FROM `hook` WHERE `hook` = '%s' AND `file` = '%s' AND `function` = '%s' LIMIT 1", $r = q("SELECT * FROM `hook` WHERE `hook` = '%s' AND `file` = '%s' AND `fn` = '%s' LIMIT 1",
dbesc($hook), dbesc($hook),
dbesc($file), dbesc($file),
dbesc($function) dbesc($function)
@ -186,7 +186,7 @@ function register_hook($hook, $file, $function, $priority = 0) {
if($r) if($r)
return true; return true;
$r = q("INSERT INTO `hook` (`hook`, `file`, `function`, `priority`) VALUES ( '%s', '%s', '%s', '%s' )", $r = q("INSERT INTO `hook` (`hook`, `file`, `fn`, `priority`) VALUES ( '%s', '%s', '%s', '%s' )",
dbesc($hook), dbesc($hook),
dbesc($file), dbesc($file),
dbesc($function), dbesc($function),
@ -206,7 +206,7 @@ function register_hook($hook, $file, $function, $priority = 0) {
* @return array * @return array
*/ */
function unregister_hook($hook, $file, $function) { function unregister_hook($hook, $file, $function) {
$r = q("DELETE FROM hook WHERE hook = '%s' AND `file` = '%s' AND `function` = '%s'", $r = q("DELETE FROM hook WHERE hook = '%s' AND `file` = '%s' AND `fn` = '%s'",
dbesc($hook), dbesc($hook),
dbesc($file), dbesc($file),
dbesc($function) dbesc($function)
@ -233,7 +233,7 @@ function load_hooks() {
if(! array_key_exists($rr['hook'],App::$hooks)) if(! array_key_exists($rr['hook'],App::$hooks))
App::$hooks[$rr['hook']] = array(); App::$hooks[$rr['hook']] = array();
App::$hooks[$rr['hook']][] = array($rr['file'],$rr['function'],$rr['priority'],$rr['hook_version']); App::$hooks[$rr['hook']][] = array($rr['file'],$rr['fn'],$rr['priority'],$rr['hook_version']);
} }
} }
//logger('hooks: ' . print_r(App::$hooks,true)); //logger('hooks: ' . print_r(App::$hooks,true));
@ -300,8 +300,13 @@ function call_hooks($name, &$data = null) {
$func($data); $func($data);
else else
$func($a, $data); $func($a, $data);
} else { }
q("DELETE FROM hook WHERE hook = '%s' AND file = '%s' AND function = '%s'", else {
// Don't do any DB write calls if we're currently logging a possibly failed DB call.
if(! DBA::$logging) {
// The hook should be removed so we don't process it.
q("DELETE FROM hook WHERE hook = '%s' AND file = '%s' AND fn = '%s'",
dbesc($name), dbesc($name),
dbesc($hook[0]), dbesc($hook[0]),
dbesc($origfn) dbesc($origfn)
@ -310,6 +315,7 @@ function call_hooks($name, &$data = null) {
} }
} }
} }
}
/** /**
@ -500,7 +506,7 @@ 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 . '/img/screenshot' . $ext)) if(file_exists('view/theme/' . $theme . '/img/screenshot' . $ext))
@ -521,7 +527,7 @@ function head_add_css($src, $media = 'screen') {
} }
function head_remove_css($src, $media = 'screen') { function head_remove_css($src, $media = 'screen') {
$a = get_app();
$index = array_search(array($src, $media), App::$css_sources); $index = array_search(array($src, $media), App::$css_sources);
if ($index !== false) if ($index !== false)
unset(App::$css_sources[$index]); unset(App::$css_sources[$index]);
@ -592,7 +598,7 @@ function head_add_js($src) {
} }
function head_remove_js($src) { function head_remove_js($src) {
$a = get_app();
$index = array_search($src, App::$js_sources); $index = array_search($src, App::$js_sources);
if($index !== false) if($index !== false)
unset(App::$js_sources[$index]); unset(App::$js_sources[$index]);
@ -633,7 +639,6 @@ function format_js_if_exists($source) {
function theme_include($file, $root = '') { function theme_include($file, $root = '') {
$a = get_app();
// Make sure $root ends with a slash / if it's not blank // Make sure $root ends with a slash / if it's not blank
if($root !== '' && $root[strlen($root)-1] !== '/') if($root !== '' && $root[strlen($root)-1] !== '/')
@ -671,7 +676,7 @@ function theme_include($file, $root = '') {
function get_intltext_template($s, $root = '') { function get_intltext_template($s, $root = '') {
$a = get_app();
$t = App::template_engine(); $t = App::template_engine();
$template = $t->get_intltext_template($s, $root); $template = $t->get_intltext_template($s, $root);
@ -680,7 +685,7 @@ function get_intltext_template($s, $root = '') {
function get_markup_template($s, $root = '') { function get_markup_template($s, $root = '') {
$a = get_app();
$t = App::template_engine(); $t = App::template_engine();
$template = $t->get_markup_template($s, $root); $template = $t->get_markup_template($s, $root);
return $template; return $template;

View file

@ -20,7 +20,7 @@ function file_tag_file_query($table,$s,$type = 'file') {
else else
$termtype = TERM_CATEGORY; $termtype = TERM_CATEGORY;
return sprintf(" AND " . (($table) ? dbesc($table) . '.' : '') . "id in (select term.oid from term where term.type = %d and term.term = '%s' and term.uid = " . (($table) ? dbesc($table) . '.' : '') . "uid ) ", return sprintf(" AND " . (($table) ? dbesc($table) . '.' : '') . "id in (select term.oid from term where term.ttype = %d and term.term = '%s' and term.uid = " . (($table) ? dbesc($table) . '.' : '') . "uid ) ",
intval($termtype), intval($termtype),
protect_sprintf(dbesc($s)) protect_sprintf(dbesc($s))
); );
@ -29,14 +29,14 @@ function file_tag_file_query($table,$s,$type = 'file') {
function term_query($table,$s,$type = TERM_UNKNOWN, $type2 = '') { function term_query($table,$s,$type = TERM_UNKNOWN, $type2 = '') {
if($type2) { if($type2) {
return sprintf(" AND " . (($table) ? dbesc($table) . '.' : '') . "id in (select term.oid from term where term.type in (%d, %d) and term.term = '%s' and term.uid = " . (($table) ? dbesc($table) . '.' : '') . "uid ) ", return sprintf(" AND " . (($table) ? dbesc($table) . '.' : '') . "id in (select term.oid from term where term.ttype in (%d, %d) and term.term = '%s' and term.uid = " . (($table) ? dbesc($table) . '.' : '') . "uid ) ",
intval($type), intval($type),
intval($type2), intval($type2),
protect_sprintf(dbesc($s)) protect_sprintf(dbesc($s))
); );
} }
else { else {
return sprintf(" AND " . (($table) ? dbesc($table) . '.' : '') . "id in (select term.oid from term where term.type = %d and term.term = '%s' and term.uid = " . (($table) ? dbesc($table) . '.' : '') . "uid ) ", return sprintf(" AND " . (($table) ? dbesc($table) . '.' : '') . "id in (select term.oid from term where term.ttype = %d and term.term = '%s' and term.uid = " . (($table) ? dbesc($table) . '.' : '') . "uid ) ",
intval($type), intval($type),
protect_sprintf(dbesc($s)) protect_sprintf(dbesc($s))
); );
@ -49,7 +49,7 @@ function store_item_tag($uid,$iid,$otype,$type,$term,$url = '') {
return false; return false;
$r = q("select * from term $r = q("select * from term
where uid = %d and oid = %d and otype = %d and type = %d where uid = %d and oid = %d and otype = %d and ttype = %d
and term = '%s' and url = '%s' ", and term = '%s' and url = '%s' ",
intval($uid), intval($uid),
intval($iid), intval($iid),
@ -61,7 +61,7 @@ function store_item_tag($uid,$iid,$otype,$type,$term,$url = '') {
if($r) if($r)
return false; return false;
$r = q("insert into term (uid, oid, otype, type, term, url) $r = q("insert into term (uid, oid, otype, ttype, term, url)
values( %d, %d, %d, %d, '%s', '%s') ", values( %d, %d, %d, %d, '%s', '%s') ",
intval($uid), intval($uid),
intval($iid), intval($iid),
@ -85,7 +85,7 @@ function get_terms_oftype($arr,$type) {
foreach($type as $t) foreach($type as $t)
foreach($arr as $x) foreach($arr as $x)
if($x['type'] == $t) if($x['ttype'] == $t)
$ret[] = $x; $ret[] = $x;
return $ret; return $ret;
@ -93,9 +93,9 @@ function get_terms_oftype($arr,$type) {
function format_term_for_display($term) { function format_term_for_display($term) {
$s = ''; $s = '';
if(($term['type'] == TERM_HASHTAG) || ($term['type'] == TERM_COMMUNITYTAG)) if(($term['ttype'] == TERM_HASHTAG) || ($term['ttype'] == TERM_COMMUNITYTAG))
$s .= '#'; $s .= '#';
elseif($term['type'] == TERM_MENTION) elseif($term['ttype'] == TERM_MENTION)
$s .= '@'; $s .= '@';
else else
return $s; return $s;
@ -142,7 +142,7 @@ function tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags = 0, $re
// Fetch tags // Fetch tags
$r = q("select term, count(term) as total from term left join item on term.oid = item.id $r = q("select term, count(term) as total from term left join item on term.oid = item.id
where term.uid = %d and term.type = %d where term.uid = %d and term.ttype = %d
and otype = %d and item_type = %d and item_private = 0 and otype = %d and item_type = %d and item_private = 0
$sql_options $item_normal $sql_options $item_normal
group by term order by total desc %s", group by term order by total desc %s",

View file

@ -20,7 +20,6 @@ define('RANDOM_STRING_TEXT', 0x01 );
* @return string substituted string * @return string substituted string
*/ */
function replace_macros($s, $r) { function replace_macros($s, $r) {
$a = get_app();
$arr = array('template' => $s, 'params' => $r); $arr = array('template' => $s, 'params' => $r);
call_hooks('replace_macros', $arr); call_hooks('replace_macros', $arr);
@ -96,7 +95,6 @@ function z_input_filter($channel_id,$s,$type = 'text/bbcode') {
if($type == 'application/x-pdl') if($type == 'application/x-pdl')
return escape_tags($s); return escape_tags($s);
$a = get_app();
if(App::$is_sys) { if(App::$is_sys) {
return $s; return $s;
} }
@ -324,6 +322,15 @@ function autoname($len) {
function xmlify($str) { function xmlify($str) {
$buffer = ''; $buffer = '';
if(is_array($str)) {
// allow to fall through so we ge a PHP error, as the log statement will
// probably get lost in the noise unless we're specifically looking for it.
btlogger('xmlify called with array: ' . print_r($str,true), LOGGER_NORMAL, LOG_WARNING);
}
$len = mb_strlen($str); $len = mb_strlen($str);
for($x = 0; $x < $len; $x ++) { for($x = 0; $x < $len; $x ++) {
$char = mb_substr($str,$x,1); $char = mb_substr($str,$x,1);
@ -567,21 +574,25 @@ function attribute_contains($attr, $s) {
*/ */
function logger($msg, $level = LOGGER_NORMAL, $priority = LOG_INFO) { function logger($msg, $level = LOGGER_NORMAL, $priority = LOG_INFO) {
// turn off logger in install mode
global $a;
global $db;
if((App::$module == 'install') || (! ($db && $db->connected)))
return;
if(App::$module == 'setup' && is_writable('install.log')) {
$debugging = true;
$logfile = 'install.log';
$loglevel = LOGGER_ALL;
}
else {
$debugging = get_config('system', 'debugging'); $debugging = get_config('system', 'debugging');
$loglevel = intval(get_config('system', 'loglevel')); $loglevel = intval(get_config('system', 'loglevel'));
$logfile = get_config('system', 'logfile'); $logfile = get_config('system', 'logfile');
}
if((! $debugging) || (! $logfile) || ($level > $loglevel)) if((! $debugging) || (! $logfile) || ($level > $loglevel))
return; return;
$where = ''; $where = '';
// We require > 5.4 but leave the version check so that install issues (including version) can be logged
if(version_compare(PHP_VERSION, '5.4.0') >= 0) { if(version_compare(PHP_VERSION, '5.4.0') >= 0) {
$stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); $stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
$where = basename($stack[0]['file']) . ':' . $stack[0]['line'] . ':' . $stack[1]['function'] . ': '; $where = basename($stack[0]['file']) . ':' . $stack[0]['line'] . ':' . $stack[1]['function'] . ': ';
@ -590,6 +601,7 @@ function logger($msg, $level = LOGGER_NORMAL, $priority = LOG_INFO) {
$s = datetime_convert() . ':' . log_priority_str($priority) . ':' . session_id() . ':' . $where . $msg . PHP_EOL; $s = datetime_convert() . ':' . log_priority_str($priority) . ':' . session_id() . ':' . $where . $msg . PHP_EOL;
$pluginfo = array('filename' => $logfile, 'loglevel' => $level, 'message' => $s,'priority' => $priority, 'logged' => false); $pluginfo = array('filename' => $logfile, 'loglevel' => $level, 'message' => $s,'priority' => $priority, 'logged' => false);
if(! (App::$module == 'setup'))
call_hooks('logger',$pluginfo); call_hooks('logger',$pluginfo);
if(! $pluginfo['logged']) if(! $pluginfo['logged'])
@ -648,11 +660,10 @@ function log_priority_str($priority) {
* @param int $level A log level. * @param int $level A log level.
*/ */
function dlogger($msg, $level = 0) { function dlogger($msg, $level = 0) {
// turn off logger in install mode
global $a;
global $db;
if((App::$module == 'install') || (! ($db && $db->connected))) // turn off logger in install mode
if(App::$module == 'setup')
return; return;
$debugging = get_config('system','debugging'); $debugging = get_config('system','debugging');
@ -799,7 +810,7 @@ function get_mentions($item,$tags) {
return $o; return $o;
foreach($tags as $x) { foreach($tags as $x) {
if($x['type'] == TERM_MENTION) { if($x['ttype'] == TERM_MENTION) {
$o .= "\t\t" . '<link rel="mentioned" href="' . $x['url'] . '" />' . "\r\n"; $o .= "\t\t" . '<link rel="mentioned" href="' . $x['url'] . '" />' . "\r\n";
$o .= "\t\t" . '<link rel="ostatus:attention" href="' . $x['url'] . '" />' . "\r\n"; $o .= "\t\t" . '<link rel="ostatus:attention" href="' . $x['url'] . '" />' . "\r\n";
} }
@ -810,7 +821,6 @@ function get_mentions($item,$tags) {
function contact_block() { function contact_block() {
$o = ''; $o = '';
$a = get_app();
if(! App::$profile['uid']) if(! App::$profile['uid'])
return; return;
@ -923,7 +933,7 @@ function micropro($contact, $redirect = false, $class = '', $textmode = false) {
function search($s,$id='search-box',$url='/search',$save = false) { function search($s,$id='search-box',$url='/search',$save = false) {
$a = get_app();
return replace_macros(get_markup_template('searchbox.tpl'),array( return replace_macros(get_markup_template('searchbox.tpl'),array(
'$s' => $s, '$s' => $s,
'$id' => $id, '$id' => $id,
@ -1068,7 +1078,7 @@ function get_mood_verbs() {
// Function to list all smilies, both internal and from addons // Function to list all smilies, both internal and from addons
// Returns array with keys 'texts' and 'icons' // Returns array with keys 'texts' and 'icons'
function list_smilies() { function list_smilies() {
$a = get_app();
$texts = array( $texts = array(
'&lt;3', '&lt;3',
'&lt;/3', '&lt;/3',
@ -1101,10 +1111,8 @@ function list_smilies() {
':coffee', ':coffee',
':facepalm', ':facepalm',
':like', ':like',
':dislike', ':dislike'
'red#matrix',
'red#',
'r#'
); );
$icons = array( $icons = array(
@ -1140,9 +1148,6 @@ function list_smilies() {
'<img class="smiley" src="' . z_root() . '/images/smiley-facepalm.gif" alt=":facepalm" />', '<img class="smiley" src="' . z_root() . '/images/smiley-facepalm.gif" alt=":facepalm" />',
'<img class="smiley" src="' . z_root() . '/images/like.gif" alt=":like" />', '<img class="smiley" src="' . z_root() . '/images/like.gif" alt=":like" />',
'<img class="smiley" src="' . z_root() . '/images/dislike.gif" alt=":dislike" />', '<img class="smiley" src="' . z_root() . '/images/dislike.gif" alt=":dislike" />',
'<a href="http://getzot.com"><strong>red<img class="smiley bb_rm-logo" src="' . z_root() . '/images/rm-32.png" alt="' . urlencode('red#matrix') . '" />matrix</strong></a>',
'<a href="http://getzot.com"><strong>red<img class="smiley bb_rm-logo" src="' . z_root() . '/images/rm-32.png" alt="' . urlencode('red#') . '" />matrix</strong></a>',
'<a href="http://getzot.com"><strong>red<img class="smiley bb_rm-logo" src="' . z_root() . '/images/rm-32.png" alt="r#" />matrix</strong></a>'
); );
@ -1213,7 +1218,7 @@ function smile_unshield($m) {
* @param array $x * @param array $x
*/ */
function preg_heart($x) { function preg_heart($x) {
$a = get_app();
if (strlen($x[1]) == 1) if (strlen($x[1]) == 1)
return $x[0]; return $x[0];
@ -1486,7 +1491,6 @@ function format_event($jobject) {
} }
function prepare_body(&$item,$attach = false) { function prepare_body(&$item,$attach = false) {
require_once('include/channel.php');
call_hooks('prepare_body_init', $item); call_hooks('prepare_body_init', $item);
@ -1716,7 +1720,6 @@ function feed_hublinks() {
/* return atom link elements for salmon endpoints */ /* return atom link elements for salmon endpoints */
function feed_salmonlinks($nick) { function feed_salmonlinks($nick) {
$a = get_app();
$salmon = '<link rel="salmon" href="' . xmlify(z_root() . '/salmon/' . $nick) . '" />' . "\n" ; $salmon = '<link rel="salmon" href="' . xmlify(z_root() . '/salmon/' . $nick) . '" />' . "\n" ;
@ -1784,7 +1787,7 @@ function mimetype_select($channel_id, $current = 'text/bbcode') {
'application/x-pdl' 'application/x-pdl'
); );
$a = get_app();
if(App::$is_sys) { if(App::$is_sys) {
$x[] = 'application/x-php'; $x[] = 'application/x-php';
} }
@ -1817,7 +1820,6 @@ function mimetype_select($channel_id, $current = 'text/bbcode') {
function lang_selector() { function lang_selector() {
global $a;
$langs = glob('view/*/hstrings.php'); $langs = glob('view/*/hstrings.php');

View file

@ -212,13 +212,13 @@ function widget_savedsearch($arr) {
$search = ((x($_GET,'search')) ? $_GET['search'] : ''); $search = ((x($_GET,'search')) ? $_GET['search'] : '');
if(x($_GET,'searchsave') && $search) { if(x($_GET,'searchsave') && $search) {
$r = q("select * from `term` where `uid` = %d and `type` = %d and `term` = '%s' limit 1", $r = q("select * from `term` where `uid` = %d and `ttype` = %d and `term` = '%s' limit 1",
intval(local_channel()), intval(local_channel()),
intval(TERM_SAVEDSEARCH), intval(TERM_SAVEDSEARCH),
dbesc($search) dbesc($search)
); );
if(! $r) { if(! $r) {
q("insert into `term` ( `uid`,`type`,`term` ) values ( %d, %d, '%s') ", q("insert into `term` ( `uid`,`ttype`,`term` ) values ( %d, %d, '%s') ",
intval(local_channel()), intval(local_channel()),
intval(TERM_SAVEDSEARCH), intval(TERM_SAVEDSEARCH),
dbesc($search) dbesc($search)
@ -227,7 +227,7 @@ function widget_savedsearch($arr) {
} }
if(x($_GET,'searchremove') && $search) { if(x($_GET,'searchremove') && $search) {
q("delete from `term` where `uid` = %d and `type` = %d and `term` = '%s'", q("delete from `term` where `uid` = %d and `ttype` = %d and `term` = '%s'",
intval(local_channel()), intval(local_channel()),
intval(TERM_SAVEDSEARCH), intval(TERM_SAVEDSEARCH),
dbesc($search) dbesc($search)
@ -254,7 +254,7 @@ function widget_savedsearch($arr) {
$o = ''; $o = '';
$r = q("select `tid`,`term` from `term` WHERE `uid` = %d and `type` = %d ", $r = q("select `tid`,`term` from `term` WHERE `uid` = %d and `ttype` = %d ",
intval(local_channel()), intval(local_channel()),
intval(TERM_SAVEDSEARCH) intval(TERM_SAVEDSEARCH)
); );
@ -296,7 +296,7 @@ function widget_filer($arr) {
$selected = ((x($_REQUEST,'file')) ? $_REQUEST['file'] : ''); $selected = ((x($_REQUEST,'file')) ? $_REQUEST['file'] : '');
$terms = array(); $terms = array();
$r = q("select distinct(term) from term where uid = %d and type = %d order by term asc", $r = q("select distinct(term) from term where uid = %d and ttype = %d order by term asc",
intval(local_channel()), intval(local_channel()),
intval(TERM_FILE) intval(TERM_FILE)
); );
@ -771,7 +771,6 @@ function widget_eventstools($arr) {
} }
function widget_design_tools($arr) { function widget_design_tools($arr) {
$a = get_app();
// mod menu doesn't load a profile. For any modules which load a profile, check it. // mod menu doesn't load a profile. For any modules which load a profile, check it.
// otherwise local_channel() is sufficient for permissions. // otherwise local_channel() is sufficient for permissions.
@ -1398,7 +1397,7 @@ function widget_admin($arr) {
$plugins = array(); $plugins = array();
if($r) { if($r) {
foreach ($r as $h){ foreach ($r as $h){
$plugin = $h['name']; $plugin = $h['aname'];
$plugins[] = array(z_root() . '/admin/plugins/' . $plugin, $plugin, 'plugin'); $plugins[] = array(z_root() . '/admin/plugins/' . $plugin, $plugin, 'plugin');
// temp plugins with admin // temp plugins with admin
App::$plugins_admin[] = $plugin; App::$plugins_admin[] = $plugin;

View file

@ -329,8 +329,12 @@ function zot_refresh($them, $channel = null, $force = false) {
return false; return false;
} }
$token = random_string();
$postvars = array(); $postvars = array();
$postvars['token'] = $token;
if($channel) { if($channel) {
$postvars['target'] = $channel['channel_guid']; $postvars['target'] = $channel['channel_guid'];
$postvars['target_sig'] = $channel['channel_guid_sig']; $postvars['target_sig'] = $channel['channel_guid_sig'];
@ -343,9 +347,9 @@ function zot_refresh($them, $channel = null, $force = false) {
$postvars['guid_hash'] = $them['xchan_hash']; $postvars['guid_hash'] = $them['xchan_hash'];
if (array_key_exists('xchan_guid',$them) && $them['xchan_guid'] if (array_key_exists('xchan_guid',$them) && $them['xchan_guid']
&& array_key_exists('xchan_guid_sig',$them) && $them['xchan_guid_sig']) { && array_key_exists('xchan_guid_sig',$them) && $them['xchan_guid_sig']) {
$postvars['guid'] = $them['xchan_guid']; $postvars['guid'] = $them['xchan_guid'];
$postvars['guid_sig'] = $them['xchan_guid_sig']; $postvars['guid_sig'] = $them['xchan_guid_sig'];
} }
$rhs = '/.well-known/zot-info'; $rhs = '/.well-known/zot-info';
@ -363,6 +367,22 @@ function zot_refresh($them, $channel = null, $force = false) {
return false; return false;
} }
$signed_token = ((is_array($j) && array_key_exists('signed_token',$j)) ? $j['signed_token'] : null);
if($signed_token) {
$valid = rsa_verify('token.' . $token,base64url_decode($signed_token),$j['key']);
if(! $valid) {
logger('invalid signed token: ' . $url . $rhs, LOGGER_NORMAL, LOG_ERR);
return false;
}
}
else {
logger('No signed token from ' . $url . $rhs, LOGGER_NORMAL, LOG_WARNING);
// after 2017-01-01 this will be a hard error unless you over-ride it.
if((time() > 1483228800) && (! get_config('system','allow_unsigned_zotfinger'))) {
return false;
}
}
$x = import_xchan($j, (($force) ? UPDATE_FLAGS_FORCED : UPDATE_FLAGS_UPDATED)); $x = import_xchan($j, (($force) ? UPDATE_FLAGS_FORCED : UPDATE_FLAGS_UPDATED));
if(! $x['success']) if(! $x['success'])
@ -505,8 +525,7 @@ function zot_refresh($them, $channel = null, $force = false) {
if($new_connection) { if($new_connection) {
if($new_perms != $previous_perms) if($new_perms != $previous_perms)
Zotlabs\Daemon\Master::Summon(array('Notifier','permission_create',$new_connection[0]['abook_id'])); Zotlabs\Daemon\Master::Summon(array('Notifier','permission_create',$new_connection[0]['abook_id']));
require_once('include/enotify.php'); Zotlabs\Lib\Enotify::submit(array(
notification(array(
'type' => NOTIFY_INTRO, 'type' => NOTIFY_INTRO,
'from_xchan' => $x['hash'], 'from_xchan' => $x['hash'],
'to_xchan' => $channel['channel_hash'], 'to_xchan' => $channel['channel_hash'],
@ -1027,8 +1046,9 @@ function zot_process_response($hub, $arr, $outq) {
/** /**
* @brief * @brief
* *
* We received a notification packet (in mod/post.php) that a message is waiting for us, and we've verified the sender. * We received a notification packet (in mod_post) that a message is waiting for us, and we've verified the sender.
* Now send back a pickup message, using our message tracking ID ($arr['secret']), which we will sign with our site private key. * Now send back a pickup message, using our message tracking ID ($arr['secret']), which we will sign with our site
* private key.
* The entire pickup message is encrypted with the remote site's public key. * The entire pickup message is encrypted with the remote site's public key.
* If everything checks out on the remote end, we will receive back a packet containing one or more messages, * If everything checks out on the remote end, we will receive back a packet containing one or more messages,
* which will be processed and delivered before this function ultimately returns. * which will be processed and delivered before this function ultimately returns.
@ -1102,6 +1122,7 @@ function zot_fetch($arr) {
* * [1] => \e string $delivery_status * * [1] => \e string $delivery_status
* * [2] => \e string $address * * [2] => \e string $address
*/ */
function zot_import($arr, $sender_url) { function zot_import($arr, $sender_url) {
$data = json_decode($arr['body'], true); $data = json_decode($arr['body'], true);
@ -1494,7 +1515,7 @@ function public_recips($msg) {
/** /**
* @brief * @brief
* *
* This is the second part of public_recipes(). * This is the second part of public_recips().
* We'll find all the channels willing to accept public posts from us, then * We'll find all the channels willing to accept public posts from us, then
* match them against the sender privacy scope and see who in that list that * match them against the sender privacy scope and see who in that list that
* the sender is allowing. * the sender is allowing.
@ -1932,7 +1953,7 @@ function remove_community_tag($sender, $arr, $uid) {
return; return;
} }
q("delete from term where uid = %d and oid = %d and otype = %d and type in ( %d, %d ) and term = '%s' and url = '%s'", q("delete from term where uid = %d and oid = %d and otype = %d and ttype in ( %d, %d ) and term = '%s' and url = '%s'",
intval($uid), intval($uid),
intval($r[0]['id']), intval($r[0]['id']),
intval(TERM_OBJ_POST), intval(TERM_OBJ_POST),
@ -2381,11 +2402,14 @@ function sync_locations($sender, $arr, $absolute = false) {
$current_site = false; $current_site = false;
$t = datetime_convert('UTC','UTC','now - 15 minutes');
if(array_key_exists('site',$arr) && $location['url'] == $arr['site']['url']) { if(array_key_exists('site',$arr) && $location['url'] == $arr['site']['url']) {
q("update hubloc set hubloc_connected = '%s', hubloc_updated = '%s' where hubloc_id = %d", q("update hubloc set hubloc_connected = '%s', hubloc_updated = '%s' where hubloc_id = %d and hubloc_connected < '%s'",
dbesc(datetime_convert()), dbesc(datetime_convert()),
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval($r[0]['hubloc_id']) intval($r[0]['hubloc_id']),
dbesc($t)
); );
$current_site = true; $current_site = true;
} }
@ -2945,8 +2969,6 @@ function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) {
if(UNO) if(UNO)
return; return;
$a = get_app();
logger('build_sync_packet'); logger('build_sync_packet');
if($packet) if($packet)
@ -3029,7 +3051,7 @@ function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) {
} }
if($groups_changed) { if($groups_changed) {
$r = q("select hash as collection, visible, deleted, name from groups where uid = %d", $r = q("select hash as collection, visible, deleted, gname as name from groups where uid = %d",
intval($uid) intval($uid)
); );
if($r) if($r)
@ -3322,10 +3344,10 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
} }
} }
if($found) { if($found) {
if(($y['name'] != $cl['name']) if(($y['gname'] != $cl['name'])
|| ($y['visible'] != $cl['visible']) || ($y['visible'] != $cl['visible'])
|| ($y['deleted'] != $cl['deleted'])) { || ($y['deleted'] != $cl['deleted'])) {
q("update groups set name = '%s', visible = %d, deleted = %d where hash = '%s' and uid = %d", q("update groups set gname = '%s', visible = %d, deleted = %d where hash = '%s' and uid = %d",
dbesc($cl['name']), dbesc($cl['name']),
intval($cl['visible']), intval($cl['visible']),
intval($cl['deleted']), intval($cl['deleted']),
@ -3341,7 +3363,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
} }
} }
if(! $found) { if(! $found) {
$r = q("INSERT INTO `groups` ( hash, uid, visible, deleted, name ) $r = q("INSERT INTO `groups` ( hash, uid, visible, deleted, gname )
VALUES( '%s', %d, %d, %d, '%s' ) ", VALUES( '%s', %d, %d, %d, '%s' ) ",
dbesc($cl['collection']), dbesc($cl['collection']),
intval($channel['channel_id']), intval($channel['channel_id']),
@ -3448,7 +3470,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
if(array_key_exists('profile',$arr) && is_array($arr['profile']) && count($arr['profile'])) { if(array_key_exists('profile',$arr) && is_array($arr['profile']) && count($arr['profile'])) {
$disallowed = array('id','aid','uid'); $disallowed = array('id','aid','uid','guid');
foreach($arr['profile'] as $profile) { foreach($arr['profile'] as $profile) {
$x = q("select * from profile where profile_guid = '%s' and uid = %d limit 1", $x = q("select * from profile where profile_guid = '%s' and uid = %d limit 1",
@ -3473,12 +3495,21 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
if(in_array($k,$disallowed)) if(in_array($k,$disallowed))
continue; continue;
if($k === 'name')
$clean['fullname'] = $v;
elseif($k === 'with')
$clean['partner'] = $v;
elseif($k === 'work')
$clean['employment'] = $v;
elseif(array_key_exists($k,$x[0]))
$clean[$k] = $v; $clean[$k] = $v;
/** /**
* @TODO check if these are allowed, otherwise we'll error * @TODO
* We also need to import local photos if a custom photo is selected * We also need to import local photos if a custom photo is selected
*/ */
} }
if(count($clean)) { if(count($clean)) {
foreach($clean as $k => $v) { foreach($clean as $k => $v) {
$r = dbq("UPDATE profile set `" . dbesc($k) . "` = '" . dbesc($v) $r = dbq("UPDATE profile set `" . dbesc($k) . "` = '" . dbesc($v)
@ -3933,8 +3964,6 @@ function zotinfo($arr) {
$ret['site']['admin'] = get_config('system','admin_email'); $ret['site']['admin'] = get_config('system','admin_email');
$a = get_app();
$visible_plugins = array(); $visible_plugins = array();
if(is_array(App::$plugins) && count(App::$plugins)) { if(is_array(App::$plugins) && count(App::$plugins)) {
$r = q("select * from addon where hidden = 0"); $r = q("select * from addon where hidden = 0");
@ -3949,7 +3978,7 @@ function zotinfo($arr) {
$ret['site']['sellpage'] = get_config('system','sellpage'); $ret['site']['sellpage'] = get_config('system','sellpage');
$ret['site']['location'] = get_config('system','site_location'); $ret['site']['location'] = get_config('system','site_location');
$ret['site']['realm'] = get_directory_realm(); $ret['site']['realm'] = get_directory_realm();
$ret['site']['project'] = Zotlabs\Lib\System::get_platform_name() . Zotlabs\Lib\System::get_server_role(); $ret['site']['project'] = Zotlabs\Lib\System::get_platform_name() . ' ' . Zotlabs\Lib\System::get_server_role();
} }
@ -4108,7 +4137,7 @@ function update_hub_connected($hub,$sitekey = '') {
$sitekey = $hub['sitekey']; $sitekey = $hub['sitekey'];
} }
// $sender['sitekey'] is a new addition to the protcol to distinguish // $sender['sitekey'] is a new addition to the protocol to distinguish
// hublocs coming from re-installed sites. Older sites will not provide // hublocs coming from re-installed sites. Older sites will not provide
// this field and we have to still mark them valid, since we can't tell // this field and we have to still mark them valid, since we can't tell
// if this hubloc has the same sitekey as the packet we received. // if this hubloc has the same sitekey as the packet we received.
@ -4117,10 +4146,13 @@ function update_hub_connected($hub,$sitekey = '') {
// Update our DB to show when we last communicated successfully with this hub // Update our DB to show when we last communicated successfully with this hub
// This will allow us to prune dead hubs from using up resources // This will allow us to prune dead hubs from using up resources
$r = q("update hubloc set hubloc_connected = '%s' where hubloc_id = %d and hubloc_sitekey = '%s' ", $t = datetime_convert('UTC','UTC','now - 15 minutes');
$r = q("update hubloc set hubloc_connected = '%s' where hubloc_id = %d and hubloc_sitekey = '%s' and hubloc_connected < '%s' ",
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval($hub['hubloc_id']), intval($hub['hubloc_id']),
dbesc($sitekey) dbesc($sitekey),
dbesc($t)
); );
// a dead hub came back to life - reset any tombstones we might have // a dead hub came back to life - reset any tombstones we might have

180
index.php
View file

@ -1,183 +1,15 @@
<?php <?php
namespace Zotlabs\Web;
/** /**
* @file index.php * @file index.php
* *
* @brief The main entry point to the application. * @brief The main entry point to the application.
*
* Bootstrap the application, load configuration, load modules, load theme, etc.
*/ */
/* require_once('Zotlabs/Web/WebServer.php');
* bootstrap the application
*/
require_once('boot.php');
if(file_exists('.htsite.php')) $server = new WebServer();
include('.htsite.php'); $server->run();
// our global App object
$a = new miniApp;
App::init();
/*
* Load the configuration file which contains our DB credentials.
* Ignore errors. If the file doesn't exist or is empty, we are running in
* installation mode.
*/
App::$install = ((file_exists('.htconfig.php') && filesize('.htconfig.php')) ? false : true);
@include('.htconfig.php');
if(! defined('UNO'))
define('UNO', 0);
$a->convert();
App::$timezone = ((x($default_timezone)) ? $default_timezone : 'UTC');
date_default_timezone_set(App::$timezone);
/*
* Try to open the database;
*/
require_once('include/dba/dba_driver.php');
if(! App::$install) {
$db = dba_factory($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type, App::$install);
if(! $db->connected) {
system_unavailable();
}
unset($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type);
/**
* Load configs from db. Overwrite configs from .htconfig.php
*/
load_config('config');
load_config('system');
load_config('feature');
App::$session = new \Zotlabs\Web\Session();
App::$session->init();
load_hooks();
call_hooks('init_1');
}
App::$language = get_best_language();
load_translation_table(App::$language,App::$install);
/**
*
* Important stuff we always need to do.
*
* The order of these may be important so use caution if you think they're all
* intertwingled with no logical order and decide to sort it out. Some of the
* dependencies have changed, but at least at one time in the recent past - the
* order was critical to everything working properly
*
*/
if(App::$session) {
App::$session->start();
}
else {
session_start();
register_shutdown_function('session_write_close');
}
/**
* Language was set earlier, but we can over-ride it in the session.
* We have to do it here because the session was just now opened.
*/
if(array_key_exists('system_language',$_POST)) {
if(strlen($_POST['system_language']))
$_SESSION['language'] = $_POST['system_language'];
else
unset($_SESSION['language']);
}
if((x($_SESSION, 'language')) && ($_SESSION['language'] !== $lang)) {
App::$language = $_SESSION['language'];
load_translation_table(App::$language);
}
if((x($_GET,'zid')) && (! App::$install)) {
App::$query_string = strip_zids(App::$query_string);
if(! local_channel()) {
$_SESSION['my_address'] = $_GET['zid'];
zid_init($a);
}
}
if((x($_SESSION, 'authenticated')) || (x($_POST, 'auth-params')) || (App::$module === 'login'))
require('include/auth.php');
if(! x($_SESSION, 'sysmsg'))
$_SESSION['sysmsg'] = array();
if(! x($_SESSION, 'sysmsg_info'))
$_SESSION['sysmsg_info'] = array();
/*
* check_config() is responsible for running update scripts. These automatically
* update the DB schema whenever we push a new one out. It also checks to see if
* any plugins have been added or removed and reacts accordingly.
*/
if(App::$install) {
/* Allow an exception for the view module so that pcss will be interpreted during installation */
if(App::$module != 'view')
App::$module = 'setup';
}
else
check_config($a);
nav_set_selected('nothing');
$Router = new Zotlabs\Web\Router($a);
/* initialise content region */
if(! x(App::$page, 'content'))
App::$page['content'] = '';
call_hooks('page_content_top', App::$page['content']);
$Router->Dispatch($a);
// If you're just visiting, let javascript take you home
if(x($_SESSION, 'visitor_home')) {
$homebase = $_SESSION['visitor_home'];
} elseif(local_channel()) {
$homebase = z_root() . '/channel/' . App::$channel['channel_address'];
}
if(isset($homebase)) {
App::$page['content'] .= '<script>var homebase = "' . $homebase . '";</script>';
}
// now that we've been through the module content, see if the page reported
// a permission problem and if so, a 403 response would seem to be in order.
if(stristr(implode("", $_SESSION['sysmsg']), t('Permission denied'))) {
header($_SERVER['SERVER_PROTOCOL'] . ' 403 ' . t('Permission denied.'));
}
call_hooks('page_end', App::$page['content']);
construct_page($a);
killme();

View file

@ -77,16 +77,15 @@ but may be an issue with nginx or other web server platforms.
Example config scripts are available for these platforms in doc/install. Example config scripts are available for these platforms in doc/install.
Apache and nginx have the most support. Apache and nginx have the most support.
- PHP 5.4 or later. The later the better. - PHP 5.5 or later.
- PHP *command line* access with register_argc_argv set to true in the - PHP *command line* access with register_argc_argv set to true in the
php.ini file - and with no hosting provider restrictions on the use of php.ini file - and with no hosting provider restrictions on the use of
exec() and proc_open(). exec() and proc_open().
- curl, gd (with at least jpeg and png support), mysqli, mbstring, mcrypt, - curl, gd (with at least jpeg and png support), mysqli, mbstring, xml,
and openssl extensions. The imagick extension is not required but desirable. and openssl extensions. The imagick extension MAY be used instead of gd,
but is not required and MAY also be disabled via configuration option.
- xml extension is required if you want webdav to work.
- some form of email server or email gateway such that PHP mail() works. - some form of email server or email gateway such that PHP mail() works.

View file

@ -37,11 +37,11 @@ define( 'UNO', 0 );
// Choose a legal default timezone. If you are unsure, use "America/Los_Angeles". // Choose a legal default timezone. If you are unsure, use "America/Los_Angeles".
// It can be changed later and only applies to timestamps for anonymous viewers. // It can be changed later and only applies to timestamps for anonymous viewers.
$default_timezone = 'America/Los_Angeles'; App::$config['system']['timezone'] = 'America/Los_Angeles';
// What is your site name? DO NOT ADD A TRAILING SLASH! // What is your site name? DO NOT ADD A TRAILING SLASH!
App::$config['system']['baseurl'] = 'https://myredsite.example'; App::$config['system']['baseurl'] = 'https://mysite.example';
App::$config['system']['sitename'] = "Hubzilla"; App::$config['system']['sitename'] = "Hubzilla";
App::$config['system']['location_hash'] = 'if the auto install failed, put a unique random string here'; App::$config['system']['location_hash'] = 'if the auto install failed, put a unique random string here';

View file

@ -96,15 +96,15 @@ CREATE TABLE IF NOT EXISTS `account` (
CREATE TABLE IF NOT EXISTS `addon` ( CREATE TABLE IF NOT EXISTS `addon` (
`id` int(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,
`name` char(255) NOT NULL DEFAULT '', `aname` char(255) NOT NULL DEFAULT '',
`version` char(255) NOT NULL DEFAULT '', `version` char(255) NOT NULL DEFAULT '',
`installed` tinyint(1) NOT NULL DEFAULT '0', `installed` tinyint(1) NOT NULL DEFAULT '0',
`hidden` tinyint(1) NOT NULL DEFAULT '0', `hidden` tinyint(1) NOT NULL DEFAULT '0',
`timestamp` bigint(20) NOT NULL DEFAULT '0', `tstamp` bigint(20) NOT NULL DEFAULT '0',
`plugin_admin` tinyint(1) NOT NULL DEFAULT '0', `plugin_admin` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `hidden` (`hidden`), KEY `hidden` (`hidden`),
KEY `name` (`name`), KEY `aname` (`aname`),
KEY `installed` (`installed`) KEY `installed` (`installed`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8; ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
@ -188,7 +188,7 @@ CREATE TABLE IF NOT EXISTS `auth_codes` (
`client_id` varchar(20) NOT NULL DEFAULT '', `client_id` varchar(20) NOT NULL DEFAULT '',
`redirect_uri` varchar(200) NOT NULL DEFAULT '', `redirect_uri` varchar(200) NOT NULL DEFAULT '',
`expires` int(11) NOT NULL DEFAULT '0', `expires` int(11) NOT NULL DEFAULT '0',
`scope` varchar(250) NOT NULL DEFAULT '', `auth_scope` varchar(512) NOT NULL DEFAULT '',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8; ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
@ -342,7 +342,7 @@ CREATE TABLE IF NOT EXISTS `clients` (
`client_id` varchar(20) NOT NULL DEFAULT '', `client_id` varchar(20) NOT NULL DEFAULT '',
`pw` varchar(20) NOT NULL DEFAULT '', `pw` varchar(20) NOT NULL DEFAULT '',
`redirect_uri` varchar(200) NOT NULL DEFAULT '', `redirect_uri` varchar(200) NOT NULL DEFAULT '',
`name` text, `clname` text,
`icon` text, `icon` text,
`uid` int(11) NOT NULL DEFAULT '0', `uid` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`client_id`) PRIMARY KEY (`client_id`)
@ -434,74 +434,19 @@ CREATE TABLE IF NOT EXISTS `event` (
KEY `event_priority` (`event_priority`) KEY `event_priority` (`event_priority`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8; ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `fcontact` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`url` char(255) NOT NULL,
`name` char(255) NOT NULL,
`photo` char(255) NOT NULL,
`request` char(255) NOT NULL,
`nick` char(255) NOT NULL,
`addr` char(255) NOT NULL,
`batch` char(255) NOT NULL,
`notify` char(255) NOT NULL,
`poll` char(255) NOT NULL,
`confirm` char(255) NOT NULL,
`priority` tinyint(1) NOT NULL,
`network` char(32) NOT NULL,
`alias` char(255) NOT NULL,
`pubkey` text NOT NULL,
`updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`id`),
KEY `addr` (`addr`),
KEY `network` (`network`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `ffinder` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`uid` int(10) unsigned NOT NULL,
`cid` int(10) unsigned NOT NULL,
`fid` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
KEY `uid` (`uid`),
KEY `cid` (`cid`),
KEY `fid` (`fid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `fserver` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`server` char(255) NOT NULL DEFAULT '',
`posturl` char(255) NOT NULL DEFAULT '',
`key` text NOT NULL,
PRIMARY KEY (`id`),
KEY `server` (`server`),
KEY `posturl` (`posturl`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `fsuggest` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`uid` int(11) NOT NULL DEFAULT '0',
`cid` int(11) NOT NULL DEFAULT '0',
`name` char(255) NOT NULL DEFAULT '',
`url` char(255) NOT NULL DEFAULT '',
`request` char(255) NOT NULL DEFAULT '',
`photo` char(255) NOT NULL DEFAULT '',
`note` text NOT NULL,
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `groups` ( CREATE TABLE IF NOT EXISTS `groups` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`hash` char(255) NOT NULL DEFAULT '', `hash` char(255) NOT NULL DEFAULT '',
`uid` int(10) unsigned NOT NULL DEFAULT '0', `uid` int(10) unsigned NOT NULL DEFAULT '0',
`visible` tinyint(1) NOT NULL DEFAULT '0', `visible` tinyint(1) NOT NULL DEFAULT '0',
`deleted` tinyint(1) NOT NULL DEFAULT '0', `deleted` tinyint(1) NOT NULL DEFAULT '0',
`name` char(255) NOT NULL DEFAULT '', `gname` char(255) NOT NULL DEFAULT '',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `uid` (`uid`), KEY `uid` (`uid`),
KEY `visible` (`visible`), KEY `visible` (`visible`),
KEY `deleted` (`deleted`), KEY `deleted` (`deleted`),
KEY `hash` (`hash`) KEY `hash` (`hash`),
KEY `gname` (`gname`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8; ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `group_member` ( CREATE TABLE IF NOT EXISTS `group_member` (
@ -519,7 +464,7 @@ CREATE TABLE IF NOT EXISTS `hook` (
`id` int(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,
`hook` char(255) NOT NULL DEFAULT '', `hook` char(255) NOT NULL DEFAULT '',
`file` char(255) NOT NULL DEFAULT '', `file` char(255) NOT NULL DEFAULT '',
`function` char(255) NOT NULL DEFAULT '', `fn` char(255) NOT NULL DEFAULT '',
`priority` int(11) unsigned NOT NULL DEFAULT '0', `priority` int(11) unsigned NOT NULL DEFAULT '0',
`hook_version` int(11) NOT NULL DEFAULT '0', `hook_version` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
@ -883,6 +828,7 @@ CREATE TABLE IF NOT EXISTS `obj` (
`obj_imgurl` char(255) NOT NULL DEFAULT '', `obj_imgurl` char(255) NOT NULL DEFAULT '',
`obj_created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `obj_created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`obj_edited` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `obj_edited` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`obj_quantity` int(11) NOT NULL DEFAULT '0',
`allow_cid` mediumtext NOT NULL, `allow_cid` mediumtext NOT NULL,
`allow_gid` mediumtext NOT NULL, `allow_gid` mediumtext NOT NULL,
`deny_cid` mediumtext NOT NULL, `deny_cid` mediumtext NOT NULL,
@ -897,6 +843,7 @@ CREATE TABLE IF NOT EXISTS `obj` (
KEY `obj_imgurl` (`obj_imgurl`), KEY `obj_imgurl` (`obj_imgurl`),
KEY `obj_created` (`obj_created`), KEY `obj_created` (`obj_created`),
KEY `obj_edited` (`obj_edited`), KEY `obj_edited` (`obj_edited`),
KEY `obj_quantity` (`obj_quantity`),
KEY `obj_obj` (`obj_obj`) KEY `obj_obj` (`obj_obj`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8; ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
@ -1033,7 +980,7 @@ CREATE TABLE IF NOT EXISTS `profile` (
`profile_name` char(255) NOT NULL DEFAULT '', `profile_name` char(255) NOT NULL DEFAULT '',
`is_default` tinyint(1) NOT NULL DEFAULT '0', `is_default` tinyint(1) NOT NULL DEFAULT '0',
`hide_friends` tinyint(1) NOT NULL DEFAULT '0', `hide_friends` tinyint(1) NOT NULL DEFAULT '0',
`name` char(255) NOT NULL DEFAULT '', `fullname` char(255) NOT NULL DEFAULT '',
`pdesc` char(255) NOT NULL DEFAULT '', `pdesc` char(255) NOT NULL DEFAULT '',
`chandesc` text NOT NULL, `chandesc` text NOT NULL,
`dob` char(32) NOT NULL DEFAULT '0000-00-00', `dob` char(32) NOT NULL DEFAULT '0000-00-00',
@ -1046,7 +993,7 @@ CREATE TABLE IF NOT EXISTS `profile` (
`hometown` char(255) NOT NULL DEFAULT '', `hometown` char(255) NOT NULL DEFAULT '',
`gender` char(32) NOT NULL DEFAULT '', `gender` char(32) NOT NULL DEFAULT '',
`marital` char(255) NOT NULL DEFAULT '', `marital` char(255) NOT NULL DEFAULT '',
`with` text NOT NULL, `partner` text NOT NULL,
`howlong` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `howlong` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`sexual` char(255) NOT NULL DEFAULT '', `sexual` char(255) NOT NULL DEFAULT '',
`politic` char(255) NOT NULL DEFAULT '', `politic` char(255) NOT NULL DEFAULT '',
@ -1062,7 +1009,7 @@ CREATE TABLE IF NOT EXISTS `profile` (
`film` text NOT NULL, `film` text NOT NULL,
`interest` text NOT NULL, `interest` text NOT NULL,
`romance` text NOT NULL, `romance` text NOT NULL,
`work` text NOT NULL, `employment` text NOT NULL,
`education` text NOT NULL, `education` text NOT NULL,
`contact` text NOT NULL, `contact` text NOT NULL,
`channels` text NOT NULL, `channels` text NOT NULL,
@ -1108,7 +1055,7 @@ CREATE TABLE IF NOT EXISTS `register` (
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`uid` int(10) unsigned NOT NULL DEFAULT '0', `uid` int(10) unsigned NOT NULL DEFAULT '0',
`password` char(255) NOT NULL DEFAULT '', `password` char(255) NOT NULL DEFAULT '',
`language` char(16) NOT NULL DEFAULT '', `lang` char(16) NOT NULL DEFAULT '',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `hash` (`hash`), KEY `hash` (`hash`),
KEY `created` (`created`), KEY `created` (`created`),
@ -1118,7 +1065,7 @@ CREATE TABLE IF NOT EXISTS `register` (
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` char(255) NOT NULL DEFAULT '', `sid` char(255) NOT NULL DEFAULT '',
`data` text NOT NULL, `sess_data` text NOT NULL,
`expire` bigint(20) unsigned NOT NULL DEFAULT '0', `expire` bigint(20) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `sid` (`sid`), KEY `sid` (`sid`),
@ -1192,20 +1139,6 @@ CREATE TABLE IF NOT EXISTS `source` (
KEY `src_xchan` (`src_xchan`) KEY `src_xchan` (`src_xchan`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8; ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `spam` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`uid` int(11) NOT NULL DEFAULT '0',
`spam` int(11) NOT NULL DEFAULT '0',
`ham` int(11) NOT NULL DEFAULT '0',
`term` char(255) NOT NULL DEFAULT '',
`date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`id`),
KEY `uid` (`uid`),
KEY `spam` (`spam`),
KEY `ham` (`ham`),
KEY `term` (`term`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `sys_perms` ( CREATE TABLE IF NOT EXISTS `sys_perms` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`cat` char(255) NOT NULL DEFAULT '', `cat` char(255) NOT NULL DEFAULT '',
@ -1221,7 +1154,7 @@ CREATE TABLE IF NOT EXISTS `term` (
`uid` int(10) unsigned NOT NULL DEFAULT '0', `uid` int(10) unsigned NOT NULL DEFAULT '0',
`oid` int(10) unsigned NOT NULL DEFAULT '0', `oid` int(10) unsigned NOT NULL DEFAULT '0',
`otype` tinyint(3) unsigned NOT NULL DEFAULT '0', `otype` tinyint(3) unsigned NOT NULL DEFAULT '0',
`type` tinyint(3) unsigned NOT NULL DEFAULT '0', `ttype` tinyint(3) unsigned NOT NULL DEFAULT '0',
`term` char(255) NOT NULL DEFAULT '', `term` char(255) NOT NULL DEFAULT '',
`url` char(255) NOT NULL DEFAULT '', `url` char(255) NOT NULL DEFAULT '',
`imgurl` char(255) NOT NULL DEFAULT '', `imgurl` char(255) NOT NULL DEFAULT '',
@ -1230,7 +1163,7 @@ CREATE TABLE IF NOT EXISTS `term` (
PRIMARY KEY (`tid`), PRIMARY KEY (`tid`),
KEY `oid` (`oid`), KEY `oid` (`oid`),
KEY `otype` (`otype`), KEY `otype` (`otype`),
KEY `type` (`type`), KEY `ttype` (`ttype`),
KEY `term` (`term`), KEY `term` (`term`),
KEY `uid` (`uid`), KEY `uid` (`uid`),
KEY `aid` (`aid`), KEY `aid` (`aid`),
@ -1244,7 +1177,7 @@ CREATE TABLE IF NOT EXISTS `tokens` (
`secret` text NOT NULL, `secret` text NOT NULL,
`client_id` varchar(20) NOT NULL DEFAULT '', `client_id` varchar(20) NOT NULL DEFAULT '',
`expires` bigint(20) unsigned NOT NULL DEFAULT '0', `expires` bigint(20) unsigned NOT NULL DEFAULT '0',
`scope` varchar(200) NOT NULL DEFAULT '', `auth_scope` varchar(512) NOT NULL DEFAULT '',
`uid` int(11) NOT NULL DEFAULT '0', `uid` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `client_id` (`client_id`), KEY `client_id` (`client_id`),
@ -1272,13 +1205,13 @@ CREATE TABLE IF NOT EXISTS `updates` (
CREATE TABLE IF NOT EXISTS `verify` ( CREATE TABLE IF NOT EXISTS `verify` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`channel` int(10) unsigned NOT NULL DEFAULT '0', `channel` int(10) unsigned NOT NULL DEFAULT '0',
`type` char(32) NOT NULL DEFAULT '', `vtype` char(32) NOT NULL DEFAULT '',
`token` char(255) NOT NULL DEFAULT '', `token` char(255) NOT NULL DEFAULT '',
`meta` char(255) NOT NULL DEFAULT '', `meta` char(255) 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 (`id`), PRIMARY KEY (`id`),
KEY `channel` (`channel`), KEY `channel` (`channel`),
KEY `type` (`type`), KEY `vtype` (`vtype`),
KEY `token` (`token`), KEY `token` (`token`),
KEY `meta` (`meta`), KEY `meta` (`meta`),
KEY `created` (`created`) KEY `created` (`created`)

View file

@ -94,16 +94,16 @@ create index "account_level" on account ("account_level");
create index "account_password_changed" on account ("account_password_changed"); create index "account_password_changed" on account ("account_password_changed");
CREATE TABLE "addon" ( CREATE TABLE "addon" (
"id" serial NOT NULL, "id" serial NOT NULL,
"name" text NOT NULL, "aname" text NOT NULL,
"version" text NOT NULL DEFAULT '0', "version" text NOT NULL DEFAULT '0',
"installed" numeric(1) NOT NULL DEFAULT '0', "installed" numeric(1) NOT NULL DEFAULT '0',
"hidden" numeric(1) NOT NULL DEFAULT '0', "hidden" numeric(1) NOT NULL DEFAULT '0',
"timestamp" numeric(20) NOT NULL DEFAULT '0', "tstamp" numeric(20) NOT NULL DEFAULT '0',
"plugin_admin" numeric(1) NOT NULL DEFAULT '0', "plugin_admin" numeric(1) NOT NULL DEFAULT '0',
PRIMARY KEY ("id") PRIMARY KEY ("id")
); );
create index "addon_hidden_idx" on addon ("hidden"); create index "addon_hidden_idx" on addon ("hidden");
create index "addon_name_idx" on addon ("name"); create index "addon_name_idx" on addon ("aname");
create index "addon_installed_idx" on addon ("installed"); create index "addon_installed_idx" on addon ("installed");
CREATE TABLE "app" ( CREATE TABLE "app" (
"id" serial NOT NULL, "id" serial NOT NULL,
@ -184,7 +184,7 @@ CREATE TABLE "auth_codes" (
"client_id" varchar(20) NOT NULL, "client_id" varchar(20) NOT NULL,
"redirect_uri" varchar(200) NOT NULL, "redirect_uri" varchar(200) NOT NULL,
"expires" bigint NOT NULL, "expires" bigint NOT NULL,
"scope" varchar(250) NOT NULL, "auth_scope" varchar(512) NOT NULL,
PRIMARY KEY ("id") PRIMARY KEY ("id")
); );
CREATE TABLE "cache" ( CREATE TABLE "cache" (
@ -333,7 +333,7 @@ CREATE TABLE "clients" (
"client_id" varchar(20) NOT NULL, "client_id" varchar(20) NOT NULL,
"pw" varchar(20) NOT NULL, "pw" varchar(20) NOT NULL,
"redirect_uri" varchar(200) NOT NULL, "redirect_uri" varchar(200) NOT NULL,
"name" text, "clname" text,
"icon" text, "icon" text,
"uid" bigint NOT NULL DEFAULT '0', "uid" bigint NOT NULL DEFAULT '0',
PRIMARY KEY ("client_id") PRIMARY KEY ("client_id")
@ -428,62 +428,6 @@ create index "event_status_idx" on event ("event_status");
create index "event_sequence_idx" on event ("event_sequence"); create index "event_sequence_idx" on event ("event_sequence");
create index "event_priority_idx" on event ("event_priority"); create index "event_priority_idx" on event ("event_priority");
CREATE TABLE "fcontact" (
"id" serial NOT NULL,
"url" text NOT NULL,
"name" text NOT NULL,
"photo" text NOT NULL,
"request" text NOT NULL,
"nick" text NOT NULL,
"addr" text NOT NULL,
"batch" text NOT NULL,
"notify" text NOT NULL,
"poll" text NOT NULL,
"confirm" text NOT NULL,
"priority" numeric(1) NOT NULL,
"network" varchar(32) NOT NULL DEFAULT '',
"alias" text NOT NULL,
"pubkey" text NOT NULL,
"updated" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00',
PRIMARY KEY ("id")
);
create index "fcontact_addr_idx" on fcontact ("addr");
create index "fcontact_network_idx" on fcontact ("network");
CREATE TABLE "ffinder" (
"id" serial NOT NULL,
"uid" bigint NOT NULL,
"cid" bigint NOT NULL,
"fid" bigint NOT NULL,
PRIMARY KEY ("id")
);
create index "ffinder_uid_idx" on ffinder ("uid");
create index "ffinder_cid_idx" on ffinder ("cid");
create index "ffinder_fid_idx" on ffinder ("fid");
CREATE TABLE "fserver" (
"id" serial NOT NULL,
"server" text NOT NULL,
"posturl" text NOT NULL,
"key" text NOT NULL,
PRIMARY KEY ("id")
);
create index "fserver_server_idx" on fserver ("server");
create index "fserver_posturl_idx" on fserver ("posturl");
CREATE TABLE "fsuggest" (
"id" serial NOT NULL,
"uid" bigint NOT NULL,
"cid" bigint NOT NULL,
"name" text NOT NULL,
"url" text NOT NULL,
"request" text NOT NULL,
"photo" text NOT NULL,
"note" text NOT NULL,
"created" timestamp NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "group_member" ( CREATE TABLE "group_member" (
"id" serial NOT NULL, "id" serial NOT NULL,
"uid" bigint NOT NULL, "uid" bigint NOT NULL,
@ -501,7 +445,7 @@ CREATE TABLE "groups" (
"uid" bigint NOT NULL, "uid" bigint NOT NULL,
"visible" numeric(1) NOT NULL DEFAULT '0', "visible" numeric(1) NOT NULL DEFAULT '0',
"deleted" numeric(1) NOT NULL DEFAULT '0', "deleted" numeric(1) NOT NULL DEFAULT '0',
"name" text NOT NULL, "gname" text NOT NULL,
PRIMARY KEY ("id") PRIMARY KEY ("id")
); );
@ -514,7 +458,7 @@ CREATE TABLE "hook" (
"id" serial NOT NULL, "id" serial NOT NULL,
"hook" text NOT NULL, "hook" text NOT NULL,
"file" text NOT NULL, "file" text NOT NULL,
"function" text NOT NULL, "fn" text NOT NULL,
"priority" bigint NOT NULL DEFAULT '0', "priority" bigint NOT NULL DEFAULT '0',
"hook_version" smallint NOT NULL DEFAULT '0', "hook_version" smallint NOT NULL DEFAULT '0',
PRIMARY KEY ("id") PRIMARY KEY ("id")
@ -873,6 +817,7 @@ CREATE TABLE "obj" (
"obj_imgurl" char(255) NOT NULL DEFAULT '', "obj_imgurl" char(255) NOT NULL DEFAULT '',
"obj_created" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00', "obj_created" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00',
"obj_edited" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00', "obj_edited" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00',
"obj_quantity" int(11) NOT NULL DEFAUL '0'.
"allow_cid" text NOT NULL, "allow_cid" text NOT NULL,
"allow_gid" text NOT NULL, "allow_gid" text NOT NULL,
"deny_cid" text NOT NULL, "deny_cid" text NOT NULL,
@ -890,6 +835,7 @@ create index "obj_url" on obj ("obj_url");
create index "obj_imgurl" on obj ("obj_imgurl"); create index "obj_imgurl" on obj ("obj_imgurl");
create index "obj_created" on obj ("obj_created"); create index "obj_created" on obj ("obj_created");
create index "obj_edited" on obj ("obj_edited"); create index "obj_edited" on obj ("obj_edited");
create index "obj_quantity" on obj ("obj_quantity");
CREATE TABLE "outq" ( CREATE TABLE "outq" (
"outq_hash" text NOT NULL, "outq_hash" text NOT NULL,
@ -1022,7 +968,7 @@ CREATE TABLE "profile" (
"profile_name" text NOT NULL, "profile_name" text NOT NULL,
"is_default" numeric(1) NOT NULL DEFAULT '0', "is_default" numeric(1) NOT NULL DEFAULT '0',
"hide_friends" numeric(1) NOT NULL DEFAULT '0', "hide_friends" numeric(1) NOT NULL DEFAULT '0',
"name" text NOT NULL, "fullname" text NOT NULL,
"pdesc" text NOT NULL DEFAULT '', "pdesc" text NOT NULL DEFAULT '',
"chandesc" text NOT NULL DEFAULT '', "chandesc" text NOT NULL DEFAULT '',
"dob" varchar(32) NOT NULL DEFAULT '', "dob" varchar(32) NOT NULL DEFAULT '',
@ -1035,7 +981,7 @@ CREATE TABLE "profile" (
"hometown" text NOT NULL DEFAULT '', "hometown" text NOT NULL DEFAULT '',
"gender" varchar(32) NOT NULL DEFAULT '', "gender" varchar(32) NOT NULL DEFAULT '',
"marital" text NOT NULL DEFAULT '', "marital" text NOT NULL DEFAULT '',
"with" text NOT NULL DEFAULT '', "partner" text NOT NULL DEFAULT '',
"howlong" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00', "howlong" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00',
"sexual" text NOT NULL DEFAULT '', "sexual" text NOT NULL DEFAULT '',
"politic" text NOT NULL DEFAULT '', "politic" text NOT NULL DEFAULT '',
@ -1051,7 +997,7 @@ CREATE TABLE "profile" (
"film" text NOT NULL DEFAULT '', "film" text NOT NULL DEFAULT '',
"interest" text NOT NULL DEFAULT '', "interest" text NOT NULL DEFAULT '',
"romance" text NOT NULL DEFAULT '', "romance" text NOT NULL DEFAULT '',
"work" text NOT NULL DEFAULT '', "employment" text NOT NULL DEFAULT '',
"education" text NOT NULL DEFAULT '', "education" text NOT NULL DEFAULT '',
"contact" text NOT NULL DEFAULT '', "contact" text NOT NULL DEFAULT '',
"channels" text NOT NULL DEFAULT '', "channels" text NOT NULL DEFAULT '',
@ -1097,7 +1043,7 @@ CREATE TABLE "register" (
"created" timestamp NOT NULL, "created" timestamp NOT NULL,
"uid" bigint NOT NULL, "uid" bigint NOT NULL,
"password" text NOT NULL, "password" text NOT NULL,
"language" varchar(16) NOT NULL, "lang" varchar(16) NOT NULL,
PRIMARY KEY ("id") PRIMARY KEY ("id")
); );
create index "reg_hash" on register ("hash"); create index "reg_hash" on register ("hash");
@ -1106,7 +1052,7 @@ create index "reg_uid" on register ("uid");
CREATE TABLE "session" ( CREATE TABLE "session" (
"id" serial, "id" serial,
"sid" text NOT NULL, "sid" text NOT NULL,
"data" text NOT NULL, "sess_data" text NOT NULL,
"expire" numeric(20) NOT NULL, "expire" numeric(20) NOT NULL,
PRIMARY KEY ("id") PRIMARY KEY ("id")
); );
@ -1177,19 +1123,6 @@ CREATE TABLE "source" (
create index "src_channel_id" on "source" ("src_channel_id"); create index "src_channel_id" on "source" ("src_channel_id");
create index "src_channel_xchan" on "source" ("src_channel_xchan"); create index "src_channel_xchan" on "source" ("src_channel_xchan");
create index "src_xchan" on "source" ("src_xchan"); create index "src_xchan" on "source" ("src_xchan");
CREATE TABLE "spam" (
"id" serial NOT NULL,
"uid" bigint NOT NULL,
"spam" bigint NOT NULL DEFAULT '0',
"ham" bigint NOT NULL DEFAULT '0',
"term" text NOT NULL,
"date" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00',
PRIMARY KEY ("id")
);
create index "spam_uid" on spam ("uid");
create index "spam_spam" on spam ("spam");
create index "spam_ham" on spam ("ham");
create index "spam_term" on spam ("term");
CREATE TABLE "sys_perms" ( CREATE TABLE "sys_perms" (
"id" serial NOT NULL, "id" serial NOT NULL,
"cat" text NOT NULL, "cat" text NOT NULL,
@ -1204,7 +1137,7 @@ CREATE TABLE "term" (
"uid" bigint NOT NULL DEFAULT '0', "uid" bigint NOT NULL DEFAULT '0',
"oid" bigint NOT NULL, "oid" bigint NOT NULL,
"otype" numeric(3) NOT NULL, "otype" numeric(3) NOT NULL,
"type" numeric(3) NOT NULL, "ttype" numeric(3) NOT NULL,
"term" text NOT NULL, "term" text NOT NULL,
"url" text NOT NULL, "url" text NOT NULL,
"imgurl" text NOT NULL DEFAULT '', "imgurl" text NOT NULL DEFAULT '',
@ -1214,7 +1147,7 @@ CREATE TABLE "term" (
); );
create index "term_oid" on term ("oid"); create index "term_oid" on term ("oid");
create index "term_otype" on term ("otype"); create index "term_otype" on term ("otype");
create index "term_type" on term ("type"); create index "term_ttype" on term ("ttype");
create index "term_term" on term ("term"); create index "term_term" on term ("term");
create index "term_uid" on term ("uid"); create index "term_uid" on term ("uid");
create index "term_aid" on term ("aid"); create index "term_aid" on term ("aid");
@ -1226,7 +1159,7 @@ CREATE TABLE "tokens" (
"secret" text NOT NULL, "secret" text NOT NULL,
"client_id" varchar(20) NOT NULL, "client_id" varchar(20) NOT NULL,
"expires" numeric(20) NOT NULL, "expires" numeric(20) NOT NULL,
"scope" varchar(200) NOT NULL, "auth_scope" varchar(512) NOT NULL,
"uid" bigint NOT NULL, "uid" bigint NOT NULL,
PRIMARY KEY ("id") PRIMARY KEY ("id")
); );
@ -1253,14 +1186,14 @@ create index "ud_last" on updates ("ud_last");
CREATE TABLE "verify" ( CREATE TABLE "verify" (
"id" serial NOT NULL, "id" serial NOT NULL,
"channel" bigint NOT NULL DEFAULT '0', "channel" bigint NOT NULL DEFAULT '0',
"type" varchar(32) NOT NULL DEFAULT '', "vtype" varchar(32) NOT NULL DEFAULT '',
"token" text NOT NULL DEFAULT '', "token" text NOT NULL DEFAULT '',
"meta" text NOT NULL DEFAULT '', "meta" text NOT NULL DEFAULT '',
"created" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00', "created" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00',
PRIMARY KEY ("id") PRIMARY KEY ("id")
); );
create index "verify_channel" on verify ("channel"); create index "verify_channel" on verify ("channel");
create index "verify_type" on verify ("type"); create index "verify_vtype" on verify ("vtype");
create index "verify_token" on verify ("token"); create index "verify_token" on verify ("token");
create index "verify_meta" on verify ("meta"); create index "verify_meta" on verify ("meta");
create index "verify_created" on verify ("created"); create index "verify_created" on verify ("created");

View file

@ -1,6 +1,6 @@
<?php <?php
define( 'UPDATE_VERSION' , 1168 ); define( 'UPDATE_VERSION' , 1173 );
/** /**
* *
@ -2097,3 +2097,92 @@ function update_r1167() {
return UPDATE_SUCCESS; return UPDATE_SUCCESS;
return UPDATE_FAILED; return UPDATE_FAILED;
} }
function update_r1168() {
$r1 = q("alter table obj add obj_quantity int not null default '0' ");
if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) {
$r2 = q("create index \"obj_quantity_idx\" on obj (\"obj_quantity\") ");
}
else {
$r2 = q("alter table obj add index ( obj_quantity ) ");
}
if($r1 && $r2)
return UPDATE_SUCCESS;
return UPDATE_FAILED;
}
function update_r1169() {
if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) {
$r1 = q("ALTER TABLE `addon` CHANGE `timestamp` `tstamp` numeric( 20 ) UNSIGNED NOT NULL DEFAULT '0' ");
$r2 = q("ALTER TABLE `addon` CHANGE `name` `aname` text NOT NULL DEFAULT '' ");
$r3 = q("ALTER TABLE `hook` CHANGE `function` `fn` text NOT NULL DEFAULT '' ");
}
else {
$r1 = q("ALTER TABLE `addon` CHANGE `timestamp` `tstamp` BIGINT( 20 ) UNSIGNED NOT NULL DEFAULT '0' ");
$r2 = q("ALTER TABLE `addon` CHANGE `name` `aname` CHAR(255) NOT NULL DEFAULT '' ");
$r3 = q("ALTER TABLE `hook` CHANGE `function` `fn` CHAR(255) NOT NULL DEFAULT '' ");
}
if($r1 && $r2 && $r3)
return UPDATE_SUCCESS;
return UPDATE_FAILED;
}
function update_r1170() {
$r1 = q("drop table fcontact");
$r2 = q("drop table ffinder");
$r3 = q("drop table fserver");
$r4 = q("drop table fsuggest");
$r5 = q("drop table spam");
if($r1 && $r2 && $r3 && $r4 && $r5)
return UPDATE_SUCCESS;
return UPDATE_FAILED;
}
function update_r1171() {
$r1 = q("ALTER TABLE verify CHANGE `type` `vtype` varchar(32) NOT NULL DEFAULT '' ");
$r2 = q("ALTER TABLE tokens CHANGE `scope` `auth_scope` varchar(512) NOT NULL DEFAULT '' ");
$r3 = q("ALTER TABLE auth_codes CHANGE `scope` `auth_scope` varchar(512) NOT NULL DEFAULT '' ");
$r4 = q("ALTER TABLE clients CHANGE `name` `clname` TEXT ");
$r5 = q("ALTER TABLE session CHANGE `data` `sess_data` TEXT NOT NULL ");
$r6 = q("ALTER TABLE register CHANGE `language` `lang` varchar(16) NOT NULL DEFAULT '' ");
if($r1 && $r2 && $r3 && $r4 && $r5 && $r6)
return UPDATE_SUCCESS;
return UPDATE_FAILED;
}
function update_r1172() {
$r1 = q("ALTER TABLE term CHANGE `type` `ttype` int(3) NOT NULL DEFAULT '0' ");
if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) {
$r2 = q("ALTER TABLE groups CHANGE `name` `gname` TEXT NOT NULL ");
$r3 = q("ALTER TABLE profile CHANGE `name` `fullname` TEXT NOT NULL ");
$r4 = q("ALTER TABLE profile CHANGE `with` `partner` TEXT NOT NULL ");
$r5 = q("ALTER TABLE profile CHANGE `work` `employment` TEXT NOT NULL ");
}
else {
$r2 = q("ALTER TABLE groups CHANGE `name` `gname` char(255) NOT NULL DEFAULT '' ");
$r3 = q("ALTER TABLE profile CHANGE `name` `fullname` char(255) NOT NULL DEFAULT '' ");
$r4 = q("ALTER TABLE profile CHANGE `with` `partner` char(255) NOT NULL DEFAULT '' ");
$r5 = q("ALTER TABLE profile CHANGE `work` `employment` TEXT NOT NULL ");
}
if($r1 && $r2 && $r3 && $r4 && $r5)
return UPDATE_SUCCESS;
return UPDATE_FAILED;
}

View file

@ -1,9 +0,0 @@
.editorWYSIWYG {font: 10pt Tahoma;border:none;}
.editorBBCODE {font: 9pt "Courier New";}
div.richeditor div.editbar {margin-top:5px;background-image:url('images/editbar_bg.gif');border-left:1px solid silver;border-right:1px solid silver;border-top:1px solid silver;border-bottom:none;}
div.richeditor div button{vertical-align:middle;width:25px;height:25px;border:1px solid transparent;background-color:Transparent;cursor:pointer;color:Black;background-position:center;background-repeat:no-repeat;background-image:none;}
div.richeditor div button:hover{border:1px solid silver;}
div.richeditor div.container {border-top:none;border-bottom:1px solid silver;border-left:1px solid silver;border-right:1px solid silver;}
div.richeditor textarea{padding:0px 0px 0px 0px;border:none;}
div.richeditor iframe{background-color:#ffffff;border:none;}

View file

@ -1,524 +0,0 @@
/*
WYSIWYG-BBCODE editor
Copyright (c) 2009, Jitbit Sotware, http://www.jitbit.com/
PROJECT HOME: http://wysiwygbbcode.codeplex.com/
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the <organization> nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY Jitbit Software ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL Jitbit Software BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
function REDITOR(elm,wysiwyg) {
this.elm = elm;
this.wysiwyg = wysiwyg;
}
REDITOR.prototype.showEditor = function() {
if (! this.enableWysiwyg) return;
this.editorVisible = true;
this.content = document.getElementById(this.body_id).value;
this.myeditor = this.ifm.contentWindow.document;
bbcode2html();
this.myeditor.designMode = "on";
this.myeditor.open();
this.myeditor.write('<html><head><link href="editor.css" rel="Stylesheet" type="text/css" /></head>');
this.myeditor.write('<body style="margin:0px 0px 0px 0px" class="editorWYSIWYG">');
this.myeditor.write(content);
this.myeditor.write('</body></html>');
this.myeditor.close();
if (this.myeditor.attachEvent) {
if(parent.ProcessKeyPress)
this.myeditor.attachEvent("onkeydown", parent.ProcessKeyPress);
this.myeditor.attachEvent("onkeypress", kp);
}
else if (this.myeditor.addEventListener) {
if (parent.ProcessKeyPress)
this.myeditor.addEventListener("keydown", parent.ProcessKeyPress, true);
this.myeditor.addEventListener("keypress",kp,true);
}
}
var myeditor, ifm;
var body_id, textboxelement;
var content;
var isIE = /msie|MSIE/.test(navigator.userAgent);
var isChrome = /Chrome/.test(navigator.userAgent);
var isSafari = /Safari/.test(navigator.userAgent) && !isChrome;
var browser = isIE || window.opera;
var textRange;
var enter = 0;
var editorVisible = false;
var enableWysiwyg = false;
function rep(re, str) {
content = content.replace(re, str);
}
function initEditor(textarea_id, wysiwyg) {
if(wysiwyg!=undefined)
enableWysiwyg = wysiwyg;
else
enableWysiwyg = true;
body_id = textarea_id;
textboxelement = document.getElementById(body_id);
textboxelement.setAttribute('class', 'editorBBCODE');
textboxelement.className = "editorBBCODE";
if (enableWysiwyg) {
ifm = document.createElement("iframe");
ifm.setAttribute("id", "rte");
ifm.setAttribute("frameborder", "0");
ifm.style.width = textboxelement.style.width;
ifm.style.height = textboxelement.style.height;
textboxelement.parentNode.insertBefore(ifm, textboxelement);
textboxelement.style.display = 'none';
if (ifm) {
ShowEditor();
} else
setTimeout('ShowEditor()', 100);
}
}
function getStyle(el,styleProp)
{
var x = document.getElementById(el);
if (x.currentStyle)
var y = x.currentStyle[styleProp];
else if (window.getComputedStyle)
var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
return y;
}
function ShowEditor() {
if (!enableWysiwyg) return;
editorVisible = true;
content = document.getElementById(body_id).value;
myeditor = ifm.contentWindow.document;
bbcode2html();
myeditor.designMode = "on";
myeditor.open();
myeditor.write('<html><head><link href="editor.css" rel="Stylesheet" type="text/css" /></head>');
myeditor.write('<body style="margin:0px 0px 0px 0px" class="editorWYSIWYG">');
myeditor.write(content);
myeditor.write('</body></html>');
myeditor.close();
if (myeditor.attachEvent) {
if(parent.ProcessKeyPress)
myeditor.attachEvent("onkeydown", parent.ProcessKeyPress);
myeditor.attachEvent("onkeypress", kp);
}
else if (myeditor.addEventListener) {
if (parent.ProcessKeyPress)
myeditor.addEventListener("keydown", parent.ProcessKeyPress, true);
myeditor.addEventListener("keypress",kp,true);
}
}
function SwitchEditor() {
if (editorVisible) {
doCheck();
ifm.style.display = 'none';
textboxelement.style.display = '';
editorVisible = false;
}
else {
if (enableWysiwyg && ifm) {
ifm.style.display = '';
textboxelement.style.display = 'none';
ShowEditor();
editorVisible = true;
}
}
}
function html2bbcode() {
rep(/<img\s[^<>]*?src=\"?([^<>]*?)\"?(\s[^<>]*)?\/?>/gi,"[img]$1[/img]");
rep(/<\/(strong|b)>/gi, "[/b]");
rep(/<(strong|b)(\s[^<>]*)?>/gi,"[b]");
rep(/<\/(em|i)>/gi,"[/i]");
rep(/<(em|i)(\s[^<>]*)?>/gi,"[i]");
rep(/<\/u>/gi, "[/u]");
rep(/\n/gi, " ");
rep(/\r/gi, " ");
rep(/<u(\s[^<>]*)?>/gi, "[u]");
rep(/<div><br(\s[^<>]*)?>/gi, "<div>");//chrome-safari fix to prevent double linefeeds
rep(/<br(\s[^<>]*)?>/gi,"\n");
rep(/<p(\s[^<>]*)?>/gi,"");
rep(/<\/p>/gi, "\n");
rep(/<ul>/gi, "[ul]");
rep(/<\/ul>/gi, "[/ul]");
rep(/<ol>/gi, "[ol]");
rep(/<\/ol>/gi, "[/ol]");
rep(/<li>/gi, "[li]");
rep(/<\/li>/gi, "[/li]");
rep(/<\/div>\s*<div([^<>]*)>/gi, "</span>\n<span$1>");//chrome-safari fix to prevent double linefeeds
rep(/<div([^<>]*)>/gi,"\n<span$1>");
rep(/<\/div>/gi,"</span>\n");
rep(/&nbsp;/gi," ");
rep(/&quot;/gi,"\"");
rep(/&amp;/gi,"&");
var sc, sc2;
do {
sc = content;
rep(/<font\s[^<>]*?color=\"?([^<>]*?)\"?(\s[^<>]*)?>([^<>]*?)<\/font>/gi,"[color=$1]$3[/color]");
if(sc==content)
rep(/<font[^<>]*>([^<>]*?)<\/font>/gi,"$1");
rep(/<a\s[^<>]*?href=\"?([^<>]*?)\"?(\s[^<>]*)?>([^<>]*?)<\/a>/gi,"[url=$1]$3[/url]");
sc2 = content;
rep(/<(span|blockquote|pre)\s[^<>]*?style=\"?font-weight: ?bold;?\"?\s*([^<]*?)<\/\1>/gi,"[b]<$1 style=$2</$1>[/b]");
rep(/<(span|blockquote|pre)\s[^<>]*?style=\"?font-weight: ?normal;?\"?\s*([^<]*?)<\/\1>/gi,"<$1 style=$2</$1>");
rep(/<(span|blockquote|pre)\s[^<>]*?style=\"?font-style: ?italic;?\"?\s*([^<]*?)<\/\1>/gi,"[i]<$1 style=$2</$1>[/i]");
rep(/<(span|blockquote|pre)\s[^<>]*?style=\"?font-style: ?normal;?\"?\s*([^<]*?)<\/\1>/gi,"<$1 style=$2</$1>");
rep(/<(span|blockquote|pre)\s[^<>]*?style=\"?text-decoration: ?underline;?\"?\s*([^<]*?)<\/\1>/gi,"[u]<$1 style=$2</$1>[/u]");
rep(/<(span|blockquote|pre)\s[^<>]*?style=\"?text-decoration: ?none;?\"?\s*([^<]*?)<\/\1>/gi,"<$1 style=$2</$1>");
rep(/<(span|blockquote|pre)\s[^<>]*?style=\"?color: ?([^<>]*?);\"?\s*([^<]*?)<\/\1>/gi, "[color=$2]<$1 style=$3</$1>[/color]");
rep(/<(span|blockquote|pre)\s[^<>]*?style=\"?font-family: ?([^<>]*?);\"?\s*([^<]*?)<\/\1>/gi, "[font=$2]<$1 style=$3</$1>[/font]");
rep(/<(blockquote|pre)\s[^<>]*?style=\"?\"? (class=|id=)([^<>]*)>([^<>]*?)<\/\1>/gi, "<$1 $2$3>$4</$1>");
rep(/<pre>([^<>]*?)<\/pre>/gi, "[code]$1[/code]");
rep(/<span\s[^<>]*?style=\"?\"?>([^<>]*?)<\/span>/gi, "$1");
if(sc2==content) {
rep(/<span[^<>]*>([^<>]*?)<\/span>/gi, "$1");
sc2 = content;
}
}while(sc!=content)
rep(/<[^<>]*>/gi,"");
rep(/&lt;/gi,"<");
rep(/&gt;/gi,">");
do {
sc = content;
rep(/\[(b|i|u)\]\[quote([^\]]*)\]([\s\S]*?)\[\/quote\]\[\/\1\]/gi, "[quote$2][$1]$3[/$1][/quote]");
rep(/\[color=([^\]]*)\]\[quote([^\]]*)\]([\s\S]*?)\[\/quote\]\[\/color\]/gi, "[quote$2][color=$1]$3[/color][/quote]");
rep(/\[(b|i|u)\]\[code\]([\s\S]*?)\[\/code\]\[\/\1\]/gi, "[code][$1]$2[/$1][/code]");
rep(/\[color=([^\]]*)\]\[code\]([\s\S]*?)\[\/code\]\[\/color\]/gi, "[code][color=$1]$2[/color][/code]");
}while(sc!=content)
//clean up empty tags
do {
sc = content;
rep(/\[b\]\[\/b\]/gi, "");
rep(/\[i\]\[\/i\]/gi, "");
rep(/\[u\]\[\/u\]/gi, "");
rep(/\[quote[^\]]*\]\[\/quote\]/gi, "");
rep(/\[code\]\[\/code\]/gi, "");
rep(/\[url=([^\]]+)\]\[\/url\]/gi, "");
rep(/\[img\]\[\/img\]/gi, "");
rep(/\[color=([^\]]*)\]\[\/color\]/gi, "");
}while(sc!=content)
}
function bbcode2html() {
// example: [b] to <strong>
rep(/\</gi,"&lt;"); //removing html tags
rep(/\>/gi,"&gt;");
rep(/\n/gi, "<br />");
rep(/\[ul\]/gi, "<ul>");
rep(/\[\/ul\]/gi, "</ul>");
rep(/\[ol\]/gi, "<ol>");
rep(/\[\/ol\]/gi, "</ol>");
rep(/\[li\]/gi, "<li>");
rep(/\[\/li\]/gi, "</li>");
if(browser) {
rep(/\[b\]/gi,"<strong>");
rep(/\[\/b\]/gi,"</strong>");
rep(/\[i\]/gi,"<em>");
rep(/\[\/i\]/gi,"</em>");
rep(/\[u\]/gi,"<u>");
rep(/\[\/u\]/gi,"</u>");
}else {
rep(/\[b\]/gi,"<span style=\"font-weight: bold;\">");
rep(/\[i\]/gi,"<span style=\"font-style: italic;\">");
rep(/\[u\]/gi,"<span style=\"text-decoration: underline;\">");
rep(/\[\/(b|i|u)\]/gi,"</span>");
}
rep(/\[img\]([^\"]*?)\[\/img\]/gi,"<img src=\"$1\" />");
var sc;
do {
sc = content;
rep(/\[url=([^\]]+)\]([\s\S]*?)\[\/url\]/gi,"<a href=\"$1\">$2</a>");
rep(/\[url\]([\s\S]*?)\[\/url\]/gi,"<a href=\"$1\">$1</a>");
if(browser) {
rep(/\[color=([^\]]*?)\]([\s\S]*?)\[\/color\]/gi, "<font color=\"$1\">$2</font>");
rep(/\[font=([^\]]*?)\]([\s\S]*?)\[\/font\]/gi, "<font face=\"$1\">$2</font>");
} else {
rep(/\[color=([^\]]*?)\]([\s\S]*?)\[\/color\]/gi, "<span style=\"color: $1;\">$2</span>");
rep(/\[font=([^\]]*?)\]([\s\S]*?)\[\/font\]/gi, "<span style=\"font-family: $1;\">$2</span>");
}
rep(/\[code\]([\s\S]*?)\[\/code\]/gi,"<pre>$1</pre>&nbsp;");
}while(sc!=content);
}
function doCheck() {
if (!editorVisible) {
ShowEditor();
}
content = myeditor.body.innerHTML;
html2bbcode();
document.getElementById(body_id).value = content;
}
function stopEvent(evt){
evt || window.event;
if (evt.stopPropagation){
evt.stopPropagation();
evt.preventDefault();
}else if(typeof evt.cancelBubble != "undefined"){
evt.cancelBubble = true;
evt.returnValue = false;
}
return false;
}
function doQuote() {
if (editorVisible) {
ifm.contentWindow.focus();
if (isIE) {
textRange = ifm.contentWindow.document.selection.createRange();
var newTxt = "[quote=]" + textRange.text + "[/quote]";
textRange.text = newTxt;
}
else {
var edittext = ifm.contentWindow.getSelection().getRangeAt(0);
var original = edittext.toString();
edittext.deleteContents();
edittext.insertNode(document.createTextNode("[quote=]" + original + "[/quote]"));
}
}
else {
AddTag('[quote=]', '[/quote]');
}
}
function kp(e){
if(isIE)
var k = e.keyCode;
else
var k = e.which;
if(k==13) {
if(isIE) {
var r = myeditor.selection.createRange();
if (r.parentElement().tagName.toLowerCase() != "li") {
r.pasteHTML('<br/>');
if (r.move('character'))
r.move('character', -1);
r.select();
stopEvent(e);
return false;
}
}
}else
enter = 0;
}
function InsertSmile(txt) {
InsertText(txt);
document.getElementById('divSmilies').style.display = 'none';
}
function InsertYoutube() {
InsertText("http://www.youtube.com/watch?v=XXXXXXXXXXX");
}
function InsertText(txt) {
if (editorVisible)
insertHtml(txt);
else
textboxelement.value += txt;
}
function doClick(command) {
if (editorVisible) {
ifm.contentWindow.focus();
myeditor.execCommand(command, false, null);
}
else {
switch (command) {
case 'bold':
AddTag('[b]', '[/b]'); break;
case 'italic':
AddTag('[i]', '[/i]'); break;
case 'underline':
AddTag('[u]', '[/u]'); break;
case 'InsertUnorderedList':
AddTag('[ul][li]', '[/li][/ul]'); break;
}
}
}
function doColor(color) {
ifm.contentWindow.focus();
if (isIE) {
textRange = ifm.contentWindow.document.selection.createRange();
textRange.select();
}
myeditor.execCommand('forecolor', false, color);
}
function doLink() {
if (editorVisible) {
ifm.contentWindow.focus();
var mylink = prompt("Enter a URL:", "http://");
if ((mylink != null) && (mylink != "")) {
if (isIE) { //IE
var range = ifm.contentWindow.document.selection.createRange();
if (range.text == '') {
range.pasteHTML("<a href='" + mylink + "'>" + mylink + "</a>");
}
else
myeditor.execCommand("CreateLink", false, mylink);
}
else if (window.getSelection) { //FF
var userSelection = ifm.contentWindow.getSelection().getRangeAt(0);
if(userSelection.toString().length==0)
myeditor.execCommand('inserthtml', false, "<a href='" + mylink + "'>" + mylink + "</a>");
else
myeditor.execCommand("CreateLink", false, mylink);
}
else
myeditor.execCommand("CreateLink", false, mylink);
}
}
else {
AddTag('[url=',']click here[/url]');
}
}
function doImage() {
if (editorVisible) {
ifm.contentWindow.focus();
myimg = prompt('Enter Image URL:', 'http://');
if ((myimg != null) && (myimg != "")) {
myeditor.execCommand('InsertImage', false, myimg);
}
}
else {
AddTag('[img]', '[/img]');
}
}
function insertHtml(html) {
ifm.contentWindow.focus();
if (isIE)
ifm.contentWindow.document.selection.createRange().pasteHTML(html);
else
myeditor.execCommand('inserthtml', false, html);
}
//textarea-mode functions
function MozillaInsertText(element, text, pos) {
element.value = element.value.slice(0, pos) + text + element.value.slice(pos);
}
function AddTag(t1, t2) {
var element = textboxelement;
if (isIE) {
if (document.selection) {
element.focus();
var txt = element.value;
var str = document.selection.createRange();
if (str.text == "") {
str.text = t1 + t2;
}
else if (txt.indexOf(str.text) >= 0) {
str.text = t1 + str.text + t2;
}
else {
element.value = txt + t1 + t2;
}
str.select();
}
}
else if (typeof(element.selectionStart) != 'undefined') {
var sel_start = element.selectionStart;
var sel_end = element.selectionEnd;
MozillaInsertText(element, t1, sel_start);
MozillaInsertText(element, t2, sel_end + t1.length);
element.selectionStart = sel_start;
element.selectionEnd = sel_end + t1.length + t2.length;
element.focus();
}
else {
element.value = element.value + t1 + t2;
}
}
//=======color picker
function getScrollY() { var scrOfX = 0, scrOfY = 0; if (typeof (window.pageYOffset) == 'number') { scrOfY = window.pageYOffset; scrOfX = window.pageXOffset; } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) { scrOfY = document.body.scrollTop; scrOfX = document.body.scrollLeft; } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) { scrOfY = document.documentElement.scrollTop; scrOfX = document.documentElement.scrollLeft; } return scrOfY; }
document.write("<style type='text/css'>.colorpicker201{visibility:hidden;display:none;position:absolute;background:#FFF;z-index:999;filter:progid:DXImageTransform.Microsoft.Shadow(color=#D0D0D0,direction=135);}.o5582brd{padding:0;width:12px;height:14px;border-bottom:solid 1px #DFDFDF;border-right:solid 1px #DFDFDF;}a.o5582n66,.o5582n66,.o5582n66a{font-family:arial,tahoma,sans-serif;text-decoration:underline;font-size:9px;color:#666;border:none;}.o5582n66,.o5582n66a{text-align:center;text-decoration:none;}a:hover.o5582n66{text-decoration:none;color:#FFA500;cursor:pointer;}.a01p3{padding:1px 4px 1px 2px;background:whitesmoke;border:solid 1px #DFDFDF;}</style>");
function getTop2() { csBrHt = 0; if (typeof (window.innerWidth) == 'number') { csBrHt = window.innerHeight; } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) { csBrHt = document.documentElement.clientHeight; } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) { csBrHt = document.body.clientHeight; } ctop = ((csBrHt / 2) - 115) + getScrollY(); return ctop; }
var nocol1 = "&#78;&#79;&#32;&#67;&#79;&#76;&#79;&#82;",
clos1 = "X";
function getLeft2() { var csBrWt = 0; if (typeof (window.innerWidth) == 'number') { csBrWt = window.innerWidth; } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) { csBrWt = document.documentElement.clientWidth; } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) { csBrWt = document.body.clientWidth; } cleft = (csBrWt / 2) - 125; return cleft; }
//function setCCbldID2(val, textBoxID) { document.getElementById(textBoxID).value = val; }
function setCCbldID2(val) { if (editorVisible) doColor(val); else AddTag('[color=' + val + ']', '[/color]'); }
function setCCbldSty2(objID, prop, val) {
switch (prop) {
case "bc": if (objID != 'none') { document.getElementById(objID).style.backgroundColor = val; }; break;
case "vs": document.getElementById(objID).style.visibility = val; break;
case "ds": document.getElementById(objID).style.display = val; break;
case "tp": document.getElementById(objID).style.top = val; break;
case "lf": document.getElementById(objID).style.left = val; break;
}
}
function putOBJxColor2(Samp, pigMent, textBoxId) { if (pigMent != 'x') { setCCbldID2(pigMent, textBoxId); setCCbldSty2(Samp, 'bc', pigMent); } setCCbldSty2('colorpicker201', 'vs', 'hidden'); setCCbldSty2('colorpicker201', 'ds', 'none'); }
function showColorGrid2(Sam, textBoxId) {
var objX = new Array('00', '33', '66', '99', 'CC', 'FF');
var c = 0;
var xl = '"' + Sam + '","x", "' + textBoxId + '"'; var mid = '';
mid += '<table bgcolor="#FFFFFF" border="0" cellpadding="0" cellspacing="0" style="border:solid 0px #F0F0F0;padding:2px;"><tr>';
mid += "<td colspan='9' align='left' style='margin:0;padding:2px;height:12px;' ><input class='o5582n66' type='text' size='12' id='o5582n66' value='#FFFFFF'><input class='o5582n66a' type='text' size='2' style='width:14px;' id='o5582n66a' onclick='javascript:alert(\"click on selected swatch below...\");' value='' style='border:solid 1px #666;'></td><td colspan='9' align='right'><a class='o5582n66' href='javascript:onclick=putOBJxColor2(" + xl + ")'><span class='a01p3'>" + clos1 + "</span></a></td></tr><tr>";
var br = 1;
for (o = 0; o < 6; o++) {
mid += '</tr><tr>';
for (y = 0; y < 6; y++) {
if (y == 3) { mid += '</tr><tr>'; }
for (x = 0; x < 6; x++) {
var grid = '';
grid = objX[o] + objX[y] + objX[x];
var b = "'" + Sam + "','" + grid + "', '" + textBoxId + "'";
mid += '<td class="o5582brd" style="background-color:#' + grid + '"><a class="o5582n66" href="javascript:onclick=putOBJxColor2(' + b + ');" onmouseover=javascript:document.getElementById("o5582n66").value="#' + grid + '";javascript:document.getElementById("o5582n66a").style.backgroundColor="#' + grid + '"; title="#' + grid + '"><div style="width:12px;height:14px;"></div></a></td>';
c++;
}
}
}
mid += "</tr></table>";
//var ttop=getTop2();
//setCCbldSty2('colorpicker201','tp',ttop);
//document.getElementById('colorpicker201').style.left=getLeft2();
document.getElementById('colorpicker201').innerHTML = mid;
setCCbldSty2('colorpicker201', 'vs', 'visible');
setCCbldSty2('colorpicker201', 'ds', 'inline');
}

View file

@ -1,53 +0,0 @@
K 25
svn:wc:ra_dav:version-url
V 26
/svn/!svn/ver/43795/images
END
icon_html.gif
K 25
svn:wc:ra_dav:version-url
V 40
/svn/!svn/ver/43795/images/icon_html.gif
END
img.gif
K 25
svn:wc:ra_dav:version-url
V 34
/svn/!svn/ver/43795/images/img.gif
END
colors.gif
K 25
svn:wc:ra_dav:version-url
V 37
/svn/!svn/ver/43795/images/colors.gif
END
editbar_bg.gif
K 25
svn:wc:ra_dav:version-url
V 41
/svn/!svn/ver/43795/images/editbar_bg.gif
END
url.gif
K 25
svn:wc:ra_dav:version-url
V 34
/svn/!svn/ver/43795/images/url.gif
END
icon_list.gif
K 25
svn:wc:ra_dav:version-url
V 40
/svn/!svn/ver/43795/images/icon_list.gif
END
icon_quote.png
K 25
svn:wc:ra_dav:version-url
V 41
/svn/!svn/ver/43795/images/icon_quote.png
END
icon_youtube.gif
K 25
svn:wc:ra_dav:version-url
V 43
/svn/!svn/ver/43795/images/icon_youtube.gif
END

View file

@ -1,300 +0,0 @@
10
dir
43979
https://wysiwygbbcode.svn.codeplex.com/svn/images
https://wysiwygbbcode.svn.codeplex.com/svn
2010-04-07T14:06:43.507000Z
43795
unknown
1e68c9db-d3bb-46d7-945c-fd054d4afafc
icon_html.gif
file
2010-04-07T14:11:18.000000Z
67fe598a2ce41218bbe984ecb9ef5120
2010-04-07T14:06:43.507000Z
43795
unknown
has-props
178
img.gif
file
2010-04-07T14:11:18.000000Z
9f86ef7d2cb43dc9211bc4527a4caa4a
2010-04-07T14:06:43.507000Z
43795
unknown
has-props
570
colors.gif
file
2010-04-07T14:11:18.000000Z
2b1af4a86dc3c0c38066fed59a6b9284
2010-04-07T14:06:43.507000Z
43795
unknown
has-props
1024
editbar_bg.gif
file
2010-04-07T14:11:18.000000Z
ab683894bf1f523a2c9e3888b88ff6fe
2010-04-07T14:06:43.507000Z
43795
unknown
has-props
301
url.gif
file
2010-04-07T14:11:18.000000Z
80486c8b54c622eff5fbde9cbe941c36
2010-04-07T14:06:43.507000Z
43795
unknown
has-props
209
icon_list.gif
file
2010-04-07T14:11:18.000000Z
33b13631551a0890584ccc2f9d9187d2
2010-04-07T14:06:43.507000Z
43795
unknown
has-props
82
icon_quote.png
file
2010-04-07T14:11:18.000000Z
c1980342644a5392efefbb315b12b246
2010-04-07T14:06:43.507000Z
43795
unknown
has-props
1239
icon_youtube.gif
file
2010-04-07T14:11:18.000000Z
406fca567bc8bd5655ae0d2cbb6c061c
2010-04-07T14:06:43.507000Z
43795
unknown
has-props
613

View file

@ -1,5 +0,0 @@
K 13
svn:mime-type
V 24
application/octet-stream
END

View file

@ -1,5 +0,0 @@
K 13
svn:mime-type
V 24
application/octet-stream
END

View file

@ -1,5 +0,0 @@
K 13
svn:mime-type
V 24
application/octet-stream
END

View file

@ -1,5 +0,0 @@
K 13
svn:mime-type
V 24
application/octet-stream
END

View file

@ -1,5 +0,0 @@
K 13
svn:mime-type
V 24
application/octet-stream
END

View file

@ -1,5 +0,0 @@
K 13
svn:mime-type
V 24
application/octet-stream
END

View file

@ -1,5 +0,0 @@
K 13
svn:mime-type
V 24
application/octet-stream
END

View file

@ -1,5 +0,0 @@
K 13
svn:mime-type
V 24
application/octet-stream
END

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