-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.php
60 lines (49 loc) · 1.75 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
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once __DIR__ . '/vendor/autoload.php';
$config = require 'config.php';
use App\Services\Database\DatabaseService;
use App\Services\Log\LogService;
use App\Services\Queue\QueueService;
use App\Services\Victorina\VictorinaService;
use App\Services\Antispam\AntispamService;
use App\Services\ChatAdministration\ChatAdministrationService;
use App\Services\Chatbot\ChatbotService;
use App\Actions\Curl;
DatabaseService::instance();
if (isset($_POST)) {
$data = json_decode(file_get_contents("php://input"), true);
$errors = array();
if (isset($data['secret'])) {
$LogService = new LogService($data);
$id = $LogService->add();
$LogService = new QueueService();
$LogService->add($data);
switch ($data['secret']) {
case 'victorina':
$victorina = new VictorinaService($data, $config, $id);
$victorina->check();
break;
case 'ekb':
$antispam = new AntispamService($data, $config, $id);
$antispam->check();
$adm = new ChatAdministrationService($data, $config, $id);
$adm->check();
break;
case 'chat':
try {
$data['id'] = $id;
$host = "https://$_SERVER[HTTP_HOST]";
$url = $host . "/vk/curl/chatbot.php";
$curl = new Curl($url, $data, 3);
$curl_result = $curl->exec();
} catch (Exception $ex) {
//LogService::test(['err' => $ex->getMessage()]);
}
break;
}
}
echo 'ok';
}