-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.php
More file actions
executable file
·104 lines (76 loc) · 1.98 KB
/
server.php
File metadata and controls
executable file
·104 lines (76 loc) · 1.98 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
/*
* server.php
*
* This file contains all code requiered to export a complete year of a user on
* the server side.
*
* (C) by PaKu 2017 <cookie4rent@gmail.com>
*/
header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1.
header("Pragma: no-cache"); // HTTP 1.0.
header("Expires: 0"); // Proxies.
phpinfo();
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once('../config.php');
require_once('../database.class.php');
if ( PHP_VERSION_ID < 50600 ) {
iconv_set_encoding("internal_encoding", "UTF-8");
iconv_set_encoding("output_encoding", "UTF-8");
iconv_set_encoding("input_encoding", "UTF-8");
}
else {
ini_set('default_charset', 'UTF-8');
}
setlocale(LC_TIME, 'de_DE.utf8');
// open database
$dbx = new DatabaseConnection(CConfig::$dbhost, CConfig::$dbuser, CConfig::$dbpass, CConfig::$dbname);
if ( ! isset($dbx) ) {
// error, no database connection available
echo "Error, no database connection available";
die;
}
$dbx->getDatabaseConnection()->query("SET NAMES 'utf8'");
$dbx->getDatabaseConnection()->set_charset("utf8");
$app = 0;
// check what to do and execute appropiate function
if ( isset($_GET["app"]) ) {
$app = $_GET["app"];
}
echo $app;
switch ($app) {
case 0:
break;
case 1:
// get user list
echo getUserlist($dbx);
break;
default:
break;
}
// close database connection when finished
$dbx->getDatabaseConnection()->close();
function getUserlist($db) {
$stmt = $db->getDatabaseConnection->stmt_init();
if ( ! isset($stmt) ) {
echo "Error while statement init";
die;
}
if ( ! $stmt->prepare("SELECT id, uname FROM " . CConfig::$db_tbl_prefix . "users") ) {
echo "Error while statement preparation " . $db->getDatabaseConnection()->error;
die;
}
$users = array();
$index = 0;
$stmt->bind_result($id, $uname);
while ($stmt->fetch() ) {
$users[] = array();
$users[$index]['id'] = $id;
$users[$index]['uname'] = $uname;
$index++;
}
echo json_encode($users);
$stmt->close();
}
?>