2012-06-04 3 views
0

내가 빈 간다 제출 전송, 워드 프레스에서이 양식 게시를 확인할 수 없습니다 워드 프레스와 오류를유효성 검사 양식은

광고 post.php을 보여줍니다

<?php 
/* 
Template Name: Publicar Post 
*/ 
$wpdb->hide_errors(); 
nocache_headers(); 
global $userdata; 
get_currentuserinfo(); // grabs the user info and puts into vars 
require_once dirname(__FILE__) . '/post-process.php'; 
get_header(); ?> 
     <div id="page"> 
      <div class="categories"> 
       <h2 style="border: 1px solid #ccc; border-bottom: none; background: url(<?php echo csp_images_url; ?>/sprite.png) left -738px repeat-x;text-align:center; padding-top: 5px; margin-top: 10px;">Categor&iacute;as</h2> 
       <ul id="menu"> 
        <?php wp_list_categories('title_li=&orderby=name&exclude='.$category_id.''); ?> 
       </ul> 
       <?php get_sidebar('o'); ?> 
      </div> 
      <div class="publish-form"> 
       <div class="post-form"> 
        <h2>Envia tu Anuncio</h2> 

          <div class="box-yellow"> 
           La publicaci&oacute;n de avisos es gratuito, sin embargo si usted desea destacar su anuncio o contratar publicidad en lugares estrat&eacute;gicos de la web, por favor <a href="<?php bloginfo('url'); ?>" title="Contacte con Nosotros">p&oacute;ngase en contacto con nosotros</a>, estaremos 
           dispuestos a su disposici&oacute;n. 
           <?php 
           $ok = classy_filter($_GET['ok']); 
           if ($err != "") { echo "<div id=\"err\" class=\"err\"><a id='closelink' href=\"#\" onClick=\"document.getElementById('err').style.display = 'none';\">X</a>$err</div>"; } 

           if ($ok == "ok") { 
            echo "<div class=\"ok\"><strong>" . __('Muchas gracias!, su art&iacute;culo ha sido enviado satisfactoriamente.') . "</strong><br />"; 

           if (get_option("post_status") == "publish") { 
            echo __('Alguien revisar&aacute; su publicaci&ocute;n en breve. Si usted tiene alguna pregunta, p&oacute;ngase en contacto con el propietario del sitio.') . "<br />"; 
             } 
            echo "</div>"; 
           } 
           ?> 
          </div> 

         <form action="" method="post" enctype="multipart/form-data" id="new_post" name="new_post"> 
          <input type="hidden" name="action" value="post" /> 
          <?php wp_nonce_field('new-post'); ?> 

          <label for="title" class="post_tags"><?php _e('T&iacute;tulo de la Publicaci&oacute;n'); ?> <span>*</span></label> 
          <input type="text" id="title" class="mid" name="post_title" size="100" maxlength="100" value="<?php echo $_POST['post_title'];?>" style="padding: 5px;" /><br /><br /> 

          <label for="cat" class="post_tags">Por favor seleccione una categor&iacute;a <span>*</span>:</label> 
          <?php wp_dropdown_categories('show_option_none=Seleccione una Categoria&hide_empty=0&hierarchical=1&class=adfields&exclude='.$category_id.''); ?> 
          <br /><br /> 

          <label for="post_tags">Suba una imagen<br /><br /> 
          <small>(Las im&aacute;genes no deben ser mayores de 1MB, los formatos soportados son: jpg, png, gif y jpeg.)</small></label> 
          <input type="file" name="imgs[]" class="wwIconified" style="padding: 5px;" /><br /> 
          <br /> 
          <label for="description" class="post_tags"><?php _e('Escriba aqu&iacute; la descripci&oacute;n de su Aviso Clasificado'); ?> <span>*</span><br /><small>(Mientras mejor se explique, mejores resultados podr&aacute; obtener).</small></label><br /> 
          <?php wp_editor(''. $_POST['content'].'', 'content', $settings); ?> 
          <div class="clear"></div> 
          <br /> 

          <label for="post_tags" class="post_tags">Etiquetas <span>*</span> <small class="mini"><?php _e('(las etiquetas ayuda a mejorar la indexaci&oacute;n de su aviso, sep&aacute;relas con comas)'); ?></small></label> 
          <input type="text" id="post_tags" class="adfields" name="post_tags" size="60" maxlength="100" value="<?php echo $_POST['post_tags']; ?>" style="padding: 5px;" /> 
          <br /><br /> 

          <label for="price" class="post_tags">Precio <span>*</span></label><br /><br /> 
          <p><small>(Es necesario que inserte el monto con su respectivo s&iacute;mbolo; ejm. S/.10.00, $20.00 USD, etc.)</small></p> 
          <input type="text" id="price" class="adfields price" name="price" size="50" maxlength="250" value="<?php echo $_POST['price']; ?>" /><br /> 
          <br /> 
          <label for="post_tags" class="post_tags">Direcci&oacute;n/Ubicaci&oacute;n <span>*</span></label><br /> 
          <input type="text" id="location" class="adfields location" name="location" size="50" maxlength="250" value="<?php echo $_POST['location']; ?>" /><br /> 
          <br />       
          <label for="post_tags" class="post_tags">Agregar URL <small><?php _e('(i.e. http://www.misitio.com)'); ?></small></label><br /> 
          <input type="text" id="addURL" class="adfields url" name="addURL" size="50" maxlength="250" value="<?php echo $_POST['addURL']; ?>" /><br /> 

          <label for="post_tags" class="post_tags">Nombre de Contacto <span>*</span></label><br /> 
          <input type="text" id="name" class="adfields name" name="name" size="50" maxlength="250" value="<?php echo $_POST['name']; ?>" /><br /> 

          <label for="post_tags" class="post_tags">Tel&eacute;fono</label><br /> 
          <input type="text" id="phone" class="adfields phone" name="phone" size="50" maxlength="250" value="<?php echo $_POST['phone']; ?>" /><br /> 

          <label for="post_tags" class="post_tags">Correo Electr&oacute;nico <span>*</span></label><br /> 
          <input type="text" id="email" class="adfields email" name="email" size="50" maxlength="250" value="<?php echo $_POST['email']; ?>" /><br /> 

          <input id="submit" type="submit" value="Publicar el Aviso" class="submit_btn" /> 
         </form> 
         <?php // } //if the form is ok don't display the form anymore ?> 
       </div> 
      </div> 
      <div class="clear"></div> 
     </div> 
<?php get_footer(); ?> 

후 process.php

이것은 유효성 검사를 처리하는 파일이며 작동하지 않는 것 같습니다.

<?php 
set_time_limit(0); 
if (isset($_POST['action']) && $_POST['action'] == 'post') { 

if (get_option("permissions") == "no") { 
    if (!is_user_logged_in()){ 
     wp_redirect(get_bloginfo('url') . '/'); 
     exit; 
    }; 
} 

    check_admin_referer('new-post'); 
    $err = ""; $ok = ""; 
    $user_id  = $current_user->user_id; 
    $post_title  = classy_filter($_POST['post_title']); 
    $post_cat  = (int)classy_filter($_POST['cat']); 
    $post_cat_array = array("$post_cat"); 

    if (isset ($_POST['content'])) { 
     $content = trim($_POST['content']); 
    } else { 
     echo 'Please enter the content'; 
    } 

    //$title  = classy_filter($_POST['title']); 
    $post_tags  = classy_filter($_POST['post_tags']); 
    $addURL   = classy_filter($_POST['addURL']); 
    $location  = classy_filter($_POST['location']); 
    $price   = classy_filter($_POST['price']); 
    $name   = classy_filter($_POST['name']); 
    $phone   = classy_filter($_POST['phone']); 
    $email   = classy_filter($_POST['email']); 

    $imgs = strip_tags($_POST['imgs']); 

    if ($post_cat == "-1") { 
     $err .= __('Por favor seleccione una categor&iacute;a') . "<br />"; 
    } else { 
     global $wpdb; 
     $cat_ids = (array) $wpdb->get_col("SELECT `term_id` FROM $wpdb->terms"); 
     if (!in_array($post_cat, $cat_ids) && $post_cat != "-1") { 
      $err .= __('La categor&iacute;a Seleccionada no Existe') . "<br />"; 
     } 
    } 

    if ($post_title == "" || $post_cat == "" || $post_tags == "" || $price == "" || $location == "" || $name == "") { 
     $err .= __('Por favor llene los campos marcados como obligatorios *') . "<br />"; 
    } 

    if (!check_email($email)) { 
     $err .= __('Por favor ingrese un Correo Electr&oacute;nico V&aacute;lido') . "<br />"; 
    } 

    if ($total != $nr1nr2) { 
     $err .= __('Los datos ingresados en el captcha son incorrectos') . "<br />"; 
    } 

    if ($err == "") { 


//imgs 
    //1024 bytes = 1kb 
    //1024000 bytes = 1mb 
    $image_folder_name = "imgs"; 
    $size_bytes = 1024000; 
    $size_mb = $size_bytes/1024000; 
    $limitedext = array(".gif",".png",".jpg",".jpeg",".bmp"); 

     // http://codex.wordpress.org/Function_Reference/wp_upload_dir 
     $upload_arr = wp_upload_dir(); 
     $dir_to_make = trailingslashit($upload_arr['basedir']) . $image_folder_name; 
     // $dir_to_make = "wp-content/uploads/imgs"; 
     $image_baseurl = trailingslashit($upload_arr['baseurl']) . $image_folder_name; 
     $image_name = substr(sanitize_title(alphanumericAndSpace($post_title)), 0, 20); 

     $i = rand(); 
     $imgs = ""; 
     $err2 = ""; 

     while(list($key,$value) = each($_FILES['imgs']['name'])) { 
      if(!empty($value)) { 
       $filename = strtolower($value); 
       $filename = str_replace(" ", "-", $filename); 
       //get image extension 
       $tipul = strrchr($filename,'.'); 
       $filename = $image_name."-$i".$tipul; 
       $add = "$dir_to_make/$filename"; 
       $image = "$image_baseurl/$filename"; 
       //$add = "$filename"; 

      //Make sure that file size is correct 
       $file_size = $_FILES['imgs']['size'][$key]; //getting the right size that coresponds with the image uploaded 
       if ($file_size == "0"){ 
        $err2 .= __('El archivo $value tiene 0 bytes.') . "<br />"; 
       } else { 
        if ($file_size > $size_bytes){ 
         $err2 .= __('El archivo $value es mayor de 5MB.') . "<br />"; 
        } 
       } 
       //check file extension 
       $ext = strrchr($filename,'.'); 
       if ((!in_array(strtolower($ext),$limitedext))) { 
        $err2 .= __('El archivo $value no es una imagen v&aacute;lida.') . "<br />"; 
       } 


       //echo $_FILES['archive']['type'][$key]; 
       if ($err2 == "") { 
        if (!file_exists($dir_to_make)) { mkdir($dir_to_make, 0777); } 
        copy($_FILES['imgs']['tmp_name'][$key], $add); 
        chmod("$add",0777); 

        //$imgs .= get_option('home')."/".$add.","; 
        $imgs .= $image . ","; 

       } 
       $err2 = ""; 
       $i++; 
      }//if empty $value 
     }//end while 

     $post_code = time(); 
     $post_status = "publish"; 

     $post_id = wp_insert_post(array(
      'post_title' => $post_title, 
      'post_content' => $content, 
      'post_category' => $post_cat_array, 
      'post_status' => $post_status, 
      'tags_input' => $post_tags 
     )); 
     add_post_meta($post_id, 'imgs', $imgs, true); 
     add_post_meta($post_id, 'addURL', $addURL, true); 
     add_post_meta($post_id, 'location', $location, true); 
     add_post_meta($post_id, 'price', $price, true); 
     add_post_meta($post_id, 'name', $name, true); 
     add_post_meta($post_id, 'phone', $phone, true); 
     add_post_meta($post_id, 'email', $email, true); 

     $ok = "ok"; 

      wp_redirect(get_bloginfo('url') . '/'); 
     } 
     exit; 
    } 

?> 

제발 도와

답변

0

시도의 변화 :

<form action="" method="post" enctype="multipart/form-data" id="new_post" name="new_post"> 

에 :

<form action="post-process.php" method="post" enctype="multipart/form-data" id="new_post" name="new_post"> 
+0

http://b2bno.com/post-publish/ 양식 작업 = "post-process.php" – shamantha

+0

도와주세요. – shamantha

+0

확실하지 않습니다. 현상금을 추가하십시오. – ub3rst4r

0

당신은 여분이있다; 첫 번째 라인에도와 오류없이 코드 밖으로

set_time_limit(0); 
if (isset($_POST['action']) && $_POST['action'] == 'post') { 

if (get_option("permissions") == "no") { 
    if (!is_user_logged_in()){ 
     wp_redirect(get_bloginfo('url') . '/'); 
     exit; 
    }; <----------------------------Get rid of this SemiColon 
} 

http://phpcodechecker.com/ 검사; 하지만 먼저 그렇게 할 것입니다.

관련 문제