/
FromPhp.php
37 lines (29 loc) · 1003 Bytes
/
FromPhp.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
function Example() {
$entry = new \KeePassCommander\KeePassEntry('Sample Entry', [
'FieldNames' => [ 'extra field 1', 'extra password 1' ],
'AttachmentNames' => [ 'example_attachment.txt' ],
]);
if (empty($entry->title)) {
echo 'KeePass is not started'."\r\n";
echo 'Has KeePassCommander.dll been copied to the directory containing KeePass.exe ?'. "\r\n";
return 2;
}
print_r($entry);
return 0;
}
// find KeePassEntry.php
$KeePassEntry_php = str_replace('/', '\\', __DIR__ . '/KeePassEntry.php');
if (!file_exists($KeePassEntry_php)) {
$KeePassEntry_php = str_replace('/', '\\', __DIR__ . '/../bin/release/KeePassEntry.php');
if (!file_exists($KeePassEntry_php)) {
echo 'KeePassEntry.php not found'."\r\n";
exit(1);
}
}
// require KeePassEntry.php containing class KeePassEntry
require_once($KeePassEntry_php);
//BEGIN example
$exitcode = Example();
//END example
exit($exitcode);