Ver Mensaje Individual
  #2 (permalink)  
Antiguo 12/09/2007, 12:10
Avatar de xiscomax
xiscomax
 
Fecha de Ingreso: febrero-2006
Mensajes: 379
Antigüedad: 18 años, 2 meses
Puntos: 5
Re: Como añadirle un elemento de confirmación "checkbox" a este formulario?

Código PHP:
$filecount = 0;
foreach($_FILES as $file => $value) {
    $attachment[(int)$filecount] = $_FILES[$file]['tmp_name'];
    $attachment_name[(int)$filecount] = $_FILES[$file]['name'];
    $attachment_size[(int)$filecount] = $_FILES[$file]['size'];
    if (is_uploaded_file($attachment[(int)$filecount])) { //Do we have a file uploaded?
        if ($attachment_size[(int)$filecount] <= $attachment_max_size * 1024) { //Do we have a file uploaded?
            $fp = fopen($attachment[(int)$filecount], "rb"); //Open it
            $data[(int)$filecount] = fread($fp, filesize($attachment[(int)$filecount])); //Read it
            $data[(int)$filecount] = chunk_split(base64_encode($data[(int)$filecount])); //Chunk it up and encode it as base64 so it can emailed
            fclose($fp);
            $filecount++;
        }
    }
}
    //$attachment = $_FILES['cattachment']['tmp_name'];
//    $attachment_name = $_FILES['cattachment']['name']; 
//    if (is_uploaded_file($attachment)) { //Do we have a file uploaded?
//      $fp = fopen($attachment, "rb"); //Open it
//      $data = fread($fp, filesize($attachment)); //Read it
//      $data = chunk_split(base64_encode($data)); //Chunk it up and encode it as base64 so it can emailed
//        fclose($fp);
//    } 
    
    $fullmsg = "------=MIME_BOUNDRY_main_message\n";
    $fullmsg .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n"; 
    $fullmsg .= "Content-Transfer-Encoding: quoted-printable\n"; 
    $fullmsg .= "\n"; 
    /* Add our message, in this case it's plain text.  You could also add HTML by changing the Content-Type to text/html */
    $fullmsg .= "Sitio web: " . $website . "\n";
        $fullmsg .= "$name wrote:\n";
    $fullmsg .= wordwrap($msg, 80, "\n") . "\n\n";
    $fullmsg .= "\n"; 
    $fullmsg .= "------=MIME_BOUNDRY_main_message\n"; 
    $fullmsg .= "\n"; 

        $fullmsg .= "------=MIME_BOUNDRY_main_message\n"; 
  
for ($i = 0, $filecount = (int) count($data); $i < $filecount; $i++) {
    $fullmsg .= "------=MIME_BOUNDRY_main_message\n";
    $fullmsg .= "Content-Type: application/octet-stream;\n\tname=\"" . $attachment_name[$i] . "\"\n";
    $fullmsg .= "Content-Transfer-Encoding: base64\n";
    $fullmsg .= "Content-Disposition: attachment;\n\tfilename=\"" . $attachment_name[$i] . "\"\n\n";
    $fullmsg .= $data[$i]; //The base64 encoded message
    $fullmsg .= "\n\n";
}

      //$fullmsg .= "Content-Type: application/octet-stream;\n\tname=\"" . $attachment_name . "\"\n";
    //$fullmsg .= "Content-Transfer-Encoding: base64\n";
    //$fullmsg .= "Content-Disposition: attachment;\n\tfilename=\"" . $attachment_name . "\"\n\n";
    //$fullmsg .= $data; //The base64 encoded message
    //$fullmsg .= "\n"; 
    $fullmsg .= "------=MIME_BOUNDRY_main_message\n";  

            mail($recipient, $subject, $fullmsg, $headers);

            $results = '<h2 class="pagetitle">' . $success_msg . '</h2>';
            echo $results;
    }
    else // Else show the form. If there are errors the strings will have updated during running the inputcheck.
    {
        $form = '<div class="formfoto">
        ' . $wpcf_strings['error'] . '
            <form enctype="multipart/form-data" action="' . get_permalink() . '" method="post">
                <div class="contactleft"><label for="wpcf_your_name">' . __('Nombre o Nick Para la Foto (*): ', 'wpcf') . '</label></div>' . $wpcf_strings['name']  . '
                <div class="contactleft"><label for="wpcf_email">' . __('E-Mail (*):', 'wpcf') . '</label></div>' . $wpcf_strings['email'] . '
                <div class="contactleft"><label for="wpcf_website">' . __('Sitio web:', 'wpcf') . '</label></div><div class="contactright"><input class="textfield" type="text" name="wpcf_website" id="wpcf_website" size="30" maxlength="100" value="' . $_POST['wpcf_website'] . '" /></div>
                <div class="contactleft nop"><label for="wpcf_msg">' . __('Cuentanos algo... (Ejemplo, porque quieres salir en webculos) ', 'wpcf') . '</label>' . $wpcf_strings['msg'] . '</div>
                <div class="contactleft nop"><label for="wpcf_msg">' . __('Seleccionar las fotos en formato JPG: ', 'wpcf') . '<small>max ' . $attachment_max_size . ' kb</small></label><br/>
                            <input type="file" name="cattachment1"  class="textfield file" /><br/>
                            <input type="file" name="cattachment2"  class="textfield file" /><br/>
                            <input type="file" name="cattachment3"  class="textfield file" /><br/>
                            <input type="file" name="cattachment4"  class="textfield file" /></div>
                <div class="contactright"><input type="submit" name="Submit" value="Enviar" id="contactsubmit" /><input type="hidden" name="wpcf_stage" value="process" /></div>
               </form>
        </div>
        <div style="clear:both; height:1px;">&nbsp;</div>';

        return str_replace('<!--contact form-->', $form, $content);
    }
}


/*Can't use WP's function here, so lets use our own*/
function getip()
{
    if (isset($_SERVER))
    {
         if (isset($_SERVER["HTTP_X_FORWARDED_FOR"]))
         {
              $ip_addr = $_SERVER["HTTP_X_FORWARDED_FOR"];
         }
         elseif (isset($_SERVER["HTTP_CLIENT_IP"]))
         {
              $ip_addr = $_SERVER["HTTP_CLIENT_IP"];
         }
         else
         {
             $ip_addr = $_SERVER["REMOTE_ADDR"];
         }
    }
    else
    {
         if ( getenv( 'HTTP_X_FORWARDED_FOR' ) )
         {
              $ip_addr = getenv( 'HTTP_X_FORWARDED_FOR' );
         }
         elseif ( getenv( 'HTTP_CLIENT_IP' ) )
         {
              $ip_addr = getenv( 'HTTP_CLIENT_IP' );
         }
         else
         {
              $ip_addr = getenv( 'REMOTE_ADDR' );
         }
    }
return $ip_addr;
}


/*CSS Styling*/
function wpcf_css()    {
    ?>
<?php

    
}

function 
wpcf_add_options_page()
    {
        
add_options_page('Contact Form Options''Formulario Fotos''manage_options''wp-contact-form/options-contactform.php');
    }

/* Action calls for all functions */

//if(get_option('wpcf_show_quicktag') == true) {add_action('admin_footer', 'wpcf_add_quicktag');}

add_action('admin_head''wpcf_add_options_page');
add_filter('wp_head''wpcf_css');
add_filter('the_content''wpcf_callback'7);

?>
Si alguien puede hecharme un cable se lo tendria muy agradecido
Salu2