$maxlength) { $length = $maxlength; } $i = 0; while ($i < $length) { $char = substr($possible, mt_rand(0, $maxlength-1), 1); if (!strstr($password, $char)) { $password .= $char; $i++; } } return $password; } function GetPostValues() { if (!empty($_POST)) { $kv = array(); foreach ($_POST as $key => $value) { $kv[] = "$key=$value"; } $q = join("&", $kv); } else { $q = 0; } return $q; } $file = fopen($mylogfile, "a"); $mydate = date("YmdHis"); $myfunc = $_GET['s']; $q = GetPostValues(); fputs($file, "$mydate $myfunc IN $q\r\n"); if ($myfunc == 'once') { $output = '{"status":0,"body":{"once":"'. generateString(8).'-'.generateString(8) .'"}}'; } if ($myfunc == 'session') { if ($_POST['action']=='new') { $output = '{"status":0,"body":{"sessionid":"'. generateString(4) . '-' . generateString(8) . '-' . generateString(8) .'","sp":{"users":[{"id":5555751,"benutzer":"nick","wt":100.7,"ht":1.88, "agt":25.1,"sx":1,"fm":3,"cr":1302150411,"att":0}]},"ind":{"lg":"en_EN","imt":1,"stp":1,"f":0,"g":89522},"syp":{"utc":' . time() . '},"ctp":{"goff":7200,"dst":1317872200,"ngoff":3600}}}'; } if ($_POST['action']=='delete') { $output = '{"status":0}'; } } if ($myfunc == 'maint') { $output = '{"status":0}'; } if ($myfunc == 'measure') { $output = '{"status":0}'; if (!empty($_POST['macaddress'])) { $str = str_replace('[','',(str_replace(']','',$_POST['measures']))); $obj = json_decode($str); $myweight = $obj->measures->value; $myweightdot = substr($myweight,0,3).'.'.substr($myweight,3,3); $myuserid = $_POST['userid']; $mytime = $_POST['meastime']; $file2 = fopen($mydatafile, "a"); fputs($file2, "$mydate $mytime $myweightdot\r\n"); fclose($file2); } } echo $output; fputs($file, "$mydate $myfunc OUT $output\r\n"); fclose($file); ?>