[ Index ] |
|
Code source de CMS made simple 1.0.5 |
1 <?php 2 #CMS - CMS Made Simple 3 #(c)2004 by Ted Kulp (wishy@users.sf.net) 4 #This project's homepage is: http://cmsmadesimple.sf.net 5 # 6 #This program is free software; you can redistribute it and/or modify 7 #it under the terms of the GNU General Public License as published by 8 #the Free Software Foundation; either version 2 of the License, or 9 #(at your option) any later version. 10 # 11 #This program is distributed in the hope that it will be useful, 12 #but WITHOUT ANY WARRANTY; without even the implied warranty of 13 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 #GNU General Public License for more details. 15 #You should have received a copy of the GNU General Public License 16 #along with this program; if not, write to the Free Software 17 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 # 19 #$Id: imagefiles.php 2834 2006-06-01 13:56:35Z elijahlofgren $ 20 21 $CMS_ADMIN_PAGE=1; 22 23 // in filetypes.inc.php filetypes are defined 24 require_once(dirname(dirname(__FILE__))."/lib/filemanager/filetypes.inc.php"); 25 require_once(dirname(dirname(__FILE__))."/lib/file.functions.php"); 26 require_once ("../include.php"); 27 28 check_login(); 29 30 $action_done=''; 31 32 function deldir($dir) 33 { 34 $handle = opendir($dir); 35 while (false!==($FolderOrFile = readdir($handle))) 36 { 37 if($FolderOrFile != "." && $FolderOrFile != "..") 38 { 39 if(@is_dir("$dir/$FolderOrFile")) 40 { 41 deldir("$dir/$FolderOrFile"); 42 } // recursive 43 else 44 { 45 unlink("$dir/$FolderOrFile"); 46 } 47 } 48 } 49 closedir($handle); 50 if(rmdir($dir)) 51 { 52 $success = true; 53 } 54 return $success; 55 } 56 57 $errors = ""; 58 59 $dir = $config["image_uploads_path"]; 60 $url = $config["image_uploads_url"]; 61 62 $reldir = ""; 63 64 if (!isset($IMConfig['thumbnail_dir'])) $IMConfig['thumbnail_dir'] = ''; 65 if (isset($_POST['reldir'])) $reldir = $_POST['reldir']; 66 else if (isset($_GET['reldir'])) $reldir = $_GET['reldir']; 67 68 if (strpos($reldir, '..') === false && strpos($reldir, '\\') === false) 69 { 70 $dir .= $reldir; 71 } 72 73 $userid = get_userid(); 74 $access = check_permission($userid, 'Modify Files'); 75 76 $username = $gCms->variables["username"]; 77 78 #Did we upload a file? 79 if (isset($_FILES) && isset($_FILES['uploadfile']) && isset($_FILES['uploadfile']['name']) && $_FILES['uploadfile']['name'] != "") 80 { 81 if ($access) 82 { 83 if (!move_uploaded_file($_FILES['uploadfile']['tmp_name'], $dir."/".$_FILES['uploadfile']['name'])) 84 { 85 $errors .= "<li>".lang('filenotuploaded')."</li>"; 86 } 87 else 88 { 89 chmod($dir."/".$_FILES['uploadfile']['name'], octdec('0'.$config['default_upload_permission'])); 90 audit(-1, $_FILES['uploadfile']['name'], 'Uploaded File'); 91 } 92 } 93 else 94 { 95 $errors .= "<li>".lang('needpermissionto', array('Modify Files'))."</li>"; 96 } 97 } 98 99 #Did we create a new dir? 100 if (isset($_POST['newdirsubmit'])) 101 { 102 if ($access) 103 { 104 #Make sure it isn't an empty dir name 105 if ($_POST['newdir'] == "") 106 { 107 $errors .= "<li>".lang('filecreatedirnoname')."</li>"; 108 } 109 else if (ereg('\.\.',$_POST['newdir'])) 110 { 111 $errors .= "<li>".lang('filecreatedirnodoubledot')."</li>"; 112 } 113 else if (ereg('/', $_POST['newdir']) || strpos($_POST['newdir'], '\\') !== false) 114 { 115 $errors .= "<li>".lang('filecreatedirnoslash')."</li>"; 116 } 117 else if (file_exists($dir."/".$_POST['newdir'])) 118 { 119 $errors .= "<li>".lang('directoryexists')."</li>"; 120 } 121 else 122 { 123 mkdir($dir."/".$_POST['newdir'], 0777); 124 audit(-1, $_POST['newdir'], 'Created Directory'); 125 } 126 } 127 else 128 { 129 $errors .= "<li>".lang('needpermissionto', array('Modify Files'))."</li>"; 130 } 131 } 132 133 if (isset($_GET['action']) && $_GET['action'] == "deletefile") 134 { 135 if ($access) 136 { 137 if (is_file($dir . "/" . $_GET['file'])) 138 { 139 if (!(unlink($dir . "/" . $_GET['file']))) 140 { 141 $errors .= "<li>".lang('errordeletingfile')."</li>"; 142 } 143 else 144 { 145 audit(-1, $reldir . "/" . $_GET['file'], 'Deleted File'); 146 } 147 } 148 else 149 { 150 $errors .= "<li>".lang('norealfile')."</li>"; 151 } 152 } 153 else 154 { 155 $errors .= "<li>".lang('needpermissionto', array('Modify Files'))."</li>"; 156 } 157 } 158 else if (isset($_GET['action']) && $_GET['action'] == "deletedir") 159 { 160 if ($access) 161 { 162 if (@is_dir($dir . "/" . $_GET['file'])) 163 { 164 if (!(deldir($dir . "/" . $_GET['file']))) 165 { 166 $errors .= "<li>".lang('errordeletingdirectory')."</li>"; 167 } 168 else 169 { 170 audit(-1, $reldir . "/" . $_GET['file'], 'Deleted Directory'); 171 } 172 } 173 else 174 { 175 $errors .= "<li>".lang('norealdirectory')."</li>"; 176 } 177 } 178 else 179 { 180 $errors .= "<li>".lang('needpermissionto', array('Modify Files'))."</li>"; 181 } 182 } 183 184 include_once ("header.php"); 185 ?> 186 187 188 189 <script type="text/javascript" src="../lib/filemanager/ImageManager/assets/dialog.js"></script> 190 <script type="text/javascript" src="../lib/filemanager/ImageManager/IMEStandalone.js"></script> 191 <?php echo " <script type=\"text/javascript\" src=\"../lib/filemanager/ImageManager/lang/{$nls['htmlarea'][$current_language]}.js\"></script>\n" ?> 192 <script type="text/javascript"> 193 //<![CDATA[ 194 195 //Create a new Imanager Manager, needs the directory where the manager is 196 //and which language translation to use. 197 198 var manager = new ImageManager('../lib/filemanager/ImageManager','en'); 199 200 var thumbdir = "<?php echo $IMConfig['thumbnail_dir']; ?>"; 201 var base_url = "<?php echo $url; ?>"; 202 //Image Manager wrapper. Simply calls the ImageManager 203 204 205 //]]> 206 </script> 207 208 <script type="text/javascript"> 209 /*<![CDATA[*/ 210 211 212 213 /*]]>*/ 214 </script> 215 216 <?php 217 218 219 $row = "row1"; 220 221 $dirtext = ""; 222 $filetext = ""; 223 $file = ""; 224 225 if ($errors != "") 226 { 227 // echo "<div class=\"pageerrorcontainer\"><ul class=\"error\">".$errors."</ul></div>"; 228 echo $themeObject->ShowErrors('<ul class="error">'.$errors.'</ul>'); 229 } 230 231 echo '<div class="pagecontainer">'; 232 echo $themeObject->ShowHeader('imagemanagement'); 233 234 ?> 235 <iframe class="imageframe" src="../lib/filemanager/ImageManager/images.php?dir=<?php echo "$reldir" ?>" name="imgManager" title="Image Selection"></iframe> 236 237 <?php 238 239 if ($access) 240 { 241 ?> 242 243 <form enctype="multipart/form-data" action="imagefiles.php" method="post" name="uploader"> 244 <div class="pageoverflow"> 245 <p class="pagetext"><?php echo lang('uploadfile')?>:</p> 246 <p class="pageinput"> 247 <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $config["max_upload_size"]?>" /> 248 <input type="hidden" name="reldir" value="<?php echo $reldir?>" /> 249 <input name="uploadfile" type="file" /> <input class="pagebutton" onmouseover="this.className='pagebuttonhover'" onmouseout="this.className='pagebutton'" type="submit" value="<?php echo lang('send')?>" /> 250 </p> 251 </div> 252 <div class="pageoverflow"> 253 <p class="pagetext"><?php echo lang('createnewfolder')?>:</p> 254 <p class="pageinput"><input type="text" name="newdir" /> <input class="pagebutton" onmouseover="this.className='pagebuttonhover'" onmouseout="this.className='pagebutton'" type="submit" name="newdirsubmit" value="<?php echo lang('create')?>" /></p> 255 </div> 256 </form> 257 258 </div> 259 260 <?php 261 } 262 263 include_once ("footer.php"); 264 265 # vim:ts=4 sw=4 noet 266 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Tue Apr 3 18:50:37 2007 | par Balluche grâce à PHPXref 0.7 |