$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",
# 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));
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 {
return $language;
}
} else {
- return $config['site']['language'];
+ return common_config('site', 'language');
}
}
# salted, hashed passwords are stored in the DB
$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]+@', '<a href="\0" class="extlink">\0</a>', $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 '<a href="' . htmlspecialchars(common_path('tag/' . $tag)) . '" rel="tag" class="hashlink">' . htmlspecialchars($tag) . '</a>';
+ if(common_config('site', 'fancy')) {
+ return '<a href="' . htmlspecialchars(common_path('tag/' . strtolower(str_replace(array('-', '_', '.'), '', $tag)))) . '" rel="tag" class="hashlink">' . htmlspecialchars($tag) . '</a>';
+ } else {
+ return '<a href="' . htmlspecialchars(common_path('index.php?action=tag&tag=' . strtolower(str_replace(array('-', '_', '.'), '', $tag)))) . '" rel="tag" class="hashlink">' . htmlspecialchars($tag) . '</a>';
+ }
}
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 '<a href="'.htmlspecialchars($recipient->profileurl).'" class="atlink">'.$nickname.'</a>';
} else {
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']);
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);
}
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));
}
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;
}
}
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;
+}