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));
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/Pubsites.php b/Zotlabs/Module/Pubsites.php
index 9313a3c5a..55f2c0ad6 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 .= '
' . t('Hub URL') . ' | ' . t('Access Type') . ' | ' . t('Registration Policy') . ' | ' . t('Ratings') . ' |
';
+ $o .= '' . t('Hub URL') . ' | ' . t('Access Type') . ' | ' . t('Registration Policy') . ' | ' . t('Software') . ' | ' . 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()) ? ' ' . t('Rate') . ' | ' : '');
@@ -43,7 +43,7 @@ class Pubsites extends \Zotlabs\Web\Controller {
$location = '
';
}
$urltext = str_replace(array('https://'), '', $jj['url']);
- $o .= ' ' . $urltext . '' . $location . ' | ' . $jj['access'] . ' | ' . $jj['register'] . ' | ' . t('View') . ' | ' . $rate_links . '
';
+ $o .= ' ' . $urltext . '' . $location . ' | ' . $jj['access'] . ' | ' . $jj['register'] . ' | ' . ucwords($jj['project']) . ' | ' . t('View') . ' | ' . $rate_links . '
';
}
}
diff --git a/Zotlabs/Module/Settings.php b/Zotlabs/Module/Settings.php
index a6293e842..f588e2824 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'),
+ '$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 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/Project/System.php b/Zotlabs/Project/System.php
index f61313da0..d95bd033c 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;
}
@@ -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/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/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
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/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/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/Zotlabs/Web/Session.php b/Zotlabs/Web/Session.php
index c26b3523c..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)
);
@@ -82,6 +87,7 @@ class Session {
$arr = session_get_cookie_params();
if($this->handler && $this->session_started) {
+
session_regenerate_id(true);
// force SessionHandler record creation with the new session_id
@@ -93,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);
@@ -111,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);
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/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"),
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/dba/dba_driver.php b/include/dba/dba_driver.php
index 4a1752672..e15e107a8 100755
--- a/include/dba/dba_driver.php
+++ b/include/dba/dba_driver.php
@@ -32,17 +32,25 @@ 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);
+// }
+
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);
}
}
+ // 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.
+
+
if(is_object($dba) && $dba->connected) {
$dns = (($dbtype == DBTYPE_POSTGRES) ? 'postgres' : 'mysql')
. ':host=' . $server . (is_null($port) ? '' : ';port=' . $port)
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
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/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 {
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/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/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/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);
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();
}
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);
}