OSDN Git Service

a102c35302e9b35afb54cb3ff2fbac8590f5cbdb
[nucleus-jp/nucleus-jp-ancient.git] / utf8 / nucleus / plugins / skinfiles / index.php
1 <?php
2
3 /*                                       */
4 /* Admin page for NP_SkinFiles           */
5 /* ------------------------------------  */
6 /* A simple skin files manager           */
7 /*                                       */
8 /* code by Jeff MacMichael               */
9 /* http://gednet.com/                    */
10 /*                                       */
11 /* version 1.01                          */
12  
13         $strRel = '../../../'; 
14         include($strRel . 'config.php');
15         
16         include($DIR_LIBS . 'PLUGINADMIN.php');
17
18         if (preg_match("/MD$/", $nucleus['version'])) {
19                 $isblogadmin = $member->isBlogAdmin(-1);
20         } else {
21                 $isblogadmin = $member->isBlogAdmin($blogid);
22         }
23         if (!($member->isAdmin() || $isblogadmin)) {
24                 $oPluginAdmin = new PluginAdmin('SkinFiles');
25                 $oPluginAdmin->start();
26                 echo "<p>"._ERROR_DISALLOWED."</p>";
27                 $oPluginAdmin->end();
28                 exit;
29         }
30
31         // set to FALSE for normal operation, or TRUE if skins are stored
32         // under owner's member id i.e. /skins/1/grey/...   (MDNucleus)
33         $privateskins = FALSE;
34         if ($privateskins) { 
35                 global $member;
36                 $SKINSUBDIR = $member->getID().'/'; 
37                 $latestskins = 'latest-skins/';
38         } else {
39                 $SKINSUBDIR = '';
40         }
41         
42         global $pluginsskinfiles, $CONF;
43         $pluginsskinfiles=$CONF['PluginURL']."skinfiles";
44
45         if (isset($_GET['action'])) {$action = $_GET['action'];}
46         if (isset($_POST['action'])) {$action = $_POST['action'];}
47
48         if ($action == 'download') { 
49                 download();
50                 return;
51                 break;
52         }
53
54         // create the admin area page
55         $oPluginAdmin = new PluginAdmin('SkinFiles');
56         $oPluginAdmin->start();
57         
58         echo "<h2>Skin File Management</h2>";
59         
60         if (strstr('renfile delfile createdir rendir deldir deleteAllInDir'
61                 .' editfile uploadfile createfile getLatestSkins', $action)) { 
62                 call_user_func($action);
63         } else {
64                 showdir();
65         }
66
67         $oPluginAdmin->end();
68         return;
69         break;
70                 
71         function createfile() {
72                 global $oPluginAdmin, $DIR_SKINS, $SKINSUBDIR, $pluginsskinfiles;
73                 $parent = $_POST["dir"];
74                 $filename = $_POST["filename"];
75                 $fullpath = $DIR_SKINS.$SKINSUBDIR.$parent.'/'.$filename;
76                 if (file_exists($fullpath)) {
77                         $msg = "Error: the file '$filename' already exists.";
78                         showdir($msg);
79                 }
80                 echo "<h3><b>Creating file \"/$parent/$filename\":</b></h3>";
81                 $errrep = error_reporting(E_ERROR);
82                 if (touch($fullpath)) { 
83                         $msg = 'The file was created successfully.';
84                 } else {
85                         $msg = 'ERROR: The file was <i>not</i> created successfully.';
86                 }
87                 $oldumask = umask(0000);
88                 chmod($fullpath, 0755);
89                 umask($oldumask);
90                 error_reporting($errrep);
91                 showdir($msg);
92         }
93
94         function createdir() {
95                 global $oPluginAdmin, $DIR_SKINS, $SKINSUBDIR, $pluginsskinfiles;
96                 $parent = $_POST["dir"];
97                 $newdir = $_POST["newdir"];
98                 if (!$newdir) {
99                         echo 'You need to specify a directory name to create. <br /><br />';
100                         echo '> <a href="'.$_SERVER['HTTP_REFERER'].'">Go back</a><br />';              
101                         return;
102                 }
103                 $errrep = error_reporting(E_ERROR);
104                 $oldumask = umask(0000);
105                 if (mkdir ($DIR_SKINS.$SKINSUBDIR.$parent.'/'.$newdir, 0755)) {
106                         $msg = 'Directory created successfully.';
107                 } else {
108                         $msg = 'There was an error creating the directory (check to see if the directory already exists).';
109                 }
110                 umask($oldumask);
111                 error_reporting($errrep);
112                 showdir($msg);
113         }
114         
115         function download() {
116                 global $DIR_SKINS, $SKINSUBDIR;
117                 $file = $_GET["rfp"];
118                 $path = $DIR_SKINS.$SKINSUBDIR.$file;
119                 $splitpath =  preg_split( "/\//", strrev($_GET["rfp"]), 2);
120                 $file = strrev($splitpath[0]);
121                 
122                 // download code taken from Paul Alger's PHP_Easy_Download. 
123
124                 // translate file name properly for Internet Explorer.
125                 if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE")){
126                         $file = preg_replace('/\./', '%2e', $file, substr_count($file, '.') - 1);
127                 }
128                 // make sure the file exists before sending headers
129                 if(!$fdl=@fopen($path,'r')){
130                         die("Cannot Open File!");
131                 } else {
132                         header("Cache-Control: ");// leave blank to avoid IE errors
133                         header("Pragma: ");// leave blank to avoid IE errors
134                         header("Content-type: application/octet-stream");
135                         header('Content-Disposition: attachment; filename="'.$file.'"');
136                         header("Content-length: ".(string)(filesize($path)));
137                         sleep(1);
138                         
139                         fpassthru($fdl);
140                 }
141                 return;
142                 break;
143         }
144         
145         function uploadfile() {
146                 global $HTTP_POST_FILES, $DIR_SKINS, $SKINSUBDIR, $pluginsskinfiles, $CONF;
147                 $filename = $HTTP_POST_FILES['filename']['name'];
148                 $filesize = $HTTP_POST_FILES['filename']['size'];
149                 $filetempname = $HTTP_POST_FILES['filename']['tmp_name'];
150                 $todir = $DIR_SKINS.$SKINSUBDIR.$_POST['dir'].'/';
151                 
152                 if ($filesize > $CONF['MaxUploadSize']) {
153                         showdir(_ERROR_FILE_TOO_BIG);
154                         return;
155                 }
156
157                 // check file type against allowed types
158                 $ok = 0;
159                 $allowedtypes = explode (',', "css,html,htm,xml,inc,txt,".$CONF['AllowedTypes']);
160                 foreach ( $allowedtypes as $type ) 
161                         if (eregi("\." .$type. "$",$filename)) $ok = 1;    
162                 if (!$ok) {
163                         showdir(_ERROR_BADFILETYPE);
164                         return;
165                 }
166                 if (!is_uploaded_file($filetempname)) {
167                         showdir(_ERROR_BADREQUEST);
168                         return;
169                 }
170                 if (file_exists($todir.$filename)) {
171                         showdir(_ERROR_UPLOADDUPLICATE);
172                         return;
173                 }
174
175                 // move file to directory
176                 if (is_uploaded_file($filetempname)) {
177                         $errrep = error_reporting(E_ERROR);
178                         if (!@move_uploaded_file($filetempname, $todir . $filename)) {
179                                 showdir(_ERROR_UPLOADMOVE);
180                                 return;
181                         }
182                         error_reporting($errrep);
183                 }
184                 // chmod uploaded file
185                 $oldumask = umask(0000);
186                 @chmod($todir . $filename, 0755); 
187                 umask($oldumask);               
188
189                 showdir("File uploaded successfully.");
190         }
191
192         function rendir() {
193                 global $DIR_SKINS, $SKINSUBDIR, $pluginsskinfiles;
194                 if (isset($_POST['newname'])) {
195                         $splitpath =  preg_split( "/\//", strrev($_POST["oldname"]), 2);
196                         $newname = strrev($splitpath[1]) .'/'. $_POST["newname"];
197                         $newname = preg_replace("/^\//", "", $newname);
198                         $res = rename ( $DIR_SKINS.$SKINSUBDIR.$_POST["oldname"], 
199                                 $DIR_SKINS.$SKINSUBDIR.$newname);
200                         if ($res) { 
201                                 $msg = "Directory successfully renamed."; 
202                         } else {
203                                 $msg = "Failed to rename directory - (check to see if another directory already exists with the new name).";
204                         }
205                         showdir($msg);
206                 } else { 
207                         $oldname = preg_replace("/^\//", "", $_GET["oldname"]);
208                         echo '<h3><b>Rename directory "/'.$oldname.'":</b></h3>';
209                         $splitpath =  preg_split( "/\//", strrev($_GET["oldname"]), 2);
210                         $dir = strrev($splitpath[0]);
211                         $parent = strrev($splitpath[1]);
212                         echo '> <a href="'.$_SERVER['HTTP_REFERER'].'">Cancel rename</a><br />';                
213                         ?>
214                                 <form method="post" action="<?php echo $pluginsskinfiles?>/">
215                                         <input type="hidden" name="action" value="rendir" />
216                                         <input type="hidden" name="dir" value="<?php echo "/$parent" ?>"/>
217                                         <input type="hidden" name="oldname" value="<?php echo $oldname?>"/>
218                                         <table><tr>
219                                                 <td><?php echo 'Rename to'?></td>
220                                                 <td><input name="newname" tabindex="90" value="<?php echo  htmlspecialchars($dir) ?>" maxlength="50" size="20" /></td>
221                                         </tr><tr>
222                                                 <td><?php echo "Rename"?></td>
223                                                 <td><input type="submit" tabindex="140" value="<?php echo "Rename this folder"?>" onclick="return checkSubmit();" /></td>
224                                         </tr></table>
225                                 </form>
226                         <?PHP
227                 }
228         }
229
230         function editfile () {
231                 global $DIR_SKINS, $SKINSUBDIR, $pluginsskinfiles;
232                 if (isset ($_POST['rfp']) && isset($_POST['content'])) {
233                         $file = $_POST['rfp'];
234                         $errrep = error_reporting(E_ERROR);
235                         $success = true;
236                         if ($fh = @fopen($DIR_SKINS.$SKINSUBDIR.$file, 'w')) { 
237                                 if (fwrite ($fh, trim(stripslashes($_POST['content'])))) {
238                                         fclose($fh);
239                                 } else {
240                                         $success = false;
241                                 }
242                         } else {
243                                 $success = false;
244                         }
245                         error_reporting($errrep);
246                         if ($success) {
247                                 $msg = 'File was edited successfully.';
248                         } else {
249                                 $msg = 'ERROR: File was <i>not</i> saved successfully.';
250                         }
251                 }
252                 if (isset ($_GET['rfp'])) { $file = $_GET['rfp']; }
253                 if (isset ($_POST['rfp'])) { $file = $_POST['rfp']; }
254                 $splitpath =  preg_split( "/\//", strrev($file), 2);
255                 $parent = strrev($splitpath[1]);
256                 echo '<h3>Editing file "/'.$file.'":</h3>';
257                 if (isset($msg)) { echo "<p><b>$msg</b></p>"; }
258                 echo "> <a href=\"$pluginsskinfiles/?dir=$parent\"> Cancel/Return to /$parent</a><br /><br />";
259                 $fh = @fopen($DIR_SKINS.$SKINSUBDIR.$file, 'r');
260                 while (!feof($fh)) { 
261                         $content .= fread($fh, 4096); 
262                 }
263                 fclose ($fh);                   
264                 ?>
265                         <form method="post" action="<?php echo $pluginsskinfiles?>/">
266                                 <input type="hidden" name="action" value="editfile" />
267                                 <input type="hidden" name="rfp" value="<?php echo $file ?>"/>
268                                 <input type="hidden" name="dir" value="<?php echo $parent ?>"/>
269                                 <input type="submit" tabindex="140" value="<?php echo "Save changes"?>" onclick="return checkSubmit();" />
270                                 <input type="reset" value="Reset Data" /><br />
271                                 <textarea class="skinedit" tabindex="8" rows="20" cols="80" name="content"><?PHP echo htmlspecialchars($content) ?></textarea>
272                                 <input type="submit" tabindex="140" value="<?php echo "Save changes"?>" onclick="return checkSubmit();" />
273                                 <input type="reset" value="Reset Data" /><br />
274                         </form>
275                 <?PHP
276         }
277
278
279         function renfile() {
280                 global $DIR_SKINS, $SKINSUBDIR, $pluginsskinfiles;
281                 if (isset($_POST['newname'])) {
282                         $splitpath =  preg_split( "/\//", strrev($_POST["oldname"]), 2);
283                         $newname = strrev($splitpath[1]) .'/'. $_POST["newname"];
284                         $newname = preg_replace("/^\//", "", $newname);
285                         $res = rename ( $DIR_SKINS.$SKINSUBDIR.$_POST["oldname"], 
286                                 $DIR_SKINS.$SKINSUBDIR.$newname);
287                         if ($res) { 
288                                 $msg = "File successfully renamed."; 
289                         } else {
290                                 $msg = "File could not be renamed - (check to see if another file already exists with the new name).";
291                         }
292                         showdir($msg);
293                 } else { 
294                         echo '<h3><b>Rename file "/'.$_GET["rfp"].'":</b></h3>';
295                         $splitpath =  preg_split( "/\//", strrev($_GET["rfp"]), 2);
296                         $file = strrev($splitpath[0]);
297                         $parent = strrev($splitpath[1]);
298                         echo '> <a href="'.$_SERVER['HTTP_REFERER'].'">Cancel rename</a><br />';                
299                         ?>
300                                 <form method="post" action="<?php echo $pluginsskinfiles?>/">
301                                         <input type="hidden" name="action" value="renfile" />
302                                         <input type="hidden" name="oldname" value="<?php echo $_GET["rfp"] ?>"/>
303                                         <input type="hidden" name="dir" value="<?php echo "/$parent" ?>"/>
304                                         <table><tr>
305                                                 <td><?php echo 'Rename to'?></td>
306                                                 <td><input name="newname" tabindex="90" value="<?php echo  htmlspecialchars($file) ?>" maxlength="50" size="20" /></td>
307                                         </tr><tr>
308                                                 <td><?php echo "Rename"?></td>
309                                                 <td><input type="submit" tabindex="140" value="<?php echo "Rename this file"?>" onclick="return checkSubmit();" /></td>
310                                         </tr></table>
311                                 </form>
312                         <?PHP
313                 }
314         }
315
316         function delfile() {
317                 global $DIR_SKINS, $SKINSUBDIR, $pluginsskinfiles;
318                 if (isset($_GET['sure'])) { 
319                         $file = $DIR_SKINS.$SKINSUBDIR.$_GET["rfp"];
320                         $errrep = error_reporting(E_ERROR);
321                         if (unlink ($file)) {
322                                 $msg = 'File "'.$_GET["rfp"].'" has been deleted.';
323                         } else {
324                                 $msg = 'ERROR: File "'.$_GET["rfp"].'" could not be deleted.';
325                         }
326                         error_reporting($errrep);
327                         showdir($msg);
328                 } else {
329                         $file = $DIR_SKINS.$SKINSUBDIR.$_GET["rfp"];
330                         $splitpath =  preg_split( "/\//", strrev($_GET["rfp"]), 2);
331                         $parent = strrev($splitpath[1]);
332                         echo '<h3><b>Delete file "'.$_GET["rfp"].'": are you sure?</b></h3>';
333                         echo '<b>This action cannot be undone!</b><br /><br />';
334                         echo "> <a href=\"$pluginsskinfiles/?action=delfile&dir=$parent&sure=y&rfp=".$_GET["rfp"]."\">Yes, delete the file.</a><br />";         
335                         echo "> <a href=\"$pluginsskinfiles/?dir=".$parent.'">No, go back.</a><br />';          
336                 }
337         }
338
339         function deldir() {
340                 global $DIR_SKINS, $SKINSUBDIR, $pluginsskinfiles;
341                 if (isset($_GET['sure'])) { 
342                         $dir = $DIR_SKINS.$SKINSUBDIR.$_GET["remdir"];
343                         $errrep = error_reporting(E_ERROR);
344                         if (rmdir ($dir)) {
345                                 $msg = 'Directory "'.$_GET["remdir"].'" has been deleted.';
346                         } else {
347                                 $msg = 'ERROR: directory "'.$_GET["remdir"].'" could not be deleted - (check to see if it contains files).';
348                         }
349                         error_reporting($errrep);
350                         showdir($msg);
351                 } else {
352                         $dir = preg_replace("/^\//", "",$_GET['remdir']);
353                         $parent = $_GET['dir'];
354                         echo '<h3><b>Delete directory "/'.$dir.'": are you sure?</b></h3>';
355                         echo '<b>This action cannot be undone!</b><br /><br />';
356                         echo "> <a href=\"$pluginsskinfiles/?action=deldir&sure=y&remdir=$dir&dir=$parent\">Yes, delete the directory (it must be empty to do this).</a><br /><br />";          
357                         echo "> <a href=\"$pluginsskinfiles/?dir=".$parent.'">No, go back.</a><br />';          
358                 }
359         }
360
361         function deleteAllInDir() {
362                 global $DIR_SKINS, $SKINSUBDIR, $pluginsskinfiles;
363                 $parent = $DIR_SKINS.$SKINSUBDIR.preg_replace("/^\//", "",$_GET['dir']);
364                 if ($dh = @opendir($parent)) { 
365                         while (($file = readdir($dh)) !== false) { 
366                                 if(!preg_match("/^\.{1,2}/", $file)){
367                                         if (!is_dir($parent.$file)) {
368                                                 $files[] = $file;
369                                         }
370                                 }
371                         }
372                         closedir($dh); 
373                 } 
374                 if (isset($_GET['sure'])) { 
375                         $errrep = error_reporting(E_ERROR);
376                         echo '<h3>Deletion results</h3><table>';
377                         echo "> <a href=\"$pluginsskinfiles/?dir=".$_GET["dir"]."\">Return to the /".$_GET["dir"]." directory.</a><br />";              
378                         foreach ($files as $file) {
379                                 if (unlink ("$parent/$file")) { 
380                                         echo "<tr><td>File: $file was deleted.</td></tr>"; 
381                                 } else {
382                                         echo "<tr><td>File: $file was <b>NOT</b> deleted.</td></tr>";
383                                 }
384                         }
385                         echo "</table>";
386                         error_reporting($errrep);
387                         echo "> <a href=\"$pluginsskinfiles/?dir=".$_GET["dir"]."\">Return to the /".$_GET["dir"]." directory.</a><br />";              
388                 } else {
389                         echo '<h3><b>Delete all files in directory "/'.$_GET['dir'].'": are you sure?</b></h3>';
390                         echo '<b>This action cannot be undone!</b><br /><br />';
391                         echo "> <a href=\"$pluginsskinfiles/?action=deleteAllInDir&sure=y&dir=".$_GET["dir"]."\">Yes, delete <u>all files</u> in this directory.</a><br />";            
392                         echo "> <a href=\"$pluginsskinfiles/?dir=".$_GET['dir'].'">No, go back.</a><br /><br />';               
393                         echo '<b>Files list:</b><table>';
394                         foreach ($files as $file) {     echo "<tr><td>$file</td></tr>"; }
395                         echo '</table>';
396                 }
397         }
398
399         // function for MDNucleus; won't work unless $privateskins is set to true
400         function getLatestSkins() {
401                 global $DIR_SKINS, $pluginsskinfiles, $privateskins, $latestskins, $member;
402                 $confirmed = $_POST['overwrite'];
403                 if (!$confirmed) {
404                         showdir("Overwrite of default skin files not confirmed - no action taken.");
405                         return;
406                 }
407                 if ($dh = @opendir($DIR_SKINS.$latestskins)) { 
408                         while (($file = readdir($dh)) !== false) { 
409                                 if(!preg_match("/^\.{1,2}/", $file))
410                                         if (is_dir($DIR_SKINS.$latestskins.$file)) $skins[] = $file;
411                         }
412                         closedir($dh); 
413                 } 
414                 if ($skins) {
415                         $msg = "Refreshed skin folders:";
416                         sort ($skins);
417                         foreach ($skins as $skin) {
418                                 $memberskin = $DIR_SKINS.$member->getID().'/'.$skin;
419                                 if (is_file($memberskin)) unlink($memberskin);
420                                 if (!is_dir($memberskin)) {
421                                         $old_umask = umask(0);
422                                         mkdir($memberskin, 0755);
423                                         umask($old_umask);
424                                 }
425                                 exec("rsync -Wtr --delete ".$DIR_SKINS.$latestskins.$skin."/* ".$memberskin.'/');
426                                 $msg .= "  $skin";
427                         }
428                 } else {
429                         showdir("No default skin folders found.  No action taken.");
430                         return;
431                 }
432                 showdir($msg);
433         }
434
435         function _isImageFile($file) {
436                 return preg_match ("/\.(gif|png|jpg|jpeg|bmp|ico)$/i", $file);
437         }
438
439         function _isEditableFile($file) {
440                 return preg_match ("/\.(inc|txt|htm|html|xml)$/i", $file);
441         }
442
443         function showdir($msg = '') {
444                 global $DIR_SKINS, $SKINSUBDIR, $pluginsskinfiles, $CONF;
445                 global $privateskins, $latestskins;
446                 if (isset($_GET['dir'])) { 
447                         $newdir = preg_replace("/^\//", "",$_GET['dir']);
448                         $currdir = $DIR_SKINS.$SKINSUBDIR."$newdir/";
449                         $in_subdir = 1;
450                 } elseif (isset($_POST['dir'])) { 
451                         $newdir = preg_replace("/^\//", "",$_POST['dir']);
452                         $currdir = $DIR_SKINS.$SKINSUBDIR."$newdir/";
453                         $in_subdir = 1;
454                 } else {
455                         $newdir = '';
456                         $currdir = $DIR_SKINS.$SKINSUBDIR;
457                         $in_subdir = 0;
458                 }
459         
460                 if ($privateskins && (!is_dir($DIR_SKINS.$SKINSUBDIR))) {
461                         $oldumask = umask(0);
462                         mkdir($DIR_SKINS.$SKINSUBDIR, 0755);
463                         umask($oldmask);
464                 }
465
466                 if (!is_dir($currdir)) {
467                         echo 'The specified location is not a directory or doesn\'t exist.';
468                         return;
469                 }
470                 
471                 if ($dh = @opendir($currdir)) { 
472                         while (($file = readdir($dh)) !== false) { 
473                                 if(!preg_match("/^\.{1,2}/", $file)){
474                                         if (is_dir($currdir.$file)) {
475                                                 $dirs[] = $file;
476                                         } else {
477                                                 $files[] = $file;
478                                         }
479                                 }
480                         }
481                         closedir($dh); 
482                 } 
483                 
484                 echo "<h3>Current Directory: <b>/$newdir</b></h3>";
485                 
486                 if ($msg) {
487                         echo '<p><b>'.htmlspecialchars($msg).'</b></p>';
488                 }
489                 
490                 if ($newdir != '') {
491                         echo "<u><a href=\"$pluginsskinfiles/\">> Return to / <</a></u><br />";
492                         if (strstr($newdir, '/')) {
493                                 $splitpath =  preg_split( "/\//", strrev($newdir), 2);
494                                 $updir = strrev($splitpath[1]);
495                                 echo "<u><a href=\"$pluginsskinfiles/?dir=/$updir\">> Return to /$updir <</a></u><br /><br />";
496                         }
497                 }
498                 echo "<u><a href=\"$pluginsskinfiles/?dir=$newdir\">> Refresh <</a></u><br />";
499
500                 echo "<table>";
501                 if(is_array($dirs)){
502                         sort($dirs);
503                         foreach($dirs as $dir) {
504                                 echo "<tr onmouseover='focusRow(this);' onmouseout='blurRow(this);'><td>";
505                                 echo "&nbsp;&nbsp;<a href=\"$pluginsskinfiles/?dir=$newdir/$dir\">";
506                                 echo "<img src=\"$pluginsskinfiles/dir.gif\"> $dir</a>&nbsp;</td>";
507                                 echo "<td>&nbsp;<a href=\"$pluginsskinfiles/?action=rendir&oldname=$newdir/$dir\" title=\"Rename directory\">(ren)</a></td>";
508                                 echo "<td>&nbsp;<a href=\"$pluginsskinfiles/?action=deldir&dir=$newdir&remdir=$newdir/$dir\" title=\"Delete directory\">(del)</a></td>";
509                                 echo "</td><td></td><td></td><td></td><td>";
510                                 echo "<td>".date('M d, Y  h:i:s a', filemtime($DIR_SKINS.$SKINSUBDIR.$newdir."/$dir"));
511                                 echo "</td></tr>";
512                         }
513                 }
514         
515                 if(is_array($files)){
516                         sort($files);
517                         foreach($files as $file) {
518                                 echo "<tr onmouseover='focusRow(this);' onmouseout='blurRow(this);'><td>";
519                                 echo "&nbsp;&nbsp;";
520                                 if (preg_match("/\.css$/i", $file)) {
521                                         echo "<img src=\"$pluginsskinfiles/css.gif\"> ";
522                                 } elseif (preg_match("/\.php(3|4)?$/i", $file)) {
523                                         echo "<img src=\"$pluginsskinfiles/php.gif\"> ";
524                                 } elseif (_isEditableFile($file)) {
525                                         echo "<img src=\"$pluginsskinfiles/text.gif\"> ";
526                                 } elseif (_isImageFile($file)) {
527                                         echo "<img src=\"$pluginsskinfiles/image.gif\"> ";
528                                 } else {
529                                         echo "<img src=\"$pluginsskinfiles/generic.png\"> ";
530                                 }
531                                 if ($newdir == '') {$thisdir = '';} else {$thisdir = "$newdir/";}
532                                 echo "$file&nbsp;";
533                                 echo "</td><td>";
534                                 echo "&nbsp;<a href=\"$pluginsskinfiles/?action=renfile&rfp=$thisdir"."$file\" title=\"Rename file\">(ren)</a>";
535                                 echo "</td><td>";
536                                 echo "&nbsp;<a href=\"$pluginsskinfiles/?action=delfile&rfp=$thisdir"."$file\" title=\"Delete file\">(del)</a>";
537                                 echo "</td><td>";
538                                 if ((is_writable($DIR_SKINS.$SKINSUBDIR.$thisdir.$file)) && (!_isImageFile($file))) {
539                                         echo "&nbsp;<a href=\"$pluginsskinfiles/?action=editfile&rfp=$thisdir"."$file\" title=\"Edit file\">(edit)</a>";
540                                 }
541                                 echo "</td><td>";
542                                 if (_isImageFile($file)) {
543                                         echo '&nbsp;<a href="'.$CONF['SkinsURL'].$SKINSUBDIR.$thisdir."$file\" title=\"View graphic\">(view)</a>";
544                                 }
545                                 echo "</td><td>";
546                                 echo "&nbsp;<a href=\"$pluginsskinfiles/?action=download&rfp=$thisdir"."$file\" title=\"Download file\">(d/l)</a>";
547                                 echo "</td><td>";
548                                 echo number_format(filesize($DIR_SKINS.$SKINSUBDIR.$thisdir.$file)/1024, 2)." KB";
549                                 echo "</td><td>";
550                                 echo date('M d, Y  h:i:s a', filemtime($DIR_SKINS.$SKINSUBDIR.$thisdir.$file));
551                                 echo "</td></tr>";
552                         }
553                 }
554                 echo "</table>";
555         
556                 if(is_array($dirs) || is_array($files)) {
557                         if ($newdir != '') {
558                                 echo "<u><a href=\"$pluginsskinfiles/\">> Return to / <</a></u><br />";
559                                 if (strstr($newdir, '/')) {
560                                         $splitpath =  preg_split( "/\//", strrev($newdir), 2);
561                                         $updir = strrev($splitpath[1]);
562                                         echo "<u><a href=\"$pluginsskinfiles/?dir=/$updir\">> Return to /$updir <</a></u><br /><br />";
563                                 }
564                         }
565                         echo "<u><a href=\"$pluginsskinfiles/?dir=$newdir\">> Refresh <</a></u><br />";
566                 }
567
568                 if ($newdir != '') {
569                         echo "<h3>Create new file in <b>/$newdir</b></h3>";
570                                 ?>
571                                 <form method="POST" enctype="multipart/form-data" action="<?php echo $pluginsskinfiles ?>/">
572                                                 <input type="hidden" name="action" value="createfile" />
573                                                 <input type="hidden" name="dir" value="<?php echo $newdir ?>">
574                                                 <input type="text" name="filename" size="40">
575                                                 <input type="submit" value="<?php echo 'Create file' ?>" />
576                                         </form>
577                                 <?PHP
578
579                                 echo "<h3>Upload new file to <b>/$newdir</b></h3>";
580                                 ?>
581                                 <form method="POST" enctype="multipart/form-data" action="<?php echo $pluginsskinfiles ?>/">
582                                                 <input type="hidden" name="action" value="uploadfile" />
583                                                 <input type="hidden" name="dir" value="<?php echo $newdir ?>">
584                                                 <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $CONF['MaxUploadSize']?>" />
585                                                 <input type="file" name="filename" size="40">
586                                                 <input type="submit" value="<?php echo _UPLOAD_BUTTON?>" />
587                                         </form>
588                                 <?PHP
589         
590                         if (count($files)) {
591                                 echo "<h3>Delete all files in <b>/$newdir</b></h3>";
592                                         ?>
593                                                 <form method="get" action="<?php echo $pluginsskinfiles?>/">
594                                                         <input type="hidden" name="action" value="deleteAllInDir" />
595                                                         <input type="hidden" name="dir" value="<?php echo $newdir?>"/>
596                                                         <?php echo "Delete all Files? (will ask for confirmation)"?>
597                                                         <input type="submit" tabindex="140" value="<?php echo "Delete All"?>" onclick="return checkSubmit();" />
598                                                 </form>
599                                         <?PHP
600                         }
601                 }
602         
603                 echo "<h3>Create a new directory in <b>/$newdir</b></h3>"; 
604                                 ?>
605                                         <form method="post" action="<?php echo $pluginsskinfiles?>/">
606                                                 <input type="hidden" name="action" value="createdir" />
607                                                 <input type="hidden" name="dir" value="<?php echo $newdir?>"/>
608                                                 <input name="newdir" tabindex="90" value="<?php echo 'newdir' ?>" size="40" />
609                                                 <input type="submit" tabindex="140" value="<?php echo "Create"?>" onclick="return checkSubmit();" />
610                                         </form>
611                                 <?PHP
612
613                 // for MDNucleus, ignored if on Win32 platform (for the moment)
614                 if (($newdir == '') && ($privateskins) && (!strtoupper(substr(PHP_OS, 0,3) == 'WIN'))) {
615                         if ($dh = @opendir($DIR_SKINS.$latestskins)) { 
616                                 while (($file = readdir($dh)) !== false) { 
617                                         if(!preg_match("/^\.{1,2}/", $file))
618                                                 if (is_dir($DIR_SKINS.$latestskins.$file)) $skins[] = $file;
619                                 }
620                                 closedir($dh); 
621                         }
622                         if ($skins) {
623                                 echo "<h3>Refresh default skin files to standard versions</h3>";
624                                 ?>
625                                         <form method="post" action="<?php echo $pluginsskinfiles?>/">
626                                                 <input type="hidden" name="action" value="getLatestSkins" />
627                                                 <?php
628                                                 sort ($skins);
629                                                 if (count($skins) > 1) {
630                                                         $lastskin = array_pop($skins);
631                                                         array_push($skins, "</b>and<b> $lastskin");
632                                                 }
633                                                 echo "This will overwrite or create files in the following skin file directories: <b>";
634                                                 echo implode(", ", $skins)."</b><br /><br />"; 
635                                                 ?> 
636                                                 Note that you may need to re-import skin definitions you wish to use (See Layout Import/Export).<br /><br />
637                                                 <input type="checkbox" name="overwrite" value="1" id="cb_overwrite" />
638                                                 <label for="cb_overwrite"><?php echo "Check this box to confirm overwrite of files<br />" ?></label>
639                                                 <input type="submit" tabindex="140" value="<?php echo "Overwrite Default Skin Files"?>" onclick="return checkSubmit();" />
640                                         </form>
641                                 <?PHP
642                         }
643                 }
644
645         }
646
647         
648         
649 ?>