예제 #1
0
파일: edit.c 프로젝트: mudchina/nitan3
int main(object me, string file)
{
        if (! SECURITY_D->valid_grant(me, "(apprentice)"))
                return 0;
                
        if (! file) return notify_fail("指令格式:edit <档名>\n");
        
        if (in_edit(me)) return notify_fail("你已经在使用编辑器了。\n");
        
        file = resolve_path(me->query("cwd"), file);

        foreach (object user in users())
        if (file == in_edit(user))
                return notify_fail(HIM "共享冲突:" + user->name(1) + HIM "(" + 
                        capitalize(user->query("id")) + ")" + 
                        HIM "正在编辑该文件(" + file + ")。\n" NOR);

        printf("编辑文件:%s\n", file);
        CHANNEL_D->do_channel(this_object(), "sys",
                sprintf("%s(%s)正在编辑文件(%s)。",
                me->name(1),
                capitalize(me->query("id")),
                file));
                
        seteuid(geteuid(me));
        me->set("cwf", file);
        SECURITY_D->backup_file(file);
        ed(file); 
        
        log_file("static/edit", sprintf("%s %-9s edit %s from %s.\n",
                                        log_time(),
                                        geteuid(me), file,
                                        query_ip_name(me)));
        return 1;
}
예제 #2
0
파일: message.c 프로젝트: mudchina/fy2
void receive_message(string msgclass, string msg)
{
	string subclass, *ch;

	if( !interactive(this_object()) ) {
		this_object()->relay_message(msgclass, msg);
		return;
	}

	if( sscanf(msgclass, "%s:%s", subclass, msgclass)==2 ) {
		switch(subclass) {
			case "channel":
				if( !pointerp(ch = query("channels"))
				||	member_array(msgclass, ch)==-1 )
					return;
				break;
			case "outdoor":
				if( !environment() || !environment()->query("outdoors") )
					return;
				break;
			default:
				error("Message: Invalid Subclass " + subclass + ".\n");
		}
	}

	if( query_temp("block_msg/all") || query_temp("block_msg/" + msgclass) )
		return;

	if( in_input(this_object()) || in_edit(this_object()) ) {
		if( sizeof(msg_buffer) < MAX_MSG_BUFFER )
			msg_buffer += ({ msg });
	} else
예제 #3
0
파일: edit.c 프로젝트: gongfuPanada/jy
int main(object me, string file)
{
	if( !file ) return notify_fail("指令格式:edit <档名>\n");

	if( in_edit(me) ) return notify_fail("你已经在使用编辑器了。\n");

	seteuid(geteuid(me));
	ed(resolve_path(me->query("cwd"), file));
	return 1;
}
예제 #4
0
파일: who.c 프로젝트: rmanis/lil
int main(string arg) {
    object user;

    printf("%-25s  idle\n", "name (*edit, +input)");
    printf("---------------------     -----\n");
    foreach (user in users()) {
        printf("%-25s %4dm\n", (string)user->query_name() +
                (in_edit(user) ? "*" : "") +
                (in_input(user) ? "+" : ""),
                query_idle(user) / 60
        );
    }
예제 #5
0
파일: who.c 프로젝트: quixadhal/SuckingMUD
int main(string arg)
{
    object *list;
    int j;

    printf("%-25s idle\n", "name (*edit, +input)");
    printf("--------------------      ----\n");
    for (list = users(), j = 0; j < sizeof(list); j++) {
        printf("%-25s %4d\n", (string)list[j]->query_name() +
                (in_edit(this_player()) ? "*" : "") +
                (in_input(this_player()) ? "+" : ""),
                query_idle(this_player()) / 60
              );
    }
    return 1;
}
예제 #6
0
int cmd_ed(string file) {
    mixed *dir;
    int test;
    string tmp, err;

    if (in_edit(this_player())) {  // get real! you can't do this!
	notify_fail("You are already editing a file.\n");
	return 0;
    }

    // set our permissions.
    seteuid(geteuid(this_player()));

    // If they haven't given an arguement as to what file...
    if (!file) file=(string)this_player()->query("cwf");
    if (!file) { 
	write("Editing: [no file specified]\n");
	ed();
	return 1;
    }

    // get the filename to edit
    tmp = (string)this_player()->query("cwd");
    file = resolv_path(tmp, file);

    // Check if there is such a directory ..

    dir = explode(file, "/");
    if (file_size(implode( dir[0..sizeof(dir)-2], "/")) != -2) {
	write("Ed: No such directory file path.\n");
	return 1; }

    //  Check to make sure the file isn't actually a directory.

    if (directory_exists(file)) {
	notify_fail("Ed: Directory with that name already exists.\n");
	return 0;
    }

    // Can we write here?
    err = catch( test = write_file(file, "") );

    if (err) {
	write("Ed: Could not edit requested file.\n" + err );
	return 1;
    }

    // now check and see if the file is being edited by someone else.
    if (test) {
	if (file_size(file) == 0) rm(file);

	if (!(file_lock(file, F_LOCK))) {
	    // in this case, it is, so we make a temp copy.
	    tmp = "/tmp/" + geteuid(this_player()) + "." + 
	    implode(explode(file, "/"), "_");
	    write("That file is being edited by " +
	      capitalize(geteuid(query_lock_object(file))) + ".\n");
	    if (!(file_lock(tmp, F_LOCK))) {
		write("Ed: Unable to create temporary file.\n");
		return 1;
	    }
	    // cp(file, tmp);  // Is cp broken?
	    if (file_size(tmp)) rm(tmp);
	    if (file_size(file) > 0)
		write_file(tmp, read_file(file));
	    file = tmp;
	}
    }

    // Now let's make the message you see as you go into ed.
    tmp = "Editing: " + file;

    // Can we write here?
    err = catch( test = write_file(file, "") );
    if (err) {
	write("Ed: Could not edit requested file.\n" + err );
	file_lock(file, F_UNLOCK);
	return 1;
    }

    if (!test)
	tmp += " [read only]";

    // is it new?
    else if (!file_size(file)) tmp += " [new file]";
    tmp += "\n";

    // write the message that we're editing a file...
    write(tmp);

    this_player()->set("cwf",file);

    // Yes, the evil admin logging... it can be circumvented, but
    // this tells us at least most of what gets changed.
    // actually, this would be better if it only logged when a crucial
    // file is actually changed.

#ifdef ED_LOG
    tmp = capitalize(geteuid(TP)) + " : \"" + file + "\" ";
    if (!test) test += "[read only] ";
    tmp += "[" + extract(ctime(time()), 4, 15) + "]";

    log_file(ED_LOG, wrap(tmp));
#endif

    // okay, let's invoke the editor, and have it go to the done function after.
    ed(file, "done_editing");

    return 1;
}
예제 #7
0
파일: c_view2.c 프로젝트: szhowardhuang/fs2
void second( object *user , string str )
{
	int     i, count, state;
	string  list, CO, state_str, list2;
	user = sort_array(user, "sort_rank", this_object());
        i = sizeof(user);
        list = sprintf( HIG"《"HIY"%|10s"HIG"》"HIC" 线上帮众 "NOR"-\n", str );
	list+= "───────────────────────────────────────\n";
	count = 0;

        while( i-- )
        {
                switch(user[i]->query("clan/rank")) {
	case 1  :       CO = HIW + "Ψ";        break;
	case 2  :       CO = HIC + "ζ";        break;
        case 3  :       CO = HIY + "Φ";        break;
        case 4  :       CO = HIG + "卍";        break;
        case 5  :       CO = HIM + "Ξ";        break;
        case 6  :       CO = HIB + "∏";        break;
        case 7  :       CO = HIR + "Χ";        break;
		default :       CO = NOR + "?";        break;
		}

        if(this_player())
        if( wizardp(user[i]) && !wizardp(this_player()))
			continue;
		if( wiz_level(this_player())<6 && user[i]->query("env/隐身") && wiz_level(user[i]) && wiz_level(user[i]) > wiz_level(this_player()) )
		{
		 continue;
		}
		state = 0;
		state_str = "";
		count++;

                list = sprintf( "%s"HIC"【"NOR"%|10s"HIC"】"NOR"%s%|10s%s"NOR"",
			list,
                        area(user[i]),
                        CO,
                        (user[i]->query("clan/title") ? user[i]->query("clan/title") : "--无职衔--"), CO );
/*
		list2 = (user[i]->query("title") ? user[i]->query("title") : "" ) +
                        (user[i]->query("nickname") ? "「"+user[i]->query("nickname")+"”" : " " ) +
                        user[i]->query("name")+"("+user[i]->query("id")+")";
                if( strlen((list2))>80 )*/
                	list2 = (user[i]->query("nickname") ? "「"+user[i]->query("nickname")+"”" : " " ) +
                        	user[i]->query("name")+"("+user[i]->query("id")+")";
                list += list2;

		if( user[i]->query_temp("netdead") ) {
			state_str += HIR"(断线)"NOR;
			state = 1;
		}
		if( !environment(user[i]) ) {
			state_str += HIG"(异次元)"NOR;
			state = 1;
		}
		if( in_edit(user[i]) ) {
			state_str += HIY"(编辑)"NOR;
			state = 1;
		}
		if( in_input(user[i]) ) {
			state_str += HIC"(阅\读)"NOR;
			state = 1;
		}
		if( interactive(user[i]) && query_idle(user[i])>120 ) {
                	state_str += sprintf( "%s", HIM"(发呆 "+query_idle(user[i])/60+" 分钟)"NOR );
                	state = 1;
                }
                if( state ) list = list + /*"\t\t\t   " +*/ state_str;
                list += "\n";
        }

	list +=	"───────────────────────────────────────\n";
	list += sprintf( " 目前线上共有 %d 位帮众, 系统负担: %s\n\n", count, query_load_average() );

        this_player()->start_more(list);
}
예제 #8
0
파일: fight.c 프로젝트: szhowardhuang/fs2
int main(object me, string arg)
{
	object obj, old_target;

        seteuid(getuid());
  if((!wizardp(me) && environment(me)->query("no_fight"))||me->query("id")=="guest")
		return notify_fail("这里禁止对打。\n");

	if(!arg || !objectp(obj = present(lower_case(arg), environment(me))))
		return notify_fail("你想攻击谁?\n");
        arg = lower_case(arg);

	if( !obj->is_character() )
		return notify_fail("看清楚一点,那并不是生物。\n");

	if (obj->query("no_kill")) return
          notify_fail ("这家伙你不能动就是不能动。\n");

	if( obj->is_fighting(me) )
		return notify_fail("加油!加油!加油!\n");

	if( !living(obj) )
		return notify_fail(obj->name() + "已经无法战斗了。\n"); 

	if(obj==me)	return notify_fail("你不能攻击自己。\n");

if( !userp(obj) && !obj->accept_fight(me) ) return
    notify_fail ("看起来你砍不到"+obj->name()+"\n");

	if (in_edit(obj) || in_input(obj) || obj->query_temp("netdead"))
          return notify_fail ("等他醒过来再砍吧.\n");

	if( userp(obj) && (object)obj->query_temp("pending/fight")!=me ) {
		message_vision("\n$N对着$n说道:" 
			+ RANK_D->query_self(me) 
			+ me->name() + ",领教"
			+ RANK_D->query_respect(obj) + "的高招!\n\n", me, obj);
		if( objectp(old_target = me->query_temp("pending/fight")) )
			tell_object(old_target, YEL + me->name() + "取消了和你比试的念头。\n" NOR);
		me->set_temp("pending/fight", obj);
		tell_object(obj, YEL "如果你愿意和对方进行比试,请你也对" + me->name() + "("+(string)me->query("id")+")"+ "下一次 fight 指令。\n" NOR);
		write(YEL "由于对方是由玩家控制的人物,你必须等对方同意才能进行比试。\n" NOR);
		return 1;
	}

	if( obj->query("can_speak") ) {
		message_vision("\n$N对着$n说道:" 
			+ RANK_D->query_self(me) 
			+ me->name() + ",领教"
			+ RANK_D->query_respect(obj) + "的高招!\n\n", me, obj);


		me->fight_ob(obj);
		obj->fight_ob(me);
	} else {
		message_vision("\n$N大喝一声,开始对$n发动攻击!\n\n", me, obj);
		me->fight_ob(obj);
		obj->kill_ob(me);
	}

	return 1;
}