Merge pull request #547 from dawnbreak/docu

[TASK] Update Doxyfile and fix Doxygen errors.
This commit is contained in:
zotlabs 2016-10-14 12:55:01 +11:00 committed by GitHub
commit b9eb74a705
36 changed files with 1868 additions and 1786 deletions

View File

@ -1,21 +1,20 @@
<?php <?php
namespace Zotlabs\Module;
/** /**
* @file mod/admin.php * @file Zotlabs/Module/Admin.php
* @brief Hubzilla's admin controller. * @brief Hubzilla's admin controller.
* *
* Controller for the /admin/ area. * Controller for the /admin/ area.
*/ */
namespace Zotlabs\Module;
require_once('include/queue_fn.php'); require_once('include/queue_fn.php');
require_once('include/account.php'); require_once('include/account.php');
/** /**
* @param App &$a * @brief Admin area.
*
*/ */
class Admin extends \Zotlabs\Web\Controller { class Admin extends \Zotlabs\Web\Controller {
private $sm = null; private $sm = null;
@ -49,7 +48,6 @@ class Admin extends \Zotlabs\Web\Controller {
return login(false); return login(false);
} }
/* /*
* Page content * Page content
*/ */
@ -80,7 +78,6 @@ class Admin extends \Zotlabs\Web\Controller {
/** /**
* @brief Returns content for Admin Summary Page. * @brief Returns content for Admin Summary Page.
* *
* @param App &$a
* @return string HTML from parsed admin_summary.tpl * @return string HTML from parsed admin_summary.tpl
*/ */
function admin_page_summary() { function admin_page_summary() {
@ -135,7 +132,6 @@ class Admin extends \Zotlabs\Web\Controller {
$upgrade = ((version_compare(STD_VERSION,$vmaster) < 0) ? t('Your software should be updated') : ''); $upgrade = ((version_compare(STD_VERSION,$vmaster) < 0) ? t('Your software should be updated') : '');
$t = get_markup_template('admin_summary.tpl'); $t = get_markup_template('admin_summary.tpl');
return replace_macros($t, array( return replace_macros($t, array(
'$title' => t('Administration'), '$title' => t('Administration'),
@ -150,10 +146,8 @@ class Admin extends \Zotlabs\Web\Controller {
'$vmaster' => array( t('Repository version (master)'), $vmaster), '$vmaster' => array( t('Repository version (master)'), $vmaster),
'$vdev' => array( t('Repository version (dev)'), $vdev), '$vdev' => array( t('Repository version (dev)'), $vdev),
'$upgrade' => $upgrade, '$upgrade' => $upgrade,
'$build' => get_config('system', 'db_version') '$build' => get_config('system', 'db_version')
)); ));
} }
} }

View File

@ -2,14 +2,15 @@
namespace Zotlabs\Module\Admin; namespace Zotlabs\Module\Admin;
/**
* @brief Admin Module for Channels.
*
*/
class Channels { class Channels {
/** /**
* @brief Channels admin page. * @brief Handle POST actions on channels admin page.
* *
* @param App &$a
*/ */
function post() { function post() {
@ -19,18 +20,18 @@ class Channels {
$xor = db_getfunc('^'); $xor = db_getfunc('^');
if (x($_POST,'page_channels_block')){ if(x($_POST, 'page_channels_block')) {
foreach($channels as $uid){ foreach($channels as $uid) {
q("UPDATE channel SET channel_pageflags = ( channel_pageflags $xor %d ) where channel_id = %d", q("UPDATE channel SET channel_pageflags = ( channel_pageflags $xor %d ) where channel_id = %d",
intval(PAGE_CENSORED), intval(PAGE_CENSORED),
intval( $uid ) intval( $uid )
); );
\Zotlabs\Daemon\Master::Summon(array('Directory',$uid,'nopush')); \Zotlabs\Daemon\Master::Summon(array('Directory', $uid, 'nopush'));
} }
notice( sprintf( tt("%s channel censored/uncensored", "%s channels censored/uncensored", count($channels)), count($channels)) ); notice( sprintf( tt("%s channel censored/uncensored", "%s channels censored/uncensored", count($channels)), count($channels)) );
} }
if (x($_POST,'page_channels_code')){ if(x($_POST, 'page_channels_code')) {
foreach($channels as $uid){ foreach($channels as $uid) {
q("UPDATE channel SET channel_pageflags = ( channel_pageflags $xor %d ) where channel_id = %d", q("UPDATE channel SET channel_pageflags = ( channel_pageflags $xor %d ) where channel_id = %d",
intval(PAGE_ALLOWCODE), intval(PAGE_ALLOWCODE),
intval( $uid ) intval( $uid )
@ -38,9 +39,9 @@ class Channels {
} }
notice( sprintf( tt("%s channel code allowed/disallowed", "%s channels code allowed/disallowed", count($channels)), count($channels)) ); notice( sprintf( tt("%s channel code allowed/disallowed", "%s channels code allowed/disallowed", count($channels)), count($channels)) );
} }
if (x($_POST,'page_channels_delete')){ if(x($_POST, 'page_channels_delete')) {
foreach($channels as $uid){ foreach($channels as $uid) {
channel_remove($uid,true); channel_remove($uid, true);
} }
notice( sprintf( tt("%s channel deleted", "%s channels deleted", count($channels)), count($channels)) ); notice( sprintf( tt("%s channel deleted", "%s channels deleted", count($channels)), count($channels)) );
} }
@ -48,13 +49,11 @@ class Channels {
goaway(z_root() . '/admin/channels' ); goaway(z_root() . '/admin/channels' );
} }
/** /**
* @brief * @brief Generate channels admin page and handle single item operations.
* *
* @return string * @return string with parsed HTML
*/ */
function get() { function get() {
if(argc() > 2) { if(argc() > 2) {
$uid = argv(3); $uid = argv(3);
@ -105,7 +104,6 @@ class Channels {
goaway(z_root() . '/admin/channels' ); goaway(z_root() . '/admin/channels' );
} }
$key = (($_REQUEST['key']) ? dbesc($_REQUEST['key']) : 'channel_id'); $key = (($_REQUEST['key']) ? dbesc($_REQUEST['key']) : 'channel_id');
$dir = 'asc'; $dir = 'asc';
if(array_key_exists('dir',$_REQUEST)) if(array_key_exists('dir',$_REQUEST))
@ -114,8 +112,6 @@ class Channels {
$base = z_root() . '/admin/channels?f='; $base = z_root() . '/admin/channels?f=';
$odir = (($dir === 'asc') ? '0' : '1'); $odir = (($dir === 'asc') ? '0' : '1');
/* get channels */ /* get channels */
$total = q("SELECT count(*) as total FROM channel where channel_removed = 0 and channel_system = 0"); $total = q("SELECT count(*) as total FROM channel where channel_removed = 0 and channel_system = 0");
@ -143,7 +139,7 @@ class Channels {
} }
} }
$t = get_markup_template("admin_channels.tpl"); $t = get_markup_template('admin_channels.tpl');
$o = replace_macros($t, array( $o = replace_macros($t, array(
// strings // // strings //
'$title' => t('Administration'), '$title' => t('Administration'),
@ -166,7 +162,7 @@ class Channels {
'$confirm_delete_multi' => t('Selected channels will be deleted!\n\nEverything that was posted in these channels on this site will be permanently deleted!\n\nAre you sure?'), '$confirm_delete_multi' => t('Selected channels will be deleted!\n\nEverything that was posted in these channels on this site will be permanently deleted!\n\nAre you sure?'),
'$confirm_delete' => t('The channel {0} will be deleted!\n\nEverything that was posted in this channel on this site will be permanently deleted!\n\nAre you sure?'), '$confirm_delete' => t('The channel {0} will be deleted!\n\nEverything that was posted in this channel on this site will be permanently deleted!\n\nAre you sure?'),
'$form_security_token' => get_form_security_token("admin_channels"), '$form_security_token' => get_form_security_token('admin_channels'),
// values // // values //
'$baseurl' => z_root(), '$baseurl' => z_root(),
@ -177,10 +173,4 @@ class Channels {
return $o; return $o;
} }
} }

View File

@ -5,11 +5,9 @@ namespace Zotlabs\Module\Admin;
class Site { class Site {
/** /**
* @brief POST handler for Admin Site Page. * @brief POST handler for Admin Site Page.
* *
* @param App &$a
*/ */
function post(){ function post(){
if (!x($_POST, 'page_site')) { if (!x($_POST, 'page_site')) {
@ -21,30 +19,30 @@ class Site {
$sitename = ((x($_POST,'sitename')) ? notags(trim($_POST['sitename'])) : ''); $sitename = ((x($_POST,'sitename')) ? notags(trim($_POST['sitename'])) : '');
$server_role = ((x($_POST,'server_role')) ? notags(trim($_POST['server_role'])) : 'standard'); $server_role = ((x($_POST,'server_role')) ? notags(trim($_POST['server_role'])) : 'standard');
$banner = ((x($_POST,'banner')) ? trim($_POST['banner']) : false); $banner = ((x($_POST,'banner')) ? trim($_POST['banner']) : false);
$admininfo = ((x($_POST,'admininfo')) ? trim($_POST['admininfo']) : false); $admininfo = ((x($_POST,'admininfo')) ? trim($_POST['admininfo']) : false);
$language = ((x($_POST,'language')) ? notags(trim($_POST['language'])) : ''); $language = ((x($_POST,'language')) ? notags(trim($_POST['language'])) : '');
$theme = ((x($_POST,'theme')) ? notags(trim($_POST['theme'])) : ''); $theme = ((x($_POST,'theme')) ? notags(trim($_POST['theme'])) : '');
$theme_mobile = ((x($_POST,'theme_mobile')) ? notags(trim($_POST['theme_mobile'])) : ''); $theme_mobile = ((x($_POST,'theme_mobile')) ? notags(trim($_POST['theme_mobile'])) : '');
// $site_channel = ((x($_POST,'site_channel')) ? notags(trim($_POST['site_channel'])) : ''); // $site_channel = ((x($_POST,'site_channel')) ? notags(trim($_POST['site_channel'])) : '');
$maximagesize = ((x($_POST,'maximagesize')) ? intval(trim($_POST['maximagesize'])) : 0); $maximagesize = ((x($_POST,'maximagesize')) ? intval(trim($_POST['maximagesize'])) : 0);
$register_policy = ((x($_POST,'register_policy')) ? intval(trim($_POST['register_policy'])) : 0); $register_policy = ((x($_POST,'register_policy')) ? intval(trim($_POST['register_policy'])) : 0);
$access_policy = ((x($_POST,'access_policy')) ? intval(trim($_POST['access_policy'])) : 0); $access_policy = ((x($_POST,'access_policy')) ? intval(trim($_POST['access_policy'])) : 0);
$invite_only = ((x($_POST,'invite_only')) ? True : False); $invite_only = ((x($_POST,'invite_only')) ? True : False);
$abandon_days = ((x($_POST,'abandon_days')) ? intval(trim($_POST['abandon_days'])) : 0); $abandon_days = ((x($_POST,'abandon_days')) ? intval(trim($_POST['abandon_days'])) : 0);
$register_text = ((x($_POST,'register_text')) ? notags(trim($_POST['register_text'])) : ''); $register_text = ((x($_POST,'register_text')) ? notags(trim($_POST['register_text'])) : '');
$frontpage = ((x($_POST,'frontpage')) ? notags(trim($_POST['frontpage'])) : ''); $frontpage = ((x($_POST,'frontpage')) ? notags(trim($_POST['frontpage'])) : '');
$mirror_frontpage = ((x($_POST,'mirror_frontpage')) ? intval(trim($_POST['mirror_frontpage'])) : 0); $mirror_frontpage = ((x($_POST,'mirror_frontpage')) ? intval(trim($_POST['mirror_frontpage'])) : 0);
$directory_server = ((x($_POST,'directory_server')) ? trim($_POST['directory_server']) : ''); $directory_server = ((x($_POST,'directory_server')) ? trim($_POST['directory_server']) : '');
$allowed_sites = ((x($_POST,'allowed_sites')) ? notags(trim($_POST['allowed_sites'])) : ''); $allowed_sites = ((x($_POST,'allowed_sites')) ? notags(trim($_POST['allowed_sites'])) : '');
$force_publish = ((x($_POST,'publish_all')) ? True : False); $force_publish = ((x($_POST,'publish_all')) ? True : False);
$disable_discover_tab = ((x($_POST,'disable_discover_tab')) ? False : True); $disable_discover_tab = ((x($_POST,'disable_discover_tab')) ? False : True);
$login_on_homepage = ((x($_POST,'login_on_homepage')) ? True : False); $login_on_homepage = ((x($_POST,'login_on_homepage')) ? True : False);
$enable_context_help = ((x($_POST,'enable_context_help')) ? True : False); $enable_context_help = ((x($_POST,'enable_context_help')) ? True : False);
$global_directory = ((x($_POST,'directory_submit_url')) ? notags(trim($_POST['directory_submit_url'])) : ''); $global_directory = ((x($_POST,'directory_submit_url')) ? notags(trim($_POST['directory_submit_url'])) : '');
$no_community_page = !((x($_POST,'no_community_page')) ? True : False); $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); $default_expire_days = ((array_key_exists('default_expire_days',$_POST)) ? intval($_POST['default_expire_days']) : 0);
@ -62,11 +60,9 @@ class Site {
$techlevel_lock = ((x($_POST,'techlock')) ? intval($_POST['techlock']) : 0); $techlevel_lock = ((x($_POST,'techlock')) ? intval($_POST['techlock']) : 0);
$techlevel = null; $techlevel = null;
if(array_key_exists('techlevel',$_POST)) if(array_key_exists('techlevel', $_POST))
$techlevel = intval($_POST['techlevel']); $techlevel = intval($_POST['techlevel']);
set_config('system', 'server_role', $server_role); set_config('system', 'server_role', $server_role);
set_config('system', 'feed_contacts', $feed_contacts); set_config('system', 'feed_contacts', $feed_contacts);
set_config('system', 'delivery_interval', $delivery_interval); set_config('system', 'delivery_interval', $delivery_interval);
@ -139,9 +135,8 @@ class Site {
/** /**
* @brief Admin page site. * @brief Admin page site.
* *
* @return string * @return string with HTML
*/ */
function get() { function get() {
/* Installed langs */ /* Installed langs */
@ -244,7 +239,6 @@ class Site {
'pro' => t('Professional') 'pro' => t('Professional')
]; ];
$techlevels = [ $techlevels = [
'0' => t('Beginner/Basic'), '0' => t('Beginner/Basic'),
'1' => t('Novice - not skilled but willing to learn'), '1' => t('Novice - not skilled but willing to learn'),
@ -254,9 +248,6 @@ class Site {
'5' => t('Wizard - I probably know more than you do') '5' => t('Wizard - I probably know more than you do')
]; ];
$homelogin = get_config('system','login_on_homepage'); $homelogin = get_config('system','login_on_homepage');
$enable_context_help = get_config('system','enable_context_help'); $enable_context_help = get_config('system','enable_context_help');
@ -280,13 +271,12 @@ class Site {
'$techlock' => [ 'techlock', t('Lock the technical skill level setting'), get_config('system','techlevel_lock'), t('Members can set their own technical comfort level by default') ], '$techlock' => [ 'techlock', t('Lock the technical skill level setting'), get_config('system','techlevel_lock'), t('Members can set their own technical comfort level by default') ],
'$banner' => array('banner', t("Banner/Logo"), $banner, ""), '$banner' => array('banner', t("Banner/Logo"), $banner, ""),
'$admininfo' => array('admininfo', t("Administrator Information"), $admininfo, t("Contact information for site administrators. Displayed on siteinfo page. BBCode can be used here")), '$admininfo' => array('admininfo', t("Administrator Information"), $admininfo, t("Contact information for site administrators. Displayed on siteinfo page. BBCode can be used here")),
'$language' => array('language', t("System language"), get_config('system','language'), "", $lang_choices), '$language' => array('language', t("System language"), get_config('system','language'), "", $lang_choices),
'$theme' => array('theme', t("System theme"), get_config('system','theme'), t("Default system theme - may be over-ridden by user profiles - <a href='#' id='cnftheme'>change theme settings</a>"), $theme_choices), '$theme' => array('theme', t("System theme"), get_config('system','theme'), t("Default system theme - may be over-ridden by user profiles - <a href='#' id='cnftheme'>change theme settings</a>"), $theme_choices),
'$theme_mobile' => array('theme_mobile', t("Mobile system theme"), get_config('system','mobile_theme'), t("Theme for mobile devices"), $theme_choices_mobile), '$theme_mobile' => array('theme_mobile', t("Mobile system theme"), get_config('system','mobile_theme'), t("Theme for mobile devices"), $theme_choices_mobile),
// '$site_channel' => array('site_channel', t("Channel to use for this website's static pages"), get_config('system','site_channel'), t("Site Channel")), // '$site_channel' => array('site_channel', t("Channel to use for this website's static pages"), get_config('system','site_channel'), t("Site Channel")),
'$feed_contacts' => array('feed_contacts', t('Allow Feeds as Connections'),get_config('system','feed_contacts'),t('(Heavy system resource usage)')), '$feed_contacts' => array('feed_contacts', t('Allow Feeds as Connections'),get_config('system','feed_contacts'),t('(Heavy system resource usage)')),
'$maximagesize' => array('maximagesize', t("Maximum image size"), intval(get_config('system','maximagesize')), t("Maximum size in bytes of uploaded images. Default is 0, which means no limits.")), '$maximagesize' => array('maximagesize', t("Maximum image size"), intval(get_config('system','maximagesize')), t("Maximum size in bytes of uploaded images. Default is 0, which means no limits.")),
'$register_policy' => array('register_policy', t("Does this site allow new member registration?"), get_config('system','register_policy'), "", $register_choices), '$register_policy' => array('register_policy', t("Does this site allow new member registration?"), get_config('system','register_policy'), "", $register_choices),
@ -317,7 +307,4 @@ class Site {
)); ));
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Zotlabs\Module;
namespace Zotlabs\Module;
require_once('include/contact_widgets.php'); require_once('include/contact_widgets.php');
require_once('include/items.php'); require_once('include/items.php');
@ -10,6 +10,10 @@ require_once('include/conversation.php');
require_once('include/acl_selectors.php'); require_once('include/acl_selectors.php');
require_once('include/permissions.php'); require_once('include/permissions.php');
/**
* @brief Channel Controller
*
*/
class Channel extends \Zotlabs\Web\Controller { class Channel extends \Zotlabs\Web\Controller {
function init() { function init() {
@ -48,12 +52,10 @@ class Channel extends \Zotlabs\Web\Controller {
// we start loading content // we start loading content
profile_load($which,$profile); profile_load($which,$profile);
} }
function get($update = 0, $load = false) { function get($update = 0, $load = false) {
if($load) if($load)
$_SESSION['loadtime'] = datetime_convert(); $_SESSION['loadtime'] = datetime_convert();
@ -143,9 +145,9 @@ class Channel extends \Zotlabs\Web\Controller {
'bbco_autocomplete' => 'bbcode', 'bbco_autocomplete' => 'bbcode',
'bbcode' => true, 'bbcode' => true,
'jotnets' => true 'jotnets' => true
); );
$o .= status_editor($a,$x); $o .= status_editor($a,$x);
} }
} }
@ -201,10 +203,10 @@ class Channel extends \Zotlabs\Web\Controller {
else { else {
if(x($category)) { if(x($category)) {
$sql_extra .= protect_sprintf(term_query('item', $category, TERM_CATEGORY)); $sql_extra .= protect_sprintf(term_query('item', $category, TERM_CATEGORY));
} }
if(x($hashtags)) { if(x($hashtags)) {
$sql_extra .= protect_sprintf(term_query('item', $hashtags, TERM_HASHTAG, TERM_COMMUNITYTAG)); $sql_extra .= protect_sprintf(term_query('item', $hashtags, TERM_HASHTAG, TERM_COMMUNITYTAG));
} }
if($datequery) { if($datequery) {
@ -228,7 +230,6 @@ class Channel extends \Zotlabs\Web\Controller {
if (! $r) { if (! $r) {
notice( t('Permission denied.') . EOL); notice( t('Permission denied.') . EOL);
} }
} }
else { else {
$r = q("SELECT distinct id AS item_id, created FROM item $r = q("SELECT distinct id AS item_id, created FROM item
@ -270,8 +271,7 @@ class Channel extends \Zotlabs\Web\Controller {
notice( t('Permission denied.') . EOL); notice( t('Permission denied.') . EOL);
} }
} } else {
else {
$items = array(); $items = array();
} }
@ -317,7 +317,6 @@ class Channel extends \Zotlabs\Web\Controller {
'$dbegin' => $datequery2 '$dbegin' => $datequery2
)); ));
} }
$update_unseen = ''; $update_unseen = '';

View File

@ -1,7 +1,7 @@
<?php <?php
namespace Zotlabs\Module; namespace Zotlabs\Module;
/** /**
* @file mod/cloud.php * @file Zotlabs/Module/Cloud.php
* @brief Initialize Hubzilla's cloud (SabreDAV). * @brief Initialize Hubzilla's cloud (SabreDAV).
* *
* Module for accessing the DAV storage area. * Module for accessing the DAV storage area.
@ -17,14 +17,15 @@ require_once('include/attach.php');
/** /**
* @brief Fires up the SabreDAV server. * @brief Cloud Module.
* *
* @param App &$a
*/ */
class Cloud extends \Zotlabs\Web\Controller { class Cloud extends \Zotlabs\Web\Controller {
/**
* @brief Fires up the SabreDAV server.
*
*/
function init() { function init() {
if (! is_dir('store')) if (! is_dir('store'))

View File

@ -1,13 +1,13 @@
<?php <?php
namespace Zotlabs\Module;
/** /**
* @file mod/dav.php * @file Zotlabs/Module/Dav.php
* @brief Initialize Hubzilla's cloud (SabreDAV). * @brief Initialize Hubzilla's cloud (SabreDAV).
* *
* Module for accessing the DAV storage area from a DAV client. * Module for accessing the DAV storage area from a DAV client.
*/ */
namespace Zotlabs\Module;
use \Sabre\DAV as SDAV; use \Sabre\DAV as SDAV;
use \Zotlabs\Storage; use \Zotlabs\Storage;
@ -16,14 +16,12 @@ require_once('vendor/autoload.php');
require_once('include/attach.php'); require_once('include/attach.php');
/**
* @brief Fires up the SabreDAV server.
*
* @param App &$a
*/
class Dav extends \Zotlabs\Web\Controller { class Dav extends \Zotlabs\Web\Controller {
/**
* @brief Fires up the SabreDAV server.
*
*/
function init() { function init() {
// workaround for HTTP-auth in CGI mode // workaround for HTTP-auth in CGI mode

View File

@ -1,97 +1,96 @@
<?php <?php
namespace Zotlabs\Module; namespace Zotlabs\Module;
/** /**
* * @brief
* This is the POST destination for the embedphotos button
* *
*/ */
class Embedphotos extends \Zotlabs\Web\Controller { class Embedphotos extends \Zotlabs\Web\Controller {
function get() { function get() {
} }
/**
*
* This is the POST destination for the embedphotos button
*
*/
function post() { function post() {
if (argc() > 1 && argv(1) === 'album') {
if (argc() > 1 && argv(1) === 'album') { // API: /embedphotos/album
// API: /embedphotos/album $name = (x($_POST,'name') ? $_POST['name'] : null );
$name = (x($_POST,'name') ? $_POST['name'] : null ); if(!$name) {
if (!$name) { json_return_and_die(array('errormsg' => 'Error retrieving album', 'status' => false));
json_return_and_die(array('errormsg' => 'Error retrieving album', 'status' => false)); }
} $album = $this->embedphotos_widget_album(array('channel' => \App::get_channel(), 'album' => $name));
$album = $this->embedphotos_widget_album(array('channel' => \App::get_channel(), 'album' => $name)); json_return_and_die(array('status' => true, 'content' => $album));
json_return_and_die(array('status' => true, 'content' => $album)); }
if(argc() > 1 && argv(1) === 'albumlist') {
} // API: /embedphotos/albumlist
if (argc() > 1 && argv(1) === 'albumlist') { $album_list = $this->embedphotos_album_list($a);
// API: /embedphotos/albumlist json_return_and_die(array('status' => true, 'albumlist' => $album_list));
$album_list = $this->embedphotos_album_list($a); }
json_return_and_die(array('status' => true, 'albumlist' => $album_list)); if(argc() > 1 && argv(1) === 'photolink') {
// API: /embedphotos/photolink
} $href = (x($_POST,'href') ? $_POST['href'] : null );
if (argc() > 1 && argv(1) === 'photolink') { if(!$href) {
// API: /embedphotos/photolink json_return_and_die(array('errormsg' => 'Error retrieving link ' . $href, 'status' => false));
$href = (x($_POST,'href') ? $_POST['href'] : null ); }
if (!$href) { $resource_id = array_pop(explode("/", $href));
json_return_and_die(array('errormsg' => 'Error retrieving link ' . $href, 'status' => false)); $r = q("SELECT obj from item where resource_type = 'photo' and resource_id = '%s' limit 1",
} dbesc($resource_id)
$resource_id = array_pop(explode("/", $href)); );
$r = q("SELECT obj from item where resource_type = 'photo' and resource_id = '%s' limit 1", if(!$r) {
dbesc($resource_id) json_return_and_die(array('errormsg' => 'Error retrieving resource ' . $resource_id, 'status' => false));
); }
if(!$r) { $obj = json_decode($r[0]['obj'], true);
json_return_and_die(array('errormsg' => 'Error retrieving resource ' . $resource_id, 'status' => false)); if(x($obj,'body')) {
} $photolink = $obj['body'];
$obj = json_decode($r[0]['obj'], true); } elseif (x($obj,'bbcode')) {
if(x($obj,'body')) { $photolink = $obj['bbcode'];
$photolink = $obj['body']; } else {
} elseif (x($obj,'bbcode')) { json_return_and_die(array('errormsg' => 'Error retrieving resource ' . $resource_id, 'status' => false));
$photolink = $obj['bbcode']; }
} else { json_return_and_die(array('status' => true, 'photolink' => $photolink));
json_return_and_die(array('errormsg' => 'Error retrieving resource ' . $resource_id, 'status' => false)); }
}
json_return_and_die(array('status' => true, 'photolink' => $photolink));
}
} }
/**
* Copied from include/widgets.php::widget_album() with a modification to get the profile_uid from
* the input array as in widget_item()
*
* @param array $args
* @return string with HTML
*/
function embedphotos_widget_album($args) {
/** $channel_id = 0;
* Copied from include/widgets.php::widget_album() with a modification to get the profile_uid from if(array_key_exists('channel', $args))
* the input array as in widget_item() $channel = $args['channel'];
* @param type $name $channel_id = intval($channel['channel_id']);
* @return string if(! $channel_id)
*/ $channel_id = \App::$profile_uid;
function embedphotos_widget_album($args) { if(! $channel_id)
return '';
$channel_id = 0;
if(array_key_exists('channel',$args))
$channel = $args['channel'];
$channel_id = intval($channel['channel_id']);
if(! $channel_id)
$channel_id = \App::$profile_uid;
if(! $channel_id)
return '';
$owner_uid = $channel_id; $owner_uid = $channel_id;
require_once('include/security.php'); require_once('include/security.php');
$sql_extra = permissions_sql($channel_id); $sql_extra = permissions_sql($channel_id);
if(! perm_is_allowed($channel_id,get_observer_hash(),'view_storage')) if(! perm_is_allowed($channel_id,get_observer_hash(),'view_storage'))
return ''; return '';
if($args['album']) if($args['album'])
$album = $args['album']; $album = $args['album'];
if($args['title']) if($args['title'])
$title = $args['title']; $title = $args['title'];
/** /**
* This may return incorrect permissions if you have multiple directories of the same name. * This may return incorrect permissions if you have multiple directories of the same name.
* It is a limitation of the photo table using a name for a photo album instead of a folder hash * It is a limitation of the photo table using a name for a photo album instead of a folder hash
*/ */
if($album) { if($album) {
$x = q("select hash from attach where filename = '%s' and uid = %d limit 1", $x = q("select hash from attach where filename = '%s' and uid = %d limit 1",
dbesc($album), dbesc($album),
@ -109,32 +108,31 @@ function embedphotos_widget_album($args) {
$r = q("SELECT p.resource_id, p.id, p.filename, p.mimetype, p.imgscale, p.description, p.created FROM photo p INNER JOIN $r = q("SELECT p.resource_id, p.id, p.filename, p.mimetype, p.imgscale, p.description, p.created FROM photo p INNER JOIN
(SELECT resource_id, max(imgscale) imgscale FROM photo WHERE uid = %d AND album = '%s' AND imgscale <= 4 AND photo_usage IN ( %d, %d ) $sql_extra GROUP BY resource_id) ph (SELECT resource_id, max(imgscale) imgscale FROM photo WHERE uid = %d AND album = '%s' AND imgscale <= 4 AND photo_usage IN ( %d, %d ) $sql_extra GROUP BY resource_id) ph
ON (p.resource_id = ph.resource_id AND p.imgscale = ph.imgscale) ON (p.resource_id = ph.resource_id AND p.imgscale = ph.imgscale)
ORDER BY created $order", ORDER BY created $order",
intval($owner_uid), intval($owner_uid),
dbesc($album), dbesc($album),
intval(PHOTO_NORMAL), intval(PHOTO_NORMAL),
intval(PHOTO_PROFILE) intval(PHOTO_PROFILE)
); );
$photos = array(); $photos = array();
if(count($r)) { if(count($r)) {
$twist = 'rotright'; $twist = 'rotright';
foreach($r as $rr) { foreach($r as $rr) {
if($twist == 'rotright')
$twist = 'rotleft';
else
$twist = 'rotright';
if($twist == 'rotright') $ext = $phototypes[$rr['mimetype']];
$twist = 'rotleft';
else
$twist = 'rotright';
$ext = $phototypes[$rr['mimetype']]; $imgalt_e = $rr['filename'];
$desc_e = $rr['description'];
$imgalt_e = $rr['filename']; $imagelink = (z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/image/' . $rr['resource_id']
$desc_e = $rr['description'];
$imagelink = (z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/image/' . $rr['resource_id']
. (($_GET['order'] === 'posted') ? '?f=&order=posted' : '')); . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''));
$photos[] = array( $photos[] = array(
'id' => $rr['id'], 'id' => $rr['id'],
'twist' => ' ' . $twist . rand(2,4), 'twist' => ' ' . $twist . rand(2,4),
'link' => $imagelink, 'link' => $imagelink,
@ -146,8 +144,8 @@ function embedphotos_widget_album($args) {
'hash'=> $rr['resource_id'], 'hash'=> $rr['resource_id'],
'unknown' => t('Unknown') 'unknown' => t('Unknown')
); );
}
} }
}
$tpl = get_markup_template('photo_album.tpl'); $tpl = get_markup_template('photo_album.tpl');
$o .= replace_macros($tpl, array( $o .= replace_macros($tpl, array(
@ -163,18 +161,16 @@ function embedphotos_widget_album($args) {
)); ));
return $o; return $o;
} }
function embedphotos_album_list($a) {
function embedphotos_album_list($a) { require_once('include/photos.php');
$o = ''; $p = photos_albums_list(\App::get_channel(), \App::get_observer());
require_once('include/photos.php'); if($p['success']) {
$p = photos_albums_list(\App::get_channel(), \App::get_observer()); return $p['albums'];
if ($p['success']) { } else {
return $p['albums']; return null;
} else { }
return null; }
}
}
} }

View File

@ -1,7 +1,7 @@
<?php <?php
namespace Zotlabs\Module; namespace Zotlabs\Module;
/** /**
* @file mod/filestorage.php * @file Zotlabs/Module/Filestorage.php
* *
*/ */

View File

@ -1,27 +1,23 @@
<?php <?php
namespace Zotlabs\Module; namespace Zotlabs\Module;
require_once('include/help.php'); require_once('include/help.php');
/** /**
* You can create local site resources in doc/Site.md and either link to doc/Home.md for the standard resources * You can create local site resources in doc/Site.md and either link to doc/Home.md for the standard resources
* or use our include mechanism to include it on your local page. * or use our include mechanism to include it on your local page.
* *@code
* #include doc/Home.md; * #include doc/Home.md;
*@endcode
* *
* The syntax is somewhat strict. * The syntax is somewhat strict.
*
*/ */
class Help extends \Zotlabs\Web\Controller { class Help extends \Zotlabs\Web\Controller {
function get() { function get() {
nav_set_selected('help'); nav_set_selected('help');
if($_REQUEST['search']) { if($_REQUEST['search']) {
$o .= '<div id="help-content" class="generic-content-wrapper">'; $o .= '<div id="help-content" class="generic-content-wrapper">';
$o .= '<div class="section-title-wrapper">'; $o .= '<div class="section-title-wrapper">';
$o .= '<h2>' . t('Documentation Search') . ' - ' . htmlspecialchars($_REQUEST['search']) . '</h2>'; $o .= '<h2>' . t('Documentation Search') . ' - ' . htmlspecialchars($_REQUEST['search']) . '</h2>';
@ -34,33 +30,27 @@ class Help extends \Zotlabs\Web\Controller {
foreach($r as $rr) { foreach($r as $rr) {
$dirname = dirname($rr['v']); $dirname = dirname($rr['v']);
$fname = basename($rr['v']); $fname = basename($rr['v']);
$fname = substr($fname,0,strrpos($fname,'.')); $fname = substr($fname, 0, strrpos($fname, '.'));
$path = trim(substr($dirname,4),'/'); $path = trim(substr($dirname, 4), '/');
$o .= '<li><a href="help/' . (($path) ? $path . '/' : '') . $fname . '" >' . ucwords(str_replace('_',' ',notags($fname))) . '</a><br />'
. '<b><i>' . 'help/' . (($path) ? $path . '/' : '') . $fname . '</i></b><br />' .
'...' . str_replace('$Projectname',\Zotlabs\Lib\System::get_platform_name(),$rr['text']) . '...<br /><br /></li>';
$o .= '<li><a href="help/' . (($path) ? $path . '/' : '') . $fname . '" >' . ucwords(str_replace('_',' ',notags($fname))) . '</a><br>'
. '<b><i>' . 'help/' . (($path) ? $path . '/' : '') . $fname . '</i></b><br>'
. '...' . str_replace('$Projectname', \Zotlabs\Lib\System::get_platform_name(), $rr['text']) . '...<br><br></li>';
} }
$o .= '</ul>'; $o .= '</ul>';
$o .= '</div>'; $o .= '</div>';
$o .= '</div>'; $o .= '</div>';
} }
return $o; return $o;
} }
$content = get_help_content(); $content = get_help_content();
return replace_macros(get_markup_template('help.tpl'), array(
return replace_macros(get_markup_template("help.tpl"), array(
'$title' => t('$Projectname Documentation'), '$title' => t('$Projectname Documentation'),
'$content' => $content '$content' => $content
)); ));
} }
} }

View File

@ -1,29 +1,24 @@
<?php <?php
namespace Zotlabs\Module;
/** namespace Zotlabs\Module;
* @file mod/ping.php
*
*/
require_once('include/bbcode.php'); require_once('include/bbcode.php');
/** /**
* @brief do several updates when pinged. * @brief Ping Controller.
* *
* This function does several tasks. Whenever called it checks for new messages,
* introductions, notifications, etc. and returns a json with the results.
*
* @param App &$a
* @result JSON
*/ */
class Ping extends \Zotlabs\Web\Controller { class Ping extends \Zotlabs\Web\Controller {
/**
* @brief do several updates when pinged.
*
* This function does several tasks. Whenever called it checks for new messages,
* introductions, notifications, etc. and returns a json with the results.
*
* @result JSON
*/
function init() { function init() {
$result = array(); $result = array();
$notifs = array(); $notifs = array();
@ -50,7 +45,7 @@ class Ping extends \Zotlabs\Web\Controller {
$item_normal = item_normal(); $item_normal = item_normal();
if(local_channel()) { if(local_channel()) {
$vnotify = get_pconfig(local_channel(),'system','vnotify'); $vnotify = get_pconfig(local_channel(),'system','vnotify');
$evdays = intval(get_pconfig(local_channel(),'system','evdays')); $evdays = intval(get_pconfig(local_channel(),'system','evdays'));
$ob_hash = get_observer_hash(); $ob_hash = get_observer_hash();
@ -97,7 +92,6 @@ class Ping extends \Zotlabs\Web\Controller {
if(! ($vnotify & VNOTIFY_ALERT)) if(! ($vnotify & VNOTIFY_ALERT))
$result['notice'] = array(); $result['notice'] = array();
if(\App::$install) { if(\App::$install) {
echo json_encode($result); echo json_encode($result);
killme(); killme();
@ -149,7 +143,6 @@ class Ping extends \Zotlabs\Web\Controller {
* Everything following is only permitted under the context of a locally authenticated site member. * Everything following is only permitted under the context of a locally authenticated site member.
*/ */
/** /**
* Handle "mark all xyz notifications read" requests. * Handle "mark all xyz notifications read" requests.
*/ */
@ -196,13 +189,10 @@ class Ping extends \Zotlabs\Web\Controller {
); );
} }
/** /**
* URL ping/something will return detail for "something", e.g. a json list with which to populate a notification * URL ping/something will return detail for "something", e.g. a json list with which to populate a notification
* dropdown menu. * dropdown menu.
*/ */
if(argc() > 1 && argv(1) === 'notify') { if(argc() > 1 && argv(1) === 'notify') {
$t = q("select count(*) as total from notify where uid = %d and seen = 0", $t = q("select count(*) as total from notify where uid = %d and seen = 0",
intval(local_channel()) intval(local_channel())
@ -212,8 +202,7 @@ class Ping extends \Zotlabs\Web\Controller {
and seen = 0 order by created desc limit 50", and seen = 0 order by created desc limit 50",
intval(local_channel()) intval(local_channel())
); );
} } else {
else {
$z1 = q("select * from notify where uid = %d $z1 = q("select * from notify where uid = %d
and seen = 0 order by created desc limit 50", and seen = 0 order by created desc limit 50",
intval(local_channel()) intval(local_channel())
@ -289,7 +278,7 @@ class Ping extends \Zotlabs\Web\Controller {
$result[] = \Zotlabs\Lib\Enotify::format($item); $result[] = \Zotlabs\Lib\Enotify::format($item);
} }
} }
// logger('ping (network||home): ' . print_r($result, true), LOGGER_DATA); // logger('ping (network||home): ' . print_r($result, true), LOGGER_DATA);
echo json_encode(array('notify' => $result)); echo json_encode(array('notify' => $result));
killme(); killme();
} }
@ -342,11 +331,10 @@ class Ping extends \Zotlabs\Web\Controller {
$strt = datetime_convert('UTC', (($rr['adjust']) ? date_default_timezone_get() : 'UTC'), $rr['dtstart']); $strt = datetime_convert('UTC', (($rr['adjust']) ? date_default_timezone_get() : 'UTC'), $rr['dtstart']);
$today = ((substr($strt, 0, 10) === datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y-m-d')) ? true : false); $today = ((substr($strt, 0, 10) === datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y-m-d')) ? true : false);
$when = day_translate(datetime_convert('UTC', (($rr['adjust']) ? date_default_timezone_get() : 'UTC'), $rr['dtstart'], $bd_format)) . (($today) ? ' ' . t('[today]') : ''); $when = day_translate(datetime_convert('UTC', (($rr['adjust']) ? date_default_timezone_get() : 'UTC'), $rr['dtstart'], $bd_format)) . (($today) ? ' ' . t('[today]') : '');
$result[] = array( $result[] = array(
'notify_link' => z_root() . '/events', // FIXME this takes you to an edit page and it may not be yours, we really want to just view the single event --> '/events/event/' . $rr['event_hash'], 'notify_link' => z_root() . '/events', /// @FIXME this takes you to an edit page and it may not be yours, we really want to just view the single event --> '/events/event/' . $rr['event_hash'],
'name' => $rr['xchan_name'], 'name' => $rr['xchan_name'],
'url' => $rr['xchan_url'], 'url' => $rr['xchan_url'],
'photo' => $rr['xchan_photo_s'], 'photo' => $rr['xchan_photo_s'],
@ -361,12 +349,9 @@ class Ping extends \Zotlabs\Web\Controller {
killme(); killme();
} }
/** /**
* Normal ping - just the counts, no detail * Normal ping - just the counts, no detail
*/ */
if($vnotify & VNOTIFY_SYSTEM) { if($vnotify & VNOTIFY_SYSTEM) {
$t = q("select count(*) as total from notify where uid = %d and seen = 0", $t = q("select count(*) as total from notify where uid = %d and seen = 0",
intval(local_channel()) intval(local_channel())
@ -403,7 +388,6 @@ class Ping extends \Zotlabs\Web\Controller {
if(! ($vnotify & VNOTIFY_CHANNEL)) if(! ($vnotify & VNOTIFY_CHANNEL))
$result['home'] = 0; $result['home'] = 0;
$t2 = dba_timer(); $t2 = dba_timer();
if($vnotify & VNOTIFY_INTRO) { if($vnotify & VNOTIFY_INTRO) {
@ -484,12 +468,11 @@ class Ping extends \Zotlabs\Web\Controller {
if(! ($vnotify & VNOTIFY_BIRTHDAY)) if(! ($vnotify & VNOTIFY_BIRTHDAY))
$result['birthdays'] = 0; $result['birthdays'] = 0;
$x = json_encode($result); $x = json_encode($result);
$t6 = dba_timer(); $t6 = dba_timer();
// logger('ping timer: ' . sprintf('%01.4f %01.4f %01.4f %01.4f %01.4f %01.4f',$t6 - $t5, $t5 - $t4, $t4 - $t3, $t3 - $t2, $t2 - $t1, $t1 - $t0)); // logger('ping timer: ' . sprintf('%01.4f %01.4f %01.4f %01.4f %01.4f %01.4f',$t6 - $t5, $t5 - $t4, $t4 - $t3, $t3 - $t2, $t2 - $t1, $t1 - $t0));
echo $x; echo $x;
killme(); killme();

View File

@ -1,36 +1,34 @@
<?php <?php
namespace Zotlabs\Module;
/** /**
* @file mod/post.php * @file Zotlabs/Module/Post.php
* *
* @brief Zot endpoint. * @brief Zot endpoint.
* *
*/ */
namespace Zotlabs\Module;
require_once('include/zot.php'); require_once('include/zot.php');
/**
* @brief Post module.
*
*/
class Post extends \Zotlabs\Web\Controller { class Post extends \Zotlabs\Web\Controller {
function init() { function init() {
if(array_key_exists('auth', $_REQUEST)) {
if (array_key_exists('auth', $_REQUEST)) {
$x = new \Zotlabs\Zot\Auth($_REQUEST); $x = new \Zotlabs\Zot\Auth($_REQUEST);
exit; exit;
} }
} }
function post() {
function post() { $z = new \Zotlabs\Zot\Receiver($_REQUEST['data'], get_config('system', 'prvkey'), new \Zotlabs\Zot\ZotHandler());
$z = new \Zotlabs\Zot\Receiver($_REQUEST['data'],get_config('system','prvkey'), new \Zotlabs\Zot\ZotHandler());
// notreached; // notreached;
exit; exit;
} }
} }

View File

@ -1,9 +1,9 @@
<?php <?php
namespace Zotlabs\Module; namespace Zotlabs\Module;
/** /**
* @file mod/setup.php * @file Zotlabs/Module/Setup.php
* *
* Controller for the initial setup/installation. * @brief Controller for the initial setup/installation.
* *
* @todo This setup module could need some love and improvements. * @todo This setup module could need some love and improvements.
*/ */
@ -13,14 +13,15 @@ namespace Zotlabs\Module;
* @brief Initialisation for the setup module. * @brief Initialisation for the setup module.
* *
*/ */
class Setup extends \Zotlabs\Web\Controller { class Setup extends \Zotlabs\Web\Controller {
private static $install_wizard_pass = 1; private static $install_wizard_pass = 1;
/**
* {@inheritDoc}
* @see \\Zotlabs\\Web\\Controller::init()
*/
function init() { function init() {
// Ensure that if somebody hasn't read the install documentation and doesn't have all // 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 // 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 // figure out what the hell is going on - that we at least spit out an error message which
@ -45,8 +46,7 @@ class Setup extends \Zotlabs\Web\Controller {
if (x($_POST, 'pass')) { if (x($_POST, 'pass')) {
$this->install_wizard_pass = intval($_POST['pass']); $this->install_wizard_pass = intval($_POST['pass']);
} } else {
else {
$this->install_wizard_pass = 1; $this->install_wizard_pass = 1;
} }
} }
@ -55,7 +55,6 @@ class Setup extends \Zotlabs\Web\Controller {
* @brief Handle the actions of the different setup steps. * @brief Handle the actions of the different setup steps.
* *
*/ */
function post() { function post() {
switch($this->install_wizard_pass) { switch($this->install_wizard_pass) {
@ -176,7 +175,6 @@ class Setup extends \Zotlabs\Web\Controller {
* *
* @return string parsed HTML output * @return string parsed HTML output
*/ */
function get() { function get() {
$o = ''; $o = '';
@ -356,7 +354,7 @@ class Setup extends \Zotlabs\Web\Controller {
'$siteurl' => array('siteurl', t('Website URL'), z_root(), t('Please use SSL (https) URL if available.')), '$siteurl' => array('siteurl', t('Website URL'), z_root(), t('Please use SSL (https) URL if available.')),
'$server_role' => array('server_role', t("Server Configuration/Role"), 'standard','',$server_roles), '$server_role' => array('server_role', t("Server Configuration/Role"), 'standard','',$server_roles),
'$timezone' => array('timezone', t('Please select a default timezone for your website'), $timezone, '', get_timezones()), '$timezone' => array('timezone', t('Please select a default timezone for your website'), $timezone, '', get_timezones()),
@ -376,7 +374,7 @@ class Setup extends \Zotlabs\Web\Controller {
* @param string $title a title for the check * @param string $title a title for the check
* @param boolean $status * @param boolean $status
* @param boolean $required * @param boolean $required
* @param[optional] string $help optional help string * @param string $help optional help string
*/ */
function check_add(&$checks, $title, $status, $required, $help = '') { function check_add(&$checks, $title, $status, $required, $help = '') {
$checks[] = array( $checks[] = array(
@ -649,7 +647,6 @@ class Setup extends \Zotlabs\Web\Controller {
$help .= t('If you are confident that the certificate is valid and signed by a trusted authority, check to see if you have failed to install an intermediate cert. These are not normally required by browsers, but are required for server-to-server communications.') . EOL; $help .= t('If you are confident that the certificate is valid and signed by a trusted authority, check to see if you have failed to install an intermediate cert. These are not normally required by browsers, but are required for server-to-server communications.') . EOL;
$this->check_add($checks, t('SSL certificate validation'), false, true, $help); $this->check_add($checks, t('SSL certificate validation'), false, true, $help);
} }
} }
@ -665,7 +662,12 @@ class Setup extends \Zotlabs\Web\Controller {
} }
} }
/**
* @brief
*
* @param App &$a
* @return string with paresed HTML
*/
function manual_config(&$a) { function manual_config(&$a) {
$data = htmlspecialchars(\App::$data['txt'], ENT_COMPAT, 'UTF-8'); $data = htmlspecialchars(\App::$data['txt'], ENT_COMPAT, 'UTF-8');
$o = t('The database configuration file ".htconfig.php" could not be written. Please use the enclosed text to create a configuration file in your web server root.'); $o = t('The database configuration file ".htconfig.php" could not be written. Please use the enclosed text to create a configuration file in your web server root.');
@ -686,7 +688,7 @@ class Setup extends \Zotlabs\Web\Controller {
function load_database($db) { function load_database($db) {
$str = file_get_contents(\DBA::$dba->get_install_script()); $str = file_get_contents(\DBA::$dba->get_install_script());
$arr = explode(';',$str); $arr = explode(';', $str);
$errors = false; $errors = false;
foreach($arr as $a) { foreach($arr as $a) {
if(strlen(trim($a))) { if(strlen(trim($a))) {
@ -700,12 +702,16 @@ class Setup extends \Zotlabs\Web\Controller {
return $errors; return $errors;
} }
/**
* @brief
*
* @return string with parsed HTML
*/
function what_next() { function what_next() {
$a = get_app(); $a = get_app();
// install the standard theme // 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 // Set a lenient list of ciphers if using openssl. Other ssl engines
// (e.g. NSS used in RedHat) require different syntax, so hopefully // (e.g. NSS used in RedHat) require different syntax, so hopefully
// the default curl cipher list will work for most sites. If not, // the default curl cipher list will work for most sites. If not,
@ -737,7 +743,13 @@ class Setup extends \Zotlabs\Web\Controller {
."</p>"; ."</p>";
} }
/**
* @brief
*
* @param unknown $v
* @param array $c
* @return array
*/
static private function check_passed($v, $c) { static private function check_passed($v, $c) {
if ($c['required']) if ($c['required'])
$v = $v && $c['status']; $v = $v && $c['status'];
@ -745,5 +757,4 @@ class Setup extends \Zotlabs\Web\Controller {
return $v; return $v;
} }
} }

View File

@ -1,10 +1,10 @@
<?php <?php
namespace Zotlabs\Module;
/** /**
* @file mod/thing.php * @file Zotlabs/Module/Thing.php
* @brief
*/ */
namespace Zotlabs\Module;
require_once('include/items.php'); require_once('include/items.php');
require_once('include/security.php'); require_once('include/security.php');
require_once('include/selectors.php'); require_once('include/selectors.php');

View File

@ -12,7 +12,7 @@ use Sabre\HTTP\ResponseInterface;
* This class also contains some data which is not necessary for authentication * This class also contains some data which is not necessary for authentication
* like timezone settings. * like timezone settings.
* *
* @extends Sabre\DAV\Auth\Backend\AbstractBasic * @extends \\Sabre\\DAV\\Auth\\Backend\\AbstractBasic
* *
* @link http://github.com/friendica/red * @link http://github.com/friendica/red
* @license http://opensource.org/licenses/mit-license.php The MIT License (MIT) * @license http://opensource.org/licenses/mit-license.php The MIT License (MIT)
@ -24,37 +24,37 @@ class BasicAuth extends DAV\Auth\Backend\AbstractBasic {
* *
* It is used for building path in filestorage/. * It is used for building path in filestorage/.
* *
* @var string|null * @var string|null $channel_name
*/ */
protected $channel_name = null; protected $channel_name = null;
/** /**
* channel_id of the current channel of the logged-in account. * @brief channel_id of the current channel of the logged-in account.
* *
* @var int * @var int $channel_id
*/ */
public $channel_id = 0; public $channel_id = 0;
/** /**
* channel_hash of the current channel of the logged-in account. * @brief channel_hash of the current channel of the logged-in account.
* *
* @var string * @var string $channel_hash
*/ */
public $channel_hash = ''; public $channel_hash = '';
/** /**
* Set in mod/cloud.php to observer_hash. * @brief Set in mod/cloud.php to observer_hash.
* *
* @var string * @var string $observer
*/ */
public $observer = ''; public $observer = '';
/** /**
* *
* @see Browser::set_writeable() * @see Browser::set_writeable()
* @var \Sabre\DAV\Browser\Plugin * @var \\Sabre\\DAV\\Browser\\Plugin $browser
*/ */
public $browser; public $browser;
/** /**
* channel_id of the current visited path. Set in Directory::getDir(). * @brief channel_id of the current visited path. Set in Directory::getDir().
* *
* @var int * @var int $owner_id
*/ */
public $owner_id = 0; public $owner_id = 0;
/** /**
@ -62,15 +62,15 @@ class BasicAuth extends DAV\Auth\Backend\AbstractBasic {
* *
* Used for creating the path in cloud/ * Used for creating the path in cloud/
* *
* @var string * @var string $owner_nick
*/ */
public $owner_nick = ''; public $owner_nick = '';
/** /**
* Timezone from the visiting channel's channel_timezone. * Timezone from the visiting channel's channel_timezone.
* *
* Used in @ref RedBrowser * Used in @ref Browser
* *
* @var string * @var string $timezone
*/ */
protected $timezone = ''; protected $timezone = '';
@ -82,7 +82,7 @@ class BasicAuth extends DAV\Auth\Backend\AbstractBasic {
* @brief Validates a username and password. * @brief Validates a username and password.
* *
* *
* @see \Sabre\DAV\Auth\Backend\AbstractBasic::validateUserPass * @see \\Sabre\\DAV\\Auth\\Backend\\AbstractBasic::validateUserPass
* @param string $username * @param string $username
* @param string $password * @param string $password
* @return bool * @return bool
@ -211,7 +211,7 @@ class BasicAuth extends DAV\Auth\Backend\AbstractBasic {
* *
* If nobody is currently logged in, this method should return null. * If nobody is currently logged in, this method should return null.
* *
* @see \Sabre\DAV\Auth\Backend\AbstractBasic::getCurrentUser * @see \\Sabre\\DAV\\Auth\\Backend\\AbstractBasic::getCurrentUser
* @return string|null * @return string|null
*/ */
public function getCurrentUser() { public function getCurrentUser() {

View File

@ -7,10 +7,10 @@ use Sabre\DAV;
/** /**
* @brief Provides a DAV frontend for the webbrowser. * @brief Provides a DAV frontend for the webbrowser.
* *
* RedBrowser is a SabreDAV server-plugin to provide a view to the DAV storage * Browser is a SabreDAV server-plugin to provide a view to the DAV storage
* for the webbrowser. * for the webbrowser.
* *
* @extends \Sabre\DAV\Browser\Plugin * @extends \\Sabre\\DAV\\Browser\\Plugin
* *
* @link http://github.com/friendica/red * @link http://github.com/friendica/red
* @license http://opensource.org/licenses/mit-license.php The MIT License (MIT) * @license http://opensource.org/licenses/mit-license.php The MIT License (MIT)
@ -19,13 +19,13 @@ class Browser extends DAV\Browser\Plugin {
/** /**
* @see set_writeable() * @see set_writeable()
* @see \Sabre\DAV\Auth\Backend\BackendInterface * @see \\Sabre\\DAV\\Auth\\Backend\\BackendInterface
* @var RedBasicAuth * @var BasicAuth $auth
*/ */
private $auth; private $auth;
/** /**
* @brief Constructor for RedBrowser class. * @brief Constructor for Browser class.
* *
* $enablePost will be activated through set_writeable() in a later stage. * $enablePost will be activated through set_writeable() in a later stage.
* At the moment the write_storage permission is only valid for the whole * At the moment the write_storage permission is only valid for the whole
@ -36,7 +36,7 @@ class Browser extends DAV\Browser\Plugin {
* Disable assets with $enableAssets = false. Should get some thumbnail views * Disable assets with $enableAssets = false. Should get some thumbnail views
* anyway. * anyway.
* *
* @param RedBasicAuth &$auth * @param BasicAuth &$auth
*/ */
public function __construct(&$auth) { public function __construct(&$auth) {
$this->auth = $auth; $this->auth = $auth;
@ -95,7 +95,6 @@ class Browser extends DAV\Browser\Plugin {
'{DAV:}getlastmodified', '{DAV:}getlastmodified',
), 1); ), 1);
$parent = $this->server->tree->getNodeForPath($path); $parent = $this->server->tree->getNodeForPath($path);
$parentpath = array(); $parentpath = array();
@ -263,10 +262,11 @@ class Browser extends DAV\Browser\Plugin {
* @brief Creates a form to add new folders and upload files. * @brief Creates a form to add new folders and upload files.
* *
* @param \Sabre\DAV\INode $node * @param \Sabre\DAV\INode $node
* @param string &$output * @param[in,out] string &$output
* @param string $path
*/ */
public function htmlActionsPanel(DAV\INode $node, &$output, $path) { public function htmlActionsPanel(DAV\INode $node, &$output, $path) {
if (! $node instanceof DAV\ICollection) if(! $node instanceof DAV\ICollection)
return; return;
// We also know fairly certain that if an object is a non-extended // We also know fairly certain that if an object is a non-extended
@ -278,9 +278,9 @@ class Browser extends DAV\Browser\Plugin {
$aclselect = null; $aclselect = null;
$lockstate = ''; $lockstate = '';
if ($this->auth->owner_id) { if($this->auth->owner_id) {
$channel = channelx_by_n($this->auth->owner_id); $channel = channelx_by_n($this->auth->owner_id);
if ($channel) { if($channel) {
$acl = new \Zotlabs\Access\AccessList($channel); $acl = new \Zotlabs\Access\AccessList($channel);
$channel_acl = $acl->get(); $channel_acl = $acl->get();
$lockstate = (($acl->is_private()) ? 'lock' : 'unlock'); $lockstate = (($acl->is_private()) ? 'lock' : 'unlock');
@ -295,12 +295,12 @@ class Browser extends DAV\Browser\Plugin {
intval($this->auth->channel_account_id) intval($this->auth->channel_account_id)
); );
$used = $r[0]['total']; $used = $r[0]['total'];
if ($used) { if($used) {
$quotaDesc = t('You are using %1$s of your available file storage.'); $quotaDesc = t('You are using %1$s of your available file storage.');
$quotaDesc = sprintf($quotaDesc, $quotaDesc = sprintf($quotaDesc,
userReadableSize($used)); userReadableSize($used));
} }
if ($limit && $used) { if($limit && $used) {
$quotaDesc = t('You are using %1$s of %2$s available file storage. (%3$s&#37;)'); $quotaDesc = t('You are using %1$s of %2$s available file storage. (%3$s&#37;)');
$quotaDesc = sprintf($quotaDesc, $quotaDesc = sprintf($quotaDesc,
userReadableSize($used), userReadableSize($used),
@ -355,7 +355,7 @@ class Browser extends DAV\Browser\Plugin {
* *
* @param int $owner * @param int $owner
* The owner_id * The owner_id
* @param string $hash * @param string $parentHash
* The parent's folder hash * The parent's folder hash
* @param string $attachName * @param string $attachName
* The name of the attachment * The name of the attachment
@ -373,6 +373,7 @@ class Browser extends DAV\Browser\Plugin {
$hash = $rr['hash']; $hash = $rr['hash'];
} }
} }
return $hash; return $hash;
} }

View File

@ -9,9 +9,9 @@ use Sabre\DAV;
* *
* A class that represents a directory. * A class that represents a directory.
* *
* @extends \Sabre\DAV\Node * @extends \\Sabre\\DAV\\Node
* @implements \Sabre\DAV\ICollection * @implements \\Sabre\\DAV\\ICollection
* @implements \Sabre\DAV\IQuota * @implements \\Sabre\\DAV\\IQuota
* *
* @link http://github.com/friendica/red * @link http://github.com/friendica/red
* @license http://opensource.org/licenses/mit-license.php The MIT License (MIT) * @license http://opensource.org/licenses/mit-license.php The MIT License (MIT)
@ -21,7 +21,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
/** /**
* @brief The path inside /cloud * @brief The path inside /cloud
* *
* @var string * @var string $red_path
*/ */
private $red_path; private $red_path;
private $folder_hash; private $folder_hash;
@ -29,7 +29,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
* @brief The full path as seen in the browser. * @brief The full path as seen in the browser.
* /cloud + $red_path * /cloud + $red_path
* @todo I think this is not used anywhere, we always strip '/cloud' and only use it in debug * @todo I think this is not used anywhere, we always strip '/cloud' and only use it in debug
* @var string * @var string $ext_path
*/ */
private $ext_path; private $ext_path;
private $root_dir = ''; private $root_dir = '';
@ -38,7 +38,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
* @brief The real path on the filesystem. * @brief The real path on the filesystem.
* The actual path in store/ with the hashed names. * The actual path in store/ with the hashed names.
* *
* @var string * @var string $os_path
*/ */
private $os_path = ''; private $os_path = '';
@ -46,7 +46,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
* @brief Sets up the directory node, expects a full path. * @brief Sets up the directory node, expects a full path.
* *
* @param string $ext_path a full path * @param string $ext_path a full path
* @param RedBasicAuth &$auth_plugin * @param BasicAuth &$auth_plugin
*/ */
public function __construct($ext_path, &$auth_plugin) { public function __construct($ext_path, &$auth_plugin) {
// $ext_path = urldecode($ext_path); // $ext_path = urldecode($ext_path);
@ -55,14 +55,14 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
// remove "/cloud" from the beginning of the path // remove "/cloud" from the beginning of the path
$modulename = \App::$module; $modulename = \App::$module;
$this->red_path = ((strpos($ext_path, '/' . $modulename) === 0) ? substr($ext_path, strlen($modulename) + 1) : $ext_path); $this->red_path = ((strpos($ext_path, '/' . $modulename) === 0) ? substr($ext_path, strlen($modulename) + 1) : $ext_path);
if (! $this->red_path) { if(! $this->red_path) {
$this->red_path = '/'; $this->red_path = '/';
} }
$this->auth = $auth_plugin; $this->auth = $auth_plugin;
$this->folder_hash = ''; $this->folder_hash = '';
$this->getDir(); $this->getDir();
if ($this->auth->browser) { if($this->auth->browser) {
$this->auth->browser->set_writeable(); $this->auth->browser->set_writeable();
} }
} }
@ -76,8 +76,8 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
/** /**
* @brief Returns an array with all the child nodes. * @brief Returns an array with all the child nodes.
* *
* @throw \Sabre\DAV\Exception\Forbidden * @throw "\Sabre\DAV\Exception\Forbidden"
* @return array \Sabre\DAV\INode[] * @return array \\Sabre\\DAV\\INode[]
*/ */
public function getChildren() { public function getChildren() {
logger('children for ' . $this->ext_path, LOGGER_DATA); logger('children for ' . $this->ext_path, LOGGER_DATA);
@ -98,8 +98,8 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
/** /**
* @brief Returns a child by name. * @brief Returns a child by name.
* *
* @throw \Sabre\DAV\Exception\Forbidden * @throw "\Sabre\DAV\Exception\Forbidden"
* @throw \Sabre\DAV\Exception\NotFound * @throw "\Sabre\DAV\Exception\NotFound"
* @param string $name * @param string $name
*/ */
public function getChild($name) { public function getChild($name) {
@ -141,7 +141,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
* *
* @todo handle duplicate directory name * @todo handle duplicate directory name
* *
* @throw \Sabre\DAV\Exception\Forbidden * @throw "\Sabre\DAV\Exception\Forbidden"
* @param string $name The new name of the directory. * @param string $name The new name of the directory.
* @return void * @return void
*/ */
@ -186,7 +186,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
* After successful creation of the file, you may choose to return the ETag * After successful creation of the file, you may choose to return the ETag
* of the new file here. * of the new file here.
* *
* @throw \Sabre\DAV\Exception\Forbidden * @throw "\Sabre\DAV\Exception\Forbidden"
* @param string $name Name of the file * @param string $name Name of the file
* @param resource|string $data Initial payload * @param resource|string $data Initial payload
* @return null|string ETag * @return null|string ETag
@ -431,7 +431,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
/** /**
* @todo add description of what this function does. * @todo add description of what this function does.
* *
* @throw \Sabre\DAV\Exception\NotFound * @throw "\Sabre\DAV\Exception\NotFound"
* @return void * @return void
*/ */
function getDir() { function getDir() {
@ -557,13 +557,13 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
/** /**
* @brief Array with all Directory and File DAV\Node items for the given path. * @brief Array with all Directory and File DAV\\Node items for the given path.
* *
* @param string $file path to a directory * @param string $file path to a directory
* @param \Zotlabs\Storage\BasicAuth &$auth * @param \Zotlabs\Storage\BasicAuth &$auth
* @returns null|array \Sabre\DAV\INode[] * @returns null|array \\Sabre\\DAV\\INode[]
* @throw \Sabre\DAV\Exception\Forbidden * @throw "\Sabre\DAV\Exception\Forbidden"
* @throw \Sabre\DAV\Exception\NotFound * @throw "\Sabre\DAV\Exception\NotFound"
*/ */
function CollectionData($file, &$auth) { function CollectionData($file, &$auth) {
$ret = array(); $ret = array();
@ -710,7 +710,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
* @param BasicAuth &$auth * @param BasicAuth &$auth
* @param boolean $test (optional) enable test mode * @param boolean $test (optional) enable test mode
* @return File|Directory|boolean|null * @return File|Directory|boolean|null
* @throw \Sabre\DAV\Exception\Forbidden * @throw "\Sabre\DAV\Exception\Forbidden"
*/ */
function FileData($file, &$auth, $test = false) { function FileData($file, &$auth, $test = false) {
logger($file . (($test) ? ' (test mode) ' : ''), LOGGER_DATA); logger($file . (($test) ? ' (test mode) ' : ''), LOGGER_DATA);

View File

@ -9,8 +9,8 @@ use Sabre\DAV;
* *
* It provides all functions to work with files in Red's cloud through DAV protocol. * It provides all functions to work with files in Red's cloud through DAV protocol.
* *
* @extends \Sabre\DAV\Node * @extends \\Sabre\\DAV\\Node
* @implements \Sabre\DAV\IFile * @implements \\Sabre\\DAV\\IFile
* *
* @link http://github.com/friendica/red * @link http://github.com/friendica/red
* @license http://opensource.org/licenses/mit-license.php The MIT License (MIT) * @license http://opensource.org/licenses/mit-license.php The MIT License (MIT)
@ -20,20 +20,20 @@ class File extends DAV\Node implements DAV\IFile {
/** /**
* The file from attach table. * The file from attach table.
* *
* @var array * @var array $data
* data * * data
* flags * * flags
* filename (string) * * filename (string)
* filetype (string) * * filetype (string)
*/ */
private $data; private $data;
/** /**
* @see \Sabre\DAV\Auth\Backend\BackendInterface * @see \\Sabre\\DAV\\Auth\\Backend\\BackendInterface
* @var \RedMatrix\RedDAV\RedBasicAuth * @var \\Zotlabs\\Storage\\BasicAuth $auth
*/ */
private $auth; private $auth;
/** /**
* @var string * @var string $name
*/ */
private $name; private $name;
@ -65,8 +65,8 @@ class File extends DAV\Node implements DAV\IFile {
/** /**
* @brief Renames the file. * @brief Renames the file.
* *
* @throw Sabre\DAV\Exception\Forbidden * @throw "\Sabre\DAV\Exception\Forbidden"
* @param string $name The new name of the file. * @param string $newName The new name of the file.
* @return void * @return void
*/ */
public function setName($newName) { public function setName($newName) {
@ -322,16 +322,16 @@ class File extends DAV\Node implements DAV\IFile {
* This method checks the permissions and then calls attach_delete() function * This method checks the permissions and then calls attach_delete() function
* to actually remove the file. * to actually remove the file.
* *
* @throw \Sabre\DAV\Exception\Forbidden * @throw "\Sabre\DAV\Exception\Forbidden"
*/ */
public function delete() { public function delete() {
logger('delete file ' . basename($this->name), LOGGER_DEBUG); logger('delete file ' . basename($this->name), LOGGER_DEBUG);
if ((! $this->auth->owner_id) || (! perm_is_allowed($this->auth->owner_id, $this->auth->observer, 'write_storage'))) { if((! $this->auth->owner_id) || (! perm_is_allowed($this->auth->owner_id, $this->auth->observer, 'write_storage'))) {
throw new DAV\Exception\Forbidden('Permission denied.'); throw new DAV\Exception\Forbidden('Permission denied.');
} }
if ($this->auth->owner_id !== $this->auth->channel_id) { if($this->auth->owner_id !== $this->auth->channel_id) {
if (($this->auth->observer !== $this->data['creator']) || intval($this->data['is_dir'])) { if (($this->auth->observer !== $this->data['creator']) || intval($this->data['is_dir'])) {
throw new DAV\Exception\Forbidden('Permission denied.'); throw new DAV\Exception\Forbidden('Permission denied.');
} }
@ -345,9 +345,9 @@ class File extends DAV\Node implements DAV\IFile {
$ch = channelx_by_n($this->auth->owner_id); $ch = channelx_by_n($this->auth->owner_id);
if($ch) { if($ch) {
$sync = attach_export_data($ch,$this->data['hash'],true); $sync = attach_export_data($ch, $this->data['hash'], true);
if($sync) if($sync)
build_sync_packet($ch['channel_id'],array('file' => array($sync))); build_sync_packet($ch['channel_id'], array('file' => array($sync)));
} }
} }
} }

View File

@ -2,51 +2,53 @@
namespace Zotlabs\Web; namespace Zotlabs\Web;
/**
*
* We have already parsed the server path into App::$argc and App::$argv
*
* App::$argv[0] is our module name. Let's call it 'foo'. We will load the
* Zotlabs/Module/Foo.php (object) or file mod/foo.php (procedural)
* and use it for handling our URL request to 'https://ourgreatwebsite.something/foo' .
* The module file contains a few functions that we call in various circumstances
* and in the following order:
* @code{.php}
* Object:
* class Foo extends \Zotlabs\Web\Controller {
* function init() { init function }
* function post() { post function }
* function get() { normal page function }
* }
*
* Procedual interface:
* foo_init()
* foo_post() (only called if there are $_POST variables)
* foo_content() - the string return of this function contains our page body
* @endcode
* Modules which emit other serialisations besides HTML (XML,JSON, etc.) should do
* so within the module init and/or post functions and then invoke killme() to terminate
* further processing.
*/
class Router { class Router {
private $modname = ''; private $modname = '';
private $controller = null; private $controller = null;
/**
* @brief Router constructor
*
* @param[in,out] App &$a
* @throws Exception module not found
*/
function __construct(&$a) { function __construct(&$a) {
/**
*
* We have already parsed the server path into App::$argc and App::$argv
*
* App::$argv[0] is our module name. Let's call it 'foo'. We will load the
* Zotlabs/Module/Foo.php (object) or file mod/foo.php (procedural)
* and use it for handling our URL request to 'https://ourgreatwebsite.something/foo' .
* The module file contains a few functions that we call in various circumstances
* and in the following order:
*
* Object:
* class Foo extends Zotlabs\Web\Controller {
* function init() { init function }
* function post() { post function }
* function get() { normal page function }
* }
*
* Procedual interface:
* foo_init()
* foo_post() (only called if there are $_POST variables)
* foo_content() - the string return of this function contains our page body
*
* Modules which emit other serialisations besides HTML (XML,JSON, etc.) should do
* so within the module init and/or post functions and then invoke killme() to terminate
* further processing.
*/
$module = \App::$module; $module = \App::$module;
$modname = "Zotlabs\\Module\\" . ucfirst($module); $modname = "Zotlabs\\Module\\" . ucfirst($module);
if(strlen($module)) { if(strlen($module)) {
/** /*
*
* We will always have a module name. * We will always have a module name.
* First see if we have a plugin which is masquerading as a module. * First see if we have a plugin which is masquerading as a module.
*
*/ */
if(is_array(\App::$plugins) && in_array($module,\App::$plugins) && file_exists("addon/{$module}/{$module}.php")) { if(is_array(\App::$plugins) && in_array($module,\App::$plugins) && file_exists("addon/{$module}/{$module}.php")) {
@ -66,7 +68,7 @@ class Router {
goaway(z_root()); goaway(z_root());
} }
/** /*
* If the site has a custom module to over-ride the standard module, use it. * If the site has a custom module to over-ride the standard module, use it.
* Otherwise, look for the standard program module * Otherwise, look for the standard program module
*/ */
@ -102,7 +104,7 @@ class Router {
} }
} }
/** /*
* This provides a place for plugins to register module handlers which don't otherwise exist * This provides a place for plugins to register module handlers which don't otherwise exist
* on the system, or to completely over-ride an existing module. * on the system, or to completely over-ride an existing module.
* If the plugin sets 'installed' to true we won't throw a 404 error for the specified module even if * If the plugin sets 'installed' to true we won't throw a 404 error for the specified module even if
@ -117,7 +119,7 @@ class Router {
$this->controller = $x['controller']; $this->controller = $x['controller'];
} }
/** /*
* The URL provided does not resolve to a valid module. * The URL provided does not resolve to a valid module.
* *
* On Dreamhost sites, quite often things go wrong for no apparent reason and they send us to '/internal_error.html'. * On Dreamhost sites, quite often things go wrong for no apparent reason and they send us to '/internal_error.html'.
@ -157,7 +159,11 @@ class Router {
} }
} }
/**
* @brief
*
* @param[in,out] App &$a
*/
function Dispatch(&$a) { function Dispatch(&$a) {
/** /**
@ -168,7 +174,7 @@ class Router {
\App::$page['page_title'] = \App::$module; \App::$page['page_title'] = \App::$module;
$placeholder = ''; $placeholder = '';
/** /*
* No theme has been specified when calling the module_init functions * No theme has been specified when calling the module_init functions
* For this reason, please restrict the use of templates to those which * For this reason, please restrict the use of templates to those which
* do not provide any presentation details - as themes will not be able * do not provide any presentation details - as themes will not be able
@ -187,7 +193,7 @@ class Router {
} }
} }
/** /*
* Do all theme initialisation here before calling any additional module functions. * Do all theme initialisation here before calling any additional module functions.
* The module_init function may have changed the theme. * The module_init function may have changed the theme.
* Additionally any page with a Comanche template may alter the theme. * Additionally any page with a Comanche template may alter the theme.
@ -195,7 +201,7 @@ class Router {
*/ */
/** /*
* In case a page has overloaded a module, see if we already have a layout defined * In case a page has overloaded a module, see if we already have a layout defined
* otherwise, if a PDL file exists for this module, use it * otherwise, if a PDL file exists for this module, use it
* The member may have also created a customised PDL that's stored in the config * The member may have also created a customised PDL that's stored in the config
@ -203,7 +209,7 @@ class Router {
load_pdl($a); load_pdl($a);
/** /*
* load current theme info * load current theme info
*/ */
@ -238,7 +244,7 @@ class Router {
} }
} }
if(! \App::$error) { if(! \App::$error) {
$arr = array('content' => \App::$page['content'], 'replace' => false); $arr = array('content' => \App::$page['content'], 'replace' => false);
call_hooks(\App::$module . '_mod_content', $arr); call_hooks(\App::$module . '_mod_content', $arr);
\App::$page['content'] = $arr['content']; \App::$page['content'] = $arr['content'];

View File

@ -2,12 +2,17 @@
namespace Zotlabs\Web; namespace Zotlabs\Web;
/*
* @brief
*
*/
class SubModule { class SubModule {
private $controller = false; private $controller = false;
/** /**
* @brief Submodule constructor.
*
* Initiate sub-modules. By default the submodule name is in argv(1), though this is configurable. * Initiate sub-modules. By default the submodule name is in argv(1), though this is configurable.
* Example: Given a URL path such as /admin/plugins, and the Admin module initiates sub-modules. * Example: Given a URL path such as /admin/plugins, and the Admin module initiates sub-modules.
* This means we'll look for a class Plugins in Zotlabs/Module/Admin/Plugins.php * This means we'll look for a class Plugins in Zotlabs/Module/Admin/Plugins.php
@ -16,9 +21,9 @@ class SubModule {
* **If** you were to provide sub-module support on the photos module, you would probably use * **If** you were to provide sub-module support on the photos module, you would probably use
* $whicharg = 2, as photos are typically called with a URL path of /photos/channel_address/submodule_name * $whicharg = 2, as photos are typically called with a URL path of /photos/channel_address/submodule_name
* where submodule_name might be something like album or image. * where submodule_name might be something like album or image.
*
* @param int $whicharg
*/ */
function __construct($whicharg = 1) { function __construct($whicharg = 1) {
if(argc() < ($whicharg + 1)) if(argc() < ($whicharg + 1))
@ -31,13 +36,20 @@ class SubModule {
} }
} }
/**
* @brief
*
* @param string $method
* @return boolean|mixed
*/
function call($method) { function call($method) {
if(! $this->controller) if(! $this->controller)
return false; return false;
if(method_exists($this->controller,$method))
if(method_exists($this->controller, $method))
return $this->controller->$method(); return $this->controller->$method();
return false; return false;
} }
} }

View File

@ -2,7 +2,10 @@
namespace Zotlabs\Zot; namespace Zotlabs\Zot;
/**
* @brief Finger
*
*/
class Finger { class Finger {
static private $token; static private $token;
@ -19,25 +22,25 @@ class Finger {
* *
* @return zotinfo array (with 'success' => true) or array('success' => false); * @return zotinfo array (with 'success' => true) or array('success' => false);
*/ */
static public function run($webbie, $channel = null, $autofallback = true) { static public function run($webbie, $channel = null, $autofallback = true) {
$ret = array('success' => false); $ret = array('success' => false);
self::$token = random_string(); self::$token = random_string();
if (strpos($webbie,'@') === false) { if (strpos($webbie, '@') === false) {
$address = $webbie; $address = $webbie;
$host = \App::get_hostname(); $host = \App::get_hostname();
} else { } else {
$address = substr($webbie,0,strpos($webbie,'@')); $address = substr($webbie, 0, strpos($webbie, '@'));
$host = substr($webbie,strpos($webbie,'@')+1); $host = substr($webbie, strpos($webbie, '@')+1);
} }
$xchan_addr = $address . '@' . $host; $xchan_addr = $address . '@' . $host;
if ((! $address) || (! $xchan_addr)) { if ((! $address) || (! $xchan_addr)) {
logger('zot_finger: no address :' . $webbie); logger('zot_finger: no address :' . $webbie);
return $ret; return $ret;
} }
@ -53,16 +56,16 @@ class Finger {
dbesc($xchan_addr) dbesc($xchan_addr)
); );
if ($r) { if($r) {
$url = $r[0]['hubloc_url']; $url = $r[0]['hubloc_url'];
if ($r[0]['hubloc_network'] && $r[0]['hubloc_network'] !== 'zot') { if($r[0]['hubloc_network'] && $r[0]['hubloc_network'] !== 'zot') {
logger('zot_finger: alternate network: ' . $webbie); logger('zot_finger: alternate network: ' . $webbie);
logger('url: '.$url.', net: '.var_export($r[0]['hubloc_network'],true), LOGGER_DATA, LOG_DEBUG); logger('url: '.$url.', net: '.var_export($r[0]['hubloc_network'], true), LOGGER_DATA, LOG_DEBUG);
return $ret; return $ret;
} }
} } else {
else {
$url = 'https://' . $host; $url = 'https://' . $host;
} }
@ -88,13 +91,12 @@ class Finger {
$result = z_post_url('http://' . $host . $rhs,$postvars); $result = z_post_url('http://' . $host . $rhs,$postvars);
} }
} }
} } else {
else {
$rhs .= '?f=&address=' . urlencode($address) . '&token=' . self::$token; $rhs .= '?f=&address=' . urlencode($address) . '&token=' . self::$token;
$result = z_fetch_url($url . $rhs); $result = z_fetch_url($url . $rhs);
if ((! $result['success']) && ($autofallback)) { if((! $result['success']) && ($autofallback)) {
if ($https) { if($https) {
logger('zot_finger: https failed. falling back to http'); logger('zot_finger: https failed. falling back to http');
$result = z_fetch_url('http://' . $host . $rhs); $result = z_fetch_url('http://' . $host . $rhs);
} }
@ -103,23 +105,25 @@ class Finger {
if(! $result['success']) { if(! $result['success']) {
logger('zot_finger: no results'); logger('zot_finger: no results');
return $ret; return $ret;
} }
$x = json_decode($result['body'],true); $x = json_decode($result['body'], true);
if($x) { if($x) {
$signed_token = ((is_array($x) && array_key_exists('signed_token',$x)) ? $x['signed_token'] : null); $signed_token = ((is_array($x) && array_key_exists('signed_token', $x)) ? $x['signed_token'] : null);
if($signed_token) { if($signed_token) {
$valid = rsa_verify('token.' . self::$token,base64url_decode($signed_token),$x['key']); $valid = rsa_verify('token.' . self::$token, base64url_decode($signed_token), $x['key']);
if(! $valid) { if(! $valid) {
logger('invalid signed token: ' . $url . $rhs, LOGGER_NORMAL, LOG_ERR); logger('invalid signed token: ' . $url . $rhs, LOGGER_NORMAL, LOG_ERR);
return $ret; return $ret;
} }
} }
else { else {
logger('No signed token from ' . $url . $rhs, LOGGER_NORMAL, LOG_WARNING); logger('No signed token from ' . $url . $rhs, LOGGER_NORMAL, LOG_WARNING);
// after 2017-01-01 this will be a hard error unless you over-ride it. // after 2017-01-01 this will be a hard error unless you over-ride it.
if((time() > 1483228800) && (! get_config('system','allow_unsigned_zotfinger'))) if((time() > 1483228800) && (! get_config('system', 'allow_unsigned_zotfinger')))
return $ret; return $ret;
} }
} }

View File

@ -5,7 +5,6 @@ namespace Hubzilla\Import;
/** /**
* @brief Class Import * @brief Class Import
* *
* @package Hubzilla\Import
*/ */
class Import { class Import {

View File

@ -1,17 +1,24 @@
<?php /** @file */ <?php
/** /**
* @file include/acl_selectors.php
* *
*/
/**
* @package acl_selectors * @package acl_selectors
*/ */
function group_select($selname,$selclass,$preselected = false,$size = 4) { /**
* @brief
*
* @param string $selname
* @param string $selclass
* @param mixed $preselected
* @param number $size
* @return string
*/
function group_select($selname, $selclass, $preselected = false, $size = 4) {
$o = ''; $o = '';
$o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\" >\r\n"; $o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\">\r\n";
$r = q("SELECT * FROM groups WHERE deleted = 0 AND uid = %d ORDER BY gname ASC", $r = q("SELECT * FROM groups WHERE deleted = 0 AND uid = %d ORDER BY gname ASC",
intval(local_channel()) intval(local_channel())
@ -40,13 +47,11 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) {
call_hooks(App::$module . '_post_' . $selname, $o); call_hooks(App::$module . '_post_' . $selname, $o);
return $o; return $o;
} }
function contact_select($selname, $selclass, $preselected = false, $size = 4, $privmail = false, $celeb = false, $privatenet = false, $tabindex = null) { function contact_select($selname, $selclass, $preselected = false, $size = 4, $privmail = false, $celeb = false, $privatenet = false, $tabindex = null) {
$o = ''; $o = '';
// When used for private messages, we limit correspondence to mutual DFRN/Friendica friends and the selector // When used for private messages, we limit correspondence to mutual DFRN/Friendica friends and the selector
@ -54,17 +59,17 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
$sql_extra = ''; $sql_extra = '';
$tabindex = ($tabindex > 0 ? "tabindex=\"$tabindex\"" : ""); $tabindex = ($tabindex > 0 ? 'tabindex="$tabindex"' : '');
if($privmail) if($privmail)
$o .= "<select name=\"$selname\" id=\"$selclass\" class=\"$selclass\" size=\"$size\" $tabindex >\r\n"; $o .= "<select name=\"$selname\" id=\"$selclass\" class=\"$selclass\" size=\"$size\" $tabindex >\r\n";
else else
$o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\" $tabindex >\r\n"; $o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\" $tabindex>\r\n";
$r = q("SELECT abook_id, xchan_name, xchan_url, xchan_photo_s from abook left join xchan on abook_xchan = xchan_hash $r = q("SELECT abook_id, xchan_name, xchan_url, xchan_photo_s from abook left join xchan on abook_xchan = xchan_hash
where abook_self = 0 and abook_channel = %d where abook_self = 0 and abook_channel = %d
$sql_extra $sql_extra
ORDER BY xchan_name ASC ", ORDER BY xchan_name ASC",
intval(local_channel()) intval(local_channel())
); );
@ -78,15 +83,14 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
if($r) { if($r) {
foreach($r as $rr) { foreach($r as $rr) {
if((is_array($preselected)) && in_array($rr['id'], $preselected)) if((is_array($preselected)) && in_array($rr['id'], $preselected))
$selected = " selected=\"selected\" "; $selected = ' selected="selected" ';
else else
$selected = ''; $selected = '';
$trimmed = mb_substr($rr['xchan_name'],0,20); $trimmed = mb_substr($rr['xchan_name'], 0, 20);
$o .= "<option value=\"{$rr['abook_id']}\" $selected title=\"{$rr['xchan_name']}|{$rr['xchan_url']}\" >$trimmed</option>\r\n"; $o .= "<option value=\"{$rr['abook_id']}\" $selected title=\"{$rr['xchan_name']}|{$rr['xchan_url']}\" >$trimmed</option>\r\n";
} }
} }
$o .= "</select>\r\n"; $o .= "</select>\r\n";
@ -98,13 +102,13 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
function fixacl(&$item) { function fixacl(&$item) {
$item = str_replace(array('<','>'),array('',''),$item); $item = str_replace(array('<', '>'), array('', ''), $item);
} }
/** /**
* Builds a modal dialog for editing permissions, using acl_selector.tpl as the template. * Builds a modal dialog for editing permissions, using acl_selector.tpl as the template.
* *
* @param array $default Optional access control list for the initial state of the dialog. * @param array $defaults Optional access control list for the initial state of the dialog.
* @param boolean $show_jotnets Whether plugins for federated networks should be included in the permissions dialog * @param boolean $show_jotnets Whether plugins for federated networks should be included in the permissions dialog
* @param PermissionDescription $emptyACL_description - An optional description for the permission implied by selecting an empty ACL. Preferably an instance of PermissionDescription. * @param PermissionDescription $emptyACL_description - An optional description for the permission implied by selecting an empty ACL. Preferably an instance of PermissionDescription.
* @param string $dialog_description Optional message to include at the top of the dialog. E.g. "Warning: Post permissions cannot be changed once sent". * @param string $dialog_description Optional message to include at the top of the dialog. E.g. "Warning: Post permissions cannot be changed once sent".
@ -118,16 +122,15 @@ function populate_acl($defaults = null,$show_jotnets = true, $emptyACL_descripti
$allow_cid = $allow_gid = $deny_cid = $deny_gid = false; $allow_cid = $allow_gid = $deny_cid = $deny_gid = false;
$showall_origin = ''; $showall_origin = '';
$showall_icon = 'fa-globe'; $showall_icon = 'fa-globe';
$role = get_pconfig(local_channel(),'system','permissions_role'); $role = get_pconfig(local_channel(), 'system', 'permissions_role');
if(! $emptyACL_description) { if(! $emptyACL_description) {
$showall_caption = t('Visible to your default audience'); $showall_caption = t('Visible to your default audience');
} else if (is_a($emptyACL_description, '\\Zotlabs\\Lib\\PermissionDescription')) { } else if(is_a($emptyACL_description, '\\Zotlabs\\Lib\\PermissionDescription')) {
$showall_caption = $emptyACL_description->get_permission_description(); $showall_caption = $emptyACL_description->get_permission_description();
$showall_origin = (($role === 'custom') ? $emptyACL_description->get_permission_origin_description() : ''); $showall_origin = (($role === 'custom') ? $emptyACL_description->get_permission_origin_description() : '');
$showall_icon = $emptyACL_description->get_permission_icon(); $showall_icon = $emptyACL_description->get_permission_icon();
} else { } else {
// For backwards compatibility we still accept a string... for now! // For backwards compatibility we still accept a string... for now!
$showall_caption = $emptyACL_description; $showall_caption = $emptyACL_description;
@ -169,9 +172,9 @@ function populate_acl($defaults = null,$show_jotnets = true, $emptyACL_descripti
'$select_label' => t('Who can see this?'), '$select_label' => t('Who can see this?'),
'$custom' => t('Custom selection'), '$custom' => t('Custom selection'),
'$showlimitedDesc' => t('Select "Show" to allow viewing. "Don\'t show" lets you override and limit the scope of "Show".'), '$showlimitedDesc' => t('Select "Show" to allow viewing. "Don\'t show" lets you override and limit the scope of "Show".'),
'$show' => t("Show"), '$show' => t('Show'),
'$hide' => t("Don't show"), '$hide' => t("Don't show"),
'$search' => t("Search"), '$search' => t('Search'),
'$allowcid' => json_encode($allow_cid), '$allowcid' => json_encode($allow_cid),
'$allowgid' => json_encode($allow_gid), '$allowgid' => json_encode($allow_gid),
'$denycid' => json_encode($deny_cid), '$denycid' => json_encode($deny_cid),
@ -183,20 +186,19 @@ function populate_acl($defaults = null,$show_jotnets = true, $emptyACL_descripti
)); ));
return $o; return $o;
} }
/** /**
* Returns a string that's suitable for passing as the $dialog_description argument to a * Returns a string that's suitable for passing as the $dialog_description argument to a
* populate_acl() call for wall posts or network posts. * populate_acl() call for wall posts or network posts.
* *
* This string is needed in 3 different files, and our .po translation system currently * This string is needed in 3 different files, and our .po translation system currently
* cannot be used as a string table (because the value is always the key in english) so * cannot be used as a string table (because the value is always the key in english) so
* I've centralized the value here (making this function name the "key") until we have a * I've centralized the value here (making this function name the "key") until we have a
* better way. * better way.
* *
* @return string Description to present to user in modal permissions dialog * @return string Description to present to user in modal permissions dialog
*/ */
function get_post_aclDialogDescription() { function get_post_aclDialogDescription() {
// I'm trying to make two points in this description text - warn about finality of wall // I'm trying to make two points in this description text - warn about finality of wall
@ -212,4 +214,3 @@ function get_post_aclDialogDescription() {
return sprintf($description, $emphasisOpen, $emphasisClose); return sprintf($description, $emphasisOpen, $emphasisClose);
} }

View File

@ -159,7 +159,6 @@ function attach_count_files($channel_id, $observer, $hash = '', $filename = '',
intval($channel_id) intval($channel_id)
); );
$ret['success'] = ((is_array($r)) ? true : false); $ret['success'] = ((is_array($r)) ? true : false);
$ret['results'] = ((is_array($r)) ? count($r) : false); $ret['results'] = ((is_array($r)) ? count($r) : false);
@ -226,7 +225,8 @@ function attach_list_files($channel_id, $observer, $hash = '', $filename = '', $
* This could exhaust memory so most useful only when immediately sending the data. * This could exhaust memory so most useful only when immediately sending the data.
* *
* @param string $hash * @param string $hash
* @param int $rev Revision * @param string $observer_hash
* @param int $rev (optional) Revision default 0
* @return array * @return array
*/ */
function attach_by_hash($hash, $observer_hash, $rev = 0) { function attach_by_hash($hash, $observer_hash, $rev = 0) {
@ -295,9 +295,10 @@ function attach_can_view_folder($uid,$ob_hash,$folder_hash) {
); );
if(! $r) if(! $r)
return false; return false;
$hash = $r[0]['folder']; $hash = $r[0]['folder'];
} } while($hash);
while($hash);
return true; return true;
} }
@ -308,8 +309,9 @@ function attach_can_view_folder($uid,$ob_hash,$folder_hash) {
* Returns the entire attach structure excluding data. * Returns the entire attach structure excluding data.
* *
* @see attach_by_hash() * @see attach_by_hash()
* @param $hash * @param string $hash
* @param $rev revision default 0 * @param string $observer_hash
* @param int $rev (optional) revision default 0
* @return associative array with everything except data * @return associative array with everything except data
* * \e boolean \b success boolean true or false * * \e boolean \b success boolean true or false
* * \e string \b message (optional) only when success is false * * \e string \b message (optional) only when success is false
@ -335,12 +337,12 @@ function attach_by_hash_nodata($hash, $observer_hash, $rev = 0) {
return $ret; return $ret;
} }
if(! perm_is_allowed($r[0]['uid'],$observer_hash,'view_storage')) { if(! perm_is_allowed($r[0]['uid'], $observer_hash, 'view_storage')) {
$ret['message'] = t('Permission denied.'); $ret['message'] = t('Permission denied.');
return $ret; return $ret;
} }
$sql_extra = permissions_sql($r[0]['uid'],$observer_hash); $sql_extra = permissions_sql($r[0]['uid'], $observer_hash);
// Now we'll see if we can access the attachment // Now we'll see if we can access the attachment
@ -355,14 +357,13 @@ function attach_by_hash_nodata($hash, $observer_hash, $rev = 0) {
} }
if($r[0]['folder']) { if($r[0]['folder']) {
$x = attach_can_view_folder($r[0]['uid'],$observer_hash,$r[0]['folder']); $x = attach_can_view_folder($r[0]['uid'], $observer_hash, $r[0]['folder']);
if(! $x) { if(! $x) {
$ret['message'] = t('Permission denied.'); $ret['message'] = t('Permission denied.');
return $ret; return $ret;
} }
} }
$ret['success'] = true; $ret['success'] = true;
$ret['data'] = $r[0]; $ret['data'] = $r[0];
@ -378,14 +379,7 @@ function attach_by_hash_nodata($hash, $observer_hash, $rev = 0) {
* @note Requires an input field \e userfile and does not accept multiple files * @note Requires an input field \e userfile and does not accept multiple files
* in one request. * in one request.
* *
* @param array $channel channel array of owner * @note A lot going on in this function, and some of it is old cruft and some is new cruft
* @param string $observer_hash hash of current observer
* @param string $options (optional) one of update, replace, revision
* @param array $arr (optional) associative array
*/
/**
* A lot going on in this function, and some of it is old cruft and some is new cruft
* and the entire thing probably needs to be refactored. It started out just storing * and the entire thing probably needs to be refactored. It started out just storing
* files, before we had DAV. It was made extensible to do extra stuff like edit an * files, before we had DAV. It was made extensible to do extra stuff like edit an
* existing file or optionally store a separate revision using $options to choose between different * existing file or optionally store a separate revision using $options to choose between different
@ -404,13 +398,18 @@ function attach_by_hash_nodata($hash, $observer_hash, $rev = 0) {
* That's where it sits currently. I repeat it needs to be refactored, and this note is here * That's where it sits currently. I repeat it needs to be refactored, and this note is here
* for future explorers and those who may be doing that work to understand where it came * for future explorers and those who may be doing that work to understand where it came
* from and got to be the monstrosity of tangled unrelated code that it currently is. * from and got to be the monstrosity of tangled unrelated code that it currently is.
*
* @param array $channel channel array of owner
* @param string $observer_hash hash of current observer
* @param string $options (optional) one of update, replace, revision
* @param array $arr (optional) associative array
* @return void|array
*/ */
function attach_store($channel, $observer_hash, $options = '', $arr = null) { function attach_store($channel, $observer_hash, $options = '', $arr = null) {
require_once('include/photos.php'); require_once('include/photos.php');
call_hooks('photo_upload_begin',$arr); call_hooks('photo_upload_begin', $arr);
$ret = array('success' => false); $ret = array('success' => false);
$channel_id = $channel['channel_id']; $channel_id = $channel['channel_id'];
@ -485,17 +484,15 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
elseif($options !== 'update') { elseif($options !== 'update') {
$f = array('src' => '', 'filename' => '', 'filesize' => 0, 'type' => ''); $f = array('src' => '', 'filename' => '', 'filesize' => 0, 'type' => '');
call_hooks('photo_upload_file',$f); call_hooks('photo_upload_file',$f);
call_hooks('attach_upload_file',$f); call_hooks('attach_upload_file',$f);
if (x($f,'src') && x($f,'filesize')) { if (x($f,'src') && x($f,'filesize')) {
$src = $f['src']; $src = $f['src'];
$filename = $f['filename']; $filename = $f['filename'];
$filesize = $f['filesize']; $filesize = $f['filesize'];
$type = $f['type']; $type = $f['type'];
} else {
} else {
if(! x($_FILES,'userfile')) { if(! x($_FILES,'userfile')) {
$ret['message'] = t('No source file.'); $ret['message'] = t('No source file.');
return $ret; return $ret;
@ -543,8 +540,6 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$hash = $x[0]['hash']; $hash = $x[0]['hash'];
} }
$def_extension = ''; $def_extension = '';
$is_photo = 0; $is_photo = 0;
$gis = @getimagesize($src); $gis = @getimagesize($src);
@ -557,7 +552,6 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$def_extension = '.jpg'; $def_extension = '.jpg';
if($gis[2] === IMAGETYPE_PNG) if($gis[2] === IMAGETYPE_PNG)
$def_extension = '.png'; $def_extension = '.png';
} }
$pathname = ''; $pathname = '';
@ -654,8 +648,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
} }
if($found) if($found)
$x++; $x++;
} } while($found);
while($found);
$filename = $basename . '(' . $x . ')' . $ext; $filename = $basename . '(' . $x . ')' . $ext;
} }
else else
@ -783,7 +776,6 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
); );
} }
else { else {
$r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, filetype, folder, filesize, revision, os_storage, is_photo, content, created, edited, os_path, allow_cid, allow_gid,deny_cid, deny_gid ) $r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, filetype, folder, filesize, revision, os_storage, is_photo, content, created, edited, os_path, allow_cid, allow_gid,deny_cid, deny_gid )
VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ", VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ",
intval($channel['channel_account_id']), intval($channel['channel_account_id']),
@ -869,7 +861,6 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
return $ret; return $ret;
} }
$ret['success'] = true; $ret['success'] = true;
$ret['data'] = $r[0]; $ret['data'] = $r[0];
if(! $is_photo) { if(! $is_photo) {
@ -1178,25 +1169,21 @@ function attach_mkdirp($channel, $observer_hash, $arr = null) {
} }
return $ret; return $ret;
} }
/** /**
* @brief Changes permissions of a file. * @brief Changes permissions of a file.
* *
* @param int $channel_id * @param int $channel_id The id of the channel
* @param array $resource * @param array $resource
* @param string $allow_cid * @param string $allow_cid
* @param string $allow_gid * @param string $allow_gid
* @param string $deny_cid * @param string $deny_cid
* @param string $deny_gid * @param string $deny_gid
* @param boolean $recurse (optional) default false * @param boolean $recurse (optional) default false
* @param boolean $sync (optional) default false
*/ */
function attach_change_permissions($channel_id, $resource, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $recurse = false, $sync = false) { function attach_change_permissions($channel_id, $resource, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $recurse = false, $sync = false) {
@ -1263,6 +1250,7 @@ function attach_change_permissions($channel_id, $resource, $allow_cid, $allow_gi
* The id of the channel * The id of the channel
* @param string $resource * @param string $resource
* The hash to delete * The hash to delete
* @param int $is_photo (optional) default 0
* @return void * @return void
*/ */
function attach_delete($channel_id, $resource, $is_photo = 0) { function attach_delete($channel_id, $resource, $is_photo = 0) {
@ -1425,6 +1413,7 @@ function get_parent_cloudpath($channel_id, $channel_name, $attachHash) {
$parentFullPath = $parentName . '/' . $parentFullPath; $parentFullPath = $parentName . '/' . $parentFullPath;
} }
} while ($parentHash); } while ($parentHash);
$parentFullPath = z_root() . '/cloud/' . $channel_name . '/' . $parentFullPath; $parentFullPath = z_root() . '/cloud/' . $channel_name . '/' . $parentFullPath;
return $parentFullPath; return $parentFullPath;
@ -1437,11 +1426,14 @@ function get_parent_cloudpath($channel_id, $channel_name, $attachHash) {
* The id of the channel * The id of the channel
* @param string $attachHash * @param string $attachHash
* The hash of the attachment * The hash of the attachment
* @param boolean $recurse
* (optional) default false
* @return string * @return string
*/ */
function find_folder_hash_by_attach_hash($channel_id, $attachHash, $recurse = false) { function find_folder_hash_by_attach_hash($channel_id, $attachHash, $recurse = false) {
logger('attach_hash: ' . $attachHash); logger('attach_hash: ' . $attachHash);
$r = q("SELECT folder FROM attach WHERE uid = %d AND hash = '%s' LIMIT 1", $r = q("SELECT folder FROM attach WHERE uid = %d AND hash = '%s' LIMIT 1",
intval($channel_id), intval($channel_id),
dbesc($attachHash) dbesc($attachHash)
@ -1453,6 +1445,7 @@ logger('attach_hash: ' . $attachHash);
else else
$hash = $r[0]['folder']; $hash = $r[0]['folder'];
} }
return $hash; return $hash;
} }
@ -1732,11 +1725,11 @@ function get_file_activity_object($channel_id, $hash, $cloudpath) {
/** /**
* @brief Returns array of channels which have recursive permission for a file * @brief Returns array of channels which have recursive permission for a file
* *
* @param $arr_allow_cid * @param array $arr_allow_cid
* @param $arr_allow_gid * @param array $arr_allow_gid
* @param $arr_deny_cid * @param array $arr_deny_cid
* @param $arr_deny_gid * @param array $arr_deny_gid
* @param $folder_hash * @param string $folder_hash
*/ */
function recursive_activity_recipients($arr_allow_cid, $arr_allow_gid, $arr_deny_cid, $arr_deny_gid, $folder_hash) { function recursive_activity_recipients($arr_allow_cid, $arr_allow_gid, $arr_deny_cid, $arr_deny_gid, $folder_hash) {
@ -1931,37 +1924,40 @@ function attach_export_data($channel, $resource_id, $deleted = false) {
} }
return $ret; return $ret;
} }
/* strip off 'store/nickname/' from the provided path */ /**
* @brief Strip off 'store/nickname/' from the provided path
*
* @param string $s
* @return string
*/
function get_attach_binname($s) { function get_attach_binname($s) {
$p = $s; $p = $s;
if(strpos($s,'store/') === 0) { if(strpos($s, 'store/') === 0) {
$p = substr($s,6); $p = substr($s, 6);
$p = substr($p,strpos($p,'/')+1); $p = substr($p, strpos($p, '/')+1);
} }
return $p; return $p;
} }
function get_dirpath_by_cloudpath($channel, $path) { function get_dirpath_by_cloudpath($channel, $path) {
$path = notags(trim($path));
$path = notags(trim($path));
$h = @parse_url($path); $h = @parse_url($path);
if(! $h || !x($h, 'path')) { if(! $h || !x($h, 'path')) {
return null; return null;
} }
if(substr($h['path'],-1,1) === '/') { if(substr($h['path'], -1, 1) === '/') {
$h['path'] = substr($h['path'],0,-1); $h['path'] = substr($h['path'], 0, -1);
} }
if(substr($h['path'],0,1) === '/') { if(substr($h['path'],0,1) === '/') {
$h['path'] = substr($h['path'],1); $h['path'] = substr($h['path'], 1);
} }
$folders = explode('/', $h['path']); $folders = explode('/', $h['path']);
$f = array_shift($folders); $f = array_shift($folders);
@ -1998,8 +1994,6 @@ function get_dirpath_by_cloudpath($channel, $path) {
} else { } else {
return $clouddir . $subdir; return $clouddir . $subdir;
} }
} }
function get_filename_by_cloudname($cloudname, $channel, $storepath) { function get_filename_by_cloudname($cloudname, $channel, $storepath) {
@ -2013,54 +2007,58 @@ function get_filename_by_cloudname($cloudname, $channel, $storepath) {
return null; return null;
} }
/**
// recursively copy a directory into cloud files * @brief recursively copy a directory into cloud files
function copy_folder_to_cloudfiles($channel, $observer_hash, $srcpath, $cloudpath) *
{ * @param array $channel
if (!is_dir($srcpath) || !is_readable($srcpath)) { * @param string $observer_hash
logger('Error reading source path: ' . $srcpath, LOGGER_NORMAL); * @param string $srcpath
* @param string $cloudpath
* @return boolean
*/
function copy_folder_to_cloudfiles($channel, $observer_hash, $srcpath, $cloudpath) {
if (!is_dir($srcpath) || !is_readable($srcpath)) {
logger('Error reading source path: ' . $srcpath, LOGGER_NORMAL);
return false;
}
$nodes = array_diff(scandir($srcpath), array('.', '..'));
foreach ($nodes as $node) {
$clouddir = $cloudpath . '/' . $node; // Sub-folder in cloud files destination
$nodepath = $srcpath . '/' . $node; // Sub-folder in source path
if(is_dir($nodepath)) {
$x = attach_mkdirp($channel, $observer_hash, array('pathname' => $clouddir));
if(!$x['success']) {
logger('Error creating cloud path: ' . $clouddir, LOGGER_NORMAL);
return false; return false;
}
// Recursively call this function where the source and destination are the subfolders
$success = copy_folder_to_cloudfiles($channel, $observer_hash, $nodepath, $clouddir);
if(!$success) {
logger('Error copying contents of folder: ' . $nodepath, LOGGER_NORMAL);
return false;
}
} elseif(is_file($nodepath) && is_readable($nodepath)) {
$x = attach_store($channel, $observer_hash, 'import', array(
'directory' => $cloudpath,
'src' => $nodepath,
'filename' => $node,
'filesize' => @filesize($nodepath),
'preserve_original' => true
));
if(!$x['success']) {
logger('Error copying file: ' . $nodepath, LOGGER_NORMAL);
logger('Return value: ' . json_encode($x), LOGGER_NORMAL);
return false;
}
} else {
logger('Error scanning source path', LOGGER_NORMAL);
return false;
} }
$nodes = array_diff(scandir($srcpath), array('.', '..')); }
foreach ($nodes as $node) {
$clouddir = $cloudpath . '/' . $node; // Sub-folder in cloud files destination
$nodepath = $srcpath . '/' . $node; // Sub-folder in source path
if(is_dir($nodepath)) {
$x = attach_mkdirp($channel, $observer_hash, array('pathname' => $clouddir));
if(!$x['success']) {
logger('Error creating cloud path: ' . $clouddir, LOGGER_NORMAL);
return false;
}
// Recursively call this function where the source and destination are the subfolders
$success = copy_folder_to_cloudfiles($channel, $observer_hash, $nodepath, $clouddir);
if(!$success) {
logger('Error copying contents of folder: ' . $nodepath, LOGGER_NORMAL);
return false;
}
} elseif (is_file($nodepath) && is_readable($nodepath)) {
$x = attach_store($channel, $observer_hash, 'import',
array(
'directory' => $cloudpath,
'src' => $nodepath,
'filename' => $node,
'filesize' => @filesize($nodepath),
'preserve_original' => true)
);
if(!$x['success']) {
logger('Error copying file: ' . $nodepath , LOGGER_NORMAL);
logger('Return value: ' . json_encode($x), LOGGER_NORMAL);
return false;
}
} else {
logger('Error scanning source path', LOGGER_NORMAL);
return false;
}
}
return true; return true;
} }
/** /**
* attach_move()
* This function performs an in place directory-to-directory move of a stored attachment or photo. * This function performs an in place directory-to-directory move of a stored attachment or photo.
* The data is physically moved in the store/nickname storage location and the paths adjusted * The data is physically moved in the store/nickname storage location and the paths adjusted
* in the attach structure (and if applicable the photo table). The new 'album name' is recorded * in the attach structure (and if applicable the photo table). The new 'album name' is recorded
@ -2070,9 +2068,13 @@ function copy_folder_to_cloudfiles($channel, $observer_hash, $srcpath, $cloudpat
* the file is relocated to the root of the channel's storage area. * the file is relocated to the root of the channel's storage area.
* *
* @fixme: this operation is currently not synced to clones !! * @fixme: this operation is currently not synced to clones !!
*
* @param int $channel_id
* @param int $resource_id
* @param string $new_folder_hash
* @return void|boolean
*/ */
function attach_move($channel_id, $resource_id, $new_folder_hash) {
function attach_move($channel_id,$resource_id,$new_folder_hash) {
$c = channelx_by_n($channel_id); $c = channelx_by_n($channel_id);
if(! $c) if(! $c)
@ -2094,6 +2096,7 @@ function attach_move($channel_id,$resource_id,$new_folder_hash) {
); );
if(! $n) if(! $n)
return; return;
$newdirname = $n[0]['filename']; $newdirname = $n[0]['filename'];
$newstorepath = $n[0]['content'] . '/' . $resource_id; $newstorepath = $n[0]['content'] . '/' . $resource_id;
} }
@ -2115,7 +2118,7 @@ function attach_move($channel_id,$resource_id,$new_folder_hash) {
if($s) { if($s) {
$overwrite = get_pconfig($channel_id,'system','overwrite_dup_files'); $overwrite = get_pconfig($channel_id,'system','overwrite_dup_files');
if($overwrite) { if($overwrite) {
// @fixme /// @fixme
return; return;
} }
else { else {
@ -2179,7 +2182,6 @@ function attach_move($channel_id,$resource_id,$new_folder_hash) {
} }
return true; return true;
} }
@ -2199,6 +2201,7 @@ function attach_folder_select_list($channel_id) {
$out[$x[0]] = $x[1]; $out[$x[0]] = $x[1];
} }
} }
return $out; return $out;
} }
@ -2228,6 +2231,6 @@ function attach_folder_rpaths($all_folders,$that_folder) {
} }
while((! $found) && (! $error) && ($parent_hash != '')); while((! $found) && (! $error) && ($parent_hash != ''));
} }
return (($error) ? false : [ $current_hash , $path ]);
return (($error) ? false : [ $current_hash , $path ]);
} }

View File

@ -578,7 +578,6 @@ function identity_basic_export($channel_id, $items = false) {
if($r) if($r)
$ret['term'] = $r; $ret['term'] = $r;
// add psuedo-column obj_baseurl to aid in relocations // add psuedo-column obj_baseurl to aid in relocations
$r = q("select obj.*, '%s' as obj_baseurl from obj where obj_channel = %d", $r = q("select obj.*, '%s' as obj_baseurl from obj where obj_channel = %d",
@ -608,7 +607,6 @@ function identity_basic_export($channel_id, $items = false) {
if($r) if($r)
$ret['chatroom'] = $r; $ret['chatroom'] = $r;
$r = q("select * from event where uid = %d", $r = q("select * from event where uid = %d",
intval($channel_id) intval($channel_id)
); );
@ -636,12 +634,10 @@ function identity_basic_export($channel_id, $items = false) {
} }
} }
$addon = array('channel_id' => $channel_id,'data' => $ret); $addon = array('channel_id' => $channel_id,'data' => $ret);
call_hooks('identity_basic_export',$addon); call_hooks('identity_basic_export',$addon);
$ret = $addon['data']; $ret = $addon['data'];
if(! $items) if(! $items)
return $ret; return $ret;
@ -663,7 +659,6 @@ function identity_basic_export($channel_id, $items = false) {
$ret['conv'] = $r; $ret['conv'] = $r;
} }
$r = q("select * from mail where mail.uid = %d", $r = q("select * from mail where mail.uid = %d",
intval($channel_id) intval($channel_id)
); );
@ -745,16 +740,24 @@ function identity_export_year($channel_id,$year,$month = 0) {
return $ret; return $ret;
} }
// export items within an arbitrary date range. Date/time is in UTC. /**
* @brief Export items within an arbitrary date range.
function channel_export_items($channel_id,$start,$finish) { *
* Date/time is in UTC.
*
* @param int $channel_id The channel ID
* @param string $start
* @param string $finish
* @return array
*/
function channel_export_items($channel_id, $start, $finish) {
if(! $start) if(! $start)
return array(); return array();
else else
$start = datetime_convert('UTC','UTC',$start); $start = datetime_convert('UTC', 'UTC', $start);
$finish = datetime_convert('UTC','UTC',(($finish) ? $finish : 'now')); $finish = datetime_convert('UTC', 'UTC', (($finish) ? $finish : 'now'));
if($finish < $start) if($finish < $start)
return array(); return array();
@ -775,9 +778,9 @@ function channel_export_items($channel_id,$start,$finish) {
if($r) { if($r) {
$ret['item'] = array(); $ret['item'] = array();
xchan_query($r); xchan_query($r);
$r = fetch_post_tags($r,true); $r = fetch_post_tags($r, true);
foreach($r as $rr) foreach($r as $rr)
$ret['item'][] = encode_item($rr,true); $ret['item'][] = encode_item($rr, true);
} }
return $ret; return $ret;
@ -866,7 +869,6 @@ function profile_load($nickname, $profile = '') {
intval($p[0]['profile_uid']) intval($p[0]['profile_uid'])
); );
if($q) { if($q) {
$extra_fields = array(); $extra_fields = array();
require_once('include/channel.php'); require_once('include/channel.php');
@ -985,7 +987,6 @@ function profile_edit_menu($uid) {
} }
return $ret; return $ret;
} }
/** /**
@ -997,6 +998,7 @@ function profile_edit_menu($uid) {
* @param array $profile * @param array $profile
* @param int $block * @param int $block
* @param boolean $show_connect * @param boolean $show_connect
* @param mixed $zcard
* *
* @return HTML string suitable for sidebar inclusion * @return HTML string suitable for sidebar inclusion
* Exceptions: Returns empty string if passed $profile is wrong type or not populated * Exceptions: Returns empty string if passed $profile is wrong type or not populated
@ -1163,7 +1165,6 @@ function advanced_profile(&$a) {
} }
$tpl = get_markup_template('profile_advanced.tpl'); $tpl = get_markup_template('profile_advanced.tpl');
$profile = array(); $profile = array();
@ -1403,7 +1404,8 @@ function zid($s,$address = '') {
$mine = get_my_url(); $mine = get_my_url();
$myaddr = (($address) ? $address : get_my_address()); $myaddr = (($address) ? $address : get_my_address());
/** @FIXME checking against our own channel url is no longer reliable. We may have a lot /**
* @FIXME checking against our own channel url is no longer reliable. We may have a lot
* of urls attached to out channel. Should probably match against our site, since we * of urls attached to out channel. Should probably match against our site, since we
* will not need to remote authenticate on our own site anyway. * will not need to remote authenticate on our own site anyway.
*/ */
@ -1633,18 +1635,18 @@ function notifications_off($channel_id) {
} }
function notifications_on($channel_id,$value) { function notifications_on($channel_id, $value) {
$x = q("update channel set channel_notifyflags = %d where channel_id = %d", $x = q("update channel set channel_notifyflags = %d where channel_id = %d",
intval($value), intval($value),
intval($channel_id) intval($channel_id)
); );
return $x; return $x;
} }
function get_channel_default_perms($uid) { function get_channel_default_perms($uid) {
$ret = []; $ret = [];
$r = q("select abook_xchan from abook where abook_channel = %d and abook_self = 1 limit 1", $r = q("select abook_xchan from abook where abook_channel = %d and abook_self = 1 limit 1",
@ -1666,7 +1668,6 @@ function get_channel_default_perms($uid) {
function profiles_build_sync($channel_id) { function profiles_build_sync($channel_id) {
$r = q("select * from profile where uid = %d", $r = q("select * from profile where uid = %d",
intval($channel_id) intval($channel_id)
); );
@ -1713,7 +1714,6 @@ function auto_channel_create($account_id) {
$arr['nickname'] = check_webbie(array($arr['nickname'], $arr['nickname'] . mt_rand(1000,9999))); $arr['nickname'] = check_webbie(array($arr['nickname'], $arr['nickname'] . mt_rand(1000,9999)));
return create_identity($arr); return create_identity($arr);
} }
function get_cover_photo($channel_id,$format = 'bbcode', $res = PHOTO_RES_COVER_1200) { function get_cover_photo($channel_id,$format = 'bbcode', $res = PHOTO_RES_COVER_1200) {
@ -1749,17 +1749,23 @@ function get_cover_photo($channel_id,$format = 'bbcode', $res = PHOTO_RES_COVER_
} }
return $output; return $output;
} }
function get_zcard($channel,$observer_hash = '',$args = array()) { /**
* @brief
*
* @param array $channel
* @param string $observer_hash
* @param array $args
* @return string
*/
function get_zcard($channel, $observer_hash = '', $args = array()) {
logger('get_zcard'); logger('get_zcard');
$maxwidth = (($args['width']) ? intval($args['width']) : 0); $maxwidth = (($args['width']) ? intval($args['width']) : 0);
$maxheight = (($args['height']) ? intval($args['height']) : 0); $maxheight = (($args['height']) ? intval($args['height']) : 0);
if(($maxwidth > 1200) || ($maxwidth < 1)) if(($maxwidth > 1200) || ($maxwidth < 1))
$maxwidth = 1200; $maxwidth = 1200;
@ -1767,25 +1773,22 @@ function get_zcard($channel,$observer_hash = '',$args = array()) {
$width = 425; $width = 425;
$size = 'hz_small'; $size = 'hz_small';
$cover_size = PHOTO_RES_COVER_425; $cover_size = PHOTO_RES_COVER_425;
$pphoto = array('mimetype' => $channel['xchan_photo_mimetype'], 'width' => 80 , 'height' => 80, 'href' => $channel['xchan_photo_m']); $pphoto = array('mimetype' => $channel['xchan_photo_mimetype'], 'width' => 80 , 'height' => 80, 'href' => $channel['xchan_photo_m']);
} } elseif($maxwidth <= 900) {
elseif($maxwidth <= 900) {
$width = 900; $width = 900;
$size = 'hz_medium'; $size = 'hz_medium';
$cover_size = PHOTO_RES_COVER_850; $cover_size = PHOTO_RES_COVER_850;
$pphoto = array('mimetype' => $channel['xchan_photo_mimetype'], 'width' => 160 , 'height' => 160, 'href' => $channel['xchan_photo_l']); $pphoto = array('mimetype' => $channel['xchan_photo_mimetype'], 'width' => 160 , 'height' => 160, 'href' => $channel['xchan_photo_l']);
} } elseif($maxwidth <= 1200) {
elseif($maxwidth <= 1200) {
$width = 1200; $width = 1200;
$size = 'hz_large'; $size = 'hz_large';
$cover_size = PHOTO_RES_COVER_1200; $cover_size = PHOTO_RES_COVER_1200;
$pphoto = array('mimetype' => $channel['xchan_photo_mimetype'], 'width' => 300 , 'height' => 300, 'href' => $channel['xchan_photo_l']); $pphoto = array('mimetype' => $channel['xchan_photo_mimetype'], 'width' => 300 , 'height' => 300, 'href' => $channel['xchan_photo_l']);
} }
// $scale = (float) $maxwidth / $width; // $scale = (float) $maxwidth / $width;
// $translate = intval(($scale / 1.0) * 100); // $translate = intval(($scale / 1.0) * 100);
$channel['channel_addr'] = channel_reddress($channel); $channel['channel_addr'] = channel_reddress($channel);
$zcard = array('chan' => $channel); $zcard = array('chan' => $channel);
@ -1798,12 +1801,11 @@ function get_zcard($channel,$observer_hash = '',$args = array()) {
if($r) { if($r) {
$cover = $r[0]; $cover = $r[0];
$cover['href'] = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $r[0]['imgscale']; $cover['href'] = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $r[0]['imgscale'];
} } else {
else {
$cover = $pphoto; $cover = $pphoto;
} }
$o .= replace_macros(get_markup_template('zcard.tpl'),array( $o .= replace_macros(get_markup_template('zcard.tpl'), array(
'$maxwidth' => $maxwidth, '$maxwidth' => $maxwidth,
'$scale' => $scale, '$scale' => $scale,
'$translate' => $translate, '$translate' => $translate,
@ -1814,18 +1816,16 @@ function get_zcard($channel,$observer_hash = '',$args = array()) {
)); ));
return $o; return $o;
} }
function get_zcard_embed($channel,$observer_hash = '',$args = array()) { function get_zcard_embed($channel, $observer_hash = '', $args = array()) {
logger('get_zcard_embed'); logger('get_zcard_embed');
$maxwidth = (($args['width']) ? intval($args['width']) : 0); $maxwidth = (($args['width']) ? intval($args['width']) : 0);
$maxheight = (($args['height']) ? intval($args['height']) : 0); $maxheight = (($args['height']) ? intval($args['height']) : 0);
if(($maxwidth > 1200) || ($maxwidth < 1)) if(($maxwidth > 1200) || ($maxwidth < 1))
$maxwidth = 1200; $maxwidth = 1200;
@ -1860,8 +1860,7 @@ function get_zcard_embed($channel,$observer_hash = '',$args = array()) {
if($r) { if($r) {
$cover = $r[0]; $cover = $r[0];
$cover['href'] = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $r[0]['imgscale']; $cover['href'] = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $r[0]['imgscale'];
} } else {
else {
$cover = $pphoto; $cover = $pphoto;
} }
@ -1876,33 +1875,59 @@ function get_zcard_embed($channel,$observer_hash = '',$args = array()) {
)); ));
return $o; return $o;
} }
/**
* @brief
*
* @param string $nick
* @return mixed
*/
function channelx_by_nick($nick) { function channelx_by_nick($nick) {
$r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_address = '%s' and channel_removed = 0 LIMIT 1", $r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_address = '%s' and channel_removed = 0 LIMIT 1",
dbesc($nick) dbesc($nick)
); );
return(($r) ? $r[0] : false); return(($r) ? $r[0] : false);
} }
/**
* @brief
*
* @param string $hash
* @return mixed
*/
function channelx_by_hash($hash) { function channelx_by_hash($hash) {
$r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_hash = '%s' and channel_removed = 0 LIMIT 1", $r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_hash = '%s' and channel_removed = 0 LIMIT 1",
dbesc($hash) dbesc($hash)
); );
return(($r) ? $r[0] : false); return(($r) ? $r[0] : false);
} }
/**
* @brief
*
* @param int $id
* @return mixed
*/
function channelx_by_n($id) { function channelx_by_n($id) {
$r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_id = %d and channel_removed = 0 LIMIT 1", $r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_id = %d and channel_removed = 0 LIMIT 1",
dbesc($id) dbesc($id)
); );
return(($r) ? $r[0] : false); return(($r) ? $r[0] : false);
} }
/**
* @brief
*
* @param string $channel
* @return string
*/
function channel_reddress($channel) { function channel_reddress($channel) {
if(! ($channel && array_key_exists('channel_address',$channel))) if(! ($channel && array_key_exists('channel_address', $channel)))
return ''; return '';
return strtolower($channel['channel_address'] . '@' . App::get_hostname()); return strtolower($channel['channel_address'] . '@' . App::get_hostname());
} }

View File

@ -1,5 +1,4 @@
<?php <?php
/** /**
* @file include/config.php * @file include/config.php
* @brief Arbitrary configuration storage. * @brief Arbitrary configuration storage.
@ -7,7 +6,6 @@
* Arrays get stored as serialized strings. * Arrays get stored as serialized strings.
* Booleans are stored as integer 0/1. * Booleans are stored as integer 0/1.
* *
* - <b>config</b> is used for hub specific configurations. It overrides the * - <b>config</b> is used for hub specific configurations. It overrides the
* configurations from .htconfig file. The storage is of size TEXT. * configurations from .htconfig file. The storage is of size TEXT.
* - <b>pconfig</b> is used for channel specific configurations and takes a * - <b>pconfig</b> is used for channel specific configurations and takes a

View File

@ -195,7 +195,7 @@ function timesel($format, $h, $m, $id='timepicker') {
/** /**
* @brief Returns a datetime selector. * @brief Returns a datetime selector.
* *
* @param $format * @param string $format
* format string, e.g. 'ymd' or 'mdy'. Not currently supported * format string, e.g. 'ymd' or 'mdy'. Not currently supported
* @param $min * @param $min
* unix timestamp of minimum date * unix timestamp of minimum date
@ -203,6 +203,7 @@ function timesel($format, $h, $m, $id='timepicker') {
* unix timestap of maximum date * unix timestap of maximum date
* @param $default * @param $default
* unix timestamp of default date * unix timestamp of default date
* @param string $label
* @param string $id * @param string $id
* id and name of datetimepicker (defaults to "datetimepicker") * id and name of datetimepicker (defaults to "datetimepicker")
* @param boolean $pickdate * @param boolean $pickdate
@ -214,6 +215,7 @@ function timesel($format, $h, $m, $id='timepicker') {
* @param $maxfrom * @param $maxfrom
* set maximum date from picker with id $maxfrom (none by default) * set maximum date from picker with id $maxfrom (none by default)
* @param boolean $required default false * @param boolean $required default false
* @param int $first_day (optional) default 0
* @return string Parsed HTML output. * @return string Parsed HTML output.
* *
* @todo Once browser support is better this could probably be replaced with * @todo Once browser support is better this could probably be replaced with

View File

@ -1,5 +1,11 @@
<?php <?php
/**
* @brief
*
* @param string $tocpath
* @return string|unknown
*/
function get_help_content($tocpath = false) { function get_help_content($tocpath = false) {
global $lang; global $lang;
@ -56,7 +62,7 @@ function get_help_content($tocpath = false) {
header($_SERVER["SERVER_PROTOCOL"] . ' 404 ' . t('Not Found')); header($_SERVER["SERVER_PROTOCOL"] . ' 404 ' . t('Not Found'));
$tpl = get_markup_template("404.tpl"); $tpl = get_markup_template("404.tpl");
return replace_macros($tpl, array( return replace_macros($tpl, array(
'$message' => t('Page not found.' ) '$message' => t('Page not found.')
)); ));
} }
} }
@ -74,12 +80,12 @@ function get_help_content($tocpath = false) {
require_once('include/bbcode.php'); require_once('include/bbcode.php');
$content = bbcode($text); $content = bbcode($text);
// bbcode retargets external content to new windows. This content is internal. // bbcode retargets external content to new windows. This content is internal.
$content = str_replace(' target="_blank"','',$content); $content = str_replace(' target="_blank"', '', $content);
} }
$content = preg_replace_callback("/#include (.*?)\;/ism", 'preg_callback_help_include', $content); $content = preg_replace_callback("/#include (.*?)\;/ism", 'preg_callback_help_include', $content);
return translate_projectname($content);
return translate_projectname($content);
} }
function preg_callback_help_include($matches) { function preg_callback_help_include($matches) {
@ -125,6 +131,12 @@ function find_doc_file($s) {
return ''; return '';
} }
/**
* @brief
*
* @param string $s
* @return number|mixed|unknown|boolean
*/
function search_doc_files($s) { function search_doc_files($s) {
$itemspage = get_pconfig(local_channel(),'system','itemspage'); $itemspage = get_pconfig(local_channel(),'system','itemspage');
@ -140,14 +152,14 @@ function search_doc_files($s) {
intval(ITEM_TYPE_DOC) intval(ITEM_TYPE_DOC)
); );
$r = fetch_post_tags($r,true); $r = fetch_post_tags($r, true);
for($x = 0; $x < count($r); $x ++) { for($x = 0; $x < count($r); $x ++) {
$position = stripos($r[$x]['body'], $s); $position = stripos($r[$x]['body'], $s);
$dislen = 300; $dislen = 300;
$start = $position-floor($dislen/2); $start = $position-floor($dislen/2);
if ( $start < 0) { if ( $start < 0) {
$start = 0; $start = 0;
} }
$r[$x]['text'] = substr($r[$x]['body'], $start, $dislen); $r[$x]['text'] = substr($r[$x]['body'], $start, $dislen);
@ -159,26 +171,32 @@ function search_doc_files($s) {
} }
} }
} }
if(stristr($r[$x]['v'],$s)) if(stristr($r[$x]['v'], $s))
$r[$x]['rank'] ++; $r[$x]['rank'] ++;
$r[$x]['rank'] += substr_count(strtolower($r[$x]['text']),strtolower($s)); $r[$x]['rank'] += substr_count(strtolower($r[$x]['text']), strtolower($s));
// bias the results to the observer's native language // bias the results to the observer's native language
if($r[$x]['lang'] === \App::$language) if($r[$x]['lang'] === \App::$language)
$r[$x]['rank'] = $r[$x]['rank'] + 10; $r[$x]['rank'] = $r[$x]['rank'] + 10;
} }
usort($r,'doc_rank_sort'); usort($r,'doc_rank_sort');
return $r; return $r;
} }
function doc_rank_sort($s1,$s2) { function doc_rank_sort($s1, $s2) {
if($s1['rank'] == $s2['rank']) if($s1['rank'] == $s2['rank'])
return 0; return 0;
return (($s1['rank'] < $s2['rank']) ? 1 : (-1)); return (($s1['rank'] < $s2['rank']) ? 1 : (-1));
} }
/**
* @brief
*
* @return string
*/
function load_context_help() { function load_context_help() {
$path = App::$cmd; $path = App::$cmd;
@ -186,16 +204,17 @@ function load_context_help() {
$lang = App::$language; $lang = App::$language;
if(! isset($lang) || !is_dir('doc/context/' . $lang . '/')) { if(! isset($lang) || !is_dir('doc/context/' . $lang . '/')) {
$lang = 'en'; $lang = 'en';
} }
while($path) { while($path) {
$context_help = load_doc_file('doc/context/' . $lang . '/' . $path . '/help.html'); $context_help = load_doc_file('doc/context/' . $lang . '/' . $path . '/help.html');
if(!$context_help) { if(!$context_help) {
// Fallback to English if the translation is absent // Fallback to English if the translation is absent
$context_help = load_doc_file('doc/context/en/' . $path . '/help.html'); $context_help = load_doc_file('doc/context/en/' . $path . '/help.html');
} }
if($context_help) if($context_help)
break; break;
array_pop($args); array_pop($args);
$path = implode($args,'/'); $path = implode($args,'/');
} }
@ -203,7 +222,12 @@ function load_context_help() {
return $context_help; return $context_help;
} }
/**
* @brief
*
* @param string $s
* @return void|boolean[]|number[]|string[]|unknown[]
*/
function store_doc_file($s) { function store_doc_file($s) {
if(is_dir($s)) if(is_dir($s))
@ -215,10 +239,9 @@ function store_doc_file($s) {
$item['aid'] = 0; $item['aid'] = 0;
$item['uid'] = $sys['channel_id']; $item['uid'] = $sys['channel_id'];
if(strpos($s, '.md'))
if(strpos($s,'.md'))
$mimetype = 'text/markdown'; $mimetype = 'text/markdown';
elseif(strpos($s,'.html')) elseif(strpos($s, '.html'))
$mimetype = 'text/html'; $mimetype = 'text/html';
else else
$mimetype = 'text/bbcode'; $mimetype = 'text/bbcode';
@ -252,6 +275,4 @@ function store_doc_file($s) {
} }
return $x; return $x;
} }

View File

@ -3,9 +3,6 @@
* @file include/items.php * @file include/items.php
*/ */
// uncertain if this line is needed and why
use Sabre\HTTP\URLUtil;
use Zotlabs\Lib as Zlib; use Zotlabs\Lib as Zlib;
require_once('include/bbcode.php'); require_once('include/bbcode.php');
@ -66,6 +63,7 @@ function collect_recipients($item, &$private_envelope) {
if($recipients && $deny) if($recipients && $deny)
$recipients = array_diff($recipients,$deny); $recipients = array_diff($recipients,$deny);
$private_envelope = true; $private_envelope = true;
} }
else { else {
@ -132,7 +130,6 @@ function collect_recipients($item, &$private_envelope) {
} }
} }
} }
// This is a somewhat expensive operation but important. // This is a somewhat expensive operation but important.
@ -184,8 +181,8 @@ function item_normal() {
* This is a compatibility function primarily for plugins, because * This is a compatibility function primarily for plugins, because
* in earlier DB schemas this was a much simpler single integer compare * in earlier DB schemas this was a much simpler single integer compare
* *
* @param array $item
*/ */
function is_item_normal($item) { function is_item_normal($item) {
if(intval($item['item_hidden']) || intval($item['item_type']) || intval($item['item_deleted']) if(intval($item['item_hidden']) || intval($item['item_type']) || intval($item['item_deleted'])
@ -194,7 +191,6 @@ function is_item_normal($item) {
return false; return false;
return true; return true;
} }
/** /**
@ -495,10 +491,6 @@ function validate_item_elements($message,$arr) {
} }
/** /**
* @brief Limit lenght on imported system messages. * @brief Limit lenght on imported system messages.
* *
@ -652,7 +644,6 @@ function get_item_elements($x,$allow_code = false) {
if(mb_strlen($arr['title']) > 255) if(mb_strlen($arr['title']) > 255)
$arr['title'] = mb_substr($arr['title'],0,255); $arr['title'] = mb_substr($arr['title'],0,255);
$arr['app'] = (($x['app']) ? htmlspecialchars($x['app'], ENT_COMPAT,'UTF-8',false) : ''); $arr['app'] = (($x['app']) ? htmlspecialchars($x['app'], ENT_COMPAT,'UTF-8',false) : '');
$arr['route'] = (($x['route']) ? htmlspecialchars($x['route'], ENT_COMPAT,'UTF-8',false) : ''); $arr['route'] = (($x['route']) ? htmlspecialchars($x['route'], ENT_COMPAT,'UTF-8',false) : '');
$arr['mid'] = (($x['message_id']) ? htmlspecialchars($x['message_id'], ENT_COMPAT,'UTF-8',false) : ''); $arr['mid'] = (($x['message_id']) ? htmlspecialchars($x['message_id'], ENT_COMPAT,'UTF-8',false) : '');
@ -1057,7 +1048,6 @@ function encode_item($item,$mirror = false) {
$x['item_blocked'] = $item['item_blocked']; $x['item_blocked'] = $item['item_blocked'];
} }
$x['message_id'] = $item['mid']; $x['message_id'] = $item['mid'];
$x['message_top'] = $item['parent_mid']; $x['message_top'] = $item['parent_mid'];
$x['message_parent'] = $item['thr_parent']; $x['message_parent'] = $item['thr_parent'];
@ -1078,9 +1068,9 @@ function encode_item($item,$mirror = false) {
$x['longlat'] = $item['coord']; $x['longlat'] = $item['coord'];
$x['signature'] = $item['sig']; $x['signature'] = $item['sig'];
$x['route'] = $item['route']; $x['route'] = $item['route'];
$x['owner'] = encode_item_xchan($item['owner']); $x['owner'] = encode_item_xchan($item['owner']);
$x['author'] = encode_item_xchan($item['author']); $x['author'] = encode_item_xchan($item['author']);
if($item['obj']) if($item['obj'])
$x['object'] = json_decode($item['obj'],true); $x['object'] = json_decode($item['obj'],true);
if($item['target']) if($item['target'])
@ -1530,6 +1520,8 @@ function get_profile_elements($x) {
* *
* @param array $arr * @param array $arr
* @param boolean $allow_exec (optional) default false * @param boolean $allow_exec (optional) default false
* @param boolean $deliver (optional) default true
*
* @return array * @return array
* * \e boolean \b success * * \e boolean \b success
* * \e int \b item_id * * \e int \b item_id

View File

@ -30,7 +30,7 @@ function get_capath() {
* * \b filep => stream resource to write body to. header and body are not returned when using this option. * * \b filep => stream resource to write body to. header and body are not returned when using this option.
* * \b custom => custom request method: e.g. 'PUT', 'DELETE' * * \b custom => custom request method: e.g. 'PUT', 'DELETE'
* * \b cookiejar => cookie file (write) * * \b cookiejar => cookie file (write)
* * \B cookiefile => cookie file (read) * * \b cookiefile => cookie file (read)
* *
* @return array an associative array with: * @return array an associative array with:
* * \e int \b return_code => HTTP return code or 0 if timeout or failure * * \e int \b return_code => HTTP return code or 0 if timeout or failure

View File

@ -443,9 +443,12 @@ function photo_upload($channel, $observer, $args) {
* *
* @param array $channel * @param array $channel
* @param array $observer * @param array $observer
* @param array $sort_key (optional) default album
* @param array $direction (optional) default asc
*
* @return bool|array false if no view_storage permission or an array * @return bool|array false if no view_storage permission or an array
* * success (bool) * * \e boolean \b success
* * albums (array) * * \e array \b albums
*/ */
function photos_albums_list($channel, $observer, $sort_key = 'album', $direction = 'asc') { function photos_albums_list($channel, $observer, $sort_key = 'album', $direction = 'asc') {
@ -455,14 +458,11 @@ function photos_albums_list($channel, $observer, $sort_key = 'album', $direction
if(! perm_is_allowed($channel_id, $observer_xchan, 'view_storage')) if(! perm_is_allowed($channel_id, $observer_xchan, 'view_storage'))
return false; return false;
$sql_extra = permissions_sql($channel_id,$observer_xchan); $sql_extra = permissions_sql($channel_id,$observer_xchan);
$sort_key = dbesc($sort_key); $sort_key = dbesc($sort_key);
$direction = dbesc($direction); $direction = dbesc($direction);
$albums = q("SELECT count( distinct resource_id ) as total, album from photo where uid = %d and photo_usage IN ( %d, %d ) $sql_extra group by album order by $sort_key $direction", $albums = q("SELECT count( distinct resource_id ) as total, album from photo where uid = %d and photo_usage IN ( %d, %d ) $sql_extra group by album order by $sort_key $direction",
intval($channel_id), intval($channel_id),
intval(PHOTO_NORMAL), intval(PHOTO_NORMAL),

View File

@ -261,6 +261,8 @@ function load_hooks() {
* name of hook to attach callback * name of hook to attach callback
* @param string $fn * @param string $fn
* function name of callback handler * function name of callback handler
* @param int $version (optional) default 0
* @param int $priority (optional) default 0
*/ */
function insert_hook($hook, $fn, $version = 0, $priority = 0) { function insert_hook($hook, $fn, $version = 0, $priority = 0) {

View File

@ -2,11 +2,12 @@
/** /**
* @file include/security.php * @file include/security.php
* *
* Some security related functions. * @brief Some security related functions.
*/ */
/** /**
* @param int $user_record The account_id * @param int $user_record The account_id
* @param array $channel
* @param bool $login_initial default false * @param bool $login_initial default false
* @param bool $interactive default false * @param bool $interactive default false
* @param bool $return * @param bool $return
@ -89,15 +90,22 @@ function authenticate_success($user_record, $channel = null, $login_initial = fa
function atoken_login($atoken) { function atoken_login($atoken) {
if(! $atoken) if(! $atoken)
return false; return false;
$_SESSION['authenticated'] = 1; $_SESSION['authenticated'] = 1;
$_SESSION['visitor_id'] = $atoken['xchan_hash']; $_SESSION['visitor_id'] = $atoken['xchan_hash'];
$_SESSION['atoken'] = $atoken['atoken_id']; $_SESSION['atoken'] = $atoken['atoken_id'];
\App::set_observer($atoken); \App::set_observer($atoken);
return true; return true;
} }
/**
* @brief
*
* @param array $atoken
* @return array|null
*/
function atoken_xchan($atoken) { function atoken_xchan($atoken) {
$c = channelx_by_n($atoken['atoken_uid']); $c = channelx_by_n($atoken['atoken_uid']);
@ -114,9 +122,9 @@ function atoken_xchan($atoken) {
'xchan_photo_l' => get_default_profile_photo(300), 'xchan_photo_l' => get_default_profile_photo(300),
'xchan_photo_m' => get_default_profile_photo(80), 'xchan_photo_m' => get_default_profile_photo(80),
'xchan_photo_s' => get_default_profile_photo(48) 'xchan_photo_s' => get_default_profile_photo(48)
]; ];
} }
return null; return null;
} }
@ -145,12 +153,16 @@ function atoken_delete($atoken_id) {
); );
} }
/**
* @brief
// in order for atoken logins to create content (such as posts) they need a stored xchan. *
// we'll create one on the first atoken_login; it can't really ever go away but perhaps * In order for atoken logins to create content (such as posts) they need a stored xchan.
// @fixme we should set xchan_deleted if it's expired or removed * we'll create one on the first atoken_login; it can't really ever go away but perhaps
* @fixme we should set xchan_deleted if it's expired or removed
*
* @param array $xchan
* @return void|boolean
*/
function atoken_create_xchan($xchan) { function atoken_create_xchan($xchan) {
$r = q("select xchan_hash from xchan where xchan_hash = '%s'", $r = q("select xchan_hash from xchan where xchan_hash = '%s'",
@ -159,7 +171,7 @@ function atoken_create_xchan($xchan) {
if($r) if($r)
return; return;
$r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_addr, xchan_url, xchan_name, xchan_network, xchan_photo_mimetype, xchan_photo_l, xchan_photo_m, xchan_photo_s ) $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_addr, xchan_url, xchan_name, xchan_network, xchan_photo_mimetype, xchan_photo_l, xchan_photo_m, xchan_photo_s )
values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s') ", values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s') ",
dbesc($xchan['xchan_hash']), dbesc($xchan['xchan_hash']),
dbesc($xchan['xchan_hash']), dbesc($xchan['xchan_hash']),
@ -202,7 +214,6 @@ function atoken_abook($uid,$xchan_hash) {
} }
return false; return false;
} }
@ -216,8 +227,8 @@ function pseudo_abook($xchan) {
$xchan['abook_blocked'] = 0; $xchan['abook_blocked'] = 0;
$xchan['abook_ignored'] = 0; $xchan['abook_ignored'] = 0;
$xchan['abook_pending'] = 0; $xchan['abook_pending'] = 0;
return $xchan;
return $xchan;
} }
@ -228,7 +239,6 @@ function pseudo_abook($xchan) {
* *
* @return bool|array false or channel record of the new channel * @return bool|array false or channel record of the new channel
*/ */
function change_channel($change_channel) { function change_channel($change_channel) {
$ret = false; $ret = false;
@ -275,7 +285,6 @@ function change_channel($change_channel) {
$arr = [ 'channel_id' => $change_channel, 'chanx' => $ret ]; $arr = [ 'channel_id' => $change_channel, 'chanx' => $ret ];
call_hooks('change_channel', $arr); call_hooks('change_channel', $arr);
} }
return $ret; return $ret;
@ -285,11 +294,11 @@ function change_channel($change_channel) {
* @brief Creates an additional SQL where statement to check permissions. * @brief Creates an additional SQL where statement to check permissions.
* *
* @param int $owner_id * @param int $owner_id
* @param bool $remote_observer - if unset use current observer * @param bool $remote_observer (optional) use current observer if unset
* @param $table (optional)
* *
* @return string additional SQL where statement * @return string additional SQL where statement
*/ */
function permissions_sql($owner_id, $remote_observer = null, $table = '') { function permissions_sql($owner_id, $remote_observer = null, $table = '') {
$local_channel = local_channel(); $local_channel = local_channel();
@ -303,7 +312,6 @@ function permissions_sql($owner_id, $remote_observer = null, $table = '') {
if($table) if($table)
$table .= '.'; $table .= '.';
$sql = " AND {$table}allow_cid = '' $sql = " AND {$table}allow_cid = ''
AND {$table}allow_gid = '' AND {$table}allow_gid = ''
AND {$table}deny_cid = '' AND {$table}deny_cid = ''
@ -358,7 +366,7 @@ function permissions_sql($owner_id, $remote_observer = null, $table = '') {
* @brief Creates an addiontal SQL where statement to check permissions for an item. * @brief Creates an addiontal SQL where statement to check permissions for an item.
* *
* @param int $owner_id * @param int $owner_id
* @param bool $remote_observer, use current observer if unset * @param bool $remote_observer (optional) use current observer if unset
* *
* @return string additional SQL where statement * @return string additional SQL where statement
*/ */

View File

@ -17,6 +17,7 @@ define('RANDOM_STRING_TEXT', 0x01 );
* @param string|SmartyEngine $s the string requiring macro substitution, * @param string|SmartyEngine $s the string requiring macro substitution,
* or an instance of SmartyEngine * or an instance of SmartyEngine
* @param array $r key value pairs (search => replace) * @param array $r key value pairs (search => replace)
*
* @return string substituted string * @return string substituted string
*/ */
function replace_macros($s, $r) { function replace_macros($s, $r) {
@ -35,6 +36,7 @@ function replace_macros($s, $r) {
* *
* @param number $size * @param number $size
* @param int $type * @param int $type
*
* @return string * @return string
*/ */
function random_string($size = 64, $type = RANDOM_STRING_HEX) { function random_string($size = 64, $type = RANDOM_STRING_HEX) {
@ -60,6 +62,7 @@ function random_string($size = 64, $type = RANDOM_STRING_HEX) {
* if these are not allowed either. * if these are not allowed either.
* *
* @param string $string Input string * @param string $string Input string
*
* @return string Filtered string * @return string Filtered string
*/ */
function notags($string) { function notags($string) {
@ -74,13 +77,13 @@ function notags($string) {
/** /**
* use this on "body" or "content" input where angle chars shouldn't be removed, * use this on "body" or "content" input where angle chars shouldn't be removed,
* and allow them to be safely displayed. * and allow them to be safely displayed.
*
* @param string $string * @param string $string
*
* @return string * @return string
*/ */
function escape_tags($string) { function escape_tags($string) {
return(htmlspecialchars($string, ENT_COMPAT, 'UTF-8', false)); return(htmlspecialchars($string, ENT_COMPAT, 'UTF-8', false));
} }
@ -272,14 +275,12 @@ function purify_html($s, $allow_position = false) {
} }
$purifier = new HTMLPurifier($config); $purifier = new HTMLPurifier($config);
return $purifier->purify($s); return $purifier->purify($s);
} }
/** /**
* @brief generate a string that's random, but usually pronounceable. * @brief generate a string that's random, but usually pronounceable.
* *
@ -376,7 +377,6 @@ function xmlify($str) {
btlogger('xmlify called with array: ' . print_r($str,true), LOGGER_NORMAL, LOG_WARNING); btlogger('xmlify called with array: ' . print_r($str,true), LOGGER_NORMAL, LOG_WARNING);
} }
$len = mb_strlen($str); $len = mb_strlen($str);
for($x = 0; $x < $len; $x ++) { for($x = 0; $x < $len; $x ++) {
$char = mb_substr($str,$x,1); $char = mb_substr($str,$x,1);
@ -412,27 +412,36 @@ function xmlify($str) {
return($buffer); return($buffer);
} }
// undo an xmlify /**
// pass xml escaped text ($s), returns unescaped text * @brief Undo an xmlify.
*
* Pass xml escaped text ($s), returns unescaped text.
*
* @param string $s
*
* @return string
*/
function unxmlify($s) { function unxmlify($s) {
$ret = str_replace('&amp;','&', $s); $ret = str_replace('&amp;', '&', $s);
$ret = str_replace(array('&lt;','&gt;','&quot;','&apos;'),array('<','>','"',"'"),$ret); $ret = str_replace(array('&lt;', '&gt;', '&quot;', '&apos;'), array('<', '>', '"', "'"), $ret);
return $ret; return $ret;
} }
// Automatic pagination. /**
// To use, get the count of total items. * @brief Automatic pagination.
// Then call App::set_pager_total($number_items); *
// Optionally call App::set_pager_itemspage($n) to the number of items to display on each page * To use, get the count of total items.
// Then call paginate($a) after the end of the display loop to insert the pager block on the page * Then call App::set_pager_total($number_items);
// (assuming there are enough items to paginate). * Optionally call App::set_pager_itemspage($n) to the number of items to display on each page
// When using with SQL, the setting LIMIT %d, %d => App::$pager['start'],App::$pager['itemspage'] * Then call paginate($a) after the end of the display loop to insert the pager block on the page
// will limit the results to the correct items for the current page. * (assuming there are enough items to paginate).
// The actual page handling is then accomplished at the application layer. * When using with SQL, the setting LIMIT %d, %d => App::$pager['start'],App::$pager['itemspage']
* will limit the results to the correct items for the current page.
* The actual page handling is then accomplished at the application layer.
*
* @param App &$a
*/
function paginate(&$a) { function paginate(&$a) {
$o = ''; $o = '';
$stripped = preg_replace('/(&page=[0-9]*)/','',App::$query_string); $stripped = preg_replace('/(&page=[0-9]*)/','',App::$query_string);
@ -451,15 +460,15 @@ function paginate(&$a) {
$o .= "<span class=\"pager_first\"><a href=\"$url"."&page=1\">" . t('first') . "</a></span> "; $o .= "<span class=\"pager_first\"><a href=\"$url"."&page=1\">" . t('first') . "</a></span> ";
$numpages = App::$pager['total'] / App::$pager['itemspage']; $numpages = App::$pager['total'] / App::$pager['itemspage'];
$numstart = 1; $numstart = 1;
$numstop = $numpages; $numstop = $numpages;
if($numpages > 14) { if($numpages > 14) {
$numstart = (($pagenum > 7) ? ($pagenum - 7) : 1); $numstart = (($pagenum > 7) ? ($pagenum - 7) : 1);
$numstop = (($pagenum > ($numpages - 7)) ? $numpages : ($numstart + 14)); $numstop = (($pagenum > ($numpages - 7)) ? $numpages : ($numstart + 14));
} }
for($i = $numstart; $i <= $numstop; $i++){ for($i = $numstart; $i <= $numstop; $i++){
if($i == App::$pager['page']) if($i == App::$pager['page'])
@ -484,6 +493,7 @@ function paginate(&$a) {
$o .= '<span class="pager_next">'."<a href=\"$url"."&page=".(App::$pager['page'] + 1).'">' . t('next') . '</a></span>'; $o .= '<span class="pager_next">'."<a href=\"$url"."&page=".(App::$pager['page'] + 1).'">' . t('next') . '</a></span>';
$o .= '</div>'."\r\n"; $o .= '</div>'."\r\n";
} }
return $o; return $o;
} }
@ -514,7 +524,6 @@ function alt_pager(&$a, $i, $more = '', $less = '') {
} }
/** /**
* @brief Generate a guaranteed unique (for this domain) item ID for ATOM. * @brief Generate a guaranteed unique (for this domain) item ID for ATOM.
* *
@ -558,17 +567,23 @@ function photo_new_resource() {
return $resource; return $resource;
} }
/**
* @brief
// for html,xml parsing - let's say you've got *
// an attribute foobar="class1 class2 class3" * for html,xml parsing - let's say you've got
// and you want to find out if it contains 'class3'. * an attribute foobar="class1 class2 class3"
// you can't use a normal sub string search because you * and you want to find out if it contains 'class3'.
// might match 'notclass3' and a regex to do the job is * you can't use a normal sub string search because you
// possible but a bit complicated. * might match 'notclass3' and a regex to do the job is
// pass the attribute string as $attr and the attribute you * possible but a bit complicated.
// are looking for as $s - returns true if found, otherwise false *
* pass the attribute string as $attr and the attribute you
* are looking for as $s - returns true if found, otherwise false
*
* @param string $attr attribute string
* @param string $s attribute you are looking for
* @return boolean true if found
*/
function attribute_contains($attr, $s) { function attribute_contains($attr, $s) {
$a = explode(' ', $attr); $a = explode(' ', $attr);
if(count($a) && in_array($s, $a)) if(count($a) && in_array($s, $a))
@ -591,10 +606,9 @@ function attribute_contains($attr, $s) {
* was called, so no need to add it to the message anymore. * was called, so no need to add it to the message anymore.
* *
* @param string $msg Message to log * @param string $msg Message to log
* @param int $level A log level. * @param int $level A log level
* @param int $priority - compatible with syslog * @param int $priority - compatible with syslog
*/ */
function logger($msg, $level = LOGGER_NORMAL, $priority = LOG_INFO) { function logger($msg, $level = LOGGER_NORMAL, $priority = LOG_INFO) {
if(App::$module == 'setup' && is_writable('install.log')) { if(App::$module == 'setup' && is_writable('install.log')) {
@ -630,19 +644,23 @@ function logger($msg, $level = LOGGER_NORMAL, $priority = LOG_INFO) {
@file_put_contents($pluginfo['filename'], $pluginfo['message'], FILE_APPEND); @file_put_contents($pluginfo['filename'], $pluginfo['message'], FILE_APPEND);
} }
// like logger() but with a function backtrace to pinpoint certain classes /**
// of problems which show up deep in the calling stack * @brief like logger() but with a function backtrace to pinpoint certain classes
* of problems which show up deep in the calling stack.
*
* @param string $msg Message to log
* @param int $level A log level
* @param int $priority - compatible with syslog
*/
function btlogger($msg, $level = LOGGER_NORMAL, $priority = LOG_INFO) { function btlogger($msg, $level = LOGGER_NORMAL, $priority = LOG_INFO) {
logger($msg, $level, $priority); logger($msg, $level, $priority);
if(version_compare(PHP_VERSION, '5.4.0') >= 0) { if(version_compare(PHP_VERSION, '5.4.0') >= 0) {
$stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); $stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
if($stack) { if($stack) {
for($x = 1; $x < count($stack); $x ++) { for($x = 1; $x < count($stack); $x ++) {
logger('stack: ' . basename($stack[$x]['file']) . ':' . $stack[$x]['line'] . ':' . $stack[$x]['function'] . '()',$level, $priority); logger('stack: ' . basename($stack[$x]['file']) . ':' . $stack[$x]['line'] . ':' . $stack[$x]['function'] . '()',$level, $priority);
} }
} }
} }
} }
@ -718,15 +736,17 @@ function activity_match($haystack,$needle) {
return false; return false;
} }
/**
// Pull out all #hashtags and @person tags from $s; * @brief Pull out all #hashtags and @person tags from $s.
// We also get @person@domain.com - which would make *
// the regex quite complicated as tags can also * We also get @person@domain.com - which would make
// end a sentence. So we'll run through our results * the regex quite complicated as tags can also
// and strip the period from any tags which end with one. * end a sentence. So we'll run through our results
// Returns array of tags found, or empty array. * and strip the period from any tags which end with one.
*
* @param string $s
* @return Returns array of tags found, or empty array.
*/
function get_tags($s) { function get_tags($s) {
$ret = array(); $ret = array();
$match = array(); $match = array();
@ -824,12 +844,14 @@ function strip_zats($s) {
return preg_replace('/[\?&]zat=(.*?)(&|$)/ism','$2',$s); return preg_replace('/[\?&]zat=(.*?)(&|$)/ism','$2',$s);
} }
/**
// quick and dirty quoted_printable encoding * @brief Quick and dirty quoted_printable encoding.
*
* @param string $s
* @return string
*/
function qp($s) { function qp($s) {
return str_replace ("%","=",rawurlencode($s)); return str_replace ("%", "=", rawurlencode($s));
} }
@ -1105,8 +1127,11 @@ function get_mood_verbs() {
return $arr; return $arr;
} }
// Function to list all smilies, both internal and from addons /**
// Returns array with keys 'texts' and 'icons' * @brief Function to list all smilies, both internal and from addons.
*
* @return Returns array with keys 'texts' and 'icons'
*/
function list_smilies() { function list_smilies() {
$texts = array( $texts = array(
@ -1602,7 +1627,9 @@ function prepare_body(&$item,$attach = false) {
* @brief Given a text string, convert from bbcode to html and add smilie icons. * @brief Given a text string, convert from bbcode to html and add smilie icons.
* *
* @param string $text * @param string $text
* @param sting $content_type * @param sting $content_type (optional) default text/bbcode
* @param boolean $cache (optional) default false
*
* @return string * @return string
*/ */
function prepare_text($text, $content_type = 'text/bbcode', $cache = false) { function prepare_text($text, $content_type = 'text/bbcode', $cache = false) {
@ -1621,7 +1648,6 @@ function prepare_text($text, $content_type = 'text/bbcode', $cache = false) {
$s = Markdown($text); $s = Markdown($text);
break; break;
case 'application/x-pdl'; case 'application/x-pdl';
$s = escape_tags($text); $s = escape_tags($text);
break; break;
@ -1735,8 +1761,12 @@ function feed_hublinks() {
return $hubxml; return $hubxml;
} }
/* return atom link elements for salmon endpoints */ /**
* @brief Return atom link elements for salmon endpoints
*
* @param string $nick
* @return string
*/
function feed_salmonlinks($nick) { function feed_salmonlinks($nick) {
$salmon = '<link rel="salmon" href="' . xmlify(z_root() . '/salmon/' . $nick) . '" />' . "\n" ; $salmon = '<link rel="salmon" href="' . xmlify(z_root() . '/salmon/' . $nick) . '" />' . "\n" ;
@ -1886,9 +1916,8 @@ function base64special_decode($s) {
return base64_decode(strtr($s,',.','+/')); return base64_decode(strtr($s,',.','+/'));
} }
/** /**
* @ Return a div to clear floats. * @brief Return a div to clear floats.
* *
* @return string * @return string
*/ */
@ -2087,11 +2116,18 @@ function ids_to_querystr($arr,$idx = 'id') {
return(implode(',', $t)); return(implode(',', $t));
} }
// Fetches xchan and hubloc data for an array of items with only an /**
// author_xchan and owner_xchan. If $abook is true also include the abook info. * @brief Fetches xchan and hubloc data for an array of items with only an
// This is needed in the API to save extra per item lookups there. * author_xchan and owner_xchan.
*
function xchan_query(&$items,$abook = true,$effective_uid = 0) { * If $abook is true also include the abook info. This is needed in the API to
* save extra per item lookups there.
*
* @param array[in,out] &$items
* @param boolean $abook If true also include the abook info
* @param number $effective_uid
*/
function xchan_query(&$items, $abook = true, $effective_uid = 0) {
$arr = array(); $arr = array();
if($items && count($items)) { if($items && count($items)) {
@ -2182,15 +2218,19 @@ function magic_link($s) {
return $s; return $s;
} }
// if $escape is true, dbesc() each element before adding quotes /**
* if $escape is true, dbesc() each element before adding quotes
function stringify_array_elms(&$arr,$escape = false) { *
* @param array[in,out] &$arr
* @param boolean $escape default false
*/
function stringify_array_elms(&$arr, $escape = false) {
for($x = 0; $x < count($arr); $x ++) for($x = 0; $x < count($arr); $x ++)
$arr[$x] = "'" . (($escape) ? dbesc($arr[$x]) : $arr[$x]) . "'"; $arr[$x] = "'" . (($escape) ? dbesc($arr[$x]) : $arr[$x]) . "'";
} }
/** /**
* Indents a flat JSON string to make it more human-readable. * @brief Indents a flat JSON string to make it more human-readable.
* *
* @param string $json The original JSON string to process. * @param string $json The original JSON string to process.
* *
@ -2249,9 +2289,8 @@ function jindent($json) {
/** /**
* @brief Creates navigation menu for webpage, layout, blocks, menu sites. * @brief Creates navigation menu for webpage, layout, blocks, menu sites.
* *
* @return string * @return string with parsed HTML
*/ */
function design_tools() { function design_tools() {
$channel = App::get_channel(); $channel = App::get_channel();
@ -2312,8 +2351,13 @@ function website_portation_tools() {
)); ));
} }
/* case insensitive in_array() */ /**
* @brief case insensitive in_array()
*
* @param string $needle
* @param array $haystack
* @return boolean
*/
function in_arrayi($needle, $haystack) { function in_arrayi($needle, $haystack) {
return in_array(strtolower($needle), array_map('strtolower', $haystack)); return in_array(strtolower($needle), array_map('strtolower', $haystack));
} }
@ -2322,10 +2366,13 @@ function normalise_openid($s) {
return trim(str_replace(array('http://','https://'),array('',''),$s),'/'); return trim(str_replace(array('http://','https://'),array('',''),$s),'/');
} }
// used in ajax endless scroll request to find out all the args that the master page was viewing. /**
// This was using $_REQUEST, but $_REQUEST also contains all your cookies. So we're restricting it * Used in ajax endless scroll request to find out all the args that the master page was viewing.
// to $_GET and $_POST. * This was using $_REQUEST, but $_REQUEST also contains all your cookies. So we're restricting it
* to $_GET and $_POST.
*
* @return string with additional URL parameters
*/
function extra_query_args() { function extra_query_args() {
$s = ''; $s = '';
if(count($_GET)) { if(count($_GET)) {
@ -2344,6 +2391,7 @@ function extra_query_args() {
} }
} }
} }
return $s; return $s;
} }
@ -2841,7 +2889,6 @@ function perms2str($p) {
return $ret; return $ret;
} }
/** /**
* @brief Turn user/group ACLs stored as angle bracketed text into arrays. * @brief Turn user/group ACLs stored as angle bracketed text into arrays.
* *
@ -2869,24 +2916,30 @@ function expand_acl($s) {
function acl2json($s) { function acl2json($s) {
$s = expand_acl($s); $s = expand_acl($s);
$s = json_encode($s); $s = json_encode($s);
return $s; return $s;
} }
/**
// When editing a webpage - a dropdown is needed to select a page layout * @brief When editing a webpage - a dropdown is needed to select a page layout
// On submit, the pdl_select value (which is the mid of an item with item_type = ITEM_TYPE_PDL) is stored in *
// the webpage's resource_id, with resource_type 'pdl'. * On submit, the pdl_select value (which is the mid of an item with item_type = ITEM_TYPE_PDL)
* is stored in the webpage's resource_id, with resource_type 'pdl'.
// Then when displaying a webpage, we can see if it has a pdl attached. If not we'll *
// use the default site/page layout. * Then when displaying a webpage, we can see if it has a pdl attached. If not we'll
* use the default site/page layout.
// If it has a pdl we'll load it as we know the mid and pass the body through comanche_parser() which will generate the *
// page layout from the given description * If it has a pdl we'll load it as we know the mid and pass the body through comanche_parser() which will generate the
* page layout from the given description
// @FIXME - there is apparently a very similar function called layout_select; this one should probably take precedence *
// and the other should be checked for compatibility and removed * @FIXME - there is apparently a very similar function called layout_select; this one should probably take precedence
* and the other should be checked for compatibility and removed
function pdl_selector($uid, $current="") { *
* @param int $uid
* @param string $current
* @return string HTML code for dropdown
*/
function pdl_selector($uid, $current='') {
$o = ''; $o = '';
$sql_extra = item_permissions_sql($uid); $sql_extra = item_permissions_sql($uid);
@ -2897,7 +2950,7 @@ function pdl_selector($uid, $current="") {
); );
$arr = array('channel_id' => $uid, 'current' => $current, 'entries' => $r); $arr = array('channel_id' => $uid, 'current' => $current, 'entries' => $r);
call_hooks('pdl_selector',$arr); call_hooks('pdl_selector', $arr);
$entries = $arr['entries']; $entries = $arr['entries'];
$current = $arr['current']; $current = $arr['current'];
@ -2913,16 +2966,17 @@ function pdl_selector($uid, $current="") {
return $o; return $o;
} }
/* /**
* array flatten_array_recursive(array); * @brief returns a one-dimensional array from a multi-dimensional array
* returns a one-dimensional array from a multi-dimensional array
* empty values are discarded * empty values are discarded
*
* example: print_r(flatten_array_recursive(array('foo','bar',array('baz','blip',array('zob','glob')),'','grip'))); * example: print_r(flatten_array_recursive(array('foo','bar',array('baz','blip',array('zob','glob')),'','grip')));
* *
* Array ( [0] => foo [1] => bar [2] => baz [3] => blip [4] => zob [5] => glob [6] => grip ) * Array ( [0] => foo [1] => bar [2] => baz [3] => blip [4] => zob [5] => glob [6] => grip )
* *
* @param array $arr multi-dimensional array
* @return one-dimensional array
*/ */
function flatten_array_recursive($arr) { function flatten_array_recursive($arr) {
$ret = array(); $ret = array();
@ -2933,64 +2987,71 @@ function flatten_array_recursive($arr) {
if(is_array($a)) { if(is_array($a)) {
$tmp = flatten_array_recursive($a); $tmp = flatten_array_recursive($a);
if($tmp) { if($tmp) {
$ret = array_merge($ret,$tmp); $ret = array_merge($ret, $tmp);
} }
} }
elseif($a) { elseif($a) {
$ret[] = $a; $ret[] = $a;
} }
} }
return($ret); return($ret);
} }
function text_highlight($s,$lang) { /**
* @brief Highlight Text.
*
* @param string $s Text to highlight
* @param string $lang Which language should be highlighted
* @return string
*/
function text_highlight($s, $lang) {
if($lang === 'js') if($lang === 'js')
$lang = 'javascript'; $lang = 'javascript';
if($lang === 'json') { if($lang === 'json') {
$lang = 'javascript'; $lang = 'javascript';
if(! strpos(trim($s),"\n")) if(! strpos(trim($s), "\n"))
$s = jindent($s); $s = jindent($s);
} }
if(! strpos('Text_Highlighter',get_include_path())) { if(! strpos('Text_Highlighter', get_include_path())) {
set_include_path(get_include_path() . PATH_SEPARATOR . 'library/Text_Highlighter'); set_include_path(get_include_path() . PATH_SEPARATOR . 'library/Text_Highlighter');
} }
require_once('library/Text_Highlighter/Text/Highlighter.php'); require_once('library/Text_Highlighter/Text/Highlighter.php');
require_once('library/Text_Highlighter/Text/Highlighter/Renderer/Html.php'); require_once('library/Text_Highlighter/Text/Highlighter/Renderer/Html.php');
$options = array( $options = array(
'numbers' => HL_NUMBERS_LI, 'numbers' => HL_NUMBERS_LI,
'tabsize' => 4, 'tabsize' => 4,
); );
$tag_added = false; $tag_added = false;
$s = trim(html_entity_decode($s,ENT_COMPAT)); $s = trim(html_entity_decode($s, ENT_COMPAT));
$s = str_replace(" ","\t",$s); $s = str_replace(" ", "\t", $s);
// The highlighter library insists on an opening php tag for php code blocks. If // The highlighter library insists on an opening php tag for php code blocks. If
// it isn't present, nothing is highlighted. So we're going to see if it's present. // it isn't present, nothing is highlighted. So we're going to see if it's present.
// If not, we'll add it, and then quietly remove it after we get the processed output back. // If not, we'll add it, and then quietly remove it after we get the processed output back.
if($lang === 'php') { if($lang === 'php') {
if(strpos('<?php',$s) !== 0) { if(strpos('<?php', $s) !== 0) {
$s = '<?php' . "\n" . $s; $s = '<?php' . "\n" . $s;
$tag_added = true; $tag_added = true;
} }
} }
$renderer = new Text_Highlighter_Renderer_HTML($options); $renderer = new Text_Highlighter_Renderer_HTML($options);
$hl = Text_Highlighter::factory($lang); $hl = Text_Highlighter::factory($lang);
$hl->setRenderer($renderer); $hl->setRenderer($renderer);
$o = $hl->highlight($s); $o = $hl->highlight($s);
$o = str_replace([" ","\n"],["&nbsp;&nbsp;&nbsp;&nbsp;",''],$o); $o = str_replace([" ", "\n"], ["&nbsp;&nbsp;&nbsp;&nbsp;", ''], $o);
if($tag_added) { if($tag_added) {
$b = substr($o,0,strpos($o,'<li>')); $b = substr($o, 0, strpos($o, '<li>'));
$e = substr($o,strpos($o,'</li>')); $e = substr($o, strpos($o, '</li>'));
$o = $b . $e; $o = $b . $e;
} }
return('<code>' . $o . '</code>'); return('<code>' . $o . '</code>');
} }
// function to convert multi-dimensional array to xml // function to convert multi-dimensional array to xml
@ -3007,30 +3068,26 @@ function text_highlight($s,$lang) {
function arrtoxml($root_elem,$arr) { function arrtoxml($root_elem,$arr) {
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><' . $root_elem . '></' . $root_elem . '>', null, false); $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><' . $root_elem . '></' . $root_elem . '>', null, false);
array2XML($xml,$arr); array2XML($xml,$arr);
return $xml->asXML(); return $xml->asXML();
} }
function array2XML($obj, $array) function array2XML($obj, $array) {
{ foreach ($array as $key => $value) {
foreach ($array as $key => $value) if(is_numeric($key))
{ $key = 'item' . $key;
if(is_numeric($key))
$key = 'item' . $key;
if (is_array($value)) if(is_array($value)) {
{ $node = $obj->addChild($key);
$node = $obj->addChild($key); array2XML($node, $value);
array2XML($node, $value); } else {
} $obj->addChild($key, htmlspecialchars($value));
else }
{ }
$obj->addChild($key, htmlspecialchars($value));
}
}
} }
function create_table_from_array($table,$arr) { function create_table_from_array($table, $arr) {
if(! ($arr && $table)) if(! ($arr && $table))
return false; return false;
@ -3043,6 +3100,6 @@ function create_table_from_array($table,$arr) {
. "')" . "')"
); );
} }
return $r;
return $r;
} }

View File

@ -1124,17 +1124,16 @@ return $o;
} }
/** /**
* @function widget_photo($arr) * @brief Widget to display a single photo.
* widget to display a single photo. *
* @param array $arr; * @param array $arr associative array with
* 'src' => URL of photo * * \e string \b src URL of photo; URL must be an http or https URL
* 'zrl' => true or false, use zid in url * * \e boolean \b zrl use zid in URL
* 'style' => CSS string * * \e string \b style CSS string
* URL must be an http or https URL *
* @return string with parsed HTML
*/ */
function widget_photo($arr) { function widget_photo($arr) {
$style = $zrl = false; $style = $zrl = false;
@ -1142,7 +1141,7 @@ function widget_photo($arr) {
if(array_key_exists('src', $arr) && isset($arr['src'])) if(array_key_exists('src', $arr) && isset($arr['src']))
$url = $arr['src']; $url = $arr['src'];
if(strpos($url,'http') !== 0) if(strpos($url, 'http') !== 0)
return ''; return '';
if(array_key_exists('style', $arr) && isset($arr['style'])) if(array_key_exists('style', $arr) && isset($arr['style']))
@ -1150,7 +1149,7 @@ function widget_photo($arr) {
// ensure they can't sneak in an eval(js) function // ensure they can't sneak in an eval(js) function
if(strpbrk($style,'(\'"<>') !== false) if(strpbrk($style, '(\'"<>') !== false)
$style = ''; $style = '';
if(array_key_exists('zrl', $arr) && isset($arr['zrl'])) if(array_key_exists('zrl', $arr) && isset($arr['zrl']))

View File

@ -176,7 +176,7 @@ function zot_zot($url, $data) {
* @param boolean $autofallback * @param boolean $autofallback
* fallback/failover to http if https connection cannot be established. Default is true. * fallback/failover to http if https connection cannot be established. Default is true.
* *
* @return array see z_post_url() and \ref mod/zfinger.php * @return array see z_post_url() and \ref Zotlabs::Zot::Finger "\\Zotlabs\\Zot\\Finger"
*/ */
function zot_finger($webbie, $channel = null, $autofallback = true) { function zot_finger($webbie, $channel = null, $autofallback = true) {
@ -571,11 +571,12 @@ function zot_refresh($them, $channel = null, $force = false) {
* * \e string \b guid_sig => guid signed with conversant's private key * * \e string \b guid_sig => guid signed with conversant's private key
* * \e string \b url => URL of the origination hub of this communication * * \e string \b url => URL of the origination hub of this communication
* * \e string \b url_sig => URL signed with conversant's private key * * \e string \b url_sig => URL signed with conversant's private key
* @param boolean $multiple (optional) default false
* *
* @returns array|null null if site is blacklisted or not found, otherwise an * @returns array|null null if site is blacklisted or not found, otherwise an
* array with an hubloc record * array with an hubloc record
*/ */
function zot_gethub($arr,$multiple = false) { function zot_gethub($arr, $multiple = false) {
if($arr['guid'] && $arr['guid_sig'] && $arr['url'] && $arr['url_sig']) { if($arr['guid'] && $arr['guid_sig'] && $arr['url'] && $arr['url_sig']) {
@ -1934,9 +1935,11 @@ function remove_community_tag($sender, $arr, $uid) {
* @brief Just calls item_store_update() and logs result. * @brief Just calls item_store_update() and logs result.
* *
* @see item_store_update() * @see item_store_update()
*
* @param array $sender (unused) * @param array $sender (unused)
* @param array $item * @param array $item
* @param int $uid (unused) * @param array $orig
* @param int $uid
*/ */
function update_imported_item($sender, $item, $orig, $uid) { function update_imported_item($sender, $item, $orig, $uid) {
@ -1957,7 +1960,7 @@ function update_imported_item($sender, $item, $orig, $uid) {
// because event_addtocal will parse the body to get the 'new' event details // because event_addtocal will parse the body to get the 'new' event details
if($orig['resource_type'] === 'event') { if($orig['resource_type'] === 'event') {
$res = event_addtocal($orig['id'],$uid); $res = event_addtocal($orig['id'], $uid);
if(! $res) if(! $res)
logger('update event: failed'); logger('update event: failed');
} }

View File

@ -1,8 +1,8 @@
INPUT = README.md index.php boot.php mod/ include/ util/ view/ version.inc INPUT = README.md index.php boot.php include/ install/ util/ view/ Zotlabs/
RECURSIVE = YES RECURSIVE = YES
PROJECT_NAME = "The Hubzilla" PROJECT_NAME = "The Hubzilla"
PROJECT_LOGO = images/rm-64.png PROJECT_LOGO = images/rm-64.png
EXCLUDE = .htconfig.php library/ doc/ vendor/ .git/ util/zotsh/easywebdav/ EXCLUDE = .htconfig.php library/ doc/ store/ vendor/ .git/ util/zotsh/easywebdav/ util/generate-hooks-index/
EXCLUDE_PATTERNS = *smarty3* *strings.php *.out *test* EXCLUDE_PATTERNS = *smarty3* *strings.php *.out *test*
OUTPUT_DIRECTORY = doc OUTPUT_DIRECTORY = doc
GENERATE_HTML = YES GENERATE_HTML = YES
@ -21,3 +21,5 @@ ALIASES += "fixme=\xrefitem fixme \"Fixme\" \"Fixme List\""
ALIASES += "FIXME=\fixme" ALIASES += "FIXME=\fixme"
ALIASES += "TODO=\todo" ALIASES += "TODO=\todo"
ALIASES += "BUG=\bug" ALIASES += "BUG=\bug"
ALIASES += "hooks=\xrefitem hooks \"Hooks\" \"Hooks List\""
ALIASES += "HOOKS=\hooks"