<?php
if(!isset($_GET['s'])) {
die('You must define a search term!');
}
$highlight = true;//highlight results or not
$search_in = array('html', 'htm');//allowable filetypes to search in
$search_dir = '.';//starting directory
$recursive = true;//should it search recursively or not
define('SIDE_CHARS', 80);
$file_count = 0;
$search_term = mb_strtolower($_GET['s'], 'UTF-8');
//$search_term = $_GET['s'];
$search_term_length = strlen($search_term);
$final_result = array();
$files = list_files($search_dir);
foreach($files as $file){
$contents = file_get_contents($file);
preg_match("/\<title\>(.*)\<\/title\>/", $contents, $page_title); //getting page title
if (preg_match("#\<body.*\>(.*)\<\/body\>#si", $contents, $body_content)){ //getting content only between <body></body> tags
$clean_content = strip_tags($body_content[0]); //remove html tags
$clean_content = preg_replace( '/\s+/', ' ', $clean_content ); //remove duplicate whitespaces, carriage returns, tabs, etc
//$found = strpos_recursive($clean_content, $search_term);
$found = strpos_recursive(mb_strtolower($clean_content, 'UTF-8'), $search_term);
$final_result[$file_count]['page_title'][] = $page_title[1];
$final_result[$file_count]['file_name'][] = $file;
}
if($found && !empty($found)) {
for ($z = 0; $z < count($found[0]); $z++){
$pos = $found[0][$z][1];
$side_chars = SIDE_CHARS;
if ($pos < SIDE_CHARS){
$side_chars = $pos;
$pos_end = SIDE_CHARS + $search_term_length;
}else{
$pos_end = SIDE_CHARS*2 + $search_term_length;
}
$pos_start = $pos - $side_chars;
$str = substr($clean_content, $pos_start, $pos_end);
$result = preg_replace('#'.$search_term.'#ui', '<span class="search_result">\0</span>', $str);
//$result = preg_replace('#'.$search_term.'#ui', '<span class="search">'.$search_term.'</span>', $str);
$final_result[$file_count]['search_result'][] = $result;
}
} else {
$final_result[$file_count]['search_result'][] = '';
}
$file_count++;
}
?>
<ol class="search_list">
<?php
$match_count = 0;
for ($i=0; $i < count($final_result); $i++){
if (!empty($final_result[$i]['search_result'][0]) || $final_result[$i]['search_result'][0] !== ''){
$match_count++;
?>
<li>
<h3 class="search_title"><a target="_top" href="<?php echo $final_result[$i]['file_name'][0]; ?>" class="search_link"> <?php echo $final_result[$i]['page_title'][0]; ?> </a></h3>
<p>...<?php echo $final_result[$i]['search_result'][0]; ?>...
<br><span class="search_result">Terms matched: <?php echo count($final_result[$i]['search_result']); ?> - URL: <?php echo $final_result[$i]['file_name'][0]; ?></span></p>
</li>
<?php
}
}
if ($match_count == 0) {
echo '<h4>No results found for <span class="search">'.$search_term.'</span></h4>';
}
?>
</ol>
<?php
//lists all the files in the directory given (and sub-directories if it is enabled)
function list_files($dir){
global $recursive, $search_in;
$result = array();
if(is_dir($dir)){
if($dh = opendir($dir)){
while (($file = readdir($dh)) !== false) {
if(!($file == '.' || $file == '..')){
$file = $dir.'/'.$file;
if(is_dir($file) && $recursive == true && $file != './.' && $file != './..'){
$result = array_merge($result, list_files($file));
}
else if(!is_dir($file)){
if(in_array(get_file_extension($file), $search_in)){
$result[] = $file;
}
}
}
}
}
}
return $result;
}
//returns the extention of a file
function get_file_extension($filename){
$result = '';
$parts = explode('.', $filename);
if(is_array($parts) && count($parts) > 1){
$result = end($parts);
}
return $result;
}
function strpos_recursive($haystack, $needle, $offset = 0, &$results = array()) {
$offset = stripos($haystack, $needle, $offset);
if($offset === false) {
return $results;
} else {
$pattern = '/'.$needle.'/ui';
preg_match_all($pattern, $haystack, $results, PREG_OFFSET_CAPTURE);
return $results;
}
}
?>
没有合适的资源?快使用搜索试试~ 我知道了~
棕色仿flash动画jquery交互个人网站模板
共337个文件
png:186个
jpg:56个
js:44个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 68 浏览量
2021-11-06
12:46:10
上传
评论
收藏 6.63MB RAR 举报
温馨提示
棕色仿flash动画jquery交互个人网站模板_棕色 动画 交互 jquery 仿flash 简历 web简历 窄 个人 网站 作品 案例 迷你
资源推荐
资源详情
资源评论
收起资源包目录
棕色仿flash动画jquery交互个人网站模板 (337个子文件)
bootstrap.css 121KB
bootstrap.css 120KB
tm_docs.css 66KB
camera.css 26KB
docs.css 22KB
bootstrap-responsive.css 21KB
style.css 18KB
docs.css 6KB
jquery.fancybox.css 4KB
prettify.css 817B
ie.css 220B
ie.css 60B
preview.css 0B
Thumbs.db 233KB
Thumbs.db 7KB
Thumbs.db 6KB
camera-loader.gif 9KB
fancybox_loading.gif 4KB
gallLoader.gif 3KB
web_site_loader.gif 3KB
page_loader.gif 3KB
360x268.gif 1KB
blank.gif 1KB
260x180.gif 949B
160x120.gif 539B
blank.gif 43B
components.html 104KB
base-css.html 91KB
javascript.html 86KB
portfolio.html 41KB
scaffolding.html 25KB
social_media.html 20KB
css3.html 20KB
slider.html 12KB
under_construction.html 7KB
index.html 5KB
index-6.html 5KB
intro.html 5KB
index-1.html 4KB
index-3.html 4KB
index-7.html 3KB
index-4.html 3KB
index-5.html 3KB
index-2.html 3KB
index-8.html 3KB
404.html 2KB
index.html 142B
favicon.ico 894B
page4_big_pic3.jpg 418KB
page2_big_pic4.jpg 363KB
bg_pic1.jpg 354KB
shelter.jpg 352KB
page2_big_pic2.jpg 347KB
page4_big_pic1.jpg 315KB
tree.jpg 295KB
page4_big_pic2.jpg 279KB
bridge.jpg 257KB
road.jpg 256KB
page4_big_pic4.jpg 190KB
page2_big_pic1.jpg 189KB
leaf.jpg 178KB
page2_big_pic3.jpg 144KB
bootstrap-mdo-sfmoma-01.jpg 129KB
big_bunny_fake.jpg 120KB
page4_big_pic5.jpg 118KB
sea.jpg 113KB
700x430_6.jpg 111KB
700x430_8.jpg 107KB
700x430_2.jpg 98KB
bootstrap-mdo-sfmoma-02.jpg 84KB
700x430_5.jpg 84KB
700x430_4.jpg 77KB
700x430_7.jpg 77KB
700x430_3.jpg 71KB
700x430_1.jpg 70KB
bootstrap-mdo-sfmoma-03.jpg 54KB
page4_pic1.jpg 21KB
page2_pic1.jpg 20KB
page4_pic3.jpg 18KB
page1_pic1.jpg 17KB
page4_pic4.jpg 16KB
page4_pic2.jpg 16KB
page4_pic5.jpg 12KB
page5_pic2.jpg 12KB
page2_pic3.jpg 12KB
120x120_8.jpg 11KB
page5_pic1.jpg 11KB
page2_pic2.jpg 11KB
120x120_2.jpg 10KB
page2_pic5.jpg 10KB
120x120_5.jpg 10KB
120x120_6.jpg 9KB
120x120_7.jpg 9KB
120x120_3.jpg 8KB
120x120_1.jpg 8KB
120x120_4.jpg 8KB
page2_pic4.jpg 7KB
leaf.jpg 5KB
big_bunny_fake.jpg 5KB
tree.jpg 5KB
共 337 条
- 1
- 2
- 3
- 4
资源评论
半抹灯芯
- 粉丝: 54
- 资源: 1075
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功