-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcpc_api.php
62 lines (41 loc) · 1.39 KB
/
cpc_api.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
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
<?php
/* If this file is moved, the followed path needs to be altered to point at root of ClassicPress installation */
include_once('../../../wp-load.php');
global $wpdb;
$code = isset($_GET['code']) && $_GET['code'] && $_GET['code'] != '' ? $_GET['code'] : 'no API security code passed';
echo '<cpc>';
echo '<version>0.1</version>';
if (cpc_api_correct($code)):
$api = isset($_GET['api']) ? $_GET['api'] : 'no API function passed';
if (cpc_api_function_permitted($api)):
if ($api == 'get_all_users'):
// Return details of all users as
// user->user_login
// user->display_name
$sql = "select * from {$wpdb->prefix}users order by user_login";
$users = $wpdb->get_results($sql);
echo '<users>';
foreach ($users as $user):
echo '<user>';
echo '<user_login>'.$user->user_login.'</user_login>';
echo '<display_name>'.$user->display_name.'</display_name>';
echo '</user>';
endforeach;
echo '</users>';
else:
echo '<error>';
echo '<name>Falsche API-Funktion ('.$api.')</name>';
echo '</error>';
endif;
else:
echo '<error>';
echo '<name>Falsche API-Funktion oder nicht aktiviert ('.$api.')</name>';
echo '</error>';
endif;
else:
echo '<error>';
echo '<name>Falscher API-Sicherheitscode ('.htmlspecialchars($code).')</name>';
echo '</error>';
endif;
echo '</cpc>';
?>