From aca756ea67f1c857ec80fa4fc4dca64749bed0c1 Mon Sep 17 00:00:00 2001
From: Roman Kelesidis
- Created by: {$data['client']} ';
+ $files_count++;
+ $row_class = ($files_count % 2) ? 'row1' : 'row2';
+ $template->assign_block_vars('filelist', [
+ 'ROW_NUMBER' => $files_count,
+ 'ROW_CLASS' => $row_class,
+ 'FILE_PATH' => clean_tor_dirname(implode('/', $file->path)),
+ 'FILE_LENGTH' => humn_size($file->length, 2),
+ 'FILE_HASH' => $file->$t_hash_field ?? '-'
+ ]);
}
-$data = [
- 'name' => !empty($t_name = $torrent->getName()) ? htmlCHR(substr($t_name, 0, 255)) : 'undefined',
- 'client' => !empty($creator = $torrent->getCreatedBy()) ? htmlCHR(substr($creator, 0, 20)) : 'unknown client',
- 'date' => (!empty($dt = $torrent->getCreationDate()) && is_numeric($creation_date = $dt->getTimestamp())) ? date('d-M-Y H:i (e)', $creation_date) : $lang['UNKNOWN'],
- 'size' => humn_size($row['size'], 2),
- 'file_count' => iterator_count($files),
- 'site_url' => FULL_URL,
- 'topic_url' => TOPIC_URL . $topic_id,
-];
+$torrent_name = !empty($t_name = $torrent->getName()) ? htmlCHR(str_short($t_name, 200)) : $lang['UNKNOWN'];
+$torrent_size = humn_size($row['size'], 2);
-header('Cache-Control: public, max-age=3600');
+$template->assign_vars([
+ 'PAGE_TITLE' => "$torrent_name (" . $torrent_size . ")",
+ 'FILES_COUNT' => sprintf($lang['BT_FLIST_FILE_PATH'], declension(iterator_count($files), 'files')),
+ 'TORRENT_CREATION_DATE' => (!empty($dt = $torrent->getCreationDate()) && is_numeric($creation_date = $dt->getTimestamp())) ? date('d-M-Y H:i (e)', $creation_date) : $lang['UNKNOWN'],
+ 'TORRENT_CLIENT' => !empty($creator = $torrent->getCreatedBy()) ? htmlCHR(str_short($creator, 20)) : $lang['UNKNOWN'],
-echo <<' . clean_tor_dirname(implode('/', $file->path)) . ' ' . humn_size($file->length, 2) . ' ' . $file->$t_hash_field . ' Name: {$data['name']} | Date: {$data['date']} | Size: {$data['size']}
-
Path ({$data['file_count']} files) | -Size | -- BTMR hash - ? - - BitTorrent Merkle Root is a hash of a file embedded in torrents with BitTorrent v2 support, tracker users can extract, calculate them, also download deduplicated torrents using desktop tools such as - Torrent Merkle Root Reader. - - - | -
---|
Generated by TorrentPier
- - - -EOF; +print_page('filelist.tpl'); diff --git a/install.php b/install.php index 8e6a165e7..e6223bb69 100644 --- a/install.php +++ b/install.php @@ -14,17 +14,10 @@ if (php_sapi_name() !== 'cli') { die('Please runphp ' . basename(__FILE__) . '
in CLI mode');
}
-// Check if already installed
-if (is_file(BB_ROOT . '.env')) {
- out('- TorrentPier already installed', 'error');
- exit;
-}
-
/**
* System requirements
*/
define('CHECK_REQUIREMENTS', [
- 'status' => true,
'php_min_version' => '8.1.0',
'ext_list' => [
'json',
@@ -105,6 +98,27 @@ function runProcess(string $cmd, string $input = null): void
proc_close($process);
}
+/**
+ * Remove directory recursively
+ *
+ * @param string $dir
+ * @return void
+ */
+function rmdir_rec(string $dir): void
+{
+ $it = new RecursiveDirectoryIterator($dir, FilesystemIterator::SKIP_DOTS);
+ $files = new RecursiveIteratorIterator($it,
+ RecursiveIteratorIterator::CHILD_FIRST);
+ foreach ($files as $file) {
+ if ($file->isDir()) {
+ rmdir($file->getPathname());
+ } else {
+ unlink($file->getPathname());
+ }
+ }
+ rmdir($dir);
+}
+
/**
* Setting permissions recursively
*
@@ -123,11 +137,11 @@ function chmod_r(string $dir, int $dirPermissions, int $filePermissions): void
$fullPath = realpath($dir . '/' . $file);
if (is_dir($fullPath)) {
- out("- Directory: $fullPath");
+ // out("- Directory: $fullPath");
chmod($fullPath, $dirPermissions);
chmod_r($fullPath, $dirPermissions, $filePermissions);
} elseif (is_file($fullPath)) {
- out("- File: $fullPath");
+ // out("- File: $fullPath");
chmod($fullPath, $filePermissions);
} else {
out("- Cannot find target path: $fullPath", 'error');
@@ -160,8 +174,48 @@ foreach (CHECK_REQUIREMENTS['ext_list'] as $ext) {
}
out("- All extensions are installed!\n", 'success');
-// Setting permissions
-out("- Setting permissions for folders...", 'info');
+// Check if already installed
+if (is_file(BB_ROOT . '.env')) {
+ out('- TorrentPier already installed', 'warning');
+ echo 'Are you sure want to re-install TorrentPier? [y/N]: ';
+ if (readline() === 'y') {
+ out("\n- Re-install process started...", 'info');
+ // environment
+ if (is_file(BB_ROOT . '.env')) {
+ if (unlink(BB_ROOT . '.env')) {
+ out('- Environment file successfully removed!');
+ } else {
+ out('- Cannot remove environment (.env) file. Delete it manually', 'error');
+ exit;
+ }
+ }
+ // composer.phar
+ if (is_file(BB_ROOT . 'composer.phar')) {
+ if (unlink(BB_ROOT . 'composer.phar')) {
+ out("- composer.phar file successfully removed!");
+ } else {
+ out('- Cannot remove composer.phar file. Delete it manually', 'error');
+ exit;
+ }
+ }
+ // composer dir
+ if (is_dir(BB_ROOT . 'vendor')) {
+ rmdir_rec(BB_ROOT . 'vendor');
+ if (!is_dir(BB_ROOT . 'vendor')) {
+ out("- Composer directory successfully removed!");
+ } else {
+ out('- Cannot remove Composer directory. Delete it manually', 'error');
+ exit;
+ }
+ }
+ out("- Re-install process completed!\n", 'success');
+ } else {
+ exit;
+ }
+}
+
+// Applying permissions
+out("- Applying permissions for folders...", 'info');
chmod_r(BB_ROOT . 'data', 0755, 0644);
chmod_r(BB_ROOT . 'internal_data', 0755, 0644);
chmod_r(BB_ROOT . 'sitemap', 0755, 0644);
@@ -194,7 +248,7 @@ if (!is_file(BB_ROOT . 'vendor/autoload.php')) {
if (is_file(BB_ROOT . 'composer.phar')) {
out('- Installing dependencies...', 'info');
runProcess('php ' . BB_ROOT . 'composer.phar install --no-interaction --no-ansi');
- out("- Completed!\n", 'success');
+ out("- Completed! Composer dependencies are installed!\n", 'success');
} else {
out('- composer.phar not found', 'error');
exit;
diff --git a/library/language/source/main.php b/library/language/source/main.php
index 1fc121473..81733a4ce 100644
--- a/library/language/source/main.php
+++ b/library/language/source/main.php
@@ -1348,6 +1348,10 @@ $lang['BT_REG_FAIL_SAME_HASH'] = 'Another torrent with same info_hash already Torrent Merkle Root Reader';
+$lang['BT_FLIST_CREATION_DATE'] = 'Creation date';
+$lang['BT_FLIST_FILE_PATH'] = 'Path (%s)';
$lang['BT_UNREG_FROM_TRACKER'] = 'Remove from tracker';
$lang['BT_UNREGISTERED'] = 'Torrent unregistered';
$lang['BT_UNREGISTERED_ALREADY'] = 'Torrent already unregistered';
@@ -1644,6 +1648,7 @@ $lang['SEND_PM_TXTB'] = '[PM]';
$lang['DECLENSION']['REPLIES'] = ['reply', 'replies'];
$lang['DECLENSION']['TIMES'] = ['time', 'times'];
+$lang['DECLENSION']['FILES'] = ['file', 'files'];
$lang['DELTA_TIME']['INTERVALS'] = [
'seconds' => ['second', 'seconds'],
@@ -1837,7 +1842,7 @@ $lang['DL_DL'] = 'DL';
$lang['DL_UL_SPEED'] = 'UL speed';
$lang['DL_DL_SPEED'] = 'DL speed';
$lang['DL_PORT'] = 'Port';
-$lang['DL_CLIENT'] = 'Client';
+$lang['DL_CLIENT'] = 'BitTorrent client';
$lang['DL_FORMULA'] = 'Formula: Uploaded/TorrentSize';
$lang['DL_ULR'] = 'ULR';
$lang['DL_STOPPED'] = 'stopped';
diff --git a/styles/templates/default/filelist.tpl b/styles/templates/default/filelist.tpl
new file mode 100644
index 000000000..25f9a9cc1
--- /dev/null
+++ b/styles/templates/default/filelist.tpl
@@ -0,0 +1,43 @@
+# | +{FILES_COUNT} | +{L_SIZE} | +{L_BT_FLIST_BTMR_HASH} | +
---|---|---|---|
{filelist.ROW_NUMBER} | +{filelist.FILE_PATH} | +{filelist.FILE_LENGTH} | +{filelist.FILE_HASH} | +
{BTMR_NOTICE} | +
{CURRENT_TIME}
+{S_TIMEZONE}
+