Faster Update, fixing bugs
[smail.git/.git] / mailbox / mailb.php
1 <?php
2 ini_set('display_errors',1);
3 ini_set('display_initial_errors',1);
4 error_reporting(E_ALL);
5 require '../api/functions.php';
6 session_issruning();
7 if (isloged()==0){
8     header('Location: ../login.php');
9     die();
10 }
11 ?>
12 <?php include '../i18n.class.php'; $i18n = new i18n('../lang/lang_{LANGUAGE}.ini'); $i18n->init();?>
13 <html>
14     <head>
15         <link type='text/css' rel='stylesheet' href='../css/all.css'/>
16         <link type='text/css' rel='stylesheet' href='../css/mailbox.css?v=1'/>
17     </head>
18     <body>
19         <h1>Mail Box <?php if(isset($_GET['box'])==true){echo $_GET['box'];}?></h1>
20         <?php
21         if (isset($_GET['info'])){
22             echo str_replace('_',' ',$_GET['info']);
23                         echo '<br>';
24         }
25         function scan_dir($dir) {
26             $ignored = array('.', '..', '.htaccess','mailb.php','getmail.php');
27             $files = array();
28             foreach (scandir($dir) as $file) {
29                 if (in_array($file, $ignored)) continue;
30                     $files[$file] = filemtime($dir . '/' . $file);
31                 }
32                 arsort($files);
33                 $files = array_keys($files);
34                 return ($files) ? $files : false;
35         }
36         if (isloged()==1){
37             if (isset($_GET['box'])){
38                 if (is_dir(preg_split('/@/',$_SESSION['m_user'])[0].'/'.$_GET['box']) and strpos($_GET['box'],'/')==false and strpos($_GET['box'],'..')==false or strpos($_GET['box'],'\\')==false){
39                     $dirs=scan_dir(getcwd().'/'.preg_split('/@/',$_SESSION['m_user'])[0].'/'.$_GET['box']);
40                     if (($dirs==false)==false){
41                         foreach ($dirs as $i){
42                             $date='';
43                             include preg_split('/@/',$_SESSION['m_user'])[0].'/mails/'.$i;
44                             echo '<span class="mail"><a href="getmail.php?box='.$_GET['box'].'&id='.$i.'">'.$sender.'</a> <text>'.str_replace('-','/',$date).'</text> <a href="getmail.php?delthem='.$i.'">Delete</a></span><br>
45 ';
46                         }
47                     }
48                 }
49             }
50             else{
51                 $dirs=scan_dir(getcwd().'/'.preg_split('/@/',$_SESSION['m_user'])[0].'/mails/');
52                 if (($dirs==false)==false){
53                     foreach ($dirs as $i){
54                         $date='';
55                         include preg_split('/@/',$_SESSION['m_user'])[0].'/mails/'.$i;
56                         echo '<span class="mail"><a href="getmail.php?id='.$i.'">'.$sender.'</a> <div class="go"><text>'.str_replace('-','/',$date).'</text> <a href="getmail.php?delthem='.$i.'">Delete</a></div></span><br>
57 ';
58                     }
59                 }
60                 else{
61                     echo '<text>'.L::mbox_dhave.'<br></text>';
62                 }
63             }
64         }
65         else{
66             http_response_code(404);
67         }
68
69         ?>
70         <text><?php echo L::mbox_note;?></text>
71     <br><a href='../send_m.php'><?php echo L::mbox_send;?></a><text> <?php echo L::mbox_or;?> </text><a href='../ch_p.php'><?php echo L::mbox_change;?></a>
72         </body>
73 </html>