[ Index ] |
PHP Cross Reference of phpwcms V1.4.3 _r380 (23.11.09) |
[Summary view] [Print] [Text view]
1 <?php 2 /************************************************************************************* 3 Copyright notice 4 5 (c) 2002-2009 Oliver Georgi (oliver@phpwcms.de) // All rights reserved. 6 7 This script is part of PHPWCMS. The PHPWCMS web content management system is 8 free software; you can redistribute it and/or modify it under the terms of 9 the GNU General Public License as published by the Free Software Foundation; 10 either version 2 of the License, or (at your option) any later version. 11 12 The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html 13 A copy is found in the textfile GPL.txt and important notices to the license 14 from the author is found in LICENSE.txt distributed with these scripts. 15 16 This script is distributed in the hope that it will be useful, but WITHOUT ANY 17 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 18 PARTICULAR PURPOSE. See the GNU General Public License for more details. 19 20 This copyright notice MUST APPEAR in all copies of the script! 21 *************************************************************************************/ 22 23 // session_name('hashID'); 24 session_start(); 25 $phpwcms = array(); 26 27 require_once ('../../config/phpwcms/conf.inc.php'); 28 require_once ('../inc_lib/default.inc.php'); 29 require_once (PHPWCMS_ROOT.'/include/inc_lib/dbcon.inc.php'); 30 31 require_once (PHPWCMS_ROOT.'/include/inc_lib/general.inc.php'); 32 checkLogin(); 33 require_once (PHPWCMS_ROOT.'/include/inc_lib/backend.functions.inc.php'); 34 35 $ref = $_SESSION['REFERER_URL']; 36 $ftp["error"] = 0; 37 38 $ftp["mark"] = isset($_POST["ftp_mark"]) ? $_POST["ftp_mark"] : false; 39 $ftp["file"] = isset($_POST["ftp_file"]) ? $_POST["ftp_file"] : false; 40 41 if(is_array($ftp["mark"]) && count($ftp["mark"])) { 42 foreach($ftp["mark"] as $key => $value) { 43 if(intval($ftp["mark"][$key])) { 44 $ftp["file"][$key] = base64_decode($ftp["file"][$key]); 45 } else { 46 unset($ftp["mark"][$key]); 47 unset($ftp["file"][$key]); 48 } 49 } 50 if(!count($ftp["mark"])) $ftp["error"] = 1; 51 } else { 52 $ftp["error"] = 1; 53 } 54 55 ?> 56 <html> 57 <head><title>phpwcms: creating thumbnail</title> 58 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo PHPWCMS_CHARSET ?>"> 59 <meta http-equiv="Expires" content="0"> 60 <meta http-equiv="Pragma" content="no-cache"> 61 <meta http-equiv="cache-control" content="no-cache"> 62 <link href="../inc_css/phpwcms.css" rel="stylesheet" type="text/css"> 63 <style type="text/css"> 64 <!-- 65 body { background-color: #EBF2F4; } 66 --> 67 </style> 68 </head> 69 <body bgcolor="#EBF2F4" text="#000000" link="#000000" vlink="#000000" alink="#000000" leftmargin="15" topmargin="15" marginwidth="15" marginheight="15"> 70 <?php 71 if(!$ftp["error"]) { 72 73 $ext_mime_type = array ( 74 'hqx' => 'application/mac-binhex40', 75 'cpt' => 'application/mac-compactpro', 76 'doc' => 'application/msword', 77 'pdf' => 'application/pdf', 78 'ai' => 'application/postscript', 79 'eps' => 'application/postscript', 80 'ps' => 'application/postscript', 81 'bcpio' => 'application/x-bcpio', 82 'bz2' => 'application/x-bzip2', 83 'csh' => 'application/x-csh', 84 'gtar' => 'application/x-gtar', 85 'gz' => 'application/x-gzip', 86 'tgz' => 'application/x-gzip', 87 'kwd' => 'application/x-kword', 88 'kwt' => 'application/x-kword', 89 'ksp' => 'application/x-kspread', 90 'kpr' => 'application/x-kpresenter', 91 'kpt' => 'application/x-kpresenter', 92 'chrt' => 'application/x-kchart', 93 'latex' => 'application/x-latex', 94 'sh' => 'application/x-sh', 95 'shar' => 'application/x-shar', 96 'swf' => 'application/x-shockwave-flash', 97 'tar' => 'application/x-tar', 98 'tcl' => 'application/x-tcl', 99 'tex' => 'application/x-tex', 100 'texinfo' => 'application/x-texinfo', 101 'texi' => 'application/x-texinfo', 102 't' => 'application/x-troff', 103 'tr' => 'application/x-troff', 104 'roff' => 'application/x-troff', 105 'man' => 'application/x-troff-man', 106 'zip' => 'application/zip', 107 'mpga' => 'audio/mpeg', 108 'mp2' => 'audio/mpeg', 109 'mp3' => 'audio/mpeg', 110 'aif' => 'audio/x-aiff', 111 'aiff' => 'audio/x-aiff', 112 'aifc' => 'audio/x-aiff', 113 'wav' => 'audio/x-wav', 114 'gif' => 'image/gif', 115 'ief' => 'image/ief', 116 'jpeg' => 'image/jpeg', 117 'jpg' => 'image/jpeg', 118 'jpe' => 'image/jpeg', 119 'png' => 'image/png', 120 'tiff' => 'image/tiff', 121 'tif' => 'image/tiff', 122 'asc' => 'text/plain', 123 'txt' => 'text/plain', 124 'c' => 'text/plain', 125 'c++' => 'text/plain', 126 'pl' => 'text/plain', 127 'cc' => 'text/plain', 128 'h' => 'text/plain', 129 'sgml' => 'text/sgml', 130 'sgm' => 'text/sgml', 131 'xml' => 'text/xml', 132 'mpeg' => 'video/mpeg', 133 'mpg' => 'video/mpeg', 134 'mpe' => 'video/mpeg', 135 'avi' => 'video/x-msvideo', 136 'html' => 'text/html', 137 'htm' => 'text/html', 138 'rtf' => 'application/rtf', 139 'talk' => 'text/x-speech', 140 'css' => 'text/css', 141 'xbm' => 'image/x-xbitmap', 142 'xpm' => 'image/x-xpixmap', 143 'rgb' => 'image/rgb', 144 'g3f' => 'image/g3fax', 145 'xwd' => 'image/x-xwindowdump', 146 'pict' => 'image/x-pict', 147 'ppm' => 'image/x-portable-pixmap', 148 'pgm' => 'image/x-portable-graymap', 149 'pbm' => 'image/x-portable-bitmap', 150 'pnm' => 'image/x-portable-anymap', 151 'bmp' => 'image/x-ms-bmp', 152 'ras' => 'image/x-cmu-raster', 153 'pcd' => 'image/x-photo-cd', 154 'cgm' => 'image/cgm', 155 'mil' => 'image/x-cals', 156 'cal' => 'image/x-cals', 157 'fif' => 'image/fif', 158 'dsf' => 'image/x-mgx-dsf', 159 'cmx' => 'image/x-cmx', 160 'wi' => 'image/wavelet', 161 'dwg' => 'image/x-dwg', 162 'dxf' => 'image/x-dxf', 163 'svf' => 'vector/x-svf', 164 'au' => 'audio/basic', 165 'snd' => 'audio/basic', 166 'mpa' => 'audio/x-mpeg', 167 'abs' => 'audio/x-mpeg', 168 'mpega' => 'audio/x-mpeg', 169 'mp2a' => 'audio/x-mpeg-2', 170 'mpa2' => 'audio/x-mpeg-2', 171 'es' => 'audio/echospeech', 172 'vox' => 'audio/voxware', 173 'lcc' => 'application/fastman', 174 'ra' => 'application/x-pn-realaudio', 175 'ram' => 'application/x-pn-realaudio', 176 'mmid' => 'x-music/x-midi', 177 'mid' => 'x-music/x-midi', 178 'skp' => 'application/x-koan', 179 'mpv2' => 'video/mpeg-2', 180 'mp2v' => 'video/mpeg-2', 181 'qt' => 'video/quicktime', 182 'mov' => 'video/quicktime', 183 'video' => 'video/x-msvideo', 184 'movie' => 'video/x-sgi-movie', 185 'vdo' => 'video/vdo', 186 'viv' => 'video/vivo', 187 'pac' => 'application/x-ns-proxy-autoconfig', 188 'ice' => 'x-conference/x-cooltalk', 189 'pdf' => 'application/pdf', 190 'mif' => 'application/x-mif', 191 'me' => 'application/x-troff-me', 192 'ms' => 'application/x-troff-ms', 193 'dvi' => 'application/x-dvi', 194 'dot' => 'application/msword', 195 'wp' => 'application/wordperfect5.1', 196 'oda' => 'application/oda', 197 'evy' => 'application/envoy', 198 'fm' => 'application/x-framemaker', 199 'frm' => 'application/x-framemaker', 200 'frame' => 'application/x-framemaker', 201 'ustar' => 'application/x-ustar', 202 'cpio' => 'application/x-cpio', 203 'sit' => 'application/x-stuffit', 204 'sea' => 'application/x-stuffit', 205 'bin' => 'application/octet-stream', 206 'uu' => 'application/octet-stream', 207 'exe' => 'application/octet-stream', 208 'dll' => 'application/octet-stream', 209 'com' => 'application/octet-stream', 210 'src' => 'application/x-wais-source', 211 'wsrc' => 'application/x-wais-source', 212 'hdf' => 'application/hdf', 213 'js' => 'text/javascript', 214 'ls' => 'text/javascript', 215 'mocha' => 'text/javascript', 216 'vbs' => 'text/vbscript', 217 'sh' => 'application/x-sh', 218 'csh' => 'application/x-csh', 219 'ppt' => 'application/mspowerpoint', 220 'axs' => 'application/x-olescript', 221 'xls' => 'application/msexcel', 222 '3dmf' => 'x-world/x-3dmf', 223 'dwf' => 'drawing/x-dwf', 224 'php' => 'text/plain', 225 'phps' => 'text/plain', 226 'rtx' => 'text/richtext' 227 ); 228 229 $ftp["dir"] = intval($_POST["file_dir"]); 230 $ftp["short_info"] = clean_slweg($_POST["file_shortinfo"]); 231 232 $ftp["aktiv"] = empty($_POST["file_aktiv"]) ? 0 : 1; 233 $ftp["public"] = empty($_POST["file_public"]) ? 0 : 1; 234 $ftp["replace"] = empty($_POST["file_replace"]) ? 0 : 1; 235 $ftp["long_info"] = clean_slweg($_POST["file_longinfo"]); 236 $ftp["copyright"] = clean_slweg($_POST["file_copyright"]); 237 $ftp["tags"] = trim( trim( clean_slweg($_POST["file_tags"]), ',') ); 238 239 $ftp["keywords"] = isset($_POST["file_keywords"]) ? $_POST["file_keywords"] : array(); 240 $ftp["keys"] = ""; 241 if(is_array($ftp["keywords"]) && count($ftp["keywords"])) { 242 foreach($ftp["keywords"] as $key => $value) { 243 unset($ftp["keywords"][$key]); 244 $key = intval($key); 245 if($value != "0_1") { 246 $ftp["keys"] .= (($ftp["keys"]) ? ":" : "").$key."_".intval($value); 247 $ftp["keywords"][$key] = intval($value); 248 } else { 249 $file_error["keywords"][$key] = 1; 250 } 251 } 252 } 253 254 255 ?><p><img src="../../img/symbole/rotation.gif" alt="" width="15" height="15"><strong class="title"> selected files uploaded via ftp will be taken over!</strong></p><?php 256 257 echo "<p class=\"v10\">"; 258 flush(); 259 260 foreach($ftp["mark"] as $key => $value) { 261 if(!ini_get('safe_mode') && function_exists('set_time_limit')) set_time_limit(60); 262 263 $file = $ftp["file"][$key]; 264 $file_path = PHPWCMS_ROOT.$phpwcms["ftp_path"].$file; 265 if(file_exists($file_path)) { 266 267 $file_type = ''; 268 $file_error["upload"] = 0; 269 $file_size = filesize($file_path); 270 271 $file_ext = check_image_extension($file_path); 272 $file_ext = (false === $file_ext) ? which_ext($file) : $file_ext; 273 274 $file_name = clearfilename( PHPWCMS_CHARSET != 'utf-8' && seems_utf8($file) ? utf8_decode($file) : $file); 275 $file_hash = md5( $file_name . microtime() ); 276 277 278 if(!trim($file_type)) { 279 280 //check file_type 281 if($ext_mime_type[$file_ext]) { 282 $file_type = $ext_mime_type[$file_ext]; 283 } else { 284 $file_check = getimagesize($file_path); 285 if(version_compare("4.3.0", phpversion(), ">=") && $file_check) { 286 $file_type = image_type_to_mime_type($file_check[2]); 287 } 288 if(!trim($file_type)) { 289 $file_type = 'application/force-download'; 290 } 291 } 292 293 } 294 295 $sql = "INSERT INTO ".DB_PREPEND."phpwcms_file (". 296 "f_pid, f_uid, f_kid, f_aktiv, f_public, f_name, f_created, f_size, f_type, f_ext, ". 297 "f_shortinfo, f_longinfo, f_keywords, f_hash, f_copyright, f_tags) VALUES (". 298 $ftp["dir"].", ".intval($_SESSION["wcs_user_id"]).", 1, ".$ftp["aktiv"].", ".$ftp["public"].", '". 299 aporeplace($file_name)."', '".time()."', '".$file_size."', '".aporeplace($file_type)."', '". 300 aporeplace($file_ext)."', '".aporeplace($ftp["short_info"])."', '". 301 aporeplace($ftp["long_info"])."', '".$ftp["keys"]."', '".$file_hash."', '". 302 aporeplace($ftp["copyright"])."', '".aporeplace($ftp["tags"])."')"; 303 304 if($result = mysql_query($sql, $db) or die("error while insert file information")) { 305 $new_fileId = mysql_insert_id($db); //Festlegen der aktuellen File-ID 306 307 $_file_extension = ($file_ext) ? '.'.$file_ext : ''; 308 $wcs_newfilename = $file_hash . $_file_extension; 309 310 // changed for using hashed file names 311 $userftppath = PHPWCMS_ROOT.$phpwcms["ftp_path"]; 312 $useruploadpath = PHPWCMS_ROOT.$phpwcms["file_path"]; 313 $usernewfile = $useruploadpath.$wcs_newfilename; 314 315 316 $oldumask = umask(0); 317 318 if ($dir = @opendir($useruploadpath)) { 319 if(@copy($userftppath.$file, $usernewfile)) { 320 321 @unlink($userftppath.$file); 322 323 // store tags 324 _dbSaveCategories($ftp["tags"], 'file', $new_fileId, ','); 325 326 } else { 327 $file_error["upload"] = "Error while writing file to storage (1)."; 328 } 329 } 330 } 331 332 if(empty($file_error["upload"])) { 333 334 // now try to find 1st file having same named and replace it if related mark is set 335 if($ftp["replace"]) { 336 337 $rsql = "SELECT * FROM ".DB_PREPEND."phpwcms_file WHERE "; 338 $rsql .= "f_name='".aporeplace($file_name)."' AND f_kid=1 "; 339 $rsql .= "AND f_pid=".$ftp["dir"]." AND f_trash=0 AND f_id != ".$new_fileId." LIMIT 1"; 340 if($rresult = mysql_query($rsql, $db)) { 341 342 if($rrow = mysql_fetch_assoc($rresult)) { 343 344 $oldFileID = $rrow['f_id']; 345 $oldFileHash = $rrow['f_hash']; 346 $oldFileNewHash = md5( $file_name . microtime() . time() ); 347 348 // now update new file by old file information of same named 349 $nsql = "UPDATE ".DB_PREPEND."phpwcms_file SET "; 350 $nsql .= "f_refid=".$oldFileID.", f_trash=5, f_size=".$rrow['f_size'].', '; 351 $nsql .= "f_type='".$rrow['f_type']."', f_changed=".now().', '; 352 $nsql .= "f_hash='".aporeplace($oldFileNewHash)."' WHERE f_id=".$new_fileId; 353 354 if(mysql_query($nsql, $db)) { 355 356 // yepp both files are updated in db 357 // now change hash of file storage files 358 rename($useruploadpath.$oldFileHash.$_file_extension, $useruploadpath.$oldFileNewHash.$_file_extension); 359 rename($usernewfile, $useruploadpath.$oldFileHash.$_file_extension); 360 361 // update file size of old file with new filesize 362 _dbUpdate('phpwcms_file', array('f_type'=>$file_type, 'f_size'=>$file_size, 'f_changed'=>now()), 'f_id='.$oldFileID); 363 364 //now try to delete all temp images if available 365 $isql = "SELECT imgcache_imgname FROM ".DB_PREPEND."phpwcms_imgcache WHERE imgcache_hash='".aporeplace($oldFileHash)."'"; 366 if($iresult = mysql_query($isql, $db)) { 367 $cImagePath = PHPWCMS_ROOT . '/' . PHPWCMS_IMAGES; 368 while($irow = mysql_fetch_row($iresult)) { 369 if(file_exists($cImagePath.$irow[0])) { 370 @unlink($cImagePath.$irow[0]); 371 } 372 } 373 } 374 } 375 } 376 mysql_free_result($rresult); 377 378 } 379 380 381 } 382 383 flush(); 384 echo $file." [OK!]<br />"; 385 } else { 386 echo $file." (".$file_error["upload"].")<br />"; 387 mysql_query("DELETE FROM ".DB_PREPEND."phpwcms_file WHERE f_id=".$new_fileId." AND f_uid=".$_SESSION["wcs_user_id"], $db); 388 } 389 390 } else { 391 echo $file." not exists<br />"; 392 } 393 flush(); 394 } 395 echo "</p>\n"; 396 } 397 398 if(empty($file_error["upload"]) && empty($ftp["error"])) { 399 echo "<p class=\"title\"><strong>every selected file was taken over</strong></p>\n"; 400 echo "<p class='v10'><a href=\"".$ref."\" style=\"font-weight: bold;\">click here to go back</a> (if no automatic redirect)</p>\n"; 401 echo "<script language=\"JavaScript\" type=\"text/javascript\">\n<!--\n"; 402 echo "window.location.href = \"".$ref."\";\n//-->\n</script>\n"; 403 404 } else { 405 echo "<p class=\"error\"><strong>error while file take over</strong></p>\n"; 406 echo "<p class='v10'><a href=\"".$ref."\" style=\"font-weight: bold;\">click here to go back</a></p>\n"; 407 } 408 echo "</body>\n</html>\n"; 409 410 411 if(isset($oldumask)) { 412 umask($oldumask); 413 } 414 415 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Dec 30 05:55:15 2009 | Cross-referenced by PHPXref 0.7 |