/** * 根据变量列表,判断某个元素的类型 * 如: * (1)$sql = "select * from user where uid=".$uid ; * 那么uid为数值类型 * (2)$sql = "select * from user where uid='".$uid ."'" ; * 那么uid为字符类型 * @param array $vars */ public function addTypeByVars(&$vars) { $len = count($vars); //调整顺序 if ($len > 2) { $item_1 = $vars[0]; $item_2 = $vars[1]; $vars[0] = $item_2; $vars[1] = $item_1; unset($item_1); unset($item_2); } //设置type for ($i = 0; $i < $len; $i++) { //如果元素有前驱和后继 if ($i - 1 >= 0 && $i + 1 <= $len - 1) { $is_pre_value = $vars[$i - 1] instanceof ValueSymbol; $is_curr_var = !$vars[$i] instanceof ValueSymbol; $is_nex_value = $vars[$i + 1] instanceof ValueSymbol; //如果前驱后继都不是value类型或者当前symbol不是变量,则pass if (!$is_pre_value || !$is_nex_value || !$is_curr_var) { continue; } //判断是否被单引号包裹 $is_start_with = CommonUtils::startWith($vars[$i - 1]->getValue(), "'"); $is_end_with = CommonUtils::endsWith($vars[$i + 1]->getValue(), "'"); if ($is_start_with != -1 && $is_end_with != -1) { $vars[$i]->setType("valueInt"); } } else { //如果没有前驱和后继 ,即为开头和结尾,且为var类型,直接设为int if ($vars[$i] instanceof VariableSymbol) { $vars[$i]->setType("valueInt"); } } } }
exit; } //1、从web ui中获取并加载项目工程 $project_path = $_POST['prj_path']; //扫描的工程路径 $scan_path = $_POST['path']; //扫描文件路径 $scan_type = $_POST['type']; //扫描的类型 $encoding = $_POST['encoding']; //CMS的编码 UTF-8 或者 GBK if (CommonUtils::endsWith($project_path, "/")) { $last = count($project_path) - 2; $project_path = substr($project_path, 0, $last); } if (CommonUtils::endsWith($scan_path, "/")) { $last = count($scan_path) - 2; $scan_path = substr($scan_path, 0, $last); } $scan_type = $scanType = strtoupper($scan_type); $encoding = strtoupper($encoding); $project_path = str_replace(array('\\', '//'), '/', $project_path); $scan_path = str_replace(array('\\', '//'), '/', $scan_path); $fileName = str_replace('/', '_', $scan_path); $fileName = str_replace(':', '_', $fileName); $serialPath = CURR_PATH . "/data/resultConetxtSerialData/" . $fileName; if (!is_file($serialPath)) { //创建文件 $fileHandler = fopen($serialPath, 'w'); fclose($fileHandler); }