0.3 First Public Versiob
[smail.git/.git] / mailbox / raw_mails.php
1 <?php
2 function scan_dir($dir) {
3     $ignored = array('.', '..', '.htaccess','index.php','getmail.php');
4     $files = array();    
5     foreach (scandir($dir) as $file) {
6         if (in_array($file, $ignored)) continue;
7             $files[$file] = filemtime($dir . '/' . $file);
8         }
9         arsort($files);
10         $files = array_keys($files);
11         return ($files) ? $files : false;
12 }
13 include '../api/functions.php';
14 session_issruning();
15 if (isloged()==1){
16     if (isset($_GET['box'])){
17         if (strpos($_GET['box'],'/') or strpos($_GET['box'],'..') or strpos($_GET['box'],'\\')){}
18         else{
19             if ($_GET['box']==''){$_GET['box']=='mails';}
20             echo 'Raw Box of '.preg_split('/@/',$_SESSION['m_user'])[0].'\\'.$_GET['box'].'\\<br>';
21             foreach (scan_dir(getcwd().'\\'.preg_split('/@/',$_SESSION['m_user'])[0].'\\'.$_GET['box'].'\\') as $d){
22                 include preg_split('/@/',$_SESSION['m_user'])[0].'\\'.$_GET['box'].'\\'.$d;
23                 try{echo '<a href="getmail.php?box='.$_GET['box'].'&id='.$d.'">'.$sender.'</a> '.$date.'<br>';}catch (Exception $e){echo '<a href="getmail.php?id='.$d.'">'.$sender.'</a> <br>';}
24             }
25         }
26     }
27     else{
28         foreach (scan_dir(getcwd().'\\'.preg_split('/@/',$_SESSION['m_user'])[0]) as $d){
29             foreach (scan_dir(getcwd().'\\'.preg_split('/@/',$_SESSION['m_user'])[0].'\\'.$d.'\\') as $i){
30                 include preg_split('/@/',$_SESSION['m_user'])[0].'\\'.$d.'\\'.$i;
31                 echo '<a href="getmail.php?id='.$i.'">'.$sender.'</a> '.$date.' '.$d.'<br> ';
32             }
33         }
34     }
35 }
36 else{
37     header('Location: ../login.html');
38 }
39 ?>