예제 #1
0
파일: guest.php 프로젝트: ansgar/pmguest
function HandleGuestStore($pagename, $auth)
{
    global $wpcom_api_key, $wpcom_home;
    $akismet = new Akismet($wpcom_home, $wpcom_api_key);
    $akismet->setCommentAuthor($_POST['name']);
    $akismet->setCommentAuthorEmail($_POST['email']);
    $akismet->setCommentAuthorURL($_POST['url']);
    $akismet->setCommentContent($_POST['comment']);
    $itemurl = $pagename . date("Ymd") . "-" . uniqid();
    $akismet->setPermalink($itemurl);
    $page['name'] = $itemurl;
    $page['text'] = "----\n";
    $page['text'] .= strlen($_POST['name']) > 0 ? $_POST['name'] : "Unbekannt";
    if (strlen($_POST['email']) > 0) {
        $page['text'] .= " [[✉->mailto:";
        $page['text'] .= $_POST['email'];
        $page['text'] .= "]]";
    }
    if (strlen($_POST['url']) > 0) {
        $page['text'] .= " [[➚->";
        $page['text'] .= substr($_POST['url'], 0, 4) == "http" ? $_POST['url'] : "http://" . $_POST['url'];
        $page['text'] .= "]]";
    }
    $page['text'] .= " schrieb am ";
    $page['text'] .= date("d.m.Y");
    $page['text'] .= ":\n\n";
    $page['text'] .= $_POST['comment'];
    $page['text'] .= $akismet->isCommentSpam() ? "(:spam: true:)" : "(:spam: false:)";
    $page['time'] = $Now;
    $page['host'] = $_SERVER['REMOTE_ADDR'];
    $page['agent'] = @$_SERVER['HTTP_USER_AGENT'];
    UpdatePage($page['name'], $page, $page);
    HandleBrowse($pagename);
}
예제 #2
0
function WikiGallerySlideshow($pagename, $auth = 'read')
{
    global $WikiGallery_DefaultSlideshowDelay, $HTMLHeaderFmt, $WikiGallery_Register;
    // get delay from url
    if (isset($_GET["delay"])) {
        $delay = intval($_GET["delay"]);
    } else {
        $delay = $WikiGallery_DefaultSlideshowDelay;
    }
    // find following picture
    $group = PageVar($pagename, '$Group');
    $next = $WikiGallery_Register[$group]->neighbourPicturePage(PageVar($pagename, '$Name'), 1);
    $nextpage = "{$group}.{$next}";
    // exists?
    if ($next && PageExists($nextpage)) {
        // add refresh header
        $url = MakeLink($nextpage, $nextpage, NULL, NULL, "\$LinkUrl");
        array_unshift($HTMLHeaderFmt, "<meta http-equiv=\"refresh\" content=\"{$delay}; URL={$url}?action=slideshow&delay={$delay}\" />");
    }
    return HandleBrowse($pagename, $auth);
}
예제 #3
0
    $WikiDir->write($pagename,$new);
    $IsPagePosted=true;
  }
}

function HandleEdit($pagename) {
  global $PageEditFmt,$EditText,$EditFields,$EditFunctions,$IsPagePosted;
  $page = ReadPage($pagename);
  $new = $page;
  foreach((array)$EditFields as $k) 
    if (isset($_POST[$k])) $new[$k]=str_replace("\r",'',stripmagic($_POST[$k]));
  foreach((array)$EditFunctions as $fn) $fn($pagename,$page,$new);
  if ($IsPagePosted) { Redirect($pagename); return; }
  $EditText = htmlspecialchars($new['text'],ENT_NOQUOTES);
  print FmtPageName($PageEditFmt,$pagename);
}

function HandleSource($pagename) {
  header("Content-type: text/plain");
  $page = ReadPage($pagename);
  echo $page['text'];
}

$action = @$_REQUEST['action'];
if ($action=='edit') HandleEdit('PmWiki.TextFormattingRules');
elseif ($action=='source') HandleSource('PmWiki.TextFormattingRules');
elseif ($action=='test') include_once('tests/00test.php');
else HandleBrowse('PmWiki.TextFormattingRules'); 

?> 
예제 #4
0
function HandleM2MSaveOptions ($pagename, $auth='read') {
	global $M2MDir, $M2MDataDir;
	session_start();
	$targetformat = $_SESSION['targetformat'];
	$options = new StylesheetOptions();
	$options->readXML("$M2MDir/options/$targetformat.xml");
	$options->setRequestValues($_REQUEST);
	$outdir = "$M2MDataDir/$pagename";
	recursive_mkdir($outdir);
	$options->writeShortXML("$outdir/{$targetformat}opt.xml");
	$options->writeStylesheet("$outdir/$targetformat.xsl", "$M2MDir/xsl/{$targetformat}.xsl");
	HandleBrowse($pagename, $auth);
}
function HandleFastCacheBrowse($pagename, $auth = 'read')
{
    # handle display of a page
    global $DefaultPageTextFmt, $PageNotFoundHeaderFmt, $HTTPHeaders, $EnableHTMLCache, $NoHTMLCache, $PageCacheFile, $LastModTime, $IsHTMLCached, $FmtV, $HandleBrowseFmt, $PageStartFmt, $PageEndFmt, $PageRedirectFmt;
    ## begin added
    global $FastCachePage, $FastCacheDir, $FastCacheValid, $FastCacheSuffix;
    if (!$FastCacheValid || !$FastCacheDir) {
        HandleBrowse($pagename, $auth);
        return;
    }
    SDV($FastCacheSuffix, '.html');
    $fcfile = "{$FastCacheDir}/{$pagename}{$FastCacheSuffix}";
    if (@filemtime($fcfile) > $LastModTime) {
        if ($FastCachePage = file_get_contents($fcfile)) {
            StopWatch("HandleFastCacheBrowse: using FastCached copy of {$pagename}");
            echo $FastCachePage;
        } else {
            $FastCacheValid = FALSE;
            StopWatch("HandleFastCacheBrowse: read error on {$fcfile}");
            HandleBrowse($pagename, $auth);
        }
        return;
    }
    ## end added
    $page = RetrieveAuthPage($pagename, $auth, true, READPAGE_CURRENT);
    if (!$page) {
        Abort("?cannot read {$pagename}");
    }
    PCache($pagename, $page);
    if (PageExists($pagename)) {
        $text = @$page['text'];
    } else {
        $FastCacheValid = FALSE;
        ## added
        SDV($DefaultPageTextFmt, '(:include $[{$SiteGroup}.PageNotFound]:)');
        $text = FmtPageName($DefaultPageTextFmt, $pagename);
        SDV($PageNotFoundHeaderFmt, 'HTTP/1.1 404 Not Found');
        SDV($HTTPHeaders['status'], $PageNotFoundHeaderFmt);
    }
    $opt = array();
    SDV($PageRedirectFmt, "<p><i>(\$[redirected from] <a rel='nofollow'\n    href='{\$PageUrl}?action=edit'>{\$FullName}</a>)</i></p>\$HTMLVSpace\n");
    if (@(!$_GET['from'])) {
        $opt['redirect'] = 1;
        $PageRedirectFmt = '';
    } else {
        $PageRedirectFmt = FmtPageName($PageRedirectFmt, $_GET['from']);
    }
    if (@$EnableHTMLCache && !$NoHTMLCache && $PageCacheFile && @filemtime($PageCacheFile) > $LastModTime) {
        list($ctext) = unserialize(file_get_contents($PageCacheFile));
        $FmtV['$PageText'] = "<!--cached-->{$ctext}";
        $IsHTMLCached = 1;
        StopWatch("HandleFastCacheBrowse: using HTMLCached copy");
        ## modified
    } else {
        $IsHTMLCached = 0;
        $text = '(:groupheader:)' . @$text . '(:groupfooter:)';
        $t1 = time();
        $FmtV['$PageText'] = MarkupToHTML($pagename, $text, $opt);
        if (@$EnableHTMLCache > 0 && !$NoHTMLCache && $PageCacheFile && time() - $t1 + 1 >= $EnableHTMLCache) {
            $fp = @fopen("{$PageCacheFile},new", "x");
            if ($fp) {
                StopWatch("HandleFastCacheBrowse: HTMLCaching page");
                ## modified
                fwrite($fp, serialize(array($FmtV['$PageText'])));
                fclose($fp);
                rename("{$PageCacheFile},new", $PageCacheFile);
            }
        }
    }
    SDV($HandleBrowseFmt, array(&$PageStartFmt, &$PageRedirectFmt, '$PageText', &$PageEndFmt));
    ## begin modified
    if ($FastCacheValid) {
        ob_start();
        PrintFmt($pagename, $HandleBrowseFmt);
        $FastCachePage = ob_get_contents();
        ob_end_flush();
        mkdirp(dirname($fcfile));
        if ($FastCacheValid && ($fc = fopen("{$fcfile},new", 'x'))) {
            StopWatch("HandleFastCacheBrowse: FastCaching {$pagename}");
            fwrite($fc, $FastCachePage);
            fclose($fc);
            rename("{$fcfile},new", $fcfile);
        } else {
            StopWatch("HandleFastCacheBrowse: error writing cache to {$fcfile},new");
        }
    } else {
        PrintFmt($pagename, $HandleBrowseFmt);
    }
    ## end modified
}