当前位置: 首页>>代码示例>>PHP>>正文


PHP mkdirp函数代码示例

本文整理汇总了PHP中mkdirp函数的典型用法代码示例。如果您正苦于以下问题:PHP mkdirp函数的具体用法?PHP mkdirp怎么用?PHP mkdirp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了mkdirp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: upload_file

 function upload_file()
 {
     if (!isset($_FILES[$this->model->name()])) {
         return;
     }
     // Set Information for Later Use
     $this->file_path = "{$this->upload_directory}" . $this->partitioned_path();
     $this->file_name = $_FILES[$this->model->name()]['name'][$this->field];
     $this->full_path = "{$this->file_path}/{$this->file_name}";
     // Check for max file size
     if (isset($this->max_file_size) && $_FILES[$this->model->name()]['size'][$this->field] > $this->max_file_size) {
         $this->model->errors[] = "Uploaded file is to large.";
     }
     // Check for accepted file types
     $this->file_type = strtolower($this->file_extension($_FILES[$this->model->name()]['name'][$this->field]));
     if (!in_array($this->file_type, $this->accepted_file_types)) {
         $this->model->errors[] = "The file type '{$this->file_type}' not allowed.";
     }
     // Upload the file
     if (file_exists(APPLICATION_ROOT . "/public{$this->file_path}")) {
         $this->destroy();
     }
     mkdirp(APPLICATION_ROOT . "/public/{$this->upload_directory}" . $this->partitioned_path());
     if (!is_uploaded_file($_FILES[$this->model->name()]['tmp_name'][$this->field])) {
         $this->model->errors[] = "Error uploading file.";
     }
     if (!copy($_FILES[$this->model->name()]['tmp_name'][$this->field], APPLICATION_ROOT . "/public/{$this->full_path}")) {
         $this->model->errors[] = "Error uploading file.";
     }
     // Resize the image
     if (isset($this->resize)) {
         $this->resize_image($this->resize, APPLICATION_ROOT . "/public/{$this->full_path}", APPLICATION_ROOT . "/public/{$this->full_path}");
     }
     $this->model->fields[$this->field] = $this->full_path;
     // Create thumbnails
     if (isset($this->thumbnails)) {
         foreach ($this->thumbnails as $name => $resize) {
             $this->resize_image($resize, APPLICATION_ROOT . "/public/{$this->full_path}", APPLICATION_ROOT . "/public/{$this->file_path}/{$name}_{$this->file_name}");
             $this->model->fields["{$name}_{$this->field}"] = "{$this->file_path}/{$name}_{$this->file_name}";
         }
     }
 }
开发者ID:russ,项目名称:jacks-php,代码行数:42,代码来源:file_upload.php

示例2: ThumbShoeMakeThumb

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);
}
开发者ID:rubykat,项目名称:pmwiki-thumbshoe,代码行数:41,代码来源:thumbs.php

示例3: write

 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");
     }
 }
开发者ID:BogusCurry,项目名称:pmwiki,代码行数:31,代码来源:pmwiki.php

示例4: file_get_contents

<?php

// require config
$configString = file_get_contents('./server/config.json');
$configOption = json_decode($configString);
// difine path & Template
$filePaths = array($configOption->path->table, $configOption->path->sql, $configOption->path->md);
$tableTemp = array('tableName' => '', 'fields' => array(), 'keys' => array());
$fieldTemp = array('Field' => '', 'Type' => '', 'Collation' => '', 'Null' => '', 'Key' => '', 'Default' => NULL, 'Extra' => '', 'Comment' => '');
$keyTemp = array('Non_unique' => '', 'Key_name' => '', 'Column_name' => '', 'Type' => '', 'Comment' => '', 'Index_comment' => '');
$descTemp = array('Name' => '', 'Engine' => '', 'Comment' => '');
// build filePath
foreach ($filePaths as $path) {
    mkdirp($path);
}
// connect mysql
$con = mysql_connect($configOption->db->host, $configOption->db->user, $configOption->db->password);
if (!$con) {
    die('Could not connect: ' . mysql_error());
}
mysql_query('set names utf8');
// make foo the current db
mysql_select_db($configOption->db->database, $con) or die(mysql_error());
// sql execute && file write
$sql_show_table = "SHOW TABLE STATUS";
$result_show_table = mysql_query($sql_show_table);
$all_tables_desc_arr = array();
$all_table_name = array();
while ($property = mysql_fetch_assoc($result_show_table)) {
    $all_table_name[] = $property['Name'];
    // p($property);
开发者ID:TheOne1006,项目名称:database_dictionary_build,代码行数:31,代码来源:php-build-mysql-db-dictionary.php

示例5: write

 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);
 }
开发者ID:BogusCurry,项目名称:pmwiki,代码行数:38,代码来源:pmwiki.php

示例6: foreach

    return;
}
$LastModTime = @filemtime($LastModFile);
foreach (get_included_files() as $f) {
    $v = @filemtime($f);
    if ($v > $LastModTime) {
        $LastModTime = $v;
    }
}
if (@$EnableIMSCaching && in_array($action, (array) $CacheActions)) {
    $HTTPLastMod = gmdate('D, d M Y H:i:s \\G\\M\\T', $LastModTime);
    $HTTPHeaders[] = "Cache-Control: no-cache";
    $HTTPHeaders[] = "Last-Modified: {$HTTPLastMod}";
    if (@$_SERVER['HTTP_IF_MODIFIED_SINCE'] == $HTTPLastMod) {
        header("HTTP/1.0 304 Not Modified");
        exit;
    }
}
if ($NoHTMLCache || !@$PageCacheDir || count($_POST) > 0 || count($_GET) > 2 || count($_GET) == 1 && !$_GET['n']) {
    $NoHTMLCache |= 1;
    return;
}
mkdirp($PageCacheDir);
if (!file_exists("{$PageCacheDir}/.htaccess") && ($fp = @fopen("{$PageCacheDir}/.htaccess", "w"))) {
    fwrite($fp, "Order Deny,Allow\nDeny from all\n");
    fclose($fp);
}
$PageCacheFile = "{$PageCacheDir}/{$pagename},cache";
if (file_exists($PageCacheFile) && @filemtime($PageCacheFile) < $LastModTime) {
    @unlink($PageCacheFile);
}
开发者ID:BogusCurry,项目名称:pmwiki,代码行数:31,代码来源:caches.php

示例7: HandlePostUpload

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");
}
开发者ID:BogusCurry,项目名称:pmwiki,代码行数:38,代码来源:upload.php

示例8: HandlePostUpload

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}");
}
开发者ID:BogusCurry,项目名称:pmwiki,代码行数:34,代码来源:upload.php

示例9: HandleFastCacheBrowse

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
}
开发者ID:jefmud,项目名称:pmwiki-kit-bootstrap-compass,代码行数:90,代码来源:fastcache.php

示例10: HandlePostDrawing_draw

/**
 * 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;
}
开发者ID:microcosmx,项目名称:experiments,代码行数:81,代码来源:AnyWikiDraw.php

示例11: write_cache_file

 function write_cache_file($pagename, $imgdata)
 {
     global $Version;
     $cachefile = $this->cachefile($pagename);
     $dir = dirname($cachefile);
     mkdirp($dir);
     if (!file_exists("{$dir}/.htaccess") && ($fp = @fopen("{$dir}/.htaccess", 'w'))) {
         fwrite($fp, "Order Deny,Allow\nDeny from all\n");
         fclose($fp);
     }
     $st = false;
     if ($cachefile && ($fp = fopen("{$cachefile},new", 'w'))) {
         $st = true;
         if ($imgdata) {
             $st = $st && fwrite($fp, "[image]\n");
             foreach ($imgdata as $k => $v) {
                 $st = $st && fwrite($fp, "{$k} = " . '"' . $v . '"' . "\n");
             }
             $st = $st && fwrite($fp, "\n");
         }
         $st = fclose($fp) && $st;
         if (file_exists($cachefile)) {
             $st = $st && unlink($cachefile);
         }
         $st = $st && rename("{$cachefile},new", $cachefile);
     }
     if ($st) {
         fixperms($cachefile);
     } else {
         Abort("Cannot write page {$pagename} cache to ({$cachefile})...");
     }
 }
开发者ID:rubykat,项目名称:pmwiki-thumbshoe,代码行数:32,代码来源:pagestore.php

示例12: write_xml

 function write_xml($pagename, $page)
 {
     global $Now, $Version, $Charset;
     $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 ($pagefile && ($fp = fopen("{$pagefile},new", "w"))) {
         $x = "<?xml version=\"1.0\" encoding=\"{$Charset}\"?>\n<page xmlns=\"http://www.pmwiki.org/cookbook/xmlpage\" version=\"{$Version}\">\n";
         $s = true && fputs($fp, $x);
         $sz = strlen($x);
         foreach ($page as $k => $v) {
             if ($k > '' && $k[0] != '=') {
                 $v = htmlspecialchars($v, ENT_NOQUOTES, $Charset);
                 if (preg_match("/^([a-z]+)(?::(\\d+))(?::(\\d+):)?\$/", $k, $m)) {
                     $p = empty($m[3]) ? "" : " prev=\"{$m[3]}\"";
                     $x = "<{$m[1]} time=\"{$m[2]}\"{$p}>{$v}</{$m[1]}>\n";
                 } else {
                     $x = "<{$k}>{$v}</{$k}>\n";
                 }
                 $s = $s && fputs($fp, $x);
                 $sz += strlen($x);
             }
         }
         $x = "</page>\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);
 }
开发者ID:anomen-s,项目名称:pmwiki-recipes,代码行数:48,代码来源:XMLPageStore.php

示例13: thumb

 function thumb($path, $width, $height, $resizeMode = "")
 {
     // exists?
     $pagename = fileNameToPageName($path);
     $original = $this->picturesBasePath . "/" . $path;
     if (!is_file($original)) {
         Abort('image doesn\'t exist');
     }
     // resize?
     if ($width == 0 && $height == 0) {
         $filename = $original;
     } else {
         // resize
         $filename = $this->cacheBasePath . "/" . $this->cacheFileName($path, $width, $height, $resizeMode);
         $exists = WikiGalleryIsFileAndNonZero($filename);
         if (!$exists || filemtime($filename) < filemtime($original)) {
             if (is_file($filename)) {
                 // if it already there, it must be updated. So remove it to avoid trouble overwriting it
                 unlink($filename);
             } else {
                 // make directory
                 $dir = dirname($filename);
                 mkdirp($dir);
             }
             // call ImageMagick or GD to scale
             $this->scale($original, $filename, $width, $height, $resizeMode);
         } else {
             // touch it so that it is not purged during cleanup
             touch($filename);
         }
     }
     // Checking if the client is validating his cache and if it is current.
     $etag = md5($original . filemtime($original) . filesize($original));
     header('ETag: ' . $etag);
     if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == filemtime($original) || isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag) {
         // Client's cache IS current, so we just respond '304 Not Modified'.
         header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($original)) . ' GMT', true, 304);
     } else {
         // Image not cached or cache outdated, we respond '200 OK' and output the image.
         header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($original)) . ' GMT', true, 200);
         header('Content-Length: ' . filesize($filename));
         header("Content-type: " . WikiGalleryMimeType($original));
         header("Pragma: ");
         header('Expires: ' . gmdate('D, j M Y H:i:s T', time() + 600));
         header("Cache-Control: max-age=600, must-revalidate");
         print file_get_contents($filename);
     }
 }
开发者ID:gregorklaric,项目名称:wikigallery,代码行数:48,代码来源:thumb.php

示例14: HandlePostUpload

function HandlePostUpload($pagename, $auth = 'upload')
{
    global $UploadVerifyFunction, $UploadFileFmt, $LastModFile, $EnableUploadVersions, $Now, $RecentUploadsFmt, $FmtV;
    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";
        if (IsEnabled($RecentUploadsFmt, 0)) {
            $FmtV['$upname'] = $upname;
            $FmtV['$upsize'] = $uploadfile['size'];
            PostRecentChanges($pagename, '', '', $RecentUploadsFmt);
        }
    }
    Redirect($pagename, "{\$PageUrl}?action=upload&uprname={$upname}&{$result}");
}
开发者ID:libcrack,项目名称:pmwiki,代码行数:39,代码来源:upload.php

示例15: templates

	include_once('ressources/class.user.inc');
	include_once('ressources/class.kav4samba.inc');
	
	if(isset($_GET["debug-page"])){ini_set('display_errors', 1);ini_set('error_reporting', E_ALL);$GLOBALS["VERBOSE"]=true;}
	
	
	if(!CheckSambaRights()){
		$tpl=new templates();
		$ERROR_NO_PRIVS=$tpl->_ENGINE_parse_body("{ERROR_NO_PRIVS}");
		echo "<H1>$ERROR_NO_PRIVS</H1>";die();
	}
	if(isset($_GET["folder-security-list-users-table"])){folder_security_users_table();exit;}
	if(isset($_GET["main-js"])){main_smb_config_js();exit();};
	if( isset($_POST['upload']) ){main_kav4samba_LicenceUploaded();exit();}
	if(isset($_GET["FolderDelete"])){folder_delete();exit;}
	if(isset($_GET["mkdirp"])){mkdirp();exit;}
	if(isset($_GET["TreeRightInfos"])){TreeRightInfos();exit;}
	if(isset($_GET["userlists"])){echo folder_security_list_users();exit;}
	if(isset($_POST["AddUserToFolder"])){folder_security_adduser();exit;}
	if(isset($_POST["SaveUseridPrivileges"])){folder_security_save_priv();exit;}
	if(isset($_POST["DeleteAllFolderSecu"])){folder_security_clean_priv();exit;}
	if(isset($_GET["main"])){main_switch();exit;}
	if(isset($_POST["ChangeShareNameOrg"])){folder_change_sharename();exit;}
	if(isset($_POST["ArticaSambaAutomAskCreation"])){main_artica_for_samba_save();exit;}
	if(isset($_POST["recycle_vfs"])){recycle_vfs_save();exit;}
	
	if(isset($_GET["jsaddons"])){echo jsaddons();exit;}
	if(!CheckSambaUniqueRights()){
		$tpl=new templates();
		$ERROR_NO_PRIVS=$tpl->_ENGINE_parse_body("{ERROR_NO_PRIVS}");
		echo "<H1>$ERROR_NO_PRIVS</H1>";die();		
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:31,代码来源:samba.index.php


注:本文中的mkdirp函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。