| Line-No. / Ref. | Code Line |
| 0001 | Public Function Core_URL_Gen(In_URL) |
| 0002 | Dim In_URL_Local As String |
| 0003 | Dim URL_Segment As String |
| 0004 | Dim srtReturned As String |
| 0005 | Dim i As Integer |
| 0006 | Dim j As Integer |
| 0007 | Dim k As Integer |
| 0008 | Dim Numeric_Segment As Boolean |
| 0009 | In_URL_Local = In_URL |
| 0010 | i = 1 |
| 0011 | srtReturned = "" |
| 0012 | j = InStr(i, In_URL_Local, ".") |
| 0013 | URL_Segment = "" |
| 0014 | Do While j > 0 Or URL_Segment <> "" |
| 0015 | If j > 0 Then |
| 0016 | URL_Segment = Mid(In_URL_Local, i, j - i) |
| 0017 | End If |
| 0018 | Numeric_Segment = False |
| 0019 | For k = 1 To Len(URL_Segment) |
| 0020 | If Mid(URL_Segment, k, 1) >= 0 And Mid(URL_Segment, k, 1) <= 9 Then |
| 0021 | Numeric_Segment = True |
| 0022 | k = Len(URL_Segment) + 1 |
| 0023 | End If |
| 0024 | Next k |
| 0025 | If Numeric_Segment = False Then |
| 0026 | If srtReturned <> "" Then |
| 0027 | srtReturned = srtReturned & "." |
| 0028 | End If |
| 0029 | srtReturned = srtReturned & URL_Segment |
| 0030 | End If |
| 0031 | If j > 0 Then |
| 0032 | i = j + 1 |
| 0033 | j = InStr(i, In_URL_Local, ".") |
| 0034 | If j = 0 Then |
| 0035 | URL_Segment = Mid(In_URL_Local, i, Len(In_URL_Local)) |
| 0036 | End If |
| 0037 | Else |
| 0038 | URL_Segment = "" |
| 0039 | End If |
| 0040 | Loop |
| 0041 | 'Debug.Print Now(); "- URL: " & In_URL_Local; " Returned: " & srtReturned |
| 0042 | Core_URL_Gen = srtReturned |
| 0043 | End Function |
| Line-No. / Ref. | Code Line |
| 0001 | Public Function Functor_05(strQuery, strNote_Text) |
| 0002 | 'Development Log report - Completed Items - Category Sequence |
| 0003 | Dim rs As Recordset |
| 0004 | Dim strNote_Text_Local |
| 0005 | Dim Implementation_Period As String |
| 0006 | Dim Category As String |
| 0007 | Dim Development As String |
| 0008 | Dim Category_Saved As String |
| 0009 | Dim strCategory_Text As String |
| 0010 | Dim Implementation_Period_Saved As String |
| 0011 | Dim strImplementation_Period_Text As String |
| 0012 | strNote_Text_Local = "" |
| 0013 | Category_Saved = "ZZZZZ" |
| 0014 | strCategory_Text = "" |
| 0015 | Implementation_Period_Saved = "ZZZZ" |
| 0016 | strImplementation_Period_Text = "" |
| 0017 | Set rs = CurrentDb.OpenRecordset(strQuery) |
| 0018 | If Not rs.EOF Then |
| 0019 | rs.MoveFirst |
| 0020 | Functor_05 = "Yes" |
| 0021 | Else |
| 0022 | Functor_05 = "No" |
| 0023 | Exit Function |
| 0024 | End If |
| 0025 | Do Until rs.EOF |
| 0026 | Category = rs.Fields(0) & "" |
| 0027 | Implementation_Period = rs.Fields(1) |
| 0028 | Development = rs.Fields(2) & "" |
| 0029 | If (Implementation_Period <> Implementation_Period_Saved) Or (Category <> Category_Saved) Then |
| 0030 | If Implementation_Period_Saved <> "ZZZZ" Then |
| 0031 | 'Finalise Previous Implementation Period |
| 0032 | strImplementation_Period_Text = "|##|" & strImplementation_Period_Text & "|##|" |
| 0033 | strImplementation_Period_Text = "|1|" & Implementation_Period_Saved & "" & strImplementation_Period_Text |
| 0034 | End If |
| 0035 | 'Ready for next Period |
| 0036 | If Category = Category_Saved Then |
| 0037 | strCategory_Text = strCategory_Text & strImplementation_Period_Text |
| 0038 | strImplementation_Period_Text = "" |
| 0039 | End If |
| 0040 | End If |
| 0041 | If Category <> Category_Saved Then |
| 0042 | If Category_Saved <> "ZZZZZ" Then |
| 0043 | 'Finalise Previous Priority |
| 0044 | strCategory_Text = "|ii|" & strCategory_Text & strImplementation_Period_Text & "|ii|" |
| 0045 | strCategory_Text = "|.|" & Category_Saved & "" & strCategory_Text |
| 0046 | End If |
| 0047 | 'Ready for next Period |
| 0048 | strNote_Text_Local = strNote_Text_Local & strCategory_Text |
| 0049 | strCategory_Text = "" |
| 0050 | Implementation_Period_Saved = "ZZZZ" |
| 0051 | strImplementation_Period_Text = "" |
| 0052 | End If |
| 0053 | strImplementation_Period_Text = strImplementation_Period_Text & "|.|" & Development |
| 0054 | 'Move on ... |
| 0055 | Category_Saved = Category |
| 0056 | Implementation_Period_Saved = Implementation_Period |
| 0057 | rs.MoveNext |
| 0058 | Loop |
| 0059 | 'Finish the list ... |
| 0060 | strImplementation_Period_Text = "|##|" & strImplementation_Period_Text & "|##|" |
| 0061 | strImplementation_Period_Text = "|1|" & Implementation_Period_Saved & "" & strImplementation_Period_Text |
| 0062 | strCategory_Text = "|ii|" & strCategory_Text & strImplementation_Period_Text & "|ii|" |
| 0063 | strCategory_Text = "|.|" & Category_Saved & "" & strCategory_Text |
| 0064 | strNote_Text_Local = strNote_Text_Local & strCategory_Text |
| 0065 | 'Top and Tail |
| 0066 | strNote_Text_Local = "Completed Items By Category:- |..|" & strNote_Text_Local & "|..|" |
| 0067 | 'Tidy up |
| 0068 | Set rs = Nothing |
| 0069 | strNote_Text = strNote_Text_Local |
| 0070 | End Function |
| Line-No. / Ref. | Code Line |
| 0001 | Public Sub Pianola_Check() |
| 0002 | Dim ie As InternetExplorer |
| 0003 | Dim html |
| 0004 | Dim i As Long |
| 0005 | Dim j As Long |
| 0006 | Dim k As Long |
| 0007 | Dim Requested_URL |
| 0008 | Dim Returned_URL |
| 0009 | Dim start As Date |
| 0010 | Dim RunTime As Single |
| 0011 | Dim Running_Hours As Single |
| 0012 | Dim Issue As String |
| 0013 | Dim Defunct As Boolean |
| 0014 | Dim Update_Time As Double |
| 0015 | Dim Recent_Check As Date |
| 0016 | Dim Recent_Check_OK As Boolean |
| 0017 | Dim Last_Bounce As Date |
| 0018 | Dim Given_Up As Boolean |
| 0019 | Dim Uncheckable As Boolean |
| 0020 | Dim strDocument As String |
| 0021 | Dim Pianola_ID As Long |
| 0022 | Dim Max_Pianola As Long |
| 0023 | Dim Pianola_Root As String |
| 0024 | Dim strDate As String |
| 0025 | Max_Pianola = 100 |
| 0026 | Pianola_ID = 2 |
| 0027 | Pianola_Root = "https://app.pianola.net/Results/Session" |
| 0028 | 'Fix the parameters below ... |
| 0029 | Stop |
| 0030 | Recent_Check = Now() - 10 'Parameter - Check gap in days |
| 0031 | RunTime = 5 'Parameter - run time in hours |
| 0032 | 'Open Internet Explorer in memory, and go to website |
| 0033 | Set ie = New InternetExplorer |
| 0034 | ie.Visible = False |
| 0035 | start = Now() |
| 0036 | Last_Bounce = start |
| 0037 | Do While Pianola_ID < Max_Pianola |
| 0038 | 'Bounce IE every 5 minutes |
| 0039 | If (Now() - Last_Bounce) * 24 * 60 > 5 Then |
| 0040 | ie.Quit |
| 0041 | Set ie = Nothing |
| 0042 | Set ie = New InternetExplorer |
| 0043 | ie.Visible = False |
| 0044 | Last_Bounce = Now() |
| 0045 | Debug.Print Now() & " - "; "IE Bounced at " & Last_Bounce |
| 0046 | End If |
| 0047 | Uncheckable = False |
| 0048 | Update_Time = Now() |
| 0049 | Given_Up = False |
| 0050 | Recent_Check_OK = True |
| 0051 | If Recent_Check_OK = True Then |
| 0052 | Requested_URL = Pianola_Root & Pianola_ID |
| 0053 | Defunct = False |
| 0054 | Issue = "" |
| 0055 | On Error GoTo Err_Fix |
| 0056 | Resume_Here: |
| 0057 | ie.Navigate Requested_URL |
| 0058 | Update_Time = Now() |
| 0059 | 'Wait until IE is done loading page |
| 0060 | i = 1 |
| 0061 | Do While ie.ReadyState <> READYSTATE_COMPLETE |
| 0062 | DoEvents |
| 0063 | i = i + 1 |
| 0064 | If i > 3000 Then |
| 0065 | Given_Up = True |
| 0066 | GoTo Give_Up |
| 0067 | End If |
| 0068 | Loop |
| 0069 | Give_Up: |
| 0070 | If Given_Up = False Then |
| 0071 | Returned_URL = ie.LocationURL |
| 0072 | strDocument = ie.Document |
| 0073 | If strDocument = "[object HTMLDocument]" Then |
| 0074 | strDocument = ie.Document.DocumentElement.innerHtml |
| 0075 | Else |
| 0076 | strDocument = ie.Document.DocumentElement.innerHtml |
| 0077 | End If |
| 0078 | If Requested_URL <> Returned_URL Then |
| 0079 | If Replace(Returned_URL, "https", "http") = Requested_URL Then |
| 0080 | Debug.Print Now() & " - "; "URL Secured: "; Returned_URL |
| 0081 | Issue = "URL Secured" |
| 0082 | Else |
| 0083 | If (Requested_URL & "/" = Returned_URL) Or (Requested_URL = Returned_URL & "/") Then |
| 0084 | Debug.Print Now() & " - "; "URL with trailing slash: "; Returned_URL |
| 0085 | Issue = "URL with trailing slash" |
| 0086 | Else |
| 0087 | If Left(Returned_URL, Len("http://www.webaddresshelp.bt.com")) = "http://www.webaddresshelp.bt.com" Then |
| 0088 | Debug.Print Now() & " - "; "URL Not found" |
| 0089 | Issue = "URL Not found" |
| 0090 | Defunct = True |
| 0091 | Else |
| 0092 | If Left(Returned_URL, Len("http://web.demo.barefruit.co.uk/")) = "http://web.demo.barefruit.co.uk/" Then |
| 0093 | Debug.Print Now() & " - "; "Website reports Document Not Found" |
| 0094 | Issue = "Document Not Found" |
| 0095 | Else |
| 0096 | Debug.Print Now() & " - "; "URL Differs: "; Returned_URL |
| 0097 | Issue = "URL Differs" |
| 0098 | End If |
| 0099 | End If |
| 0100 | End If |
| 0101 | End If |
| 0102 | End If |
| 0103 | i = InStr(strDocument, "") |
| 0104 | If i > 0 Then |
| 0105 | j = InStr(i, strDocument, "") |
| 0106 | If j > 0 Then |
| 0107 | k = InStr(i, strDocument, ",") |
| 0108 | End If |
| 0109 | If k > 0 And k < j Then |
| 0110 | strDate = Trim(Mid(strDocument, k + 1, j - k - 1)) |
| 0111 | Debug.Print Now() & " - "; Pianola_ID, strDate |
| 0112 | End If |
| 0113 | End If |
| 0114 | i = InStr(strDocument, " |
| 0115 | k = Len(" |
| 0116 | If i > 0 Then |
| 0117 | j = InStr(i + k, strDocument, """>") |
| 0118 | If j > 0 Then |
| 0119 | strDate = Trim(Mid(strDocument, i + k, j - i - k)) |
| 0120 | Debug.Print Now() & " - "; Pianola_ID, strDate |
| 0121 | End If |
| 0122 | End If |
| 0123 | End If |
| 0124 | End If |
| 0125 | If Given_Up = True Then |
| 0126 | 'Flag those with file-types that can't be checked |
| 0127 | End If |
| 0128 | Running_Hours = (Now() - start) * 24 |
| 0129 | If Running_Hours > RunTime Then |
| 0130 | Stop |
| 0131 | start = Now() |
| 0132 | End If |
| 0133 | Pianola_ID = Pianola_ID + 1 |
| 0134 | Loop |
| 0135 | ie.Quit |
| 0136 | Set ie = Nothing |
| 0137 | Debug.Print Now() & " - "; "Job complete at " & Now() |
| 0138 | MsgBox "Webrefs Checker Completed at " & Now() |
| 0139 | Exit Sub |
| 0140 | Err_Fix: |
| 0141 | Debug.Print Now() & " - "; Err.Description |
| 0142 | DoEvents |
| 0143 | Err.Clear |
| 0144 | ie.Quit |
| 0145 | Set ie = Nothing |
| 0146 | Set ie = New InternetExplorer |
| 0147 | ie.Visible = False |
| 0148 | Last_Bounce = Now() |
| 0149 | Debug.Print Now() & " - "; "IE Bounced at " & Last_Bounce |
| 0150 | GoTo Resume_Here |
| 0151 | End Sub |
| Line-No. / Ref. | Code Line |
| 0001 | Public Function Reference_Files(strText, Calling_Type, Calling_ID, Calling_Timestamp, Optional Depth) |
| 0002 | Dim x As Long |
| 0003 | Dim Y As Long |
| 0004 | Dim strFile_Name As String |
| 0005 | Dim FileRef As Long |
| 0006 | Dim strText_Local As String |
| 0007 | Dim strText_End As String |
| 0008 | Dim qryString As String |
| 0009 | Dim rsTableToRead As Recordset |
| 0010 | Dim iDepth As Integer |
| 0011 | Dim strPrefix As String |
| 0012 | Dim i As Integer |
| 0013 | If Len(strText) = 0 Then |
| 0014 | Reference_Files = "Not Found" |
| 0015 | Exit Function |
| 0016 | End If |
| 0017 | If IsMissing(Depth) Then |
| 0018 | iDepth = 2 |
| 0019 | Else |
| 0020 | iDepth = Depth |
| 0021 | End If |
| 0022 | i = 0 |
| 0023 | strPrefix = "" |
| 0024 | Do While i < iDepth |
| 0025 | strPrefix = strPrefix & "../" |
| 0026 | i = i + 1 |
| 0027 | Loop |
| 0028 | strText_Local = strText |
| 0029 | x = 1 |
| 0030 | x = InStr(x, strText_Local, "+F") |
| 0031 | Reference_Files = "Not Found" |
| 0032 | Do While x > 0 |
| 0033 | Reference_Files = "Found" |
| 0034 | Y = InStr(x + 1, strText_Local, "F+") |
| 0035 | 'Watch out for false positives in finding +F |
| 0036 | If Y = 0 Or x = 1 Then 'x = 1 is a fudge for the next test ... |
| 0037 | x = x + 1 |
| 0038 | Else |
| 0039 | If Mid(strText_Local, x - 1, 4) = "++FN" Then 'Watch out for footnotes! |
| 0040 | x = x + 1 |
| 0041 | Else |
| 0042 | If (Y - x > 80) Or (Y - x = 2) Then 'Need to decide on a sensible limit! |
| 0043 | x = x + 1 |
| 0044 | Else |
| 0045 | strFile_Name = Mid(strText_Local, x + 2, Y - x - 2) |
| 0046 | If Y > Len(strText_Local) - 2 Then |
| 0047 | strText_End = "" |
| 0048 | Else |
| 0049 | strText_End = Mid(strText_Local, Y + 2, Len(strText_Local)) |
| 0050 | End If |
| 0051 | 'Determine File_ID (or add if new) |
| 0052 | qryString = "SELECT * FROM PDF_File_Control WHERE (((PDF_File_Control.File_Name)=""" & strFile_Name & """));" |
| 0053 | Set rsTableToRead = CurrentDb.OpenRecordset(qryString) |
| 0054 | If Not rsTableToRead.EOF Then |
| 0055 | rsTableToRead.MoveFirst |
| 0056 | FileRef = rsTableToRead.Fields(0) |
| 0057 | Else |
| 0058 | 'Insert a new row |
| 0059 | 'Check no spaces in file name ... |
| 0060 | If InStr(strFile_Name, " ") > 0 Then |
| 0061 | Debug.Print Now() & " - Reference_Files: " & strFile_Name & " contains spaces." 'Bug |
| 0062 | End If |
| 0063 | rsTableToRead.AddNew |
| 0064 | rsTableToRead.Fields(1) = strFile_Name |
| 0065 | rsTableToRead.Fields(2) = Now() |
| 0066 | rsTableToRead.Fields(3) = Calling_ID |
| 0067 | rsTableToRead.Update |
| 0068 | 'Read it back to get the ID |
| 0069 | qryString = "SELECT * FROM PDF_File_Control WHERE (((PDF_File_Control.File_Name)=""" & strFile_Name & """));" |
| 0070 | Set rsTableToRead = CurrentDb.OpenRecordset(qryString) |
| 0071 | If rsTableToRead.EOF Then |
| 0072 | Debug.Print Now() & " - Reference_Files: " & strFile_Name & " not found." 'Bug |
| 0073 | Else |
| 0074 | rsTableToRead.MoveFirst |
| 0075 | FileRef = rsTableToRead.Fields(0) |
| 0076 | End If |
| 0077 | End If |
| 0078 | 'strText_Local = Left(strText_Local, x - 1) & IIf(Calling_Type <> "X", "", "") & "[PDF File]++1319#" & strFile_Name & "++" & strText_End |
| 0079 | strText_Local = Left(strText_Local, x - 1) & "[PDF File]++1319#" & strFile_Name & "++" & strText_End |
| 0080 | If Calling_Type <> "X" Then |
| 0081 | 'NameRef = NameRef + 1 |
| 0082 | OK = Cross_Reference_Add(Calling_Type, Calling_ID, Calling_Timestamp, "F", FileRef, 0) |
| 0083 | End If |
| 0084 | Set rsTableToRead = Nothing |
| 0085 | End If |
| 0086 | End If |
| 0087 | End If |
| 0088 | x = InStr(x, strText_Local, "+F") |
| 0089 | Loop |
| 0090 | strText = strText_Local |
| 0091 | End Function |
| Line-No. / Ref. | Code Line |
| 0001 | Public Function Remove_Hyperlinks(Photo_Title) |
| 0002 | Dim Hyperlink_Start As Integer |
| 0003 | Dim Hyperlink_End As Integer |
| 0004 | Dim Photo_Title_Local |
| 0005 | Dim Hyperlink As String |
| 0006 | Photo_Title_Local = Photo_Title |
| 0007 | 'Remove hard-codings ... |
| 0008 | Hyperlink_Start = 1 |
| 0009 | Do While Hyperlink_Start > 0 |
| 0010 | Hyperlink_Start = InStr(Hyperlink_Start, Photo_Title_Local, " |
| 0011 | If Hyperlink_Start > 0 Then |
| 0012 | Hyperlink_End = InStr(Hyperlink_Start, Photo_Title_Local, ">") |
| 0013 | Photo_Title_Local = Left(Photo_Title_Local, Hyperlink_Start - 1) & Mid(Photo_Title_Local, Hyperlink_End + 1) |
| 0014 | End If |
| 0015 | Loop |
| 0016 | Photo_Title_Local = Replace(Photo_Title_Local, "", "") |
| 0017 | 'Remove Note-links |
| 0018 | Hyperlink_Start = 1 |
| 0019 | Do While Hyperlink_Start > 0 |
| 0020 | Hyperlink_Start = InStr(Hyperlink_Start, Photo_Title_Local, "++") |
| 0021 | If Hyperlink_Start > 0 Then |
| 0022 | Hyperlink_End = InStr(Hyperlink_Start + 1, Photo_Title_Local, "++") |
| 0023 | If Hyperlink_End > 0 Then |
| 0024 | Hyperlink = Mid(Photo_Title_Local, Hyperlink_Start, Hyperlink_End - Hyperlink_Start + 2) |
| 0025 | If Len(Hyperlink) < 20 Then |
| 0026 | Photo_Title_Local = Left(Photo_Title_Local, Hyperlink_Start - 1) & Mid(Photo_Title_Local, Hyperlink_Start + Len(Hyperlink)) |
| 0027 | Else |
| 0028 | Hyperlink_Start = Hyperlink_Start + 20 |
| 0029 | End If |
| 0030 | Else |
| 0031 | Hyperlink_Start = 0 |
| 0032 | End If |
| 0033 | End If |
| 0034 | Loop |
| 0035 | 'Return |
| 0036 | Remove_Hyperlinks = Photo_Title_Local |
| 0037 | End Function |
| Line-No. / Ref. | Code Line |
| 0001 | Public Function Zap_Cross_References(Calling_Type, Calling_ID, Calling_Timestamp) |
| 0002 | 'This function does two things: (a) deletes the references associated with a calling object (b) saves these references in the zapper table so they can be compared with the replacement rows and appropriate action taken |
| 0003 | Dim strQuery As String |
| 0004 | Dim Calling_ID_Local As Integer |
| 0005 | Dim rsAuthors As Recordset |
| 0006 | 'Zap the Zapper |
| 0007 | strQuery = "DELETE * FROM Cross_Reference_Zapper;" |
| 0008 | DoCmd.RunSQL (strQuery) |
| 0009 | 'Find the Calling_ID for Authors |
| 0010 | If Calling_Type = "A" Then |
| 0011 | strQuery = "SELECT Authors.Author_ID FROM Authors WHERE Authors.Author_Name=""" & Calling_ID & """;" |
| 0012 | Set rsAuthors = CurrentDb.OpenRecordset(strQuery) |
| 0013 | If Not rsAuthors.EOF Then |
| 0014 | Calling_ID_Local = rsAuthors.Fields(0) |
| 0015 | Else |
| 0016 | Calling_ID_Local = 0 |
| 0017 | End If |
| 0018 | Set rsAuthors = Nothing |
| 0019 | Else |
| 0020 | Calling_ID_Local = Calling_ID |
| 0021 | End If |
| 0022 | If Calling_ID_Local <> 0 Then |
| 0023 | 'Populate the Zapper |
| 0024 | strQuery = "INSERT INTO Cross_Reference_Zapper SELECT Cross_Reference.* FROM Cross_Reference WHERE (((Cross_Reference.Calling_Type)=""" & Calling_Type & """) AND ((Cross_Reference.Calling_ID)=" & Calling_ID_Local & ") AND ((Cross_Reference.Calling_Timestamp)=" & Calling_Timestamp & "));" |
| 0025 | DoCmd.RunSQL (strQuery) |
| 0026 | 'Do the Zapping |
| 0027 | strQuery = "DELETE Cross_Reference.* FROM Cross_Reference INNER JOIN [Cross_Reference_Zapper] ON Cross_Reference.ID = [Cross_Reference_Zapper].ID;" |
| 0028 | DoCmd.RunSQL (strQuery) |
| 0029 | End If |
| 0030 | End Function |