Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 18,587
» Latest member: GeorgeRenna
» Forum threads: 71,790
» Forum posts: 368,326

Full Statistics

Latest Threads
Undefined index: expires_...
Forum: CodeIgniter 3.x
1 hour ago
» Replies: 0   » Views: 8
how to retrive data from ...
Forum: CodeIgniter 4 Support
1 hour ago
» Replies: 0   » Views: 15
Calender in Codeigniter 4
Forum: CodeIgniter 4 Support
2 hours ago
» Replies: 4   » Views: 48
How to continue a Code Ig...
Forum: General Help
3 hours ago
» Replies: 1   » Views: 30
Transaction in controller...
Forum: CodeIgniter 4 Support
3 hours ago
» Replies: 0   » Views: 11
CSRF with fetch API
Forum: CodeIgniter 4 Support
8 hours ago
» Replies: 3   » Views: 116
Simple chat facility - if...
Forum: General Help
9 hours ago
» Replies: 16   » Views: 398
setTranslateURIDashes Not...
Forum: CodeIgniter 4 Support
Yesterday, 11:32 AM
» Replies: 0   » Views: 20
What is the better soluti...
Forum: CodeIgniter 4 Support
Yesterday, 10:21 AM
» Replies: 1   » Views: 110
How to create index using...
Forum: CodeIgniter 4 Support
Yesterday, 10:19 AM
» Replies: 1   » Views: 80

 
  How can i move force_https in before filter
Posted by: cvlancvlan - 07-03-2020, 11:57 AM - Forum: CodeIgniter 4 Support - No Replies

How can i move force_https in before filter ? I wan't remove this force_https from system/Controller.php and i want add in filter.
I created an login sistem in filters where i recive informations from $_POST. In this case the redirect to https it will be done after i checked some informations from $_POST. I want first the redirect to be done.

I tried this but didn't work. app/GlobalFilter.php

PHP Code:
<?php namespace App\Filters;
use 
CodeIgniter\Filters\FilterInterface;
use 
CodeIgniter\HTTP\RequestInterface;
use 
CodeIgniter\HTTP\ResponseInterface

class 
GlobalFilter implements FilterInterface {
    
    protected 
$session;
    
    public function 
before(RequestInterface $requestResponseInterface $response) {

        
force_https(31536000$request$response);
    
   
    
}
    
    public function 
after(RequestInterface $requestResponseInterface $response) {
       
    
}
   


How can i override system/Controller.php ?
I tried copy this system/Controller.php in app/Controller.php folder but didn't work for me


  Using cache Redis questions
Posted by: MatheusCastro - 07-03-2020, 11:06 AM - Forum: CodeIgniter 4 Support - Replies (1)

Hello,
I have my redis server using docker.

I found the installation of phpredis a bit confusing to be honest, I couldn't even implement it.

At Codeigniter I saw that have an implementation of PredisHandler, but I didn't see anything in the documentation. Perhaps because the author no longer updates the project even though it is "stable".

Is PredisHandler recommended? Or would the best alternative be phpredis?

Do you know any place that has a more readable implementation of phpredis?

The implementation works perfectly when using Predis.


  Logging all sql-queries
Posted by: fs444 - 07-03-2020, 10:46 AM - Forum: CodeIgniter 3.x - Replies (4)

How I can log all sql-queries in current page?

I found this code

PHP Code:
$this->db->queries 


but when I located it at the end of index.php, it crashed the site.


  Cart and Paypal integration
Posted by: mmrtonmoy - 07-03-2020, 02:08 AM - Forum: CodeIgniter 4 Feature Requests - Replies (3)

I am beginner in CodeIgniter. I think CodeIgniter is the best framework in the world. I think of these features are available in codeigniter , it will be great.

  1. payment integration(paypal) library
  2. cart library
When making an e-commerch site it must be to add this system in site.
So if codeigniter provides this fetures internally . It will be very helpful for developer. It also create attract to the developer to use codeigniter.
please add payment integration(paypal) library that a developer can integrate just write one or two code.
please add this feature soon.


  Codeigniter-4 redirect back and ajax issue
Posted by: Cyto5 - 07-02-2020, 02:46 PM - Forum: General Help - Replies (3)

Does anyone have a suggestion on how to fix this issue without manually modifying CI core code.

CI4 saves a reference to the last requested url so it can do it's redirect()->back() function however when you use ajax it stores that call and when I want to use back on the next page (say a link clicked from the current page) it tries to redirect me back to the ajax page and not the main page.

CI's function that handles this is in system/Codeigniter.php (line 969 on my version) public function storePreviousURL($uri)

I can add an exception inside of this to ignore url's with ajax in the name however I am editing code I shouldn't be touching because it will get overwritten during updates. I am not sure how to intercept this and make changes from the outside. I am not sure how to override this class since it's a level above the core classes that you can extend and override.

Thanks for the help.


Sad database migrate
Posted by: lnavarro - 07-02-2020, 10:57 AM - Forum: General Help - No Replies

hi everyone, im try to use myth-auth, in my local machine it work fine, i run php spark migrate -all, and migrate controller, both work fine on my local machine....... the problem is on my production server, i cant use ssh to run cli, and i try migrate controller but doesnt work, i have try this 2 codes on the controller

try{
      $migrate->setNamespace('Myth\Auth')->latest();      //this code work on my local machine
}


and this other
try{
      $migrate->latest();
}



Do I need some other configuration on my production server?

PD: sorry for my english Smile


  MultiLanguage and 404
Posted by: Vertig0 - 07-02-2020, 07:34 AM - Forum: CodeIgniter 4 Support - No Replies

Hey.

I recently started using codeigniter4 and have a little MultiLanguage problem.
I have 2 languages planned on my site, English and Russian.
I followed the instructions described here.

I created translation files.

Code:
/app
    /Language
        /en
            app.php
        /ru
            app.php

My APP config:
PHP Code:
public $defaultLocale 'en';
public 
$negotiateLocale false;
public 
$supportedLocales = ['en''ru']; 

In the route I have written:
PHP Code:
$routes->get('{locale}/''Home::index'); 

When i add to route {locale} and i have trouble with 404.

Any non-existent page of the first level always gives the 200th code, like "localhost/dsa".
Any non-existent page should give the 404th code?
This problem is not observed if I do not use {locale}, 
Iit’s critical for me that each language has a unique prefix.
Sorry if I indistinctly described the problem, English is not my main language.

If you need clarifying information, I am ready to provide.


  insert batch with group checkbox
Posted by: eleumas - 07-02-2020, 02:03 AM - Forum: CodeIgniter 4 Support - Replies (6)

Hi. I have a group of checkbox like this:

Code:
<input type="checkbox" name="preview[]" value="1"/>
<input type="checkbox" name="preview[]" value="1"/>
<input type="checkbox" name="preview[]" value="1"/>

and the follow code in my controller:

PHP Code:
for($i 0$i $count$i++)
      {

        foreach($this->request->getPost('preview') as $preview)
        {
          $c = array('preview' => $preview);

          $data[$i] = array(
            'article_id' => $this->request->getPost('article_id'),
            'name'       => $names[$i],
            'text'       => $this->request->getPost('text')[$i],
            'title'      => $this->request->getPost('title')[$i],
            'alt'        => $this->request->getPost('alt')[$i],
            'preview'    => $c,
          );
        }
      }

      $imagesModel = new ImagesModel();
      $save $imagesModel->insertBatch($data); 

The value of checkbox is wrong. This is or always 1 or always 0. I have tried too the ternary operator, something like this:

PHP Code:
$c $this->request->getPost('preview') == 0

but the problem has not been resolved.

Someone can help me please? Thanks  Smile


  Input array problem in class validation
Posted by: hugoafr - 07-01-2020, 04:08 PM - Forum: CodeIgniter 4 Support - Replies (2)

Hello,

Sorry for the inconvenience, when migrating my applications from CI3 to CI4, validations with input form as array do not work. I am trying to correct the system / validation / validation.php file


Sorry for the English, I don't know much.

PHP Code:
This way it doesn't work 
VIEW
<?=form_input('
data_form[usuario]', '', 'class="form-control form-control-sm" placeholder="Usuario"');?>
<?=form_password('
data_form[password]', '', 'class="form-control form-control-sm" placeholder="Contraseña"');?>

<?=form_dropdown('
data_form[id_sucursal]', $opt_sucursal, '', 'class="form-control form-control-sm" placeholder="Sucursal"');?>

CONTROLLER
$this->validation->setRule('
data_form[usuario]', 'Usuario', 'trim|required');
$this->validation->setRule('
data_form[password]', 'Contraseña', 'trim|required');
$this->validation->setRule('
data_form[id_sucursal]', 'Sucursal', 'trim|required');
if(! $this->validation->withRequest($this->request)->run()){

This is how it works 
VIEW
<?=form_input('
usuario', '', 'class="form-control form-control-sm" placeholder="Usuario"');?>
<?=form_password('
password', '', 'class="form-control form-control-sm" placeholder="Contraseña"');?>

<?=form_dropdown('
id_sucursal', $opt_sucursal, '', 'class="form-control form-control-sm" placeholder="Sucursal"');?>

CONTROLLER
$this->validation->setRule('
usuario', 'Usuario', 'trim|required');
$this->validation->setRule('
password', 'Contraseña', 'trim|required');
$this->validation->setRule('
id_sucursal', 'Sucursal', 'trim|required');
if(! $this->validation->withRequest($this->request)->run()){ 


  CSRF with fetch API
Posted by: Leo - 07-01-2020, 11:04 AM - Forum: CodeIgniter 4 Support - Replies (3)

Can someone help me with this?

Code:
fetch(SITE_CONSTANT+'/login/updateUser', {
    method: "post",
    body: "Some string"
})
    .then(response => response.json())
    .then(data => data.result)
    .then(result => console.log(result));

posting stuff with fetch api from javascript to a controller. It works when I turn off csrf, but does not when it's on.

I tried to do like this:
Code:
let csrfs = document.querySelectorAll('input[name=csrf_token]');
let csrf = {name: csrfs[0].name, value: csrfs[0].value};
fetch(SITE_CONSTANT+'/login/updateUser', {
    method: "post",
    body: [csrf, {name: "a name", value: "a value"}]
})
    .then(response => response.json())
    .then(data => data.result)
    .then(result => console.log(result));

Like how I do with Jquery ajax - but still no dice Sad help?



  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.