+function add_author_info($wikitext)
+{
+ global $auth_user, $auth_user_fullname;
+ $author = preg_replace('/"/', '', $auth_user);
+ $fullname = $auth_user_fullname;
+ if (!$fullname && $author) {
+ // Fullname is empty, use $author as its fullname
+ $fullname = preg_replace('/^[^:]*:/', '', $author);
+ }
+ $displayname = preg_replace('/"/', '', $fullname);
+ $user_prefix = get_auth_user_prefix();
+ $author_text = sprintf('#author("%s","%s","%s")',
+ get_date_atom(UTIME + LOCALZONE),
+ ($author ? $user_prefix . $author : ''),
+ $displayname) . "\n";
+ return $author_text . $wikitext;
+}
+
+function remove_author_info($wikitext)
+{
+ return preg_replace('/^\s*#author\([^\n]*(\n|$)/m', '', $wikitext);
+}
+
+function get_date_atom($timestamp)
+{
+ // Compatible with DATE_ATOM format
+ // return date(DATE_ATOM, $timestamp);
+ $zmin = abs(LOCALZONE / 60);
+ return date('Y-m-d\TH:i:s', $timestamp) . sprintf('%s%02d:%02d',
+ (LOCALZONE < 0 ? '-' : '+') , $zmin / 60, $zmin % 60);
+}
+