Exemplo n.º 1
0
void Mineserver::saveAllPlayers()
{
  for (std::set<User*>::const_iterator it = users().begin(); it != users().end(); ++it)
  {
    if ((*it)->logged) (*it)->saveData();
  }
}
Exemplo n.º 2
0
void update_ads_phase()
{
	int i;
	int ads_count = 0;
	object* all;
	
	remove_call_out("update_ads_phase");
	
	if(current_ads_phase==0) 
	{
       		init_ads_phase();
   	}

	current_ads_phase = (++current_ads_phase) % sizeof(ads_phase);
	
	message("channel:ads", "【广告】" + ads_phase[current_ads_phase]["time_msg"] + "\n", users());
	
	all = users();
	for(i=0;i<sizeof(all);i++) {
		if( member_array("ads", all[i]->query("channels"))==-1 ) continue;
		else ads_count++;
	}
	
	if(ads_count >=1) {
	//	message( "channel:wiz", sprintf("【巫师】%d 个玩家接收此广告。\n", ads_count), users());
		log_file("ADS", sprintf("[%s] \"" + ads_phase[current_ads_phase]["time_msg"] + "\" 被 [%d] 个玩家接收\n", 
		ctime(time()),	ads_count));
	}

	this_object()->event_common();

       	call_out("update_ads_phase", ads_phase[current_ads_phase]["length"]);
}
Exemplo n.º 3
0
size_t Mineserver::getLoggedUsersCount()
{
    size_t count = 0;
    for(std::set<User*>::const_iterator it = users().begin(); it != users().end(); ++it) {
        if((*it)->logged) count++;
    }
    return count;
}
Exemplo n.º 4
0
void event_noon()
{
	object *ob;
        int i, skill,con,con1,con2,con3;
        string get_month,ill,msg;
get_month = CHINESE_D->chinese_month(TIME_TICK);
        switch(get_month)
        {
                case "三":
                case "四":
                case "五":
                     ill = "ill_kesou";
                     msg = HIG + "忽然喉头一阵痕痒,你感觉似乎要咳嗽了。\n" + NOR;
                     break;
                case "六":
                case "七":
                case "八":
                     ill = "ill_zhongshu";
                     msg = HIG+"突然你胸臆之间一阵翻腾,你中暑了。\n" + NOR;
                     break;
                case "九":
                case "十":
                case "十一":
                     ill = "ill_shanghan";
                     msg = HIG+"陡的你打了个冷战,头昏沉沉的,你得伤寒病了。\n"+NOR;
                     break;
                case "十二":
                case "一":
                case "二":
                     ill = "ill_dongshang";
                     msg = HIG+"你肢体末端一阵僵直,看来你被冻伤了。\n"+NOR;
                     break;
        }
        if(random(2))
        {
                ill = "ill_fashao";msg = HIG+"你偶感风寒,竟而发起烧来。\n"+NOR;
        }
        ob = users();
        for(i=0; i<sizeof(ob); i++)
        {
                if( !environment(ob[i]) ) continue;
                if( !environment(ob[i])->query("outdoors") ) continue;
                if( ob[i]->query("age")==14 ) continue;
con1 = ob[i]->query("kee");
 con2 = ob[i]->query("max_kee");
                (int)con = con1/con2*50;//形成第一个生病判断条件
con3 = ob[i]->query("force");
con2 = ob[i]->query("max_force");
		if( con2 == 0) con2 = 1;
                (int)con1 = con3/con2*50;//形成第二个生病判断条件
                if(random(con)+random(50)+random(con1)<25)
                {
                        ob[i]->apply_condition(ill, 10);
                        tell_object(ob[i], msg);
                }
        }
message("channel:chat", HIY +"【闲聊】太监:时至午正,皇上退朝,文武百官下殿!\n"+ NOR, users());
}
Exemplo n.º 5
0
static void the_end() {
    time -= 60;
     if(time < 11) call_out("end_it", 0);
    else call_out("the_end", 60);
       if(time < 541 && time > 480) {
  message("broadcast", "%^BOLD%^%^CYAN%^The gods begin to wage a war "
            "across the sky.%^%^RESET%^%^"
        "\nReboot in 9 minutes!",
         users());  }
    else if(time < 481 && time > 420) {
   message("broadcast", "%^BOLD%^%^BLUE%^Peacekeepers "
    "rush to save everything from the impending doom.%^RESET%^"
             "\nReboot in 8 minutes!",
    users()); }
    else if(time < 421 && time > 360) {
  message("broadcast", "%^BOLD%^%^YELLOW%^Lightning strikes "
    "down from the clouds, smiting everything it hits.%^RESET%^"
            "\nReboot in 7 minutes!",
   users());  }
  else if(time < 361 && time > 300) {
    message("broadcast", "%^MAGENTA%^With a loud thunder clap, the "
      "ground buckles and everything around you begins to collapse.%^RESET%^"
       "\nReboot in 6 minutes!",
      users());  }
  else if(time < 301 && time > 240) {
    message("broadcast", "%^BOLD%^%^WHITE%^In the graveyards "
         "the dead begin to climb from their graves.%^RESET%^"
      "\nReboot in 5 minutes!",
     users()); }
   else if(time < 241 && time > 180) {
     message("broadcast", "%^RED%^The moon slowly rises on the "
   "horizon, blood red.%^RESET%^"
     "\nReboot in 4 minutes!",
  users()); }
   else if( time < 181 && time > 120) {

   message("broadcast", "%^GREEN%^You hear a rumble in the forests "
  "as trees crash to the ground, %^BOLD%^%^RED%^burning.%^RESET%^"
   "\nReboot in 3 minutes!",
  users()); }
     else if(time < 121 && time > 60) {
     message("broadcast", "%^BOLD%^%^MAGENTA%^Everywhere you look people "
    "are fleeing in %^RESET%^%^RED%^terror.%^RESET%^%^BOLD%^%^MAGENTA%^  Trampling "
"each other in the general panic, they throw down their belongings and vainly "
    "look for shelter.%^RESET%^"
     "\nReboot in 2 minutes!",
 users()); }
   else if(time < 61 && time > 10) {
    message("broadcast", "%^BOLD%^%^BLACK%^The destruction is nearly here, "
     "walls of storm clouds are rapidly closing in, you see your fate and "
     "war with either joining the surrounding turmoil, or facing down the clouds."
     "%^RESET%^\nReboot in 1 minute.",
     users()); }
    if(time/60 == 3) message("broadcast", "%^CYAN%^Salox screams:"
        "%^RESET%^ Tell me "
      "if you want a trip to the shop!", users());
    let_everyone_know();
}
Exemplo n.º 6
0
void autosave()
{
 object *user ;
 int i;
        user = users();
        message("chat", HIY "自动更新幻想西天TASK任务。\n"NOR, users());
        for(i=0; i<sizeof(user); i++) 
        user[i]->save();
}
Exemplo n.º 7
0
void do_thunder() {
    int i, x = random(sizeof(MESSAGE)-1);
    for(i = 0;i < sizeof(users());i++) {
        if((environment(users()[i])->query_property("thunder")==1) &&
(interactive(users()[i]))) {
            message("info","%^YELLOW%^"+MESSAGE[ x ],users()[i]);
        }
    }
}
Exemplo n.º 8
0
Arquivo: cron.c Projeto: mudchina/fy4
void autosave()
{
 object *user ;
 int i;
         user = users();
        message("system", HIR "\n 自动存档...", users());
        for(i=0; i<sizeof(user); i++) 
        user[i]->save();
	message("system", HIG "...存档完毕 \n" NOR, users()); 
}
Exemplo n.º 9
0
Arquivo: cron.c Projeto: mudchina/fy2
void autosave()
{
 object *user ;
 int i;
         user = users();
        message("system", HIR "\n ╫╘╢п┤ц╡╡гогого", users());
        for(i=0; i<sizeof(user); i++) 
        user[i]->save();
	message("system", HIG "гогого┤ц╡╡═ъ▒╧ \n" NOR, users()); 
}
Exemplo n.º 10
0
int main(object me, string str)
{
    if (!str) {
        write(CYN"你看起来表情丰富。\n"NOR);
        return 1;
    }
        str = replace_string(str, "$BLK$", BLK);
        str = replace_string(str, "$RED$", RED);
        str = replace_string(str, "$GRN$", GRN);
        str = replace_string(str, "$YEL$", YEL);
        str = replace_string(str, "$BLU$", BLU);
        str = replace_string(str, "$MAG$", MAG);
        str = replace_string(str, "$CYN$", CYN);
        str = replace_string(str, "$WHT$", WHT);
        str = replace_string(str, "$HIR$", HIR);
        str = replace_string(str, "$HIG$", HIG);
        str = replace_string(str, "$HIY$", HIY);
        str = replace_string(str, "$HIB$", HIB);
        str = replace_string(str, "$HIM$", HIM);
        str = replace_string(str, "$HIC$", HIC);
        str = replace_string(str, "$HIW$", HIW);
        str = replace_string(str, "$NOR$", NOR);
	if( strsrch(str, "$ME$") == -1 )
	write("你输入的字串中必需含有$ME$\n");
	else{
	str = replace_string(str, "$ME$", me->name());
	if(check_legal_name(str))
	message("channel:chat", GRN +"【闲聊】"+ str + "\n" + NOR, users());
	}

    return 1;
}
Exemplo n.º 11
0
Arquivo: users.c Projeto: Elohim/FGmud
int cmd(){
    int i;
    object *user_ob;
    string ret, name, *user_name;

    user_ob = users();
    user_name = ({ });
mixed cmd(string str) {
  if(!TP->query_creator() && !TP->query_property("emoteall")) {
    return notify_fail(NOT_ALLOWED);
  }

  if(!str || str == "") {
    return notify_fail("Syntax : emoteall <string>\n");
  }

  if(!TP->query_creator() &&
     TP->adjust_sp(-EMOTEALL_COST*((strlen(str)/10)+1)+100) < 0) {
    return notify_fail(NO_POWER);
  }

  str = replace(str, BEEP, "");
  if (TP->query_volume(D_ALCOHOL)) {
    str = TP->drunk_speech(str);
  }
  log_file("ECHOS", ctime(time())+" "+TP->query_name()+" emotes "+
           "to all: "+str+"\n");
  str += "%^RESET%^";
  my_mess("You emoteall : ", TP->query_cap_name()+" " + str);
  TP->comm_event(users(), "player_emote_all", "%^BOLD%^%^RED%^" + TP->query_cap_name() + " " + str + "\n");
  return 1;
}
Exemplo n.º 13
0
void init_day_phase()
{
	mixed *local;
	int i, t;

	// Get minutes of today.
	local = localtime(TIME_TICK);
	t = local[2] * 60 + local[1];
	// hour * 60 + minutes

	// Find the day phase for now.
	for( i=0; i < sizeof(day_phase); i++)
		if( t >= day_phase[i]["length"] )
			t -= (int)day_phase[i]["length"];
		else break;

	current_day_phase = (i==0? sizeof(day_phase)-1: i - 1);
	current_day_phase = (i==0? sizeof(day_phase)-1: i - 1);
	// MUD 运行时间久了,时间会有偏差,这里是调整程序,每小时执行一次
	message("channel:sys", HIR"【系统】泥巴时间对齐系统时间,一小时一次。\n"NOR, users());
	remove_call_out("init_day_phase");
	call_out("init_day_phase", 3600);

	// Since in our time scale, 1 minute == 1 second in RL, so we don't need
	// any conversion before using this number as call_out dalay, if you
	// changed the time scale, be sure to convert it.

	call_out("update_day_phase", (int)day_phase[(current_day_phase+1) % sizeof(day_phase)]["length"]-t);
}
Exemplo n.º 14
0
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;
}
Exemplo n.º 15
0
void next_step(string ours, string later, object tp) {
   string color;
   object *people;
   int i;
   i = random(6);
   switch(i) {
     case 0: color = "%^RED%^"; break;
     case 1: color = "%^ORANGE%^"; break;
     case 2: color = "%^BLUE%^"; break;
     case 3: color = "%^CYAN%^"; break;
     case 4: color = "%^MAGENTA%^"; break;
     case 5: color = "%^BOLD%^%^WHITE%^"; break;
     default: color = "%^GREEN%^"; break;
   }
   if(random(2) == 0)
     color += "%^BOLD%^";
   people = users();
   i = sizeof(people);
   message("info", color+later+"%^RESET%^", tp);
   while(i--) {
     if(tp == people[i]) continue;
     if(!environment(people[i])) continue;
     if(environment(people[i])->query_property("indoors") == 1) continue;
     message("info", color+ours+"%^RESET%^", people[i]);
   }
}
Exemplo n.º 16
0
int where_all()
{
    string str;
    object *list;
    int i, j, ppl_cnt;
    object me, where;
        me = this_player();
        str = "* " + MUD_NAME + "\n";
        str += "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n";
        str += "聞喘旗催      嶄猟侖兆          朕念了崔      \n";
        str += "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n";
        list = users();
    j = sizeof(list);
    while( j-- ) {
        where=environment(list[j]);
        // Skip those users in login limbo.
        if( !where ) continue;
        str = sprintf("%s%-14s%-18s%-s(%s)\n",
                                str,
                                list[j]->query("id"),
                                list[j]->query("name"),
            where->query("short"),
            file_name(where)
                        );
                }
        str += "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n";
    me->start_more(str);
    return 1;
}
Exemplo n.º 17
0
void update_day_phase()
{
	int i,j;
	object *inusers,envroom;
	string str;
	remove_call_out("update_day_phase");

	current_day_phase = (++current_day_phase) % sizeof(day_phase);
	if( !undefinedp(day_phase[current_day_phase]["event_fun"]) )
		call_other(this_object(), day_phase[current_day_phase]["event_fun"]);
        i=0;
        // here is modified by vikee 2001-2-15 13:15
        str=HIR"〖"HIY"窗外"HIR"〗:"NOR+day_phase[current_day_phase]["time_msg"];
        inusers=users();
        for (i;i<(j=sizeof(inusers));i++)
        {
            envroom=environment(inusers[i]);
            if (envroom)
           {
            if ( intp(envroom->query("outdoors")))
             {
               if (envroom->query("outdoors")<1)
             	tell_object(inusers[i],str+"\n");
               else 
               tell_object(inusers[i],day_phase[current_day_phase]["time_msg"]+"\n");
             }
            else
             {
             	tell_object(inusers[i],day_phase[current_day_phase]["time_msg"]+"\n");
             }
          }     
       }
       call_out("update_day_phase", day_phase[current_day_phase]["length"]);

}
Exemplo n.º 18
0
/**
 * @fn addUserPrivate
 */
QueuedResult<long long>
QueuedCorePrivateHelper::addUserPrivate(const QString &_name, const QString &_email,
                                        const QString &_password, const uint _permissions,
                                        const uint _priority, const QueuedLimits::Limits &_limits)
{
    qCDebug(LOG_LIB) << "Add user" << _name << "with email" << _email << "and permissions"
                     << _permissions;
    // add to database
    QVariantHash properties = {{"name", _name},         {"password", _password},
                               {"email", _email},       {"permissions", _permissions},
                               {"priority", _priority}, {"limits", _limits.toString()}};
    auto id = database()->add(QueuedDB::USERS_TABLE, properties);
    if (id == -1) {
        qCWarning(LOG_LIB) << "Could not add user" << _name;
        return QueuedError("", QueuedEnums::ReturnStatus::Error);
    }

    // add to child object
    users()->add(properties, id);
    // notify plugins
    if (plugins())
        emit(plugins()->interface()->onAddUser(id));

    return id;
}
Exemplo n.º 19
0
mixed  main(object  me,  string  arg,  int  remote)
{
	object  *ulist;
	int  i;

        if (! SECURITY_D->valid_grant(me, "(arch)"))
                return 0;

	ulist  =  users();
	i  =  sizeof(ulist);
	while  (i--)  {
		object  who  =  ulist[i];
		object  ridee  =  ulist[i]->query_temp("ridee");
		
		if  (!  ridee)
			continue;
		if  (ridee->query_temp("rider")  !=  who)  {
			continue;
		}	
		write  ("    ");
		write  (who->query("name")+"("+who->query("id")+")");
		write  (ridee->query("ride/msg")+"在");
		write  (ridee->query("name")+"("+ridee->query("id")+")");
		write  ("上。\n");
	}
	return  1;
}
Exemplo n.º 20
0
  void	Config::parseUsers()
  {
    std::ifstream	file("conf/users.json");

    if(!file.fail())
      {
	bool parsingSuccessful = _readerJson.parse(file, _root, false);
    
	if (!parsingSuccessful)
	  {
	    std::cerr  << "\033[31mFailed to parse users file\n\033[36m"
		       << _readerJson.getFormatedErrorMessages()
		       << "\033[0m" << std::endl;
	    _root = Json::Value(Json::objectValue);
	    Json::Value	users(Json::arrayValue);
	    Json::Value::UInt	i = 0;
	    _root[i] = users;
	  }
	file.close();
      }
    else
      {
	std::cerr << "\033[31mCan't find users file\033[0m" << std::endl;
      }

    /* je remplie ma map avec les utilisateurs */
    for (size_t i = 0; i < _root["users"].size(); i++)
      {
	_keysAndTokens[reinterpret_cast<int32_t>(_root["users"][i]["id"].asInt())] = reinterpret_cast<uint32_t>(_root["users"][i]["token"].asUInt());
      }
  }
Exemplo n.º 21
0
int main(object me) 
{
        float value;
        mapping r;

        if (time() - me->query_temp("scan_time") < 10
           && ! wizardp(me))
                return notify_fail("等等,系统喘气中……\n");

        r = rusage();
        value = SCALE * (r["utime"] + r["stime"]) / uptime();

        write(NOR + WHT "\n\t\t         .__________ 系 统 资 讯 __________.\n");
        write(NOR + WHT "\t\t ─────────────────────────\n");
        write(NOR + WHT "\t\t 游戏的识别名称:  " + MUD_NAME + "\n");
        write(NOR + WHT "\t\t 界面系统的版本:  " + __VERSION__ + "\n");
        write(NOR + WHT "\t\t 系统函数库版本:  Nitan Mudlib Version 2.1\n");
        printf(NOR + WHT "\t\t CPU 使用百分比:  %f %% 被这个游戏使用中\n", value );
        write(NOR + WHT "\t\t CPU 的负担状况:  " + query_load_average() + "\n");
        printf(NOR + WHT "\t\t 共使用的记忆体:  %s bytes\n", memory_expression(memory_info()) );
        write(NOR + WHT "\t\t 线上使用者总数:  " + sizeof( users() ) + "  个人在线上\n");
        write(NOR + WHT "\t\t 注册使用者总数:  " + count_ppls() + "  个人在本游戏注册\n");
        write(NOR + WHT "\t\t 载入的物件总数:  " + sizeof( objects() ) + " 个物件\n");
        write(NOR + WHT "\t\t 心跳总数的资讯:  " + sizeof(heart_beats()) + " 个\n");
        write(NOR + WHT "\t\t 延迟呼叫数资讯:  " + sizeof(call_out_info()) + " 个\n");
        write(NOR + WHT "\t\t 系统负载的资讯:  " + query_load_average() + "\n");
        write(NOR + WHT "\t\t 讯息传输的资讯:  " + query_rusage_message() + "\n");
        write(NOR + WHT "\t\t 连续执行的时间:  " + dotime() + "\n");
        write(NOR + WHT "\t\t 游戏现在的状态:  " + STATUS + "\n" NOR);
        write(NOR + WHT "\t\t 游戏对 PK 限制:   每天不超过 8 人,每人不超过 2 次\n\n" NOR);

        me->set_temp("scan_time", time());

        return 1;
}
Exemplo n.º 22
0
int do_purge_all_players()
{
        int i, j, ppl_cnt, count;
        string *dir, *ppls, name;
        mixed info;

        seteuid(getuid());
        message("system", "\n*** 整理玩家储存档中,请稍候.... ***\n", users());
        write("处理中:");
        count = 0;
        ppl_cnt = 0;
        dir = get_dir(DATA_DIR + "login/");
        for(i=0; i<sizeof(dir); i++) {
                reset_eval_cost();
                write(dir[i]);
                ppls = get_dir(DATA_DIR + "login/" + dir[i] + "/");
                ppl_cnt += sizeof(ppls);
                for(j=0; j<sizeof(ppls); j++) {
                        if( sscanf(ppls[j], "%s.o", name)==1 )
                                if( (string)SECURITY_D->get_status(name)!="(player)" )
                                        continue;
                        info = stat(DATA_DIR + "login/" + dir[i] + "/" + ppls[j]);
                        if( SECURITY_D->get_status(name) == "(player)" ) {
                                rm(DATA_DIR + "login/" + dir[i] + "/" + ppls[j]);
                                rm(DATA_DIR + "user/" + dir[i] + "/" + ppls[j]);
                                count ++;
                        }
                }
        }
        write("\n\n原来总共有 " + ppl_cnt + " 位使用者。\n");
        write("现在总共有 " + (ppl_cnt - count) + " 位使用者。\n");

        return 1;
}
Exemplo n.º 23
0
bool AuthModel::validateField(Field field)
{
  if (field == RememberMeField)
    return true;

  User user = users().findWithIdentity(Identity::LoginName,
				       valueText(LoginNameField));
  if (field == LoginNameField) {
    if (user.isValid())
      setValid(LoginNameField);
    else {
      setValidation
	(LoginNameField,
	 WValidator::Result(ValidationState::Invalid,
			    WString::tr("Wt.Auth.user-name-invalid")));

      throttlingDelay_ = 0;
    }

    return user.isValid();
  } else if (field == PasswordField) {
    if (user.isValid()) {
      PasswordResult r
	= passwordAuth()->verifyPassword(user, valueText(PasswordField));

      switch (r) {
      case PasswordResult::PasswordInvalid:
	setValidation
	  (PasswordField,
	   WValidator::Result(ValidationState::Invalid,
			      WString::tr("Wt.Auth.password-invalid")));

	if (passwordAuth()->attemptThrottlingEnabled())
	  throttlingDelay_ = passwordAuth()->delayForNextAttempt(user);

	return false;
      case PasswordResult::LoginThrottling:
	setValidation
	  (PasswordField,
	   WValidator::Result(ValidationState::Invalid,
			      WString::tr("Wt.Auth.password-info")));
	setValidated(PasswordField, false);

	throttlingDelay_ = passwordAuth()->delayForNextAttempt(user);
	LOG_SECURE("throttling: " << throttlingDelay_
		   << " seconds for " << user.identity(Identity::LoginName));

	return false;
      case PasswordResult::PasswordValid:
	setValid(PasswordField);
	return true;
      }

      /* unreachable */
      return false;
    } else
      return false;
  } else
    return false;
}
Exemplo n.º 24
0
User AuthModel::processAuthToken()
{
  WApplication *app = WApplication::instance();
  const WEnvironment& env = app->environment();

  if (baseAuth()->authTokensEnabled()) {
    const std::string *token =
      env.getCookie(baseAuth()->authTokenCookieName());

    if (token) {
      AuthTokenResult result = baseAuth()->processAuthToken(*token, users());

      switch(result.state()) {
      case AuthTokenState::Valid: {
        if (!result.newToken().empty()) {
          /*
           * Only extend the validity from what we had currently.
           */
          app->setCookie(baseAuth()->authTokenCookieName(), result.newToken(),
                         result.newTokenValidity(), "", "", app->environment().urlScheme() == "https");
        }

	return result.user();
      }
      case AuthTokenState::Invalid:
        app->setCookie(baseAuth()->authTokenCookieName(),std::string(), 0, "", "", app->environment().urlScheme() == "https");

	return User();
      }
    }
  }

  return User();
}
Exemplo n.º 25
0
static void end_it() {
    time -= 50;
    call_out("shut", 10);
   message("broadcast", "Chaos reigns as the mud reboots in "
      "10 seconds!", users());
    let_everyone_know();
}
Exemplo n.º 26
0
/**
 * @fn editUserPermissionPrivate
 */
QueuedResult<bool> QueuedCorePrivateHelper::editUserPermissionPrivate(
    const long long _id, const QueuedEnums::Permission &_permission, const bool _add)
{
    qCDebug(LOG_LIB) << "Edit permissions" << static_cast<int>(_permission) << "for user" << _id
                     << "add" << _add;

    auto userObj = users()->user(_id);
    if (!userObj) {
        qCWarning(LOG_LIB) << "Could not find user with ID" << _id;
        return QueuedError("User does not exist", QueuedEnums::ReturnStatus::InvalidArgument);
    }

    // edit runtime permissions to get value
    auto perms
        = _add ? userObj->addPermission(_permission) : userObj->removePermission(_permission);
    auto permissions = static_cast<uint>(perms);
    qCInfo(LOG_LIB) << "New user permissions" << perms;

    // modify in database now
    QVariantHash payload = {{"permissions", permissions}};
    bool status = database()->modify(QueuedDB::USERS_TABLE, _id, payload);
    if (!status) {
        qCWarning(LOG_LIB) << "Could not modify user record" << _id
                           << "in database, do not edit it in memory";
        // rollback in-memory values
        if (_add)
            userObj->removePermission(_permission);
        else
            userObj->addPermission(_permission);
        return QueuedError("", QueuedEnums::ReturnStatus::Error);
    }

    return true;
}
Exemplo n.º 27
0
string for_remote_who(string arg)
{
// arg can be -i id onnly, -n name only 
	string str="";
	object *list;
	int ppl_cnt,j;
	list = users();
	j = sizeof(list);
	while( j--)
	{
	if( !environment(list[j]) ) continue;
	switch(arg) {
	case "-i" :
        str += sprintf("%s ",
                capitalize(list[j]->query("id"))
        );
		break;
	case "-n" :
        str += sprintf("%s ",
                list[j]->name(1)
        );
                break;
	default :
        str += sprintf("%s ",
                capitalize(list[j]->query("id"))
        );
		    }
	}	
	return str;
}
Exemplo n.º 28
0
Arquivo: whois.c Projeto: cosin/XYJ
int main(object me, string arg)
{
	int i;
	object *all_user, *named_user;
	
	seteuid(getuid());
	
	if( ! arg )
		return notify_fail("whois <中文名字>\n");
	
	all_user = users();
	
	named_user = filter_array(all_user, (:check_name:), arg);
	
	i = sizeof(named_user);
	
	switch(i){
	case 0:
		printf("在线的没人叫%s。\n", arg);
		break;
	case 1:
		printf("%s的英文名字是"BOLD"%s。\n"NOR,
			arg, named_user[0]->query("id"));
		break;
	default:
		printf("一共有%s个在线玩家叫%s:\n", chinese_number(i), arg);
		while(i --)
			printf(BOLD"%s\n"NOR, named_user[i]->query("id"));
		break;
	}

	return 1;
	
}
Exemplo n.º 29
0
void Element::setUsers( UserList ul )
{
	if (!isRecord())
		return;

	UserList toAdd;
	UserList toRemove;

	UserList currentUsers = users();

	foreach( User emp, ul )
		if( !currentUsers.contains( emp ) )
			toAdd += emp;

	foreach( User eu, currentUsers )
		if( !ul.contains( eu ) )
			toRemove += eu;

	ElementUserList tul = ElementUser::recordsByElement( *this );
	foreach( ElementUser eu, tul )
		if( toRemove.contains( eu.user() ) )
			eu.remove();

	foreach( User emp, toAdd )
	{
		ElementUser tu;
		tu.setElement( *this );
		tu.setUser( emp );
		tu.setActive( 1 );
		tu.commit();
	}
Exemplo n.º 30
0
int pull_sword(string arg)
{
	object me = this_player();
	object room = environment(me);

	if(!arg||arg!="sword")
	return notify_fail("你想拔什么东西呀??\n");

	if( room->query_temp("mon/sword")==1 )
	return notify_fail("黄金剑已经消失,只剩一道剑的光影停留在原处。\n");

	message_vision(HIY"黄金剑发出一道耀眼的光茫后,竟然消失在你手中,而你的身形却慢慢消失。\n"NOR,me);
	tell_object(users(),HIW"一道白色的光芒直透天际,长白山的上空突然妖气弥漫,一个不祥的预兆涌上你心头。\n"NOR);

	room->delete_temp("mon/search");
	room->set_temp("mon/sword",1);

	set("exits",([
	"enter"	:__DIR__"mon59",
	"out"	:__DIR__"mon25",
	]));

	call_out("close",720,me);
	return 1;

}