; +-----------------------------------------------------------------+ ; | - - TinyFuge Edit - - | ; | Written and Copyright Jun 3, 1997 Christian J. Robinson | ; | (infynity@onewest.net) | ; | Distributed under the terms of the GNU Public License. | ; | No warranty, express or implied! | ; +-----------------------------------------------------------------+ ; This code was designed to completely get away from having any server side ; code for the /ed command, because that makes it all inherently insecure. ; However, this code does send the client some code to grab the info you are ; editing, but this is considered acceptable and reasonably safe. Especially ; since it chooses a random number to include as part of the trigger. ; If the number it gets back is -not- what it chose when you invoked /ed, it ; complains of a possible spoof, and ignores the trigger string. On top of ; that, it will complain and ignore -any- edit trigger if you haven't invoked ; /ed since the last time it got a matching trigger. ; This /ed code calls a handler (a command /def) called ed_, for ; your current world, or a world specified with -w, sending it any ; arguments it received. That is, if the world type is 'tiny.mux' when you ; invoked /ed, it would run /ed_tiny.mux, plus whatever you typed after /ed as ; arguments. If there is no handler for the world type, it will complain and ; stop. ; A handler should /return the necessary text to somehow get the world to send ; you the string: TinyFugueEdit (randnum) > (whatever is needed to set the new ; attribute) Without the ()'s, of course. (See the handlers I have defined ; below.) ; So far I only have a handler for all MUSH/MUX types (ed_tiny.mux just calls ; ed_tiny.mush), plus a somewhat workable MUCK handler that requires ; server-side code (ick). ; ; If all else fails, read the code. :) ; ----------------------------------------------------------------------------- ; RCS: ; $Id: tf-edit.tf,v 1.10 2006/10/16 00:49:00 infynity Exp $ ; $Log: tf-edit.tf,v $ ; Revision 1.10 2006/10/16 00:49:00 infynity ; *** empty log message *** ; ; Revision 1.9 2006/10/16 00:25:14 infynity ; Make the spoof warning much more explicit ; ; Revision 1.8 2004/02/18 10:15:31 infynity ; *** empty log message *** ; ; Revision 1.7 2002/05/31 13:21:19 infynity ; Added example MUF program for MUCKs to allow editing. ; ; Revision 1.6 2001/10/08 14:31:22 infynity ; Changed @pemit to @pemit/silent for MUX/MUSH. ; ; Revision 1.5 2000/11/13 03:46:55 infynity ; Email address change, again. ; ; Revision 1.4 2000/11/03 06:03:56 infynity ; Email address change. ; ; Revision 1.3 2000/04/22 10:21:20 infynity ; Code cleanup. /ed now more "cleanly" calls the handlers, ; which no longer need to /echo -e, and are expected to /return... ; ; Commentary cleanup. ; ; Revision 1.2 1999/07/12 10:38:50 infynity ; Added a handler for MUCK, but it requires a server-side program. Ah well. ; ; Revision 1.1 1999/07/12 08:18:20 infynity ; Initial revision ; ; ----------------------------------------------------------------------------- /loaded __OWNLIB__/tf-edit.tf ; Set up: /set tf_edit_randnum=0 ; The trigger: /def -i -ag -p100 -mglob -t"TinyFugueEdit * > *" -q tf_edit_trig = \ /if ({2} = {tf_edit_randnum} & {tf_edit_randnum} != 0) \ /grab %-3 %;\ /set tf_edit_randnum=0 %;\ /else \ /if ($(/ver) >= 5.0 ) \ /echo %% $[decode_attr("@{Cbgbrightred,b,Cblack}WARNING:@{n}")] Possible TinyFugueEdit spoof-> %* %;\ /else \ /echo %% WARNING: Possible TinyFugueEdit spoof-> %* %;\ /endif %; \ /endif ; The tf command: /def -i ed = \ /test getopts("w:") %;\ /if ({opt_w} !~ "" & $(/listsockets -s %{opt_w}) =~ "") \ /echo -e %% No connected worlds match '%{opt_w}'. %;\ /return %;\ /endif %; \ /let wtype=$[world_info((({opt_w} !~ "") ? {opt_w} : ${world_name}), 'type')] %;\ /if ($(/listdef -s -i ed_%{wtype}) !/ "") \ /set tf_edit_randnum=$[rand(99,9999999)] %;\ /ed_%{wtype} $[escape('%[]{}\'', {*})] %;\ /let _text=%? %;\ /if ({_text} !~ "") \ /test send(_text, {opt_w}) %;\ /endif %;\ /else \ /echo -e %% An /ed macro handler does not exist for world type: '%{wtype}' %;\ /endif ; Uncomment this to make it so sending 'ed *' actually calls '/ed *'. ;/def -i -mglob -h'SEND ed *' tf_edit_send_hook = /ed %-1 ; A handler for tiny.mush: /def -i ed_tiny.mush = \ /if (regmatch('(.+)/([^ ]+)$', {*})) \ /echo %% TF Edit - Object: %P1 %;\ /echo %% - Attribute: %P2 %;\ /let _text=@pemit/silent me=TinyFugueEdit %tf_edit_randnum > &%P2 %P1=[get(%P1/%P2)] %;\ /return _text %;\ /else \ /echo -e %% /ED Usage for world type '%{wtype}': /ed / %;\ /return '' %;\ /endif ; tiny.mux is close enough to tiny.mush: /def -i ed_tiny.mux = /ed_tiny.mush %* ; A handler for tiny.muck: (This requires a program on the MUCK; see below.) /def -i ed_tiny.muck = \ /if (regmatch('(.+)=([^ ]+)$', {*})) \ /echo %% TF Edit - Object: %P1 %;\ /echo %% - Property: %P2 %;\ /let _text=edit %tf_edit_randnum %P1=%P2 %;\ /return _text %;\ /else \ /echo -e %% /ED Usage for world type '%{wtype}': /ed = %;\ /return '' %;\ /endif ;; The following is an example muck program for allowing editing, without the ;; first leading ; chracter: ; ;: tfedit ; dup " " instr dup not if ; "Wrong format. Error." .tell exit then ; 1 - strcut 1 strcut swap pop ; dup "=" instr dup not if ; "Wrong format. Error." .tell exit then ; 1 - strcut 1 strcut swap pop swap ; strip ; dup "#-2" instr if ; "Um.. huh???" .tell exit then ; dup "#" instr 1 = if ; 1 strcut swap pop ; atoi dbref ; else ; match ; then ; dup #-2 dbcmp if ; "Which one?" .tell exit then ; dup ok? not if ; "Object not found." .tell exit then ; me @ over controls not if ; "You don't own that." .tell exit then ; over "/" instr 3 pick strlen = if ; "Cannot edit a propdir." .tell exit then ; me @ 3 pick getprop dup not if ; pop "" ; else ; dup string? not if ; "This property contains a non-string argument... edit will not work." ; .tell exit then ; then ; "TinyFugueEdit " 5 rotate strcat ; " > @set #" strcat ; rot intostr strcat ; "=" strcat rot strcat ; ":" strcat swap strcat ; .tell ;; ; vim: set et: