Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
MediaDBViewerAPI
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
BA_SI-Projekt
MediaDBViewerAPI
Commits
2ac1299f
Commit
2ac1299f
authored
Jan 12, 2016
by
Nico Schallehn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SQlite hinzugefügt für API-Key verwaltung zusätzlich Key Überprüfung
usw.
parent
f51d1802
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
4 deletions
+36
-4
api.class.php
api.class.php
+25
-2
api.php
api.php
+1
-0
test.php
test.php
+10
-2
No files found.
api.class.php
View file @
2ac1299f
...
...
@@ -6,11 +6,33 @@
class
MediaDBViewerAPI
{
private
$API_KEY
;
private
$DB_Server
;
private
$DB_Username
;
private
$DB_Passwort
;
function
APIinit
(
$KEY
)
{
if
(
isset
(
$KEY
)
AND
strlen
(
$KEY
)
==
API_KEY_LEN
){
$this
->
API_KEY
=
$KEY
;
$ret
=
true
;
if
(
$db
=
sqlite_open
(
API_KEY_DB
,
0666
,
$sqliteerror
))
{
$result
=
sqlite_query
(
$db
,
'select * from Keys WHERE Key = '
.
$KEY
);
if
(
sqlite_num_rows
(
$result
)
==
1
){
$entry
=
sqlite_fetch_array
(
$query
,
SQLITE_ASSOC
);
$this
->
DB_Server
=
$entry
[
'Server'
];
$this
->
DB_Username
=
$entry
[
'Username'
];
$this
->
DB_Passwort
=
$entry
[
'Passwort'
];
$this
->
API_KEY
=
$KEY
;
$ret
=
true
;
}
else
{
$ret
=
false
;
}
}
else
{
$ret
=
false
;
}
}
else
{
$ret
=
false
;
...
...
@@ -20,6 +42,7 @@ class MediaDBViewerAPI{
function
API_serverinfo
(){
return
array
(
"time"
=>
time
(),
"time_h"
=>
date
(
time
()),
"HTTP_USER_AGENT"
=>
$_SERVER
[
'HTTP_USER_AGENT'
],
"REMOTE_ADDR"
=>
$_SERVER
[
'REMOTE_ADDR'
]
);
...
...
api.php
View file @
2ac1299f
...
...
@@ -13,6 +13,7 @@ include 'api.class.php';
*/
define
(
API_KEY_LEN
,
10
);
define
(
API_VERSION
,
0.001
);
define
(
API_KEY_DB
,
"Key.sqlite"
);
$API
=
new
MediaDBViewerAPI
();
...
...
test.php
View file @
2ac1299f
<?php
include
'api.class.php'
;
$arr
=
get_defined_functions
();
API_KEY_DB
print_r
(
$arr
);
\ No newline at end of file
if
(
$db
=
sqlite_open
(
API_KEY_DB
,
0666
,
$sqliteerror
))
{
sqlite_query
(
$db
,
'CREATE TABLE Keys (Key PRIMARY KEY varchar(10), Server varchar(20), Username varchar(20), Passwort varchar(20))'
);
sqlite_query
(
$db
,
"INSERT INTO Keys VALUES ('0123456789', 'localhost', 'MediaDB', 'MediaDB')"
);
$result
=
sqlite_query
(
$db
,
'select * from Keys'
);
var_dump
(
sqlite_fetch_array
(
$result
));
}
else
{
die
(
$sqliteerror
);
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment