chore: create production-v2 branch with content only

This branch contains ONLY:
- Pages (config/www/user/pages/)
- Themes (config/www/user/themes/)
- Plugins (config/www/user/plugins/)
- PRODUCTION.md
- Minimal .gitignore

Clean slate for production deployment.
All development files, configs, scripts removed.
This commit is contained in:
Charles N Wyble
2026-01-13 20:12:03 -05:00
commit 665c7f47af
2558 changed files with 434613 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
<?php
namespace Grav\Plugin\Problems;
use Grav\Plugin\Problems\Base\Problem;
/**
* Class Apache
* @package Grav\Plugin\Problems
*/
class Apache extends Problem
{
public function __construct()
{
$this->id = 'Apache Modules';
$this->class = get_class($this);
$this->order = 1;
$this->level = Problem::LEVEL_CRITICAL;
$this->status = true;
$this->help = 'https://learn.getgrav.org/basics/requirements#apache-requirements';
}
/**
* @return $this
*/
public function process()
{
// Perform some Apache checks
if (function_exists('apache_get_modules') && strpos(PHP_SAPI, 'apache') !== false) {
$require_apache_modules = ['mod_rewrite'];
$apache_modules = apache_get_modules();
$apache_errors = [];
$apache_success = [];
foreach ($require_apache_modules as $module) {
if (in_array($module, $apache_modules, true)) {
$apache_success[$module] = 'module required but not enabled';
} else {
$apache_errors[$module] = 'module is not installed or enabled';
}
}
if (empty($apache_errors)) {
$this->status = true;
$this->msg = 'All modules look good!';
} else {
$this->status = false;
$this->msg = 'There were problems with required modules:';
}
$this->details = ['errors' => $apache_errors, 'success' => $apache_success];
} else {
$this->msg = 'Apache is not installed or PHP is not installed as Apache module, skipping...';
}
return $this;
}
}

View File

@@ -0,0 +1,141 @@
<?php
namespace Grav\Plugin\Problems\Base;
use JsonSerializable;
/**
* Class Problem
* @package Grav\Plugin\Problems\Base
*/
class Problem implements JsonSerializable
{
const LEVEL_CRITICAL = 'critical';
const LEVEL_WARNING = 'warning';
const LEVEL_NOTICE = 'notice';
/** @var string */
protected $id = '';
/** @var int */
protected $order = 0;
/** @var string */
protected $level = '';
/** @var bool */
protected $status = false;
/** @var string */
protected $msg = '';
/** @var array */
protected $details = [];
/** @var string */
protected $help = '';
/** @var string */
protected $class = '';
/**
* @param array $data
* @return void
*/
public function load(array $data): void
{
$this->set_object_vars($data);
}
/**
* @return $this
*/
public function process()
{
return $this;
}
/**
* @return string
*/
public function getId(): string
{
return $this->id;
}
/**
* @return int
*/
public function getOrder(): int
{
return $this->order;
}
/**
* @return string
*/
public function getLevel(): string
{
return $this->level;
}
/**
* @return bool
*/
public function getStatus(): bool
{
return $this->status;
}
/**
* @return string
*/
public function getMsg(): string
{
return $this->msg;
}
/**
* @return array
*/
public function getDetails(): array
{
return $this->details;
}
/**
* @return string
*/
public function getHelp(): string
{
return $this->help;
}
/**
* @return string
*/
public function getClass(): string
{
return $this->class;
}
/**
* @return array
*/
public function toArray(): array
{
return get_object_vars($this);
}
/**
* @return array
*/
public function jsonSerialize(): array
{
return $this->toArray();
}
/**
* @param array $vars
*/
protected function set_object_vars(array $vars): void
{
$has = get_object_vars($this);
foreach ($has as $name => $oldValue) {
$this->{$name} = $vars[$name] ?? null;
}
}
}

View File

@@ -0,0 +1,159 @@
<?php
namespace Grav\Plugin\Problems\Base;
use Grav\Common\Cache;
use Grav\Common\Grav;
use RocketTheme\Toolbox\Event\Event;
/**
* Class ProblemChecker
* @package Grav\Plugin\Problems\Base
*/
class ProblemChecker
{
/** @var string */
const PROBLEMS_PREFIX = 'problem-check-';
/** @var array */
protected $problems = [];
/** @var string */
protected $status_file;
public function __construct()
{
/** @var Cache $cache */
$cache = Grav::instance()['cache'];
$this->status_file = CACHE_DIR . $this::PROBLEMS_PREFIX . $cache->getKey() . '.json';
}
/**
* @return bool
*/
public function load(): bool
{
if ($this->statusFileExists()) {
$json = file_get_contents($this->status_file) ?: '';
$data = json_decode($json, true);
if (!is_array($data)) {
return false;
}
foreach ($data as $problem) {
$class = $problem['class'];
$this->problems[] = new $class($problem);
}
}
return true;
}
/**
* @return string
*/
public function getStatusFile():string
{
return $this->status_file;
}
/**
* @return bool
*/
public function statusFileExists(): bool
{
return file_exists($this->status_file);
}
/**
* @return void
*/
public function storeStatusFile(): void
{
$problems = $this->getProblemsSerializable();
$json = json_encode($problems);
file_put_contents($this->status_file, $json);
}
/**
* @param string|null $problems_dir
* @return bool
*/
public function check($problems_dir = null): bool
{
$problems_dir = $problems_dir ?: dirname(__DIR__);
$problems = [];
$problems_found = false;
$iterator = new \DirectoryIterator($problems_dir);
foreach ($iterator as $file) {
if (!$file->isFile() || $file->getExtension() !== 'php') {
continue;
}
$classname = 'Grav\\Plugin\\Problems\\' . $file->getBasename('.php');
if (class_exists($classname)) {
/** @var Problem $problem */
$problem = new $classname();
$problems[$problem->getId()] = $problem;
}
}
// Fire event to allow other plugins to add problems
Grav::instance()->fireEvent('onProblemsInitialized', new Event(['problems' => $problems]));
// Get the problems in order
usort($problems, function($a, $b) {
/** @var Problem $a */
/** @var Problem $b */
return $b->getOrder() - $a->getOrder();
});
// run the process methods in new order
foreach ($problems as $problem) {
$problem->process();
if ($problem->getStatus() === false && $problem->getLevel() === Problem::LEVEL_CRITICAL) {
$problems_found = true;
}
}
$this->problems = $problems;
return $problems_found;
}
/**
* @return array
*/
public function getProblems(): array
{
if (empty($this->problems)) {
$this->check();
}
$problems = $this->problems;
// Put the failed ones first
usort($problems, function($a, $b) {
/** @var Problem $a */
/** @var Problem $b */
return $a->getStatus() - $b->getStatus();
});
return $problems;
}
/**
* @return array
*/
public function getProblemsSerializable(): array
{
if (empty($this->problems)) {
$this->getProblems();
}
$problems = [];
foreach ($this->problems as $problem) {
$problems[] = $problem->toArray();
}
return $problems;
}
}

View File

@@ -0,0 +1,79 @@
<?php
namespace Grav\Plugin\Problems;
use Grav\Plugin\Problems\Base\Problem;
/**
* Class EssentialFolders
* @package Grav\Plugin\Problems
*/
class EssentialFolders extends Problem
{
public function __construct()
{
$this->id = 'Essential Folders';
$this->class = get_class($this);
$this->order = 100;
$this->level = Problem::LEVEL_CRITICAL;
$this->status = false;
$this->help = 'https://learn.getgrav.org/basics/folder-structure';
}
/**
* @return $this
*/
public function process()
{
$essential_folders = [
GRAV_ROOT => false,
GRAV_ROOT . '/vendor' => false,
GRAV_SYSTEM_PATH => false,
GRAV_CACHE_PATH => true,
GRAV_LOG_PATH => true,
GRAV_TMP_PATH => true,
GRAV_BACKUP_PATH => true,
GRAV_WEBROOT => false,
GRAV_WEBROOT . '/images' => true,
GRAV_WEBROOT . '/assets' => true,
GRAV_WEBROOT . '/' . GRAV_USER_PATH .'/accounts' => true,
GRAV_WEBROOT . '/' . GRAV_USER_PATH .'/data' => true,
GRAV_WEBROOT . '/' . GRAV_USER_PATH .'/pages' => false,
GRAV_WEBROOT . '/' . GRAV_USER_PATH .'/config' => false,
GRAV_WEBROOT . '/' . GRAV_USER_PATH .'/plugins/error' => false,
GRAV_WEBROOT . '/' . GRAV_USER_PATH .'/plugins' => false,
GRAV_WEBROOT . '/' . GRAV_USER_PATH .'/themes' => false,
];
// Check for essential files & perms
$file_errors = [];
$file_success = [];
foreach ($essential_folders as $file => $check_writable) {
$file_path = (!preg_match('`^(/|[a-z]:[\\\/])`ui', $file) ? GRAV_ROOT . '/' : '') . $file;
$file_path = preg_replace('`^/+`', '/', $file_path);
if (!is_dir($file_path)) {
$file_errors[$file_path] = 'does not exist';
} elseif (!$check_writable) {
$file_success[$file_path] = 'exists';
} elseif (!is_writable($file_path)) {
$file_errors[$file_path] = 'exists but is <strong>not writeable</strong>';
} else {
$file_success[$file_path] = 'exists and is writable';
}
}
if (empty($file_errors)) {
$this->status = true;
$this->msg = 'All folders look good!';
} else {
$this->status = false;
$this->msg = 'There were problems with required folders:';
}
$this->details = ['errors' => $file_errors, 'success' => $file_success];
return $this;
}
}

View File

@@ -0,0 +1,169 @@
<?php
namespace Grav\Plugin\Problems;
use Grav\Common\Grav;
use Grav\Plugin\Problems\Base\Problem;
/**
* Class PHPModules
* @package Grav\Plugin\Problems
*/
class PHPModules extends Problem
{
protected $modules_errors = [];
protected $modules_warning = [];
protected $modules_success = [];
public function __construct()
{
$this->id = 'PHP Modules';
$this->class = get_class($this);
$this->order = 101;
$this->level = Problem::LEVEL_CRITICAL;
$this->status = false;
$this->help = 'https://learn.getgrav.org/basics/requirements#php-requirements';
}
/**
* @param string $module PHP module name.
* @param bool $required If it is required for grav.
* @param string $module_show_name More common module name to display.
* @return void
*/
protected function check_php_module(string $module, bool $required, string $module_show_name = ''): void{
$msg = 'PHP ';
$msg .= (($module_show_name!=='') ? $module_show_name : $module);
$msg .= ' is %s installed';
if(extension_loaded($module)){
$this->modules_success[$module] = sprintf($msg, 'successfully');
}else if($required){
$this->modules_errors[$module] = sprintf($msg, 'required but not');
}else{
$this->modules_warning[$module] = sprintf($msg, 'recommended but not');
}
}
/**
* @param string $module PHP cache module name.
* @param string $module_show_name More common module name to display.
* @return void
*/
protected function check_cache_module(string $module, string $module_show_name = ''): void{
$msg = 'PHP (optional) Cache ';
$msg .= (($module_show_name!=='') ? $module_show_name : $module);
$msg .= ' is %s installed';
if( extension_loaded($module) ){
$this->modules_success[$module] = sprintf($msg, 'successfully');
} else {
$this->modules_warning[$module] = sprintf($msg, 'not');
}
}
/**
* @return $this
*/
public function process()
{
// Check for PHP CURL library
$this->check_php_module('curl', true, 'Curl (Data Transfer Library)');
// Check for PHP Ctype library
$this->check_php_module('ctype', true, 'Ctype');
// Check for PHP Dom library
$this->check_php_module('dom', true, 'DOM');
// Check for PHP fileinfo library
$this->check_php_module('fileinfo', false);
// Check for GD library
$msg = 'PHP GD (Image Manipulation Library) is %s installed';
if (defined('GD_VERSION') && function_exists('gd_info')) {
$msg = sprintf($msg, 'successfully');
// Extra checks for Image support
$ginfo = gd_info();
$gda = array('PNG Support', 'JPEG Support', 'FreeType Support', 'GIF Read Support', 'WebP Support', 'AVIF Support');
$gda_msg = '';
$problems_found = false;
foreach ($gda as $image_type) {
if (!array_key_exists($image_type, $ginfo)) {
$problems_found = true;
if($gda_msg !== '') {
$gda_msg .= ', ';
}
$gda_msg .= $image_type;
}
}
if ($problems_found) {
$this->modules_warning['gd'] = $msg . ' but missing ' . $gda_msg;
}
$this->modules_success['gd'] = $msg;
} else {
$this->modules_errors['gd'] = sprintf($msg, 'required but not');
}
// Check for PHP MbString library
$this->check_php_module('mbstring', true, 'Mbstring (Multibyte String Library)');
// Check for PHP iconv library
$this->check_php_module('iconv', false);
// Check for PHP intl library
$this->check_php_module('intl', false, 'intl (Internationalization Functions)');
// Check for PHP Open SSL library
$this->check_php_module('openssl', true, 'OpenSSL (Secure Sockets Library)');
// Check for PHP JSON library
$this->check_php_module('json', true, 'JSON Library');
// Check for PHP libraries for symfony
$this->check_php_module('PCRE', true, 'PCRE (Perl Compatible Regular Expressions)');
$this->check_php_module('session', true);
// Check for PHP XML libraries
$this->check_php_module('libxml', true, 'libxml Library');
$this->check_php_module('simplexml', true, 'SimpleXML Library');
$this->check_php_module('xml', true, 'XML Library');
// Check for PHP yaml library
$this->check_php_module('yaml', false);
// Check for PHP Zip library
$this->check_php_module('zip', true, 'Zip extension');
// Check Exif if enabled
$required = Grav::instance()['config']->get('system.media.auto_metadata_exif');
$this->check_php_module('exif', $required, 'Exif (Exchangeable Image File Format)');
// Check cache modules
$this->check_cache_module('apcu', 'APC User Cache');
$this->check_cache_module('memcache');
$this->check_cache_module('memcached');
$this->check_cache_module('redis');
$this->check_cache_module('wincache', 'WinCache');
$this->check_cache_module('zend opcache', 'Zend OPcache');
if (empty($this->modules_errors)) {
$this->status = true;
$this->msg = 'All required modules look good!';
if(!empty($this->modules_warning)) {
$this->msg .= ' Some recommendations do exist.';
}
} else {
$this->status = false;
$this->msg = 'There were problems with required modules:';
}
$this->details = ['errors' => $this->modules_errors, 'warning' => $this->modules_warning, 'success' => $this->modules_success];
return $this;
}
}

View File

@@ -0,0 +1,43 @@
<?php
namespace Grav\Plugin\Problems;
use Grav\Plugin\Problems\Base\Problem;
/**
* Class PHPVersion
* @package Grav\Plugin\Problems
*/
class PHPVersion extends Problem
{
public function __construct()
{
$this->id = 'PHP Minimum Version';
$this->class = get_class($this);
$this->order = 102;
$this->level = Problem::LEVEL_CRITICAL;
$this->status = false;
$this->help = 'https://getgrav.org/blog/raising-php-requirements-2018';
}
/**
* @return $this
*/
public function process()
{
$min_php_version = defined('GRAV_PHP_MIN') ? GRAV_PHP_MIN : '5.6.4';
$your_php_version = PHP_VERSION;
$msg = 'Your PHP <strong>%s</strong> is %s than the minimum of <strong>%s</strong> required';
// Check PHP version
if (version_compare($your_php_version, $min_php_version, '<')) {
$this->msg = sprintf($msg, $your_php_version, 'less', $min_php_version);
} else {
$this->msg = sprintf($msg, $your_php_version, 'greater', $min_php_version);
$this->status = true;
}
return $this;
}
}

View File

@@ -0,0 +1,48 @@
<?php
namespace Grav\Plugin\Problems;
use Grav\Plugin\Problems\Base\Problem;
/**
* Class Permissions
* @package Grav\Plugin\Problems
*/
class Permissions extends Problem
{
public function __construct()
{
$this->id = 'Permissions Setup';
$this->class = get_class($this);
$this->order = -1;
$this->level = Problem::LEVEL_WARNING;
$this->status = false;
$this->help = 'https://learn.getgrav.org/troubleshooting/permissions';
}
/**
* @return $this
*/
public function process()
{
if (PHP_OS_FAMILY === 'Windows') {
$this->msg = 'Permission check is not available for Windows.';
$this->status = true;
return $this;
}
umask($umask = umask(022));
$msg = 'Your default file umask is <strong>%s</strong> which %s';
if (($umask & 2) !== 2) {
$this->msg = sprintf($msg, decoct($umask), 'is potentially dangerous');
$this->status = false;
} else {
$this->msg = sprintf($msg, decoct($umask), 'looks good!');
$this->status = true;
}
return $this;
}
}