home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / backftpb.zip / backftp.ita < prev    next >
Text File  |  1996-04-17  |  5KB  |  212 lines

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // File: Backftp.mex (ITALIAN VERSION: rename to backftp.mex)
  4. //
  5. // Desc: Back Ftp for Maximus 3.0
  6. //
  7. // Copyright 1995-1996 Alberto Velo
  8. //
  9. //
  10. //////////////////////////////////////////////////////////////////////////////
  11.  
  12. #include <max.mh>
  13. #include <prm.mh>
  14.  
  15. string: sito,dir,file,userarea,cfg,fftp;
  16. int: ld, haspaid,error;
  17. #define cfg "backftp.usr"  // must be in MAX directory !
  18. #define fftp "backftp.dat" // in Max dir
  19.  
  20. void cls()
  21. {
  22. print ("\f\n" COL_YELLOWONBLUE " --- Back-Ftp for Maximus 3.0 --- \n");
  23. print ("       (c) Alberto Velo, 1995     \n" COL_WHITE);
  24. }
  25.  
  26. int need_money()
  27. {
  28. string: key;
  29. int: nkey, i;
  30. char: c;
  31.  
  32. print("\nCiao, " COL_YELLOW, usr.name);
  33. print(COL_WHITE "\n\nUn attimo: controllo il tuo account...");
  34. key:= usr.xkeys;
  35. nkey:= strlen(key);
  36.  
  37. for (i := 1; i < (nkey+1); i := i + 1)
  38.     {
  39.     c:= key[i];
  40.     if (c = 'X') haspaid := 1;
  41.     }
  42.  
  43. if (haspaid <> 1) {
  44.     print(COL_LRED "\n\n\aERRORE! Non sei abilitato all'uso del Back-Ftp !");
  45.     print("\nQuesto servizio e' riservato agli utenti abbonati.");
  46.     return (haspaid);
  47.     }
  48. print("\nLivello 1: utente abilitato...");
  49. }
  50.  
  51. int area()
  52. {
  53. int: file,ln,pos,i,area;
  54. string: linea,nome,dir,user;
  55. user:= usr.name;
  56. file:= fileexists(cfg);
  57.  
  58. if (file <> 1) return (error:=1);
  59. file:= open(cfg, IOPEN_READ);
  60.  
  61. do
  62. {
  63.      ln:= readln(file,linea);
  64.  for (pos := stridx (linea, pos, '=');
  65.       pos;
  66.       pos := stridx (linea, pos+1, '='))
  67.  {
  68.  i := strfind(linea,user);
  69.  if (i > 0){
  70.      print("\nLivello 2: utente abilitato...");
  71.     dir:=  strtrim(substr(linea, pos+1,strlen(linea))," ");
  72.     goto eof;
  73.     }
  74.  }
  75. }
  76. while (ln >= 0);
  77.  
  78. return (error:=1); //Utente non presente in backftp.usr
  79.  
  80. eof:
  81. userarea:= "USER." + dir;
  82. if (area:= fileareaselect(userarea) <> 1) return(error:=2);  // Area misconfigured
  83. print(COL_GREEN "\n\nLa tua area personale e': " COL_LGREEN,userarea);
  84. print(COL_GREEN "\nIn quell'area riceverai i files prelevati in ftp.\n");
  85. }
  86.  
  87. int leggi_dati(int: ld)
  88. {
  89. if (ld=0) 
  90.     {
  91.     input_str(sito,INPUT_NLB_LINE,0,0,COL_WHITE "\nInserisci il sito: " COL_YELLOW);
  92.     input_str(dir,INPUT_NLB_LINE,0,0,COL_WHITE "\nInserisci la directory: " COL_YELLOW);
  93.     input_str(file,INPUT_NLB_LINE,0,0,COL_WHITE "\nInserisci il file: " COL_YELLOW);
  94.     }
  95. else if (ld=1)
  96.     {
  97.     input_str(sito,INPUT_NLB_LINE,0,0,COL_WHITE "\nInserisci il sito: " COL_YELLOW);
  98.     }
  99. else if (ld=2)
  100.     {
  101.     input_str(dir,INPUT_NLB_LINE,0,0,COL_WHITE "\nInserisci la directory: " COL_YELLOW);
  102.     }
  103. else if (ld=3)
  104.     {
  105.     input_str(file,INPUT_NLB_LINE,0,0,COL_WHITE "\nInserisci il file: " COL_YELLOW);
  106.     }
  107. }
  108.  
  109.  
  110. int prepara_dat(string: sito, string: dir, string: gfile)
  111. {
  112. string: user,localdir;
  113. int: file,dat;
  114. localdir:= farea.downpath;
  115. user:=usr.name;
  116. dat:= fileexists(fftp);
  117. if (dat=1)
  118.     {
  119.     file:= open(fftp, IOPEN_WRITE | IOPEN_APPEND);
  120.     }
  121. else    {
  122.     file:= open(fftp, IOPEN_WRITE | IOPEN_CREATE);
  123.     }
  124.  
  125. writeln(file,"<");
  126. writeln(file,user);
  127. writeln(file,localdir);
  128. writeln(file,sito);
  129. writeln(file,dir);
  130. writeln(file,gfile);
  131. writeln(file,">");
  132. }
  133.  
  134. int main()
  135. {
  136. char: yn, grt;
  137. string: localdir;
  138. cls();
  139. need_money();
  140. if (haspaid <> 1) goto the_end;
  141. area();
  142. if (error = 1 or error=2) {
  143.     print(COL_LRED "\n\nERRORE n. ",error," : utente non abilitato.");
  144.     print("\nContatta il SysOp, segnalando il codice d'errore ottenuto.");
  145.     goto the_end;
  146.     }
  147.  
  148. insert:
  149. leggi_dati(ld);
  150.  
  151. if (strlen(sito) = 0) 
  152.     { print(COL_LRED "\nDEVI dirmi dove prendere il file!\n");
  153.     ld:=1;    
  154.     goto insert;
  155.     }
  156. if (strlen(file) = 0) 
  157.     { print(COL_LRED "\nDEVI dirmi il nome del file!\n");
  158.     ld:=3;
  159.     goto insert;
  160.     }
  161.  
  162. isok:
  163. cls();
  164. print("\n\nHai richiesto un ftp per: ");
  165. print(COL_WHITE "\n\nSito      :" COL_YELLOW, sito);
  166. print(COL_WHITE "\nDirectory :" COL_YELLOW, dir);
  167. print(COL_WHITE "\nFile      :" COL_YELLOW, file);
  168.  
  169. print(COL_WHITE "\n\nQuesti sono i dati inseriti.\nPer cambiare il nome del sito premi '" COL_LMAGENTA "S" COL_WHITE "', '" COL_LMAGENTA "D" COL_WHITE "' per la directory e '" COL_LMAGENTA "F" COL_WHITE "' per il file.");
  170. print("Premi '" COL_LMAGENTA "Q" COL_WHITE "' per uscire senza salvare.\n");
  171. print("Premi" COL_LMAGENTA " [Enter]" COL_WHITE " o qualsiasi altro tasto per accettare i dati correnti.");
  172. yn := input_ch(CINPUT_DISPLAY | CINPUT_PROMPT, COL_WHITE "\n\nVuoi cambiare qualcosa ?");
  173.  
  174. if (yn <> 'S' and yn <> 'D' and yn <> 'F' and yn <> 'Q') goto ok;
  175. if (yn= 'S') 
  176.     {
  177.     leggi_dati(1);
  178.     goto isok;
  179.     }
  180. else if (yn= 'D') 
  181.     {
  182.     leggi_dati(2);
  183.     goto isok;
  184.     }
  185. else if (yn= 'F') 
  186.     {
  187.     leggi_dati(3);
  188.     goto isok;
  189.     }
  190. else if (yn= 'Q') 
  191.     {
  192.     cls();
  193.     print(COL_LRED "\nBack-Ftp ABORTED.");
  194.     goto the_end;
  195.     }
  196.  
  197. ok:
  198. cls();
  199. prepara_dat(sito,dir,file);
  200.  
  201. print(COL_YELLOW "\n\nBack-Ftp OK." COL_WHITE);
  202. print("\nLa tua richiesta e' stata inoltrata correttamente. \nTroverai il file richiesto nella tua area personale, " COL_GREEN,userarea,COL_WHITE ".");
  203. print("\nRiceverai inoltre un messaggio in area Matrix (Netmail), che ti informera'");
  204. print("\ndell'arrivo del file richiesto, o del motivo del mancato arrivo.");
  205. print(COL_LBLUE "\n\n\t\t",prm_string(PRM_SYSNAME), "'s Back-Ftp");
  206.  
  207. grt := input_ch(CINPUT_PROMPT, COL_WHITE "\n\n   Premi un tasto");
  208.  
  209. the_end:
  210. return 0;
  211. }
  212.