1 rizwank 1.1 <?php
2 require "./inc/head.php";
3 ?>
4 <?php
5 if ( $_POST ) {
6 require "./inc/upload_class.php";
7 require "./inc/Zip.php";
8 $perms = substr(sprintf('%o', fileperms('./albums/')), -4);
9 if ($perms != '0777')
10 @chmod(('albums/'), 0777) or die("<h2>Error</h2><p>SSPAdmin does not have the proper permissions to write to the albums folder. SSPAdmin tried do set the permissions for you, but was rejected. Please chmod this folder to 777");
11 $clean_name = $_POST['aName'];
12 $the_id = str_replace(" ", "-", $clean_name);
13 $max_size = 1024*100; // the max. size for uploading
14
15 $my_upload = new file_upload;
16 $my_upload->upload_dir = realpath('./albums/') . '/'; // "files" is the folder for the uploaded files (you have to create this folder)
17 $my_upload->extensions = array(".zip"); // specify the allowed extensions here
18 $my_upload->max_length_filename = 100; // change this value to fit your field length in your database (standard 100)
19
20 $my_upload->the_temp_file = $_FILES['upload']['tmp_name'];
21 $my_upload->the_file = $the_id.'.zip';
22 rizwank 1.1 $my_upload->http_error = $_FILES['upload']['error'];
23 $my_upload->replace = (isset($_POST['replace'])) ? $_POST['replace'] : "n"; // because only a checked checkboxes is true
24 $my_upload->do_filename_check = (isset($_POST['check'])) ? $_POST['check'] : "n"; // use this boolean to check for a valid filename
25 if ($my_upload->upload()) {
26 if (!@mkdir('./albums/'.$the_id, 0777))
27 {
28 unlink(realpath('./albums/'.$the_id.'.zip'));
29 $m = 2;
30 } else {
31 $my_zip = new Archive_Zip(realpath('./albums/'.$the_id.'.zip'));
32 $my_zip->extract(Array('add_path'=>realpath('./albums/'.$the_id.'/')));
33 unlink(realpath('./albums/'.$the_id.'.zip'));
34 header("Location: add-album-exe.php?aDir=$the_id&aName=$clean_name");
35 }
36 } else {
37 $m = true;
38 }
39 }
40 ?>
41 <?php include "./inc/doctype.php"; ?>
42 <head>
43 rizwank 1.1 <?php include "./inc/charset.php"; ?>
44 <title>SSP Admin :: Add an Album</title>
45 <?php include "./inc/head_elem.php"; ?>
46 </head>
47
48 <body>
49 <div id="container">
50
51 <?php include "./inc/h1.php"; ?>
52
53
54
55 <?php
56 if ( $m == 1) {
57 ?>
58
59 <h2>Error</h2>
60 <p>There was an error uploading your files. Please check the documentation or the SSPAdmin forums.</p>
61
62 <?php } else if ($m == 2) { ?>
63 <h2>Error</h2><p>There is already an album folder with the name <strong><?php echo $the_id; ?></strong>. Please <a href="add-album.php">go back</a> and select another name.</p>
64 rizwank 1.1 <?php } ?>
65 </div>
66
67
68 </body>
69 </html>
|