Changeset 3479656
- Timestamp:
- 03/11/2026 02:15:21 AM (3 weeks ago)
- Location:
- linguise
- Files:
-
- 52 edited
- 1 copied
-
tags/2.2.30 (copied) (copied from linguise/trunk)
-
tags/2.2.30/composer.json (modified) (1 diff)
-
tags/2.2.30/languages/linguise.pot (modified) (1 diff)
-
tags/2.2.30/linguise.php (modified) (1 diff)
-
tags/2.2.30/readme.txt (modified) (2 diffs)
-
tags/2.2.30/src/constants.php (modified) (1 diff)
-
tags/2.2.30/vendor/autoload.php (modified) (1 diff)
-
tags/2.2.30/vendor/composer/autoload_psr4.php (modified) (1 diff)
-
tags/2.2.30/vendor/composer/autoload_real.php (modified) (2 diffs)
-
tags/2.2.30/vendor/composer/autoload_static.php (modified) (4 diffs)
-
tags/2.2.30/vendor/composer/installed.json (modified) (2 diffs)
-
tags/2.2.30/vendor/composer/installed.php (modified) (3 diffs)
-
tags/2.2.30/vendor/linguise/script-php/.version (modified) (1 diff)
-
tags/2.2.30/vendor/linguise/script-php/composer.json (modified) (1 diff)
-
tags/2.2.30/vendor/linguise/script-php/src/Cache.php (modified) (14 diffs)
-
tags/2.2.30/vendor/linguise/script-php/src/Certificates.php (modified) (2 diffs)
-
tags/2.2.30/vendor/linguise/script-php/src/Configuration.php (modified) (2 diffs)
-
tags/2.2.30/vendor/linguise/script-php/src/Defer.php (modified) (1 diff)
-
tags/2.2.30/vendor/linguise/script-php/src/Helper.php (modified) (1 diff)
-
tags/2.2.30/vendor/linguise/script-php/src/Hook.php (modified) (1 diff)
-
tags/2.2.30/vendor/linguise/script-php/src/HttpResponse.php (modified) (5 diffs)
-
tags/2.2.30/vendor/linguise/script-php/src/Management.php (modified) (23 diffs)
-
tags/2.2.30/vendor/linguise/script-php/src/OobeManager.php (modified) (34 diffs)
-
tags/2.2.30/vendor/linguise/script-php/src/Session.php (modified) (1 diff)
-
tags/2.2.30/vendor/linguise/script-php/src/templates/Helper.php (modified) (1 diff)
-
tags/2.2.30/vendor/linguise/script-php/src/templates/management-expert.php (modified) (1 diff)
-
tags/2.2.30/vendor/linguise/script-php/src/templates/management.php (modified) (2 diffs)
-
trunk/composer.json (modified) (1 diff)
-
trunk/languages/linguise.pot (modified) (1 diff)
-
trunk/linguise.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/src/constants.php (modified) (1 diff)
-
trunk/vendor/autoload.php (modified) (1 diff)
-
trunk/vendor/composer/autoload_psr4.php (modified) (1 diff)
-
trunk/vendor/composer/autoload_real.php (modified) (2 diffs)
-
trunk/vendor/composer/autoload_static.php (modified) (4 diffs)
-
trunk/vendor/composer/installed.json (modified) (2 diffs)
-
trunk/vendor/composer/installed.php (modified) (3 diffs)
-
trunk/vendor/linguise/script-php/.version (modified) (1 diff)
-
trunk/vendor/linguise/script-php/composer.json (modified) (1 diff)
-
trunk/vendor/linguise/script-php/src/Cache.php (modified) (14 diffs)
-
trunk/vendor/linguise/script-php/src/Certificates.php (modified) (2 diffs)
-
trunk/vendor/linguise/script-php/src/Configuration.php (modified) (2 diffs)
-
trunk/vendor/linguise/script-php/src/Defer.php (modified) (1 diff)
-
trunk/vendor/linguise/script-php/src/Helper.php (modified) (1 diff)
-
trunk/vendor/linguise/script-php/src/Hook.php (modified) (1 diff)
-
trunk/vendor/linguise/script-php/src/HttpResponse.php (modified) (5 diffs)
-
trunk/vendor/linguise/script-php/src/Management.php (modified) (23 diffs)
-
trunk/vendor/linguise/script-php/src/OobeManager.php (modified) (34 diffs)
-
trunk/vendor/linguise/script-php/src/Session.php (modified) (1 diff)
-
trunk/vendor/linguise/script-php/src/templates/Helper.php (modified) (1 diff)
-
trunk/vendor/linguise/script-php/src/templates/management-expert.php (modified) (1 diff)
-
trunk/vendor/linguise/script-php/src/templates/management.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
linguise/tags/2.2.30/composer.json
r3463145 r3479656 22 22 }, 23 23 "require": { 24 "linguise/script-php": "^1.3.4 5",24 "linguise/script-php": "^1.3.46", 25 25 "symfony/polyfill-intl-idn": "1.31.0", 26 26 "symfony/polyfill-mbstring": "1.31.0", -
linguise/tags/2.2.30/languages/linguise.pot
r3478678 r3479656 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Linguise - AI Automatic Multilingual Translation 2.2. 29\n"5 "Project-Id-Version: Linguise - AI Automatic Multilingual Translation 2.2.30\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/linguise\n" 7 7 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" -
linguise/tags/2.2.30/linguise.php
r3478678 r3479656 5 5 * Plugin URI: https://www.linguise.com/ 6 6 * Description: Linguise translation plugin 7 * Version:2.2. 297 * Version:2.2.30 8 8 * Text Domain: linguise 9 9 * Domain Path: /languages -
linguise/tags/2.2.30/readme.txt
r3478678 r3479656 4 4 Requires at least: 4.0 5 5 Tested up to: 6.9 6 Stable tag: 2.2. 296 Stable tag: 2.2.30 7 7 Requires PHP: 7.0 8 8 License: GPLv2 or later … … 108 108 109 109 == Changelog == 110 = 2.2.30 = 111 - Feature: Make cache clearing more consistent and eager 112 110 113 = 2.2.29 = 111 114 - Fix: "has attribute" can be null in some cases should have used conditional op -
linguise/tags/2.2.30/src/constants.php
r3478678 r3479656 1 1 <?php 2 2 if (!defined('LINGUISE_SCRIPT_TRANSLATION_VERSION')) { 3 define('LINGUISE_SCRIPT_TRANSLATION_VERSION', 'wordpress_plugin/2.2. 29');3 define('LINGUISE_SCRIPT_TRANSLATION_VERSION', 'wordpress_plugin/2.2.30'); 4 4 } 5 5 6 6 if (!defined('LINGUISE_VERSION')) { 7 define('LINGUISE_VERSION', '2.2. 29');7 define('LINGUISE_VERSION', '2.2.30'); 8 8 } -
linguise/tags/2.2.30/vendor/autoload.php
r3463145 r3479656 23 23 require_once __DIR__ . '/composer/autoload_real.php'; 24 24 25 return ComposerAutoloaderInit af7434287c0c5184d81a0a96ec705617::getLoader();25 return ComposerAutoloaderInit64d341d450ad698561b4da1b882592a7::getLoader(); -
linguise/tags/2.2.30/vendor/composer/autoload_psr4.php
r3226654 r3479656 13 13 'Symfony\\Polyfill\\Intl\\Normalizer\\' => array($vendorDir . '/symfony/polyfill-intl-normalizer'), 14 14 'Symfony\\Polyfill\\Intl\\Idn\\' => array($vendorDir . '/symfony/polyfill-intl-idn'), 15 'Linguise\\Script\\Core\\Templates\\' => array($vendorDir . '/linguise/script-php/src/templates'), 15 16 'Linguise\\Script\\Core\\' => array($vendorDir . '/linguise/script-php/src'), 16 17 'JsonPath\\' => array($vendorDir . '/galbar/jsonpath/src/Galbar/JsonPath'), -
linguise/tags/2.2.30/vendor/composer/autoload_real.php
r3463145 r3479656 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit af7434287c0c5184d81a0a96ec7056175 class ComposerAutoloaderInit64d341d450ad698561b4da1b882592a7 6 6 { 7 7 private static $loader; … … 23 23 } 24 24 25 spl_autoload_register(array('ComposerAutoloaderInit af7434287c0c5184d81a0a96ec705617', 'loadClassLoader'), true, true);25 spl_autoload_register(array('ComposerAutoloaderInit64d341d450ad698561b4da1b882592a7', 'loadClassLoader'), true, true); 26 26 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); 27 spl_autoload_unregister(array('ComposerAutoloaderInit af7434287c0c5184d81a0a96ec705617', 'loadClassLoader'));27 spl_autoload_unregister(array('ComposerAutoloaderInit64d341d450ad698561b4da1b882592a7', 'loadClassLoader')); 28 28 29 29 require __DIR__ . '/autoload_static.php'; 30 call_user_func(\Composer\Autoload\ComposerStaticInit af7434287c0c5184d81a0a96ec705617::getInitializer($loader));30 call_user_func(\Composer\Autoload\ComposerStaticInit64d341d450ad698561b4da1b882592a7::getInitializer($loader)); 31 31 32 32 $loader->register(true); 33 33 34 $filesToLoad = \Composer\Autoload\ComposerStaticInit af7434287c0c5184d81a0a96ec705617::$files;34 $filesToLoad = \Composer\Autoload\ComposerStaticInit64d341d450ad698561b4da1b882592a7::$files; 35 35 $requireFile = \Closure::bind(static function ($fileIdentifier, $file) { 36 36 if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { -
linguise/tags/2.2.30/vendor/composer/autoload_static.php
r3463145 r3479656 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit af7434287c0c5184d81a0a96ec7056177 class ComposerStaticInit64d341d450ad698561b4da1b882592a7 8 8 { 9 9 public static $files = array ( … … 31 31 'L' => 32 32 array ( 33 'Linguise\\Script\\Core\\Templates\\' => 31, 33 34 'Linguise\\Script\\Core\\' => 21, 34 35 ), … … 63 64 array ( 64 65 0 => __DIR__ . '/..' . '/symfony/polyfill-intl-idn', 66 ), 67 'Linguise\\Script\\Core\\Templates\\' => 68 array ( 69 0 => __DIR__ . '/..' . '/linguise/script-php/src/templates', 65 70 ), 66 71 'Linguise\\Script\\Core\\' => … … 156 161 { 157 162 return \Closure::bind(function () use ($loader) { 158 $loader->prefixLengthsPsr4 = ComposerStaticInit af7434287c0c5184d81a0a96ec705617::$prefixLengthsPsr4;159 $loader->prefixDirsPsr4 = ComposerStaticInit af7434287c0c5184d81a0a96ec705617::$prefixDirsPsr4;160 $loader->classMap = ComposerStaticInit af7434287c0c5184d81a0a96ec705617::$classMap;163 $loader->prefixLengthsPsr4 = ComposerStaticInit64d341d450ad698561b4da1b882592a7::$prefixLengthsPsr4; 164 $loader->prefixDirsPsr4 = ComposerStaticInit64d341d450ad698561b4da1b882592a7::$prefixDirsPsr4; 165 $loader->classMap = ComposerStaticInit64d341d450ad698561b4da1b882592a7::$classMap; 161 166 162 167 }, null, ClassLoader::class); -
linguise/tags/2.2.30/vendor/composer/installed.json
r3463145 r3479656 57 57 { 58 58 "name": "linguise/script-php", 59 "version": "v1.3.4 5",60 "version_normalized": "1.3.4 5.0",59 "version": "v1.3.46", 60 "version_normalized": "1.3.46.0", 61 61 "source": { 62 62 "type": "git", 63 63 "url": "git@bitbucket.org:linguise/script-php.git", 64 "reference": "0 a8f5e7d6aaa343d311e7c4de3858808685272ef"64 "reference": "0d251debce930c506aa3cd7c9835f64045888d8a" 65 65 }, 66 66 "require": { … … 75 75 "vlucas/phpdotenv": "^5.6" 76 76 }, 77 "time": "2026-0 2-17T06:35:08+00:00",77 "time": "2026-03-11T01:49:57+00:00", 78 78 "type": "library", 79 79 "installation-source": "source", 80 80 "autoload": { 81 81 "psr-4": { 82 "Linguise\\Script\\Core\\": "src/" 82 "Linguise\\Script\\Core\\": "src/", 83 "Linguise\\Script\\Core\\Templates\\": "src/templates/" 83 84 } 84 85 }, -
linguise/tags/2.2.30/vendor/composer/installed.php
r3478678 r3479656 4 4 'pretty_version' => 'dev-master', 5 5 'version' => 'dev-master', 6 'reference' => ' 08a04170ddd02ca3bd401c6a811ee4c513c54364',6 'reference' => 'b3dc8d26c6f5a95b5137af0a0b83bcaac4023c42', 7 7 'type' => 'library', 8 8 'install_path' => __DIR__ . '/../../', … … 21 21 ), 22 22 'linguise/script-php' => array( 23 'pretty_version' => 'v1.3.4 5',24 'version' => '1.3.4 5.0',25 'reference' => '0 a8f5e7d6aaa343d311e7c4de3858808685272ef',23 'pretty_version' => 'v1.3.46', 24 'version' => '1.3.46.0', 25 'reference' => '0d251debce930c506aa3cd7c9835f64045888d8a', 26 26 'type' => 'library', 27 27 'install_path' => __DIR__ . '/../linguise/script-php', … … 32 32 'pretty_version' => 'dev-master', 33 33 'version' => 'dev-master', 34 'reference' => ' 08a04170ddd02ca3bd401c6a811ee4c513c54364',34 'reference' => 'b3dc8d26c6f5a95b5137af0a0b83bcaac4023c42', 35 35 'type' => 'library', 36 36 'install_path' => __DIR__ . '/../../', -
linguise/tags/2.2.30/vendor/linguise/script-php/.version
r3463145 r3479656 1 1.3.4 51 1.3.46 -
linguise/tags/2.2.30/vendor/linguise/script-php/composer.json
r3366846 r3479656 12 12 "autoload": { 13 13 "psr-4": { 14 "Linguise\\Script\\Core\\": "src/" 14 "Linguise\\Script\\Core\\": "src/", 15 "Linguise\\Script\\Core\\Templates\\": "src/templates/" 15 16 } 16 17 }, -
linguise/tags/2.2.30/vendor/linguise/script-php/src/Cache.php
r3321566 r3479656 3 3 namespace Linguise\Vendor\Linguise\Script\Core; 4 4 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore 6 6 7 7 class Cache … … 39 39 * @return Cache 40 40 */ 41 public static function getInstance() {42 43 if (is_null(self::$_instance)) {41 public static function getInstance() 42 { 43 if (is_null(self::$_instance)) { 44 44 self::$_instance = new Cache(); 45 45 } … … 48 48 } 49 49 50 public function getPath() { 50 public function getPath() 51 { 51 52 Helper::prepareDataDir(); 52 53 return Configuration::getInstance()->get('data_dir') . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR; 53 54 } 54 55 55 public function serve() { 56 public function serve() 57 { 56 58 $response = Response::getInstance(); 57 59 … … 69 71 // In case we failed to json_encode (non utf8 chars and no mbstring extension) 70 72 if (!$this->_hash) { 71 return false; 73 return false; // @codeCoverageIgnore 72 74 } 73 75 … … 82 84 83 85 if (!$this->load()) { 84 return false; 86 return false; // @codeCoverageIgnore 85 87 } 86 88 … … 90 92 } 91 93 92 protected function load() { 94 protected function load() 95 { 93 96 $cache_file = Configuration::getInstance()->get('data_dir') . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . $this->_language . '_' . $this->_hash . '.php'; 94 97 … … 108 111 } 109 112 110 public function save() { 113 public function save() 114 { 111 115 if (!$this->_hash || !$this->_language) { 112 116 return false; … … 128 132 } 129 133 134 // Run clear first 135 $this->clear(true, 30); // aggresive 30s cache time check 136 130 137 file_put_contents($cache_file, '<?php die(); ?>' . $content); 131 138 … … 134 141 135 142 /** 143 * Internal method to check if the cache should be cleared based on the last cleared time and the cache time check defined in configuration 144 * 145 * @param int $cache_time_check The time in seconds to check if the cache should be cleared or not 146 * 147 * @return boolean 148 */ 149 private function internalShouldBeExecuted($cache_time_check) 150 { 151 $cache_info_file = $this->getPath() . 'clear.txt'; 152 153 if (file_exists($cache_info_file)) { 154 $last_cleared = file_get_contents($cache_info_file); 155 if ($last_cleared === false) { 156 // If we cannot read the file, consider it as not cleared 157 return true; // @codeCoverageIgnore 158 } 159 160 // Strip then cast to int 161 $last_cleared = (int)trim($last_cleared); 162 if (time() - $last_cleared < $cache_time_check) { 163 // Cache was cleared recently, skip 164 return false; 165 } 166 } 167 168 // too old, we can clear it again 169 return true; 170 } 171 172 /** 136 173 * Check if the request to launch this task should be executed or not 137 174 * 138 175 * @return bool 139 176 */ 140 public function shouldBeExecuted() { 177 public function shouldBeExecuted() 178 { 141 179 if (!Configuration::getInstance()->get('cache_enabled')) { 142 180 return false; 143 181 } 144 $cache_info_file = $this->getPath() . 'clear.txt'; 145 if (file_exists($cache_info_file) && (int)file_get_contents($cache_info_file) + Configuration::getInstance()->get('cache_time_check') > time()) { 146 return false; 147 } 148 return true; 149 } 150 151 public function clear() { 152 if (!$this->shouldBeExecuted()) { 182 183 $cache_time_check = Configuration::getInstance()->get('cache_time_check') ?? 600; 184 // cast to int 185 $cache_time_check = (int)$cache_time_check; 186 return $this->internalShouldBeExecuted($cache_time_check); 187 } 188 189 /** 190 * Clear cache files until the total size is under the limit defined in configuration 191 * 192 * @param boolean $no_output Whether to output the response or not, set to true when this method is not called from web request 193 * @param boolean $real_timing The real timing to check if the cache should be cleared or not, used for testing purposes 194 */ 195 public function clear($no_output = false, $real_timing = null) 196 { 197 if ($real_timing !== null && !$this->internalShouldBeExecuted($real_timing)) { 153 198 return; 199 } elseif ($real_timing === null && !$this->shouldBeExecuted()) { 200 return; 154 201 } 155 202 … … 158 205 $files = glob($cache_path . '*.php'); 159 206 160 usort($files, function ($x, $y) {207 usort($files, function ($x, $y) { 161 208 $x_mtime = @filemtime($x); // Silent both errors if the file does not exist or is not readable 162 209 $y_mtime = @filemtime($y); 163 210 if ($x_mtime === false || $y_mtime === false) { 164 return 0; // If we cannot get the modification time, consider them equal 211 // If we cannot get the modification time, consider them equal 212 return 0; // @codeCoverageIgnore 165 213 } 166 214 return ($x_mtime < $y_mtime) ? -1 : 1; … … 176 224 $size = @filesize($file); // Silent the error if the file does not exist or is not readable 177 225 if ($size === false) { 178 continue; // If we cannot get the size, skip this file 226 // If we cannot get the size, skip this file 227 continue; // @codeCoverageIgnore 179 228 } 180 229 $total_size += $size; … … 188 237 file_put_contents($cache_path . 'clear.txt', time()); 189 238 239 if ($no_output) { 240 return; 241 } 242 190 243 $response = Response::getInstance(); 191 244 $response->setResponseCode(200, false); 192 $response->setContent('Cleared cache: ' . (int)($total_cleared /1000) . 'kb');245 $response->setContent('Cleared cache: ' . (int)($total_cleared / 1000) . 'kb'); 193 246 $response->end(); 194 247 } … … 200 253 $files = glob($cache_path . '*.php'); 201 254 202 foreach ($files as $file) {255 foreach ($files as $file) { 203 256 if (!in_array($file, ['.', '..']) && is_file($file)) { 204 257 $size = @filesize($file); // Silent the error if the file does not exist or is not readable 205 258 if ($size === false) { 206 continue; // If we cannot get the size, skip this file 259 // If we cannot get the size, skip this file 260 continue; // @codeCoverageIgnore 207 261 } 208 262 $total_cleared += $size; … … 213 267 $response = Response::getInstance(); 214 268 if ($total_cleared > 0) { 215 $response->setContent('Cleared cache: ' . (int)($total_cleared /1000) . 'kb');269 $response->setContent('Cleared cache: ' . (int)($total_cleared / 1000) . 'kb'); 216 270 } else { 217 271 $response->setContent('Cache Empty!'); -
linguise/tags/2.2.30/vendor/linguise/script-php/src/Certificates.php
r3397694 r3479656 3 3 namespace Linguise\Vendor\Linguise\Script\Core; 4 4 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore 6 6 7 7 class Certificates … … 70 70 /** 71 71 * Download latest bundle 72 * 73 * @codeCoverageIgnore 72 74 * 73 75 * @return void -
linguise/tags/2.2.30/vendor/linguise/script-php/src/Configuration.php
r3316163 r3479656 4 4 use ReflectionProperty; 5 5 6 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); 6 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore 7 7 8 8 class Configuration { … … 120 120 $configurationLocalLoaded = $this->loadFile($basePath . DIRECTORY_SEPARATOR . 'ConfigurationLocal.php', true); 121 121 if (!$configurationLocalLoaded) { 122 $this->load ($basePath . DIRECTORY_SEPARATOR . 'Configuration.php');122 $this->loadFile($basePath . DIRECTORY_SEPARATOR . 'Configuration.php'); 123 123 } 124 124 } -
linguise/tags/2.2.30/vendor/linguise/script-php/src/Defer.php
r2650802 r3479656 3 3 namespace Linguise\Vendor\Linguise\Script\Core; 4 4 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore 6 6 7 7 class Defer -
linguise/tags/2.2.30/vendor/linguise/script-php/src/Helper.php
r3388557 r3479656 344 344 } 345 345 } 346 347 /** 348 * Stop the script execution 349 * 350 * @param string $message Optional message to display upon stopping 351 * 352 * @return void 353 */ 354 public static function stop($message = '') 355 { 356 if (!defined('LINGUISE_SCRIPT_TESTING')) { 357 die($message); // @codeCoverageIgnore 358 } 359 } 346 360 } -
linguise/tags/2.2.30/vendor/linguise/script-php/src/Hook.php
r3265440 r3479656 3 3 namespace Linguise\Vendor\Linguise\Script\Core; 4 4 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore 6 6 7 7 class Hook -
linguise/tags/2.2.30/vendor/linguise/script-php/src/HttpResponse.php
r3354997 r3479656 3 3 namespace Linguise\Vendor\Linguise\Script\Core; 4 4 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore 6 6 7 class HttpResponse { 7 class HttpResponse 8 { 8 9 static function errorJSON($message, $code = 500) 9 10 { … … 14 15 'message' => $message 15 16 ]); 16 exit;17 Helper::stop(); 17 18 } 18 19 … … 26 27 'data' => $data 27 28 ]); 28 exit;29 Helper::stop(); 29 30 } 30 31 … … 35 36 echo '<h1>403 Forbidden</h1>'; 36 37 echo '<p>You are not allowed to access this page.</p>'; 37 die();38 Helper::stop(); 38 39 } 39 40 … … 44 45 echo '<h1>400 Bad Request</h1>'; 45 46 echo '<p>Unknown action.</p>'; 46 die();47 Helper::stop(); 47 48 } 48 49 } -
linguise/tags/2.2.30/vendor/linguise/script-php/src/Management.php
r3397694 r3479656 3 3 namespace Linguise\Vendor\Linguise\Script\Core; 4 4 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore 6 6 7 use Linguise\Vendor\Linguise\Script\Core\HttpResponse; 7 8 8 class Management { 9 class Management 10 { 9 11 /** 10 12 * @var null|Management … … 46 48 } 47 49 48 public function editorRun() { 50 public function editorRun() 51 { 49 52 Helper::defineConstants(false); 50 53 … … 67 70 $oobe = OobeManager::getInstance(); 68 71 $oobe->run($message, $api_web_errors); 72 return; 69 73 } 70 74 if (!isset($_POST['_token'])) { … … 73 77 $oobe = OobeManager::getInstance(); 74 78 $oobe->run($message, $api_web_errors); 79 return; 75 80 } 76 81 if (!$sess->verifyCsrfToken('linguise_config', $_POST['_token'])) { … … 78 83 $oobe = OobeManager::getInstance(); 79 84 $oobe->run($message, $api_web_errors); 85 return; 80 86 } 81 87 … … 127 133 ]; 128 134 } else { 135 // @codeCoverageIgnoreStart 129 136 $api_web_errors[] = [ 130 137 'type' => 'error', 131 138 'message' => 'Unable to load configuration from Linguise, please try again later or contact our support team if the problem persist.', 132 139 ]; 140 // @codeCoverageIgnoreEnd 133 141 } 134 142 … … 158 166 159 167 if (empty($dynamic_translations['public_key']) && !empty($old_options['dynamic_translations']['public_key'])) { 160 $dynamic_translations['public_key'] = $old_options['dynamic_translations']['public_key']; 168 $dynamic_translations['public_key'] = $old_options['dynamic_translations']['public_key']; // @codeCoverageIgnore 161 169 } 162 170 … … 169 177 if ($token_changed) { 170 178 // If token changed, we update enabled state 179 // @codeCoverageIgnoreStart 171 180 $dynamic_translations['enabled'] = Helper::boolInt($api_result['data']['dynamic_translations']['enabled']); 181 // @codeCoverageIgnoreEnd 172 182 } 173 183 } else if ($api_result !== false && isset($api_result['status_code'])) { … … 329 339 if ($original['value'] === $value) { 330 340 // Skip if value is the same as original 331 continue; 341 continue; // @codeCoverageIgnore 332 342 } 333 343 334 344 if ($original['value'] === null && empty($value)) { 335 345 // If original is null and value is empty, we don't need to save it 336 continue; 346 continue; // @codeCoverageIgnore 337 347 } 338 348 … … 355 365 if (!$sess->hasSession()) { 356 366 HttpResponse::errorJSON('Unauthorized', 401); 367 return; 357 368 } 358 369 if (!isset($_POST['nonce'])) { 359 370 HttpResponse::errorJSON('Missing nonce token', 400); 371 return; 360 372 } 361 373 if (!$sess->verifyCsrfToken('linguise_config_iframe', $_POST['nonce'])) { 362 374 HttpResponse::errorJSON('Invalid nonce token', 403); 375 return; 363 376 } 364 377 … … 378 391 // response with error 379 392 HttpResponse::errorJSON('Missing required field: ' . $field, 400); 393 return; 380 394 } 381 395 } … … 414 428 } 415 429 416 // This is from API -> Website 430 /** 431 * This is from API -> Website (here) 432 * 433 * @codeCoverageIgnore 434 */ 417 435 public function remoteUpdate() 418 436 { … … 421 439 if (empty($jwt_token)) { 422 440 HttpResponse::errorJSON('Missing Hash header', 400); 441 return; 423 442 } 424 443 … … 427 446 if (empty($input_data)) { 428 447 HttpResponse::errorJSON('Invalid request', 400); 448 return; 429 449 } 430 450 … … 432 452 if (json_last_error() !== JSON_ERROR_NONE) { 433 453 HttpResponse::errorJSON('Invalid JSON data', 400); 454 return; 434 455 } 435 456 … … 440 461 if ($input_data['token'] !== $options['token']) { 441 462 HttpResponse::errorJSON('Invalid token', 401); 463 return; 442 464 } 443 465 … … 503 525 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); 504 526 if (Configuration::getInstance()->get('dl_certificates') === true) { 505 curl_setopt($ch, CURLOPT_CAINFO, Certificates::getInstance()->getPath()); 527 curl_setopt($ch, CURLOPT_CAINFO, Certificates::getInstance()->getPath()); // @codeCoverageIgnore 506 528 } 507 529 } … … 510 532 $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); 511 533 if (PHP_VERSION_ID < 80000) { 534 // @codeCoverageIgnoreStart 512 535 curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5) 536 // @codeCoverageIgnoreEnd 513 537 } 514 538 515 539 if ($response_code !== 200) { 516 540 HttpResponse::errorJSON('Invalid JWT verification token: ' . print_r($response_code, true), 403); 541 return; 517 542 } 518 543 … … 538 563 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); 539 564 if (Configuration::getInstance()->get('dl_certificates') === true) { 540 curl_setopt($ch, CURLOPT_CAINFO, Certificates::getInstance()->getPath()); 565 curl_setopt($ch, CURLOPT_CAINFO, Certificates::getInstance()->getPath()); // @codeCoverageIgnore 541 566 } 542 567 } … … 548 573 $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); 549 574 if (PHP_VERSION_ID < 80000) { 575 // @codeCoverageIgnoreStart 550 576 curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5) 577 // @codeCoverageIgnoreEnd 551 578 } 552 579 … … 597 624 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); 598 625 if (Configuration::getInstance()->get('dl_certificates') === true) { 599 curl_setopt($ch, CURLOPT_CAINFO, Certificates::getInstance()->getPath()); 626 curl_setopt($ch, CURLOPT_CAINFO, Certificates::getInstance()->getPath()); // @codeCoverageIgnore 600 627 } 601 628 } … … 607 634 $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); 608 635 if (PHP_VERSION_ID < 80000) { 636 // @codeCoverageIgnoreStart 609 637 curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5) 638 // @codeCoverageIgnoreEnd 610 639 } 611 640 … … 636 665 637 666 if (!empty($api_host)) { 638 return $protocol . '://' . $api_host . (in_array($api_port, $api_port_base) ? '' : ':' . $api_port) . ''; 667 return $protocol . '://' . $api_host . (in_array($api_port, $api_port_base) ? '' : ':' . $api_port) . ''; // @codeCoverageIgnore 639 668 } 640 669 } -
linguise/tags/2.2.30/vendor/linguise/script-php/src/OobeManager.php
r3463145 r3479656 3 3 namespace Linguise\Vendor\Linguise\Script\Core; 4 4 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore 6 6 7 7 use Linguise\Vendor\Linguise\Script\Core\Helper; 8 8 9 class OobeManager { 9 class OobeManager 10 { 10 11 /** 11 12 * @var null|OobeManager … … 37 38 } 38 39 39 public function oobeRun($html_message = \null) { 40 public function oobeRun($html_message = \null) 41 { 40 42 // Start session 41 43 $sess = Session::getInstance()->start(); … … 54 56 } 55 57 58 /** 59 * @codeCoverageIgnore 60 */ 56 61 private function writeOOBE($database_store) 57 62 { 63 if (defined('LINGUISE_SCRIPT_TESTING_SKIP_OOBE_WRITE') && LINGUISE_SCRIPT_TESTING_SKIP_OOBE_WRITE) { 64 return; 65 } 66 58 67 // Modify OOBE status in ui-config.php 59 68 $ui_config = realpath(__DIR__ . DIRECTORY_SEPARATOR . '..') . DIRECTORY_SEPARATOR . 'ui-config.php'; … … 63 72 if (empty($replaced_content)) { 64 73 HttpResponse::errorJSON('Failed to update ui-config.php', 500); 74 return; 65 75 } 66 76 … … 80 90 http_response_code($status_code); 81 91 $this->oobeRun($message); 82 die(); 92 if (!defined('LINGUISE_SCRIPT_TESTING')) { 93 die(); // @codeCoverageIgnore 94 } 83 95 } 84 96 … … 158 170 if (!isset($_POST['_token'])) { 159 171 HttpResponse::errorJSON('Missing CSRF token', 400); 172 return; 160 173 } 161 174 $sess = Session::getInstance()->start(); 162 175 if (!$sess->verifyCsrfToken('linguise_oobe_register', $_POST['_token'])) { 163 176 HttpResponse::errorJSON('Invalid CSRF token', 403); 177 return; 164 178 } 165 179 } … … 176 190 if (empty($mode)) { 177 191 HttpResponse::errorJSON('Missing `db_mode` data', 400); 192 return; 178 193 } 179 194 … … 182 197 if (empty($host) || empty($user) || empty($name)) { 183 198 HttpResponse::errorJSON('Missing `db_host`, `db_user` or `db_name` data', 400); 199 return; 184 200 } 185 201 if (!$testMode && (empty($prefix))) { 186 202 HttpResponse::errorJSON('Missing `db_prefix` data', 400); 203 return; 187 204 } 188 205 … … 191 208 if ($result !== true) { 192 209 HttpResponse::errorJSON($result, 500); 210 return; 193 211 } 194 212 HttpResponse::successJSON(true, 'MySQL connection test successful', 200); 213 return; 195 214 } 196 215 … … 210 229 if ($result !== true) { 211 230 HttpResponse::errorJSON($result, 500); 231 return; 212 232 } 213 233 HttpResponse::successJSON(true, 'SQLite connection test successful', 200); 234 return; 214 235 } 215 236 … … 228 249 if (defined('LINGUISE_OOBE_DONE') && LINGUISE_OOBE_DONE) { 229 250 $this->oobeRunError('Not allowed', 403); 251 return; 230 252 } elseif (!defined('LINGUISE_OOBE_DONE')) { 231 253 // Missing data 232 254 $this->oobeRunError('Unknown status', 500); 255 return; 233 256 } 234 257 235 258 if (!isset($_POST['_token'])) { 236 259 $this->oobeRunError('Missing CSRF token', 400); 260 return; 237 261 } 238 262 $sess = Session::getInstance()->start(); 239 263 if (!$sess->verifyCsrfToken('linguise_oobe_register', $_POST['_token'])) { 240 264 $this->oobeRunError('Invalid CSRF token', 403); 265 return; 241 266 } 242 267 … … 244 269 if (empty($new_pass)) { 245 270 $this->oobeRunError('Missing password', 400); 271 return; 246 272 } 247 273 … … 250 276 if (strlen($new_pass) < 10) { 251 277 $this->oobeRunError('Password must be at least 10 characters long', 400); 278 return; 252 279 } 253 280 254 281 if ($sess->hasSession()) { 255 282 $this->oobeRunError('Already activated', 403); 283 return; 256 284 } 257 285 … … 260 288 if (!isset($_POST['token'])) { 261 289 $this->oobeRunError('Missing token', 400); 290 return; 262 291 } 263 292 … … 265 294 if ($token !== Configuration::getInstance()->get('token')) { 266 295 $this->oobeRunError('Invalid token provided in session', 401); 296 return; 267 297 } 268 298 … … 288 318 if ($sqlite_test !== true) { 289 319 $this->oobeRunError($sqlite_test, 500); 320 return; 290 321 } 291 322 } … … 341 372 $sess->setSession($hashed_pass, true); // Set session with password mode 342 373 $this->run(); 343 die(); 374 if (!defined('LINGUISE_SCRIPT_TESTING')) { 375 die(); // @codeCoverageIgnore 376 } 344 377 } else { 345 378 // This will automatically return error response … … 364 397 if ($sqlite_test !== true) { 365 398 $this->oobeRunError($sqlite_test, 500); 399 return; 366 400 } 367 401 } … … 376 410 if ($existing_password) { 377 411 $this->oobeRunError('Password already set', 400); 412 return; 378 413 } 379 414 … … 394 429 $sess->setSession($hashed_pass, true); // Set session with password mode 395 430 $this->run(); 396 die(); 397 } 398 } 399 400 public function run($html_message = \null, $api_web_errors = []) { 431 if (!defined('LINGUISE_SCRIPT_TESTING')) { 432 die(); // @codeCoverageIgnore 433 } 434 } 435 } 436 437 public function run($html_message = \null, $api_web_errors = []) 438 { 401 439 // Start session 402 440 $sess = Session::getInstance()->start(); … … 411 449 case 'download-debug': 412 450 $this->downloadDebug(); 413 break;451 return; // @codeCoverageIgnore 414 452 case 'update-config': 415 453 break; … … 420 458 HttpResponse::unknownGETAction(); 421 459 } 422 break;460 return; // @codeCoverageIgnore 423 461 } 424 462 } … … 449 487 } 450 488 require_once LINGUISE_BASE_DIR . 'src' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'footer.php'; 451 die(); 489 if (!defined('LINGUISE_SCRIPT_TESTING')) { 490 die(); // @codeCoverageIgnore 491 } 452 492 } 453 493 … … 464 504 // No session, we just redirect to login page 465 505 HttpResponse::successJSON(true, 'No session found', 200); 466 exit;467 506 } 468 507 } … … 473 512 $message = '<div class="linguise-notification-popup"><span class="material-icons fail">check</span>Missing CSRF token</div>'; 474 513 $this->oobeRun($message); 514 return; 475 515 } 476 516 $sess = Session::getInstance()->start(); … … 478 518 $message = '<div class="linguise-notification-popup"><span class="material-icons fail">check</span>Invalid CSRF token</div>'; 479 519 $this->oobeRun($message); 520 return; 480 521 } 481 522 … … 498 539 } 499 540 541 /** 542 * @codeCoverageIgnore 543 */ 500 544 private function testMySQL($host, $user, $password, $name, $port = 3306, $prefix = '') 501 545 { 546 if (defined('LINGUISE_TESTING_SKIP_DB_CHECK')) { 547 return LINGUISE_TESTING_SKIP_DB_CHECK; 548 } 549 502 550 // Check if MySQLi is enabled 503 551 if (!extension_loaded('mysqli')) { … … 532 580 } 533 581 582 /** 583 * @codeCoverageIgnore 584 */ 534 585 private function testSqlite() 535 586 { 587 if (defined('LINGUISE_TESTING_SKIP_DB_CHECK')) { 588 return LINGUISE_TESTING_SKIP_DB_CHECK; 589 } 590 536 591 // Check if SQLite3 is enabled 537 592 if (!extension_loaded('sqlite3')) { … … 557 612 } 558 613 614 /** 615 * @codeCoverageIgnore 616 */ 559 617 private function prepareRootDatabaseSQLite() 560 618 { 619 if (defined('LINGUISE_TESTING_SKIP_DB_CHECK')) { 620 return LINGUISE_TESTING_SKIP_DB_CHECK; 621 } 622 561 623 $databases_dir = LINGUISE_BASE_DIR . '.databases' . DIRECTORY_SEPARATOR; 562 624 if (!file_exists($databases_dir)) { … … 596 658 $sess = Session::getInstance()->start(); 597 659 if (!$sess->hasSession()) { 598 die('Unauthorized'); 660 if (!defined('LINGUISE_SCRIPT_TESTING')) { 661 die('Unauthorized'); // @codeCoverageIgnore 662 } else { 663 throw new \Exception('Unauthorized'); 664 } 599 665 } 600 666 601 667 $debug_file = LINGUISE_BASE_DIR . 'debug.php'; 602 668 if (file_exists($debug_file)) { 669 // @codeCoverageIgnoreStart 603 670 header('Content-Description: File Transfer'); 604 671 header('Content-Type: application/octet-stream'); … … 617 684 } 618 685 619 die(); 686 if (!defined('LINGUISE_SCRIPT_TESTING')) { 687 die(); // @codeCoverageIgnore 688 } 689 // @codeCoverageIgnoreEnd 620 690 } else { 621 die('No debug file found'); 691 if (!defined('LINGUISE_SCRIPT_TESTING')) { 692 die('No debug file found'); // @codeCoverageIgnore 693 } else { 694 echo 'No debug file found'; 695 } 622 696 } 623 697 } … … 650 724 651 725 // Connect to database and install options 652 Helper::prepareDataDir(); 726 if (!defined('LINGUISE_TESTING_SKIP_DB_CHECK')) { 727 Helper::prepareDataDir(); // @codeCoverageIgnore 728 } 653 729 $db = Database::getInstance(true); 654 730 655 731 if (!LINGUISE_OOBE_DONE) { 656 732 // Not yet ready 657 return; 733 return; // @codeCoverageIgnore 658 734 } 659 735 … … 694 770 if (!$sess->hasSession()) { 695 771 HttpResponse::errorJSON('Unauthorized', 401); 772 return; 696 773 } 697 774 if (!isset($_GET['nonce'])) { 698 775 HttpResponse::errorJSON('Missing nonce token', 400); 776 return; 699 777 } 700 778 if (!$sess->verifyCsrfToken('linguise_clear_debug', $_GET['nonce'])) { 701 779 HttpResponse::errorJSON('Invalid nonce token', 403); 780 return; 702 781 } 703 782 … … 721 800 if (!$sess->hasSession()) { 722 801 HttpResponse::errorJSON('Unauthorized', 401); 802 return; 723 803 } 724 804 if (!isset($_GET['nonce'])) { 725 805 HttpResponse::errorJSON('Missing nonce token', 400); 806 return; 726 807 } 727 808 if (!$sess->verifyCsrfToken('linguise_clear_cache', $_GET['nonce'])) { 728 809 HttpResponse::errorJSON('Invalid nonce token', 403); 810 return; 729 811 } 730 812 -
linguise/tags/2.2.30/vendor/linguise/script-php/src/Session.php
r3388557 r3479656 80 80 } 81 81 82 return Database::getInstance(true, true)->ensureConnection(); 82 return Database::getInstance(true, true)->ensureConnection(); // @codeCoverageIgnore 83 83 } 84 84 -
linguise/tags/2.2.30/vendor/linguise/script-php/src/templates/Helper.php
r3316993 r3479656 5 5 use Linguise\Vendor\Linguise\Script\Core\Request; 6 6 7 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); 7 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore 8 8 9 9 class Helper { -
linguise/tags/2.2.30/vendor/linguise/script-php/src/templates/management-expert.php
r3316993 r3479656 89 89 return $root . '/' . AdminHelper::getManagementBase(); 90 90 } 91 return $root . '/' . AdminHelper::getManagementBase() . '?linguise_action=' . $action; 91 return $root . '/' . AdminHelper::getManagementBase() . '?linguise_action=' . $action; // @codeCoverageIgnore 92 92 } 93 93 -
linguise/tags/2.2.30/vendor/linguise/script-php/src/templates/management.php
r3321000 r3479656 81 81 $nonce = Session::getInstance()->getCsrfToken($nonce_key); 82 82 if (empty($nonce)) { 83 return make_action_url($action); 83 return make_action_url($action); // @codeCoverageIgnore 84 84 } 85 85 return make_action_url($action) . '&nonce=' . $nonce; … … 98 98 foreach ($global_options['enabled_languages'] as $language) { 99 99 if ($language === $global_options['default_language']) { 100 continue; 100 continue; // @codeCoverageIgnore 101 101 } 102 102 if (isset($languages_contents[$language])) { -
linguise/trunk/composer.json
r3463145 r3479656 22 22 }, 23 23 "require": { 24 "linguise/script-php": "^1.3.4 5",24 "linguise/script-php": "^1.3.46", 25 25 "symfony/polyfill-intl-idn": "1.31.0", 26 26 "symfony/polyfill-mbstring": "1.31.0", -
linguise/trunk/languages/linguise.pot
r3478678 r3479656 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Linguise - AI Automatic Multilingual Translation 2.2. 29\n"5 "Project-Id-Version: Linguise - AI Automatic Multilingual Translation 2.2.30\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/linguise\n" 7 7 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" -
linguise/trunk/linguise.php
r3478678 r3479656 5 5 * Plugin URI: https://www.linguise.com/ 6 6 * Description: Linguise translation plugin 7 * Version:2.2. 297 * Version:2.2.30 8 8 * Text Domain: linguise 9 9 * Domain Path: /languages -
linguise/trunk/readme.txt
r3478678 r3479656 4 4 Requires at least: 4.0 5 5 Tested up to: 6.9 6 Stable tag: 2.2. 296 Stable tag: 2.2.30 7 7 Requires PHP: 7.0 8 8 License: GPLv2 or later … … 108 108 109 109 == Changelog == 110 = 2.2.30 = 111 - Feature: Make cache clearing more consistent and eager 112 110 113 = 2.2.29 = 111 114 - Fix: "has attribute" can be null in some cases should have used conditional op -
linguise/trunk/src/constants.php
r3478678 r3479656 1 1 <?php 2 2 if (!defined('LINGUISE_SCRIPT_TRANSLATION_VERSION')) { 3 define('LINGUISE_SCRIPT_TRANSLATION_VERSION', 'wordpress_plugin/2.2. 29');3 define('LINGUISE_SCRIPT_TRANSLATION_VERSION', 'wordpress_plugin/2.2.30'); 4 4 } 5 5 6 6 if (!defined('LINGUISE_VERSION')) { 7 define('LINGUISE_VERSION', '2.2. 29');7 define('LINGUISE_VERSION', '2.2.30'); 8 8 } -
linguise/trunk/vendor/autoload.php
r3463145 r3479656 23 23 require_once __DIR__ . '/composer/autoload_real.php'; 24 24 25 return ComposerAutoloaderInit af7434287c0c5184d81a0a96ec705617::getLoader();25 return ComposerAutoloaderInit64d341d450ad698561b4da1b882592a7::getLoader(); -
linguise/trunk/vendor/composer/autoload_psr4.php
r3226654 r3479656 13 13 'Symfony\\Polyfill\\Intl\\Normalizer\\' => array($vendorDir . '/symfony/polyfill-intl-normalizer'), 14 14 'Symfony\\Polyfill\\Intl\\Idn\\' => array($vendorDir . '/symfony/polyfill-intl-idn'), 15 'Linguise\\Script\\Core\\Templates\\' => array($vendorDir . '/linguise/script-php/src/templates'), 15 16 'Linguise\\Script\\Core\\' => array($vendorDir . '/linguise/script-php/src'), 16 17 'JsonPath\\' => array($vendorDir . '/galbar/jsonpath/src/Galbar/JsonPath'), -
linguise/trunk/vendor/composer/autoload_real.php
r3463145 r3479656 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit af7434287c0c5184d81a0a96ec7056175 class ComposerAutoloaderInit64d341d450ad698561b4da1b882592a7 6 6 { 7 7 private static $loader; … … 23 23 } 24 24 25 spl_autoload_register(array('ComposerAutoloaderInit af7434287c0c5184d81a0a96ec705617', 'loadClassLoader'), true, true);25 spl_autoload_register(array('ComposerAutoloaderInit64d341d450ad698561b4da1b882592a7', 'loadClassLoader'), true, true); 26 26 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); 27 spl_autoload_unregister(array('ComposerAutoloaderInit af7434287c0c5184d81a0a96ec705617', 'loadClassLoader'));27 spl_autoload_unregister(array('ComposerAutoloaderInit64d341d450ad698561b4da1b882592a7', 'loadClassLoader')); 28 28 29 29 require __DIR__ . '/autoload_static.php'; 30 call_user_func(\Composer\Autoload\ComposerStaticInit af7434287c0c5184d81a0a96ec705617::getInitializer($loader));30 call_user_func(\Composer\Autoload\ComposerStaticInit64d341d450ad698561b4da1b882592a7::getInitializer($loader)); 31 31 32 32 $loader->register(true); 33 33 34 $filesToLoad = \Composer\Autoload\ComposerStaticInit af7434287c0c5184d81a0a96ec705617::$files;34 $filesToLoad = \Composer\Autoload\ComposerStaticInit64d341d450ad698561b4da1b882592a7::$files; 35 35 $requireFile = \Closure::bind(static function ($fileIdentifier, $file) { 36 36 if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { -
linguise/trunk/vendor/composer/autoload_static.php
r3463145 r3479656 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit af7434287c0c5184d81a0a96ec7056177 class ComposerStaticInit64d341d450ad698561b4da1b882592a7 8 8 { 9 9 public static $files = array ( … … 31 31 'L' => 32 32 array ( 33 'Linguise\\Script\\Core\\Templates\\' => 31, 33 34 'Linguise\\Script\\Core\\' => 21, 34 35 ), … … 63 64 array ( 64 65 0 => __DIR__ . '/..' . '/symfony/polyfill-intl-idn', 66 ), 67 'Linguise\\Script\\Core\\Templates\\' => 68 array ( 69 0 => __DIR__ . '/..' . '/linguise/script-php/src/templates', 65 70 ), 66 71 'Linguise\\Script\\Core\\' => … … 156 161 { 157 162 return \Closure::bind(function () use ($loader) { 158 $loader->prefixLengthsPsr4 = ComposerStaticInit af7434287c0c5184d81a0a96ec705617::$prefixLengthsPsr4;159 $loader->prefixDirsPsr4 = ComposerStaticInit af7434287c0c5184d81a0a96ec705617::$prefixDirsPsr4;160 $loader->classMap = ComposerStaticInit af7434287c0c5184d81a0a96ec705617::$classMap;163 $loader->prefixLengthsPsr4 = ComposerStaticInit64d341d450ad698561b4da1b882592a7::$prefixLengthsPsr4; 164 $loader->prefixDirsPsr4 = ComposerStaticInit64d341d450ad698561b4da1b882592a7::$prefixDirsPsr4; 165 $loader->classMap = ComposerStaticInit64d341d450ad698561b4da1b882592a7::$classMap; 161 166 162 167 }, null, ClassLoader::class); -
linguise/trunk/vendor/composer/installed.json
r3463145 r3479656 57 57 { 58 58 "name": "linguise/script-php", 59 "version": "v1.3.4 5",60 "version_normalized": "1.3.4 5.0",59 "version": "v1.3.46", 60 "version_normalized": "1.3.46.0", 61 61 "source": { 62 62 "type": "git", 63 63 "url": "git@bitbucket.org:linguise/script-php.git", 64 "reference": "0 a8f5e7d6aaa343d311e7c4de3858808685272ef"64 "reference": "0d251debce930c506aa3cd7c9835f64045888d8a" 65 65 }, 66 66 "require": { … … 75 75 "vlucas/phpdotenv": "^5.6" 76 76 }, 77 "time": "2026-0 2-17T06:35:08+00:00",77 "time": "2026-03-11T01:49:57+00:00", 78 78 "type": "library", 79 79 "installation-source": "source", 80 80 "autoload": { 81 81 "psr-4": { 82 "Linguise\\Script\\Core\\": "src/" 82 "Linguise\\Script\\Core\\": "src/", 83 "Linguise\\Script\\Core\\Templates\\": "src/templates/" 83 84 } 84 85 }, -
linguise/trunk/vendor/composer/installed.php
r3478678 r3479656 4 4 'pretty_version' => 'dev-master', 5 5 'version' => 'dev-master', 6 'reference' => ' 08a04170ddd02ca3bd401c6a811ee4c513c54364',6 'reference' => 'b3dc8d26c6f5a95b5137af0a0b83bcaac4023c42', 7 7 'type' => 'library', 8 8 'install_path' => __DIR__ . '/../../', … … 21 21 ), 22 22 'linguise/script-php' => array( 23 'pretty_version' => 'v1.3.4 5',24 'version' => '1.3.4 5.0',25 'reference' => '0 a8f5e7d6aaa343d311e7c4de3858808685272ef',23 'pretty_version' => 'v1.3.46', 24 'version' => '1.3.46.0', 25 'reference' => '0d251debce930c506aa3cd7c9835f64045888d8a', 26 26 'type' => 'library', 27 27 'install_path' => __DIR__ . '/../linguise/script-php', … … 32 32 'pretty_version' => 'dev-master', 33 33 'version' => 'dev-master', 34 'reference' => ' 08a04170ddd02ca3bd401c6a811ee4c513c54364',34 'reference' => 'b3dc8d26c6f5a95b5137af0a0b83bcaac4023c42', 35 35 'type' => 'library', 36 36 'install_path' => __DIR__ . '/../../', -
linguise/trunk/vendor/linguise/script-php/.version
r3463145 r3479656 1 1.3.4 51 1.3.46 -
linguise/trunk/vendor/linguise/script-php/composer.json
r3366846 r3479656 12 12 "autoload": { 13 13 "psr-4": { 14 "Linguise\\Script\\Core\\": "src/" 14 "Linguise\\Script\\Core\\": "src/", 15 "Linguise\\Script\\Core\\Templates\\": "src/templates/" 15 16 } 16 17 }, -
linguise/trunk/vendor/linguise/script-php/src/Cache.php
r3321566 r3479656 3 3 namespace Linguise\Vendor\Linguise\Script\Core; 4 4 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore 6 6 7 7 class Cache … … 39 39 * @return Cache 40 40 */ 41 public static function getInstance() {42 43 if (is_null(self::$_instance)) {41 public static function getInstance() 42 { 43 if (is_null(self::$_instance)) { 44 44 self::$_instance = new Cache(); 45 45 } … … 48 48 } 49 49 50 public function getPath() { 50 public function getPath() 51 { 51 52 Helper::prepareDataDir(); 52 53 return Configuration::getInstance()->get('data_dir') . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR; 53 54 } 54 55 55 public function serve() { 56 public function serve() 57 { 56 58 $response = Response::getInstance(); 57 59 … … 69 71 // In case we failed to json_encode (non utf8 chars and no mbstring extension) 70 72 if (!$this->_hash) { 71 return false; 73 return false; // @codeCoverageIgnore 72 74 } 73 75 … … 82 84 83 85 if (!$this->load()) { 84 return false; 86 return false; // @codeCoverageIgnore 85 87 } 86 88 … … 90 92 } 91 93 92 protected function load() { 94 protected function load() 95 { 93 96 $cache_file = Configuration::getInstance()->get('data_dir') . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . $this->_language . '_' . $this->_hash . '.php'; 94 97 … … 108 111 } 109 112 110 public function save() { 113 public function save() 114 { 111 115 if (!$this->_hash || !$this->_language) { 112 116 return false; … … 128 132 } 129 133 134 // Run clear first 135 $this->clear(true, 30); // aggresive 30s cache time check 136 130 137 file_put_contents($cache_file, '<?php die(); ?>' . $content); 131 138 … … 134 141 135 142 /** 143 * Internal method to check if the cache should be cleared based on the last cleared time and the cache time check defined in configuration 144 * 145 * @param int $cache_time_check The time in seconds to check if the cache should be cleared or not 146 * 147 * @return boolean 148 */ 149 private function internalShouldBeExecuted($cache_time_check) 150 { 151 $cache_info_file = $this->getPath() . 'clear.txt'; 152 153 if (file_exists($cache_info_file)) { 154 $last_cleared = file_get_contents($cache_info_file); 155 if ($last_cleared === false) { 156 // If we cannot read the file, consider it as not cleared 157 return true; // @codeCoverageIgnore 158 } 159 160 // Strip then cast to int 161 $last_cleared = (int)trim($last_cleared); 162 if (time() - $last_cleared < $cache_time_check) { 163 // Cache was cleared recently, skip 164 return false; 165 } 166 } 167 168 // too old, we can clear it again 169 return true; 170 } 171 172 /** 136 173 * Check if the request to launch this task should be executed or not 137 174 * 138 175 * @return bool 139 176 */ 140 public function shouldBeExecuted() { 177 public function shouldBeExecuted() 178 { 141 179 if (!Configuration::getInstance()->get('cache_enabled')) { 142 180 return false; 143 181 } 144 $cache_info_file = $this->getPath() . 'clear.txt'; 145 if (file_exists($cache_info_file) && (int)file_get_contents($cache_info_file) + Configuration::getInstance()->get('cache_time_check') > time()) { 146 return false; 147 } 148 return true; 149 } 150 151 public function clear() { 152 if (!$this->shouldBeExecuted()) { 182 183 $cache_time_check = Configuration::getInstance()->get('cache_time_check') ?? 600; 184 // cast to int 185 $cache_time_check = (int)$cache_time_check; 186 return $this->internalShouldBeExecuted($cache_time_check); 187 } 188 189 /** 190 * Clear cache files until the total size is under the limit defined in configuration 191 * 192 * @param boolean $no_output Whether to output the response or not, set to true when this method is not called from web request 193 * @param boolean $real_timing The real timing to check if the cache should be cleared or not, used for testing purposes 194 */ 195 public function clear($no_output = false, $real_timing = null) 196 { 197 if ($real_timing !== null && !$this->internalShouldBeExecuted($real_timing)) { 153 198 return; 199 } elseif ($real_timing === null && !$this->shouldBeExecuted()) { 200 return; 154 201 } 155 202 … … 158 205 $files = glob($cache_path . '*.php'); 159 206 160 usort($files, function ($x, $y) {207 usort($files, function ($x, $y) { 161 208 $x_mtime = @filemtime($x); // Silent both errors if the file does not exist or is not readable 162 209 $y_mtime = @filemtime($y); 163 210 if ($x_mtime === false || $y_mtime === false) { 164 return 0; // If we cannot get the modification time, consider them equal 211 // If we cannot get the modification time, consider them equal 212 return 0; // @codeCoverageIgnore 165 213 } 166 214 return ($x_mtime < $y_mtime) ? -1 : 1; … … 176 224 $size = @filesize($file); // Silent the error if the file does not exist or is not readable 177 225 if ($size === false) { 178 continue; // If we cannot get the size, skip this file 226 // If we cannot get the size, skip this file 227 continue; // @codeCoverageIgnore 179 228 } 180 229 $total_size += $size; … … 188 237 file_put_contents($cache_path . 'clear.txt', time()); 189 238 239 if ($no_output) { 240 return; 241 } 242 190 243 $response = Response::getInstance(); 191 244 $response->setResponseCode(200, false); 192 $response->setContent('Cleared cache: ' . (int)($total_cleared /1000) . 'kb');245 $response->setContent('Cleared cache: ' . (int)($total_cleared / 1000) . 'kb'); 193 246 $response->end(); 194 247 } … … 200 253 $files = glob($cache_path . '*.php'); 201 254 202 foreach ($files as $file) {255 foreach ($files as $file) { 203 256 if (!in_array($file, ['.', '..']) && is_file($file)) { 204 257 $size = @filesize($file); // Silent the error if the file does not exist or is not readable 205 258 if ($size === false) { 206 continue; // If we cannot get the size, skip this file 259 // If we cannot get the size, skip this file 260 continue; // @codeCoverageIgnore 207 261 } 208 262 $total_cleared += $size; … … 213 267 $response = Response::getInstance(); 214 268 if ($total_cleared > 0) { 215 $response->setContent('Cleared cache: ' . (int)($total_cleared /1000) . 'kb');269 $response->setContent('Cleared cache: ' . (int)($total_cleared / 1000) . 'kb'); 216 270 } else { 217 271 $response->setContent('Cache Empty!'); -
linguise/trunk/vendor/linguise/script-php/src/Certificates.php
r3397694 r3479656 3 3 namespace Linguise\Vendor\Linguise\Script\Core; 4 4 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore 6 6 7 7 class Certificates … … 70 70 /** 71 71 * Download latest bundle 72 * 73 * @codeCoverageIgnore 72 74 * 73 75 * @return void -
linguise/trunk/vendor/linguise/script-php/src/Configuration.php
r3316163 r3479656 4 4 use ReflectionProperty; 5 5 6 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); 6 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore 7 7 8 8 class Configuration { … … 120 120 $configurationLocalLoaded = $this->loadFile($basePath . DIRECTORY_SEPARATOR . 'ConfigurationLocal.php', true); 121 121 if (!$configurationLocalLoaded) { 122 $this->load ($basePath . DIRECTORY_SEPARATOR . 'Configuration.php');122 $this->loadFile($basePath . DIRECTORY_SEPARATOR . 'Configuration.php'); 123 123 } 124 124 } -
linguise/trunk/vendor/linguise/script-php/src/Defer.php
r2650802 r3479656 3 3 namespace Linguise\Vendor\Linguise\Script\Core; 4 4 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore 6 6 7 7 class Defer -
linguise/trunk/vendor/linguise/script-php/src/Helper.php
r3388557 r3479656 344 344 } 345 345 } 346 347 /** 348 * Stop the script execution 349 * 350 * @param string $message Optional message to display upon stopping 351 * 352 * @return void 353 */ 354 public static function stop($message = '') 355 { 356 if (!defined('LINGUISE_SCRIPT_TESTING')) { 357 die($message); // @codeCoverageIgnore 358 } 359 } 346 360 } -
linguise/trunk/vendor/linguise/script-php/src/Hook.php
r3265440 r3479656 3 3 namespace Linguise\Vendor\Linguise\Script\Core; 4 4 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore 6 6 7 7 class Hook -
linguise/trunk/vendor/linguise/script-php/src/HttpResponse.php
r3354997 r3479656 3 3 namespace Linguise\Vendor\Linguise\Script\Core; 4 4 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore 6 6 7 class HttpResponse { 7 class HttpResponse 8 { 8 9 static function errorJSON($message, $code = 500) 9 10 { … … 14 15 'message' => $message 15 16 ]); 16 exit;17 Helper::stop(); 17 18 } 18 19 … … 26 27 'data' => $data 27 28 ]); 28 exit;29 Helper::stop(); 29 30 } 30 31 … … 35 36 echo '<h1>403 Forbidden</h1>'; 36 37 echo '<p>You are not allowed to access this page.</p>'; 37 die();38 Helper::stop(); 38 39 } 39 40 … … 44 45 echo '<h1>400 Bad Request</h1>'; 45 46 echo '<p>Unknown action.</p>'; 46 die();47 Helper::stop(); 47 48 } 48 49 } -
linguise/trunk/vendor/linguise/script-php/src/Management.php
r3397694 r3479656 3 3 namespace Linguise\Vendor\Linguise\Script\Core; 4 4 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore 6 6 7 use Linguise\Vendor\Linguise\Script\Core\HttpResponse; 7 8 8 class Management { 9 class Management 10 { 9 11 /** 10 12 * @var null|Management … … 46 48 } 47 49 48 public function editorRun() { 50 public function editorRun() 51 { 49 52 Helper::defineConstants(false); 50 53 … … 67 70 $oobe = OobeManager::getInstance(); 68 71 $oobe->run($message, $api_web_errors); 72 return; 69 73 } 70 74 if (!isset($_POST['_token'])) { … … 73 77 $oobe = OobeManager::getInstance(); 74 78 $oobe->run($message, $api_web_errors); 79 return; 75 80 } 76 81 if (!$sess->verifyCsrfToken('linguise_config', $_POST['_token'])) { … … 78 83 $oobe = OobeManager::getInstance(); 79 84 $oobe->run($message, $api_web_errors); 85 return; 80 86 } 81 87 … … 127 133 ]; 128 134 } else { 135 // @codeCoverageIgnoreStart 129 136 $api_web_errors[] = [ 130 137 'type' => 'error', 131 138 'message' => 'Unable to load configuration from Linguise, please try again later or contact our support team if the problem persist.', 132 139 ]; 140 // @codeCoverageIgnoreEnd 133 141 } 134 142 … … 158 166 159 167 if (empty($dynamic_translations['public_key']) && !empty($old_options['dynamic_translations']['public_key'])) { 160 $dynamic_translations['public_key'] = $old_options['dynamic_translations']['public_key']; 168 $dynamic_translations['public_key'] = $old_options['dynamic_translations']['public_key']; // @codeCoverageIgnore 161 169 } 162 170 … … 169 177 if ($token_changed) { 170 178 // If token changed, we update enabled state 179 // @codeCoverageIgnoreStart 171 180 $dynamic_translations['enabled'] = Helper::boolInt($api_result['data']['dynamic_translations']['enabled']); 181 // @codeCoverageIgnoreEnd 172 182 } 173 183 } else if ($api_result !== false && isset($api_result['status_code'])) { … … 329 339 if ($original['value'] === $value) { 330 340 // Skip if value is the same as original 331 continue; 341 continue; // @codeCoverageIgnore 332 342 } 333 343 334 344 if ($original['value'] === null && empty($value)) { 335 345 // If original is null and value is empty, we don't need to save it 336 continue; 346 continue; // @codeCoverageIgnore 337 347 } 338 348 … … 355 365 if (!$sess->hasSession()) { 356 366 HttpResponse::errorJSON('Unauthorized', 401); 367 return; 357 368 } 358 369 if (!isset($_POST['nonce'])) { 359 370 HttpResponse::errorJSON('Missing nonce token', 400); 371 return; 360 372 } 361 373 if (!$sess->verifyCsrfToken('linguise_config_iframe', $_POST['nonce'])) { 362 374 HttpResponse::errorJSON('Invalid nonce token', 403); 375 return; 363 376 } 364 377 … … 378 391 // response with error 379 392 HttpResponse::errorJSON('Missing required field: ' . $field, 400); 393 return; 380 394 } 381 395 } … … 414 428 } 415 429 416 // This is from API -> Website 430 /** 431 * This is from API -> Website (here) 432 * 433 * @codeCoverageIgnore 434 */ 417 435 public function remoteUpdate() 418 436 { … … 421 439 if (empty($jwt_token)) { 422 440 HttpResponse::errorJSON('Missing Hash header', 400); 441 return; 423 442 } 424 443 … … 427 446 if (empty($input_data)) { 428 447 HttpResponse::errorJSON('Invalid request', 400); 448 return; 429 449 } 430 450 … … 432 452 if (json_last_error() !== JSON_ERROR_NONE) { 433 453 HttpResponse::errorJSON('Invalid JSON data', 400); 454 return; 434 455 } 435 456 … … 440 461 if ($input_data['token'] !== $options['token']) { 441 462 HttpResponse::errorJSON('Invalid token', 401); 463 return; 442 464 } 443 465 … … 503 525 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); 504 526 if (Configuration::getInstance()->get('dl_certificates') === true) { 505 curl_setopt($ch, CURLOPT_CAINFO, Certificates::getInstance()->getPath()); 527 curl_setopt($ch, CURLOPT_CAINFO, Certificates::getInstance()->getPath()); // @codeCoverageIgnore 506 528 } 507 529 } … … 510 532 $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); 511 533 if (PHP_VERSION_ID < 80000) { 534 // @codeCoverageIgnoreStart 512 535 curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5) 536 // @codeCoverageIgnoreEnd 513 537 } 514 538 515 539 if ($response_code !== 200) { 516 540 HttpResponse::errorJSON('Invalid JWT verification token: ' . print_r($response_code, true), 403); 541 return; 517 542 } 518 543 … … 538 563 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); 539 564 if (Configuration::getInstance()->get('dl_certificates') === true) { 540 curl_setopt($ch, CURLOPT_CAINFO, Certificates::getInstance()->getPath()); 565 curl_setopt($ch, CURLOPT_CAINFO, Certificates::getInstance()->getPath()); // @codeCoverageIgnore 541 566 } 542 567 } … … 548 573 $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); 549 574 if (PHP_VERSION_ID < 80000) { 575 // @codeCoverageIgnoreStart 550 576 curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5) 577 // @codeCoverageIgnoreEnd 551 578 } 552 579 … … 597 624 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); 598 625 if (Configuration::getInstance()->get('dl_certificates') === true) { 599 curl_setopt($ch, CURLOPT_CAINFO, Certificates::getInstance()->getPath()); 626 curl_setopt($ch, CURLOPT_CAINFO, Certificates::getInstance()->getPath()); // @codeCoverageIgnore 600 627 } 601 628 } … … 607 634 $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); 608 635 if (PHP_VERSION_ID < 80000) { 636 // @codeCoverageIgnoreStart 609 637 curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5) 638 // @codeCoverageIgnoreEnd 610 639 } 611 640 … … 636 665 637 666 if (!empty($api_host)) { 638 return $protocol . '://' . $api_host . (in_array($api_port, $api_port_base) ? '' : ':' . $api_port) . ''; 667 return $protocol . '://' . $api_host . (in_array($api_port, $api_port_base) ? '' : ':' . $api_port) . ''; // @codeCoverageIgnore 639 668 } 640 669 } -
linguise/trunk/vendor/linguise/script-php/src/OobeManager.php
r3463145 r3479656 3 3 namespace Linguise\Vendor\Linguise\Script\Core; 4 4 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore 6 6 7 7 use Linguise\Vendor\Linguise\Script\Core\Helper; 8 8 9 class OobeManager { 9 class OobeManager 10 { 10 11 /** 11 12 * @var null|OobeManager … … 37 38 } 38 39 39 public function oobeRun($html_message = \null) { 40 public function oobeRun($html_message = \null) 41 { 40 42 // Start session 41 43 $sess = Session::getInstance()->start(); … … 54 56 } 55 57 58 /** 59 * @codeCoverageIgnore 60 */ 56 61 private function writeOOBE($database_store) 57 62 { 63 if (defined('LINGUISE_SCRIPT_TESTING_SKIP_OOBE_WRITE') && LINGUISE_SCRIPT_TESTING_SKIP_OOBE_WRITE) { 64 return; 65 } 66 58 67 // Modify OOBE status in ui-config.php 59 68 $ui_config = realpath(__DIR__ . DIRECTORY_SEPARATOR . '..') . DIRECTORY_SEPARATOR . 'ui-config.php'; … … 63 72 if (empty($replaced_content)) { 64 73 HttpResponse::errorJSON('Failed to update ui-config.php', 500); 74 return; 65 75 } 66 76 … … 80 90 http_response_code($status_code); 81 91 $this->oobeRun($message); 82 die(); 92 if (!defined('LINGUISE_SCRIPT_TESTING')) { 93 die(); // @codeCoverageIgnore 94 } 83 95 } 84 96 … … 158 170 if (!isset($_POST['_token'])) { 159 171 HttpResponse::errorJSON('Missing CSRF token', 400); 172 return; 160 173 } 161 174 $sess = Session::getInstance()->start(); 162 175 if (!$sess->verifyCsrfToken('linguise_oobe_register', $_POST['_token'])) { 163 176 HttpResponse::errorJSON('Invalid CSRF token', 403); 177 return; 164 178 } 165 179 } … … 176 190 if (empty($mode)) { 177 191 HttpResponse::errorJSON('Missing `db_mode` data', 400); 192 return; 178 193 } 179 194 … … 182 197 if (empty($host) || empty($user) || empty($name)) { 183 198 HttpResponse::errorJSON('Missing `db_host`, `db_user` or `db_name` data', 400); 199 return; 184 200 } 185 201 if (!$testMode && (empty($prefix))) { 186 202 HttpResponse::errorJSON('Missing `db_prefix` data', 400); 203 return; 187 204 } 188 205 … … 191 208 if ($result !== true) { 192 209 HttpResponse::errorJSON($result, 500); 210 return; 193 211 } 194 212 HttpResponse::successJSON(true, 'MySQL connection test successful', 200); 213 return; 195 214 } 196 215 … … 210 229 if ($result !== true) { 211 230 HttpResponse::errorJSON($result, 500); 231 return; 212 232 } 213 233 HttpResponse::successJSON(true, 'SQLite connection test successful', 200); 234 return; 214 235 } 215 236 … … 228 249 if (defined('LINGUISE_OOBE_DONE') && LINGUISE_OOBE_DONE) { 229 250 $this->oobeRunError('Not allowed', 403); 251 return; 230 252 } elseif (!defined('LINGUISE_OOBE_DONE')) { 231 253 // Missing data 232 254 $this->oobeRunError('Unknown status', 500); 255 return; 233 256 } 234 257 235 258 if (!isset($_POST['_token'])) { 236 259 $this->oobeRunError('Missing CSRF token', 400); 260 return; 237 261 } 238 262 $sess = Session::getInstance()->start(); 239 263 if (!$sess->verifyCsrfToken('linguise_oobe_register', $_POST['_token'])) { 240 264 $this->oobeRunError('Invalid CSRF token', 403); 265 return; 241 266 } 242 267 … … 244 269 if (empty($new_pass)) { 245 270 $this->oobeRunError('Missing password', 400); 271 return; 246 272 } 247 273 … … 250 276 if (strlen($new_pass) < 10) { 251 277 $this->oobeRunError('Password must be at least 10 characters long', 400); 278 return; 252 279 } 253 280 254 281 if ($sess->hasSession()) { 255 282 $this->oobeRunError('Already activated', 403); 283 return; 256 284 } 257 285 … … 260 288 if (!isset($_POST['token'])) { 261 289 $this->oobeRunError('Missing token', 400); 290 return; 262 291 } 263 292 … … 265 294 if ($token !== Configuration::getInstance()->get('token')) { 266 295 $this->oobeRunError('Invalid token provided in session', 401); 296 return; 267 297 } 268 298 … … 288 318 if ($sqlite_test !== true) { 289 319 $this->oobeRunError($sqlite_test, 500); 320 return; 290 321 } 291 322 } … … 341 372 $sess->setSession($hashed_pass, true); // Set session with password mode 342 373 $this->run(); 343 die(); 374 if (!defined('LINGUISE_SCRIPT_TESTING')) { 375 die(); // @codeCoverageIgnore 376 } 344 377 } else { 345 378 // This will automatically return error response … … 364 397 if ($sqlite_test !== true) { 365 398 $this->oobeRunError($sqlite_test, 500); 399 return; 366 400 } 367 401 } … … 376 410 if ($existing_password) { 377 411 $this->oobeRunError('Password already set', 400); 412 return; 378 413 } 379 414 … … 394 429 $sess->setSession($hashed_pass, true); // Set session with password mode 395 430 $this->run(); 396 die(); 397 } 398 } 399 400 public function run($html_message = \null, $api_web_errors = []) { 431 if (!defined('LINGUISE_SCRIPT_TESTING')) { 432 die(); // @codeCoverageIgnore 433 } 434 } 435 } 436 437 public function run($html_message = \null, $api_web_errors = []) 438 { 401 439 // Start session 402 440 $sess = Session::getInstance()->start(); … … 411 449 case 'download-debug': 412 450 $this->downloadDebug(); 413 break;451 return; // @codeCoverageIgnore 414 452 case 'update-config': 415 453 break; … … 420 458 HttpResponse::unknownGETAction(); 421 459 } 422 break;460 return; // @codeCoverageIgnore 423 461 } 424 462 } … … 449 487 } 450 488 require_once LINGUISE_BASE_DIR . 'src' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'footer.php'; 451 die(); 489 if (!defined('LINGUISE_SCRIPT_TESTING')) { 490 die(); // @codeCoverageIgnore 491 } 452 492 } 453 493 … … 464 504 // No session, we just redirect to login page 465 505 HttpResponse::successJSON(true, 'No session found', 200); 466 exit;467 506 } 468 507 } … … 473 512 $message = '<div class="linguise-notification-popup"><span class="material-icons fail">check</span>Missing CSRF token</div>'; 474 513 $this->oobeRun($message); 514 return; 475 515 } 476 516 $sess = Session::getInstance()->start(); … … 478 518 $message = '<div class="linguise-notification-popup"><span class="material-icons fail">check</span>Invalid CSRF token</div>'; 479 519 $this->oobeRun($message); 520 return; 480 521 } 481 522 … … 498 539 } 499 540 541 /** 542 * @codeCoverageIgnore 543 */ 500 544 private function testMySQL($host, $user, $password, $name, $port = 3306, $prefix = '') 501 545 { 546 if (defined('LINGUISE_TESTING_SKIP_DB_CHECK')) { 547 return LINGUISE_TESTING_SKIP_DB_CHECK; 548 } 549 502 550 // Check if MySQLi is enabled 503 551 if (!extension_loaded('mysqli')) { … … 532 580 } 533 581 582 /** 583 * @codeCoverageIgnore 584 */ 534 585 private function testSqlite() 535 586 { 587 if (defined('LINGUISE_TESTING_SKIP_DB_CHECK')) { 588 return LINGUISE_TESTING_SKIP_DB_CHECK; 589 } 590 536 591 // Check if SQLite3 is enabled 537 592 if (!extension_loaded('sqlite3')) { … … 557 612 } 558 613 614 /** 615 * @codeCoverageIgnore 616 */ 559 617 private function prepareRootDatabaseSQLite() 560 618 { 619 if (defined('LINGUISE_TESTING_SKIP_DB_CHECK')) { 620 return LINGUISE_TESTING_SKIP_DB_CHECK; 621 } 622 561 623 $databases_dir = LINGUISE_BASE_DIR . '.databases' . DIRECTORY_SEPARATOR; 562 624 if (!file_exists($databases_dir)) { … … 596 658 $sess = Session::getInstance()->start(); 597 659 if (!$sess->hasSession()) { 598 die('Unauthorized'); 660 if (!defined('LINGUISE_SCRIPT_TESTING')) { 661 die('Unauthorized'); // @codeCoverageIgnore 662 } else { 663 throw new \Exception('Unauthorized'); 664 } 599 665 } 600 666 601 667 $debug_file = LINGUISE_BASE_DIR . 'debug.php'; 602 668 if (file_exists($debug_file)) { 669 // @codeCoverageIgnoreStart 603 670 header('Content-Description: File Transfer'); 604 671 header('Content-Type: application/octet-stream'); … … 617 684 } 618 685 619 die(); 686 if (!defined('LINGUISE_SCRIPT_TESTING')) { 687 die(); // @codeCoverageIgnore 688 } 689 // @codeCoverageIgnoreEnd 620 690 } else { 621 die('No debug file found'); 691 if (!defined('LINGUISE_SCRIPT_TESTING')) { 692 die('No debug file found'); // @codeCoverageIgnore 693 } else { 694 echo 'No debug file found'; 695 } 622 696 } 623 697 } … … 650 724 651 725 // Connect to database and install options 652 Helper::prepareDataDir(); 726 if (!defined('LINGUISE_TESTING_SKIP_DB_CHECK')) { 727 Helper::prepareDataDir(); // @codeCoverageIgnore 728 } 653 729 $db = Database::getInstance(true); 654 730 655 731 if (!LINGUISE_OOBE_DONE) { 656 732 // Not yet ready 657 return; 733 return; // @codeCoverageIgnore 658 734 } 659 735 … … 694 770 if (!$sess->hasSession()) { 695 771 HttpResponse::errorJSON('Unauthorized', 401); 772 return; 696 773 } 697 774 if (!isset($_GET['nonce'])) { 698 775 HttpResponse::errorJSON('Missing nonce token', 400); 776 return; 699 777 } 700 778 if (!$sess->verifyCsrfToken('linguise_clear_debug', $_GET['nonce'])) { 701 779 HttpResponse::errorJSON('Invalid nonce token', 403); 780 return; 702 781 } 703 782 … … 721 800 if (!$sess->hasSession()) { 722 801 HttpResponse::errorJSON('Unauthorized', 401); 802 return; 723 803 } 724 804 if (!isset($_GET['nonce'])) { 725 805 HttpResponse::errorJSON('Missing nonce token', 400); 806 return; 726 807 } 727 808 if (!$sess->verifyCsrfToken('linguise_clear_cache', $_GET['nonce'])) { 728 809 HttpResponse::errorJSON('Invalid nonce token', 403); 810 return; 729 811 } 730 812 -
linguise/trunk/vendor/linguise/script-php/src/Session.php
r3388557 r3479656 80 80 } 81 81 82 return Database::getInstance(true, true)->ensureConnection(); 82 return Database::getInstance(true, true)->ensureConnection(); // @codeCoverageIgnore 83 83 } 84 84 -
linguise/trunk/vendor/linguise/script-php/src/templates/Helper.php
r3316993 r3479656 5 5 use Linguise\Vendor\Linguise\Script\Core\Request; 6 6 7 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); 7 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore 8 8 9 9 class Helper { -
linguise/trunk/vendor/linguise/script-php/src/templates/management-expert.php
r3316993 r3479656 89 89 return $root . '/' . AdminHelper::getManagementBase(); 90 90 } 91 return $root . '/' . AdminHelper::getManagementBase() . '?linguise_action=' . $action; 91 return $root . '/' . AdminHelper::getManagementBase() . '?linguise_action=' . $action; // @codeCoverageIgnore 92 92 } 93 93 -
linguise/trunk/vendor/linguise/script-php/src/templates/management.php
r3321000 r3479656 81 81 $nonce = Session::getInstance()->getCsrfToken($nonce_key); 82 82 if (empty($nonce)) { 83 return make_action_url($action); 83 return make_action_url($action); // @codeCoverageIgnore 84 84 } 85 85 return make_action_url($action) . '&nonce=' . $nonce; … … 98 98 foreach ($global_options['enabled_languages'] as $language) { 99 99 if ($language === $global_options['default_language']) { 100 continue; 100 continue; // @codeCoverageIgnore 101 101 } 102 102 if (isset($languages_contents[$language])) {
Note: See TracChangeset
for help on using the changeset viewer.