$tmp_file ) { $to_file = ''; $from_file = ''; $has_error = 0; $error_message = ''; if(trim($_FILES['contact_form_parameter_attachments']['name'][$key]) && $_FILES['contact_form_parameter_attachments']['size'][$key]){ $to_file = $base_path.'/temp/'.basename($tmp_file); $from_file = $_FILES['contact_form_parameter_attachments']['name'][$key]; if (!@move_uploaded_file($tmp_file,$to_file)) { /* Fail to copy %s, Contact your admin... */ $has_error= 1; $error_message = 'Fail to copy'; } }elseif(trim($_FILES['contact_form_parameter_attachments']['name'][$key])){ $has_error= 2; $error_message = 'Unknown name'; } $attachments[]=array( "name"=>$from_file, "location"=>$to_file, "has_error" => $has_error, "error_message" => $error_message ); $has_errors += $has_error; if($error_message) { $errors_messages[] = $error_message; } } } print encoding_normalize::json_encode(array('has_errors' => $has_errors, 'errors_messages' => $errors_messages, 'attachments' => $attachments)); break; case 'send_mail': if(empty($id)) $id = 1; $contact_form = new contact_form($id); //domForm.toJson au départ de l'appel, les données sont déjà en UTF-8 $form_fields = json_decode(stripslashes(encoding_normalize::utf8_normalize($form_fields))); if($charset != 'utf-8') { $form_fields = (object) pmb_utf8_decode($form_fields); } if(!empty($attachments)) { $attachments = json_decode(encoding_normalize::utf8_normalize(stripslashes($attachments))); if($charset != 'utf-8') { $attachments = (object) pmb_utf8_decode($attachments); } $form_fields->contact_form_parameter_attachments = $attachments; } $contact_form->set_form_fields($form_fields); if($contact_form->check_form()) { $contact_form->send_mail(); } // Log - afin de faire des stats sur les mails envoyes if($pmb_logs_activate && $contact_form->is_sended()) { generate_log(); } print encoding_normalize::json_encode(array('sended' => $contact_form->is_sended(), 'messages' => $contact_form->get_messages())); break; } break; case 'object': switch ($action){ case 'change': $contact_form_object = new contact_form_object($id); print encoding_normalize::json_encode(array('id' => $id, 'message' => $contact_form_object->get_translated_message())); break; } } ?>