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