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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 17,973
» Latest member: KarFreak
» Forum threads: 71,514
» Forum posts: 367,229

Full Statistics

Latest Threads
ci_session cookie rejecti...
Forum: CodeIgniter 4 Support
Less than 1 minute ago
» Replies: 1   » Views: 48
form_dropdown() function
Forum: CodeIgniter 4 Support
20 minutes ago
» Replies: 4   » Views: 96
CI4 in shared hosting
Forum: Installation & Setup
50 minutes ago
» Replies: 0   » Views: 6
CI4 in localhost
Forum: Installation & Setup
56 minutes ago
» Replies: 0   » Views: 6
Starting a CI 4 project: ...
Forum: CodeIgniter 4 Discussion
4 hours ago
» Replies: 10   » Views: 541
SubQuery Not Working
Forum: CodeIgniter 4 Support
6 hours ago
» Replies: 3   » Views: 599
SmartyACL - Auth library ...
Forum: Addins
8 hours ago
» Replies: 1   » Views: 203
CodeIgniter - French Comm...
Forum: Regional User Groups
11 hours ago
» Replies: 43   » Views: 21,498
AJAX ARRAY
Forum: General Help
Yesterday, 09:47 AM
» Replies: 2   » Views: 93
External Javascript
Forum: CodeIgniter 4 Support
Yesterday, 05:52 AM
» Replies: 0   » Views: 68

 
  CI4 in shared hosting
Posted by: pippuccio76 - 50 minutes ago - Forum: Installation & Setup - No Replies

Hi , i upload an application in ci4 to a shared hosting in a subfolder  , when i try to access it i have this problem :


ErrorException

realpath(): open_basedir restriction in effect. File(/var/www/html) is not within the allowed path(s):

This is my url : http://eventisportivi1.altervista.org/co..._4/public/


  CI4 in localhost
Posted by: pippuccio76 - 56 minutes ago - Forum: Installation & Setup - No Replies

hi , sorry for english im new in ci4 , in ci3 when i unzip the project in my localhost i can access by the browser visit the url http://localhost/myproject , now in ci4 i must add at the url the public http://localhost/myproject/public  but i have the error 

Code:
[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif][color=#222222][size=xx-large]Whoops![/size][/color]

[color=#777777][size=large]We seem to have hit a snag. Please try again later...[/size][/color][/font][/size][/color]

my .env is in development mode .

If i run the command php spark serve it work fine , Why ?


  External Javascript
Posted by: 68thorby68 - Yesterday, 05:52 AM - Forum: CodeIgniter 4 Support - No Replies

Hi,
I am using CI4

My preferred way of using javascript/jquery is to use external .js files

Code:
<script src="<?php echo base_url('includes/common/js/myfunctions.js'); ?>" ></script>


rather than including the javascript/jquery in the page
Code:
$.ajax({
    type: "POST",
    processData: false, // important
    contentType: false, // important
    data: data,
    url: "<?= base_url('file/function'); ?>",
    dataType: "script",
    beforeSend: function() {
        $('.processing').show();
    },
    complete: function() {
        $('.processing').hide();
    },
    success: function (data) {
        alert(data);            
    },
    error: function(data) {
        alert('error '+data);
    },
});
Does codeigniter 4 address any of the obvious issues that would arise is if I was to use try and use codeigniter helpers like base_url() in an external js file???


  form_dropdown() function
Posted by: mjamilasfihani - Yesterday, 02:24 AM - Forum: CodeIgniter 4 Support - Replies (4)

any idea to set the first option become hidden?


  Array to string conversion
Posted by: Beewez - 05-30-2020, 09:53 PM - Forum: Regional User Groups - No Replies

Hola

Tengo el siguiente problema en CI4, cuando quiero generar un nuevo usuario en mi db desde un formulario, devuelve el siguiente error:

Conversión de matriz a cadena

pero al editar / modificar este usuario, lo guarda en la base perfectamente sin errores

Este es mi código:

PHP Code:
<?php
echo form_open('/home/guarda');
if(isset(
$users)){
    $name=$users[0]['name'];
    $email=$users[0]['email'];
}
else{
    $name="";
    $email="";
}
?>
<div class="form-group">
<?php
echo form_label('Nombre','name');
echo 
form_input(array('name'=>'name','placeholder'=>'Nombre','class'=>'form-control','value'=>$name));
echo 
"<br>";
echo 
form_label('Email','email');
echo 
form_input(array('name'=>'email','placeholder'=>'Email','class'=>'form-control','value'=>$email));
echo 
"<br>";
echo 
form_submit('guarda','Guardar','class="btn btn-primary"');
if(isset(
$users)){
    echo form_hidden('id',$users[0]['id']);
}

?>
</div>
<?php

echo form_close();
?>

PHP Code:
    public function guarda(){
        
$userModel=new UserModel($db);
        
$request= \Config\Services::request();
        
$data=array(
            
'name'=>$request->getPostGet('name'),
            
'email'=>$request->getPostGet('email'),
        );
        if(
$request->getPostGet('id')){
            
$data['id']=$request->getPostGet('id');
        }
        if(
$userModel->save($data)===false){
            
var_dump($userModel->errors());
        }
        if(
$request->getPostGet('id')){
            
$users=$userModel->find([$request->getPostGet('id')]);
            
$users=array('users'=>$users);
            
$estructura=view('estructura/header').view('estructura/formulario',$users);    
        }
        else{
            
$users=$userModel->findAll();
            
$users=array('users'=>$users);
            
$estructura=view('estructura/header').view('estructura/body',$users);
        }
        return 
$estructura;

    }
    public function 
editar(){
        
$userModel=new UserModel($db);
        
$request= \Config\Services::request();
        
$id=$request->getPostGet('id');
        
$users=$userModel->find([$id]);
        
$users=array('users'=>$users);
        
$estructura=view('estructura/header').view('estructura/formulario',$users);
        return 
$estructura;

    } 

PHP Code:
<?php

namespace App\Models;

use 
CodeIgniter\Model;

class 
UserModel extends Model
{
    protected $table      'users';
    protected $primaryKey 'id';

    protected $returnType     'array';
    protected $useSoftDeletes true;

    protected $allowedFields = ['name''email'];

    protected $useTimestamps false;
    protected $createdField  'created_at';
    protected $updatedField  'updated_at';
    protected $deletedField  'deleted_at';

    # -----------------------------------------------------------------
    # Pongo todas las reglas de validacion
    # -----------------------------------------------------------------
    protected $validationRules    = array(
        # Valido el name
        # le digo que sea requerido y (|) que sea alfanumerico y que tenga un minimo de 3 caracteres
        'name' => 'required|alpha_numeric_space|min_length[3]',
        # Valido el email, que sea requerido, de timo email y unico
        'email' => 'required|valid_email|is_unique[users.email]'
    );

    # -----------------------------------------------------------------
    # Si Falla alguna de las validaciones entonces enviame este mensaje
    # -----------------------------------------------------------------
    protected $validationMessages = [
        'email' => [
            'is_unique' => 'Ese correo ya se encuentra registrado'
        ]
    ];

    protected $skipValidation     false


  ini_set(): A session is active
Posted by: fabianoc - 05-30-2020, 05:35 PM - Forum: General Help - No Replies

Code:
Severity: Warning

Message: ini_set(): A session is active. You cannot change the session module's ini settings at this time

Filename: Session/Session.php

Line Number: 282

My system : 
PHP 7.3.11 on Mac OS Catalina

After upgrading from CI 2.2.1 to 3.1.11 version I keep getting these Warnings, I have no session_start() calls in my code, if I set ENVIRONMENT = production the warnings stop, I need to keep ENVIRONMENT = development to test the app but I can't remove these warnings from sessions.

My Session config:
PHP Code:
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'credsession';
$config['sess_expiration'] = 0;
$config['sess_save_path'] = sys_get_temp_dir();
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE

I tried commenting session_start() on line 143 of "system/libraries/Session/Session.php" and the warnings stop, but I don't think that's a good solution.
I removed the system folder and pasted the system 3.1.11 version into my app, followed all upgrading instructions on https://www.codeigniter.com/userguide3/i...e_300.html 

Could this be a php 7.3.11 problem?


  Parser function (parseConditionals) error - JS in HTML with condition IF
Posted by: MarcinKabiesz - 05-30-2020, 05:27 PM - Forum: CodeIgniter 4 Support - No Replies

Hello,
I think I found a view parser problem. The problem occurs according to the error code when substituting the phrase "{if" in the HTML code that contains the JS code. There is no '{if' tag used to be replaced by the parser, but it tries to do it.

My JS code in HTML:
                success: function (data) {
                  if (data.code == true) {
                    clock_time = clock_time_session;
                  }

As you can see, this is a piece of AJAX code written before the end of BODY in HTML.

The parser lets go when I do this trick:
                success: function (data) {
// -> Added Comment (fix), finaly pattern not matched
                  if (data.code == true) {
                    clock_time = clock_time_session;
                  }

After analyzing the regex that is to replace the {if} {elseif} {else} etc ... it looks like a syntax error in the saved regex.

File system/View/Parser.php:
Pattern line 524/868 in the parseConditionals function:
$pattern = '/\{\s*(if|elseif)\s*((?:\()?(.*?)(?:\))?)\s*\}/ms';

My Fix:
$pattern = '/\{(if|elseif)\s*((?:\()?(.*?)(?:\))?)\s*\}/ms';

CUT: "\s*" -> ""

It seems to me that the use of spaces between "{" and "if" should not be allowed, which also translates into a parser crash through your own JS code in BODY HTML.

Please check the Framework again for using the view parser.

I'm using the latest stable version 4.0.3.


A little note.

I noticed that you also allow {   else  } or {  endif} tags. Since you write in the documentation specifically {else} or {endif} instead of what I gave above, I think there is no point in allowing additional whitespace or new lines - no sense ...

Note:
I didn't notice that after my change, of course, the debugger toolbar stopped working. In the documentation, examples show that there is no space between the parenthesis and if, and yet they themselves had to use it with the debugger toolbar. ehh ...

My Fix #2:
$pattern = '/\{\s*(if|elseif)\s*((?:\()?(.*?)(?:\))?)\s*\}/m';

CUT: "/ms" -> "/m"

The debugger strip and JS code work then.


  AJAX ARRAY
Posted by: andwise - 05-30-2020, 04:08 PM - Forum: General Help - Replies (2)

Hello there. I'm from Turkey. I use google translate because i don't speak english.

I am sending an array to the Controller with AJAX. There are 3 different IDs in the array I sent. I will pull data from the database with these IDs, but I don't know how to separate them.

Ajax

Code:
$.ajax({
            url: '<?php echo base_url('varyasyonlar/o_getir') ?>',
            type: 'POST',
            data: {opts: opts},
            dataType: 'JSON',
            cache: false,
            success: function (data) {
                const toast = swal.mixin({
                    toast: true,
                    position: 'top-end',
                    showConfirmButton: false,
                    timer: 3000,
                    padding: '2em'
                });

                toast({
                    type: 'success',
                    title: 'Çalıştı.',
                    padding: '2em',
                })
            },
            error: function (data) {
                swal({
                    title: 'Bir hata oluştu!',
                    type: 'error',
                    padding: '2em'
                });
            }
        });

Controller
Code:
public function o_getir() {
        $data = $this->input->post('opts');

        $this->varyasyonlar_model->o_get2($data);
       
        foreach ($data as $key => $row) {
            $output['opsiyon_id'][$key] = $row->opsiyon_id;
            $output['opsiyon_baslik'][$key] = $row->opsiyon_baslik;
        }

        echo json_encode($output);    
    }

Model
Code:
public function o_get2($data) {

        for ($i = 0; $i < count($data); $i++) {
            $this->db->where('varyasyon_id', $data[$i]);
            $result[] = $this->db->get('opsiyonlar')->result_array();
        }
       
        return $result;
    }

IDs in Array
[Image: s6OuIG.png]

The data I want to bring from the database.
[Image: IVwJGn.png]

The data of each ID must be in different arrays.


Exclamation insert() return null
Posted by: pws - 05-30-2020, 05:07 AM - Forum: CodeIgniter 4 Support - Replies (4)

Hello,
i using CI4 and i call method insert() and i set all required params but function return 0! why? how i can get error message if is exist!
My code is:

namespace App\Models;
use CodeIgniter\Database\ConnectionInterface;
use CodeIgniter\Model;

class UserModel extends Model
{

    protected $table = 'users';
protected $primaryKey = 'id';
    protected $allowedFields = ['role', 'email','password','display_name','active','token'];
protected $useSoftDeletes = true;
protected $returnType = 'array';
protected $useTimestamps = true;
    protected $createdField  = 'created_at';
protected $deletedField  = 'deleted_at';



------------------------------- 
$signup_email=$this->request->getVar('signup_email');
$signup_password=$this->request->getVar('signup_password');
$signup_password_confirmation=$this->request->getVar('signup_password_confirmation');
$val = $this->validate([
'signup_email' => ['label' => 'Email', 'rules' => 'trim|required|valid_email'],
'signup_password' => ['label' => 'Password', 'rules' => 'trim|required'],
'signup_password_confirmation' => ['label' => lang('app.field_confirm_password'), 'rules' => 'trim|required|matches[signup_password]']
]);
if (!$val)
{

$validation=$this->validator;
$error_msg=$validation->listErrors();
$res=array("error"=>true,"validation"=>$error_msg);
}
else{
$UserModel=new UserModel();

$data = [
'display_name' => $signup_email,
'email'  => $signup_email,
'password'  => md5($signup_password),
'role'=>'customer',
'active'=>'no'

];
$user_id =$UserModel->insert($data);
$res=array("error"=>false,"validation"=>$user_id);

}


  validation custom error not working in saved rules
Posted by: nmaa3003 - 05-30-2020, 01:12 AM - Forum: CodeIgniter 4 Support - No Replies

PHP Code:
    //--------------------------------------------------------------------
    // Rules
    //--------------------------------------------------------------------
    
public $merchant_register = [
        
'email' => [
            
'label' => 'Email Address'
            
'rules' => 'trim|required|valid_email|is_unique[merchant.email]'
            
'errors' => [
                
'is_unique' => 'Your email address has been registered'
            
]
        ],
        
'password' => [
            
'label' => 'Password'
            
'rules' => 'trim|required|string|min_length[8]|max_length[30]'
        
],
        
'confirm_password' => [
            
'label' => 'Confirm Password'
            
'rules' => 'required|matches[password]'
        
],
        
'mobile' => [
            
'label' => 'Mobile No'
            
'rules' => 'trim|required|numeric|min_length[10]'
        
]
    ]; 

the default error was the one shows in the screen when i put existing email.
this is saved rule in :

PHP Code:
<?php namespace Config;

class Validation 

and run by this command which is working good. just the custom error not showing.


PHP Code:
$validation $data['validation']->run($input'merchant_register'); 



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