mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-22 22:33:55 -07:00
Merge 005058277c
into cb28304866
This commit is contained in:
commit
b619203e96
9 changed files with 803 additions and 520 deletions
52
common.php
52
common.php
|
@ -15,12 +15,40 @@ if (!defined('BB_ROOT')) define('BB_ROOT', './');
|
||||||
|
|
||||||
header('X-Frame-Options: SAMEORIGIN');
|
header('X-Frame-Options: SAMEORIGIN');
|
||||||
|
|
||||||
// Get initial config
|
// Cloudflare
|
||||||
require(BB_ROOT . 'library/config.php');
|
if (isset($_SERVER['HTTP_CF_CONNECTING_IP']))
|
||||||
|
{
|
||||||
|
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP'];
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once BB_ROOT . 'library/defines.php';
|
||||||
|
|
||||||
// Composer
|
// Composer
|
||||||
require(BB_ROOT . 'vendor/autoload.php');
|
require(BB_ROOT . 'vendor/autoload.php');
|
||||||
|
|
||||||
|
require_once BB_ROOT . 'library/config.php';
|
||||||
|
|
||||||
|
$di = new \TorrentPier\Di();
|
||||||
|
|
||||||
|
$di->register(new \TorrentPier\ServiceProviders\ConfigServiceProvider, [
|
||||||
|
'config.file.system.main' => __DIR__ . '/library/config.php',
|
||||||
|
'config.file.local.main' => __DIR__ . '/library/config.local.php',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$di->register(new \TorrentPier\ServiceProviders\DbServiceProvider, [
|
||||||
|
'config.db' => $di->config->db->toArray()
|
||||||
|
]);
|
||||||
|
|
||||||
|
$di->register(new \TorrentPier\ServiceProviders\SphinxServiceProvider, [
|
||||||
|
'config.sphinx' => $di->config->sphinx->toArray()
|
||||||
|
]);
|
||||||
|
|
||||||
|
$bb_cfg = $di->config->toArray();
|
||||||
|
$page_cfg = $di->config->page->toArray();
|
||||||
|
$tr_cfg = $di->config->tracker->toArray();
|
||||||
|
$rating_limits = $di->config->rating->toArray();
|
||||||
|
define('BB_CFG_LOADED', true);
|
||||||
|
|
||||||
// Load Zend Framework
|
// Load Zend Framework
|
||||||
use Zend\Loader\StandardAutoloader;
|
use Zend\Loader\StandardAutoloader;
|
||||||
$loader = new StandardAutoloader(array('autoregister_zf' => true));
|
$loader = new StandardAutoloader(array('autoregister_zf' => true));
|
||||||
|
@ -65,12 +93,28 @@ define('BOT_UID', -746);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database
|
* Database
|
||||||
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
// Core DB class
|
// Core DB class
|
||||||
require(CORE_DIR . 'dbs.php');
|
require(CORE_DIR . 'dbs.php');
|
||||||
$DBS = new DBS($bb_cfg);
|
$DBS = new DBS([
|
||||||
|
'db' => [
|
||||||
|
'db' => [
|
||||||
|
$di->config->db->hostname,
|
||||||
|
$di->config->db->database,
|
||||||
|
$di->config->db->username,
|
||||||
|
$di->config->db->password,
|
||||||
|
$di->config->db->charset,
|
||||||
|
false
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'db_alias' => $bb_cfg['db_alias']
|
||||||
|
]);
|
||||||
|
|
||||||
function DB ($db_alias = 'db1')
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
function DB ($db_alias = 'db')
|
||||||
{
|
{
|
||||||
global $DBS;
|
global $DBS;
|
||||||
return $DBS->get_db_obj($db_alias);
|
return $DBS->get_db_obj($db_alias);
|
||||||
|
|
|
@ -38,11 +38,13 @@
|
||||||
"zendframework/zend-loader": "^2.5",
|
"zendframework/zend-loader": "^2.5",
|
||||||
"zendframework/zend-mail": "^2.5",
|
"zendframework/zend-mail": "^2.5",
|
||||||
"zendframework/zend-session": "^2.5",
|
"zendframework/zend-session": "^2.5",
|
||||||
"zendframework/zend-version": "^2.5"
|
"zendframework/zend-version": "^2.5",
|
||||||
|
"pimple/pimple": "^3.0",
|
||||||
|
"ripaclub/sphinxsearch": "^0.8.0"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"TorrentPier\\": "library/"
|
"TorrentPier\\": "src/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"minimum-stability": "stable",
|
"minimum-stability": "stable",
|
||||||
|
|
115
composer.lock
generated
115
composer.lock
generated
|
@ -4,8 +4,8 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"hash": "9a65af4ba5edfe73ffdded1ea1b995f7",
|
"hash": "c254b55c3197ea827eb5e4a75b49e6a6",
|
||||||
"content-hash": "0074d54ee83fdffa1dec1fba0adc560d",
|
"content-hash": "de4bc86e5ded359c5716096e4c795fc0",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "container-interop/container-interop",
|
"name": "container-interop/container-interop",
|
||||||
|
@ -79,6 +79,117 @@
|
||||||
],
|
],
|
||||||
"time": "2015-09-02 17:23:59"
|
"time": "2015-09-02 17:23:59"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "pimple/pimple",
|
||||||
|
"version": "v3.0.2",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/silexphp/Pimple.git",
|
||||||
|
"reference": "a30f7d6e57565a2e1a316e1baf2a483f788b258a"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/silexphp/Pimple/zipball/a30f7d6e57565a2e1a316e1baf2a483f788b258a",
|
||||||
|
"reference": "a30f7d6e57565a2e1a316e1baf2a483f788b258a",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.3.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "3.0.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-0": {
|
||||||
|
"Pimple": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Fabien Potencier",
|
||||||
|
"email": "fabien@symfony.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Pimple, a simple Dependency Injection Container",
|
||||||
|
"homepage": "http://pimple.sensiolabs.org",
|
||||||
|
"keywords": [
|
||||||
|
"container",
|
||||||
|
"dependency injection"
|
||||||
|
],
|
||||||
|
"time": "2015-09-11 15:10:35"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ripaclub/sphinxsearch",
|
||||||
|
"version": "0.8.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/ripaclub/sphinxsearch.git",
|
||||||
|
"reference": "f9d7550b6250519785e4db15c32b23865f2d49f3"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/ripaclub/sphinxsearch/zipball/f9d7550b6250519785e4db15c32b23865f2d49f3",
|
||||||
|
"reference": "f9d7550b6250519785e4db15c32b23865f2d49f3",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.5",
|
||||||
|
"zendframework/zend-db": "~2.4",
|
||||||
|
"zendframework/zend-servicemanager": "~2.4",
|
||||||
|
"zendframework/zend-stdlib": "~2.4"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "~4.3",
|
||||||
|
"satooshi/php-coveralls": "dev-master"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ripaclub/zf2-sphinxsearch": "ZF2 integration module for SphinxSearch library",
|
||||||
|
"ripaclub/zf2-sphinxsearch-tool": "Utility that provides a set of tools to create and handle Sphinx Search configs and sources"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"SphinxSearch\\": "library",
|
||||||
|
"SphinxSearchTest\\": "tests"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"BSD-2-Clause"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Leonardo Grasso",
|
||||||
|
"email": "me@leonardograsso.com",
|
||||||
|
"homepage": "http://github.com/leogr"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Leo Di Donato",
|
||||||
|
"email": "leodidonato@gmail.com",
|
||||||
|
"homepage": "http://github.com/leodido"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Sphinx Search library provides SphinxQL indexing and searching features",
|
||||||
|
"homepage": "https://github.com/ripaclub/sphinxsearch",
|
||||||
|
"keywords": [
|
||||||
|
"indexing",
|
||||||
|
"pdo",
|
||||||
|
"query builder",
|
||||||
|
"search",
|
||||||
|
"search engine",
|
||||||
|
"sphinx",
|
||||||
|
"sphinxql",
|
||||||
|
"zf2"
|
||||||
|
],
|
||||||
|
"time": "2015-06-22 18:12:29"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "rych/bencode",
|
"name": "rych/bencode",
|
||||||
"version": "v1.0.0",
|
"version": "v1.0.0",
|
||||||
|
|
File diff suppressed because it is too large
Load diff
62
library/defines.php
Normal file
62
library/defines.php
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// Ratio limits
|
||||||
|
define('TR_RATING_LIMITS', true); // ON/OFF
|
||||||
|
define('MIN_DL_FOR_RATIO', 10737418240); // 10 GB in bytes, 0 - disable
|
||||||
|
|
||||||
|
// Path (trailing slash '/' at the end: XX_PATH - without, XX_DIR - with)
|
||||||
|
define('BB_PATH', realpath(BB_ROOT) );
|
||||||
|
define('ADMIN_DIR', BB_PATH .'/admin/' );
|
||||||
|
define('DATA_DIR', BB_PATH .'/data/' );
|
||||||
|
define('INT_DATA_DIR', BB_PATH .'/internal_data/' );
|
||||||
|
define('AJAX_HTML_DIR', BB_ROOT .'/internal_data/ajax_html/' );
|
||||||
|
define('CACHE_DIR', BB_PATH .'/internal_data/cache/' );
|
||||||
|
define('LOG_DIR', BB_PATH .'/internal_data/log/' );
|
||||||
|
define('SITEMAP_DIR', BB_PATH .'/internal_data/sitemap/' );
|
||||||
|
define('TRIGGERS_DIR', BB_PATH .'/internal_data/triggers/' );
|
||||||
|
define('AJAX_DIR', BB_ROOT .'/library/ajax/' );
|
||||||
|
define('CFG_DIR', BB_PATH .'/library/config/' );
|
||||||
|
define('INC_DIR', BB_PATH .'/library/includes/' );
|
||||||
|
define('CLASS_DIR', BB_PATH .'/library/includes/classes/');
|
||||||
|
define('CORE_DIR', BB_PATH .'/library/includes/core/' );
|
||||||
|
define('UCP_DIR', BB_PATH .'/library/includes/ucp/' );
|
||||||
|
define('LANG_ROOT_DIR', BB_PATH .'/library/language/' );
|
||||||
|
define('IMAGES_DIR', BB_PATH .'/styles/images/' );
|
||||||
|
define('TEMPLATES_DIR', BB_PATH .'/styles/templates/' );
|
||||||
|
|
||||||
|
// Templates
|
||||||
|
define('ADMIN_TPL_DIR', TEMPLATES_DIR .'/admin/');
|
||||||
|
|
||||||
|
// Debug
|
||||||
|
define('DBG_LOG', false); // enable forum debug (off on production)
|
||||||
|
define('DBG_TRACKER', false); // enable tracker debug (off on production)
|
||||||
|
define('COOKIE_DBG', 'bb_dbg'); // debug cookie name
|
||||||
|
define('SQL_DEBUG', true); // enable forum sql & cache debug
|
||||||
|
define('SQL_LOG_ERRORS', true); // all SQL_xxx options enabled only if SQL_DEBUG == TRUE
|
||||||
|
define('SQL_CALC_QUERY_TIME', true); // for stats
|
||||||
|
define('SQL_LOG_SLOW_QUERIES', true); // log sql slow queries
|
||||||
|
define('SQL_SLOW_QUERY_TIME', 10); // slow query in seconds
|
||||||
|
define('SQL_PREPEND_SRC_COMM', false); // prepend source file comment to sql query
|
||||||
|
|
||||||
|
// Log options
|
||||||
|
define('LOG_EXT', 'log');
|
||||||
|
define('LOG_SEPR', ' | ');
|
||||||
|
define('LOG_LF', "\n");
|
||||||
|
define('LOG_MAX_SIZE', 1048576); // bytes
|
||||||
|
|
||||||
|
// Error reporting
|
||||||
|
ini_set('error_reporting', E_ALL);
|
||||||
|
ini_set('display_errors', 0);
|
||||||
|
ini_set('log_errors', 1);
|
||||||
|
ini_set('error_log', LOG_DIR .'php_err.log');
|
||||||
|
|
||||||
|
// Triggers
|
||||||
|
define('BB_ENABLED', TRIGGERS_DIR .'$on');
|
||||||
|
define('BB_DISABLED', TRIGGERS_DIR .'$off');
|
||||||
|
define('CRON_ALLOWED', TRIGGERS_DIR .'cron_allowed');
|
||||||
|
define('CRON_RUNNING', TRIGGERS_DIR .'cron_running');
|
||||||
|
|
||||||
|
// Misc
|
||||||
|
define('MEM_USAGE', function_exists('memory_get_usage'));
|
||||||
|
|
||||||
|
define('GZIP_OUTPUT_ALLOWED', (extension_loaded('zlib') && !ini_get('zlib.output_compression')));
|
40
src/Di.php
Normal file
40
src/Di.php
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace TorrentPier;
|
||||||
|
|
||||||
|
use Pimple\Container;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Di
|
||||||
|
* Dependency Injection Container
|
||||||
|
*
|
||||||
|
* @package TorrentPier
|
||||||
|
*/
|
||||||
|
class Di extends Container
|
||||||
|
{
|
||||||
|
private static $instance;
|
||||||
|
|
||||||
|
public function __construct(array $values = [])
|
||||||
|
{
|
||||||
|
parent::__construct($values);
|
||||||
|
static::$instance = $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getInstance()
|
||||||
|
{
|
||||||
|
if (static::$instance instanceof Container) {
|
||||||
|
return static::$instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \Exception('The container has not been initialized');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __get($id)
|
||||||
|
{
|
||||||
|
if ($this->offsetExists($id)) {
|
||||||
|
return $this->offsetGet($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \Exception("Service '{$id}' is not registered in the container");
|
||||||
|
}
|
||||||
|
}
|
26
src/ServiceProviders/ConfigServiceProvider.php
Normal file
26
src/ServiceProviders/ConfigServiceProvider.php
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace TorrentPier\ServiceProviders;
|
||||||
|
|
||||||
|
use Pimple\Container;
|
||||||
|
use Pimple\ServiceProviderInterface;
|
||||||
|
use Zend\Config\Factory;
|
||||||
|
|
||||||
|
class ConfigServiceProvider implements ServiceProviderInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function register(Container $container)
|
||||||
|
{
|
||||||
|
$container['config'] = function($container) {
|
||||||
|
$config = Factory::fromFile($container['config.file.system.main'], true);
|
||||||
|
|
||||||
|
if (isset($container['config.file.local.main']) && file_exists($container['config.file.local.main'])) {
|
||||||
|
$config->merge(Factory::fromFile($container['config.file.local.main'], true));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $config;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
22
src/ServiceProviders/DbServiceProvider.php
Normal file
22
src/ServiceProviders/DbServiceProvider.php
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace TorrentPier\ServiceProviders;
|
||||||
|
|
||||||
|
use Pimple\Container;
|
||||||
|
use Pimple\ServiceProviderInterface;
|
||||||
|
use Zend\Db\Adapter\Adapter;
|
||||||
|
|
||||||
|
class DbServiceProvider implements ServiceProviderInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function register(Container $container)
|
||||||
|
{
|
||||||
|
$container['db'] = function($container) {
|
||||||
|
$adapter = new Adapter($container['config.db']);
|
||||||
|
unset($container['config.db']);
|
||||||
|
return $adapter;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
41
src/ServiceProviders/SphinxServiceProvider.php
Normal file
41
src/ServiceProviders/SphinxServiceProvider.php
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace TorrentPier\ServiceProviders;
|
||||||
|
|
||||||
|
use Pimple\Container;
|
||||||
|
use Pimple\ServiceProviderInterface;
|
||||||
|
use SphinxSearch\Db\Adapter\Driver\Pdo\Statement;
|
||||||
|
use SphinxSearch\Db\Adapter\Exception\UnsupportedDriverException;
|
||||||
|
use SphinxSearch\Db\Adapter\Platform\SphinxQL;
|
||||||
|
use Zend\Db\Adapter\Adapter;
|
||||||
|
use Zend\Db\Adapter\Driver\Mysqli\Mysqli;
|
||||||
|
use Zend\Db\Adapter\Driver\Pdo\Pdo;
|
||||||
|
|
||||||
|
class SphinxServiceProvider implements ServiceProviderInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function register(Container $container)
|
||||||
|
{
|
||||||
|
$container['sphinx'] = function($container) {
|
||||||
|
$platform = new SphinxQL();
|
||||||
|
$adapter = new Adapter($container['config.sphinx']);
|
||||||
|
|
||||||
|
$driver = $adapter->getDriver();
|
||||||
|
// Check driver
|
||||||
|
if ($driver instanceof Pdo && $driver->getDatabasePlatformName(Pdo::NAME_FORMAT_CAMELCASE) == 'Mysql' ) {
|
||||||
|
$driver->registerStatementPrototype(new Statement());
|
||||||
|
} elseif (!$driver instanceof Mysqli) {
|
||||||
|
$class = get_class($driver);
|
||||||
|
throw new UnsupportedDriverException(
|
||||||
|
$class . ' not supported. Use Zend\Db\Adapter\Driver\Pdo\Pdo or Zend\Db\Adapter\Driver\Mysqli\Mysqli'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$platform->setDriver($adapter->getDriver());
|
||||||
|
unset($container['config.sphinx']);
|
||||||
|
return $adapter;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue