![]() Server : Apache System : Linux pod-100823:apache2_74:v0.6.0 5.4.0-1138-gcp #147~18.04.1-Ubuntu SMP Mon Oct 7 21:46:26 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33.10 Disable Function : apache_child_terminate,apache_get_modules,apache_get_version,apache_getenv,apache_note,apache_setenv,disk_free_space,disk_total_space,diskfreespace,dl,exec,fastcgi_finish_request,link,opcache_compile_file,opcache_get_configuration,opcache_invalidate,opcache_is_script_cached,opcache_reset,passthru,pclose,pcntl_exec,popen,posix_getpid,posix_getppid,posix_getpwuid,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_uname,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,realpath_cache_get,shell_exec,show_source,symlink,system Directory : /nas/content/live/attorneyexperi/wp-content/themes/directory2/ait-theme/ajax/ |
<?php class AitSendEmailAjax extends AitFrontendAjax { /** * @WpAjax */ public function send() { $captcha = new ReallySimpleCaptcha(); $captcha->tmp_dir = aitPaths()->dir->cache . '/captcha'; if(!empty($_POST['response-email-content'])){ $matches = array(); preg_match_all('/{([^}]*)}/', $_POST['response-email-content'], $matches); foreach($matches[1] as $i => $match){ if(!empty($_POST[$match])){ $_POST['response-email-content'] = str_replace($matches[0][$i], $_POST[$match], $_POST['response-email-content']); } } $_POST['response-email-content'] = str_ireplace(array("\r\n", "\n"), "<br />", $_POST['response-email-content']); } // unescape all escaped quotes .. not safe .. probably remove //$_POST['response-email-content'] = str_ireplace(array("\'", '\"'), array("'", '"'), $_POST['response-email-content']); $headers = array( 'Content-Type: text/html; charset=UTF-8', ); if(!empty($_POST['email'])){ array_push($headers, 'Reply-To: '.$_POST['email'].' <'.$_POST['email'].'>'); } if(!empty($_POST['response-email-sender'])){ array_push($headers, 'From: '.'<'.$_POST['response-email-sender'].'>'); } if(!empty($_POST['captcha-check'])){ if($captcha->check('ait-captcha-'.$_POST['response-email-check'], $_POST['captcha-check'])){ $requiredFieldsCounter = 0; $requiredFieldsMessage = __("Required fields: (%s) are not set-up in contact form element", 'ait'); $requiredFieldsStrings = array(); if(!empty($_POST['response-email-address'])){ $requiredFieldsCounter += 1; } else { array_push($requiredFieldsStrings, "Email Address"); } if(!empty($_POST['response-email-subject'])){ $requiredFieldsCounter += 1; } else { array_push($requiredFieldsStrings, "Email Subject"); } if(!empty($_POST['response-email-content'])){ $requiredFieldsCounter += 1; } else { array_push($requiredFieldsStrings, "Email Content"); } if($requiredFieldsCounter == 3){ $result = wp_mail($_POST['response-email-address'], $_POST['response-email-subject'], $_POST['response-email-content'], $headers); if($result == true){ $this->sendJson(array('message' => sprintf(__("Mail sent to %s", 'ait'), $_POST['response-email-address']))); } else { $this->sendErrorJson(array('message' => __("Message sending failed", 'ait'))); } } else { $this->sendErrorJson(array('message' => sprintf($requiredFieldsMessage, implode(" ,", $requiredFieldsStrings)))); } }else{ $this->sendErrorJson(array('message' => __("Captcha check failed", 'ait'))); } } else { $requiredFieldsCounter = 0; $requiredFieldsMessage = __("Required fields: (%s) are not set-up in contact form element", 'ait'); $requiredFieldsStrings = array(); if(!empty($_POST['response-email-address'])){ $requiredFieldsCounter += 1; } else { array_push($requiredFieldsStrings, "Email Address"); } if(!empty($_POST['response-email-subject'])){ $requiredFieldsCounter += 1; } else { array_push($requiredFieldsStrings, "Email Subject"); } if(!empty($_POST['response-email-content'])){ $requiredFieldsCounter += 1; } else { array_push($requiredFieldsStrings, "Email Content"); } if($requiredFieldsCounter == 3){ $result = wp_mail($_POST['response-email-address'], $_POST['response-email-subject'], $_POST['response-email-content'], $headers); if($result == true){ $this->sendJson(array('message' => sprintf(__("Mail sent to %s", 'ait'), $_POST['response-email-address']))); } else { $this->sendErrorJson(array('message' => __("Message sending failed", 'ait'))); } } else { $this->sendErrorJson(array('message' => sprintf($requiredFieldsMessage, implode(" ,", $requiredFieldsStrings)))); } } } /** * @WpAjax */ public function getCaptcha(){ $rand = rand(); $captcha = new AitReallySimpleCaptcha(); $imgUrl = ""; $captcha->tmp_dir = aitPaths()->dir->cache . '/captcha'; $cacheUrl = aitPaths()->url->cache . '/captcha'; $img = $captcha->generate_image('ait-captcha-'.$rand, $captcha->generate_random_word()); $imgUrl = $cacheUrl."/".$img; $this->sendJson(array('rand' => $rand, 'url' => $imgUrl, 'html' => '<img src="'.$imgUrl.'" alt="captcha">')); } }