2 error_reporting(E_ALL
); ini_set("display_errors", 1);
3 require_once '../include/messaging.class.php';
5 if (!isset($_COOKIE['DMDM']) && !isset($_COOKIE['MDMD'])) {
10 $email = urldecode(trim($_GET['un']));
11 if(filter_var($email, FILTER_VALIDATE_EMAIL
))
16 define('MDB_PATH', '/home/mdb/');
19 function loggedEmail($email, $directory){
20 $strReplaced = str_replace("@", "-", $email);
21 $firstChar = substr($email, 0, 1);
22 $secondChar = substr($email, 1, 1);
23 $directory = $directory.$firstChar."/".$secondChar."/".$strReplaced."/";
27 function within_str($subject, $lsearch, $rsearch) {
28 $data = strstr($subject, $lsearch);
29 $data = str_replace($lsearch, "", $data);
30 $trim = strstr($data, $rsearch);
32 return(str_replace($trim, "", $data));
35 function notification($directory,$init) {
39 $files = glob("*.dat");
40 foreach($files as $filename){
41 $value = $init->getContent($filename);
46 $from = $init->within_str(max($value), "<from>", "</from>");
47 // $to = $init->within_str(max($value), "<to>", "</to>");
48 $id = $init->within_str(max($value), "<id>", "</id>");
49 // $subj = $init->within_str(max($value), "<subj>", "</subj>");
50 $read = $init->within_str(max($value), "<read>", "</read>");
51 // $msg = $init->within_str(max($value), "<msg>", "</msg>");
52 $array[$filename] = array("id" => $id, "read"=>$read, "from" => $from);
53 // $array[$filename] = array("id" => $id, "subj" =>$subj, "read"=>$read, "msg"=>$msg ,"from" => $from, "to" => $to, );
56 //$array = $init->array_sort($array, 'id', SORT_ASC);
61 throw new Exception("");
64 $array = $init->array_sort($array, 'id', SORT_ASC
);
65 foreach($array as $filename => $value){
66 // $array = file($filename);
67 // $value = max($array);
69 $checkUnread = $value['read'];
75 return ($i==0) ?
'' : $i.",".$date;
78 return $e->getMessage();
83 $userDirectory = loggedEmail($email, MDB_PATH
);
85 $count = notification($userDirectory,$init);
86 echo (empty($count)) ?
"0,0" : $count;