Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    Come personalizzare lo script di Leonardo Arteconi?

    AIUTO!! Esperti di html, non conosco molto ben il php.
    Devo far passare per questo script alcuni campi tipo "nome", cognome, indirizzo e un messaggo di testo. Dove devo porre le modifiche per aggiungere le variabili?
    L'unica variabile attiva nel form è email. Ma se ne devo aggiungere di nuove da passare dove devo mettere le mani nello script? Ve ne metto una prima parte intanto...

    Saluti e grazie a tutti!!


    <?php

    .... codice mancante...

    class html_mime_mail{

    var $headers;
    var $body;
    var $multipart;
    var $mime;
    var $parts = array();

    function html_mime_mail($headers = ''){
    $this->headers = $headers;
    }

    function add_attachment($file, $name = '', $c_type = 'application/octet-stream'){
    $this->parts[] = array( 'body' => $file,
    'name' => $name,
    'c_type' => $c_type );
    }

    function add_body_text($body){
    $this->body = $body;
    }

    function build_body(){
    $body = 'Content-Type: text/html'."\n";
    $body .= 'Content-Transfer-Encoding: base64'."\n\n";
    $body .= chunk_split(base64_encode($this->body))."\n";
    return $body;
    }

    function build_part($i){
    $message_part = '';
    $message_part.= 'Content-Type: '.$this->parts[$i]['c_type'];
    if($this->parts[$i]['name'] ['cognome'] != '')
    $message_part .= '; name="'.$this->parts[$i]['name'] ['cognome']."\"\n";
    else
    $message_part .= "\n";

    $message_part.= 'Content-Transfer-Encoding: base64'."\n";
    $message_part.= 'Content-Disposition: attachment; filename="'.$this->parts[$i]['name'] ['cognome']."\"\n\n";
    $message_part.= chunk_split(base64_encode($this->parts[$i]['body']))."\n";
    return $message_part;
    }

    function build_message(){
    $boundary = '=_'.md5(uniqid(time()));

    $this->headers.= "MIME-Version: 1.0\n";
    $this->headers.= "Content-Type: multipart/mixed;".chr(10).chr(9)."boundary=\"".$boundary."\" \n";
    $this->multipart = '';
    $this->multipart.= "This is a MIME encoded message.\nCreated by html_mime_mail.class.\nSee http://www.heyes-computing.net/ for a copy.\n\n";

    $this->multipart .= '--'.$boundary."\n".$this->build_body();

    for($i=(count($this->parts)-1); $i>=0; $i--){
    $this->multipart.= '--'.$boundary."\n".$this->build_part($i);
    }

    $this->mime = $this->multipart."--".$boundary."--\n";
    }

    function send($to_name, $to_addr, $from_name, $from_addr, $subject = '', $headers = ''){

    if($to_name != '') $to = '"'.$to_name.'" <'.$to_addr.'>';
    else $to = $to_addr;

    if($from_name != '') $from = '"'.$from_name.'" <'.$from_addr.'>';
    else $from = $from_addr;

    mail($to, $subject, $this->mime, 'From: '.$from."\n".$this->headers);
    }

    } // End of class.

    class template{

    var $var_names = array();
    var $files = array();
    var $start = '{';
    var $end = '}';

    function load_file($file_id, $filename){
    $this->files[$file_id] = fread($fp = fopen($filename, 'r'), filesize($filename));
    fclose($fp);
    }

    function set_identifiers($start, $end){
    $this->start = $start;
    $this->end = $end;
    }

    function register($file_id, $var_name){
    if(is_long(strpos($var_name, ',')) == TRUE){
    $var_name = explode(',', $var_name);
    for(reset($var_name); $current = current($var_name); next($var_name)) $this->var_names[$file_id][] = $current;
    }else{
    $this->var_names[$file_id][] = $var_name;
    }
    }

    function parse($file_id){
    if(isset($this->var_names[$file_id]) AND count($this->var_names[$file_id]) > 0){
    for($i=0; $i<count($this->var_names[$file_id]); $i++){
    $temp_var = $this->var_names[$file_id][$i];
    global $$temp_var;
    $this->files[$file_id] = str_replace($this->start.$temp_var.$this->end, $$temp_var, $this->files[$file_id]);
    }
    }
    }

    function parse_loop($file_id, $array_name){
    global $$array_name;
    $loop_code = '';
    $file = explode(chr(10), $this->files[$file_id]);

    $start_pos = strpos(strtolower($this->files[$file_id]), '<loop name="'.$array_name.'">') + strlen('<loop name="'.$array_name.'">');
    $end_pos = strpos(strtolower($this->files[$file_id]), '</loop name="'.$array_name.'">');

    $loop_code = substr($this->files[$file_id], $start_pos, $end_pos-$start_pos);
    $this->files[$file_id] = str_replace(substr($this->files[$file_id], strpos(strtolower($this->files[$file_id]), '<loop name="'.$array_name.'">'),strlen('<loop name="'.$array_name.'">')), '', $this->files[$file_id]);
    $this->files[$file_id] = str_replace(substr($this->files[$file_id], strpos(strtolower($this->files[$file_id]), '</loop name="'.$array_name.'">'),strlen('</loop name="'.$array_name.'">')), '', $this->files[$file_id]);

    if($loop_code != ''){
    $new_code = '';
    for($i=0; $i<count($$array_name); $i++){
    $temp_code = $loop_code;
    while(list($key,) = each(${$array_name}[$i])){
    $temp_code = str_replace($this->start.$key.$this->end,${$array_name}[$i][$key], $temp_code);
    }
    $new_code .= $temp_code;
    }
    $this->files[$file_id] = str_replace($loop_code, $new_code, $this->files[$file_id]);
    }
    }

    function parse_sql($file_id, $result_name){
    global $$result_name;
    $loop_code = '';

    $start_pos = strpos(strtolower($this->files[$file_id]), '<loop name="'.$result_name.'">') + strlen('<loop name="'.$result_name.'">');
    $end_pos = strpos(strtolower($this->files[$file_id]), '</loop name="'.$result_name.'">');

    $loop_code = substr($this->files[$file_id], $start_pos, $end_pos-$start_pos);
    $this->files[$file_id] = str_replace(substr($this->files[$file_id], strpos(strtolower($this->files[$file_id]), '<loop name="'.$result_name.'">'),strlen('<loop name="'.$result_name.'">')), '', $this->files[$file_id]);
    $this->files[$file_id] = str_replace(substr($this->files[$file_id], strpos(strtolower($this->files[$file_id]), '</loop name="'.$result_name.'">'),strlen('</loop name="'.$result_name.'">')), '', $this->files[$file_id]);

    if($loop_code != ''){
    $new_code = '';
    $field_names = array();
    for($i=0; $i<mysql_num_fields($$result_name); $i++) $field_names[] = mysql_field_name($$result_name,$i);
    while($row_data = mysql_fetch_array($$result_name, MYSQL_ASSOC)){
    $temp_code = $loop_code;
    for($i=0; $i<count($field_names); $i++){
    $temp_code = str_replace($this->start.$field_names[$i].$this->end, $row_data[$field_names[$i]], $temp_code);
    }
    $new_code.= $temp_code;
    }
    $this->files[$file_id] = str_replace($loop_code, $new_code, $this->files[$file_id]);
    }
    }

    function print_file($file_id){
    if(is_long(strpos($file_id, ',')) == TRUE){
    $file_id = explode(',', $file_id);
    for(reset($file_id); $current = current($file_id); next($file_id)) echo $this->files[$current];
    }else{
    echo $this->files[$file_id];
    }
    }

    function return_file($file_id){
    $ret = '';
    if(is_long(strpos($file_id, ',')) == TRUE){
    $file_id = explode(',', $file_id);
    for(reset($file_id); $current = current($file_id); next($file_id)) $ret .= $this->files[$current];
    }else{
    $ret .= $this->files[$file_id];
    }
    return $ret;
    }

    } // End of class



    function check_required($key, $value){
    if(substr($key,-9) == '_required' AND $value == ''){
    global $required_error;
    header('Location: '.$required_error);
    exit;
    }
    }

    /
    function file_upload_php3($key, $value){
    if(substr($key,-5) != '_file' AND substr($key,-14) != '_file_required') return FALSE;
    if(substr($key,-9) == '_required' AND ($value == 'none' OR $value == '')){


    .... a questo indirizzo lo script completo:http://php.html.it/script/vedi/1216/...cessor-script/

  2. #2
    Ragazzi mi basta un segnale. Dove posso mettere le mani?
    Un segno, un'indicazione.
    Un piccolo esempio..

  3. #3
    leggi il regolamento e riapri la discussione con un titolo a norma....
    essendo il tuo primo messaggio solitamente lo cambiavo io e ti avvertivo ma sinceramente non sono riuscito a capire cosa vuoi fare quindi ti consiglio di spiegarti meglio nel prossimo messaggio e magari fare domande + mirate, se la cosa è difficile meglio farle passo passo....
    buon php
    ciao

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.