<?php
$search_str = $_GET['url'];
$results = search('.', $search_str);
if(!$results[0]){
$player=[];
$player['code']=404;
$player['msg']='没有搜索到文件';
$json=json_encode($player,JSON_UNESCAPED_UNICODE);
print_r($json);
exit;
}else{
$player=[];
$player['code']=200;
$player['url']=$results[0];
$json=json_encode($player,JSON_UNESCAPED_UNICODE);
print_r($json);
exit;
}
function search($dir, $search_str) {
$files = scandir($dir);
$results = array();
foreach ($files as $file) {
if ($file == '.' || $file == '..') {
continue;
}
$path = $dir.'/'.$file;
if (is_dir($path)) {
$results = array_merge($results, search($path, $search_str));
} else if (@strpos($file, $search_str) !== false) {
$results[] = $path;
}
}
return $results;
}
?>
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
请登录后发表评论
注册
社交帐号登录