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

Translation as in Laravel

$
0
0
Hi everyone, I did such a translation of files as in Laravel. You can see how I do a deal, someone can tell you how to do it better.

I created a library and in it I connect files in .json format


PHP Code:
class Language {

    protected 
$CI;
    public 
$deft_lang;
    public 
$json;
    public 
$patch;

    public function 
__construct()
    {
        
$this->CI =& get_instance();
        
$this->CI->load->helper('lang');
        
$this->CI->load->helper('cookie');
        
$lan substr($this->CI->config->item('language'), 02);
        
$this->deft_lang = (get_cookie('lang') != $lan) ? get_cookie('lang') : $lan;
        
set_cookie('lang'$this->deft_lang,93062220);
        
$this->patch =  APPPATH.'/lang/'.$this->deft_lang.'.json';
        if(
file_exists($this->patch))
        {
            
$json file_get_contents($this->patch);
            
$this->json json_decode($jsontrue);
        }
    }
    public function 
search($message,$par NULL)
    {
        if(!empty(
$this->json))
        {
            if (
array_key_exists($message$this->json))
                
$mes $this->json[$message];
            else 
$mes $message;
        }
        else 
$mes $message;

        return 
str_replace("%%s%%"$par$mes);
    }

after that I loaded the language helper.php helper through autoload.php and take the following
PHP Code:
function __($mess$var '')
{
    
$lang = new Language();
    return 
$lang->search($mess,$var);

and in the template it looks like this

Code:
<h1><?php echo __('Welcome to CodeIgniter!');?></h1>
but with the parameter

Code:
<p><?php echo __('If you are exploring CodeIgniter for the very first time, you should start by reading the %%s%%.','<a href="user_guide/">'.__('User Guide').'</a>');?></p>
I am very confused that I, in the helper, at each function call creates a class can somehow be different. I just did as I know, but I'm sure you can do a lot better.

and here is the .json file


Code:
{
    "Welcome to CodeIgniter!": "Добро пожаловать в CodeIgniter!",
    "The page you are looking at is being generated dynamically by CodeIgniter.": "Страница, которую вы просматриваете, динамически генерируется CodeIgniter.",
    "If you would like to edit this page you'll find it located at:": "Если вы хотите отредактировать эту страницу, вы найдете ее по адресу:",
    "The corresponding controller for this page is found at:": "Соответствующий контроллер для этой страницы находится по адресу:",
    "If you are exploring CodeIgniter for the very first time, you should start by reading the %%s%%.": "Если вы впервые исследуете CodeIgniter, вам следует начать с чтения %%s%%.",
    "User Guide": "Гид пользователя"
}

get users who live within 10 km radius of the current logged in user codeigniter 3

$
0
0
Hello
am trying to get all user who are within 10 km radius of the current logged in user so i tried getting only the addresses i get them but now i want to link the addresses with their owners so that i can display the users names etc.
so to get the addresses i used this code:
PHP Code:
    function Addresses($CurrentUserAdd){
        
$CI =& get_instance();
    $query $CI->db->get('users');
    $results = array();
    while ($row $query->unbuffered_row('array')) {
        if (getDistance($CurrentUserAdd$row['address']) <= 10.00) {
            $results[] = getDistance($CurrentUserAdd$row['address']);
        }
    }
    return $results;
    }
    
    function 
getDistance($CurrentUserAddress$otherUserAddress$unit 'k'){
    
    // Google API key
    
    $apiKey 'AIzaSyBRMLF9pK8EoY-wOnp1_N1uZ7pH6fOnlLQ';
    
    
        
// Change address format
    
    $formattedAddrFrom    str_replace(' ''+'$CurrentUserAddress);
    
    $formattedAddrTo     str_replace(' ''+'$otherUserAddress);
    
    
        
// Geocoding API request with start address
    
    $geocodeFrom file_get_contents('https://maps.googleapis.com/maps/api/geocode/json?address='.$formattedAddrFrom.'&sensor=false&key='.$apiKey);
    
    $outputFrom json_decode($geocodeFrom);
    
    if(!empty($outputFrom->error_message)){
    
        return $outputFrom->error_message;
    
    }
    
    
        
// Geocoding API request with end address
    
    $geocodeTo file_get_contents('https://maps.googleapis.com/maps/api/geocode/json?address='.$formattedAddrTo.'&sensor=false&key='.$apiKey);
    
    $outputTo json_decode($geocodeTo);
    
    if(!empty($outputTo->error_message)){
    
        return $outputTo->error_message;
    
    }
    
    
        
// Get latitude and longitude from the geodata
    
    $latitudeFrom    $outputFrom->results[0]->geometry->location->lat;
    
    $longitudeFrom    $outputFrom->results[0]->geometry->location->lng;
    
    $latitudeTo        $outputTo->results[0]->geometry->location->lat;
    
    $longitudeTo    $outputTo->results[0]->geometry->location->lng;
    
    
        
// Calculate distance between latitude and longitude
    
    $theta    $longitudeFrom $longitudeTo;
    
    $dist    sin(deg2rad($latitudeFrom)) * sin(deg2rad($latitudeTo)) +  cos(deg2rad($latitudeFrom)) * cos(deg2rad($latitudeTo)) * cos(deg2rad($theta));
    
    $dist    acos($dist);
    
    $dist    rad2deg($dist);
    
    $miles    $dist 60 1.1515;
    
    
        
// Convert unit and return distance
    
    $unit strtoupper($unit);
    
    if($unit == "K"){
    
        return round($miles 1.6093442);
    
    }elseif($unit == "M"){
    
        return round($miles 1609.3442);
    
    }else{
    
        return round($miles2);
    
    }
    } 
My view: to view the km less than 10.00km
PHP Code:
print_r(Addresses($this->session->userdata('address')));
i get this 

Array 
PHP Code:

PHP Code:
    [0] => 1.31 
PHP Code:
    [1] => 1.85 
PHP Code:
    [2] => 3.15 
PHP Code:
    [3] => 
PHP Code:
    [4] => 1.84 
PHP Code:
    [5] => 1.54 
PHP Code:

i tried this to get all users data with less than 10 km but it just gives me all users 

PHP Code:
    function Addresses($CurrentUserAdd){
        
$CI =& get_instance();
    $CI->db->where(getDistance($CurrentUserAdd'address') <= 10.00);
    $query $CI->db->get('users');
    return $query->result_array();
    } 
i just want to recommend users closer to the currently logged in user
Please help thanks in advance.

How to get the last Inserted ID after insert data using the query builder ?

$
0
0
Hello !

Does anyone knows how to get the last Inserted ID after insert data using the query builder class?

In CI 3 I just used:
PHP Code:
$this->db->insert_id(); 

What would be the equivalent in CI 4 ?

PHP Code:
    public function insertNewCandidate($candidate) {

        $db      = \Config\Database::connect();
        $builder $db->table('dados_candidates');
        
        $query 
$builder->insert($candidate);

        if( $query ):
            
            
return ?????????????;
            
        
else: 

            return FALSE;
            
        
endif;
        
    


And YES, I do want to use query builder for this... 

I tried to find it in $db, $builder and $query... But it is not there....

trouble sending email controller

$
0
0
hi 
a bit of a novice, but can anyone give me an idea what might be wrong in this code? 
when submit button is pressed, there is no message or email sent ... 

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class ContactUs extends MY_Controller
{
function __construct()
{
parent::__construct();
//$this->load->model('front/homepage_model');
}

public function index()
{  
if(isset($_POST['submit']) && $_POST['submit'] == 'Contact1')
{
$name          = $this->input->post('name');
            $email        = $this->input->post('email');
            $message      = $this->input->post('msg');
            $subject      = $this->input->post('subject');
            $main_msg =`<b>Name : </b>`.$name.`  <br> <b>Email : </b> `.$email.` <br> Message : `.$message.``;
            $to      = 'sales@xxx.com';
            $subject      = 'Mail From [color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]@xxx.com[/font][/size][/color]';
            $headers = "From: sales@[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]xxx.com[/font][/size][/color].biz \r\n";
            $headers .= "Reply-To: sales[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]@xxx.com[/font][/size][/color] \r\n";
            $headers .= 'Content-type:text/html; charset=ISO-8859-1\r\n';
            $headers .= 'MIME-Version: 1.0' . "\r\n";
            $mail    = $this->send_mail($to, $subject, $main_msg, $headers,$email);           
            if ($mail)
            {
                $this->session->set_flashdata('message', '<div class="alert alert-danger alert-dismissable fade in" style="color: #f1f1f1; background-color: #f25c27;"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Thank You</strong> Your order request has been submited successfully, We will notify you soon.</div>');
                redirect(base_url('contactUs'));
            }
            else
            {
                $this->session->set_flashdata('message', '<div style="color: #f1f1f1; background-color: #f25c27;" class="alert alert-success alert-dismissable"><i class="fa fa-check"></i><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button><b> <strong>Sorry!</strong> Try out after some time, we cant process your request for  this time.</b></div>');
                redirect(base_url('contactUs'));
            }
}
  $this->show_view_front('front/contact_us',$this->data);

    }

}
/* End of file */
?>

Thank you

**EDIT: code tags added for readability**

What causes this “Missing argument 2 for Categories::posts()” error?

$
0
0
I am working on a small blogging application. There is a clear separation between its back-end and its front-end.
The back-end is an [b]API[/b], made with Codeigniter 3, that spits out pages, posts, pagination etc.


In this API, the [b]Categories[/b] controller displays, among others, [i]post by category[/i]:



Code:
public function posts($path, $category_id) {
    //load and configure pagination
    $this->load->library('pagination');
    $config['base_url'] = "http://".$_SERVER['HTTP_HOST'] . $path;
    $config['base_url'] = base_url('/categories/posts/' . $category_id);
    $config['query_string_segment'] = 'page';
    $config['total_rows'] = $this->Posts_model->get_num_rows_by_category($category_id);
    $config['per_page'] = 12;

    if (!isset($_GET[$config['query_string_segment']]) || $_GET[$config['query_string_segment']] < 1) {
        $_GET[$config['query_string_segment']] = 1;
    }

    $limit = $config['per_page'];
    $offset = ($this->input->get($config['query_string_segment']) - 1) * $limit;
    $this->pagination->initialize($config);

    $data = $this->Static_model->get_static_data();
    $data['pagination'] = $this->pagination->create_links();
    $data['pages'] = $this->Pages_model->get_pages();
    $data['categories'] = $this->Categories_model->get_categories();
    $data['category_name'] = $this->Categories_model->get_category($category_id)->name;
    $data['posts'] = $this->Posts_model->get_posts_by_category($category_id, $limit, $offset);

    // All posts in a CATEGORY
    $this->output->set_content_type('application/json')->set_output(json_encode($data,JSON_PRETTY_PRINT));
}

The code above has a bug who's cause I can not find. The error message the application throws is:

Code:
Missing argument 2 for Categories::posts()

Where is my mistake?

Tell me how to correctly implement the translation in the likeness of Laravel

$
0
0
I have expanded the core of Lang.php

PHP Code:
class MY_Lang extends CI_Lang
{
    public 
$config;
    public function 
__construct()
    {
        
parent::__construct();
        
$this->config =& get_config();
    }
    public function 
lo()
    {
        
$json_arr = array();
        
$lan substr($this->config['language'], 02);
        
$deft_lang = (get_cookie('lang') != $lan) ? get_cookie('lang') : $lan;
        
set_cookie('lang'$deft_lang,93062220);
        
$patch APPPATH.'language/'.$deft_lang.'.json';
        if(
file_exists($patch))
        {
            
$json file_get_contents($patch);
            
$json_arr json_decode($jsontrue);
        }
        return 
$json_arr;
    }

and created a helper and added it to the auto connection.

PHP Code:
if ( ! function_exists('__')) {
    function 
__($mess$var '')
    {
        
$CI =& get_instance();
        
$lang $CI->lang->lo();

        if (!empty(
$lang)) {
            if (
array_key_exists($mess$lang))
                
$mes $lang[$mess];
            else 
$mes $mess;
        } else 
$mes $mess;

        return 
str_replace("%%s%%"$var$mes);
    }

and call me in the right place like this.

Code:
<h1><?php echo __('Welcome to CodeIgniter!');?></h1>

Code:
<p><?php echo __('If you are exploring CodeIgniter for the very first time, you should start by reading the %%s%%.','<a href="user_guide/">'.__('User Guide').'</a>');?></p>
can see how it can be implemented even better.

Make a normal translation for a site similar to Laravel

$
0
0
A question for developers, you can implement the translation of the application in a similar manner as in Laravel so that you can call a simple function __ ('translation', parameter) from anywhere. Because it’s not very convenient to create arrays of translation, for example, how you implemented


PHP Code:
return [
   'commandNotFound' => 'Команда "{0}" не найдена.',
   'helpUsage'       => 'Использование:',
   'helpDescription' => 'Описание:',
   'helpOptions'     => 'Опции:',
   'helpArguments'   => 'Аргументы:',
   'invalidColor'    => 'Недопустимый {0} цвет: {1}.',
]; 



and do like this




PHP Code:
return [
    
'Uso:'          => 'Использование:',
    
'Descripción:'  => 'Описание:',
    
'Opciones:'     => 'Опции:',
    
'Argumentos:'   => 'Аргументы:',
    
'Inválido {0} color: {1}.'    => 'Недопустимый {0} цвет: {1}.',
]; 

and then call us like this __ ('Opciones:') anywhere

Need help with CSS

$
0
0
Hello everyone,

Among several open-source shopping carts, I chose one based on CI found on GitHub for my e-commerce project but now stuck with a sidebar navigation menu. I have searched the web but cannot find a way to style my menu to display and organize content like menu that will open to the right and display all sub-menus in rows and columns.

What I have actually achieved with some CSS tweaks is a tree view (vertical) menu but what I want is make each category, upon hover, display sub-menus in a row/column (horizontal) within a single big table. Fact is because of the database-driven categories nature of CI, I'm  not even sure which chunks of code to present here, so not to overwhelm anyone. Any help is greatly appreciated and I hope, most importantly to be able to learn how to maintain the code, how each part works because I love it.

This is what I have:
Category 1

Sub1
    Item1
Sub2
    Item2
Sub3
    Item3
Sub4
    Item4

Category 2

Sub1
    Item1
Sub2
    Item2
Sub3
    Item3
Sub4
    Item4


This is what I want:
Category 1 Sub1  Sub2  Sub3  Sub4
                  Item1  Item2  Item3  Item4 


Category 2 Sub1  Sub2  Sub3  Sub4
                  Item1  Item2  Item3  Item4



Homepage VIEW:
Code:
<div id="nav-categories">
<?php

function loop_tree($pages, $is_recursion = false)
{
?>
<ul class="<?= $is_recursion === true ? 'children' : 'parent' ?>">
<?php
foreach ($pages as $page) {
$children = false;
if (isset($page['children']) && !empty($page['children'])) {
$children = true;
}
?>
<li>
<?php if ($children === true) {
?>
<i class="fa fa-chevron-right" aria-hidden="true"></i>
<?php } else { ?>
<i class="fa fa-circle-o" aria-hidden="true"></i>
<?php } ?>
<a href="javascript:void(0);" data-categorie-id="<?= $page['id'] ?>" class="go-category left-side <?= isset($_GET['category']) && $_GET['category'] == $page['id'] ? 'selected' : '' ?>">
<?= $page['name'] ?>
</a>
<?php
if ($children === true) {
loop_tree($page['children'], true);
} else {
?>
</li>
<?php
}
}
?>
</ul>
<?php
if ($is_recursion === true) {
?>
</li>
<?php
}
}

loop_tree($home_categories);
?>
</div>



CSS:
Code:
div.filter-sidebar {
margin-bottom : 30px;
}
div.filter-sidebar .title, .title.alone {
font-size : 18px; line-height : 1; margin : 0 0 10px; padding : 0;
}
div.filter-sidebar .title span, .title.alone span {
border-bottom : 3px solid #8c0707; color : #666; display : inline-block; margin-bottom : -3px; padding-bottom : 10px;
}
div.filter-sidebar ul {
list-style : none; padding : 0px; z-index : 1;
}
div.filter-sidebar ul li, div.filter-sidebar ul li a {
margin-bottom : 1px;
}
div.filter-sidebar ul li a {
color : #6d6d6d; display : inline-block; font-size : 13px;
}
div.filter-sidebar ul li a.selected, div.filter-sidebar ul li a:hover {
color : #1e88e5;
}
div.filter-sidebar ul.children {
padding-left : 13px;
}
div.filter-sidebar ul.parent i, div.filter-sidebar ul.children i {
font-size : 10px;
}
div.filter-sidebar .title a.clear-filter, div.filter-sidebar .title i {
color : #666; float : right;
}


ul {
padding: 1em;
text-decoration: none;
color: #fff;
}

ul li ul {
background: #fafafa;
visibility: hidden;
opacity: 0;
min-width: 20rem;
position: relative;
transition: all 1s ease;
margin-top: 2rem;
left: 0;
display: none;
}

ul li:hover > ul, ul li ul:hover {
visibility: visible;
opacity: 1;
display: block;
}

li:hover ul {
display: block;
position: absolute;
left: 90px;
top: 1;
}

li:hover>ul {
display: block;
margin: 0;
padding: 0 10px;
}

Thank you.

**EDIT: added code tags for readability. Poster: see https://forum.codeigniter.com/misc.php?a...help&hid=7 **

Redirect inside Constructor NOT WORKING

$
0
0
Hello All,

I need help with a explanation on WHY a "return redirect->to()" wont work inside a constructor...

This wont work:

PHP Code:
    public function __construct()
    {
        return 
redirect()->to('http://www.google.com');
    }


    public function 
index()
    {
        echo 
'Hello World!!!!!';
    } 
 
This will work:

PHP Code:
    public function __construct()
    {
        
    }


    public function 
index()
    {
        return 
redirect()->to('http://www.google.com');
        
        echo 
'Hello World!!!!!';
    } 

Of course this is only a example and I will have some logic inside the constructor, like: if(NotLogged){ redirect() }

Thank you for the explanation...

Ajax in CI

$
0
0
Dear all,
i started 2 years ago writting with CI (i write code in php for > 25Years). I loved the power of Smarty - xajax/Jaxon - Swift. I managed to integrate all of them into CI (plus the hiding of /applications;/core; and so on).
Last year i try to update the part of Jaxon-php, but i have no success. Until the version of 2.0-beta28 works, but now newer one.
Now i try it again and i strucle on the same problem (never mind here). The developer from jaxon-php (better for jaxon-php/codeigniter) give no response over a year....

So i looked for a alternate for writing AJAX-Application in CI and wonder if all recommendations goes into native JQuery-Ajax-Calls. For a simple Ajax-Call in JQuery i need to wrote 16 Lines of Code in the template (i got it from a example Smile ).
To be honest: i like to write PHP-Code, but not more JQuery-Code as needed Angel

My lines of codes shows like this:

PHP Code:
// Initialize of Controller where a AJAX-Call is done after the template is rendered (onload)
// Jaxon.App is the automated genereated JS-Function-Namespace
// auswertungen_austria_ajax is the php-file where the Response-Class is in
// hole_liste(true) is a public method in the Response-Class (hole_liste = get_list in german)
 
public function Austritt() {
        $this->jaxon->register();
        $this->smarty->assign("seek_opt",array());
        $this->smarty->assign("zus_BodyOnl","Jaxon.App.auswertungen_austritt_ajax.hole_liste(true);");
        
        $this->smarty->view('benutzer-listenAustritt2-index.tpl', array(
            'jaxonCss' => $this->jaxon->css(),
            'jaxonJs' => $this->jaxon->js(),
            'jaxonScript' => $this->jaxon->script(),
        ));

PHP Code:
// Method of a response class to answer a request...
// with the response i can assign into elements whatever it needs - independent which template is used
// and i can call other functions in the class over javascript (from the client site)
// Jaxon.App = the generated functions from Jaxon
// auswertungen_ajax = the Class file for the Response
// refresh_table() = the public method that is called

public function icon_set($id) {
    
$temp $this->ci->da_workstep_model->get($id);
    
$content $this->ci->smarty->fetch("anw_detail_approved.tpl",["i" => $temp,"id" => $id]);

    
$this->response->assign("icon_workstep_approved_".$id,"innerHTML",$content);
        $this->response->script("Jaxon.App.auswertungen_ajax.refresh_table();");

PHP Code:
// Smarty-Template to send a response to the server side from a single "onchange" ...
// domains_ajax is the Class-File for Jaxon-Response
// rech_pos_add is the public method in the class
{strip}
<
select name=domain id=domain onchange="Jaxon.App.domains_ajax.rech_pos_add(this.value);">
    <
option value=0>{LP_say('-- Bitte auswählen--')}</option>
    {
html_options options=$arr_domain_liste selected=$dom_id}
</
select>
{/
strip

The example above has no interaction between, but should explain what i mean.
I have all changes of data in the place where it should be and have not struggle with different template-files (where the JQuery-Code for a AJAX-Request has to be, as i understand).
In my usage, i have only to know what the name of the field (element-ID) is, where i like to place data into.... (of course - most of the time i give the response-method the name as parameter where i like to insert the requested data Rolleyes )

So - my question is:
Is there a convenient AJAX-Library that gives the focus back to writing PHP-Code without the need the usage/learning of JQuery/Javascript ?
I searched the last weeks around, but had no real success. The last promising result i found is from Mr. ajaxboy (its called cjax), but his library is slited in Version 5.9 over to 2 years...

Could someone give me a glue ?
Help for upgrading jaxcon-core to the current 2.2.6 is also welcome Smile (it´s a real cool tool, but 2 year old code is a loose cannon Dodgy )
kr Tom

Problem with Model()->find() and Model()->findAll()

$
0
0
Hi! I have faced with problem with Model()->find() and Model()->findAll(). If i call ones of this methods i get null. It's doesn't work after update to 4.0.0-rc.2.1 with composer.

For example, i have model UserModel witch based on BaseModel witch extends Model. 

PHP Code:
class UserModel extends BaseModel
{

    private $user_uploads_dir;

    private $user_avatar_uri;

    protected $table      'users';

    protected $primaryKey 'id';

    protected $returnType 'array';

    protected $useTimestamps true;

    protected $dateFormat 'int';

    protected $createdField  'created';

    protected $updatedField  null;

    protected $deletedField 'deleted';

    protected $useSoftDeletes true;



Table users has 1 row with id = 1
When i try to get row from DB with find() or findAll() i get Null result. I don't known why it's happening.

PHP Code:
$items = (new UserModel())->find(1); // will be null 


PHP Code:
$items = (new UserModel())->where('id'1)->get()->getRowArray(); // will be array with user data 

Tell me, please, what i doing wrong? I created issue on github.com, but jimm-parry redirect me to this forum. 

Is there a CodeIgniter 3.x roadmap?

$
0
0
Good evening everyone.

With the upcoming release of CI4, I am wondering if there are any plans to keep adding features to the CI3 codebase?  I am also wondering what the lifecycle of CI3 will be once CI4 is released.  Will a new project built with CI3 today need to be migrated to CI4 in very short order or will there be some CI3 security releases post CI4?

Thanks

Fatal Memory Error in version 3.1.6+

$
0
0
I have never been able to migrate from 3.1.5 to 3.1.6 because of the following error

==================
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in /var/www/html/rtsusers/system/core/Loader.php on line 1205

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in Unknown on line 0

===================

I discovered that the problem lies in the file /system/core/Loader.php

If I edit everything in the /system/core/Loader.php in the version 3.1.5 to look like /system/core/Loader.php in 3.1.11 then all edits cause no problem except the following in the new version.

Code:
// =========== from line 1046... /system/core/Loader.php in 3.1.11 CAUSES FATAL MEMORY ERROR ===========
// Safety: Was the class already loaded by a previous call?
if (class_exists($class, FALSE))
{
$property = $object_name;
if (empty($property))
{
$property = strtolower($class);
isset($this->_ci_varmap[$property]) && $property = $this->_ci_varmap[$property];
}

$CI =& get_instance();
if (isset($CI->$property))
{
log_message('debug', $class.' class already loaded. Second attempt ignored.');
return;
}

return $this->_ci_init_library($class, '', $params, $object_name);
}

// Let's search for the requested library file and load it.
foreach ($this->_ci_library_paths as $path)
{
// BASEPATH has already been checked for
if ($path === BASEPATH)
{
continue;
}

$filepath = $path.'libraries/'.$subdir.$class.'.php';
// Does the file exist? No? Bummer...
if ( ! file_exists($filepath))
{
continue;
}

include_once($filepath);
return $this->_ci_init_library($class, '', $params, $object_name);
}

Code:
// =========== /system/core/Loader.php in 3.1.5 WORKS WITHOUT ANY PROBLEM ===========

// Let's search for the requested library file and load it.
foreach ($this->_ci_library_paths as $path)
{
// BASEPATH has already been checked for
if ($path === BASEPATH)
{
continue;
}

$filepath = $path.'libraries/'.$subdir.$class.'.php';

// Safety: Was the class already loaded by a previous call?
if (class_exists($class, FALSE))
{
// Before we deem this to be a duplicate request, let's see
// if a custom object name is being supplied. If so, we'll
// return a new instance of the object
if ($object_name !== NULL)
{
$CI =& get_instance();
if ( ! isset($CI->$object_name))
{
return $this->_ci_init_library($class, '', $params, $object_name);
}
}

log_message('debug', $class.' class already loaded. Second attempt ignored.');
return;
}
// Does the file exist? No? Bummer...
if ( ! file_exists($filepath))
{
continue;
}

include_once($filepath);
return $this->_ci_init_library($class, '', $params, $object_name);
}

Please help me.

EDIT: code tags added for readability. See MyCode

.php   YESworking.php (Size: 36.26 KB / Downloads: 0)

.php   NOTworking.php (Size: 36.21 KB / Downloads: 0)

.html   ERRORmessage.html (Size: 273 bytes / Downloads: 0)

display list file ftp

$
0
0
help me how to display files in the cpanel folder using ftp

localhost causes "Index of /" page

$
0
0

Namespaces duplicated

$
0
0
Hi,
I am struggling with a very strange problem. When I try to use in my controller app/Config/Email.php class from my app directory, somehow the Class: vendor/codeigniter4/framework/app/Config/Email.php is used instead!

My environment:
1. Codeigniter 4 RC.2 installed with Composer.
2. My $psr4 in Config/Autoload.php is like:
Code:
$psr4 = [
            'Config'      => APPPATH . 'Config',
            APP_NAMESPACE => APPPATH,                // For custom namespace
            'App'         => APPPATH,                // To ensure filters, etc still found,
];
3. My Controller is:
PHP Code:
use Config\Email;
// I tried also \Config\Email and App\Config\Email - same result

....

$config = new Email(); 

I haven't find similar issue in the forum yet. Very thanks for any help.

How to have more detailed error

$
0
0
In CI3 We had lines or error

now with CI4 I only have Whoops!

We seem to have hit a snag. Please try again later...

And I know something is wrong but I have no idea where to search.

How to have like CI3  error lines

hey i need helpe asp please with this error 1048

$
0
0
in my gratuadion work, i have this error in de sing in function(cadastrar) i dunno know why  ever time i try  a error mensage shows up (error 1048)

the controllerSad
public function cadastrar(){
  $this->load->model("usuarios_model");
  $this->usuarios_model->cadastro($usuario);

})

and the model(
public function cadastro($usuario)
  {
    $this->db->insert("tempusuarius",$usuario);


  })

and the php file(
<?php
        echo"<h1>cadastre-se</h1>";
        echo form_open("usuarios/novo");
        echo form_label('Nome','nome');
        echo form_input( array('Name' =>'nome' ,'id'=>'nome', 'maxlength'=>'255', 'class'=>'form-control' ));
        echo"<br>";
        echo form_label('Email','e-mail');
        echo form_input(array('name' =>'e-mail' ,'id'=>'e-mail','maxlength'=>'255','class'=>'form-control' ));
        echo"<br>";
        echo form_label('Senha','senha');
        echo form_password(array('name' =>'senha' ,'id'=>'senha','maxlength'=>'255','class'=>'form-control' ));
        echo"<br>";
        echo form_button(array('class' =>'btn btn-primary' ,'content'=>'cadastrar','type'=>'submit' ));
      echo form_close();?>

variables de sesión

$
0
0
Estoy usando un proyecto con varios scripts (cada uno para diferentes proceso), puedo usar variables de sesión en estos diferentes scripts.

Debug is breaking my JSON... How to disable it from some methods ?

$
0
0
Hi everyone !

The debug is breaking my JSON return....

Since my app is heavily based on JSON returns, I decided to keep it in a view file.

The problem is that CI is adding a html comment on it !

PHP Code:
    public function jsonFormAdd()
    {

        
$data = array();

        
$returnView view('ExpAdmin/ExpData/Candidates/Json/formAdd'$data);

        return 
$this->response->setJSON($returnView);

    } 

 The json:

Code:
<!-- DEBUG-VIEW START 1 APPPATH/Config/../Views/ExpAdmin/ExpData/Candidates/Json/formAdd.php -->
[{"tabs":false,"titulo":"Adicionar Candidate","method":"post","botoes":true,"id":"novoCandidate","action":"candidates\/processa_formulario_adicao","csrf":0,"csrf_name":0,"classes":["form_input","input"],"sections":[{"fields":[{"tipo":1,"name":"stName","legenda":"Name","ajuda":"Full Name","classes":"","required":true},{"tipo":1,"name":"stEmail","legenda":"Email","ajuda":"","classes":"email ","email":1,"required":true},{"tipo":1,"name":"stAddressOne","legenda":"Address 1","ajuda":"","classes":"","required":true},{"tipo":1,"name":"stAddressTwo","legenda":"Address 2","ajuda":"","classes":""},{"tipo":1,"name":"stCity","legenda":"City","ajuda":"","classes":"","required":true},{"tipo":1,"name":"stPostalCode","legenda":"Postal Code","ajuda":"","classes":""},{"tipo":1,"name":"stCountry","legenda":"Country","ajuda":"","classes":""},{"tipo":1,"name":"stPhone","legenda":"Phone","ajuda":"","classes":""}]}]}]
<!-- DEBUG-VIEW ENDED 1 APPPATH/Config/../Views/ExpAdmin/ExpData/Candidates/Json/formAdd.php -->

How to disable the toolbar there ? Thank you !
Viewing all 14239 articles
Browse latest View live


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