Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all 14343 articles
Browse latest View live

Help Needed: ModSecurity False Positives in CodeIgniter Application

$
0
0
Hello everyone, I hope this message finds you well.
I am currently facing an issue with my CodeIgniter application where ModSecurity is triggering false positives, resulting in access being denied with a 403 error. The logs indicate that requests to specific URIs, such as /login/agregando_v_cac , are being blocked due to rules related to remote file injection attacks.

Here are some details from the logs:

ModSecurity ID: 340162 and 340163
Error Message: "Unauthorized URL detected as argument"
Request Method: POST
It seems that ModSecurity is interpreting certain parameters or headers in my requests as potentially malicious, which is causing these blocks. I suspect this might be due to special characters or patterns in the data being sent.
I would greatly appreciate any guidance on how to modify my PHP code or adjust my application’s request handling to prevent these false positives. 

Are there specific practices or code adjustments in CodeIgniter that could help mitigate this issue?

Shield add user pics

$
0
0
I there is a way to add  pics of user in shield ?

Can php spark db:seed work for updating data or is it limited to insert?

$
0
0
Hi,
I am adding a language to an existing multi-lingual website, and I am looking for the best way to update existing records in database with the content for the added language. I have several tables that need additional content. One has for example fields such as title_en, content_en, title_nl, content_nl and I am adding title_fr and content_fr. Migration is done so existing records have the 2 added columns. Now I want to populate the content for French. 

I have been using seeding to insert content into empty tables very easily and fast, and was wondering if there is an option to update existing content too?
In other words, instead of using in a seeder file  something like this for my table 'blocks'
PHP Code:
$this->db->table("blocks")->insertBatch($data); 

Is there an updateBatch($data) or saveBatch($data) equivalent I could use? I check the documentation but could not find it.

What best approach would you recommend to do this? (I'd like to be able to prepare all the content for the additional language and add it super fast just like through a db: seed  command)

Thanks Smile

locale in routes ?

$
0
0
hi

let's say we have $defaultLocale = 'it' and $supportedLocales = ['it','en','fr'];

by using $routes->get('{locale}/', 'Home::index');

the site responds to site/it/ and site/en/ site/fr/

what i would expect is site/ to be defaultLocale and also have site/en/  and site/fr/
site/it/ should trow 404

any suggestion on how can i get this behavior ?

thanks

503 service unavailable

$
0
0
All of a sudden I'm getting this error: 503 service unavailable with CodeIgniter pages. We didn't change anything, and there is nothing wrong on the server, it only happens with Codeigniter scripts. I know that isn't a ton of info to go by, but can anyone give me troubleshooting steps to try and figure out what could be wrong? This is version 3.1.13, upgrading to 4 isn't an option right now. Thanks

Deploying CodeIgniter 4 on IIS Server

$
0
0
Hi,

I previously posted a question about deploying CodeIgniter 4 on a Windows IIS Server:

[CodeIgniter 4 on IIS 10] Route is not working
https://forum.codeigniter.com/showthread.php?tid=89074

I’ve tried resolving the issue by redeploying CodeIgniter 4.5.5 on IIS, but the problem still persists.


Has anyone successfully deployed a CodeIgniter 4.x website on an IIS Server without encountering issues?


I also think the user guide would benefit from including a dedicated section on deploying CodeIgniter on IIS Servers:
https://codeigniter.com/user_guide/intro/index.html

It would be great to have an official tutorial for deploying on IIS Servers.


Your insights and assistance would be greatly appreciated.
Thank you!

Flash data returning NULL after redirect via controller

$
0
0
I'm trying to show an error if the email or password is wrong, but it keeps returning NULL...
here's my code:
Code:
/*
            Validate user
        */
        $myModel = model('myModel');
        $data['result'] = $myModel->find(['email' => $this->request->getPost('email')]);
        if (!isset($data['result'][0]))
        {
            $this->session->setFlashdata('incorrect_login', true);
            $this->session->keepFlashdata('incorrect_login');
            return redirect()->to('home');
        }
        else if ($data['result'][0]['password'] === $this->request->getPost('password'))
        {
            $this->session->set('logged_in', true);
            return redirect()->to('edit');
        }
        else
        {
            $this->session->setFlashdata('incorrect_login', true);
            $this->session->keepFlashdata('incorrect_login');
            return redirect()->to('home');
        }

After installing Shield, I can't find the login path.

$
0
0
I read through the installation documentation for Shield, and I don't think I made any mistakes during installation, right?
.
  1. Code:
    composer require codeigniter4/shield
  2. Code:
    php spark shield:setup
Current status: The installation has no errors, all the necessary files and data have been generated, the homepage can be accessed normally, but I can't access
Code:
xxx.com/login

Multi-level routing filters not working

$
0
0
Good day!
I want restrict routing groups by shield permissions , but filter working only for parent group. In children groups permission filter not working. Where my bad?
CI 4.5.5 \ Shield 1.1.0

PHP Code:
$routes->group('admin', ['filter' => 'permission:admin.access'], static function (RouteCollection $routes) { // permission:admin.access is working
    $routes->get('/''Admin::index', ['as' => 'admin']);

    $routes->group('users', ['filter' => 'permission:users.access'], static function (RouteCollection $routes) { // permission:users.access is ignoring
        $routes->get('/''Auth\Users::index', ['as' => 'admin-users']);
    });
}); 

Shield - Problems on first setup - missing files

$
0
0
Hi,

after some trouble (caused by my less understandings of some technical thinks) i've installed codeigniter4/appstarter by composer.

After that i installed shield by composer

Here is the log of the last parts

"bash-5.1$ /usr/local/php82/bin/php composer.phar require codeigniter4/shield
./composer.json has been updated
Running composer update codeigniter4/shield
Loading composer repositories with package information
Updating dependencies
Lock file operations: 2 installs, 0 updates, 0 removals
  - Locking codeigniter4/settings (v2.2.0)
  - Locking codeigniter4/shield (v1.1.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals
  - Downloading codeigniter4/shield (v1.1.0)
  - Installing codeigniter4/settings (v2.2.0): Extracting archive
  - Installing codeigniter4/shield (v1.1.0): Extracting archive
Generating optimized autoload files
26 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
No security vulnerability advisories found.
Using version ^1.1 for codeigniter4/shield
bash-5.1$ /usr/local/php82/bin/php spark shieldConfusedetup

CodeIgniter v4.5.5 Command Line Tool - Server Time: 2024-11-28 20:23:18 UTC+00:00

  Created: APPPATH/Config/Auth.php
  Created: APPPATH/Config/AuthGroups.php
  Created: APPPATH/Config/AuthToken.php
  Updated: APPPATH/Config/Autoload.php
  Updated: APPPATH/Config/Routes.php
  Updated: We have updated file 'APPPATH/Config/Security.php' for security reasons.
  Updated: APPPATH/Config/Email.php

  Run `spark migrate --all` now? [y, n]: y
Running all new migrations...
        Running: (CodeIgniter\Shield) 2020-12-28-223112_CodeIgniter\Shield\Database\Migrations\CreateAuthTables
        Running: (CodeIgniter\Settings) 2021-07-04-041948_CodeIgniter\Settings\Database\Migrations\CreateSettingsTable
        Running: (CodeIgniter\Settings) 2021-11-14-143905_CodeIgniter\Settings\Database\Migrations\AddContextColumn
Migrations complete."


After all, i see in my database some new "auth_"-tables.

If if look into the app/Controller folder - i miss all files about the authentification part for example "ActionController, LoginController, RegisterController..."
Also in App/views is only the error-folder and the welcome-message files. I think there must be much more files for example "login, register etc"

Why this files not in my folders, normaly this files should copy by installtion with the composer or am i wrong?

It seems that all the files from the shield-package are not copied to my folder!?

What i do wrong and what i should do now?

Grocery Crud custom model with CI4

$
0
0
Hi!

I want to implement a custom model from Grocery Crud but I see that CI4 does not have `get_instance` anymore. As per the example I need to do:
```
<?php
//CustomersModel.php

use GroceryCrud\Core\Model;
use GroceryCrud\Core\Model\ModelFieldType;

class CustomersModel extends Model {

    protected $ci;
    protected $db;

    function __construct($databaseConfig) {
        $this->setDatabaseConnection($databaseConfig);

        $this->ci = & get_instance();
        $this->db = $this->ci->db;
    }

    public function getFieldTypes($tableName)
    {
     ...
```

The question is, how may I get a CI4 context as this example is for CI3?
Example website: https://www.grocerycrud.com/docs/custom-model
Thank you.

Shield save session value on login

$
0
0
Hi how can customize shield to save more session variable ?

Queue cache old process

$
0
0
Hello Community,
I have been using CI4 Queue add-on to process some jobs, however I have been facing strange issue with the job process when it fails and retry.
for e.g. A job has been added to queue and it fails. Now suppose some changes made into code and the failed job again added into queue but this time the new code changes doesn't reflect into process. The outcome is still same, the new changes only reflects if the fresh job added into queue. I don't understand why and how the old code executes in case of retry?
Also the Skip locked feature giving fatal error, I have 10.4.32-MariaDB
is this possible to run multiple concurrent jobs without affecting main application?

correct use of GIT for projects with codeigniter

$
0
0
Good morning,
I tried to search around the web, but I couldn't find a solution.
I tried many times, but I always end up with the same result. In one way or another, I always have errors.

I'll try to explain the situation:

I create a project in codeigniter via composer, I start creating controllers, models and views and I create several pages. everything works perfectly.

Via a GIT server, I commit and then push, thus synchronizing my project in the GIT server.

From another PC, I clone the git project and, without making any changes, I try to view it.

errors upon errors and problems.

from the second PC, if I create a new project and then launch: php spark serve, everything works. on the project cloned from GIT sometimes the php spark serve command doesn't even start.

At this point I start to doubt my method.
is there a procedure to follow to be able to use git with codeigniter correctly?

are there any files that I need to add or remove from .gitignore?

Thanks.

Problem with mail

$
0
0
hi , because my free hosting doesn't permit to send mail via smtp i change configuration to send mail with 'mail' , but i have this problem :
Call to undefined function CodeIgniter\Email\mail()
SYSTEMPATH/Email/Email.php at line 1762

How can i solve it ?

Links not working

$
0
0
I'm facing a weird issue with links in web page, you can see the test web page here: https://test.aeroclubbelluno.org/
In my project links in the main page don't work...I just get the following error ( The pages in server are linked to CHI SIAMO main menu )

Quote:404 Not Found
Not Found

The requested URL was not found on this server.
My Routes file is very clean...so far:

Code:
use CodeIgniter\Router\RouteCollection;

/**
* @var RouteCollection $routes
*/
$routes->get('/', 'Home::index');
$routes->get('lang/{locale}', 'Language::index');
$routes->get('/aeroclub', 'Aeroclub::index');

And the Aeroclub controller also...
Code:
namespace App\Controllers;

class Aeroclub extends BaseController
{
public function index(): string
    {
        return view('pages/public/aeroclub/aboutus', $this->viewData);
    }

    public function dolomites(): string
    {
        return view('pages/public/aeroclub/dolomites', $this->viewData);
    }

    public function organization(): string
    {
        return view('pages/public/aeroclub/organization', $this->viewData);
    }

    public function history(): string
    {
        return view('pages/public/aeroclub/history', $this->viewData);
    }
}

I have no idea what's wrong...any hint or suggestion?
In my local PC the links work fine
Thanks a lot for any kind feedback

Problem with sessions

$
0
0
CRITICAL - 22:25:34 01-12-2024 --> ErrorException: session_start(): Failed to read session data: user (path: /var/www/www-root/data/mod-tmp)
[Method: GET, Route: /]
in SYSTEMPATH/Session/Session.php on line 920.
1 [internal function]: CodeIgniter\Debug\Exceptions->errorHandler(2, 'session_start(): Failed to read session data: user (path: /var/www/www-root/data/mod-tmp)', '/var/www/www-root/data/www/server/vendor/codeigniter4/framework/system/Session/Session.php', 920)
2 SYSTEMPATH/Session/Session.php(920): session_start()
3 SYSTEMPATH/Session/Session.php(242): CodeIgniter\Session\Session->startSession()
4 SYSTEMPATH/Config/Services.php(710): CodeIgniter\Session\Session->start()
5 SYSTEMPATH/Config/BaseService.php(312): CodeIgniter\Config\Services:Confusedession(Object(Config\Session), false)
6 SYSTEMPATH/Config/BaseService.php(251): CodeIgniter\Config\BaseService::__callStatic('session', [...])
7 SYSTEMPATH/Config/Services.php(668): CodeIgniter\Config\BaseService::getSharedInstance('session', null)
8 SYSTEMPATH/Config/BaseService.php(321): CodeIgniter\Config\Services:Confusedession()
9 SYSTEMPATH/Config/BaseService.php(202): CodeIgniter\Config\BaseService::__callStatic('session', [])
10 SYSTEMPATH/Common.php(998): CodeIgniter\Config\BaseService::get('session')
11 SYSTEMPATH/Common.php(971): service('session')
12 APPPATH/Filters/LoginFrontend.php(26): session()
13 SYSTEMPATH/Filters/Filters.php(203): App\Filters\LoginFrontend->before(Object(CodeIgniter\HTTP\IncomingRequest), null)
14 SYSTEMPATH/Filters/Filters.php(184): CodeIgniter\Filters\Filters->runBefore([...])
15 SYSTEMPATH/CodeIgniter.php(481): CodeIgniter\Filters\Filters->run('settings/office/voip', 'before')
16 SYSTEMPATH/CodeIgniter.php(355): CodeIgniter\CodeIgniter->handleRequest(null, Object(Config\Cache), false)
17 SYSTEMPATH/Boot.php(325): CodeIgniter\CodeIgniter->run()
18 SYSTEMPATH/Boot.php(67): CodeIgniter\Boot::runCodeIgniter(Object(CodeIgniter\CodeIgniter))
19 FCPATH/index.php(56): CodeIgniter\Boot::bootWeb(Object(Config\Paths))

I get this error from time to time

Confiration:
php 8.3.8
Redis Version 6.1.0
Redis Sentinel Version 1.0
Available serializers php, json
Ubuntu 22.04
FastCGI (Nginx + PHP-FPM)

Basic understanding of folders and structures

$
0
0
Hello. After some initial problems, I was now able to install both Codeigniter and Shield via Composer.

But I have a few basic questions because I can't really understand the following things at the moment.

1) I installed Codeigniter in a root projectfolder, then shield out of the rootfolder. A new “vendor” folder has now been created in the project folder.
What is this folder for?

2) There is now a lot in the "vendor" folder (bin/composer/fakerphp/liminas/mikey179 etc) and a "codeigniter4" folder, which is also contained there, there is now the "settings" "framework" and "shield" folder.
- Why didn't these
   
a) folders end up directly in the main project folder?

b) It seems to me that there is a complete installation of Codeigniter in the "vendort/framework" folder, in addition to the one in the main folder - why?

c) How do the folder structures behave? Until now I always thought I had a project directory, for example with the "app" folder and had all my controllers, models etc. there.

Last for the moment, what is the role of the "thisParty" folder?

Or did I simply do something wrong when installing shield? (At least running does)

Thank you!

Myth Auth to Shield Migrator

failure in json response in codeigniter 3 controller method

$
0
0
in my codeigniter view page i have a form submission process; 
and in controller method i use following to process form imput data:


PHP Code:
$FORM_KURALLARI PROFIL_OLUSTURMA_FORM_KURALLARI();
$this->form_validation->set_rules($FORM_KURALLARI);
if (
$this->form_validation->run() == FALSE) {
    log_message('debug','unvalid form=='.json_encode(validation_errors()));;
    $response = array(
        'durum' => "warning",
        'icon' => 'fa-times',
        'mesaj' => validation_errors(),
        'buton1' => ceviri('Tamam'true)
    );
    $this->output->set_content_type('application/json')->set_output(json_encode($response));
    return;
}
  

so if data input is not meet conditions as i defined for fields the failure for fields will be displayed;
e.g. input for email address or telephone number!
here while the errors could be logged successfully, json response does not displayed at all;

what cause this problem? and how could i resolve that?
Viewing all 14343 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>