pike.git / lib / modules / Search.pmod / Utils.pmod

version» Context lines:

pike.git/lib/modules/Search.pmod/Utils.pmod:1:   // This file is part of Roxen Search   // Copyright © 2001 Roxen IS. All rights reserved.   // - // $Id: Utils.pmod,v 1.6 2001/07/04 18:10:42 nilsson Exp $ + // $Id: Utils.pmod,v 1.7 2001/07/04 19:00:48 nilsson Exp $      public array(string) tokenize_and_normalize( string what )   //! This can be optimized quite significantly when compared to   //! tokenize( normalize( x ) ) in the future, currently it's not all   //! that much faster, but still faster.   {    return Unicode.split_words_and_normalize( lower_case(what) );   }      public array(string) tokenize(string in)
pike.git/lib/modules/Search.pmod/Utils.pmod:86:    }       void log_notice( int code, void|string extra ) {    log_event( code, "notices", extra );    }       private mapping codes = ([    404 : "File %s not found",    ]);    -  array(array(string)) get_log( int profile, array(string) types, -  int form, int to ) { +  array(array(string|int)) get_log( int profile, array(string) types, +  int from, int to ) {       string sql = ""; - #define SQLADD(X) do{sizeof(sql)?sql=" WHERE "+(X):sql+=" AND "+(X)}while(0) + #define SQLADD(X) do{sizeof(sql)?(sql=" WHERE "+(X)):(sql+=" AND "+(X));}while(0)    if(profile)    SQLADD("profile=" + profile);    if(!sizeof(types))    return ({});    if(sizeof(types)!=3)    SQLADD("(type='" + (types*"' OR type='") + "')");    if(from)    SQLADD("at>" + from);    if(to)    SQLADD("to<" + to);   #undef SQLADD       Sql.Sql db = get_db(); -  if(!db) return; +  if(!db) return ({});       return map(db->query("SELECT unix_timstamp(at) as at,profile,code,type,extra FROM eventlog"+sql),    lambda(mapping in) { -  return ({ in->at, in->profile, in->type, +  return ({ (int)in->at, (int)in->profile, in->type,    in->extra?sprintf(codes[(int)in->code], in->extra):codes[(int)in->code] });    } );    }   }