X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=lib%2Futil.php;h=2da767a04400ceaf7ff191ea63144a755f90e432;hb=dd4c0ebaa8717012e8bae58088c1a2760152bc41;hp=c6cdfbcb949ab0d447802ce55461f9b53cbd5fb3;hpb=c4d67892751b17856b235182874c3304890dc2c3;p=quix0rs-gnu-social.git
diff --git a/lib/util.php b/lib/util.php
index c6cdfbcb94..2da767a044 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -136,7 +136,7 @@ function common_init_language() {
$language = common_language();
# So we don't have to make people install the gettext locales
putenv('LANGUAGE='.$language);
- putenv('LANG='.$language);
+ putenv('LANG='.$language);
$locale_set = setlocale(LC_ALL, $language . ".utf8",
$language . ".UTF8",
$language . ".utf-8",
@@ -174,7 +174,7 @@ function common_show_header($pagetitle, $callable=NULL, $data=NULL, $headercall=
# FIXME: correct language for interface
$language = common_language();
-
+
common_element_start('html', array('xmlns' => 'http://www.w3.org/1999/xhtml',
'xml:lang' => $language,
'lang' => $language));
@@ -304,6 +304,8 @@ function common_nav_menu() {
if ($user) {
common_menu_item(common_local_url('profilesettings'),
_('Settings'));
+ common_menu_item(common_local_url('invite'),
+ _('Invite'));
common_menu_item(common_local_url('logout'),
_('Logout'));
} else {
@@ -484,7 +486,7 @@ function common_language() {
return $language;
}
} else {
- return $config['site']['language'];
+ return common_config('site', 'language');
}
}
# salted, hashed passwords are stored in the DB
@@ -686,20 +688,24 @@ function common_render_content($text, $notice) {
$r = preg_replace('/[\x{0}-\x{8}\x{b}-\x{c}\x{e}-\x{19}]/', '', $r);
$id = $notice->profile_id;
$r = preg_replace('@https?://[^)\]>\s]+@', '\0', $r);
- $r = preg_replace('/(^|\s+)@([a-z0-9]{1,64})/e', "'\\1@'.common_at_link($id, '\\2')", $r);
+ $r = preg_replace('/(^|\s+)@([A-Za-z0-9]{1,64})/e', "'\\1@'.common_at_link($id, '\\2')", $r);
$r = preg_replace('/^T ([A-Z0-9]{1,64}) /e', "'T '.common_at_link($id, '\\1').' '", $r);
- $r = preg_replace('/(^|\s+)#([a-z0-9]{1,64})/e', "'\\1#'.common_tag_link('\\2')", $r);
+ $r = preg_replace('/(^|\s+)#([A-Za-z0-9_\-\.]{1,64})/e', "'\\1#'.common_tag_link('\\2')", $r);
# XXX: machine tags
return $r;
}
function common_tag_link($tag) {
- return '' . htmlspecialchars($tag) . '';
+ if(common_config('site', 'fancy')) {
+ return '' . htmlspecialchars($tag) . '';
+ } else {
+ return '' . htmlspecialchars($tag) . '';
+ }
}
function common_at_link($sender_id, $nickname) {
$sender = Profile::staticGet($sender_id);
- $recipient = common_relative_profile($sender, $nickname);
+ $recipient = common_relative_profile($sender, common_canonical_nickname($nickname));
if ($recipient) {
return ''.$nickname.'';
} else {
@@ -810,10 +816,16 @@ function common_fancy_url($action, $args=NULL) {
return common_path('doc/'.$args['title']);
case 'login':
case 'logout':
- case 'register':
case 'subscribe':
case 'unsubscribe':
+ case 'invite':
return common_path('main/'.$action);
+ case 'register':
+ if ($args && $args['code']) {
+ return common_path('main/register/'.$args['code']);
+ } else {
+ return common_path('main/register');
+ }
case 'remotesubscribe':
if ($args && $args['nickname']) {
return common_path('main/remote?nickname=' . $args['nickname']);
@@ -901,6 +913,16 @@ function common_fancy_url($action, $args=NULL) {
return common_path($path . (($args) ? ('?' . http_build_query($args)) : ''));
case 'tags':
return common_path('tags' . (($args) ? ('?' . http_build_query($args)) : ''));
+ case 'favor':
+ return common_path('main/favor');
+ case 'disfavor':
+ return common_path('main/disfavor');
+ case 'showfavorites':
+ if ($args && isset($args['page'])) {
+ return common_path($args['nickname'].'/favorites?page=' . $args['page']);
+ } else {
+ return common_path($args['nickname'].'/favorites');
+ }
default:
return common_simple_url($action, $args);
}
@@ -1420,6 +1442,15 @@ function common_copy_args($from) {
return $to;
}
+// Neutralise the evil effects of magic_quotes_gpc in the current request.
+// This is used before handing a request off to OAuthRequest::from_request.
+function common_remove_magic_from_request() {
+ if(get_magic_quotes_gpc()) {
+ $_POST=array_map('stripslashes',$_POST);
+ $_GET=array_map('stripslashes',$_GET);
+ }
+}
+
function common_user_uri(&$user) {
return common_local_url('userbyid', array('id' => $user->id));
}
@@ -1490,22 +1521,20 @@ function common_canonical_sms($sms) {
function common_error_handler($errno, $errstr, $errfile, $errline, $errcontext) {
switch ($errno) {
case E_USER_ERROR:
- echo "ERROR: [$errno] $errstr ($errfile:$errline)\n";
- echo " Fatal error on line $errline in file $errfile";
- echo ", PHP " . PHP_VERSION . " (" . PHP_OS . ")\n";
- echo "Aborting...\n";
+ common_log(LOG_ERR, "[$errno] $errstr ($errfile:$errline)");
exit(1);
break;
case E_USER_WARNING:
- echo "WARNING [$errno] $errstr ($errfile:$errline)\n";
+ common_log(LOG_WARNING, "[$errno] $errstr ($errfile:$errline)");
break;
case E_USER_NOTICE:
- echo "NOTICE [$errno] $errstr ($errfile:$errline)\n";
+ common_log(LOG_NOTICE, "[$errno] $errstr ($errfile:$errline)");
break;
}
+ # FIXME: show error page if we're on the Web
/* Don't execute PHP internal error handler */
return true;
}
@@ -1517,3 +1546,33 @@ function common_session_token() {
}
return $_SESSION['token'];
}
+
+function common_disfavor_form($notice) {
+ common_element_start('form', array('id' => 'disfavor-' . $notice->id,
+ 'method' => 'post',
+ 'action' => common_local_url('disfavor')));
+ common_hidden('token', common_session_token());
+ common_hidden('notice', $notice->id);
+ common_submit('disfavor-submit-' . $notice->id, 'â¥');
+ common_element_end('form');
+}
+
+function common_favor_form($notice) {
+ common_element_start('form', array('id' => 'favor-' . $notice->id,
+ 'method' => 'post',
+ 'action' => common_local_url('favor')));
+ common_hidden('token', common_session_token());
+ common_hidden('notice', $notice->id);
+ common_submit('favor-submit-' . $notice->id, 'â¡');
+ common_element_end('form');
+}
+
+function common_cache_key($extra) {
+ return 'laconica:' . common_keyize(common_config('site', 'name')) . ':' . $extra;
+}
+
+function common_keyize($str) {
+ $str = strtolower($str);
+ $str = preg_replace('/\s/', '_', $str);
+ return $str;
+}