| | Copyright: copyright (C) 2004 by Mike de Boer | | Description: zOOm Image Gallery, a multi-gallery component for | | Mambo based on RSGallery by Ronald Smit. It's the most | | feature-rich gallery component for Mambo! | | Filename: upl_scan.php | | Version: 2.0 | | | ----------------------------------------------------------------------- **/ // MOS Intruder Alerts defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); if(array_key_exists('uls', $_REQUEST)) $urls = $_REQUEST['urls']; if ($urls){ $setFilename = $_REQUEST['setFilename']; $imgname = $_REQUEST['imgname']; $keywords = $_REQUEST['keywords']; $descr = $_REQUEST['descr']; $zoom->createCheckAllScript(); if (!$catid){ ?> "._ZOOM_SCAN_STEP2_DESCR1." $url "._ZOOM_SCAN_STEP2_DESCR2."

"; $handle = fs_opendir($theUrl); while (($file = readdir($handle)) != false) { if ($file != "." && $file != "..") { $tag = ereg_replace(".*\.([^\.]*)$", "\\1", $file); $tag = strtolower($tag); if ($zoom->acceptableFormat($tag)) { /* Tack it onto userfile */ $userfile_name[] = $file; if (substr($url,-1) == "/") { $userfile[] = fs_export_filename($url . $file); } else { $userfile[] = fs_export_filename($url . "/" . $file); } } } } closedir($handle); }else{ // Get rid of any preceding whitespace (fix for odd browsers like konqueror) $url = eregi_replace("^[[:space:]]+", "", $url); // If the URI doesn't start with a scheme, prepend 'http://' if (!fs_is_file($url)) { if (!ereg("^(http|ftp)", $url)) { $url = "http://$url"; } } /* Parse URL for name and file type */ $url_stuff = parse_url($url); $name = basename($url_stuff["path"]); $tag = ereg_replace(".*\.([^\.]*)$", "\\1", $url); $tag = strtolower($tag); //Dont output warning messages if we cant open url /* * Try to open the url in lots of creative ways. * Do NOT use fs_fopen here because that will pre-process * the URL in win32 style (ie, convert / to \, etc). */ $id = @fopen($url, "rb"); if (!ereg("http", $url)) { if (!$id) $id = @fopen("http://$url", "rb"); if (!$id) $id = @fopen("http://$url/", "rb"); } if (!$id) $id = @fopen("$url/", "rb"); if ($id) { echo '

' . _ZOOM_A_MESS_PROCESSING_FILE . ' ' . urldecode($url) . '

'; } else { echo '

' . _ZOOM_A_MESS_NOTOPEN_URL. ' "'. $url . '"

'; continue; } // copy file locally $file = $mosConfig_absolute_path . "/media/photo.$name"; $od = fs_fopen($file, "wb"); if ($id && $od) { while (!feof($id)) { fwrite($od, fread($id, 65536)); } fclose($id); fclose($od); } // Make sure we delete this file when we're through... $temp_files[$file]++; // If this is an image - add it to the processor array if ($zoom->acceptableFormat($tag)) { // Tack it onto userfile $userfile_name[] = $name; $userfile[] = $file; } else { // Slurp the file echo '

' . sprintf( _ZOOM_A_MESS_PARSE_URL, $url ) . '

'; $fd = fs_fopen ($file, "r"); $contents = fread ($fd, fs_filesize ($file)); fclose ($fd); // We'll need to add some stuff to relative links $base_url = $url_stuff["scheme"] . '://' . $url_stuff["host"]; $base_dir = ''; if ($url_stuff["port"]) { $base_url .= ':' . $url_stuff["port"]; } // Hack to account for broken dirname if (ereg("/$", $url_stuff["path"])) { $base_dir = $url_stuff["path"]; } else { $base_dir = dirname($url_stuff["path"]); } // Make sure base_dir ends in a / ( accounts for empty base_dir ) if (!ereg("/$", $base_dir)) { $base_dir .= '/'; } $things = array(); while ($cnt = eregi('(src|href)="?([^" >]+\.$zoom->acceptableFormatRegexp())[" >]', $contents, $results)) { $things[$results[2]]++; $contents = str_replace($results[2], "", $contents); $userfile_name[] = $results[2]; } // Add each unique link to an array we scan later foreach (array_keys($things) as $thing) { /* * Some sites (slashdot) have images that start with // and this * confuses Gallery. Prepend 'http:' */ if (!strcmp(substr($thing, 0, 2), "//")) { $thing = "http:$thing"; } // Absolute Link ( http://www.foo.com/bar ) if (substr($thing, 0, 4) == 'http') { $userfile[] = $thing; // Relative link to the host ( /foo.bar ) } elseif (substr($thing, 0, 1) == '/') { $userfile[] = $base_url . $thing; // Relative link to the dir ( foo.bar ) } else { $userfile[] = $base_url . $base_dir . $thing; } } }// END if is-image? }// END if is_dir? if(sizeof($userfile) > 0){ ?>

.php?option=com_zoom&Itemid=&page=upload&formtype=scan"> createFileList($userfile); ?>

_counter = 0; foreach($userfile as $file){ $name = $userfile_name[$zoom->_counter]; ?> _counter++; } if(isset($setFilename)) echo ''; else echo ''; ?>
'. _ZOOM_NOIMG . '

'; }// END if userfiles found? echo '

' . count($userfile) . ' ' . _ZOOM_ALERT_IMGFOUND . '

'; }// END foreach urls... }elseif($scannedimg){ // Now, finally, it's time to start uploading... echo '

'._ZOOM_SCAN_STEP3.'

'; $i = 0; foreach($scannedimg as $image){ $filename = urldecode($userfile_name[$image]); // Get the actual image (with path and everything)... if(!fs_is_file($userfile[$image])) $theImage = $mosConfig_absolute_path."/".$userfile[$image]; else $theImage = $userfile[$image]; if (!empty($usercaption) && is_array($usercaption)) $caption = $zoom->removeTags(array_shift($usercaption)); if(!$descr) $descr = $zoom->_CONFIG['tempDescr']; if (isset($setFilename)) $name = $filename; else $name = $imgname; if($rotate[$image]){ $key = "rotate$i"; $degrees = $_REQUEST[$key]; $rotatelt = $rotate[$image]; } if($zoom->_toolbox->processImage($theImage, $filename, $keywords, $name, $descr, $rotatelt, $degrees, 2)) $i++; } // end of foreach-loop if($zoom->_toolbox->_err_num > 0) $zoom->_toolbox->displayErrors($err_num, $err_names, $err_types); echo '

' . $i . ' ' . _ZOOM_ALERT_UPLOADSOK . '

'; }else{ // Display form... $zoom->createFormControlScript("scan_form"); ?>
.php?option=com_zoom&Itemid=&page=upload&formtype=scan"> added by mic if( ini_get( 'safe_mode' ) == 1 ){ ?>
 
 
 

 
createCatDropdown('catid', '');?>
 
 
 
_CONFIG['autonumber']){ echo " "; ?>   _CONFIG['autonumber']) echo " checked";?> />
 
 
 
$junk) { fs_unlink($tf); } } ?>