예제 #1
0
파일: adds.c 프로젝트: Lopo/Lotos
int backup_talker(void)
{
	char fname[6][FNAME_LEN];
	int i;

	set_crash();
	switch (double_fork()) {
		case -1 :
			sprintf(text,"~OLSYSTEM: backup_talker(): Failed to fork backup process...\n");
			write_level(ARCH, 1, text, NULL);
			write_syslog(ERRLOG, 1, "backup_talker(): Failed to fork process...\n");
			return 0; /* double_fork() failed */
		case  0 : /* Start Backup Of Files */
		  	sprintf(fname[0], "%s/%s.tgz", BACKUPDIR, BACKUPFILE);
		  	sprintf(fname[1], "%s/%s.log1", LOGFILES, BACKUPFILE);
		  	sprintf(fname[2], "%s/%s.log2", LOGFILES, BACKUPFILE);
		  	sprintf(fname[3], "%s/%s.tgz", TEMPFILES, BACKUPFILE);
		  	sprintf(fname[4], "%s/%s.log1", TEMPFILES, BACKUPFILE);
		  	sprintf(fname[5], "%s/%s.log2", TEMPFILES, BACKUPFILE);
		  	for (i=0; i<6; i++) unlink(fname[i]);
			write_syslog(SYSLOG, 1, "Backing Up Talker Files To : %s/%s.tgz\n",BACKUPDIR,BACKUPFILE);
			write_syslog(SYSLOG, 1, "For Zip Progress, Read File: %s/%s.log\n",LOGFILES,BACKUPFILE);
//		sprintf(text,"zip -v -9 -r %s/%s.zip * > %s/%s/%s.log", BACKUPDIR, BACKUPFILE, ROOTDIR, LOGFILES, BACKUPFILE);
			sprintf(text, "tar -zcfp '%s' '%s' 1> '%s' 2> '%s'", fname[3], ROOTDIR, fname[4], fname[5]);
			system(text);
			for (i=0; i<3; i++)
				rename(fname[i+3], fname[i]);
			_exit(1);
			return 1;
		}
	return 0;
}
예제 #2
0
파일: ct_msg.c 프로젝트: Lopo/Lotos
void send_icqpage(UR_OBJECT user, char *inpstr)
{
	char fname[FNAME_LEN], icqnum[ICQ_LEN+1], subj[100], addr[100];
	int on;
	UR_OBJECT ur;
	FILE *fp;

	if (word_count<3) {
		write_usage(user, "%s <user>/<ICQ#> <text>", command_table[ICQPAGE].name);
		return;
		}
	icqnum[0]='\0';
	if (is_number(word[1])) strncpy(icqnum, word[1], ICQ_LEN);
	else {
		if (!(ur=get_user_name(user, word[1]))) {
			if (!(ur=create_user())) {
				vwrite_user(user, "%s: nemozem vytvorit docasny user objekt.\n", syserror);
				write_syslog(ERRLOG, 1, "Unable to create temp user object in send_icqpage()\n");
				return;
				}
			strcpy(ur->name, word[1]);
			if (!load_user_details(ur)) {
				write_user(user, nosuchuser);
				destruct_user(ur);
				destructed=0;
				return;
				}
			on=0;
			}
		else on=1;
		strcpy(icqnum, ur->icq);
		if (!on) {
			destruct_user(ur);
			destructed=0;
			}
		}
	if (icqnum[0]=='\0') {
		write_user(user, "sprava neposlana, chybne alebo nezistitelne ICQ cislo\n");
		return;
		}
	sprintf(fname, "%s/%s.icq", TEMPFILES, user->name);
	if (!(fp=fopen(fname, "w"))) {
		write_user(user, "nemozem vytvorit docasny subor pre spravu\n");
		write_syslog(ERRLOG, 1, "unable to open file in send_icqpage()\n");
		return;
		}
	fprintf(fp, icq_page_email);
	fprintf(fp, "%s\n", remove_first(inpstr));
	fclose(fp);
	sprintf(addr, "*****@*****.**", icqnum);
	sprintf(subj, "ICQ page from %s", user->name);
	send_email(addr, subj, fname);
	write_user(user, "sprava bola odoslana\n");
}
예제 #3
0
int main(void)
{
	int ret = 0;
	write_syslog((char*)"GMI_LedWdReboot\n");
	sync();
	ret = GMI_LedWdReboot();
	if(ret){
		write_syslog((char*)"GMI_LedWdReboot failed!!!\n");
		return -1;
	}
	sleep(1);
	return 0;
}
예제 #4
0
파일: hangman.c 프로젝트: Lopo/Lotos
int pl02x100_init(int cm)
{
	PL_OBJECT plugin;
	CM_OBJECT com;
	int i=0;

	set_crash();
/* create plugin */
	if ((plugin=create_plugin())==NULL) {
		write_syslog(ERRLOG, 1, "Nemozem vytvorit novu polozku v registroch pre plugin 'hangman'!\n");
		return 0;
		}
	strcpy(plugin->name,"Hangman");                 /* Plugin Description   */
	strcpy(plugin->author,"Lopo");                  /* Author's name        */
	strcpy(plugin->registration,"02-100");          /* Plugin/Author ID     */
	strcpy(plugin->ver,"1.3");                      /* Plugin version       */
	strcpy(plugin->req_ver,"120");                  /* OSS version required */
	plugin->id = cm;                                /* ID used as reference */
	plugin->req_userfile = 1;                       /* Requires user data?  */
	                                                /* (no separate file required
	                                                    since it keeps its data
	                                                    in a central file, but
	                                                    we need to do housekeeping
	                                                    procedures when the user
	                                                    leaves, so we set this to
	                                                    1 so that we are notified
	                                                    when a user leaves.) */
	plugin->triggerable = 0;                        /* This plugin is triggered
	                                                   by the system timer, and
	                                                   it will automatically
	                                                   save the current poker
	                                                   data when the boards
	                                                   are automatically
	                                                   checked. */
/* create associated command */
	if ((com=create_cmd())==NULL) {
		write_syslog(ERRLOG, 1, "Nemozem pridat prikaz do registrov pre plugin %s !\n", plugin->registration);
		return 0;
		}
	i++;                                            /* Keep track of number created */
	strcpy(com->command,"hangman");                 /* Name of command */
	com->id = plugin->id;                           /* Command reference ID */
	com->req_lev = USER;                            /* Required level for cmd. */
	com->comnum = i;
	com->plugin = plugin;
/* end creating command - repeat as needed for more commands */

	return i;
}
예제 #5
0
파일: rooms.c 프로젝트: blindsight/Amnuts
/*
 * Enter a description for a personal room
 */
void
personal_room_decorate(UR_OBJECT user, char *inpstr)
{
  if (inpstr) {
    if (!amsys->personal_rooms) {
      write_user(user, "Personal room functions are currently disabled.\n");
      return;
    }
    if (strcmp(user->room->owner, user->name)) {
      write_user(user,
                 "You have to be in your personal room to decorate it.\n");
      return;
    }
    if (word_count < 2) {
      write_user(user, "\n~BB*** Decorating your personal room ***\n\n");
      user->misc_op = 19;
      editor(user, NULL);
      return;
    }
    strcat(inpstr, "\n");
  } else {
    inpstr = user->malloc_start;
  }
  *user->room->desc = '\0';
  strncat(user->room->desc, inpstr, ROOM_DESC_LEN);
  if (strlen(user->room->desc) < strlen(inpstr)) {
    vwrite_user(user, "The description is too long for the room \"%s\".\n",
                user->room->name);
  }
  write_user(user, "You have now redecorated your personal room.\n");
  if (!personal_room_store(user->name, 1, user->room)) {
    write_syslog(SYSLOG | ERRLOG, 1,
                 "ERROR: Unable to save personal room status in personal_room_decorate()\n");
  }
}
예제 #6
0
파일: rooms.c 프로젝트: blindsight/Amnuts
/*
 * Parse the user rooms
 */
void
parse_user_rooms(void)
{
  char dirname[80], name[USER_NAME_LEN + 1], *s;
  DIR *dirp;
  struct dirent *dp;
  RM_OBJECT rm;

  sprintf(dirname, "%s/%s", USERFILES, USERROOMS);
  dirp = opendir(dirname);
  if (!dirp) {
    fprintf(stderr,
            "Amnuts: Directory open failure in parse_user_rooms().\n");
    boot_exit(19);
  }
  /* parse the names of the files but do not include . and .. */
  for (dp = readdir(dirp); dp; dp = readdir(dirp)) {
    s = strchr(dp->d_name, '.');
    if (!s || strcmp(s, ".R")) {
      continue;
    }
    *name = '\0';
    strncat(name, dp->d_name, (size_t) (s - dp->d_name));
    rm = create_room();
    if (!personal_room_store(name, 0, rm)) {
      write_syslog(SYSLOG | ERRLOG, 1,
                   "ERROR: Could not read personal room attributes.  Using standard config.\n");
    }
  }
  closedir(dirp);
}
예제 #7
0
파일: spodlist.c 프로젝트: amnuts/Amnuts
/*
 * Add a name to the spodlist
 */
void
add_name_to_spodlist(char *name, int logintime)
{
    SP_OBJECT cur, prev, new_node;

    new_node = (SP_OBJECT) malloc(sizeof *new_node);
    if (!new_node) { /* oops! no memory */
        write_syslog(SYSLOG, 1, "ERROR: Out of memory to malloc in spodlist.c");
        return;
    }
    memset(new_node, 0, (sizeof *new_node));
    new_node->login = logintime;
    strcpy(new_node->name, name);
    prev = NULL;
    for (cur = first_spod; cur; cur = cur->next) {
        if (new_node->login >= cur->login) {
            break;
        }
        prev = cur;
    }
    new_node->next = cur;
    if (!prev) {
        first_spod = new_node;
    } else {
        prev->next = new_node;
    }
}
예제 #8
0
파일: rooms.c 프로젝트: blindsight/Amnuts
/*
 * allows a user to rename their room
 */
void
personal_room_rename(UR_OBJECT user, char *inpstr)
{
  if (!amsys->personal_rooms) {
    write_user(user, "Personal room functions are currently disabled.\n");
    return;
  }
  if (word_count < 2) {
    write_user(user, "Usage: myname <name you want room to have>\n");
    return;
  }
  if (strcmp(user->room->owner, user->name)) {
    write_user(user, "You have to be in your personal room to rename it.\n");
    return;
  }
  if (strlen(inpstr) > PERSONAL_ROOMNAME_LEN) {
    write_user(user, "You cannot have a room name that long.\n");
    return;
  }
  if (strlen(inpstr) - teslen(inpstr, 0) < 1) {
    write_user(user, "You must enter a room name.\n");
    return;
  }
  strcpy(user->room->show_name, inpstr);
  vwrite_user(user, "You have now renamed your room to: %s\n",
              user->room->show_name);
  if (!personal_room_store(user->name, 1, user->room)) {
    write_syslog(SYSLOG | ERRLOG, 1,
                 "ERROR: Unable to save personal room status in personal_room_rename()\n");
  }
}
예제 #9
0
파일: adds.c 프로젝트: Lopo/Lotos
/* allows a user to rename their room */
void personal_room_rename(UR_OBJECT user,char *inpstr) {
	char name[ROOM_NAME_LEN+1];
	RM_OBJECT rm;

	if (!amsys->personal_rooms) {
		write_user(user,"Personal room functions are currently disabled.\n");
		return;
		}
	if (word_count<2) {
		write_usage(user, "%s <nazov>\n", command_table[MYNAME].name);
		return;
		}
	sprintf(name,"(%s)",user->name);
	strtolower(name);
	/* get room that user is in */
	if ((rm=get_room_full(name))==NULL) {
		write_user(user,"Sorry, but you cannot use the room renaming feature at this time.\n");
		return;
		}
	if (user->room!=rm) {
		write_user(user,"You have to be in your personal room to rename it.\n");
		return;
		}
	if (strlen(inpstr)>PERSONAL_ROOMNAME_LEN) {
		write_user(user,"You cannot have a room name that long.\n");
		return;
		}
	strcpy(rm->real_name,inpstr);
	vwrite_user(user,"You have now renamed your room to: %s\n",rm->real_name);
	if (!personal_room_store(user->name,1,rm))
		write_syslog(SYSLOG,1,"ERROR: Unable to save personal room status in personal_room_rename()\n");
}
예제 #10
0
/*
 * read flagged users from file
 */
int
load_flagged_users(UR_OBJECT user)
{
  char filename[80], name[USER_NAME_LEN + 1];
  FILE *fp;
  int f;
  unsigned flags, errors;

  sprintf(filename, "%s/%s/%s.U", USERFILES, USERFLAGGED, user->name);
  fp = fopen(filename, "r");
  if (!fp) {
    return 1;
  }
  errors = 0;
  for (f = fscanf(fp, "%s %u\n", name, &flags); f == 2;
       f = fscanf(fp, "%s %u\n", name, &flags)) {
    if (!create_flagged_user_entry(user, name, flags)) {
      write_syslog(SYSLOG | ERRLOG, 1,
                   "ERROR: Cannot create flagged user object for %s\n",
                   user->name);
      ++errors;
    }
  }
  fclose(fp);
  return !errors;
}
예제 #11
0
파일: boards.c 프로젝트: Lopo/Lotos
/*** Show list of people suggestions are from without seeing the whole lot ***/
void suggestions_from(UR_OBJECT user)
{
    FILE *fp;
    int cnt;
    char id[ARR_SIZE],line[ARR_SIZE], *str;

    set_crash();
    if (!amsys->suggestion_count) {
        write_user(user,"There are currently no suggestions.\n");
        return;
    }
    if (!(fp=fopen(SUGBOARD, "r"))) {
        write_user(user,"There was an error trying to read the suggestion board.\n");
        write_syslog(ERRLOG,1,"Unable to open suggestion board in suggestions_from().\n");
        return;
    }
    write_user(user,"\n~BB*** Suggestions on the suggestions board from ***\n\n");
    cnt=0;
    line[0]='\0';
    fgets(line,ARR_SIZE-1,fp);
    while (!feof(fp)) {
        sscanf(line,"%s",id);
        str=colour_com_strip(id);
        if (!strcmp(str,"From:")) {
            cnt++;
            vwrite_user(user,"~FT%2d)~RS %s",cnt,remove_first(line));
        }
        line[0]='\0';
        fgets(line,ARR_SIZE-1,fp);
    }
    fclose(fp);
    vwrite_user(user,"\nTotal of ~OL%d~RS suggestions.\n\n",amsys->suggestion_count);
}
예제 #12
0
/*
 * add a command to the commands linked list.  Get which command via the passed id
 * int and the enum in the header file
 */
int
add_command(enum cmd_value cmd_id)
{
  CMD_OBJECT cmd, tmp;

  cmd = (CMD_OBJECT) malloc(sizeof *cmd);
  if (!cmd) {
    write_syslog(SYSLOG | ERRLOG, 0,
                 "ERROR: Memory allocation failure in add_command().\n");
    return 0;
  }
  memset(cmd, 0, (sizeof *cmd));
  strcpy(cmd->name, command_table[cmd_id].name);
  cmd->id = cmd_id;
  strcpy(cmd->alias, command_table[cmd_id].alias);
  cmd->level = (enum lvl_value) command_table[cmd_id].level;
  cmd->function = command_table[cmd_id].function;
  cmd->count = 0;

  /*
     do an insertion sort on the linked list
     this could take a long time, but it only needs to be done once when booting, so it
     does not really matter
   */
  for (tmp = first_command; tmp; tmp = tmp->next) {
    if (strcmp(cmd->name, tmp->name) < 0) {
      break;
    }
  }
  if (!tmp) {
    if (tmp == first_command) {
      /* insert in an empty list */
      first_command = cmd;
      cmd->prev = NULL;
      cmd->next = NULL;
      last_command = cmd;
    } else {
      /* insert at the end of the list */
      last_command->next = cmd;
      cmd->prev = last_command;
      cmd->next = NULL;
      last_command = cmd;
    }
  } else {
    if (tmp == first_command) {
      /* insert as first item in the list */
      first_command->prev = cmd;
      cmd->prev = NULL;
      cmd->next = first_command;
      first_command = cmd;
    } else {
      /* insert in the middle of the list somewhere */
      tmp->prev->next = cmd;
      cmd->prev = tmp->prev;
      tmp->prev = cmd;
      cmd->next = tmp;
    }
  }
  return 1;
}
예제 #13
0
파일: adds.c 프로젝트: Lopo/Lotos
/* Restore a user to his original rank from a temp promote.  S.C.  09/27/99 */
void restore(UR_OBJECT user)
{
UR_OBJECT u;

	set_crash();
if (word_count<2) {
   write_usage(user,"restore <user>");
   return;
   }
if (!(u=get_user_name(user,word[1]))) {
   write_user(user, notloggedon);
   return;
   }
if (u->level>u->real_level) {
  u->level=u->real_level;
  vwrite_user(user,"%s Ma odteraz svoj originalny level.\n", u->name);
  vwrite_room_except(u->room,u,"%s begins fading as their power is restored to normal.\n",u->name);
  vwrite_user(u,"Bol obnoveny tvoj originalny level.\n");
  write_syslog(SYSLOG, 1, "%s restored %s to their original level.\n",user->name,u->name);
  sprintf(text,"Had their level restored by %s.\n",user->name);
  add_history(u->name,1,text);
  return;
  }
else {
  write_user(user,"You can't restore a person to their original rank if they're already there.\n");
  return;
  }
}
예제 #14
0
/*
 * add a user node to the user linked list
 */
int
add_user_node(const char *name, enum lvl_value level)
{
  UD_OBJECT entry;

  entry = (UD_OBJECT) malloc(sizeof *entry);
  if (!entry) {
    write_syslog(SYSLOG | ERRLOG, 0,
                 "ERROR: Memory allocation failure in add_user_node().\n");
    return 0;
  }
  memset(entry, 0, (sizeof *entry));
  if (!first_user_entry) {
    first_user_entry = entry;
    entry->prev = NULL;
  } else {
    last_user_entry->next = entry;
    entry->prev = last_user_entry;
  }
  entry->next = NULL;
  last_user_entry = entry;
  strcpy(entry->name, name);
  entry->level = level;
  *entry->date = '\0';
  entry->retired = 0;
  ++amsys->user_count;
  ++amsys->level_count[entry->level];
  return 1;
}
예제 #15
0
파일: unmuzzle.c 프로젝트: amnuts/Amnuts
/*
 * Unmuzzle the bastard now he has apologised and grovelled enough via email
 */
void
unmuzzle(UR_OBJECT user)
{
    UR_OBJECT u;
    int on;

    if (word_count < 2) {
        write_user(user, "Usage: unmuzzle <user>\n");
        return;
    }
    u = retrieve_user(user, word[1]);
    if (!u) {
        return;
    }
    on = retrieve_user_type == 1;
    /* error checks */
    if (u == user) {
        write_user(user,
                "Trying to unmuzzle yourself is the tenth sign of madness.\n");
        done_retrieve(u);
        return;
    }
    /* FIXME: Use sentinel other JAILED */
    if (u->muzzled == JAILED) {
        vwrite_user(user, "%s~RS is not muzzled.\n", u->recap);
        done_retrieve(u);
        return;
    }
    if (u->muzzled > user->level) {
        vwrite_user(user,
                "%s~RS's muzzle is set to level %s, you do not have the power to remove it.\n",
                u->recap, user_level[u->muzzled].name);
        done_retrieve(u);
        return;
    }
    /* do the unmuzzle */
    u->muzzled = JAILED; /* FIXME: Use sentinel other JAILED */
    vwrite_user(user, "~FG~OLYou remove %s~RS's muzzle.\n", u->recap);
    write_syslog(SYSLOG, 1, "%s unmuzzled %s.\n", user->name, u->name);
    add_history(u->name, 0, "~FGUnmuzzled~RS by %s, level %d (%s).\n",
            user->name, user->level, user_level[user->level].name);
    sprintf(text, "~FG~OLYou have been unmuzzled!\n");
    if (!on) {
        send_mail(user, u->name, text, 0);
    } else {
        write_user(u, text);
    }
    /* finish up */
    if (!on) {
        strcpy(u->site, u->last_site);
        u->socket = -2;
    }
    save_user_details(u, on);
    done_retrieve(u);
}
예제 #16
0
파일: email.c 프로젝트: Lopo/Lotos
/*** verify user's email when it is set specified ***/
void set_forward_email(UR_OBJECT user)
{
	FILE *fp;
	char fname[FNAME_LEN];

	set_crash();
	if (!user->email[0] || !strcmp(user->email,"#UNSET")) {
		write_user(user,"Your email address is currently ~FRunset~RS.  If you wish to use the\nauto-forwarding function then you must set your email address.\n\n");
		user->autofwd=0;
		return;
		}
	if (!amsys->forwarding) {
		write_user(user,"Even though you have set your email, the auto-forwarding function is currently unavaliable.\n");
		user->mail_verified=0;
		user->autofwd=0;
		return;
		}
	user->mail_verified=0;
	user->autofwd=0;
	/* Let them know by email */
	sprintf(fname,"%s/%s.FWD",MAILSPOOL,user->name);
	if (!(fp=fopen(fname,"w"))) {
		write_syslog(ERRLOG, 1, "Unable to open forward mail file in set_forward_email()\n");
		return;
		}
	sprintf(user->verify_code,"lotos%d",rand()%999);
	/* email header */
	fprintf(fp,"From: %s\n",reg_sysinfo[TALKERNAME]);
	fprintf(fp,"To: %s <%s>\n\n",user->name,user->email);
	/* email body */
	fprintf(fp,"Hello, %s.\n\n",user->name);
	fprintf(fp, vrf_fwd_email, user->verify_code);
	fputs(talker_signature,fp);
	fclose(fp);
	/* send the mail */
	send_email(user->email, "Verification of auto-mail", fname);
	write_syslog(SYSLOG,1,"%s had mail sent to them by set_forward_email().\n",user->name);
	/* Inform them online */
	write_user(user,"Now that you have set your email you can use the auto-forward functions.\n");
	write_user(user,"You must verify your address with the code you will receive shortly, via email.\n");
	write_user(user,"If you do not receive any email, then use ~FTset email <email>~RS again, making\nsure you have the correct address.\n\n");
}
예제 #17
0
파일: libpola.c 프로젝트: Kowai/Pola
int isdenied(mode* m, const char* pathname) {
	// access denied
	if (m->c != 'y' && m->c != 'Y' && m->c != 'r' && m->c != 'R') {
		write_syslog(pathname);
	/*	// set errno so the calling application knows what happened
		errno = EACCES;*/
		// return with error
		return 1;
	} else {
		return 0;
	}
}
예제 #18
0
파일: boards.c 프로젝트: Lopo/Lotos
/** delete suggestions from the board **/
void delete_suggestions(UR_OBJECT user)
{
    int cnt;

    set_crash();
    if (word_count<2) {
        write_user(user,"Pouzitie: dsug all\n");
        write_user(user,"          dsug <#>\n");
        write_user(user,"          dsug to <#>\n");
        write_user(user,"          dsug from <#> to <#>\n");
        return;
    }
    if (get_wipe_parameters(user)==-1) return;
    if (!amsys->suggestion_count) {
        write_user(user,"There are no suggestions to delete.\n");
        return;
    }
    if (user->wipe_from==-1) {
        unlink(SUGBOARD);
        write_user(user,"All suggestions deleted.\n");
        write_syslog(SYSLOG,1,"%s wiped all suggestions from the suggestions board\n",user->name);
        amsys->suggestion_count=0;
        return;
    }
    if (user->wipe_from>amsys->suggestion_count) {
        vwrite_user(user,"There %s only %d suggestion%s on the board.\n",PLTEXT_IS(amsys->suggestion_count),amsys->suggestion_count,PLTEXT_S(amsys->suggestion_count));
        return;
    }
    cnt=wipe_messages(SUGBOARD, user->wipe_from,user->wipe_to,0);
    if (cnt==amsys->suggestion_count) {
        unlink(SUGBOARD);
        vwrite_user(user,"There %s only %d suggestion%s on the board, all now deleted.\n",PLTEXT_WAS(cnt),cnt,PLTEXT_S(cnt));
        write_syslog(SYSLOG,1,"%s wiped all suggestions from the suggestions board\n",user->name);
        amsys->suggestion_count=0;
        return;
    }
    amsys->suggestion_count-=cnt;
    vwrite_user(user,"%d suggestion%s deleted.\n",cnt,PLTEXT_S(cnt));
    write_syslog(SYSLOG,1,"%s wiped %d suggestion%s from the suggestions board\n",user->name,cnt,PLTEXT_S(cnt));
}
예제 #19
0
파일: boards.c 프로젝트: Lopo/Lotos
/** Write a suggestion to the board, or read if if you can **/
void suggestions(UR_OBJECT user, int done_editing)
{
    FILE *fp;
    char *c;
    int cnt=0;

    set_crash();
    if (com_num==RSUG) {
        write_user(user,"~BB~FG*** The Suggestions board has the following ideas ***\n\n");
        switch (more(user, user->socket, SUGBOARD)) {
        case 0:
            write_user(user,"There are no suggestions.\n\n");
            break;
        case 1:
            user->misc_op=2;
        }
        return;
    }
#ifdef NETLINKS
    if (user->type==REMOTE_TYPE) {
        write_user(user,"Remote users cannot use this command, sorry!\n");
        return;
    }
#endif
    if (!done_editing) {
        write_user(user,"~BB~FG*** Writing a suggestion ***\n\n");
        user->misc_op=8;
        editor(user,NULL);
        return;
    }
    if (!(fp=fopen(SUGBOARD, "a"))) {
        vwrite_user(user,"%s: couldn't add suggestion.\n",syserror);
        write_syslog(ERRLOG,1,"Couldn't open file %s to write in suggestions().\n", SUGBOARD);
        return;
    }
    sprintf(text,"~OLFrom: %s  %s\n",user->bw_recap,long_date(0));
    fputs(text,fp);
    c=user->malloc_start;
    while (c!=user->malloc_end) {
        putc(*c++,fp);
        if (*c=='\n') cnt=0;
        else ++cnt;
        if (cnt==80) {
            putc('\n',fp);
            cnt=0;
        }
    }
    fprintf(fp,"\n");
    fclose(fp);
    write_user(user,"Suggestion written.  Thank you for your contribution.\n");
    amsys->suggestion_count++;
}
예제 #20
0
파일: libpola.c 프로젝트: Kowai/Pola
/**
 * costum opendir
 */
DIR *costum_opendir (const char* dirname, DIR *(*Normal_Opendir)(const char *name))
{
    char* cmd = getenv("CMD");

    if (strstr(cmd, dirname) != NULL)
    {
        return Normal_Opendir(dirname);
    }

    write_syslog(dirname);
    errno = EACCES;
    return NULL;
}
예제 #21
0
파일: boards.c 프로젝트: Lopo/Lotos
/*** Show list of people board posts are from without seeing the whole lot ***/
void board_from(UR_OBJECT user)
{
    FILE *fp;
    int cnt;
    char id[ARR_SIZE],line[ARR_SIZE],fname[FNAME_LEN],rmname[ROOM_NAME_LEN+1];
    RM_OBJECT rm;

    set_crash();
    if (word_count<2) rm=user->room;
    else {
        if ((rm=get_room(word[1]))==NULL) {
            write_user(user,nosuchroom);
            return;
        }
        if (!has_room_access(user,rm)) {
            write_user(user,"That room is currently private, you cannot read the board.\n");
            return;
        }
    }
    if (!rm->mesg_cnt) {
        write_user(user,"That room has no messages on it's board.\n");
        return;
    }
    if (rm->access==PERSONAL_LOCKED || rm->access==PERSONAL_UNLOCKED) {
        midcpy(rm->name,rmname,1,strlen(rm->name)-2);
        rmname[0]=toupper(rmname[0]);
        sprintf(fname,"%s/%s.B", USERROOMS, rmname);
    }
    else sprintf(fname,"%s/%s.B", ROOMFILES, rm->name);
    if (!(fp=fopen(fname,"r"))) {
        write_user(user,"There was an error trying to read message board.\n");
        write_syslog(ERRLOG,1,"Unable to open message board for %s in board_from().\n",rm->name);
        return;
    }
    vwrite_user(user,"\n~FG~BB*** Posts on the %s message board from ***\n\n",rm->name);
    cnt=0;
    line[0]='\0';
    fgets(line,ARR_SIZE-1,fp);
    while (!feof(fp)) {
        sscanf(line,"%s",id);
        if (!strcmp(id,"PT:")) {
            cnt++;
            vwrite_user(user,"~FT%2d)~RS %s", cnt, remove_first(remove_first(remove_first(line))));
        }
        line[0]='\0';
        fgets(line,ARR_SIZE-1,fp);
    }
    fclose(fp);
    vwrite_user(user,"\nTotal of ~OL%d~RS messages.\n\n", rm->mesg_cnt);
}
예제 #22
0
파일: rooms.c 프로젝트: blindsight/Amnuts
/*
 * Change whether a rooms access is fixed or not
 */
void
change_room_fix(UR_OBJECT user, int fix)
{
  RM_OBJECT rm;
  const char *name;

  if (word_count < 2) {
    rm = user->room;
  } else {
    rm = get_room(word[1]);
    if (!rm) {
      write_user(user, nosuchroom);
      return;
    }
  }
  if (fix) {
    if (is_fixed_room(rm)) {
      if (rm == user->room) {
        write_user(user, "This room's access is already fixed.\n");
      } else {
        write_user(user, "That room's access is already fixed.\n");
      }
      return;
    }
  } else {
    if (!is_fixed_room(rm)) {
      if (rm == user->room) {
        write_user(user, "This room's access is already unfixed.\n");
      } else {
        write_user(user, "That room's access is already unfixed.\n");
      }
      return;
    }
  }
  rm->access ^= FIXED;
  reset_access(rm);
  write_syslog(SYSLOG, 1, "%s %s access to room %s.\n", user->name,
               is_fixed_room(rm) ? "FIXED" : "UNFIXED", rm->name);
  name = user->vis ? user->recap : invisname;
  if (user->room == rm) {
    vwrite_room_except(rm, user, "%s~RS has %s~RS access for this room.\n",
                       name, is_fixed_room(rm) ? "~FRFIXED" : "~FGUNFIXED");
  } else {
    vwrite_room(rm, "This room's access has been %s~RS.\n",
                is_fixed_room(rm) ? "~FRFIXED" : "~FGUNFIXED");
  }
  vwrite_user(user, "Access for room %s is now %s~RS.\n", rm->name,
              is_fixed_room(rm) ? "~FRFIXED" : "~FGUNFIXED");
}
예제 #23
0
파일: macros.c 프로젝트: Lopo/Lotos
MC_OBJECT create_macro(void)
{
	MC_OBJECT mc;
	
	set_crash();
	if ((mc=(MC_OBJECT)malloc(sizeof(struct macro_struct)))==NULL) {
		write_syslog(ERRLOG, 1, "Chyba alokacie pamate v create_macro().\n");
		return NULL;
		}
	mc->name[0]='\0';
	mc->comstr[0]='\0';
	mc->next=NULL;
	mc->prev=NULL;
	return mc;
}
예제 #24
0
파일: eightball.c 프로젝트: Lopo/Lotos
int pl00x100_init(int cm)
{
	PL_OBJECT plugin;
	CM_OBJECT com;
	int i=0;

	set_crash();
/* create plugin */
	if ((plugin=create_plugin())==NULL) {
		write_syslog(ERRLOG, 1, "Unable to create new registry entry!\n");
		return 0;
		}
	strcpy(plugin->name,"TalkerMagicEightBall");    /* Plugin Description   */
	strcpy(plugin->author,"Lopo");                  /* Author's name        */
	strcpy(plugin->registration,"00-100");          /* Plugin/Author ID     */
	strcpy(plugin->ver,"1.2");                      /* Plugin version       */
	strcpy(plugin->req_ver,"110");                  /* Runtime ver required */
	plugin->id = cm;                                /* ID used as reference */
	plugin->req_userfile = 0;                       /* Requires user data?  */
	plugin->triggerable = 0;                        /* Can be triggered by
	                                                   regular speech? */

/* create associated command */
	if ((com=create_cmd())==NULL) {
		write_syslog(ERRLOG, 1, "Unable to add command to registry!\n");
		return 0;
		}
	i++;                                            /* Keep track of number created */
	strcpy(com->command,"8ball");                   /* Name of command */
	com->id = plugin->id;                           /* Command reference ID */
	com->req_lev = USER;                            /* Required level for cmd. */
	com->comnum = i;                                /* Per-plugin command ID */
	com->plugin = plugin;                           /* Link to parent plugin */
/* end creating command - repeat as needed for more commands */
	return i;
}
예제 #25
0
파일: libpola.c 프로젝트: Kowai/Pola
/**
 * costum open interactive
 */
DIR *costum_iopendir (const char* dirname,
                             DIR *(*Normal_Opendir)(const char *name))
{
    char a;
    char line[IOPENDIR_SIZE];
    printf("opening directory %s ? yes/no r : ", dirname);
    fgets(line, IOPENDIR_SIZE, stdin);
    sscanf(line, "%c", &a);
    if ( a == 'y')
        return Normal_Opendir(dirname);

    //if we arrive here, there is a non autorized acces to dirname
    write_syslog(dirname);
    errno = EACCES;
    return NULL;
}
예제 #26
0
파일: hangman.c 프로젝트: Lopo/Lotos
int pl02x100_save_user_details(UR_OBJECT user)
{
	FILE *fp;
	char filename[500];
	
	set_crash();
	sprintf(filename, "%s/%s.02x100", USERPLDATAS, user->name);
	if (!(fp=fopen(filename, "w"))) {
		write_user(user, "HANGMAN: chyba pri ukladani user dat\n");
		write_syslog(ERRLOG, 1, "Chyba pri ukladani dat v 02x100_save_user_details()\n");
		return 0;
		}
	fprintf(fp, "%d %d", user->pl02x100->win, user->pl02x100->lose);
	fclose(fp);
	return 1;
}
예제 #27
0
void writeToCustomLog(char *log_string) {
    ticks = time(NULL);
    char d_time[25];
    snprintf(d_time, 25, "%.24s", ctime(&ticks));

    if (globals.use_syslog == true) {
        write_syslog(log_string);
        return;
    }

    if (NULL != custom_fd) {
        fprintf(custom_fd, "[%s][pid %d] %s\n", d_time, getpid(), log_string);
        fflush(custom_fd);
    }
    VERBOSE(log_string);
}
예제 #28
0
파일: hangman.c 프로젝트: Lopo/Lotos
/*** Create a hang player ***/
struct pl02x100_player *pl02x100_create_player(void)
{
	struct pl02x100_player *player;

	set_crash();
if ((player=(struct pl02x100_player *)malloc(sizeof(struct pl02x100_player)))==NULL) {
        write_syslog(ERRLOG, 1, "chyba alokacie pamate v 02x100_create_player().\n");
        return NULL;
        }

/* initialise the player */
	player->user = NULL;
	player->win=player->lose=0;
	player->stage=-1;

	return player;
}
예제 #29
0
파일: adds.c 프로젝트: Lopo/Lotos
void oss_versionVerify(void)
{
	PL_OBJECT plugin,p;
	CM_OBJECT com;

	set_crash();
	for (plugin=plugin_first; plugin!=NULL; plugin=p) {
		p=plugin->next;
		if (atoi(RUN_VER) < atoi(plugin->req_ver)) {
			printf("\nLotos: Plugin '%s' pozaduje vyssiu verziu Lotos.\n",plugin->name);
			write_syslog(SYSLOG, 0, "Lotos: Plugin '%s' pozaduje Lotos verzie %s.\n",plugin->name,plugin->req_ver);
			for (com=cmds_first; com!=NULL; com=com->next) if (com->plugin==plugin) destroy_pl_cmd(com);
			destroy_plugin(plugin);
			}
		printf(".");
		}
	printf("  OK\n");
}
예제 #30
0
파일: boots.c 프로젝트: Lopo/Lotos
void create_kill_file(void)
{
	FILE *fp;
	int i=0;

	set_crash();
	if ((fp=fopen(KILLFILE, "wb"))==NULL) {
		write_syslog(ERRLOG, 1, "nemozem vytvorit KILLFILE v create_kill_file()\n");
		return;
		}
	sprintf(text, "kill -9 %d\n", getpid());
	while (text[i]) {
		fwrite(text+i, 1, sizeof(char), fp);
		i++;
		}
	fclose(fp);
	sprintf(text, "chmod 700 %s", KILLFILE);
	system(text);
}