Ejemplo n.º 1
0
function ThumbShoeHandleDelete($pagename, $auth = 'delete')
{
    global $WikiLibDirs, $WikiDir, $LastModFile;
    $page = RetrieveAuthPage($pagename, $auth, true, READPAGE_CURRENT);
    if (!$page) {
        Abort("?cannot delete {$pagename}");
        return;
    }
    $deleted = false;
    foreach ((array) $WikiLibDirs as $dir) {
        if ($dir->exists($pagename) and $dir->iswrite) {
            $dir->delete($pagename);
            $deleted = true;
            break;
        }
    }
    if (!$deleted) {
        // look in the default WikiDir
        if ($WikiDir->exists($pagename)) {
            $WikiDir->delete($pagename);
            $deleted = true;
        }
    }
    if ($deleted && $LastModFile) {
        touch($LastModFile);
        fixperms($LastModFile);
    }
    Redirect($pagename);
    exit;
}
Ejemplo n.º 2
0
function HandleRecipeCheck($pagename, $auth = 'admin')
{
    global $RecipeListUrl, $Version, $RecipeInfo, $RecipeCheckFmt, $PageStartFmt, $PageEndFmt;
    $page = RetrieveAuthPage($pagename, $auth, true, READPAGE_CURRENT);
    if (!$page) {
        Abort('?admin access required');
    }
    $cvinfo = GetRecipeList($RecipeListUrl);
    if (!$cvinfo) {
        $msg = "Unable to retrieve cookbook data from {$RecipeListUrl}\n";
        $allow_url_fopen = ini_get('allow_url_fopen');
        if (!$allow_url_fopen) {
            $msg .= "\n      <br /><br />It appears that your PHP environment isn't allowing\n      the recipelist to be downloaded from pmwiki.org  \n      (allow_url_fopen&nbsp;=&nbsp;{$allow_url_fopen}).";
        }
        Abort($msg);
    }
    $rinfo['PmWiki:Upgrades'] = $Version;
    ScanRecipeInfo('cookbook', $cvinfo);
    foreach ((array) $RecipeInfo as $r => $v) {
        if (!@$v['Version']) {
            continue;
        }
        $r = preg_replace('/^(?!PmWiki:)(Cookbook[.:])?/', 'Cookbook:', $r);
        $rinfo[$r] = $v['Version'];
    }
    $markup = "!!Recipe status for {\$PageUrl}\n" . RecipeTable($rinfo, $cvinfo);
    $html = MarkupToHTML($pagename, $markup);
    SDV($RecipeCheckFmt, array(&$PageStartFmt, $html, &$PageEndFmt));
    PrintFmt($pagename, $RecipeCheckFmt);
}
Ejemplo n.º 3
0
function HandleThumbShoePostRename($pagename, $auth = 'edit')
{
    global $WikiLibDirs;
    global $ThumbShoePageSep;
    global $HandleAuth, $UploadFileFmt, $LastModFile, $TimeFmt;
    $newname = $_REQUEST['newname'];
    if ($newname == '') {
        Abort("?no new image name");
    }
    $newname = str_replace('.', '_', $newname);
    $newpage = $_REQUEST['newpage'];
    if ($newpage == '') {
        Abort("?no new image page");
    }
    $newimgpage = $newpage . $ThumbShoePageSep . $newname;
    $tsdir = '';
    foreach ((array) $WikiLibDirs as $dir) {
        if ($dir->exists($pagename) and $dir->iswrite) {
            $tsdir = $dir;
            break;
        }
    }
    if (!$tsdir) {
        Abort("Cannot rename {$pagename} to {$newimgpage}; cannot find page");
        return;
    }
    ## check authorization
    if (!RetrieveAuthPage($newimgpage, $auth, TRUE, READPAGE_CURRENT)) {
        Abort("?cannot rename image page from {$pagename} to {$newimgpage}");
    }
    $newnewpage = @$tsdir->rename($pagename, $newimgpage);
    if ($newnewpage) {
        Redirect($newnewpage);
    }
}
Ejemplo n.º 4
0
 /**
  * This method show the user's dashboard
  * @return \Illuminate\View\View
  */
 public function getIndex()
 {
     //We get the user information and remove the password and token from the response
     $user_profile = User::findBy(['_id' => Auth::user()->_id], ['password' => false, 'token' => false, 'token' => false]);
     if (!$user_profile) {
         Abort(404);
     }
     return view('user.dashboard', ['user_profile' => $user_profile]);
 }
Ejemplo n.º 5
0
 /**
  * This method show the user's profile
  * @return \Illuminate\View\View
  */
 public function getIndex($username)
 {
     //We get the user information and remove the password and token from the response
     $user_profile = User::findBy(['username' => $username], ['password' => false, 'token' => false, 'token' => false]);
     if (!$user_profile) {
         Abort(404);
     }
     //var_dump($user_profile);
     return view('user.profile', ['user_profile' => $user_profile]);
 }
Ejemplo n.º 6
0
function HandleGuestDelete($pagename, $auth)
{
    global $WikiDir, $LastModFile;
    $page = RetrieveAuthPage($pagename, $auth, true, READPAGE_CURRENT);
    if (!$page) {
        Abort("?cannot delete {$pagename}");
        return;
    }
    $WikiDir->delete($pagename);
    if ($LastModFile) {
        touch($LastModFile);
        fixperms($LastModFile);
    }
    Redirect(substr($pagename, 0, strlen($pagename) - 22));
}
Ejemplo n.º 7
0
function ThumbShoeMakeThumb($pagename, $picpath, $w = 128, $h = 128)
{
    global $ThumbShoeThumbBg, $ThumbShoeThumbPrefix;
    global $UploadDir;
    $uploaddir = PageVar($pagename, '$TSAttachDir');
    $name = PageVar($pagename, '$Name');
    $thumbpath = "{$uploaddir}/{$ThumbShoeThumbPrefix}{$name}.png";
    if (!file_exists($picpath)) {
        return;
    }
    // if the thumbnail has already been created
    // and it is newer than the original image, return.
    if (file_exists($thumbpath) && filemtime($thumbpath) > filemtime($picpath)) {
        return;
    }
    if (!file_exists($uploaddir)) {
        mkdirp($uploaddir);
    }
    $bg = $ThumbShoeThumbBg;
    $tmp1 = "{$uploaddir}/{$name}_tmp.png";
    $area = $w * $h;
    # Need to use the following conversion because of
    # ImageMagick version earlier than 6.3
    $cmdfmt = 'convert -thumbnail \'%dx%d>\' -bordercolor %s -background %s -border 50 -gravity center  -crop %dx%d+0+0 +repage %s %s';
    $cl = sprintf($cmdfmt, $w, $h, $bg, $bg, $w, $h, $picpath, $tmp1);
    $r = exec($cl, $o, $status);
    if (intval($status) != 0) {
        Abort("convert returned <pre>{$r}\n" . print_r($o, true) . "'</pre> with a status '{$status}'.<br/> Command line was '{$cl}'.");
    }
    if (!file_exists($tmp1)) {
        Abort("Failed to create '{$tmp1}';<br/> Command line was '{$cl}'.");
    }
    // fluff
    $cmdfmt = 'convert -mattecolor %s -frame 6x6+3+0 %s %s';
    $cl = sprintf($cmdfmt, $bg, $tmp1, $thumbpath);
    $r = exec($cl, $o, $status);
    if (intval($status) != 0) {
        Abort("convert returned <pre>{$r}\n" . print_r($o, true) . "'</pre> with a status '{$status}'.<br/> Command line was '{$cl}'.");
    }
    unlink($tmp1);
}
Ejemplo n.º 8
0
 static function captchaListener()
 {
     if (isset($_GET['qgcaptcha'])) {
         $ticket = $_GET['qgcaptcha'];
         $text = randString(5, "abcdefghijkmnpqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ23456789");
         $_SESSION['qg_rTicket'][$ticket]['captcha'] = $text;
         header('Content-type: image/png');
         $img = ImageCreateFromPNG(sysPATH . 'core/util/rTicket/captchabg.png');
         //Backgroundimage
         $color = ImageColorAllocate($img, 0, 0, 0);
         //Farbe
         $ttf = sysPATH . 'core/util/rTicket/xfiles.ttf';
         //Schriftart
         $ttfsize = 13;
         //Schriftgrösse
         $angle = rand(0, 7);
         $t_x = rand(5, 20);
         $t_y = 23;
         imagettftext($img, $ttfsize, $angle, $t_x, $t_y, $color, $ttf, $text);
         imagepng($img);
         imagedestroy($img);
         Abort();
     }
 }
Ejemplo n.º 9
0
 public function __construct()
 {
     $this->objLoggedInUser = \Auth::User();
     if (!$this->objLoggedInUser || !$this->objLoggedInUser->HasPermission('Admin/View')) {
         Abort('404');
     }
     View::share('objLoggedInUser', $this->objLoggedInUser);
     View::share('ActiveClass', static::ACTIVE_CLASS);
     $FormResponse = Session::get('FormResponse') ? Session::get('FormResponse') : [];
     View::share('FormResponse', $FormResponse);
     $NewOrderCount = \App\Invoice::perminvoices($this->objLoggedInUser)->new()->count();
     $AssignedOrderCount = \App\Invoice::perminvoices($this->objLoggedInUser)->assigned($this->objLoggedInUser)->count();
     $FinalizedOrderCount = \App\Invoice::perminvoices($this->objLoggedInUser)->finalized()->count();
     $TotalOrderCount = \App\Invoice::perminvoices($this->objLoggedInUser)->count();
     $ContactUsCount = \App\Invoice::perminvoices($this->objLoggedInUser)->contact()->new()->count();
     $ReviewedCount = \App\Invoice::perminvoices($this->objLoggedInUser)->reviewed()->count();
     View::share('ReviewedCount', $ReviewedCount);
     View::share('ContactUsCount', $ContactUsCount);
     View::share('NewOrderCount', $NewOrderCount);
     View::share('AssignedOrderCount', $AssignedOrderCount);
     View::share('FinalizedOrderCount', $FinalizedOrderCount);
     View::share('TotalOrderCount', $TotalOrderCount);
     // No parent constructor.  All is well.
 }
Ejemplo n.º 10
0
function HandleApprove($pagename, $auth = 'edit')
{
    global $ApproveUrlPattern, $WhiteUrlPatterns, $ApprovedUrlPagesFmt, $action;
    Lock(2);
    $page = ReadPage($pagename);
    $text = preg_replace('/[()]/', '', $page['text']);
    preg_match_all("/{$ApproveUrlPattern}/", $text, $match);
    ReadApprovedUrls($pagename);
    $addpat = array();
    foreach ($match[0] as $a) {
        if ($action == 'approvesites') {
            $a = preg_replace("!^([^:]+://[^/]+).*\$!", '$1', $a);
        }
        $addpat[] = $a;
    }
    if (count($addpat) > 0) {
        $aname = FmtPageName($ApprovedUrlPagesFmt[0], $pagename);
        $apage = RetrieveAuthPage($aname, $auth);
        if (!$apage) {
            Abort("?cannot edit {$aname}");
        }
        $new = $apage;
        if (substr($new['text'], -1, 1) != "\n") {
            $new['text'] .= "\n";
        }
        foreach ($addpat as $a) {
            foreach ((array) $WhiteUrlPatterns as $pat) {
                if (preg_match("!^{$pat}(/|\$)!i", $a)) {
                    continue 2;
                }
            }
            $urlp = preg_quote($a, '!');
            $WhiteUrlPatterns[] = $urlp;
            $new['text'] .= "  {$a}\n";
        }
        $_POST['post'] = 'y';
        PostPage($aname, $apage, $new);
    }
    Redirect($pagename);
}
Ejemplo n.º 11
0
function HandlePostUpload($pagename, $auth = 'upload') {
  global $UploadVerifyFunction, $UploadFileFmt, $LastModFile, 
    $EnableUploadVersions, $Now, $RecentUploadsFmt, $FmtV,
    $NotifyItemUploadFmt, $NotifyItemFmt, $IsUploadPosted,
    $UploadRedirectFunction;
  UploadAuth($pagename, $auth);
  $uploadfile = $_FILES['uploadfile'];
  $upname = $_REQUEST['upname'];
  if ($upname=='') $upname=$uploadfile['name'];
  $upname = MakeUploadName($pagename,$upname);
  if (!function_exists($UploadVerifyFunction))
    Abort('?no UploadVerifyFunction available');
  $filepath = FmtPageName("$UploadFileFmt/$upname",$pagename);
  $result = $UploadVerifyFunction($pagename,$uploadfile,$filepath);
  if ($result=='') {
    $filedir = preg_replace('#/[^/]*$#','',$filepath);
    mkdirp($filedir);
    if (IsEnabled($EnableUploadVersions, 0))
      @rename($filepath, "$filepath,$Now");
    if (!move_uploaded_file($uploadfile['tmp_name'],$filepath))
      { Abort("?cannot move uploaded file to $filepath"); return; }
    fixperms($filepath,0444);
    if ($LastModFile) { touch($LastModFile); fixperms($LastModFile); }
    $result = "upresult=success";
    $FmtV['$upname'] = $upname;
    $FmtV['$upsize'] = $uploadfile['size'];
    if (IsEnabled($RecentUploadsFmt, 0)) {
      PostRecentChanges($pagename, '', '', $RecentUploadsFmt);
    }
    if (IsEnabled($NotifyItemUploadFmt, 0) && function_exists('NotifyUpdate')) {
      $NotifyItemFmt = $NotifyItemUploadFmt;
      $IsUploadPosted = 1;
      register_shutdown_function('NotifyUpdate', $pagename, getcwd());
    }
  }
  SDV($UploadRedirectFunction, 'Redirect');
  $UploadRedirectFunction($pagename,"{\$PageUrl}?action=upload&uprname=$upname&$result");
}
Ejemplo n.º 12
0
<?php

if (!defined('PmWiki')) {
    exit;
}
/*  Copyright 2007 Patrick R. Michaud (pmichaud@pobox.com)
    This file is pmform.php; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published
    by the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

*/
$RecipeInfo['PmForm']['Version'] = '2007-06-12';
if ($VersionNum < 2001946) {
    Abort("pmform requires pmwiki-2.2.0-beta46 or later (currently {$Version})");
}
if (@$_REQUEST['pmform']) {
    $MessagesFmt[] = "<div class='wikimessage'>\$[Post successful]</div>";
}
SDV($PmFormRedirectFunction, 'Redirect');
SDV($FmtPV['$CurrentTime'], "\$GLOBALS['CurrentTime']");
SDV($PmFormTemplatesFmt, array('{$SiteGroup}.LocalTemplates', '{$SiteGroup}.PmFormTemplates'));
SDV($PmFormPostPatterns, array('/\\(:/' => '( :', '/:\\)/' => ': )', '/\\$:/' => '$ :'));
SDVA($InputTags['pmform'], array(':fn' => 'InputActionForm', ':args' => array('target'), ':html' => "<form action='{\$PageUrl}' \$InputFormArgs><input type='hidden' name='n' value='{\$FullName}' /><input type='hidden' name='action' value='pmform' />", 'method' => 'post'));
Markup('pmform', '<input', '/\\(:pmform *([-\\w]+)( .*?)?:\\)/e', "PmFormMarkup(\$pagename, '\$1', PSS('\$2'))");
Markup('ptv:', 'block', '/^(\\w[-\\w]+)\\s*:.*$/', "<:block,0><div class='property-\$1'>\$0</div>");
SDV($HandleActions['pmform'], 'HandlePmForm');
SDV($HandleAuth['pmform'], 'read');
function PmFormConfig($pagename, $target)
{
    global $PmForm, $PmFormPageFmt;
Ejemplo n.º 13
0
function HandlePostUpload($pagename)
{
    global $UploadVerifyFunction, $UploadFileFmt, $LastModFile;
    $page = RetrieveAuthPage($pagename, 'upload');
    if (!$page) {
        Abort("?cannot upload to {$pagename}");
    }
    $uploadfile = $_FILES['uploadfile'];
    $upname = $_REQUEST['upname'];
    if ($upname == '') {
        $upname = $uploadfile['name'];
    }
    $upname = MakeUploadName($pagename, $upname);
    if (!function_exists($UploadVerifyFunction)) {
        Abort('?no UploadVerifyFunction available');
    }
    $filepath = FmtPageName("{$UploadFileFmt}/{$upname}", $pagename);
    $result = $UploadVerifyFunction($pagename, $uploadfile, $filepath);
    if ($result == '') {
        $filedir = preg_replace('#/[^/]*$#', '', $filepath);
        mkdirp($filedir);
        if (!move_uploaded_file($uploadfile['tmp_name'], $filepath)) {
            Abort("?cannot move uploaded file to {$filepath}");
            return;
        }
        fixperms($filepath);
        if ($LastModFile) {
            touch($LastModFile);
            fixperms($LastModFile);
        }
        $result = "upresult=success";
    }
    Redirect($pagename, "\$PageUrl?action=upload&upname={$upname}&{$result}");
}
Ejemplo n.º 14
0
function AuthUserLDAP($pagename, $id, $pw, $pwlist) {
  global $AuthLDAPBindDN, $AuthLDAPBindPassword;
  if (!$pw) return false;
  if (!function_exists('ldap_connect')) 
    Abort('authuser: LDAP authentication requires PHP ldap functions','ldapfn');
  foreach ((array)$pwlist as $ldap) {
    if (!preg_match('!(ldaps?://[^/]+)/(.*)$!', $ldap, $match))
      continue;
    ##  connect to the LDAP server
    list($z, $url, $path) = $match;
    $ds = ldap_connect($url);
    ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
    ##  For Active Directory, don't specify a path and we simply
    ##  attempt to bind with the username and password directly
    if (!$path && @ldap_bind($ds, $id, $pw)) { ldap_close($ds); return true; }
    ##  Otherwise, we use Apache-style urls for LDAP authentication
    ##  Split the path into its search components
    list($basedn, $attr, $sub, $filter) = explode('?', $path);
    if (!$attr) $attr = 'uid';
    if (!$sub) $sub = 'one';
    if (!$filter) $filter = '(objectClass=*)';
    $binddn = @$AuthLDAPBindDN;
    $bindpw = @$AuthLDAPBindPassword;
    if (ldap_bind($ds, $binddn, $bindpw)) {
      ##  Search for the appropriate uid
      $fn = ($sub == 'sub') ? 'ldap_search' : 'ldap_list';
      $sr = $fn($ds, $basedn, "(&$filter($attr=$id))", array($attr));
      $x = ldap_get_entries($ds, $sr);
      ##  If we find a unique id, bind to it for success
      if ($x['count'] == 1) {
        $dn = $x[0]['dn'];
        if (@ldap_bind($ds, $dn, $pw)) { ldap_close($ds); return true; }
      }
    }
    ldap_close($ds);
  }
  return false;
}
Ejemplo n.º 15
0
/**
 * Handle the .draw file format
 */
function HandlePostDrawing_draw($pagename)
{
    global $UploadVerifyFunction, $UploadFileFmt, $LastModFile, $Now;
    global $RecentChangesFmt, $IsPagePosted, $EnableDrawingRecentChanges;
    $page = RetrieveAuthPage($pagename, 'upload');
    if (!$page) {
        Abort("?cannot upload to {$pagename}");
    }
    $uploadImage = $_FILES['uploadImage'];
    $uploadDrawing = $_FILES['uploadDrawing'];
    $uploadMap = $_FILES['uploadMap'];
    $drawingBaseTime = $_POST['drawingbasetime'];
    // The time the user began editing this drawing.
    $imageupname = $uploadImage['name'];
    $drawingupname = $uploadDrawing['name'];
    $mapupname = $uploadMap['name'];
    $imageupname = MakeUploadName($pagename, $imageupname);
    $drawingupname = MakeUploadName($pagename, $drawingupname);
    $mapupname = MakeUploadName($pagename, $mapupname);
    $imageFilePath = FmtPageName("{$UploadFileFmt}/{$imageupname}", $pagename);
    $drawingFilePath = FmtPageName("{$UploadFileFmt}/{$drawingupname}", $pagename);
    $mapFilePath = FmtPageName("{$UploadFileFmt}/{$mapupname}", $pagename);
    if (file_exists($drawingFilePath)) {
        // Only worth checking timestamps if a drawing actually currently exists!
        if (filemtime($drawingFilePath) > $drawingBaseTime) {
            // Assign a new timestamp to the client... hopefully this time they'll be ok...
            header("PmWikiDraw-DrawingChanged: {$Now}");
            exit;
        }
    }
    // If we've got to here then we can assume its safe to overwrite the current file
    // Note: we should do the history archival/recent changes stuff here.
    if ($EnableDrawingRecentChanges == true && isset($_POST['drawingname'])) {
        $imageModified = $_POST['drawingname'];
        $RecentChangesFmt = array('Main.AllRecentChanges' => '* [[$Group/$Name]]  Drawing - ' . $imageModified . ' modified . . . $CurrentTime', '$Group.RecentChanges' => '* [[$Group/$Name]]  Drawing - ' . $imageModified . ' modified . . . $CurrentTime');
        $IsPagePosted = true;
        $x = "";
        $y = "";
        PostRecentChanges($pagename, $x, $y);
        $IsPagePosted = false;
    }
    $filedir = preg_replace('#/[^/]*$#', '', $imageFilePath);
    mkdirp($filedir);
    if (!move_uploaded_file($uploadImage['tmp_name'], $imageFilePath)) {
        Abort("?cannot move uploaded image to {$imageFilePath}");
        return;
    }
    fixperms($imageFilePath, 0444);
    if ($LastModFile) {
        touch($LastModFile);
        fixperms($LastModFile);
    }
    $filedir = preg_replace('#/[^/]*$#', '', $drawingFilePath);
    mkdirp($filedir);
    if (!move_uploaded_file($uploadDrawing['tmp_name'], $drawingFilePath)) {
        Abort("?cannot move uploaded drawing to {$drawingFilePath}");
        return;
    }
    fixperms($drawingFilePath, 0444);
    if ($LastModFile) {
        touch($LastModFile);
        fixperms($LastModFile);
    }
    $filedir = preg_replace('#/[^/]*$#', '', $mapFilePath);
    mkdirp($filedir);
    if (!move_uploaded_file($uploadMap['tmp_name'], $mapFilePath)) {
        Abort("?cannot move uploaded map to {$mapFilePath}");
        return;
    }
    fixperms($mapFilePath, 0444);
    if ($LastModFile) {
        touch($LastModFile);
        fixperms($LastModFile);
    }
    // Sets the drawingBaseTime header for incremental save support.
    header("PmWikiDraw-DrawingBaseTime: " . filemtime($drawingFilePath));
    exit;
}
Ejemplo n.º 16
0
 function write($pagename,$page) {
   global $Now, $Version;
   $page['name'] = $pagename;
   $page['time'] = $Now;
   $page['host'] = $_SERVER['REMOTE_ADDR'];
   $page['agent'] = @$_SERVER['HTTP_USER_AGENT'];
   $page['rev'] = @$page['rev']+1;
   unset($page['version']); unset($page['newline']);
   uksort($page, 'CmpPageAttr');
   $s = false;
   $pagefile = $this->pagefile($pagename);
   $dir = dirname($pagefile); mkdirp($dir);
   if (!file_exists("$dir/.htaccess") && $fp = @fopen("$dir/.htaccess", "w")) 
     { fwrite($fp, "Order Deny,Allow\nDeny from all\n"); fclose($fp); }
   if ($pagefile && ($fp=fopen("$pagefile,new","w"))) {
     $r0 = array('%', "\n", '<');
     $r1 = array('%25', '%0a', '%3c');
     $x = "version=$Version ordered=1 urlencoded=1\n";
     $s = true && fputs($fp, $x); $sz = strlen($x);
     foreach($page as $k=>$v) 
       if ($k > '' && $k{0} != '=') {
         $x = str_replace($r0, $r1, "$k=$v") . "\n";
         $s = $s && fputs($fp, $x); $sz += strlen($x);
       }
     $s = fclose($fp) && $s;
     $s = $s && (filesize("$pagefile,new") > $sz * 0.95);
     if (file_exists($pagefile)) $s = $s && unlink($pagefile);
     $s = $s && rename("$pagefile,new", $pagefile);
   }
   $s && fixperms($pagefile);
   if (!$s)
     Abort("Cannot write page to $pagename ($pagefile)...changes not saved");
   PCache($pagename, $page);
 }
Ejemplo n.º 17
0
function HandleRss($pagename)
{
    global $RssMaxItems, $RssSourceSize, $RssDescSize, $RssChannelFmt, $RssChannelDesc, $RssTimeFmt, $RssChannelBuildDate, $RssItemsRDFList, $RssItemsRDFListFmt, $RssItems, $RssItemFmt, $HandleRssFmt, $FmtV;
    $t = ReadTrail($pagename, $pagename);
    $page = RetrieveAuthPage($pagename, 'read', false);
    if (!$page) {
        Abort("?cannot read {$pagename}");
    }
    $cbgmt = $page['time'];
    $r = array();
    for ($i = 0; $i < count($t) && count($r) < $RssMaxItems; $i++) {
        if (!PageExists($t[$i]['pagename'])) {
            continue;
        }
        $page = RetrieveAuthPage($t[$i]['pagename'], 'read', false);
        Lock(0);
        if (!$page) {
            continue;
        }
        $text = MarkupToHTML($t[$i]['pagename'], substr($page['text'], 0, $RssSourceSize));
        $text = entityencode(preg_replace("/<.*?>/s", "", $text));
        preg_match("/^(.{0,{$RssDescSize}}\\s)/s", $text, $match);
        $r[] = array('name' => $t[$i]['pagename'], 'time' => $page['time'], 'desc' => $match[1] . " ...", 'author' => $page['author']);
        if ($page['time'] > $cbgmt) {
            $cbgmt = $page['time'];
        }
    }
    SDV($RssChannelBuildDate, entityencode(gmdate('D, d M Y H:i:s \\G\\M\\T', $cbgmt)));
    SDV($RssChannelDesc, entityencode(FmtPageName('$Group.$Title', $pagename)));
    foreach ($r as $page) {
        $FmtV['$RssItemPubDate'] = gmstrftime($RssTimeFmt, $page['time']);
        $FmtV['$RssItemDesc'] = $page['desc'];
        $FmtV['$RssItemAuthor'] = $page['author'];
        $RssItemsRDFList[] = entityencode(FmtPageName($RssItemsRDFListFmt, $page['name']));
        $RssItems[] = entityencode(FmtPageName($RssItemFmt, $page['name']));
    }
    header("Content-type: text/xml");
    PrintFmt($pagename, $HandleRssFmt);
    exit;
}
Ejemplo n.º 18
0
 function write($pagename, $page)
 {
     global $Now, $Version, $Newline;
     $page['name'] = $pagename;
     $page['time'] = $Now;
     $page['host'] = $_SERVER['REMOTE_ADDR'];
     $page['agent'] = @$_SERVER['HTTP_USER_AGENT'];
     $page['rev'] = @$page['rev'] + 1;
     unset($page['version']);
     unset($page['newline']);
     uksort($page, 'CmpPageAttr');
     $s = false;
     $pagefile = $this->pagefile($pagename);
     $dir = dirname($pagefile);
     mkdirp($dir);
     if (!file_exists("{$dir}/.htaccess") && ($fp = @fopen("{$dir}/.htaccess", "w"))) {
         fwrite($fp, "Order Deny,Allow\nDeny from all\n");
         fclose($fp);
     }
     if ($pagefile && ($fp = fopen("{$pagefile},new", "w"))) {
         $s = true && fputs($fp, "version={$Version} ordered=1\nnewline={$Newline}\n");
         foreach ($page as $k => $v) {
             if ($k > '' && $k[0] != '=') {
                 $s = $s && fputs($fp, str_replace("\n", $Newline, "{$k}={$v}") . "\n");
             }
         }
         $s = fclose($fp) && $s;
         if (file_exists($pagefile)) {
             $s = $s && unlink($pagefile);
         }
         $s = $s && rename("{$pagefile},new", $pagefile);
     }
     $s && fixperms($pagefile);
     if (!$s) {
         Abort("Cannot write page to {$pagename} ({$pagefile})...changes not saved");
     }
     PCache($pagename, $page);
 }
Ejemplo n.º 19
0
        $EnableWikiStyles=1;                    #include default wikistyles
    Each feature has a default setting, if the corresponding $Enable
    variable is not set then you get the default.

    To avoid processing any of the features of this file, set 
        $EnableStdConfig = 0;
    in config.php.
    
    Script maintained by Petko YOTOV www.pmwiki.org/petko
*/
$pagename = ResolvePageName($pagename);
if (!IsEnabled($EnableStdConfig, 1)) {
    return;
}
if (!function_exists('session_start') && IsEnabled($EnableRequireSession, 1)) {
    Abort('PHP is lacking session support', 'session');
}
if (IsEnabled($EnablePGCust, 1)) {
    include_once "{$FarmD}/scripts/pgcust.php";
}
if (isset($PostConfig) && is_array($PostConfig)) {
    asort($PostConfig, SORT_NUMERIC);
    foreach ($PostConfig as $k => $v) {
        if (!$k || !$v || $v < 0 || $v >= 50) {
            continue;
        }
        if (function_exists($k)) {
            $k($pagename);
        } elseif (file_exists($k)) {
            include_once $k;
        }
Ejemplo n.º 20
0
function LoadPageTemplate($pagename, $tfilefmt)
{
    global $PageStartFmt, $PageEndFmt, $EnableSkinDiag, $HTMLHeaderFmt, $HTMLFooterFmt, $IsTemplateLoaded, $TmplFmt, $TmplDisplay, $PageTextStartFmt, $PageTextEndFmt, $SkinDirectivesPattern;
    SDV($PageTextStartFmt, "\n<div id='wikitext'>\n");
    SDV($PageTextEndFmt, "</div>\n");
    SDV($SkinDirectivesPattern, "[[<]!--((?:wiki|file|function|markup):.*?)--[]>]");
    $sddef = array('PageEditFmt' => 0);
    $k = implode('', file(FmtPageName($tfilefmt, $pagename)));
    if (IsEnabled($EnableSkinDiag, 0)) {
        if (!preg_match('/<!--((No)?(HT|X)MLHeader|HeaderText)-->/i', $k)) {
            Abort("Skin template missing &lt;!--HTMLHeader--&gt;", 'htmlheader');
        }
        if (!preg_match('/<!--(No)?(HT|X)MLFooter-->/i', $k)) {
            Abort("Skin template missing &lt;!--HTMLFooter--&gt;", 'htmlheader');
        }
    }
    $sect = preg_split('#[[<]!--(/?(?:Page[A-Za-z]+Fmt|(?:HT|X)ML(?:Head|Foot)er|HeaderText|PageText).*?)--[]>]#', $k, 0, PREG_SPLIT_DELIM_CAPTURE);
    $TmplFmt['Start'] = array_merge(array('headers:'), preg_split("/{$SkinDirectivesPattern}/s", array_shift($sect), 0, PREG_SPLIT_DELIM_CAPTURE));
    $TmplFmt['End'] = array($PageTextEndFmt);
    $ps = 'Start';
    while (count($sect) > 0) {
        $k = array_shift($sect);
        $v = preg_split("/{$SkinDirectivesPattern}/s", array_shift($sect), 0, PREG_SPLIT_DELIM_CAPTURE);
        $TmplFmt[$ps][] = "<!--{$k}-->";
        if ($k[0] == '/') {
            $TmplFmt[$ps][] = count($v) > 1 ? $v : $v[0];
            continue;
        }
        @(list($var, $sd) = explode(' ', $k, 2));
        $GLOBALS[$var] = count($v) > 1 ? $v : $v[0];
        if ($sd > '') {
            $sddef[$var] = $sd;
        }
        if ($var == 'PageText') {
            $ps = 'End';
        }
        if ($var == 'HTMLHeader' || $var == 'XMLHeader') {
            $TmplFmt[$ps][] =& $HTMLHeaderFmt;
        }
        if ($var == 'HTMLFooter' || $var == 'XMLFooter') {
            $TmplFmt[$ps][] =& $HTMLFooterFmt;
        }
        ##   <!--HeaderText--> deprecated, 2.1.16
        if ($var == 'HeaderText') {
            $TmplFmt[$ps][] =& $HTMLHeaderFmt;
        }
        $TmplFmt[$ps][$var] =& $GLOBALS[$var];
    }
    array_push($TmplFmt['Start'], $PageTextStartFmt);
    $PageStartFmt = 'function:PrintSkin Start';
    $PageEndFmt = 'function:PrintSkin End';
    $IsTemplateLoaded = 1;
    SDVA($TmplDisplay, $sddef);
}
Ejemplo n.º 21
0
function ThumbrunMakeThumb($uploaddir, $file, $thumbfile, $w, $h)
{
    global $Thumbrun;
    $filepath = "{$uploaddir}/{$file}";
    $thumbpath = "{$uploaddir}/{$thumbfile}";
    if (@$Thumbrun['ThumbDir']) {
        $thumbpath = $uploaddir . '/' . $Thumbrun['ThumbDir'] . '/' . $thumbfile;
    }
    if (file_exists($thumbpath) || !file_exists($filepath)) {
        return;
    }
    $bg = $Thumbrun['ThumbBg'];
    $tmp1 = "{$uploaddir}/{$thumbfile}_tmp.png";
    $area = $w * $h;
    #$cmdfmt = 'convert -thumbnail \'%dx%d\' -gravity center -background %s -extent \'%dx%d\' %s %s';
    # Need to use the following conversion instead because of
    # ImageMagick version earlier than 6.3
    $cmdfmt = 'convert -thumbnail \'%dx%d>\' -bordercolor %s -background %s -border 50 -gravity center  -crop %dx%d+0+0 +repage %s %s';
    $cl = sprintf($cmdfmt, $w, $h, $bg, $bg, $w, $h, $filepath, $tmp1);
    $r = exec($cl, $o, $status);
    if (intval($status) != 0) {
        Abort("convert returned <pre>{$r}\n" . print_r($o, true) . "'</pre> with a status '{$status}'.<br/> Command line was '{$cl}'.");
    }
    // fluff
    #$cmdfmt = 'convert -page +4+4 %s -matte \( +clone -background navy -shadow 60x4+4+4 \) +swap -background none -mosaic %s';
    $cmdfmt = 'convert -mattecolor %s -frame 6x6+3+0 %s %s';
    $cl = sprintf($cmdfmt, $bg, $tmp1, $thumbpath);
    $r = exec($cl, $o, $status);
    if (intval($status) != 0) {
        Abort("convert returned <pre>{$r}\n" . print_r($o, true) . "'</pre> with a status '{$status}'.<br/> Command line was '{$cl}'.");
    }
    unlink($tmp1);
}
Ejemplo n.º 22
0
function HandleSearchA($pagename, $level = 'read') {
  global $PageSearchForm, $FmtV, $HandleSearchFmt, 
    $PageStartFmt, $PageEndFmt;
  SDV($HandleSearchFmt,array(&$PageStartFmt, '$PageText', &$PageEndFmt));
  SDV($PageSearchForm, '$[{$SiteGroup}/Search]');
  $form = RetrieveAuthPage($pagename, $level, true, READPAGE_CURRENT);
  if (!$form) Abort("?unable to read $pagename");
  PCache($pagename, $form);
  $text = preg_replace('/\\[([=@])(.*?)\\1\\]/s', ' ', @$form['text']);
  if (!preg_match('/\\(:searchresults(\\s.*?)?:\\)/', $text))
    foreach((array)$PageSearchForm as $formfmt) {
      $form = ReadPage(FmtPageName($formfmt, $pagename), READPAGE_CURRENT);
      if ($form['text']) break;
    }
  $text = @$form['text'];
  if (!$text) $text = '(:searchresults:)';
  $FmtV['$PageText'] = MarkupToHTML($pagename,$text);
  PrintFmt($pagename, $HandleSearchFmt);
}
Ejemplo n.º 23
0
function HandleDiff($pagename, $auth = 'read')
{
    global $HandleDiffFmt, $PageStartFmt, $PageDiffFmt, $PageEndFmt;
    $page = RetrieveAuthPage($pagename, $auth, true);
    if (!$page) {
        Abort("?cannot diff {$pagename}");
    }
    PCache($pagename, $page);
    SDV($HandleDiffFmt, array(&$PageStartFmt, &$PageDiffFmt, "<div id='wikidiff'>", 'function:PrintDiff', '</div>', &$PageEndFmt));
    PrintFmt($pagename, $HandleDiffFmt);
}
Ejemplo n.º 24
0
function ConvertV1WikiD($path) {
  global $WikiDir;
  Lock(2);
  if (!is_dir($path)) {
    Abort("?$path is not an accessible directory");
    exit();
  }
  $WikiV1Dir = new PageStore1x("$path/\$FullName");
  $oldlist = $WikiV1Dir->ls();
  $newlist = ListPages();
  $bothlist = array_intersect($oldlist,$newlist); sort($bothlist);
  $difflist = array_diff($oldlist,$newlist); sort($difflist);
  $bcount = count($bothlist);
  $dcount = count($difflist); 

  echo "
    <html>
    <head>
    <title>Convert v1 pages to v2</title>
    </head>
    <body>
    <h2>Convert and Copy PmWiki v1.x pages into v2.x</h2>
  ";

  $copy = array();
  if (@$_POST['copydiff']) $copy = $difflist;
  if (@$_POST['copyboth']) $copy = array_merge($copy,$bothlist);
  if (@$_POST['copy']) $copy = array_merge($copy,$_POST['copy']);

  if (@$copy) { 
    echo "<p>Okay, I'm now converting the pages you've requested.
       When this is finished, you can see if anything else needs to
       be converted, otherwise you can get rid of the 
       <tt>include_once('scripts/compat1x.php');</tt> and
       <tt>ConvertV1WikiD()</tt> lines that are in your 
       local/config.php file.</p>";
    $copy = array_unique($copy);
    foreach($copy as $p) { 
      echo "<li>Converting $p</li>\n"; 
      $page = $WikiV1Dir->read($p);
      WritePage($p,$page);
    }
    echo "<p>Converted ", count($copy), " pages.</p>\n";
  } else {
    echo "
      <p>This function will migrate pages from a 1.x wiki.d/ directory ($path)
      into your 2.x wiki.d/ directory, converting markups as it proceeds. 
      Note that the files in your 1.x wiki.d/ directory are not affected
      by this script, so if the conversion doesn't work out for any reason
      you still have your original pages lying around.</p>
    ";
  }

  /* now rebuild the lists */
  $oldlist = $WikiV1Dir->ls();
  $newlist = ListPages();
  $bothlist = array_intersect($oldlist,$newlist); sort($bothlist);
  $difflist = array_diff($oldlist,$newlist); sort($difflist);
  $bcount = count($bothlist);
  $dcount = count($difflist); 

 
  echo " <form method='post'> ";

  echo "<h3>Migrate pages from v1 to v2 (don't overwrite existing 
    v2 pages)</h3>";

  if ($difflist) {
    echo "
      <p>The following $dcount pages exist only in the version 1
      wiki.d/ directory.  </p>
      <dd><input type='submit' name='copydiff' value='Copy and convert all
        pages that do not already exist' /></dd>
      <p>or</p><dd><input type='submit' name='copyindv' value='Copy and convert
        pages checked in the list below' /><p></p></dd>
    ";
    foreach($difflist as $p) 
      echo "<dd><input type='checkbox' name='copy[]' value='$p' /> $p</dd>\n";
  } else {
    echo "<p>There aren't any pages in your version 1 wiki.d/ directory that 
      are not already in your version 2 directory.</p>";
  }
  
  echo "<h3>Migrate pages from v1 to v2 (overwrite existing v2 pages)</h3>
    <p>The following $bcount pages exist in <em>both</em> the version 1 and
    version 2 wiki.d/ directories.  If you use one of the buttons below,
    then your converted version 1 pages will <em>overwrite</em> the existing 
    version 2 pages, and you will lose any edits that you might have made
    in the version 2 installation (it's possible that
    this is what you want).</p>
    <dd><input type='submit' name='copyboth' value='Convert and overwrite
      pages that do already exist' /></dd>
    <p>or</p><dd><input type='submit' name='copyindv' value='Convert and
      overwrite pages checked in the list below' /><p></p></dd>
  ";
  foreach($bothlist as $p) 
    echo "<dd><input type='checkbox' name='copy[]' value='$p' /> $p</dd>\n";

  echo "</form></body></html>\n";
  exit();
}
Ejemplo n.º 25
0
function HandleFeed($pagename, $auth = 'read')
{
    global $FeedFmt, $action, $PCache, $FmtV, $ISOTimeFmt, $RSSTimeFmt, $FeedOpt, $FeedDescPatterns, $CategoryGroup, $EntitiesTable;
    SDV($ISOTimeFmt, '%Y-%m-%dT%H:%M:%SZ');
    SDV($RSSTimeFmt, 'D, d M Y H:i:s \\G\\M\\T');
    SDV($FeedDescPatterns, array('/<[^>]*$/' => ' ', '/\\w+$/' => '', '/<[^>]+>/' => ''));
    SDVA($FeedCategoryOpt, array('link' => $pagename, 'readf' => 1));
    SDVA($FeedTrailOpt, array('trail' => $pagename, 'count' => 10, 'readf' => 1));
    $f = $FeedFmt[$action];
    $page = RetrieveAuthPage($pagename, $auth, true, READPAGE_CURRENT);
    if (!$page) {
        Abort("?cannot generate feed");
    }
    $feedtime = $page['time'];
    # determine list of pages to display
    if (@($_REQUEST['trail'] || $_REQUEST['group'] || $_REQUEST['link'])) {
        $opt['readf'] = 1;
    } else {
        if ($action == 'dc') {
            $opt = array();
        } else {
            if (preg_match("/^{$CategoryGroup}\\./", $pagename)) {
                $opt = $FeedCategoryOpt;
            } else {
                $opt = $FeedTrailOpt;
            }
        }
    }
    if (!$opt) {
        PCache($pagename, $page);
        $pagelist = array(&$PCache[$pagename]);
    } else {
        $opt = array_merge($opt, @$_REQUEST);
        $pagelist = MakePageList($pagename, $opt);
    }
    # process list of pages in feed
    $rdfseq = '';
    foreach ($pagelist as $page) {
        $pn = $page['name'];
        if (!PageExists($pn)) {
            continue;
        }
        $pl[] = $pn;
        if (@$opt['count'] && count($pl) >= $opt['count']) {
            break;
        }
        $rdfseq .= FmtPageName("<rdf:li resource=\"\$PageUrl\" />\n", $pn);
        if ($page['time'] > $feedtime) {
            $feedtime = $page['time'];
        }
    }
    $pagelist = $pl;
    $FmtV['$FeedRDFSeq'] = $rdfseq;
    $FmtV['$FeedISOTime'] = gmstrftime($ISOTimeFmt, $feedtime);
    $FmtV['$FeedRSSTime'] = gmdate($RSSTimeFmt, $feedtime);
    # format start of feed
    $out = FmtPageName($f['feed']['_start'], $pagename);
    # format feed elements
    foreach ($f['feed'] as $k => $v) {
        if ($k[0] == '_' || !$v) {
            continue;
        }
        $x = FmtPageName($v, $pagename);
        if (!$x) {
            continue;
        }
        $out .= $v[0] == '<' ? $x : "<{$k}>{$x}</{$k}>\n";
    }
    # format items in feed
    if (@$f['feed']['_items']) {
        $out .= FmtPageName($f['feed']['_items'], $pagename);
    }
    foreach ($pagelist as $pn) {
        $page =& $PCache[$pn];
        $FmtV['$ItemDesc'] = @$page['description'] ? $page['description'] : trim(preg_replace(array_keys($FeedDescPatterns), array_values($FeedDescPatterns), @$page['excerpt']));
        $FmtV['$ItemISOTime'] = gmstrftime($ISOTimeFmt, $page['time']);
        $out .= FmtPageName($f['item']['_start'], $pn);
        foreach ((array) @$f['item'] as $k => $v) {
            if ($k[0] == '_' || !$v) {
                continue;
            }
            if (is_callable($v)) {
                $out .= $v($pn, $page, $k);
                continue;
            }
            if (strpos($v, '$LastModifiedBy') !== false && !@$page['author']) {
                continue;
            }
            if (strpos($v, '$Category') !== false) {
                if (preg_match_all("/(?<=^|,){$CategoryGroup}\\.([^,]+)/", @$page['targets'], $match)) {
                    foreach ($match[1] as $c) {
                        $FmtV['$Category'] = $c;
                        $out .= FmtPageName($v, $pn);
                    }
                }
                continue;
            }
            $x = FmtPageName($v, $pn);
            if (!$x) {
                continue;
            }
            $out .= $v[0] == '<' ? $x : "<{$k}>{$x}</{$k}>\n";
        }
        $out .= FmtPageName($f['item']['_end'], $pn);
    }
    $out .= FmtPageName($f['feed']['_end'], $pagename);
    foreach ((array) @$f['feed']['_header'] as $fmt) {
        header(FmtPageName($fmt, $pagename));
    }
    print str_replace(array_keys($EntitiesTable), array_values($EntitiesTable), $out);
}
Ejemplo n.º 26
0
 function write($pagename,$page) {
   global $Now,$Version,$Newline;
   $page['name'] = $pagename;
   $page['time'] = $Now;
   $page['host'] = $_SERVER['REMOTE_ADDR'];
   $page['agent'] = $_SERVER['HTTP_USER_AGENT'];
   $page['rev'] = @$page['rev']+1;
   $s = false;
   $pagefile = FmtPageName($this->dirfmt,$pagename);
   mkgiddir(dirname($pagefile));
   if ($pagefile && ($fp=fopen("$pagefile,new","w"))) {
     $s = true && fputs($fp,"version=$Version\nnewline=$Newline\n");
     foreach($page as $k=>$v) 
       if ($k>'') $s = $s&&fputs($fp,str_replace("\n",$Newline,"$k=$v")."\n");
     $s = fclose($fp) && $s;
     if (file_exists($pagefile)) $s = $s && unlink($pagefile);
     $s = $s && rename("$pagefile,new",$pagefile);
   }
   if (!$s)
     Abort("Cannot write page to $pagename ($pagefile)...changes not saved");
 }
Ejemplo n.º 27
0
 function write($pagename, $page)
 {
     global $Now, $Version, $Newline;
     $page['name'] = $pagename;
     $page['time'] = $Now;
     $page['host'] = $_SERVER['REMOTE_ADDR'];
     $page['agent'] = $_SERVER['HTTP_USER_AGENT'];
     $page['rev'] = @$page['rev'] + 1;
     unset($page['version']);
     unset($page['newline']);
     $s = false;
     $pagefile = FmtPageName($this->dirfmt, $pagename);
     mkdirp(dirname($pagefile));
     if ($pagefile && ($fp = fopen("{$pagefile},new", "w"))) {
         $s = true && fputs($fp, "version={$Version}\nnewline={$Newline}\n");
         foreach ($page as $k => $v) {
             if ($k > '') {
                 $s = $s && fputs($fp, str_replace("\n", $Newline, "{$k}={$v}") . "\n");
             }
         }
         $s = fclose($fp) && $s;
         if (file_exists($pagefile)) {
             $s = $s && unlink($pagefile);
         }
         $s = $s && rename("{$pagefile},new", $pagefile);
     }
     $s && fixperms($pagefile);
     if (!$s) {
         Abort("Cannot write page to {$pagename} ({$pagefile})...changes not saved");
     }
 }
Ejemplo n.º 28
0
function SetSkin($pagename, $skin)
{
    global $Skin, $SkinDir, $SkinDirUrl, $IsTemplateLoaded, $PubDirUrl, $FarmPubDirUrl, $FarmD;
    unset($Skin);
    foreach ((array) $skin as $s) {
        $sd = FmtPageName("pub/skins/{$s}", $pagename);
        if (is_dir($sd)) {
            $Skin = $s;
            $SkinDirUrl = "{$PubDirUrl}/skins/{$Skin}";
            break;
        }
        $sd = FmtPageName("{$FarmD}/pub/skins/{$s}", $pagename);
        if (is_dir($sd)) {
            $Skin = $s;
            $SkinDirUrl = "{$FarmPubDirUrl}/skins/{$Skin}";
            break;
        }
    }
    if (!is_dir($sd)) {
        Abort("?unable to find skin from list " . implode(' ', (array) $skin));
    }
    $SkinDir = $sd;
    $IsTemplateLoaded = 0;
    if (file_exists("{$SkinDir}/{$Skin}.php")) {
        include_once "{$SkinDir}/{$Skin}.php";
    } else {
        if (file_exists("{$SkinDir}/skin.php")) {
            include_once "{$SkinDir}/skin.php";
        }
    }
    if ($IsTemplateLoaded) {
        return;
    }
    if (file_exists("{$SkinDir}/{$Skin}.tmpl")) {
        LoadPageTemplate($pagename, "{$SkinDir}/{$Skin}.tmpl");
    } else {
        if (file_exists("{$SkinDir}/skin.tmpl")) {
            LoadPageTemplate($pagename, "{$SkinDir}/skin.tmpl");
        } else {
            if ($dh = opendir($SkinDir)) {
                while (($fname = readdir($dh)) !== false) {
                    if (substr($fname, -5) != '.tmpl') {
                        continue;
                    }
                    if ($IsTemplateLoaded) {
                        Abort("?unable to find unique template in {$SkinDir}");
                    }
                    LoadPageTemplate($pagename, "{$SkinDir}/{$fname}");
                }
                closedir($dh);
            }
        }
    }
    if (!$IsTemplateLoaded) {
        Abort("Unable to load {$Skin} template");
    }
}
Ejemplo n.º 29
0
function HandlePostUpload($pagename, $auth = 'upload') {
  global $UploadVerifyFunction, $UploadFileFmt, $LastModFile, 
    $EnableUploadVersions, $Now;
  $page = RetrieveAuthPage($pagename, $auth, true, READPAGE_CURRENT);
  if (!$page) Abort("?cannot upload to $pagename");
  $uploadfile = $_FILES['uploadfile'];
  $upname = $_REQUEST['upname'];
  if ($upname=='') $upname=$uploadfile['name'];
  $upname = MakeUploadName($pagename,$upname);
  if (!function_exists($UploadVerifyFunction))
    Abort('?no UploadVerifyFunction available');
  $filepath = FmtPageName("$UploadFileFmt/$upname",$pagename);
  $result = $UploadVerifyFunction($pagename,$uploadfile,$filepath);
  if ($result=='') {
    $filedir = preg_replace('#/[^/]*$#','',$filepath);
    mkdirp($filedir);
    if (IsEnabled($EnableUploadVersions, 0))
      @rename($filepath, "$filepath,$Now");
    if (!move_uploaded_file($uploadfile['tmp_name'],$filepath))
      { Abort("?cannot move uploaded file to $filepath"); return; }
    fixperms($filepath,0444);
    if ($LastModFile) { touch($LastModFile); fixperms($LastModFile); }
    $result = "upresult=success";
  }
  Redirect($pagename,"{\$PageUrl}?action=upload&uprname=$upname&$result");
}
Ejemplo n.º 30
0
function HandleRefCount($pagename, $auth='read') {
  global $HandleRefCountFmt,$PageStartFmt,$PageEndFmt;
  $page = RetrieveAuthPage($pagename, $auth, true, READPAGE_CURRENT);
  if (!$page) Abort('?unauthorized');
  PCache($pagename, $page);
  SDV($HandleRefCountFmt,array(&$PageStartFmt,
    'function:PrintRefCount',&$PageEndFmt));
  PrintFmt($pagename,$HandleRefCountFmt);
}