Welcome Guest, Not a member yet? Register   Sign In
  CSRF Protection Problem
Posted by: donpwinston - 6 hours ago - Replies (6)

I get the following error message in the session using the debug toolbar:
error                  The action you have requested is not allowed.

When I comment out the csrf entry in app/Config/Filters.php The problem goes away. (I can't submit post requests)
What is causing this not to work?
I've got the following in .env

Code:
app.baseURL = 'https://noticestest.uscourts.gov/'
app.forceGlobalSecureRequests = false
app.indexPage = ''
# app.sessionDriver = 'CodeIgniter\Session\Handlers\FileHandler'
# app.sessionCookieName = 'ci_session'
# app.sessionExpiration = 7200
# app.sessionSavePath = null
# app.sessionMatchIP = false
app.sessionTimeToUpdate = 0
#app.sessionRegenerateDestroy = true
app.CSPEnabled = true
app.appTimezone = 'America/New_York'

cookie.secure = true
security.csrfProtection = 'session'


  variable to layout
Posted by: pippuccio76 - 8 hours ago - Replies (1)

hi how can i send variable to footer in layout ( with <?= $this->renderSection('content') ?> ) ? variable set to every view that extend a template  : <?= $this->extend('templates/layout_user') ?>


  Do you have any tips for the best way to structure partial views?
Posted by: castle - Today, 04:56 AM - Replies (3)

Hi,
I'm reading about renderSection(), but it seems a bit confusing for me. I don't get its workflow and how it really works. Do you have any tips or know any good tutorial about it?
Thanks.


  Multi tenant SaaS application - user management
Posted by: Hogar - Today, 04:25 AM - No Replies

Hi all,
Using extra time during this difficult (COVID) times I got with WFH I created an interesting business application that I want to start commercializing, but I created it single tenant. Now, that I definitely want to make it multi tenant, I decided to start from the begging (of course, I will be reusing a lot of code). I decided generally on multi-database approach but still have some doubts which I would like to discuss here, so any comment is welcomed!
1. In order to enable metrics, reporting, etc. I will be having one central database that will consist of following data: tenant data, tenant subscription (modules that can be accessed), tenant level and duration (trial, basic, pro, etc. whatever you want to call different subscription models), but also each tenant activity per user (analytics, GDPR compliance when accessing private data, resource planing, subscription monitoring). In this database there will be also a table linking each tenant with their own database.
2. Each tenant will be accessing same URL, but with their identification number in first segment (e.g. app.somedomain.com/somerandomdata) where "some random data" will be one way hash of id number for each tenant used in the app. This is for the purpose of enabling same usernames for different tenants (in central database, both id and hash of the id will be stored). Once login process is completed (tenant identified using URI's first segment, using appropriate database for login), $_SESSION will hold data on tenant id (including tenant db id which will probably be same hash used for login), user id, user access rights. Now, URI will be same for each tenant, but the application will be using two databases, one central for storing activity data and another tenant specific identified by tenant db id hold in the session for all other db transactions.
Ok. Would not go further, because I believe that after this, everything is clear. Any thoughts?


  retrieve average rating on a join
Posted by: remesses_thegreat - Today, 02:06 AM - Replies (2)

Good Day 

I need help with result. I have a model that returns all business branches. 
I would like to join an additional table called Ratings and return the average rating for each company.

Does anyone have a simple script i can use. What's the best practice to achieve this.

Thanks in advance


PHP Code:
function getAllBranches()
    {
        $db      = \Config\Database::connect();
        $builder $db->table('branches');
        $builder->join('companies''companies.id = branches.companyId');
        $builder->join('businessprofile''businessprofile.companyId = branches.companyId'); 
        
        $builder
->where('paymentstatus''active');
        
        $query 
$builder->get();
        
        
return $query->getResult();
    


  CodeIgniter4 Attribute Routes
Posted by: kenjis - Yesterday, 11:41 PM - No Replies

Hi, all.

I started to develop a package that you can set routes in your Controllers with PHP8 Attributes.

PHP Code:
namespace App\Controllers;

use 
Kenjis\CI4\AttributeRoutes\Route;

class 
News extends BaseController
{
    #[Route('news', methods: ['get'])]
    public function index()
    {
        ...
    }


This package generates Routes File from the Attribute Routes in your Controllers.
So, there is no extra overhead at runtime.

See https://github.com/kenjis/ci4-attribute-routes


Question Jobs/Queues in CI4
Posted by: vimkaf - Yesterday, 03:13 PM - No Replies

I'm still new in the world of Async PHP but I find myself needing a jobs queues and dispatcher or worker especially when I'm integrating several APIs in an application.
 I want to know if this is in the works for CI4, is this something we should be expecting or we look for an alternative.


  validacion json
Posted by: Z4K7 - Yesterday, 02:08 PM - Replies (2)

I am trying to send a JSON validation response but it only gives me the same result that I enter a value.

PHP Code:
$Moneda model('XXXX')->XXXX($datos);
        $this->validacion->setRules([
            'amount' => [
            'label'  => 'cantidad',
            'rules'  => 'required|decimal|greater_than_equal_to['.$Moneda['min_withdraw'].']|less_than_equal_to['.$Moneda['max_withdraw'].']',
            'errors' => [
                'required' => 'Ingrese la cantidad.',
                'greater_than_equal_to' => 'El campo de cantidad debe contener un número mayor o igual a 1000.',
                'less_than_equal_to'=> 'El campo de cantidad debe contener un número menor o igual a 10000.',
                ],
            ],
 ]);
        if ($this->validacion->withRequest($this->request)->run()) {
            
            
        
}else {
            $error $this->validacion->getErrors();
                echo json_encode($error);
                $this->response->setStatusCode(424);
        }


AJAX

$("#retiro").submit(function (e) { 
            var id = $(this).data('id');
            $.ajax({
                type"POST",
                url"/XXXX/XXXX/"+id,
                data"data",
                dataType"dataType",
                success: function (response) {
                    
                
},
                statusCode:{
                    424: function(xhr){
                    var json JSON.parse(xhr.responseText);
                        if (json.required.length !=0) {
                            alertify.set('notifier','position''top-right');
                            alertify.error(json.required);
                        }
                    }
                }
            });
            e.preventDefault();
            
        
});

RESULTADO:

Estado
424
Failed Dependency
VersiónHTTP
/1.1
Transferido675 B 
(tamaño 33 B)
Política de referenciastrict-origin-when-cross-origin

amount 
:"Ingrese la cantidad." 

If I enter data in the INPUT I get the same information 


Question ErrorException imagecreatefrompng()
Posted by: hosterfy - Yesterday, 10:19 AM - Replies (2)

Hello,

I publish this issue, because there is an error when we try to import into a form a PNG image. The issue occurs only for PNG images, not for JPG.

ErrorException
imagecreatefrompng(): gd-png: libpng warning: Interlace handling should be turned on when using png_read_image

You can see it on this screenshot : https://prnt.sc/26et5v1

The impacted PHP version is 7.4.27 (all required extensions installed like GD, ImageMagick, etc. But when i change to PHP version 7.3.33 all is working.

I really don't understand why there is this issue only on 7.4 and above PHP version..

Also, i checked the above code, the image is properly uploaded but the CI code part is impacted by this issue :


PHP Code:
foreach($data['files'] as $file){
 
$edit_image = \Config\Services::image()
 
        ->withFile($file["file"])
 
        ->fit(400400'center')
 
        ->save($file["file"]);         
 
}
 
$avatar $file["name"]; 


Sorry about my bad english.

Thanks in advance.


  Time() not same?
Posted by: mylastof - Yesterday, 05:22 AM - Replies (1)

Code:
$now = Time::now();
$new_now = Time::createFromTimestamp($now->timestamp);

$new_now create from $now->timestamp
but $new_now not showing the same Time with $now
even I add timeZone in the createFromTimestamp()
The time not change.

Is this a bug?

Code:
// $now with (int)1642422355
object(CodeIgniter\I18n\Time)[78]
  protected 'timezone' =>
    object(DateTimeZone)[80]
      public 'timezone_type' => int 3
      public 'timezone' => string 'America/Chicago' (length=15)
  protected 'locale' => string 'en' (length=2)
  protected 'toStringFormat' => string 'yyyy-MM-dd HH:mm:ss' (length=19)
  public 'date' => string '2022-01-17 06:25:55.438431' (length=26)
  public 'timezone_type' => int 3
  public 'timezone' => string 'America/Chicago' (length=15)

Code:
// $new_now with (int) 1642422355
object(CodeIgniter\I18n\Time)[81]
  protected 'timezone' =>
    object(DateTimeZone)[82]
      public 'timezone_type' => int 3
      public 'timezone' => string 'UTC' (length=3)
  protected 'locale' => string 'en' (length=2)
  protected 'toStringFormat' => string 'yyyy-MM-dd HH:mm:ss' (length=19)
  public 'date' => string '2022-01-17 12:25:55.000000' (length=26)
  public 'timezone_type' => int 3
  public 'timezone' => string 'UTC' (length=3)


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

Username
  

Password
  





Latest Threads
CSRF Protection Problem
by donpwinston
2 hours ago
variable to layout
by BilltheCat
7 hours ago
validacion json
by remesses_thegreat
9 hours ago
retrieve average rating o...
by remesses_thegreat
10 hours ago
Aksara - a Complex CRUD S...
by abydahana
Today, 08:47 AM
Do you have any tips for ...
by castle
Today, 08:46 AM
ErrorException imagecreat...
by hosterfy
Today, 08:28 AM
I transfered a live site ...
by Irfanraza
Today, 06:57 AM
Status code 307 redirect ...
by Daviddenk101
Today, 04:51 AM
Multi tenant SaaS applica...
by Hogar
Today, 04:25 AM

Forum Statistics
» Members: 31,565
» Latest member: MARYLANADA
» Forum threads: 74,428
» Forum posts: 363,100

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB