mirror of
https://github.com/e107inc/e107.git
synced 2025-04-19 20:21:51 +02:00
CoreImage: Pack SQLite into phar
This has two benefits: 1. Protects the SQLite database from being accessed on the Internet by having the e107_INIT constant check. 2. Compresses the SQLite database, saving over ⅔ of the space!
This commit is contained in:
parent
d3539cd5b5
commit
84081c3d3d
2
.github/workflows/build-release.yml
vendored
2
.github/workflows/build-release.yml
vendored
@ -26,7 +26,7 @@ jobs:
|
||||
run: git fetch origin +refs/tags/*:refs/tags/* +refs/heads/*:refs/remotes/origin/*
|
||||
|
||||
- name: Run build script
|
||||
run: php e107_make.php
|
||||
run: php -dphar.readonly=0 e107_make.php
|
||||
working-directory: ./.github/workflows/build-release/
|
||||
|
||||
- name: Upload build artifacts
|
||||
|
58
.github/workflows/build-release/CoreImage.php
vendored
58
.github/workflows/build-release/CoreImage.php
vendored
@ -17,10 +17,12 @@ class CoreImage
|
||||
|
||||
public function __construct($exportFolder, $tempFolder, $currentVersion, $imageFile)
|
||||
{
|
||||
set_time_limit(240);
|
||||
$imagePharFile = "$imageFile.phar";
|
||||
$phar = new Phar($imagePharFile);
|
||||
|
||||
file_put_contents($imageFile, '');
|
||||
$this->db = new PDO("sqlite:{$imageFile}");
|
||||
$imageSqliteFile = "$imageFile.sqlite";
|
||||
file_put_contents($imageSqliteFile, '');
|
||||
$this->db = new PDO("sqlite:{$imageSqliteFile}");
|
||||
$this->db->exec('
|
||||
CREATE TABLE IF NOT EXISTS file_hashes (
|
||||
path TEXT,
|
||||
@ -43,29 +45,17 @@ class CoreImage
|
||||
# ORDER BY path ASC;
|
||||
|
||||
$this->create_image($exportFolder, $tempFolder, $currentVersion);
|
||||
|
||||
$phar->startBuffering();
|
||||
$phar->setStub($this->generateStub());
|
||||
$phar->addFile($imageSqliteFile, "core_image.sqlite");
|
||||
$phar->compressFiles(Phar::BZ2);
|
||||
$phar->stopBuffering();
|
||||
rename($imagePharFile, $imageFile);
|
||||
}
|
||||
|
||||
function create_image($exportFolder, $tempFolder, $currentVersion)
|
||||
{
|
||||
$data = "<?php\n";
|
||||
$data .= "/*\n";
|
||||
$data .= "+ ----------------------------------------------------------------------------+\n";
|
||||
$data .= "| e107 website system\n";
|
||||
$data .= "|\n";
|
||||
$data .= "| Copyright (C) 2008-" . date("Y") . " e107 Inc. \n";
|
||||
$data .= "| http://e107.org\n";
|
||||
// $data .= "| jalist@e107.org\n";
|
||||
$data .= "|\n";
|
||||
$data .= "| Released under the terms and conditions of the\n";
|
||||
$data .= "| GNU General Public License (http://gnu.org).\n";
|
||||
$data .= "|\n";
|
||||
$data .= "| \$URL$\n";
|
||||
$data .= "| \$Id$\n";
|
||||
$data .= "+----------------------------------------------------------------------------+\n";
|
||||
$data .= "*/\n\n";
|
||||
$data .= "if (!defined('e107_INIT')) { exit; }\n\n";
|
||||
|
||||
echo("[Core-Image] Scanning Dir: " . $exportFolder . "\n");
|
||||
$this->generateCurrentChecksums($exportFolder, $currentVersion);
|
||||
|
||||
echo("[Core-Image] Scanning Removed Files from Git" . "\n");
|
||||
@ -199,4 +189,28 @@ class CoreImage
|
||||
);
|
||||
$statement->execute([$releaseVersion]);
|
||||
}
|
||||
|
||||
private function generateStub()
|
||||
{
|
||||
$data = "<?php\n";
|
||||
$data .= "/*\n";
|
||||
$data .= "+ ----------------------------------------------------------------------------+\n";
|
||||
$data .= "| e107 website system\n";
|
||||
$data .= "|\n";
|
||||
$data .= "| Copyright (C) 2008-" . date("Y") . " e107 Inc. \n";
|
||||
$data .= "| http://e107.org\n";
|
||||
// $data .= "| jalist@e107.org\n";
|
||||
$data .= "|\n";
|
||||
$data .= "| Released under the terms and conditions of the\n";
|
||||
$data .= "| GNU General Public License (http://gnu.org).\n";
|
||||
$data .= "|\n";
|
||||
$data .= "| \$URL$\n";
|
||||
$data .= "| \$Id$\n";
|
||||
$data .= "+----------------------------------------------------------------------------+\n";
|
||||
$data .= "*/\n\n";
|
||||
$data .= "if (!defined('e107_INIT')) { exit; }\n\n";
|
||||
$data .= "__HALT_COMPILER();";
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user