Torna indietro   Hardware Upgrade Forum > Software > Programmazione

Dreame X60 Pro Ultra Complete: i bracci si estendono sempre di più
Dreame X60 Pro Ultra Complete: i bracci si estendono sempre di più
Dreame X60 Pro Ultra Complete implementa due bracci estensibili, per spazzola e moccio, che si spingono ben oltre quanto visto sino ad oggi permettendo una pulizia di casa ancor più capillare e precisa
TCL 65C8L, la recensione del SQD-Mini LED da 4400 nit misurati
TCL 65C8L, la recensione del SQD-Mini LED da 4400 nit misurati
La tecnologia SQD-Mini LED di TCL arriva sul taglio da 65 pollici con la serie C8L: 2040 zone, pannello WHVA 2.0 e un picco che alle rilevazioni delle sonde tocca i 4400 nit nel profilo Filmmaker e un HDR quasi perfetto
MSI Maestro 500 Wireless: ANC e 90 ore di autonomia a 70 euro
MSI Maestro 500 Wireless: ANC e 90 ore di autonomia a 70 euro
Wireless 2.4 GHz, Bluetooth 5.4, cancellazione attiva del rumore, design pieghevole e un'autonomia che mette in imbarazzo prodotti che costano il doppio. Le Maestro 500 non eccellono in nulla, ma offrono tutto. E a questo prezzo è difficile chiedere di più
Tutti gli articoli Tutte le news

Vai al Forum
Rispondi
 
Strumenti
Old 06-10-2006, 21:58   #1
Gnappoide
Senior Member
 
L'Avatar di Gnappoide
 
Iscritto dal: Aug 2002
Città: Repubblica Della Serenissima (VENEZIA)
Messaggi: 660
Formmail con allegato

Ciao a tutti,
avrei bisogno di un consiglio su uno script in php che mandi una mail (ad un destinatario predefinito) con la possibilità di allegare un file da un sito.
Lo so che ce ne sono molti in giro, io ne usavo uno che faceva un controllo sui campi, sulla validità dell'indirizzo mail, sul limite della grandezza del file e sulla sua estensione.
Andavo tanto bene, solo che mi funzionava a meraviglia con altervista.
Dopo che ho cambiato hosting, adesso mi arrivano le mail con l'allegato che pesa 0kb..
Gnappoide è offline   Rispondi citando il messaggio o parte di esso
Old 07-10-2006, 14:06   #2
Pappe
Senior Member
 
L'Avatar di Pappe
 
Iscritto dal: Nov 2005
Città: Parma GialloBlu
Messaggi: 450
potresti allegare quello che usavi per modificarlo..
__________________


Dell Latitude E6420 @ Windows 7 Pro
ASUS A6Ja-Q039H @ Windows 7 Pro
Pappe è offline   Rispondi citando il messaggio o parte di esso
Old 07-10-2006, 17:13   #3
Gnappoide
Senior Member
 
L'Avatar di Gnappoide
 
Iscritto dal: Aug 2002
Città: Repubblica Della Serenissima (VENEZIA)
Messaggi: 660
Hai ragione scusa

Codice:
function get_ext($key) {
    $key=strtolower(substr(strrchr($key, "."), 1));
    // Cause there the same right?
    $key=str_replace("jpeg","jpg",$key);
    return $key;
}

function phattach($file,$name) {
    global $boundary;
    
    $fp=@fopen($file,"r");
    $str=@fread($fp, filesize($file));
    $str=@chunk_split(base64_encode($str));
    $message="--".$boundary."\n";
    $message.="Content-Type: application/octet-stream; name=\"".$name."\"\n";
    //$message.="Content-disposition: attachment\n"; Thanks goes to someone named Chris (I think, it was awhile ago) for his fix below!
    $message.="Content-disposition: attachment; filename=\"".$name."\"\n";
    $message.="Content-Transfer-Encoding: base64\n";
    $message.="\n";
    $message.="$str\n";
    $message.="\n";

    return $message;
}

//Little bit of security from people forging headers. People are mean sometimes :(
function clean($key) {
    $key=str_replace("\r", "", $key);
    $key=str_replace("\n", "", $key);
    $find=array(
        "/bcc\:/i",
        "/Content\-Type\:/i",
        "/Mime\-Type\:/i",
        "/cc\:/i",
        "/to\:/i"
    );
  $key=preg_replace($find,"",$key);
  return $key;
}

// Safe for register_globals=on =)

$error="";
$types="";
$sent_mail=false;

// Do some loopy stuff for the valid file types so people can see what types are valid before they try and upload invalid ones.

$ext_count=count($allowtypes);
$i=0;

foreach($allowtypes AS $extension) {
    
    //Gets rid of the last comma
    
    If($i <= $ext_count-2) {
        $types .="*.".$extension.", ";
    } Else {
        $types .="*.".$extension;
    }
    $i++;
}
unset($i,$ext_count); // why not


// If they post the form start the mailin'!

If($_POST['submit']==true) {
    extract($_POST, EXTR_SKIP);

        // Check the form for errors
    
        If(trim($yourname)=="") {
            $error.="Non hai inserito il tuo nome e cognome.<br />";
        }
        
        If(trim($youremail)=="") {
            $error.="Non hai inserito il tuo indirizzo email.<br />";
        } Elseif(!eregi("^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}\$",$youremail)) {
            $error.="Invalid email address.<br />";
        }

        If(trim($emailsubject)=="") {
            $emailsubject=$defaultsubject;
        }

        If(trim($yourmessage)=="") {
            $error.="Non hai inserito un messaggio.<br />";
        }
        
        // Verify Attachment info
        
        If($allowattach > 0) {
            
            //Loopish
            
            For($i=0; $i <= $allowattach-1; $i++) {
                
                If($_FILES['attachment']['name'][$i]) {
                    
                    $ext=get_ext($_FILES['attachment']['name'][$i]);
                    $size=$_FILES['attachment']['size'][$i];
                    $max_bytes=$max_file_size*1024;
                    
                    //Check if the file type uploaded is a valid file type.
                    
                    If(!in_array($ext, $allowtypes)) {
                        
                        $error.= "Estensione del file allegato non valida: ".$_FILES['attachment']['name'][$i].", puoi allegare solo files in ".$types." Grazie.<br />";
                        
                        //Check the size of each file
                        
                    } Elseif($size > $max_bytes) {
                        $error.= "Il tuo: ".$_FILES['attachment']['name'][$i]." è troppo grande. Puoi allegare files grandi al massimo ".$max_file_size."kb.<br />";
                    }
                    
                } // If Files
                
            } // For

            //Tally the size of all the files uploaded, check if it's over the ammount.
            
              $total_size=array_sum($_FILES['attachment']['size']);
              
            $max_file_total_bytes=$max_file_total*1024;
            
            If($total_size > $max_file_total_bytes) {
                $error.="Puoi allegare files grandi al massimo ".$max_file_total."kb<br />";
            }
            
        } // If Allowattach

    If($error) {
    
        $display_message=$error;

    } Else {
        
        If($use_subject_drop AND is_array($subjects) AND is_array($emails)) {
            $subject_count=count($subjects);
            $email_count=count($emails);
            
            If($subject_count==$email_count) {
                
                $myemail=$emails[$emailsubject];
                $emailsubject=$subjects[$emailsubject];
                
            }
            
        }
        
        
        $boundary=md5(uniqid(time()));
        
        //Little bit of security from people forging headers. People are mean sometimes :(
        
        $yourname=clean($yourname);
        $yourmessage=clean($yourmessage);
        $youremail=clean($youremail);
        
        //Headers
        
        $headers="From: ".$yourname." <".$youremail.">\n";
        $headers.="Reply-To: ".$yourname." <".$youremail.">\n";
        $headers.="MIME-Version: 1.0\n";
        $headers.="Content-Type: multipart/mixed; boundary=\"".$boundary."\"\n";
        $headers.="X-Sender: ".$_SERVER['REMOTE_ADDR']."\n";
        $headers.="X-Mailer: PHP/".phpversion()."\n";
        $headers.="X-Priority: ".$priority."\n";
        $headers.="Return-Path: <".$youremail.">\n";
        $headers.="This is a multi-part message in MIME format.\n";

        //Message
            
        $message = "--".$boundary."\n";
        $message.="Content-Type: text/plain; charset=\"iso-8859-1\"\n";
        $message.="Content-Transfer-Encoding: quoted-printable\n";
        $message.="\n";
        $message.="$yourmessage";
        $message.="\n";

        //Lets attach to something! =)
        
        If($allowattach > 0) {
            
            For($i=0; $i <= $allowattach-1; $i++) {
                
                If($_FILES['attachment']['name'][$i]) {
                    
                    $message.=phattach($_FILES['attachment']['tmp_name'][$i],$_FILES['attachment']['name'][$i]);
                    
                }
                
            } //For
            
        } // If
        
        
        // End the message
        
        $message.="--".$boundary."--\n";
        
        // Send the completed message
        
        If(!mail($myemail,$emailsubject,$message,$headers)) {
            
            Exit("Attenzione, è avvenuto un errore. \n");
            
        } Else {
        
            $sent_mail=true;
            
        }

    } // Else

} // $_POST
Manca tutta la parte iniziale dove dice che il codice è del tizio, ect..ect..ect..
Gnappoide è offline   Rispondi citando il messaggio o parte di esso
 Rispondi


Dreame X60 Pro Ultra Complete: i bracci si estendono sempre di più Dreame X60 Pro Ultra Complete: i bracci si esten...
TCL 65C8L, la recensione del SQD-Mini LED da 4400 nit misurati TCL 65C8L, la recensione del SQD-Mini LED da 440...
MSI Maestro 500 Wireless: ANC e 90 ore di autonomia a 70 euro MSI Maestro 500 Wireless: ANC e 90 ore di autono...
NL-LC1 è il primo dissipatore a liquido AIO di Noctua: silenzio è la parola d'ordine NL-LC1 è il primo dissipatore a liquido A...
Boox Go 10.3 (Gen II) Lumi: il tablet e-ink con Android 15 e penna, dal prezzo super Boox Go 10.3 (Gen II) Lumi: il tablet e-ink con ...
NVIDIA mostra una comunità di rob...
Sony annuncia LYTIA L910, arriva il sens...
Ericsson, il 5G è l’infrastruttur...
Marvell punta tutto su TSMC A14: sar&agr...
Hyundai a un passo dal controllo totale ...
Questo SSD vecchio 16 anni ha resistito ...
Monopattino elettrico Xiaomi in offerta:...
Microsoft usa le capre di Age of Empires...
Microsoft conferma bug nel Cestino in tu...
Accenture crolla del 20% in borsa, il pe...
ASUS Pro WS W890E-SAGE SE: sette PCIe 5....
Attenzione al prezzo di questa TV Hisens...
Chrome sbeffeggiato da Ballmer nel 2009:...
Un gioco Mac compatibile con Apple Silic...
La batteria allo stato solido di Honda s...
Chromium
GPU-Z
OCCT
LibreOffice Portable
Opera One Portable
Opera One 106
CCleaner Portable
CCleaner Standard
Cpu-Z
Driver NVIDIA GeForce 546.65 WHQL
SmartFTP
Trillian
Google Chrome Portable
Google Chrome 120
VirtualBox
Tutti gli articoli Tutte le news Tutti i download

Strumenti

Regole
Non Puoi aprire nuove discussioni
Non Puoi rispondere ai messaggi
Non Puoi allegare file
Non Puoi modificare i tuoi messaggi

Il codice vB è On
Le Faccine sono On
Il codice [IMG] è On
Il codice HTML è Off
Vai al Forum


Tutti gli orari sono GMT +1. Ora sono le: 06:14.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Served by www3v