(file) Return to add-album-up-single.php CVS log (file) (dir) Up to [RizwankCVS] / geekymedia_web / photo / sspadmin

  1 rizwank 1.1 <?php
  2             require "./inc/head.php";
  3             ?>
  4             <?php include "./inc/doctype.php"; ?>
  5             <head>
  6             <?php include "./inc/charset.php"; ?>
  7             <title>SSP Admin :: Add an Album</title>
  8             <?php include "./inc/head_elem.php"; ?>
  9             <?php 
 10             	$chk = strpos($_SERVER['HTTP_USER_AGENT'], 'Safari');
 11             ?>
 12             <script type="text/javascript">
 13             
 14             	var selbox = 0;
 15             	var isSafari = <?php ($chk === false) ? $r = 'false' : $r= 'true'; echo $r; ?>;
 16             	
 17             	function checkForm(theForm)
 18             	{
 19             	
 20             		if (theForm.upload.value == '')
 21             		{
 22 rizwank 1.1 			alert("Please Select a File to Upload");
 23             			return false;
 24             		}
 25             		else
 26             		{
 27             			if (isSafari)
 28             			{
 29             				theForm.btn.disabled = true;
 30             				theForm.btn.value = 'Uploading...Please Wait';
 31             			} else {
 32             				document.getElementById('before').style.display = 'none';
 33             				document.getElementById('after').style.display = 'block';
 34             				progress();
 35             			}
 36             			return true;
 37             		}
 38             	}
 39             	
 40             	function progress()
 41             	{
 42             		var elem = document.getElementById('boxes-up');
 43 rizwank 1.1 		var a = elem.getElementsByTagName('DIV');
 44             		if (selbox == 3)
 45             			selbox = 0;
 46             		if (selbox == 0)
 47             			a[2].className = 'pbox';
 48             		else
 49             			a[selbox-1].className = 'pbox';
 50             		a[selbox].className = 'pbox-sel';
 51             		selbox += 1;
 52             		setTimeout(progress, 500);
 53             	}
 54             </script>
 55             <style type="text/css">
 56             div#after { display:none; }
 57             div#boxes-up { width:230px; margin:0 auto; }
 58             div.pbox { width:50px; height:50px; float:left; margin:10px; background:#c7c7c7; border:1px solid #555555;}
 59             div.pbox-sel { width:50px; height:50px; float:left; margin:10px; background:#ffffff; border:1px solid #cc0000;}
 60             </style>
 61             </head>
 62             
 63             <body>
 64 rizwank 1.1 	<div id="container">
 65             		
 66             		<?php include "./inc/h1.php"; ?>
 67             <?php
 68             	if ( $_POST ) {
 69             		require "./inc/upload_class.php";
 70             		
 71             		if ($_POST['aName'])
 72             		{
 73             		$clean_name = $_POST['aName'];
 74             		$the_id = str_replace(" ", "-", $clean_name);
 75             		$perms = substr(sprintf('%o', fileperms(realpath('./albums/'))), -4);
 76             		if ($perms != '0777')
 77             			@chmod(('albums/'), 0777) or die("<h2>Error</h2><p>SSPAdmin does not have the proper permissions to write to the albums folder. SSPAdmin tried to set the permissions for you, but was rejected. Please chmod this folder to 777");
 78             		@mkdir('./albums/'.$the_id, 0777) or die("<h2>Error</h2><p>There is already an album folder with the name <strong>$the_id</strong>. Please <a href=\"add-album.php\">go back</a> and select another name.");
 79             		$max_size = 1024*100; // the max. size for uploading
 80             		mkdir('./albums/'.$the_id.'/lg/', 0777);
 81             		$my_upload = new file_upload;
 82             		$my_upload->upload_dir = realpath('./albums/'.$the_id.'/lg/') . '/'; // "files" is the folder for the uploaded files (you have to create this folder)
 83             		$my_upload->extensions = array(".jpeg", ".jpg", ".JPEG", ".JPG", ".swf", ".SWF", ".FLV", ".flv"); // specify the allowed extensions here
 84             		$my_upload->max_length_filename = 100; // change this value to fit your field length in your database (standard 100)
 85 rizwank 1.1 		$my_upload->the_temp_file = $_FILES['upload']['tmp_name'];
 86             		$my_upload->the_file = $_FILES['upload']['name'];
 87             		$my_upload->http_error = $_FILES['upload']['error'];
 88             		if (!$my_upload->upload()) { 
 89             			$m = true;
 90             			echo($my_upload->http_error);
 91             		} else {
 92             			$aName = $_POST['aName'];
 93             			mysql_query("INSERT INTO $atbl (id, name, path) VALUES (NULL, '$aName', '$clean_name')") or die("Error".mysql_error());
 94             			$aid = mysql_insert_id();
 95             			mysql_query("INSERT INTO $itbl (id, aid, src) VALUES (NULL, $aid, '$my_upload->the_file')") or die("Error".mysql_error());
 96             		}
 97             ?>
 98             <?php
 99             			if ( $m ) {
100             		?>
101             		
102             		<h2>Error</h2>
103             		<p>There was an error uploading your files. Please check the documentation or the SSPAdmin forums.</p>
104             		
105             		<?php } else { ?>
106 rizwank 1.1 		<h2>Success!</h2>
107             		<p>Your image (<strong><?php echo $my_upload->the_file; ?></strong>) was uploaded and a new album (named <strong><?php echo $aName ?></strong>) was created. <a href="edit-album.php?aid=<?php echo $aid ?>">Click here to edit it</a>. You can also use the form below to add another image to this album.</p>
108             		
109             		<div class="album-wrap">
110             		<h2>Add Another File</h2>
111             		<form action="add-album-up-single.php" method="post" enctype="multipart/form-data">
112             		
113             		<fieldset class="center"><label>File to Upload: </label><input type="file" name="upload"></fieldset><fieldset class="center"><input name="btn" type="submit" value="Upload this Picture" /></fieldset><input type="hidden" name="aid" value="<?php echo $aid; ?>"</form></div>
114             		<?php } ?>
115             
116             	</div>
117             <?php
118             }
119             		else
120             		{
121             			$aid = $_POST['aid'];
122             			$q = "SELECT path, name FROM $atbl WHERE id = $aid";
123             			$r = mysql_query($q);
124             			$rw = mysql_fetch_row($r);
125             			$path = $rw[0];
126             			$name = $rw[1];
127 rizwank 1.1 			$max_size = 1024*100; // the max. size for uploading
128             			$my_upload = new file_upload;
129             			$my_upload->upload_dir = realpath('./albums/'.$path.'/lg/') . '/'; // "files" is the folder for the uploaded files (you have to create this folder)
130             			
131             			$perms = substr(sprintf('%o', fileperms(realpath('./albums/'))), -4);
132             			if ($perms != '0777')
133             				@chmod(('albums/'), 0777) or die("<h2>Error</h2><p>SSPAdmin does not have the proper permissions to write to the albums folder. SSPAdmin tried to set the permissions for you, but was rejected. Please chmod this folder to 777");
134             				
135             			$perms = substr(sprintf('%o', fileperms(realpath('./albums/'.$path.'/lg/'))), -4);
136             			if ($perms != '0777')
137             				@chmod(('albums/'.$path.'/lg/'), 0777) or die("<h2>Error</h2><p>SSPAdmin does not have the proper permissions to write to the folder: albums/$path/lg/ SSPAdmin tried to set the permissions for you, but was rejected. Please chmod this folder to 777");
138             				
139             			$my_upload->extensions = array(".jpeg", ".jpg", ".JPEG", ".JPG", ".swf", ".SWF", ".FLV", ".flv"); // specify the allowed extensions here
140             			$my_upload->max_length_filename = 100; // change this value to fit your field length in your database (standard 100)
141             			$my_upload->the_temp_file = $_FILES['upload']['tmp_name'];
142             			$my_upload->the_file = $_FILES['upload']['name'];
143             			$my_upload->http_error = $_FILES['upload']['error'];
144             			if (!$my_upload->upload()) { 
145             				$m = true;
146             			} else {
147             				mysql_query("INSERT INTO $itbl (id, aid, src) VALUES (NULL, $aid, '$my_upload->the_file')") or die("Error".mysql_error());
148 rizwank 1.1 			}
149             			
150             			?>
151             			<h2>Success!</h2>
152             		<p>Your image (<strong><?php echo $my_upload->the_file; ?></strong>) was uploaded and added to the following album: <strong><?php echo $name; ?></strong></p>
153             		
154             		<div id="before">
155             		<div class="album-wrap">
156             		<h2>Add Another File</h2>
157             		<form action="add-album-up-single.php" method="post" enctype="multipart/form-data" onSubmit="return checkForm(this)">
158             		
159             		<fieldset class="center"><label>File to Upload: </label><input type="file" name="upload"></fieldset><fieldset class="center"><input name="btn" type="submit" value="Upload this Picture" /></fieldset><input type="hidden" name="aid" value="<?php echo $aid; ?>"</form></div></div>
160             		<?php
161             		}
162             	} else {
163             		$aid = $_GET['aid'];
164             		$q = "SELECT name FROM $atbl WHERE id = $aid";
165             		$r = mysql_query($q);
166             		$rw = mysql_fetch_row($r);
167             		$name = $rw[0];
168             ?> 	
169 rizwank 1.1 	<h2>Add an Image to an Existing Gallery</h2>
170             	<p>Use the form below to upload a file to the following album: <strong><?php echo $name; ?></strong></p>
171             	<div id="before">
172             	<div class="album-wrap">
173             	<form action="add-album-up-single.php" method="post" enctype="multipart/form-data" onSubmit="return checkForm(this)">
174             		
175             		<fieldset class="center"><label>File to Upload: </label><input type="file" name="upload"></fieldset><fieldset class="center"><input name="btn" type="submit" value="Upload this Picture" /></fieldset><input type="hidden" name="aid" value="<?php echo $aid; ?>"</form>
176             	</div></div>
177             <?php } ?>
178             <div id="after" class="album-wrap center"><p><strong>Uploading...Please Wait</strong></p><div id="boxes-up"><div class="pbox">&nbsp;</div><div class="pbox">&nbsp;</div><div class="pbox">&nbsp;</div></div><div style="clear:both">&nbsp;</div></div>
179             </div>
180             </body>
181             </html>

Rizwan Kassim
Powered by
ViewCVS 0.9.2