update NodCms v3.4.1  to  v3.4.1c

update NodCms v3.4.1 to v3.4.1c

Home - Site powered by CodeIgniter 4.3.0-0 framework - PHP8.2 - LINUX / Debian 11.6 server

Hello devs,
Date of work 2023/01/12
autor gbobard@gmail.com
 website
 http://byoosdigital.com
This filename    nodcms_v3-4-1c_portage_ci4-3-0_and_php8-2.txt
source File nodcms_v3-4-1_new on github
 https://github.com/khodakhah/nodcms
or https://github.com/khodakhah/nodcms.git
--------------------------------------------------
with_php8-2_nodcms-v3.4.1c.zip and LINUX - Debian 11.6
--------------------------------------------------
OBJECTIVES
To port nodcms_3-4-1 to CodeIgniter 4.3.0-0
and then improve TRANSLATION 'fr', PAGINATION, AUTH, DISPLAY of articles, multi-
LANGUAGE
UPDATE
ARE REQUIRED
nodcms version 3-4-1 on Oct 16, 2022 codeIgniter 4.3.0-0 gbobard@gmail.com
environment
debian 11.6 - PHP8.2 - MariaDB 10.5
.htaccess file to be installed in /root/ then replace /myPath by your working
directory
# redirect to public page

RewriteEngine On
RewriteCond %{REQUEST_URI} !^public$
RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge [NC]
RewriteRule "^(.*)$" "/myPath/public/" [R=301,L]

# disable directory browsing
# For security reasons, Option all cannot be overridden.
Options +SymLinksIfOwnerMatch -Indexes
# prevent folder listing
IndexIgnore *
End of .htaccess code
1)
******************************
Compatibility
 CI 4.1.4
ajouter dans nodcms-core/config/Execptions.php
/**
*
--------------------------------------------------------------------------
* HIDE FROM DEBUG TRACE
*
--------------------------------------------------------------------------
* Any data that you would like to hide from the debug trace.
* In order to specify 2 levels, use "/" to separate.
* ex. ['server', 'setup/password', 'secret_token']
*
* @var array
*/
public $sensitiveDataInTrace = [];
2)
*******************************
/root/public/.htaccess
line 33 to be modified with
 index.php?/$1
RewriteRule ^([\s\S]*)$ index.php?/$1 [L,NC,QSA]
//Enable apache2 rewrite mode, URL rewriting
$sudo a2enmod rewrite
IN /etc/apache2/apache2.conf //AllowOverride None change AllowOverride All

Options Indexes FollowSymLinks
AllowOverride All
Require all granted

//then restart the apache2 server
$sudo systemcl restart apache2
Edit this file /root/public/env.development.php
 rename to .env
and modify
#--------------------------------------------------------------------
# Example Environment Configuration file
#
# This file can be used as a starting point for your own
# custom .env files, and contains most of the possible settings
# available in a default install.
#
# By default, all of the settings are commented out. If you want
# to override the setting, you must un-comment it by removing the '#'
# at the beginning of the line.
#--------------------------------------------------------------------
#--------------------------------------------------------------------
# ENVIRONMENT
#--------------------------------------------------------------------
CI_ENVIRONMENT=development
ENVIRONMENT=development
#--------------------------------------------------------------------
# APP
#--------------------------------------------------------------------
# Web root URL
app.baseURL=http://localhost/nodcms_v3-4-1_new/public/
START CONFIGURATION
********************************
if you would rather work in http only mode then disable forced https mode in:
root/nodcms-core/config/App.php
|-------------------------------------------------------------------------
-
| URI PROTOCOL
|-------------------------------------------------------------------------
-
|
| If true, this will force every request made to this application to be
| made via a secure connection (HTTPS). If the incoming request is not
| secure, the user will be redirected to a secure version of the page
| and the HTTP Strict Transport Security header will be set.
*/
public $forceGlobalSecureRequests = false;
*******************************
INSTALL of the dependencies
go to the root of the project HERE /myPath/nodcms_v3-4-1c_new, example:
/var/www/html/nodcms_v3-4-1c_new
//then launch the 'composer' app knowing that it must be installed on the server
sudo composer install
dependencies will be installed automatically but there are now two STSTEM
/root/system
 and root/vendor/codeigniter4/framework/system
answer yes to the following question
Continue as root/super user [yes]? y
4)
********************************
activate the development mode to track alarms and other messages
IN /root/public/index.php
// Acceptable values: development, testing, production
define('ENVIRONMENT', 'development');
*********************************
activate the mode logs
IN root/nodcms-core/Config/logger.php
public $threshold =
 public $threshold = [3, 4, 5, 8,9];
END CONFIGURATION
**********************************
START User AUTHENTIFICATION
5) modify
 root/nodcms-core/models/Users.php field password 255 car.
the data model table users changes the size 'password' to 255 characters, same
in the model Users function init()
and add field auth
function init()
{
$table_name = "users";
$primary_key = "user_id";
$fields = array(
'user_id'=>"int(10) unsigned NOT NULL AUTO_INCREMENT",
'username'=>"varchar(50) DEFAULT NULL",
'password'=>"varchar(255) DEFAULT NULL",
'auth'=>"varchar(4) DEFAULT 'HASH'",
...
*************************************
replace MD5 authentication with the PHP functions passord_hash() and
password_verify()
6) modify
 root/nodcms-core/Models/Users.php
public function loginMatch($username, $password) : ?array
{
// old code...return $this->getOne(null, ['username'=>$username,
'password'=>md5($password)]);
$auth = $this->getOne(null, ['username'=>$username, 'auth'=>'MD5',
'password'=>md5($password)]);
if($auth){
$data['password'] = password_hash($password,
PASSWORD_DEFAULT);
$data['auth'] = 'HASH';
$id = $auth['user_id'];
parent::edit($id, $data);
return $auth;
}
$data = $this->getOne(null, ['username'=>$username]);
$pass = $data['password'];
$authenticatePassword = password_verify($password, $pass);
if($authenticatePassword){
return $data;
}
}
returnarray();
*************************************
IN /root/nodcms-users/Controllers/Users.php replace MD5 with
password_hash($data['password'], PASSWORD_DEFAULT)
line 119
public function userRegistration()
{
...
"password"=>password_hash($data['password'], PASSWORD_DEFAULT),
and line 297
public function setNewPassword($user_unique_key, $active_code)
{
...
'password'=>password_hash($data['password'], PASSWORD_DEFAULT),
*************************************
IN
 /root/nodcms-core/Controllers/GeneralMembers.php modify this line 221
if(md5($post_data['password']) != $this->userdata["password"]){
...
modifies like this
public function accountChangePassword()
{
...
if(!password_verify($post_data['password'], $this-
>userdata['password'])){
return $this->errorMessage("Your current password is wrong.",
$self_url);
}
**************************************
IN /root/nodcms-core/Models/Users.php replace MD5 with
password_hash($data['password'], PASSWORD_DEFAULT)
line 97
public function add(array $data): int
{
...
$data['password'] = password_hash($data['password'], PASSWORD_DEFAULT);
}
return parent::add($data);
and 111
public function edit($id, $data)
{
if(key_exists('password', $data)) {
$data['password'] = password_hash($data['password'],
PASSWORD_DEFAULT);
}
....
END AUTHENTIFICATION
****************************************
6) modify
 root/nodcms-core/Models/Model.php force the return type (int)
 for
this line return count($result)!=0?(int) $result["sum($field)"]:0;
function getSum($field, $conditions = null): int
{
$builder = $this->getBuilder();
$builder->select("sum($field)");
}
if ($conditions != null)
$this->searchDecode($conditions, $builder);
$query = $builder->get();
$result = $query->getRowArray();
return count($result)!=0?(int) $result["sum($field)"]:0;
**************************************
START PAGINATION
IN /root/nodcms-layout/Views/common/pagination/
copy the pagination_bootstrap.php file as seen on the site:
https://includebeer.com/fr/blog/creation-dune-application-web-de-base-avec-
codeigniter-4-partie-4
IN root/nodcms-core/Config/pager.php
add this line
public $templates = [
...
// Custom template for using Bootstrap
'bootstrap'
 => '\NodCMS\Layout\Views\common\pagination\
pagination_bootstrap',
];
IN IN root/nodcms-core/Controllers/GeneralAdmin.php
 //for pagination user
public function user(int $page = 1)
{
...
$config = array();
$config['base_url'] = ADMIN_URL.'user';
$tab = array_filter(explode('/', $config['base_url']));
unset($tab[0], $tab[2]);
$config['tab_uri_segment'] = implode('/', $tab);
$config['reuse_query_string'] = TRUE;
$config['total_rows'] = Services::model()->users()->getCount();
$config['uri_segment'] = count($tab)+1;
$config['per_page'] = 10;
...
****************************************
IN root/nodcms-core/Controllers/App.php
protected function mkPagination(array $config)
{
$pagination = \Config\Services::pager();
$pagination->setPath($config['tab_uri_segment']);
$pagination->setSegment($config['uri_segment']);
if((int) ceil($config['total_rows'] / $config['per_page']) > 1){
$this->data['pagination'] = $pagination->makeLinks($pagination-
>getCurrentPage(), $config['per_page'], $config['total_rows'], 'bootstrap',
$config['uri_segment']);
}
else{
$this->data['pagination'] = "";
}
}
IN root/nodcms-blog/Controllers/blog.php //for pagination blog - posts
function posts($page = 1, $category_id = null)
{
//custom byoosdigital.com
$tab = array_filter(explode('/', $self_url));
unset($tab[0], $tab[2]);
$config['tab_uri_segment'] = implode('/', $tab);
$config = array(
);
'base_url'=>$self_url,
'query_string_segment'=>'',
'reuse_query_string'=>TRUE,
'total_rows'=>Models::blogPost()->getCount($conditions),
'uri_segment'=>count($tab)+1,
'tab_uri_segment'=>implode('/', $tab),
'per_page'=>10,
END PAGINATION
*******************************************
START TRADUCTION
IN root/nodcms-core/Language/en/App.php
Add the directory 'fr' IN root/nodcms-core/Language/en/App.php
translate the sentences from English to French
load the fr.zip language
END TRADUCTION
********************************************
START LANGUAGE managment of 'code'
Repairing the default language code 'en' 'fr' ...
IN /root/nodcms-core/Filters/UrlLocale.php
/**
* @inheritDoc FIX byoosdigital.com
*/
public function before(RequestInterface $request, $arguments = null)
{
$config=config('app');
$localePrefix = $request->uri->getSegment(1);
// No prefix has been set
if(empty($localePrefix)) {
$locale=$config->defaultLocale;
if(empty($local)) {
// getDefaultRecord force 'en' or browser language //
other code...'locale_accept_from_http($_SERVER['HTTP_ACCEPT_LANGUAGE'])'
$language = Models::languages()->getDefaultRecord();
}else{
$language = Models::languages()->getByCode($locale);
}
}
// Set system language from URL language code (Language prefix)
else{
$language = Models::languages()->getByCode($localePrefix);
}
if(empty($language)){
$language = Models::languages()->getOne(null);
}
if(empty($language)){
throw new \Exception("Language \"{$localePrefix}\" not found in
database.");
}
if($language['code'] != $localePrefix) {
$request->uri->setSegment(1, $language['code']);
return redirect()->to($request->uri->getPath());
}
}
// Set language from database
Services::language()->set($language);
// Load settings from database
Services::settings()->load($language['language_id']);
return false;
exploit the configuration
 IN root/nodcms-core/Config/App.php
 public
$defaultLocale = 'fr';
********************************************
then in the library Language IN root/nodcms-core/libraries/language.php
méthode set afin de stocker la langue courante en session
public function set(array $language)
{
$session = \Config\Services::session();
$newdata['language'] = $language;
$session->set($newdata);
$this->DBlanguage = $language;
parent::setLocale($language['code']);
}
*********************************************
puis dans la vue... IN root/nodcms-layout/Views/nodcms-top-menu.php

remplacer par >language['image']); ?>" />
*********************************************
IN
 /root/nodcms-core/Controllers/General.php
$this->data['languages'] = Models::languages()->getAllActives();
déplacer la ligne ci-dessus IN /root/nodcms-core/Controllers/Frontend.php
parent::__construct();
....
gestion des langues sur le frontend
// added this code from nodcms 3.3c -- Set Languages menu
$this->data['lang_url'] = base_url().'/'.uri_string();
$this->data['languages'] = Models::languages()->getAllActives();
foreach ($this->data['languages'] as &$value) {
$url_array = explode("/",$this->data["lang_url"]);
$url_array[array_search($this->lang,$url_array)]=$value["code"];
$value["lang_url"] = implode("/",$url_array);
}
// end new code
END LANGUAGE
*********************************************
Try to display the View Site link on the Admin side
// Add top menu
Services::topMenu()->addLink(
'view_site',
_l("View Site", $this),
CONFIG_BASE_URL."{$this->language['code']}"
);
*********************************************
IN /root/nodcms-articles/Views/frontend/article.php
render($content_type); ?>
... add echo ...
BUGG fixed, OUF!!!...
***********************************************
THE SERVICES
IN root/nodcms-services/Controllers/ServicesAdmin.php
if($this->settings['services_page']){
$config[] = array(
'field' => 'service_uri',
'label' => _l("Service URI", $this),
'rules' => 'required|validURI|is_unique[services.service_uri'.
(isset($current_data)?",service_id,$current_data[service_id]":"").']',
'type' => "text",
'default'=>isset($current_data)?$current_data["service_uri"]:'',
'input_prefix'=>base_url($this->language['code']."/service-"),//
correctif, remplacer / par -
);
}
FIN SERVICES
*************************************************
PORTFOLIO
IN root/nodcms-portfolio/Config/Routes.php
Ajouter une route
$routes->get('{locale}/portfolio', "\NodCMS\Portfolio\Controllers\
Portfolio::Home");
définir un menu sur la route 'portfolio'
Apparement ce module n'est pas complet ... à suivre ...
**************************************************
installation avec php8.1 correctif CI_415
IN /root/vendor/codeigniter4/..../system/Validation/FormatRules.php
public function valid_ip(?string $ip = null, ?string $which = ''): bool //
correctif $which = ''
{
if (empty($ip)) {
return false;
}
switch (strtolower($which)) {
case 'ipv4':
$which = FILTER_FLAG_IPV4;
break;
case 'ipv6':
$which = FILTER_FLAG_IPV6;
break;
}
default:
$which = FILTER_DEFAULT;// correctif FILTER_DEFAULT
break;
IN /root/vendor/codeigniter4/..../system/HTTP/ResponseTrait.php
public function send()
{
// If we're enforcing a Content Security Policy,
// we need to give it a chance to build out it's headers.
if ($this->CSPEnabled === true) {
$this->CSP->finalize($this);
} else {
$this->body = str_replace(['', '{csp-script-
nonce}'], '', $this->body ?? '');//correctif
}
$this->sendHeaders();
$this->sendCookies();
$this->sendBody();
return $this;
IN
 /root/nodcms-core/View/View.php
 string $viewPath = ''
public function __construct($config = null, string $viewPath = '', $loader =
null, bool $debug = null, LoggerInterface $logger = null)
{
IN /root/vendor/codeigniter4/framework/system/View/View.php
 string
$viewPath = ''
public function __construct($config = null, string $viewPath = '', $loader =
null, bool $debug = null, LoggerInterface $logger = null)
{
IN /var/www/html/cms/vendor/codeigniter4/framework/system/I18n/Time.php
string $time = ''
public function __construct(?string $time = '', $timezone = null, ?string
$locale = null)
{
****************************************************
IN/root/nodcms-core/Models/Model.php
remplacer $builder->group_start();
 par $builder->groupStart();
remplacer $builder->group_end();
 par $builder->groupEnd();
le nom de ces méthodes ont changées entre CI3.1.11 et CI4.1.5
****************************************************
NOTA: le répertoire root/nodcms-core/wiew a été renommé par rapport à
l'install appstarter de CI4...( bon à savoir )...
portage de CI4.1.5 vers CI 4.2.x le 16/06/2022
télécharger la version 4.2.11 de codeigniter4
lancer la procédure composer install à la racine de CI4.2
dans le projet nodCMS 3.2.2c copier les fichiers de CI4.2 composer.jsn et
composer.lock
lancer la procédure composer update à la racine du projet nodCMS 3.2.2c
puis copier de ci4.2.11 le répertoire /system
 ver le projet nodCMS 3.2.2c
vendor/codeigniter4/framework/system
version PHP8.2 et CI 4.3.0-0
IN /root/nodcms-core/Config/Cache.php
// BYOOSdigital.com
public array $file = [];
IN /root/nodcms-core/view/view.php
//added BYOOSdigital.com Creation of dynamic property is deprecated
public $mainTemplate;
public $frameTemplate;
public $cleanFrame;
public $page_sidebar;
public $page_sidebar_closed;
public $page_sidebar_items;
public $page_sidebar_close;
public $page_sidebar_menu_closed;
public $display_title;
public $display_page_title;
public $view;
public
public
public
public
public
public
public
$session;
$langArray;
$controllerType;
$admin_panel_items;
$captcha_session_name;
$html_form_data;
$settings_default;
bugg on login /root/nodcms-users/controllers/Users.php
IN /root/nodcms-core/validation/Validation.php
FIX
 , string $originalField = null and $originalField
protected function processRules(string $field, string $label = null, $value,
$rules = null, ?array $data = null, string $originalField = null): bool
{
// clean the latest error message up
$this->latestErrorMessage = null;
// execute customize only if original method found an error
if(!parent::processRules($field, $label, $value, $rules, $data,
$originalField))
Create of dynamic property NodCMS\Core\Libraries\Ajaxlist::$view is deprecated
protected $view;
function{
...
__construct()
IN /root/nodcms-core/View/Layout.php
//added BYOOSdigital.com Creation of dynamic property is deprecated
public $avatar_file_key;
****************************************************************
How to make nodCms version 3.4.1 work on PHP8.2 and CI 4.3.0-0
Class "Config\Renderer" not found
//the name of the Renderer class has changed to AbstractRenderer
IN root/APPPATH/Config/Kint.php at line 46
public $richSort = AbstractRenderer::SORT_FULL;
//and
use Kint\Renderer\AbstractRenderer;
//vérify:
class Kint extends BaseConfig
IN /root/vendor/autoload_psr4.php
'Kint\\' => array($vendorDir . '/kint-php/kint/src'),
...
Deprecated: Creation of dynamic property Config\App::$cookieSameSite is
deprecated in
/var/www/html/1__codeigniter_dev/1__2023/cms/nodcms_v3-4-1/vendor/codeigniter4/
framework/system/HTTP/Response.php on line 168
//BYOOSdigital.com
public $cookieSameSite;
Deprecated: Creation of dynamic property Config\Exceptions::
$sensitiveDataInTrace is deprecated in
/var/www/html/1__codeigniter_dev/1__2023/cms/nodcms_v3-4-1/vendor/codeigniter4/
framework/system/Debug/Exceptions.php on line 84
Deprecated: Creation of dynamic property Config\Exceptions::$logDeprecations is
deprecated in
/var/www/html/1__codeigniter_dev/1__2023/cms/nodcms_v3-4-1/vendor/codeigniter4/
framework/system/Debug/Exceptions.php on line 87
Deprecated: Creation of dynamic property Config\Exceptions::$deprecationLogLevel
is deprecated in
/var/www/html/1__codeigniter_dev/1__2023/cms/nodcms_v3-4-1/vendor/codeigniter4/
framework/system/Debug/Exceptions.php on line 88
IN /root/nodcms-core/Config/Exeptions/php
//Creation of dynamic property Config\Exceptions::... is deprecated
public $sensitiveDataInTrace;
public $logDeprecations;
public $deprecationLogLevel;
IN
 /root/vendor/codeigniter4/framework/system/View/View.php
 ligne 143
$this->viewPath = rtrim((string)$viewPath, '\\/ ') .
DIRECTORY_SEPARATOR;
IN /root/nodcms-core/view/view.php
//added BYOOSdigital.com Creation of dynamic property is deprecated
public $mainTemplate;
public $frameTemplate;
public $cleanFrame;
public $page_sidebar;
public $page_sidebar_closed;
public $page_sidebar_items;
public $page_sidebar_close;
public $page_sidebar_menu_closed;
public $display_title;
public $display_page_title;
public $view;
public $session;
public $langArray;
public $controllerType;
public $admin_panel_items;
public $captcha_session_name;
public $html_form_data;
public $settings_default;
public $userdata;
*************************************************
START CONSTANTS
IN /root/nodcms-module/bootstrap.php replace the module code with the module
name
define('BLOG_ADMIN_URL', base_url("admin-blog").'/');
define('GALLERY_ADMIN_URL',base_url('admin-gallery').'/');
define('PORTFOLIO_ADMIN_URL',base_url("admin-portfolio").'/');
define('SERVICES_ADMIN_URL',base_url("admin-services").'/');
the following "defines" are relocated to their module, bootstrap.php file
the following "defines" are relocated to their module, bootstrap.php file
place a test if not defined before each line of "define".
example:
public function backend()
{
if (!defined('BLOG_ADMIN_URL'))
define('BLOG_ADMIN_URL', base_url("admin-blog").'/');
IN /root/nodcms-core/bootstrap.php
added this define under COREPATH
define('COREPATH', $paths->appDirectory . DIRECTORY_SEPARATOR);
// NodCMS database path
define("DB_CONFIG_PATH", COREPATH.'Config/Database.php');
// NodCMS public path
define("SELF_PATH", FCPATH);
// Find the requested protocol
$protocol_status = intval(isset($_SERVER['HTTPS']));
define("SSL_PROTOCOL", $protocol_status);
define("URL_PROTOCOL", $protocol_status ? "https://" : "http://");
END CONSTANTS
*************************************************
START CKEDITOR
//error js load ckeditor, a slash "/" is missing between the public segment and
assets
Échec du chargement pour l’élément

Comments

Related posts

NodCms Content Manager version2-1

NodCms Content Manager version2-1

CI4:version 4.4.3 compatible paging example

CI4:version 4.4.3 compatible paging example