From 4298203cabb87053f97a3e87c0a0d7527f1b68d0 Mon Sep 17 00:00:00 2001 From: ghost Date: Fri, 30 Jun 2023 14:38:29 +0300 Subject: [PATCH] make paths absolute --- crontab/cleaner.php | 16 ++++++++-------- crontab/crawler.php | 24 ++++++++++++------------ public/api.php | 14 +++++++------- public/explore.php | 14 +++++++------- public/file.php | 18 +++++++++--------- public/index.php | 6 +++--- public/search.php | 14 +++++++------- 7 files changed, 53 insertions(+), 53 deletions(-) diff --git a/crontab/cleaner.php b/crontab/cleaner.php index d383435..286eefd 100644 --- a/crontab/cleaner.php +++ b/crontab/cleaner.php @@ -10,11 +10,11 @@ if (false === sem_acquire($semaphore, true)) { } // Load system dependencies -require_once('../config/app.php'); -require_once('../library/curl.php'); -require_once('../library/robots.php'); -require_once('../library/mysql.php'); -require_once('../library/ftp.php'); +require_once(__DIR__ . '/../config/app.php'); +require_once(__DIR__ . '/../library/curl.php'); +require_once(__DIR__ . '/../library/robots.php'); +require_once(__DIR__ . '/../library/mysql.php'); +require_once(__DIR__ . '/../library/ftp.php'); // Connect database $db = new MySQL(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD); @@ -95,7 +95,7 @@ try { if ($hostPageSnap->storageLocal) { - unlink('../storage/snap/hp/' . $snapFilePath . $hostPageSnap->timeAdded . '.zip'); + unlink(__DIR__ . '/../storage/snap/hp/' . $snapFilePath . $hostPageSnap->timeAdded . '.zip'); } if ($hostPageSnap->storageMega) { @@ -141,7 +141,7 @@ try { if ($hostPageSnap->storageLocal) { - unlink('../storage/snap/hp/' . $snapFilePath . $hostPageSnap->timeAdded . '.zip'); + unlink(__DIR__ . '/../storage/snap/hp/' . $snapFilePath . $hostPageSnap->timeAdded . '.zip'); } if ($hostPageSnap->storageMega) { @@ -243,7 +243,7 @@ try { if ($hostPageSnap->storageLocal) { - unlink('../storage/snap/hp/' . $snapFilePath . $hostPageSnap->timeAdded . '.zip'); + unlink(__DIR__ . '/../storage/snap/hp/' . $snapFilePath . $hostPageSnap->timeAdded . '.zip'); } if ($hostPageSnap->storageMega) { diff --git a/crontab/crawler.php b/crontab/crawler.php index 75ca6d7..550daba 100644 --- a/crontab/crawler.php +++ b/crontab/crawler.php @@ -10,14 +10,14 @@ if (false === sem_acquire($semaphore, true)) { } // Load system dependencies -require_once('../config/app.php'); -require_once('../library/ftp.php'); -require_once('../library/curl.php'); -require_once('../library/robots.php'); -require_once('../library/filter.php'); -require_once('../library/parser.php'); -require_once('../library/mysql.php'); -require_once('../library/vendor/simple_html_dom.php'); +require_once(__DIR__ . '/../config/app.php'); +require_once(__DIR__ . '/../library/ftp.php'); +require_once(__DIR__ . '/../library/curl.php'); +require_once(__DIR__ . '/../library/robots.php'); +require_once(__DIR__ . '/../library/filter.php'); +require_once(__DIR__ . '/../library/parser.php'); +require_once(__DIR__ . '/../library/mysql.php'); +require_once(__DIR__ . '/../library/vendor/simple_html_dom.php'); // Check disk quota 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(); $snapPath = chunk_split($queueHostPage->hostPageId, 1, '/'); - $snapTmp = '../storage/tmp/snap/hp/' . $snapPath . $snapTime . '.zip'; - @mkdir('../storage/tmp/snap/hp/' . $snapPath, 0755, true); + $snapTmp = __DIR__ . '/../storage/tmp/snap/hp/' . $snapPath . $snapTime . '.zip'; + @mkdir(__DIR__ . '/../storage/tmp/snap/hp/' . $snapPath, 0755, true); // Create new ZIP container $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 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 $db->updateHostPageSnapStorageLocal($hostPageSnapId, true); diff --git a/public/api.php b/public/api.php index 48a8f2d..57181e2 100644 --- a/public/api.php +++ b/public/api.php @@ -4,13 +4,13 @@ define('API_VERSION', 0.10); // Load system dependencies -require_once('../config/app.php'); -require_once('../library/curl.php'); -require_once('../library/robots.php'); -require_once('../library/filter.php'); -require_once('../library/parser.php'); -require_once('../library/mysql.php'); -require_once('../library/sphinxql.php'); +require_once(__DIR__ . '/../config/app.php'); +require_once(__DIR__ . '/../library/curl.php'); +require_once(__DIR__ . '/../library/robots.php'); +require_once(__DIR__ . '/../library/filter.php'); +require_once(__DIR__ . '/../library/parser.php'); +require_once(__DIR__ . '/../library/mysql.php'); +require_once(__DIR__ . '/../library/sphinxql.php'); if (API_ENABLED) { diff --git a/public/explore.php b/public/explore.php index a96986b..0e44076 100644 --- a/public/explore.php +++ b/public/explore.php @@ -1,13 +1,13 @@ hostPageId, 1, '/') . $hostPageSnap->timeAdded . '.zip'; // Download local snap in higher priority if possible - if ($hostPageSnap->storageLocal && file_exists('../storage/snap/' . $snapFile) && - is_readable('../storage/snap/' . $snapFile)) { + if ($hostPageSnap->storageLocal && file_exists(__DIR__ . '/../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); @@ -85,7 +85,7 @@ switch ($type) { header(sprintf('Content-Disposition: filename="snap.%s.%s.%s.zip"', $hostPageSnap->hostPageSnapId, $hostPageSnap->hostPageId, $hostPageSnap->timeAdded)); - readfile('../storage/snap/' . $snapFile); + readfile(__DIR__ . '/../storage/snap/' . $snapFile); // Then try to download from MEGA storage if exists } else if ($hostPageSnap->storageMega) { diff --git a/public/index.php b/public/index.php index c804138..77ed19d 100644 --- a/public/index.php +++ b/public/index.php @@ -1,9 +1,9 @@