function save_knowledgebase_entry ($titel,$text) {
global $notesuser, $noteswebpass;
$text = urlencode($text);
$titel = urlencode($titel);
echo "$titel<br>$text<hr>";
$varURL = "https://mailserver/Technik/knowledgebase.nsf/CreateKBEntry?OpenAgent";
$datapost = $titel."&".$text;
$ch = curl_init($varURL);
curl_setopt($ch, CURLOPT_URL, $varURL);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $datapost);
curl_setopt($ch, CURLOPT_USERPWD, $notesuser.":".$noteswebpass);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
$erg = curl_exec($ch);
preg_match("#<body[^>]*>(.*?)</body>#si", $erg, $erg_array);
$output = $erg_array[1];
curl_close($ch);
return $output;
}
Sub Initialize
Dim s As New NotesSession
Dim db As NotesDatabase
Dim col As NotesDocumentCollection
Dim doc As NotesDocument
Dim docid As String
Dim view As NotesView
Dim vc As NotesViewEntryCollection
Dim arg As String, p1 As Long
Dim argarray As Variant
Dim counter As Integer
Dim argtitel As String
Dim argtext As String
On Error GoTo ErrHandler
Set doc = s.DocumentContext
Dim qs As String
qs = doc.query_string(0)
If doc.HasItem("Request_Content") Then
qs=qs & "&"
ForAll aContent In doc.Request_Content
qs=qs & aContent
End ForAll
End If
Print "Werte=" & qs & "<br>"
arg = qs
p1 = InStr(arg, "&")
If p1 = 0 Then ' kein Parameter angegeben?
Print "Error 1: keine Parameter übergeben!"
Exit Sub
End If
arg = LCase(Mid$(arg, p1 + 1)) ' alle Parameter aus der URL extrahieren
argarray = Split(arg,"&") ' jeden Parameter trennen und in Array speichern
argtitel = urlDecode(argarray(0))
argtext = urlDecode(argarray(1))
Print "Titel: " & argtitel & " erstellt<br>"
Set db = s.GetDatabase("MAILSERVER/SRV/Group", "Technik\knowledgebase.nsf", False)
If Not db.IsOpen Then Call db.Open("", "")
Set view = db.GetView("All Documents")
Set doc = db.Createdocument()
docid = doc.UniversalID
doc.Subject = "TEST - " & argtitel
doc.Body = argtext
doc.ApptUNID = docid
Call doc.Save( True, True )
ErrResume:
Exit Sub
ErrHandler:
Print "** CreateKBEntry ** Error occured " & Str(Err) & ": " & Error$ & " in line " & Str(Erl) & ". Agent stopped."
Resume ErrResume
End Sub
Public Function urlDecode(s As String) As String
If Len(s) = 0 Then Exit Function
Dim i As Integer
Dim tmp As String
Dim c As String
For i = 1 To Len(s)
c = Mid$(s, i, 1)
If c = "+" Then c = " "
If c = "%" Then
c = Chr$("&H" + Mid$(s, i + 1, 2))
i = i + 2
End If
tmp = tmp + c
Next i
urlDecode = tmp
End Function
arg = LCase(Mid$(arg, p1 + 1)) ' alle Parameter aus der URL extrahieren