aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
Diffstat (limited to 'mod')
-rw-r--r--mod/admin.php59
-rw-r--r--mod/attach.php5
-rw-r--r--mod/blocks.php54
-rw-r--r--mod/branchtopic.php42
-rw-r--r--mod/channel.php2
-rw-r--r--mod/cloud.php2
-rw-r--r--mod/connedit.php42
-rw-r--r--mod/dav.php2
-rw-r--r--mod/directory.php17
-rw-r--r--mod/dirsearch.php11
-rw-r--r--mod/editblock.php31
-rw-r--r--mod/editlayout.php35
-rw-r--r--mod/editpost.php1
-rw-r--r--mod/editwebpage.php47
-rw-r--r--mod/filestorage.php10
-rw-r--r--mod/help.php2
-rw-r--r--mod/home.php253
-rw-r--r--mod/impel.php191
-rw-r--r--mod/invite.php6
-rw-r--r--mod/item.php114
-rw-r--r--mod/layouts.php66
-rwxr-xr-xmod/like.php2
-rw-r--r--mod/lockview.php12
-rw-r--r--mod/magic.php2
-rw-r--r--mod/manage.php8
-rw-r--r--mod/menu.php104
-rw-r--r--mod/mitem.php160
-rw-r--r--mod/network.php1
-rw-r--r--mod/p.php2
-rw-r--r--mod/page.php51
-rw-r--r--mod/parse_url.php2
-rw-r--r--mod/photos.php2
-rw-r--r--mod/post.php7
-rw-r--r--mod/probe.php3
-rw-r--r--mod/profile_photo.php2
-rw-r--r--mod/public.php161
-rw-r--r--mod/pubsites.php2
-rw-r--r--mod/receive.php2
-rw-r--r--mod/rpost.php18
-rw-r--r--mod/search.php14
-rw-r--r--mod/settings.php37
-rwxr-xr-xmod/setup.php448
-rw-r--r--mod/siteinfo.php10
-rw-r--r--mod/suggest.php1
-rw-r--r--mod/update_public.php37
-rw-r--r--mod/viewconnections.php35
-rw-r--r--mod/viewsrc.php3
-rw-r--r--mod/wall_attach.php3
-rw-r--r--mod/webfinger.php13
-rw-r--r--mod/webpages.php72
-rw-r--r--mod/wfinger.php19
-rw-r--r--mod/zfinger.php2
52 files changed, 1323 insertions, 904 deletions
diff --git a/mod/admin.php b/mod/admin.php
index fd2ba510b..74abc0b34 100644
--- a/mod/admin.php
+++ b/mod/admin.php
@@ -230,7 +230,7 @@ function admin_page_summary(&$a) {
$alertmsg = '';
// annoy admin about upcoming unsupported PHP version
if (version_compare(PHP_VERSION, '5.4', '<')) {
- $alertmsg = 'Your PHP version ' . PHP_VERSION . ' will not be supported with the next major release of RedMatrix. You are strongly urged to upgrade to a current version.'
+ $alertmsg = 'Your PHP version ' . PHP_VERSION . ' will not be supported with the next major release of $Projectname. You are strongly urged to upgrade to a current version.'
. '<br>PHP 5.3 has reached its <a href="http://php.net/eol.php" class="alert-link">End of Life (EOL)</a> in August 2014.'
. ' A list about current PHP versions can be found <a href="http://php.net/supported-versions.php" class="alert-link">here</a>.';
}
@@ -277,6 +277,8 @@ function admin_page_site_post(&$a){
$abandon_days = ((x($_POST,'abandon_days')) ? intval(trim($_POST['abandon_days'])) : 0);
$register_text = ((x($_POST,'register_text')) ? notags(trim($_POST['register_text'])) : '');
+ $frontpage = ((x($_POST,'frontpage')) ? notags(trim($_POST['frontpage'])) : '');
+ $mirror_frontpage = ((x($_POST,'mirror_frontpage')) ? intval(trim($_POST['mirror_frontpage'])) : 0);
$allowed_sites = ((x($_POST,'allowed_sites')) ? notags(trim($_POST['allowed_sites'])) : '');
$allowed_email = ((x($_POST,'allowed_email')) ? notags(trim($_POST['allowed_email'])) : '');
@@ -284,7 +286,7 @@ function admin_page_site_post(&$a){
$block_public = ((x($_POST,'block_public')) ? True : False);
$force_publish = ((x($_POST,'publish_all')) ? True : False);
$disable_discover_tab = ((x($_POST,'disable_discover_tab')) ? True : False);
- $no_login_on_homepage = ((x($_POST,'no_login_on_homepage')) ? True : False);
+ $login_on_homepage = ((x($_POST,'login_on_homepage')) ? True : False);
$global_directory = ((x($_POST,'directory_submit_url')) ? notags(trim($_POST['directory_submit_url'])) : '');
$no_community_page = !((x($_POST,'no_community_page')) ? True : False);
$default_expire_days = ((array_key_exists('default_expire_days',$_POST)) ? intval($_POST['default_expire_days']) : 0);
@@ -305,8 +307,10 @@ function admin_page_site_post(&$a){
set_config('system', 'delivery_interval', $delivery_interval);
set_config('system', 'poll_interval', $poll_interval);
set_config('system', 'maxloadavg', $maxloadavg);
+ set_config('system', 'frontpage', $frontpage);
+ set_config('system', 'mirror_frontpage', $mirror_frontpage);
set_config('system', 'sitename', $sitename);
- set_config('system', 'no_login_on_homepage', $no_login_on_homepage);
+ set_config('system', 'login_on_homepage', $login_on_homepage);
set_config('system', 'verify_email', $verify_email);
set_config('system', 'default_expire_days', $default_expire_days);
@@ -439,6 +443,9 @@ function admin_page_site(&$a) {
// SSL_POLICY_FULL => t("Force all links to use SSL")
// );
+
+ $homelogin = get_config('system','login_on_homepage');
+
$t = get_markup_template("admin_site.tpl");
return replace_macros($t, array(
'$title' => t('Administration'),
@@ -464,6 +471,8 @@ function admin_page_site(&$a) {
'$register_policy' => array('register_policy', t("Does this site allow new member registration?"), get_config('system','register_policy'), "", $register_choices),
'$access_policy' => array('access_policy', t("Which best describes the types of account offered by this hub?"), get_config('system','access_policy'), "This is displayed on the public server site list.", $access_choices),
'$register_text' => array('register_text', t("Register text"), htmlspecialchars(get_config('system','register_text'), ENT_QUOTES, 'UTF-8'), t("Will be displayed prominently on the registration page.")),
+ '$frontpage' => array('frontpage', t("Site homepage to show visitors (default: login box)"), get_config('system','frontpage'), t("example: 'public' to show public stream, 'page/sys/home' to show a system webpage called 'home' or 'include:home.html' to include a file.")),
+ '$mirror_frontpage' => array('mirror_frontpage', t("Preserve site homepage URL"), get_config('system','mirror_frontpage'), t('Present the site homepage in a frame at the original location instead of redirecting')),
'$abandon_days' => array('abandon_days', t('Accounts abandoned after x days'), get_config('system','account_abandon_days'), t('Will not waste system resources polling external sites for abandonded accounts. Enter 0 for no time limit.')),
'$allowed_sites' => array('allowed_sites', t("Allowed friend domains"), get_config('system','allowed_sites'), t("Comma separated list of domains which are allowed to establish friendships with this site. Wildcards are accepted. Empty to allow any domains")),
'$allowed_email' => array('allowed_email', t("Allowed email domains"), get_config('system','allowed_email'), t("Comma separated list of domains which are allowed in email addresses for registrations to this site. Wildcards are accepted. Empty to allow any domains")),
@@ -472,7 +481,7 @@ function admin_page_site(&$a) {
'$verify_email' => array('verify_email', t("Verify Email Addresses"), get_config('system','verify_email'), t("Check to verify email addresses used in account registration (recommended).")),
'$force_publish' => array('publish_all', t("Force publish"), get_config('system','publish_all'), t("Check to force all profiles on this site to be listed in the site directory.")),
'$disable_discover_tab' => array('disable_discover_tab', t("Disable discovery tab"), get_config('system','disable_discover_tab'), t("Remove the tab in the network view with public content pulled from sources chosen for this site.")),
- '$no_login_on_homepage' => array('no_login_on_homepage', t("No login on Homepage"), get_config('system','no_login_on_homepage'), t("Check to hide the login form from your sites homepage when visitors arrive who are not logged in (e.g. when you put the content of the homepage in via the site channel).")),
+ '$login_on_homepage' => array('login_on_homepage', t("login on Homepage"),((intval($homelogin) || $homelogin === false) ? 1 : '') , t("Present a login box to visitors on the home page if no other content has been configured.")),
'$proxyuser' => array('proxyuser', t("Proxy user"), get_config('system','proxyuser'), ""),
'$proxy' => array('proxy', t("Proxy URL"), get_config('system','proxy'), ""),
@@ -847,10 +856,12 @@ function admin_page_channels_post(&$a) {
$channels = ( x($_POST, 'channel') ? $_POST['channel'] : Array() );
check_form_security_token_redirectOnErr('/admin/channels', 'admin_channels');
+
+ $xor = db_getfunc('^');
if (x($_POST,'page_channels_block')){
foreach($channels as $uid){
- q("UPDATE channel SET channel_pageflags = ( channel_pageflags & ~%d ) where channel_id = %d",
+ q("UPDATE channel SET channel_pageflags = ( channel_pageflags $xor %d ) where channel_id = %d",
intval(PAGE_CENSORED),
intval( $uid )
);
@@ -858,6 +869,15 @@ function admin_page_channels_post(&$a) {
}
notice( sprintf( tt("%s channel censored/uncensored", "%s channels censored/uncensored", count($channels)), count($channels)) );
}
+ if (x($_POST,'page_channels_code')){
+ foreach($channels as $uid){
+ q("UPDATE channel SET channel_pageflags = ( channel_pageflags $xor %d ) where channel_id = %d",
+ intval(PAGE_ALLOWCODE),
+ intval( $uid )
+ );
+ }
+ notice( sprintf( tt("%s channel code allowed/disallowed", "%s channels code allowed/disallowed", count($channels)), count($channels)) );
+ }
if (x($_POST,'page_channels_delete')){
require_once("include/Contact.php");
foreach($channels as $uid){
@@ -899,14 +919,29 @@ function admin_page_channels(&$a){
case "block":{
check_form_security_token_redirectOnErr('/admin/channels', 'admin_channels', 't');
- q("UPDATE channel SET channel_pageflags = ( channel_pageflags & ~%d ) where channel_id = %d",
- intval(PAGE_CENSORED),
+ $pflags = $channel[0]['channel_pageflags'] ^ PAGE_CENSORED;
+ q("UPDATE channel SET channel_pageflags = %d where channel_id = %d",
+ intval($pflags),
intval( $uid )
);
proc_run('php','include/directory.php',$uid,'nopush');
- notice( sprintf( (($channel[0]['channel_pageflags'] & PAGE_CENSORED) ? t("Channel '%s' uncensored"): t("Channel '%s' censored")) , $channel[0]['channel_name'] . ' (' . $channel[0]['channel_address'] . ')' ) . EOL);
+ notice( sprintf( (($pflags & PAGE_CENSORED) ? t("Channel '%s' censored"): t("Channel '%s' uncensored")) , $channel[0]['channel_name'] . ' (' . $channel[0]['channel_address'] . ')' ) . EOL);
+ }; break;
+
+ case "code":{
+ check_form_security_token_redirectOnErr('/admin/channels', 'admin_channels', 't');
+ $pflags = $channel[0]['channel_pageflags'] ^ PAGE_ALLOWCODE;
+ q("UPDATE channel SET channel_pageflags = %d where channel_id = %d",
+ intval($pflags),
+ intval( $uid )
+ );
+
+ notice( sprintf( (($pflags & PAGE_ALLOWCODE) ? t("Channel '%s' code allowed"): t("Channel '%s' code disallowed")) , $channel[0]['channel_name'] . ' (' . $channel[0]['channel_address'] . ')' ) . EOL);
}; break;
+
+ default:
+ break;
}
goaway($a->get_baseurl(true) . '/admin/channels' );
}
@@ -935,6 +970,11 @@ function admin_page_channels(&$a){
$channels[$x]['blocked'] = true;
else
$channels[$x]['blocked'] = false;
+
+ if($channels[$x]['channel_pageflags'] & PAGE_ALLOWCODE)
+ $channels[$x]['allowcode'] = true;
+ else
+ $channels[$x]['allowcode'] = false;
}
}
@@ -948,7 +988,8 @@ function admin_page_channels(&$a){
'$delete' => t('Delete'),
'$block' => t('Censor'),
'$unblock' => t('Uncensor'),
-
+ '$code' => t('Allow Code'),
+ '$uncode' => t('Disallow Code'),
'$h_channels' => t('Channel'),
'$th_channels' => array( t('UID'), t('Name'), t('Address')),
diff --git a/mod/attach.php b/mod/attach.php
index cf72d09c6..118c67dd5 100644
--- a/mod/attach.php
+++ b/mod/attach.php
@@ -36,7 +36,8 @@ function attach_init(&$a) {
header('Content-disposition: attachment; filename="' . $r['data']['filename'] . '"');
if($r['data']['flags'] & ATTACH_FLAG_OS ) {
- $istream = fopen('store/' . $c[0]['channel_address'] . '/' . $r['data']['data'],'rb');
+ $fname = dbunescbin($r['data']['data']);
+ $istream = fopen('store/' . $c[0]['channel_address'] . '/' . $fname,'rb');
$ostream = fopen('php://output','wb');
if($istream && $ostream) {
pipe_streams($istream,$ostream);
@@ -45,7 +46,7 @@ function attach_init(&$a) {
}
}
else
- echo $r['data']['data'];
+ echo dbunescbin($r['data']['data']);
killme();
}
diff --git a/mod/blocks.php b/mod/blocks.php
index f755f92b0..11e7d4a30 100644
--- a/mod/blocks.php
+++ b/mod/blocks.php
@@ -33,6 +33,8 @@ function blocks_content(&$a) {
$which = argv(1);
+ $_SESSION['return_url'] = $a->query_string;
+
$uid = local_channel();
$owner = 0;
$channel = null;
@@ -68,7 +70,6 @@ function blocks_content(&$a) {
return;
}
-
// Block design features from visitors
if((! $uid) || ($uid != $owner)) {
@@ -76,17 +77,12 @@ function blocks_content(&$a) {
return;
}
+ $mimetype = (($_REQUEST['mimetype']) ? $_REQUEST['mimetype'] : get_pconfig($owner,'system','page_mimetype'));
- if(feature_enabled($owner,'expert')) {
- $mimetype = (($_REQUEST['mimetype']) ? $_REQUEST['mimetype'] : get_pconfig($owner,'system','page_mimetype'));
- if(! $mimetype)
- $mimetype = 'choose';
- }
- else {
- $mimetype = 'text/bbcode';
+ if(! $mimetype) {
+ $mimetype = 'choose';
}
-
$x = array(
'webpage' => ITEM_BUILDBLOCK,
'is_owner' => true,
@@ -98,6 +94,8 @@ function blocks_content(&$a) {
'mimetype' => $mimetype,
'ptlabel' => t('Block Name'),
'profile_uid' => intval($owner),
+ 'expanded' => true,
+ 'novoting' => true
);
if($_REQUEST['title'])
@@ -107,12 +105,12 @@ function blocks_content(&$a) {
if($_REQUEST['pagetitle'])
$x['pagetitle'] = $_REQUEST['pagetitle'];
+ $editor = status_editor($a,$x);
-
- $o .= status_editor($a,$x);
-
- $r = q("select * from item_id where uid = %d and service = 'BUILDBLOCK' order by sid asc",
- intval($owner)
+ $r = q("select iid, sid, mid, title, body, mimetype, created, edited from item_id left join item on item_id.iid = item.id
+ where item_id.uid = %d and service = 'BUILDBLOCK' and item_restrict = %d order by item.created desc",
+ intval($owner),
+ intval(ITEM_BUILDBLOCK)
);
$pages = null;
@@ -120,7 +118,24 @@ function blocks_content(&$a) {
if($r) {
$pages = array();
foreach($r as $rr) {
- $pages[$rr['iid']][] = array('url' => $rr['iid'],'title' => $rr['sid']);
+ $element_arr = array(
+ 'type' => 'block',
+ 'title' => $rr['title'],
+ 'body' => $rr['body'],
+ 'created' => $rr['created'],
+ 'edited' => $rr['edited'],
+ 'mimetype' => $rr['mimetype'],
+ 'pagetitle' => $rr['sid'],
+ 'mid' => $rr['mid']
+ );
+ $pages[$rr['iid']][] = array(
+ 'url' => $rr['iid'],
+ 'name' => $rr['sid'],
+ 'title' => $rr['title'],
+ 'created' => $rr['created'],
+ 'edited' => $rr['edited'],
+ 'bb_element' => '[element]' . base64url_encode(json_encode($element_arr)) . '[/element]'
+ );
}
}
@@ -129,7 +144,16 @@ function blocks_content(&$a) {
$o .= replace_macros(get_markup_template('blocklist.tpl'), array(
'$baseurl' => $url,
+ '$title' => t('Blocks'),
+ '$name' => t('Block Name'),
+ '$blocktitle' => t('Block Title'),
+ '$created' => t('Created'),
+ '$edited' => t('Edited'),
+ '$create' => t('Create'),
'$edit' => t('Edit'),
+ '$share' => t('Share'),
+ '$delete' => t('Delete'),
+ '$editor' => $editor,
'$pages' => $pages,
'$channel' => $which,
'$view' => t('View'),
diff --git a/mod/branchtopic.php b/mod/branchtopic.php
new file mode 100644
index 000000000..609cb19ec
--- /dev/null
+++ b/mod/branchtopic.php
@@ -0,0 +1,42 @@
+<?php
+
+function branchtopic_init(&$a) {
+
+ if(! local_channel())
+ return;
+
+ $item_id = 0;
+
+ if(argc() > 1)
+ $item_id = intval(argv(1));
+
+ if(! $item_id)
+ return;
+
+ $channel = $a->get_channel();
+
+ if(! $channel)
+ return;
+
+
+ $r = q("select * from item where id = %d and uid = %d and owner_xchan = '%s' and id != parent limit 1",
+ intval($item_id),
+ intval(local_channel()),
+ dbesc($channel['channel_hash'])
+ );
+
+ if(! $r)
+ return;
+
+ $p = q("select * from item where id = %d and uid = %d limit 1",
+ intval($r[0]['parent']),
+ intval(local_channel())
+ );
+
+ $x = q("update item set parent = id, route = '', item_flags = (item_flags | %d) where id = %d",
+ intval(ITEM_THREAD_TOP),
+ intval($item_id)
+ );
+
+ return;
+}
diff --git a/mod/channel.php b/mod/channel.php
index 022def2a8..b06602994 100644
--- a/mod/channel.php
+++ b/mod/channel.php
@@ -146,7 +146,7 @@ function channel_content(&$a, $update = 0, $load = false) {
*/
- $sql_extra = item_permissions_sql($a->profile['profile_uid'],$remote_contact,$groups);
+ $sql_extra = item_permissions_sql($a->profile['profile_uid']);
if(get_pconfig($a->profile['profile_uid'],'system','channel_list_mode') && (! $mid))
$page_mode = 'list';
diff --git a/mod/cloud.php b/mod/cloud.php
index b36e6c482..4b5d45f97 100644
--- a/mod/cloud.php
+++ b/mod/cloud.php
@@ -117,7 +117,7 @@ function cloud_init(&$a) {
if ((! $auth->observer) && (! $isapublic_file) && (! $davguest)) {
try {
- $auth->Authenticate($server, t('RedMatrix - Guests: Username: {your email address}, Password: +++'));
+ $auth->Authenticate($server, t('$Projectname - Guests: Username: {your email address}, Password: +++'));
}
catch (Exception $e) {
logger('mod_cloud: auth exception' . $e->getMessage());
diff --git a/mod/connedit.php b/mod/connedit.php
index 2c4c0cef8..cb524547c 100644
--- a/mod/connedit.php
+++ b/mod/connedit.php
@@ -177,7 +177,17 @@ function connedit_post(&$a) {
if(($_REQUEST['pending']) && ($abook_flags & ABOOK_FLAG_PENDING)) {
$abook_flags = ( $abook_flags ^ ABOOK_FLAG_PENDING );
$new_friend = true;
+ if(! $abook_my_perms) {
+ $abook_my_perms = get_channel_default_perms(local_channel());
+
+ $role = get_pconfig(local_channel(),'system','permissions_role');
+ if($role) {
+ $x = get_role_perms($role);
+ if($x['perms_accept'])
+ $abook_my_perms = $x['perms_accept'];
+ }
+ }
}
$r = q("UPDATE abook SET abook_profile = '%s', abook_my_perms = %d , abook_closeness = %d, abook_flags = %d
@@ -335,12 +345,12 @@ function connedit_content(&$a) {
$o .= "<script>function connectDefaultShare() {
\$('.abook-edit-me').each(function() {
if(! $(this).is(':disabled'))
- $(this).removeAttr('checked');
+ $(this).prop('checked', false);
});\n\n";
$perms = get_perms();
foreach($perms as $p => $v) {
if($my_perms & $v[1]) {
- $o .= "\$('#me_id_perms_" . $p . "').attr('checked','checked'); \n";
+ $o .= "\$('#me_id_perms_" . $p . "').prop('checked', true); \n";
}
}
$o .= " }\n</script>\n";
@@ -558,16 +568,32 @@ function connedit_content(&$a) {
if(feature_enabled(local_channel(),'affinity')) {
+ $labels = array(
+ t('Me'),
+ t('Family'),
+ t('Friends'),
+ t('Acquaintances'),
+ t('All')
+ );
+ call_hooks('affinity_labels',$labels);
+ $label_str = '';
+
+ if($labels) {
+ foreach($labels as $l) {
+ if($label_str) {
+ $label_str .= ", '|'";
+ $label_str .= ", '" . $l . "'";
+ }
+ else
+ $label_str .= "'" . $l . "'";
+ }
+ }
+
$slider_tpl = get_markup_template('contact_slider.tpl');
$slide = replace_macros($slider_tpl,array(
- '$me' => t('Me'),
'$min' => 1,
'$val' => (($contact['abook_closeness']) ? $contact['abook_closeness'] : 99),
- '$intimate' => t('Best Friends'),
- '$friends' => t('Friends'),
- '$oldfriends' => t('Former Friends'),
- '$acquaintances' => t('Acquaintances'),
- '$world' => t('Unknown')
+ '$labels' => $label_str,
));
}
diff --git a/mod/dav.php b/mod/dav.php
index f7f89b6da..2f811a7f0 100644
--- a/mod/dav.php
+++ b/mod/dav.php
@@ -118,7 +118,7 @@ function dav_init(&$a) {
if ((! $auth->observer) && (! $isapublic_file) && (! $davguest)) {
try {
- $auth->Authenticate($server, t('RedMatrix channel'));
+ $auth->Authenticate($server, t('$Projectname channel'));
}
catch (Exception $e) {
logger('mod_cloud: auth exception' . $e->getMessage());
diff --git a/mod/directory.php b/mod/directory.php
index 274584862..7c7f63037 100644
--- a/mod/directory.php
+++ b/mod/directory.php
@@ -51,6 +51,10 @@ function directory_content(&$a) {
$observer = get_observer_hash();
$globaldir = get_globaldir_setting($observer);
+ // override your personal global search pref if we're doing a navbar search of the directory
+ if(intval($_REQUEST['navsearch']))
+ $globaldir = 1;
+
$safe_mode = get_safemode_setting($observer);
$pubforums = null;
@@ -78,12 +82,15 @@ function directory_content(&$a) {
$suggest = (local_channel() && x($_REQUEST,'suggest')) ? $_REQUEST['suggest'] : '';
if($suggest) {
+
$r = suggestion_query(local_channel(),get_observer_hash());
// Remember in which order the suggestions were
$addresses = array();
+ $common = array();
$index = 0;
foreach($r as $rr) {
+ $common[$rr['xchan_addr']] = $rr['total'];
$addresses[$rr['xchan_addr']] = $index++;
}
@@ -151,7 +158,11 @@ function directory_content(&$a) {
if(! is_null($pubforums))
$query .= '&pubforums=' . intval($pubforums);
- $sort_order = ((x($_REQUEST,'order')) ? $_REQUEST['order'] : 'date');
+ $directory_sort_order = get_config('system','directory_sort_order');
+ if(! $directory_sort_order)
+ $directory_sort_order = 'date';
+
+ $sort_order = ((x($_REQUEST,'order')) ? $_REQUEST['order'] : $directory_sort_order);
if($sort_order)
$query .= '&order=' . urlencode($sort_order);
@@ -231,7 +242,7 @@ function directory_content(&$a) {
$hometown = ((x($profile,'hometown') == 1) ? t('Hometown: ') . $profile['hometown'] : False);
- $about = ((x($profile,'about') == 1) ? t('About: ') . bbcode($profile['about']) : False);
+ $about = ((x($profile,'about') == 1) ? t('About: ') . bbcode(strip_bbimage($profile['about'])) : False);
$keywords = ((x($profile,'keywords')) ? $profile['keywords'] : '');
@@ -296,6 +307,8 @@ function directory_content(&$a) {
'keywords' => $out,
'ignlink' => $suggest ? $a->get_baseurl() . '/directory?ignore=' . $rr['hash'] : '',
'ignore_label' => "Don't suggest",
+ 'common_friends' => (($common[$rr['address']]) ? intval($common[$rr['address']]) : ''),
+ 'common_txt' => sprintf( t('Common connections: %s'), intval($common[$rr['address']]) ),
'safe' => $safe_mode
);
diff --git a/mod/dirsearch.php b/mod/dirsearch.php
index 07621aaef..d997020b2 100644
--- a/mod/dirsearch.php
+++ b/mod/dirsearch.php
@@ -91,6 +91,12 @@ function dirsearch_content(&$a) {
else
$sync = false;
+
+ if($hub)
+ $hub_query = " and xchan_hash in (select hubloc_hash from hubloc where hubloc_host = '" . protect_sprintf(dbesc($hub)) . "') ";
+ else
+ $hub_query = '';
+
$sort_order = ((x($_REQUEST,'order')) ? $_REQUEST['order'] : '');
$joiner = ' OR ';
@@ -99,8 +105,6 @@ function dirsearch_content(&$a) {
if($name)
$sql_extra .= dir_query_build($joiner,'xchan_name',$name);
- if($hub)
- $sql_extra .= " $joiner xchan_hash in (select hubloc_hash from hubloc where hubloc_host = '" . protect_sprintf(dbesc($hub)) . "') ";
if($address)
$sql_extra .= dir_query_build($joiner,'xchan_addr',$address);
if($city)
@@ -248,13 +252,12 @@ function dirsearch_content(&$a) {
}
else {
- $r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash where ( $logic $sql_extra ) and xchan_network = 'zot' and not ( xchan_flags & %d )>0 and not ( xchan_flags & %d )>0 and not ( xchan_flags & %d )>0 $safesql $order $qlimit ",
+ $r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash where ( $logic $sql_extra ) $hub_query and xchan_network = 'zot' and not ( xchan_flags & %d )>0 and not ( xchan_flags & %d )>0 and not ( xchan_flags & %d )>0 $safesql $order $qlimit ",
intval(XCHAN_FLAGS_HIDDEN),
intval(XCHAN_FLAGS_ORPHAN),
intval(XCHAN_FLAGS_DELETED)
);
-
$ret['page'] = $page + 1;
$ret['records'] = count($r);
}
diff --git a/mod/editblock.php b/mod/editblock.php
index 73be6a9f3..a0ece8133 100644
--- a/mod/editblock.php
+++ b/mod/editblock.php
@@ -70,7 +70,6 @@ function editblock_content(&$a) {
$o = '';
-
// Figure out which post we're editing
$post_id = ((argc() > 2) ? intval(argv(2)) : 0);
@@ -96,7 +95,6 @@ function editblock_content(&$a) {
return;
}
-
$plaintext = true;
$mimeselect = '';
@@ -110,22 +108,21 @@ function editblock_content(&$a) {
else
$mimeselect = mimetype_select($itm[0]['uid'],$mimetype);
-
$o .= replace_macros(get_markup_template('edpost_head.tpl'), array(
- '$title' => t('Edit Block')
+ '$title' => t('Edit Block'),
+ '$delete' => ((($itm[0]['author_xchan'] === $ob_hash) || ($itm[0]['owner_xchan'] === $ob_hash)) ? t('Delete') : false),
+ '$id' => $itm[0]['id']
));
-
$a->page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array(
'$baseurl' => $a->get_baseurl(),
'$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
'$ispublic' => '&nbsp;', // t('Visible to <strong>everybody</strong>'),
'$geotag' => '',
'$nickname' => $channel['channel_address'],
- '$confirmdelete' => t('Delete block?')
+ '$confirmdelete' => t('Delete block?')
));
-
$tpl = get_markup_template("jot.tpl");
$jotplugins = '';
@@ -184,26 +181,6 @@ function editblock_content(&$a) {
'$expires' => t('Set expiration date'),
));
-
- if(($itm[0]['author_xchan'] === $ob_hash) || ($itm[0]['owner_xchan'] === $ob_hash))
- $o .= '<br /><br /><a class="block-delete-link" href="item/drop/' . $itm[0]['id'] . '" >' . t('Delete Block') . '</a><br />';
-
-
- $x = array(
- 'type' => 'block',
- 'title' => $itm[0]['title'],
- 'body' => $itm[0]['body'],
- 'term' => $itm[0]['term'],
- 'created' => $itm[0]['created'],
- 'edited' => $itm[0]['edited'],
- 'mimetype' => $itm[0]['mimetype'],
- 'pagetitle' => $page_title,
- 'mid' => $itm[0]['mid']
- );
-
- $o .= EOL . EOL . t('Share') . EOL . '<textarea onclick="this.select();" class="shareable_element_text" >[element]' . base64url_encode(json_encode($x)) . '[/element]</textarea>' . EOL . EOL;
-
-
return $o;
}
diff --git a/mod/editlayout.php b/mod/editlayout.php
index f6d76f6b4..8ab5aab22 100644
--- a/mod/editlayout.php
+++ b/mod/editlayout.php
@@ -23,7 +23,6 @@ function editlayout_init(&$a) {
function editlayout_content(&$a) {
-
if(! $a->profile) {
notice( t('Requested profile is not available.') . EOL );
$a->error = 404;
@@ -69,7 +68,6 @@ function editlayout_content(&$a) {
$o = '';
-
// Figure out which post we're editing
$post_id = ((argc() > 2) ? intval(argv(2)) : 0);
@@ -105,7 +103,9 @@ function editlayout_content(&$a) {
$plaintext = true;
$o .= replace_macros(get_markup_template('edpost_head.tpl'), array(
- '$title' => t('Edit Layout')
+ '$title' => t('Edit Layout'),
+ '$delete' => ((($itm[0]['author_xchan'] === $ob_hash) || ($itm[0]['owner_xchan'] === $ob_hash)) ? t('Delete') : false),
+ '$id' => $itm[0]['id']
));
$a->page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array(
@@ -114,7 +114,7 @@ function editlayout_content(&$a) {
'$ispublic' => '&nbsp;', // t('Visible to <strong>everybody</strong>'),
'$geotag' => $geotag,
'$nickname' => $channel['channel_address'],
- '$confirmdelete' => t('Delete layout?')
+ '$confirmdelete' => t('Delete layout?')
));
@@ -130,7 +130,7 @@ function editlayout_content(&$a) {
// FIXME A return path with $_SESSION doesn't always work for observer - it may WSoD
// instead of loading a sensible page. So, send folk to the webpage list.
- $rp = '/layouts/' . $which;
+ $rp = 'layouts/' . $which;
$o .= replace_macros($tpl,array(
'$return_path' => $rp,
@@ -161,8 +161,9 @@ function editlayout_content(&$a) {
'$public' => t('Public post'),
'$jotnets' => $jotnets,
'$title' => htmlspecialchars($itm[0]['title'],ENT_COMPAT,'UTF-8'),
- '$placeholdertitle' => t('Title (optional)'),
+ '$placeholdertitle' => t('Layout Description (Optional)'),
'$pagetitle' => $layout_title,
+ '$placeholdpagetitle' => t('Layout Name'),
'$category' => '',
'$placeholdercategory' => t('Categories (optional, comma-separated list)'),
'$emtitle' => t('Example: bob@example.com, mary@example.com'),
@@ -170,34 +171,12 @@ function editlayout_content(&$a) {
'$acl' => '',
'$bang' => '',
'$profile_uid' => (intval($owner)),
- '$preview' => t('Preview'),
'$jotplugins' => $jotplugins,
'$sourceapp' => t($a->sourcename),
'$defexpire' => '',
'$feature_expire' => false,
'$expires' => t('Set expiration date'),
));
-
-
- if(($itm[0]['author_xchan'] === $ob_hash) || ($itm[0]['owner_xchan'] === $ob_hash))
- $o .= '<br /><br /><a class="layout-delete-link" href="item/drop/' . $itm[0]['id'] . '" >' . t('Delete Layout') . '</a><br />';
-
-
- $x = array(
- 'type' => 'layout',
- 'title' => $itm[0]['title'],
- 'body' => $itm[0]['body'],
- 'term' => $itm[0]['term'],
- 'created' => $itm[0]['created'],
- 'edited' => $itm[0]['edited'],
- 'mimetype' => $itm[0]['mimetype'],
- 'pagetitle' => $page_title,
- 'mid' => $itm[0]['mid']
- );
-
- $o .= EOL . EOL . t('Share') . EOL . '<textarea onclick="this.select();" class="shareable_element_text" >[element]' . base64url_encode(json_encode($x)) . '[/element]</textarea>' . EOL . EOL;
-
-
return $o;
diff --git a/mod/editpost.php b/mod/editpost.php
index 58ebe31cb..81bb91b2a 100644
--- a/mod/editpost.php
+++ b/mod/editpost.php
@@ -132,6 +132,7 @@ function editpost_content(&$a) {
'$ptyp' => $itm[0]['type'],
'$content' => undo_post_tagging($itm[0]['body']),
'$post_id' => $post_id,
+ '$parent' => (($itm[0]['parent'] != $itm[0]['id']) ? $itm[0]['parent'] : ''),
'$baseurl' => $a->get_baseurl(),
'$defloc' => $channel['channel_location'],
'$visitor' => false,
diff --git a/mod/editwebpage.php b/mod/editwebpage.php
index e81cde479..cdf5d8c20 100644
--- a/mod/editwebpage.php
+++ b/mod/editwebpage.php
@@ -90,11 +90,18 @@ function editwebpage_content(&$a) {
// We've already figured out which item we want and whose copy we need,
// so we don't need anything fancy here
- $itm = q("SELECT * FROM `item` WHERE `id` = %d and uid = %s LIMIT 1",
+ $sql_extra = item_permissions_sql($owner);
+
+ $itm = q("SELECT * FROM `item` WHERE `id` = %d and uid = %s $sql_extra LIMIT 1",
intval($post_id),
intval($owner)
);
+ if(! $itm) {
+ notice( t('Permission denied.') . EOL);
+ return;
+ }
+
if($itm[0]['item_flags'] & ITEM_OBSCURED) {
$key = get_config('system','prvkey');
if($itm[0]['title'])
@@ -126,7 +133,7 @@ function editwebpage_content(&$a) {
$plaintext = true;
if(get_config('system','page_mimetype'))
- $mimeselect = '<input type="hidden" name="mimetype" value="' . $mimetype . '" />';
+ $mimeselect = '<input type="hidden" name="mimetype" value="' . $mimetype . '" />';
else
$mimeselect = mimetype_select($itm[0]['uid'],$mimetype);
@@ -135,12 +142,7 @@ function editwebpage_content(&$a) {
$layoutselect = '<input type="hidden" name="layout_mid" value="' . $layout . '" />';
else
$layoutselect = layout_select($itm[0]['uid'],$itm[0]['layout_mid']);
-
- $o .= replace_macros(get_markup_template('edpost_head.tpl'), array(
- '$title' => t('Edit Webpage')
- ));
-
$a->page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array(
'$baseurl' => $a->get_baseurl(),
'$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
@@ -150,7 +152,6 @@ function editwebpage_content(&$a) {
'$confirmdelete' => t('Delete webpage?')
));
-
$tpl = get_markup_template("jot.tpl");
$jotplugins = '';
@@ -164,8 +165,9 @@ function editwebpage_content(&$a) {
$rp = 'webpages/' . $which;
-logger('canwrite: ' . (perm_is_allowed($owner, get_observer_hash(), 'post_photos') || perm_is_allowed($owner, get_observer_hash(), 'write_storage')));
- $o .= replace_macros($tpl,array(
+ logger('canwrite: ' . (perm_is_allowed($owner, get_observer_hash(), 'post_photos') || perm_is_allowed($owner, get_observer_hash(), 'write_storage')));
+
+ $editor = replace_macros($tpl,array(
'$return_path' => $rp,
'$webpage' => ITEM_WEBPAGE,
'$placeholdpagetitle' => t('Page link title'),
@@ -186,7 +188,7 @@ logger('canwrite: ' . (perm_is_allowed($owner, get_observer_hash(), 'post_photos
'$video' => t('Insert Vorbis [.ogg] video'),
'$audio' => t('Insert Vorbis [.ogg] audio'),
'$setloc' => t('Set your location'),
- '$noloc' => t('Clear browser location'),
+ '$noloc' => ((get_pconfig($uid, 'system', 'use_browser_location')) ? t('Clear browser location') : ''),
'$wait' => t('Please wait'),
'$permset' => t('Permission settings'),
'$ptyp' => $itm[0]['type'],
@@ -218,23 +220,12 @@ logger('canwrite: ' . (perm_is_allowed($owner, get_observer_hash(), 'post_photos
));
- if(($itm[0]['author_xchan'] === $ob_hash) || ($itm[0]['owner_xchan'] === $ob_hash))
- $o .= '<br /><br /><a class="page-delete-link" href="item/drop/' . $itm[0]['id'] . '" >' . t('Delete Webpage') . '</a><br />';
-
-
- $x = array(
- 'type' => 'webpage',
- 'title' => $itm[0]['title'],
- 'body' => $itm[0]['body'],
- 'term' => $itm[0]['term'],
- 'created' => $itm[0]['created'],
- 'edited' => $itm[0]['edited'],
- 'mimetype' => $itm[0]['mimetype'],
- 'pagetitle' => $page_title,
- 'mid' => $itm[0]['mid']
- );
-
- $o .= EOL . EOL . t('Share') . EOL . '<textarea onclick="this.select();" class="shareable_element_text" >[element]' . base64url_encode(json_encode($x)) . '[/element]</textarea>' . EOL . EOL;
+ $o .= replace_macros(get_markup_template('edpost_head.tpl'), array(
+ '$title' => t('Edit Webpage'),
+ '$delete' => ((($itm[0]['author_xchan'] === $ob_hash) || ($itm[0]['owner_xchan'] === $ob_hash)) ? t('Delete') : false),
+ '$editor' => $editor,
+ '$id' => $itm[0]['id']
+ ));
return $o;
diff --git a/mod/filestorage.php b/mod/filestorage.php
index f2c795379..8b52c086b 100644
--- a/mod/filestorage.php
+++ b/mod/filestorage.php
@@ -21,7 +21,7 @@ function filestorage_post(&$a) {
$recurse = ((x($_POST, 'recurse')) ? intval($_POST['recurse']) : 0);
$resource = ((x($_POST, 'filehash')) ? notags($_POST['filehash']) : '');
- $no_activity = ((x($_POST, 'no_activity')) ? intval($_POST['no_activity']) : 0);
+ $notify = ((x($_POST, 'notify')) ? intval($_POST['notify']) : 0);
if(! $resource) {
notice(t('Item not found.') . EOL);
@@ -41,7 +41,7 @@ function filestorage_post(&$a) {
attach_change_permissions($channel_id, $resource, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny, $recurse);
- file_activity($channel_id, $object, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny, 'post', $no_activity);
+ file_activity($channel_id, $object, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny, 'post', $notify);
goaway($cloudPath);
}
@@ -148,15 +148,15 @@ function filestorage_content(&$a) {
'$aclselect' => $aclselect_e,
'$lockstate' => $lockstate,
'$permset' => t('Set/edit permissions'),
- '$recurse' => t('Include all files and sub folders'),
+ '$recurse' => array('recurse', t('Include all files and sub folders'), 0, '', array(t('No'), t('Yes'))),
'$backlink' => t('Return to file list'),
'$isadir' => $is_a_dir,
'$cpdesc' => t('Copy/paste this code to attach file to a post'),
'$cpldesc' => t('Copy/paste this URL to link file from a web page'),
'$submit' => t('Submit'),
- '$attach_btn_title' => t('Attach this file to a new post'),
+ '$attach_btn_title' => t('Share this file'),
'$link_btn_title' => t('Show URL to this file'),
- '$activity_btn_title' => t('Do not show in shared with me folder of your connections')
+ '$notify' => array('notify', t('Notify your contacts about this file'), 0, '', array(t('No'), t('Yes')))
));
echo $o;
diff --git a/mod/help.php b/mod/help.php
index 0081e54e7..3d7c0a628 100644
--- a/mod/help.php
+++ b/mod/help.php
@@ -97,7 +97,7 @@ function help_content(&$a) {
$content = preg_replace_callback("/#include (.*?)\;/ism", 'preg_callback_help_include', $content);
return replace_macros(get_markup_template("help.tpl"), array(
- '$content' => $content
+ '$content' => translate_projectname($content)
));
}
diff --git a/mod/home.php b/mod/home.php
index 7f28a89fc..3091be3a1 100644
--- a/mod/home.php
+++ b/mod/home.php
@@ -20,7 +20,7 @@ function home_init(&$a) {
if(! $dest)
$dest = get_config('system','startpage');
if(! $dest)
- $dest = z_root() . '/apps';
+ $dest = z_root() . '/network';
goaway($dest);
}
@@ -37,9 +37,6 @@ function home_content(&$a, $update = 0, $load = false) {
$o = '';
- if($load)
- $_SESSION['loadtime'] = datetime_convert();
-
if(x($_SESSION,'theme'))
unset($_SESSION['theme']);
if(x($_SESSION,'mobile_theme'))
@@ -47,236 +44,38 @@ function home_content(&$a, $update = 0, $load = false) {
$splash = ((argc() > 1 && argv(1) === 'splash') ? true : false);
- if(get_config('system','projecthome')) {
- $o .= file_get_contents('assets/home.html');
- $a->page['template'] = 'full';
- $a->page['title'] = t('Red Matrix - &quot;The Network&quot;');
- return $o;
- }
-
-
- // Deprecated
- $channel_address = get_config("system", "site_channel" );
-
- // See if the sys channel set a homepage
- if (! $channel_address) {
- require_once('include/identity.php');
- $u = get_sys_channel();
- if ($u) {
- $u = array($u);
- // change to channel_id when below deprecated and skip the $u=...
- $channel_address = $u[0]['channel_address'];
- }
- }
-
- if($channel_address) {
- $page_id = 'home';
-
- $u = q("select channel_id from channel where channel_address = '%s' limit 1",
- dbesc($channel_address)
- );
-
- $r = q("select item.* from item left join item_id on item.id = item_id.iid
- where item.uid = %d and sid = '%s' and service = 'WEBPAGE' and
- item_restrict = %d limit 1",
- intval($u[0]['channel_id']),
- dbesc($page_id),
- intval(ITEM_WEBPAGE)
- );
-
- if($r) {
- xchan_query($r);
- $r = fetch_post_tags($r,true);
-
- if($r[0]['layout_mid']) {
- $l = q("select body from item where mid = '%s' and uid = %d limit 1",
- dbesc($r[0]['layout_mid']),
- intval($u[0]['channel_id'])
- );
+ call_hooks('home_content',$o);
+ if($o)
+ return $o;
- if($l) {
- require_once('include/comanche.php');
- comanche_parser($a,$l[0]['body']);
- $a->pdl = $l[0]['body'];
- }
+ $frontpage = get_config('system','frontpage');
+ if($frontpage) {
+ if(strpos($frontpage,'include:') !== false) {
+ $file = trim(str_replace('include:' , '', $frontpage));
+ if(file_exists($file)) {
+ $a->page['template'] = 'full';
+ $a->page['title'] = t('$Projectname');
+ $o .= file_get_contents($file);
+ return $o;
}
-
- $a->profile = array('profile_uid' => $u[0]['channel_id']);
- $a->profile_uid = $u[0]['channel_id'];
- $o .= prepare_page($r[0]);
- return $o;
}
- }
-
- // Nope, we didn't find an item. Let's see if there's any html
-
- if(file_exists('home.html')) {
- $o .= file_get_contents('home.html');
- }
- else {
- $sitename = get_config('system','sitename');
- if($sitename)
- $o .= '<h1>' . sprintf( t("Welcome to %s") ,$sitename) . '</h1>';
-
- if(intval(get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) {
- // If there's nothing special happening, just spit out a login box
-
- if (! $a->config['system']['no_login_on_homepage'])
- $o .= login(($a->config['system']['register_policy'] == REGISTER_CLOSED) ? 0 : 1);
- return $o;
+ if(intval(get_config('system','mirror_frontpage'))) {
+ $o = '<html><head><title>' . t('$Projectname') . '</title></head><body style="margin: 0; padding: 0; border: none;" ><iframe src="' . z_root() . '/' . $frontpage . '" width="100%" height="100%" style="margin: 0; padding: 0; border: none;" ></iframe></body></html>';
+ echo $o;
+ killme();
}
- else {
-
- if(get_config('system','disable_discover_tab')) {
- call_hooks('home_content',$o);
- return $o;
- }
-
- if(! $update) {
-
- $maxheight = get_config('system','home_divmore_height');
- if(! $maxheight)
- $maxheight = 75;
-
- $o .= '<div id="live-home"></div>' . "\r\n";
- $o .= "<script> var profile_uid = " . ((intval(local_channel())) ? local_channel() : (-1))
- . "; var profile_page = " . $a->pager['page']
- . "; divmore_height = " . intval($maxheight) . "; </script>\r\n";
-
- $a->page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),array(
- '$baseurl' => z_root(),
- '$pgtype' => 'home',
- '$uid' => ((local_channel()) ? local_channel() : '0'),
- '$gid' => '0',
- '$cid' => '0',
- '$cmin' => '0',
- '$cmax' => '99',
- '$star' => '0',
- '$liked' => '0',
- '$conv' => '0',
- '$spam' => '0',
- '$fh' => '1',
- '$nouveau' => '0',
- '$wall' => '0',
- '$list' => '0',
- '$page' => (($a->pager['page'] != 1) ? $a->pager['page'] : 1),
- '$search' => '',
- '$order' => 'comment',
- '$file' => '',
- '$cats' => '',
- '$tags' => '',
- '$dend' => '',
- '$mid' => '',
- '$verb' => '',
- '$dbegin' => ''
- ));
- }
-
- if($update && ! $load) {
- // only setup pagination on initial page view
- $pager_sql = '';
- }
- else {
- $a->set_pager_itemspage(20);
- $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval($a->pager['itemspage']), intval($a->pager['start']));
- }
-
- require_once('include/identity.php');
-
- if(get_config('system','site_firehose')) {
- require_once('include/security.php');
- $uids = " and item.uid in ( " . stream_perms_api_uids(PERMS_PUBLIC) . " ) and item_private = 0 and (item_flags & " . intval(ITEM_WALL) . " ) > 0 ";
- }
- else {
- $sys = get_sys_channel();
- $uids = " and item.uid = " . intval($sys['channel_id']) . " ";
- $a->data['firehose'] = intval($sys['channel_id']);
- }
-
- $page_mode = 'list';
-
- $simple_update = (($update) ? " and item.item_unseen = 1 " : '');
-
- if($update && $_SESSION['loadtime'])
- $simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) OR item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) ";
- if($load)
- $simple_update = '';
-
- //logger('update: ' . $update . ' load: ' . $load);
-
- if($update) {
-
- $ordering = "commented";
-
- if($load) {
-
- // Fetch a page full of parent items for this page
-
- $r = q("SELECT distinct item.id AS item_id, $ordering FROM item
- left join abook on item.author_xchan = abook.abook_xchan
- WHERE true $uids AND item.item_restrict = 0
- AND item.parent = item.id
- and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)
- $sql_extra3 $sql_extra $sql_nets
- ORDER BY $ordering DESC $pager_sql ",
- intval(ABOOK_FLAG_BLOCKED)
- );
-
-
- }
- elseif($update) {
-
- $r = q("SELECT distinct item.id AS item_id, $ordering FROM item
- left join abook on item.author_xchan = abook.abook_xchan
- WHERE true $uids AND item.item_restrict = 0
- AND item.parent = item.id $simple_update
- and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)
- $sql_extra3 $sql_extra $sql_nets",
- intval(ABOOK_FLAG_BLOCKED)
- );
- $_SESSION['loadtime'] = datetime_convert();
- }
- // Then fetch all the children of the parents that are on this page
- $parents_str = '';
- $update_unseen = '';
-
- if($r) {
-
- $parents_str = ids_to_querystr($r,'item_id');
-
- $items = q("SELECT item.*, item.id AS item_id FROM item
- WHERE true $uids AND item.item_restrict = 0
- AND item.parent IN ( %s )
- $sql_extra ",
- dbesc($parents_str)
- );
-
- xchan_query($items,true,(-1));
- $items = fetch_post_tags($items,true);
- $items = conv_sort($items,$ordering);
- }
- else {
- $items = array();
- }
-
- }
-
- // fake it
- $mode = ('network');
-
- $o .= conversation($a,$items,$mode,$update,$page_mode);
-
- if(($items) && (! $update))
- $o .= alt_pager($a,count($items));
+ goaway(z_root() . '/' . $frontpage);
+ }
- return $o;
+ $sitename = get_config('system','sitename');
+ if($sitename)
+ $o .= '<h1>' . sprintf( t("Welcome to %s") ,$sitename) . '</h1>';
- }
- call_hooks('home_content',$o);
- return $o;
- }
+ $loginbox = get_config('system','login_on_homepage');
+ if(intval($loginbox) || $loginbox === false)
+ $o .= login(($a->config['system']['register_policy'] == REGISTER_CLOSED) ? 0 : 1);
return $o;
-} \ No newline at end of file
+}
diff --git a/mod/impel.php b/mod/impel.php
index 1b641b301..0b29bcf02 100644
--- a/mod/impel.php
+++ b/mod/impel.php
@@ -2,6 +2,7 @@
// import page design element
+require_once('include/menu.php');
function impel_init(&$a) {
@@ -21,10 +22,13 @@ function impel_init(&$a) {
if(! $j)
json_return_and_die($ret);
-
$channel = $a->get_channel();
$arr = array();
+ $is_menu = false;
+
+ // a portable menu has its links rewritten with the local baseurl
+ $portable_menu = false;
switch($j['type']) {
case 'webpage':
@@ -42,80 +46,155 @@ function impel_init(&$a) {
$namespace = 'PDL';
$installed_type = t('layout');
break;
+ case 'portable-menu':
+ $portable_menu = true;
+ // fall through
+ case 'menu':
+ $is_menu = true;
+ $installed_type = t('menu');
+ break;
default:
logger('mod_impel: unrecognised element type' . print_r($j,true));
break;
}
- $arr['uid'] = local_channel();
- $arr['aid'] = $channel['channel_account_id'];
- $arr['title'] = $j['title'];
- $arr['body'] = $j['body'];
- $arr['term'] = $j['term'];
- $arr['created'] = datetime_convert('UTC','UTC', $j['created']);
- $arr['edited'] = datetime_convert('UTC','UTC',$j['edited']);
- $arr['owner_xchan'] = get_observer_hash();
- $arr['author_xchan'] = (($j['author_xchan']) ? $j['author_xchan'] : get_observer_hash());
- $arr['mimetype'] = (($j['mimetype']) ? $j['mimetype'] : 'text/bbcode');
-
- if(! $j['mid'])
- $j['mid'] = item_message_id();
-
- $arr['mid'] = $arr['parent_mid'] = $j['mid'];
-
-
- if($j['pagetitle']) {
- require_once('library/urlify/URLify.php');
- $pagetitle = strtolower(URLify::transliterate($j['pagetitle']));
+
+ if($is_menu) {
+ $m = array();
+ $m['menu_channel_id'] = local_channel();
+ $m['menu_name'] = $j['pagetitle'];
+ $m['menu_desc'] = $j['desc'];
+ if($j['created'])
+ $m['menu_created'] = datetime_convert($j['created']);
+ if($j['edited'])
+ $m['menu_edited'] = datetime_convert($j['edited']);
+
+ $m['menu_flags'] = 0;
+ if($j['flags']) {
+ if(in_array('bookmark',$j['flags']))
+ $m['menu_flags'] |= MENU_BOOKMARK;
+ if(in_array('system',$j['flags']))
+ $m['menu_flags'] |= MENU_SYSTEM;
+
+ }
+
+ $menu_id = menu_create($m);
+
+ if($menu_id) {
+ if(is_array($j['items'])) {
+ foreach($j['items'] as $it) {
+ $mitem = array();
+
+ $mitem['mitem_link'] = str_replace('[baseurl]',z_root(),$it['link']);
+ $mitem['mitem_desc'] = escape_tags($it['desc']);
+ $mitem['mitem_order'] = intval($it['order']);
+ if(is_array($it['flags'])) {
+ $mitem['mitem_flags'] = 0;
+ if(in_array('zid',$it['flags']))
+ $mitem['mitem_flags'] |= MENU_ITEM_ZID;
+ if(in_array('new-window',$it['flags']))
+ $mitem['mitem_flags'] |= MENU_ITEM_NEWWIN;
+ if(in_array('chatroom',$it['flags']))
+ $mitem['mitem_flags'] |= MENU_ITEM_CHATROOM;
+ }
+ menu_add_item($menu_id,local_channel(),$mitem);
+ }
+ if($j['edited']) {
+ $x = q("update menu set menu_edited = '%s' where menu_id = %d and menu_channel_id = %d",
+ dbesc(datetime_convert('UTC','UTC',$j['edited'])),
+ intval($menu_id),
+ intval(local_channel())
+ );
+ }
+ }
+ $ret['success'] = true;
+ }
+ $x = $ret;
}
+ else {
+ $arr['uid'] = local_channel();
+ $arr['aid'] = $channel['channel_account_id'];
+ $arr['title'] = $j['title'];
+ $arr['body'] = $j['body'];
+ $arr['term'] = $j['term'];
+ $arr['layout_mid'] = $j['layout_mid'];
+ $arr['created'] = datetime_convert('UTC','UTC', $j['created']);
+ $arr['edited'] = datetime_convert('UTC','UTC',$j['edited']);
+ $arr['owner_xchan'] = get_observer_hash();
+ $arr['author_xchan'] = (($j['author_xchan']) ? $j['author_xchan'] : get_observer_hash());
+ $arr['mimetype'] = (($j['mimetype']) ? $j['mimetype'] : 'text/bbcode');
+
+ if(! $j['mid'])
+ $j['mid'] = item_message_id();
+
+ $arr['mid'] = $arr['parent_mid'] = $j['mid'];
+
+
+ if($j['pagetitle']) {
+ require_once('library/urlify/URLify.php');
+ $pagetitle = strtolower(URLify::transliterate($j['pagetitle']));
+ }
- // Verify ability to use html or php!!!
+ // Verify ability to use html or php!!!
- $execflag = false;
+ $execflag = false;
+
+ if($arr['mimetype'] === 'application/x-php') {
+ $z = q("select account_id, account_roles, channel_pageflags from account left join channel on channel_account_id = account_id where channel_id = %d limit 1",
+ intval(local_channel())
+ );
+
+ if($z && (($z[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE) || ($z[0]['channel_pageflags'] & PAGE_ALLOWCODE))) {
+ $execflag = true;
+ }
+ }
- if($arr['mimetype'] === 'application/x-php') {
- $z = q("select account_id, account_roles, channel_pageflags from account left join channel on channel_account_id = account_id where channel_id = %d limit 1",
+ $remote_id = 0;
+
+ $z = q("select * from item_id where sid = '%s' and service = '%s' and uid = %d limit 1",
+ dbesc($pagetitle),
+ dbesc($namespace),
+ intval(local_channel())
+ );
+ $i = q("select id, edited, item_restrict from item where mid = '%s' and uid = %d limit 1",
+ dbesc($arr['mid']),
intval(local_channel())
);
- if($z && (($z[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE) || ($z[0]['channel_pageflags'] & PAGE_ALLOWCODE))) {
- $execflag = true;
+ if($z && $i) {
+ $remote_id = $z[0]['id'];
+ $arr['id'] = $i[0]['id'];
+ // don't update if it has the same timestamp as the original
+ if($arr['edited'] > $i[0]['edited'])
+ $x = item_store_update($arr,$execflag);
+ }
+ else {
+ if(($i) && ($i[0]['item_restrict'] & ITEM_DELETED)) {
+ // was partially deleted already, finish it off
+ q("delete from item where mid = '%s' and uid = %d",
+ dbesc($arr['mid']),
+ intval(local_channel())
+ );
+ }
+ $x = item_store($arr,$execflag);
+ }
+
+ if($x['success']) {
+ $item_id = $x['item_id'];
+ update_remote_id($channel,$item_id,$arr['item_restrict'],$pagetitle,$namespace,$remote_id,$arr['mid']);
}
}
- $remote_id = 0;
-
- $z = q("select * from item_id where sid = '%s' and service = '%s' and uid = %d limit 1",
- dbesc($pagetitle),
- dbesc($namespace),
- intval(local_channel())
- );
- $i = q("select id from item where mid = '%s' and uid = %d limit 1",
- dbesc($arr['mid']),
- intval(local_channel())
- );
- if($z && $i) {
- $remote_id = $z[0]['id'];
- $arr['id'] = $i[0]['id'];
- // don't update if it has the same timestamp as the original
- if($arr['edited'] > $i[0]['edited'])
- $x = item_store_update($arr,$execflag);
+ if($x['success']) {
+ $ret['success'] = true;
+ info( sprintf( t('%s element installed'), $installed_type));
}
else {
- $x = item_store($arr,$execflag);
+ notice( sprintf( t('%s element installation failed'), $installed_type));
}
- if($x['success'])
- $item_id = $x['item_id'];
-
-
- update_remote_id($channel,$item_id,$arr['item_restrict'],$pagetitle,$namespace,$remote_id,$arr['mid']);
-
-
- $ret['success'] = true;
-
- info( sprintf( t('%s element installed'), $installed_type));
+//??? should perhaps return ret?
json_return_and_die(true);
-} \ No newline at end of file
+}
diff --git a/mod/invite.php b/mod/invite.php
index e197278d1..1fdfbacc6 100644
--- a/mod/invite.php
+++ b/mod/invite.php
@@ -129,12 +129,12 @@ function invite_content(&$a) {
'$invite' => t('Send invitations'),
'$addr_text' => t('Enter email addresses, one per line:'),
'$msg_text' => t('Your message:'),
- '$default_message' => t('Please join my community on RedMatrix.') . "\r\n" . "\r\n"
+ '$default_message' => t('Please join my community on $Projectname.') . "\r\n" . "\r\n"
. $linktxt
. (($invonly) ? "\r\n" . "\r\n" . t('You will need to supply this invitation code: ') . $invite_code . "\r\n" . "\r\n" : '')
- . t('1. Register at any RedMatrix location (they are all inter-connected)')
+ . t('1. Register at any $Projectname location (they are all inter-connected)')
. "\r\n" . "\r\n" . z_root() . '/register'
- . "\r\n" . "\r\n" . t('2. Enter my RedMatrix network address into the site searchbar.')
+ . "\r\n" . "\r\n" . t('2. Enter my $Projectname network address into the site searchbar.')
. "\r\n" . "\r\n" . $ob['xchan_addr'] . ' (' . t('or visit ') . z_root() . '/channel/' . $channel['channel_address'] . ')'
. "\r\n" . "\r\n"
. t('3. Click [Connect]')
diff --git a/mod/item.php b/mod/item.php
index fa40aea03..3ff286268 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -22,7 +22,6 @@ require_once('include/attach.php');
function item_post(&$a) {
-
// This will change. Figure out who the observer is and whether or not
// they have permission to post here. Else ignore the post.
@@ -116,7 +115,7 @@ function item_post(&$a) {
* Check service class limits
*/
if ($uid && !(x($_REQUEST,'parent')) && !(x($_REQUEST,'post_id'))) {
- $ret = item_check_service_class($uid,x($_REQUEST,'webpage'));
+ $ret = item_check_service_class($uid,(($_REQUEST['webpage'] == ITEM_WEBPAGE) ? true : false));
if (!$ret['success']) {
notice( t($ret['message']) . EOL) ;
if(x($_REQUEST,'return'))
@@ -305,6 +304,7 @@ function item_post(&$a) {
}
}
}
+
$public_policy = ((x($_REQUEST,'public_policy')) ? escape_tags($_REQUEST['public_policy']) : map_scope($channel['channel_r_stream'],true));
if($webpage)
@@ -327,13 +327,15 @@ function item_post(&$a) {
$str_group_deny = $orig_post['deny_gid'];
$str_contact_deny = $orig_post['deny_cid'];
$public_policy = $orig_post['public_policy'];
+ $private = $orig_post['item_private'];
}
if((strlen($str_group_allow))
|| strlen($str_contact_allow)
|| strlen($str_group_deny)
|| strlen($str_contact_deny)
- || strlen($public_policy)) {
+ || strlen($public_policy)
+ || $private) {
$private = 1;
}
@@ -399,6 +401,7 @@ function item_post(&$a) {
$verb = notags(trim($_REQUEST['verb']));
$title = escape_tags(trim($_REQUEST['title']));
$body = trim($_REQUEST['body']);
+ $body .= trim($_REQUEST['attachment']);
$postopts = '';
$private = (
@@ -452,8 +455,6 @@ function item_post(&$a) {
}
}
- $post_type = notags(trim($_REQUEST['type']));
-
$mimetype = notags(trim($_REQUEST['mimetype']));
if(! $mimetype)
$mimetype = 'text/bbcode';
@@ -548,40 +549,6 @@ function item_post(&$a) {
$body = preg_replace_callback('/\[img(.*?)\](.*?)\[\/img\]/ism','red_zrlify_img_callback',$body);
- /**
- *
- * When a photo was uploaded into the message using the (profile wall) ajax
- * uploader, The permissions are initially set to disallow anybody but the
- * owner from seeing it. This is because the permissions may not yet have been
- * set for the post. If it's private, the photo permissions should be set
- * appropriately. But we didn't know the final permissions on the post until
- * now. So now we'll look for links of uploaded photos and attachments that are in the
- * post and set them to the same permissions as the post itself.
- *
- * If the post was end-to-end encrypted we can't find images and attachments in the body,
- * use our media_str input instead which only contains these elements - but only do this
- * when encrypted content exists because the photo/attachment may have been removed from
- * the post and we should keep it private. If it's encrypted we have no way of knowing
- * so we'll set the permissions regardless and realise that the media may not be
- * referenced in the post.
- *
- * What is preventing us from being able to upload photos into comments is dealing with
- * the photo and attachment permissions, since we don't always know who was in the
- * distribution for the top level post.
- *
- * We might be able to provide this functionality with a lot of fiddling:
- * - if the top level post is public (make the photo public)
- * - if the top level post was written by us or a wall post that belongs to us (match the top level post)
- * - if the top level post has privacy mentions, add those to the permissions.
- * - otherwise disallow the photo *or* make the photo public. This is the part that gets messy.
- */
-
- if(! $preview) {
- fix_attached_photo_permissions($profile_uid,$owner_xchan['xchan_hash'],((strpos($body,'[/crypt]')) ? $_POST['media_str'] : $body),$str_contact_allow,$str_group_allow,$str_contact_deny,$str_group_deny);
-
- fix_attached_file_permissions($channel,$observer['xchan_hash'],((strpos($body,'[/crypt]')) ? $_POST['media_str'] : $body),$str_contact_allow,$str_group_allow,$str_contact_deny,$str_group_deny);
-
- }
@@ -602,7 +569,7 @@ function item_post(&$a) {
if($results) {
// Set permissions based on tag replacements
- set_linkified_perms($results, $str_contact_allow, $str_group_allow, $profile_uid, $parent_item);
+ set_linkified_perms($results, $str_contact_allow, $str_group_allow, $profile_uid, $parent_item, $private);
$post_tags = array();
foreach($results as $result) {
@@ -619,6 +586,43 @@ function item_post(&$a) {
}
}
+
+ /**
+ *
+ * When a photo was uploaded into the message using the (profile wall) ajax
+ * uploader, The permissions are initially set to disallow anybody but the
+ * owner from seeing it. This is because the permissions may not yet have been
+ * set for the post. If it's private, the photo permissions should be set
+ * appropriately. But we didn't know the final permissions on the post until
+ * now. So now we'll look for links of uploaded photos and attachments that are in the
+ * post and set them to the same permissions as the post itself.
+ *
+ * If the post was end-to-end encrypted we can't find images and attachments in the body,
+ * use our media_str input instead which only contains these elements - but only do this
+ * when encrypted content exists because the photo/attachment may have been removed from
+ * the post and we should keep it private. If it's encrypted we have no way of knowing
+ * so we'll set the permissions regardless and realise that the media may not be
+ * referenced in the post.
+ *
+ * What is preventing us from being able to upload photos into comments is dealing with
+ * the photo and attachment permissions, since we don't always know who was in the
+ * distribution for the top level post.
+ *
+ * We might be able to provide this functionality with a lot of fiddling:
+ * - if the top level post is public (make the photo public)
+ * - if the top level post was written by us or a wall post that belongs to us (match the top level post)
+ * - if the top level post has privacy mentions, add those to the permissions.
+ * - otherwise disallow the photo *or* make the photo public. This is the part that gets messy.
+ */
+
+ if(! $preview) {
+ fix_attached_photo_permissions($profile_uid,$owner_xchan['xchan_hash'],((strpos($body,'[/crypt]')) ? $_POST['media_str'] : $body),$str_contact_allow,$str_group_allow,$str_contact_deny,$str_group_deny);
+
+ fix_attached_file_permissions($channel,$observer['xchan_hash'],((strpos($body,'[/crypt]')) ? $_POST['media_str'] : $body),$str_contact_allow,$str_group_allow,$str_contact_deny,$str_group_deny);
+
+ }
+
+
$attachments = '';
$match = false;
@@ -640,6 +644,7 @@ function item_post(&$a) {
$body = str_replace($match[1],'',$body);
}
}
+
}
// BBCODE end alert
@@ -659,8 +664,19 @@ function item_post(&$a) {
$item_unseen = 1;
- if($post_type === 'wall' || $post_type === 'wall-comment')
- $item_flags = $item_flags | ITEM_WALL;
+
+ // determine if this is a wall post
+
+ if($parent) {
+ if($parent_item['item_flags'] & ITEM_WALL) {
+ $item_flags = $item_flags | ITEM_WALL;
+ }
+ }
+ else {
+ if(! $webpage) {
+ $item_flags = $item_flags | ITEM_WALL;
+ }
+ }
if($origin)
$item_flags = $item_flags | ITEM_ORIGIN;
@@ -950,6 +966,10 @@ function item_content(&$a) {
if(local_channel() && local_channel() == $i[0]['uid'])
$local_delete = true;
+ $sys = get_sys_channel();
+ if(is_site_admin() && $sys['channel_id'] == $i[0]['uid'])
+ $can_delete = true;
+
$ob_hash = get_observer_hash();
if($ob_hash && ($ob_hash === $i[0]['author_xchan'] || $ob_hash === $i[0]['owner_xchan'] || $ob_hash === $i[0]['source_xchan']))
$can_delete = true;
@@ -1080,6 +1100,7 @@ function item_check_service_class($channel_id,$iswebpage) {
$ret = array('success' => false, $message => '');
if ($iswebpage) {
+ // note: we aren't counting comanche templates and blocks, only webpages
$r = q("select count(id) as total from item where parent = id
and ( item_restrict & %d ) > 0 and ( item_restrict & %d ) = 0 and uid = %d ",
intval(ITEM_WEBPAGE),
@@ -1088,7 +1109,8 @@ function item_check_service_class($channel_id,$iswebpage) {
);
}
else {
- $r = q("select count(id) as total from item where parent = id and item_restrict = 0 and uid = %d ",
+ $r = q("select count(id) as total from item where parent = id and item_restrict = 0 and (item_flags & %d) > 0 and uid = %d ",
+ intval(ITEM_WALL),
intval($channel_id)
);
}
@@ -1099,14 +1121,16 @@ function item_check_service_class($channel_id,$iswebpage) {
}
if (!$iswebpage) {
+ $max = service_class_fetch($channel_id,'total_items');
if(! service_class_allows($channel_id,'total_items',$r[0]['total'])) {
- $result['message'] .= upgrade_message() . sprintf( t('You have reached your limit of %1$.0f top level posts.'),$r[0]['total']);
+ $result['message'] .= upgrade_message() . sprintf( t('You have reached your limit of %1$.0f top level posts.'),$max);
return $result;
}
}
else {
+ $max = service_class_fetch($channel_id,'total_pages');
if(! service_class_allows($channel_id,'total_pages',$r[0]['total'])) {
- $result['message'] .= upgrade_message() . sprintf( t('You have reached your limit of %1$.0f webpages.'),$r[0]['total']);
+ $result['message'] .= upgrade_message() . sprintf( t('You have reached your limit of %1$.0f webpages.'),$max);
return $result;
}
}
diff --git a/mod/layouts.php b/mod/layouts.php
index 74a713cf1..689a31c8c 100644
--- a/mod/layouts.php
+++ b/mod/layouts.php
@@ -33,6 +33,8 @@ function layouts_content(&$a) {
$which = argv(1);
+ $_SESSION['return_url'] = $a->query_string;
+
$uid = local_channel();
$owner = 0;
$channel = null;
@@ -86,6 +88,9 @@ function layouts_content(&$a) {
return;
}
+ //This feature is not exposed in redbasic ui since it is not clear why one would want to
+ //download a json encoded pdl file - we dont have a possibility to import it.
+ //Use the buildin share/install feature instead.
if((argc() > 3) && (argv(2) === 'share') && (argv(3))) {
$r = q("select sid, service, mimetype, title, body from item_id
left join item on item.id = item_id.iid
@@ -98,22 +103,9 @@ function layouts_content(&$a) {
header('Content-disposition: attachment; filename="' . $r[0]['sid'] . '.pdl"');
echo json_encode($r);
killme();
-
}
}
- $tabs = array(
- array(
- 'label' => t('Layout Help'),
- 'url' => 'help/Comanche',
- 'sel' => '',
- 'title' => t('Help with this feature'),
- 'id' => 'layout-help-tab',
- ));
-
- $o .= replace_macros(get_markup_template('common_tabs.tpl'),array('$tabs' => $tabs));
-
-
// Create a status editor (for now - we'll need a WYSIWYG eventually) to create pages
// Nickname is set to the observers xchan, and profile_uid to the owners.
// This lets you post pages at other people's channels.
@@ -122,13 +114,15 @@ function layouts_content(&$a) {
'webpage' => ITEM_PDL,
'is_owner' => true,
'nickname' => $a->profile['channel_address'],
- 'lockstate' => (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'),
'bang' => '',
'showacl' => false,
'visitor' => false,
'nopreview' => 1,
'ptlabel' => t('Layout Name'),
'profile_uid' => intval($owner),
+ 'expanded' => true,
+ 'placeholdertitle' => t('Layout Description (Optional)'),
+ 'novoting' => true
);
if($_REQUEST['title'])
@@ -138,12 +132,12 @@ function layouts_content(&$a) {
if($_REQUEST['pagetitle'])
$x['pagetitle'] = $_REQUEST['pagetitle'];
+ $editor = status_editor($a,$x);
- $o .= status_editor($a,$x);
-
- $r = q("select iid, sid, mid from item_id left join item on item.id = item_id.iid
- where item_id.uid = %d and service = 'PDL' order by sid asc",
- intval($owner)
+ $r = q("select iid, sid, mid, title, body, mimetype, created, edited from item_id left join item on item_id.iid = item.id
+ where item_id.uid = %d and service = 'PDL' and item_restrict = %d order by item.created desc",
+ intval($owner),
+ intval(ITEM_PDL)
);
$pages = null;
@@ -151,28 +145,48 @@ function layouts_content(&$a) {
if($r) {
$pages = array();
foreach($r as $rr) {
+ $element_arr = array(
+ 'type' => 'layout',
+ 'title' => $rr['title'],
+ 'body' => $rr['body'],
+ 'created' => $rr['created'],
+ 'edited' => $rr['edited'],
+ 'mimetype' => $rr['mimetype'],
+ 'pagetitle' => $rr['sid'],
+ 'mid' => $rr['mid']
+ );
$pages[$rr['iid']][] = array(
'url' => $rr['iid'],
- 'title' => $rr['sid'],
- 'mid' => $rr['mid']
+ 'title' => $rr['sid'],
+ 'descr' => $rr['title'],
+ 'mid' => $rr['mid'],
+ 'created' => $rr['created'],
+ 'edited' => $rr['edited'],
+ 'bb_element' => '[element]' . base64url_encode(json_encode($element_arr)) . '[/element]'
);
- }
+ }
}
//Build the base URL for edit links
$url = z_root() . '/editlayout/' . $which;
$o .= replace_macros(get_markup_template('layoutlist.tpl'), array(
+ '$title' => t('Layouts'),
+ '$create' => t('Create'),
+ '$help' => array('text' => t('Help'), 'url' => 'help/comanche', 'title' => t('Comanche page description language help')),
+ '$editor' => $editor,
'$baseurl' => $url,
+ '$name' => t('Layout Name'),
+ '$descr' => t('Layout Description'),
+ '$created' => t('Created'),
+ '$edited' => t('Edited'),
'$edit' => t('Edit'),
'$share' => t('Share'),
+ '$download' => t('Download PDL file'),
'$pages' => $pages,
'$channel' => $which,
'$view' => t('View'),
- '$preview' => '1',
-
));
-
- return $o;
+ return $o;
}
diff --git a/mod/like.php b/mod/like.php
index d3b6f3ecf..e79ff5f48 100755
--- a/mod/like.php
+++ b/mod/like.php
@@ -18,7 +18,7 @@ function like_content(&$a) {
if(! $observer) {
$_SESSION['return_url'] = $a->query_string;
$o .= t('This action is restricted to members.') . EOL;
- $o .= t('Please <a href="rmagic">login with your RedMatrix ID</a> or <a href="register">register as a new RedMatrix member</a> to continue.') . EOL;
+ $o .= t('Please <a href="rmagic">login with your $Projectname ID</a> or <a href="register">register as a new $Projectname member</a> to continue.') . EOL;
return $o;
}
}
diff --git a/mod/lockview.php b/mod/lockview.php
index a46fb6d69..84c16f658 100644
--- a/mod/lockview.php
+++ b/mod/lockview.php
@@ -14,10 +14,13 @@ function lockview_content(&$a) {
if(! $item_id)
killme();
- if (!in_array($type, array('item','photo','event')))
+ if (!in_array($type, array('item','photo','event', 'menu_item')))
killme();
- $r = q("SELECT * FROM %s WHERE id = %d LIMIT 1",
+ //we have different naming in in menu_item table
+ $id = (($type == 'menu_item') ? 'mitem_id' : 'id');
+
+ $r = q("SELECT * FROM %s WHERE $id = %d LIMIT 1",
dbesc($type),
intval($item_id)
);
@@ -27,7 +30,10 @@ function lockview_content(&$a) {
$item = $r[0];
- if($item['uid'] != local_channel()) {
+ //we have different naming in in menu_item table
+ $uid = (($type == 'menu_item') ? $item['mitem_channel_id'] : $item['uid']);
+
+ if($uid != local_channel()) {
echo '<li>' . t('Remote privacy information not available.') . '</li>';
killme();
}
diff --git a/mod/magic.php b/mod/magic.php
index df8ac39a8..2fee87241 100644
--- a/mod/magic.php
+++ b/mod/magic.php
@@ -133,7 +133,6 @@ function magic_init(&$a) {
$channel['token'] = $token;
$channel['token_sig'] = $token_sig;
-
$r = q("insert into verify ( type, channel, token, meta, created) values ('%s','%d','%s','%s','%s')",
dbesc('auth'),
intval($channel['channel_id']),
@@ -141,7 +140,6 @@ function magic_init(&$a) {
dbesc($x[0]['hubloc_url']),
dbesc(datetime_convert())
);
-
$target_url = $x[0]['hubloc_callback'] . '/?f=&auth=' . urlencode($channel['channel_address'] . '@' . $a->get_hostname())
. '&sec=' . $token . '&dest=' . urlencode($dest) . '&version=' . ZOT_REVISION;
diff --git a/mod/manage.php b/mod/manage.php
index 54a65dbbf..3712be6f1 100644
--- a/mod/manage.php
+++ b/mod/manage.php
@@ -149,14 +149,16 @@ function manage_content(&$a) {
intval(local_channel()),
intval(PERMS_A_DELEGATE)
);
- if(! $delegates)
- $delegates = null;
if($delegates) {
for($x = 0; $x < count($delegates); $x ++) {
- $delegates[$x]['link'] = 'magic?f=&dest=' . urlencode($delegates[$x]['xchan_url']) . '&delegate=' . urlencode($delegates[$x]['xchan_addr']);
+ $delegates[$x]['link'] = 'magic?f=&dest=' . urlencode($delegates[$x]['xchan_url'])
+ . '&delegate=' . urlencode($delegates[$x]['xchan_addr']);
}
}
+ else {
+ $delegates = null;
+ }
diff --git a/mod/menu.php b/mod/menu.php
index 7e9c580a8..f46dc9471 100644
--- a/mod/menu.php
+++ b/mod/menu.php
@@ -3,11 +3,20 @@
require_once('include/menu.php');
require_once('include/identity.php');
+function menu_init(&$a) {
+ if (array_key_exists('sys', $_REQUEST) && $_REQUEST['sys'] && is_site_admin()) {
+ $sys = get_sys_channel();
+ if ($sys && intval($sys['channel_id'])) {
+ $a->is_sys = true;
+ }
+ }
+}
+
function menu_post(&$a) {
$uid = local_channel();
- if(array_key_exists('sys',$_REQUEST) && $_REQUEST['sys'] && is_site_admin()) {
+ if(array_key_exists('sys', $_REQUEST) && $_REQUEST['sys'] && is_site_admin()) {
$sys = get_sys_channel();
$uid = intval($sys['channel_id']);
$a->is_sys = true;
@@ -17,7 +26,7 @@ function menu_post(&$a) {
return;
$_REQUEST['menu_channel_id'] = $uid;
-
+
if($_REQUEST['menu_bookmark'])
$_REQUEST['menu_flags'] |= MENU_BOOKMARK;
if($_REQUEST['menu_system'])
@@ -28,7 +37,7 @@ function menu_post(&$a) {
$_REQUEST['menu_id'] = intval(argv(1));
$r = menu_edit($_REQUEST);
if($r) {
- info( t('Menu updated.') . EOL);
+ //info( t('Menu updated.') . EOL);
goaway(z_root() . '/mitem/' . $menu_id . (($a->is_sys) ? '?f=&sys=1' : ''));
}
else
@@ -37,14 +46,13 @@ function menu_post(&$a) {
else {
$r = menu_create($_REQUEST);
if($r) {
- info( t('Menu created.') . EOL);
+ //info( t('Menu created.') . EOL);
goaway(z_root() . '/mitem/' . $r . (($a->is_sys) ? '?f=&sys=1' : ''));
}
else
notice( t('Unable to create menu.'). EOL);
}
-
}
@@ -52,7 +60,7 @@ function menu_content(&$a) {
$uid = local_channel();
- if($a->is_sys && is_site_admin()) {
+ if ($a->is_sys && is_site_admin()) {
$sys = get_sys_channel();
$uid = intval($sys['channel_id']);
}
@@ -62,75 +70,85 @@ function menu_content(&$a) {
return '';
}
-
if(argc() == 1) {
+
+
+
// list menus
$x = menu_list($uid);
if($x) {
for($y = 0; $y < count($x); $y ++) {
+ $m = menu_fetch($x[$y]['menu_name'],$uid,get_observer_hash());
+ if($m)
+ $x[$y]['element'] = '[element]' . base64url_encode(json_encode(menu_element($m))) . '[/element]';
$x[$y]['bookmark'] = (($x[$y]['menu_flags'] & MENU_BOOKMARK) ? true : false);
}
}
+ $create = replace_macros(get_markup_template('menuedit.tpl'), array(
+ '$menu_name' => array('menu_name', t('Menu Name'), '', t('Unique name (not visible on webpage) - required'), '*'),
+ '$menu_desc' => array('menu_desc', t('Menu Title'), '', t('Visible on webpage - leave empty for no title'), ''),
+ '$menu_bookmark' => array('menu_bookmark', t('Allow Bookmarks'), 0 , t('Menu may be used to store saved bookmarks'), array(t('No'), t('Yes'))),
+ '$submit' => t('Submit and proceed'),
+ '$sys' => $a->is_sys,
+ '$display' => 'none'
+ ));
+
$o = replace_macros(get_markup_template('menulist.tpl'),array(
- '$title' => t('Manage Menus'),
+ '$title' => t('Menus'),
+ '$create' => $create,
'$menus' => $x,
+ '$nametitle' => t('Menu Name'),
+ '$desctitle' => t('Menu Title'),
'$edit' => t('Edit'),
'$drop' => t('Drop'),
+ '$created' => t('Created'),
+ '$edited' => t('Edited'),
'$new' => t('New'),
'$bmark' => t('Bookmarks allowed'),
- '$hintnew' => t('Create a new menu'),
+ '$hintnew' => t('Create'),
'$hintdrop' => t('Delete this menu'),
'$hintcontent' => t('Edit menu contents'),
- '$hintedit' => t('Edit this menu')
+ '$hintedit' => t('Edit this menu'),
+ '$sys' => $a->is_sys
));
return $o;
}
-
if(argc() > 1) {
- if(argv(1) === 'new') {
- $o = replace_macros(get_markup_template('menuedit.tpl'), array(
- '$header' => t('New Menu'),
- '$menu_name' => array('menu_name', t('Menu name'), '', t('Must be unique, only seen by you'), '*'),
- '$menu_desc' => array('menu_desc', t('Menu title'), '', t('Menu title as seen by others'), ''),
- '$menu_bookmark' => array('menu_bookmark', t('Allow bookmarks'), 0 , t('Menu may be used to store saved bookmarks'), ''),
- '$submit' => t('Create')
- ));
- return $o;
- }
+ if(intval(argv(1))) {
- elseif(intval(argv(1))) {
- $m = menu_fetch_id(intval(argv(1)),$uid);
- if(! $m) {
- notice( t('Menu not found.') . EOL);
- return '';
- }
if(argc() == 3 && argv(2) == 'drop') {
$r = menu_delete_id(intval(argv(1)),$uid);
- if($r)
- info( t('Menu deleted.') . EOL);
- else
+ if(!$r)
notice( t('Menu could not be deleted.'). EOL);
goaway(z_root() . '/menu' . (($a->is_sys) ? '?f=&sys=1' : ''));
}
- else {
- $o = replace_macros(get_markup_template('menuedit.tpl'), array(
- '$header' => t('Edit Menu'),
- '$menu_id' => intval(argv(1)),
- '$hintedit' => t('Add or remove entries to this menu'),
- '$editcontents' => t('Edit menu contents'),
- '$menu_name' => array('menu_name', t('Menu name'), $m['menu_name'], t('Must be unique, only seen by you'), '*'),
- '$menu_desc' => array('menu_desc', t('Menu title'), $m['menu_desc'], t('Menu title as seen by others'), ''),
- '$menu_bookmark' => array('menu_bookmark', t('Allow bookmarks'), (($m['menu_flags'] & MENU_BOOKMARK) ? 1 : 0), t('Menu may be used to store saved bookmarks'), ''),
- '$menu_system' => (($m['menu_flags'] & MENU_SYSTEM) ? 1 : 0),
- '$submit' => t('Modify')
- ));
- return $o;
+
+ $m = menu_fetch_id(intval(argv(1)),$uid);
+
+ if(! $m) {
+ notice( t('Menu not found.') . EOL);
+ return '';
}
+
+ $o = replace_macros(get_markup_template('menuedit.tpl'), array(
+ '$header' => t('Edit Menu'),
+ '$menu_id' => intval(argv(1)),
+ '$hintedit' => t('Add or remove entries to this menu'),
+ '$editcontents' => t('Edit menu contents'),
+ '$menu_name' => array('menu_name', t('Menu name'), $m['menu_name'], t('Must be unique, only seen by you'), '*'),
+ '$menu_desc' => array('menu_desc', t('Menu title'), $m['menu_desc'], t('Menu title as seen by others'), ''),
+ '$menu_bookmark' => array('menu_bookmark', t('Allow bookmarks'), (($m['menu_flags'] & MENU_BOOKMARK) ? 1 : 0), t('Menu may be used to store saved bookmarks'), array(t('No'), t('Yes'))),
+ '$menu_system' => (($m['menu_flags'] & MENU_SYSTEM) ? 1 : 0),
+ '$submit' => t('Submit and proceed')
+ ));
+
+ return $o;
+
}
else {
notice( t('Not found.') . EOL);
diff --git a/mod/mitem.php b/mod/mitem.php
index b561ec7d6..c4c293d1e 100644
--- a/mod/mitem.php
+++ b/mod/mitem.php
@@ -41,14 +41,17 @@ function mitem_post(&$a) {
return;
}
-
-
if(! $a->data['menu'])
return;
$channel = $a->get_channel();
+ if(!$_REQUEST['mitem_desc'] || !$_REQUEST['mitem_link']) {
+ notice( t('Unable to create element.') . EOL);
+ return;
+ }
+
$_REQUEST['mitem_channel_id'] = $uid;
$_REQUEST['menu_id'] = $a->data['menu']['menu_id'];
@@ -64,7 +67,7 @@ function mitem_post(&$a) {
$_REQUEST['mitem_id'] = $mitem_id;
$r = menu_edit_item($_REQUEST['menu_id'],$uid,$_REQUEST);
if($r) {
- info( t('Menu element updated.') . EOL);
+ //info( t('Menu element updated.') . EOL);
goaway(z_root() . '/mitem/' . $_REQUEST['menu_id'] . (($a->is_sys) ? '?f=&sys=1' : ''));
}
else
@@ -74,8 +77,13 @@ function mitem_post(&$a) {
else {
$r = menu_add_item($_REQUEST['menu_id'],$uid,$_REQUEST);
if($r) {
- info( t('Menu element added.') . EOL);
- goaway(z_root() . '/mitem/' . $_REQUEST['menu_id'] . (($a->is_sys) ? '?f=&sys=1' : ''));
+ //info( t('Menu element added.') . EOL);
+ if($_REQUEST['submit']) {
+ goaway(z_root() . '/menu' . (($a->is_sys) ? '?f=&sys=1' : ''));
+ }
+ if($_REQUEST['submit-more']) {
+ goaway(z_root() . '/mitem/' . $_REQUEST['menu_id'] . '?f=&display=block' . (($a->is_sys) ? '&sys=1' : '') );
+ }
}
else
notice( t('Unable to add menu element.') . EOL);
@@ -84,6 +92,7 @@ function mitem_post(&$a) {
+
}
@@ -115,6 +124,21 @@ function mitem_content(&$a) {
$m = menu_fetch($a->data['menu']['menu_name'],$uid,$ob_hash);
$a->data['menu_item'] = $m;
+ $menu_list = menu_list($uid);
+
+ foreach($menu_list as $menus) {
+ if($menus['menu_name'] != $m['menu']['menu_name'])
+ $menu_names[] = $menus['menu_name'];
+ }
+
+ $perm_defaults = array(
+ 'allow_cid' => $channel['channel_allow_cid'],
+ 'allow_gid' => $channel['channel_allow_gid'],
+ 'deny_cid' => $channel['channel_deny_cid'],
+ 'deny_gid' => $channel['channel_deny_gid']
+ );
+
+ $lockstate = (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock');
if(argc() == 2) {
$r = q("select * from menu_item where mitem_menu_id = %d and mitem_channel_id = %d order by mitem_order asc, mitem_desc asc",
@@ -122,61 +146,62 @@ function mitem_content(&$a) {
intval($uid)
);
+ if($_GET['display']) {
+ $display = $_GET['display'];
+ }
+ else {
+ $display = (($r) ? 'none' : 'block');
+ }
+
+ $create = replace_macros(get_markup_template('mitemedit.tpl'), array(
+ '$menu_id' => $a->data['menu']['menu_id'],
+ '$permissions' => t('Menu Item Permissions'),
+ '$permdesc' => t("\x28click to open/close\x29"),
+ '$aclselect' => populate_acl($perm_defaults,false),
+ '$mitem_desc' => array('mitem_desc', t('Link Name'), '', 'Visible name of the link','*'),
+ '$mitem_link' => array('mitem_link', t('Link or Submenu Target'), '', t('Enter URL of the link or select a menu name to create a submenu'), '*', 'list="menu-names"'),
+ '$usezid' => array('usezid', t('Use magic-auth if available'), true, '', array(t('No'), t('Yes'))),
+ '$newwin' => array('newwin', t('Open link in new window'), false,'', array(t('No'), t('Yes'))),
+ '$mitem_order' => array('mitem_order', t('Order in list'),'0',t('Higher numbers will sink to bottom of listing')),
+ '$submit' => t('Submit and finish'),
+ '$submit_more' => t('Submit and continue'),
+ '$display' => $display,
+ '$lockstate' => $lockstate,
+ '$menu_names' => $menu_names
+ ));
$o .= replace_macros(get_markup_template('mitemlist.tpl'),array(
- '$title' => t('Manage Menu Elements'),
- '$menuname' => $a->data['menu']['menu_name'],
- '$menudesc' => $a->data['menu']['menu_desc'],
- '$edmenu' => t('Edit menu'),
- '$menu_id' => $a->data['menu']['menu_id'],
- '$mlist' => $r,
- '$edit' => t('Edit element'),
- '$drop' => t('Drop element'),
- '$new' => t('New element'),
- '$hintmenu' => t('Edit this menu container'),
- '$hintnew' => t('Add menu element'),
- '$hintdrop' => t('Delete this menu item'),
- '$hintedit' => t('Edit this menu item')
+ '$title' => t('Menu:'),
+ '$create' => $create,
+ '$nametitle' => t('Link Name'),
+ '$targettitle' => t('Link Target'),
+ '$menuname' => $a->data['menu']['menu_name'],
+ '$menudesc' => $a->data['menu']['menu_desc'],
+ '$edmenu' => t('Edit menu'),
+ '$menu_id' => $a->data['menu']['menu_id'],
+ '$mlist' => $r,
+ '$edit' => t('Edit element'),
+ '$drop' => t('Drop element'),
+ '$new' => t('New element'),
+ '$hintmenu' => t('Edit this menu container'),
+ '$hintnew' => t('Add menu element'),
+ '$hintdrop' => t('Delete this menu item'),
+ '$hintedit' => t('Edit this menu item'),
));
-
+
return $o;
}
if(argc() > 2) {
- if(argv(2) === 'new') {
-
- $perm_defaults = array(
- 'allow_cid' => $channel['channel_allow_cid'],
- 'allow_gid' => $channel['channel_allow_gid'],
- 'deny_cid' => $channel['channel_deny_cid'],
- 'deny_gid' => $channel['channel_deny_gid']
- );
-
- $o = replace_macros(get_markup_template('mitemedit.tpl'), array(
- '$header' => t('New Menu Element'),
- '$menu_id' => $a->data['menu']['menu_id'],
- '$permissions' => t('Menu Item Permissions'),
- '$permdesc' => t("\x28click to open/close\x29"),
- '$aclselect' => populate_acl($perm_defaults,false),
- '$mitem_desc' => array('mitem_desc', t('Link text'), '', '','*'),
- '$mitem_link' => array('mitem_link', t('URL of link'), '', '', '*'),
- '$usezid' => array('usezid', t('Use RedMatrix magic-auth if available'), true, ''),
- '$newwin' => array('newwin', t('Open link in new window'), false,''),
-// permissions go here
- '$mitem_order' => array('mitem_order', t('Order in list'),'0',t('Higher numbers will sink to bottom of listing')),
- '$submit' => t('Create')
- ));
- return $o;
- }
-
+ if(intval(argv(2))) {
- elseif(intval(argv(2))) {
$m = q("select * from menu_item where mitem_id = %d and mitem_channel_id = %d limit 1",
intval(argv(2)),
intval($uid)
);
+
if(! $m) {
notice( t('Menu item not found.') . EOL);
goaway(z_root() . '/menu'. (($a->is_sys) ? '?f=&sys=1' : ''));
@@ -184,6 +209,8 @@ function mitem_content(&$a) {
$mitem = $m[0];
+ $lockstate = (($mitem['allow_cid'] || $mitem['allow_gid'] || $mitem['deny_cid'] || $mitem['deny_gid']) ? 'lock' : 'unlock');
+
if(argc() == 4 && argv(3) == 'drop') {
$r = menu_del_item($mitem['mitem_menu_id'], $uid, intval(argv(2)));
if($r)
@@ -193,27 +220,26 @@ function mitem_content(&$a) {
goaway(z_root() . '/mitem/' . $mitem['mitem_menu_id'] . (($a->is_sys) ? '?f=&sys=1' : ''));
}
- else {
-
- // edit menu item
-
- $o = replace_macros(get_markup_template('mitemedit.tpl'), array(
- '$header' => t('Edit Menu Element'),
- '$menu_id' => $a->data['menu']['menu_id'],
- '$permissions' => t('Menu Item Permissions'),
- '$permdesc' => t("\x28click to open/close\x29"),
- '$aclselect' => populate_acl($mitem,false),
- '$mitem_id' => intval(argv(2)),
- '$mitem_desc' => array('mitem_desc', t('Link text'), $mitem['mitem_desc'], '','*'),
- '$mitem_link' => array('mitem_link', t('URL of link'), $mitem['mitem_link'], '', '*'),
- '$usezid' => array('usezid', t('Use RedMatrix magic-auth if available'), (($mitem['mitem_flags'] & MENU_ITEM_ZID) ? 1 : 0), ''),
- '$newwin' => array('newwin', t('Open link in new window'), (($mitem['mitem_flags'] & MENU_ITEM_NEWWIN) ? 1 : 0),''),
-// permissions go here
- '$mitem_order' => array('mitem_order', t('Order in list'),$mitem['mitem_order'],t('Higher numbers will sink to bottom of listing')),
- '$submit' => t('Modify')
- ));
- return $o;
- }
+
+ // edit menu item
+ $o = replace_macros(get_markup_template('mitemedit.tpl'), array(
+ '$header' => t('Edit Menu Element'),
+ '$menu_id' => $a->data['menu']['menu_id'],
+ '$permissions' => t('Menu Item Permissions'),
+ '$permdesc' => t("\x28click to open/close\x29"),
+ '$aclselect' => populate_acl($mitem,false),
+ '$mitem_id' => intval(argv(2)),
+ '$mitem_desc' => array('mitem_desc', t('Link text'), $mitem['mitem_desc'], '','*'),
+ '$mitem_link' => array('mitem_link', t('Link or Submenu Target'), $mitem['mitem_link'], 'Enter URL of the link or select a menu name to create a submenu', '*', 'list="menu-names"'),
+ '$usezid' => array('usezid', t('Use magic-auth if available'), (($mitem['mitem_flags'] & MENU_ITEM_ZID) ? 1 : 0), '', array(t('No'), t('Yes'))),
+ '$newwin' => array('newwin', t('Open link in new window'), (($mitem['mitem_flags'] & MENU_ITEM_NEWWIN) ? 1 : 0),'', array(t('No'), t('Yes'))),
+ '$mitem_order' => array('mitem_order', t('Order in list'),$mitem['mitem_order'],t('Higher numbers will sink to bottom of listing')),
+ '$submit' => t('Submit'),
+ '$lockstate' => $lockstate,
+ '$menu_names' => $menu_names
+ ));
+
+ return $o;
}
}
}
diff --git a/mod/network.php b/mod/network.php
index d96c6830d..e8630278a 100644
--- a/mod/network.php
+++ b/mod/network.php
@@ -506,7 +506,6 @@ function network_content(&$a, $update = 0, $load = false) {
$mode = (($nouveau) ? 'network-new' : 'network');
-
$o .= conversation($a,$items,$mode,$update,$page_mode);
if(($items) && (! $update))
diff --git a/mod/p.php b/mod/p.php
index 9d1c12dbc..924fd7eba 100644
--- a/mod/p.php
+++ b/mod/p.php
@@ -43,7 +43,7 @@ function p_init(&$a) {
'$handle' => xmlify($myaddr),
'$public' => 'true',
'$created' => $created,
- '$provider' => (($item['app']) ? $item['app'] : 'redmatrix')
+ '$provider' => (($item['app']) ? $item['app'] : t('$projectname'))
));
header('Content-type: text/xml');
diff --git a/mod/page.php b/mod/page.php
index 05d88aa52..3cb63a2bc 100644
--- a/mod/page.php
+++ b/mod/page.php
@@ -11,10 +11,11 @@ function page_init(&$a) {
$profile = 0;
profile_load($a,$which,$profile);
- if($a->profile['profile_uid'])
- head_set_icon($a->profile['thumb']);
+ if($a->profile['profile_uid'])
+ head_set_icon($a->profile['thumb']);
+
// load the item here in the init function because we need to extract
// the page layout and initialise the correct theme.
@@ -22,9 +23,11 @@ function page_init(&$a) {
$observer = $a->get_observer();
$ob_hash = (($observer) ? $observer['xchan_hash'] : '');
- $perms = get_all_perms($a->profile['profile_uid'],$ob_hash);
- if(! $perms['view_pages']) {
+ // perm_is_allowed is denied unconditionally when 'site blocked to unauthenticated members'.
+ // This bypasses that restriction for sys channel (public) content
+
+ if((! perm_is_allowed($a->profile['profile_uid'],$ob_hash,'view_pages')) && (! is_sys_channel($a->profile['profile_uid']))) {
notice( t('Permission denied.') . EOL);
return;
}
@@ -35,7 +38,11 @@ function page_init(&$a) {
}
$channel_address = argv(1);
- $page_id = argv(2);
+
+ // The page link title was stored in a urlencoded format
+ // php or the browser may/will have decoded it, so re-encode it for our search
+
+ $page_id = urlencode(argv(2));
$u = q("select channel_id from channel where channel_address = '%s' limit 1",
dbesc($channel_address)
@@ -55,13 +62,13 @@ function page_init(&$a) {
$sql_options = item_permissions_sql($u[0]['channel_id']);
$r = q("select item.* from item left join item_id on item.id = item_id.iid
- where item.uid = %d and sid = '%s' and service = 'WEBPAGE' and
- item_restrict = %d $sql_options $revision limit 1",
+ where item.uid = %d and sid = '%s' and (( service = 'WEBPAGE' and
+ item_restrict = %d ) or ( service = 'PDL' and item_restrict = %d )) $sql_options $revision limit 1",
intval($u[0]['channel_id']),
dbesc($page_id),
- intval(ITEM_WEBPAGE)
+ intval(ITEM_WEBPAGE),
+ intval(ITEM_PDL)
);
-
if(! $r) {
// Check again with no permissions clause to see if it is a permissions issue
@@ -73,6 +80,7 @@ function page_init(&$a) {
dbesc($page_id),
intval(ITEM_WEBPAGE)
);
+
if($x) {
// Yes, it's there. You just aren't allowed to see it.
notice( t('Permission denied.') . EOL);
@@ -83,7 +91,12 @@ function page_init(&$a) {
return;
}
- if($r[0]['layout_mid']) {
+ if($r[0]['item_restrict'] == ITEM_PDL) {
+ require_once('include/comanche.php');
+ comanche_parser(get_app(),$r[0]['body']);
+ get_app()->pdl = $r[0]['body'];
+ }
+ elseif($r[0]['layout_mid']) {
$l = q("select body from item where mid = '%s' and uid = %d limit 1",
dbesc($r[0]['layout_mid']),
intval($u[0]['channel_id'])
@@ -98,8 +111,6 @@ function page_init(&$a) {
$a->data['webpage'] = $r;
-
-
}
@@ -111,17 +122,11 @@ function page_content(&$a) {
if(! $r)
return;
- // logger('layout: ' . print_r($a->layout,true));
-
- // Use of widgets should be determined by Comanche, but we don't have it on system pages yet, so...
-
- // I recommend we now get rid of this bit - it's quite a hack to work around... - mike
-
- if ($perms['write_pages']) {
- $chan = $a->channel['channel_id'];
- $who = $channel_address;
- $which = $r[0]['id'];
- $o .= writepages_widget($who,$which);
+ if($r[0]['item_restrict'] == ITEM_PDL) {
+ $r[0]['body'] = t('Lorem Ipsum');
+ $r[0]['mimetype'] = 'text/plain';
+ $r[0]['title'] = '';
+
}
xchan_query($r);
diff --git a/mod/parse_url.php b/mod/parse_url.php
index b6c0559f9..2a6f7663e 100644
--- a/mod/parse_url.php
+++ b/mod/parse_url.php
@@ -325,7 +325,7 @@ function parse_url_content(&$a) {
// If this is a Red site, use zrl rather than url so they get zids sent to them by default
- if( x($siteinfo,'generator') && (strpos($siteinfo['generator'],RED_PLATFORM . ' ') === 0))
+ if( x($siteinfo,'generator') && (strpos($siteinfo['generator'],PLATFORM_NAME . ' ') === 0))
$template = str_replace('url','zrl',$template);
if($siteinfo["title"] == "") {
diff --git a/mod/photos.php b/mod/photos.php
index 503a113dc..296aab67f 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -553,7 +553,7 @@ function photos_content(&$a) {
'$nickname' => $a->data['channel']['channel_address'],
'$newalbum_label' => t('Enter a new album name'),
'$newalbum_placeholder' => t('or select an existing one (doubleclick)'),
- '$visible' => array('visible', t('Create a status post for this upload'),0,''),
+ '$visible' => array('visible', t('Create a status post for this upload'), 0, '', array(t('No'), t('Yes'))),
'$albums' => $albums['albums'],
'$selname' => $selname,
'$permissions' => t('Permissions'),
diff --git a/mod/post.php b/mod/post.php
index 95931a3f0..908b9eb1d 100644
--- a/mod/post.php
+++ b/mod/post.php
@@ -757,8 +757,13 @@ function post_post(&$a) {
$sender_hash = make_xchan_hash($arr['guid'],$arr['guid_sig']);
// garbage collect any old unused notifications
+
+ // This was and should be 10 minutes but my hosting provider has time lag between the DB and
+ // the web server. We should probably convert this to webserver time rather than DB time so
+ // that the different clocks won't affect it and allow us to keep the time short.
+
q("delete from verify where type = 'auth' and created < %s - INTERVAL %s",
- db_utcnow(), db_quoteinterval('10 MINUTE')
+ db_utcnow(), db_quoteinterval('30 MINUTE')
);
$y = q("select xchan_pubkey from xchan where xchan_hash = '%s' limit 1",
diff --git a/mod/probe.php b/mod/probe.php
index 8e0b60dcc..62a2227b0 100644
--- a/mod/probe.php
+++ b/mod/probe.php
@@ -15,6 +15,7 @@ function probe_content(&$a) {
if(x($_GET,'addr')) {
$channel = $a->get_channel();
$addr = trim($_GET['addr']);
+ $do_import = ((intval($_GET['import']) && is_site_admin()) ? true : false);
$res = zot_finger($addr,$channel,false);
$o .= '<pre>';
if($res['success'])
@@ -29,6 +30,8 @@ function probe_content(&$a) {
$o .= sprintf( t('Fetching URL returns error: %1$s'),$res['error'] . "\r\n\r\n");
}
+ if($do_import && $j)
+ $x = import_xchan($j);
if($j && $j['permissions'] && $j['permissions']['iv'])
$j['permissions'] = json_decode(crypto_unencapsulate($j['permissions'],$channel['channel_prvkey']),true);
$o .= str_replace("\n",'<br />',print_r($j,true));
diff --git a/mod/profile_photo.php b/mod/profile_photo.php
index fd5ea2af2..597b5f66d 100644
--- a/mod/profile_photo.php
+++ b/mod/profile_photo.php
@@ -341,7 +341,7 @@ function profile_photo_content(&$a) {
return;
}
- $ph = photo_factory($r[0]['data'], $r[0]['type']);
+ $ph = photo_factory(dbunescbin($r[0]['data']), $r[0]['type']);
// go ahead as if we have just uploaded a new photo to crop
profile_photo_crop_ui_head($a, $ph);
}
diff --git a/mod/public.php b/mod/public.php
new file mode 100644
index 000000000..64ae9d20a
--- /dev/null
+++ b/mod/public.php
@@ -0,0 +1,161 @@
+<?php
+
+require_once('include/conversation.php');
+
+function public_content(&$a, $update = 0, $load = false) {
+
+ if($load)
+ $_SESSION['loadtime'] = datetime_convert();
+
+
+ if(get_config('system','block_public') && (! get_account_id()) && (! remote_channel())) {
+ return login();
+ }
+
+
+ if(get_config('system','disable_discover_tab'))
+ return;
+
+ if(! $update) {
+
+ $maxheight = get_config('system','home_divmore_height');
+ if(! $maxheight)
+ $maxheight = 75;
+
+ $o .= '<div id="live-public"></div>' . "\r\n";
+ $o .= "<script> var profile_uid = " . ((intval(local_channel())) ? local_channel() : (-1))
+ . "; var profile_page = " . $a->pager['page']
+ . "; divmore_height = " . intval($maxheight) . "; </script>\r\n";
+
+ $a->page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),array(
+ '$baseurl' => z_root(),
+ '$pgtype' => 'public',
+ '$uid' => ((local_channel()) ? local_channel() : '0'),
+ '$gid' => '0',
+ '$cid' => '0',
+ '$cmin' => '0',
+ '$cmax' => '99',
+ '$star' => '0',
+ '$liked' => '0',
+ '$conv' => '0',
+ '$spam' => '0',
+ '$fh' => '1',
+ '$nouveau' => '0',
+ '$wall' => '0',
+ '$list' => '0',
+ '$page' => (($a->pager['page'] != 1) ? $a->pager['page'] : 1),
+ '$search' => '',
+ '$order' => 'comment',
+ '$file' => '',
+ '$cats' => '',
+ '$tags' => '',
+ '$dend' => '',
+ '$mid' => '',
+ '$verb' => '',
+ '$dbegin' => ''
+ ));
+ }
+
+ if($update && ! $load) {
+ // only setup pagination on initial page view
+ $pager_sql = '';
+ }
+ else {
+ $a->set_pager_itemspage(20);
+ $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval($a->pager['itemspage']), intval($a->pager['start']));
+ }
+
+ require_once('include/identity.php');
+ require_once('include/security.php');
+
+ if(get_config('system','site_firehose')) {
+ $uids = " and item.uid in ( " . stream_perms_api_uids(PERMS_PUBLIC) . " ) and item_private = 0 and (item_flags & " . intval(ITEM_WALL) . " ) > 0 ";
+ }
+ else {
+ $sys = get_sys_channel();
+ $uids = " and item.uid = " . intval($sys['channel_id']) . " ";
+ $sql_extra = item_permissions_sql($sys['channel_id']);
+ $a->data['firehose'] = intval($sys['channel_id']);
+ }
+
+
+
+ $page_mode = 'list';
+
+ $simple_update = (($update) ? " and item.item_unseen = 1 " : '');
+
+ if($update && $_SESSION['loadtime'])
+ $simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) OR item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) ";
+ if($load)
+ $simple_update = '';
+
+ //logger('update: ' . $update . ' load: ' . $load);
+
+ if($update) {
+
+ $ordering = "commented";
+
+ if($load) {
+
+ // Fetch a page full of parent items for this page
+
+ $r = q("SELECT distinct item.id AS item_id, $ordering FROM item
+ left join abook on item.author_xchan = abook.abook_xchan
+ WHERE true $uids AND item.item_restrict = 0
+ AND item.parent = item.id
+ and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)
+ $sql_extra3 $sql_extra $sql_nets
+ ORDER BY $ordering DESC $pager_sql ",
+ intval(ABOOK_FLAG_BLOCKED)
+ );
+
+
+ }
+ elseif($update) {
+
+ $r = q("SELECT distinct item.id AS item_id, $ordering FROM item
+ left join abook on item.author_xchan = abook.abook_xchan
+ WHERE true $uids AND item.item_restrict = 0
+ AND item.parent = item.id $simple_update
+ and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)
+ $sql_extra3 $sql_extra $sql_nets",
+ intval(ABOOK_FLAG_BLOCKED)
+ );
+ $_SESSION['loadtime'] = datetime_convert();
+ }
+ // Then fetch all the children of the parents that are on this page
+ $parents_str = '';
+ $update_unseen = '';
+
+ if($r) {
+
+ $parents_str = ids_to_querystr($r,'item_id');
+
+ $items = q("SELECT item.*, item.id AS item_id FROM item
+ WHERE true $uids AND item.item_restrict = 0
+ AND item.parent IN ( %s )
+ $sql_extra ",
+ dbesc($parents_str)
+ );
+
+ xchan_query($items,true,(-1));
+ $items = fetch_post_tags($items,true);
+ $items = conv_sort($items,$ordering);
+ }
+ else {
+ $items = array();
+ }
+
+ }
+
+ // fake it
+ $mode = ('network');
+
+ $o .= conversation($a,$items,$mode,$update,$page_mode);
+
+ if(($items) && (! $update))
+ $o .= alt_pager($a,count($items));
+
+ return $o;
+
+} \ No newline at end of file
diff --git a/mod/pubsites.php b/mod/pubsites.php
index ff3854492..62990c70c 100644
--- a/mod/pubsites.php
+++ b/mod/pubsites.php
@@ -16,7 +16,7 @@ function pubsites_content(&$a) {
$o .= '<h1>' . t('Public Sites') . '</h1>';
$o .= '<div class="descriptive-text">' .
- t('The listed sites allow public registration into the Red Matrix. All sites in the matrix are interlinked so membership on any of them conveys membership in the matrix as a whole. Some sites may require subscription or provide tiered service plans. The provider links <strong>may</strong> provide additional details.') . '</div>' . EOL;
+ t('The listed sites allow public registration for the $Projectname network. All sites in the network are interlinked so membership on any of them conveys membership in the network as a whole. Some sites may require subscription or provide tiered service plans. The provider links <strong>may</strong> provide additional details.') . '</div>' . EOL;
$ret = z_fetch_url($url);
if($ret['success']) {
diff --git a/mod/receive.php b/mod/receive.php
index b7d27d40f..deaf8cb37 100644
--- a/mod/receive.php
+++ b/mod/receive.php
@@ -31,7 +31,7 @@ function receive_post(&$a) {
// Diaspora sites *may* provide a truncated guid.
- $r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_guid like '%s' AND NOT (channel_pageflags & %d )>0 LIMIT 1",
+ $r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_guid like '%s' AND (channel_pageflags & %d ) = 0 LIMIT 1",
dbesc($guid . '%'),
intval(PAGE_REMOVED)
);
diff --git a/mod/rpost.php b/mod/rpost.php
index 10ae6b8ab..0c0916646 100644
--- a/mod/rpost.php
+++ b/mod/rpost.php
@@ -94,9 +94,12 @@ function rpost_content(&$a) {
$channel = $a->get_channel();
- $o .= replace_macros(get_markup_template('edpost_head.tpl'), array(
- '$title' => t('Edit post')
- ));
+ $channel_acl = array(
+ 'allow_cid' => $channel['channel_allow_cid'],
+ 'allow_gid' => $channel['channel_allow_gid'],
+ 'deny_cid' => $channel['channel_deny_cid'],
+ 'deny_gid' => $channel['channel_deny_gid']
+ );
if($_REQUEST['url']) {
$x = z_fetch_url(z_root() . '/parse_url?f=&url=' . urlencode($_REQUEST['url']));
@@ -111,18 +114,23 @@ function rpost_content(&$a) {
'nickname' => $channel['channel_address'],
'lockstate' => (($channel['channel_allow_cid'] || $channel['channel_allow_gid']
|| $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'),
- 'acl' => populate_acl($channel),
+ 'acl' => populate_acl($channel_acl),
'bang' => '',
'visitor' => true,
'profile_uid' => local_channel(),
'title' => $_REQUEST['title'],
'body' => $_REQUEST['body'],
+ 'attachment' => $_REQUEST['attachment'],
'source' => ((x($_REQUEST,'source')) ? strip_tags($_REQUEST['source']) : ''),
'return_path' => 'rpost/return'
);
+ $editor = status_editor($a,$x);
- $o .= status_editor($a,$x);
+ $o .= replace_macros(get_markup_template('edpost_head.tpl'), array(
+ '$title' => t('Edit post'),
+ '$editor' => $editor
+ ));
return $o;
diff --git a/mod/search.php b/mod/search.php
index 4d66086f8..426642141 100644
--- a/mod/search.php
+++ b/mod/search.php
@@ -57,12 +57,12 @@ function search_content(&$a,$update = 0, $load = false) {
}
if(strpos($search,'@') === 0) {
$search = substr($search,1);
- goaway(z_root() . '/directory' . '?f=1&search=' . $search);
+ goaway(z_root() . '/directory' . '?f=1&navsearch=1&search=' . $search);
}
// look for a naked webbie
if(strpos($search,'@') !== false) {
- goaway(z_root() . '/directory' . '?f=1&search=' . $search);
+ goaway(z_root() . '/directory' . '?f=1&navsearch=1&search=' . $search);
}
if(! $search)
@@ -153,24 +153,26 @@ function search_content(&$a,$update = 0, $load = false) {
}
if(local_channel()) {
$r = q("SELECT $prefix mid, item.id as item_id, item.* from item
- WHERE item_restrict = 0
+ WHERE item_restrict = 0 AND ( item_flags & %d ) = 0
AND ((( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND item_private = 0 )
OR ( `item`.`uid` = %d )) OR item.owner_xchan = '%s' )
$sql_extra
$suffix $pager_sql ",
+ intval(ITEM_OBSCURED),
intval(local_channel()),
dbesc($sys['xchan_hash'])
);
}
if($r === null) {
$r = q("SELECT $prefix mid, item.id as item_id, item.* from item
- WHERE item_restrict = 0
+ WHERE item_restrict = 0 AND ( item_flags & %d ) = 0
AND (((( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = ''
AND `item`.`deny_gid` = '' AND item_private = 0 )
and owner_xchan in ( " . stream_perms_xchans(($observer) ? (PERMS_NETWORK|PERMS_PUBLIC) : PERMS_PUBLIC) . " ))
$pub_sql ) OR owner_xchan = '%s')
$sql_extra
$suffix $pager_sql",
+ intval(ITEM_OBSCURED),
dbesc($sys['xchan_hash'])
);
}
@@ -201,9 +203,9 @@ function search_content(&$a,$update = 0, $load = false) {
}
if($tag)
- $o .= '<h2>Items tagged with: ' . htmlspecialchars($search, ENT_COMPAT,'UTF-8') . '</h2>';
+ $o .= '<h2>' . sprintf( t('Items tagged with: %s'),htmlspecialchars($search, ENT_COMPAT,'UTF-8')) . '</h2>';
else
- $o .= '<h2>Search results for: ' . htmlspecialchars($search, ENT_COMPAT,'UTF-8') . '</h2>';
+ $o .= '<h2>' . sprintf( t('Search results for: %s'),htmlspecialchars($search, ENT_COMPAT,'UTF-8')) . '</h2>';
$o .= conversation($a,$items,'search',$update,'client');
diff --git a/mod/settings.php b/mod/settings.php
index 56949f9d4..b0ba04dfc 100644
--- a/mod/settings.php
+++ b/mod/settings.php
@@ -95,18 +95,23 @@ function settings_post(&$a) {
dbesc($name),
dbesc($redirect),
dbesc($icon),
- local_channel(),
+ intval(local_channel()),
dbesc($key));
} else {
- $r = q("INSERT INTO clients
- (client_id, pw, name, redirect_uri, icon, uid)
- VALUES ('%s','%s','%s','%s','%s',%d)",
- dbesc($key),
- dbesc($secret),
- dbesc($name),
- dbesc($redirect),
- dbesc($icon),
- local_channel());
+ $r = q("INSERT INTO clients (client_id, pw, name, redirect_uri, icon, uid)
+ VALUES ('%s','%s','%s','%s','%s',%d)",
+ dbesc($key),
+ dbesc($secret),
+ dbesc($name),
+ dbesc($redirect),
+ dbesc($icon),
+ intval(local_channel())
+ );
+ $r = q("INSERT INTO xperm (xp_client, xp_channel, xp_perm) VALUES ('%s', %d, '%s') ",
+ dbesc($key),
+ intval(local_channel()),
+ dbesc('all')
+ );
}
}
goaway($a->get_baseurl(true)."/settings/oauth/");
@@ -119,6 +124,7 @@ function settings_post(&$a) {
call_hooks('feature_settings_post', $_POST);
if($_POST['dspr-submit']) {
+ set_pconfig(local_channel(),'system','diaspora_allowed',intval($_POST['dspr_allowed']));
set_pconfig(local_channel(),'system','diaspora_public_comments',intval($_POST['dspr_pubcomment']));
set_pconfig(local_channel(),'system','prevent_tag_hijacking',intval($_POST['dspr_hijack']));
info( t('Diaspora Policy Settings updated.') . EOL);
@@ -389,7 +395,7 @@ function settings_post(&$a) {
}
$username = ((x($_POST,'username')) ? notags(trim($_POST['username'])) : '');
- $timezone = ((x($_POST,'timezone')) ? notags(trim($_POST['timezone'])) : '');
+ $timezone = ((x($_POST,'timezone_select')) ? notags(trim($_POST['timezone_select'])) : '');
$defloc = ((x($_POST,'defloc')) ? notags(trim($_POST['defloc'])) : '');
$openid = ((x($_POST,'openid_url')) ? notags(trim($_POST['openid_url'])) : '');
$maxreq = ((x($_POST,'maxreq')) ? intval($_POST['maxreq']) : 0);
@@ -662,12 +668,13 @@ function settings_content(&$a) {
$settings_addons = t('No feature settings configured');
if($diaspora_enabled) {
+ $dspr_allowed = get_pconfig(local_channel(),'system','diaspora_allowed');
+ if($dspr_allowed === false)
+ $dspr_allowed = 1;
$pubcomments = get_pconfig(local_channel(),'system','diaspora_public_comments');
if($pubcomments === false)
$pubcomments = 1;
$hijacking = get_pconfig(local_channel(),'system','prevent_tag_hijacking');
-
-
}
call_hooks('feature_settings', $settings_addons);
@@ -679,6 +686,7 @@ function settings_content(&$a) {
'$diaspora_enabled' => $diaspora_enabled,
'$dsprdesc' => t('Settings for the built-in Diaspora emulator'),
'$pubcomments' => array('dspr_pubcomment', t('Allow any Diaspora member to comment on your public posts'), $pubcomments, '', $yes_no),
+ '$dspr_allowed' => array('dspr_allowed', t('Enable the Diaspora protocol for this channel'), $dspr_allowed, '', $yes_no),
'$dsprtitle' => t('Diaspora Policy Settings'),
'$hijacking' => array('dspr_hijack', t('Prevent your hashtags from being redirected to other sites'), $hijacking, '', $yes_no),
'$dsprsubmit' => t('Submit'),
@@ -839,6 +847,9 @@ function settings_content(&$a) {
$tpl = get_markup_template("settings_display.tpl");
$o = replace_macros($tpl, array(
'$ptitle' => t('Display Settings'),
+ '$d_tset' => t('Theme Settings'),
+ '$d_ctset' => t('Custom Theme Settings'),
+ '$d_cset' => t('Content Settings'),
'$form_security_token' => get_form_security_token("settings_display"),
'$submit' => t('Submit'),
'$baseurl' => $a->get_baseurl(true),
diff --git a/mod/setup.php b/mod/setup.php
index b885388be..d88cf73f1 100755
--- a/mod/setup.php
+++ b/mod/setup.php
@@ -1,40 +1,53 @@
<?php
+/**
+ * @file mod/setup.php
+ *
+ * Controller for the initial setup/installation.
+ *
+ * @todo This setup module could need some love and improvements.
+ */
-$install_wizard_pass=1;
-
+$install_wizard_pass = 1;
+/**
+ * @brief Initialisation for the setup module.
+ *
+ * @param[in,out] App &$a
+ */
function setup_init(&$a){
- // Ensure that if somebody hasn't read the install documentation and doesn't have all
- // the required modules or has a totally borked shared hosting provider and they can't
+ // Ensure that if somebody hasn't read the install documentation and doesn't have all
+ // the required modules or has a totally borked shared hosting provider and they can't
// figure out what the hell is going on - that we at least spit out an error message which
// we can inquire about when they write to tell us that our software doesn't work.
- // The worst thing we can do at this point is throw a white screen of death and rely on
- // them knowing about servers and php modules and logfiles enough so that we can guess
+ // The worst thing we can do at this point is throw a white screen of death and rely on
+ // them knowing about servers and php modules and logfiles enough so that we can guess
// at the source of the problem. As ugly as it may be, we need to throw a technically worded
- // PHP error message in their face. Once installation is complete application errors will
- // throw a white screen because these error messages divulge information which can
- // potentially be useful to hackers.
-
-
- error_reporting(E_ERROR | E_WARNING | E_PARSE );
- ini_set('log_errors','0');
- ini_set('display_errors', '1');
+ // PHP error message in their face. Once installation is complete application errors will
+ // throw a white screen because these error messages divulge information which can
+ // potentially be useful to hackers.
+ error_reporting(E_ERROR | E_WARNING | E_PARSE );
+ ini_set('log_errors', '0');
+ ini_set('display_errors', '1');
// $baseurl/setup/testrwrite to test if rewite in .htaccess is working
- if (argc() ==2 && argv(1)=="testrewrite") {
- echo "ok";
+ if (argc() == 2 && argv(1) == "testrewrite") {
+ echo 'ok';
killme();
}
+
global $install_wizard_pass;
- if (x($_POST,'pass'))
+ if (x($_POST, 'pass'))
$install_wizard_pass = intval($_POST['pass']);
-
-
}
+/**
+ * @brief Handle the actions of the different setup steps.
+ *
+ * @param[in,out] App &$a
+ */
function setup_post(&$a) {
global $install_wizard_pass, $db;
@@ -58,8 +71,9 @@ function setup_post(&$a) {
require_once('include/dba/dba_driver.php');
unset($db);
$db = dba_factory($dbhost, $dbport, $dbuser, $dbpass, $dbdata, $dbtype, true);
+
if(! $db->connected) {
- echo "Database Connect failed: " . $db->error;
+ echo 'Database Connect failed: ' . $db->error;
killme();
$a->data['db_conn_failed']=true;
}
@@ -83,10 +97,10 @@ function setup_post(&$a) {
}
}*/
//if(get_db_errno()) {
-
+
//}
- return;
+ return;
break;
case 4:
$urlpath = $a->get_path();
@@ -100,10 +114,9 @@ function setup_post(&$a) {
$timezone = notags(trim($_POST['timezone']));
$adminmail = notags(trim($_POST['adminmail']));
$siteurl = notags(trim($_POST['siteurl']));
-
if($siteurl != z_root()) {
- $test = z_fetch_url($siteurl."/setup/testrewrite");
+ $test = z_fetch_url($siteurl."/setup/testrewrite");
if((! $test['success']) || ($test['body'] != 'ok')) {
$a->data['url_fail'] = true;
$a->data['url_error'] = $test['error'];
@@ -147,7 +160,7 @@ function setup_post(&$a) {
$a->data['db_installed'] = true;
return;
- break;
+ break;
}
}
@@ -156,47 +169,50 @@ function get_db_errno() {
return mysqli_connect_errno();
else
return mysql_errno();
-}
+}
+/**
+ * @brief Get output for the setup page.
+ *
+ * Depending on the state we are currently in it returns different content.
+ *
+ * @param App &$a
+ * @return string parsed HTML output
+ */
function setup_content(&$a) {
-
global $install_wizard_pass, $db;
+
$o = '';
- $wizard_status = "";
- $install_title = t('Red Matrix Server - Setup');
-
+ $wizard_status = '';
+ $install_title = t('$Projectname Server - Setup');
-
- if(x($a->data,'db_conn_failed')) {
+ if(x($a->data, 'db_conn_failed')) {
$install_wizard_pass = 2;
$wizard_status = t('Could not connect to database.');
}
- if(x($a->data,'url_fail')) {
+ if(x($a->data, 'url_fail')) {
$install_wizard_pass = 3;
$wizard_status = t('Could not connect to specified site URL. Possible SSL certificate or DNS issue.');
if($a->data['url_error'])
$wizard_status .= ' ' . $a->data['url_error'];
}
- if(x($a->data,'db_create_failed')) {
+ if(x($a->data, 'db_create_failed')) {
$install_wizard_pass = 2;
$wizard_status = t('Could not create table.');
}
-
- $db_return_text="";
- if(x($a->data,'db_installed')) {
+ $db_return_text = '';
+ if(x($a->data, 'db_installed')) {
$txt = '<p style="font-size: 130%;">';
$txt .= t('Your site database has been installed.') . EOL;
$db_return_text .= $txt;
}
-
- if(x($a->data,'db_failed')) {
+ if(x($a->data, 'db_failed')) {
$txt = t('You may need to import the file "install/schema_xxx.sql" manually using a database client.') . EOL;
$txt .= t('Please see the file "install/INSTALL.txt".') . EOL ."<hr>" ;
$txt .= "<pre>".$a->data['db_failed'] . "</pre>". EOL ;
$db_return_text .= $txt;
}
-
if($db && $db->connected) {
$r = q("SELECT COUNT(*) as `total` FROM `account`");
if($r && count($r) && $r[0]['total']) {
@@ -210,23 +226,22 @@ function setup_content(&$a) {
}
}
- if(x($a->data,'txt') && strlen($a->data['txt'])) {
+ if(x($a->data, 'txt') && strlen($a->data['txt'])) {
$db_return_text .= manual_config($a);
}
-
- if ($db_return_text!="") {
+
+ if ($db_return_text != "") {
$tpl = get_markup_template('install.tpl');
return replace_macros($tpl, array(
'$title' => $install_title,
- '$pass' => "",
+ '$pass' => '',
'$text' => $db_return_text . what_next(),
));
}
-
+
switch ($install_wizard_pass){
case 1: { // System check
-
$checks = array();
check_funcs($checks);
@@ -238,22 +253,23 @@ function setup_content(&$a) {
check_smarty3($checks);
check_keys($checks);
-
- if(x($_POST,'phpath'))
+
+ if (x($_POST, 'phpath'))
$phpath = notags(trim($_POST['phpath']));
check_php($phpath, $checks);
- check_htaccess($checks);
-
- function check_passed($v, $c){
+ check_phpconfig($checks);
+
+ check_htaccess($checks);
+
+ function check_passed($v, $c) {
if ($c['required'])
$v = $v && $c['status'];
+
return $v;
}
$checkspassed = array_reduce($checks, "check_passed", true);
-
-
$tpl = get_markup_template('install_checks.tpl');
$o .= replace_macros($tpl, array(
@@ -269,7 +285,7 @@ function setup_content(&$a) {
));
return $o;
}; break;
-
+
case 2: { // Database config
$dbhost = ((x($_POST,'dbhost')) ? notags(trim($_POST['dbhost'])) : 'localhost');
@@ -281,18 +297,17 @@ function setup_content(&$a) {
$phpath = notags(trim($_POST['phpath']));
$adminmail = notags(trim($_POST['adminmail']));
$siteurl = notags(trim($_POST['siteurl']));
-
$tpl = get_markup_template('install_db.tpl');
$o .= replace_macros($tpl, array(
'$title' => $install_title,
'$pass' => t('Database connection'),
- '$info_01' => t('In order to install Red Matrix we need to know how to connect to your database.'),
+ '$info_01' => t('In order to install $Projectname we need to know how to connect to your database.'),
'$info_02' => t('Please contact your hosting provider or site administrator if you have questions about these settings.'),
'$info_03' => t('The database you specify below should already exist. If it does not, please create it before continuing.'),
'$status' => $wizard_status,
-
+
'$dbhost' => array('dbhost', t('Database Server Name'), $dbhost, t('Default is localhost')),
'$dbport' => array('dbport', t('Database Port'), $dbport, t('Communication port number - use 0 for default')),
'$dbuser' => array('dbuser', t('Database Login Name'), $dbuser, ''),
@@ -302,16 +317,14 @@ function setup_content(&$a) {
'$adminmail' => array('adminmail', t('Site administrator email address'), $adminmail, t('Your account email address must match this in order to use the web admin panel.')),
'$siteurl' => array('siteurl', t('Website URL'), z_root(), t('Please use SSL (https) URL if available.')),
-
'$lbl_10' => t('Please select a default timezone for your website'),
-
+
'$baseurl' => $a->get_baseurl(),
-
+
'$phpath' => $phpath,
-
+
'$submit' => t('Submit'),
-
));
return $o;
}; break;
@@ -324,241 +337,296 @@ function setup_content(&$a) {
$dbdata = notags(trim($_POST['dbdata']));
$dbtype = intval(notags(trim($_POST['dbtype'])));
$phpath = notags(trim($_POST['phpath']));
-
+
$adminmail = notags(trim($_POST['adminmail']));
$siteurl = notags(trim($_POST['siteurl']));
$timezone = ((x($_POST,'timezone')) ? ($_POST['timezone']) : 'America/Los_Angeles');
-
+
$tpl = get_markup_template('install_settings.tpl');
$o .= replace_macros($tpl, array(
'$title' => $install_title,
'$pass' => t('Site settings'),
-
'$status' => $wizard_status,
-
- '$dbhost' => $dbhost,
- '$dbport' => $dbport,
+
+ '$dbhost' => $dbhost,
+ '$dbport' => $dbport,
'$dbuser' => $dbuser,
'$dbpass' => $dbpass,
'$dbdata' => $dbdata,
'$phpath' => $phpath,
'$dbtype' => $dbtype,
-
+
'$adminmail' => array('adminmail', t('Site administrator email address'), $adminmail, t('Your account email address must match this in order to use the web admin panel.')),
'$siteurl' => array('siteurl', t('Website URL'), z_root(), t('Please use SSL (https) URL if available.')),
-
'$timezone' => array('timezone', t('Please select a default timezone for your website'), $timezone, '', get_timezones()),
-
+
'$baseurl' => $a->get_baseurl(),
-
-
-
+
'$submit' => t('Submit'),
-
));
return $o;
}; break;
-
}
}
/**
- * checks : array passed to template
- * title : string
- * status : boolean
- * required : boolean
- * help : string optional
+ * @brief Add a check result to the array for output.
+ *
+ * @param[in,out] array &$checks array passed to template
+ * @param string $title a title for the check
+ * @param boolean $status
+ * @param boolean $required
+ * @param[optional] string $help optional help string
*/
-function check_add(&$checks, $title, $status, $required, $help){
+function check_add(&$checks, $title, $status, $required, $help = '') {
$checks[] = array(
- 'title' => $title,
- 'status' => $status,
+ 'title' => $title,
+ 'status' => $status,
'required' => $required,
- 'help' => $help,
+ 'help' => $help
);
}
+/**
+ * @brief Checks the PHP environment.
+ *
+ * @param[in,out] string &$phpath
+ * @param[out] array &$checks
+ */
function check_php(&$phpath, &$checks) {
- if (strlen($phpath)){
+ $help = '';
+
+ if (strlen($phpath)) {
$passed = file_exists($phpath);
} else {
if(is_windows())
$phpath = trim(shell_exec('where php'));
else
$phpath = trim(shell_exec('which php'));
+
$passed = strlen($phpath);
}
- $help = "";
+
if(!$passed) {
$help .= t('Could not find a command line version of PHP in the web server PATH.'). EOL;
- $help .= t("If you don't have a command line version of PHP installed on server, you will not be able to run background polling via cron.") . EOL;
+ $help .= t('If you don\'t have a command line version of PHP installed on server, you will not be able to run background polling via cron.') . EOL;
$help .= EOL . EOL ;
$tpl = get_markup_template('field_input.tpl');
$help .= replace_macros($tpl, array(
'$field' => array('phpath', t('PHP executable path'), $phpath, t('Enter full path to php executable. You can leave this blank to continue the installation.')),
));
- $phpath="";
+ $phpath = '';
}
-
+
check_add($checks, t('Command line PHP').($passed?" (<tt>$phpath</tt>)":""), $passed, false, $help);
-
+
if($passed) {
$str = autoname(8);
$cmd = "$phpath install/testargs.php $str";
$result = trim(shell_exec($cmd));
$passed2 = $result == $str;
- $help = "";
+ $help = '';
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.');
}
+
check_add($checks, t('PHP register_argc_argv'), $passed, true, $help);
}
-
-
}
-function check_keys(&$checks) {
+/**
+ * @brief Some PHP configuration checks.
+ *
+ * @todo Change how we display such informational text. Add more description
+ * how to change them.
+ *
+ * @param[out] array &$checks
+ */
+function check_phpconfig(&$checks) {
+ require_once 'include/environment.php';
$help = '';
+ $result = getPhpiniUploadLimits();
+ $help = sprintf(t('Your max allowed total upload size is set to %s. Maximum size of one file to upload is set to %s. You are allowed to upload up to %d files at once.'),
+ userReadableSize($result['post_max_size']),
+ userReadableSize($result['max_upload_filesize']),
+ $result['max_file_uploads']
+ );
+ $help .= '<br>' . t('You can adjust these settings in the servers php.ini.');
+
+ check_add($checks, t('PHP upload limits'), true, false, $help);
+}
+
+/**
+ * @brief Check if the openssl implementation can generate keys.
+ *
+ * @param[out] array $checks
+ */
+function check_keys(&$checks) {
+ $help = '';
$res = false;
- if(function_exists('openssl_pkey_new'))
- $res=openssl_pkey_new(array(
- 'digest_alg' => 'sha1',
- 'private_key_bits' => 4096,
- 'encrypt_key' => false ));
+ if (function_exists('openssl_pkey_new')) {
+ $res = openssl_pkey_new(array(
+ 'digest_alg' => 'sha1',
+ 'private_key_bits' => 4096,
+ 'encrypt_key' => false)
+ );
+ }
// Get private key
- if(! $res) {
+ if (! $res) {
$help .= t('Error: the "openssl_pkey_new" function on this system is not able to generate encryption keys'). EOL;
$help .= t('If running under Windows, please see "http://www.php.net/manual/en/openssl.installation.php".');
}
- check_add($checks, t('Generate encryption keys'), $res, true, $help);
+ check_add($checks, t('Generate encryption keys'), $res, true, $help);
}
-
+/**
+ * @brief Check for some PHP functions and modules.
+ *
+ * @param[in,out] array &$checks
+ */
function check_funcs(&$checks) {
$ck_funcs = array();
- check_add($ck_funcs, t('libCurl PHP module'), true, true, "");
- check_add($ck_funcs, t('GD graphics PHP module'), true, true, "");
- check_add($ck_funcs, t('OpenSSL PHP module'), true, true, "");
- check_add($ck_funcs, t('mysqli or postgres PHP module'), true, true, "");
- check_add($ck_funcs, t('mb_string PHP module'), true, true, "");
- check_add($ck_funcs, t('mcrypt PHP module'), true, true, "");
-
-
+
+ // add check metadata, the real check is done bit later and return values set
+ check_add($ck_funcs, t('libCurl PHP module'), true, true);
+ check_add($ck_funcs, t('GD graphics PHP module'), true, true);
+ check_add($ck_funcs, t('OpenSSL PHP module'), true, true);
+ check_add($ck_funcs, t('mysqli or postgres PHP module'), true, true);
+ check_add($ck_funcs, t('mb_string PHP module'), true, true);
+ check_add($ck_funcs, t('mcrypt PHP module'), true, true);
+ check_add($ck_funcs, t('xml PHP module'), true, true);
+
if(function_exists('apache_get_modules')){
- if (! in_array('mod_rewrite',apache_get_modules())) {
+ if (! in_array('mod_rewrite', apache_get_modules())) {
check_add($ck_funcs, t('Apache mod_rewrite module'), false, true, t('Error: Apache webserver mod-rewrite module is required but not installed.'));
} else {
- check_add($ck_funcs, t('Apache mod_rewrite module'), true, true, "");
+ check_add($ck_funcs, t('Apache mod_rewrite module'), true, true);
}
}
if((! function_exists('proc_open')) || strstr(ini_get('disable_functions'),'proc_open')) {
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'));
}
else {
- check_add($ck_funcs, t('proc_open'), true, true, "");
+ check_add($ck_funcs, t('proc_open'), true, true);
}
- if(! function_exists('curl_init')){
- $ck_funcs[0]['status']= false;
- $ck_funcs[0]['help']= t('Error: libCURL PHP module required but not installed.');
+ if(! function_exists('curl_init')) {
+ $ck_funcs[0]['status'] = false;
+ $ck_funcs[0]['help'] = t('Error: libCURL PHP module required but not installed.');
}
- if(! function_exists('imagecreatefromjpeg')){
- $ck_funcs[1]['status']= false;
- $ck_funcs[1]['help']= t('Error: GD graphics PHP module with JPEG support required but not installed.');
+ if(! function_exists('imagecreatefromjpeg')) {
+ $ck_funcs[1]['status'] = false;
+ $ck_funcs[1]['help'] = t('Error: GD graphics PHP module with JPEG support required but not installed.');
}
if(! function_exists('openssl_public_encrypt')) {
- $ck_funcs[2]['status']= false;
- $ck_funcs[2]['help']= t('Error: openssl PHP module required but not installed.');
+ $ck_funcs[2]['status'] = false;
+ $ck_funcs[2]['help'] = t('Error: openssl PHP module required but not installed.');
}
- if(! function_exists('mysqli_connect') && !function_exists('pg_connect')){
- $ck_funcs[3]['status']= false;
- $ck_funcs[3]['help']= t('Error: mysqli or postgres PHP module required but neither are installed.');
+ if(! function_exists('mysqli_connect') && !function_exists('pg_connect')) {
+ $ck_funcs[3]['status'] = false;
+ $ck_funcs[3]['help'] = t('Error: mysqli or postgres PHP module required but neither are installed.');
}
- if(! function_exists('mb_strlen')){
- $ck_funcs[4]['status']= false;
- $ck_funcs[4]['help']= t('Error: mb_string PHP module required but not installed.');
+ if(! function_exists('mb_strlen')) {
+ $ck_funcs[4]['status'] = false;
+ $ck_funcs[4]['help'] = t('Error: mb_string PHP module required but not installed.');
}
- if(! function_exists('mcrypt_encrypt')){
- $ck_funcs[5]['status']= false;
- $ck_funcs[5]['help']= t('Error: mcrypt PHP module required but not installed.');
+ if(! function_exists('mcrypt_encrypt')) {
+ $ck_funcs[5]['status'] = false;
+ $ck_funcs[5]['help'] = t('Error: mcrypt PHP module required but not installed.');
+ }
+ if(! extension_loaded('xml')) {
+ $ck_funcs[6]['status'] = false;
+ $ck_funcs[6]['help'] = t('Error: xml PHP module required for DAV but not installed.');
}
-
- $checks = array_merge($checks, $ck_funcs);
-
+ $checks = array_merge($checks, $ck_funcs);
}
-
+/**
+ * @brief Check for .htconfig requirements.
+ *
+ * @param[out] array &$checks
+ */
function check_htconfig(&$checks) {
$status = true;
- $help = "";
- if( (file_exists('.htconfig.php') && !is_writable('.htconfig.php')) ||
+ $help = '';
+
+ if( (file_exists('.htconfig.php') && !is_writable('.htconfig.php')) ||
(!file_exists('.htconfig.php') && !is_writable('.')) ) {
-
- $status=false;
- $help = t('The web installer needs to be able to create a file called ".htconfig.php" in the top folder of your web server and it is unable to do so.') .EOL;
- $help .= t('This is most often a permission setting, as the web server may not be able to write files in your folder - even if you can.').EOL;
- $help .= t('At the end of this procedure, we will give you a text to save in a file named .htconfig.php in your Red top folder.').EOL;
- $help .= t('You can alternatively skip this procedure and perform a manual installation. Please see the file "install/INSTALL.txt" for instructions.').EOL;
- }
-
- check_add($checks, t('.htconfig.php is writable'), $status, false, $help);
+ $status = false;
+ $help = t('The web installer needs to be able to create a file called ".htconfig.php" in the top folder of your web server and it is unable to do so.') .EOL;
+ $help .= t('This is most often a permission setting, as the web server may not be able to write files in your folder - even if you can.').EOL;
+ $help .= t('At the end of this procedure, we will give you a text to save in a file named .htconfig.php in your Red top folder.').EOL;
+ $help .= t('You can alternatively skip this procedure and perform a manual installation. Please see the file "install/INSTALL.txt" for instructions.').EOL;
+ }
+ check_add($checks, t('.htconfig.php is writable'), $status, false, $help);
}
+/**
+ * @brief Checks for our templating engine Smarty3 requirements.
+ *
+ * @param[out] array &$checks
+ */
function check_smarty3(&$checks) {
$status = true;
- $help = "";
- if( !is_writable(TEMPLATE_BUILD_PATH) ) {
-
- $status=false;
+ $help = '';
+
+ 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 .= 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 .= 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;
}
-
- check_add($checks, sprintf( t('%s is writable'), TEMPLATE_BUILD_PATH), $status, true, $help);
+ check_add($checks, sprintf( t('%s is writable'), TEMPLATE_BUILD_PATH), $status, true, $help);
}
+/**
+ * @brief Check for store directory.
+ *
+ * @param[out] array &$checks
+ */
function check_store(&$checks) {
$status = true;
- $help = "";
+ $help = '';
- @os_mkdir(TEMPLATE_BUILD_PATH,STORAGE_DEFAULT_PERMISSIONS,true);
+ @os_mkdir(TEMPLATE_BUILD_PATH, STORAGE_DEFAULT_PERMISSIONS, true);
- if( !is_writable('store') ) {
-
- $status=false;
+ if(! is_writable('store')) {
+ $status = false;
$help = t('Red 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('Please ensure that the user that your web server runs as (e.g. www-data) has write access to this folder.').EOL;
}
-
- check_add($checks, t('store is writable'), $status, true, $help);
+ check_add($checks, t('store is writable'), $status, true, $help);
}
-
+/**
+ * @brief Check URL rewrite und SSL certificate.
+ *
+ * @param[out] array &$checks
+ */
function check_htaccess(&$checks) {
$a = get_app();
$status = true;
- $help = "";
+ $help = '';
$ssl_error = false;
$url = $a->get_baseurl() . '/setup/testrewrite';
if (function_exists('curl_init')){
- $test = z_fetch_url($url);
+ $test = z_fetch_url($url);
if(! $test['success']) {
if(strstr($url,'https://')) {
$test = z_fetch_url($url,false,0,array('novalidate' => true));
@@ -581,26 +649,27 @@ function check_htaccess(&$checks) {
$help .= t('This can cause usability issues elsewhere (not just on your own site) so we must insist on this requirement.') .EOL;
$help .= t('Providers are available that issue free certificates which are browser-valid.'). EOL;
- check_add($checks, t('SSL certificate validation'),false,true, $help);
+ check_add($checks, t('SSL certificate validation'), false, true, $help);
}
- }
-
- if ((! $test['success']) || ($test['body'] != "ok")) {
- $status = false;
- $help = t('Url rewrite in .htaccess is not working. Check your server configuration.'.'Test: '.var_export($test,true));
- }
- check_add($checks, t('Url rewrite is working'), $status, true, $help);
- } else {
- // cannot check modrewrite if libcurl is not installed
- }
-
+ }
+
+ if ((! $test['success']) || ($test['body'] != "ok")) {
+ $status = false;
+ $help = t('Url rewrite in .htaccess is not working. Check your server configuration.'.'Test: '.var_export($test,true));
+ }
+
+ check_add($checks, t('Url rewrite is working'), $status, true, $help);
+ } else {
+ // cannot check modrewrite if libcurl is not installed
+ }
}
-
+
function manual_config(&$a) {
- $data = htmlspecialchars($a->data['txt'],ENT_COMPAT,'UTF-8');
+ $data = htmlspecialchars($a->data['txt'], ENT_COMPAT, 'UTF-8');
$o = t('The database configuration file ".htconfig.php" could not be written. Please use the enclosed text to create a configuration file in your web server root.');
$o .= "<textarea rows=\"24\" cols=\"80\" >$data</textarea>";
+
return $o;
}
@@ -619,50 +688,47 @@ function load_database($db) {
$arr = explode(';',$str);
$errors = false;
foreach($arr as $a) {
- if(strlen(trim($a))) {
+ if(strlen(trim($a))) {
$r = @$db->q(trim($a));
if(! $r) {
$errors .= t('Errors encountered creating database tables.') . $a . EOL;
}
}
}
+
return $errors;
}
function what_next() {
$a = get_app();
// install the standard theme
- set_config('system','allowed_themes','redbasic');
+ set_config('system', 'allowed_themes', 'redbasic');
// Set a lenient list of ciphers if using openssl. Other ssl engines
- // (e.g. NSS used in RedHat) require different syntax, so hopefully
- // the default curl cipher list will work for most sites. If not,
+ // (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.
// 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
+ // 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
- // to make the content available rather than tell folks that there's a
- // weird SSL error which they can't do anything about.
+ // to make the content available rather than tell folks that there's a
+ // weird SSL error which they can't do anything about.
$x = curl_version();
if(stristr($x['ssl_version'],'openssl'))
set_config('system','curl_ssl_ciphers','ALL:!eNULL');
-
// Create a system channel
require_once ('include/identity.php');
- create_sys_channel();
-
+ create_sys_channel();
$baseurl = $a->get_baseurl();
- return
+ return
t('<h1>What next</h1>')
."<p>".t('IMPORTANT: You will need to [manually] setup a scheduled task for the poller.')
- .t('Please see the file "install/INSTALL.txt".')
+ .t('Please see the file "install/INSTALL.txt".')
."</p><p>"
.t("Go to your new Red node <a href='$baseurl/register'>registration page</a> and register as new user. Remember to use the same email you have entered as administrator email. This will allow you to enter the site admin panel.")
."</p>";
}
-
-
diff --git a/mod/siteinfo.php b/mod/siteinfo.php
index 856909a27..904228f13 100644
--- a/mod/siteinfo.php
+++ b/mod/siteinfo.php
@@ -90,7 +90,7 @@ function siteinfo_init(&$a) {
'default_service_restrictions' => $service_class,
'admin' => $admin,
'site_name' => (($site_name) ? $site_name : ''),
- 'platform' => RED_PLATFORM,
+ 'platform' => PLATFORM_NAME,
'dbdriver' => $db->getdriver(),
'lastpoll' => get_config('system','lastpoll'),
'info' => (($site_info) ? $site_info : ''),
@@ -152,8 +152,8 @@ function siteinfo_content(&$a) {
$donate .= file_get_contents('doc/site_donate.html');
$o = replace_macros(get_markup_template('siteinfo.tpl'), array(
- '$title' => t('Red'),
- '$description' => t('This is a hub of redmatrix - a global cooperative network of decentralized privacy enhanced websites.'),
+ '$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,
@@ -161,10 +161,10 @@ function siteinfo_content(&$a) {
'$lastpoll' => get_poller_runtime(),
'$commit' => $commit,
'$web_location' => t('Running at web location') . ' ' . z_root(),
- '$visit' => t('Please visit <a href="https://redmatrix.me">redmatrix.me</a> to learn more about the Red Matrix.'),
+ '$visit' => t('Please visit <a href="https://redmatrix.me">redmatrix.me</a> to learn more about $Projectname.'),
'$bug_text' => t('Bug reports and issues: please visit'),
'$bug_link_url' => 'https://github.com/redmatrix/redmatrix/issues',
- '$bug_link_text' => 'redmatrix issues',
+ '$bug_link_text' => '$projectname issues',
'$contact' => t('Suggestions, praise, etc. - please email "redmatrix" at librelist - dot com'),
'$donate' => $donate,
'$adminlabel' => t('Site Administrators'),
diff --git a/mod/suggest.php b/mod/suggest.php
index fec0e85a4..438d884ca 100644
--- a/mod/suggest.php
+++ b/mod/suggest.php
@@ -44,6 +44,7 @@ function suggest_content(&$a) {
$arr[] = array(
'url' => chanlink_url($rr['xchan_url']),
+ 'common' => $rr['total'],
'profile' => $rr['xchan_url'],
'name' => $rr['xchan_name'],
'photo' => $rr['xchan_photo_m'],
diff --git a/mod/update_public.php b/mod/update_public.php
new file mode 100644
index 000000000..d0a08e0e6
--- /dev/null
+++ b/mod/update_public.php
@@ -0,0 +1,37 @@
+<?php
+
+// See update_profile.php for documentation
+
+require_once('mod/public.php');
+
+function update_public_content(&$a) {
+
+ $profile_uid = ((intval($_GET['p'])) ? intval($_GET['p']) : (-1));
+ $load = (((argc() > 1) && (argv(1) == 'load')) ? 1 : 0);
+ header("Content-type: text/html");
+ echo "<!DOCTYPE html><html><body>\r\n";
+ echo ((array_key_exists('msie',$_GET) && $_GET['msie'] == 1) ? '<div>' : '<section>');
+
+ $text = public_content($a,$profile_uid, $load);
+ $pattern = "/<img([^>]*) src=\"([^\"]*)\"/";
+ $replace = "<img\${1} dst=\"\${2}\"";
+ $text = preg_replace($pattern, $replace, $text);
+
+ if(! $load) {
+ $replace = '<br />' . t('[Embedded content - reload page to view]') . '<br />';
+ $pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i";
+ $text = preg_replace($pattern, $replace, $text);
+ $pattern = "/<\s*video[^>]*>(.*?)<\s*\/\s*video>/i";
+ $text = preg_replace($pattern, $replace, $text);
+ $pattern = "/<\s*embed[^>]*>(.*?)<\s*\/\s*embed>/i";
+ $text = preg_replace($pattern, $replace, $text);
+ $pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i";
+ $text = preg_replace($pattern, $replace, $text);
+ }
+
+ echo str_replace("\t",' ',$text);
+ echo ((array_key_exists('msie',$_GET) && $_GET['msie'] == 1) ? '</div>' : '</section>');
+ echo "</body></html>\r\n";
+ killme();
+
+} \ No newline at end of file
diff --git a/mod/viewconnections.php b/mod/viewconnections.php
index ee68c2149..ef6681e64 100644
--- a/mod/viewconnections.php
+++ b/mod/viewconnections.php
@@ -28,6 +28,10 @@ function viewconnections_content(&$a) {
return;
}
+ if(! $_REQUEST['aj'])
+ $_SESSION['return_url'] = $a->query_string;
+
+
$is_owner = ((local_channel() && local_channel() == $a->profile['uid']) ? true : false);
$abook_flags = ABOOK_FLAG_PENDING|ABOOK_FLAG_SELF;
@@ -54,7 +58,7 @@ function viewconnections_content(&$a) {
intval($a->pager['start'])
);
- if(! $r) {
+ if((! $r) && (! $_REQUEST['aj'])) {
info( t('No connections.') . EOL );
return $o;
}
@@ -81,13 +85,30 @@ function viewconnections_content(&$a) {
}
- $tpl = get_markup_template("viewcontact_template.tpl");
- $o .= replace_macros($tpl, array(
- '$title' => t('View Connections'),
- '$contacts' => $contacts,
- '$paginate' => paginate($a),
- ));
+ if($_REQUEST['aj']) {
+ if($contacts) {
+ $o = replace_macros(get_markup_template('viewcontactsajax.tpl'),array(
+ '$contacts' => $contacts
+ ));
+ }
+ else {
+ $o = '<div id="content-complete"></div>';
+ }
+ echo $o;
+ killme();
+ }
+ else {
+ $o .= "<script> var page_query = '" . $_GET['q'] . "'; var extra_args = '" . extra_query_args() . "' ; </script>";
+ $tpl = get_markup_template("viewcontact_template.tpl");
+ $o .= replace_macros($tpl, array(
+ '$title' => t('View Connections'),
+ '$contacts' => $contacts,
+// '$paginate' => paginate($a),
+ ));
+ }
+ if(! $contacts)
+ $o .= '<div id="content-complete"></div>';
return $o;
}
diff --git a/mod/viewsrc.php b/mod/viewsrc.php
index 983a0e725..3125ae4c0 100644
--- a/mod/viewsrc.php
+++ b/mod/viewsrc.php
@@ -21,7 +21,7 @@ function viewsrc_content(&$a) {
}
if(local_channel() && $item_id) {
- $r = q("select item_flags, body from item where item_restrict = 0 and uid in (%d , %d) and id = %d limit 1",
+ $r = q("select item_flags, body, id from item where item_restrict = 0 and uid in (%d , %d) and id = %d limit 1",
intval(local_channel()),
intval($sys['channel_id']),
intval($item_id)
@@ -35,6 +35,7 @@ function viewsrc_content(&$a) {
}
if(is_ajax()) {
+ print '<div><i class="icon-pencil"> ' . t('Source of Item') . ' ' . $r[0]['id'] . '</i></div>';
echo $o;
killme();
}
diff --git a/mod/wall_attach.php b/mod/wall_attach.php
index 498389986..4b7103802 100644
--- a/mod/wall_attach.php
+++ b/mod/wall_attach.php
@@ -23,7 +23,8 @@ function wall_attach_post(&$a) {
if($_FILES['userfile']['tmp_name']) {
$x = @getimagesize($_FILES['userfile']['tmp_name']);
- if(($x) && ($x[2] === IMG_GIF || $x[2] === IMG_JPG || $x[2] === IMG_JPEG || $x[2] === IMG_PNG)) {
+ logger('getimagesize: ' . print_r($x,true), LOGGER_DATA);
+ if(($x) && ($x[2] === IMAGETYPE_GIF || $x[2] === IMAGETYPE_JPEG || $x[2] === IMAGETYPE_PNG)) {
$args = array( 'source' => 'editor', 'visible' => 0, 'contact_allow' => array($channel['channel_hash']));
$ret = photo_upload($channel,$observer,$args);
if($ret['success']) {
diff --git a/mod/webfinger.php b/mod/webfinger.php
index 74bd2c954..a646961a8 100644
--- a/mod/webfinger.php
+++ b/mod/webfinger.php
@@ -14,10 +14,15 @@ function webfinger_content(&$a) {
if(x($_GET,'addr')) {
$addr = trim($_GET['addr']);
- if(strpos($addr,'@' !== false))
- $res = webfinger($addr);
- else
- $res = lrdd($addr);
+ if(strpos($addr,'@') !== false) {
+ $res = webfinger_rfc7033($addr);
+ if(! $res)
+ $res = old_webfinger($addr);
+ }
+ else {
+ if(function_exists('lrdd'))
+ $res = lrdd($addr);
+ }
$o .= '<pre>';
$o .= str_replace("\n",'<br />',print_r($res,true));
$o .= '</pre>';
diff --git a/mod/webpages.php b/mod/webpages.php
index 6aff72a5e..362f7bacb 100644
--- a/mod/webpages.php
+++ b/mod/webpages.php
@@ -32,6 +32,8 @@ function webpages_content(&$a) {
}
$which = argv(1);
+
+ $_SESSION['return_url'] = $a->query_string;
$uid = local_channel();
$owner = 0;
@@ -68,26 +70,20 @@ function webpages_content(&$a) {
return;
}
- if(feature_enabled($owner,'expert')) {
- $mimetype = (($_REQUEST['mimetype']) ? $_REQUEST['mimetype'] : get_pconfig($owner,'system','page_mimetype'));
- if(! $mimetype)
- $mimetype = 'choose';
- }
- else {
- $mimetype = 'text/bbcode';
+ $mimetype = (($_REQUEST['mimetype']) ? $_REQUEST['mimetype'] : get_pconfig($owner,'system','page_mimetype'));
+
+ if(! $mimetype) {
+ $mimetype = 'choose';
}
$layout = (($_REQUEST['layout']) ? $_REQUEST['layout'] : get_pconfig($owner,'system','page_layout'));
if(! $layout)
$layout = 'choose';
-
// Create a status editor (for now - we'll need a WYSIWYG eventually) to create pages
// Nickname is set to the observers xchan, and profile_uid to the owner's.
// This lets you post pages at other people's channels.
-
-
if((! $channel) && ($uid) && ($uid == $a->profile_uid)) {
$channel = $a->get_channel();
}
@@ -102,8 +98,8 @@ function webpages_content(&$a) {
else
$channel_acl = array();
-
- $o = profile_tabs($a,true);
+ $is_owner = ($uid && $uid == $owner);
+ $o = profile_tabs($a, $is_owner, $a->profile['channel_address']);
$x = array(
'webpage' => ITEM_WEBPAGE,
@@ -111,11 +107,14 @@ function webpages_content(&$a) {
'nickname' => $a->profile['channel_address'],
'lockstate' => (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'),
'bang' => '',
- 'acl' => (($uid && $uid == $owner) ? populate_acl($channel_acl,false) : ''),
+ 'acl' => (($is_owner) ? populate_acl($channel_acl,false) : ''),
+ 'showacl' => (($is_owner) ? true : false),
'visitor' => true,
'profile_uid' => intval($owner),
'mimetype' => $mimetype,
'layout' => $layout,
+ 'expanded' => true,
+ 'novoting' => true
);
if($_REQUEST['title'])
@@ -125,15 +124,18 @@ function webpages_content(&$a) {
if($_REQUEST['pagetitle'])
$x['pagetitle'] = $_REQUEST['pagetitle'];
- $o .= status_editor($a,$x);
+ $editor = status_editor($a,$x);
// Get a list of webpages. We can't display all them because endless scroll makes that unusable,
// so just list titles and an edit link.
- //TODO - this should be replaced with pagelist_widget
+ /** @TODO - this should be replaced with pagelist_widget */
+
+ $sql_extra = item_permissions_sql($owner);
$r = q("select * from item_id left join item on item_id.iid = item.id
- where item_id.uid = %d and service = 'WEBPAGE' order by item.created desc",
- intval($owner)
+ where item_id.uid = %d and service = 'WEBPAGE' and item_restrict = %d $sql_extra order by item.created desc",
+ intval($owner),
+ intval(ITEM_WEBPAGE)
);
$pages = null;
@@ -142,12 +144,28 @@ function webpages_content(&$a) {
$pages = array();
foreach($r as $rr) {
unobscure($rr);
+
+ $lockstate = (($rr['allow_cid'] || $rr['allow_gid'] || $rr['deny_cid'] || $rr['deny_gid']) ? 'lock' : 'unlock');
+
+ $element_arr = array(
+ 'type' => 'webpage',
+ 'title' => $rr['title'],
+ 'body' => $rr['body'],
+ 'created' => $rr['created'],
+ 'edited' => $rr['edited'],
+ 'mimetype' => $rr['mimetype'],
+ 'pagetitle' => $rr['sid'],
+ 'mid' => $rr['mid'],
+ 'layout_mid' => $rr['layout_mid']
+ );
$pages[$rr['iid']][] = array(
- 'url' => $rr['iid'],
- 'pagetitle' => $rr['sid'],
- 'title' => $rr['title'],
- 'created' => datetime_convert('UTC',date_default_timezone_get(),$rr['created']),
- 'edited' => datetime_convert('UTC',date_default_timezone_get(),$rr['edited'])
+ 'url' => $rr['iid'],
+ 'pagetitle' => $rr['sid'],
+ 'title' => $rr['title'],
+ 'created' => datetime_convert('UTC',date_default_timezone_get(),$rr['created']),
+ 'edited' => datetime_convert('UTC',date_default_timezone_get(),$rr['edited']),
+ 'bb_element' => '[element]' . base64url_encode(json_encode($element_arr)) . '[/element]',
+ 'lockstate' => $lockstate
);
}
}
@@ -157,21 +175,23 @@ function webpages_content(&$a) {
$url = z_root() . '/editwebpage/' . $which;
$o .= replace_macros(get_markup_template('webpagelist.tpl'), array(
- '$listtitle' => t('Webpages'),
+ '$listtitle' => t('Webpages'),
'$baseurl' => $url,
+ '$create' => t('Create'),
'$edit' => t('Edit'),
+ '$share' => t('Share'),
+ '$delete' => t('Delete'),
'$pages' => $pages,
'$channel' => $which,
+ '$editor' => $editor,
'$view' => t('View'),
'$preview' => t('Preview'),
'$actions_txt' => t('Actions'),
'$pagelink_txt' => t('Page Link'),
- '$title_txt' => t('Title'),
+ '$title_txt' => t('Page Title'),
'$created_txt' => t('Created'),
'$edited_txt' => t('Edited')
-
));
return $o;
-
}
diff --git a/mod/wfinger.php b/mod/wfinger.php
index bdec92b54..1493dd6ba 100644
--- a/mod/wfinger.php
+++ b/mod/wfinger.php
@@ -55,17 +55,26 @@ function wfinger_init(&$a) {
if($resource && $r) {
+ $h = q("select hubloc_addr from hubloc where hubloc_hash = '%s'",
+ dbesc($r[0]['channel_hash'])
+ );
+
$result['subject'] = $resource;
$aliases = array(
- 'acct:' . $r[0]['channel_address'] . '@' . $a->get_hostname(),
z_root() . '/channel/' . $r[0]['channel_address'],
z_root() . '/~' . $r[0]['channel_address']
);
+ if($h) {
+ foreach($h as $hh) {
+ $aliases[] = 'acct:' . $hh['hubloc_addr'];
+ }
+ }
+
$result['aliases'] = array();
- $result['properties'] = array('http://webfinger.example/ns/name' => $r[0]['channel_name']);
+ $result['properties'] = array('http://webfinger.net/ns/name' => $r[0]['channel_name']);
foreach($aliases as $alias)
if($alias != $resource)
@@ -75,18 +84,18 @@ function wfinger_init(&$a) {
$result['links'] = array(
array(
- 'rel' => 'http://webfinger.example/rel/avatar',
+ 'rel' => 'http://webfinger.net/rel/avatar',
'type' => $r[0]['xchan_photo_mimetype'],
'href' => $r[0]['xchan_photo_l']
),
array(
- 'rel' => 'http://webfinger.example/rel/profile-page',
+ 'rel' => 'http://webfinger.net/rel/profile-page',
'href' => z_root() . '/profile/' . $r[0]['channel_address'],
),
array(
- 'rel' => 'http://webfinger.example/rel/blog',
+ 'rel' => 'http://webfinger.net/rel/blog',
'href' => z_root() . '/channel/' . $r[0]['channel_address'],
),
diff --git a/mod/zfinger.php b/mod/zfinger.php
index e236a1e73..6b93b3410 100644
--- a/mod/zfinger.php
+++ b/mod/zfinger.php
@@ -280,7 +280,7 @@ function zfinger_init(&$a) {
$ret['site']['channels'] = channel_total();
- $ret['site']['version'] = RED_PLATFORM . ' ' . RED_VERSION . '[' . DB_UPDATE_VERSION . ']';
+ $ret['site']['version'] = PLATFORM_NAME . ' ' . RED_VERSION . '[' . DB_UPDATE_VERSION . ']';
$ret['site']['admin'] = get_config('system','admin_email');