home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / telecomm / storm100 / cis.bas < prev    next >
BASIC Source File  |  1993-11-03  |  4KB  |  173 lines

  1. 'Fancy CIS logon script
  2. 'Stores ID and password in STORM.INI file in [CompuServe] section
  3. 'Password
  4. Loop:
  5. FAST ON
  6. UserID$ = SET$("STORM","CompuServe","ID")
  7. temp$ = SET$("STORM","CompuServe","Password")
  8. Password$ = ""
  9. 'Basic glitch, FOR loop will always be executed once!
  10. 'So check length first
  11. IF LEN(temp$) > 0 THEN
  12.     FOR x = 1 TO LEN(temp$)
  13.         Password$ = Password$ + CHR$( ASC( MID$(temp$,x,1)) XOR 255)
  14.     NEXT x
  15. ENDIF
  16. IF LEN(UserID$) = 0 OR LEN(Password$) = 0 THEN
  17.     GOSUB Setup
  18.     IF LEN(UserID$) = 0 OR LEN(Password$) = 0 THEN
  19.         GOTO Loop
  20.     ELSE
  21.         PRINT "Setup Complete"
  22.         PRINT "Thank you"
  23.         PRINT "========="
  24.         END
  25.     ENDIF
  26. ENDIF
  27. Tries = 7
  28. ETX$ = CHR$(3)
  29. CompuServeHost$ = "CIS" + CHR$(13)
  30. FailStr$ = ""
  31. FirstTry = -1
  32. '
  33. TOPW 1
  34. TERM OFF :'Ensure don't miss anything
  35. FAST OFF
  36. PAUSE 2
  37. SEND ETX$;
  38. '
  39. StartConnect:
  40. IF Tries = 0 THEN CIS_Failure
  41.     Tries = Tries - 1
  42. '
  43. Connect_Wait:
  44. WAIT 80,"UIC:","Host Name:","User ID:","Password:"
  45. ON WAIT(0) GOTO Send_ETX,Send_Host_Name,Send_ID,Send_Password
  46. GOTO Send_CR
  47. '
  48. Send_CR:
  49.     SEND CHR$(13)
  50. GOTO Connect_Wait
  51. '
  52. Send_Host_Name:
  53.     SEND CompuServeHost$
  54. GOTO Connect_Wait
  55. '
  56. Send_ID:
  57.     PRINT "Logging onto CompuServe"
  58.     SEND UserID$ + "\" + Password$
  59. GOTO Logon_Wait
  60. '
  61. Send_Password:
  62.     SEND Password$
  63. '
  64. Logon_Wait:
  65. WAIT 60,"CompuServe", CHR$(6),"? LOG","?? LOG"," NTW"
  66. ON WAIT(0) GOTO Success,Success,Log_Msg,Log_Msg,Logon_Failure
  67. GOTO Cis_Failure
  68. '
  69. Log_Msg:
  70. WAIT 50,"INE","ISX","SIL","SIU","SNA","STU","INS"
  71. ON WAIT(0) GOTO Bad_ID,Bad_ID_Syntax,System_NA,System_NA,System_NA,System_NA,Invalid_Switch
  72. GOTO Try_Again
  73. '
  74. Bad_ID:
  75.     FailStr$ = "Incorrect user ID or password"
  76. GOTO Try_Again
  77. '
  78. Bad_ID_Syntax:
  79.     FailStr$ = "Incorrect user ID syntax"
  80. GOTO Try_Again
  81. '
  82. System_Unavailable:
  83.     FailStr$ = "The system is unavailable, try again later"
  84. GOTO CIS_Failure
  85. '
  86. Invalid_Switch:
  87.     FailStr$ = "Invalid Switch"
  88. 'fall through to Try_again
  89. Try_Again:
  90. IF NOT FirstTry THEN CIS_Failure
  91.     SEND ETX$;
  92.     FirstTry = 0
  93. '
  94. WAIT 30,"User ID"
  95. IF WAIT(0) = 1 THEN Send_ID ELSE CIS_Failure
  96. '
  97. Logon_Failure:
  98.     PRINT "Remote is busy or unavailable"
  99.     TOPW 3
  100.     END
  101. '
  102. CIS_Failure:
  103.     PRINT FailStr$
  104.     TOPW 3
  105.     END
  106. '
  107. Success:
  108. PRINT "Logged on!"
  109. END
  110. 'First time setup for CompuServe
  111. Setup:
  112. TOPW 3:CLS :PRINT "Welcome to Storm's CompuServe Setup Script"
  113. PRINT "==========================================":PRINT
  114. IF LEN(UserID$) > 0 THEN GetPassword
  115. RepeatID:
  116. PRINT
  117. PRINT "Please enter your User ID";
  118. 'Require LINE INPUT since ID contains a comma!
  119. LINE INPUT UserID$
  120. GOSUB ValidateID
  121. IF LEN(UserID$) = 0 THEN RepeatID
  122. 'Since ID was absent, assume password was as well
  123. IF BadBoy THEN PRINT "Thank you for cooperating"
  124. GetPassword:
  125. PRINT
  126. PRINT "Please enter your password";
  127. LINE INPUT Password$
  128. IF LEN(Password$) = 0 THEN RepeatPassword
  129. temp$ = ""
  130. 'Simple hack to encrypt password
  131. 'Turns it into unreadable graphics/foreign characters
  132. FOR x = 1 TO LEN(Password$)
  133.     temp$ = temp$ + CHR$( ASC( MID$(Password$,x,1)) XOR 255)
  134. NEXT x
  135. PRINT "Your User ID is ";UserID$
  136. PRINT "Your Password is ";Password$
  137. PRINT "Is that correct (Y/N)"
  138. INPUT confirm$
  139. confirm$ = UCASE$( LEFT$(confirm$,1))
  140. IF confirm$ <> "Y" THEN RepeatID
  141. SET "STORM","CompuServe","Password",temp$
  142. SET "STORM","CompuServe","ID",UserID$
  143. RETURN
  144. 'Validate by looking for a single comma and the rest digits
  145. 'Another way would be by using the VAL function
  146. 'e.g. VAL("72227,3507") is 72227.
  147. 'I presume there is an extreme lower and upper limit for
  148. 'all possible PPN's.
  149. ValidateID:
  150.     IF LEN(UserID$) = 0 THEN RETURN
  151.     IF INSTR(UserID$,",") = 0 THEN GOSUB BadID:RETURN
  152.     ComCount = 0
  153.     FOR x = 1 TO LEN(UserID$)
  154.         x$ = MID$(UserID$,x,1)
  155.         IF NOT ISDIGIT(x$) THEN
  156.             IF x$ <> "," THEN
  157.                 GOSUB BadID
  158.                 RETURN
  159.             ELSE
  160.                 ComCount = ComCount + 1:'Can only have one!
  161.                 IF ComCount > 1 THEN GOSUB BadID:RETURN
  162.             ENDIF
  163.         ENDIF
  164.     NEXT x
  165. RETURN
  166. BadID:
  167. PRINT "[";UserID$;"] is not a valid CompuServe ID"
  168. PRINT "I wish you would be more cooperative":PRINT
  169. BadBoy = 1
  170. UserID$ = ""
  171. RETURN
  172.  
  173.