Skip to content

Commit

Permalink
Version 4.4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
luigifab committed Jul 7, 2022
1 parent 3a6e2d8 commit 50bcd15
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 38 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ For more information, go to https://www.luigifab.fr/openmage/versioning (IPv6 is

This repository is a releases mirror. To install the module, please use the composer key available in the documentation.

- Current version: 4.4.2 (06/06/2022)
- Current version: 4.4.3 (07/07/2022)
- Compatibility: OpenMage 19.x / 20.x / 21.x, PHP 7.2 / 7.3 / 7.4 / 8.0 / 8.1
- Client compatibility: Firefox 36+, Chrome 32+, Opera 19+, Edge 16+, Safari 9+
- Translations: English (en), French (fr-FR/fr-CA), German (de), Italian (it), Portuguese (pt-PT/pt-BR), Spanish (es) / Chinese (zh), Czech (cs), Dutch (nl), Greek (el), Hungarian (hu), Japanese (ja), Polish (pl), Romanian (ro), Russian (ru), Slovak (sk), Turkish (tr), Ukrainian (uk)
- License: GNU GPL 2+

If you like, take some of your time to improve the translations, go to https://bit.ly/2HyCCEc.
If you like, take some of your time to improve the translations, go to https://bit.ly/2HyCCEc.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"require": {
"php": ">=7.2.0",
"openmage/magento-lts": ">=19.4.0",
"symfony/polyfill-php80": "*",
"ext-mbstring": "*",
"ext-json": "*",
"ext-curl": "*",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Created V/23/05/2014
* Updated L/23/05/2022
* Updated V/24/06/2022
*
* Copyright 2011-2022 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/openmage/versioning
Expand Down Expand Up @@ -35,13 +35,13 @@ public function render(Varien_Data_Form_Element_Abstract $element) {
protected function checkChanges() {

$index = file_get_contents(getenv('SCRIPT_FILENAME') ?? BP.'/index.php');
if (mb_strpos($index, '::f{4}:\\d{1,3}') === false)
if (!str_contains($index, '::f{4}:\\d{1,3}'))
return 'index.php';
if (mb_strpos($index, '? substr($ip, 7)') === false)
if (!str_contains($index, '? substr($ip, 7)'))
return 'index.php';
if (mb_strpos($index, '$ip = empty($ip) ? getenv(\'REMOTE_ADDR\')') === false)
if (!str_contains($index, '$ip = empty($ip) ? getenv(\'REMOTE_ADDR\')'))
return 'index.php';
if (mb_strpos($index, 'config/upgrade.ip') === false)
if (!str_contains($index, 'config/upgrade.ip'))
return 'index.php';

return true;
Expand Down
5 changes: 2 additions & 3 deletions src/app/code/community/Luigifab/Versioning/Model/History.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Created V/03/08/2012
* Updated S/05/12/2020
* Updated V/24/06/2022
*
* Copyright 2011-2022 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/openmage/versioning
Expand Down Expand Up @@ -35,9 +35,8 @@ public function init(int $page, int $size) {
// construction d'un premier tableau
$resource = fopen($file, 'rb');

while (($line = fgetcsv($resource, 50000, ',', '`')) !== false) {
while (!empty($line = fgetcsv($resource, 50000, ',', '`'))) {

$line = (array) $line; // (yes)
if (!empty($line[0])) {

$item = new Varien_Object();
Expand Down
4 changes: 2 additions & 2 deletions src/app/code/community/Luigifab/Versioning/Model/Observer.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Created J/31/05/2012
* Updated D/10/10/2021
* Updated V/24/06/2022
*
* Copyright 2011-2022 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/openmage/versioning
Expand Down Expand Up @@ -149,7 +149,7 @@ protected function updateIpConfig(array $global) {
continue;

if (stripos($key, '_byip') !== false) {
$key = (string) substr($key, 0, strrpos($key, '_')); // (yes)
$key = substr($key, 0, strrpos($key, '_'));
$value = array_filter(preg_split('#\s+#', $value));
$config[$key][] = '-'.implode("-\n-", $value).'-';
}
Expand Down
8 changes: 4 additions & 4 deletions src/app/code/community/Luigifab/Versioning/Model/Scm/Git.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Created S/03/12/2011
* Updated D/26/12/2021
* Updated V/24/06/2022
*
* Copyright 2011-2022 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/openmage/versioning
Expand Down Expand Up @@ -193,9 +193,9 @@ public function getCurrentDiff($from = null, $to = null, $dir = null, $excl = nu

// https://github.com/git/git/commit/296d4a94e7231a1d57356889f51bff57a1a3c5a1 (ignore-matching-lines)
if (!empty($excl) && version_compare($this->getSoftwareVersion(), '2.30.0', '>=')) {
if (mb_strpos($excl, 'copyright') !== false)
if (str_contains($excl, 'copyright'))
$command .= ' --ignore-matching-lines " Copyright 20[0-9][0-9]\-20[0-9][0-9]"';
if (mb_strpos($excl, 'updatedat') !== false)
if (str_contains($excl, 'updatedat'))
$command .= ' --ignore-matching-lines " Updated [A-Z]/[0-9][0-9]/[0-9][0-9]/[0-9][0-9][0-9][0-9]"';
}

Expand Down Expand Up @@ -321,7 +321,7 @@ public function getCurrentDiffStatus($from = null, $to = null, $dir = null, $exc
$lines[$i] = str_replace('M'."\t", "\t\t".str_replace('-', ' ', $help->__('modified:-------')), $line);
}
else if (mb_stripos($line, 'R') === 0) {
$tmp = (array) preg_split('#\s+#', $line); // (yes)
$tmp = preg_split('#\s+#', $line);
if ((count($tmp) == 3) && (($pos = mb_strrpos($tmp[2], '/')) !== false) && (mb_stripos($tmp[1], mb_substr($tmp[2], 0, $pos)) === 0))
$line = $tmp[0]."\t".$tmp[1].' > '.mb_substr($tmp[2], $pos + 1);
$lines[$i] = preg_replace("#R\d*\t#", "\t\t".str_replace('-', ' ', $help->__('renamed:--------')), $line);
Expand Down
4 changes: 2 additions & 2 deletions src/app/code/community/Luigifab/Versioning/etc/config.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
* Created S/03/12/2011
* Updated M/22/02/2022
* Updated J/09/06/2022
*
* Copyright 2011-2022 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/openmage/versioning
Expand All @@ -20,7 +20,7 @@
<config>
<modules>
<Luigifab_Versioning>
<version>4.4.2</version>
<version>4.4.3</version>
</Luigifab_Versioning>
</modules>
<global>
Expand Down
36 changes: 18 additions & 18 deletions src/errors/processor.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Created J/12/08/2010
* Updated J/02/12/2021
* Updated D/03/07/2022
*
* Copyright 2011-2022 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/openmage/versioning
Expand All @@ -26,7 +26,6 @@ class Processor {
private $_dataSource = [];
private $_dataTranslated = [];


public function init(string $type) {

$ip = empty(getenv('HTTP_X_FORWARDED_FOR')) ? false : explode(',', getenv('HTTP_X_FORWARDED_FOR'));
Expand Down Expand Up @@ -91,7 +90,6 @@ public function init(string $type) {
}
}


public function getPageTitle() {
$text = $this->__($this->getData('type').'_pagetitle');
return empty($this->getData('report')) ? $text : $text.' ('.$this->getData('report').')';
Expand All @@ -110,7 +108,6 @@ public function getHtmlReload() {
return (mb_stripos($text, '_autoreload') === false) ? '<p id="reload">'.$text.'</p>' : '';
}


public function getUrl(string $file) {

$base = getenv('SCRIPT_NAME'); // /sites/14/web/errors[/503.php] /sites/14/web[/index.php]
Expand Down Expand Up @@ -155,7 +152,7 @@ public function saveReport(array $data) {
// data['url'] = 'REQUEST_URI'
// data['skin'] = app()->getStore()->getData('code');
// data['script_name'] = 'SCRIPT_NAME'
$text = [
$text = str_replace('^', chr(194).chr(160), implode("\n", [
'',
'- - - -',
empty($this->getData('ip')) ? 'REMOTE_ADDR^^^^^not available' : 'REMOTE_ADDR^^^^^'.$this->getData('ip'),
Expand All @@ -167,16 +164,16 @@ public function saveReport(array $data) {
'GET^^^^'.(empty($_GET) ? 'empty' : implode(' ', array_keys($_GET))),
'POST^^^'.(empty($_POST) ? 'empty' : implode(' ', array_keys($_POST))),
'FILES^^'.(empty($_FILES) ? 'empty' : implode(' ', array_keys($_FILES))),
'COOKIE^'.(empty($_COOKIE) ? 'empty' : implode(' ', array_keys($_COOKIE)))];
'COOKIE^'.(empty($_COOKIE) ? 'empty' : implode(' ', array_keys($_COOKIE))),
]));

$data = (mb_stripos($data[0], $data[1]) === false) ? $data[0]."\n".$data[1] : $data[0];
$text = str_replace('^', chr(194).chr(160), implode("\n", $text));
@file_put_contents($dir.$id, $data.$text);
$emsg = (mb_stripos($data[0], $data[1]) === false) ? $data[0]."\n".$data[1] : $data[0];
@file_put_contents($dir.$id, $emsg.$text);

$this->setData('report', $id);
$this->setData('report_content', htmlspecialchars($data.$text, ENT_NOQUOTES | ENT_SUBSTITUTE));
$this->setData('report_content', htmlspecialchars($emsg.$text, ENT_NOQUOTES | ENT_SUBSTITUTE));

$email = (array) explode(' ', $this->getConfig('email')); // (yes)
$email = array_filter(explode(' ', $this->getConfig('email')));
if (!empty($email)) {
$subject = 'Fatal error #'.$id;
$headers = 'Content-Type: text/html; charset=utf-8'."\r\n".'From: root'.mb_substr($email[0], mb_strrpos($email[0], '@'));
Expand All @@ -200,8 +197,7 @@ public function canShowReport() {
return false;
}


// configuration et données
// config et données
public function getConfig(string $key) {
return empty($this->_config[$this->type.'_'.$key]) ? false : $this->_config[$this->type.'_'.$key];
}
Expand All @@ -215,7 +211,6 @@ public function setData(string $key, $value) {
return $this;
}


// langue et traduction
protected function searchCurrentLocale(array $locales, string $result = 'en_US') {

Expand All @@ -235,7 +230,7 @@ static function ($items, $item) {
// ajoute la locale présente dans l'url en premier car elle est prioritaire
if (!empty($_GET['lang'])) {
$code = str_replace('-', '_', $_GET['lang']);
if (strpos($code, '_') !== false)
if (str_contains($code, '_'))
array_unshift($codes, substr($code, 0, strpos($code, '_')));
array_unshift($codes, $code);
}
Expand All @@ -244,7 +239,7 @@ static function ($items, $item) {
// essaye es ou fil puis es_ES ou fil_PH
foreach ($codes as $code) {

if ((strlen($code) >= 2) && (strpos($code, '_') === false)) {
if ((strlen($code) >= 2) && !str_contains($code, '_')) {
// es devient es_ES de manière à prioriser es_ES au lieu d'utiliser es_XX
if (in_array($code.'_'.strtoupper($code), $locales)) {
$result = $code.'_'.strtoupper($code);
Expand Down Expand Up @@ -273,8 +268,7 @@ protected function loadCSV(string $file) {

$resource = fopen($file, 'rb');

while (($line = fgetcsv($resource, 5000)) !== false) {
$line = (array) $line; // (yes)
while (!empty($line = fgetcsv($resource, 5000))) {
if (!empty($line[0]) && !empty($line[1])) {
$this->_dataSource[] = $line[0];
$this->_dataTranslated[] = $line[1];
Expand Down Expand Up @@ -305,4 +299,10 @@ public function __(string $text, ...$values) {

return str_replace([' ?', ' !', ' ;', ' :'], ['&nbsp;?', '&nbsp;!', '&nbsp;;', '&nbsp;:'], $final);
}
}

if (!function_exists('str_contains')) {
function str_contains($haystack, $needle) {
return ($needle === '') || (strpos($haystack, $needle) !== false);
}
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit 50bcd15

Please sign in to comment.