0.3 First Public Versiob
[smail.git/.git] / mailbox / reicive.php
1 <?php 
2 function string($length = 30) {
3     return substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, $length);} 
4
5 if (isset($_POST['mail']) and $_POST['to'] and isset($_POST['html']) and isset($_POST['hash'])){
6     $mail=['mail'=>$_POST['mail'], 'hash'=>$_POST['hash']];
7     $other=array(
8         CURLOPT_URL => 'https://'.preg_split('/@/',$_POST['mail'])[1].'/mailbox/user.php',
9         CURLOPT_POST => true,
10         CURLOPT_POSTFIELDS => $mail,
11         CURLOPT_RETURNTRANSFER => true
12     );
13     $curl=curl_init();
14     curl_setopt_array($curl, ($other));
15     $out=curl_exec($curl);
16     if (curl_error($curl)){
17         http_response_code(400);
18     }
19     else{
20         $info=curl_getinfo($curl,CURLINFO_HTTP_CODE);
21                 echo $info;
22             if ($info==200){
23             if (file_exists($_POST['to'].'/index.php')){
24                                 $date=date('Y-m-d H:i:s');
25                 $content='<?php
26 $html="'.'<!version=0.1>'.str_replace("'",'"',$_POST['html']).'";
27 $sender="'.$_POST['mail'].'";
28 $date="'.$date.'";
29 ?>';
30                 file_put_contents($_POST['to'].'/mails/'.string().'.php',$content);
31                 http_response_code(200);
32             }
33             else{
34                 http_response_code(404);
35             }
36         }
37         else{
38             echo $out;
39             http_response_code(500);
40         }
41     }
42     curl_close($curl);
43 }
44 else{
45     http_response_code(404);
46 }
47 ?>