Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $name = strip_tags($_POST['name']);
- $email = strip_tags($_POST['email']);
- $message = strip_tags($_POST['theMessage']);
- $plan = strip_tags($_POST['plan']);
- $password = strip_tags($_POST['password']);
- function getPlanText($plan){
- if ($plan=='1'){
- return "
- <div style='width:400px; border:1px solid #eee; padding:20px;background: #faf8f4;margin:30px 0' align='center'>
- <h1>Plan 1</h1>
- <h2>$29/mo</h2>
- <h3>$70 Setup fee (one-time)</h3>
- <p>
- <strong>VPS</strong><br>
- CPU: four cores<br>
- Intel® Xeon® E5-2620v3, E5-2630v4 or 4114 processor<br>
- 8 GB RAM<br>
- 200 GB disk space (100% SSD)<br>
- OS: Debian 9<br>
- <strong>Installed apps</strong><br>
- Zabbix<br>
- GLPI<br>
- Kibana (Wazuh)<br>
- <strong>Support</strong><br>
- VPS<br>
- Application (no configuration support)<br><br>
- First payment: $99
- </p></div>";
- };
- if ($plan=='2'){
- return "<div style='width:400px; border:1px solid #eee; padding:20px;background: #faf8f4;margin:30px 0' align='center'>
- <h1>Plan 2</h1>
- <h2>$149/mo</h2>
- <h3>Free Setup</h3>
- <p>
- <strong>VPS</strong><br>
- CPU: eight cores<br>
- Intel® Xeon® E5-2620v3, E5-2630v4 or 4114 processor<br>
- 30 GB RAM<br>
- 800 GB disk space (100% SSD)<br>
- OS: Debian 9<br>
- <strong>Installed apps</strong><br>
- Zabbix<br>
- GLPI<br>
- Kibana (Wazuh)<br>
- <strong>Support</strong><br>
- Apps Configuration via email or chat<br>
- VPS<br>
- Apps
- </p></div>
- ";
- };
- if ($plan=='3') {
- return "<div style='width:400px; border:1px solid #eee; padding:20px;background: #faf8f4;margin:30px 0' align='center'><h3>Custom plan</h3><br></div>";
- }
- };
- if (isset($_POST['token']) && isset($_POST['action'])) {
- $captcha_token = $_POST['token'];
- $captcha_action = $_POST['action'];
- } else {
- die('Капча работает некорректно. Обратитесь к администратору!');
- }
- $url = 'https://www.google.com/recaptcha/api/siteverify';
- $params = [
- 'secret' => '___',
- 'response' => $captcha_token,
- 'remoteip' => $_SERVER['REMOTE_ADDR']
- ];
- $ch = curl_init($url);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- $response = curl_exec($ch);
- if(!empty($response)) $decoded_response = json_decode($response);
- $success = false;
- if ($decoded_response && $decoded_response->success && $decoded_response->action == $captcha_action && $decoded_response->score > 0) {
- $success = $decoded_response->success;
- // обрабатываем данные формы, которая защищена капчей
- function cURL($url, $ref, $header, $cookie, $p){
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
- curl_setopt($ch, CURLOPT_REFERER, $ref);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- if ($p) {
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $p);
- }
- $result = curl_exec($ch);
- curl_close($ch);
- if ($result){
- return $result;
- }else{
- return '';
- }
- }
- $qstring = "https://173.212.216.142:4444/API?function=add_user&family=&name=".urlencode($name)."&patronymic=&email=".urlencode($email)."&tariff_scheme_id=$plan";
- $json_file = cURL($qstring,'',0,0,null);
- $json_array = json_decode($json_file, true);
- //$desc = $json_array['result'];
- $result = $json_array['result'];
- $json_array['customermessage'] = $message;
- $json_array['password'] = $password;
- //$result='OK';
- if ($result == 'OK') {
- $json_array['landmessage'] = "<div class='col-md-12'><h5>Thank you! You have <span style='color:#499c20'>successfully registered</span>. <br> Please check your mailbox for further instructions.</h5></div>";
- // Send message to SLACK
- // Create a constant to store your Slack URL
- define('SLACK_WEBHOOK', 'https://hooks.slack.com/services/___/___/_____');
- // Make your message
- $msgslack = "New user registered\n Name: $name\n Email: $email\n Plan: $plan\n Message: $message";
- $ms = array('payload' => json_encode(array('text' => $msgslack)));
- // Use curl to send your message
- $c = curl_init(SLACK_WEBHOOK);
- curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($c, CURLOPT_POST, true);
- curl_setopt($c, CURLOPT_POSTFIELDS, $ms);
- curl_exec($c);
- curl_close($c);
- // </ send message to SLACK
- // Mail init
- require 'PHPMailerAutoload.php';
- $mail = new PHPMailer;
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->Host = 'mail.int-cloud.net'; // Specify main and backup SMTP servers
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = 'reg@int-cloud.net'; // SMTP username
- $mail->Password = 'xRtw;?2X$Htl'; // SMTP password
- $mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
- $mail->Port = 465; // TCP port to connect to
- $mail->isHTML(true); // Set email format to HTML
- // Send message to INT office
- $mail->setFrom('robot@int-cloud.net', 'Mailer');
- $mail->addAddress('reg@int-cloud.net', 'Office'); // Add a recipient
- $mail->addReplyTo('reg@int-cloud.net', 'Int robot');
- $mail->Subject = 'New user registered';
- $mail->Body = "Name: $name <br>Email: $email<br>Plan: $plan<br>Message: <br>$message ";
- $mail->AltBody = 'Тело письма тупо текст';
- if(!$mail->send()) {
- echo 'Debug: mail not sent';
- echo 'Errors: ' . $mail->ErrorInfo;
- } else {
- }
- // Send message to customer
- $mail->setFrom('robot@int-cloud.net', 'Int-cloud mailer');
- $mail->addAddress($email, $name); // Add a recipient
- $mail->addReplyTo('reg@int-cloud.net', 'Int-cloud support center');
- $mail->Subject = 'Int-cloud registration';
- $mail->Body = "Dear $name,<br>
- Thank you very much for your order at INT-Cloud!<br>
- Below, you will find details<br>".getPlanText($plan)."
- <br><br>
- Please note that we can only start with the setup of your order once we have received the initial payment. Invoice will be sent soon.<br>
- After we have received your payment, we will send you a separate e-mail. It will then take up to 12 hours until everything has been completed and we will send you the login data.<br>
- <br>
- We are very happy to welcome you as a new customer.<br>
- <br>
- Best regards,<br>
- <br>
- Your INT-Cloud team";
- if(!$mail->send()) {
- echo 'Debug: mail to customer not sent';
- echo 'Errors: ' . $mail->ErrorInfo;
- } else {
- echo 'Debug: mail to customer sent successfuly';
- }
- }
- if ($result === 'error') {
- $json_array['landmessage'] = $json_array['description'];
- }
- //echo json_encode($json_array);
- // echo ("Debug. Captcha success string: ".$success);
- echo ($json_array['landmessage']);
- echo "Debug. Recaptcha response: ";
- var_dump($decoded_response);
- } else {
- // прописываем действие, если пользователь оказался ботом
- echo "ReCaptcha not passed. Aren't you a bot?";
- }
- //echo json_encode($success);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement