$index = (array) json_decode(file_get_contents($path . "/index.json")); $contents = array(); if ($dh = opendir($path)) { while (false !== ($en = readdir($dh))) { if ($en != "." && $en != "..") { array_push($contents, substr($en, 0, -5)); } } } $index["contents"] = $contents; $index["tsample"] = json_decode(file_get_contents($path . "/tsample.json")); echo json_encode($index); break; case "data": //?req=data&tmin=0&tmax=10000000000&node=&metric=hv.0 $path = $CACHEDIR . "/" . sanitized("savename"); //downsampling length $DSLEN = 1000; $tmin = $_GET["tmin"] + 1 or die("Must specify tmin= parameter"); $tmax = $_GET["tmax"] + 1 or die("Must specify tmax= parameter"); $metric = $_GET["metric"] or die("Must specify metric= parameter"); $times = json_decode(file_get_contents($path . "/tsample.json")); $data = json_decode(file_get_contents($path . "/" . $metric . ".json")); $ret = array(); $dx = 0; while ($times[$dx] < $tmin && $dx < count($times) - 1) { ++$dx; } while ($times[$dx] < $tmax && $dx < count($times) - 1) { array_push($ret, array($times[$dx], $data[$dx])); ++$dx;
*/ include "config.php"; if (isset($_GET["message"]) && isset($_GET["user_from"]) && isset($_GET["user_to"])) { $message = strip_tags($_GET["message"]); $user_from = strip_tags($_GET["user_from"]); $user_to = strip_tags($_GET["user_to"]); if (strlen($message) < 1) { echo 1; } else { if (strlen($message) > 500) { echo 2; } else { $search = array("<", ">", ">", "<"); function sanitized($text) { $text = htmlspecialchars($text, ENT_QUOTES); $text = str_replace("\n\r", "\n", $text); $text = str_replace("\r\n", "\n", $text); $text = str_replace("\n", "<br>", $text); return $text; } $result = mysql_query("select * from `chat` where `to` = '" . mysql_real_escape_string(str_replace($search, "", $user_from)) . "' and `from` = '" . mysql_real_escape_string(str_replace($search, "", $user_to)) . "' and `receiver_read` = '" . mysql_real_escape_string("no") . "'"); if (mysql_num_rows($result) > 0) { mysql_query("update `chat` set `receiver_read` = '" . mysql_real_escape_string("yes") . "' where `to` = '" . mysql_real_escape_string(str_replace($search, "", $user_from)) . "' and `from` = '" . mysql_real_escape_string(str_replace($search, "", $user_to)) . "' and `receiver_read` = '" . mysql_real_escape_string("no") . "'"); } mysql_query("insert into `chat` values ('', '" . mysql_real_escape_string(str_replace($search, "", $user_to)) . "', '" . mysql_real_escape_string(str_replace($search, "", $user_from)) . "', '" . mysql_real_escape_string(sanitized($message)) . "', '" . mysql_real_escape_string(time()) . "', '" . mysql_real_escape_string("yes") . "', '" . mysql_real_escape_string("no") . "', '" . mysql_real_escape_string("no") . "', '" . mysql_real_escape_string("no") . "', '')") or die(3); } } } else { echo 4; }