-
Notifications
You must be signed in to change notification settings - Fork 1
/
api.php
65 lines (52 loc) · 1.22 KB
/
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
63
64
<?php
require_once 'vendor/skunk.php';
require_once 'vendor/idiorm.php';
require_once 'vendor/paris.php';
$config = require_once 'config.php';
require_once 'model/prefix.php';
require_once 'number.php';
ORM::configure( $config['database']['dsn'] );
ORM::configure( 'username', $config['database']['username'] );
ORM::configure( 'password', $config['database']['password'] );
$s = new Skunk();
$s->hook(
'send_head',
function ( &$s ) {
$s->header( "X-Made-With", "Joy" );
}
);
$s->hook(
'before',
function ( &$s ) {
$s->header( "Content-Type", "application/json" );
$s->body = array();
}
);
$s->hook(
'after',
function ( &$s ) {
if( is_array( $s->body ) ) {
$s->body = json_encode( $s->body );
}
}
);
$s->get(
'/launder/bulk(/)',
function ( &$s ) {
if( ! isset( $_REQUEST["number"] ) || 0 == count( $_REQUEST["number"] ) ) {
$s->body["error"] = true;
$s->body["message"] = "No Numbers Given";
return;
}
foreach( $_REQUEST["number"] as $number ) {
$s->body[] = ProcessNumber( $number );
}
}
);
$s->get(
'/launder/<number>(/)',
function ( &$s, $number ) {
$s->body = ProcessNumber( $number );
}
);
$s->run( $_SERVER['PATH_INFO'] );