Description: <!DOCTYPE HTML PUBLIC "<%=this.www_doctype_fpi%>" "<%=this.www_doctype_uri%>"><HTML><HEAD><%this:tell_www_head(@args)%><link REL="icon" HREF="/favicon.ico" TYPE="image/x-ico"><link REL="SHORTCUT ICON" HREF="/favicon.ico"></HEAD><BODY <%=this.www_body_args%>><CENTER><%=$html_utils:tabbar(2, "Search", "/search", "Grep", "/grep", "Tree", "/tree", "Audit", "/audit", "Names", "/names")%></CENTER><IMG SRC="<%=$www.fileURL%>/pics/mc_search.jpg" ALIGN="right" WIDTH=210 HEIGHT=127 ALT="[Search icon]"><H2>Grep Tool</H2>Search for any expression in the properties, verbs and/or files on one or more objects.<% if (player.user == $no_one) %> <P> <H4 ALIGN="center">Sorry, due to concerns about Denial of Service attacks<SUP><A HREF="http://www.everything2.org/index.pl?node=Denial+of+Service+attack">[?]</A></SUP> the Grep Tool is only available after you have logged in.</H4><% elseif (!player:isa($webber)) return; %><% else %><%(player.user):isa($guardian) || set_task_perms(player.user);text = $www:parse_GET("text") || "";objectstr = $su:trim($www:parse_GET("objects") || "");mode_prop = $www:parse_GET("props");mode_verb = $www:parse_GET("verbs");mode_file = $www:parse_GET("files");is_regex = $www:parse_GET("is_regex");all_matches = $www:parse_GET("all_matches");if (text) verb = (is_regex ? "@egrep" | "@grep") + (all_matches ? "!" | "");%><P><I>> <%=tostr(verb, " ", $html_utils:literal_text(text), " on ", $html_utils:literal_text(objectstr), (mode_prop ? "." | ""),(mode_verb ? ":" | ""),(mode_file ? "!" | ""))%></I><P><%if (!objectstr) "If no objects are specified, then the entire Moo is grepped."; objects = $set_utils:union($root:descendants_suspended(), {$trash, $root, $new_root});elseif (m = match(objectstr, "^%(#?[0-9]+%)%(-%|%.%.%)%(#?[0-9]+%)$")) "Objects can be a range in the format of #123..#234 or #123-#234."; objects = {}; for x in [toobj(m[$][m[3][1][1]..m[3][1][2]])..toobj(m[$][m[3][3][1]..m[3][3][2]])] $recycler:valid(x) && (objects = {@objects, x}); endforelse objects = {player.user:my_match_object(objectstr)}; if (!valid(objects[1])) objects = E_INVARG; elseif (objects[1]:isa($accountable)) "If just a player is specified, then their audit is included"; objects = setadd(objects[1].owned_objects, objects[1]); endifendifif (objects == E_INVARG) player:tell("<B>Sorry, I can't match '",$html_utils:literal_text(objectstr),"' to an object.</B>");elseif (!objects) player:tell("<B>Zero objects specified.</B>");elseif (is_regex && `match("test", text) ! E_INVARG' == E_INVARG) player:tell("<B>'", $html_utils:literal_text(text), "' is not a legal regular expression.</B>");elseif (!mode_prop && !mode_verb && !mode_file) player:tell("<B>Grep what? Properties, verbs and/or files?</B>");else $code_utils:semaphore_enter("grep", player.user); if (mode_prop) player:tell("<P><B>=== ", verb, " of properties on ", length(objects) == 1 ? $su:nn(objects[1]) | tostr(length(objects), " objects"), " for '", $html_utils:literal_text(text), "' ===</B><BR>"); count = 0; for x in (objects) $cmd_utils:suspend_if_needed(0, player.user); for y in ($code_utils:grep_props(x, text, is_regex, all_matches)) player:pause(); link = tostr("<A HREF=\"/",$www:find_ref(x), ".", $su:subst(y[1], $www.desubst_single), "\">", x, ".", $html_utils:literal_text(y[1]), "</A>"); player:tell(link, " (Line ", y[2], ") -> <TT>", $html_utils:literal_text(y[3]), "</TT><BR>"); count = count + 1; if (count == (player.user:isa($guardian) ? 1000 | 100)) player:tell("<I>", count, " property matches printed. Too much spam. Terminating grep.</I><BR>"); break x; endif endfor endfor endif if (mode_verb) player:tell("<P><B>=== ", verb, " of verbs on ", length(objects) == 1 ? $su:nn(objects[1]) | tostr(length(objects), " objects"), " for '", $html_utils:literal_text(text), "' ===</B><BR>"); count = 0; for x in (objects) $cmd_utils:suspend_if_needed(0, player.user); for y in ($code_utils:grep_verbs(x, text, is_regex, all_matches)) player:pause(); link = tostr("<A HREF=\"/",$www:find_ref(x), "%3A", $su:subst(verbs(x)[y[1]], $www.desubst_single), "\">", x, ":", $html_utils:literal_text(verbs(x)[y[1]]), "</A>"); if (player.user.wizard && verb_info(x, y[1])[1].wizard) link = tostr("<B>", link, "</B>"); endif player:tell(link, " (Line ", y[2], ") -> <TT>", $html_utils:literal_text(y[3]), "</TT><BR>"); count = count + 1; if (count == (player.user:isa($guardian) ? 1000 | 100)) player:tell("<I>", count, " property matches printed. Too much spam. Terminating grep.</I><BR>"); break x; endif endfor endfor endif if (mode_file) player:tell("<P><B>=== ", verb, " of files on ", length(objects) == 1 ? $su:nn(objects[1]) | tostr(length(objects), " objects"), " for '", $html_utils:literal_text(text), "' ===</B><BR>"); count = 0; if (!player:tell("[Sorry, file grepping hasn't been implemented yet.]")) for x in (objects) $cmd_utils:suspend_if_needed(0, player.user); for y in ($code_utils:grep_files(x, text, is_regex, all_matches)) player:pause(); link = tostr("<A HREF=\"/",$www:find_ref(x), "!", $su:subst(y[1], $www.desubst_single), "\">", x, "!", $html_utils:literal_text(y[1]), "</A>"); player:tell(link, " (Line ", y[2], ") -> <TT>", $html_utils:literal_text(y[3]), "</TT><BR>"); count = count + 1; if (count == (player.user:isa($guardian) ? 1000 | 100)) player:tell("<I>", count, " property matches printed. Too much spam. Terminating grep.</I><BR>"); break x; endif endfor endfor endif endif player:tell("<P><B>=== End of ", verb, " ===</B><HR>"); $code_utils:semaphore_exit("grep", player.user);endif%><% endif %><P><FORM ACTION="/grep"><DL><DT>Grep for text:<DD><INPUT TYPE="text" NAME="text" SIZE=30 VALUE="<%=$html_utils:literal_text(text)%>"><DD><INPUT TYPE="checkbox" NAME="is_regex" <%=is_regex ? "CHECKED" | ""%>> Parse as a regular expression.<DD><INPUT TYPE="checkbox" NAME="all_matches" <%=all_matches ? "CHECKED" | ""%>> Show every match, not just the first one in each prop/verb/file.<DT>On objects:<DD><INPUT TYPE="text" NAME="objects" SIZE=15 VALUE="<%=$html_utils:literal_text(objectstr)%>"><DD>(e.g. <TT>#123</TT> or <TT>#100..#150</TT> or <TT>~<%=player.user.name%></TT>)<DT>Search all:<DD><INPUT TYPE="checkbox" NAME="props" <%=mode_prop ? "CHECKED" | ""%>> properties and/or<DD><INPUT TYPE="checkbox" NAME="verbs" <%=mode_verb ? "CHECKED" | ""%>> verbs.<!-- <DD><INPUT TYPE="checkbox" NAME="files" <%=mode_file ? "CHECKED" | ""%>> files. --><DT><INPUT TYPE="submit" VALUE="Grep!"></DL></FORM><P><% endif %><% this:tell_www_tail(@args); %></BODY></HTML><!-- Last modified by Dax (#789) on Thu Sep 26 07:14:03 2002 MDT. --> |