Browse Source

make paths absolute

main
ghost 2 years ago
parent
commit
4298203cab
  1. 16
      crontab/cleaner.php
  2. 24
      crontab/crawler.php
  3. 14
      public/api.php
  4. 14
      public/explore.php
  5. 18
      public/file.php
  6. 6
      public/index.php
  7. 14
      public/search.php

16
crontab/cleaner.php

@ -10,11 +10,11 @@ if (false === sem_acquire($semaphore, true)) {
} }
// Load system dependencies // Load system dependencies
require_once('../config/app.php'); require_once(__DIR__ . '/../config/app.php');
require_once('../library/curl.php'); require_once(__DIR__ . '/../library/curl.php');
require_once('../library/robots.php'); require_once(__DIR__ . '/../library/robots.php');
require_once('../library/mysql.php'); require_once(__DIR__ . '/../library/mysql.php');
require_once('../library/ftp.php'); require_once(__DIR__ . '/../library/ftp.php');
// Connect database // Connect database
$db = new MySQL(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD); $db = new MySQL(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
@ -95,7 +95,7 @@ try {
if ($hostPageSnap->storageLocal) { if ($hostPageSnap->storageLocal) {
unlink('../storage/snap/hp/' . $snapFilePath . $hostPageSnap->timeAdded . '.zip'); unlink(__DIR__ . '/../storage/snap/hp/' . $snapFilePath . $hostPageSnap->timeAdded . '.zip');
} }
if ($hostPageSnap->storageMega) { if ($hostPageSnap->storageMega) {
@ -141,7 +141,7 @@ try {
if ($hostPageSnap->storageLocal) { if ($hostPageSnap->storageLocal) {
unlink('../storage/snap/hp/' . $snapFilePath . $hostPageSnap->timeAdded . '.zip'); unlink(__DIR__ . '/../storage/snap/hp/' . $snapFilePath . $hostPageSnap->timeAdded . '.zip');
} }
if ($hostPageSnap->storageMega) { if ($hostPageSnap->storageMega) {
@ -243,7 +243,7 @@ try {
if ($hostPageSnap->storageLocal) { if ($hostPageSnap->storageLocal) {
unlink('../storage/snap/hp/' . $snapFilePath . $hostPageSnap->timeAdded . '.zip'); unlink(__DIR__ . '/../storage/snap/hp/' . $snapFilePath . $hostPageSnap->timeAdded . '.zip');
} }
if ($hostPageSnap->storageMega) { if ($hostPageSnap->storageMega) {

24
crontab/crawler.php

@ -10,14 +10,14 @@ if (false === sem_acquire($semaphore, true)) {
} }
// Load system dependencies // Load system dependencies
require_once('../config/app.php'); require_once(__DIR__ . '/../config/app.php');
require_once('../library/ftp.php'); require_once(__DIR__ . '/../library/ftp.php');
require_once('../library/curl.php'); require_once(__DIR__ . '/../library/curl.php');
require_once('../library/robots.php'); require_once(__DIR__ . '/../library/robots.php');
require_once('../library/filter.php'); require_once(__DIR__ . '/../library/filter.php');
require_once('../library/parser.php'); require_once(__DIR__ . '/../library/parser.php');
require_once('../library/mysql.php'); require_once(__DIR__ . '/../library/mysql.php');
require_once('../library/vendor/simple_html_dom.php'); require_once(__DIR__ . '/../library/vendor/simple_html_dom.php');
// Check disk quota // Check disk quota
if (CRAWL_STOP_DISK_QUOTA_MB_LEFT > disk_free_space('/') / 1000000) { if (CRAWL_STOP_DISK_QUOTA_MB_LEFT > disk_free_space('/') / 1000000) {
@ -953,8 +953,8 @@ foreach ($db->getHostPageCrawlQueue(CRAWL_PAGE_LIMIT, time() - CRAWL_PAGE_SECOND
$snapTime = time(); $snapTime = time();
$snapPath = chunk_split($queueHostPage->hostPageId, 1, '/'); $snapPath = chunk_split($queueHostPage->hostPageId, 1, '/');
$snapTmp = '../storage/tmp/snap/hp/' . $snapPath . $snapTime . '.zip'; $snapTmp = __DIR__ . '/../storage/tmp/snap/hp/' . $snapPath . $snapTime . '.zip';
@mkdir('../storage/tmp/snap/hp/' . $snapPath, 0755, true); @mkdir(__DIR__ . '/../storage/tmp/snap/hp/' . $snapPath, 0755, true);
// Create new ZIP container // Create new ZIP container
$zip = new ZipArchive(); $zip = new ZipArchive();
@ -983,9 +983,9 @@ foreach ($db->getHostPageCrawlQueue(CRAWL_PAGE_LIMIT, time() - CRAWL_PAGE_SECOND
// Copy tmp snap to the permanent local storage // Copy tmp snap to the permanent local storage
if ($snapLocal) { if ($snapLocal) {
@mkdir('../storage/snap/hp/' . $snapPath, 0755, true); @mkdir(__DIR__ . '/../storage/snap/hp/' . $snapPath, 0755, true);
if (copy($snapTmp, '../storage/snap/hp/' . $snapPath . $snapTime . '.zip')) { if (copy($snapTmp, __DIR__ . '/../storage/snap/hp/' . $snapPath . $snapTime . '.zip')) {
// Update snap location info // Update snap location info
$db->updateHostPageSnapStorageLocal($hostPageSnapId, true); $db->updateHostPageSnapStorageLocal($hostPageSnapId, true);

14
public/api.php

@ -4,13 +4,13 @@
define('API_VERSION', 0.10); define('API_VERSION', 0.10);
// Load system dependencies // Load system dependencies
require_once('../config/app.php'); require_once(__DIR__ . '/../config/app.php');
require_once('../library/curl.php'); require_once(__DIR__ . '/../library/curl.php');
require_once('../library/robots.php'); require_once(__DIR__ . '/../library/robots.php');
require_once('../library/filter.php'); require_once(__DIR__ . '/../library/filter.php');
require_once('../library/parser.php'); require_once(__DIR__ . '/../library/parser.php');
require_once('../library/mysql.php'); require_once(__DIR__ . '/../library/mysql.php');
require_once('../library/sphinxql.php'); require_once(__DIR__ . '/../library/sphinxql.php');
if (API_ENABLED) { if (API_ENABLED) {

14
public/explore.php

@ -1,13 +1,13 @@
<?php <?php
// Load system dependencies // Load system dependencies
require_once('../config/app.php'); require_once(__DIR__ . '/../config/app.php');
require_once('../library/curl.php'); require_once(__DIR__ . '/../library/curl.php');
require_once('../library/robots.php'); require_once(__DIR__ . '/../library/robots.php');
require_once('../library/filter.php'); require_once(__DIR__ . '/../library/filter.php');
require_once('../library/parser.php'); require_once(__DIR__ . '/../library/parser.php');
require_once('../library/mysql.php'); require_once(__DIR__ . '/../library/mysql.php');
require_once('../library/sphinxql.php'); require_once(__DIR__ . '/../library/sphinxql.php');
// Connect Sphinx search server // Connect Sphinx search server
$sphinx = new SphinxQL(SPHINX_HOST, SPHINX_PORT); $sphinx = new SphinxQL(SPHINX_HOST, SPHINX_PORT);

18
public/file.php

@ -1,9 +1,9 @@
<?php <?php
require_once('../config/app.php'); require_once(__DIR__ . '/../config/app.php');
require_once('../library/icon.php'); require_once(__DIR__ . '/../library/icon.php');
require_once('../library/mysql.php'); require_once(__DIR__ . '/../library/mysql.php');
require_once('../library/ftp.php'); require_once(__DIR__ . '/../library/ftp.php');
$type = !empty($_GET['type']) ? $_GET['type'] : false; $type = !empty($_GET['type']) ? $_GET['type'] : false;
@ -22,7 +22,7 @@ switch ($type) {
if (WEBSITE_IDENTICON_IMAGE_CACHE) { if (WEBSITE_IDENTICON_IMAGE_CACHE) {
$filename = dirname(__FILE__) . '/../storage/cache/' . $query . '.webp'; $filename = __DIR__ . '/../storage/cache/' . $query . '.webp';
if (!file_exists($filename)) { if (!file_exists($filename)) {
@ -73,10 +73,10 @@ switch ($type) {
$snapFile = 'hp/' . chunk_split($hostPageSnap->hostPageId, 1, '/') . $hostPageSnap->timeAdded . '.zip'; $snapFile = 'hp/' . chunk_split($hostPageSnap->hostPageId, 1, '/') . $hostPageSnap->timeAdded . '.zip';
// Download local snap in higher priority if possible // Download local snap in higher priority if possible
if ($hostPageSnap->storageLocal && file_exists('../storage/snap/' . $snapFile) && if ($hostPageSnap->storageLocal && file_exists(__DIR__ . '/../storage/snap/' . $snapFile) &&
is_readable('../storage/snap/' . $snapFile)) { is_readable(__DIR__ . '/../storage/snap/' . $snapFile)) {
$snapSize = (int) @filesize('../storage/snap/' . $snapFile); $snapSize = (int) @filesize(__DIR__ . '/../storage/snap/' . $snapFile);
$db->updateHostPageSnapDownload($hostPageSnapDownloadId, 'local', $snapSize, 200); $db->updateHostPageSnapDownload($hostPageSnapDownloadId, 'local', $snapSize, 200);
@ -85,7 +85,7 @@ switch ($type) {
header(sprintf('Content-Disposition: filename="snap.%s.%s.%s.zip"', $hostPageSnap->hostPageSnapId, header(sprintf('Content-Disposition: filename="snap.%s.%s.%s.zip"', $hostPageSnap->hostPageSnapId,
$hostPageSnap->hostPageId, $hostPageSnap->hostPageId,
$hostPageSnap->timeAdded)); $hostPageSnap->timeAdded));
readfile('../storage/snap/' . $snapFile); readfile(__DIR__ . '/../storage/snap/' . $snapFile);
// Then try to download from MEGA storage if exists // Then try to download from MEGA storage if exists
} else if ($hostPageSnap->storageMega) { } else if ($hostPageSnap->storageMega) {

6
public/index.php

@ -1,9 +1,9 @@
<?php <?php
// Load system dependencies // Load system dependencies
require_once('../config/app.php'); require_once(__DIR__ . '/../config/app.php');
require_once('../library/filter.php'); require_once(__DIR__ . '/../library/filter.php');
require_once('../library/sphinxql.php'); require_once(__DIR__ . '/../library/sphinxql.php');
// Connect Sphinx search server // Connect Sphinx search server
$sphinx = new SphinxQL(SPHINX_HOST, SPHINX_PORT); $sphinx = new SphinxQL(SPHINX_HOST, SPHINX_PORT);

14
public/search.php

@ -1,13 +1,13 @@
<?php <?php
// Load system dependencies // Load system dependencies
require_once('../config/app.php'); require_once(__DIR__ . '/../config/app.php');
require_once('../library/curl.php'); require_once(__DIR__ . '/../library/curl.php');
require_once('../library/robots.php'); require_once(__DIR__ . '/../library/robots.php');
require_once('../library/filter.php'); require_once(__DIR__ . '/../library/filter.php');
require_once('../library/parser.php'); require_once(__DIR__ . '/../library/parser.php');
require_once('../library/mysql.php'); require_once(__DIR__ . '/../library/mysql.php');
require_once('../library/sphinxql.php'); require_once(__DIR__ . '/../library/sphinxql.php');
// Connect Sphinx search server // Connect Sphinx search server
$sphinx = new SphinxQL(SPHINX_HOST, SPHINX_PORT); $sphinx = new SphinxQL(SPHINX_HOST, SPHINX_PORT);

Loading…
Cancel
Save