aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--[-rwxr-xr-x]include/Contact.php0
-rw-r--r--[-rwxr-xr-x]include/EmailNotification.php0
-rw-r--r--[-rwxr-xr-x]include/Photo.php0
-rw-r--r--[-rwxr-xr-x]include/Scrape.php0
-rw-r--r--[-rwxr-xr-x]include/acl_selectors.php0
-rw-r--r--[-rwxr-xr-x]include/api.php0
-rw-r--r--[-rwxr-xr-x]include/attach.php0
-rw-r--r--[-rwxr-xr-x]include/auth.php0
-rw-r--r--[-rwxr-xr-x]include/bb2diaspora.php0
-rw-r--r--[-rwxr-xr-x]include/cache.php0
-rw-r--r--[-rwxr-xr-x]include/config.php298
-rw-r--r--[-rwxr-xr-x]include/contact_selectors.php0
-rw-r--r--[-rwxr-xr-x]include/contact_widgets.php0
-rw-r--r--[-rwxr-xr-x]include/conversation.php0
-rw-r--r--[-rwxr-xr-x]include/cronhooks.php0
-rw-r--r--[-rwxr-xr-x]include/crypto.php0
-rw-r--r--[-rwxr-xr-x]include/datetime.php0
-rw-r--r--[-rwxr-xr-x]include/dba.php0
-rw-r--r--[-rwxr-xr-x]include/delivery.php0
-rw-r--r--[-rwxr-xr-x]include/diaspora.php0
-rw-r--r--[-rwxr-xr-x]include/directory.php0
-rw-r--r--[-rwxr-xr-x]include/email.php0
-rw-r--r--[-rwxr-xr-x]include/enotify.php0
-rw-r--r--[-rwxr-xr-x]include/event.php0
-rw-r--r--[-rwxr-xr-x]include/expire.php0
-rw-r--r--[-rwxr-xr-x]include/fcontact.php0
-rw-r--r--[-rwxr-xr-x]include/group.php0
-rw-r--r--[-rwxr-xr-x]include/html2bbcode.php0
-rw-r--r--[-rwxr-xr-x]include/items.php0
-rw-r--r--[-rwxr-xr-x]include/message.php0
-rw-r--r--[-rwxr-xr-x]include/nav.php0
-rw-r--r--[-rwxr-xr-x]include/network.php0
-rw-r--r--[-rwxr-xr-x]include/notifier.php0
-rw-r--r--[-rwxr-xr-x]include/oauth.php0
-rw-r--r--[-rwxr-xr-x]include/oembed.php0
-rw-r--r--[-rwxr-xr-x]include/pgettext.php0
-rw-r--r--[-rwxr-xr-x]include/plugin.php0
-rw-r--r--[-rwxr-xr-x]include/poller.php0
-rw-r--r--[-rwxr-xr-x]include/profile_advanced.php0
-rw-r--r--[-rwxr-xr-x]include/profile_selectors.php0
-rw-r--r--[-rwxr-xr-x]include/profile_update.php0
-rw-r--r--[-rwxr-xr-x]include/queue.php0
-rw-r--r--[-rwxr-xr-x]include/queue_fn.php0
-rw-r--r--[-rwxr-xr-x]include/remoteupdate.php0
-rw-r--r--[-rwxr-xr-x]include/salmon.php0
-rw-r--r--[-rwxr-xr-x]include/security.php0
-rw-r--r--[-rwxr-xr-x]include/session.php0
-rw-r--r--[-rwxr-xr-x]include/socgraph.php0
-rw-r--r--[-rwxr-xr-x]include/system_unavailable.php0
-rw-r--r--[-rwxr-xr-x]include/template_processor.php0
-rw-r--r--include/text.php3
51 files changed, 154 insertions, 147 deletions
diff --git a/include/Contact.php b/include/Contact.php
index d9949b1ef..d9949b1ef 100755..100644
--- a/include/Contact.php
+++ b/include/Contact.php
diff --git a/include/EmailNotification.php b/include/EmailNotification.php
index 8861e8f5d..8861e8f5d 100755..100644
--- a/include/EmailNotification.php
+++ b/include/EmailNotification.php
diff --git a/include/Photo.php b/include/Photo.php
index 4d02b5c65..4d02b5c65 100755..100644
--- a/include/Photo.php
+++ b/include/Photo.php
diff --git a/include/Scrape.php b/include/Scrape.php
index 9c237916b..9c237916b 100755..100644
--- a/include/Scrape.php
+++ b/include/Scrape.php
diff --git a/include/acl_selectors.php b/include/acl_selectors.php
index a5f5aff53..a5f5aff53 100755..100644
--- a/include/acl_selectors.php
+++ b/include/acl_selectors.php
diff --git a/include/api.php b/include/api.php
index 065f14cff..065f14cff 100755..100644
--- a/include/api.php
+++ b/include/api.php
diff --git a/include/attach.php b/include/attach.php
index 6d611cec0..6d611cec0 100755..100644
--- a/include/attach.php
+++ b/include/attach.php
diff --git a/include/auth.php b/include/auth.php
index 1341f3bb8..1341f3bb8 100755..100644
--- a/include/auth.php
+++ b/include/auth.php
diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php
index 8487f845a..8487f845a 100755..100644
--- a/include/bb2diaspora.php
+++ b/include/bb2diaspora.php
diff --git a/include/cache.php b/include/cache.php
index 3c8a3f713..3c8a3f713 100755..100644
--- a/include/cache.php
+++ b/include/cache.php
diff --git a/include/config.php b/include/config.php
index 4cff38090..c999b76f2 100755..100644
--- a/include/config.php
+++ b/include/config.php
@@ -1,80 +1,87 @@
<?php
-
/**
*
* Arbitrary configuration storage
* Note:
* Please do not store booleans - convert to 0/1 integer values
* The get_?config() functions return boolean false for keys that are unset,
- * and this could lead to subtle bugs.
+ * and this could lead to subtle bugs.
*
* There are a few places in the code (such as the admin panel) where boolean
* configurations need to be fixed as of 10/08/2011.
+ *
+ * @package config;
*/
-// retrieve a "family" of config variables from database to cached storage
-
+/**
+ * retrieve a "family" of config variables
+ * from database to cached storage
+ */
if(! function_exists('load_config')) {
-function load_config($family) {
- global $a;
- $r = q("SELECT * FROM `config` WHERE `cat` = '%s'",
- dbesc($family)
- );
- if(count($r)) {
- foreach($r as $rr) {
- $k = $rr['k'];
- if ($rr['cat'] === 'config') {
- $a->config[$k] = $rr['v'];
- } else {
- $a->config[$family][$k] = $rr['v'];
+ function load_config($family) {
+ global $a;
+ $r = q("SELECT * FROM `config` WHERE `cat` = '%s'",
+ dbesc($family)
+ );
+ if(count($r)) {
+ foreach($r as $rr) {
+ $k = $rr['k'];
+ if ($rr['cat'] === 'config') {
+ $a->config[$k] = $rr['v'];
+ } else {
+ $a->config[$family][$k] = $rr['v'];
+ }
}
}
}
-}}
-
-// get a particular config variable given the family name
-// and key. Returns false if not set.
-// $instore is only used by the set_config function
-// to determine if the key already exists in the DB
-// If a key is found in the DB but doesn't exist in
-// local config cache, pull it into the cache so we don't have
-// to hit the DB again for this item.
+}
+/**
+ * get a particular config variable given the family name
+ * and key. Returns false if not set.
+ *
+ * If a key is found in the DB but doesn't exist in
+ * local config cache, pull it into the cache so we don't have
+ *to hit the DB again for this item.
+ */
if(! function_exists('get_config')) {
-function get_config($family, $key, $instore = false) {
+ function get_config($family, $key) {
+
+ global $a;
- global $a;
- if(! $instore) {
if(isset($a->config[$family][$key])) {
if($a->config[$family][$key] === '!<unset>!') {
return false;
}
return $a->config[$family][$key];
}
+ $ret = q("SELECT `v` FROM `config` WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1",
+ dbesc($family),
+ dbesc($key)
+ );
+ if(count($ret)) {
+ // manage array value
+ $val = (preg_match("|^a:[0-9]+:{.*}$|", $ret[0]['v'])?unserialize( $ret[0]['v']):$ret[0]['v']);
+ $a->config[$family][$key] = $val;
+ return $val;
+ }
+ else {
+ $a->config[$family][$key] = '!<unset>!';
+ }
+ return false;
}
- $ret = q("SELECT `v` FROM `config` WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1",
- dbesc($family),
- dbesc($key)
- );
- if(count($ret)) {
- // manage array value
- $val = (preg_match("|^a:[0-9]+:{.*}$|", $ret[0]['v'])?unserialize( $ret[0]['v']):$ret[0]['v']);
- $a->config[$family][$key] = $val;
- return $val;
- }
- else {
- $a->config[$family][$key] = '!<unset>!';
- }
- return false;
-}}
-
-// Store a config value ($value) in the category ($family)
-// under the key ($key)
-// Return the value, or false if the database update failed
+}
+/**
+ * Store a config value ($value) in the category ($family)
+ * under the key ($key)
+ *
+ * Return the value, or false if the database update failed
+ */
if(! function_exists('set_config')) {
+
function set_config($family,$key,$value) {
global $a;
@@ -82,142 +89,139 @@ function set_config($family,$key,$value) {
$dbvalue = (is_array($value)?serialize($value):$value);
$dbvalue = (is_bool($value) ? intval($value) : $value);
- if(get_config($family,$key,true) === false) {
$a->config[$family][$key] = $value;
- $ret = q("INSERT INTO `config` ( `cat`, `k`, `v` ) VALUES ( '%s', '%s', '%s' ) ",
- dbesc($family),
- dbesc($key),
- dbesc($dbvalue)
+ $ret = q("REPLACE INTO `config` ( `cat`, `k`, `v` ) VALUES ( '%s', '%s', '%s' ) ",
+ dbesc($family),
+ dbesc($key),
+ dbesc($dbvalue)
);
- if($ret)
+ if($ret) {
return $value;
+ }
return $ret;
- }
-
- $ret = q("UPDATE `config` SET `v` = '%s' WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1",
- dbesc($dbvalue),
- dbesc($family),
- dbesc($key)
- );
-
- $a->config[$family][$key] = $value;
- if($ret)
- return $value;
- return $ret;
-}}
+ }
+}
if(! function_exists('load_pconfig')) {
-function load_pconfig($uid,$family) {
- global $a;
- $r = q("SELECT * FROM `pconfig` WHERE `cat` = '%s' AND `uid` = %d",
- dbesc($family),
- intval($uid)
- );
- if(count($r)) {
- foreach($r as $rr) {
- $k = $rr['k'];
- $a->config[$uid][$family][$k] = $rr['v'];
+ function load_pconfig($uid,$family) {
+ global $a;
+ $r = q("SELECT * FROM `pconfig` WHERE `cat` = '%s' AND `uid` = %d",
+ dbesc($family),
+ intval($uid)
+ );
+ if(count($r)) {
+ foreach($r as $rr) {
+ $k = $rr['k'];
+ $a->config[$uid][$family][$k] = $rr['v'];
+ }
}
}
-}}
-
+}
+/**
+ * get a particular user-specific config variable given the family name,
+ * the user id and key. Returns false if not set.
+ *
+ * If a key is found in the DB but doesn't exist in
+ * local config cache, pull it into the cache so we don't have
+ * to hit the DB again for this item.
+ */
if(! function_exists('get_pconfig')) {
-function get_pconfig($uid,$family, $key, $instore = false) {
+ function get_pconfig($uid,$family, $key) {
+
+ global $a;
- global $a;
- if(! $instore) {
if(isset($a->config[$uid][$family][$key])) {
if($a->config[$uid][$family][$key] === '!<unset>!') {
return false;
}
return $a->config[$uid][$family][$key];
}
- }
- $ret = q("SELECT `v` FROM `pconfig` WHERE `uid` = %d AND `cat` = '%s' AND `k` = '%s' LIMIT 1",
- intval($uid),
- dbesc($family),
- dbesc($key)
- );
- if(count($ret)) {
- $val = (preg_match("|^a:[0-9]+:{.*}$|", $ret[0]['v'])?unserialize( $ret[0]['v']):$ret[0]['v']);
- $a->config[$uid][$family][$key] = $val;
- return $val;
- }
- else {
- $a->config[$uid][$family][$key] = '!<unset>!';
+ $ret = q("SELECT `v` FROM `pconfig` WHERE `uid` = %d AND `cat` = '%s' AND `k` = '%s' LIMIT 1",
+ intval($uid),
+ dbesc($family),
+ dbesc($key)
+ );
+
+ if(count($ret)) {
+ $val = (preg_match("|^a:[0-9]+:{.*}$|", $ret[0]['v'])?unserialize( $ret[0]['v']):$ret[0]['v']);
+ $a->config[$uid][$family][$key] = $val;
+ return $val;
+ }
+ else {
+ $a->config[$uid][$family][$key] = '!<unset>!';
+ }
+ return false;
}
- return false;
-}}
+}
+/**
+ * Delete a value from config. This function
+ * deletes both: db value and cache entry.
+ */
if(! function_exists('del_config')) {
-function del_config($family,$key) {
-
- global $a;
- if(x($a->config[$family],$key))
- unset($a->config[$family][$key]);
- $ret = q("DELETE FROM `config` WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1",
- dbesc($family),
- dbesc($key)
- );
- return $ret;
-}}
-
-
+ function del_config($family,$key) {
+
+ global $a;
+ if(x($a->config[$family],$key))
+ unset($a->config[$family][$key]);
+ $ret = q("DELETE FROM `config` WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1",
+ dbesc($family),
+ dbesc($key)
+ );
+ return $ret;
+ }
+}
-// Same as above functions except these are for personal config storage and take an
-// additional $uid argument.
+/**
+ * Store a user-specific config value ($value) for user $uid in the category ($family)
+ * under the key ($key).
+ *
+ * Return the value, or false if the database update failed
+ */
if(! function_exists('set_pconfig')) {
-function set_pconfig($uid,$family,$key,$value) {
+ function set_pconfig($uid,$family,$key,$value) {
- global $a;
+ global $a;
+
+ // manage array value
+ $dbvalue = (is_array($value)?serialize($value):$value);
+ $dbvalue = (is_bool($value)?serialize($value):$value);
- // manage array value
- $dbvalue = (is_array($value)?serialize($value):$value);
- if(get_pconfig($uid,$family,$key,true) === false) {
$a->config[$uid][$family][$key] = $value;
- $ret = q("INSERT INTO `pconfig` ( `uid`, `cat`, `k`, `v` ) VALUES ( %d, '%s', '%s', '%s' ) ",
- intval($uid),
- dbesc($family),
- dbesc($key),
- dbesc($dbvalue)
+ $ret = q("REPLACE INTO `pconfig` ( `uid`, `cat`, `k`, `v` ) VALUES ( %d, '%s', '%s', '%s' ) ",
+ intval($uid),
+ dbesc($family),
+ dbesc($key),
+ dbesc($dbvalue)
);
- if($ret)
+ if($ret) {
return $value;
+ }
return $ret;
- }
- $ret = q("UPDATE `pconfig` SET `v` = '%s' WHERE `uid` = %d AND `cat` = '%s' AND `k` = '%s' LIMIT 1",
- dbesc($dbvalue),
- intval($uid),
- dbesc($family),
- dbesc($key)
- );
-
- $a->config[$uid][$family][$key] = $value;
- if($ret)
- return $value;
- return $ret;
-}}
+ }
+}
if(! function_exists('del_pconfig')) {
-function del_pconfig($uid,$family,$key) {
-
- global $a;
- if(x($a->config[$uid][$family],$key))
- unset($a->config[$uid][$family][$key]);
- $ret = q("DELETE FROM `pconfig` WHERE `uid` = %d AND `cat` = '%s' AND `k` = '%s' LIMIT 1",
- intval($uid),
- dbesc($family),
- dbesc($key)
- );
- return $ret;
-}}
+ function del_pconfig($uid,$family,$key) {
+
+ global $a;
+ if(x($a->config[$uid][$family],$key))
+ unset($a->config[$uid][$family][$key]);
+ $ret = q("DELETE FROM `pconfig` WHERE `uid` = %d AND `cat` = '%s' AND `k` = '%s' LIMIT 1",
+ intval($uid),
+ dbesc($family),
+ dbesc($key)
+ );
+ return $ret;
+ }
+}
diff --git a/include/contact_selectors.php b/include/contact_selectors.php
index 4b3ca987a..4b3ca987a 100755..100644
--- a/include/contact_selectors.php
+++ b/include/contact_selectors.php
diff --git a/include/contact_widgets.php b/include/contact_widgets.php
index e0f37f078..e0f37f078 100755..100644
--- a/include/contact_widgets.php
+++ b/include/contact_widgets.php
diff --git a/include/conversation.php b/include/conversation.php
index df92a40ed..df92a40ed 100755..100644
--- a/include/conversation.php
+++ b/include/conversation.php
diff --git a/include/cronhooks.php b/include/cronhooks.php
index 37541f013..37541f013 100755..100644
--- a/include/cronhooks.php
+++ b/include/cronhooks.php
diff --git a/include/crypto.php b/include/crypto.php
index 0feb45c24..0feb45c24 100755..100644
--- a/include/crypto.php
+++ b/include/crypto.php
diff --git a/include/datetime.php b/include/datetime.php
index 6d395fe3f..6d395fe3f 100755..100644
--- a/include/datetime.php
+++ b/include/datetime.php
diff --git a/include/dba.php b/include/dba.php
index 76cc0bc7b..76cc0bc7b 100755..100644
--- a/include/dba.php
+++ b/include/dba.php
diff --git a/include/delivery.php b/include/delivery.php
index 794b8f27a..794b8f27a 100755..100644
--- a/include/delivery.php
+++ b/include/delivery.php
diff --git a/include/diaspora.php b/include/diaspora.php
index 06df9c24a..06df9c24a 100755..100644
--- a/include/diaspora.php
+++ b/include/diaspora.php
diff --git a/include/directory.php b/include/directory.php
index cae78adb4..cae78adb4 100755..100644
--- a/include/directory.php
+++ b/include/directory.php
diff --git a/include/email.php b/include/email.php
index b43ae0dc1..b43ae0dc1 100755..100644
--- a/include/email.php
+++ b/include/email.php
diff --git a/include/enotify.php b/include/enotify.php
index 8385bdec5..8385bdec5 100755..100644
--- a/include/enotify.php
+++ b/include/enotify.php
diff --git a/include/event.php b/include/event.php
index 29202badd..29202badd 100755..100644
--- a/include/event.php
+++ b/include/event.php
diff --git a/include/expire.php b/include/expire.php
index 5fa0ec758..5fa0ec758 100755..100644
--- a/include/expire.php
+++ b/include/expire.php
diff --git a/include/fcontact.php b/include/fcontact.php
index 8821a985f..8821a985f 100755..100644
--- a/include/fcontact.php
+++ b/include/fcontact.php
diff --git a/include/group.php b/include/group.php
index 4a35912e5..4a35912e5 100755..100644
--- a/include/group.php
+++ b/include/group.php
diff --git a/include/html2bbcode.php b/include/html2bbcode.php
index 69ccf41b7..69ccf41b7 100755..100644
--- a/include/html2bbcode.php
+++ b/include/html2bbcode.php
diff --git a/include/items.php b/include/items.php
index ee6960534..ee6960534 100755..100644
--- a/include/items.php
+++ b/include/items.php
diff --git a/include/message.php b/include/message.php
index 377d7c715..377d7c715 100755..100644
--- a/include/message.php
+++ b/include/message.php
diff --git a/include/nav.php b/include/nav.php
index 2c9c643a9..2c9c643a9 100755..100644
--- a/include/nav.php
+++ b/include/nav.php
diff --git a/include/network.php b/include/network.php
index 38d0980d5..38d0980d5 100755..100644
--- a/include/network.php
+++ b/include/network.php
diff --git a/include/notifier.php b/include/notifier.php
index ca7c7b92e..ca7c7b92e 100755..100644
--- a/include/notifier.php
+++ b/include/notifier.php
diff --git a/include/oauth.php b/include/oauth.php
index 2724dcf7c..2724dcf7c 100755..100644
--- a/include/oauth.php
+++ b/include/oauth.php
diff --git a/include/oembed.php b/include/oembed.php
index 1f45d2814..1f45d2814 100755..100644
--- a/include/oembed.php
+++ b/include/oembed.php
diff --git a/include/pgettext.php b/include/pgettext.php
index 83e76ba9d..83e76ba9d 100755..100644
--- a/include/pgettext.php
+++ b/include/pgettext.php
diff --git a/include/plugin.php b/include/plugin.php
index e37ae8435..e37ae8435 100755..100644
--- a/include/plugin.php
+++ b/include/plugin.php
diff --git a/include/poller.php b/include/poller.php
index 90a97867c..90a97867c 100755..100644
--- a/include/poller.php
+++ b/include/poller.php
diff --git a/include/profile_advanced.php b/include/profile_advanced.php
index 004a58524..004a58524 100755..100644
--- a/include/profile_advanced.php
+++ b/include/profile_advanced.php
diff --git a/include/profile_selectors.php b/include/profile_selectors.php
index 92579f64a..92579f64a 100755..100644
--- a/include/profile_selectors.php
+++ b/include/profile_selectors.php
diff --git a/include/profile_update.php b/include/profile_update.php
index 61eaee75d..61eaee75d 100755..100644
--- a/include/profile_update.php
+++ b/include/profile_update.php
diff --git a/include/queue.php b/include/queue.php
index 7e92705be..7e92705be 100755..100644
--- a/include/queue.php
+++ b/include/queue.php
diff --git a/include/queue_fn.php b/include/queue_fn.php
index 3c1087f4e..3c1087f4e 100755..100644
--- a/include/queue_fn.php
+++ b/include/queue_fn.php
diff --git a/include/remoteupdate.php b/include/remoteupdate.php
index 9effc9b6e..9effc9b6e 100755..100644
--- a/include/remoteupdate.php
+++ b/include/remoteupdate.php
diff --git a/include/salmon.php b/include/salmon.php
index 3d525f51a..3d525f51a 100755..100644
--- a/include/salmon.php
+++ b/include/salmon.php
diff --git a/include/security.php b/include/security.php
index 66622fd33..66622fd33 100755..100644
--- a/include/security.php
+++ b/include/security.php
diff --git a/include/session.php b/include/session.php
index 6c32e299f..6c32e299f 100755..100644
--- a/include/session.php
+++ b/include/session.php
diff --git a/include/socgraph.php b/include/socgraph.php
index 3f5194049..3f5194049 100755..100644
--- a/include/socgraph.php
+++ b/include/socgraph.php
diff --git a/include/system_unavailable.php b/include/system_unavailable.php
index bd7196cdf..bd7196cdf 100755..100644
--- a/include/system_unavailable.php
+++ b/include/system_unavailable.php
diff --git a/include/template_processor.php b/include/template_processor.php
index 4c317efe1..4c317efe1 100755..100644
--- a/include/template_processor.php
+++ b/include/template_processor.php
diff --git a/include/text.php b/include/text.php
index 5456b5ad3..29c781030 100644
--- a/include/text.php
+++ b/include/text.php
@@ -80,6 +80,9 @@ function escape_tags($string) {
if(! function_exists('autoname')) {
function autoname($len) {
+ if(! $len)
+ return '';
+
$vowels = array('a','a','ai','au','e','e','e','ee','ea','i','ie','o','ou','u');
if(mt_rand(0,5) == 4)
$vowels[] = 'y';