Пример #1
0
int cgi_access_manager::cgi_access_write(const CString& container){

#ifndef ANSI

	chmod(container.asString(), _S_IREAD | _S_IWRITE);

#endif
	int hfile2 = v_open(container.asString(), O_WRONLY | O_TRUNC | O_CREAT, S_IRWXU);    

	if (hfile2 == -1) {

		perror("<br>Error writing access.struct:");

		return 0;

	}

    for (int m = 0; m<entry_manager::entries_count();m++) {
		write(hfile2, entry_manager::get_name(m).asString(), entry_manager::get_name(m).StrLength());
		write(hfile2, ",", strlen(","));
		CString PasswdValue(entry_manager::get_value(m).Encrypt());
		write(hfile2, PasswdValue.asString(), PasswdValue.StrLength());
		write(hfile2, "\n", strlen("\n"));
    }
    close(hfile2);
    return 1;
}
Пример #2
0
int cgi_admin_manager::write_full_admin(const CString& AdminClass, const CString& Equiv){
	if ((!AdminClass.StrLength())||(!Equiv.StrLength())) return 0;
	if (!equiv_file.StrLength()) {
		current_cgi_admin_manager = this;
		equiv_file = entry_manager::make_equiv_path("admin.struct");
	}
#ifndef ANSI

	chmod(equiv_file.asString(), _S_IREAD | _S_IWRITE);

#endif
	int hfile2 = v_open(equiv_file.asString(), O_WRONLY | O_APPEND | O_CREAT, S_IRWXU);    
	if (hfile2 == -1) {

		perror("<br>Error writing admin.struct:");

		return 0;  

	}
	write(hfile2, AdminClass.asString(), AdminClass.StrLength());    
	write(hfile2, ",", strlen(","));
	write(hfile2, Equiv.asString(), Equiv.StrLength());
	write(hfile2, "\n", strlen("\n"));  
	close(hfile2);
	return 1; 
}
Пример #3
0
int cgi_access_manager::write_full_access(const CString& Equiv, const CString& Password){
	if (!equiv_file.StrLength()) {
		current_cgi_access_manager = this;
		equiv_file = entry_manager::make_equiv_path("access.struct");
	}

#ifndef ANSI

	chmod(equiv_file.asString(), _S_IREAD | _S_IWRITE);

#endif

	int hfile2 = v_open(equiv_file.asString(), O_WRONLY | O_APPEND | O_CREAT, S_IRWXU);

	if (hfile2 == -1) {

		perror("<br>Error writing access.struct:");

		return 0;

	}
    CString EPassword(Password);    
    write(hfile2, Equiv.asString(), Equiv.StrLength());    
    write(hfile2, ",", strlen(","));

	CString EncryptedPassword(EPassword); EncryptedPassword.Encrypt();
    write(hfile2, EncryptedPassword.asString(), EncryptedPassword.StrLength());
    write(hfile2, "\n", strlen("\n"));  
    close(hfile2);
    return 1;      
}
Пример #4
0
int cgi_admin_manager::cgi_admin_write(const CString& container){
#ifndef ANSI

	chmod(equiv_file.asString(), _S_IREAD | _S_IWRITE);

#endif

	int hfile2 = v_open(container.asString(), O_WRONLY | O_TRUNC | O_CREAT, S_IRWXU);  
	if (hfile2 == -1) {

		perror("<br>Error writing admin.struct:");

		return 0;

	}
	for (int i=0;i<entry_manager::class_count();i++){
		for (int j=0;j<entry_manager::class_count(i);j++) {
			write(hfile2, entry_manager::get_name(i, j).asString(), entry_manager::get_name(i, j).StrLength());    
			write(hfile2, ",", strlen(","));
			write(hfile2, entry_manager::get_class(i).asString(), entry_manager::get_class(i).StrLength());
			write(hfile2, "\n", strlen("\n"));  
		}
	}
	close(hfile2);
	return 1;  
}
Пример #5
0
int CHttpRequest::Send(inetSocket& Sock, const CString& Request){
  if (send(Sock.S,Request.asString(),Request.StrLength(),0) == -1) {
    switch(errno) {
    case EBADF: Sock.wserror("(sending to port) The socket  argument  is  not  a  valid  file descriptor."); break;
#ifdef ANSI
    case ECONNRESET: Sock.wserror("(sending to port) A connection was forcibly closed by a peer."); break;
    case EDESTADDRREQ: Sock.wserror("(sending to port) The socket is not connection-mode and no peer address is set."); break;
    case EMSGSIZE: Sock.wserror("(sending to port) The message is too large be sent all at once, as the socket requires."); break;
    case ENOTCONN: Sock.wserror("(sending to port) The socket is not connected or otherwise  has not had the peer prespecified."); break;
    case ENOTSOCK: Sock.wserror("(sending to port) The socket  argument  does  not  refer  to  a socket."); break;
    case EOPNOTSUPP: Sock.wserror("(sending to port) The socket  argument  is  associated  with  a socket  that  does not support one or more of the values set in flags."); break;      
    case ENETDOWN: Sock.wserror("(sending to port) The local interface used to reach the  destination is down."); break;      
    case ENETUNREACH: Sock.wserror("(sending to port) No route to the network is present."); break;      
    case ENOBUFS: Sock.wserror("(sending to port) Insufficient resources were available in  the system to perform the operation."); break;      
#ifdef ENOSR
    case ENOSR: Sock.wserror("(sending to port) There  were  insufficient  STREAMS  resources available for the operation to complete."); break;      
#endif
#endif
    case EINTR: Sock.wserror("(sending to port) A signal interrupted send() before  any  data was transmitted."); break;
    case EPIPE: Sock.wserror("(sending to port) The socket is shut down for writing,  or  the socket  is  connection-mode  and  the peer is closed or shut  down  for  reading.   In  the latter  case,  and  if  the socket is of type SOCK_STREAM, the SIGPIPE signal is  generated to the calling process."); break;      
    case EAGAIN: Sock.wserror("(sending to port) The  socket's  file  descriptor   is   marked O_NONBLOCK  and the requested operation would block."); break;      
    case EIO: Sock.wserror("(sending to port) An I/O error occurred while reading  from  or writing to the file system."); break;      
    default : Sock.wserror("(sending to port) Unexpected error."); break;
    }
    RStatusValue = HTTPR_USER + 2;
    return 0;
  } else return 1;
}
Пример #6
0
struct tm recent_manager::encode_date_article(const CString& date){
	assert(date.StrLength());
	char sep, weekday[10], month[10], hour[10];	
	char * months[] = {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
	char * weekdays[] = {"Sun", "Mon","Tue","Wed","Thu","Fri","Sat"};
	int year;
	struct tm thisdate;

	sscanf(date.asString(), "%s%s%d%s%d", weekday, month, &thisdate.tm_mday, hour, &year);
	
	for (int i=0;i<12;i++) if (!strcmpi(month, months[i])) {thisdate.tm_mon = i + 1; break;}
	for (int j=0;j<7;j++) if (!strcmpi(weekday, weekdays[j])) {thisdate.tm_wday = j + 1; break;}
	thisdate.tm_year = year - 1900;
	sscanf(hour, "%d%c%d%c%d", &thisdate.tm_hour, &sep, &thisdate.tm_min, &sep, &thisdate.tm_sec);
	thisdate.tm_isdst = -1;
	return(thisdate);
}