/** * 敏感分析服务 * * @return void */ function searchEngine($data, $runtime = false) { $process_start_time = getCurrentTime(); $result = post(X::getConfigVar("searchEngine"), ["words" => cleanFormat($data['content']), 'if_spam' => $data['if_spam']]); $process_end_time = getCurrentTime(); if ($runtime) { $process_time = round($process_end_time - $process_start_time, 4); //运行时间 return [$result, $process_time]; } return $result; }
/** * 安全输入函数,获取参数并且对参数进行过滤 */ function securelyInput($paramName, $defaultValue = NULL) { switch (strtolower(AT)) { case 'auto': if (is_null($_GET[$paramName]) || $_GET[$paramName] == '') { if (is_null($_POST[$paramName]) || $_POST[$paramName] == '') { return $defaultValue; } else { return cleanFormat($_POST[$paramName]); } } else { return cleanFormat($_GET[$paramName]); } case 'post': if (is_null($_POST[$paramName]) || $_POST[$paramName] == '') { return $defaultValue; } else { return cleanFormat($_POST[$paramName]); } case 'get': if (is_null($_GET[$paramName]) || $_GET[$paramName] == '') { return $defaultValue; } else { return cleanFormat($_GET[$paramName]); } default: return NULL; } }
<?php header('Content-Type: application/json'); echo json_encode(['files' => cleanFormat($_FILES['yolo'])]); function cleanFormat($files) { $clean = []; $length = count($files['name']); for ($i = 0; $i < $length; $i++) { $clean[] = ['name' => $files['name'][$i]]; } return $clean; }