Initial commit
[2ch-be.git] / dev-test / zwitch / index.bak
blob54dcdbfa6cb3e7904ccd0f914abb51b163a9adfb
1 <?php 
2 include 'config.php'; 
3 include 'include/header.php'; 
5 function array_sort($array, $on, $order=SORT_ASC) {
6   $new_array = array();
7   $sortable_array = array();
8   if (count($array) > 0) {
9     foreach ($array as $k => $v) {
10       if (is_array($v)) {
11         foreach ($v as $k2 => $v2) {
12           if ($k2 == $on) {
13             $sortable_array[$k] = $v2;
14           }
15         }
16       } else {
17         $sortable_array[$k] = $v;
18       }
19     }
21     switch ($order) {
22       case SORT_ASC:
23         asort($sortable_array);
24       break;
25       case SORT_DESC:
26         arsort($sortable_array);
27       break;
28     }
30     foreach ($sortable_array as $k => $v) {
31       $new_array[$k] = $array[$k];
32     }
33   }
35   return $new_array;
38 <body>
39 <div class="container margintopandbottom">
40         <?php include 'menu.php'; ?>
41         <div class="col-md-12">        
42         <div class="panel panel-default"><h1 class="centertext">Be Messaging Monitoring System</h1></div>
43        <?php
44             $inbox = new Message;
45                       
46                             $files = file(DB_PATH."idlist.log");
48                     
49                       $files = file(DB_PATH."idlist.log");
50                       foreach ($files as $key) {
51                              $array[0] = explode("<><>", $key);                                                                 
52                              $worldofArray[0] = $array[0][1];
53                              $dir[] = array('directory' => $inbox->loggedEmail($worldofArray[0], MDB_PATH), 'id' => $array[0][0]);
54                       }
56                       foreach($dir as $key){
57                              if(is_dir($key['directory'])){
58                                      $count = 0;
59                                      $hi = explode("/", $key['directory']);
60                                      $strReplaced = str_replace("-", "@", $hi[5]);
62                                      foreach (glob($key['directory']."*.dat") as $filename){
63                                              $count++;
64                                              $h = explode("/", $filename);
65                                      }
66                                      $arrayContainer[] = array('directory' => $key['directory'], 'id' => $key['id'], 'conversation_count' => $count, 'email' => $strReplaced );
67                           }
68                       }                                                                                         
69                                                    $arrayContainer = array_sort($arrayContainer, 'conversation_count', SORT_DESC);
70                             $returned = array_values($arrayContainer);
71                             // print_r($returned);
72             ?>
73        <table class="table table-bordered table-striped table-responsive">
74         <thead>
75                 <td><strong>ID</strong></td>
76                 <td><strong>Email</strong></td>
77                 <td><strong>Number of Conversation</strong></td>
78         </thead>
79                 <?php
80                 $count = count($arrayContainer)/10;
81                 if(strpos($count,".")>0)
82                   $count = $count+1;
83                 $p = (isset($_GET['p'])&&is_numeric($_GET['p']))?($_GET['p']*10):10;
84                 $s = (isset($_GET['p'])&&is_numeric($_GET['p']))?$p-10:0;
86                 for ($i=$s; $i < $p; $i++) { 
87                   if(isset($returned[$i]))
88                   echo "<tr><td>{$returned[$i]['id']}</td><td><a href=\"conversation.php?em={$returned[$i]['email']}\">{$returned[$i]['email']}</a></td><td>{$returned[$i]['conversation_count']}</td></tr>";                  
89                 }
90                 echo "<ul class=\"pagination\" id='page'>";
91                 for ($i=1; $i <= $count; $i++){ 
92                         $active = ($_GET['p']==$i) ? 'class="active"' : '';               
93                         echo "<li {$active}><a href='{$livesitePath}index.php?p={$i}'>{$i}</a></li>";
94                 }
95                 echo "</ul>";
96                 ?>
97         </table>
98         </div>  
100 </div>
101 </body>
102 </html>