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 :: Edit Album</title>
8 <?php include "./inc/head_elem.php"; ?>
9
10 </head>
11
12 <body>
13 <div id="container">
14
15 <?php include "./inc/h1.php"; ?>
16
17 <div id="sub-nav"><strong>Edit Album Sub-Nav »</strong> <a href="edit-album-images.php?aid=<?php echo $aid?>">Edit Album Metadata</a> | <a href="edit-album-images.php?aid=<?php echo $aid?>">Edit Album Images</a> | <a href="edit-album-order.php?aid=<?php echo $aid; ?>">Edit Album Order</a></div>
18 <?php if ($m==2)
19 echo '<p class="update-msg"><small>Album Added. Edit Metadata Below, or <a href="edit-album.php?aid='.$aid.'">Edit the Album\'s Images</a></small></p>';
20 ?>
21 <h2>Generate Thumbnails</h2>
22 rizwank 1.1
23 <?php
24 if (isset($_GET['dim']))
25 {
26 flush();
27 $dim = $_GET['dim'];
28 $gd2=checkgd();
29
30 // Perms check on the albums directory
31 $perms = substr(sprintf('%o', fileperms("./albums/")), -4);
32 if ($perms != '0777')
33 {
34 @chmod(('albums/'), 0777) or die("<h2>Error</h2><p>SSPAdmin does not have the proper permissions to read from the albums directory. SSPAdmin tried to set the permissions for you, but was rejected. Please chmod this folder to 777. Your current permissions on this directory are $perms");
35 }
36
37 // Perms check on the specific album directory
38 $perms = substr(sprintf('%o', fileperms("./albums/$p/")), -4);
39 if ($perms != '0777')
40 {
41 @chmod(('albums/'.$p.'/'), 0777) or die("<h2>Error</h2><p>SSPAdmin does not have the proper permissions to read from the folder: albums/$p SSPAdmin tried to set the permissions for you, but was rejected. Please chmod this folder to 777. Your current permissions on this directory are $perms");
42 }
43 rizwank 1.1
44 // Perms Check on the lg Folder
45 $perms = substr(sprintf('%o', fileperms("./albums/$p/lg/")), -4);
46 if ($perms != '0777')
47 {
48 @chmod(('albums/'.$p.'/lg/'), 0777) or die("<h2>Error</h2><p>SSPAdmin does not have the proper permissions to read from the folder: albums/$p/lg SSPAdmin tried to set the permissions for you, but was rejected. Please chmod this folder to 777. Your current permissions on this directory are $perms");
49 }
50
51 $pics=directory('albums/'.$p.'/lg/',"jpg,JPG,JPEG,jpeg");
52
53 if ( !@is_dir ('albums/'.$p.'/tn/') )
54 {
55 if ( !@mkdir ('albums/'.$p.'/tn/', 0777))
56 {
57 die("No <b>tn</b> folder found in this album's directory. SSPAdmin tried to make one, but did not have the necessary priveleges. Make sure this album's directory is CHMODed to 777.");
58 }
59 } else
60 {
61 $perms = substr(sprintf('%o', fileperms("./albums/$p/tn/")), -4);
62 if ($perms != '0777')
63 {
64 rizwank 1.1 @chmod(('albums/'.$p.'/tn/'), 0777) or die("<h2>Error</h2><p>SSPAdmin does not have the proper permissions to write to the folder: albums/$p/tn/ SSPAdmin tried do set the permissions for you, but was rejected. Please chmod this folder to 777. Your current permissions on this directory are $perms");
65 }
66 }
67
68 if ($pics[0]!=""){
69 foreach ($pics as $pi){
70 createthumb('albums/'.$p.'/lg/'.$pi,'albums/'.$p.'/tn/'.$pi,$dim,$dim);
71 flush();
72 }
73 flush();
74 mysql_query("UPDATE $atbl SET tn=1 WHERE id = $aid") or die(mysql_error());
75 echo '<p>Thumbnails Created Successfully! Your album is now set to display thumbnails.</p>';
76 } else {
77 echo '<p>No Images Found...</p>';
78 }
79 } else
80 {
81 function gdVersion($user_ver = 0)
82 {
83 if (! extension_loaded('gd')) { return; }
84 static $gd_ver = 0;
85 rizwank 1.1 // Just accept the specified setting if it's 1.
86 if ($user_ver == 1) { $gd_ver = 1; return 1; }
87 // Use the static variable if function was called previously.
88 if ($user_ver !=2 && $gd_ver > 0 ) { return $gd_ver; }
89 // Use the gd_info() function if possible.
90 if (function_exists('gd_info')) {
91 $ver_info = gd_info();
92 preg_match('/\d/', $ver_info['GD Version'], $match);
93 $gd_ver = $match[0];
94 return $match[0];
95 }
96 // If phpinfo() is disabled use a specified / fail-safe choice...
97 if (preg_match('/phpinfo/', ini_get('disable_functions'))) {
98 if ($user_ver == 2) {
99 $gd_ver = 2;
100 return 2;
101 } else {
102 $gd_ver = 1;
103 return 1;
104 }
105 }
106 rizwank 1.1 // ...otherwise use phpinfo().
107 ob_start();
108 phpinfo(8);
109 $info = ob_get_contents();
110 ob_end_clean();
111 $info = stristr($info, 'gd version');
112 preg_match('/\d/', $info, $match);
113 $gd_ver = $match[0];
114 return $match[0];
115 }
116
117 if ($gdv = gdVersion()) {
118
119 ?>
120
121 <p>This process will make thumbnails from your existing full size images for this album. WARNING: If you have existing thumbnails, this process will overwrite them.</p>
122 <form action="generate-thumbs.php" method="get">
123 <fieldset>Maximum Width or Height: <input name="dim" type="text" size="4" value="90" /> <input type="submit" value="Generate Thumbs" /></fieldset>
124 <input type="hidden" name="aid" value="<?php echo $aid ?>" />
125 </form>
126 <?php } else { ?>
127 rizwank 1.1 <p>To generate thumbnails, you must have PHP compiled with the GD extension. Contact your host or system administrator for more information.</p>
128 <?php } ?>
129
130 <?php
131 }
132 /*
133 Function checkgd()
134 checks the version of gd, and returns "yes" when it's higher than 2
135 */
136 function checkgd(){
137 $gd2="";
138 ob_start();
139 phpinfo(8);
140 $phpinfo=ob_get_contents();
141 ob_end_clean();
142 $phpinfo=strip_tags($phpinfo);
143 $phpinfo=stristr($phpinfo,"gd version");
144 $phpinfo=stristr($phpinfo,"version");
145 preg_match('/\d/',$phpinfo,$gd);
146 if ($gd[0]=='2'){$gd2="yes";}
147 return $gd2;
148 rizwank 1.1 }
149
150 /*
151 Function ditchtn($arr,$thumbname)
152 filters out thumbnails
153 */
154 function ditchtn($arr,$thumbname){
155 foreach ($arr as $item){
156 if (!preg_match("/^".$thumbname."/",$item)){$tmparr[]=$item;}
157 }
158 return $tmparr;
159 }
160
161 /*
162 Function createthumb($name,$filename,$new_w,$new_h)
163 creates a resized image
164 variables:
165 $name Original filename
166 $filename Filename of the resized image
167 $new_w width of resized image
168 $new_h height of resized image
169 rizwank 1.1 */
170 function createthumb($name,$filename,$new_w,$new_h){
171 global $gd2;
172 $system=explode(".",$name);
173 if (preg_match("/jpg|jpeg|JPG|JPEG/",$system[1])){$src_img=imagecreatefromjpeg($name);}
174 if (preg_match("/png/",$system[1])){$src_img=imagecreatefrompng($name);}
175 $old_x=imageSX($src_img);
176 $old_y=imageSY($src_img);
177 if ($old_x > $old_y) {
178 $thumb_w=$new_w;
179 $thumb_h=$old_y*($new_h/$old_x);
180 }
181 if ($old_x < $old_y) {
182 $thumb_w=$old_x*($new_w/$old_y);
183 $thumb_h=$new_h;
184 }
185 if ($old_x == $old_y) {
186 $thumb_w=$new_w;
187 $thumb_h=$new_h;
188 }
189 if ($gd2==""){
190 rizwank 1.1 $dst_img=ImageCreate($thumb_w,$thumb_h);
191 imagecopyresized($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y);
192 }else{
193 $dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);
194 imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y);
195 }
196 if (preg_match("/png/",$system[1])){
197 imagepng($dst_img,$filename);
198 } else {
199 imagejpeg($dst_img,$filename);
200 }
201 imagedestroy($dst_img);
202 imagedestroy($src_img);
203 }
204
205 /*
206 Function directory($directory,$filters)
207 reads the content of $directory, takes the files that apply to $filter
208 and returns an array of the filenames.
209 You can specify which files to read, for example
210 $files = directory(".","jpg,gif");
211 rizwank 1.1 gets all jpg and gif files in this directory.
212 $files = directory(".","all");
213 gets all files.
214 */
215 function directory($dir,$filters){
216 $handle=opendir($dir);
217 $files=array();
218 if ($filters == "all"){while(($file = readdir($handle))!==false){$files[] = $file;}}
219 if ($filters != "all"){
220 $filters=explode(",",$filters);
221 while (($file = readdir($handle))!==false) {
222 for ($f=0;$f<sizeof($filters);$f++):
223 $system=explode(".",$file);
224 if ($system[1] == $filters[$f]){$files[] = $file;}
225 endfor;
226 }
227 }
228 closedir($handle);
229 return $files;
230 }
231 ?>
232 rizwank 1.1
233 </div>
234
235
236 </body>
237 </html>
|