-
Notifications
You must be signed in to change notification settings - Fork 96
/
boris
executable file
·85 lines (75 loc) · 2.48 KB
/
boris
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
#! /usr/bin/env php
<?php
use Gazelle\Enum\FeaturedAlbumType;
use Gazelle\Enum\LeechType;
use Gazelle\Enum\LeechReason;
error_reporting(E_ALL);
require_once(__DIR__ . '/lib/bootstrap.php');
require_once(__DIR__ . '/vendor/d11wtq/boris/lib/autoload.php');
require_once('tests/helper.php');
$remove = [];
foreach (['pcntl_fork', 'pcntl_signal', 'pcntl_signal_dispatch', 'pcntl_waitpid'] as $function) {
if (!function_exists($function)) {
$remove[] = $function;
}
}
if ($remove) {
echo "The following functions musst be removed from the `disable_functions` directive in cli/php.ini:\n";
echo "=> ", implode(', ', $remove), "\n";
exit;
}
define('BORIS', 1);
$_SERVER['HTTP_USER_AGENT'] = 'boris';
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
Gazelle\Base::setRequestContext(new Gazelle\BaseRequestContext(
'boris', $_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT']
));
$b = new Boris\Boris(SITE_NAME . '> ');
$b->setInspector(new Boris\ExportInspector);
$torMan = new Gazelle\Manager\Torrent;
$userMan = new Gazelle\Manager\User;
$preload = [
'cache' => $Cache,
'db' => Gazelle\DB::DB(),
'debug' => $Debug,
'Twig' => $Twig,
'artMan' => new Gazelle\Manager\Artist,
'bonus' => new Gazelle\Manager\Bonus,
'collMan' => new Gazelle\Manager\Collage,
'forMan' => new Gazelle\Manager\Forum,
'pg' => new Gazelle\DB\Pg(GZPG_DSN),
'postMan' => new Gazelle\Manager\ForumPost,
'privMan' => new Gazelle\Manager\Privilege,
'repMan' => new Gazelle\Manager\Report($userMan),
'reqMan' => new Gazelle\Manager\Request,
'tagMan' => new Gazelle\Manager\Tag,
'tgMan' => new Gazelle\Manager\TGroup,
'threadMan' => new Gazelle\Manager\ForumThread,
'torMan' => $torMan,
'trepMan' => new Gazelle\Manager\Torrent\Report($torMan),
'trepTypeMan' => new Gazelle\Manager\Torrent\ReportType,
'userMan' => $userMan,
];
printf("** preloaded objects:\n** %s\n", implode(', ', array_keys($preload)));
$b->setLocal($preload);
$b->start();
/*
* Sample usage:
*
./boris
[1] ops> $db->query('select count(*) from torrents');
// object(mysqli_result)(
// 'current_field' => NULL,
// 'field_count' => NULL,
// 'lengths' => NULL,
// 'num_rows' => NULL,
// 'type' => NULL
// )
[2] ops> $db->to_array();
// array(
// 0 => array(
// 0 => '14',
// 'count(*)' => '14'
// )
// )
*/