From bfbe6c166081608deaa1e388f6287a1bf933c0c6 Mon Sep 17 00:00:00 2001 From: sasiflo Date: Tue, 17 May 2016 12:27:15 +0200 Subject: [PATCH 01/16] Synchronization: Directory creation on sync import corrected. --- Zotlabs/Storage/Directory.php | 10 ++++++---- include/import.php | 22 ++++++++++++++-------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Zotlabs/Storage/Directory.php b/Zotlabs/Storage/Directory.php index 3c0cff6ef..84368d07e 100644 --- a/Zotlabs/Storage/Directory.php +++ b/Zotlabs/Storage/Directory.php @@ -194,7 +194,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota { * @return null|string ETag */ public function createFile($name, $data = null) { - logger($name, LOGGER_DEBUG); + logger('create file in directory ' . $name, LOGGER_DEBUG); if (! $this->auth->owner_id) { logger('permission denied ' . $name); @@ -358,7 +358,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota { * @return void */ public function createDirectory($name) { - logger($name, LOGGER_DEBUG); + logger('create directory ' . $name, LOGGER_DEBUG); if ((! $this->auth->owner_id) || (! perm_is_allowed($this->auth->owner_id, $this->auth->observer, 'write_storage'))) { throw new DAV\Exception\Forbidden('Permission denied.'); @@ -372,7 +372,9 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota { $result = attach_mkdir($r[0], $this->auth->observer, array('filename' => $name, 'folder' => $this->folder_hash)); if($result['success']) { - $sync = attach_export_data($r[0],$ret['data']['hash']); + $sync = attach_export_data($r[0],$result['data']['hash']); + logger('createDirectory: attach_export_data returns $sync:' . print_r($sync, true), LOGGER_DEBUG); + if($sync) { build_sync_packet($r[0]['channel_id'],array('file' => array($sync))); } @@ -563,4 +565,4 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota { $free ); } -} \ No newline at end of file +} diff --git a/include/import.php b/include/import.php index 00058047e..a62ec4ed5 100644 --- a/include/import.php +++ b/include/import.php @@ -973,8 +973,11 @@ function sync_files($channel,$files) { $attach_exists = false; $x = attach_by_hash($att['hash']); + logger('sync_files duplicate check: attach_exists=' . $attach_exists, LOGGER_DEBUG); + logger('sync_files duplicate check: att=' . print_r($att,true), LOGGER_DEBUG); + logger('sync_files duplicate check: attach_by_hash() returned ' . print_r($x,true), LOGGER_DEBUG); - if($x) { + if($x['success']) { $attach_exists = true; $attach_id = $x[0]['id']; } @@ -1043,15 +1046,17 @@ function sync_files($channel,$files) { if($attach_exists) { - $str = ''; - foreach($att as $k => $v) { - if($str) - $str .= ","; - $str .= " `" . $k . "` = '" . $v . "' "; - } - $r = dbq("update `attach` set " . $str . " where id = " . intval($attach_id) ); + logger('sync_files attach exists: ' . print_r($att,true), LOGGER_DEBUG); + $str = ''; + foreach($att as $k => $v) { + if($str) + $str .= ","; + $str .= " `" . $k . "` = '" . $v . "' "; + } + $r = dbq("update `attach` set " . $str . " where id = " . intval($attach_id) ); } else { + logger('sync_files attach does not exists: ' . print_r($att,true), LOGGER_DEBUG); $r = dbq("INSERT INTO attach (`" . implode("`, `", array_keys($att)) . "`) VALUES ('" @@ -1064,6 +1069,7 @@ function sync_files($channel,$files) { if($att['filetype'] === 'multipart/mixed' && $att['is_dir']) { os_mkdir($newfname, STORAGE_DEFAULT_PERMISSIONS,true); + $attachment_stored = true; continue; } else { From 20cb4130d47028cbedf09f8da9feb6ccf8f759db Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 17 May 2016 17:46:30 -0700 Subject: [PATCH 02/16] support work for a long-term fix for issue #390, essentially one can specify a theme:schema string anywhere a theme is input. It will be honoured unless an existing schema setting over-rides this behaviour. This should also be backward compatible but the theme selection code has been cleaned up slightly and there may be subtle differences in behaviour after this commit. On my site this required a page refresh as the first page load after this change was a bit confused. --- Zotlabs/Render/Theme.php | 131 ++++++++++++++++++++++++++++++++++++ Zotlabs/Storage/Browser.php | 8 ++- Zotlabs/Web/Router.php | 8 ++- boot.php | 106 ++--------------------------- include/plugin.php | 5 +- include/smarty.php | 7 +- 6 files changed, 153 insertions(+), 112 deletions(-) create mode 100644 Zotlabs/Render/Theme.php diff --git a/Zotlabs/Render/Theme.php b/Zotlabs/Render/Theme.php new file mode 100644 index 000000000..a8b86f371 --- /dev/null +++ b/Zotlabs/Render/Theme.php @@ -0,0 +1,131 @@ + 1) ? $t[1] : ''); + + $opts = ''; + $opts = ((\App::$profile_uid) ? '?f=&puid=' . \App::$profile_uid : ''); + + $schema_str = ((x(\App::$layout,'schema')) ? '&schema=' . App::$layout['schema'] : ''); + if(($s) && (! $schema_str)) + $schema_str = '&schema=' . $s; + $opts .= $schema_str; + + if(file_exists('view/theme/' . $t . '/php/style.php')) + return('view/theme/' . $t . '/php/style.pcss' . $opts); + + return('view/theme/' . $t . '/css/style.css'); + } +} + diff --git a/Zotlabs/Storage/Browser.php b/Zotlabs/Storage/Browser.php index ca262b739..3556f7f06 100644 --- a/Zotlabs/Storage/Browser.php +++ b/Zotlabs/Storage/Browser.php @@ -246,11 +246,13 @@ class Browser extends DAV\Browser\Plugin { \App::$page['content'] = $html; load_pdl($a); - $theme_info_file = "view/theme/" . current_theme() . "/php/theme.php"; + $current_theme = \Zotlabs\Render\Theme::current(); + + $theme_info_file = "view/theme/" . $current_theme[0] . "/php/theme.php"; if (file_exists($theme_info_file)){ require_once($theme_info_file); - if (function_exists(str_replace('-', '_', current_theme()) . '_init')) { - $func = str_replace('-', '_', current_theme()) . '_init'; + if (function_exists(str_replace('-', '_', $current_theme[0]) . '_init')) { + $func = str_replace('-', '_', $current_theme[0]) . '_init'; $func($a); } } diff --git a/Zotlabs/Web/Router.php b/Zotlabs/Web/Router.php index e6733ffdb..f9290ac30 100644 --- a/Zotlabs/Web/Router.php +++ b/Zotlabs/Web/Router.php @@ -206,13 +206,15 @@ class Router { * load current theme info */ - $theme_info_file = 'view/theme/' . current_theme() . '/php/theme.php'; + $current_theme = \Zotlabs\Render\Theme::current(); + + $theme_info_file = 'view/theme/' . $current_theme[0] . '/php/theme.php'; if (file_exists($theme_info_file)){ require_once($theme_info_file); } - if(function_exists(str_replace('-', '_', current_theme()) . '_init')) { - $func = str_replace('-', '_', current_theme()) . '_init'; + if(function_exists(str_replace('-', '_', $current_theme[0]) . '_init')) { + $func = str_replace('-', '_', $current_theme[0]) . '_init'; $func($a); } elseif (x(\App::$theme_info, 'extends') && file_exists('view/theme/' . \App::$theme_info['extends'] . '/php/theme.php')) { diff --git a/boot.php b/boot.php index 381111b26..7fc096fa3 100755 --- a/boot.php +++ b/boot.php @@ -1874,105 +1874,6 @@ function is_windows() { return ((strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? true : false); } - -function current_theme(){ - $app_base_themes = array('redbasic'); - - $a = get_app(); - $page_theme = null; - - // Find the theme that belongs to the channel whose stuff we are looking at - - if(App::$profile_uid && App::$profile_uid != local_channel()) { - $r = q("select channel_theme from channel where channel_id = %d limit 1", - intval(App::$profile_uid) - ); - if($r) - $page_theme = $r[0]['channel_theme']; - } - - if(array_key_exists('theme', App::$layout) && App::$layout['theme']) - $page_theme = App::$layout['theme']; - - // Allow folks to over-rule channel themes and always use their own on their own site. - // The default is for channel themes to take precedence over your own on pages belonging - // to that channel. - - if($page_theme && local_channel() && App::$profile_uid && local_channel() != App::$profile_uid) { - if(get_pconfig(local_channel(),'system','always_my_theme')) - $page_theme = null; - } - - $is_mobile = App::$is_mobile || App::$is_tablet; - - $standard_system_theme = ((isset(App::$config['system']['theme'])) ? App::$config['system']['theme'] : ''); - $standard_theme_name = ((isset($_SESSION) && x($_SESSION,'theme')) ? $_SESSION['theme'] : $standard_system_theme); - - if($is_mobile) { - if(isset($_SESSION['show_mobile']) && !$_SESSION['show_mobile']) { - $system_theme = $standard_system_theme; - $theme_name = $standard_theme_name; - } - else { - $system_theme = ((isset(App::$config['system']['mobile_theme'])) ? App::$config['system']['mobile_theme'] : ''); - $theme_name = ((isset($_SESSION) && x($_SESSION,'mobile_theme')) ? $_SESSION['mobile_theme'] : $system_theme); - - if($theme_name === '' || $theme_name === '---' ) { - // user has selected to have the mobile theme be the same as the normal one - $system_theme = $standard_system_theme; - $theme_name = $standard_theme_name; - } - } - } - else { - $system_theme = $standard_system_theme; - $theme_name = $standard_theme_name; - - if($page_theme) - $theme_name = $page_theme; - } - - if($theme_name && - (file_exists('view/theme/' . $theme_name . '/css/style.css') || - file_exists('view/theme/' . $theme_name . '/php/style.php'))) - return($theme_name); - - foreach($app_base_themes as $t) { - if(file_exists('view/theme/' . $t . '/css/style.css') || - file_exists('view/theme/' . $t . '/php/style.php')) - return($t); - } - - $fallback = array_merge(glob('view/theme/*/css/style.css'),glob('view/theme/*/php/style.php')); - if(count($fallback)) - return (str_replace('view/theme/','', substr($fallback[0],0,-10))); - -} - - -/** - * @brief Return full URL to theme which is currently in effect. - * - * Provide a sane default if nothing is chosen or the specified theme does not exist. - * - * @param bool $installing default false - * - * @return string - */ -function current_theme_url($installing = false) { - global $a; - - $t = current_theme(); - - $opts = ''; - $opts = ((App::$profile_uid) ? '?f=&puid=' . App::$profile_uid : ''); - $opts .= ((x(App::$layout,'schema')) ? '&schema=' . App::$layout['schema'] : ''); - if(file_exists('view/theme/' . $t . '/php/style.php')) - return('view/theme/' . $t . '/php/style.pcss' . $opts); - - return('view/theme/' . $t . '/css/style.css'); -} - /** * @brief Check if current user has admin role. * @@ -1980,6 +1881,7 @@ function current_theme_url($installing = false) { * * @return bool true if user is an admin */ + function is_site_admin() { $a = get_app(); @@ -2209,7 +2111,9 @@ function construct_page(&$a) { } } - if (($p = theme_include(current_theme() . '.js')) != '') + $current_theme = Zotlabs\Render\Theme::current(); + + if (($p = theme_include($current_theme[0] . '.js')) != '') head_add_js($p); if (($p = theme_include('mod_' . App::$module . '.php')) != '') @@ -2223,7 +2127,7 @@ function construct_page(&$a) { head_add_css(((x(App::$page, 'template')) ? App::$page['template'] : 'default' ) . '.css'); head_add_css('mod_' . App::$module . '.css'); - head_add_css(current_theme_url($installing)); + head_add_css(Zotlabs\Render\Theme::url($installing)); head_add_js('mod_' . App::$module . '.js'); diff --git a/include/plugin.php b/include/plugin.php index 8dd67bb0c..89047d4b1 100755 --- a/include/plugin.php +++ b/include/plugin.php @@ -648,12 +648,13 @@ function theme_include($file, $root = '') { else $parent = 'NOPATH'; - $theme = current_theme(); + $theme = Zotlabs\Render\Theme::current(); + $thname = $theme[0]; $ext = substr($file,strrpos($file,'.')+1); $paths = array( - "{$root}view/theme/$theme/$ext/$file", + "{$root}view/theme/$thname/$ext/$file", "{$root}view/theme/$parent/$ext/$file", "{$root}view/site/$ext/$file", "{$root}view/$ext/$file", diff --git a/include/smarty.php b/include/smarty.php index 3812c6021..762efe335 100755 --- a/include/smarty.php +++ b/include/smarty.php @@ -11,13 +11,14 @@ class FriendicaSmarty extends Smarty { parent::__construct(); $a = get_app(); - $theme = current_theme(); + $theme = Zotlabs\Render\Theme::current(); + $thname = $theme[0]; // setTemplateDir can be set to an array, which Smarty will parse in order. // The order is thus very important here - $template_dirs = array('theme' => "view/theme/$theme/tpl/"); + $template_dirs = array('theme' => "view/theme/$thname/tpl/"); if( x(App::$theme_info,"extends") ) - $template_dirs = $template_dirs + array('extends' => "view/theme/".App::$theme_info["extends"]."/tpl/"); + $template_dirs = $template_dirs + array('extends' => "view/theme/" . App::$theme_info["extends"] . "/tpl/"); $template_dirs = $template_dirs + array('base' => 'view/tpl/'); $this->setTemplateDir($template_dirs); From 43c2b22fca908cb5c7bb740855cbd9d04e085d62 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 17 May 2016 19:49:21 -0700 Subject: [PATCH 03/16] cli utilities - argc and argv reversed. Not functionally incorrect since it was consistent but aesthetically incorrect. --- Zotlabs/Project/System.php | 2 +- include/checksites.php | 4 ++-- include/cli_suggest.php | 7 ++----- include/cronhooks.php | 4 ++-- include/deliver.php | 4 ++-- include/deliver_hooks.php | 4 ++-- include/directory.php | 4 ++-- include/expire.php | 4 ++-- include/externals.php | 4 ++-- include/gprobe.php | 4 ++-- include/importdoc.php | 4 ++-- include/notifier.php | 4 ++-- include/onedirsync.php | 4 ++-- include/onepoll.php | 4 ++-- include/poller.php | 4 ++-- include/queue.php | 4 ++-- include/ratenotif.php | 4 ++-- util/po2php.php | 4 ++-- 18 files changed, 35 insertions(+), 38 deletions(-) diff --git a/Zotlabs/Project/System.php b/Zotlabs/Project/System.php index f61313da0..7ee848411 100644 --- a/Zotlabs/Project/System.php +++ b/Zotlabs/Project/System.php @@ -5,7 +5,7 @@ namespace Zotlabs\Project; class System { static public function get_platform_name() { - if(is_array(\App::$config) && is_array(\App::$config['system']) && \App::$config['system']['platform_name']) + if(is_array(\App::$config) && is_array(\App::$config['system']) && array_key_exists('platform_name',\App::$config['system'])) return \App::$config['system']['platform_name']; return PLATFORM_NAME; } diff --git a/include/checksites.php b/include/checksites.php index e9c08c202..9d3ca1797 100644 --- a/include/checksites.php +++ b/include/checksites.php @@ -7,7 +7,7 @@ require_once('include/hubloc.php'); -function checksites_run($argv, $argc){ +function checksites_run($argc,$argv){ cli_startup(); @@ -57,6 +57,6 @@ function checksites_run($argv, $argc){ } if (array_search(__file__,get_included_files())===0){ - checksites_run($argv,$argc); + checksites_run($argc,$argv); killme(); } diff --git a/include/cli_suggest.php b/include/cli_suggest.php index 321ffd2e0..94b65f8ee 100644 --- a/include/cli_suggest.php +++ b/include/cli_suggest.php @@ -5,18 +5,15 @@ require_once('include/cli_startup.php'); require_once('include/socgraph.php'); -function cli_suggest_run($argv, $argc){ +function cli_suggest_run($argc,$argv){ cli_startup(); - - $a = get_app(); - update_suggestions(); } if (array_search(__file__,get_included_files())===0){ - cli_suggest_run($argv,$argc); + cli_suggest_run($argc,$argv); killme(); } diff --git a/include/cronhooks.php b/include/cronhooks.php index a314593d2..ae3806984 100644 --- a/include/cronhooks.php +++ b/include/cronhooks.php @@ -4,7 +4,7 @@ require_once('boot.php'); require_once('include/cli_startup.php'); -function cronhooks_run($argv, $argc){ +function cronhooks_run($argc,$argv){ cli_startup(); @@ -18,6 +18,6 @@ function cronhooks_run($argv, $argc){ } if (array_search(__file__,get_included_files())===0){ - cronhooks_run($argv,$argc); + cronhooks_run($argc,$argv); killme(); } diff --git a/include/deliver.php b/include/deliver.php index 40df543d5..12f28d6a9 100644 --- a/include/deliver.php +++ b/include/deliver.php @@ -5,7 +5,7 @@ require_once('include/zot.php'); require_once('include/queue_fn.php'); -function deliver_run($argv, $argc) { +function deliver_run($argc,$argv) { cli_startup(); @@ -82,6 +82,6 @@ function deliver_run($argv, $argc) { } if (array_search(__file__,get_included_files())===0){ - deliver_run($argv,$argc); + deliver_run($argc,$argv); killme(); } diff --git a/include/deliver_hooks.php b/include/deliver_hooks.php index f0d6ba1b1..f8f3bb19b 100644 --- a/include/deliver_hooks.php +++ b/include/deliver_hooks.php @@ -5,7 +5,7 @@ require_once('include/cli_startup.php'); require_once('include/zot.php'); -function deliver_hooks_run($argv, $argc) { +function deliver_hooks_run($argc,$argv) { cli_startup(); @@ -24,6 +24,6 @@ function deliver_hooks_run($argv, $argc) { } if (array_search(__file__,get_included_files())===0){ - deliver_hooks_run($argv,$argc); + deliver_hooks_run($argc,$argv); killme(); } diff --git a/include/directory.php b/include/directory.php index 8792a15e1..5120474a6 100644 --- a/include/directory.php +++ b/include/directory.php @@ -16,7 +16,7 @@ require_once('include/queue_fn.php'); * @param array $argv * @param array $argc */ -function directory_run($argv, $argc){ +function directory_run($argc,$argv){ cli_startup(); @@ -108,6 +108,6 @@ function directory_run($argv, $argc){ } if (array_search(__file__, get_included_files()) === 0) { - directory_run($argv, $argc); + directory_run($argc,$argv); killme(); } diff --git a/include/expire.php b/include/expire.php index e75594b5f..a2468e0f2 100644 --- a/include/expire.php +++ b/include/expire.php @@ -6,7 +6,7 @@ require_once('boot.php'); require_once('include/cli_startup.php'); -function expire_run($argv, $argc){ +function expire_run($argc,$argv){ cli_startup(); @@ -93,6 +93,6 @@ function expire_run($argv, $argc){ } if (array_search(__file__, get_included_files()) === 0){ - expire_run($argv, $argc); + expire_run($argc,$argv); killme(); } diff --git a/include/externals.php b/include/externals.php index 3a3a32420..ddf44dc52 100644 --- a/include/externals.php +++ b/include/externals.php @@ -5,7 +5,7 @@ require_once('include/cli_startup.php'); require_once('include/zot.php'); require_once('include/identity.php'); -function externals_run($argv, $argc){ +function externals_run($argc,$argv){ cli_startup(); $a = get_app(); @@ -98,6 +98,6 @@ function externals_run($argv, $argc){ } if (array_search(__file__,get_included_files())===0){ - externals_run($argv,$argc); + externals_run($argc,$argv); killme(); } diff --git a/include/gprobe.php b/include/gprobe.php index d8d893d9e..bd02ac31b 100644 --- a/include/gprobe.php +++ b/include/gprobe.php @@ -3,7 +3,7 @@ require_once('include/cli_startup.php'); require_once('include/zot.php'); -function gprobe_run($argv, $argc){ +function gprobe_run($argc,$argv){ cli_startup(); @@ -33,6 +33,6 @@ function gprobe_run($argv, $argc){ } if (array_search(__file__,get_included_files())===0){ - gprobe_run($argv,$argc); + gprobe_run($argc,$argv); killme(); } diff --git a/include/importdoc.php b/include/importdoc.php index 90dfb2fc4..7c65037d3 100755 --- a/include/importdoc.php +++ b/include/importdoc.php @@ -5,7 +5,7 @@ require_once('include/cli_startup.php'); -function importdoc_run($argv, $argc){ +function importdoc_run($argc,$argv){ cli_startup(); @@ -16,7 +16,7 @@ function importdoc_run($argv, $argc){ } if (array_search(__file__,get_included_files())===0){ - importdoc_run($argv,$argc); + importdoc_run($argc,$argv); killme(); } diff --git a/include/notifier.php b/include/notifier.php index 708d42bd0..780a8798c 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -74,7 +74,7 @@ require_once('include/bbcode.php'); require_once('include/identity.php'); require_once('include/Contact.php'); -function notifier_run($argv, $argc){ +function notifier_run($argc,$argv){ cli_startup(); @@ -659,6 +659,6 @@ function notifier_run($argv, $argc){ if (array_search(__file__,get_included_files())===0){ - notifier_run($argv,$argc); + notifier_run($argc,$argv); killme(); } diff --git a/include/onedirsync.php b/include/onedirsync.php index ce516da9d..d794fe35e 100644 --- a/include/onedirsync.php +++ b/include/onedirsync.php @@ -6,7 +6,7 @@ require_once('include/zot.php'); require_once('include/dir_fns.php'); -function onedirsync_run($argv, $argc){ +function onedirsync_run($argc,$argv){ cli_startup(); @@ -77,6 +77,6 @@ function onedirsync_run($argv, $argc){ } if (array_search(__file__,get_included_files())===0){ - onedirsync_run($argv,$argc); + onedirsync_run($argc,$argv); killme(); } diff --git a/include/onepoll.php b/include/onepoll.php index fedeb1e95..bfd79feea 100644 --- a/include/onepoll.php +++ b/include/onepoll.php @@ -7,7 +7,7 @@ require_once('include/socgraph.php'); require_once('include/Contact.php'); -function onepoll_run($argv, $argc){ +function onepoll_run($argc,$argv){ cli_startup(); @@ -154,6 +154,6 @@ function onepoll_run($argv, $argc){ } if (array_search(__file__,get_included_files())===0){ - onepoll_run($argv,$argc); + onepoll_run($argc,$argv); killme(); } diff --git a/include/poller.php b/include/poller.php index 808b54ee5..1a5b8508c 100644 --- a/include/poller.php +++ b/include/poller.php @@ -4,7 +4,7 @@ require_once('boot.php'); require_once('include/cli_startup.php'); -function poller_run($argv, $argc){ +function poller_run($argc,$argv){ cli_startup(); @@ -440,6 +440,6 @@ function poller_run($argv, $argc){ } if (array_search(__file__,get_included_files())===0){ - poller_run($argv,$argc); + poller_run($argc,$argv); killme(); } diff --git a/include/queue.php b/include/queue.php index 8a3b2aa58..1159e01a0 100644 --- a/include/queue.php +++ b/include/queue.php @@ -4,7 +4,7 @@ require_once('include/cli_startup.php'); require_once('include/queue_fn.php'); require_once('include/zot.php'); -function queue_run($argv, $argc){ +function queue_run($argc,$argv){ cli_startup(); @@ -90,6 +90,6 @@ function queue_run($argv, $argc){ } if (array_search(__file__,get_included_files())===0){ - queue_run($argv,$argc); + queue_run($argc,$argv); killme(); } diff --git a/include/ratenotif.php b/include/ratenotif.php index 2c636c710..3a5e515ae 100644 --- a/include/ratenotif.php +++ b/include/ratenotif.php @@ -5,7 +5,7 @@ require_once('include/zot.php'); require_once('include/queue_fn.php'); -function ratenotif_run($argv, $argc){ +function ratenotif_run($argc,$argv){ cli_startup(); @@ -114,6 +114,6 @@ function ratenotif_run($argv, $argc){ } if (array_search(__file__,get_included_files())===0){ - ratenotif_run($argv,$argc); + ratenotif_run($argc,$argv); killme(); } diff --git a/util/po2php.php b/util/po2php.php index 66807083b..ab8c495f9 100644 --- a/util/po2php.php +++ b/util/po2php.php @@ -1,7 +1,7 @@ \n\n"; @@ -140,5 +140,5 @@ function trim_message($str) { } if (array_search(__file__,get_included_files())===0){ - po2php_run($argv,$argc); + po2php_run($argc,$argv); } From 16f79b70e4e3fd572de4d3fc938802fa8c536bca Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 17 May 2016 22:32:49 -0700 Subject: [PATCH 04/16] experimental PDO DBA driver --- include/dba/dba_driver.php | 15 ++++-- include/dba/dba_pdo.php | 95 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+), 4 deletions(-) create mode 100755 include/dba/dba_pdo.php diff --git a/include/dba/dba_driver.php b/include/dba/dba_driver.php index 4a1752672..498bfffa7 100755 --- a/include/dba/dba_driver.php +++ b/include/dba/dba_driver.php @@ -32,16 +32,23 @@ function dba_factory($server, $port,$user,$pass,$db,$dbtype,$install = false) { if(is_null($port)) $set_port = 5432; $dba = new dba_postgres($server, $set_port, $user, $pass, $db, $install); } else { +// require_once('include/dba/dba_pdo.php'); +// $dba = new dba_pdo($server, $set_port,$user,$pass,$db,$install); +// } + if(class_exists('mysqli')) { if (is_null($port)) $set_port = ini_get("mysqli.default_port"); require_once('include/dba/dba_mysqli.php'); $dba = new dba_mysqli($server, $set_port,$user,$pass,$db,$install); - } else { - if (is_null($port)) $set_port = "3306"; - require_once('include/dba/dba_mysql.php'); - $dba = new dba_mysql($server, $set_port,$user,$pass,$db,$install); } } + +// else { +// if (is_null($port)) $set_port = "3306"; +// require_once('include/dba/dba_mysql.php'); +// $dba = new dba_mysql($server, $set_port,$user,$pass,$db,$install); +// } +// } if(is_object($dba) && $dba->connected) { $dns = (($dbtype == DBTYPE_POSTGRES) ? 'postgres' : 'mysql') diff --git a/include/dba/dba_pdo.php b/include/dba/dba_pdo.php new file mode 100755 index 000000000..7255a2b66 --- /dev/null +++ b/include/dba/dba_pdo.php @@ -0,0 +1,95 @@ +driver_dbtype = 'mysql'; // (($dbtype == DBTYPE_POSTGRES) ? 'postgres' : 'mysql'); + $dns = $this->driver_dbtype + . ':host=' . $server . (is_null($port) ? '' : ';port=' . $port) + . ';dbname=' . $db; + + + try { + $this->db = new PDO($dns,$user,$pass); + $this->db->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); + } + catch(PDOException $e) { + if(file_exists('dbfail.out')) { + file_put_contents('dbfail.out', datetime_convert() . "\nConnect: " . $e->getMessage() . "\n", FILE_APPEND); + } + + return false; + } + + $this->connected = true; + return true; + + } + + function q($sql) { + if((! $this->db) || (! $this->connected)) + return false; + + $this->error = ''; + $select = ((stripos($sql,'select') === 0) ? true : false); + + try { + $result = $this->db->query($sql); + } + catch(PDOException $e) { + + $this->error = $e->getMessage(); + if($this->error) { + db_logger('dba_mysqli: ERROR: ' . printable($sql) . "\n" . $this->error, LOGGER_NORMAL, LOG_ERR); + if(file_exists('dbfail.out')) { + file_put_contents('dbfail.out', datetime_convert() . "\n" . printable($sql) . "\n" . $this->error . "\n", FILE_APPEND); + } + } + } + + if(!($select)) { + if($this->debug) { + db_logger('dba_mysqli: DEBUG: ' . printable($sql) . ' returns ' . (($result) ? 'true' : 'false'), LOGGER_NORMAL,(($result) ? LOG_INFO : LOG_ERR)); + } + return $result; + } + + if($this->debug) { + db_logger('dba_mysqli: DEBUG: ' . printable($sql) . ' returned ' . count($result) . ' results.', LOGGER_NORMAL, LOG_INFO); + } + + $r = array(); + if($result) { + foreach($result as $x) { + $r[] = $x; + } + if($this->debug) { + db_logger('dba_pdo: ' . printable(print_r($r,true)), LOGGER_NORMAL, LOG_INFO); + } + } + return $r; + } + + function escape($str) { + if($this->db && $this->connected) { + return substr(substr(@$this->db->quote($str),1),0,-1); + } + } + + function close() { + if($this->db) + $this->db = null; + $this->connected = false; + } + + function getdriver() { + return 'pdo'; + } + +} \ No newline at end of file From c77732b8edfbfa49cd52df4c2ac3b27a55d2ee02 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 18 May 2016 21:23:24 +0200 Subject: [PATCH 05/16] only show $showall_origin if permission_role is custom. it does not make much sense otherwise since the member is merely using a preset of permissions. --- include/acl_selectors.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/acl_selectors.php b/include/acl_selectors.php index 136f8aa50..6b727c9a2 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -230,14 +230,14 @@ function populate_acl($defaults = null,$show_jotnets = true, $emptyACL_descripti $allow_cid = $allow_gid = $deny_cid = $deny_gid = false; $showall_origin = ''; $showall_icon = 'fa-globe'; - + $role = get_pconfig(local_channel(),'system','permissions_role'); if(! $emptyACL_description) { $showall_caption = t('Visible to your default audience'); } else if (is_a($emptyACL_description, 'PermissionDescription')) { $showall_caption = $emptyACL_description->get_permission_description(); - $showall_origin = $emptyACL_description->get_permission_origin_description(); + $showall_origin = (($role === 'custom') ? $emptyACL_description->get_permission_origin_description() : ''); $showall_icon = $emptyACL_description->get_permission_icon(); } else { @@ -271,7 +271,7 @@ function populate_acl($defaults = null,$show_jotnets = true, $emptyACL_descripti '$showall' => $showall_caption, '$showallOrigin' => $showall_origin, '$showallIcon' => $showall_icon, - '$select_label' => t('Who can see this'), + '$select_label' => t('Who can see this?'), '$showlimited' => t('Custom selection'), '$showlimitedDesc' => t('Select "Show" to allow viewing. "Don\'t show" lets you override and limit the scope of "Show".'), '$show' => t("Show"), From d38851023ec5bac78ece9469c758851e97e01285 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 18 May 2016 16:28:51 -0700 Subject: [PATCH 06/16] provide server role on pubsites page --- Zotlabs/Module/Pubsites.php | 6 +++--- Zotlabs/Project/System.php | 2 +- include/zot.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Zotlabs/Module/Pubsites.php b/Zotlabs/Module/Pubsites.php index 9313a3c5a..a1d91f53d 100644 --- a/Zotlabs/Module/Pubsites.php +++ b/Zotlabs/Module/Pubsites.php @@ -28,10 +28,10 @@ class Pubsites extends \Zotlabs\Web\Controller { if($ret['success']) { $j = json_decode($ret['body'],true); if($j) { - $o .= ''; + $o .= '
' . t('Hub URL') . '' . t('Access Type') . '' . t('Registration Policy') . '' . t('Ratings') . '
'; if($j['sites']) { foreach($j['sites'] as $jj) { - if($jj['project'] !== \Zotlabs\Project\System::get_platform_name()) + if(strpos($jj['project'],\Zotlabs\Project\System::get_platform_name()) === false) continue; $host = strtolower(substr($jj['url'],strpos($jj['url'],'://')+3)); $rate_links = ((local_channel()) ? '' : ''); @@ -43,7 +43,7 @@ class Pubsites extends \Zotlabs\Web\Controller { $location = '
 '; } $urltext = str_replace(array('https://'), '', $jj['url']); - $o .= '' . $rate_links . ''; + $o .= '' . $rate_links . ''; } } diff --git a/Zotlabs/Project/System.php b/Zotlabs/Project/System.php index 7ee848411..d95bd033c 100644 --- a/Zotlabs/Project/System.php +++ b/Zotlabs/Project/System.php @@ -45,7 +45,7 @@ class System { static public function get_server_role() { if(UNO) return 'basic'; - return 'advanced'; + return 'pro'; } static public function get_std_version() { diff --git a/include/zot.php b/include/zot.php index 8adc74ffa..5400bd96e 100644 --- a/include/zot.php +++ b/include/zot.php @@ -3944,7 +3944,7 @@ function zotinfo($arr) { $ret['site']['sellpage'] = get_config('system','sellpage'); $ret['site']['location'] = get_config('system','site_location'); $ret['site']['realm'] = get_directory_realm(); - $ret['site']['project'] = Zotlabs\Project\System::get_platform_name(); + $ret['site']['project'] = Zotlabs\Project\System::get_platform_name() . Zotlabs\Project\System::get_server_role(); } From 166d63ff608c94152ce7213472fac6a2b61fa913 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 18 May 2016 16:31:12 -0700 Subject: [PATCH 07/16] missing close tag --- Zotlabs/Module/Pubsites.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zotlabs/Module/Pubsites.php b/Zotlabs/Module/Pubsites.php index a1d91f53d..55f2c0ad6 100644 --- a/Zotlabs/Module/Pubsites.php +++ b/Zotlabs/Module/Pubsites.php @@ -43,7 +43,7 @@ class Pubsites extends \Zotlabs\Web\Controller { $location = '
 '; } $urltext = str_replace(array('https://'), '', $jj['url']); - $o .= '
' . $rate_links . ''; + $o .= '' . $rate_links . ''; } } From 37d14f3a1dbc8b4fea6831585c746be4a6602fcb Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 18 May 2016 17:02:46 -0700 Subject: [PATCH 08/16] Revert "yet more session work" This reverts commit 51edd472c2e007490bdad3198ba1b2a3d7a09c45. --- Zotlabs/Storage/BasicAuth.php | 24 +++--------------------- Zotlabs/Web/Session.php | 4 ++-- 2 files changed, 5 insertions(+), 23 deletions(-) diff --git a/Zotlabs/Storage/BasicAuth.php b/Zotlabs/Storage/BasicAuth.php index 02c4117da..da5af7659 100644 --- a/Zotlabs/Storage/BasicAuth.php +++ b/Zotlabs/Storage/BasicAuth.php @@ -73,9 +73,6 @@ class BasicAuth extends DAV\Auth\Backend\AbstractBasic { protected $timezone = ''; - public $module_disabled = false; - - /** * @brief Validates a username and password. * @@ -95,7 +92,7 @@ class BasicAuth extends DAV\Auth\Backend\AbstractBasic { intval($record['account_id']), intval($record['account_default_channel']) ); - if($r && $this->check_module_access($r[0]['channel_id'])) { + if ($r) { return $this->setAuthenticated($r[0]); } } @@ -112,17 +109,13 @@ class BasicAuth extends DAV\Auth\Backend\AbstractBasic { if ((($record['account_flags'] == ACCOUNT_OK) || ($record['account_flags'] == ACCOUNT_UNVERIFIED)) && (hash('whirlpool', $record['account_salt'] . $password) === $record['account_password'])) { logger('password verified for ' . $username); - if($this->check_module_access($r[0]['channel_id'])) - return $this->setAuthenticated($r[0]); + return $this->setAuthenticated($r[0]); } } } } - if($this->module_disabled) - $error = 'module not enabled for ' . $username; - else - $error = 'password failed for ' . $username; + $error = 'password failed for ' . $username; logger($error); log_failed_login($error); @@ -146,17 +139,6 @@ class BasicAuth extends DAV\Auth\Backend\AbstractBasic { return true; } - protected function check_module_access($channel_id) { - if($channel_id && \App::$module === 'cdav') { - $x = get_pconfig($channel_id,'cdav','enabled'); - if(! $x) { - $this->module_disabled = true; - return false; - } - } - return true; - } - /** * Sets the channel_name from the currently logged-in channel. * diff --git a/Zotlabs/Web/Session.php b/Zotlabs/Web/Session.php index c26b3523c..b1f5526ea 100644 --- a/Zotlabs/Web/Session.php +++ b/Zotlabs/Web/Session.php @@ -13,8 +13,8 @@ namespace Zotlabs\Web; class Session { - private $handler = null; - private $session_started = false; + static private $handler = null; + static private $session_started = false; public function init() { From 1f7e6cae823e75ab47fa9c9a1a496842d20901d5 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 18 May 2016 17:03:54 -0700 Subject: [PATCH 09/16] Revert "Revert "yet more session work"" This reverts commit 37d14f3a1dbc8b4fea6831585c746be4a6602fcb. --- Zotlabs/Storage/BasicAuth.php | 24 +++++++++++++++++++++--- Zotlabs/Web/Session.php | 4 ++-- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/Zotlabs/Storage/BasicAuth.php b/Zotlabs/Storage/BasicAuth.php index da5af7659..02c4117da 100644 --- a/Zotlabs/Storage/BasicAuth.php +++ b/Zotlabs/Storage/BasicAuth.php @@ -73,6 +73,9 @@ class BasicAuth extends DAV\Auth\Backend\AbstractBasic { protected $timezone = ''; + public $module_disabled = false; + + /** * @brief Validates a username and password. * @@ -92,7 +95,7 @@ class BasicAuth extends DAV\Auth\Backend\AbstractBasic { intval($record['account_id']), intval($record['account_default_channel']) ); - if ($r) { + if($r && $this->check_module_access($r[0]['channel_id'])) { return $this->setAuthenticated($r[0]); } } @@ -109,13 +112,17 @@ class BasicAuth extends DAV\Auth\Backend\AbstractBasic { if ((($record['account_flags'] == ACCOUNT_OK) || ($record['account_flags'] == ACCOUNT_UNVERIFIED)) && (hash('whirlpool', $record['account_salt'] . $password) === $record['account_password'])) { logger('password verified for ' . $username); - return $this->setAuthenticated($r[0]); + if($this->check_module_access($r[0]['channel_id'])) + return $this->setAuthenticated($r[0]); } } } } - $error = 'password failed for ' . $username; + if($this->module_disabled) + $error = 'module not enabled for ' . $username; + else + $error = 'password failed for ' . $username; logger($error); log_failed_login($error); @@ -139,6 +146,17 @@ class BasicAuth extends DAV\Auth\Backend\AbstractBasic { return true; } + protected function check_module_access($channel_id) { + if($channel_id && \App::$module === 'cdav') { + $x = get_pconfig($channel_id,'cdav','enabled'); + if(! $x) { + $this->module_disabled = true; + return false; + } + } + return true; + } + /** * Sets the channel_name from the currently logged-in channel. * diff --git a/Zotlabs/Web/Session.php b/Zotlabs/Web/Session.php index b1f5526ea..c26b3523c 100644 --- a/Zotlabs/Web/Session.php +++ b/Zotlabs/Web/Session.php @@ -13,8 +13,8 @@ namespace Zotlabs\Web; class Session { - static private $handler = null; - static private $session_started = false; + private $handler = null; + private $session_started = false; public function init() { From c17b47518d57de90264378ff082e8a2576bec273 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 18 May 2016 17:55:22 -0700 Subject: [PATCH 10/16] comment out session_regenerate until we get this sorted --- Zotlabs/Web/Session.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zotlabs/Web/Session.php b/Zotlabs/Web/Session.php index c26b3523c..2b058d379 100644 --- a/Zotlabs/Web/Session.php +++ b/Zotlabs/Web/Session.php @@ -82,7 +82,7 @@ class Session { $arr = session_get_cookie_params(); if($this->handler && $this->session_started) { - session_regenerate_id(true); + // session_regenerate_id(true); // force SessionHandler record creation with the new session_id // which occurs as a side effect of read() From 77eb9bcfa04faee0fbf20a1d9fae90bdf0dcbcc3 Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Wed, 18 May 2016 21:32:23 -0400 Subject: [PATCH 11/16] Link new plugins when updating repos via admin/plugins --- Zotlabs/Module/Admin.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Zotlabs/Module/Admin.php b/Zotlabs/Module/Admin.php index 9b54a4081..cb843e212 100644 --- a/Zotlabs/Module/Admin.php +++ b/Zotlabs/Module/Admin.php @@ -1758,6 +1758,18 @@ class Admin extends \Zotlabs\Web\Controller { $git = new GitRepo('sys', null, false, $repoName, $repoDir); try { if ($git->pull()) { + $files = array_diff(scandir($repoDir), array('.', '..')); + foreach ($files as $file) { + if (is_dir($repoDir . '/' . $file) && $file !== '.git') { + $source = '../extend/addon/' . $repoName . '/' . $file; + $target = realpath(__DIR__ . '/../../addon/') . '/' . $file; + unlink($target); + if (!symlink($source, $target)) { + logger('Error linking addons to /addon'); + json_return_and_die(array('message' => 'Error linking addons to /addon', 'success' => false)); + } + } + } json_return_and_die(array('message' => 'Repo updated.', 'success' => true)); } else { json_return_and_die(array('message' => 'Error updating addon repo.', 'success' => false)); From f4b31dcb3a56789c9c96e982466b11fe472e1444 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 18 May 2016 20:36:03 -0700 Subject: [PATCH 12/16] Document what I know about the session regeneration issue. I'm really tired of fighting this darn thing. Sessions and cookies need to work. --- Zotlabs/Web/Session.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Zotlabs/Web/Session.php b/Zotlabs/Web/Session.php index 2b058d379..63ccd91fe 100644 --- a/Zotlabs/Web/Session.php +++ b/Zotlabs/Web/Session.php @@ -82,6 +82,19 @@ class Session { $arr = session_get_cookie_params(); if($this->handler && $this->session_started) { + + // The session should be regenerated to prevent session fixation attacks. + // Traditionally this has been working well, but stopped working in Firefox + // recently (~46.0). It works well in other browsers. FF takes time for the + // new cookie to propagate and it appears to still use the old cookie for the + // next several requests. We don't have an easy way to flush the cookies and + // ensure the browser is using the right one. I've tried several methods including + // delayed cookie deletion and issuing a page reload just after authentication + // and none have been successful and all are hacks to work around what looks to be + // a browser issue. This is an important @FIXME. We should enable by default and let + // folks disable it if they have issues, except they can't login to change it if + // their sessions aren't working. + // session_regenerate_id(true); // force SessionHandler record creation with the new session_id From ada26dd2cbf99e7e8395b4e466a3f73245d004f1 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 18 May 2016 21:00:31 -0700 Subject: [PATCH 13/16] This explains it all. Don't set the domain when creating a cookie. You'll get a wildcard and sessions will break if you have multiple domains running hubzilla (or any php basic session based code). --- Zotlabs/Web/Session.php | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/Zotlabs/Web/Session.php b/Zotlabs/Web/Session.php index 63ccd91fe..4f2a3f1f7 100644 --- a/Zotlabs/Web/Session.php +++ b/Zotlabs/Web/Session.php @@ -41,10 +41,15 @@ class Session { $arr = session_get_cookie_params(); + + // Note when setting cookies: set the domain to false which creates a single domain + // cookie. If you use a hostname it will create a .domain.com wildcard which will + // have some nasty side effects if you have any other subdomains running hubzilla. + session_set_cookie_params( ((isset($arr['lifetime'])) ? $arr['lifetime'] : 0), ((isset($arr['path'])) ? $arr['path'] : '/'), - (($arr['domain']) ? $arr['domain'] : \App::get_hostname()), + (($arr['domain']) ? $arr['domain'] : false), ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') ? true : false), ((isset($arr['httponly'])) ? $arr['httponly'] : true) ); @@ -83,19 +88,7 @@ class Session { if($this->handler && $this->session_started) { - // The session should be regenerated to prevent session fixation attacks. - // Traditionally this has been working well, but stopped working in Firefox - // recently (~46.0). It works well in other browsers. FF takes time for the - // new cookie to propagate and it appears to still use the old cookie for the - // next several requests. We don't have an easy way to flush the cookies and - // ensure the browser is using the right one. I've tried several methods including - // delayed cookie deletion and issuing a page reload just after authentication - // and none have been successful and all are hacks to work around what looks to be - // a browser issue. This is an important @FIXME. We should enable by default and let - // folks disable it if they have issues, except they can't login to change it if - // their sessions aren't working. - - // session_regenerate_id(true); + session_regenerate_id(true); // force SessionHandler record creation with the new session_id // which occurs as a side effect of read() @@ -106,9 +99,9 @@ class Session { logger('no session handler'); if (x($_COOKIE, 'jsdisabled')) { - setcookie('jsdisabled', $_COOKIE['jsdisabled'], $newxtime, '/', \App::get_hostname(),((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') ? true : false),((isset($arr['httponly'])) ? $arr['httponly'] : true)); + setcookie('jsdisabled', $_COOKIE['jsdisabled'], $newxtime, '/', false,((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') ? true : false),((isset($arr['httponly'])) ? $arr['httponly'] : true)); } - setcookie(session_name(),session_id(),$newxtime, '/', \App::get_hostname(),((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') ? true : false),((isset($arr['httponly'])) ? $arr['httponly'] : true)); + setcookie(session_name(),session_id(),$newxtime, '/', false,((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') ? true : false),((isset($arr['httponly'])) ? $arr['httponly'] : true)); $arr = array('expire' => $xtime); call_hooks('new_cookie', $arr); @@ -124,7 +117,7 @@ class Session { $xtime = (($_SESSION['remember_me']) ? (60 * 60 * 24 * 365) : 0 ); if($xtime) - setcookie(session_name(),session_id(),(time() + $xtime), '/', \App::get_hostname(),((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') ? true : false),((isset($arr['httponly'])) ? $arr['httponly'] : true)); + setcookie(session_name(),session_id(),(time() + $xtime), '/', false,((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') ? true : false),((isset($arr['httponly'])) ? $arr['httponly'] : true)); $arr = array('expire' => $xtime); call_hooks('extend_cookie', $arr); From 3355210878c6af1d4ee1719d223e83dd9e086ddc Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 18 May 2016 22:03:43 -0700 Subject: [PATCH 14/16] explain what we're doing and where we're going with this. --- include/dba/dba_driver.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/include/dba/dba_driver.php b/include/dba/dba_driver.php index 498bfffa7..e15e107a8 100755 --- a/include/dba/dba_driver.php +++ b/include/dba/dba_driver.php @@ -32,6 +32,8 @@ function dba_factory($server, $port,$user,$pass,$db,$dbtype,$install = false) { if(is_null($port)) $set_port = 5432; $dba = new dba_postgres($server, $set_port, $user, $pass, $db, $install); } else { + +// Highly experimental at the present time. // require_once('include/dba/dba_pdo.php'); // $dba = new dba_pdo($server, $set_port,$user,$pass,$db,$install); // } @@ -42,13 +44,12 @@ function dba_factory($server, $port,$user,$pass,$db,$dbtype,$install = false) { $dba = new dba_mysqli($server, $set_port,$user,$pass,$db,$install); } } + + // Until we have a proper PDO driver, store the DB connection parameters for + // plugins/addons which use PDO natively (such as cdav). This is wasteful as + // it opens a separate connection to the DB, but saves a lot of effort re-writing + // third-party interfaces that are working and well tested. -// else { -// if (is_null($port)) $set_port = "3306"; -// require_once('include/dba/dba_mysql.php'); -// $dba = new dba_mysql($server, $set_port,$user,$pass,$db,$install); -// } -// } if(is_object($dba) && $dba->connected) { $dns = (($dbtype == DBTYPE_POSTGRES) ? 'postgres' : 'mysql') From 905432c7ae738ff69090bf8cc912c42d2cea5ab2 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 18 May 2016 22:53:43 -0700 Subject: [PATCH 15/16] text clarifications --- Zotlabs/Module/Dav.php | 1 + Zotlabs/Module/Settings.php | 4 ++-- Zotlabs/Storage/BasicAuth.php | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Zotlabs/Module/Dav.php b/Zotlabs/Module/Dav.php index 549c992cc..d65ad3405 100644 --- a/Zotlabs/Module/Dav.php +++ b/Zotlabs/Module/Dav.php @@ -64,6 +64,7 @@ class Dav extends \Zotlabs\Web\Controller { $auth = new \Zotlabs\Storage\BasicAuth(); + $auth->setRealm(ucfirst(\Zotlabs\Project\System::get_platform_name()) . 'WebDAV'); // $authBackend = new \Sabre\DAV\Auth\Backend\BasicCallBack(function($userName,$password) { // if(account_verify_password($userName,$password)) diff --git a/Zotlabs/Module/Settings.php b/Zotlabs/Module/Settings.php index a6293e842..1f5c55067 100644 --- a/Zotlabs/Module/Settings.php +++ b/Zotlabs/Module/Settings.php @@ -1062,11 +1062,11 @@ class Settings extends \Zotlabs\Web\Controller { '$lbl_p2macro' => t('Advanced Privacy Settings'), - '$expire' => array('expire',t('Expire other channel content after this many days'),$expire,sprintf( t('0 or blank to use the website limit. The website expires after %d days.'),intval($sys_expire))), + '$expire' => array('expire',t('Expire other channel content after this many days'),$expire, t('0 or blank to use the website limit.') . ' ' . ((intval($sys_expire)) ? sprintf( t('This website expires after %d days.'),intval($sys_expire)) : t('This website does not expire imported content.')) . ' ' . t('The website limit takes precedence if lower than your limit.')), '$maxreq' => array('maxreq', t('Maximum Friend Requests/Day:'), intval($channel['channel_max_friend_req']) , t('May reduce spam activity')), '$permissions' => t('Default Post Permissions'), '$permdesc' => t("\x28click to open/close\x29"), - '$aclselect' => populate_acl($perm_defaults, false, \PermissionDescription::fromDescription(t('Use my default audience setting for the type of post'))), + '$aclselect' => populate_acl($perm_defaults, false, \PermissionDescription::fromDescription(t('Use my default audience setting for the type of object published'))), '$suggestme' => $suggestme, '$group_select' => $group_select, '$role' => array('permissions_role' , t('Channel permissions category:'), $permissions_role, '', get_roles()), diff --git a/Zotlabs/Storage/BasicAuth.php b/Zotlabs/Storage/BasicAuth.php index 02c4117da..121a9c3a1 100644 --- a/Zotlabs/Storage/BasicAuth.php +++ b/Zotlabs/Storage/BasicAuth.php @@ -79,7 +79,6 @@ class BasicAuth extends DAV\Auth\Backend\AbstractBasic { /** * @brief Validates a username and password. * - * Guest access is granted with the password "+++". * * @see \Sabre\DAV\Auth\Backend\AbstractBasic::validateUserPass * @param string $username From 93a7df5a1b9ac260657ba789760cb9e4c11544a7 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 18 May 2016 22:57:23 -0700 Subject: [PATCH 16/16] one more text clarification --- Zotlabs/Module/Settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zotlabs/Module/Settings.php b/Zotlabs/Module/Settings.php index 1f5c55067..f588e2824 100644 --- a/Zotlabs/Module/Settings.php +++ b/Zotlabs/Module/Settings.php @@ -1064,7 +1064,7 @@ class Settings extends \Zotlabs\Web\Controller { '$expire' => array('expire',t('Expire other channel content after this many days'),$expire, t('0 or blank to use the website limit.') . ' ' . ((intval($sys_expire)) ? sprintf( t('This website expires after %d days.'),intval($sys_expire)) : t('This website does not expire imported content.')) . ' ' . t('The website limit takes precedence if lower than your limit.')), '$maxreq' => array('maxreq', t('Maximum Friend Requests/Day:'), intval($channel['channel_max_friend_req']) , t('May reduce spam activity')), - '$permissions' => t('Default Post Permissions'), + '$permissions' => t('Default Post and Publish Permissions'), '$permdesc' => t("\x28click to open/close\x29"), '$aclselect' => populate_acl($perm_defaults, false, \PermissionDescription::fromDescription(t('Use my default audience setting for the type of object published'))), '$suggestme' => $suggestme,
' . t('Hub URL') . '' . t('Access Type') . '' . t('Registration Policy') . '' . t('Software') . '' . t('Ratings') . '
' . t('Rate') . '
' . $urltext . '' . $location . '' . $jj['access'] . '' . $jj['register'] . ' ' . t('View') . '
' . $urltext . '' . $location . '' . $jj['access'] . '' . $jj['register'] . ' ' . t('View') . '
' . $urltext . '' . $location . '' . $jj['access'] . '' . $jj['register'] . ' ' . t('View') . '
' . $urltext . '' . $location . '' . $jj['access'] . '' . $jj['register'] . '' . ucwords($jj['project']) . ' ' . t('View') . '