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

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