Example #1
0
 /**
  * Gets the url for a square thumbnail.
  *
  * You have to set the `side` option.
  * Optionally, you can set `force` option.
  * @param string $path Path to the image file
  * @param array $options Array of HTML attributes
  * @return string
  */
 public function squareUrl($path, array $options = [])
 {
     if (!empty($options['side'])) {
         $size['side'] = $options['side'];
     }
     if (!empty($options['force'])) {
         $size['force'] = true;
     }
     if (!empty($size)) {
         $path = Router::url(['_name' => 'square', encodePath($path), '?' => $size], true);
     }
     return $path;
 }
Example #2
0
function search($server, $path)
{
    $id = $server . $path;
    $app = Slim\Slim::getInstance();
    $app->contentType('application/json');
    $root_dir = getOption('root') . "/" . $id;
    $extensions = getOption('extensions');
    echo "{\n  \"server\": \"{$server}\",\n";
    echo "  \"path\": \"" . encodePath($path) . "\"";
    exec("ls -1 " . escapeshellarg($root_dir), $output);
    echo ",\n  \"content\": [";
    $is_first = true;
    foreach ($output as &$file) {
        $path_parts = pathinfo($file);
        if (isset($path_parts['extension'])) {
            $extension = $path_parts['extension'];
        }
        if (!startsWith($file, '.') && is_dir("{$root_dir}/{$file}")) {
            if ($is_first) {
                $is_first = false;
            } else {
                echo ",";
            }
            echo "\n    { \"folder\": " . json_encode($file) . ", \"link\": \"" . encodePath("{$id}/{$file}") . "\" }";
        } else {
            if (is_file("{$root_dir}/{$file}") && in_array($extension, $extensions)) {
                if ($is_first) {
                    $is_first = false;
                } else {
                    echo ",";
                }
                echo "\n    { \"file\": " . json_encode($file) . ", \"link\": \"" . encodePath("{$id}/{$file}") . "\", \"type\": \"" . $extension . "\" }";
            }
        }
    }
    echo "\n  ],";
    echo "\n  \"search\": false";
    echo "\n}\n";
    $response = $app->response();
    $response["Cache-Control"] = "max-age=600";
}
Example #3
0
    <td  align=center>修改时间</td>
</tr>
<?php 
while ($tmp_Str = $DIRObject->read()) {
    if ($tmp_Str != "." && $tmp_Str != "..") {
        $numb++;
        print "<tr>";
        if (is_dir($DIRObject->path . $tmp_Str)) {
            print "<td>";
            print "<a href='?dir=" . $_DIR_PATH . $tmp_Str . "&index=1'>";
            //有些服务器编码后路径不对
            print $tmp_Str;
            print "</a>";
            print " </td>";
            print "<td>";
            print "<a href='?dir=" . encodePath($_DIR_PATH . $tmp_Str) . "&index=1'>";
            print "[<font color=red>目录</font>] ";
            print "</a>";
            print " </td>";
            print "<td align=center>";
            print strftime("%Y年%m月%d日 %H:%M:%S", filemtime($_DIR_PATH . $tmp_Str));
            print " </td>";
        } else {
            if (strstr($tmp_Str, ".php") || strstr($tmp_Str, ".asp")) {
                //不显示 .php .asp的文件
                continue;
            }
            print "<td>";
            print "<a target=_blank href='" . $_DIR_PATH . $tmp_Str . "'>";
            //有些服务器编码后路径不对
            print $tmp_Str;