function f_img_resize($path, $w, $h, $watermark = null)
{
    if (!$path) {
        return;
    }
    //Image::configure(array('driver' => 'gd'));
    $path_0 = $path;
    if (!file_exists(WEB . $path_0)) {
        return;
    }
    $path = str_replace('/upload/', '/upload/thum/', $path);
    $new = file_dir($path);
    $ext = file_ext($path);
    $new = $new . '/' . file_name($path) . "_{$w_}{$h}" . '.' . $ext;
    if (file_exists(WEB . $new)) {
        return $new;
    }
    echo WEB . $path_0;
    $img = Image::make(WEB . $path_0);
    $img->resize($w, $h);
    if (!is_dir(WEB . file_dir($new))) {
        mkdir(WEB . $new, 0777, true);
    }
    if ($watermark) {
        $img->insert(WEB . $watermark);
    }
    $img->save(WEB . $new);
    return $new;
}
 function file_dir_delete_recursive($path)
 {
     $result = FALSE;
     if ($path) {
         $file_prefix = '';
         if (substr($path, -1) == '*') {
             $file_prefix = basename($path, '*');
             $path = file_dir($path);
         }
         if (file_exists($path) && is_dir($path)) {
             $path = path_add_slash_end($path);
             if ($handle = opendir($path)) {
                 $result = TRUE;
                 while ($result && FALSE !== ($file = readdir($handle))) {
                     if ($file != "." && $file != "..") {
                         if ($file_prefix && substr($file, 0, strlen($file_prefix)) != $file_prefix) {
                             continue;
                         }
                         if (is_dir($path . $file)) {
                             $result = file_dir_delete_recursive($path . $file);
                         } else {
                             $result = @unlink($path . $file);
                         }
                     }
                 }
                 closedir($handle);
                 if (!$file_prefix && $result) {
                     $result = @rmdir($path);
                 }
             }
         }
     }
     return $result;
 }
Exemple #3
0
/**
 * 上传目录列表
 * @param string $path 目录名
 * @param string $exts 获取后缀名
 * @return array
 */
function file_list_upload($path, $exts = '', &$res = array())
{
    $list = file_dir($path);
    foreach ($list as $info) {
        if ($info['type'] == 'dir') {
            continue;
        }
        if ($exts && !preg_match("/({$exts})\$/i", $info['ext'])) {
            continue;
        }
        $info['url'] = str_replace(UPLOAD_PATH, '', $path) . $info['path'];
        array_push($res, $info);
    }
    return $res;
}
Exemple #4
0
    setcookie($CONFIG['cookie_name'] . '_filemove', base64_encode(serialize($filename)), 0, $CONFIG['cookie_path']);
    foreach ($filename as $n => $name) {
        echo $name . "  ";
    }
    echo "</td></tr>";
    echo "<tr><td class='tableh1' align='center'><b>{$lang_plugin_FileMove['folder_ar']}</b></td></tr>";
    //choix du répertoire d'arrivée
    echo "<tr><td>";
    list_dir($directory, 1, $dfolder, $selection, $selection1, $Drep);
    echo "</td></tr>";
    endtable();
} else {
    starttable('100%', $lang_plugin_FileMove['display_name'] . ' - ' . $lang_plugin_FileMove['version'] . '    ' . '<a href="pluginmgr.php" class="admin_menu">Plugin Manager</a>', 2);
    //affichage du contenu du répertoire
    echo "<tr><td>";
    $nb = 2;
    //Change this value according the column number you will display
    starttable('100%', $lang_plugin_FileMove['DFolder'] . $Drep, $nb);
    echo "<form name='file' action='' method='post'>";
    echo "<tr>";
    file_dir($dfolder, $nb);
    echo "<input type='hidden' name='dfolder' value='{$dfolder}'";
    echo "<tr><td align='center' colspan='{$nb}'><input type='Submit' value='{$lang_plugin_FileMove['valid']}'></td></tr>";
    echo "</tr></form>";
    endtable();
    echo "</td></tr>";
}
//Fin de tableau
endtable();
pagefooter();
ob_end_flush();