From 5ef8199dae8f49cf04888799f1257beef0d2a0e0 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 7 Jun 2016 18:17:39 -0700 Subject: [PATCH 1/3] Finish the config family --- Zotlabs/Lib/AConfig.php | 25 +++ Zotlabs/Lib/AbConfig.php | 73 ++++++++ Zotlabs/Lib/IConfig.php | 165 +++++++++++++++++ Zotlabs/Lib/PConfig.php | 2 +- Zotlabs/Lib/XConfig.php | 160 ++++++++++++++++ include/config.php | 386 ++------------------------------------- 6 files changed, 442 insertions(+), 369 deletions(-) create mode 100644 Zotlabs/Lib/AConfig.php create mode 100644 Zotlabs/Lib/AbConfig.php create mode 100644 Zotlabs/Lib/IConfig.php create mode 100644 Zotlabs/Lib/XConfig.php diff --git a/Zotlabs/Lib/AConfig.php b/Zotlabs/Lib/AConfig.php new file mode 100644 index 000000000..24ec97dfa --- /dev/null +++ b/Zotlabs/Lib/AConfig.php @@ -0,0 +1,25 @@ + $family, 'k' => $key, 'v' => $value, 'sharing' => $sharing); + + if(is_null($idx)) + $item['iconfig'][] = $entry; + else + $item['iconfig'][$idx] = $entry; + return $value; + } + + if(intval($item)) + $iid = intval($item); + + if(! $iid) + return false; + + if(self::Get($item, $family, $key) === false) { + $r = q("insert into iconfig( iid, cat, k, v, sharing ) values ( %d, '%s', '%s', '%s', %d ) ", + intval($iid), + dbesc($family), + dbesc($key), + dbesc($dbvalue), + intval($sharing) + ); + } + else { + $r = q("update iconfig set v = '%s', sharing = %d where iid = %d and cat = '%s' and k = '%s' ", + dbesc($dbvalue), + intval($sharing), + intval($iid), + dbesc($family), + dbesc($key) + ); + } + + if(! $r) + return false; + + return $value; + } + + + + static public function Delete(&$item, $family, $key) { + + + $is_item = false; + $idx = null; + + if(is_array($item)) { + $is_item = true; + if(is_array($item['iconfig'])) { + for($x = 0; $x < count($item['iconfig']); $x ++) { + if($item['iconfig'][$x]['cat'] == $family && $item['iconfig'][$x]['k'] == $key) { + unset($item['iconfig'][$x]); + } + } + } + return true; + } + + if(intval($item)) + $iid = intval($item); + + if(! $iid) + return false; + + return q("delete from iconfig where iid = %d and cat = '%s' and k = '%s' ", + intval($iid), + dbesc($family), + dbesc($key) + ); + + } + +} \ No newline at end of file diff --git a/Zotlabs/Lib/PConfig.php b/Zotlabs/Lib/PConfig.php index 0cd65392e..195321375 100644 --- a/Zotlabs/Lib/PConfig.php +++ b/Zotlabs/Lib/PConfig.php @@ -65,7 +65,7 @@ class PConfig { return false; if(! array_key_exists($uid, \App::$config)) - load_pconfig($uid); + self::Load($uid); if((! array_key_exists($family, \App::$config[$uid])) || (! array_key_exists($key, \App::$config[$uid][$family]))) return false; diff --git a/Zotlabs/Lib/XConfig.php b/Zotlabs/Lib/XConfig.php new file mode 100644 index 000000000..e28dcf559 --- /dev/null +++ b/Zotlabs/Lib/XConfig.php @@ -0,0 +1,160 @@ + $family, 'k' => $key, 'v' => $value, 'sharing' => $sharing); - - if(is_null($idx)) - $item['iconfig'][] = $entry; - else - $item['iconfig'][$idx] = $entry; - return $value; - } - - if(intval($item)) - $iid = intval($item); - - if(! $iid) - return false; - - if(get_iconfig($item, $family, $key) === false) { - $r = q("insert into iconfig( iid, cat, k, v, sharing ) values ( %d, '%s', '%s', '%s', %d ) ", - intval($iid), - dbesc($family), - dbesc($key), - dbesc($dbvalue), - intval($sharing) - ); - } - else { - $r = q("update iconfig set v = '%s', sharing = %d where iid = %d and cat = '%s' and k = '%s' ", - dbesc($dbvalue), - intval($sharing), - intval($iid), - dbesc($family), - dbesc($key) - ); - } - - if(! $r) - return false; - - return $value; + return Zlib\IConfig::Set($item, $family, $key, $value, $sharing = false); } - - function del_iconfig(&$item, $family, $key) { - - - $is_item = false; - $idx = null; - - if(is_array($item)) { - $is_item = true; - if(is_array($item['iconfig'])) { - for($x = 0; $x < count($item['iconfig']); $x ++) { - if($item['iconfig'][$x]['cat'] == $family && $item['iconfig'][$x]['k'] == $key) { - unset($item['iconfig'][$x]); - } - } - } - return true; - } - - if(intval($item)) - $iid = intval($item); - - if(! $iid) - return false; - - return q("delete from iconfig where iid = %d and cat = '%s' and k = '%s' ", - intval($iid), - dbesc($family), - dbesc($key) - ); - + return Zlib\IConfig::Delete($item, $family, $key); } - From e6d20877b8a836891f072122d0e244a647e3cf27 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 7 Jun 2016 18:27:37 -0700 Subject: [PATCH 2/3] whitespace --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 232f122b6..8a6c003fc 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,11 @@ Hubzilla - Community Server =========================== -Groupware re-imagined and re-invented. Connect and link decentralised web communities. --------------------------------------------------------------------------------------- +Groupware re-imagined and re-invented. +-------------------------------------- + +Connect and link decentralised web communities. +-----------------------------------------------

Installing Hubzilla From e46e7002a8945f3156b4c4dcfdedb57316d94ba9 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 7 Jun 2016 22:55:24 -0700 Subject: [PATCH 3/3] block random_profile from accessing sys channels --- include/connections.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/connections.php b/include/connections.php index d18383fad..2d10b8354 100644 --- a/include/connections.php +++ b/include/connections.php @@ -590,7 +590,8 @@ function random_profile() { for($i = 0; $i < $retryrandom; $i++) { - $r = q("select xchan_url from xchan left join hubloc on hubloc_hash = xchan_hash where hubloc_connected > %s - interval %s order by $randfunc limit 1", + $r = q("select xchan_url from xchan left join hubloc on hubloc_hash = xchan_hash where xchan_addr not like '%s' and hubloc_connected > %s - interval %s order by $randfunc limit 1", + dbesc('sys@%'), db_utcnow(), db_quoteinterval('30 day') );