-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathparser.php
More file actions
47 lines (45 loc) · 1.62 KB
/
parser.php
File metadata and controls
47 lines (45 loc) · 1.62 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
<?php
date_default_timezone_set('Europe/Moscow');
define('DS', DIRECTORY_SEPARATOR);
try {
spl_autoload_register(
function ($className) {
$fileName = __DIR__ . DS . str_replace('\\', DS, $className) . '.php';
if (!is_file($fileName) || !is_readable($fileName)) {
throw new \Exception(sprintf('Для класса %s не удалось прочитать файл %s', $className, $fileName));
}
require_once $fileName;
}
);
$config = new \components\system\Config();
$config->setFileName(__DIR__ . DS . 'config.php');
$application = new \components\system\Application($config);
$application->get('login')->login();
$longopts = array(
"group::",
"politics::",
"position::",
);
$options = getopt('', $longopts);
$filters = array();
$hasFilter = false;
foreach ($longopts as $opt) {
$opt = str_replace(':', '', $opt);
$filters[$opt] = isset($options[$opt]) ? (string) $options[$opt] : null;
if (!is_null($filters[$opt])) {
$hasFilter = true;
}
}
if (!$hasFilter) {
throw new Exception('Нет ни одного фильтра. Доступные фильтры: ' . implode(', ', array_keys($filters)));
}
$groupId = isset($options['group']) ? $options['group'] : 0;
if (!is_numeric($groupId)) {
$service = 'groups.communities';
} else {
$service = 'groups.subscribers';
}
$application->get($service)->getList($groupId, $filters);
} catch (\Exception $e) {
die($e->getMessage() . PHP_EOL);
}