7138742b80d89a7c0d206ecd99f7233ef78edcb3
[saltmail.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><?php if (isset($_GET['channel'])){?>Mail Box - Special<?php } else{ ?>Mail Box<?php } ?> <?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['channel'])){
38                 if (is_dir($_GET['channel']) and strpos($_GET['channel'],'/')==false and strpos($_GET['channel'],'..')==false or strpos($_GET['channel'],'\\')==false){
39                     $dirs=scan_dir(getcwd().'/'.$_GET['channel'].'/mails/');
40                     if (($dirs==false)==false){
41                         foreach ($dirs as $files){
42                             include getcwd().'/'.$_GET['channel'].'/mails/'.$files;
43                             echo '<span class="mail"><a href="'.$_GET['channel'].'/mails/'.$files.'">'.substr($content,0,20).'...</a> <text>'.str_replace('-','/',$date).'</text> </span><br>
44 ';  
45                         }
46                     }
47                 }
48             }
49             elseif (isset($_GET['box'])){
50                 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){
51                     $dirs=scan_dir(getcwd().'/'.preg_split('/@/',$_SESSION['m_user'])[0].'/'.$_GET['box']);
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?box='.$_GET['box'].'&id='.$i.'">'.$sender.'</a> <text>'.str_replace('-','/',$date).'</text> <a href="getmail.php?delthem='.$i.'">Delete</a></span><br>
57 ';
58                         }
59                     }
60                 }
61             }
62             else{
63                 $dirs=scan_dir(getcwd().'/'.preg_split('/@/',$_SESSION['m_user'])[0].'/mails/');
64                 if (($dirs==false)==false){
65                     foreach ($dirs as $i){
66                         $date='';
67                         include preg_split('/@/',$_SESSION['m_user'])[0].'/mails/'.$i;
68                         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>
69 ';
70                     }
71                 }
72                 else{
73                     echo '<text>'.L::mbox_dhave.'<br></text>';
74                 }
75             }
76         }
77         else{
78             http_response_code(404);
79         }
80
81         ?>
82         <text><?php echo L::mbox_note;?></text>
83     <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>
84         </body>
85 </html>