home *** CD-ROM | disk | FTP | other *** search
/ .net 1999 December / netCD65.iso / pc / Software / VirtualA / 32bit / vasetup.exe / %MYDIR% / Hmisysop.ebs < prev    next >
Encoding:
Text File  |  1999-10-06  |  63.0 KB  |  1,898 lines

  1. 'T:HMISYSOP.EBS for CompuServe
  2. ' VA 4.52 release
  3.  
  4. Type MsgStatSummary
  5.     element As Integer
  6.     threads As Long
  7.     messages As Long
  8.     percentage As Double
  9.     ttotal As Long
  10.     mtotal As Long
  11. End Type
  12.  
  13. 'T:iFlags for CompuServe (constant)
  14. Const IM_SPECIAL = 128              ' My special msg format
  15. Const IM_DELETE = 2048              ' Delete scratchpad file afterwards?
  16. Const IM_MARKUNREAD = 131072
  17.  
  18. Const FAP_MAX_SECTIONS% = 24
  19.  
  20. Const HMI_STATE_FIRST% = 0
  21. Const HMI_STATE_NEXT% = HMI_STATE_FIRST + 1
  22. Const HMI_STATE_ABORT% = HMI_STATE_NEXT + 1
  23.  
  24. Const FAP_USF_HIGH_MSG% = &H2
  25. Const FAP_USF_NAME% = &H4
  26. Const FAP_USR_JOIN% = &H1
  27. Const FAP_USR_PERMANENT% = &H2
  28. Const FAP_WAITING_MSGS% = &H1
  29. Const FAP_NEW_BULLETINS% = &H2
  30. Const FAP_CONFERENCE_IN_PROGRESS% = &H4
  31. Const FAP_NOT_A_MEMBER% = &H8
  32. Const FAP_IS_SYSOP% = &H10        ' user is SYSOP in this Forum
  33. Const FAP_FREE_USER% = &H20
  34. Const FAP_LOCKED_OUT% = &H40
  35. Const FAP_TRANSACTION_BILLING% = &H80
  36. Const FAP_ALLOW_MULTIPLE_SEARCH% = &H100
  37. Const FAP_NISA_FORUM% = &H200
  38.  
  39. ' SysOp Alert Flags
  40. Const FAP_LIBRARIES_FULL% = &H1
  41. Const FAP_MERGE_IS_SCHEDULED% = &H2
  42. Const FAP_MERGE_FAILED% = &H4
  43. Const FAP_MERGE_ALLOWED% = &H8
  44. Const FAP_MERGE_IS_RUNNING% = &H10
  45. Const FAP_SET_PRICES% = &H40
  46. Const FAP_MSG_SYSOP% = &H400
  47. Const FAP_CONF_SYSOP% = &H800
  48. Const FAP_EDIT_SYSOP% = &H1000
  49. Const FAP_LIB_SYSOP% = &H2000
  50. Const FAP_MEMBER_SYSOP% = &H4000
  51. Const FAP_PRIMARY_SYSOP% = &H8000
  52.  
  53. ' Modify Message/Thread Request Options
  54. Const FAP_MM_KEEP% = &H1       ' copy to a new thread, living original
  55.              ' unchanged, only for a message
  56. Const FAP_MM_PRIVATE% = &H4
  57. Const FAP_MM_HOLD% = &H10
  58.  
  59. ' Modify Message/Thread Request Components
  60. Const FAP_MMC_CHANGE_SUBJECT% = &H1
  61. Const FAP_MMC_CHANGE_RECIPIENT% = &H4     ' only for Message
  62. Const FAP_MMC_CHANGE_SECTION_ID% = &H20
  63. Const FAP_MMC_CHANGE_EXPIRATION% = &H80
  64.  
  65. ' Delete Messages Response reason flags:
  66. ' typedef enum FAPDELMSGREASON
  67. Const FAP_DM_MESSAGE_NOT_FOUND% = 0
  68. Const FAP_DM_MESSAGE_IS_HELD% = FAP_DM_MESSAGE_NOT_FOUND + 1
  69. Const FAP_DM_INVALID_ADDRESS% = FAP_DM_MESSAGE_IS_HELD + 1
  70. Const FAP_DM_NOT_AUTHORIZED% = FAP_DM_INVALID_ADDRESS + 1
  71.  
  72. ' Forward Messages Options flags:
  73. Const FAP_FM_SEND_TO_DIFFERENT% = &H1
  74. Const FAP_FM_DELETE_ORIGINAL% = &H2
  75.  
  76. ' Merge Thread Request Options
  77. Const FAP_MS_MERGE_AS_REPLY = &H1
  78.  
  79. Const FAP_MC_THREAD_ID% = &H1000
  80. Const FAP_MC_THREADS% = &H8000
  81.  
  82. ' The Sections bit flag values
  83. Const FAP_SECT_PRIVATE% = &H1
  84. Const FAP_SECT_READ_ONLY% = &H2
  85. Const FAP_SECT_VISITOR% = &H4
  86. Const FAP_SECT_SELECTED% = &H80
  87.  
  88. ' Member Directory Components flags
  89. Const FAP_MDC_USER_NAME% = &H1
  90. Const FAP_MDC_USER_ID% = &H2
  91. Const FAP_MDC_INTERESTS% = &H4
  92. Const FAP_MDC_AUXILIARY_DATA% = &H8
  93. Const FAP_MDC_FLAGS% = &H10
  94. Const FAP_MDC_SECTIONS% = &H20
  95. Const FAP_MDC_SYSOP_SECTIONS% = &H40
  96. Const FAP_MDC_LAST_ACCESS% = &H80
  97. Const FAP_MDC_DATE_JOINED% = &H100
  98.  
  99. ' Member Directory Search types
  100. ' enum FAPMDSTYPES
  101. Const FAP_MDS_ALL% = 0
  102. Const FAP_MDS_NAME% = FAP_MDS_ALL + 1
  103. Const FAP_MDS_USER_ID% = FAP_MDS_NAME + 1
  104. Const FAP_MDS_INTERESTS% = FAP_MDS_USER_ID + 1
  105. Const FAP_MDS_AUXILIARY_DATA% = FAP_MDS_INTERESTS + 1
  106. Const FAP_MDS_MSG_SECTION_ACCESS% = FAP_MDS_AUXILIARY_DATA + 1          ' Pattern is string of 24 ASCII
  107. Const FAP_MDS_LIB_SECTION_ACCESS% = FAP_MDS_MSG_SECTION_ACCESS + 1  ' '0' or '1' characters (0x30 and
  108. Const FAP_MDS_CONF_SECTION_ACCESS% = FAP_MDS_LIB_SECTION_ACCESS + 1 ' 0x31 where 0 indicates no access,
  109. Const FAP_MDS_MSG_SYSOP_ACCESS% = FAP_MDS_CONF_SECTION_ACCESS + 1          ' 1 indicates access
  110. Const FAP_MDS_LIB_SYSOP_ACCESS% = FAP_MDS_MSG_SYSOP_ACCESS + 1          ' First chracter corresponds to
  111. Const FAP_MDS_CONF_SYSOP_ACCESS% = FAP_MDS_LIB_SYSOP_ACCESS + 1     ' section 0
  112. Const FAP_MDS_LAST_VISIT% = FAP_MDS_CONF_SYSOP_ACCESS + 1
  113. Const FAP_MDS_DATE_JOINED% = FAP_MDS_LAST_VISIT + 1
  114. Const FAP_MDS_SYSOP_TYPE% = FAP_MDS_DATE_JOINED + 1
  115. Const FAP_MDS_LAST_UPDATED% = FAP_MDS_SYSOP_TYPE + 1
  116.  
  117. ' Modify Member Record Request Components
  118. Const FAP_MDM_USER_NAME% = &H1
  119. Const FAP_MDM_FLAGS% = &H2
  120. Const FAP_MDM_UPDATE_MSG_ACCESS% = &H4
  121. Const FAP_MDM_UPDATE_LIB_ACCESS% = &H8
  122. Const FAP_MDM_UPDATE_CONF_ACCESS% = &H10
  123. Const FAP_MDM_UPDATE_MSG_SYSOP% = &H20
  124. Const FAP_MDM_UPDATE_LIB_SYSOP% = &H40
  125. Const FAP_MDM_UPDATE_CONF_SYSOP% = &H80
  126. Const FAP_MDM_AUXILIARY_DATA% = &H100
  127.  
  128. ' Member Directory Flags
  129. Const FAP_MDF_LOCK_OUT% = &H1
  130. Const FAP_MDF_FREE_USER% = &H20
  131. Const FAP_MDF_SUPPORT_PERSONNEL% = &H80
  132. Const FAP_MDF_KEY_ACCOUNT% = &H100
  133. Const FAP_MDF_WIZOP% = &H200
  134. Const FAP_MDF_MSG_SYSOP% = &H400
  135. Const FAP_MDF_CONF_SYSOP% = &H800
  136. Const FAP_MDF_EDIT_SYSOP% = &H1000
  137. Const FAP_MDF_LIB_SYSOP% = &H2000
  138. Const FAP_MDF_MEMBER_SYSOP% = &H4000
  139.  
  140. ' Delete Members Response
  141. ' typedef enum FAPDELMEMBERREASON
  142. Const FAP_DMB_UNSPECIFIED% = 0
  143. Const FAP_DMB_MEMBER_NOT_FOUND% = FAP_DMB_UNSPECIFIED% + 1
  144. Const FAP_DMB_OPERATOR_FAILURE% = FAP_DMB_MEMBER_NOT_FOUND% + 1
  145. Const FAP_DMB_NOT_AUTHORISED% = FAP_DMB_OPERATOR_FAILURE% + 1
  146.  
  147. ' Send Announcement Request Types of description
  148. ' typedef enum FAPANNOUNCTYPES
  149. Const FAP_SA_DESC_MSG% = 0
  150. Const FAP_SA_DESC_LIB% = FAP_SA_DESC_MSG + 1
  151. Const FAP_SA_DESC_CON% = FAP_SA_DESC_LIB + 1
  152. Const FAP_SA_BULLETIN% = FAP_SA_DESC_CON + 1
  153.  
  154. '+-----------+
  155. '| Bulletins |
  156. '+-----------+
  157. ' enum FAPBULLETINS
  158. Const FAP_BULLETIN_SHORT% = 1
  159. Const FAP_BULLETIN_REGULAR% = FAP_BULLETIN_SHORT + 1
  160. Const FAP_BULLETIN_CONFERENCE% = FAP_BULLETIN_REGULAR + 1
  161. Const FAP_BULLETIN_LIBRARY% = FAP_BULLETIN_CONFERENCE + 1
  162. Const FAP_BULLETIN_MEMBERSHIP% = FAP_BULLETIN_LIBRARY + 1
  163. Const FAP_BULLETIN_SYSOP% = FAP_BULLETIN_MEMBERSHIP + 1
  164. Const FAP_BULLETIN_NEW_MEMBER% = FAP_BULLETIN_SYSOP + 1
  165. Const FAP_BULLETIN_MESSAGES% = FAP_BULLETIN_NEW_MEMBER + 1
  166. Const FAP_BULLETIN_LOCKED_USER% = FAP_BULLETIN_MESSAGES + 1
  167. Const FAP_BULLETIN_ASCII_NEW_MEMBER% = FAP_BULLETIN_LOCKED_USER + 1
  168. Const FAP_BULLETIN_CLOSED_FORUM_ANNOUNCE% = FAP_BULLETIN_ASCII_NEW_MEMBER + 1
  169.  
  170. ' Search Types
  171. ' enum FAPSEARCHTYPES
  172. Const FAP_SFH_FILENAME% = 0
  173. Const FAP_SFH_USER_ID% = FAP_SFH_FILENAME + 1
  174. Const FAP_SFH_KEYWORD% = FAP_SFH_USER_ID + 1
  175. Const FAP_SFH_ACCESS_COUNT% = FAP_SFH_KEYWORD + 1
  176. Const FAP_SFH_DATE_RANGE% = FAP_SFH_ACCESS_COUNT + 1
  177. Const FAP_SFH_LAST_ACCESS_RANGE% = FAP_SFH_DATE_RANGE + 1
  178. Const FAP_SFH_FILE_ABSTRACT% = FAP_SFH_LAST_ACCESS_RANGE + 1
  179. Const FAP_SFH_FILE_BODY% = FAP_SFH_FILE_ABSTRACT + 1
  180. Const FAP_SFH_MATCH_NON_PUBLIC_ONLY% = FAP_SFH_FILE_BODY + 1
  181. Const FAP_SFH_SIZE_RANGE% = FAP_SFH_MATCH_NON_PUBLIC_ONLY + 1
  182. Const FAP_SFH_TITLE% = FAP_SFH_SIZE_RANGE + 1
  183. Const FAP_SFH_FILE_TYPES% = FAP_SFH_TITLE + 1
  184. Const FAP_SFH_DISPOSITION% = FAP_SFH_FILE_TYPES + 1
  185.  
  186. ' File Header Components bits
  187. Const FAP_FDC_FILENAME% = &H1
  188. Const FAP_FDC_USER_ID% = &H2
  189. Const FAP_FDC_FILE_TYPE% = &H4
  190. Const FAP_FDC_FILE_SIZE% = &H8
  191. Const FAP_FDC_TITLE% = &H10
  192. Const FAP_FDC_DATE_SUBMITTED% = &H20
  193. Const FAP_FDC_ACCESS_COUNT% = &H40
  194. Const FAP_FDC_KEYS% = &H80
  195. Const FAP_FDC_ABSTRACT% = &H100
  196. Const FAP_FDC_LIB_SECTION% = &H200
  197. Const FAP_FDC_USER_NAME% = &H400
  198. Const FAP_FDC_LAST_ACCESS% = &H800
  199. Const FAP_FDC_PRICE% = &H1000
  200. Const FAP_FDC_COMMENT% = &H2000
  201. Const FAP_FDC_EXPIRATION_DATE% = &H4000
  202. Const FAP_FDC_RELEASE_DATE% = &H8000
  203.  
  204. ' File Header Options
  205. Const FAP_FILE_DELETABLE% = &H1
  206. Const FAP_FILE_NON_PUBLIC% = &H2
  207. Const FAP_FILE_MARKED_FOR_DELETION% = &H4
  208. Const FAP_FILE_HAS_FEE% = &H8
  209.  
  210. ' Modify File Request Components
  211. Const FAP_MF_FILE_NAME% = &H1&
  212. Const FAP_MF_USER_ID% = &H2&
  213. Const FAP_MF_FILE_TYPE% = &H4&
  214. Const FAP_MF_TITLE% = &H10&
  215. Const FAP_MF_ACCESS_COUNT% = &H40&
  216. Const FAP_MF_KEYS% = &H80&
  217. Const FAP_MF_ABSTRACT% = &H100&
  218. Const FAP_MF_LIB_SECTION_ID% = &H200&
  219. Const FAP_MF_SET_FEE% = &H400&
  220. Const FAP_MF_COMMENT% = &H800&
  221. Const FAP_MF_EXPIRATION_DATE% = &H1000&
  222. Const FAP_MF_RELEASE_DATE% = &H2000&
  223. Const FAP_MF_TARGET_CATALOG_NO% = &H4000&
  224.  
  225. ' Modify File Request Options
  226. Const FAP_MO_COMMIT% = &H1
  227. Const FAP_MO_MAKE_CHANGES% = &H2
  228.  
  229. Const HMI_FT_UNSPECIFIED% = 0
  230. Const HMI_FT_TEXT% = 1
  231. Const HMI_FT_BINARY% = 2
  232. Const HMI_FT_IMAGE% = 3
  233. Const HMI_FT_RLE% = 4
  234. Const HMI_FT_NAPLPS% = 5
  235. Const HMI_FT_GIF% = 6
  236. Const HMI_FT_JPEG% = 7
  237. Const HMI_FT_ETO% = 8
  238. Const HMI_FT_HTML% = 9
  239. Const HMI_FT_PNG% = 10
  240.  
  241. Declare Function MakeDateString(s As HMITIMESTAMP) As String
  242. Declare Function HMIGotoForum(ByVal forum As String) As Boolean
  243. Declare Function UniqueFileName$
  244. Declare Function QueueFile(service As String, sfilename As String, queueflags As Long) As Boolean
  245. Declare Sub ReportSuccess(id As String)
  246. Declare Function StartCapture(pseudo As String)
  247. Declare Function SectionNumber(ByVal section As String)
  248. Declare Function MyDate$
  249. Declare Sub StartSysopLog(forum As String, msg As String)
  250. Declare Sub EndSysopLog()
  251. Declare Function FullErrorMessage() As String
  252. Declare Function ParseString(args As String, delim As String) As String
  253. Declare Function ReadMessageFile(filename As String, noformat As Integer) As String
  254. Declare Sub ReplaceAllInString(txt As String, search As String, replace As String)
  255. Declare Sub WriteLibraryMessage(forum As String, filedesc As FAPFILEDESCRIPTION, downloaded As String)
  256. Declare Function ParseSectionList(ByVal sect As String, ByVal validsects As Long, ByRef count As Integer) As Long
  257. Declare Function ParseSectionList1(ByVal sect As String, ByVal validsects As Long, ByRef count As Integer, ByRef mask As Long) As Long
  258. Declare Sub FetchMessageThread(id As String, forum As String, number As String, thr As Boolean)
  259. Declare Sub NewDownloadFile(id As String, forum As String, filename As String, pubavail As Boolean)
  260. Declare Sub AsciiListOfMailUsers(id as String, forum As String, TheDate as String, SendMailToUsers as String)
  261. Declare Sub AsciiWhoIs(id As String, forum As String, uid As String)
  262. Declare Sub AsciiListMembers(id As String, forum As String, list As String, info As String)
  263. Declare Sub GetMemberCount(id As String, forum As String)
  264. Declare Function Plural(l As Long) As String
  265.  
  266. Public WhereAmI As String                       'name of last forum/page etc
  267. Public FAPconfig As FAPCONFIG
  268. Public Sysop As Boolean                         'are we a sysop?
  269. Public szMsgSection() As FAPSECTIONENTRY, szLibSection() As FAPSECTIONENTRY
  270. Public Nisa As Boolean          'do we need to work round NISA "features" ?
  271. Public LastNisaForum As String
  272.  
  273. Dim sysopconfig As FAPSYSOPCONFIG
  274. Dim szFilesSections(FAP_MAX_SECTIONS%) As Long
  275. Dim LastAsciiForum As String
  276. Dim LastSectionList As String
  277. Dim szConfSection() As FAPSECTIONENTRY
  278. Dim AllMsgSects As Long, AllLibSects As Long, AllConfSects As Long
  279. Dim PublicMsgSects As Long, PublicLibSects As Long, PublicConfSects As Long
  280. Dim notime AS HMITIMESTAMP
  281.  
  282. Sub LogPrint(msg As String)
  283.     Terminal.Print msg & Basic.Eoln$
  284.     LogResult msg
  285. End Sub
  286.  
  287. 'Go to forum as Sysop
  288. 'If fails, return -1
  289. 'If ASCII, return 0
  290. 'If HMI, get sysop configuration, return 1
  291. Function SysopGotoForum(ByVal forum As String) As Integer
  292.  
  293.     ' Mangle the forum name a bit
  294.     forum = ParseString(forum, "/")
  295.  
  296.     If forum = LastAsciiForum Then
  297.         Terminal.Print "Forum " & forum & " is an ASCII forum" & Basic.Eoln$
  298.         SysopGotoForum = 0
  299.         Exit Function
  300.     End If
  301.     If Not HMIGotoForum(forum) Then
  302.         SysopGotoForum = -1
  303.         Exit Function
  304.     End If
  305.     If Sysop = 0 Then
  306.         LogPrint "You are not SYSOP of forum " & forum
  307.         SysopGotoForum = -1
  308.         Exit Function
  309.     End If
  310.     If (FAPconfig.wAlerts And FAP_NISA_FORUM%) = 0 Then 
  311.         Terminal.Print "Forum " & forum & " is an ASCII forum" & Basic.Eoln$
  312.         LastAsciiForum = forum
  313.         SysopGotoForum = 0
  314.         Exit Function
  315.     End If
  316.  
  317.     If LastNisaForum <> forum Then
  318.         FAPReadSysopConfig sysopconfig, szFilesSections(), ""
  319.         AllMsgSects = sysopconfig.svMsgSections
  320.         AllLibSects = sysopconfig.svLibSections
  321.         AllConfSects = sysopconfig.svConfSections
  322.         LogSysopConfig forum
  323.         LastNisaForum = forum
  324.     End If
  325.  
  326.     SysopGotoForum = 1
  327. End Function
  328.  
  329. Function SectionList(ByVal sectionvector As Long) As String
  330.     Dim s As String, i As Integer
  331.  
  332.     While sectionvector
  333.         If sectionvector And 1 Then 
  334.             If s > "" Then s = s + ", "
  335.             s = s & i
  336.         End If
  337.         i = i + 1
  338.         sectionvector = sectionvector \ 2
  339.     Wend
  340.     SectionList = s
  341. End Function
  342.  
  343. Sub LogSysopConfig(ByVal forum As String)
  344.     BeginSysopLog forum, "Forum information for " & forum
  345.     CaptureText Basic.Eoln$
  346.     If sysopconfig.wAlerts And FAP_LIBRARIES_FULL% Then CaptureLine "Libraries full"
  347.     If sysopconfig.wAlerts And FAP_MERGE_IS_SCHEDULED% Then CaptureLine "Merge is scheduled"
  348.     If sysopconfig.wAlerts And FAP_MERGE_FAILED% Then CaptureLine "Merge failed"
  349.     If sysopconfig.wAlerts And FAP_MERGE_ALLOWED% Then CaptureLine "Merge allowed"
  350.     If sysopconfig.wAlerts And FAP_MERGE_IS_RUNNING% Then CaptureLine "Merge is running"
  351.     If sysopconfig.wAlerts And FAP_SET_PRICES% Then CaptureLine "Set prices"
  352.     If sysopconfig.wAlerts And FAP_MSG_SYSOP% Then CaptureLine "Message sysop"
  353.     If sysopconfig.wAlerts And FAP_CONF_SYSOP% Then CaptureLine "Conference sysop"
  354.     If sysopconfig.wAlerts And FAP_EDIT_SYSOP% Then CaptureLine "Edit sysop"
  355.     If sysopconfig.wAlerts And FAP_LIB_SYSOP% Then CaptureLine "Library sysop"
  356.     If sysopconfig.wAlerts And FAP_MEMBER_SYSOP% Then CaptureLine "Member sysop"
  357.     If sysopconfig.wAlerts And FAP_PRIMARY_SYSOP% Then CaptureLine "Primary sysop"
  358.     CaptureLine "Message sections: " + SectionList(AllMsgSects)
  359.     CaptureLine "Library sections: " + SectionList(AllLibSects)
  360.     CaptureLine "Conference sections: " + SectionList(AllConfSects)
  361.     For i = 0 To FAP_MAX_SECTIONS%
  362.         If szFilesSections(i) Then 
  363.             CaptureLine "Library " & i & " has " & szFilesSections(i) & _
  364.                 " non-merged file" & Plural(szFilesSections(i))
  365.         End If
  366.     Next
  367.     CaptureLine "Merge time: " & MakeDateString(sysopconfig.tsMergeTime)
  368.     CaptureLine "Membership: " & sysopconfig.dwMembership
  369.     EndSysopLog
  370. End Sub
  371.  
  372. Sub ExtractPublicSections(szSection() As FAPSECTIONENTRY, PublicSects As Long)
  373.     Dim i As Integer, l As Long
  374.  
  375.     PublicSects = 0
  376.     For i = 0 To Ubound(szSection)
  377.         If (szSection(i).cFlag And FAP_SECT_PRIVATE%) = 0 Then
  378.             l = 2 ^ szSection(i).cID
  379.             PublicSects = PublicSects And l
  380.         End If
  381.     Next
  382. End Sub
  383.  
  384. Sub SysopCollectPublicSections()
  385.     Dim sctConf As FAPSECTIONS
  386.  
  387.     If LastSectionList = LastNisaForum Then Exit Sub
  388.  
  389.     FAPReadConfSections sctConf, szConfSection()
  390.     ExtractPublicSections szMsgSection(), PublicMsgSects
  391.     ExtractPublicSections szLibSection(), PublicLibSects
  392.     ExtractPublicSections szConfSection(), PublicConfSects
  393.     LastSectionList = LastNisaForum
  394. End Sub
  395.  
  396. Sub BeginSysopLog(ByVal forum As String, msg As String)
  397.     StartSysopLog forum, msg
  398.     Terminal.Print msg & Basic.Eoln$
  399. End Sub
  400.  
  401. Sub SysopLog (msg As String)
  402.     CaptureText msg + Basic.Eoln$
  403.     Terminal.Print msg & Basic.Eoln$
  404.     LogResult msg
  405. End Sub
  406.  
  407. 'T:HMISysopModSecSub (subroutine) (CompuServe)
  408. 'Changes subject and section of a message all in one go
  409. Sub HMISysopModSecSub(id As String, forum As String, num As String, section As String, subject As String)
  410.     On Error Goto HMISysopModSecSub_error
  411.  
  412.     section = SectionNumber("/"+section)
  413.     Select Case SysopGotoForum(forum)
  414.     Case -1
  415.         Goto HMISysopModSecSub_fail
  416.     Case 0
  417.         If subject="" THen
  418.             SysopModify id, forum, num, section
  419.         Else
  420.             SysopModSecSub id, forum, num, section, subject
  421.         End If
  422.         Exit Sub
  423.     End Select
  424.  
  425.     subject = Left$(subject, 24)
  426.  
  427.     BeginSysopLog forum, "Modify section: "+forum+" thread #"+num+" to section "+section +" new subject: "+subject
  428.  
  429.     If FAPModifyMsg (val(num), 0, FAP_MMC_CHANGE_SECTION_ID% Or FAP_MMC_CHANGE_SUBJECT%, subject, "", "", val(section), notime) = 0 Then
  430.         Goto HMISysopModSecSub_fail
  431.     End If
  432.  
  433.     EndSysopLog
  434.     ReportSuccess id & " : Message #" & num & " New Section #" & section & " New subject " & subject
  435.     FetchMessageThread "", forum, num, True
  436.     Exit Sub
  437.  
  438. HMISysopModSecSub_error:
  439.     SysopLog "Error:" & FullErrorMessage
  440. HMISysopModSecSub_fail:
  441.     SysopLog "Unable to modify section: "+forum+" thread #"+num+" to section "+section +" new subject: "+subject
  442.     EndSysopLog
  443. End Sub
  444.  
  445. Function HMIGetThreadID(num As String) As Long
  446.     Dim hdr As FAPMSGHEADER
  447.  
  448.     On Error Resume Next
  449.     Terminal.Print "Obtaining thread ID for message " & num & Basic.Eoln$
  450.     FAPReadMsgHeader hdr, Val(num), FAP_MC_THREAD_ID%
  451.     HMIGetThreadID = hdr.dwThreadID
  452.     If hdr.dwThreadID = 0 Then
  453.         SysopLog "Cannot find message " + num
  454.     Else
  455.         Terminal.Print "Thread ID is " & hdr.dwThreadID & Basic.Eoln$
  456.     End If
  457. End Function
  458.  
  459. 'T:HMISysopHold (subroutine) (CompuServe)
  460. Sub HMISysopHold(id As String, forum As String, num As String, onoff As String, what As String)
  461.     Dim cOptions As Integer, result As Integer, threadid As Long
  462.  
  463.     On Error Goto HMISysopHold_error
  464.  
  465.     Select Case SysopGotoForum(forum)
  466.     Case -1
  467.         Goto HMISysopHold_fail
  468.     Case 0
  469.         SysopHold id, forum, num, onoff, what
  470.         Exit Sub
  471.     End Select
  472.  
  473.     BeginSysopLog forum, "Hold/unhold: "+forum+" "+what+" #"+num+" to "+onoff
  474.  
  475.     Select Case onoff
  476.     Case "ON"
  477.         cOptions = FAP_MM_HOLD%
  478.     Case "OFF"
  479.         cOptions = 0
  480.     Case Else
  481.         SysopLog "Invalid command"
  482.         Goto HMISysopHold_fail
  483.     End Select
  484.  
  485.     Select Case what
  486.     Case "Message"
  487.         result = FAPModifyMsg (val(num), cOptions, 0, "", "", "", 0, notime)
  488.         FetchMessageThread "", forum, num, False
  489.     Case "Thread"
  490.         'This is probably wrong - you really need to retrieve
  491.         'the thread map, and do FAPModifyMessage on each message in it!
  492.         threadid = HMIGetThreadID(num)
  493.         If threadid = 0 Then Goto HMISysopHold_fail
  494.         result = FAPModifyThread (threadid, cOptions, 0, "", 0, notime)
  495.         FetchMessageThread "", forum, num, True
  496.     Case "All"
  497.         threadid = HMIGetThreadID(num)
  498.         If threadid = 0 Then Goto HMISysopHold_fail
  499.         result = FAPModifyThread (threadid, cOptions, 0, "", 0, notime)
  500.         FetchMessageThread "", forum, num, True
  501.     Case Else
  502.         SysopLog "Invalid command"
  503.         Goto HMISysopHold_fail
  504.     End Select
  505.  
  506.     If result = 0 Then Goto HMISysopHold_fail
  507.  
  508.     EndSysopLog
  509.  
  510.     ReportSuccess id & " : Hold/unhold: " & forum & " " & what & " #" & num & " to " & onoff & " "
  511.     Exit Sub
  512.  
  513. HMISysopHold_error:
  514.     SysopLog "Error:" & FullErrorMessage
  515. HMISysopHold_fail:
  516.     SysopLog "Unable to hold/unhold "+forum+" #"+num+" to "+what+" "+onoff
  517.     EndSysopLog
  518. End Sub
  519.  
  520. 'T:HMISysopFMB (subroutine) (CompuServe)
  521. Sub HMISysopFMB(id As String, forum As String, num As String, userid As String, _
  522.     priv As String, asnew As String, subject As String, section As String)
  523.     Dim cOption As Integer, cComponents As Integer
  524.     Dim uname As String, uid As String
  525.  
  526.     On Error Goto HMISysopFMB_error
  527.  
  528.     section = SectionNumber("/S"+section)
  529.     Select Case SysopGotoForum(forum)
  530.     Case -1
  531.         Goto HMISysopFMB_fail
  532.     Case 0
  533.         SysopFMB id, forum, num, userid, priv, asnew, subject, section
  534.         Exit Sub
  535.     End Select
  536.  
  537.     BeginSysopLog forum, "Forward message: "+forum+" #"+num+" to "+userid
  538.  
  539.     subject = Left$(subject, 24)
  540.  
  541.     cOptions = 0
  542.     cComponents = 0
  543.     If priv = "y" Then 
  544.         cOptions = cOptions Or FAP_MM_PRIVATE%
  545.         SysopLog "Setting private flag"
  546.     End If
  547.     If asnew = "y" Then 
  548.         cOptions = cOptions Or FAP_MM_KEEP%
  549.         SysopLog "Setting Keep flag"
  550.     End If
  551.     If userid > "" Then 
  552.         cComponents = cComponents Or FAP_MMC_CHANGE_RECIPIENT%
  553.         AnalyseName userid, uname, uid
  554.         SysopLog "Changing recipient to name: '" & uname & "' id: '" & uid & "'"
  555.     End If
  556.     If subject > "" Then 
  557.         cComponents = cComponents Or FAP_MMC_CHANGE_SUBJECT%
  558.         SysopLog "Changing subject to '" & subject & "'"
  559.     End If
  560.     If section > "" Then 
  561.         cComponents = cComponents Or FAP_MMC_CHANGE_SECTION_ID%
  562.         SysopLog "Changing section to " & section
  563.     End If
  564.  
  565.     If FAPModifyMsg (val(num), cOptions, cComponents, subject, uname, uid, val(section), notime) = 0 Then
  566.         Goto HMISysopFMB_fail
  567.     End If
  568.  
  569.     EndSysopLog
  570.  
  571.     ReportSuccess id & " : Forward message " & forum & " #" & num & " to " & userid & " "
  572.     Exit Sub
  573.  
  574. HMISysopFMB_error:
  575.     SysopLog "Error:" & FullErrorMessage
  576. HMISysopFMB_fail:
  577.     SysopLog "Unable to forward message #"+num+" to "+userid
  578.     EndSysopLog
  579. End Sub
  580.  
  581. 'T:HMISysopFMB1 (subroutine) (CompuServe)
  582. Sub HMISysopFMB1(id As String, forum As String, num As String, _
  583.                  userid As String, priv As String)
  584.     HMISysopFMB id, forum, num, userid, priv, "", "", ""
  585. End Sub
  586.  
  587. 'T:HMISysopFMB2 (subroutine) (CompuServe)
  588. Sub HMISysopFMB2(id As String, forum As String, num As String, _
  589.                  userid As String, priv As String, subject As String, _
  590.                  section As String)
  591.     HMISysopFMB id, forum, num, userid, priv, "y", subject, section
  592. End Sub
  593.  
  594. Function ReportDeleteMsgErrors(DeleteMsgs() As FAPDELETEMSG) As Boolean
  595.     Dim i As Integer, msg As String
  596.  
  597.     'Will error accessing Ubound(DeleteMsgs) if there are no error reports
  598.     On Error Goto ReportDeleteMsgErrors_ok
  599.     For i = 0 To Ubound(DeleteMsgs)
  600.         Select Case DeleteMsgs(i).nReason
  601.         Case FAP_DM_MESSAGE_NOT_FOUND%
  602.             msg = "not found"
  603.         Case FAP_DM_MESSAGE_IS_HELD%
  604.             msg = "already held"
  605.         Case FAP_DM_INVALID_ADDRESS%
  606.             msg = "has an invalid destination address"
  607.         Case FAP_DM_NOT_AUTHORIZED%
  608.             msg = "- you have no authorisation to forward this message"
  609.         Case Else
  610.             msg = "- unknown error"
  611.         End Select
  612.         SysopLog "Message " & DeleteMsgs(i).dwMsgNo & " " & msg
  613.     Next
  614.     ReportDeleteMsgErrors = True
  615.     Exit Function
  616.  
  617. ReportDeleteMsgErrors_ok:
  618.     ReportDeleteMsgErrors = False
  619. End Function
  620.  
  621. 'T:HMISysopFMA (subroutine) (CompuServe)
  622. Sub HMISysopFMA(id As String, forum As String, num As String, userid As String)
  623.     Dim uname As String, uid As String
  624.     Dim lpForwardMsgs(0 To 0) As FAPFORWARDMSGS
  625.     Dim ReturnValue() As FAPDELETEMSG
  626.     
  627.     On Error Goto HMISysopFMA_error
  628.  
  629.     Select Case SysopGotoForum(forum)
  630.     Case -1
  631.         Goto HMISysopFMA_fail
  632.     Case 0
  633.         SysopFMA id, forum, num, userid
  634.         Exit Sub
  635.     End Select
  636.  
  637.     BeginSysopLog forum, "Forward by Mail: "+forum+" #"+num+" mail to "+userid
  638.  
  639.     lpForwardMsgs(0).dwMsgNo = val(num)
  640.     lpForwardMsgs(0).cOptions = FAP_FM_DELETE_ORIGINAL%
  641.     If userid > "" Then
  642.         lpForwardMsgs(0).cOptions = lpForwardMsgs(0).cOptions Or FAP_FM_SEND_TO_DIFFERENT%
  643.         AnalyseName userid, lpForwardMsgs(0).lpRecipientName, lpForwardMsgs(0).lpRecipientId
  644.         SysopLog "Changing recipient to name: '" & _
  645.                 lpForwardMsgs(0).lpRecipientName & "' id: '" & _
  646.                 lpForwardMsgs(0).lpRecipientId & "'"
  647.     End If
  648.     FAPForwardMsgs_ ReturnValue(), lpForwardMsgs()
  649.  
  650.     If ReportDeleteMsgErrors(ReturnValue()) Then Goto HMISysopFMA_fail
  651.  
  652.     EndSysopLog
  653.  
  654.     ReportSuccess id & " : Forward by Mail " & forum & " #" & num & " to " & userid & " "
  655.     Exit Sub
  656.  
  657. HMISysopFMA_error:
  658.     SysopLog "Error:" & FullErrorMessage
  659. HMISysopFMA_fail:
  660.     SysopLog "Unable to forward message #"+num+" to "+userid+" by mail"
  661.     EndSysopLog
  662. End Sub
  663.  
  664. 'T:HMISysopDelete (subroutine) (CompuServe)
  665. Sub HMISysopDelete(id As String, forum As String, num As String)
  666.     Dim msgno(0 To 0) As Long
  667.     Dim ReturnValue() As FAPDELETEMSG
  668.     
  669.     On Error Goto HMISysopDelete_error
  670.  
  671.     Select Case SysopGotoForum(forum)
  672.     Case -1
  673.         Goto HMISysopDelete_fail
  674.     Case 0
  675.         SysopDelete id, forum, num
  676.         Exit Sub
  677.     End Select
  678.  
  679.     BeginSysopLog forum, "Delete Message: "+forum+" #"+num
  680.  
  681.     msgno(0) = val(num)
  682.     FAPDeleteMessages ReturnValue(), msgno()
  683.  
  684.     If ReportDeleteMsgErrors(ReturnValue()) Then Goto HMISysopDelete_fail
  685.  
  686.     EndSysopLog
  687.  
  688.     ReportSuccess id & " : Message #" & num & " from " & forum & " deleted "
  689.     Exit Sub
  690.  
  691. HMISysopDelete_error:
  692.     SysopLog "Error:" & FullErrorMessage
  693. HMISysopDelete_fail:
  694.     SysopLog "Unable to delete message #"+number+" from "+forum
  695.     EndSysopLog
  696. End Sub
  697.  
  698. 'T:HMISysopMergeThreads (subroutine) (CompuServe)
  699. Sub HMISysopMergeThreads(id As String, forum As String, num As String, newthreadid as String, parentmessage as String)
  700.     Dim threadid as Long, cOptions As Integer
  701.     Dim Result as Integer
  702.     Dim nthreadid as Long, nparent as Long
  703.  
  704.     On Error Goto HMISysopMergeThread_error
  705.  
  706.     Select Case SysopGotoForum(forum)
  707.     Case -1
  708.         Goto HMISysopMergeThread_fail
  709.     Case 0
  710.         SysopLog "Unable to Merge Threads in ASCII forum: "+forum
  711.         Exit Sub
  712.     End Select
  713.  
  714.     BeginSysopLog forum, "Merge Message " & forum & " #" & num & " to thread " & newthreadid
  715.  
  716.     threadid = HMIGetThreadID(num)
  717.     if threadid = 0 Then Goto HMISysopMergeThread_fail
  718.     cOptions = 0
  719.     nthreadid = val(newthreadid)
  720.     nparent = val(parentmessage)
  721.  
  722.     if nparent then cOptions = FAP_MS_MERGE_AS_REPLY
  723.  
  724.     Result = FAPMergeThreads(cOptions,nthreadid,threadid,nparent)
  725.     If Result = 0 Then Goto HMISysopMergeThread_fail
  726.  
  727.     EndSysopLog
  728.  
  729.     ReportSuccess id & " : Message #" & num & " in " & forum & " merged to thread " & newthreadid & " message# " & parentmessage
  730.     FetchMessageThread "", forum, num, True
  731.     Exit Sub
  732.  
  733. HMISysopMergeThread_error:
  734.     SysopLog "Error:" & FullErrorMessage
  735. HMISysopMergeThread_fail:
  736.     SysopLog "Unable to Merge message #" & num & " in " & forum & " to thread " & newthreadid & " message #" & parentmessage
  737.     EndSysopLog
  738. End Sub
  739.  
  740.  
  741.  
  742. 'Add and remove sections from the default (public) section list supplied
  743. 'according to string typed in by user
  744. Function AmendSectionList(ByVal sections As Long, validsects As long, _
  745.           addsect As String) As Long
  746.     Dim l As Long, count as Integer
  747.     Dim mask as Long
  748.  
  749.     l = ParseSectionList1(addsect, validsects, count, mask)
  750.     sections = sections Or l
  751.     sections = sections And Not mask
  752.     sections = sections And validsects
  753.     AmendSectionList = sections
  754. End Function
  755.  
  756. Function HMIGetMemberInfo(member As FAPMDENTRY, uid As String, _
  757.         cComponents As Integer) As Boolean
  758.     Dim memberdir() AS FAPMDENTRY
  759.     Dim lpSearchTerm(0 To 0) As FAPSEARCHTERM
  760.     Dim totcount As long
  761.  
  762.     lpSearchTerm(0).cType = FAP_MDS_USER_ID%
  763.     lpSearchTerm(0).lpPattern = uid
  764.     totcount = 1
  765.     Terminal.Print "Searching for member details for " & uid & Basic.Eoln$
  766.     FAPMDSearch memberdir(), HMI_STATE_FIRST%, 1, cComponents, _
  767.             lpSearchTerm(), totcount
  768.     If totcount <> 1 Then
  769.         SysopLog "Member " & uid & " not found"
  770.         HMIGetMemberInfo = False
  771.         Exit Function
  772.     Else
  773.         Terminal.Print "Member details found" & Basic.Eoln$
  774.     End If
  775.     HMIGetMemberInfo = True
  776.     member = memberdir(0)
  777. End Function
  778.  
  779. Function HMIDoMemberAmendments(member() As FAPMODIFYMEMBER, _
  780.         user As String, flgs As String, aux As String, _
  781.         syssct as String, syslib as String, sysco as String) As Boolean
  782.     Dim ReturnValue() As FAPDELETEMEMBER
  783.  
  784.     If user > "" Then
  785.         member(0).lpName = user
  786.         member(0).wComponents = member(0).wComponents Or FAP_MDM_USER_NAME%
  787.     End If
  788.     If flgs > "" Then
  789.         Dim i As Integer
  790.  
  791.         For i = 1 To Len(flgs)
  792.             Select Case Ucase$(Mid$(flgs, i, 1))
  793.             Case "B"
  794.                 member(0).wFlags = member(0).wFlags Or FAP_MDF_MSG_SYSOP%
  795.                 member(0).wComponents = member(0).wComponents Or FAP_MDM_UPDATE_MSG_SYSOP%
  796.                 member(0).svSysOpMsgSections = AmendSectionList(member(0).svSysOpMsgSections, AllMsgSects, syssct)
  797.             Case "C"
  798.                 member(0).wFlags = member(0).wFlags Or FAP_MDF_CONF_SYSOP%
  799.                 member(0).wComponents = member(0).wComponents Or FAP_MDM_UPDATE_CONF_SYSOP%
  800.                 member(0).svSysOpConfSections = AmendSectionList(member(0).svSysOpConfSections, AllConfSects, sysco)
  801.             Case "D"
  802.                 member(0).wFlags = member(0).wFlags Or FAP_MDF_LIB_SYSOP%
  803.                 member(0).wComponents = member(0).wComponents Or FAP_MDM_UPDATE_LIB_SYSOP%
  804.                 member(0).svSysOpLibSections = AmendSectionList(member(0).svSysOpLibSections, AllLibSects, syslib)
  805.             Case "E"
  806.                 member(0).wFlags = member(0).wFlags Or FAP_MDF_EDIT_SYSOP%
  807.             Case "F"
  808.                 member(0).wFlags = member(0).wFlags Or FAP_MDF_FREE_USER%
  809.             Case "L"
  810.                 member(0).wFlags = member(0).wFlags Or FAP_MDF_LOCK_OUT%
  811.             Case "M"
  812.                 member(0).wFlags = member(0).wFlags Or FAP_MDF_MEMBER_SYSOP%
  813.             Case "W"
  814.                 member(0).wFlags = member(0).wFlags Or FAP_MDF_WIZOP%
  815.             Case "Z"
  816.                 member(0).wFlags = 0
  817.             Case Else
  818.                 SysopLog "Unrecognised flag character '" & Mid$(flgs, i, 1) & "' ignored"
  819.             End Select
  820.         Next
  821.         member(0).wComponents = member(0).wComponents Or FAP_MDM_FLAGS%
  822.     End If
  823.     If aux > "" Then
  824.         member(0).lpAuxiliary = aux
  825.         member(0).wComponents = member(0).wComponents Or FAP_MDM_AUXILIARY_DATA%
  826.     End If
  827.  
  828.     If member(0).wComponents And FAP_MDM_FLAGS% then
  829.         If (Not member(0).wFlags) And FAP_MDF_MSG_SYSOP% Then
  830.             member(0).wComponents = member(0).wComponents Or FAP_MDM_UPDATE_MSG_SYSOP%
  831.             member(0).svSysOpMsgSections = 0
  832.         End If
  833.         If (Not member(0).wFlags) And FAP_MDF_CONF_SYSOP% Then
  834.             member(0).wComponents = member(0).wComponents Or FAP_MDM_UPDATE_CONF_SYSOP%
  835.             member(0).svSysOpConfSections = 0
  836.         End If
  837.         If (Not member(0).wFlags) And FAP_MDF_LIB_SYSOP% Then
  838.             member(0).wComponents = member(0).wComponents Or FAP_MDM_UPDATE_LIB_SYSOP%
  839.             member(0).svSysOpLibSections = 0
  840.         End If
  841.         If member(0).svSysOpMsgSections=0 Then member(0).wFlags = member(0).wFlags And Not FAP_MDF_MSG_SYSOP%
  842.         If member(0).svSysOpConfSections=0 Then member(0).wFlags = member(0).wFlags And Not FAP_MDF_CONF_SYSOP%
  843.         If member(0).svSysOpLibSections=0 Then member(0).wFlags = member(0).wFlags And Not FAP_MDF_LIB_SYSOP%
  844.     End If
  845.     Terminal.Print "Updating details for member " & member(0).lpUserId & Basic.Eoln$
  846.     FAPModifyMembers ReturnValue(), member()
  847.     On Error Goto HMIDoMemberAmendments_ok
  848.     'Will get an error if there were no problems, because ReturnValue is empty
  849.     SysopLog ReturnValue(0).lpReason
  850.     HMIDoMemberAmendments = False
  851.     Exit Function
  852.  
  853. HMIDoMemberAmendments_ok:
  854.     Terminal.Print "Details updated" & Basic.Eoln$
  855.     HMIDoMemberAmendments = True
  856. End Function
  857.  
  858. 'T:HMIAddMember (subroutine) (CompuServe)
  859. ' Go to forum sysop area and add member
  860. Sub HMIAddMember(id As String, forum As String, uid As String, user as String, _
  861.               aux As String, flgs As String, addsct As String, _
  862.               remsct As String, addlib As String, remlib As String, _
  863.               addco As String, remco As String)
  864.  
  865.     Dim lpUserIds(0 To 0) As String
  866.     Dim msgsect As Long, libsect As Long, confsect As Long
  867.     Dim i As Integer
  868.     Dim member(0 To 0) As FAPMODIFYMEMBER
  869.  
  870.     On Error Goto HMIAddMember_error
  871.  
  872.     Select Case SysopGotoForum(forum)
  873.     Case -1
  874.         Goto HMIAddMember_fail
  875.     Case 0
  876.         AddMember id, forum, uid, user, aux, flgs, addsct, remsct, _
  877.             addlib, remlib, addco, remco
  878.         Exit Sub
  879.     End Select
  880.  
  881.     BeginSysopLog forum, "Add Member "+uid+" "+user+" to forum "+forum
  882.  
  883.     lpUserIds(0) = uid
  884.     'Now work out what secstions the new member should be in
  885.     SysopCollectPublicSections
  886.     msgsect = AmendSectionList(PublicMsgSects, AllMsgSects, addsct)
  887.     libsect = AmendSectionList(PublicLibSects, AllLibSects, addlib)
  888.     confsect = AmendSectionList(PublicConfSects, AllConfSects, addco)
  889.  
  890.     i = FAPAddMembers(msgsect, libsect, confsect, lpUserIds())
  891.     'Ignore return value, in case that uid is already a member
  892.  
  893.     member(0).wComponents = FAP_MDM_UPDATE_MSG_ACCESS% Or FAP_MDM_UPDATE_LIB_ACCESS% Or FAP_MDM_UPDATE_CONF_ACCESS%
  894.     member(0).lpUserId = uid
  895.     member(0).svMsgSections = msgsect
  896.     member(0).svLibSections = libsect
  897.     member(0).svConfSections = confsect
  898.     If HMIDoMemberAmendments(member(), user, flgs, aux, remsct, remlib, remco) = 0 Then Goto HMIAddMember_fail
  899.  
  900.     EndSysopLog
  901.  
  902.     ReportSuccess id & " : " & user & " [" & uid & "] added to " & forum
  903.     Exit Sub
  904.  
  905. HMIAddMember_error:
  906.     SysopLog "Error:" & FullErrorMessage
  907. HMIAddMember_fail:
  908.     SysopLog "Unable to add user " + uid + " " + user + " to forum " + forum
  909.     EndSysopLog
  910. End Sub
  911.  
  912. 'T:HMIEditMember (subroutine) (CompuServe)
  913. ' Go to forum sysop area and edit member
  914. Sub HMIEditMember(id As String, forum As String, uid As String, user as String, _
  915.                aux As String, flgs As String, addsct As String, _
  916.                remsct As String, addlib As String, remlib As String, _
  917.                addco As String, remco As String)
  918.     Dim lpUserIds(0 To 0) As String
  919.     Dim member(0 To 0) As FAPMODIFYMEMBER
  920.     Dim cComponents As Integer
  921.  
  922.     On Error Goto HMIEditMember_error
  923.  
  924.     Select Case SysopGotoForum(forum)
  925.     Case -1
  926.         Goto HMIEditMember_fail
  927.     Case 0
  928.         EditMember id, forum, uid, user, aux, flgs, addsct, remsct, _
  929.             addlib, remlib, addco, remco
  930.         Exit Sub
  931.     End Select
  932.  
  933.     BeginSysopLog forum, "Edit Member "+uid+" "+user+" in forum "+forum
  934.  
  935.     lpUserIds(0) = uid
  936.  
  937.     cComponents = FAP_MDC_USER_NAME% or FAP_MDC_FLAGS%  ' work around HMI problems
  938.  
  939.     If remsct > "" And InStr(Ucase$(flgs),"B")=0 Then flgs = flgs & "B"
  940.     If remco > "" And InStr(Ucase$(flgs),"C")=0 Then flgs = flgs & "C"
  941.     If remlib > "" And InStr(Ucase$(flgs),"D")=0 Then flgs = flgs & "D"
  942.  
  943.     If addsct > "" Or addco > "" Or addlib > "" Then cComponents = cComponents Or FAP_MDC_SECTIONS%
  944.  
  945.     If cComponents <> 0 Then
  946.         'Must find out some current information for this member
  947.         Dim memberdir AS FAPMDENTRY
  948.  
  949.         If Not HMIGetMemberInfo(memberdir, uid, cComponents) Then Goto HMIEditMember_fail
  950.         member(0).wFlags = memberdir.wFlags
  951.         member(0).svSysOpMsgSections = memberdir.svSysOpMsgSections
  952.         member(0).svSysOpConfSections = memberdir.svSysOpConfSections
  953.         member(0).svSysOpLibSections = memberdir.svSysOpLibSections
  954.         member(0).lpName=memberdir.lpName
  955.  
  956.         member(0).wComponents = FAP_MDM_USER_NAME% or FAP_MDM_FLAGS%
  957.  
  958.         SysopCollectPublicSections
  959.  
  960.         If cComponents And FAP_MDC_SECTIONS% Then
  961.             member(0).wComponents = member(0).wComponents or FAP_MDM_UPDATE_MSG_ACCESS% Or FAP_MDM_UPDATE_LIB_ACCESS% Or FAP_MDM_UPDATE_CONF_ACCESS%
  962.             member(0).svMsgSections = AmendSectionList(memberdir.svMsgSections, AllMsgSects, addsct)
  963.             member(0).svLibSections = AmendSectionList(memberdir.svLibSections, AllLibSects, addlib)
  964.             member(0).svConfSections = AmendSectionList(memberdir.svConfSections, AllConfSects, addco)
  965.         End If
  966.     End If
  967.  
  968.     member(0).lpUserId = uid
  969.  
  970.     If Not HMIDoMemberAmendments(member(), user, flgs, aux, remsct, remlib, remco) Then Goto HMIEditMember_fail
  971.  
  972.     EndSysopLog
  973.  
  974.     ReportSuccess id & " : Member privileges for " & user & " [" & uid & "] on " & forum & " changed"
  975.     Exit Sub
  976.  
  977. HMIEditMember_error:
  978.     SysopLog "Error:" & FullErrorMessage
  979. HMIEditMember_fail:
  980.     SysopLog "Unable to edit user " + uid + " " + user + " to forum " + forum
  981.     EndSysopLog
  982. End Sub
  983.  
  984. 'T:HMIUploadAnnouncements (subroutine) (CompuServe)
  985. ' Go to forum sysop area and upload annoucements
  986. Sub HMIUploadAnnouncements(id As String, forum As String, ann As String, _
  987.                        filename as String, resetfl As String)
  988.     Dim body As String, block As String
  989.     Dim BulletinType As Integer
  990.     Dim ofs As Long
  991.  
  992.     On Error Goto HMIUploadAnnouncements_error
  993.  
  994.     Select Case SysopGotoForum(forum)
  995.     Case -1
  996.         Goto HMIUploadAnnouncements_fail
  997.     Case 0
  998.         UploadAnnouncements id, forum, ann, filename, resetfl
  999.         Exit Sub
  1000.     End Select
  1001.  
  1002.     BeginSysopLog forum, "Upload announcement " & ann & " for forum " & forum
  1003.  
  1004.     Select Case Val(ann)
  1005.     Case 1
  1006.         BulletinType = FAP_BULLETIN_SHORT%
  1007.     Case 2
  1008.         BulletinType = FAP_BULLETIN_REGULAR%
  1009.     Case 3
  1010.         BulletinType = FAP_BULLETIN_MEMBERSHIP%
  1011.     Case 4
  1012.         BulletinType = FAP_BULLETIN_LOCKED_USER%
  1013.     Case 5
  1014.         BulletinType = FAP_BULLETIN_ASCII_NEW_MEMBER%
  1015.     Case 6
  1016.         BulletinType = FAP_BULLETIN_NEW_MEMBER%
  1017.     Case 7
  1018.         BulletinType = FAP_BULLETIN_CONFERENCE%
  1019.     Case 8
  1020.         BulletinType = FAP_BULLETIN_LIBRARY%
  1021.     Case 9
  1022.         BulletinType = FAP_BULLETIN_MESSAGES%
  1023.     Case 10
  1024.         BulletinType = FAP_BULLETIN_SYSOP%
  1025.     End Select
  1026.  
  1027.     body = ReadMessageFile(filename, 2)
  1028.     if len(body)>0 then
  1029.         ReplaceAllInString body, "%DATE%", MyDate$
  1030.         block = Mid$(body, 1, 1024)
  1031.         ofs = 1025
  1032.         If FAPSendAnnouncement(HMI_STATE_FIRST%, FAP_SA_BULLETIN%, _
  1033.         BulletinType, 0, block) = 0 Then Goto HMIUploadAnnouncements_fail
  1034.         Do
  1035.             block = Mid$(body, ofs, 1024)
  1036.             ofs = ofs + 1024
  1037.             If FAPSendAnnouncement(HMI_STATE_NEXT%, FAP_SA_BULLETIN%, _
  1038.                  BulletinType, 0, block) = 0 Then Goto HMIUploadAnnouncements_fail
  1039.         Loop Until block=""
  1040.     else
  1041.         SysopLog "Error: Could not read announcement file"
  1042.         goto HMIUploadAnnouncements_fail
  1043.     end if
  1044.     EndSysopLog
  1045.  
  1046.     ReportSuccess id & " : Announcement " & ann & " for forum " & forum & " uploaded "
  1047.     Exit Sub
  1048.  
  1049. HMIUploadAnnouncements_error:
  1050.     SysopLog "Error:" & FullErrorMessage
  1051. HMIUploadAnnouncements_fail:
  1052.     SysopLog "Unable to upload announcement " & ann & " for forum " & forum
  1053.     EndSysopLog
  1054. End Sub
  1055.  
  1056. Sub HMIForumReports(sId As String, sForum As String, repno As Integer)
  1057.     Dim sMsgStatFile As String
  1058.     Dim ReportHeader As FAPRPTCONFIG, Report() As FAPREPORT
  1059.     Dim i As Integer
  1060.     Dim title As String, body As String
  1061.  
  1062.     On Error Goto HMIForumReports_error
  1063.  
  1064.     If SysopGotoForum(sForum) <> 1 Then Goto HMIForumReports_fail
  1065.  
  1066.     Terminal.Print "Collecting forum reports for "+sForum & Basic.Eoln$
  1067.  
  1068.     FAPReportConfig ReportHeader, Report()
  1069.  
  1070.     ' Start text capture
  1071.     sMsgStatFile = UniqueFileName$() 
  1072.     Capture CAPTURE_ON, sMsgStatFile
  1073.     CaptureLine "#pragma ciscontrol=yes;markunread=no;deleteexisting=no"
  1074.  
  1075.     For i = 0 To UBound(Report)
  1076.         if (i=repno) or (repno<0) then
  1077.             CaptureLine "!start " & sForum & "/Forum_Reports CompuServe"
  1078.             CaptureLine Report(i).lpTitle
  1079.             CaptureText Basic.Eoln$
  1080.  
  1081.             body = FAPReportRead (HMI_STATE_FIRST, Report(i).cReportNo, "", i, 2048)
  1082.             While body > ""
  1083.                 CaptureLines body
  1084.                 body = FAPReportRead (HMI_STATE_NEXT, Report(i).cReportNo, "", i, 2048)
  1085.             Wend
  1086.             CaptureLine "!end"
  1087.         end if
  1088.     Next
  1089.  
  1090.     ' Stop text capture
  1091.     CaptureText "!end" & Basic.Eoln$
  1092.     Capture CAPTURE_OFF
  1093.  
  1094.     ' Now add OutputFile to import queue
  1095.     i = QueueFile(Session.Service, sMsgStatFile, IM_SPECIAL or IM_DELETE)
  1096.  
  1097.     ReportSuccess sId & " : Message stats collection for " & sForum & " "
  1098.     Exit Sub
  1099.  
  1100. HMIForumReports_error:
  1101.     LogResult "Error:" & FullErrorMessage
  1102. HMIForumReports_fail:
  1103.     LogPrint "Unable to get forum reports for "+sForum
  1104. End Sub
  1105.  
  1106. Sub HMIAllForumReports(sId As String, sForum As String)
  1107.     HMIForumReports sId, sForum, -1
  1108. end Sub
  1109.  
  1110. Sub HMIForumReportsWelcome(sId As String, sForum As String)
  1111.     HMIForumReports sId, sForum, 0
  1112. End Sub
  1113.  
  1114. Sub HMIForumReportsMessStat(sId As String, sForum As String)
  1115.     HMIForumReports sId, sForum, 1
  1116. End Sub
  1117.  
  1118. Sub HMIForumReportsMessSize(sId As String, sForum As String)
  1119.     HMIForumReports sId, sForum, 2
  1120. End Sub
  1121.  
  1122. Sub HMIForumReportsLibActivity(sId As String, sForum As String)
  1123.     HMIForumReports sId, sForum, 3
  1124. End Sub
  1125.  
  1126. Sub HMIForumReportsLibStat(sId As String, sForum As String)
  1127.     HMIForumReports sId, sForum, 4
  1128. End Sub
  1129.  
  1130. Sub HMIForumReportsMemStat(sId As String, sForum As String)
  1131.     HMIForumReports sId, sForum, 5
  1132. End Sub
  1133.  
  1134. Function GetMessageNo(d As Date)
  1135.     Dim tsTime As HMITIMESTAMP, msg As Long
  1136.  
  1137.     ' Note - this function does not correct for the fact that CIS probably
  1138.     ' holds all times in EST!
  1139.     tsTime.cSeconds = 0
  1140.     tsTime.cMinutes = 0
  1141.     tsTime.cHour = 0
  1142.     tsTime.cDay = Day(d)
  1143.     tsTime.cMonth = Month(d)
  1144.     tsTime.cYear = Year(d) - 1970
  1145.     msg = FAPSearchDate(&H00FFFFFF, tsTime)  ' Don't pass AllMsgSects since
  1146.                      ' that causes HMI a problem
  1147.     Terminal.Print "First message posted after " & MakeDateString(tsTime)
  1148.     Terminal.Print " is #" & msg & Basic.Eoln$
  1149.     CaptureText "First message posted after " & MakeDateString(tsTime)
  1150.     CaptureText " is #" & msg & Basic.Eoln$
  1151.     If msg > FAPconfig.dwNewestMsg Then
  1152.         msg = FAPconfig.dwNewestMsg
  1153.     End If
  1154.     GetMessageNo = msg
  1155. End Function
  1156.  
  1157. Sub CalcStatTotals(stat As MsgStatSummary, msgcount() As FAPMSGCOUNT, flag As Boolean, msgc0() As FAPMSGCOUNT)
  1158.     Dim i As Integer, j As Integer, k As Integer
  1159.  
  1160.     stat.element = 0
  1161.     stat.ttotal = 0
  1162.     stat.mtotal = 0
  1163.     On Error Resume Next
  1164.     For i = 0 to Ubound(msgcount)
  1165.         stat.ttotal = stat.ttotal + msgcount(i).wNewThreads
  1166.         if flag then
  1167.            k = -1
  1168.            for j=0 to Ubound(msgc0)
  1169.             if msgcount(i).cMsgSection=msgc0(j).cMsgSection then k=j
  1170.            next
  1171.            if (k>=0) then msgcount(i).wNewMsgs = msgcount(i).wNewMsgs - msgc0(k).wNewMsgs
  1172.         end if
  1173.         stat.mtotal = stat.mtotal + msgcount(i).wNewMsgs
  1174.     Next
  1175. End Sub
  1176.  
  1177. Sub CalcStatPercentages(stat As MsgStatSummary, msgcount() As FAPMSGCOUNT, sect As Integer)
  1178.     Dim i,j as Integer
  1179.  
  1180.     stat.threads = 0
  1181.     stat.messages = 0
  1182.     stat.percentage = 0
  1183.     On Error Resume Next                'If beyond array bounds return all zeroes
  1184.     i=-1
  1185.     for j=0 to ubound(msgcount)
  1186.         if sect=msgcount(j).cMsgSection then i=j
  1187.     next
  1188.     if i>=0 then stat.element=i
  1189.     If sect = msgcount(stat.element).cMsgSection Then
  1190.         stat.threads = msgcount(stat.element).wNewThreads
  1191.         stat.messages = msgcount(stat.element).wNewMsgs
  1192.         If stat.mtotal <> 0 Then stat.percentage = 100 * stat.messages / stat.mtotal
  1193.         stat.element = stat.element + 1
  1194.     End If
  1195. End Sub
  1196.  
  1197. Function RFormat$(n, fmt As String)
  1198.     RFormat$ = Right$(Space$(Len(fmt)) & Format$(n, fmt), Len(fmt))
  1199. End Function
  1200.  
  1201. Sub HMIForumStats(sId As String, sForum As String)
  1202.     Dim sMsgStatFile As String, buf As String
  1203.     Dim d As Date, n As Date
  1204.     Dim msg As Long
  1205.     Dim msgcount0() As FAPMSGCOUNT
  1206.     Dim msgcount1() As FAPMSGCOUNT
  1207.     Dim msgcount7() As FAPMSGCOUNT
  1208.     Dim stat0 As MsgStatSummary, stat1 As MsgStatSummary, stat7 As MsgStatSummary
  1209.     Dim i As Integer, sect As Integer
  1210.  
  1211.     On Error Goto HMIForumStats_error
  1212.  
  1213.     If Not HMIGotoForum(sForum) Then
  1214.         Exit Sub
  1215.     End If
  1216.  
  1217.     Terminal.Print "Collecting message stats for "+sForum & Basic.Eoln$
  1218.  
  1219.     n = Now()
  1220.     ' Start text capture
  1221.     sMsgStatFile = UniqueFileName$() 
  1222.     Capture CAPTURE_ON, sMsgStatFile
  1223.     CaptureText Basic.Eoln$ + "!end" + Basic.Eoln$
  1224.  
  1225.     CaptureLine "!start " & sForum & "/Statistics CompuServe"
  1226.     CaptureLine "Message Stats at " & Format$(n,"dd-mmm-yy hh:mm:ss")
  1227.     CaptureText Basic.Eoln$
  1228.  
  1229.     CaptureText "Current message is                                 #" & FAPconfig.dwNewestMsg & Basic.Eoln$
  1230.  
  1231.  
  1232.     terminal.print "Getting message counts - today" & Basic.Eoln$
  1233.     d = DateAdd("d", 0, n)
  1234.     msg = GetMessageNo(d)
  1235.     FAPGetMsgCounts msgcount0(), &H00FFFFFF, msg
  1236.     CalcStatTotals stat0, msgcount0(), 0, msgcount0()
  1237.  
  1238.     d = DateAdd("d", -1, n)
  1239.     msg = GetMessageNo(d)
  1240.     Terminal.Print "Getting message counts - 1 day" & Basic.Eoln$
  1241.     FAPGetMsgCounts msgcount1(), &H00FFFFFF, msg
  1242.     CalcStatTotals stat1, msgcount1(), 1, msgcount0()
  1243.     d = DateAdd("d", -7, n)
  1244.     msg = GetMessageNo(d)
  1245.     Terminal.Print "Getting message counts - 7 days" & Basic.Eoln$
  1246.     FAPGetMsgCounts msgcount7(), &H00FFFFFF, msg
  1247.     CalcStatTotals stat7, msgcount7(), 1, msgcount0()
  1248.  
  1249.     CaptureLine "                                 1-Day                    7-Day"
  1250.     CaptureLine "----- Section ----------- Subs / Msgs ------------ Subs / Msgs ---------"
  1251.     For i = 0 To Ubound(szMsgSection)
  1252.         sect = szMsgSection(i).cId
  1253.         CalcStatPercentages stat1, msgcount1(), sect
  1254.         CalcStatPercentages stat7, msgcount7(), sect
  1255.         CaptureText RFormat$(sect, "#0") & " "
  1256.         buf = szMsgSection(i).lpTitle
  1257.         ReplaceAllInString buf, "_", " "
  1258.         CaptureText Left$(buf + Space$(22), 22)
  1259.         CaptureText RFormat$(stat1.threads, "####0") & " /"
  1260.         CaptureText RFormat$(stat1.messages, "####0") & " ("
  1261.         CaptureText RFormat$(stat1.percentage, "##0.00") & "%)   "
  1262.         CaptureText RFormat$(stat7.threads, "####0") & " /"
  1263.         CaptureText RFormat$(stat7.messages, "####0") & " ("
  1264.         CaptureText RFormat$(stat7.percentage, "##0.00") & "%)" & Basic.Eoln$
  1265.     Next
  1266.     CaptureLine "------------------------------------------------------------------------"
  1267.     CaptureText "      Totals:            "
  1268.     CaptureText RFormat$(stat1.ttotal, "####0") & " /"
  1269.     CaptureText RFormat$(stat1.mtotal, "####0") & "             "
  1270.     CaptureText RFormat$(stat7.ttotal, "####0") & " /"
  1271.     CaptureText RFormat$(stat7.mtotal, "####0") & Basic.Eoln$
  1272.     CaptureLine "!end"
  1273.  
  1274.     ' Stop text capture
  1275.     Capture CAPTURE_OFF
  1276.  
  1277.     ' Now add OutputFile to import queue
  1278.     i = QueueFile(Session.Service, sMsgStatFile, IM_SPECIAL or IM_DELETE)
  1279.  
  1280.     ReportSuccess sId & " : Message stats collection for " & sForum & " "
  1281.     Exit Sub
  1282.  
  1283. HMIForumStats_error:
  1284.     LogResult "Error:" & FullErrorMessage
  1285. HMIForumStats_fail:
  1286.     LogPrint "Unable to get message stats for "+sForum
  1287. End Sub
  1288.  
  1289. Function SearchForFile(sect As String, fname As String, pub As Integer) As Long
  1290.     Dim fdesc() As FAPFILEDESCRIPTION, fterm() As FAPSEARCHTERM
  1291.  
  1292.     ' Scan library for the file
  1293.     SearchForFile = 0
  1294.     On Error Resume Next
  1295.     Terminal.Print "Searching for "
  1296.     If pub = 0 Then
  1297.         ReDim fterm(0 to 1)
  1298.         fterm(1).cType = FAP_SFH_MATCH_NON_PUBLIC_ONLY
  1299.         Terminal.Print "unmerged "
  1300.     Else
  1301.         ReDim fterm(0 to 0)
  1302.     End If
  1303.     Terminal.Print "file " & fname & " in section " & sect & Basic.Eoln$
  1304.     fterm(0).cType = FAP_SFH_FILENAME
  1305.     fterm(0).lpPattern = fname
  1306.     FAPSearchFile fdesc(), HMI_STATE_FIRST%, 1, 1, 2 ^ Val(sect), _
  1307.             FAP_FDC_FILENAME%, fterm()
  1308.  
  1309.     SearchForFile = fdesc(0).dwCatalogNo    'Will cause error if fdesc array empty
  1310. End Function
  1311.  
  1312. 'T:HMISysopRelease (subroutine) (CompuServe)
  1313. Sub HMISysopRelease(id As String, forum As String, fname As String)
  1314.     Dim sect As String, catno As Long
  1315.  
  1316.     On Error Goto HMISysopRelease_error
  1317.  
  1318.     Select Case SysopGotoForum(forum)
  1319.     Case -1
  1320.         Goto HMISysopRelease_fail
  1321.     Case 0
  1322.         SysopRelease id, forum, fname
  1323.         Exit Sub
  1324.     End Select
  1325.  
  1326.     sect = SectionNumber(forum)
  1327.  
  1328.     BeginSysopLog forum, "Release and Merge: "+forum+" section "+sect+" file: "+fname
  1329.  
  1330.     ' Scan library for the file
  1331.     catno = SearchForFile(sect, fname, 0)
  1332.     If catno = 0 Then
  1333.         SysopLog "File "+fname+" not found in "+forum
  1334.         Goto HMISysopRelease_fail
  1335.     End If
  1336.  
  1337.     On Error Goto HMISysopRelease_error
  1338.  
  1339.     Terminal.Print "Releasing file, catalog no. " & catno & Basic.Eoln$
  1340.     If FAPModifyFile (catno, 0, FAP_MO_COMMIT% , "", "", 0, "", 0, "", "", 0, _
  1341.             "", "", notime, notime, 0) = 0 Then Goto HMISysopRelease_fail
  1342.  
  1343.     EndSysopLog
  1344.  
  1345.     ReportSuccess id & " : Released and Merged " & forum & " file: " & fname
  1346.     Exit Sub
  1347.  
  1348. HMISysopRelease_error:
  1349.     SysopLog "Error:" & FullErrorMessage
  1350. HMISysopRelease_fail:
  1351.     SysopLog "Unable to release "+fname+" in "+forum
  1352.     EndSysopLog
  1353. End Sub
  1354.  
  1355. 'T:HMISysopRelMerge (subroutine) (CompuServe)
  1356. Sub HMISysopRelMerge(id As String, forum As String, fname As String)
  1357.     Dim sect As String, catno As Long
  1358.  
  1359.     On Error Goto HMISysopRelMerge_error
  1360.  
  1361.     Select Case SysopGotoForum(forum)
  1362.     Case -1
  1363.         Goto HMISysopRelMerge_fail
  1364.     Case 0
  1365.         SysopRelMerge id, forum, fname
  1366.         Exit Sub
  1367.     End Select
  1368.  
  1369.     HMISysopRelease id, forum, fname
  1370.     Exit Sub
  1371.  
  1372. HMISysopRelMerge_error:
  1373.     SysopLog "Error:" & FullErrorMessage
  1374. HMISysopRelMerge_fail:
  1375.     SysopLog "Unable to release "+fname+" in "+forum
  1376.     EndSysopLog
  1377. End Sub
  1378.  
  1379.  
  1380. 'T:HMISysopDownload (subroutine) (CompuServe)
  1381. Sub HMISysopDownload(id As String, forum As String, fname As String)
  1382.     Select Case SysopGotoForum(forum)
  1383.     Case -1
  1384.         SysopLog "Unable to download unreleased "+fname+" in "+forum
  1385.         EndSysopLog
  1386.         Exit Sub
  1387.     Case 0
  1388.         SysopDownload id, forum, fname
  1389.         Exit Sub
  1390.     End Select
  1391.  
  1392.     NewDownloadFile id, forum, fname, False
  1393. End Sub
  1394.  
  1395. 'T:HMISysopErase (subroutine) (CompuServe)
  1396. Sub HMISysopErase(id As String, forum As String, fname As String)
  1397.     Dim sect As String, catno(0 To 0) As Long
  1398.     Dim fdel() As FAPDELETEFILE
  1399.  
  1400.     On Error Goto HMISysopErase_error
  1401.  
  1402.     Select Case SysopGotoForum(forum)
  1403.     Case -1
  1404.         Goto HMISysopErase_fail
  1405.     Case 0
  1406.         SysopErase id, forum, fname
  1407.         Exit Sub
  1408.     End Select
  1409.  
  1410.     sect = SectionNumber(forum)
  1411.  
  1412.     BeginSysopLog forum, "Erase in: "+forum+" section "+sect+" file: "+fname
  1413.  
  1414.     ' Scan library for the file
  1415.     On Error Goto HMISysopErase_error
  1416.  
  1417.     catno(0) = SearchForFile(sect, fname, 1)
  1418.     if catno(0) = 0 Then 
  1419.         catno(0) = SearchForFile(sect, fname, 0)
  1420.         If catno(0) = 0 Then
  1421.             SysopLog "File "+fname+" not found in "+forum
  1422.             Goto HMISysopErase_fail
  1423.         else
  1424.             Terminal.Print "Erasing file, catalog no. " & catno(0) & Basic.Eoln$
  1425.             FAPDeleteFiles_ fdel(), catno()
  1426.         End If
  1427.     Else
  1428.         Terminal.Print "Marking file as erased, catalog no. " & catno(0) & Basic.Eoln$
  1429.         FAPDeleteFiles_ fdel(), catno()
  1430.     End If
  1431.  
  1432.  
  1433.     EndSysopLog
  1434.  
  1435.     ReportSuccess id & " : Erased " & forum & " file: " & fname
  1436.     Exit Sub
  1437.  
  1438. HMISysopErase_error:
  1439.     SysopLog "Error:" & FullErrorMessage
  1440. HMISysopErase_fail:
  1441.     SysopLog "Unable to erase "+fname+" in "+forum
  1442.     EndSysopLog
  1443. End Sub
  1444.  
  1445. Function GetSectionSearchVector(info As String) As String
  1446.     Dim t As long, i As Integer, sectionvector As Long
  1447.     Dim lpPattern As String
  1448.  
  1449.     sectionvector = ParseSectionList(info,&H00FFFFFF, i)
  1450.     lpPattern = ""
  1451.     t = 1
  1452.     For i = 0 to 23
  1453.         If sectionvector And t Then
  1454.     lpPattern = lpPattern & "1"
  1455.         Else
  1456.     lpPattern = lpPattern & "0"
  1457.         End If
  1458.         t = t + t
  1459.     Next
  1460.     GetSectionSearchVector=lpPattern
  1461. End Function
  1462.  
  1463. Sub HMISysopLibrary(id As String, forum As String, section As String)
  1464.     Dim fname As String, i As Integer, t As String
  1465.     Dim tforum As String, count As Long
  1466.     Dim filedesc() As FAPFILEDESCRIPTION
  1467.     Dim searchterm(0 to 1) As FAPSEARCHTERM
  1468.     Dim searchflags As Long, sectionvector As Long, ok As Boolean
  1469.  
  1470.     Select Case SysopGotoForum(forum)
  1471.     Case -1
  1472.         LogPrint "Error downloading unmerged files list from forum "+forum
  1473.         Exit Sub
  1474.     Case 0
  1475.         SysopLibrary id, forum, section
  1476.         Exit Sub
  1477.     End Select
  1478.  
  1479.     tforum = forum
  1480.     tforum = ParseString(tforum, "/")
  1481.  
  1482.     ' Set which bits of info we want
  1483.     searchflags = &H6FF + FAP_FDC_ABSTRACT%
  1484.     ok = True
  1485.  
  1486.     ' Scan library for the files
  1487.     fname = UniqueFilename$()
  1488.     count = 0
  1489.     Capture CAPTURE_ON, fname
  1490.     CaptureText Basic.Eoln$+"#pragma ciscontrol=yes;markunread=yes;deleteexisting=no"+Basic.Eoln$
  1491.     Terminal.Print "Collecting unmerged files list from section(s) " + LTrim$(section) + Basic.Eoln$
  1492.  
  1493.     searchterm(0).cType = FAP_SFH_FILENAME%
  1494.     searchterm(0).lpPattern = "*.*"
  1495.     searchterm(1).cType = FAP_SFH_MATCH_NON_PUBLIC_ONLY
  1496.  
  1497.     ' Select section to search
  1498.     sectionvector = ParseSectionList(section, FAPconfig.svLibSections, i)
  1499.  
  1500.     Terminal.CaptureStatus CAPTURE_ON
  1501.     On Error Goto EndOfLibrary
  1502.     FAPSearchFile filedesc(), 0, 1, 1, sectionvector, searchflags, searchterm()
  1503.     Do While filedesc(0).dwCatalogNo > 0
  1504.         count = count + 1
  1505.         Terminal.CaptureStatus count
  1506.  
  1507.         WriteLibraryMessage tforum, filedesc(0), ""
  1508.  
  1509.         FAPSearchFile filedesc(), 1, 1, 1, sectionvector, searchflags, searchterm()
  1510.     Loop
  1511.     Terminal.Print "Collected "+LTrim$(Str(count))+" unmerged files" + Basic.Eoln$
  1512. EndOfLibrary:
  1513.     If Err<>9 Then
  1514.         LogResult "Error " & FullErrorMessage
  1515.         LogResult "Error while downloading unmerged files list from "+forum
  1516.         ok = False
  1517.     End If
  1518.     On Error Goto 0
  1519.     Terminal.CaptureStatus CAPTURE_OFF
  1520.     Capture CAPTURE_OFF
  1521.  
  1522.     ' Add to import queue
  1523.     If count > 0 Then
  1524.         b = QueueFile(Session.Service, fname, IM_DELETE Or IM_MARKUNREAD)
  1525.     Else
  1526.         DeleteFile fname
  1527.     End If
  1528.  
  1529.     If ok Then ReportSuccess id & " : Downloaded unmerged files list from " & forum
  1530. End Sub
  1531.  
  1532. Sub HMISysopModifyFile(id As String, forum As String, fname As String, _
  1533.       newfname As String, ftype As String, subj As String, keys As String, _
  1534.       userid As String, sysopcomment As String, accesscount As String, _
  1535.       newlib As String, msgfile As String)
  1536.     Dim sect As String, catno As Long, ft As Integer, c As Long
  1537.     Dim abstract As String, options As Integer
  1538.  
  1539.     On Error Goto HMISysopModifyFile_error
  1540.  
  1541.     Select Case SysopGotoForum(forum)
  1542.     Case -1
  1543.         Goto HMISysopModifyFile_fail
  1544.     Case 0
  1545.         SysopModifyFile id, forum, fname, newfname, ftype, subj, keys, userid, sysopcomment, accesscount, msgfile
  1546.         Exit Sub
  1547.     End Select
  1548.  
  1549.     sect = SectionNumber(forum)
  1550.     BeginSysopLog forum, "Modify File: "+forum+" section "+sect+" file: "+fname
  1551.  
  1552.     ' Scan library/preview for the file
  1553.     catno = SearchForFile(sect, fname, 0) ' preview
  1554.     If catno=0 Then catno = SearchForFile(sect, fname, 1) ' public
  1555.     If catno = 0 Then
  1556.         SysopLog "File "+fname+" not found in "+forum
  1557.         Goto HMISysopModifyFile_fail
  1558.     End If
  1559.  
  1560.     On Error Goto HMISysopModifyFile_error
  1561.  
  1562.     ' Build list of what we're modifying
  1563.     c = 0
  1564.  
  1565.     If newfname<>"" Then c = c Or FAP_MF_FILE_NAME%
  1566.  
  1567.     ftype = UCase$(ftype)
  1568.     ft = 0
  1569.     If ftype="ASCII" Then ft = HMI_FT_TEXT%
  1570.     If ftype="BINARY" Then ft = HMI_FT_BINARY%
  1571.     If ftype="IMAGE" Then ft = HMI_FT_IMAGE%
  1572.     If ftype="GRAPHIC:RLE" Then ft = HMI_FT_RLE%
  1573.     If ftype="GRAPHIC:NAPLPS" Then ft = HMI_FT_NAPLPS%
  1574.     If ftype="GRAPHIC:GIF" Then ft = HMI_FT_GIF%
  1575.     If ftype="GRAPHIC:JPEG" Then ft = HMI_FT_JPEG%
  1576.     If ftype="GRAPHIC:PNG" Then ft = HMI_FT_PNG%
  1577.     If ft<>0 Then c = c Or FAP_MF_FILE_TYPE%
  1578.  
  1579.     If subj<>"" Then c = c Or FAP_MF_TITLE%
  1580.     If keys<>"" Then c = c Or FAP_MF_KEYS%
  1581.     If userid<>"" Then c = c Or FAP_MF_USER_ID%
  1582.     If sysopcomment<>"" Then c = c Or FAP_MF_COMMENT%
  1583.     If accesscount<>"" Then c = c Or FAP_MF_ACCESS_COUNT%
  1584.     abstract = ReadMessageFile(msgfile, 2)
  1585.     If abstract<>"" Then c = c Or FAP_MF_ABSTRACT%
  1586.     If UCase$(newlib)="PENDING" Then
  1587.         options = FAP_MO_MAKE_CHANGES% ' Move to pending area
  1588.         newlib = ""
  1589.     Else
  1590.     options = FAP_MO_MAKE_CHANGES%       ' Make live
  1591.     End If
  1592.     If newlib<>"" Then
  1593.         c = c Or FAP_MF_LIB_SECTION_ID%
  1594.         If Not IsNumeric(Mid$(newlib, 1, 1)) Then newlib = SectionNumber("/"+newlib)
  1595.     End If
  1596.  
  1597.     Terminal.Print "Modifying file, catalog no. " & catno & Basic.Eoln$
  1598.     If FAPModifyFile (catno, c, options, newfname, userid, ft, subj, _
  1599.     Val(accesscount), keys, abstract, Val(newlib), "", sysopcomment, _
  1600.     notime, notime, 0) = 0 Then Goto HMISysopModifyFile_fail
  1601.  
  1602.     EndSysopLog
  1603.  
  1604.     ReportSuccess id & " : Modified " & forum & " file: " & fname
  1605.     Exit Sub
  1606.  
  1607. HMISysopModifyFile_error:
  1608.     SysopLog "Error:" & FullErrorMessage
  1609. HMISysopModifyFile_fail:
  1610.     SysopLog "Unable to modify "+fname+" in "+forum
  1611.     EndSysopLog
  1612. End Sub
  1613.  
  1614. 'T:ListOfMailUsers (subroutine) (CompuServe)
  1615. Sub ListOfMailUsers(id as String, forum As String, TheDate as String, SendMailToUsers as String)
  1616.     Dim searchterm(0 To 0) As FAPSEARCHTERM
  1617.     Dim members() As FAPMDENTRY
  1618.     Dim fname As String, errmsg As String, BSCFile As String
  1619.     Dim count As Integer, i As Integer, cComp As Integer
  1620.     Dim retcount As Long
  1621.     Dim ok As Boolean
  1622.  
  1623.     If Not HMIGotoForum(forum) Then
  1624.         Exit Sub
  1625.     End If
  1626.  
  1627.     If (FAPconfig.wAlerts And FAP_NISA_FORUM%) = 0 Then
  1628.         AsciiListOfMailUsers id, forum, TheDate, SendMailToUsers
  1629.         Exit Sub
  1630.     End If
  1631.  
  1632.     Terminal.Print "Listing members joined since " & TheDate & Basic.Eoln$
  1633.  
  1634.     fname = UniqueFilename$()
  1635.     count = 0
  1636.     Capture CAPTURE_ON, fname
  1637.     CaptureLine "#pragma ciscontrol=no;deleteexisting=no"
  1638.     CaptureLine "!start " & forum & "/Membership New_Joiners"
  1639.     CaptureLine "People who have joined the forum since " + TheDate
  1640.     CaptureLine ""
  1641.  
  1642.     ' Convert Date (mm-dd-yy -> yymmdd)
  1643.     TheDate = Mid$(TheDate, 7, 2)+Mid$(TheDate, 1, 2)+Mid$(TheDate, 4, 2)
  1644.     cComp = FAP_MDC_USER_NAME% + FAP_MDC_USER_ID%
  1645.     ok = True
  1646.     searchterm(0).cType = FAP_MDS_DATE_JOINED%
  1647.     searchterm(0).lpPattern = TheDate+"0000:"
  1648.  
  1649.     If UCase$(SendMailToUsers) = "Y" then
  1650.         BSCFile = Session.ServicePath
  1651.         AddBackslash BSCFile
  1652.         BSCFile = BSCFIle & Session.Service & ".bsc"
  1653.         Open BSCFile For Append Access Write Shared As #2
  1654.  
  1655.         CaptureLine "These people will all be mailed the 'welcome to the forum'"
  1656.         CaptureLine "text the next time you do a connect to CompuServe."
  1657.         CaptureLine ""
  1658.     End If
  1659.  
  1660.     Terminal.CaptureStatus CAPTURE_ON
  1661.     On Error Goto ListOfMailUsers_error
  1662.     FAPMDSearch members(), HMI_STATE_FIRST%, 11, cComp, searchterm(), retcount
  1663.     Do While members(0).lpUserId <> ""
  1664.         For i = 0 To UBound(members)
  1665.             count = count + 1
  1666.             Terminal.CaptureStatus count, "Receiving Member Directory"
  1667.             CaptureLine members(i).lpName & " [" & members(i).lpUserId & "]"
  1668.  
  1669.             If UCase$(SendMailToUsers) = "Y" then
  1670.                 Print #2, ";-; id:" & Chr(9) & "system type:" & Chr(9) & "script script:" & Chr(9) & "Send Welcome Mail to User priority:" & Chr(9) & "30 #:" & Chr(9) & forum & " #:" & Chr(9) & members(i).lpName & " [" & members(i).lpUserId & "]"
  1671.                 Print #2, "WelcomeMailTo"
  1672.                 Print #2, forum
  1673.                 Print #2, members(i).lpName & " [" & members(i).lpUserId & "]"
  1674.             End If
  1675.         Next
  1676.         FAPMDSearch members(), HMI_STATE_NEXT%, 11, cComp, searchterm(), retcount
  1677.     Loop
  1678.     CaptureLine "!end"
  1679.     Terminal.Print "Collected "+LTrim$(Str(count))+" members" + Basic.Eoln$
  1680.     Goto ListOfMailUsers_ok
  1681. ListOfMailUsers_error:
  1682.     If Err<>9 Then
  1683.         errmsg = FullErrorMessage()
  1684.         LogResult "Error while downloading members from "+forum+" error : " + errmsg
  1685.         ok = False
  1686.     End If
  1687. ListOfMailUsers_ok:
  1688.     On Error Goto 0
  1689.     Terminal.CaptureStatus CAPTURE_OFF
  1690.     Capture CAPTURE_OFF
  1691.     If UCase$(SendMailToUsers) = "Y" then Close #2
  1692.  
  1693.     ' Add to import queue
  1694.     If count > 0 Then
  1695.         b = QueueFile(Session.Service, fname, IM_DELETE)
  1696.     Else
  1697.         DeleteFile fname
  1698.     End If
  1699.  
  1700.     If ok And id<>"" Then ReportSuccess id & " : Downloaded member(s) for " & forum
  1701. End Sub
  1702.  
  1703. 'T:ListMembers (subroutine) (CompuServe)
  1704. Sub ListMembers(id As String, forum As String, list As String, info As String)
  1705.     Dim searchterm(0 To 0) As FAPSEARCHTERM
  1706.     Dim members() As FAPMDENTRY
  1707.     Dim fname As String, menuitem As String, errmsg As String
  1708.     Dim count As Integer, cComp AS Integer, i As Integer, t As Long
  1709.     Dim ok As Boolean
  1710.     Dim retcount As Long, sectionvector As Long
  1711.  
  1712.     If Not HMIGotoForum(forum) Then
  1713.         LogResult "Unable to access " + forum + " to get member list"
  1714.         Exit Sub
  1715.     End If
  1716.  
  1717.     If (FAPconfig.wAlerts And FAP_NISA_FORUM%) = 0 Then
  1718.         AsciiListMembers id, forum, list, info
  1719.         Exit Sub
  1720.     End If
  1721.  
  1722.     menuitem = ParseString(list, " ")
  1723.     Terminal.Print "Listing members matching " & menuitem & " " & info & Basic.Eoln$
  1724.     fname = UniqueFilename$()
  1725.     count = 0
  1726.     Capture CAPTURE_ON, fname
  1727.     CaptureLine "#pragma ciscontrol=no;deleteexisting=no"
  1728.     CaptureLine "!start " & forum & "/Membership Member_List"
  1729.     CaptureLine list & " " & info
  1730.     CaptureLine ""
  1731.  
  1732.     cComp = FAP_MDC_USER_NAME% + FAP_MDC_USER_ID%
  1733.     ok = True
  1734.     searchterm(0).lpPattern = info
  1735.     Select Case menuitem
  1736.     Case "ALL"
  1737.         searchterm(0).cType = FAP_MDS_ALL%
  1738.     Case "UID"
  1739.         searchterm(0).cType = FAP_MDS_USER_ID%
  1740.     Case "NAM"
  1741.         searchterm(0).cType = FAP_MDS_NAME%
  1742.     Case "DLV"
  1743.         searchterm(0).cType = FAP_MDS_LAST_VISIT%
  1744.     Case "AUX"
  1745.         searchterm(0).cType = FAP_MDS_AUXILIARY_DATA%
  1746.     Case "DJN"
  1747.         searchterm(0).cType = FAP_MDS_DATE_JOINED%
  1748.     Case "SFG"
  1749.         searchterm(0).cType = FAP_MDS_SYSOP_TYPE%
  1750.     Case "SMA"
  1751.         searchterm(0).cType = FAP_MDS_MSG_SECTION_ACCESS%
  1752.         searchterm(0).lpPattern = GetSectionSearchVector(info)
  1753.     Case "SLA"
  1754.         searchterm(0).cType = FAP_MDS_LIB_SECTION_ACCESS%
  1755.         searchterm(0).lpPattern = GetSectionSearchVector(info)
  1756.     Case "SCA"
  1757.         searchterm(0).cType = FAP_MDS_CONF_SECTION_ACCESS%
  1758.         searchterm(0).lpPattern = GetSectionSearchVector(info)
  1759.     Case Else
  1760.         LogResult "Unsupported membership search option used in " & forum
  1761.         Exit Sub
  1762.     End Select
  1763.  
  1764.     Terminal.CaptureStatus CAPTURE_ON
  1765.     On Error Goto ListMembers_error
  1766.     FAPMDSearch members(), HMI_STATE_FIRST%, 11, cComp, searchterm(), retcount
  1767.     Do While members(0).lpUserId <> ""
  1768.         For i = 0 To UBound(members)
  1769.             count = count + 1
  1770.             Terminal.CaptureStatus count, "Receiving Member Directory"
  1771.             CaptureLine members(i).lpName & " [" & members(i).lpUserId & "]"
  1772.         Next
  1773.         FAPMDSearch members(), HMI_STATE_NEXT%, 11, cComp, searchterm(), retcount
  1774.     Loop
  1775.     CaptureLine "!end"
  1776.     Terminal.Print "Collected "+LTrim$(Str(count))+" members" + Basic.Eoln$
  1777.     Goto ListMembers_ok
  1778. ListMembers_error:
  1779.     If Err<>9 Then
  1780.         errmsg = FullErrorMessage()
  1781.         LogResult "Error while downloading members from "+forum+" error : " + errmsg
  1782.         ok = False
  1783.     End If
  1784. ListMembers_ok:
  1785.     On Error Goto 0
  1786.     Terminal.CaptureStatus CAPTURE_OFF
  1787.     Capture CAPTURE_OFF
  1788.  
  1789.     ' Add to import queue
  1790.     If count > 0 Then
  1791.         b = QueueFile(Session.Service, fname, IM_DELETE)
  1792.     Else
  1793.         DeleteFile fname
  1794.     End If
  1795.  
  1796.     If ok And id<>"" Then ReportSuccess id & " : Downloaded member(s) for " & forum
  1797. End Sub
  1798.  
  1799. 'T:GetMemberCount (subroutine) (CompuServe)
  1800. Sub GetMemberCount(id As String, forum As String)
  1801.     Dim searchterm(0 To 0) As FAPSEARCHTERM
  1802.     Dim members() As FAPMDENTRY
  1803.     Dim fname As String, menuitem As String, errmsg As String
  1804.     Dim count As Integer, cComp AS Integer, i As Integer
  1805.     Dim retcount As Long
  1806.  
  1807.     If Not HMIGotoForum(forum) Then
  1808.         LogResult "Unable to access " + forum + " to get membership count"
  1809.         Exit Sub
  1810.     End If
  1811.  
  1812.     If (FAPconfig.wAlerts And FAP_NISA_FORUM%) = 0 Then
  1813.         AsciiGetMemberCount id, forum
  1814.         Exit Sub
  1815.     End If
  1816.  
  1817.     Terminal.Print "Getting membership count" & Basic.Eoln$
  1818.  
  1819.     fname = UniqueFilename$()
  1820.     count = 0
  1821.     Capture CAPTURE_ON, fname
  1822.     CaptureLine "#pragma ciscontrol=no;deleteexisting=no"
  1823.     CaptureLine "!start " & forum & "/Membership Member_Count"
  1824.     CaptureLine ""
  1825.  
  1826.     cComp = FAP_MDC_USER_ID%
  1827.     searchterm(0).cType = FAP_MDS_ALL%
  1828.     searchterm(0).lpPattern = ""
  1829.  
  1830.     On Error Goto GetMemberCount_error
  1831.     FAPMDSearch members(), HMI_STATE_FIRST%, 100, cComp, searchterm(), retcount
  1832.     Do While members(0).lpUserId <> ""
  1833.         count = count + UBound(members) + 1
  1834.         Terminal.Status "Counting Forum Members " & Str(count)
  1835.         FAPMDSearch members(), HMI_STATE_NEXT%, 100, cComp, searchterm(), retcount
  1836.     Loop
  1837. GetMemberCount_error:
  1838.     On Error Goto 0
  1839.     Terminal.Status ""
  1840.     CaptureLine "Total membership = " & count
  1841.     CaptureLine "!end"
  1842.     Capture CAPTURE_OFF
  1843.  
  1844.     ' Add to import queue
  1845.     b = QueueFile(Session.Service, fname, IM_DELETE)
  1846.  
  1847.     If id<>"" Then ReportSuccess id & " : Member count for forum " & forum & " collected"
  1848. End Sub
  1849.  
  1850. 'T:WhoIs (subroutine) (CompuServe)
  1851. Sub WhoIs(id As String, forum As String, uid As String)
  1852.     Dim searchterm(0 To 0) As FAPSEARCHTERM
  1853.     Dim members() As FAPMDENTRY
  1854.     Dim fname As String, errmsg As String
  1855.     Dim cComp As Integer
  1856.     Dim retcount As Long
  1857.  
  1858.     If Not HMIGotoForum(forum) Then
  1859.         LogResult "Unable to access " + forum + " to get who is"
  1860.         Exit Sub
  1861.     End If
  1862.  
  1863.     If (FAPconfig.wAlerts And FAP_NISA_FORUM%) = 0 Then
  1864.         AsciiWhoIs id, forum, uid
  1865.         Exit Sub
  1866.     End If
  1867.  
  1868.     Terminal.Print "Who Is " & uid & Basic.Eoln$
  1869.  
  1870.     ' Search for user and get last access
  1871.     On Error Resume Next
  1872.     cComp = FAP_MDC_USER_NAME% + FAP_MDC_USER_ID% + FAP_MDC_LAST_ACCESS%
  1873.     searchterm(0).cType = FAP_MDS_USER_ID%
  1874.     searchterm(0).lpPattern = uid
  1875.     FAPMDSearch members(), HMI_STATE_FIRST%, 1, cComp, searchterm(), retcount
  1876.  
  1877.     ' Write message
  1878.     fname = UniqueFilename$()
  1879.     Capture CAPTURE_ON, fname
  1880.     CaptureLine "#pragma ciscontrol=no;deleteexisting=no"
  1881.     CaptureLine "!start " & forum & "/Sysop_Logs User_Log"
  1882.     CaptureLine ""
  1883.     CaptureLine members(0).lpName & " [" & members(0).lpUserId & "]"
  1884.     CaptureLine "Last Accessed: " & MakeDateString(members(0).tsLastAccess)
  1885.     CaptureLine "!end"
  1886.     Capture CAPTURE_OFF
  1887.     On Error Goto 0
  1888.  
  1889.     ' Add to import queue
  1890.     If QueueFile(Session.Service, fname, IM_DELETE) Then
  1891.         ReportSuccess id & " : Who is for " & uid & " collected"
  1892.     Else
  1893.         ReportSuccess id & " : Who is for " & uid & " failed"
  1894.     End If
  1895. End Sub
  1896.  
  1897.  
  1898.