<%@Language=JavaScript%> <% /*Hello*/ // // This is the preferences file for ASPSimpleSearch by // blur software http://blursoftware.com/ASPSimpleSearch/ // ======================================================= // // ASPSimpleSearch - A Free ASP Search Engine // Copyright (C) 2001,2002 Joel Coreson // // Licensed under the GNU General Public License // http://www.gnu.org/licenses/gpl.html // or see the included gpl.txt // var gs_webServerRoot = "E:\\web\\central1\\"; var gs_assRootDir = "E:\\web\\central1\\"; var gs_allowedHosts = "www.centralbiz.biz"; var gs_allowedExtensions = ".htm,.html"; var gs_searchTermTooShort = "2"; var gi_truncateSearch_Bytes = "100000"; var gs_excludedFolders = "stats"; var gs_excludedFiles = ""; %> <% /* ASPSimpleSearch - A Free ASP Search Engine Copyright (C) 2001,2002 Joel Coreson Licensed under the GNU General Public License http://www.gnu.org/licenses/gpl.html or see the included gpl.txt This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 US Contact the author: http://blursoftware.com/contact/ Snail Mail: blur software PO Box 220318 Portland, OR 97269 IMPORTANT: All copyright notices must remain intact both in the scripts and in the output. */ // // ASPSimpleSearch 1.13 // http://blursoftware.com/ASPSimpleSearch/ // ======================================================= // This application is "donation-ware." If you appreciate this // script, please donate $5.00 at my site. If you are using // this script in a business environment, you are encouraged // to donate more (suggested $15 minimum). // // If you've improved the code, found a bug, or have a better way // to do something then the dumb ass way I did ... don't let that // work/thinking you did go to waste! Let me know! // // Please report: // bugs, code improvements, general improvements, wish list items, // or anything else to http://blursoftware.com/contact/ // //===================================================================== // Declare vars / objects / initialize stuff //===================================================================== Response.Buffer = false; Response.CacheControl = 'Private'; //You can find "Response.CharSet" in the setInternationalSupport() function Response.ContentType = 'text/html'; Response.Expires = 0; Server.ScriptTimeout = 30; var gs_assVersion = 'ASPSimpleSearch Engine ver 1.13'; var gs_http_host = 'http://' + Request.ServerVariables( 'HTTP_HOST' ) + '/'; //global search term vars var gs_searchTerm = String( Request.QueryString( 'searchTerm' ) ); var gboo_isSearchTerm = ( Request.QueryString( 'searchTerm' ).Count > 0 ); var gobj_searchTerm = new Object(); //global error handling vars var gary_error = new Array(); var gary_msg = new Array(); //global results vars var gobj_results = new Array(); var gi_resultCount = 0; var gi_fileSizeCount = 0; var gi_scriptTime = 0; var gi_filesSearchedCount = 0; //===================================================================== // Generic Utils //===================================================================== //`````````````````````````````````````````````````` //function wo( as_data ) //-Argument(s): as_data - the string to write to the client. //-Returns: n/a. //-Description: This is a wrapper function for Response.Write(); // Why you ask? Because now you could redirect the output // to somewhere else if you wanted. Plus it saves typing. // BTW, "wo" stands for "Write Out" //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function wo( as_data ) { Response.Write( as_data + '\r' ); } //`````````````````````````````````````````````````` //function htmlEncode( as_data ) //-Argument(s): as_data - the string to HTMLEncode. //-Returns: The HTMLEncoded string. //-Description: This is just like woClean(), but returns the cleaned // string instead of Response.Write()ing it. //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function htmlEncode( as_data ) { return Server.HTMLEncode( String( as_data ) ); } //`````````````````````````````````````````````````` //function isEmpty( as_data ) //-Argument(s): as_data - the string to check //-Returns: true or false //-Description: checks to see if there are any non-whitespace characters. // returns true if there are, false if not. This tells us if // the string is empty or not. //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function isEmpty( as_data ) { return !/\S/g.test( as_data ); } //`````````````````````````````````````````````````` //function trim( as_data ) //-Argument(s): as_data - the string to be trimmed //-Returns: the trimmed string //-Description: This is just a javascript equivalent of the VBScript Trim() // It removes any leading or trailing spaces from the string. //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function trim( as_data ) { return String( as_data ).replace( /^\s+/g, '' ).replace( /\s+$/g, '' ); } //`````````````````````````````````````````````````` //function isValidReferer( as_allowedHosts ) //-Argument(s): as_allowedHosts - comma delimited list of allowed hosts //-Returns: true or false //-Description: Checks the current refferer against the list of valid // refferers, returns true if it's found, false if not. //-Requires: -FUNCTIONS- // addError() //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function isValidReferer( as_allowedHosts ) { if ( as_allowedHosts == '' ) return true; var lary_allowedHosts = as_allowedHosts.toLowerCase().split( ',' ); var ls_http_referrer = String( Request.ServerVariables( 'HTTP_REFERER' ) ).toLowerCase(); for ( var i=0; i' + ls_http_referrer ); return false; } //`````````````````````````````````````````````````` //function isClientConnected() //-Argument(s): none. //-Returns: true or Response.End() //-Description: Checks using Response.IsClientConnected(), returns true if they are, // Response.Ends if they are not. //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function isClientConnected() { if ( !Response.IsClientConnected() ) { //Write this to the window just incase something is broke and there really is //a client connected. Don't want them staring at a blank screen now do we? Response.Write( '

ERROR: Client is not connected. Please notify the webmaster
See "isClientConnected()" function.

' ); Response.End(); } else return true; } //`````````````````````````````````````````````````` //function returnCurrentTime() //-Argument(s): none. //-Returns: the time. //-Description: This simply returns the current time. It is used to // calculate the length of time the search took. //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function returnCurrentTime() { var lobj_date = new Date(); var li_time = lobj_date.getTime(); delete lobj_date; return li_time; } //`````````````````````````````````````````````````` //function removeArrayElement( aary_data, ai_index ) //-Argument(s): aary_data - the array // ai_index - the index number you want removed //-Returns: the adjusted array //-Description: This removes an index from an array and moves everything // after that index down one, then shortens the array's length. // It simply "deletes" a particular index ... it's very handy. //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function removeArrayElement( aary_data, ai_index ) { //This script modified from: //http://developer.irt.org/script/1308.htm //Written by: Erik Versaevel - webmaster@joos.net //Thanks Erik. var li_index = ai_index; var lary_data = aary_data; for ( ; li_index 0 ) { wo( ls_opener + '

Error:

' ); wo( '\r' + ls_closer ); } if ( gary_msg.length > 0 ) { wo( ls_opener + '

Info:

' ); wo( '\r' + ls_closer ); } } //`````````````````````````````````````````````````` //function arePrefsGood() //-Argument(s): none. //-Returns: n/a. //-Description: Checks to make sure the variables in the preferences file // are defined. If they are not, it adds an error and assigns // very basic default values to the vars. //-Requires: -FUNCTIONS- // addError() // addMsg() // -VARIABLES- // gs_webServerRoot // gs_assRootDir // gs_allowedHosts // gs_allowedExtensions // gs_searchTermTooShort // gi_truncateSearch_Bytes // gs_excludedFolders // gs_excludedFiles //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function arePrefsGood(){ //the isVarDefined() function is here to minimize the amount of code function isVarDefined( as_var, as_varName ) { if ( as_var == 'undefined' ) { addError( as_varName + ' is not defined' ); return false; } else return true; } var ls_initialTest = typeof gs_webServerRoot + typeof gs_assRootDir + typeof gs_allowedHosts + typeof gs_allowedExtensions + typeof gs_searchTermTooShort + typeof gi_truncateSearch_Bytes + typeof gs_excludedFolders + typeof gs_excludedFiles; if ( ls_initialTest.indexOf( 'undefined' ) != -1 ) { addError( 'One or more variables in the ass-preferences file are not defined:' ); if( !isVarDefined( typeof gs_webServerRoot, 'gs_webServerRoot' ) ) { gs_webServerRoot = Server.MapPath( "/" ); } if( !isVarDefined( typeof gs_assRootDir, 'gs_assRootDir' ) ) { gs_assRootDir = "C:\\inetpub\\"; } if( !isVarDefined( typeof gs_allowedHosts, 'gs_allowedHosts' ) ) { gs_allowedHosts = "localhost"; } if( !isVarDefined( typeof gs_allowedExtensions, 'gs_allowedExtensions' ) ) { gs_allowedExtensions = ".htm,.html,.txt"; } if( !isVarDefined( typeof gs_searchTermTooShort, 'gs_searchTermTooShort' ) ) { gs_searchTermTooShort = 2; } if( !isVarDefined( typeof gi_truncateSearch_Bytes, 'gi_truncateSearch_Bytes' ) ) { gi_truncateSearch_Bytes = 100000; } if( !isVarDefined( typeof gs_excludedFolders, 'gs_excludedFolders' ) ) { gs_excludedFolders = ""; } if( !isVarDefined( typeof gs_excludedFiles, 'gs_excludedFiles' ) ) { gs_excludedFiles = ""; } addMsg( 'Perhaps you should run the install again?' ); } } //===================================================================== // Object Constructors //===================================================================== //`````````````````````````````````````````````````` //function newResultsObj( as_path, as_title, as_summary, ai_hitCount, ai_fileSize, as_fileSizeMsg ) //-Argument(s): as_path - the path to the page containing the search (i.e. http://site.com/thepage.htm) // as_title - the tag of that page // as_summary - the search term shown in context from the page // ai_hitCount - number of times the search term appeared on that page // ai_fileSize - file size in KiloBytes // as_fileSizeMsg - tells us if the fileSize was truncated //-Returns: n/a. creates the object //-Description: Creates the gobj_results object //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function newResultsObj( as_path, as_title, as_summary, ai_hitCount, ai_fileSize, as_fileSizeMsg ) { this.path = as_path; this.title = as_title; this.summary = as_summary; this.hitCount = ai_hitCount; this.fileSize = ai_fileSize; this.fileSizeMsg = as_fileSizeMsg; } //`````````````````````````````````````````````````` //function newSearchTermObj( as_rawOriginalTerm, as_outputSafeTerm, areg_internalRegExp, as_termArray ) //-Argument(s): as_rawOriginalTerm - the original "untouched" search term // as_outputSafeTerm - the HTML encoded search term, suitable for writting to the client // areg_internalRegExp - the regular expression used for searching // as_termArray - the array of search terms (not used for anything as of yet) //-Returns: n/a. creates the object //-Description: Creates the gobj_searchTerm object //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function newSearchTermObj( as_rawOriginalTerm, as_outputSafeTerm, areg_internalRegExp, as_termArray ) { this.rawOriginalTerm = as_rawOriginalTerm; this.outputSafeTerm = as_outputSafeTerm; this.internalRegExp = areg_internalRegExp; this.termArray = as_termArray; } //===================================================================== // Search Term Functions //===================================================================== //`````````````````````````````````````````````````` //function parseBoolean( aary_searchTerm ) //-Argument(s): aary_searchTerm - an array of the search terms //-Returns: the finished search term //-Description: Parses the search term for any boolean terms in to a // regular expression (except for "quotes", that is done // by the parseQuotes() function). // Currently only handles 'and' & 'or'. 'not' support is // coming in the future. //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function parseBoolean( aary_searchTerm ) { var lreg_AND = /^and(?:\+|\|)+/gi; var lreg_OR = /^or(?:\+|\|)+/gi; var lreg_AND_RegExp = /\+\.\*/gi; var lreg_OR_RegExp = /\|/gi; var lreg_AND_OR_RegExp = /\+\.\*\|/gi; var ls_defaultBoolean = '+.*'; var ls_defaultBooleanEnd = '+'; var ls_term = ''; var lary_searchTerm = aary_searchTerm; for ( var i=0; i<lary_searchTerm.length; i++ ) { //if it's in quotes, just leave it (see parseQuotes() function) if ( lary_searchTerm[i].charAt( 0 ) != '"' ) { //if it's the last word in the term, use ls_defaultBooleanEnd, else use ls_defaultBoolean if ( ( i + 1 ) != lary_searchTerm.length ) lary_searchTerm[i] = lary_searchTerm[i] + ls_defaultBoolean; else lary_searchTerm[i] = lary_searchTerm[i] + ls_defaultBooleanEnd; //if one of the words is "and" then parse it in to a RegExp suitable for searching if ( lary_searchTerm[i].search( lreg_AND ) > -1 ) { if ( i < lary_searchTerm.length ){ lary_searchTerm[i-1] = lary_searchTerm[i-1].replace( lreg_AND_RegExp, '' ); lary_searchTerm[i] = ls_defaultBoolean; } else lary_searchTerm[i] = '+'; } //if one of the words is "or" then parse it in to a RegExp suitable for searching if ( lary_searchTerm[i].search( lreg_OR ) > -1 ) { if ( i < lary_searchTerm.length ) { lary_searchTerm[i-1] = lary_searchTerm[i-1].replace( lreg_OR_RegExp, '' ); lary_searchTerm[i] = '|'; } else lary_searchTerm[i] = ''; } } } ls_term = lary_searchTerm.join( '' ).replace( lreg_AND_OR_RegExp, '+|' ); return ls_term; } //`````````````````````````````````````````````````` //function parseQuotes( as_searchTerm ) //-Argument(s): as_searchTerm - the search term //-Returns: the parsed search term //-Description: parses any word(s) that are in "quotes" and replaces // them with (parentheses) (and some other RegExp symbols). //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function parseQuotes( as_searchTerm ) { var li_quoteCount = 0; var ls_searchTerm = as_searchTerm; for ( var i=0; i<ls_searchTerm.length; i++ ) { if ( ls_searchTerm.charAt(i) == '"' ) { li_quoteCount++; if ( i == 0 ) ls_searchTerm = '(?:' + ls_searchTerm.substring( 1, ls_searchTerm.length ); else if ( i == ls_searchTerm.length ) ls_searchTerm = ls_searchTerm.substring( 0, ls_searchTerm.length ) + ')'; else { if ( li_quoteCount % 2 == 0 ) ls_searchTerm = ls_searchTerm.substring( 0, i ) + ')' + ls_searchTerm.substring( i + 1, ls_searchTerm.length ); else ls_searchTerm = ls_searchTerm.substring( 0, i ) + '(?:' + ls_searchTerm.substring( i + 1, ls_searchTerm.length ); } } } return ls_searchTerm; } //`````````````````````````````````````````````````` //function returnSearchTermArray( as_searchTerm, as_allowedChars ) //-Argument(s): as_searchTerm - the search term // as_allowedChars //-Returns: Array of search terms. //-Description: Returns an array of the search terms, based on the allowed character set //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function returnSearchTermArray( as_searchTerm, as_allowedChars ) { var lreg_termInQuotes = new RegExp( '"(?:[' + as_allowedChars + ']| )+"|[' + as_allowedChars + ']+', 'gi' ); return String( as_searchTerm.match( lreg_termInQuotes ) ).split( ',' ); } //`````````````````````````````````````````````````` //function parseSearchTerm( as_searchTerm ) //-Argument(s): as_searchTerm - the search term //-Returns: n/a. Assigns values to the gobj_searchTerm object. //-Description: Parses the search term in to a regular expression. Calls // parseBoolean() and parseQuotes() for help. // Assigns the values to the gobj_searchTerm object // (rawOriginalTerm, outputSafeTerm,internalRegExp,termArray) //-Requires: -FUNCTIONS- // trim() // removeArrayElement() // addError() // addMsg() // removeCommonWordsFromSearchTerm() // shouldWeSearch() // parseBoolean() // parseQuotes() // newSearchTermObj() // htmlEncode() // returnSearchTermArray() // -VARIABLES- // gobj_searchTerm //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function parseSearchTerm( as_searchTerm, as_allowedChars ) { var ls_searchTerm = trim( as_searchTerm ); var lary_searchTerm = returnSearchTermArray( as_searchTerm, as_allowedChars ); var lreg_searchTerm = new RegExp(); //hmm ... if ( /^"Nice ASS"$/.test( ls_searchTerm ) ) easter(); //The search cannot begin or end with "or" "and" or "not" because those // are boolean words. These statments remove the offending first or last word and // continues the search. if ( ( lary_searchTerm[0] == 'or' ) || ( lary_searchTerm[0] == 'and' ) || ( lary_searchTerm[0] == 'not' ) ) { lary_searchTerm = removeArrayElement( lary_searchTerm, 0 ); ls_searchTerm = lary_searchTerm.join( '' ); addError( 'Your search cannot begin with: "or", "and", or "not".' ); addMsg( 'Your search continued with the first word omitted.' ); } if ( ( lary_searchTerm[lary_searchTerm.length-1] == 'or' ) || ( lary_searchTerm[lary_searchTerm.length-1] == 'and' ) || ( lary_searchTerm[lary_searchTerm.length-1] == 'not' ) ) { lary_searchTerm.length = lary_searchTerm.length - 1; ls_searchTerm = lary_searchTerm.join( '' ); addError( 'Your search cannot end with: "or", "and", or "not".' ); addMsg( 'Your search continued with the last word omitted.' ); } //Remove common words like "the", "is, "a" etc. lary_searchTerm = removeCommonWordsFromSearchTerm( lary_searchTerm ); ls_searchTerm = lary_searchTerm.join( ' ' ); //Since we've scanned and snipped the search term so much, // we should check that it still meets the basic requirements // by running shouldWeSearch() if ( shouldWeSearch( ls_searchTerm, as_allowedChars ) ) { lreg_searchTerm = parseBoolean( lary_searchTerm ); lreg_searchTerm = parseQuotes( lreg_searchTerm ); gobj_searchTerm = new newSearchTermObj( as_searchTerm, htmlEncode( trim( ls_searchTerm ) ), lreg_searchTerm, lary_searchTerm ); return true; } else return false; } //`````````````````````````````````````````````````` //function removeCommonWordsFromSearchTerm( aary_searchTerm ) //-Argument(s): aary_searchTerm - array containing the search terms //-Returns: the modified aary_searchTerm //-Description: Checks the search term array for words that are considered // common and therefore not useful in a search. Words like: // "the", "is", "in", "what", "where" ... etc. //-Requires: -FUNCTIONS- // addError() // addMsg() //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function removeCommonWordsFromSearchTerm( aary_searchTerm ){ var lary_commonSearchWords = new Array( 'the', 'is', 'in', 'a', 'i', 'what', 'when', 'where', 'why', 'how' ); var lary_tempRemovalIndex = new Array(); var lary_tempRemovalWord = new Array(); var ls_tempError = ''; var ls_tempDelim = ''; var lary_searchTerm = aary_searchTerm; for ( var i=0; i<lary_searchTerm.length; i++ ) { for ( var e=0; e<lary_commonSearchWords.length; e++ ) { if ( aary_searchTerm[i].search( '^' + lary_commonSearchWords[e] + '$' ) != -1 ) { lary_tempRemovalIndex[lary_tempRemovalIndex.length] = i; lary_tempRemovalWord[lary_tempRemovalWord.length] = lary_searchTerm[i]; } } } if ( lary_tempRemovalWord.length > 0 ) { if ( lary_tempRemovalWord.length > 1 ) { for ( var i=0; i<lary_tempRemovalWord.length; i++ ) { if ( i == lary_tempRemovalWord.length - 2 ) ls_tempDelim = ', and '; else if ( i == lary_tempRemovalWord.length - 1 ) ls_tempDelim = ' '; else ls_tempDelim = ', '; ls_tempError += '"' + lary_tempRemovalWord[i] + '"' + ls_tempDelim; } addError( ls_tempError + ' are too common to be useful.' ); addMsg( 'Your search continued with those words omitted.' ); } else { addError( '"' + lary_tempRemovalWord + '" is too common to be useful.' ); addMsg( 'Your search continued with that word omitted.' ); } lary_tempRemovalIndex.reverse(); for (var i=0; i<lary_tempRemovalIndex.length; i++) { removeArrayElement( lary_searchTerm, lary_tempRemovalIndex[i] ); } } return lary_searchTerm; } //hmm ... function easter() { wo( '<h1 style="font-size:3em; color:blue;">' + gs_assVersion + '</h1>' ); wo( '<pre>' + unescape( '%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20._bOBOBOBOBObObOBOBOboB__%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20_b0%5CBOBbo%7C/BOBob%5CbO+b@Ob*OBOB_%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20b@@OBO/BOBOB%21%2C%5CBOBO%28%28b%5COBO%29/%29BOBOb%0D%0A%20%20%20%20%20%20%20%20%20%20%3ABOBOB@%29%5CB%5CO%2C%2CB%28-/-%21%29B%2C%5COB%60O/.%28bo%29%29BO%0D%0A%20%20%20%20%20%20%20%20%20bO@B@BOB%2C-%21O%21B%60%2C+B%2C-.OBO%20%21%3B%21BoB%21O-B-%28B%7C%0D%0A%20%20%20%20%20%20%20%20BOBOBOBoBOB/OBOBo%5C%21B%2C..%20OB-%20o%7C%21Bo%29B%21OB%3AOBo_%0D%0A%20%20%20%20%20%20%20b@OBOBOBOBO@BOBOBO%60BO..%21-B%29%29%5C%21%7COB%28o%21B%7CO@BOBO%3B%0D%0A%20%20%20%20%20%20%7CBOBOBO@%21@BOBOBObOB%29OB%7C%21b%7COBO%7CBOB@BOBOBOBO@BOB%21%0D%0A%20%20%20%20%20.BO@BOBOBOBOB@OBOB@OBOBOBoBOB@%7COBOBOBOB%29+%5COBOBOBO%0D%0A%20%20%20%20%20%3ABO@B@OBOBOBOBOBOBOB@OBOBOBO@%7CoBOB%28+f%21-%20%29-oBOB%28%28B%2C%0D%0A%20%20%20%20%20BOBOBOB%29%29%29%29%29O%28%28%28B%28*O@BOBOBOBOB%28O/%29%27%21%27--/%21-%28BOB%29%29O%7C%0D%0A%20%20%20%20%20@D@B@%29O%28%28%28%28%21/%5C%5C%5C%29%5CB%21/%28OBOB%29%29%5C%21%27-.%21%60-%21%20%21/%27%5C%20OBO%28BO%7C%0D%0A%20%20%20%20%7CBOBOBOB%29%27%21-%27%2C/%21.%60.%5C-%20%21%5C%5C%5C%27/%2C/%2C/-%20-.%5C%20-%20-/--%21OBO%21BO%0D%0A%20%20%20%20%7CBOBOBOB%29%5C%60%2C%5C%20-..%60%20-%2C-/-%60%2C-.-%21.%60%20%21%27/%2C/%27/.-%28-%60OB/%21OB%0D%0A%20%20%20%20%7C@B@OBOB%21%5C%21%21%20-%21---%21-%2C%28.%28%28.%5C--%5C-%60-%21%60-%5C.%27/%20%21%29%21%5COB%28%28OB%0D%0A%20%20%20%20%7CBOBOB%28%28%29%29%5C-%2C%27%5C%60-/-%21.----%20/%21%21%60%21%60-%20%21%5C-%20-%21%20-%21%20-%29O%29%29BO%0D%0A%20%20%20%20%7CBO@BOBo%21%5C%21-%21-.%20%21-%5C-.-%21%60-%60%2C--.%27-%27%5C-%60/%60%2C.%20%21%7C-%2CBOB/O@%0D%0A%20%20%20%20%7CB@O@B%29OB-%5C%60%20-%2C-%2C%5C.%60%2C%21%20/%21--%60/%27-%27%21-./.-%2C-%2C%29%29%21-OB%28%28OB%0D%0A%20%20%20%20%60BOBOB%28O%29%5C--%5C%27%5C%60-%28%20---%21%21%21%21/%21%60%21/.-%21--%27%21%2C%5C%60%28%28%5C%21BOB%29O@%0D%0A%20%20%20%20%20BOB@OBO%28%28%21%28%20%5C-%20%29--%27%21/.---.%27/%27%21%27-%27%60%21%60%20-%27-%5C%29-.BOB%28OB%0D%0A%20%20%20%20%3A%28BOBoBO%29-/bOBObOB-/%20-%27/%5C-.%60-/.%27BoBObOoB%2C/O/%20BOB%5COb%0D%0A%20%20%20%20BOBOB%29O@//Bo+bOBOBO%21%21-%60-%60%20--.%27%2CBOB@OB+OBoB%7C%21%20OBOB@/%7C%0D%0A%20%20%20%20%7CBOBO%29BOB%28.%27%5C%3A__%29O%29B/%2C%27%28%21%21%60/%2C%21oB%29%5C%21%21.%21%20-%60+%29%29%21/OBO%28B%0D%0A%20%20%20%20%21BO%28B%28Ob%29%29%29%29%29OB%5C%28%28O%28bO%27%5C-/-.%5CB%28%28%28/+%5C%29%29%29/%21%21%28%28%5C%20OB%29O%7C%0D%0A%20%20%20%20%7CBOB%5C%29O%2C%60BO//BOBO%5CBOBO%28%21%21%20/bOBOBOBOBO/BO%2C/%5C%29%5C%20OBO@%3B%0D%0A%20%20%20%20%21BOB//%5C%27%21%5C%5C.%2CBOb%27%2C%7C%5COB%7C.%20-%5C//%28B%27%20%3AOBO..B-%20%5C%29O%20@BOB%3B%0D%0A%20%20%20%20%21BOB%5C%28%28%60-%60-%20/%20..%5C%28%28/%7CO%7C-%27%5C%20%5C%27-%21%21%5C%5C//%27%21%2C%5C%60%21%60%28-%20BOBO%0D%0A%20%20%20%20%60BOB%29%29%29%60/./%28%5C%28%5C%29%29%29%21%21%29O/%60%21%28%60%20%27%21%2C%5C%29%29%29_%28-%5C%20-%2C%27%21%21%27B%28%28O%0D%0A%20%20%20%20%20BO%28%5C%28%5C%27-%20/%27%21%5C%5C%7E%21%60.-%5CB%3B%5C%27/%20%5C%60.-%21%20%2C%5C%27%21%27%20%20-%20%21%20-%20O%5CB%21%0D%0A%20%20%20%20%20B%21O%5C-/%20%27-%20-.%60.-%20-%20-%5CB%20/-%60-%20-%20--%20-%20%27%2C%60-%20%20%21%20.%27-b%5C%29%3B%0D%0A%20%20%20%20%20%3A%27B%3B-%29%21%20--%60.%20-%20%2C%21-%27%3B%7C.-%28./%2C/%60/%27/%27%21%20.%60%20%20%27%2C-%21%21%20b-O-%0D%0A%20%20%20%20%20%20%28%28B%60%28%5C-%27-%20%21-%20.%20.%21%28%28/.-%5C-%3A-%21%60-/-%60%20%2C%27%2C%27%20%27.%60%5C-%21O%20/%27%0D%0A%20%20%20%20%20%20%60%5C%29%20%29B%21%21%20-%20-%20%20/%29%29%21O%60.%60%21%21%60%28%20/%21%29L/%20-%20-%60%20%27%2C%2C%29%20%7C%60%7E%27%0D%0A%20%20%20%20%20%20%20%20%60%20/BO%2C%20-%27%20_b/%7C/%21%5C%21-%2C%27%2C-%5C-%2CO%5C%60Bo%2C-%20--..%28/%2C%21%0D%0A%20%20%20%20%20%20%20%20%20%21%28BOb/%20/o%5C%5C%5CBOBO%28b-%21/oB@O-%5C%21%20BO/%27%29//%28%28%28.%21%0D%0A%20%20%20%20%20%20%20%20%20/%29B%28O%28%28%28%28//BOBOB@OBOBO%28%60/%21-%2C-BOB%28%28O/B%29%29-%27%0D%0A%20%20%20%20%20%20%20%20%20%21%28BOBO%29%5C%29%3ABOBOBOBOBO@%5C%20%2C-./%21%60%2C%5CBO%29%29%29%29B//%0D%0A%20%20%20%20%20%20%20%20%20%20BOB%7C/-//oBOBOBOBOB%21%60%2C%2C_o%5CBOBOBO-%21%21%21bO%28-%0D%0A%20%20%20%20%20%20%20%20%20%20BO%29%5Cb%21-%21.BOB%7E%21%7E%5C*+%28%28++O%7E%5C%21B@o%21%5C%28%5C%21%21B%29%29%27%0D%0A%20%20%20%20%20%20%20%20%20%20%60B/-O%29%29%21/%29BOb.%20%20%20%20%20%20%20%20%20%20.oBO%60-%29--%20/B%28/%0D%0A%20%20%20%20%20%20%20%20%20%20%20%5CB/%28/--.+OBOBOB-%5C+-%3D%3D/%7E/O%29%5C.%27%2C//%20B+/%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20B%7C/O%21%2C%27%28BOBOBoB_/o%3A%3Ab%21%60%5C-%2C-..%27-oB%5C%27%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%21%7C//%3B-%20BOBOB%28%28%21-%21%29%5C%21%2C%5C%60-%5C.---%20%21OB%27%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20B-%28%28-%5COB@%29%29O%29%29B..%28%5C%5C%5C%29%5C%2C/-%20/-%28Ob%27%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%60%7C-%5CBOB@%7E/OBOBOB%29%29%29%29O%28%21.-%60%2C%27/BO%21%0D%0A%20%20%20%20%20%20%2C%20%20%20%20%20%20%20%60bOBO@%21%21BOBo%217/7/%60%5C7%5C-.%27-%20%5CBO%21%0D%0A%20%20.-._%3B%20-%2C%20%20%20%20bOBOB%21%5C%28OB%29%21%27%2C%5C-%5C%5C-%27%2C/%27/%27/OB%7E%0D%0A%20/%27bOBo%20bO%5C%20.BO%29BO%29%29%5CB%28%28%5C/%28%20%21%21%21%2C-%60.%60.%5C%21%28O%27%0D%0A%3A%20BObo%20b@OBoBOBOB%60OB%28OB%29%21%29%20%21%2C-%2C-/.%27-%5C/%3DO%27%0D%0A_%20%60%20.%2C/BOBOBOBO*%20%20BOB%29OB/.%21%2C%2C%5C-%5C.-%2C%5CoB@%27%0D%0ABO@BO/%20B%28OBOBOB%20%20%20%20%60OBOBOBO%28Bo%29BOBOBOb%0D%0A%60BOBOB%20%20OB@OB@%20%20%20%20%20%20%20%20%27%7E%7E%7E%7EObOBOBO+%7E%0D%0A%20BOBO@%29%20BOBOB%0D%0A%20%20BOBob.OBOb%0D%0A%20%20%60*BOBOB*%27%0D%0A%20%20%20%20%60Bo%7E%27%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20J.R.%22BOB%22%20Dobbs%0D%0A' ) + '</pre>' ); Response.End(); } //`````````````````````````````````````````````````` //function isAllowedChars( as_searchTerm ) //-Argument(s): as_searchTerm - the search term to check // areg_allowedChars - the characters to allow in the search term //-Returns: true or false //-Description: Checks the search term for the allowed characters. // Returns false if any other character is found, true // if only the allowed characters are found. //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function isAllowedChars( as_searchTerm, as_allowedChars ) { var lreg_allowedChars = new RegExp( '[^' + as_allowedChars + ' ]', 'gi' ); return !lreg_allowedChars.test( as_searchTerm ); } //===================================================================== // Search Functions //===================================================================== //`````````````````````````````````````````````````` //function searchFiles( aobj_fso, aobj_folder, as_assRootDir, // areg_searchTerm, as_allowedExtensions, as_excludedFiles, as_webServerRoot, // as_http_host, ai_truncateSearchBytes ) //-Argument(s): aobj_fso - the FileSystemObject to use for file stuff // aobj_folder - the current folder object // as_assRootDir - ASS root directory // areg_searchTerm - the RegExp search term // as_allowedExtensions - a comma delim list of searchable file extensions // as_excludedFiles - a comma delim list of files to exclude from searching // as_webServerRoot - the web server (IIS) root directory // as_http_host - the current HTTP host this file resides on // ai_truncateSearchBytes - size limit (in bytes) to truncate searches at. //-Returns: true or false ... but that's not used for // anything right now. //-Description: The main search function that actually scans the // files for the search term. Assigns data to the results // object: path, title, summary, hitCount, fileSize. //-Requires: -FUNCTIONS- // isValidExtension() // isFileExcluded() // stripAsp() // findMatch() // getPageTitle() // convertLocalPaths() // getPageSummary() // newResultsObj() // -VARIABLES- // gi_filesSearchedCount // gi_fileSizeCount // gs_webServerRoot // gs_http_host // gobj_results // gi_resultCount //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function searchFiles( aobj_fso, aobj_folder, as_assRootDir, areg_searchTerm, as_allowedExtensions, as_excludedFiles, as_webServerRoot, as_http_host, ai_truncateSearchBytes ) { var lenum_Files = new Enumerator( aobj_folder.Files ); var lreg_aspFileExt = /\.asp$/i; for ( lenum_Files.moveFirst(); !lenum_Files.atEnd(); lenum_Files.moveNext() ) { var ls_fileName = String( lenum_Files.item().Name ); //Check to see if the extention is a searchable one if ( isValidExtension( as_allowedExtensions, ls_fileName ) ) { //Store in a var to minimize the object access var ls_fileNameAndPath = String( lenum_Files.item() ); //Check to see if the file is excluded from searches if ( !isFileExcluded( as_excludedFiles, as_assRootDir, ls_fileNameAndPath ) ) { //Get file size in bytes var li_fileSize = lenum_Files.item().Size; var ls_fileSizeMsg = ''; var li_truncateSearchBytes = Number( ai_truncateSearchBytes ); //if the file size is larger than our limit, assign the limit as the search size var li_searchedFileSize = ( li_fileSize > li_truncateSearchBytes ) ? li_truncateSearchBytes : li_fileSize; //open the file and read it var lobj_textStream = aobj_fso.OpenTextFile( ls_fileNameAndPath ); var ls_fileContents = lobj_textStream.Read( li_searchedFileSize ); //strip out any HTML comments ls_fileContents = stripComments( ls_fileContents ); //If it's an ASP file, strip out any ASP code if ( lreg_aspFileExt.test( ls_fileName ) ) { ls_fileContents = stripAsp( ls_fileContents ); } //Strip out any HTML code var ls_strippedFileContents = stripHtml( ls_fileContents ); //Perform the search var lary_matches = findMatch( ls_strippedFileContents, areg_searchTerm ); //increase files searched count gi_filesSearchedCount++; //increase the fileSize counter (before we do any rounding) gi_fileSizeCount += li_searchedFileSize; if ( lary_matches != null ) { //get the page's <title> tag var ls_pageTitle = getPageTitle( ls_fileContents, convertLocalPaths( as_webServerRoot, ls_fileNameAndPath, as_http_host ) ); //Get the summary for the page var ls_pageSummary = getPageSummary( ls_strippedFileContents, lary_matches ); //assign the file size, rounded to the nearest KB. // if the file's actual size is larger than what we searched for, // display the "search was truncated" message if ( li_fileSize > li_searchedFileSize ) { ls_fileSizeMsg = '[<span class="search_truncatedMsg">truncated from ' + Math.round( li_fileSize / 1000 ) + 'KB</span>]'; li_fileSize = Math.round( li_searchedFileSize / 1000 ); } else li_fileSize = Math.round( li_fileSize / 1000 ); //assign values to the results object and increase the counters gobj_results[gi_resultCount] = new newResultsObj( convertLocalPaths( gs_webServerRoot, ls_fileNameAndPath, gs_http_host ), ls_pageTitle, ls_pageSummary, lary_matches.length, li_fileSize, ls_fileSizeMsg ); gi_resultCount++; } } } } if ( gi_resultCount <= 0 ) return false; else return true; } //`````````````````````````````````````````````````` //function traverseSubFolders( aobj_fso, aobj_folder, as_assRootDir, // areg_searchTerm, as_allowedExtensions, as_excludedFolders, as_excludedFiles, // as_webServerRoot, as_http_host, ai_truncateSearchBytes ) //-Argument(s): aobj_fso - the FileSystemObject to use for file stuff // aobj_folder - the current folder object // as_assRootDir - ASS root directory // areg_searchTerm - the RegExp search term // as_allowedExtensions - a comma delim list of searchable file extensions // as_excludedFolders - a comma delim list of folders to exclude from searching // as_excludedFiles - a comma delim list of files to exclude from searching // as_webServerRoot - the web server (IIS) root directory // as_http_host - the current HTTP host this file resides on // ai_truncateSearchBytes - size limit (in bytes) to truncate searches at. //-Returns: n/a. //-Description: If the folder is not in the exclude list (via // isFolderExcluded() function), then it iterates // through all folders and subfolders and runs the // searchFiles() function. //-Requires: -FUNCTIONS- // isFolderExcluded() // searchFiles() // isClientConnected() //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function traverseSubFolders( aobj_fso, aobj_folder, as_assRootDir, areg_searchTerm, as_allowedExtensions, as_excludedFolders, as_excludedFiles, as_webServerRoot, as_http_host, ai_truncateSearchBytes ) { for ( var lobj_subFolder = new Enumerator( aobj_folder.SubFolders ); !lobj_subFolder.atEnd(); lobj_subFolder.moveNext() ) { if ( !isFolderExcluded( as_excludedFolders, as_assRootDir, lobj_subFolder.item() ) ) { if ( isClientConnected() ) { searchFiles( aobj_fso, lobj_subFolder.item(), as_assRootDir, areg_searchTerm, as_allowedExtensions, as_excludedFiles, as_webServerRoot, as_http_host, ai_truncateSearchBytes ); traverseSubFolders( aobj_fso, lobj_subFolder.item(), as_assRootDir, areg_searchTerm, as_allowedExtensions, as_excludedFolders, as_excludedFiles, as_webServerRoot, as_http_host, ai_truncateSearchBytes ); } } } } //===================================================================== // Search Helpers //===================================================================== //`````````````````````````````````````````````````` //function isFolderExcluded( as_excludedFolders, as_assRootDir, as_folder ) //-Argument(s): as_excludedFolders - a comma delim string of folder names to exclude // as_assRootDir - the ASS root directory (top most searchable directory) // as_folder - the current folder name to check //-Returns: true - if folder name IS found in as_excludedFolders // false - if it's NOT found //-Description: Checks to see if the passed folder argument // is listed in the as_excludedFolders variable. //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function isFolderExcluded( as_excludedFolders, as_assRootDir, as_folder ) { if ( as_excludedFolders == '' ) return false; var ls_totalPath = ''; var lary_excludedFolders = String( as_excludedFolders ).split( ',' ); var ls_folder = String( as_folder ).toLowerCase(); //If it's a FP extension folder, then return true because it's excluded // otherwise check the excluded folders list if ( isFrontPageExtensionFolder( ls_folder ) ) return true; else { for ( var i=0; i<lary_excludedFolders.length; i++ ) { ls_totalPath = ( as_assRootDir + lary_excludedFolders[i] ).toLowerCase(); if ( ls_folder.indexOf( ls_totalPath ) != -1 ) return true; } return false; } } //`````````````````````````````````````````````````` //function isFrontPageExtensionFolder( as_folder ) //-Argument(s): as_folder - folder name //-Returns: true - if folder name IS a FrontPage Extension folder // false - if it's NOT //-Description: Checks to see if the passed folder argument // is a "special" FrontPage Extension folder //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function isFrontPageExtensionFolder( as_folder ) { var lary_fpFolder = new Array( '_borders', '_derived', '_fpclass', '_overlay', '_private', '_themes', '_vti_adm', '_vti_aut', '_vti_bin', '_vti_bot', '_vti_cnf', '_vti_log', '_vti_map', '_vti_pvt', '_vti_txt' ); var ls_folder = String( as_folder ).toLowerCase(); for ( var i=0; i<lary_fpFolder.length; i++ ) { if ( ls_folder.indexOf( lary_fpFolder[i] ) != -1 ) return true; } return false; } //`````````````````````````````````````````````````` //function isFileExcluded( as_excludedFiles, as_assRootDir, as_file ) //-Argument(s): as_excludedFiles - a comma delim string of file names to exclude // as_assRootDir - the ASS root directory (top most searchable directory) // as_file - the current file name to check //-Returns: true - if file name IS found in as_excludedFiles // false - if it's NOT found //-Description: Checks to see if the passed file argument // is listed in the as_excludedFiles variable. //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function isFileExcluded( as_excludedFiles, as_assRootDir, as_file ) { if ( as_excludedFiles == '' ) return false; var lary_excludedFiles = as_excludedFiles.split( ',' ); var ls_file = String( as_file ).toLowerCase(); for ( var i=0; i<lary_excludedFiles.length; i++ ) { ls_totalPath = ( as_assRootDir + lary_excludedFiles[i] ).toLowerCase(); if ( ls_file.indexOf( ls_totalPath ) != -1 ) return true; } return false; } //`````````````````````````````````````````````````` //function isValidExtension( as_allowedExtensions, as_fileName ) //-Argument(s): as_fileName - file name // as_allowedExtensions - comma delimited list of allowed extensions //-Returns: true or false. //-Description: checks if the file name has a "search worthy" // extension. If it is listed, returns true. //-Requires: -VARIABLES- // gs_allowedExtensions //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function isValidExtension( as_allowedExtensions, as_fileName ) { var lary_allowedExtensions = String( as_allowedExtensions ).split( ',' ); var lreg_extension = new RegExp(); for ( var i=0; i<lary_allowedExtensions.length; i++ ) { //extension must appear at the end of string, hence the $ modifier lreg_extension.compile( '\\' + lary_allowedExtensions[i] + '$', 'i' ); if ( lreg_extension.test( as_fileName ) ) return true; } return false; } //`````````````````````````````````````````````````` //function findMatch( as_data, as_term ) //-Argument(s): as_data - the string to search // as_term - the term to search for //-Returns: an array of the found term, or null if none are found //-Description: simply performs a match() method on a string and returns // the results //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function findMatch( as_data, as_term ) { return String( as_data ).match( as_term ); } //`````````````````````````````````````````````````` //function stripAsp( as_data ) //-Argument(s): as_data - the page contents //-Returns: The stripped text from the page. //-Description: This function removes all ASP code from a page // so it will not be searched (thus revealing source // code). //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function stripAsp( as_data ) { var lreg_aspBrackets = /\<\%(?:.|\n)*?\%\>/g; return String( as_data ).replace( lreg_aspBrackets, '' ); } //`````````````````````````````````````````````````` //function stripComments( as_data ) //-Argument(s): as_data - the page contents //-Returns: The stripped text from the page. //-Description: This function removes all HTML comments // from a page so they will not be searched //-Author: Byl Walker, Oct. 2002 //-Updates By: Joel Coreson, Oct. 2002 //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function stripComments( as_data ) { var lreg_commentBrackets = /\<!--(?:.|\n)*?--\>/g; return String( as_data ).replace( lreg_commentBrackets, '' ); } //`````````````````````````````````````````````````` //function stripHtml( as_data ) //-Argument(s): as_data - the page contents //-Returns: The stripped text from the page. //-Description: This function removes all HTML from // a page so it will not be searched //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function stripHtml( as_data ) { var lreg_html = /<(?:.|\n)+?>/g; return String( as_data ).replace( lreg_html, '' ); } //`````````````````````````````````````````````````` //function setInternationalSupport() //-Argument(s): none //-Returns: n/a //-Description: Set's the CharSet HTTP header and the list of // characters to allow in the search term. // // CharSet Reference: // http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/charsets/charset4.asp // // JavaScript Unicode Chart: // http://www273.pair.com/med/unicode/charts.html //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function setInternationalSupport() { // To use another charset other than the default: // // 1. Uncomment the "Response.CharSet" and "ls_allowedChars" lines // for the charset you desire. // 2. Comment out all other instances of "Response.CharSet" and "ls_allowedChars". // { //DEFAULT - Western European (ISO) Response.CharSet = 'iso-8859-1'; //Western European (ISO) ls_allowedChars = 'a-z0-9_\"'; } { /* Greek -------------- Unicode Codes ð - 00F0 ñ - 00F1 ó - 00F3 ö - 00F6 ø - 00F8 ù - 00F9 ã - 00E3 ä - 00E4 è - 00E8 ë - 00EB î - 00EE */ //Response.CharSet = 'unicode'; //ls_allowedChars = 'a-z0-9_\"\\u00F0\\u00F1\\u00F3\\u00F6\\u00F8\\u00F9\\u00E3\\u00E4\\u00E8\\u00EB\\u00EE'; } { /* Turkish -------------- Unicode Codes Ç - 00C7 Ð - 00D0 Ö - 00D6 Ü - 00DC Ý - 00DD Þ - 00DE ð - 00F0 ö - 00F6 ü - 00FC ý - 00FD þ - 00FE ç - 00E7 */ //Response.CharSet = 'unicode'; //ls_allowedChars = 'a-z0-9_\\"\\u00C7\\u00D0\\u00D6\\u00DC\\u00DD\\u00DE\\u00F0\\u00F6\\u00FC\\u00FD\\u00FE\\u00E7'; } return ls_allowedChars; } //===================================================================== // Results functions //===================================================================== //`````````````````````````````````````````````````` //function convertLocalPaths( as_webServerRoot, as_localPath, as_http_host ) //-Argument(s): as_webServerRoot - the root of IIS // as_localPath - the local path (i.e. 'C:\inetpub\mysite\bob.htm') // as_http_host - the http host to replace the local path //-Returns: the modified web URL //-Description: removes the localPath and replaces it with the // internet URL. i.e. 'C:\inetpub\mysite\bob.htm' input becomes // 'http://bigcoatposse.com/bob.htm' as output //-Requires: -VARIABLES- // gs_assRootDir //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function convertLocalPaths( as_webServerRoot, as_localPath, as_http_host ) { var ls_webServerRoot = as_webServerRoot.toLowerCase(); var ls_localPath = String( as_localPath ).toLowerCase(); var lreg_backSlashes = /\\/g; var ls_returnValue = ''; /************************* Auto detect path (default) *************************/ ls_returnValue = ls_localPath.replace( ls_webServerRoot, '' ); ls_returnValue = as_http_host.slice( 0, as_http_host.length ) + ls_returnValue; ls_returnValue = ls_returnValue.replace( lreg_backSlashes, '\/' ); /************************* Hard code path *************************/ //To hard code a path, follow these four steps //Step 1 - Comment out the auto detect lines above //Step 2 - Uncomment this line //ls_returnValue = ls_localPath.replace( gs_assRootDir, '' ); //Step 3 - a) Run a search so you can see some results. // b) Look at the path being returned and decide what part of that path should // be replaced with "http://yourDomain.com/" // c) Take that part of the path and enter it for ls_localReplacePath as all // lower case. Don't forget, in JavaScript you must escape back slashes! // Example 'c:\inetpub\' is incorrect. It must be 'c:\\inetpub\\' // d) Uncomment out this line //var ls_localReplacePath = 'path goes here' //Step 4 - Uncomment out these two lines //ls_returnValue = ls_returnValue.replace( ls_localReplacePath, as_http_host ); //ls_returnValue = ls_returnValue.replace( lreg_backSlashes, '\/' ); return ls_returnValue; } //`````````````````````````````````````````````````` //function getPageTitle( as_fileContents, as_fileName ) //-Argument(s): as_fileContents - the entire file text // as_fileName - the name of the file //-Returns: ls_pageTitle - the finished title text //-Description: Scans the entire page for a <title> tag, then grabs the text. // if it does not have one (as in the case with say, a TXT file) it // returns the name of the file instead. //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function getPageTitle( as_fileContents, as_fileName ) { var lreg_title = /<title>(.+|\n+)<\/title>/gim; lreg_title.exec( as_fileContents ); //if there is no <title> tag, return the file name var ls_pageTitle = ( RegExp.$1 == '' ) ? as_fileName : RegExp.$1; return ls_pageTitle; } //`````````````````````````````````````````````````` //function getPageSummary( as_fileContents, aary_match ) //-Argument(s): as_fileContents - the entire file text // aary_match - the array containing the found search terms //-Returns: The finished summary text //-Description: Scans the entire page for the search term, then pulls a bit of text // before and after the found term. How much text it pulls is semi-random. // It uses the number of characters in the lary_spacingBegining & // lary_spacingEnd arrays. This function also wraps the found term(s) // in a <span> tag so you can highlight it via CSS. //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function getPageSummary( as_fileContents, aary_match ) { var lary_spacingBegining = new Array( 30, 50, 70 ); var lary_spacingEnd = new Array( 100, 80, 60 ); var li_spacingBegining = 0; var li_spacingEnd = 0; var ls_summary = ""; var ls_strippedResults = ""; var ls_highlightedTerm = ""; var lreg_newLine = /[\f\n\r\t]+/g; var lreg_spaces = / {2,}/g; var lreg_htmlSpaces = /(?: )*/gi; //This randomizes the number of characters grabbed for the //summary so all of the high lighting doesn't appear in the //same place. var lobj_Date = new Date(); var i = lobj_Date.getMilliseconds() % 3; li_spacingBegining = lary_spacingBegining[i]; li_spacingEnd = lary_spacingEnd[i]; delete lobj_Date; //remove any new line characters and anything with more then 2 spaces. ls_strippedResults = as_fileContents.replace( lreg_newLine, ' ' ).replace( lreg_spaces, ' ' ).replace( lreg_htmlSpaces, '' ); li_searchIndex = ls_strippedResults.search( aary_match[0] ); ls_summary = ls_strippedResults.substring( ( li_searchIndex - li_spacingBegining ), ( li_searchIndex + aary_match[0].length + li_spacingEnd ) ); for ( var i=0; i<aary_match.length; i++ ) { ls_highlightedTerm = '<span class="search_term">' + aary_match[i] + '</span>'; if ( ls_summary.indexOf( ls_highlightedTerm ) == -1 ) ls_summary = ls_summary.replace( aary_match[i], ls_highlightedTerm ); } return ls_summary; } //`````````````````````````````````````````````````` //function sortResults() //-Argument(s): aobj_results - the results object //-Returns: none. //-Description: Sorts the results from highest to lowest based // on the hitCount property. //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function sortResults( aobj_results ) { //function for sortting the results based on the hitCount function sortObj( a, b ) { var ls_sortProp = "hitCount"; if (a[ls_sortProp] < b[ls_sortProp]) return -1; if (a[ls_sortProp] > b[ls_sortProp]) return 1; else return 0; } aobj_results.sort( sortObj ); return aobj_results.reverse(); } //`````````````````````````````````````````````````` //function displayResults() //-Argument(s): n/a. //-Returns: none. Response.Writes the finished HTML for display //-Description: Writes the HTML to display the results to the browser. // This is a function you'll want to customize to fit // your needs. //-Requires: -VARIABLES- // gobj_searchTerm // gi_resultCount // gobj_results // gs_assVersion // gi_scriptTime // gi_filesSearchedCount // gi_fileSizeCount // gboo_isSearchTerm //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function displayResults() { if ( gobj_results.length > 0 ) { wo( '\n<p>The search term <span class="search_term">' + gobj_searchTerm.outputSafeTerm + '</span> was found on the following ' + gi_resultCount + ' pages:</p>' ); wo( '<ul class="search_container">' ); for ( var i=0; i<gobj_results.length; i++ ) { wo( '<li>' ); wo( ' <span class="search_title"><a href="' + gobj_results[i].path + '">' + gobj_results[i].title + '</a></span><br>' ); wo( ' <span class="search_summary">' + gobj_results[i].summary + '</span><br>' ); wo( ' <span class="search_link">' + gobj_results[i].path + '</span> - <span class="search_fileSize">' + gobj_results[i].fileSize + 'KB</span> ' + gobj_results[i].fileSizeMsg + ' - <span class="search_hitCount">(hits: ' + gobj_results[i].hitCount + ')</span><br><br>' ); wo( '</li>' ); } wo( '</ul>' ); wo( '<!--' + gs_assVersion + '-->' ) wo( '<p class="search_searchInfo">This search took ' + gi_scriptTime + 'seconds. Searched ' + gi_filesSearchedCount + ' files totaling ' + Math.round( gi_fileSizeCount / 1000 ) + 'KB.</p>' ); } else if ( gboo_isSearchTerm ) wo( '\n<p>The search term <span class="search_term">' + gobj_searchTerm.outputSafeTerm + '</span> was <span class="error">not found</span> on any pages. Try making your search <i>less specific</i>. Plurals tend to restrict search results (i.e. search for "cat" instead of "cats").</p>' ); } //===================================================================== // Master Search Functions //===================================================================== //`````````````````````````````````````````````````` //function shouldWeSearch( as_searchTerm ) //-Argument(s): as_searchTerm - A string of the original search term // as_allowedChars - String of characters that are allowed for searches //-Returns: true or false //-Description: This function runs all of the error checking and tests // to see if the search should even begin. //-Requires: -FUNCTIONS- // isEmpty() // trim() // isAllowedChars() // isValidReferer() // addError() // -VARIABLES- // gboo_isSearchTerm // gs_searchTermTooShort // gs_allowedHosts //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function shouldWeSearch( as_searchTerm, as_allowedChars ) { //Was a search submitted? if ( gboo_isSearchTerm ) { //Is the search term blank? if ( !isEmpty( as_searchTerm ) ) { //Is it too short? (Less than gs_searchTermTooShort characters) if ( trim( as_searchTerm ).length > gs_searchTermTooShort ) { //Does it contain illegal characters? if ( isAllowedChars( as_searchTerm, as_allowedChars ) ) { //Is it coming from a host we trust? if ( isValidReferer( gs_allowedHosts ) ) { //ok, we passed all the tests return true; } else return false; } else { addError( 'Invalid characters' ); addError( 'Only letters, numbers and underscore "_" can be searched for.' ); return false; } } else { addError( 'Search term is too short' ); addError( 'Please enter a search term longer than ' + gs_searchTermTooShort + ' characters.' ); return false; } } else { addError( 'Nothing to search for' ); addError( 'Please enter some text to search for, it must be more than ' + gs_searchTermTooShort + ' characters long.' ); return false; } } else return false; } //`````````````````````````````````````````````````` //function masterFunction() //-Argument(s): none. //-Returns: n/a. //-Description: This is the first function called. This function does a lot of // "initialization stuff." It checks to see if the searching // should even be done (via shouldWeSearch() ). It is also were most // of the global vars are passed to functions. //-Requires: -FUNCTIONS- // shouldWeSearch() // returnCurrentTime() // parseSearchTerm() // isClientConnected() // searchFiles() // traverseSubFolders() // sortResults() // -VARIABLES- // gs_searchTerm // gs_assRootDir // gs_assRootDir // gs_allowedExtensions // gs_excludedFiles // gs_webServerRoot // gs_http_host // gi_truncateSearch_Bytes // gobj_results // gi_scriptTime //,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, function masterFunction() { //Set the character set we will allow in the search term // and set the http charset header var ls_allowedChars = setInternationalSupport(); if ( shouldWeSearch( gs_searchTerm, ls_allowedChars ) ) { //start the script timer var li_startTime = returnCurrentTime(); //parse the search term if ( parseSearchTerm( gs_searchTerm, ls_allowedChars ) ) { if ( isClientConnected() ) { // If you have purchased SoftArtisans FileManager, then comment out the // first lobj_FSO, and UNcomment the second lobj_FSO. //Microsoft's FileSystemObject (FSO) var lobj_FSO = Server.CreateObject( 'Scripting.FileSystemObject' ); //SoftArtisans FileManager - http://www.softartisans.com/ //var lobj_FSO = Server.CreateObject( 'SoftArtisans.FileManager' ); var lobj_Folder = lobj_FSO.GetFolder( gs_assRootDir ); var lreg_SearchTerm = new RegExp( gobj_searchTerm.internalRegExp, 'gim' ); //search the root folder searchFiles( lobj_FSO, lobj_Folder, gs_assRootDir, lreg_SearchTerm, gs_allowedExtensions, gs_excludedFiles, gs_webServerRoot, gs_http_host, gi_truncateSearch_Bytes ); //search all the other folders traverseSubFolders( lobj_FSO, lobj_Folder, gs_assRootDir, lreg_SearchTerm, gs_allowedExtensions, gs_excludedFolders, gs_excludedFiles, gs_webServerRoot, gs_http_host, gi_truncateSearch_Bytes ); delete lobj_FSO; } } //sort the results based on hitCount gobj_results = sortResults( gobj_results ); //stop the script timer var li_stopTime = returnCurrentTime(); //assign the script execution time to gi_scriptTime var gi_scriptTime = ( (li_stopTime - li_startTime) / 1000 ); } } //Check if the user preferences are defined. // If you are confident that your prefs are good (and will // remain that way) then comment out this line for // a minor speed improvement. arePrefsGood(); //call the master function to get the ball rolling masterFunction(); %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Search
 
 
Search
<% //This function displays any error messages that occur. writeMsg(); //This function displays the results //Place this where ever you would like the results to be displayed. displayResults(); %>


August 4, 2008 ::: BLI Honors Konica Minolta with Two Pick of the Year Awards

Konica Minolta, a leading provider of advanced imaging and networking technologies for the desktop to the print shop, today announced that Buyers Laboratory Inc. (BLI), a leading source for the unbiased and reliable intelligence for the imaging industry, has awarded Konica Minolta's bizhub C353 and magicolor 8650DN with Spring 2008 "Pick of the Year Awards" in their respective segments. After BLI's rigorous lab-based evaluations, which assess a wide range of products' performance areas including reliability, productivity, and security, BLI has acknowledged the bizhubTM C353 and magicolor® 8650DN as leading products at the forefront of the industry. more info...

July 21, 2008 ::: Konica Minolta Introduces PageScope Enterprise Suite for MFP Accounting and Authentication Management

Konica Minolta, a leading provider of advanced imaging and networking technologies for the desktop to the print shop, today announced the release of PageScope Enterprise Suite, a solution that brings enterprise-level accounting, user management and authentication to businesses of all sizes. This new suite of solutions allows organizations to authenticate and track users on any bizhub system within a corporation, and provide a custom user interface on all networked multifunctional products (MFPs - print, copy, fax, and scan all in one system) within the Konica Minolta next-generation series. more info...

Home     About Us      FAQ's      Download
Copyright © 2005 - 2008 Central Business Systems Inc. All rights reserved.
285 Kenmore Ave. - Buffalo, NY 14223 - 716.803.9000