Ver Mensaje Individual
  #6 (permalink)  
Antiguo 31/01/2008, 10:59
michi122513
Invitado
 
Mensajes: n/a
Puntos:
Re: Ayuda para convertir funcion

Problema solucionado, contacte con un usuario del script y me dio la solucion:

Código PHP:
<?php
    
/*
    *
    * Mihalism multi host v3.1.x                      
    * Copyright (c) 2005 - 2007 Mihalism Inc (www.mihalism.com)
    *
    */
    
require_once('./page_header.php');

    
$file_count 0;
    
$path       $CONFIG['file_path'];

    switch(
$_POST['type']){
        case 
'url_upload':
            
url_upload();
            break;
        default:
            
direct_upload();
    }

    function 
url_upload(){
        global 
$CONFIG$DB$UDATA$file_count$path$filename;
        for(
$i 0$i <= 15$i++){
            
$file = array(
                
'name'  => $_POST['userfile'][$i],
                
//'name'  => array_shift(explode('?', basename($_POST['userfile'][$i]))),
                
'url'   => $_POST['userfile'][$i],
                
'rand'  => random_string(20)
            );
            if(
$file['name'] != ''){
                
$file_count++;
                if(
$file_count <= 15){
                    if(
$i >= 1){
                        echo 
"<div class='cell_divider'></div><br>\n";
                    }
                    
//var_dump($_POST['userfile'][$i] );
                    
$extension file_type($file['name']);
                    
$filename  $file['rand'].".".$extension;
                    
$thumbnail thumbnail_name($filename);
                    if(!
preg_match("/(https|http|ftp):\/\/[^\"\s']+/"$file['url'])){
                        
message("The file <b>{$file['name']}</b> contains a invalid URL.");
                    }elseif(!
in_array($extension$CONFIG['file_types'])){
                        
message("The file <b>{$file['name']}</b> extension is not allowed.");
                    }elseif(!
$fcc cupload($file['name'])){
                        
message("The file <b>{$file['name']}</b> is not readable or does not exists.");
                    }elseif(
strlen($fcc) > $CONFIG['max_file_size']){
                        
message("The file <b>{$file['name']}</b> exceeds the max file size allowed.");
                    }elseif(
strlen($fcc) < 500){
                        
message("The file <b>{$file}</b> contains no data.");
                    }elseif(
file_exists(ROOT_PATH.$path.$filename) !== false){
                        
message("The file <b>{$file['name']}</b> seems to already exists on this server.");
                    }elseif(!
fwrite(fopen($path.$filename'x'), $fcc)){
                        
message("File transfer failed for file <b>{$file['name']}</b>.");
                    }else{
                        if(
$CONFIG['is_user'] == true){
                            
$DB->query("INSERT INTO `".SQL_FILE_STORAGE_TABLE."` VALUES('', '{$filename}', '0', '{$UDATA['user_id']}');");
                        }else{
                            
$DB->query("INSERT INTO `".SQL_FILE_STORAGE_TABLE."` VALUES('', '{$filename}', '{$_POST['private']}', '0');");
                        }
                        
$DB->query("INSERT INTO `".SQL_FILE_LOGS_TABLE."` VALUES ('', '{$filename}', '".time()."', '{$_SERVER['REMOTE_ADDR']}');");
                        
create_thumbnail($filename);
                        
results_table();
                    }
                }
            }
        }
    }

    function 
cupload($image_url){
        
$ch curl_init();
        
$timeout 0;
        
curl_setopt ($chCURLOPT_URL$image_url);
        
curl_setopt ($chCURLOPT_CONNECTTIMEOUT$timeout);

        
// Getting binary data
        
curl_setopt($chCURLOPT_RETURNTRANSFER1);
        
curl_setopt($chCURLOPT_BINARYTRANSFER1);

        
$image curl_exec($ch);
        
curl_close($ch);

        return 
$image;
    }

    function 
direct_upload(){
        global 
$CONFIG$DB$UDATA$file_count$path$filename;
        for(
$i 0$i <= 15$i++){
            
$file = array(
                
'name'  => $_FILES['userfile']['name'][$i],
                
'size'  => $_FILES['userfile']['size'][$i],
                
'tmp'   => $_FILES['userfile']['tmp_name'][$i],
                
'error' => $_FILES['userfile']['error'][$i],
                
'rand'  => random_string(20)
            );
            if(
$file['error'] != && $file['name'] != ''){
                
$file_count++;
                if(
$file_count <= 15){
                    if(
$i >= 1){
                        echo 
"<div class='cell_divider'></div><br>\n";
                    }
                    
$extension file_type($file['name']);
                    
$filename  $file['rand'].".".$extension;
                    
$thumbnail thumbnail_name($filename);
                    if(!
in_array($extension$CONFIG['file_types'])){
                        
message("The file {$file['name']}</b> extension is not allowed.");
                    }elseif(
$file['size'] > $CONFIG['max_file_size']){
                        
message("The file <b>{$file['name']}</b> exceeds the max file size allowed.");
                    }elseif(
$file['error'] != 0){
                        
$filerror = array(            
                            
=> "The file <b>{$file['name']}</b> exceeds the <a href=\"http://us2.php.net/manual/en/ini.core.php#ini.upload-max-filesize\">upload_max_filesize</a> directive in php.ini.",
                            
=> "The file <b>{$file['name']}</b> exceeds the <b><i>MAX_FILE_SIZE</i></b> directive that was specified in the HTML form.",
                            
=> "The file <b>{$file['name']}</b> was only partially uploaded.",
                            
=> "Missing a temporary folder.",
                            
=> "Failed to write file <b>{$file['name']}</b> to disk.",
                            
=> "File <b>{$file['name']}</b> upload stopped by extension."
                                
);
                        
message($filerror[$file['error']]);
                    }elseif(
file_exists(ROOT_PATH.$path.$filename)){
                        
message("The file <b>{$file['name']}</b> seems to already exists on this server.");
                    }elseif(!
move_uploaded_file($file['tmp'], ROOT_PATH.$path.$filename)){
                        
message("File upload failed for file <b>{$file['name']}</b>.");
                    }else{
                        if(
$CONFIG['is_user'] == true){
                            
$DB->query("INSERT INTO `".SQL_FILE_STORAGE_TABLE."` VALUES('', '{$filename}', '0', '{$UDATA['user_id']}');");
                        }else{
                            
$DB->query("INSERT INTO `".SQL_FILE_STORAGE_TABLE."` VALUES('', '{$filename}', '{$_POST['private']}', '0');");
                        }
                        
$DB->query("INSERT INTO `".SQL_FILE_LOGS_TABLE."` VALUES ('', '{$filename}', '".time()."', '{$_SERVER['REMOTE_ADDR']}');");
                        
create_thumbnail($filename);
                        
results_table();
                    }
                }
            }
        }
    }

    if(
$file_count == 0){
        
message("Please go back and ".(($_POST['type'] != 'url_upload') ? 'select' 'enter')." at least one file to upload.");
    }

    require_once(
'./page_footer.php');
?>
Muchas gracias por toda la ayuda GatorV
PD: disculpen por el doble post