Advertisement
Guest User

Untitled

a guest
Feb 13th, 2019
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.98 KB | None | 0 0
  1. <?php
  2. $name = strip_tags($_POST['name']);
  3. $email = strip_tags($_POST['email']);
  4. $message = strip_tags($_POST['theMessage']);
  5. $plan = strip_tags($_POST['plan']);
  6. $password = strip_tags($_POST['password']);
  7.  
  8.  
  9. function getPlanText($plan){
  10. if ($plan=='1'){
  11. return "
  12. <div style='width:400px; border:1px solid #eee; padding:20px;background: #faf8f4;margin:30px 0' align='center'>
  13. <h1>Plan 1</h1>
  14. <h2>$29/mo</h2>
  15. <h3>$70 Setup fee (one-time)</h3>
  16. <p>
  17. <strong>VPS</strong><br>
  18. CPU: four cores<br>
  19. Intel® Xeon® E5-2620v3, E5-2630v4 or 4114 processor<br>
  20. 8 GB RAM<br>
  21. 200 GB disk space (100% SSD)<br>
  22. OS: Debian 9<br>
  23. <strong>Installed apps</strong><br>
  24. Zabbix<br>
  25. GLPI<br>
  26. Kibana (Wazuh)<br>
  27.  
  28. <strong>Support</strong><br>
  29. VPS<br>
  30. Application (no configuration support)<br><br>
  31. First payment: $99
  32. </p></div>";
  33. };
  34. if ($plan=='2'){
  35. return "<div style='width:400px; border:1px solid #eee; padding:20px;background: #faf8f4;margin:30px 0' align='center'>
  36. <h1>Plan 2</h1>
  37. <h2>$149/mo</h2>
  38. <h3>Free Setup</h3>
  39. <p>
  40. <strong>VPS</strong><br>
  41. CPU: eight cores<br>
  42. Intel® Xeon® E5-2620v3, E5-2630v4 or 4114 processor<br>
  43. 30 GB RAM<br>
  44. 800 GB disk space (100% SSD)<br>
  45. OS: Debian 9<br>
  46.  
  47. <strong>Installed apps</strong><br>
  48. Zabbix<br>
  49. GLPI<br>
  50. Kibana (Wazuh)<br>
  51.  
  52. <strong>Support</strong><br>
  53. Apps Configuration via email or chat<br>
  54. VPS<br>
  55. Apps
  56. </p></div>
  57. ";
  58. };
  59. if ($plan=='3') {
  60. return "<div style='width:400px; border:1px solid #eee; padding:20px;background: #faf8f4;margin:30px 0' align='center'><h3>Custom plan</h3><br></div>";
  61. }
  62. };
  63.  
  64.  
  65.  
  66. if (isset($_POST['token']) && isset($_POST['action'])) {
  67. $captcha_token = $_POST['token'];
  68. $captcha_action = $_POST['action'];
  69. } else {
  70. die('Капча работает некорректно. Обратитесь к администратору!');
  71. }
  72.  
  73. $url = 'https://www.google.com/recaptcha/api/siteverify';
  74. $params = [
  75. 'secret' => '___',
  76. 'response' => $captcha_token,
  77. 'remoteip' => $_SERVER['REMOTE_ADDR']
  78. ];
  79.  
  80. $ch = curl_init($url);
  81. curl_setopt($ch, CURLOPT_POST, 1);
  82. curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
  83. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  84. curl_setopt($ch, CURLOPT_HEADER, 0);
  85. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  86.  
  87. $response = curl_exec($ch);
  88. if(!empty($response)) $decoded_response = json_decode($response);
  89.  
  90. $success = false;
  91.  
  92. if ($decoded_response && $decoded_response->success && $decoded_response->action == $captcha_action && $decoded_response->score > 0) {
  93. $success = $decoded_response->success;
  94. // обрабатываем данные формы, которая защищена капчей
  95.  
  96.  
  97. function cURL($url, $ref, $header, $cookie, $p){
  98. $ch = curl_init();
  99. curl_setopt($ch, CURLOPT_URL, $url);
  100. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  101. curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
  102. curl_setopt($ch, CURLOPT_REFERER, $ref);
  103. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  104. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  105. if ($p) {
  106. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  107. curl_setopt($ch, CURLOPT_POST, 1);
  108. curl_setopt($ch, CURLOPT_POSTFIELDS, $p);
  109. }
  110. $result = curl_exec($ch);
  111. curl_close($ch);
  112. if ($result){
  113. return $result;
  114. }else{
  115. return '';
  116. }
  117. }
  118.  
  119.  
  120. $qstring = "https://173.212.216.142:4444/API?function=add_user&family=&name=".urlencode($name)."&patronymic=&email=".urlencode($email)."&tariff_scheme_id=$plan";
  121. $json_file = cURL($qstring,'',0,0,null);
  122. $json_array = json_decode($json_file, true);
  123. //$desc = $json_array['result'];
  124. $result = $json_array['result'];
  125. $json_array['customermessage'] = $message;
  126. $json_array['password'] = $password;
  127.  
  128. //$result='OK';
  129. if ($result == 'OK') {
  130. $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>";
  131.  
  132.  
  133. // Send message to SLACK
  134.  
  135. // Create a constant to store your Slack URL
  136. define('SLACK_WEBHOOK', 'https://hooks.slack.com/services/___/___/_____');
  137.  
  138. // Make your message
  139. $msgslack = "New user registered\n Name: $name\n Email: $email\n Plan: $plan\n Message: $message";
  140. $ms = array('payload' => json_encode(array('text' => $msgslack)));
  141. // Use curl to send your message
  142. $c = curl_init(SLACK_WEBHOOK);
  143.  
  144. curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
  145. curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
  146. curl_setopt($c, CURLOPT_POST, true);
  147. curl_setopt($c, CURLOPT_POSTFIELDS, $ms);
  148. curl_exec($c);
  149. curl_close($c);
  150.  
  151. // </ send message to SLACK
  152.  
  153. // Mail init
  154. require 'PHPMailerAutoload.php';
  155. $mail = new PHPMailer;
  156.  
  157. $mail->isSMTP(); // Set mailer to use SMTP
  158. $mail->Host = 'mail.int-cloud.net'; // Specify main and backup SMTP servers
  159. $mail->SMTPAuth = true; // Enable SMTP authentication
  160. $mail->Username = 'reg@int-cloud.net'; // SMTP username
  161. $mail->Password = 'xRtw;?2X$Htl'; // SMTP password
  162. $mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
  163. $mail->Port = 465; // TCP port to connect to
  164. $mail->isHTML(true); // Set email format to HTML
  165.  
  166. // Send message to INT office
  167. $mail->setFrom('robot@int-cloud.net', 'Mailer');
  168. $mail->addAddress('reg@int-cloud.net', 'Office'); // Add a recipient
  169. $mail->addReplyTo('reg@int-cloud.net', 'Int robot');
  170. $mail->Subject = 'New user registered';
  171. $mail->Body = "Name: $name <br>Email: $email<br>Plan: $plan<br>Message: <br>$message ";
  172. $mail->AltBody = 'Тело письма тупо текст';
  173.  
  174. if(!$mail->send()) {
  175. echo 'Debug: mail not sent';
  176. echo 'Errors: ' . $mail->ErrorInfo;
  177. } else {
  178. }
  179.  
  180. // Send message to customer
  181.  
  182. $mail->setFrom('robot@int-cloud.net', 'Int-cloud mailer');
  183. $mail->addAddress($email, $name); // Add a recipient
  184. $mail->addReplyTo('reg@int-cloud.net', 'Int-cloud support center');
  185. $mail->Subject = 'Int-cloud registration';
  186. $mail->Body = "Dear $name,<br>
  187. Thank you very much for your order at INT-Cloud!<br>
  188. Below, you will find details<br>".getPlanText($plan)."
  189. <br><br>
  190. 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>
  191. 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>
  192. <br>
  193. We are very happy to welcome you as a new customer.<br>
  194. <br>
  195. Best regards,<br>
  196. <br>
  197. Your INT-Cloud team";
  198.  
  199. if(!$mail->send()) {
  200. echo 'Debug: mail to customer not sent';
  201. echo 'Errors: ' . $mail->ErrorInfo;
  202. } else {
  203. echo 'Debug: mail to customer sent successfuly';
  204. }
  205. }
  206.  
  207. if ($result === 'error') {
  208. $json_array['landmessage'] = $json_array['description'];
  209. }
  210.  
  211. //echo json_encode($json_array);
  212. // echo ("Debug. Captcha success string: ".$success);
  213. echo ($json_array['landmessage']);
  214. echo "Debug. Recaptcha response: ";
  215. var_dump($decoded_response);
  216.  
  217.  
  218. } else {
  219. // прописываем действие, если пользователь оказался ботом
  220. echo "ReCaptcha not passed. Aren't you a bot?";
  221. }
  222.  
  223. //echo json_encode($success);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement