aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/account.php55
-rw-r--r--include/auth.php12
-rw-r--r--include/follow.php131
-rw-r--r--include/identity.php7
-rwxr-xr-xinclude/items.php50
-rw-r--r--include/language.php171
-rw-r--r--include/menu.php2
-rw-r--r--include/permissions.php21
-rw-r--r--include/photo/photo_driver.php16
-rw-r--r--include/poller.php13
-rwxr-xr-xinclude/text.php37
11 files changed, 317 insertions, 198 deletions
diff --git a/include/account.php b/include/account.php
index 7d1aa598d..1206223d9 100644
--- a/include/account.php
+++ b/include/account.php
@@ -401,3 +401,58 @@ function user_deny($hash) {
return true;
}
+
+
+/**
+ * @function downgrade_accounts()
+ * Checks for accounts that have past their expiration date.
+ * If the account has a service class which is not the site default,
+ * the service class is reset to the site default and expiration reset to never.
+ * If the account has no service class it is expired and subsequently disabled.
+ * called from include/poller.php as a scheduled task.
+ *
+ * Reclaiming resources which are no longer within the service class limits is
+ * not the job of this function, but this can be implemented by plugin if desired.
+ * Default behaviour is to stop allowing additional resources to be consumed.
+ */
+
+
+function downgrade_accounts() {
+
+ $r = q("select * from account where not ( account_flags & %d )
+ and account_expires != '0000-00-00 00:00:00'
+ and account_expires < UTC_TIMESTAMP() ",
+ intval(ACCOUNT_EXPIRED)
+ );
+
+ if(! $r)
+ return;
+
+ $basic = get_config('system','default_service_class');
+
+
+ foreach($r as $rr) {
+
+ if(($basic) && ($rr['account_service_class']) && ($rr['account_service_class'] != $basic)) {
+ $x = q("UPDATE account set account_service_class = '%s', account_expires = '%s'
+ where account_id = %d limit 1",
+ dbesc($basic),
+ dbesc('0000-00-00 00:00:00'),
+ intval($rr['account_id'])
+ );
+ $ret = array('account' => $rr);
+ call_hooks('account_downgrade', $ret );
+ logger('downgrade_accounts: Account id ' . $rr['account_id'] . ' downgraded.');
+ }
+ else {
+ $x = q("UPDATE account SET account_flags = (account_flags | %d) where account_id = %d limit 1",
+ intval(ACCOUNT_EXPIRED),
+ intval($rr['account_id'])
+ );
+ $ret = array('account' => $rr);
+ call_hooks('account_downgrade', $ret);
+ logger('downgrade_accounts: Account id ' . $rr['account_id'] . ' expired.');
+ }
+ }
+}
+
diff --git a/include/auth.php b/include/auth.php
index 2b7c385fd..a3b028c73 100644
--- a/include/auth.php
+++ b/include/auth.php
@@ -93,7 +93,7 @@ if((isset($_SESSION)) && (x($_SESSION,'authenticated')) && ((! (x($_POST,'auth-p
}
}
- $r = q("select * from hubloc left join xchan on xchan_hash = hubloc_hash where hubloc_hash = '%s' limit 1",
+ $r = q("select * from xchan left join hubloc on xchan_hash = hubloc_hash where xchan_hash = '%s' limit 1",
dbesc($_SESSION['visitor_id'])
);
if($r) {
@@ -230,3 +230,13 @@ else {
authenticate_success($record, true, true);
}
}
+
+
+function match_openid($authid) {
+ $r = q("select * from pconfig where cat = 'system' and k = 'openid' and v = '%s' limit 1",
+ dbesc($authid)
+ );
+ if($r)
+ return $r[0]['uid'];
+ return false;
+}
diff --git a/include/follow.php b/include/follow.php
index 845ce11da..0508a8b37 100644
--- a/include/follow.php
+++ b/include/follow.php
@@ -16,6 +16,8 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
$result = array('success' => false,'message' => '');
$a = get_app();
+ $is_red = false;
+
if(! allowed_url($url)) {
$result['message'] = t('Channel is blocked on this site.');
@@ -37,82 +39,94 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
$ret = zot_finger($url,$channel);
if($ret['success']) {
+ $is_red = true;
$j = json_decode($ret['body'],true);
}
- else {
- $result['message'] = t('Channel discovery failed. Website may be down or misconfigured.');
- logger('mod_follow: ' . $result['message']);
- return $result;
- }
- logger('follow: ' . $url . ' ' . print_r($j,true));
+ if($is_red && $j) {
- if(! $j) {
- $result['message'] = t('Response from remote channel was not understood.');
- logger('mod_follow: ' . $result['message']);
- return $result;
- }
+ $my_perms = PERMS_W_STREAM|PERMS_W_MAIL;
+ logger('follow: ' . $url . ' ' . print_r($j,true), LOGGER_DEBUG);
- if(! ($j['success'] && $j['guid'])) {
- $result['message'] = t('Response from remote channel was incomplete.');
- logger('mod_follow: ' . $result['message']);
- return $result;
- }
- // Premium channel, set confirm before callback to avoid recursion
+ if(! ($j['success'] && $j['guid'])) {
+ $result['message'] = t('Response from remote channel was incomplete.');
+ logger('mod_follow: ' . $result['message']);
+ return $result;
+ }
- if(array_key_exists('connect_url',$j) && (! $confirm))
- goaway(zid($j['connect_url']));
+ // Premium channel, set confirm before callback to avoid recursion
+ if(array_key_exists('connect_url',$j) && (! $confirm))
+ goaway(zid($j['connect_url']));
- // check service class limits
+ // check service class limits
- $r = q("select count(*) as total from abook where abook_channel = %d and not (abook_flags & %d) ",
- intval($uid),
- intval(ABOOK_FLAG_SELF)
- );
- if($r)
- $total_channels = $r[0]['total'];
+ $r = q("select count(*) as total from abook where abook_channel = %d and not (abook_flags & %d) ",
+ intval($uid),
+ intval(ABOOK_FLAG_SELF)
+ );
+ if($r)
+ $total_channels = $r[0]['total'];
- if(! service_class_allows($uid,'total_channels',$total_channels)) {
- $result['message'] = upgrade_message();
- return $result;
- }
+ if(! service_class_allows($uid,'total_channels',$total_channels)) {
+ $result['message'] = upgrade_message();
+ return $result;
+ }
- // do we have an xchan and hubloc?
- // If not, create them.
+ // do we have an xchan and hubloc?
+ // If not, create them.
- $x = import_xchan($j);
+ $x = import_xchan($j);
- if(! $x['success'])
- return $x;
+ if(! $x['success'])
+ return $x;
- $xchan_hash = $x['hash'];
+ $xchan_hash = $x['hash'];
- $their_perms = 0;
+ $their_perms = 0;
- $global_perms = get_perms();
+ $global_perms = get_perms();
- if( array_key_exists('permissions',$j) && array_key_exists('data',$j['permissions'])) {
- $permissions = crypto_unencapsulate(array(
- 'data' => $j['permissions']['data'],
- 'key' => $j['permissions']['key'],
- 'iv' => $j['permissions']['iv']),
- $channel['channel_prvkey']);
- if($permissions)
- $permissions = json_decode($permissions,true);
- logger('decrypted permissions: ' . print_r($permissions,true), LOGGER_DATA);
- }
- else
- $permissions = $j['permissions'];
+ if( array_key_exists('permissions',$j) && array_key_exists('data',$j['permissions'])) {
+ $permissions = crypto_unencapsulate(array(
+ 'data' => $j['permissions']['data'],
+ 'key' => $j['permissions']['key'],
+ 'iv' => $j['permissions']['iv']),
+ $channel['channel_prvkey']);
+ if($permissions)
+ $permissions = json_decode($permissions,true);
+ logger('decrypted permissions: ' . print_r($permissions,true), LOGGER_DATA);
+ }
+ else
+ $permissions = $j['permissions'];
- foreach($permissions as $k => $v) {
- if($v) {
- $their_perms = $their_perms | intval($global_perms[$k][1]);
+ foreach($permissions as $k => $v) {
+ if($v) {
+ $their_perms = $their_perms | intval($global_perms[$k][1]);
+ }
}
}
+ else {
+
+ // attempt network auto-discovery
+
+ $my_perms = 0;
+ $their_perms = 0;
+ $xchan_hash = '';
+
+
+
+
+ }
+
+ if(! $xchan_hash) {
+ $result['message'] = t('Channel discovery failed.');
+ logger('follow: ' . $result['message']);
+ return $result;
+ }
if((local_user()) && $uid == local_user()) {
$aid = get_account_id();
@@ -156,7 +170,7 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
intval($uid),
dbesc($xchan_hash),
intval($their_perms),
- intval(PERMS_W_STREAM|PERMS_W_MAIL),
+ intval($my_perms),
dbesc(datetime_convert()),
dbesc(datetime_convert())
);
@@ -172,7 +186,8 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
);
if($r) {
$result['abook'] = $r[0];
- proc_run('php', 'include/notifier.php', 'permission_update', $result['abook']['abook_id']);
+ if($is_red)
+ proc_run('php', 'include/notifier.php', 'permission_update', $result['abook']['abook_id']);
}
$arr = array('channel_id' => $uid, 'abook' => $result['abook']);
@@ -188,12 +203,6 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
group_add_member($uid,'',$xchan_hash,$g['id']);
}
- // Then send a ping/message to the other side
-
-
$result['success'] = true;
return $result;
-
-
-
}
diff --git a/include/identity.php b/include/identity.php
index d0fffaede..d83498a69 100644
--- a/include/identity.php
+++ b/include/identity.php
@@ -1104,6 +1104,11 @@ function get_theme_uid() {
if(! $uid)
return local_user();
}
+ if(! $uid) {
+ $x = get_sys_channel();
+ if($x)
+ return $x['channel_id'];
+ }
return $uid;
}
@@ -1137,7 +1142,7 @@ function get_default_profile_photo($size = 175) {
*/
function is_foreigner($s) {
- return((strpbrk($s,':@')) ? true : false);
+ return((strpbrk($s,'.:@')) ? true : false);
}
diff --git a/include/items.php b/include/items.php
index c90bfb41c..7e15e9411 100755
--- a/include/items.php
+++ b/include/items.php
@@ -725,14 +725,60 @@ function import_author_xchan($x) {
return $arr['xchan_hash'];
if((! array_key_exists('network', $x)) || ($x['network'] === 'zot')) {
- return import_author_zot($x);
+ $y = import_author_zot($x);
}
- // TODO: create xchans for other common and/or aligned networks
+ if($x['network'] === 'rss') {
+ $y = import_author_rss($x);
+ }
+
+ return(($y) ? $y : false);
+}
+
+function import_author_rss($x) {
+
+ if(! $x['url'])
+ return false;
+
+ $r = q("select xchan_hash from xchan where xchan_network = 'rss' and xchan_url = '%s' limit 1",
+ dbesc($x['url'])
+ );
+ if($r) {
+ logger('import_author_rss: in cache' , LOGGER_DEBUG);
+ return $r[0]['xchan_hash'];
+ }
+ $name = trim($x['name']);
+
+ $r = q("insert into xchan ( xchan_hash, xchan_url, xchan_name, xchan_network )
+ values ( '%s', '%s', '%s', '%s' )",
+ dbesc($x['url']),
+ dbesc($x['url']),
+ dbesc(($name) ? $name : t('Unknown')),
+ dbesc('rss')
+ );
+ if($r) {
+
+ $photos = import_profile_photo($x['photo'],$x['url']);
+
+ if($photos) {
+ $r = q("update xchan set xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' where xchan_url = '%s' and xchan_network = 'rss' limit 1",
+ dbesc(datetime_convert('UTC','UTC',$arr['photo_updated'])),
+ dbesc($photos[0]),
+ dbesc($photos[1]),
+ dbesc($photos[2]),
+ dbesc($photos[3]),
+ dbesc($x['url'])
+ );
+ if($r)
+ return $x['url'];
+ }
+ }
return false;
+
}
+
function encode_item($item) {
$x = array();
$x['type'] = 'activity';
diff --git a/include/language.php b/include/language.php
index 2e7ad5ff1..b43f5aacc 100644
--- a/include/language.php
+++ b/include/language.php
@@ -1,22 +1,28 @@
-<?php /** @file */
-
-
+<?php
/**
- * translation support
+ * @file
+ *
+ * @brief translation support
+ *
+ * This file contains functions to work with translations and other
+ * language related tasks.
*/
/**
+ * @brief Get the browser's submitted preferred languages.
+ *
+ * This functions parses the HTTP_ACCEPT_LANGUAGE header sent by the browser and
+ * extracts the preferred languages and their priority.
*
* Get the language setting directly from system variables, bypassing get_config()
* as database may not yet be configured.
*
* If possible, we use the value from the browser.
*
+ * @return array with ordered list of preferred languages from browser
*/
-
function get_browser_language() {
-
$langs = array();
if (x($_SERVER,'HTTP_ACCEPT_LANGUAGE')) {
@@ -43,9 +49,18 @@ function get_browser_language() {
return $langs;
}
-
+/**
+ * @brief Returns the best language for which also a translation exists.
+ *
+ * This function takes the results from get_browser_language() and compares it
+ * with the available translations and returns the best fitting language for
+ * which there exists a translation.
+ *
+ * If there is no match fall back to config['system']['language']
+ *
+ * @return Language code in 2-letter ISO 639-1 (en).
+ */
function get_best_language() {
-
$langs = get_browser_language();
if(isset($langs) && count($langs)) {
@@ -79,7 +94,6 @@ function push_lang($language) {
$a->strings = array();
load_translation_table($language);
$a->language = $language;
-
}
function pop_lang() {
@@ -109,7 +123,7 @@ function load_translation_table($lang, $install = false) {
if(! $install) {
$plugins = q("SELECT name FROM addon WHERE installed=1;");
- if ($plugins!==false) {
+ if ($plugins !== false) {
foreach($plugins as $p) {
$name = $p['name'];
if(file_exists("addon/$name/lang/$lang/strings.php")) {
@@ -128,15 +142,18 @@ function load_translation_table($lang, $install = false) {
}
-// translate string if translation exists
-
+/**
+ * @brief translate string if translation exists.
+ *
+ * @param s string that should get translated
+ * @return translated string if exsists, otherwise s
+ */
function t($s) {
-
global $a;
if(x($a->strings,$s)) {
$t = $a->strings[$s];
- return is_array($t)?$t[0]:$t;
+ return is_array($t) ? $t[0] : $t;
}
return $s;
}
@@ -147,14 +164,14 @@ function tt($singular, $plural, $count){
if(x($a->strings,$singular)) {
$t = $a->strings[$singular];
- $f = 'string_plural_select_' . str_replace('-','_',$a->language);
+ $f = 'string_plural_select_' . str_replace('-', '_', $a->language);
if(! function_exists($f))
$f = 'string_plural_select_default';
$k = $f($count);
- return is_array($t)?$t[$k]:$t;
+ return is_array($t) ? $t[$k] : $t;
}
- if ($count!=1){
+ if ($count != 1){
return $plural;
} else {
return $singular;
@@ -168,84 +185,47 @@ function string_plural_select_default($n) {
return ($n != 1);
}
-
-
+/**
+ * @brief Takes a string and tries to identify the language.
+ *
+ * It uses the pear library Text_LanguageDetect and it can identify 52 human languages.
+ * It returns the identified languges and a confidence score for each.
+ *
+ * Strings need to have a min length config['system']['language_detect_min_length']
+ * and you can influence the confidence that must be met before a result will get
+ * returned through config['system']['language_detect_min_confidence'].
+ *
+ * @see http://pear.php.net/package/Text_LanguageDetect
+ * @param s A string to examine
+ * @return Language code in 2-letter ISO 639-1 (en, de, fr) format
+ */
function detect_language($s) {
-
- $detected_languages = array(
- 'Albanian' => 'sq',
- 'Arabic' => 'ar',
- 'Azeri' => 'az',
- 'Bengali' => 'bn',
- 'Bulgarian' => 'bg',
- 'Cebuano' => '',
- 'Croatian' => 'hr',
- 'Czech' => 'cz',
- 'Danish' => 'da',
- 'Dutch' => 'nl',
- 'English' => 'en',
- 'Estonian' => 'et',
- 'Farsi' => 'fa',
- 'Finnish' => 'fi',
- 'French' => 'fr',
- 'German' => 'de',
- 'Hausa' => 'ha',
- 'Hawaiian' => '',
- 'Hindi' => 'hi',
- 'Hungarian' => 'hu',
- 'Icelandic' => 'is',
- 'Indonesian' => 'id',
- 'Italian' => 'it',
- 'Kazakh' => 'kk',
- 'Kyrgyz' => 'ky',
- 'Latin' => 'la',
- 'Latvian' => 'lv',
- 'Lithuanian' => 'lt',
- 'Macedonian' => 'mk',
- 'Mongolian' => 'mn',
- 'Nepali' => 'ne',
- 'Norwegian' => 'no',
- 'Pashto' => 'ps',
- 'Pidgin' => '',
- 'Polish' => 'pl',
- 'Portuguese' => 'pt',
- 'Romanian' => 'ro',
- 'Russian' => 'ru',
- 'Serbian' => 'sr',
- 'Slovak' => 'sk',
- 'Slovene' => 'sl',
- 'Somali' => 'so',
- 'Spanish' => 'es',
- 'Swahili' => 'sw',
- 'Swedish' => 'sv',
- 'Tagalog' => 'tl',
- 'Turkish' => 'tr',
- 'Ukrainian' => 'uk',
- 'Urdu' => 'ur',
- 'Uzbek' => 'uz',
- 'Vietnamese' => 'vi',
- 'Welsh' => 'cy'
- );
-
require_once('Text/LanguageDetect.php');
- $min_length = get_config('system','language_detect_min_length');
+ $min_length = get_config('system', 'language_detect_min_length');
if($min_length === false)
$min_length = LANGUAGE_DETECT_MIN_LENGTH;
- $min_confidence = get_config('system','language_detect_min_confidence');
+ $min_confidence = get_config('system', 'language_detect_min_confidence');
if($min_confidence === false)
$min_confidence = LANGUAGE_DETECT_MIN_CONFIDENCE;
-
- $naked_body = preg_replace('/\[(.+?)\]/','',$s);
- if(mb_strlen($naked_body) < intval($min_length))
+ // strip off bbcode
+ $naked_body = preg_replace('/\[(.+?)\]/', '', $s);
+ if(mb_strlen($naked_body) < intval($min_length)) {
+ logger('detect language: string length less than ' . intval($min_length), LOGGER_DATA);
return '';
+ }
$l = new Text_LanguageDetect;
- $lng = $l->detectConfidence($naked_body);
-
- logger('detect language: ' . print_r($lng,true) . $naked_body, LOGGER_DATA);
+ try {
+ // return 2-letter ISO 639-1 (en) language code
+ $l->setNameMode(2);
+ $lng = $l->detectConfidence($naked_body);
+ logger('detect language: ' . print_r($lng, true) . $naked_body, LOGGER_DATA);
+ } catch (Text_LanguageDetect_Exception $e) {
+ logger('detect language exception: ' . $e->getMessage(), LOGGER_DATA);
+ }
if((! $lng) || (! (x($lng,'language')))) {
return '';
@@ -256,6 +236,29 @@ function detect_language($s) {
return '';
}
- return(($lng && (x($lng,'language'))) ? $detected_languages[ucfirst($lng['language'])] : '');
+ return($lng['language']);
+}
+
+/**
+ * @brief Returns the display name of a given language code.
+ *
+ * By default we use the localized language name. You can switch the result
+ * to any language with the optional 2nd parameter $l.
+ *
+ * $s and $l can be in any format that PHP's Locale understands. We will mostly
+ * use the 2-letter ISO 639-1 (en, de, fr) format.
+ *
+ * If nothing could be looked up it returns $s.
+ *
+ * @param $s Language code to look up
+ * @param $l (optional) In which language to return the name
+ * @return string with the language name, or $s if unrecognized
+ */
+function get_language_name($s, $l = null) {
+ if($l === null)
+ $l = $s;
+ logger('get_language_name: for ' . $s . ' in ' . $l . ' returns: ' . Locale::getDisplayLanguage($s, $l), LOGGER_DEBUG);
+ return Locale::getDisplayLanguage($s, $l);
}
+
diff --git a/include/menu.php b/include/menu.php
index e9049bf8e..2f1719d0b 100644
--- a/include/menu.php
+++ b/include/menu.php
@@ -38,7 +38,7 @@ function menu_render($menu, $edit = false) {
return replace_macros(get_markup_template('usermenu.tpl'),array(
'$menu' => $menu['menu'],
- '$edit' => $edit,
+ '$edit' => (($edit) ? t("Edit") : ''),
'$items' => $menu['items']
));
}
diff --git a/include/permissions.php b/include/permissions.php
index 420591c54..eb1a7966f 100644
--- a/include/permissions.php
+++ b/include/permissions.php
@@ -88,8 +88,13 @@ function get_all_perms($uid,$observer_xchan,$internal_use = true) {
// These take priority over all other settings.
if($observer_xchan) {
+ if($r[0][$channel_perm] & PERMS_AUTHED) {
+ $ret[$perm_name] = true;
+ continue;
+ }
+
if(! $abook_checked) {
- $x = q("select abook_my_perms, abook_flags from abook
+ $x = q("select abook_my_perms, abook_flags, xchan_network from abook left join xchan on abook_xchan = xchan_hash
where abook_channel = %d and abook_xchan = '%s' and not ( abook_flags & %d ) limit 1",
intval($uid),
dbesc($observer_xchan),
@@ -137,9 +142,9 @@ function get_all_perms($uid,$observer_xchan,$internal_use = true) {
continue;
}
- // If we're still here, we have an observer, which means they're in the network.
+ // If we're still here, we have an observer, check the network.
- if($r[0][$channel_perm] & PERMS_NETWORK) {
+ if(($r[0][$channel_perm] & PERMS_NETWORK) && ($x[0]['xchan_network'] === 'zot')) {
$ret[$perm_name] = true;
continue;
}
@@ -240,7 +245,11 @@ function perm_is_allowed($uid,$observer_xchan,$permission) {
return false;
if($observer_xchan) {
- $x = q("select abook_my_perms, abook_flags from abook where abook_channel = %d and abook_xchan = '%s' and not ( abook_flags & %d ) limit 1",
+ if($r[0][$channel_perm] & PERMS_AUTHED)
+ return true;
+
+ $x = q("select abook_my_perms, abook_flags, xchan_network from abook left join xchan on abook_xchan = xchan_hash
+ where abook_channel = %d and abook_xchan = '%s' and not ( abook_flags & %d ) limit 1",
intval($uid),
dbesc($observer_xchan),
intval(ABOOK_FLAG_SELF)
@@ -272,9 +281,9 @@ function perm_is_allowed($uid,$observer_xchan,$permission) {
return false;
}
- // If we're still here, we have an observer, which means they're in the network.
+ // If we're still here, we have an observer, check the network.
- if($r[0][$channel_perm] & PERMS_NETWORK)
+ if(($r[0][$channel_perm] & PERMS_NETWORK) && ($x[0]['xchan_network'] === 'zot'))
return true;
diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php
index c2eeafa54..484550cb7 100644
--- a/include/photo/photo_driver.php
+++ b/include/photo/photo_driver.php
@@ -538,14 +538,20 @@ function import_profile_photo($photo,$xchan,$thing = false) {
}
$photo_failure = false;
+ $img_str = '';
+ if($photo) {
+ $filename = basename($photo);
+ $type = guess_image_type($photo,true);
- $filename = basename($photo);
- $type = guess_image_type($photo,true);
- $result = z_fetch_url($photo,true);
+ if(! $type)
+ $type = 'image/jpeg';
- if($result['success'])
- $img_str = $result['body'];
+ $result = z_fetch_url($photo,true);
+
+ if($result['success'])
+ $img_str = $result['body'];
+ }
$img = photo_factory($img_str, $type);
if($img->is_valid()) {
diff --git a/include/poller.php b/include/poller.php
index ce9b75eb3..1c6f68eab 100644
--- a/include/poller.php
+++ b/include/poller.php
@@ -32,16 +32,6 @@ function poller_run($argv, $argc){
proc_run('php',"include/queue.php");
- // expire any expired accounts
-
- q("UPDATE account
- SET account_flags = (account_flags | %d)
- where not (account_flags & %d)
- and account_expires != '0000-00-00 00:00:00'
- and account_expires < UTC_TIMESTAMP() ",
- intval(ACCOUNT_EXPIRED),
- intval(ACCOUNT_EXPIRED)
- );
// expire any expired mail
@@ -115,6 +105,9 @@ function poller_run($argv, $argc){
q("delete from notify where seen = 1 and date < UTC_TIMESTAMP() - INTERVAL 30 DAY");
+ // expire any expired accounts
+ require_once('include/account.php');
+ downgrade_accounts();
// If this is a directory server, request a sync with an upstream
// directory at least once a day, up to once every poll interval.
diff --git a/include/text.php b/include/text.php
index 2f5accf6e..dfd35c769 100755
--- a/include/text.php
+++ b/include/text.php
@@ -1324,24 +1324,15 @@ function prepare_text($text,$content_type = 'text/bbcode') {
function zidify_callback($match) {
- if (feature_enabled(local_user(),'sendzid')) {
- $replace = '<a' . $match[1] . ' href="' . zid($match[2]) . '"';
- }
- else {
- $replace = '<a' . $match[1] . 'class="zrl"' . $match[2] . ' href="' . zid($match[3]) . '"';
- }
-
+ $is_zid = ((feature_enabled(local_user(),'sendzid')) || (strpos($match[1],'zrl')) ? true : false);
+ $replace = '<a' . $match[1] . ' href="' . (($is_zid) ? zid($match[2]) : $match[2]) . '"';
$x = str_replace($match[0],$replace,$match[0]);
return $x;
}
function zidify_img_callback($match) {
- if (feature_enabled(local_user(),'sendzid')) {
- $replace = '<img' . $match[1] . ' src="' . zid($match[2]) . '"';
- }
- else {
- $replace = '<img' . $match[1] . ' src="' . zid($match[2]) . '"';
- }
+ $is_zid = ((feature_enabled(local_user(),'sendzid')) || (strpos($match[1],'zrl')) ? true : false);
+ $replace = '<img' . $match[1] . ' src="' . (($is_zid) ? zid($match[2]) : $match[2]) . '"';
$x = str_replace($match[0],$replace,$match[0]);
return $x;
@@ -1349,25 +1340,13 @@ function zidify_img_callback($match) {
function zidify_links($s) {
- if(feature_enabled(local_user(),'sendzid')) {
- $s = preg_replace_callback('/\<a(.*?)href\=\"(.*?)\"/ism','zidify_callback',$s);
- $s = preg_replace_callback('/\<img(.*?)src\=\"(.*?)\"/ism','zidify_img_callback',$s);
- }
- else {
- $s = preg_replace_callback('/\<a(.*?)class\=\"zrl\"(.*?)href\=\"(.*?)\"/ism','zidify_callback',$s);
- $s = preg_replace_callback('/\<img class\=\"zrl\"(.*?)src\=\"(.*?)\"/ism','zidify_img_callback',$s);
-// FIXME - remove the following line and redo the regex for the prev line once all Red images are converted to zmg
- $s = preg_replace_callback('/\<img(.*?)src\=\"(.*?)\"/ism','zidify_img_callback',$s);
- }
-
+ $s = preg_replace_callback('/\<a(.*?)href\=\"(.*?)\"/ism','zidify_callback',$s);
+ $s = preg_replace_callback('/\<img(.*?)src\=\"(.*?)\"/ism','zidify_img_callback',$s);
return $s;
}
-
-
-
/**
* return atom link elements for all of our hubs
*/
@@ -1924,3 +1903,7 @@ function in_arrayi($needle, $haystack) {
return in_array(strtolower($needle), array_map('strtolower', $haystack));
}
+function normalise_openid($s) {
+ return trim(str_replace(array('http://','https://'),array('',''),$s),'/');
+}
+