error("Invalid " . json_encode(array("title" => valid($_POST['title']), "author" => valid($_POST['author']), "lines" => valid($_POST['lines']), "id" => valid($_POST['id'])))); } } else { if ($mode == "GET_BOOKS") { $who = clean($_POST['who']); if (!valid($who)) { error("Invalid"); } else { $query = mysql_query("SELECT * FROM `snmail2` WHERE `to`='{$who}'") or die(mysql_error()); if (mysql_num_rows($query) > 0) { echo json_encode(array("message" => "inbox", "status" => "OK", "username" => $who, "unread" => mysql_num_rows($query))); while ($array = mysql_fetch_array($query)) { $to = $array['to']; $from = $array['from']; $rawLines = $array['lines']; $lines = dirty($rawLines); $id = $array['id']; // Generate $mailMess = array(); $mailMess["id"] = $id; $mailMess["to"] = $to; $mailMess["from"] = $from; $mailMess["lines"] = $lines; echo "\n" . json_encode($mailMess); } mysql_query("DELETE FROM `snmail2` WHERE `to`='{$who}'") or die(mysql_error()); } else { echo json_encode(array("message" => "no mail", "status" => "OK")); } } } else {
$useIp = false; if (valid($_REQUEST['ip'])) { $ip = clean($_REQUEST['ip']); $useIp = true; } $words = array(); $query = null; $title = "UNKNOWN"; if ($useIp) { $query = mysql_query("SELECT `message` FROM `mail` WHERE `sent_from`='{$ip}'"); } else { $query = mysql_query("SELECT `message` FROM `mail`"); } if (mysql_num_rows($query) > 0) { while ($a = mysql_fetch_array($query)) { $word = explode(" ", cClean(dirty($a['message']))); foreach ($word as $w) { $w = strtolower(str_replace(" ", "", $w)); if (strlen($w) > 0) { $words[$w]++; } } } if ($useIp) { $title = "<h1>Word use for {$ip} (" . mysql_num_rows($query) . " messages, " . count($words) . " words)</h1>"; } else { $title = "<h1>Word use for GLOBAL (" . mysql_num_rows($query) . " messages, " . count($words) . " words)</h1>"; } echo $title; arsort($words); foreach ($words as $key => $val) {