Пример #1
0
function fm_extractzip($file, $dest = FALSE, $overwrite = FALSE)
{
    if (!$GLOBALS['ext_pclzip']) {
        return false;
    }
    $archive = new PclZip(fm_mklocal($file));
    if (is_dir('cache/up/extracted/')) {
        fm_clearcache('up/extracted/');
    }
    @mkdir('cache/up/extracted/');
    $res = $archive->extract(PCLZIP_OPT_PATH, 'cache/up/extracted/');
    if ($res == 0) {
        return FALSE;
    }
    $res = fm_upload('extracted/', $dest, $overwrite);
    fm_clearcache('up/extracted/');
    return $res;
}
Пример #2
0
function fm_clearcache($source = '')
{
    //global $ftp,$ftp_prepath,$fmurl,$preurl;
    $source = cleanPath($source);
    if (startsWith($source, '../')) {
        return FALSE;
    }
    if (is_dir('cache/' . $source)) {
        if ($source && substr($source, -1) != '/') {
            $source .= '/';
        }
        $dh = @opendir('cache/' . $source);
        if ($dh) {
            while (false !== ($file = @readdir($dh))) {
                if ($file == '.' || $file == '..') {
                    continue;
                }
                fm_clearcache($source . $file);
                if (is_dir('cache/' . $source . $file)) {
                    // directory?
                    @rmdir('cache/' . $source . $file);
                }
            }
        }
        @closedir($dh);
    } else {
        @unlink('cache/' . $source);
    }
    if ($source == '' && !is_dir('cache/up/')) {
        @mkdir('cache/up/');
        @chmod('cache/up/', 0777);
    }
    if ($source == '' && !is_dir('cache/down/')) {
        @mkdir('cache/down/');
        @chmod('cache/down/', 0777);
    }
    if (!is_file('cache/data-backup.inc.php')) {
        @copy('persist.inc.php', 'cache/data-backup.inc.php');
        @chmod('cache/data-backup.inc.php', 0777);
    }
    if (!is_file('cache/config-backup.inc.php')) {
        @copy('config.inc.php', 'cache/config-backup.inc.php');
        @chmod('cache/config-backup.inc.php', 0777);
    }
    return TRUE;
}