home *** CD-ROM | disk | FTP | other *** search
Wrap
////////////////////////////////////////////////////////////////////////////// // // File: Back-ftp // // Desc: Back Ftp for Maximus 3.0 // // Copyright 1995-1996 Alberto Velo // // ////////////////////////////////////////////////////////////////////////////// #include <max.mh> #include <prm.mh> string: sito,dir,file,userarea,cfg,fftp; int: ld, haspaid,error; #define cfg "backftp.usr" // must be in MAX directory ! #define fftp "backftp.dat" // in Max dir void cls() { print ("\f\n" COL_YELLOWONBLUE " --- Back-Ftp for Maximus 3.0 --- \n"); print (" (c) Alberto Velo, 1995 \n" COL_WHITE); } int need_money() { string: key; int: nkey, i; char: c; print("\nHello, " COL_YELLOW, usr.name); print(COL_WHITE "\n\nPlease wait: checking your account..."); key:= usr.xkeys; nkey:= strlen(key); for (i := 1; i < (nkey+1); i := i + 1) { c:= key[i]; if (c = 'X') haspaid := 1; } if (haspaid <> 1) { print(COL_LRED "\n\n\aERROR! You don't have access to Back-Ftp !"); print("\nThis service is reserved to payant users."); return (haspaid); } print("\nLevel 1: ok..."); } int area() { int: file,ln,pos,i,area; string: linea,nome,dir,user; user:= usr.name; file:= fileexists(cfg); if (file <> 1) return (error:=1); file:= open(cfg, IOPEN_READ); do { ln:= readln(file,linea); for (pos := stridx (linea, pos, '='); pos; pos := stridx (linea, pos+1, '=')) { i := strfind(linea,user); if (i > 0){ print("\nLevel 2: ok..."); dir:= strtrim(substr(linea, pos+1,strlen(linea))," "); goto eof; } } } while (ln >= 0); return (error:=1); //Utente non presente in backftp.usr eof: userarea:= "USER." + dir; if (area:= fileareaselect(userarea) <> 1) return(error:=2); // Area misconfigured print(COL_GREEN "\n\nYour personal area is: " COL_LGREEN,userarea); print(COL_GREEN "\nThere you will find files retrieved with BackFtp.\n"); } int leggi_dati(int: ld) { if (ld=0) { input_str(sito,INPUT_NLB_LINE,0,0,COL_WHITE "\nHost name: " COL_YELLOW); input_str(dir,INPUT_NLB_LINE,0,0,COL_WHITE "\nDirectory: " COL_YELLOW); input_str(file,INPUT_NLB_LINE,0,0,COL_WHITE "\nFile name: " COL_YELLOW); } else if (ld=1) { input_str(sito,INPUT_NLB_LINE,0,0,COL_WHITE "\nHost name: " COL_YELLOW); } else if (ld=2) { input_str(dir,INPUT_NLB_LINE,0,0,COL_WHITE "\nDirectory: " COL_YELLOW); } else if (ld=3) { input_str(file,INPUT_NLB_LINE,0,0,COL_WHITE "\nFile name: " COL_YELLOW); } } int prepara_dat(string: sito, string: dir, string: gfile) { string: user,localdir; int: file,dat; localdir:= farea.downpath; user:=usr.name; dat:= fileexists(fftp); if (dat=1) { file:= open(fftp, IOPEN_WRITE | IOPEN_APPEND); } else { file:= open(fftp, IOPEN_WRITE | IOPEN_CREATE); } writeln(file,"<"); writeln(file,user); writeln(file,localdir); writeln(file,sito); writeln(file,dir); writeln(file,gfile); writeln(file,">"); } int main() { char: yn, grt; string: localdir; cls(); need_money(); if (haspaid <> 1) goto the_end; area(); if (error = 1 or error=2) { print(COL_LRED "\n\nERROR n. ",error," : access not granted."); print("\nPlease contact the SysOp and signal the error code."); goto the_end; } insert: leggi_dati(ld); if (strlen(sito) = 0) { print(COL_LRED "\nYou MUST tell me where to get the file!\n"); ld:=1; goto insert; } if (strlen(file) = 0) { print(COL_LRED "\nYou MUST tell me file name!\n"); ld:=3; goto insert; } isok: cls(); print("\n\nYou requested a ftp for: "); print(COL_WHITE "\n\nHostname :" COL_YELLOW, sito); print(COL_WHITE "\nDirectory :" COL_YELLOW, dir); print(COL_WHITE "\nFile :" COL_YELLOW, file); print(COL_WHITE "\n\nThese are data you filled in.\nPress '" COL_LMAGENTA "S" COL_WHITE "' if you wish to change hostname, '" COL_LMAGENTA "D" COL_WHITE "' to change directory and '" COL_LMAGENTA "F" COL_WHITE "' for \nfile name."); print("\nPress '" COL_LMAGENTA "Q" COL_WHITE "' to quit without saving.\n"); print("Press" COL_LMAGENTA " [Enter]" COL_WHITE " or any other key to accept current data."); yn := input_ch(CINPUT_DISPLAY | CINPUT_PROMPT, COL_WHITE "\n\nDo you wish to change something ?"); if (yn <> 'S' and yn <> 'D' and yn <> 'F' and yn <> 'Q') goto ok; if (yn= 'S') { leggi_dati(1); goto isok; } else if (yn= 'D') { leggi_dati(2); goto isok; } else if (yn= 'F') { leggi_dati(3); goto isok; } else if (yn= 'Q') { cls(); print(COL_LRED "\nBack-Ftp ABORTED."); goto the_end; } ok: cls(); prepara_dat(sito,dir,file); print(COL_YELLOW "\n\nBack-Ftp OK." COL_WHITE); print("\nYour request has been saved.\nYou will find the reqeusted file in your personal userdir, " COL_GREEN,userarea,COL_WHITE "."); print("\nYou will be also notified with a Matrix (Netmail) message, informing you'"); print("\nabout the log of the ftp session."); print(COL_LBLUE "\n\n\t\t",prm_string(PRM_SYSNAME), "'s Back-Ftp"); grt := input_ch(CINPUT_PROMPT, COL_WHITE "\n\n Press a key"); the_end: return 0; }