+ case 'logged':
+ if (!call_user_func(array($globals->session, 'doAuthCookie'))) {
+ $platal = empty($GLOBALS['IS_XNET_SITE']) ? new Platal() : new Xnet();
+ $platal->force_login($page);
+ }
+ return;
+
+ default:
+ if (!call_user_func(array($globals->session, 'doAuth'))) {
+ $platal = empty($GLOBALS['IS_XNET_SITE']) ? new Platal() : new Xnet();
+ $platal->force_login($page);
+ }
+ if ($perm == 'admin') {
+ check_perms();
+ }
+ return;
+ }
+}
+
+function wiki_require_page($pagename)
+{
+ global $globals;
+ $pagename_slashes = str_replace('.','/',$pagename);
+ $pagename_dots = str_replace('/','.',$pagename);
+ if (is_file(wiki_work_dir().'/cache_'.$pagename_dots.'.tpl')) {
+ return;
+ }
+ system('wget --no-check-certificate '. escapeshellarg($globals->baseurl.'/'.$pagename_slashes) . ' -O /dev/null');
+}
+
+function wiki_delete_page($pagename)
+{
+ $pagename_dots = str_replace('/','.',$pagename);
+ if (!strpos($pagename_dots, '.')) {
+ return false;
+ }
+ $file = wiki_work_dir().'/'.wiki_filename($pagename_dots);
+ $cachefile = wiki_work_dir().'/cache_'.$pagename_dots.'.tpl';
+ if (is_file($cachefile)) {
+ unlink($cachefile);
+ }
+ if (!is_file($file)) {
+ return false;
+ }
+ unlink($file);
+ return true;
+}
+
+function wiki_links_in_line($line, $groupname)
+{
+ $links = array();
+ if (preg_match_all('@\[\[([^~][^\]\|\?#]*)((\?|#)[^\]\|]+)?(\\|[^\]]+)?\]\]@', $line, $matches, PREG_OFFSET_CAPTURE)) {
+ foreach ($matches[1] as $j => $link) if (!preg_match('@http://@', $link[0])) {
+ $mylink = str_replace('/','.',trim($link[0]));
+ $sup = trim(substr($matches[2][$j][0],1));
+ $alt = trim(substr($matches[4][$j][0],1));
+ $newlink = str_replace(' ','',ucwords($mylink));
+ if (strpos($newlink,'.') === false) {
+ $newlink = $groupname.'.'.$newlink;