/* Routines to handle the NickServ SET command.
 *
 * IRC Services is copyright (c) 1996-2009 Andrew Church.
 *     E-mail: <achurchweeti@achurch.org>
 * Parts written by Andrew Kempe and others.
 * This program is free but copyrighted software; see the file COPYING for
 * details.
 */

#include "services.h"
#include "modules.h"
#include "language.h"
#include "encrypt.h"
#include "modules/operserv/operserv.h"

#include "nickserv.h"
#include "ns-local.h"


char last_vhost_nick[NICKMAX];
char last_yas_nick[NICKMAX];
char last_burc_nick[NICKMAX];
char last_sehir_nick[NICKMAX];
char last_takim_nick[NICKMAX];
char last_durum_nick[NICKMAX];
char last_tweet_nick[NICKMAX];

/*************************************************************************/

static Module *module;
static int cb_set = -1;
static int cb_set_email = -1;
static int cb_unset = -1;

/*************************************************************************/

static void do_set_password(User *u, NickGroupInfo *ngi, NickInfo *ni,
			    char *param);
static void do_set_language(User *u, NickGroupInfo *ngi, char *param);
static void do_set_url(User *u, NickGroupInfo *ngi, char *param);
static void do_set_vhost(User *u, NickGroupInfo *ngi, char *param);
static void do_set_email(User *u, NickGroupInfo *ngi, char *param);
static void do_set_yas(User *u, NickGroupInfo *ngi, char *param);
static void do_set_burc(User *u, NickGroupInfo *ngi, char *param);
static void do_set_sehir(User *u, NickGroupInfo *ngi, char *param);
static void do_set_takim(User *u, NickGroupInfo *ngi, char *param);
static void do_set_durum(User *u, NickGroupInfo *ngi, char *param);
static void do_set_tweet(User *u, NickGroupInfo *ngi, char *param);
static void do_set_helper(User *u, NickGroupInfo *ngi, char *param);
static void do_set_bayrak(User *u, NickGroupInfo *ngi, char *param);
static void do_set_iliskinick(User *u, NickGroupInfo *ngi, char *param);
static void do_set_iliski(User *u, NickGroupInfo *ngi, char *param);
static void do_set_info(User *u, NickGroupInfo *ngi, char *param);
static void do_set_kill(User *u, NickGroupInfo *ngi, char *param);
static void do_set_secure(User *u, NickGroupInfo *ngi, char *param);
static void do_set_private(User *u, NickGroupInfo *ngi, char *param);
static void do_set_hide(User *u, NickGroupInfo *ngi, char *param,
			char *setting);
static void do_set_timezone(User *u, NickGroupInfo *ngi, char *param);
static void do_set_noexpire(User *u, NickInfo *ni, char *param);
static void do_set_noop(User *u, NickGroupInfo *ngi, char *param);

/*************************************************************************/
/*************************************************************************/

void do_set(User *u)
{
    char *cmd   = strtok(NULL, " ");
    char *param = strtok_remaining();
    char *extra = NULL;
    NickInfo *ni;
    NickGroupInfo *ngi;
    int is_servadmin = is_services_admin(u);

    if (readonly) {
	notice_lang(s_NickServ, u, NICK_SET_DISABLED);
	return;
    }

    if (is_servadmin && param && strchr(param, ' ')
     && (ni = get_nickinfo(cmd))
    ) {
	cmd = strtok(param, " ");
	param = strtok_remaining();
    } else {
	ni = u->ni;
    }
   // if (cmd && stricmp(cmd, "INFO") != 0 && stricmp(cmd, "DURUM") != 0) {
if (cmd && stricmp(cmd, "INFO") != 0 && stricmp(cmd, "DURUM") != 0)  {
if (cmd && stricmp(cmd, "TWEET") != 0)  {

	param = strtok(param, " ");
	extra = strtok(NULL, " ");
    }
}
    if (!cmd || !param || (stricmp(cmd,"HIDE")==0 && !extra)) {
	if (is_oper(u))
	    syntax_error(s_NickServ, u, "SET", NICK_SET_OPER_SYNTAX);
	else
	    syntax_error(s_NickServ, u, "SET", NICK_SET_SYNTAX);
    } else if (!ni) {
	notice_lang(s_NickServ, u, NICK_NOT_REGISTERED);
    } else if (ni->status & NS_VERBOTEN) {
	notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, ni->nick);
    } else if (!(ngi = get_ngi(ni))) {
	notice_lang(s_NickServ, u, INTERNAL_ERROR);
    } else if (!is_servadmin && !user_identified(u)
	       && !(stricmp(cmd,"EMAIL")==0 && user_ident_nomail(u))) {
	notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
    } else if (call_callback_5(module, cb_set, u, ni, ngi, cmd, param) > 0) {
	return;
    } else if (stricmp(cmd, "PASSWORD") == 0) {
	do_set_password(u, ngi, ni, param);
    } else if (stricmp(cmd, "LANGUAGE") == 0) {
	do_set_language(u, ngi, param);
    } else if (stricmp(cmd, "URL") == 0) {
	do_set_url(u, ngi, param);
    } else if (stricmp(cmd, "EMAIL") == 0) {
	do_set_email(u, ngi, param);  
  } else if (stricmp(cmd, "INFO") == 0) {
	do_set_info(u, ngi, param);
} else if (stricmp(cmd, "YAS") == 0) {
       do_set_yas(u, ngi, param);
   } else if (stricmp(cmd, "BURC") == 0) {
       do_set_burc(u, ngi, param);
   } else if (stricmp(cmd, "SEHIR") == 0) {
       do_set_sehir(u, ngi, param);
 } else if (stricmp(cmd, "TAKIM") == 0) {
       do_set_takim(u, ngi, param);
   } else if (stricmp(cmd, "VHOST") == 0) {
do_set_vhost(u, ngi, param);
  } else if (stricmp(cmd, "DURUM") == 0) {
do_set_durum(u, ngi, param);
  } else if (stricmp(cmd, "TWEET") == 0) {
do_set_tweet(u, ngi, param);
  } else if (stricmp(cmd, "ILISKI") == 0) {
do_set_iliski(u, ngi, param);
  } else if (stricmp(cmd, "ILISKINICK") == 0) {
do_set_iliskinick(u, ngi, param);  
    } else if (stricmp(cmd, "HELPER") == 0) {
        do_set_helper(u, ngi, param);
      } else if (stricmp(cmd, "BAYRAK") == 0) {
        do_set_bayrak(u, ngi, param);  
  } else if (stricmp(cmd, "KILL") == 0) {
	do_set_kill(u, ngi, param);
    } else if (stricmp(cmd, "SECURE") == 0) {
	do_set_secure(u, ngi, param);
    } else if (stricmp(cmd, "PRIVATE") == 0) {
	do_set_private(u, ngi, param);
    } else if (stricmp(cmd, "HIDE") == 0) {
	do_set_hide(u, ngi, param, extra);
    } else if (stricmp(cmd, "TIMEZONE") == 0) {
	do_set_timezone(u, ngi, param);
    } else if (stricmp(cmd, "NOEXPIRE") == 0) {
	do_set_noexpire(u, ni, param);
    } else if (stricmp(cmd, "NOOP") == 0) {
        do_set_noop(u, ngi, param);
    } else {
	if (is_servadmin)
	    notice_lang(s_NickServ, u, NICK_SET_UNKNOWN_OPTION_OR_BAD_NICK,
			strupper(cmd));
	else
	    notice_lang(s_NickServ, u, NICK_SET_UNKNOWN_OPTION, strupper(cmd));
    }
}

/*************************************************************************/

void do_unset(User *u)
{
    char *cmd   = strtok(NULL, " ");
    char *extra = strtok(NULL, " ");
    NickInfo *ni;
    NickGroupInfo *ngi;
    int is_servadmin = is_services_admin(u);

    if (readonly) {
	notice_lang(s_NickServ, u, NICK_SET_DISABLED);
	return;
    }

    if (is_servadmin && extra && (ni = get_nickinfo(cmd))) {
	cmd = extra;
	extra = strtok(NULL, " ");
    } else {
	ni = u->ni;
    }
    if (!cmd || extra) {
	syntax_error(s_NickServ, u, "UNSET",
	    NSRequireEmail ? NICK_UNSET_SYNTAX_REQ_EMAIL : NICK_UNSET_SYNTAX);
    } else if (!ni) {
	notice_lang(s_NickServ, u, NICK_NOT_REGISTERED);
    } else if (ni->status & NS_VERBOTEN) {
	notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, ni->nick);
    } else if (!(ngi = get_ngi(ni))) {
	notice_lang(s_NickServ, u, INTERNAL_ERROR);
    } else if (!is_servadmin && !user_identified(u)) {
	notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
    } else if (call_callback_4(module, cb_unset, u, ni, ngi, cmd) > 0) {
	return;
    } else if (stricmp(cmd, "URL") == 0) {
	do_set_url(u, ngi, NULL);
    } else if (stricmp(cmd, "EMAIL") == 0) {
	if (NSRequireEmail) {
	    if (ni != u->ni)
		notice_lang(s_NickServ, u, NICK_UNSET_EMAIL_OTHER_BAD);
	    else
		notice_lang(s_NickServ, u, NICK_UNSET_EMAIL_BAD);
	} else {
	    do_set_email(u, ngi, NULL);
	}
    } else if (stricmp(cmd, "INFO") == 0) {
	do_set_info(u, ngi, NULL);
} else if (stricmp(cmd, "YAS") == 0) {
       do_set_yas(u, ngi, NULL);
    } else if (stricmp(cmd, "BURC") == 0) {
       do_set_burc(u, ngi, NULL);
    } else if (stricmp(cmd, "SEHIR") == 0) {
       do_set_sehir(u, ngi, NULL);
    } else if (stricmp(cmd, "TAKIM") == 0) {
       do_set_takim(u, ngi, NULL);
} else if (stricmp(cmd, "VHOST") == 0) {
       do_set_vhost(u, ngi, NULL);
} else if (stricmp(cmd, "DURUM") == 0) {
       do_set_durum(u, ngi, NULL);
} else if (stricmp(cmd, "TWEET") == 0) {
       do_set_tweet(u, ngi, NULL);
} else if (stricmp(cmd, "ILISKI") == 0) {
       do_set_iliski(u, ngi, NULL);
} else if (stricmp(cmd, "ILISKINICK") == 0) {
       do_set_iliskinick(u, ngi, NULL);
   } else if (stricmp(cmd, "HELPER") == 0) {
       do_set_helper(u, ngi, NULL);
   } else if (stricmp(cmd, "BAYRAK") == 0) {
       do_set_bayrak(u, ngi, NULL);
 } else {
	syntax_error(s_NickServ, u, "UNSET",
	    NSRequireEmail ? NICK_UNSET_SYNTAX_REQ_EMAIL : NICK_UNSET_SYNTAX);
    }
}

/*************************************************************************/

static void do_set_password(User *u, NickGroupInfo *ngi, NickInfo *ni,
			    char *param)
{
    int len = strlen(param), max;

    if (NSSecureAdmins && u->ni != ni && nick_is_services_admin(ni)
     && !is_services_root(u)
    ) {
	notice_lang(s_NickServ, u, PERMISSION_DENIED);
	return;
    } else if (stricmp(param, ni->nick) == 0 || (StrictPasswords && len < 5)) {
	notice_lang(s_NickServ, u, MORE_OBSCURE_PASSWORD);
	return;
    }

    /* Password length checks and truncation (see do_register()) */
    max = encrypt_check_len(len, PASSMAX);
    if ((max == 0 && len > PASSMAX-1) || max > PASSMAX-1)
	max = PASSMAX-1;
    if (max > 0) {
	memset(param+max, 0, len-max);
	len = max;
	notice_lang(s_NickServ, u, PASSWORD_TRUNCATED, max);
    }
    if (encrypt(param, len, ngi->pass, PASSMAX) < 0) {
	memset(param, 0, len);
	module_log("Failed to encrypt password for %s (set)", ni->nick);
	notice_lang(s_NickServ, u, NICK_SET_PASSWORD_FAILED);
	return;
    }
    put_nickgroupinfo(ngi);
    if (NSShowPassword)
	notice_lang(s_NickServ, u, NICK_SET_PASSWORD_CHANGED_TO, param);
    else
	notice_lang(s_NickServ, u, NICK_SET_PASSWORD_CHANGED);
send_cmd(s_NickServ, "PRIVMSG #operlog :NICK-SET-PASSWORD: * \2%s\2 * rumuzu şifresini değiştirdi", ni->nick);
    memset(param, 0, strlen(param));
    if (u->ni != ni) {
	module_log("%s!%s@%s used SET PASSWORD as Services admin on %s",
		   u->nick, u->username, u->host, ni->nick);
/*
time_t zaman;
struct tm * timeinfo;
time ( &zaman );
timeinfo = localtime ( &zaman );
FILE *dosya_yaz = fopen("nickservibo.txt","a");
if (dosya_yaz != NULL) {
  fprintf(dosya_yaz,"[%s] %s  SETPASS -> %s\n", asctime (timeinfo), u->nick, ni->nick);
  fprintf(dosya_yaz,"-----------------------\n");
  fclose(dosya_yaz);
}
*/

	if (WallSetpass) {
	    wallops(s_NickServ, "\2%s\2 used SET PASSWORD as Services admin "
			"on \2%s\2", u->nick, ni->nick);
send_cmd(s_NickServ, "PRIVMSG #operlog :NICK-SET-PASSWORD: * \2%s\2 * rumuzunun şifresi değiştirildi, komutu uygulayan: * \2%s\2 *", ni->nick, u->nick);
	}
    }
}


/*************************************************************************/

static void do_set_bayrak(User *u, NickGroupInfo *ngi, char *param)
{

NickInfo *ni;
ni = get_nickinfo(u->nick);

if (!is_services_root(u)) {
notice_lang(s_NickServ, u, PERMISSION_DENIED);
return;
}



    if (stricmp(param, "ON") == 0) {
   ngi->hediye = 1;
 send_cmd(s_NickServ, "NOTICE %s :Bayrak asiiniz aktiflestirilmistir.",u->nick);
put_nickgroupinfo(ngi);
    } else if (stricmp(param, "OFF") == 0) {
 ngi->hediye = 0;
 send_cmd(s_NickServ, "NOTICE %s :Deaktif hale getirildi.",u->nick);
    } else {
 send_cmd(s_NickServ, "NOTICE %s Hatali bir Kullanim.", u->nick);
 send_cmd(s_NickServ, "NOTICE %s :\2Kullanimi, /NS SET Bayrak ON/OFF", u->nick);
    }
  put_nickgroupinfo(ngi);
}



/*************************************************************************/



static void do_set_helper(User *u, NickGroupInfo *ngi, char *param)
{

    NickInfo *ni;
ni = get_nickinfo(u->nick);

if (!is_services_admin(u)) {
notice_lang(s_NickServ, u, PERMISSION_DENIED);
return;
}


    if (stricmp(param, "ON") == 0) {
   ngi->helper = 1;
 send_cmd(s_NickServ, "NOTICE %s :Kullanici Artik  \2HELPER\2 statusundedir. ",u->nick);
put_nickgroupinfo(ngi);
    } else if (stricmp(param, "OFF") == 0) {
 ngi->helper = 0;
 send_cmd(s_NickServ, "NOTICE %s :Kullanici \2HELPER\2 statusunden silinmistir.",u->nick);
    } else {
 send_cmd(s_NickServ, "NOTICE %s Hatali bir Kullanim.", u->nick);
 send_cmd(s_NickServ, "NOTICE %s :\2Kullanimi, /NS SET NICK HELPER ON/OFF \2", u->nick);
 send_cmd(s_NickServ, "NOTICE %s :Eklemek icin, \2/NS SET NICK HELPER ON\2", u->nick);
 send_cmd(s_NickServ, "NOTICE %s :Silmek icin, \2/NS SET NICK HELPER OFF\2", u->nick);
 return;
    }
    put_nickgroupinfo(ngi);
}


/*************************************************************************/

static void do_set_language(User *u, NickGroupInfo *ngi, char *param)
{
    int langnum;

    if (param[strspn(param, "0123456789")] != 0) {  /* i.e. not a number */
	syntax_error(s_NickServ, u, "SET LANGUAGE", NICK_SET_LANGUAGE_SYNTAX);
	return;
    }
    langnum = atoi(param)-1;
    if (langnum < 0 || langnum >= NUM_LANGS || langlist[langnum] < 0) {
	notice_lang(s_NickServ, u, NICK_SET_LANGUAGE_UNKNOWN,
		    langnum+1, s_NickServ);
	return;
    }
    ngi->language = langlist[langnum];
    put_nickgroupinfo(ngi);
    notice_lang(s_NickServ, u, NICK_SET_LANGUAGE_CHANGED,
		getstring(ngi,LANG_NAME));
}

/*************************************************************************/

static void do_set_url(User *u, NickGroupInfo *ngi, char *param)
{
    const char *nick = ngi_mainnick(ngi);

// NickInfo *ni = get_nickinfo(u->nick);

/*
 static int ibos =  60*60*24*500;
//if (ni) {
if (ni->toplamzaman  <= ibos) {
//send_cmd(s_NickServ, "NOTICE %s :\2CS INFO\2 Komutu Kullanmak icin puaniniz \2(3)\2 Olmalidir.", u->nick);
//send_cmd(s_NickServ, "NOTICE %s :Puaniniz \2%d\2",  u->nick, (ni->toplamzaman / 86400 * 3));
send_cmd(s_NickServ, "NOTICE %s :Bu komut bir sureligine kapalidir.",  u->nick);
  return;
}


*/

    if (param && !valid_url(param)) {
	notice_lang(s_NickServ, u, BAD_URL);
	return;
    }

    free(ngi->url);
    if (param) {
	ngi->url = sstrdup(param);
	notice_lang(s_NickServ, u, NICK_SET_URL_CHANGED, nick, param);
    } else {
	ngi->url = NULL;
	notice_lang(s_NickServ, u, NICK_UNSET_URL, nick);
    }
    put_nickgroupinfo(ngi);
}

/*************************************************************************/

static void do_set_email(User *u, NickGroupInfo *ngi, char *param)
{
    const char *nick = ngi_mainnick(ngi);
    char oldemail[BUFSIZE];
  NickInfo *ni;
ni = get_nickinfo(u->nick);

    if (param && !valid_email(param)) {
	notice_lang(s_NickServ, u, BAD_EMAIL);
	return;
    }

    if (param && !is_services_admin(u)) {
	int n = count_nicks_with_email(param);
	if (n < 0) {
	    notice_lang(s_NickServ, u, NICK_SET_EMAIL_UNAUTHED);
	    return;
	} else if (NSRegEmailMax && n >= NSRegEmailMax) {
	    notice_lang(s_NickServ, u, NICK_SET_EMAIL_TOO_MANY_NICKS,
			param, n, NSRegEmailMax);
	    return;
	}
    }



    if (ngi->email) {
	strscpy(oldemail, ngi->email, sizeof(oldemail));
	free(ngi->email);
    } else {
	*oldemail = 0;
    }
    if (param) {
	ngi->email = sstrdup(param);
	if (*oldemail) {
	    module_log("%s E-mail address changed from %s to %s by %s!%s@%s",
		       nick, oldemail, param, u->nick, u->username, u->host);
	} else {
	    module_log("%s E-mail address set to %s by %s!%s@%s",
		       nick, param, u->nick, u->username, u->host);
	}
	notice_lang(s_NickServ, u, NICK_SET_EMAIL_CHANGED, nick, param);
	if (!is_services_admin(u)) {
	    /* Note: this (like the SET EMAIL callback in mail-auth)
	     * assumes that only the user or a servadmin can change the
	     * E-mail address; if the user isn't a servadmin, therefore,
	     * they must be doing it to their own nick, and we use/modify
	     * the User structure. */
	    if (user_ident_nomail(u)) {
		u->ni->authstat &= ~NA_IDENT_NOMAIL;
		u->ni->authstat |= NA_IDENTIFIED;
	    }
	}
    } else {
	ngi->email = NULL;
	if (*oldemail) {
	    module_log("%s E-mail address cleared by %s!%s@%s (was %s)",
		       nick, u->nick, u->username, u->host, oldemail);
	}
	notice_lang(s_NickServ, u, NICK_UNSET_EMAIL, nick);
    }
    put_nickgroupinfo(ngi);
    call_callback_2(module, cb_set_email, u, ngi);
}

/*************************************************************************/

static void do_set_info(User *u, NickGroupInfo *ngi, char *param)
{
    const char *nick = ngi_mainnick(ngi);
//NickInfo *ni = get_nickinfo(u->nick);

    free(ngi->info);
    if (param) {
	ngi->info = sstrdup(param);
	notice_lang(s_NickServ, u, NICK_SET_INFO_CHANGED, nick, param);
    } else {
	ngi->info = NULL;
	notice_lang(s_NickServ, u, NICK_UNSET_INFO, nick);
    }
    put_nickgroupinfo(ngi);
}




// Written By Sky-Dancer
// hatali olabilir ??
int Karsilastir(char *Gelen, char *Skyy);
int Karsilastir(char *Gelen, char *Skyy) {
	char Sky[512];
	int i;
	strcpy(Sky, Gelen);
	for (i=0; i<strlen(Sky); i++) {
		if (Sky[i] == 'ı') Sky[i] = 'i';
		if (Sky[i] == 'ö') Sky[i] = 'o';
		if (Sky[i] == 'ç') Sky[i] = 'c';
		if (Sky[i] == 'ğ') Sky[i] = 'g';
		if (Sky[i] == 'ü') Sky[i] = 'u';
		if (Sky[i] == 'Ö') Sky[i] = 'o';
		if (Sky[i] == 'Ç') Sky[i] = 'c';
		if (Sky[i] == 'Ş') Sky[i] = 's';
		if (Sky[i] == 'Ğ') Sky[i] = 'g';
		if (Sky[i] == 'Ü') Sky[i] = 'u';
	}
	if (!stricmp(Sky, Skyy)) return 1;
return 0;
}

//Coded toXic
// ReCodded Somewhere By Sky-Dancer :@
 
/****************************************************************************/

static void do_set_yas(User *u, NickGroupInfo *ngi, char *param) {
	NickInfo *ni;    
	ni = get_nickinfo(u->nick); 
	char *nick = ngi_mainnick(ngi);
	 
	if (!param) {
		ngi->yas = NULL;
		send_cmd(s_NickServ, "NOTICE %s :Yasiniz \2 Kaldirildi.", u->nick);
		send_cmd(s_NickServ, "SKYW2 %s :0", u->nick);
		put_nickgroupinfo(ngi);
	return;
	}

	if (param[strspn(param, "0123456789")] != 0) {  
		send_cmd(s_NickServ, "NOTICE %s :~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", u->nick);
		send_cmd(s_NickServ, "NOTICE %s :-\2", u->nick);
		send_cmd(s_NickServ, "NOTICE %s :\2Maalesef\2, Sahip Olmak istediginiz \2yas\2, Listemizde ekli \2degildir.\2", u->nick);
		send_cmd(s_NickServ, "NOTICE %s :Ayrintili Bilgi icin, \2 #HELP \2 Kanalina giriniz..", u->nick);
		send_cmd(s_NickServ, "NOTICE %s :-\2", u->nick);
	return;
	}

	if (atoi(param)>100 || atoi(param)<0) {
		send_cmd(s_NickServ, "NOTICE %s :Lütfen yaşınızı 0-100 aralığında belirleyiniz.", u->nick);
                send_cmd(s_NickServ, "NOTICE %s :Ayrintili Bilgi icin, \2 #HELP \2 Kanalina giriniz..", u->nick);
	return;
	}

	ngi->yas = sstrdup(param);
	notice_lang(s_NickServ, u, NICK_SET_YAS_CHANGED, nick, param);

strscpy(last_yas_nick, u->nick, NICKMAX);
	send_cmd(s_NickServ, "NOTICE %s :Yas Seceneginiz, \2 %s \2 Olarak degistirildi..", u->nick, ngi->yas);
	send_cmd(s_NickServ, "SKYW2 %s :Kullanıcısının Yaşı : \2%s\2", u->nick, ngi->yas);
	put_nickgroupinfo(ngi);
}

/***********************************************************************/
 

static void do_set_takim(User *u, NickGroupInfo *ngi, char *param) {
	NickInfo *ni;    
	ni = get_nickinfo(u->nick); 
    const char *nick = ngi_mainnick(ngi);
	int i;
	int sonuc = 0;
	 
	if (!param) {
		ngi->takim = NULL;
		send_cmd(s_NickServ, "NOTICE %s :Takiminiz \2 Kaldirildi.", u->nick);
		send_cmd(s_NickServ, "SKYW3 %s :0", u->nick);
		put_nickgroupinfo(ngi);
	return;
	}

	for (i=0; TakimListesi[i]!=NULL; i++) {
		if (Karsilastir(param, TakimListesi[i])) {
			send_cmd(s_NickServ, "NOTICE %s :~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", u->nick);
			send_cmd(s_NickServ, "NOTICE %s :-\2",u->nick);
			send_cmd(s_NickServ, "NOTICE %s :Sectiginiz takim \2 %s", u->nick, param);
			sonuc=1;
			break;
		}
	}

	if (sonuc==1) {
		ngi->takim = sstrdup(param);
		notice_lang(s_NickServ, u, NICK_SET_TAKIM_CHANGED, nick, param);

strscpy(last_takim_nick, u->nick, NICKMAX);
		send_cmd(s_NickServ, "NOTICE %s :-", u->nick);
send_cmd(s_NickServ, "SVSJOIN %s #%s", u->nick, ngi->takim);
send_cmd(s_NickServ, "CHGHOST %s %s.%s.ChatAskim.Net", u->nick, ngi->takim, u->nick);
		send_cmd(s_NickServ, "NOTICE %s :Takiminiz \2%s\2 Olarak Belirlendi.", u->nick, ngi->takim);
		send_cmd(s_NickServ, "SKYW3 %s :Kullanıcısının Takımı : \2%s\2", u->nick, ngi->takim);
	} else {
		send_cmd(s_NickServ, "NOTICE %s :~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", u->nick);
		send_cmd(s_NickServ, "NOTICE %s :-\2", u->nick);
		send_cmd(s_NickServ, "NOTICE %s :\2Maalesef\2, Sahip Olmak istediginiz \2takim\2, Listemizde ekli \2degildir.\2", u->nick);
		send_cmd(s_NickServ, "NOTICE %s :Kullanilabilir takimlari listelemek icin, \2 /NS takimlar\2 Komutunu Kullaniniz.", u->nick);
		send_cmd(s_NickServ, "NOTICE %s :Ayrintili Bilgi icin, \2 #HELP \2 Kanalina giriniz..", u->nick);
		send_cmd(s_NickServ, "NOTICE %s :-\2", u->nick);
	return;
	}
}
 
  
 
/************************************************************************/
 
static void do_set_burc(User *u, NickGroupInfo *ngi, char *param) {
    NickInfo *ni;    
	ni = get_nickinfo(u->nick); 
    const char *nick = ngi_mainnick(ngi);
	int i;
	int sonuc = 0;

	if (!param) {
		ngi->burc = NULL;
		send_cmd(s_NickServ, "NOTICE %s :Burcunuz \2 Kaldirildi.", u->nick);
		send_cmd(s_NickServ, "SKYW4 %s :0", u->nick);
		put_nickgroupinfo(ngi);
	return;
	} 

	for (i=0; BurcListesi[i]!=NULL; i++) {
		if (Karsilastir(param, BurcListesi[i])) {
			send_cmd(s_NickServ, "NOTICE %s :~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", u->nick);
			send_cmd(s_NickServ, "NOTICE %s :-\2",u->nick);
			send_cmd(s_NickServ, "NOTICE %s :Sectiginiz Burc \2 %s", u->nick, param);
			sonuc=1;
		break;
		}
	}

	if (sonuc==1){
		ngi->burc = sstrdup(param);
		notice_lang(s_NickServ, u, NICK_SET_BURC_CHANGED, nick, param);

strscpy(last_burc_nick, u->nick, NICKMAX);
		send_cmd(s_NickServ, "NOTICE %s :-", u->nick); 
		send_cmd(s_NickServ, "NOTICE %s :Burcunuz \2%s\2 Olarak Belirlendi.", u->nick, ngi->burc);
		//send_cmd(s_NickServ, "SKYW4 %s :Kullanıcısının Burcu : \2%s\2", u->nick, ngi->burc);
	} else {
		send_cmd(s_NickServ, "NOTICE %s :~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", u->nick);
		send_cmd(s_NickServ, "NOTICE %s :-\2", u->nick);
		send_cmd(s_NickServ, "NOTICE %s :\2Maalesef\2, Sahip Olmak istediginiz \2Burc\2, Listemizde ekli \2degildir.\2", u->nick);
		send_cmd(s_NickServ, "NOTICE %s :Kullanilabilir Burclari listelemek icin, \2 /NS Burclar\2 Komutunu Kullaniniz.", u->nick);
		send_cmd(s_NickServ, "NOTICE %s :Ayrintili Bilgi icin, \2 #HELP \2 Kanalina giriniz..", u->nick);
		send_cmd(s_NickServ, "NOTICE %s :-\2", u->nick);
		send_cmd(s_NickServ, "NOTICE %s :~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", u->nick);
	return;
	}
}

static void do_set_sehir(User *u, NickGroupInfo *ngi,   char *param) {
    NickInfo *ni;    
	ni = get_nickinfo(u->nick); 
//    const char *nick = ngi_mainnick(ngi);
	int i;
	int sonuc = 0;
 
	if (!param) {
		ngi->sehir = NULL;
		send_cmd(s_NickServ, "NOTICE %s :Sehiriniz \2 Kaldirildi.", u->nick);
		send_cmd(s_NickServ, "SKYW1 %s :0", u->nick);
		put_nickgroupinfo(ngi);
	return;
	}

	for (i=0; SehirListesi[i]!=NULL; i++ ) {
  if (Karsilastir(param, SehirListesi[i])) {
			send_cmd(s_NickServ, "NOTICE %s :~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", u->nick);
			send_cmd(s_NickServ, "NOTICE %s :-\2",u->nick);
			send_cmd(s_NickServ, "NOTICE %s :Sectiginiz sehir \2 %s", u->nick, param);
			sonuc=1;
		break;
		}
	
}


	if (sonuc==1) {
		ngi->sehir = sstrdup(param);
strscpy(last_sehir_nick, u->nick, NICKMAX);
		send_cmd(s_NickServ, "NOTICE %s :-", u->nick);
                   send_cmd(s_NickServ, "SVSJOIN %s #%s", u->nick, ngi->sehir);
		send_cmd(s_NickServ, "NOTICE %s :Sehriniz \2%s\2 Olarak Belirlendi.", u->nick, ngi->sehir);
		send_cmd(s_NickServ, "SKYW1 %s :Kullanıcısının Şehri : \2%s\2", u->nick, ngi->sehir); 
	} else {
		send_cmd(s_NickServ, "NOTICE %s :~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", u->nick);
		send_cmd(s_NickServ, "NOTICE %s :-\2", u->nick);
		send_cmd(s_NickServ, "NOTICE %s :\2Maalesef\2, Sahip Olmak istediginiz \2Sehir\2, Listenizde ekli \2degildir.\2", u->nick);
		send_cmd(s_NickServ, "NOTICE %s :Kullanilabilir Sehirleri listelemek icin, \2 /NS Sehirler\2 Komutunu Kullaniniz.", u->nick);
		send_cmd(s_NickServ, "NOTICE %s :Ayrintili Bilgi icin, \2 #HELP \2 Kanalina giriniz..", u->nick);
		send_cmd(s_NickServ, "NOTICE %s :-\2", u->nick);
		send_cmd(s_NickServ, "NOTICE %s :~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", u->nick);
	return;
	}
}






static void do_set_vhost(User *u, NickGroupInfo *ngi,   char *param) {
    NickInfo *ni;
        ni = get_nickinfo(u->nick);
//    const char *nick = ngi_mainnick(ngi);
        int i;
        int sonuc = 0;
//  time_t now = time(NULL);


      if (!param) {
                ngi->vhost = NULL;
                send_cmd(s_NickServ, "NOTICE %s :Vhostunuz \2 Kaldirildi.", u->nick);
                put_nickgroupinfo(ngi);
        return;
        }
/*
static int SEVIYEXXXX =  60*60*24*1;
 if (!is_services_admin(u) && SEVIYEXXXX &&  ni->toplamzaman  <= SEVIYEXXXX) {
        notice_lang(s_NickServ, u, PERMISSION_DENIED);
send_cmd(s_NickServ,
    "NOTICE %s :Toplam Online Sureniz \2%d\2 Gun \2%d\2 Saat \2%d\2 Dakika ve \2%d\2 Saniye Olmalidir.",
     u->nick,  (SEVIYEXXXX / 86400), ((SEVIYEXXXX % 86400) / 3600),
     (((SEVIYEXXXX % 86400) % 3600) / 60),
     ((((SEVIYEXXXX % 86400) % 3600) % 60) % 60));
return;
}
 

if (!is_services_admin(u) && ngi->LastVHost && now - ngi->LastVHost < 600) {
send_cmd(s_NickServ, "NOTICE %s Bu Komutu gunde \2 1 \2 Kez Kullanabilirsiniz..", u->nick);
return;
}

ngi->LastVHost = now;
*/


        for (i=0; vhostlistesi[i]!=NULL; i++ ) {
                if (Karsilastir(param, vhostlistesi[i])) {
                        send_cmd(s_NickServ, "NOTICE %s :~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", u->nick);
                        send_cmd(s_NickServ, "NOTICE %s :-\2",u->nick);
                        send_cmd(s_NickServ, "NOTICE %s :Sectiginiz vhost \2 %s", u->nick, param);
                        sonuc=1;
                break;
                }
        }

        if (sonuc==1) {
                ngi->vhost = sstrdup(param);
               
                send_cmd(s_NickServ, "NOTICE %s :-", u->nick);
                send_cmd(s_NickServ, "NOTICE %s :Hostunuz \2%s\2 Olarak Belirlendi.", u->nick, ngi->vhost);
                send_cmd(s_NickServ, "CHGHOST %s %s.%s.ChatAskim.Net", u->nick, ngi->vhost, u->nick);

strscpy(last_vhost_nick, u->nick, NICKMAX);
time_t zaman;
struct tm * timeinfo;
time ( &zaman );
timeinfo = localtime ( &zaman );
/*
FILE *dosya_yaz = fopen("vhostlar.txt","a");
if (dosya_yaz != NULL) {
          fprintf(dosya_yaz,"[%s] %s vhost Secti. -> %s\n", asctime (timeinfo), u->nick, ngi->vhost);
          fclose(dosya_yaz);
}*/

        } else {
                send_cmd(s_NickServ, "NOTICE %s :~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", u->nick);
                send_cmd(s_NickServ, "NOTICE %s :-\2", u->nick);
                send_cmd(s_NickServ, "NOTICE %s :\2Maalesef\2, Sahip Olmak istediginiz \2vhost\2, Listenizde ekli \2degildir.\2", u->nick);
                send_cmd(s_NickServ, "NOTICE %s :Kullanilabilir vhostleri listelemek icin, \2 /NS Vhostlist\2 Komutunu Kullaniniz.", u->nick);
                send_cmd(s_NickServ, "NOTICE %s :Ayrintili Bilgi icin, \2 #HELP \2 Kanalina giriniz..", u->nick);
                send_cmd(s_NickServ, "NOTICE %s :-\2", u->nick);
                send_cmd(s_NickServ, "NOTICE %s :~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", u->nick);
        return;
        }
}


/****************************************************************************/

static void do_set_tweet(User *u, NickGroupInfo *ngi, char *param)
{




 NickInfo *ni;
ni = get_nickinfo(u->nick);
char *tweet;
 tweet = strtok_remaining();


if (!param) {
ngi->tweet = NULL;
send_cmd(s_NickServ, "NOTICE %s \2Tweetiniz \2 Kaldirildi.", u->nick);
put_nickgroupinfo(ngi);
return;
}

ngi->tweet = sstrdup(param);
send_cmd(s_NickServ, "NOTICE %s TWEET Seceneginiz, \2 %s \2 Olarak degistirildi..", u->nick, ngi->tweet);
send_cmd(s_NickServ, "NOTICE %s  Kullanicilar tweetinizi, \2/NS PROFIL %s\2 komutu ile gorebilecekler.", u->nick, u->nick);
send_cmd(s_NickServ, "PRIVMSG #operlog %s Tweet girdi.  %s", u->nick, ngi->tweet);

strscpy(last_tweet_nick, u->nick, NICKMAX);
/*
time_t zaman;
struct tm * timeinfo;
time ( &zaman );
timeinfo = localtime ( &zaman );
FILE *dosya_yaz;
          dosya_yaz = fopen("tweet.txt","a");
if (dosya_yaz != NULL) {
          fprintf(dosya_yaz,"[%s] %s tweet -> %s\n", asctime (timeinfo), u->nick, ngi->tweet);
          fclose(dosya_yaz);
 }
*/
put_nickgroupinfo(ngi);
}



/****************************************************************************/

static void do_set_durum(User *u, NickGroupInfo *ngi, char *param)
{




 NickInfo *ni;
ni = get_nickinfo(u->nick);
char *durum;
 durum = strtok_remaining();


if (!param) {
ngi->durum = NULL;
send_cmd(s_NickServ, "NOTICE %s \2DURUM \2 Kaldirildi.", u->nick);
put_nickgroupinfo(ngi);
return;
}

static int SEVIYEXXXX =  60*60*24*20;
 if (!is_services_admin(u) && SEVIYEXXXX &&  ni->toplamzaman  <= SEVIYEXXXX) {
        notice_lang(s_NickServ, u, PERMISSION_DENIED);
send_cmd(s_NickServ,
    "NOTICE %s :Toplam Online Sureniz \2%d\2 Gun \2%d\2 Saat \2%d\2 Dakika ve \2%d\2 Saniye Olmalidir.",
     u->nick,  (SEVIYEXXXX / 86400), ((SEVIYEXXXX % 86400) / 3600),
     (((SEVIYEXXXX % 86400) % 3600) / 60),
     ((((SEVIYEXXXX % 86400) % 3600) % 60) % 60));
return;
}


ngi->durum = sstrdup(param);
send_cmd(s_NickServ, "NOTICE %s SWHOIS Seceneginiz, \2 %s \2 Olarak degistirildi..", u->nick, ngi->durum);
send_cmd(s_NickServ, "NOTICE %s  Kullanicilar durumunuzu \2/NS PROFIL %s\2 komutu ile gorebilecekler.", u->nick, u->nick);
send_cmd(s_NickServ, "PRIVMSG #operlog \2%s\2 Kullanicisi \2DURUM\2 bilgisi girdi. Belirledigi \2DURUM\2 %s", u->nick, ngi->durum);
strscpy(last_durum_nick, u->nick, NICKMAX);
/*
time_t zaman;
struct tm * timeinfo;
time ( &zaman );
timeinfo = localtime ( &zaman );
FILE *dosya_yaz;
          dosya_yaz = fopen("durum.txt","a");
if (dosya_yaz != NULL) {
          fprintf(dosya_yaz,"[%s] %s SWHOIS -> %s\n", asctime (timeinfo), u->nick, ngi->durum);
  //fprintf(dosya_yaz,"--------------------------\n");
          fclose(dosya_yaz);
 }*/
put_nickgroupinfo(ngi);
}



/*************************************************************************/


static void do_set_iliskinick(User *u, NickGroupInfo *ngi, char *param)
{




 NickInfo *ni;
ni = get_nickinfo(u->nick);
char *iliski;
 iliski = strtok_remaining();


if (!param) {
ngi->iliskinick = NULL;
send_cmd(s_NickServ, "NOTICE %s %s Kullanici ile iliskiniz isteginiz uzere bitirilmistir..", u->nick, ngi->iliskinick);
put_nickgroupinfo(ngi);
return;
}

ngi->iliskinick = sstrdup(param);
send_cmd(s_NickServ, "NOTICE %s ILISKINIZ Olan Kullanicimiz   \2%s\2 Olarak degistirildi..", u->nick, ngi->iliskinick);
} 


/****************************************************************/



static void do_set_iliski(User *u, NickGroupInfo *ngi,   char *param)
{

    NickInfo *ni;
        ni = get_nickinfo(u->nick);
   // const char *nick = ngi_mainnick(ngi);
        int i;
        int sonuc = 0;


  char *iliskiListesi[]={
"Yok", "Var", "Nisanli", "Evli", "Karmasik",
"Serbest", "Dul", "Bosanmis", "Takilmaca",

};


        if (!param) {
                ngi->iliski = NULL;
                send_cmd(s_NickServ, "NOTICE %s :iliski durumunuz \2 Kaldirildi.", u->nick);
                put_nickgroupinfo(ngi);
        return;
        }

        for (i=0; iliskiListesi[i]!=NULL; i++) {
                if (Karsilastir(param, iliskiListesi[i])) {
                        send_cmd(s_NickServ, "NOTICE %s :~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", u->nick);
                        send_cmd(s_NickServ, "NOTICE %s :-\2",u->nick);
                        send_cmd(s_NickServ, "NOTICE %s :Iliskiniz \2 %s", u->nick, param);
                        sonuc=1;
                break;
                }
        }

        if (sonuc==1){
                ngi->iliski = sstrdup(param);
                send_cmd(s_NickServ, "NOTICE %s :-", u->nick);
                send_cmd(s_NickServ, "NOTICE %s :iliskiniz \2%s\2 Olarak Belirlendi.", u->nick, ngi->iliski);
        } else {
                send_cmd(s_NickServ, "NOTICE %s :~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", u->nick);
                send_cmd(s_NickServ, "NOTICE %s :-\2", u->nick);
                send_cmd(s_NickServ, "NOTICE %s :\2Maalesef\2, Sahip Olmak istediginiz \2iliski durumu\2, Listemizde ekli \2degildir.\2", u->nick);
                send_cmd(s_NickServ, "NOTICE %s :Kullanilabilir iliskileri listelemek icin, \2 /NS iliskiler\2 Komutunu Kullaniniz.", u->nick);
                send_cmd(s_NickServ, "NOTICE %s :Ayrintili Bilgi icin, \2 #HELP \2 Kanalina giriniz..", u->nick);
                send_cmd(s_NickServ, "NOTICE %s :-\2", u->nick);
                send_cmd(s_NickServ, "NOTICE %s :~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", u->nick);
        return;
        }
}





  /* char *array[8]={
"Yok", "Var", "Nisanli", "Evli", "Karmasik",
"Serbest", "Dul", "Bosanmis",

};

for (i=0; i<=8; i++ )
{
 if (param)
 {
  sprintf(giris, "%s", sstrdup(param));
 }
if (!strcmp(giris, array[i]))
{
send_cmd(s_NickServ, "NOTICE %s ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", u->nick);
send_cmd(s_NickServ, "NOTICE %s -\2",u->nick);

        send_cmd(s_NickServ, "NOTICE %s iliski durumunuz \2 %s", u->nick, array[i]);
        sonuc=1;
        break;
}
}
if (sonuc==1) {

       ngi->iliski = sstrdup(param);

send_cmd(s_NickServ, "NOTICE %s -", u->nick);
send_cmd(s_NickServ, "NOTICE %s ILISKI Durumunuz \2%s\2 Olarak Degistirildi..", u->nick, ngi->iliski);
send_cmd(s_NickServ, "PRIVMSG #operlog \2%s\2 Kullanicisi iliski durumunu \2%s\2 olarak degistirdil.",  u->nick, ngi->iliski);
  
} 
else {
send_cmd(s_NickServ, "NOTICE %s ~~~~~~~~~~~~~~~~\2[HATA]\2~~~~~~~~~~~~~~~~~~~~~~~~~", u->nick);
send_cmd(s_NickServ, "NOTICE %s -\2", u->nick);
send_cmd(s_NickServ, "NOTICE %s \2Maalesef\2, Sahip Olmak istediginiz \2ILISKI DURUMU\2, Listemizde ekli \2degildir.\2", u->nick);
send_cmd(s_NickServ, "NOTICE %s Kullanilabilir ILISKI DURUMLARINI listelemek icin, \2 /NS ILISKILER\2 Komutunu Kullaniniz.", u->nick);
send_cmd(s_NickServ, "NOTICE %s Ayrintili Bilgi icin, \2 #HELP \2 Kanalina giriniz..", u->nick);
send_cmd(s_NickServ, "NOTICE %s -\2", u->nick);
send_cmd(s_NickServ, "NOTICE %s ~~~~~~~~~~~~~~~\2[HATA SON]\2~~~~~~~~~~~~~~~~~~~~~~~~~~", u->nick);
return;

}
}
*/



/***********************************************************************/

static void do_set_kill(User *u, NickGroupInfo *ngi, char *param)
{
    if (stricmp(param, "ON") == 0) {
	ngi->flags |= NF_KILLPROTECT;
	ngi->flags &= ~(NF_KILL_QUICK | NF_KILL_IMMED);
	notice_lang(s_NickServ, u, NICK_SET_KILL_ON);
    } else if (stricmp(param, "QUICK") == 0) {
	ngi->flags |= NF_KILLPROTECT | NF_KILL_QUICK;
	ngi->flags &= ~NF_KILL_IMMED;
	notice_lang(s_NickServ, u, NICK_SET_KILL_QUICK);
    } else if (stricmp(param, "IMMED") == 0) {
	if (NSAllowKillImmed) {
	    ngi->flags |= NF_KILLPROTECT | NF_KILL_QUICK | NF_KILL_IMMED;
	    notice_lang(s_NickServ, u, NICK_SET_KILL_IMMED);
	} else {
	    notice_lang(s_NickServ, u, NICK_SET_KILL_IMMED_DISABLED);
	    return;
	}
    } else if (stricmp(param, "OFF") == 0) {
	ngi->flags &= ~(NF_KILLPROTECT | NF_KILL_QUICK | NF_KILL_IMMED);
	notice_lang(s_NickServ, u, NICK_SET_KILL_OFF);
    } else {
	syntax_error(s_NickServ, u, "SET KILL",
		     NSAllowKillImmed ? NICK_SET_KILL_IMMED_SYNTAX
				      : NICK_SET_KILL_SYNTAX);
	return;
    }
    put_nickgroupinfo(ngi);
}

/*************************************************************************/

static void do_set_secure(User *u, NickGroupInfo *ngi, char *param)
{
    if (stricmp(param, "ON") == 0) {
	ngi->flags |= NF_SECURE;
	notice_lang(s_NickServ, u, NICK_SET_SECURE_ON);
    } else if (stricmp(param, "OFF") == 0) {
	ngi->flags &= ~NF_SECURE;
	notice_lang(s_NickServ, u, NICK_SET_SECURE_OFF);
    } else {
	syntax_error(s_NickServ, u, "SET SECURE", NICK_SET_SECURE_SYNTAX);
	return;
    }
    put_nickgroupinfo(ngi);
}

/*************************************************************************/

static void do_set_private(User *u, NickGroupInfo *ngi, char *param)
{
    if (stricmp(param, "ON") == 0) {
	ngi->flags |= NF_PRIVATE;
	notice_lang(s_NickServ, u, NICK_SET_PRIVATE_ON);
    } else if (stricmp(param, "OFF") == 0) {
	ngi->flags &= ~NF_PRIVATE;
	notice_lang(s_NickServ, u, NICK_SET_PRIVATE_OFF);
    } else {
	syntax_error(s_NickServ, u, "SET PRIVATE", NICK_SET_PRIVATE_SYNTAX);
	return;
    }
    put_nickgroupinfo(ngi);
}

/*************************************************************************/

static void do_set_hide(User *u, NickGroupInfo *ngi, char *param,
			char *setting)
{
    int flag, onmsg, offmsg;

    if (stricmp(param, "EMAIL") == 0) {
	flag = NF_HIDE_EMAIL;
	onmsg = NICK_SET_HIDE_EMAIL_ON;
	offmsg = NICK_SET_HIDE_EMAIL_OFF;
    } else if (stricmp(param, "USERMASK") == 0) {
	flag = NF_HIDE_MASK;
	onmsg = NICK_SET_HIDE_MASK_ON;
	offmsg = NICK_SET_HIDE_MASK_OFF;
    } else if (stricmp(param, "QUIT") == 0) {
	flag = NF_HIDE_QUIT;
	onmsg = NICK_SET_HIDE_QUIT_ON;
	offmsg = NICK_SET_HIDE_QUIT_OFF;
    } else {
	syntax_error(s_NickServ, u, "SET HIDE", NICK_SET_HIDE_SYNTAX);
	return;
    }
    if (stricmp(setting, "ON") == 0) {
	ngi->flags |= flag;
	notice_lang(s_NickServ, u, onmsg, s_NickServ);
    } else if (stricmp(setting, "OFF") == 0) {
	ngi->flags &= ~flag;
	notice_lang(s_NickServ, u, offmsg, s_NickServ);
    } else {
	syntax_error(s_NickServ, u, "SET HIDE", NICK_SET_HIDE_SYNTAX);
	return;
    }
    put_nickgroupinfo(ngi);
}
static void do_set_noop(User *u, NickGroupInfo *ngi, char *param)
{
    if (stricmp(param, "ON") == 0) {
 ngi->noop = 1;
 send_cmd(s_NickServ, "NOTICE %s :Noop özelligi aktif hale getirildi. Nickiniz icin kanallarda access eklenmeyecektir.",u->nick);
    } else if (stricmp(param, "OFF") == 0) {
 ngi->noop = 0;
 send_cmd(s_NickServ, "NOTICE %s :Noop özelligi Deaktif Edildi. Nickiniz icin kanallarda access eklenebilir.",u->nick);
    } else {
 send_cmd(s_NickServ, "NOTICE %s :/2Kullanımı : SET NOOP ON/OFF/2", u->nick);
 return;
    }
    put_nickgroupinfo(ngi);
}

/*************************************************************************/

/* Timezone definitions. */
static struct {
    const char *name;
    int16 offset;
} timezones[] = {
    {"GMT-12",-720},
    {"GMT-11",-660},
    {"GMT-10",-600}, {"HST",-600},
    {"GMT-9", -540},
    {"GMT-8", -480}, {"PST",-480},
    {"GMT-7", -420}, {"MST",-420}, {"PDT",-420},
    {"GMT-6", -360}, {"CST",-360}, {"MDT",-360},
    {"GMT-5", -300}, {"EST",-300}, {"CDT",-300},
    {"GMT-4", -240}, {"AST",-240}, {"EDT",-240},
    {"GMT-3", -180}, {"BRT",-180}, {"ADT",-180},
    {"GMT-2", -120}, {"BRST",-120},
    {"GMT-1",  -60},
    {"GMT+0",    0}, {"GMT",   0}, {"UTC",   0}, {"WET",   0},
    {"GMT+1",   60}, {"MET",  60}, {"BST",  60}, {"IST",  60},
    {"GMT+2",  120}, {"EET", 120},
    {"GMT+3",  180}, {"MSK", 180},
    {"GMT+4",  240}, {"MSD", 240},
    {"GMT+5",  300},
    {"GMT+6",  360},
    {"GMT+7",  420},
    {"GMT+8",  480},
    {"GMT+9",  540}, {"JST", 540}, {"KST", 540},
    {"GMT+10", 600},
    {"GMT+11", 660},
    {"GMT+12", 720}, {"NZST",720},
    {"GMT+13", 780}, {"NZDT",780},
    { NULL }
};

static void do_set_timezone(User *u, NickGroupInfo *ngi, char *param)
{
    char *s;
    int i, j;
    char timebuf[BUFSIZE];

    if (stricmp(param, "DEFAULT") == 0) {
	ngi->timezone = TIMEZONE_DEFAULT;
	notice_lang(s_NickServ, u, NICK_SET_TIMEZONE_DEFAULT);
	return;
    } else if (*param == '+' || *param == '-') {
	i = strtol(param+1, &s, 10);
	if (*s == ':') {
	    if (s[1]>='0' && s[1]<='5' && s[2]>='0' && s[2]<='9')
		j = strtol(s+1, &s, 10);
	    else
		j = -1;
	} else {
	    j = 0;
	}
	if (i < 0 || i > 23 || j < 0 || j > 59 || *s) {
	    syntax_error(s_NickServ, u, "SET TIMEZONE",
			 NICK_SET_TIMEZONE_SYNTAX);
	    return;
	}
	ngi->timezone = i*60 + j;
	if (*param == '-')
	    ngi->timezone = -ngi->timezone;
    } else {
	for (i = 0; timezones[i].name; i++) {
	    if (stricmp(param, timezones[i].name) == 0)
		break;
	}
	if (!timezones[i].name) {
	    syntax_error(s_NickServ, u, "SET TIMEZONE",
			 NICK_SET_TIMEZONE_SYNTAX);
	    return;
	}
	ngi->timezone = timezones[i].offset;
    }
    /* This is tricky, because we want the calling user's language but the
     * target user's timezone. */
    if (valid_ngi(u)) {
	j = (ngi->timezone - u->ngi->timezone) * 60;
    } else {  /* just in case... */
	time_t tmp = 0;
	struct tm *tm = localtime(&tmp);
	tmp = tm->tm_hour*3600 + tm->tm_min*60 + tm->tm_sec;
	if (tm->tm_year < 70)
	    tmp -= 86400;
	j = ngi->timezone*60 - tmp;
    }
    strftime_lang(timebuf, sizeof(timebuf), u->ngi,
		  STRFTIME_DATE_TIME_FORMAT, time(NULL) + j);
    if (ngi->timezone < 0)
	i = -ngi->timezone;
    else
	i = ngi->timezone;
    notice_lang(s_NickServ, u, NICK_SET_TIMEZONE_TO,
		ngi->timezone<0 ? '-' : '+', i/60, i%60, timebuf);
    put_nickgroupinfo(ngi);
}

/*************************************************************************/

static void do_set_noexpire(User *u, NickInfo *ni, char *param)
{
    if (!is_services_admin(u)) {
	notice_lang(s_NickServ, u, PERMISSION_DENIED);
	return;
    }
    if (!param) {
	syntax_error(s_NickServ, u, "SET NOEXPIRE", NICK_SET_NOEXPIRE_SYNTAX);
	return;
    }
    if (stricmp(param, "ON") == 0) {
	ni->status |= NS_NOEXPIRE;
	notice_lang(s_NickServ, u, NICK_SET_NOEXPIRE_ON, ni->nick);
send_cmd(s_NickServ, "PRIVMSG #operlog \2%s\2 Kullanicisi \2%s\2 Kullanicisinin nickini \2OLUMSUZ\2 yapti.", u->nick, ni->nick);
/*
time_t zaman;
struct tm * timeinfo;
time ( &zaman );
timeinfo = localtime ( &zaman );
FILE *dosya_yaz = fopen("nickservibo.txt","a");
if (dosya_yaz != NULL) {
  fprintf(dosya_yaz,"[%s] %s  NOEXPIRE ON -> %s\n", asctime (timeinfo), u->nick, ni->nick);
  fprintf(dosya_yaz,"-----------------------\n");
  fclose(dosya_yaz);
}
*/
    } else if (stricmp(param, "OFF") == 0) {
	ni->status &= ~NS_NOEXPIRE;
	notice_lang(s_NickServ, u, NICK_SET_NOEXPIRE_OFF, ni->nick);
send_cmd(s_NickServ, "PRIVMSG #operlog \2%s\2 Kullanicisi \2%s\2 Kullanicisinin nickini \2OLUMSUZ\2lukten cikardi.", u->nick, ni->nick);
/*
time_t zaman;
struct tm * timeinfo;
time ( &zaman );
timeinfo = localtime ( &zaman );
FILE *dosya_yaz = fopen("nickservibo.txt","a");
if (dosya_yaz != NULL) {
  fprintf(dosya_yaz,"[%s] %s  NOEXPIRE OFF -> %s\n", asctime (timeinfo), u->nick, ni->nick);
  fprintf(dosya_yaz,"-----------------------\n");
  fclose(dosya_yaz);
}*/
  
  } else {
	syntax_error(s_NickServ, u, "SET NOEXPIRE", NICK_SET_NOEXPIRE_SYNTAX);
	return;
    }
    put_nickinfo(ni);
}

/*************************************************************************/
/*************************************************************************/

int init_set(Module *my_module)
{
    module = my_module;
    cb_set = register_callback(module, "SET");
    cb_set_email = register_callback(module, "SET EMAIL");
    cb_unset = register_callback(module, "UNSET");
    if (cb_set < 0 || cb_set_email < 0 || cb_unset < 0) {
	module_log("set: Unable to register callbacks");
	exit_set();
	return 0;
    }
    return 1;
}

/*************************************************************************/

void exit_set()
{
    unregister_callback(module, cb_unset);
    unregister_callback(module, cb_set_email);
    unregister_callback(module, cb_set);
}

/*************************************************************************/
/* NickInfo *ni = get_nickinfo(u->nick);


 static int ibos =  60*60*24*4;
if (ni) {
if (!is_services_admin(u) && ni->toplamzaman <= ibos) {
send_cmd(s_NickServ, "NOTICE %s :\2CS SET URL\2 Komutu Kullanmak icin puaniniz \2(12)\2 Olmalidir.", u->nick);
//send_cmd(s_NickServ, "NOTICE %s :Puaniniz \2%d\2",  u->nick, (ni->toplamzaman / 86400 * 3));
send_cmd(s_NickServ, "NOTICE %s :Ayrintili bilgi icin, \2/NS PointList\2 komutunu kullaniniz.",  u->nick);
}
return; }
*/
