summaryrefslogtreecommitdiff
path: root/lib/util.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/util.php')
-rw-r--r--lib/util.php31
1 files changed, 26 insertions, 5 deletions
diff --git a/lib/util.php b/lib/util.php
index 675ff51f0..f862d7fcc 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -519,11 +519,16 @@ function common_shorten_links($text)
function common_shorten_link($url, $reverse = false)
{
+
static $url_cache = array();
if ($reverse) return isset($url_cache[$url]) ? $url_cache[$url] : $url;
$user = common_current_user();
-
+ if (!isset($user)) {
+ // common current user does not find a user when called from the XMPP daemon
+ // therefore we'll set one here fix, so that XMPP given URLs may be shortened
+ $user->urlshorteningservice = 'ur1.ca';
+ }
$curlh = curl_init();
curl_setopt($curlh, CURLOPT_CONNECTTIMEOUT, 20); // # seconds to wait
curl_setopt($curlh, CURLOPT_USERAGENT, 'Laconica');
@@ -874,7 +879,23 @@ function common_broadcast_notice($notice, $remote=false)
function common_enqueue_notice($notice)
{
- foreach (array('jabber', 'omb', 'sms', 'public', 'twitter', 'facebook', 'ping') as $transport) {
+ $transports = array('omb', 'sms', 'twitter', 'facebook', 'ping');
+
+ if (common_config('xmpp', 'enabled')) {
+ $transports = array_merge($transports, array('jabber', 'public'));
+ }
+
+ if (common_config('memcached', 'enabled')) {
+ // Note: limited to 8 chars
+ $transports[] = 'memcache';
+ }
+
+ if (common_config('inboxes', 'enabled') === true ||
+ common_config('inboxes', 'enabled') === 'transitional') {
+ $transports[] = 'inbox';
+ }
+
+ foreach ($transports as $transport) {
$qi = new Queue_item();
$qi->notice_id = $notice->id;
$qi->transport = $transport;
@@ -961,7 +982,7 @@ function common_root_url($ssl=false)
function common_good_rand($bytes)
{
// XXX: use random.org...?
- if (file_exists('/dev/urandom')) {
+ if (@file_exists('/dev/urandom')) {
return common_urandom($bytes);
} else { // FIXME: this is probably not good enough
return common_mtrand($bytes);
@@ -1327,10 +1348,10 @@ function common_compatible_license($from, $to)
*/
function common_database_tablename($tablename)
{
-
+
if(common_config('db','quote_identifiers')) {
$tablename = '"'. $tablename .'"';
}
//table prefixes could be added here later
return $tablename;
-} \ No newline at end of file
+}