本文整理汇总了PHP中_mkdir_p函数的典型用法代码示例。如果您正苦于以下问题:PHP _mkdir_p函数的具体用法?PHP _mkdir_p怎么用?PHP _mkdir_p使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_mkdir_p函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: macro_Clip
function macro_Clip($formatter, $value)
{
global $DBInfo;
$keyname = $DBInfo->_getPageKey($formatter->page->name);
$_dir = str_replace("./", '', $DBInfo->upload_dir . '/' . $keyname);
// support hashed upload dir
if (!is_dir($_dir) and !empty($DBInfo->use_hashed_upload_dir)) {
$prefix = get_hashed_prefix($keyname);
$_dir = str_replace('./', '', $DBInfo->upload_dir . '/' . $prefix . $keyname);
}
$name = _rawurlencode($value);
$enable_edit = 0;
umask(00);
if (!file_exists($_dir)) {
_mkdir_p($_dir, 0777);
}
$pngname = $name . '.png';
$now = time();
$url = $formatter->link_url($formatter->page->name, "?action=clip&value={$name}&now={$now}");
if (!file_exists($_dir . "/{$pngname}")) {
return "<a href='{$url}'>" . _("Paste a new picture") . "</a>";
}
$edit = '';
$end_tag = '';
if ($enable_edit) {
$edit = "<a href='{$url}'>";
$end_tag = '</a>';
}
return "{$edit}<img src='{$DBInfo->url_prefix}/{$_dir}/{$pngname}' border='0' alt='image' />{$end_tag}\n";
}
示例2: _mkdir_p
function _mkdir_p($target, $mode = 0777)
{
// from php.net/mkdir user contributed notes
if (file_exists($target)) {
if (!is_dir($target)) {
return false;
} else {
return true;
}
}
// recursivly create dirs.
return _mkdir_p(dirname($target), $mode) and mkdir($target, $mode);
}
示例3: processor_pic
function processor_pic($formatter, $value = "")
{
global $DBInfo;
$GROFF = "groff -e -p -ms -Tps ";
$CONVERT = "convert -transparent white -density 120x120 -crop 0x0 -trim ";
$vartmp_dir =& $DBInfo->vartmp_dir;
if (getenv("OS") == "Windows_NT") {
$NULL = 'NUL';
$vartmp_dir = getenv('TEMP');
#$convert="wconvert";
}
$cache_dir = $DBInfo->upload_dir . "/PIC";
$cache_url = !empty($DBInfo->upload_url) ? $DBInfo->upload_url . '/PIC' : $DBInfo->url_prefix . '/' . $cache_dir;
if ($value[0] == '#' and $value[1] == '!') {
list($line, $value) = explode("\n", $value, 2);
}
$pic_script = $value;
# print "<pre>$pic_script</pre>";
$uniq = md5($pic_script);
if ($DBInfo->cache_public_dir) {
$fc = new Cache_text('pic', array('ext' => 'png', 'dir' => $DBInfo->cache_public_dir));
$pngname = $fc->getKey($uniq, false);
$outpath_png = $DBInfo->cache_public_dir . '/' . $pngname;
$png_url = $DBInfo->cache_public_url ? $DBInfo->cache_public_url . '/' . $pngname : $DBInfo->url_prefix . '/' . $outpath_png;
} else {
$outpath_png = $cache_dir . '/' . $uniq . '.png';
$png_url = $cache_url . '/' . $uniq . '.png';
}
$outpath_pic = "{$vartmp_dir}/{$uniq}.pic";
$outpath_ps = "{$vartmp_dir}/{$uniq}.ps";
if (!file_exists(dirname($outpath_png))) {
umask(00);
_mkdir_p(dirname($outpath_png), 0777);
umask(022);
}
if ($formatter->refresh || !file_exists($outpath_png)) {
# write to pic script file
$ifp = fopen("{$outpath_pic}", "w");
fwrite($ifp, $pic_script);
fclose($ifp);
# convert processing
$fp = popen("{$GROFF} {$outpath_pic} >{$outpath_ps}" . $formatter->NULL, 'r');
pclose($fp);
$fp = popen("{$CONVERT} {$outpath_ps} {$outpath_png}" . $formatter->NULL, 'r');
pclose($fp);
# delete temporary files
unlink($outpath_ps);
unlink($outpath_pic);
}
return "<img class='tex' src='{$png_url}' alt='pic' />";
}
示例4: TitleIndexer_Text
function TitleIndexer_Text($name = 'titleindexer')
{
global $Config;
$this->text_dir = $Config['text_dir'];
$this->cache_dir = $Config['cache_dir'] . '/' . $name;
if (!is_dir($this->cache_dir)) {
$om = umask(00);
_mkdir_p($this->cache_dir, 0777);
umask($om);
}
$this->pagelst = $this->cache_dir . '/' . $name . '.lst';
$this->pagecnt = $this->cache_dir . '/' . $name . '.cnt';
$this->pagelck = $this->cache_dir . '/' . $name . '.lock';
}
示例5: TitleIndexer_Text
function TitleIndexer_Text($name = 'titleindexer')
{
global $Config;
if (strtolower($Config['charset']) != 'utf-8') {
$this->_match_flags = 'im';
}
$this->text_dir = $Config['text_dir'];
$this->cache_dir = $Config['cache_dir'] . '/' . $name;
if (!is_dir($this->cache_dir)) {
$om = umask(00);
_mkdir_p($this->cache_dir, 0777);
umask($om);
}
$this->pagelst = $this->cache_dir . '/' . $name . '.lst';
$this->pagecnt = $this->cache_dir . '/' . $name . '.cnt';
$this->pagelck = $this->cache_dir . '/' . $name . '.lock';
}
示例6: BBS_text
function BBS_text($name, $conf)
{
# $conf['data_dir'] from DBInfo.
$this->bbsname = $name;
# XXX
$this->text_dir = $conf['data_dir'] . '/text/' . $name . '.d';
# XXX
$this->data_dir = $conf['data_dir'] . '/bbs/' . $name;
$this->cache_dir = $this->data_dir . '/cache';
$this->dba_type = $conf['dba_type'];
$this->use_attach = $conf['use_attach'];
# XXX
$this->index = $this->data_dir . '/.index';
$this->current = $this->data_dir . '/.current';
$this->count = $this->data_dir . '/.count';
# XXX
if ($conf['use_counter']) {
$this->counter = new Counter_dba($this);
}
if (!$this->counter->counter) {
$this->counter = new Counter();
}
if (!file_exists($this->index)) {
umask(00);
_mkdir_p($this->data_dir, 0777);
// XXX
@mkdir($this->text_dir, 0777);
// XXX
@mkdir($this->text_dir, 0777);
// XXX
umask(022);
touch($this->index);
touch($this->count);
# XXX global lock.
touch($this->text_dir . '/.lock');
$fp = fopen($this->current, 'w');
if ($fp) {
fwrite($fp, '1');
fclose($fp);
}
}
}
示例7: PageIndex
function PageIndex($name = 'pageindex')
{
global $Config;
if (strtolower($Config['charset']) != 'utf-8') {
$this->_match_flags = 'im';
}
$this->text_dir = $Config['text_dir'];
$this->cache_dir = $Config['cache_dir'] . '/' . $name;
if (!empty($Config['pageindex_chunksize'])) {
$this->chunksize = $Config['pageindex_chunksize'];
}
if (!is_dir($this->cache_dir)) {
$om = umask(00);
_mkdir_p($this->cache_dir, 0777);
umask($om);
}
$this->pagelst = $this->cache_dir . '/' . $name . '.lst';
$this->pageidx = $this->cache_dir . '/' . $name . '.idx';
$this->pagecnt = $this->cache_dir . '/' . $name . '.cnt';
$this->pagelck = $this->cache_dir . '/' . $name . '.lock';
}
示例8: _ci
function _ci($key, $log)
{
$dir = dirname($key);
if (!is_dir($dir . '/RCS')) {
$om = umask(00);
_mkdir_p($dir . '/RCS', 2777);
umask($om);
}
$mlog = '';
$plog = '';
if (getenv('OS') == 'Windows_NT' and isset($log[0])) {
// win32 cmd.exe arguments do not accept UTF-8 charset correctly.
// just use the stdin commit msg method instead of using -m"log" argument.
$logfile = tempnam($this->DB->vartmp_dir, 'COMMIT_LOG');
$fp = fopen($logfile, 'w');
if (is_resource($fp)) {
fwrite($fp, $log);
fclose($fp);
$plog = ' < ' . $logfile;
}
}
if (empty($plog)) {
// $log = escapeshellarg($log); // win32 does not work correctly
$log = '"' . preg_replace('/([\\\\"])/', "\\\\\\1", $log) . '"';
$mlog = ' -m' . $log;
}
if (!empty($this->DB->rcs_always_unlock)) {
$fp = popen("rcs -l -M {$key}", 'r');
if (is_resource($fp)) {
pclose($fp);
}
}
$fp = @popen("ci -l -x,v/ -q -t-\"" . $key . "\" " . $mlog . " " . $key . $plog . $this->NULL, "r");
if (is_resource($fp)) {
pclose($fp);
}
if (isset($plog[0])) {
unlink($logfile);
}
}
示例9: processor_gnuplot
//.........这里部分代码省略.........
if (preg_match('/^postscript\\s*(enhanced|color)?/', $tmatch[2])) {
// XXX
$term = $tmatch[2];
$ext = 'ps';
$size = '#set term ' . $term;
} else {
if (preg_match('/^svg/', $tmatch[2])) {
$term = $tmatch[2];
$ext = 'svg';
$size = "set size 1.0,1.0\n#set term " . $term;
}
}
}
if ($term != 'dumb') {
$plt = "\n" . $size . "\n" . $plt;
}
$uniq = md5($plt);
if ($DBInfo->cache_public_dir) {
$fc = new Cache_text('gnuplot', array('ext' => $ext, 'dir' => $DBInfo->cache_public_dir));
$pngname = $fc->getKey($uniq, false);
$png = $DBInfo->cache_public_dir . '/' . $pngname;
$png_url = $DBInfo->cache_public_url ? $DBInfo->cache_public_url . '/' . $pngname : $DBInfo->url_prefix . '/' . $png;
$cache_dir = $DBInfo->cache_public_dir;
} else {
$cache_dir = $DBInfo->upload_dir . "/GnuPlot";
$cache_url = $DBInfo->upload_url ? $DBInfo->upload_url . '/GnuPlot' : $DBInfo->url_prefix . '/' . $cache_dir;
$png = $cache_dir . '/' . $uniq . ".{$ext}";
$png_url = $cache_url . '/' . $uniq . ".{$ext}";
}
$outpath =& $png;
$src = "\nset term {$term}\nset out '{$outpath}'\n{$plt}\n";
if (!is_dir(dirname($png))) {
$om = umask(00);
_mkdir_p(dirname($png), 0777);
umask($om);
}
$log = '';
if ($formatter->refresh || !file_exists($outpath)) {
$flog = tempnam($vartmp_dir, "GNUPLOT");
#
# for Win32 wgnuplot.exe
#
if (getenv("OS") == "Windows_NT") {
$finp = tempnam($vartmp_dir, "GNUPLOT");
$ifp = fopen($finp, "w");
fwrite($ifp, $src);
fclose($ifp);
$cmd = "{$gnuplot} \"{$finp}\" > {$flog}";
$fp = system($cmd);
$log = join(file($flog), "");
if (file_exists($outpath)) {
unlink($flog);
unlink($finp);
} else {
print "<font color='red'>ERROR:</font> Gnuplot does not work correctly";
}
} else {
#
# Unix
#
$cmd = $gnuplot;
$formatter->errlog('GnuPlot');
$fp = popen($cmd . $formatter->LOG, "w");
if (is_resource($fp)) {
fwrite($fp, $src);
pclose($fp);
示例10: processor_latex
function processor_latex(&$formatter, $value = "", $options = array())
{
global $DBInfo;
if (empty($formatter->latex_uniq)) {
$formatter->latex_all = '';
$formatter->latex_uniq = array();
}
$latex_convert_options = !empty($DBInfo->latex_convert_options) ? $DBInfo->latex_convert_options : "-trim -crop 0x0 -density 120x120";
$raw_mode = isset($options['retval']) ? 1 : 0;
# site spesific variables
$latex = "latex";
$dvicmd = "dvipng";
$dviopt = '-D 120 -gamma 1.3';
$convert = "convert";
$mogrify = "mogrify";
$vartmp_dir =& $DBInfo->vartmp_dir;
$cache_dir = $DBInfo->upload_dir . "/LaTeX";
$cache_url = !empty($DBInfo->upload_url) ? $DBInfo->upload_url . '/LaTeX' : $DBInfo->url_prefix . '/' . $cache_dir;
$option = '-interaction=batchmode ';
$mask = '';
$options['dpi'] = intval($options['dpi']);
if (preg_match('/ps$/', $dvicmd)) {
$tmpext = 'ps';
$dviopt = '-D 300';
if (!empty($options['dpi'])) {
$latex_convert_options .= ' -density ' . $options['dpi'] . 'x' . $options['dpi'];
}
} else {
$tmpext = 'png';
$mask = '-%d';
if (!empty($options['dpi'])) {
$dviopt = preg_replace('/-D 120/', '', $dviopt);
$dviopt .= ' -D ' . $options['dpi'];
}
}
if ($value[0] == '#' and $value[1] == '!') {
list($line, $value) = explode("\n", $value, 2);
}
if (!$value) {
if (empty($DBInfo->latex_allinone)) {
return '';
}
}
$tex = $value;
if (!empty($DBInfo->latex_renumbering)) {
$GLOBALS['_latex_eq_num'] = !empty($formatter->latex_num) ? $formatter->latex_num : 0;
// renumbering
// just remove numbers and use \\tag{num}
$ntex = preg_replace_callback('/\\\\begin\\{\\s*(equation)\\s*\\}((.|\\n)+)\\\\end\\{\\s*\\1\\s*\\}/', '_latex_renumber', $tex);
#print '<pre>'.$ntex.'</pre>';
if ($tex != $ntex) {
$tex = $ntex;
}
$formatter->latex_num = $GLOBALS['_latex_eq_num'];
// save
} else {
if (!$raw_mode and !empty($DBInfo->latex_allinone)) {
$chunks = preg_split('/(\\\\begin\\{\\s*(?:equation)\\s*\\}(?:(?:.|\\n)+)\\\\end\\{\\s*\\1\\s*\\})/', $tex, -1, PREG_SPLIT_DELIM_CAPTURE);
if (($sz = count($chunks)) > 0) {
$ntex = '';
for ($i = 1; $i < $sz; $i += 2) {
$ntex .= $chunks[$i - 1];
preg_match('/\\\\begin\\{\\s*(equation)\\s*\\}((.|\\n)+)\\\\end\\{\\s*\\1\\s*\\}/', $chunks[$i], $m);
$ntex .= _latex_renumber(array('', $m[1], $m[2]), "\n%%");
}
$tex = $ntex;
}
#print '<pre>'.$ntex.'</pre>';
}
}
if (!empty($DBInfo->latex_template) and file_exists($DBInfo->data_dir . '/' . $DBInfo->latex_template)) {
$templ = implode('', file($DBInfo->data_dir . '/' . $DBInfo->latex_template));
} else {
$head = !empty($DBInfo->latex_header) ? $DBInfo->latex_header : '';
$templ = "\\documentclass[10pt,notitlepage]{article}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{amsfonts}{$head}\n%%\\usepackage[all]{xy}\n\\pagestyle{empty}\n\\begin{document}\n@TEX@\n\\end{document}\n%%{$dviopt}\n%%{$latex_convert_options}\n";
}
$src = str_replace('@TEX@', $tex, $templ);
$uniq = $tex ? md5($src) : $formatter->latex_uniq[sizeof($formatter->latex_uniq) - 1];
// check image file exists
if (empty($raw_mode) and !empty($DBInfo->latex_allinone) and $tex) {
$formatter->latex_uniq[] = $uniq;
$formatter->latex_all .= $tex . "\n\\pagebreak\n\n";
#print '<pre>'.$tex.'</pre>';
}
if (!empty($DBInfo->cache_public_dir)) {
$fc = new Cache_text('latex', array('ext' => 'png', 'dir' => $DBInfo->cache_public_dir));
$pngname = $fc->getKey($uniq, false);
$png = $DBInfo->cache_public_dir . '/' . $pngname;
$png_url = !empty($DBInfo->cache_public_url) ? $DBInfo->cache_public_url . '/' . $pngname : $DBInfo->url_prefix . '/' . $png;
} else {
$png = $cache_dir . '/' . $uniq . '.png';
$png_url = $cache_url . '/' . $uniq . '.png';
}
if (!is_dir(dirname($png))) {
$om = umask(00);
_mkdir_p(dirname($png), 0777);
umask($om);
}
$NULL = '/dev/null';
if (getenv("OS") == "Windows_NT") {
//.........这里部分代码省略.........
示例11: processor_geshi
function processor_geshi($formatter, $value, $options)
{
global $DBInfo;
if (!defined('GESHI_VERSION')) {
return $formatter->processor_repl('vim', $value, $options);
}
$syntax = array('actionscript', 'ada', 'apache', 'asm', 'asp', 'bash', 'c', 'c_mac', 'caddcl', 'cadlisp', 'cpp', 'csharp', 'css-gen', 'css', 'delphi', 'html4strict', 'java', 'javascript', 'lisp', 'lua', 'nsis', 'objc', 'oobas', 'oracle8', 'pascal', 'perl', 'php-brief', 'php', 'python', 'qbasic', 'smarty', 'sql', 'vb', 'vbnet', 'visualfoxpro', 'xml');
if ($value[0] == '#' and $value[1] == '!') {
list($line, $value) = explode("\n", $value, 2);
}
# get parameters
if ($line) {
$line = substr($line, 2);
$tag = strtok($line, ' ');
$type = strtok(' ');
$extra = strtok('');
if ($tag != 'vim') {
$extra = $type;
$type = $tag;
}
}
$src = rtrim($value);
// XXX
if (!$type) {
$type = 'nosyntax';
}
$uniq = md5($extra . $value);
if ($DBInfo->cache_public_dir) {
$fc = new Cache_text('geshi', array('ext' => 'html', 'dir' => $DBInfo->cache_public_dir));
$htmlname = $fc->getKey($uniq, false);
$html = $DBInfo->cache_public_dir . '/' . $htmlname;
} else {
$cache_dir = $DBInfo->upload_dir . "/GeshiProcessor";
$html = $cache_dir . '/' . $uniq . '.html';
}
if (!is_dir(dirname($html))) {
$om = umask(00);
_mkdir_p(dirname($html), 0777);
umask($om);
}
if (file_exists($html) && !$formatter->refresh) {
$out = "";
$fp = fopen($html, "r");
while (!feof($fp)) {
$out .= fread($fp, 1024);
}
return $out;
}
# comment out the following two lines to freely use any syntaxes.
if (!in_array($type, $syntax)) {
return "<pre class='code'>\n{$line}\n" . htmlspecialchars($src) . "\n</pre>\n";
}
$geshi = new GeSHi($src, $type, dirname(__FILE__) . "/../../lib/geshi/geshi");
if ($extra == "number") {
$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
}
if ($extra == "fancy") {
$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);
} else {
$geshi->enable_line_numbers(GESHI_NO_LINE_NUMBERS);
}
$out = '';
$geshi->set_comments_style(1, 'font-style: normal;');
$geshi->set_header_type(GESHI_HEADER_DIV);
#$geshi->set_header_type(GESHI_HEADER_PRE);
#$out = '<style type="text/css"><!--'.$geshi->get_stylesheet().'--></style>';
#$geshi->enable_classes();
$out .= $geshi->parse_code();
$fp = fopen($html, "w");
fwrite($fp, $out);
fclose($fp);
return $out;
}
示例12: do_SWFUpload
function do_SWFUpload($formatter, $options = array())
{
global $DBInfo;
$swfupload_dir = $DBInfo->upload_dir . '/.swfupload';
$mysubdir = '';
if (!is_dir($swfupload_dir)) {
$om = umask(00);
mkdir($swfupload_dir, 0777);
umask($om);
$fp = fopen($swfupload_dir . '/.htaccess', 'w');
if ($fp) {
$htaccess = <<<EOF
Options -Indexes
Order deny,allow
EOF;
fwrite($fp, $htaccess);
fclose($fp);
}
}
// check subdir
if (!empty($DBInfo->swfupload_depth) and $DBInfo->swfupload_depth > 2) {
$depth = $DBInfo->swfupload_depth;
} else {
$depth = 2;
}
$myid = md5($_SERVER['REMOTE_ADDR'] . '.' . 'MONIWIKI');
// FIXME
if (session_id() != '') {
// ip based
if (0 and $_SESSION['_swfupload']) {
// XXX flash bug?
$myid = $_SESSION['_swfupload'];
} else {
if (!empty($options['value']) and ($p = strpos($options['value'], '/')) !== false) {
$tmp = explode('/', $options['value']);
#list($dum,$myid,$dum2)=explode('/',$options['value'],3);
$myid = $tmp[1];
}
}
}
$prefix = substr($myid, 0, $depth);
$mysubdir = $prefix . '/' . $myid . '/';
// debug
//$options['_mysubdir']=$mysubdir;
//$fp=fopen($swfupload_dir.'/swflog.txt','a+');
//foreach ($options as $k=>$v) {
// if (is_string($v))
// fwrite($fp,sprintf("%s=>%s\n",$k,$v));
//}
//foreach ($_SESSION as $k=>$v) {
// if (is_string($v))
// fwrite($fp,sprintf("%s=>%s\n",$k,$v));
//}
//fwrite($fp,"------------------------\n");
//fclose($fp);
// set the personal subdir
if (!empty($options['value']) and preg_match('/^[a-z0-9\\/]+$/i', $options['value'])) {
//if ($mysubdir == $options['value']) // XXX check subdir
// $mysubdir = $options['value'];
list($dum, $myval, $dum2) = explode('/', $options['value'], 3);
// XXX
if (!is_dir($swfupload_dir . '/' . $mysubdir)) {
$om = umask(00);
_mkdir_p($swfupload_dir . '/' . $mysubdir, 0777);
umask($om);
}
}
//move the uploaded file
if (isset($_FILES['Filedata']['tmp_name'])) {
move_uploaded_file($_FILES['Filedata']['tmp_name'], $swfupload_dir . '/' . $mysubdir . $_FILES['Filedata']['name']);
echo "Success";
return;
} else {
if (isset($options['MYFILES']) and is_array($options['MYFILES'])) {
include_once 'plugin/UploadFile.php';
$options['_pds_subdir'] = $mysubdir;
// a temporary pds dir
$options['_pds_remove'] = 1;
// remove all files in pds dir
do_UploadFile($formatter, $options);
} else {
$formatter->send_header("", $options);
$formatter->send_title("", "", $options);
$out = macro_SWFUpload($formatter, '');
print $formatter->get_javascripts();
print $out;
if (!in_array('UploadedFiles', $formatter->actions)) {
$formatter->actions[] = 'UploadedFiles';
}
$formatter->send_footer("", $options);
}
}
}
示例13: macro_Play
//.........这里部分代码省略.........
$playfile = $basename . '.xml';
} else {
$cache_dir = $DBInfo->upload_dir . "/VisualTour";
$cache_url = $DBInfo->upload_url ? $DBInfo->upload_url . '/VisualTour' : $DBInfo->url_prefix . '/' . $cache_dir;
$basename = $cache_dir . '/' . $md5sum;
$urlbase = $cache_url . '/' . $md5sum;
$playfile = $basename . '.xml';
}
$playlist = $urlbase . '.xml';
$list = array();
for ($i = 0; $i < $sz; $i++) {
if (!preg_match("/^((https?|ftp):)?\\/\\//", $url[$i])) {
$url = qualifiedUrl($url);
}
$ext = substr($media[$i], -3, 3);
// XXX
$list[] = '<title>' . $media[$i] . '</title>' . "\n" . '<location>' . $url[$i] . '</location>' . "\n";
}
$tracks = "<track>\n" . implode("</track>\n<track>\n", $list) . "</track>\n";
// UTF-8 FIXME
$xml = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
<title>XSPF Playlist</title>
<info>XSPF Playlist</info>
<trackList>
{$tracks}
</trackList>
</playlist>
XML;
# check cache dir exists or not and make it
if (!is_dir(dirname($playfile))) {
$om = umask(00);
_mkdir_p(dirname($playfile), 0777);
umask($om);
}
if ($formatter->refresh or !file_exists($playfile)) {
$fp = fopen($playfile, "w");
fwrite($fp, $xml);
fclose($fp);
}
$displayheight = $height;
$height += $sz * 40;
// XXX
$addparam = "displayheight: '{$displayheight}'";
$filelist = qualifiedUrl($playlist);
} else {
$filelist = $url[0];
}
$jw_script = <<<EOS
<p id="mediaplayer{$num}"></p>
<script type="text/javascript">
(function() {
var params = {
allowfullscreen: "true"
};
var flashvars = {
width: "{$width}",
height: "{$height}",
// image: "preview.jpg",
{$addparam}
file: "{$filelist}"
};
swfobject.embedSWF("{$_swf_prefix}/mediaplayer.swf","mediaplayer{$num}","{$width}","{$height}","0.0.9",
示例14: macro_VisualTour
function macro_VisualTour($formatter, $value, $options = array())
{
global $DBInfo;
putenv('GDFONTPATH=' . getcwd() . '/data');
$dotcmd = "dot";
#$dotcmd="twopi";
#$dotcmd="neato";
$maptype = 'imap';
$maptype = 'cmap';
if (!$formatter->page->exists()) {
return "";
}
$args = explode(',', $value);
$extra = '';
foreach ($args as $arg) {
$arg = trim($arg);
if (($p = strpos($arg, '=')) === false) {
if ($arg == 'show') {
$extra .= '&t=show';
} else {
if (is_int($arg)) {
$w = $arg;
} else {
if ($DBInfo->hasPage($arg)) {
$pgname = $arg;
}
}
}
} else {
$k = strtok($arg, '=');
$v = strtok('');
if ($k == 'width' or $k == 'w') {
$w = (int) $v;
} else {
if ($k == 'depth' or $k == 'd') {
$d = (int) $v;
} else {
if ($k == 'arena' or $k == 'a') {
$extra .= '&arena=' . $v;
}
}
}
}
}
if (!empty($options['w']) and $options['w'] < 6) {
$w = $options['w'];
} else {
$w = !empty($w) ? $w : 2;
}
if (!empty($options['d']) and $options['d'] < 6) {
$d = $options['d'];
} else {
$d = !empty($d) ? $d : 3;
}
if (!empty($options['f'])) {
$extra .= "&f=" . $options['f'];
}
if (!empty($options['arena'])) {
$extra .= "&arena=" . $options['arena'];
}
if (isset($pgname[0])) {
$urlname = _urlencode($pgname);
} else {
$urlname = $formatter->page->urlname;
$pgname = $formatter->page->name;
}
$dot = $formatter->macro_repl('dot', $pgname, $options);
if (!empty($DBInfo->cache_public_dir)) {
$fc = new Cache_text('visualtour', array('dir' => $DBInfo->cache_public_dir));
$fname = $fc->getKey($dot);
$basename = $DBInfo->cache_public_dir . '/' . $fname;
$dotfile = $basename . '.dot';
$pngfile = $basename . '.png';
$mapfile = $basename . '.map';
$urlbase = $DBInfo->cache_public_url ? $DBInfo->cache_public_url . '/' . $fname : $DBInfo->url_prefix . '/' . $basename;
$png_url = $urlbase . '.png';
$map_url = $urlbase . '.map';
} else {
$md5sum = md5($dot);
$cache_dir = $DBInfo->upload_dir . "/VisualTour";
$cache_url = $DBInfo->upload_url ? $DBInfo->upload_url . '/VisualTour' : $DBInfo->url_prefix . '/' . $cache_dir;
$basename = $cache_dir . '/' . $md5sum;
$pngfile = $basename . '.png';
$mapfile = $basename . '.map';
$dotfile = $basename . '.dot';
$urlbase = $cache_url . '/' . $md5sum;
$png_url = $urlbase . '.png';
$map_url = $urlbase . '.map';
}
if (!is_dir(dirname($pngfile))) {
$om = umask(00);
_mkdir_p(dirname($pngfile), 0777);
umask($om);
}
$err = '';
if ($formatter->refresh or !file_exists($dotfile)) {
$fp = fopen($dotfile, "w");
fwrite($fp, $dot);
fclose($fp);
$cmd = "{$dotcmd} -Tpng {$dotfile} -o {$pngfile}";
//.........这里部分代码省略.........
示例15: processor_vim
function processor_vim($formatter, $value, $options)
{
global $DBInfo;
$vim_default = '-T xterm';
static $jsloaded = 0;
$vartmp_dir =& $DBInfo->vartmp_dir;
$syntax = array("php", "c", "python", "jsp", "sh", "cpp", "java", "ruby", "forth", "fortran", "perl", "haskell", "lisp", "st", "objc", "tcl", "lua", "asm", "masm", "tasm", "make", "mysql", "awk", "docbk", "diff", "html", "tex", "vim", "xml", "dtd", "sql", "conf", "config", "nosyntax", "apache");
#$opts=array("number");
$line = '';
if ($value[0] == '#' and $value[1] == '!') {
list($line, $value) = explode("\n", $value, 2);
}
# get parameters
if ($line) {
$line = substr($line, 2);
$tag = strtok($line, ' ');
$type = strtok(' ');
$extra = strtok('');
if ($tag != 'vim') {
$extra = $type;
$type = $tag;
}
}
$src = $value;
if (!preg_match('/^\\w+$/', $type)) {
$type = 'nosyntax';
}
$option = '';
if ($extra == "number") {
$option = '+"set number" ';
}
if ($DBInfo->vim_options) {
$option .= $DBInfo->vim_options . ' ';
}
$uniq = md5($option . $extra . $type . $src);
if ($DBInfo->cache_public_dir) {
$fc = new Cache_text('vim', array('ext' => 'html', 'dir' => $DBInfo->cache_public_dir));
$htmlname = $fc->getKey($uniq, false);
$html = $DBInfo->cache_public_dir . '/' . $htmlname;
} else {
$cache_dir = $DBInfo->upload_dir . "/VimProcessor";
$html = $cache_dir . '/' . $uniq . '.html';
}
$script = '';
if (!empty($DBInfo->use_numbering) and empty($formatter->no_js)) {
$formatter->register_javascripts('numbering.js');
$script = "<script type=\"text/javascript\">\n/*<![CDATA[*/\naddtogglebutton('PRE-{$uniq}');\n/*]]>*/\n</script>";
}
if (!is_dir(dirname($html))) {
$om = umask(00);
_mkdir_p(dirname($html), 0777);
umask($om);
}
if (file_exists($html) && empty($formatter->refresh) && empty($formatter->preview)) {
$out = "";
$fp = fopen($html, "r");
while (!feof($fp)) {
$out .= fread($fp, 1024);
}
@fclose($fp);
return '<div>' . $out . $script . '</div>';
}
if (!empty($DBInfo->vim_nocheck) and !in_array($type, $syntax)) {
$lines = explode("\n", $line . "\n" . str_replace('<', '<', $src));
if ($lines[sizeof($lines) - 1] == "") {
array_pop($lines);
}
$src = "<span class=\"line\">" . implode("</span>\n<span class=\"line\">", $lines) . "</span>";
return '<div>' . $script . "<pre class='wiki' id='PRE-{$uniq}'>\n{$src}</pre></div>\n";
}
$tohtml = !empty($DBInfo->vim_2html) ? $DBInfo->vim_2html : ($tohtml = '$VIMRUNTIME/syntax/2html.vim');
#$tohtml= realpath($DBInfo->data_dir).'/2html.vim';
if (getenv("OS") == "Windows_NT") {
$vim = "gvim";
# Win32
$fout = tempnam($vartmp_dir, "OUT");
} else {
$tohtml = '\\' . $tohtml;
$vim = "vim";
$fout = "/dev/stdout";
}
$tmpf = tempnam($vartmp_dir, "FOO");
$fp = fopen($tmpf, "w");
fwrite($fp, $src);
fclose($fp);
$cmd = "{$vim} {$vim_default} -e -s {$tmpf} " . ' +"syntax on " +"set syntax=' . $type . '" ' . $option . ' +"so ' . $tohtml . '" +"wq! ' . $fout . '" +qall';
$log = '';
$out = '';
if (getenv("OS") == "Windows_NT") {
system($cmd);
$out = join(file($fout), "");
unlink($fout);
} else {
$formatter->errlog();
$fp = popen($cmd . $formatter->LOG, "r");
if (is_resource($fp)) {
while ($s = fgets($fp, 1024)) {
$out .= $s;
}
pclose($fp);
//.........这里部分代码省略.........