function mailto($address, $alternative = '(e-mail address hidden)') { if (empty($address)) { return ' '; } else { $prog = urlenc("var a='" . urlenc(str_replace('@', '@', $address)) . "';document.write('<a href=\"mailto:'+unescape(a)+'\">'+unescape(a)+'</a>');"); return "<script type='text/javascript'>eval(unescape('" . q($prog) . "'));</script><noscript>" . q($alternative) . "</noscript>"; } }
function renderdir($rootdir, $dir) { global $ignore; $ret = ''; $r = $fnlist = $dirlist = array(); $r['index'] = null; if (($dir = safepath($rootdir, $dir)) === false) { redirect('index.php'); } $r['dir'] = $dir; $list = (array) uscandir(pathjoin($rootdir, $dir)); if ($list === false) { redirect('index.php?base=' . $_GET['base']); } foreach ($list as $e) { if ($e == '.' || $e == '..' || in_array(strtolower($e), $ignore)) { continue; } if (uis_dir(pathjoin($rootdir, $dir, $e))) { $dirlist[] = $e; } else { $fnlist[] = $e; } } $index_file = tryindex($fnlist, $dir); if (!empty($index_file)) { $r['index'] = pathjoin($rootdir, $dir, $index_file); } natsort($dirlist); natsort($fnlist); foreach ($dirlist as $e) { $cfg = loadcfg(pathjoin($rootdir, $dir, $e)); if (isset($cfg['index'])) { $idx = pathjoin($dir, $e, upath($cfg['index'])); $ahref = urlenc(pathjoin($rootdir, $idx)); $img = 'thumb.php?base=' . $_GET['base'] . '&file=' . urlencode($idx); } else { $ahref = 'index.php?base=' . $_GET['base'] . '&dir=' . urlencode(pathjoin($dir, $e)); $img = 'images/dir.gif'; } if (isset($cfg['icon'])) { $img = 'thumb.php?base=' . $_GET['base'] . '&file=' . urlencode(pathjoin($dir, $e, upath($cfg['icon']))); } $ret .= mkitem($e, $e, $e, '<a href="' . $ahref . '"' . ($cfg['target'] == '_blank' ? ' target="_blank"' : '') . '>', $img, istoday(pathjoin($rootdir, $dir, $e)), ($dz = udirsize(pathjoin($rootdir, $dir, $e))) > 0 ? '<br /><a name="pack" style="visibility: hidden; float:right;" href="pack.php?base=' . $_GET['base'] . '&dir=' . urlencode(pathjoin($dir, $e)) . '"><img alt="Download" title="Download - ' . fsize($dz) . '" src="images/pack.gif" /></a>' : ''); } foreach ($fnlist as $e) { if (isvideo($e) || isaudio($e)) { $ahref = '<a href="flowplayer.php?base=' . $_GET['base'] . '&file=' . urlencode(pathjoin($dir, $e)) . '">'; } elseif (isimage($e)) { $ahref = '<a href="image.php?base=' . $_GET['base'] . '&file=' . urlencode(pathjoin($dir, $e)) . '">'; } elseif (isweb($e)) { $ahref = '<a href="' . urlenc(pathjoin($rootdir, $dir, $e)) . '">'; } elseif (isdocument($e)) { $ahref = '<a href="document.php?base=' . $_GET['base'] . '&file=' . urlencode(pathjoin($dir, $e)) . '">'; } elseif (iscode($e)) { $ahref = '<a href="code.php?base=' . $_GET['base'] . '&file=' . urlencode(pathjoin($dir, $e)) . '">'; } else { $ahref = '<a href="' . urlenc(pathjoin($rootdir, $dir, $e)) . '">'; } # echo $dir.$e."\t".urlencode($dir.$e)."\n"; $ret .= mkitem($e, $e, $e . ' - (' . fsize(ufilesize(pathjoin($rootdir, $dir, $e))) . ')', $ahref, 'thumb.php?base=' . $_GET['base'] . '&file=' . urlencode(pathjoin($dir, $e)), istoday(pathjoin($rootdir, $dir, $e)), null); } $r['html'] = $ret; return $r; }
} ?> }, plugins: { streaming: { url: 'flowplayer/flowplayer.pseudostreaming-3.2.7.swf' }, audio: { url: 'flowplayer/flowplayer.audio-3.2.2.swf' } } }); </script> <br /><br /> <a href="<?php echo urlenc($rootdir . $file); ?> " style="color:#555;">原始檔案下載(<?php echo fsize(ufilesize($rootdir . $_GET['file'])); ?> )</a> </center> </body> </html> <?php } else { $job = array('base' => $_GET['base'], 'file' => $file); $gmc = new Gearmanclient(); $gmc->addServer(); $gmc->doBackground("webnautilus", serialize($job)); ?>
/** A caching arguments generator * It takes the current arguments array, and applies the action: * @param int $do = 0 : Kill mode: kill arguments, others are saved * = 1 : Save mode: save arguments, others are deleted * @param string $args.. List of $_GET varnames to apply the $do to * @return string The generated arguments list, startting from '?' and with trailing '&' * The results are cached on 1st invoke: it's CPU-safe to reinvoke. * @example GET: "a=1&b=2&c=3&d=4" * mkuri(0,'a','b'); // "c=3&d=4&" // kill a,b * mkuri(1,'a','b'); // "a=1&b=2&" // save a,b * mkuri(0) = "kill nothing" // "a=1&b=2&c=3&d=4&" */ function mkuri($do = 0) { static $getk = null; static $kcache = array(); // Reset the cache? if (is_null($do)) { $getk = null; $kcache = array(); } /* func args */ $A = func_get_args(); unset($A[0]); /* GET keys */ if (is_null($getk)) { $getk = array_keys($_GET); } /* Apply filter */ $keys = $do == 1 ? array_intersect($A, $getk) : array_diff($getk, $A); /* Finish */ $ret = ''; foreach ($keys as $k) { if (!isset($kcache[$k])) { $kcache[$k] = urlenc(array($k => $_GET[$k])); } #urlencode($k).'='.urlencode($_GET[$k]).'&'; $ret .= $kcache[$k]; } return $ret; }
<body><!-- <?php echo $hash; ?> --> <div style="font-size:10pt;"><?php echo mklink(getbasename($_GET['base']), $file); ?> </div> <?php if (isspecimage($file)) { ?> 抱歉,您的瀏覽器無法直接開啟這種格式的圖檔,麻煩<a href="<?php echo urlenc($rootdir . $file); ?> ">直接下載</a>。 <?php } else { ?> <img onload="autozoom(this);" onclick="freezoom(this);" style="display:block; margin:auto; cursor:pointer;" src="<?php echo urlenc(r($rootdir . $file)); ?> " style="margin:auto;" title="<?php echo basename($_GET['file']); ?> " /> <?php } ?> </body> </html>