Browse Source

move connections to the bootstrap

main
ghost 1 year ago
parent
commit
bf759f9dd7
  1. 24
      src/config/bootstrap.php
  2. 3
      src/crontab/export/feed.php
  3. 3
      src/crontab/import/feed.php
  4. 12
      src/crontab/scrape.php
  5. 12
      src/crontab/sitemap.php
  6. 12
      src/public/action.php
  7. 12
      src/public/download.php
  8. 12
      src/public/edit.php
  9. 12
      src/public/faq.php
  10. 24
      src/public/index.php
  11. 24
      src/public/magnet.php
  12. 12
      src/public/node.php
  13. 12
      src/public/welcome.php

24
src/config/bootstrap.php

@ -42,3 +42,27 @@ require_once __DIR__ . '/../library/time.php';
// Vendors autoload // Vendors autoload
require_once __DIR__ . '/../../vendor/autoload.php'; require_once __DIR__ . '/../../vendor/autoload.php';
// Connect database
try {
$db = new Database(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
} catch (Exception $e) {
var_dump($e);
exit;
}
// Connect Sphinx
try {
$sphinx = new Sphinx(SPHINX_HOST, SPHINX_PORT);
} catch(Exception $e) {
var_dump($e);
exit;
}

3
src/crontab/export/feed.php

@ -29,9 +29,6 @@ $public = [
// Begin export // Begin export
try try
{ {
// Connect DB
$db = new Database(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
// Init API folder if not exists // Init API folder if not exists
@mkdir(__DIR__ . '/../public/api'); @mkdir(__DIR__ . '/../public/api');

3
src/crontab/import/feed.php

@ -28,9 +28,6 @@ $debug =
// Begin export // Begin export
try try
{ {
// Connect DB
$db = new Database(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
// Transaction begin // Transaction begin
$db->beginTransaction(); $db->beginTransaction();

12
src/crontab/scrape.php

@ -19,18 +19,6 @@ $debug = [
], ],
]; ];
// Connect DB
try {
$db = new Database(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
} catch(Exception $e) {
var_dump($e);
exit;
}
// Init Scraper // Init Scraper
try { try {

12
src/crontab/sitemap.php

@ -19,18 +19,6 @@ $debug = [
], ],
]; ];
// Connect DB
try {
$db = new Database(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
} catch(Exception $e) {
var_dump($e);
exit;
}
// Begin // Begin
try { try {

12
src/public/action.php

@ -3,18 +3,6 @@
// Bootstrap // Bootstrap
require_once __DIR__ . '/../config/bootstrap.php'; require_once __DIR__ . '/../config/bootstrap.php';
// Connect database
try {
$db = new Database(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
} catch (Exception $e) {
var_dump($e);
exit;
}
// Define response // Define response
$response = (object) $response = (object)
[ [

12
src/public/download.php

@ -3,18 +3,6 @@
// Bootstrap // Bootstrap
require_once __DIR__ . '/../config/bootstrap.php'; require_once __DIR__ . '/../config/bootstrap.php';
// Connect database
try {
$db = new Database(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
} catch (Exception $e) {
var_dump($e);
exit;
}
// Define response // Define response
$response = (object) $response = (object)
[ [

12
src/public/edit.php

@ -3,18 +3,6 @@
// Bootstrap // Bootstrap
require_once __DIR__ . '/../config/bootstrap.php'; require_once __DIR__ . '/../config/bootstrap.php';
// Connect database
try {
$db = new Database(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
} catch (Exception $e) {
var_dump($e);
exit;
}
// Define variables // Define variables
$response = (object) $response = (object)
[ [

12
src/public/faq.php

@ -4,18 +4,6 @@
// Bootstrap // Bootstrap
require_once __DIR__ . '/../config/bootstrap.php'; require_once __DIR__ . '/../config/bootstrap.php';
// Connect database
try {
$db = new Database(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
} catch (Exception $e) {
var_dump($e);
exit;
}
// Define response // Define response
$response = (object) $response = (object)
[ [

24
src/public/index.php

@ -3,30 +3,6 @@
// Bootstrap dependencies // Bootstrap dependencies
require_once __DIR__ . '/../config/bootstrap.php'; require_once __DIR__ . '/../config/bootstrap.php';
// Connect Sphinx
try {
$sphinx = new Sphinx(SPHINX_HOST, SPHINX_PORT);
} catch(Exception $e) {
var_dump($e);
exit;
}
// Connect database
try {
$db = new Database(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
} catch (Exception $e) {
var_dump($e);
exit;
}
// Define variables // Define variables
$request = (object) $request = (object)
[ [

24
src/public/magnet.php

@ -3,30 +3,6 @@
// Bootstrap // Bootstrap
require_once __DIR__ . '/../config/bootstrap.php'; require_once __DIR__ . '/../config/bootstrap.php';
// Connect Sphinx
try {
$sphinx = new Sphinx(SPHINX_HOST, SPHINX_PORT);
} catch(Exception $e) {
var_dump($e);
exit;
}
// Connect database
try {
$db = new Database(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
} catch (Exception $e) {
var_dump($e);
exit;
}
// Define response // Define response
$response = (object) $response = (object)
[ [

12
src/public/node.php

@ -4,18 +4,6 @@
// Bootstrap // Bootstrap
require_once __DIR__ . '/../config/bootstrap.php'; require_once __DIR__ . '/../config/bootstrap.php';
// Connect database
try {
$db = new Database(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
} catch (Exception $e) {
var_dump($e);
exit;
}
// Define response // Define response
$response = (object) $response = (object)
[ [

12
src/public/welcome.php

@ -4,18 +4,6 @@
// Bootstrap // Bootstrap
require_once __DIR__ . '/../config/bootstrap.php'; require_once __DIR__ . '/../config/bootstrap.php';
// Connect database
try {
$db = new Database(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
} catch (Exception $e) {
var_dump($e);
exit;
}
// Define response // Define response
$response = (object) $response = (object)
[ [

Loading…
Cancel
Save