Exemple #1
0
    }
    fclose($sfp);
    fclose($afp);
}
$options = getopt('d:o:e:');
if (!$options || !isset($options['o'])) {
    echo "Usage: php php-sfx.php [options]\n\n";
    echo "Options:\n";
    echo "    -d  the source directory (default: '.')\n";
    echo "    -o  the output file\n";
    echo "    -e  the extraction directory (default: '.')\n";
    exit;
}
$dir = realpath(isset($options['d']) ? $options['d'] : '.');
$sfxFile = $options['o'];
$archiveFile = $sfxFile . '.tmp';
$extractDir = isset($options['e']) ? $options['e'] : '.';
if ($dir === FALSE) {
    echo "The source directory does not exist.";
    exit(1);
}
@mkdir(dirname($sfxFile), 0777, TRUE);
@unlink($sfxFile);
// @ - file may not exist
@unlink($archiveFile);
// @ - file may not exist
$count = create_archive($dir, $archiveFile);
create_sfx($sfxFile, $archiveFile, $extractDir);
echo "{$count} items packed successfully.";
@unlink($archiveFile);
// @ - file may not exist
Exemple #2
0
 function show_archive()
 {
     global $db;
     $query = $db->query("SELECT Time FROM page");
     $query = $query->fetchAll();
     $tmp_arr = array();
     foreach ($query as $time) {
         $tmp = explode('-', $time['Time']);
         $year = $tmp[0];
         $month = $tmp[1];
         if (!isset($tmp_arr[$year])) {
             $tmp_arr[$year] = array();
         }
         array_push($tmp_arr[$year], $month);
         // $tmp_arr[$year] = array_unique($tmp_arr[$year]);
         // print_r($tmp_arr);
     }
     create_archive($tmp_arr);
 }
        break;
    case 'create_folder':
        create_folder($_POST["name"], rtrim($_POST["to"], '/') . '/');
        break;
    case 'copy':
        copy_file($_POST["file_name"], rtrim($_POST["from"], "/") . "/", rtrim($_POST['to'], "/") . "/");
        break;
    case 'multiple_copy':
        copy_multiple_file($_POST["file"], $_POST["folder"], $_POST["folder_name"], rtrim($_POST["from"], "/") . "/", rtrim($_POST['to'], "/") . "/");
        break;
    case 'rename':
        rename_file($_POST["old_name"], $_POST["new_name"], rtrim($_POST["to"], "/") . '/');
        break;
    case 'remove':
        delete_file($_POST["name"], rtrim($_POST["from"], "/") . "/");
        break;
    case 'multiple_remove':
        delete_multiple_file($_POST["file"], $_POST["folder"], rtrim($_POST["from"], "/") . "/");
        break;
    case 'create_archive':
        create_archive($_POST["archive_name"], rtrim($_POST["to"], '/') . '/', $_POST["extension"], $_POST["files"], $_POST["multiple"]);
        break;
    case 'extract_archive':
        extract_archive($_POST["archive_name"], rtrim($_POST["to"], '/') . '/', $_POST["archive_password"]);
        break;
    case 'properties':
        get_stat($_POST["name"], rtrim($_POST["to"], '/') . '/');
        break;
    default:
        break;
}