it uses "post" so no querystring
There are all sorts of tricks used to output the js correctly so careless editing may break the script
The actual file lists are not in the xtscript so should not get timeouts
The search query must be 2 or more chars and is filtered against malicious input
This version is set up to search 4 folders
still subject to change
SUGGESTIONS WELCOME
demo http://ggnnww.yn.lt/filelist_folder/newsearch
<!--parser:xtscript-->
var $per_page=5
get search
# Search string health check
var $star= call strpos $haystack=#$search;$needle=*
var $query= call strpos $haystack=#$search;$needle=?
var $dquot= call strpos $haystack=#$search;$needle="
var $squot= call strpos $haystack=#$search;$needle='
if not $search or $star or $query or $dquot or $squot
del $search
var $disable_js=//
goto @end1
endif
# Search string length check
var $len=call strlen $val=$search
if $len < 2
del $search
print search string too short min 2 chars<br />
goto @end1
endif
# Do the search
get anywhere
if $anywhere
var $checked=checked="checked"
var $any=*
endif
var $dummy=['dummy']
# Filelist template that creates javascript array
var $template=['.file_name_parsed.','.file_url.','.file_size.','.file_datetime.','.file_mime.'],
# Filelist templates
var $list1= xt:filelist folder="/FOLDER1" template="$template" filter="$any$search*.*" per_page="0"
var $list2= xt:filelist folder="/FOLDER2" template="$template" filter="$any$search*.*" per_page="0"
var $list3= xt:filelist folder="/FOLDER3" template="$template" filter="$any$search*.*" per_page="0"
var $list4= xt:filelist folder="/FOLDER4" template="$template" filter="$any$search*.*" per_page="0"
@end1
# The search form
print {{<div style="border:1px solid;padding:2px;margin:2px;display:inline-block">
<form action="<xt:url/>" method="post">
<input type="search" name="search" value="$search" />
<input type="submit" value="go" /><br />
Anywhere in filename <input type="checkbox" name="anywhere" value="1" $checked />
</form>
</div><br />}}
# The actual filelist functions are created below
<!--/parser:xtscript-->
<script type="text/javascript">
{_$$disable_js|}var list=[<{_$$list1|} ><{_$$list2|} ><{_$$list3|} ><{_$$list4|} >{_$$dummy|}];
<!--parser:xtscript-->
# The output script
get_or_default results_page;0
if $search
print {{list.length=list.length-1;
var length=list.length;
if (length){
var total_pages=Math.floor(}}
print {{list.length/$per_page);
var results_page=$results_page;
var search='$search';
var per_page=$per_page}}
print_raw {{;
var offset=(results_page*per_page);
var page_end=(offset + per_page);
if (page_end > length)page_end=length;
list.sort();
document.write('<div style="border:1px solid;padding:2px;margin:2px;text-align:left">');
if (length > 1)document.write((offset+1)+' to '+page_end+' of ');
document.write( length+' Result');
if (length > 1) document.write('s');
document.write(' For "<b>'+search+'</b>"<br />');
for(i=offset;i < page_end;i++){
document.write('<div style="border:1px solid;padding:2px;margin:2px;text-align:left;">');
document.write('<a href="'+list[i][1]+'?__xt_download=1">'+list[i][0]+'</a><br />');
document.write('Url <input value="'+list[i][1]+'" /><br />');
document.write('<small> Size <span>'+list[i][2]+'</span>');
document.write(' Date <span>'+list[i][3]+'</span>');
document.write(' Type <span>'+list[i][4]+'</span></small></div>');}
}}
# Pagination
print_raw {{
if (length > per_page){
document.write('<div>');
if (offset){
document.write('<form style="display:inline" action="<xt:url />" method="post"><input type="hidden" name="results_page" value="'+(results_page-1)+'" />}}
print <input type="hidden" name="search" value="$search" /><input type="hidden" name="anywhere" value="$anywhere" />
print_raw {{<input type="submit" value="←" /></form>');} else {document.write('<input type="button" value="•" />');}
if (page_end < length){
document.write('<form style="display:inline" action="<xt:url />" method="post"><input type="hidden" name="results_page" value="'+(results_page+1)+'" />}}
print <input type="hidden" name="search" value="$search" /><input type="hidden" name="anywhere" value="$anywhere" />
print_raw {{<input type="submit" value="→" /></form>');} else {document.write('<input type="button" value="•" />');}
document.write('</div>');}
document.write('</div>'); ;}}
endif
if $search
print } else {document.write('<div style="border:1px solid;padding:2px;margin:2px;display:inline-block;text-align:left;">
print No results for $search</div>');}
endif
<!--/parser:xtscript-->
</script>
Copy code
var $per_page=5
get search
# Search string health check
var $star= call strpos $haystack=#$search;$needle=*
var $query= call strpos $haystack=#$search;$needle=?
var $dquot= call strpos $haystack=#$search;$needle="
var $squot= call strpos $haystack=#$search;$needle='
if not $search or $star or $query or $dquot or $squot
del $search
var $disable_js=//
goto @end1
endif
# Search string length check
var $len=call strlen $val=$search
if $len < 2
del $search
print search string too short min 2 chars<br />
goto @end1
endif
# Do the search
get anywhere
if $anywhere
var $checked=checked="checked"
var $any=*
endif
var $dummy=['dummy']
# Filelist template that creates javascript array
var $template=['.file_name_parsed.','.file_url.','.file_size.','.file_datetime.','.file_mime.'],
# Filelist templates
var $list1= xt:filelist folder="/FOLDER1" template="$template" filter="$any$search*.*" per_page="0"
var $list2= xt:filelist folder="/FOLDER2" template="$template" filter="$any$search*.*" per_page="0"
var $list3= xt:filelist folder="/FOLDER3" template="$template" filter="$any$search*.*" per_page="0"
var $list4= xt:filelist folder="/FOLDER4" template="$template" filter="$any$search*.*" per_page="0"
@end1
# The search form
print {{<div style="border:1px solid;padding:2px;margin:2px;display:inline-block">
<form action="<xt:url/>" method="post">
<input type="search" name="search" value="$search" />
<input type="submit" value="go" /><br />
Anywhere in filename <input type="checkbox" name="anywhere" value="1" $checked />
</form>
</div><br />}}
# The actual filelist functions are created below
<!--/parser:xtscript-->
<script type="text/javascript">
{_$$disable_js|}var list=[<{_$$list1|} ><{_$$list2|} ><{_$$list3|} ><{_$$list4|} >{_$$dummy|}];
<!--parser:xtscript-->
# The output script
get_or_default results_page;0
if $search
print {{list.length=list.length-1;
var length=list.length;
if (length){
var total_pages=Math.floor(}}
print {{list.length/$per_page);
var results_page=$results_page;
var search='$search';
var per_page=$per_page}}
print_raw {{;
var offset=(results_page*per_page);
var page_end=(offset + per_page);
if (page_end > length)page_end=length;
list.sort();
document.write('<div style="border:1px solid;padding:2px;margin:2px;text-align:left">');
if (length > 1)document.write((offset+1)+' to '+page_end+' of ');
document.write( length+' Result');
if (length > 1) document.write('s');
document.write(' For "<b>'+search+'</b>"<br />');
for(i=offset;i < page_end;i++){
document.write('<div style="border:1px solid;padding:2px;margin:2px;text-align:left;">');
document.write('<a href="'+list[i][1]+'?__xt_download=1">'+list[i][0]+'</a><br />');
document.write('Url <input value="'+list[i][1]+'" /><br />');
document.write('<small> Size <span>'+list[i][2]+'</span>');
document.write(' Date <span>'+list[i][3]+'</span>');
document.write(' Type <span>'+list[i][4]+'</span></small></div>');}
}}
# Pagination
print_raw {{
if (length > per_page){
document.write('<div>');
if (offset){
document.write('<form style="display:inline" action="<xt:url />" method="post"><input type="hidden" name="results_page" value="'+(results_page-1)+'" />}}
print <input type="hidden" name="search" value="$search" /><input type="hidden" name="anywhere" value="$anywhere" />
print_raw {{<input type="submit" value="←" /></form>');} else {document.write('<input type="button" value="•" />');}
if (page_end < length){
document.write('<form style="display:inline" action="<xt:url />" method="post"><input type="hidden" name="results_page" value="'+(results_page+1)+'" />}}
print <input type="hidden" name="search" value="$search" /><input type="hidden" name="anywhere" value="$anywhere" />
print_raw {{<input type="submit" value="→" /></form>');} else {document.write('<input type="button" value="•" />');}
document.write('</div>');}
document.write('</div>'); ;}}
endif
if $search
print } else {document.write('<div style="border:1px solid;padding:2px;margin:2px;display:inline-block;text-align:left;">
print No results for $search</div>');}
endif
<!--/parser:xtscript-->
</script>
Copy code