aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Access/PermissionRoles.php45
-rw-r--r--Zotlabs/Access/Permissions.php16
-rw-r--r--Zotlabs/Daemon/Notifier.php8
-rw-r--r--Zotlabs/Daemon/Ratenotif.php2
-rw-r--r--Zotlabs/Lib/AConfig.php4
-rw-r--r--Zotlabs/Lib/AbConfig.php4
-rw-r--r--Zotlabs/Lib/Config.php6
-rw-r--r--Zotlabs/Lib/Enotify.php2
-rw-r--r--Zotlabs/Lib/IConfig.php6
-rw-r--r--Zotlabs/Lib/PConfig.php6
-rw-r--r--Zotlabs/Lib/System.php24
-rw-r--r--Zotlabs/Lib/XConfig.php6
-rw-r--r--Zotlabs/Module/Admin/Site.php3
-rw-r--r--Zotlabs/Module/Connedit.php37
-rw-r--r--Zotlabs/Module/Dirsearch.php10
-rw-r--r--Zotlabs/Module/Help.php33
-rw-r--r--Zotlabs/Module/Item.php34
-rw-r--r--Zotlabs/Module/Pubsites.php2
-rw-r--r--Zotlabs/Module/Settings/Tokens.php2
-rw-r--r--Zotlabs/Module/Setup.php39
-rw-r--r--Zotlabs/Module/Siteinfo.php80
-rw-r--r--Zotlabs/Module/Wall_attach.php2
-rw-r--r--Zotlabs/Module/Wiki.php227
-rw-r--r--Zotlabs/Zot/Auth.php6
24 files changed, 409 insertions, 195 deletions
diff --git a/Zotlabs/Access/PermissionRoles.php b/Zotlabs/Access/PermissionRoles.php
index 8b116adc5..94c49c44f 100644
--- a/Zotlabs/Access/PermissionRoles.php
+++ b/Zotlabs/Access/PermissionRoles.php
@@ -7,6 +7,9 @@ use Zotlabs\Lib as Zlib;
class PermissionRoles {
+ static public function version() {
+ return 1;
+ }
static function role_perms($role) {
@@ -160,6 +163,7 @@ class PermissionRoles {
$ret['limits'] = PermissionLimits::Std_Limits();
break;
+ case 'custom':
default:
break;
}
@@ -174,7 +178,48 @@ class PermissionRoles {
return $ret;
}
+ static public function new_custom_perms($uid,$perm,$abooks) {
+
+ // set permissionlimits for this permission here, for example:
+
+ // if($perm === 'mynewperm')
+ // \Zotlabs\Access\PermissionLimits::Set($uid,$perm,1);
+
+
+ // set autoperms here if applicable
+ // choices are to set to 0, 1, or the value of an existing perm
+
+ if(get_pconfig($uid,'system','autoperms')) {
+
+ $c = channelx_by_n($uid);
+ $value = 0;
+ // if($perm === 'mynewperm')
+ // $value = get_abconfig($uid,$c['channel_hash'],'autoperms','someexistingperm'));
+
+ if($c) {
+ set_abconfig($uid,$c['channel_hash'],'autoperms',$perm,$value);
+ }
+
+
+ }
+
+ // now set something for all existing connections.
+
+ if($abooks) {
+ foreach($abooks as $ab) {
+ switch($perm) {
+ // case 'mynewperm':
+ // choices are to set to 1, set to 0, or clone an existing perm
+ // set_abconfig($uid,$ab['abook_xchan'],'my_perms',$perm,
+ // get_abconfig($uid,$ab['abook_xchan'],'my_perms','someexistingperm'));
+
+ default:
+ break;
+ }
+ }
+ }
+ }
static public function roles() {
diff --git a/Zotlabs/Access/Permissions.php b/Zotlabs/Access/Permissions.php
index 61ea51a48..43baa6cf7 100644
--- a/Zotlabs/Access/Permissions.php
+++ b/Zotlabs/Access/Permissions.php
@@ -10,9 +10,20 @@ class Permissions {
/**
* Extensible permissions.
* To add new permissions, add to the list of $perms below, with a simple description.
+ *
* Also visit PermissionRoles.php and add to the $ret['perms_connect'] property for any role
* if this permission should be granted to new connections.
*
+ * Next look at PermissionRoles::new_custom_perms() and provide a handler for updating custom
+ * permission roles. You will want to set a default PermissionLimit for each channel and also
+ * provide a sane default for any existing connections. You may or may not wish to provide a
+ * default auto permission. If in doubt, leave this alone as custom permissions by definition
+ * are the responsbility of the channel owner to manage. You just don't want to create any
+ * suprises or break things so you have an opportunity to provide sane settings.
+ *
+ * Update the version here and in PermissionRoles
+ *
+ *
* Permissions with 'view' in the name are considered read permissions. Anything
* else requires authentication. Read permission limits are PERMS_PUBLIC and anything else
* is given PERMS_SPECIFIC.
@@ -23,6 +34,11 @@ class Permissions {
*
*/
+ static public function version() {
+ // This must match the version in PermissionRoles.php before permission updates can run.
+ return 1;
+ }
+
static public function Perms($filter = '') {
diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php
index 36edbc057..63ced4f56 100644
--- a/Zotlabs/Daemon/Notifier.php
+++ b/Zotlabs/Daemon/Notifier.php
@@ -491,7 +491,7 @@ class Notifier {
// Now we have collected recipients (except for external mentions, FIXME)
// Let's reduce this to a set of hubs.
- $r = q("select * from hubloc where hubloc_hash in (" . implode(',',$recipients) . ")
+ $r = q("select hubloc.*, site.site_crypto from hubloc left join site on site_url = hubloc_url where hubloc_hash in (" . implode(',',$recipients) . ")
and hubloc_error = 0 and hubloc_deleted = 0"
);
@@ -603,8 +603,8 @@ class Notifier {
$packet = zot_build_packet($channel,$packet_type,(($packet_recips) ? $packet_recips : null));
}
elseif($packet_type === 'request') {
- $packet = zot_build_packet($channel,$packet_type,$env_recips,$hub['hubloc_sitekey'],$hash,
- array('message_id' => $request_message_id)
+ $packet = zot_build_packet($channel,$packet_type,$env_recips,$hub['hubloc_sitekey'],$hub['site_crypto'],
+ $hash, array('message_id' => $request_message_id)
);
}
@@ -618,7 +618,7 @@ class Notifier {
));
}
else {
- $packet = zot_build_packet($channel,'notify',$env_recips,(($private) ? $hub['hubloc_sitekey'] : null),$hash);
+ $packet = zot_build_packet($channel,'notify',$env_recips,(($private) ? $hub['hubloc_sitekey'] : null), $hub['site_crypto'],$hash);
queue_insert(array(
'hash' => $hash,
'account_id' => $target_item['aid'],
diff --git a/Zotlabs/Daemon/Ratenotif.php b/Zotlabs/Daemon/Ratenotif.php
index 1cba5e26d..a94b89004 100644
--- a/Zotlabs/Daemon/Ratenotif.php
+++ b/Zotlabs/Daemon/Ratenotif.php
@@ -77,7 +77,7 @@ class Ratenotif {
continue;
$hash = random_string();
- $n = zot_build_packet($channel,'notify',null,null,$hash);
+ $n = zot_build_packet($channel,'notify',null,null,'',$hash);
queue_insert(array(
'hash' => $hash,
diff --git a/Zotlabs/Lib/AConfig.php b/Zotlabs/Lib/AConfig.php
index ab8648a18..4e7c5483f 100644
--- a/Zotlabs/Lib/AConfig.php
+++ b/Zotlabs/Lib/AConfig.php
@@ -10,8 +10,8 @@ class AConfig {
return XConfig::Load('a_' . $account_id);
}
- static public function Get($account_id,$family,$key) {
- return XConfig::Get('a_' . $account_id,$family,$key);
+ static public function Get($account_id,$family,$key,$default = false) {
+ return XConfig::Get('a_' . $account_id,$family,$key, $default);
}
static public function Set($account_id,$family,$key,$value) {
diff --git a/Zotlabs/Lib/AbConfig.php b/Zotlabs/Lib/AbConfig.php
index cb5d96951..dfc9efc6c 100644
--- a/Zotlabs/Lib/AbConfig.php
+++ b/Zotlabs/Lib/AbConfig.php
@@ -16,7 +16,7 @@ class AbConfig {
}
- static public function Get($chan,$xhash,$family,$key) {
+ static public function Get($chan,$xhash,$family,$key, $default = false) {
$r = q("select * from abconfig where chan = %d and xchan = '%s' and cat = '%s' and k = '%s' limit 1",
intval($chan),
dbesc($xhash),
@@ -26,7 +26,7 @@ class AbConfig {
if($r) {
return ((preg_match('|^a:[0-9]+:{.*}$|s', $r[0]['v'])) ? unserialize($r[0]['v']) : $r[0]['v']);
}
- return false;
+ return $default;
}
diff --git a/Zotlabs/Lib/Config.php b/Zotlabs/Lib/Config.php
index d4ee1aeda..5625a3f79 100644
--- a/Zotlabs/Lib/Config.php
+++ b/Zotlabs/Lib/Config.php
@@ -98,13 +98,13 @@ class Config {
* @return mixed Return value or false on error or if not set
*/
- static public function Get($family,$key) {
+ static public function Get($family,$key,$default = false) {
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 $default;
}
return ((! is_array(\App::$config[$family][$key])) && (preg_match('|^a:[0-9]+:{.*}$|s', \App::$config[$family][$key]))
? unserialize(\App::$config[$family][$key])
@@ -112,7 +112,7 @@ class Config {
);
}
- return false;
+ return $default;
}
/**
diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php
index b6f4d3351..c64ff9868 100644
--- a/Zotlabs/Lib/Enotify.php
+++ b/Zotlabs/Lib/Enotify.php
@@ -102,7 +102,7 @@ class Enotify {
$title = $params['item']['title'];
$body = $params['item']['body'];
}
- if($item['created'] < datetime_convert('UTC','UTC','now - 1 month')) {
+ if($params['item']['created'] < datetime_convert('UTC','UTC','now - 1 month')) {
logger('notification invoked for an old item which may have been refetched.',LOGGER_DEBUG,LOG_INFO);
return;
}
diff --git a/Zotlabs/Lib/IConfig.php b/Zotlabs/Lib/IConfig.php
index 28c9ab58e..33d94bd49 100644
--- a/Zotlabs/Lib/IConfig.php
+++ b/Zotlabs/Lib/IConfig.php
@@ -10,7 +10,7 @@ class IConfig {
return;
}
- static public function Get(&$item, $family, $key) {
+ static public function Get(&$item, $family, $key, $default = false) {
$is_item = false;
@@ -28,7 +28,7 @@ class IConfig {
$iid = $item;
if(! $iid)
- return false;
+ return $default;
if(is_array($item) && array_key_exists('iconfig',$item) && is_array($item['iconfig'])) {
foreach($item['iconfig'] as $c) {
@@ -48,7 +48,7 @@ class IConfig {
$item['iconfig'][] = $r[0];
return $r[0]['v'];
}
- return false;
+ return $default;
}
diff --git a/Zotlabs/Lib/PConfig.php b/Zotlabs/Lib/PConfig.php
index 3b47a250a..d70697fbc 100644
--- a/Zotlabs/Lib/PConfig.php
+++ b/Zotlabs/Lib/PConfig.php
@@ -67,16 +67,16 @@ class PConfig {
* @return mixed Stored value or false if it does not exist
*/
- static public function Get($uid,$family,$key,$instore = false) {
+ static public function Get($uid,$family,$key,$default = false) {
if(is_null($uid) || $uid === false)
- return false;
+ return $default;
if(! array_key_exists($uid, \App::$config))
self::Load($uid);
if((! array_key_exists($family, \App::$config[$uid])) || (! array_key_exists($key, \App::$config[$uid][$family])))
- return false;
+ return $default;
return ((! is_array(\App::$config[$uid][$family][$key])) && (preg_match('|^a:[0-9]+:{.*}$|s', \App::$config[$uid][$family][$key]))
? unserialize(\App::$config[$uid][$family][$key])
diff --git a/Zotlabs/Lib/System.php b/Zotlabs/Lib/System.php
index 32aaa82a9..306c90f4a 100644
--- a/Zotlabs/Lib/System.php
+++ b/Zotlabs/Lib/System.php
@@ -42,6 +42,20 @@ class System {
}
+ static public function get_project_link() {
+ if(is_array(\App::$config) && is_array(\App::$config['system']) && \App::$config['system']['project_link'])
+ return \App::$config['system']['project_link'];
+ return 'https://hubzilla.org';
+ }
+
+ static public function get_project_srclink() {
+ if(is_array(\App::$config) && is_array(\App::$config['system']) && \App::$config['system']['project_srclink'])
+ return \App::$config['system']['project_srclink'];
+ return 'https://github.com/redmatrix/hubzilla';
+ }
+
+
+
static public function get_server_role() {
if(is_array(\App::$config) && is_array(\App::$config['system']) && \App::$config['system']['server_role'])
return \App::$config['system']['server_role'];
@@ -54,5 +68,15 @@ class System {
return '0.0.0';
}
+ static public function compatible_project($p) {
+ if(get_directory_realm() != DIRECTORY_REALM)
+ return true;
+
+ foreach(['hubzilla','zap'] as $t) {
+ if(stristr($p,$t))
+ return true;
+ }
+ return false;
+ }
}
diff --git a/Zotlabs/Lib/XConfig.php b/Zotlabs/Lib/XConfig.php
index 7f3d0f2cd..bf78c360f 100644
--- a/Zotlabs/Lib/XConfig.php
+++ b/Zotlabs/Lib/XConfig.php
@@ -59,16 +59,16 @@ class XConfig {
* @return mixed Stored $value or false if it does not exist
*/
- static public function Get($xchan, $family, $key) {
+ static public function Get($xchan, $family, $key, $default = false) {
if(! $xchan)
- return false;
+ return $default;
if(! array_key_exists($xchan, \App::$config))
load_xconfig($xchan);
if((! array_key_exists($family, \App::$config[$xchan])) || (! array_key_exists($key, \App::$config[$xchan][$family])))
- return false;
+ return $default;
return ((! is_array(\App::$config[$xchan][$family][$key])) && (preg_match('|^a:[0-9]+:{.*}$|s', \App::$config[$xchan][$family][$key]))
? unserialize(\App::$config[$xchan][$family][$key])
diff --git a/Zotlabs/Module/Admin/Site.php b/Zotlabs/Module/Admin/Site.php
index 251533e68..829ca71e4 100644
--- a/Zotlabs/Module/Admin/Site.php
+++ b/Zotlabs/Module/Admin/Site.php
@@ -22,6 +22,7 @@ class Site {
$banner = ((x($_POST,'banner')) ? trim($_POST['banner']) : false);
$admininfo = ((x($_POST,'admininfo')) ? trim($_POST['admininfo']) : false);
+ $siteinfo = ((x($_POST,'siteinfo')) ? trim($_POST['siteinfo']) : '');
$language = ((x($_POST,'language')) ? notags(trim($_POST['language'])) : '');
$theme = ((x($_POST,'theme')) ? notags(trim($_POST['theme'])) : '');
$theme_mobile = ((x($_POST,'theme_mobile')) ? notags(trim($_POST['theme_mobile'])) : '');
@@ -97,6 +98,7 @@ class Site {
linkify_tags($a, $admininfo, local_channel());
set_config('system', 'admininfo', $admininfo);
}
+ set_config('system','siteinfo',$siteinfo);
set_config('system', 'language', $language);
set_config('system', 'theme', $theme);
if ( $theme_mobile === '---' ) {
@@ -273,6 +275,7 @@ class Site {
'$banner' => array('banner', t("Banner/Logo"), $banner, ""),
'$admininfo' => array('admininfo', t("Administrator Information"), $admininfo, t("Contact information for site administrators. Displayed on siteinfo page. BBCode can be used here")),
+ '$siteinfo' => array('siteinfo', t('Site Information'), get_config('system','siteinfo'), t("Publicly visible description of this site. Displayed on siteinfo page. BBCode can be used here")),
'$language' => array('language', t("System language"), get_config('system','language'), "", $lang_choices),
'$theme' => array('theme', t("System theme"), get_config('system','theme'), t("Default system theme - may be over-ridden by user profiles - <a href='#' id='cnftheme'>change theme settings</a>"), $theme_choices),
'$theme_mobile' => array('theme_mobile', t("Mobile system theme"), get_config('system','mobile_theme'), t("Theme for mobile devices"), $theme_choices_mobile),
diff --git a/Zotlabs/Module/Connedit.php b/Zotlabs/Module/Connedit.php
index 5ab6f814b..5968ccde6 100644
--- a/Zotlabs/Module/Connedit.php
+++ b/Zotlabs/Module/Connedit.php
@@ -41,11 +41,13 @@ class Connedit extends \Zotlabs\Web\Controller {
}
}
+
$channel = \App::get_channel();
if($channel)
head_set_icon($channel['xchan_photo_s']);
}
+
/* @brief Evaluate posted values and set changes
*
@@ -396,6 +398,7 @@ class Connedit extends \Zotlabs\Web\Controller {
return login();
}
+ $section = ((array_key_exists('section',$_REQUEST)) ? $_REQUEST['section'] : '');
$channel = \App::get_channel();
$my_perms = get_channel_default_perms(local_channel());
$role = get_pconfig(local_channel(),'system','permissions_role');
@@ -546,9 +549,33 @@ class Connedit extends \Zotlabs\Web\Controller {
if(\App::$poi) {
+ $abook_prev = 0;
+ $abook_next = 0;
+
$contact_id = \App::$poi['abook_id'];
$contact = \App::$poi;
-
+
+ $cn = q("SELECT abook_id, xchan_name from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and abook_self = 0 order by xchan_name",
+ intval(local_channel())
+ );
+
+ if($cn) {
+ $pntotal = count($cn);
+
+ for($x = 0; $x < $pntotal; $x ++) {
+ if($cn[$x]['abook_id'] == $contact_id) {
+ if($x === 0)
+ $abook_prev = 0;
+ else
+ $abook_prev = $cn[$x - 1]['abook_id'];
+ if($x === $pntotal)
+ $abook_next = 0;
+ else
+ $abook_next = $cn[$x +1]['abook_id'];
+ }
+ }
+ }
+
$tools = array(
'view' => array(
@@ -615,8 +642,10 @@ class Connedit extends \Zotlabs\Web\Controller {
$self = false;
- if(intval($contact['abook_self']))
+ if(intval($contact['abook_self'])) {
$self = true;
+ $abook_prev = $abook_next = 0;
+ }
$tpl = get_markup_template("abook_edit.tpl");
@@ -751,6 +780,7 @@ class Connedit extends \Zotlabs\Web\Controller {
'$header' => (($self) ? t('Connection Default Permissions') : sprintf( t('Connection: %s'),$contact['xchan_name'])),
'$autoperms' => array('autoperms',t('Apply these permissions automatically'), ((get_pconfig(local_channel(),'system','autoperms')) ? 1 : 0), t('Connection requests will be approved without your interaction'), $yes_no),
'$addr' => $contact['xchan_addr'],
+ '$section' => $section,
'$addr_text' => t('This connection\'s primary address is'),
'$loc_text' => t('Available locations:'),
'$locstr' => $locstr,
@@ -792,7 +822,8 @@ class Connedit extends \Zotlabs\Web\Controller {
'$multiprofs' => $multiprofs,
'$contact_id' => $contact['abook_id'],
'$name' => $contact['xchan_name'],
-
+ '$abook_prev' => $abook_prev,
+ '$abook_next' => $abook_next
));
$arr = array('contact' => $contact,'output' => $o);
diff --git a/Zotlabs/Module/Dirsearch.php b/Zotlabs/Module/Dirsearch.php
index 927800bbb..e6cf5449a 100644
--- a/Zotlabs/Module/Dirsearch.php
+++ b/Zotlabs/Module/Dirsearch.php
@@ -12,7 +12,7 @@ class Dirsearch extends \Zotlabs\Web\Controller {
}
- function get() {
+ function get() {
$ret = array('success' => false);
@@ -410,13 +410,13 @@ class Dirsearch extends \Zotlabs\Web\Controller {
$rand = db_getfunc('rand');
$realm = get_directory_realm();
if($realm == DIRECTORY_REALM) {
- $r = q("select * from site where site_access != 0 and site_register !=0 and ( site_realm = '%s' or site_realm = '') and site_type = %d order by $rand",
+ $r = q("select * from site where site_access != 0 and site_register !=0 and ( site_realm = '%s' or site_realm = '') and site_type = %d and site_dead = 0 order by $rand",
dbesc($realm),
intval(SITE_TYPE_ZOT)
);
}
else {
- $r = q("select * from site where site_access != 0 and site_register !=0 and site_realm = '%s' and site_type = %d order by $rand",
+ $r = q("select * from site where site_access != 0 and site_register !=0 and site_realm = '%s' and site_type = %d and site_dead = 0 order by $rand",
dbesc($realm),
intval(SITE_TYPE_ZOT)
);
@@ -457,6 +457,6 @@ class Dirsearch extends \Zotlabs\Web\Controller {
}
}
return $ret;
- }
-
+ }
+
}
diff --git a/Zotlabs/Module/Help.php b/Zotlabs/Module/Help.php
index 570e8e0cf..27d94e405 100644
--- a/Zotlabs/Module/Help.php
+++ b/Zotlabs/Module/Help.php
@@ -44,8 +44,39 @@ class Help extends \Zotlabs\Web\Controller {
return $o;
}
+
+
+ if(argc() > 2 && argv(argc()-2) === 'assets') {
+ $path = '';
+ for($x = 1; $x < argc(); $x ++) {
+ if(strlen($path))
+ $path .= '/';
+ $path .= argv($x);
+ }
+ $realpath = 'doc/' . $path;
+ //Set the content-type header as appropriate
+ $imageInfo = getimagesize($realpath);
+ switch ($imageInfo[2]) {
+ case IMAGETYPE_JPEG:
+ header("Content-Type: image/jpeg");
+ break;
+ case IMAGETYPE_GIF:
+ header("Content-Type: image/gif");
+ break;
+ case IMAGETYPE_PNG:
+ header("Content-Type: image/png");
+ break;
+ default:
+ break;
+ }
+ header("Content-Length: " . filesize($realpath));
- $content = get_help_content();
+ // dump the picture and stop the script
+ readfile($realpath);
+ killme();
+ }
+
+ $content = get_help_content();
return replace_macros(get_markup_template('help.tpl'), array(
'$title' => t('$Projectname Documentation'),
diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php
index 344e839f4..d6df20130 100644
--- a/Zotlabs/Module/Item.php
+++ b/Zotlabs/Module/Item.php
@@ -126,6 +126,8 @@ class Item extends \Zotlabs\Web\Controller {
$ret = $this->item_check_service_class($uid,(($_REQUEST['webpage'] == ITEM_TYPE_WEBPAGE) ? true : false));
if (!$ret['success']) {
notice( t($ret['message']) . EOL) ;
+ if($api_source)
+ return ( [ 'success' => false, 'message' => 'service class exception' ] );
if(x($_REQUEST,'return'))
goaway(z_root() . "/" . $return_path );
killme();
@@ -180,6 +182,8 @@ class Item extends \Zotlabs\Web\Controller {
if(($r === false) || (! count($r))) {
notice( t('Unable to locate original post.') . EOL);
+ if($api_source)
+ return ( [ 'success' => false, 'message' => 'invalid post id' ] );
if(x($_REQUEST,'return'))
goaway(z_root() . "/" . $return_path );
killme();
@@ -214,6 +218,8 @@ class Item extends \Zotlabs\Web\Controller {
if(! $can_comment) {
notice( t('Permission denied.') . EOL) ;
+ if($api_source)
+ return ( [ 'success' => false, 'message' => 'permission denied' ] );
if(x($_REQUEST,'return'))
goaway(z_root() . "/" . $return_path );
killme();
@@ -222,6 +228,8 @@ class Item extends \Zotlabs\Web\Controller {
else {
if(! perm_is_allowed($profile_uid,$observer['xchan_hash'],($webpage) ? 'write_pages' : 'post_wall')) {
notice( t('Permission denied.') . EOL) ;
+ if($api_source)
+ return ( [ 'success' => false, 'message' => 'permission denied' ] );
if(x($_REQUEST,'return'))
goaway(z_root() . "/" . $return_path );
killme();
@@ -276,6 +284,8 @@ class Item extends \Zotlabs\Web\Controller {
if(! $channel) {
logger("mod_item: no channel.");
+ if($api_source)
+ return ( [ 'success' => false, 'message' => 'no channel' ] );
if(x($_REQUEST,'return'))
goaway(z_root() . "/" . $return_path );
killme();
@@ -291,6 +301,8 @@ class Item extends \Zotlabs\Web\Controller {
}
else {
logger("mod_item: no owner.");
+ if($api_source)
+ return ( [ 'success' => false, 'message' => 'no owner' ] );
if(x($_REQUEST,'return'))
goaway(z_root() . "/" . $return_path );
killme();
@@ -433,6 +445,8 @@ class Item extends \Zotlabs\Web\Controller {
if($preview)
killme();
info( t('Empty post discarded.') . EOL );
+ if($api_source)
+ return ( [ 'success' => false, 'message' => 'no content' ] );
if(x($_REQUEST,'return'))
goaway(z_root() . "/" . $return_path );
killme();
@@ -473,6 +487,8 @@ class Item extends \Zotlabs\Web\Controller {
}
else {
notice( t('Executable content type not permitted to this channel.') . EOL);
+ if($api_source)
+ return ( [ 'success' => false, 'message' => 'forbidden content type' ] );
if(x($_REQUEST,'return'))
goaway(z_root() . "/" . $return_path );
killme();
@@ -553,8 +569,8 @@ class Item extends \Zotlabs\Web\Controller {
$body = preg_replace_callback('/\[zrl(.*?)\[\/(zrl)\]/ism','\red_escape_codeblock',$body);
- $body = preg_replace_callback("/([^\]\='".'"'."\/]|^|\#\^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\+\,]+)/ism", 'nakedoembed', $body);
- $body = preg_replace_callback("/([^\]\='".'"'."\/]|^|\#\^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\+\,]+)/ism", '\red_zrl_callback', $body);
+ $body = preg_replace_callback("/([^\]\='".'"'."\/]|^|\#\^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\+\,\(\)]+)/ism", 'nakedoembed', $body);
+ $body = preg_replace_callback("/([^\]\='".'"'."\/]|^|\#\^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\+\,\(\)]+)/ism", '\red_zrl_callback', $body);
$body = preg_replace_callback('/\[\$b64zrl(.*?)\[\/(zrl)\]/ism','\red_unescape_codeblock',$body);
$body = preg_replace_callback('/\[\$b64url(.*?)\[\/(url)\]/ism','\red_unescape_codeblock',$body);
@@ -863,7 +879,8 @@ class Item extends \Zotlabs\Web\Controller {
logger('mod_item: post cancelled by plugin or duplicate suppressed.');
if($return_path)
goaway(z_root() . "/" . $return_path);
-
+ if($api_source)
+ return ( [ 'success' => false, 'message' => 'operation cancelled' ] );
$json = array('cancel' => 1);
$json['reload'] = z_root() . '/' . $_REQUEST['jsreload'];
echo json_encode($json);
@@ -916,6 +933,10 @@ class Item extends \Zotlabs\Web\Controller {
if(! $nopush)
\Zotlabs\Daemon\Master::Summon(array('Notifier', 'edit_post', $post_id));
+
+ if($api_source)
+ return($x);
+
if((x($_REQUEST,'return')) && strlen($return_path)) {
logger('return: ' . $return_path);
goaway(z_root() . "/" . $return_path );
@@ -990,8 +1011,11 @@ class Item extends \Zotlabs\Web\Controller {
else {
logger('mod_item: unable to retrieve post that was just stored.');
notice( t('System error. Post not saved.') . EOL);
- goaway(z_root() . "/" . $return_path );
- // NOTREACHED
+ if($return_path)
+ goaway(z_root() . "/" . $return_path );
+ if($api_source)
+ return ( [ 'success' => false, 'message' => 'system error' ] );
+ killme();
}
if(($parent) && ($parent != $post_id)) {
diff --git a/Zotlabs/Module/Pubsites.php b/Zotlabs/Module/Pubsites.php
index 1c9cd5121..d87967189 100644
--- a/Zotlabs/Module/Pubsites.php
+++ b/Zotlabs/Module/Pubsites.php
@@ -36,7 +36,7 @@ class Pubsites extends \Zotlabs\Web\Controller {
$o .= '</tr>';
if($j['sites']) {
foreach($j['sites'] as $jj) {
- if(! $jj['project'])
+ if(! \Zotlabs\Lib\System::compatible_project($jj['project']))
continue;
if(strpos($jj['version'],' ')) {
$x = explode(' ', $jj['version']);
diff --git a/Zotlabs/Module/Settings/Tokens.php b/Zotlabs/Module/Settings/Tokens.php
index e63fed128..d32a00c95 100644
--- a/Zotlabs/Module/Settings/Tokens.php
+++ b/Zotlabs/Module/Settings/Tokens.php
@@ -115,6 +115,7 @@ class Tokens {
$desc2 = t('You may also provide <em>dropbox</em> style access links to friends and associates by adding the Login Password to any specific site URL as shown. Examples:');
$global_perms = \Zotlabs\Access\Permissions::Perms();
+ $their_perms = [];
$existing = get_all_perms(local_channel(),(($atoken_xchan) ? $atoken_xchan : ''));
@@ -123,7 +124,6 @@ class Tokens {
intval(local_channel()),
dbesc($atoken_xchan)
);
- $their_perms = array();
if($theirs) {
foreach($theirs as $t) {
$their_perms[$t['k']] = $t['v'];
diff --git a/Zotlabs/Module/Setup.php b/Zotlabs/Module/Setup.php
index fde9fe823..b5258a28f 100644
--- a/Zotlabs/Module/Setup.php
+++ b/Zotlabs/Module/Setup.php
@@ -161,13 +161,6 @@ class Setup extends \Zotlabs\Web\Controller {
}
}
- function get_db_errno() {
- if(class_exists('mysqli'))
- return mysqli_connect_errno();
- else
- return mysql_errno();
- }
-
/**
* @brief Get output for the setup page.
*
@@ -175,6 +168,7 @@ class Setup extends \Zotlabs\Web\Controller {
*
* @return string parsed HTML output
*/
+
function get() {
$o = '';
@@ -401,7 +395,8 @@ class Setup extends \Zotlabs\Web\Controller {
if (strlen($phpath)) {
$passed = file_exists($phpath);
- } else {
+ }
+ elseif(function_exists('shell_exec')) {
if(is_windows())
$phpath = trim(shell_exec('where php'));
else
@@ -426,9 +421,13 @@ class Setup extends \Zotlabs\Web\Controller {
if($passed) {
$str = autoname(8);
$cmd = "$phpath install/testargs.php $str";
- $result = trim(shell_exec($cmd));
- $passed2 = $result == $str;
$help = '';
+
+ if(function_exists('shell_exec'))
+ $result = trim(shell_exec($cmd));
+ else
+ $help .= t('Unable to check command line PHP, as shell_exec() is disabled. This is required.') . EOL;
+ $passed2 = (($result == $str) ? true : false);
if(!$passed2) {
$help .= t('The command line version of PHP on your system does not have "register_argc_argv" enabled.'). EOL;
$help .= t('This is required for message delivery to work.');
@@ -457,7 +456,7 @@ class Setup extends \Zotlabs\Web\Controller {
userReadableSize($result['max_upload_filesize']),
$result['max_file_uploads']
);
- $help .= '<br>' . t('You can adjust these settings in the servers php.ini.');
+ $help .= '<br>' . t('You can adjust these settings in the server php.ini file.');
$this->check_add($checks, t('PHP upload limits'), true, false, $help);
}
@@ -512,11 +511,17 @@ class Setup extends \Zotlabs\Web\Controller {
$this->check_add($ck_funcs, t('Apache mod_rewrite module'), true, true);
}
}
- if((! function_exists('proc_open')) || strstr(ini_get('disable_functions'),'proc_open')) {
- $this->check_add($ck_funcs, t('proc_open'), false, true, t('Error: proc_open is required but is either not installed or has been disabled in php.ini'));
+ if((! function_exists('exec')) || strstr(ini_get('disable_functions'),'exec')) {
+ $this->check_add($ck_funcs, t('exec'), false, true, t('Error: exec is required but is either not installed or has been disabled in php.ini'));
+ }
+ else {
+ $this->check_add($ck_funcs, t('exec'), true, true);
+ }
+ if((! function_exists('shell_exec')) || strstr(ini_get('disable_functions'),'shell_exec')) {
+ $this->check_add($ck_funcs, t('shell_exec'), false, true, t('Error: shell_exec is required but is either not installed or has been disabled in php.ini'));
}
else {
- $this->check_add($ck_funcs, t('proc_open'), true, true);
+ $this->check_add($ck_funcs, t('shell_exec'), true, true);
}
if(! function_exists('curl_init')) {
@@ -579,7 +584,7 @@ class Setup extends \Zotlabs\Web\Controller {
if(! is_writable(TEMPLATE_BUILD_PATH) ) {
$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('This software 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 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 .= 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;
@@ -601,7 +606,7 @@ class Setup extends \Zotlabs\Web\Controller {
if(! is_writable('store')) {
$status = false;
- $help = t('This software uses the store directory to save uploaded files. The web server needs to have write access to the store directory under the Red top level folder') . EOL;
+ $help = t('This software uses the store directory to save uploaded files. The web server needs to have write access to the store directory under the top level web 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;
}
@@ -716,7 +721,7 @@ class Setup extends \Zotlabs\Web\Controller {
// (e.g. NSS used in RedHat) require different syntax, so hopefully
// the default curl cipher list will work for most sites. If not,
// this can set via config. Many distros are now disabling RC4,
- // but many Red sites still use it and are unable to change it.
+ // but many existing sites still use it and are unable to change it.
// We do not use SSL for encryption, only to protect session cookies.
// z_fetch_url() is also used to import shared links and other content
// so in theory most any cipher could show up and we should do our best
diff --git a/Zotlabs/Module/Siteinfo.php b/Zotlabs/Module/Siteinfo.php
index a15e2896d..7c3918425 100644
--- a/Zotlabs/Module/Siteinfo.php
+++ b/Zotlabs/Module/Siteinfo.php
@@ -15,63 +15,33 @@ class Siteinfo extends \Zotlabs\Web\Controller {
function get() {
- if(! get_config('system','hidden_version_siteinfo')) {
- $version = sprintf( t('Version %s'), \Zotlabs\Lib\System::get_project_version());
- if(@is_dir('.git') && function_exists('shell_exec')) {
- $commit = @shell_exec('git log -1 --format="%h"');
- $tag = \Zotlabs\Lib\System::get_std_version(); // @shell_exec('git describe --tags --abbrev=0');
- }
- if(! isset($commit) || strlen($commit) > 16)
- $commit = '';
- }
- else {
- $version = $commit = '';
- }
+ $siteinfo = replace_macros(get_markup_template('siteinfo.tpl'),
+ [
+ '$title' => t('About this site'),
+ '$sitenametxt' => t('Site Name'),
+ '$sitename' => \Zotlabs\Lib\System::get_site_name(),
+ '$headline' => t('Site Information'),
+ '$site_about' => bbcode(get_config('system','siteinfo')),
+ '$admin_headline' => t('Administrator'),
+ '$admin_about' => bbcode(get_config('system','admininfo')),
+ '$terms' => t('Terms of Service'),
+ '$prj_header' => t('Software and Project information'),
+ '$prj_name' => t('This site is powered by $Projectname'),
+ '$prj_transport' => t('Federated and decentralised networking and identity services provided by Zot'),
+ '$transport_link' => '<a href="https://zotlabs.com">https://zotlabs.com</a>',
+ '$prj_version' => ((get_config('system','hidden_version_siteinfo')) ? '' : sprintf( t('Version %s'), \Zotlabs\Lib\System::get_project_version())),
+ '$prj_linktxt' => t('Project homepage'),
+ '$prj_srctxt' => t('Developer homepage'),
+ '$prj_link' => \Zotlabs\Lib\System::get_project_link(),
+ '$prj_src' => \Zotlabs\Lib\System::get_project_srclink(),
+ ]
+ );
- $plugins_list = implode(', ',visible_plugin_list());
+ call_hooks('about_hook', $siteinfo);
+
+ return $siteinfo;
- if($plugins_list)
- $plugins_text = t('Installed plugins/addons/apps:');
- else
- $plugins_text = t('No installed plugins/addons/apps');
-
- $txt = get_config('system','admininfo');
- $admininfo = bbcode($txt);
-
- if(file_exists('doc/site_donate.html'))
- $donate .= file_get_contents('doc/site_donate.html');
-
- if(function_exists('sys_getloadavg'))
- $loadavg = sys_getloadavg();
-
- $o = replace_macros(get_markup_template('siteinfo.tpl'), array(
- '$title' => t('$Projectname'),
- '$description' => t('This is a hub of $Projectname - a global cooperative network of decentralized privacy enhanced websites.'),
- '$version' => $version,
- '$tag_txt' => t('Tag: '),
- '$tag' => $tag,
- '$polled' => t('Last background fetch: '),
- '$lastpoll' => get_poller_runtime(),
- '$load_average' => t('Current load average: '),
- '$loadavg_all' => $loadavg[0] . ', ' . $loadavg[1] . ', ' . $loadavg[2],
- '$commit' => $commit,
- '$web_location' => t('Running at web location') . ' ' . z_root(),
- '$visit' => t('Please visit <a href="http://hubzilla.org">hubzilla.org</a> to learn more about $Projectname.'),
- '$bug_text' => t('Bug reports and issues: please visit'),
- '$bug_link_url' => 'https://github.com/redmatrix/hubzilla/issues',
- '$bug_link_text' => t('$projectname issues'),
- '$contact' => t('Suggestions, praise, etc. - please email "redmatrix" at librelist - dot com'),
- '$donate' => $donate,
- '$adminlabel' => t('Site Administrators'),
- '$admininfo' => $admininfo,
- '$plugins_text' => $plugins_text,
- '$plugins_list' => $plugins_list
- ));
-
- call_hooks('about_hook', $o);
-
- return $o;
-
}
+
}
diff --git a/Zotlabs/Module/Wall_attach.php b/Zotlabs/Module/Wall_attach.php
index 9268fbb0a..c6fe7518e 100644
--- a/Zotlabs/Module/Wall_attach.php
+++ b/Zotlabs/Module/Wall_attach.php
@@ -12,7 +12,7 @@ class Wall_attach extends \Zotlabs\Web\Controller {
$using_api = false;
- if(\App::$data['api_info'] && array_key_exists('media',$_FILES)) {
+ if($_REQUEST['api_source'] && array_key_exists('media',$_FILES)) {
$using_api = true;
}
diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php
index edcd6ec58..01a1bdc41 100644
--- a/Zotlabs/Module/Wiki.php
+++ b/Zotlabs/Module/Wiki.php
@@ -34,20 +34,16 @@ class Wiki extends \Zotlabs\Web\Controller {
notice( t('Not found') . EOL);
return;
}
-
- $tab = 'wiki';
-
-
+
require_once('include/wiki.php');
require_once('include/acl_selectors.php');
require_once('include/conversation.php');
+ require_once('include/bbcode.php');
// TODO: Combine the interface configuration into a unified object
// Something like $interface = array('new_page_button' => false, 'new_wiki_button' => false, ...)
$wiki_owner = false;
$showNewWikiButton = false;
- $showCommitMsg = false;
- $hidePageHistory = false;
$pageHistory = array();
$local_observer = null;
$resource_id = '';
@@ -90,50 +86,82 @@ class Wiki extends \Zotlabs\Web\Controller {
// Not the channel owner
$owner_acl = $x = array();
}
-
+
+ $is_owner = ((local_channel()) && (local_channel() == \App::$profile['profile_uid']) ? true : false);
+ $o = profile_tabs($a, $is_owner, \App::$profile['channel_address']);
+
// Download a wiki
- if ((argc() > 3) && (argv(2) === 'download') && (argv(3) === 'wiki')) {
- $resource_id = argv(4);
- $w = wiki_get_wiki($resource_id);
- if (!$w['path']) {
- notice(t('Error retrieving wiki') . EOL);
- }
- $zip_folder_name = random_string(10);
- $zip_folderpath = '/tmp/' . $zip_folder_name;
- if (!mkdir($zip_folderpath, 0770, false)) {
- logger('Error creating zip file export folder: ' . $zip_folderpath, LOGGER_NORMAL);
- notice(t('Error creating zip file export folder') . EOL);
- }
- $zip_filename = $w['urlName'];
- $zip_filepath = '/tmp/' . $zip_folder_name . '/' . $zip_filename;
- // Generate the zip file
- \Zotlabs\Lib\ExtendedZip::zipTree($w['path'], $zip_filepath, \ZipArchive::CREATE);
- // Output the file for download
- header('Content-disposition: attachment; filename="' . $zip_filename . '.zip"');
- header("Content-Type: application/zip");
- $success = readfile($zip_filepath);
- if ($success) {
- rrmdir($zip_folderpath); // delete temporary files
- } else {
- rrmdir($zip_folderpath); // delete temporary files
- logger('Error downloading wiki: ' . $resource_id);
- }
+ if((argc() > 3) && (argv(2) === 'download') && (argv(3) === 'wiki')) {
+
+ $resource_id = argv(4);
+
+ $w = wiki_get_wiki($resource_id);
+ if(!$w['path']) {
+ notice(t('Error retrieving wiki') . EOL);
+ }
+
+ $zip_folder_name = random_string(10);
+ $zip_folderpath = '/tmp/' . $zip_folder_name;
+ if(!mkdir($zip_folderpath, 0770, false)) {
+ logger('Error creating zip file export folder: ' . $zip_folderpath, LOGGER_NORMAL);
+ notice(t('Error creating zip file export folder') . EOL);
+ }
+
+ $zip_filename = $w['urlName'];
+ $zip_filepath = '/tmp/' . $zip_folder_name . '/' . $zip_filename;
+
+ // Generate the zip file
+ \Zotlabs\Lib\ExtendedZip::zipTree($w['path'], $zip_filepath, \ZipArchive::CREATE);
+
+ // Output the file for download
+
+ header('Content-disposition: attachment; filename="' . $zip_filename . '.zip"');
+ header('Content-Type: application/zip');
+
+ $success = readfile($zip_filepath);
+
+ if(!$success) {
+ logger('Error downloading wiki: ' . $resource_id);
+ notice(t('Error downloading wiki: ' . $resource_id) . EOL);
+ }
+
+ // delete temporary files
+ rrmdir($zip_folderpath);
+ killme();
+
}
switch (argc()) {
case 2:
- // Configure page template
- $wikiheaderName = t('Wiki');
- $wikiheaderPage = t('Sandbox');
- require_once('library/markdown.php');
- $content = t('"# Wiki Sandbox\n\nContent you **edit** and **preview** here *will not be saved*."');
- $renderedContent = Markdown(json_decode($content));
- $hide_editor = false;
- $showPageControls = false;
- $showNewWikiButton = $wiki_owner;
- $showNewPageButton = false;
- $hidePageHistory = true;
- $showCommitMsg = false;
+ $wikis = wiki_list($owner, get_observer_hash());
+ if ($wikis) {
+ $o .= replace_macros(get_markup_template('wikilist.tpl'), array(
+ '$header' => t('Wikis'),
+ '$channel' => $owner['channel_address'],
+ '$wikis' => $wikis['wikis'],
+ // If the observer is the local channel owner, show the wiki controls
+ '$owner' => ((local_channel() && local_channel() === intval(\App::$profile['uid'])) ? true : false),
+ '$edit' => t('Edit'),
+ '$download' => t('Download'),
+ '$view' => t('View'),
+ '$create' => t('Create New'),
+ '$submit' => t('Submit'),
+ '$wikiName' => array('wikiName', t('Wiki name')),
+ '$mimeType' => array('mimeType', t('Content type'), '', '', ['text/markdown' => 'Markdown', 'text/bbcode' => 'BB Code']),
+ '$name' => t('Name'),
+ '$type' => t('Type'),
+ '$lockstate' => $x['lockstate'],
+ '$acl' => $x['acl'],
+ '$allow_cid' => $x['allow_cid'],
+ '$allow_gid' => $x['allow_gid'],
+ '$deny_cid' => $x['deny_cid'],
+ '$deny_gid' => $x['deny_gid'],
+ '$notify' => array('postVisible', t('Create a status post for this wiki'), '', '', array(t('No'), t('Yes')))
+ ));
+
+ return $o;
+ }
+
break;
case 3:
// /wiki/channel/wiki -> No page was specified, so redirect to Home.md
@@ -144,10 +172,12 @@ class Wiki extends \Zotlabs\Web\Controller {
// Fetch the wiki info and determine observer permissions
$wikiUrlName = urlencode(argv(2));
$pageUrlName = urlencode(argv(3));
+
$w = wiki_exists_by_name($owner['channel_id'], $wikiUrlName);
if(!$w['resource_id']) {
notice(t('Wiki not found') . EOL);
goaway('/'.argv(0).'/'.argv(1));
+ return; //not reached
}
$resource_id = $w['resource_id'];
@@ -158,6 +188,7 @@ class Wiki extends \Zotlabs\Web\Controller {
if(!$perms['read']) {
notice(t('Permission denied.') . EOL);
goaway('/'.argv(0).'/'.argv(1));
+ return; //not reached
}
if($perms['write']) {
$wiki_editor = true;
@@ -169,53 +200,59 @@ class Wiki extends \Zotlabs\Web\Controller {
}
$wikiheaderName = urldecode($wikiUrlName);
$wikiheaderPage = urldecode($pageUrlName);
+ $renamePage = (($wikiheaderPage === 'Home') ? '' : t('Rename page'));
+
$p = wiki_get_page_content(array('resource_id' => $resource_id, 'pageUrlName' => $pageUrlName));
if(!$p['success']) {
notice(t('Error retrieving page content') . EOL);
goaway('/'.argv(0).'/'.argv(1).'/'.$wikiUrlName);
+ return; //not reached
}
- $content = ($p['content'] !== '' ? htmlspecialchars_decode($p['content'],ENT_COMPAT) : '"# New page\n"');
+
+ $mimeType = $p['mimeType'];
+
+ $rawContent = (($p['mimeType'] == 'text/bbcode') ? htmlspecialchars_decode(json_decode($p['content']),ENT_COMPAT) : htmlspecialchars_decode($p['content'],ENT_COMPAT));
+ $content = ($p['content'] !== '' ? $rawContent : '"# New page\n"');
// Render the Markdown-formatted page content in HTML
- require_once('library/markdown.php');
- $html = wiki_generate_toc(zidify_text(purify_html(Markdown(wiki_bbcode(json_decode($content))))));
- $renderedContent = wiki_convert_links($html,argv(0).'/'.argv(1).'/'.$wikiUrlName);
+ if($mimeType == 'text/bbcode') {
+ $renderedContent = wiki_convert_links(bbcode($content),argv(0).'/'.argv(1).'/'.$wikiUrlName);
+ }
+ else {
+ require_once('library/markdown.php');
+ $html = wiki_generate_toc(zidify_text(purify_html(Markdown(wiki_bbcode(json_decode($content))))));
+ $renderedContent = wiki_convert_links($html,argv(0).'/'.argv(1).'/'.$wikiUrlName);
+ }
$hide_editor = false;
$showPageControls = $wiki_editor;
$showNewWikiButton = $wiki_owner;
$showNewPageButton = $wiki_editor;
- $hidePageHistory = false;
- $showCommitMsg = true;
$pageHistory = wiki_page_history(array('resource_id' => $resource_id, 'pageUrlName' => $pageUrlName));
break;
default: // Strip the extraneous URL components
- goaway('/'.argv(0).'/'.argv(1).'/'.$wikiUrlName.'/'.$pageUrlName);
+ goaway('/' . argv(0) . '/' . argv(1) . '/' . $wikiUrlName . '/' . $pageUrlName);
+ return; //not reached
}
$wikiModalID = random_string(3);
- $wikiModal = replace_macros(
- get_markup_template('generic_modal.tpl'), array(
- '$id' => $wikiModalID,
- '$title' => t('Revision Comparison'),
- '$ok' => t('Revert'),
- '$cancel' => t('Cancel')
- )
- );
-
- $is_owner = ((local_channel()) && (local_channel() == \App::$profile['profile_uid']) ? true : false);
-
- $o .= profile_tabs($a, $is_owner, \App::$profile['channel_address']);
-
+ $wikiModal = replace_macros(get_markup_template('generic_modal.tpl'), array(
+ '$id' => $wikiModalID,
+ '$title' => t('Revision Comparison'),
+ '$ok' => t('Revert'),
+ '$cancel' => t('Cancel')
+ ));
+
$o .= replace_macros(get_markup_template('wiki.tpl'),array(
'$wikiheaderName' => $wikiheaderName,
'$wikiheaderPage' => $wikiheaderPage,
- '$hideEditor' => $hide_editor,
+ '$renamePage' => $renamePage,
+ '$hideEditor' => $hide_editor, // True will completely hide the content section and is used for the case of no wiki selected
+ '$chooseWikiMessage' => t('Choose an available wiki from the list on the left.'),
'$showPageControls' => $showPageControls,
- '$tools_label' => 'Wiki Tools',
+ '$editOrSourceLabel' => (($showPageControls) ? t('Edit') : t('Source')),
+ '$tools_label' => 'Page Tools',
'$showNewWikiButton'=> $showNewWikiButton,
'$showNewPageButton'=> $showNewPageButton,
- '$hidePageHistory' => $hidePageHistory,
- '$showCommitMsg' => $showCommitMsg,
'$channel' => $owner['channel_address'],
'$resource_id' => $resource_id,
'$page' => $pageUrlName,
@@ -226,12 +263,11 @@ class Wiki extends \Zotlabs\Web\Controller {
'$deny_cid' => $x['deny_cid'],
'$deny_gid' => $x['deny_gid'],
'$bang' => $x['bang'],
+ '$mimeType' => $mimeType,
'$content' => $content,
'$renderedContent' => $renderedContent,
- '$wikiName' => array('wikiName', t('Enter the name of your new wiki:'), '', ''),
- '$pageName' => array('pageName', t('Enter the name of the new page:'), '', ''),
- '$pageRename' => array('pageRename', t('Enter the new name:'), '', ''),
- '$commitMsg' => array('commitMsg', '', '', '', '', 'placeholder="(optional) Enter a custom message when saving the page..."'),
+ '$pageRename' => array('pageRename', t('New page name'), '', ''),
+ '$commitMsg' => array('commitMsg', '', '', '', '', 'placeholder="Short description of your changes (optional)"'),
'$pageHistory' => $pageHistory['history'],
'$wikiModal' => $wikiModal,
'$wikiModalID' => $wikiModalID,
@@ -247,12 +283,16 @@ class Wiki extends \Zotlabs\Web\Controller {
'$modalerrorlink' => t('Error getting photo link'),
'$modalerroralbum' => t('Error getting album'),
));
- head_add_js('library/ace/ace.js'); // Ace Code Editor
+
+ if($p['mimeType'] != 'text/bbcode')
+ head_add_js('library/ace/ace.js'); // Ace Code Editor
+
return $o;
}
function post() {
require_once('include/wiki.php');
+ require_once('include/bbcode.php');
$nick = argv(1);
$owner = channelx_by_nick($nick);
@@ -268,13 +308,21 @@ class Wiki extends \Zotlabs\Web\Controller {
// Render mardown-formatted text in HTML for preview
if((argc() > 2) && (argv(2) === 'preview')) {
$content = $_POST['content'];
- $resource_id = $_POST['resource_id'];
- require_once('library/markdown.php');
- $content = wiki_bbcode($content);
- $html = wiki_generate_toc(zidify_text(purify_html(Markdown($content))));
+ $resource_id = $_POST['resource_id'];
$w = wiki_get_wiki($resource_id);
$wikiURL = argv(0).'/'.argv(1).'/'.$w['urlName'];
- $html = wiki_convert_links($html,$wikiURL);
+
+ $mimeType = $w['mimeType'];
+
+ if($mimeType == 'text/bbcode') {
+ $html = wiki_convert_links(bbcode($content),$wikiURL);
+ }
+ else {
+ require_once('library/markdown.php');
+ $content = wiki_bbcode($content);
+ $html = wiki_generate_toc(zidify_text(purify_html(Markdown($content))));
+ $html = wiki_convert_links($html,$wikiURL);
+ }
json_return_and_die(array('html' => $html, 'success' => true));
}
@@ -288,17 +336,19 @@ class Wiki extends \Zotlabs\Web\Controller {
if (local_channel() !== intval($owner['channel_id'])) {
goaway('/' . argv(0) . '/' . $nick . '/');
}
-
$wiki = array();
// Generate new wiki info from input name
$wiki['postVisible'] = ((intval($_POST['postVisible']) === 0) ? 0 : 1);
$wiki['rawName'] = $_POST['wikiName'];
$wiki['htmlName'] = escape_tags($_POST['wikiName']);
$wiki['urlName'] = urlencode($_POST['wikiName']);
+ $wiki['mimeType'] = $_POST['mimeType'];
+
if($wiki['urlName'] === '') {
notice( t('Error creating wiki. Invalid name.') . EOL);
goaway('/wiki');
}
+
// Get ACL for permissions
$acl = new \Zotlabs\Access\AccessList($owner);
$acl->set_from_array($_POST);
@@ -355,7 +405,18 @@ class Wiki extends \Zotlabs\Web\Controller {
}
$page = wiki_create_page($name, $resource_id);
if ($page['success']) {
- json_return_and_die(array('url' => '/'.argv(0).'/'.argv(1).'/'.$page['wiki']['urlName'].'/'.urlencode($page['page']['urlName']), 'success' => true));
+ $ob = \App::get_observer();
+ $commit = wiki_git_commit(array(
+ 'commit_msg' => t('New page created'),
+ 'resource_id' => $resource_id,
+ 'observer' => $ob,
+ 'files' => array($page['page']['fileName'])
+ ));
+ if($commit['success']) {
+ json_return_and_die(array('url' => '/'.argv(0).'/'.argv(1).'/'.$page['wiki']['urlName'].'/'.$page['page']['urlName'], 'success' => true));
+ } else {
+ json_return_and_die(array('message' => 'Error making git commit','url' => '/'.argv(0).'/'.argv(1).'/'.$page['wiki']['urlName'].'/'.urlencode($page['page']['urlName']),'success' => false));
+ }
} else {
logger('Error creating page');
json_return_and_die(array('message' => 'Error creating page.', 'success' => false));
@@ -405,7 +466,7 @@ class Wiki extends \Zotlabs\Web\Controller {
'commit_msg' => $commitMsg,
'resource_id' => $resource_id,
'observer' => $ob,
- 'files' => array($pageUrlName.'.md')
+ 'files' => array($saved['fileName'])
));
if($commit['success']) {
json_return_and_die(array('message' => 'Wiki git repo commit made', 'success' => true));
@@ -544,7 +605,7 @@ class Wiki extends \Zotlabs\Web\Controller {
'commit_msg' => 'Renamed ' . urldecode($pageUrlName) . ' to ' . $renamed['page']['htmlName'],
'resource_id' => $resource_id,
'observer' => $ob,
- 'files' => array($pageUrlName . '.md', $renamed['page']['fileName']),
+ 'files' => array($pageUrlName . substr($renamed['page']['fileName'], -3), $renamed['page']['fileName']),
'all' => true
));
if($commit['success']) {
diff --git a/Zotlabs/Zot/Auth.php b/Zotlabs/Zot/Auth.php
index 0837be21a..d4d3bee1d 100644
--- a/Zotlabs/Zot/Auth.php
+++ b/Zotlabs/Zot/Auth.php
@@ -149,9 +149,13 @@ class Auth {
// The actual channel sending the packet ($c[0]) is not important, but this provides a
// generic zot packet with a sender which can be verified
+ $x = q("select site_crypto from site where site_url = '%s' limit 1",
+ dbesc($hubloc['hubloc_url'])
+ );
+
$p = zot_build_packet($channel,$type = 'auth_check',
array(array('guid' => $hubloc['hubloc_guid'],'guid_sig' => $hubloc['hubloc_guid_sig'])),
- $hubloc['hubloc_sitekey'], $this->sec);
+ $hubloc['hubloc_sitekey'], (($x) ? $x[0]['site_crypto'] : ''), $this->sec);
$this->Debug('auth check packet created using sitekey ' . $hubloc['hubloc_sitekey']);
$this->Debug('packet contents: ' . $p);