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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 23,059
» Latest member: reyzwee14
» Forum threads: 73,113
» Forum posts: 374,269

Full Statistics

Latest Threads
Admin Panel for website
Forum: General Help
27 minutes ago
» Replies: 1   » Views: 34
"Class 'App\Models\UserMo...
Forum: CodeIgniter 4 Support
2 hours ago
» Replies: 2   » Views: 55
HTTPS site losing PHP con...
Forum: CodeIgniter 4 Support
4 hours ago
» Replies: 0   » Views: 23
A way to override the ins...
Forum: CodeIgniter 4 Feature Requests
5 hours ago
» Replies: 5   » Views: 176
Why the $this->find( $id ...
Forum: CodeIgniter 4 Support
7 hours ago
» Replies: 4   » Views: 1,223
Helper - Call to undefine...
Forum: General Help
Today, 09:33 AM
» Replies: 7   » Views: 684
Best practice in SEO
Forum: Best Practices
Today, 07:49 AM
» Replies: 2   » Views: 138
Why would I choose Nginx ...
Forum: General Help
Today, 02:51 AM
» Replies: 1   » Views: 149
PHP warning not logged in...
Forum: CodeIgniter 4 Support
Today, 01:57 AM
» Replies: 3   » Views: 107
is_ajax_request() doesn't...
Forum: Issues
Today, 01:44 AM
» Replies: 2   » Views: 1,862

 
  adding an .ico image
Posted by: richb201 - 02-24-2021, 02:05 PM - Forum: General Help - Replies (2)

How can I add an ico image? When I save a bookmark of this CI tab, the CI "flame" appears in front of the name. How do I set it so when a user bookmarks my app, my ico appears under bookmarks?


  buggy debug bar since I put logic in the manager
Posted by: filit - 02-24-2021, 10:24 AM - Forum: CodeIgniter 4 Support - No Replies

Hi,
I had a website with all the business logic inside the controller. 
I only had controllers and models, but controllers had too much code

So, following the best practices I read on codeigniter.com website and inside Codeigniter Foundation book, I decided to move some code into a Manager class, inside App/Libraries, to have a cleaner code and easier to reuse.

The website runs correctly and does everything as before, but now in the debug bar I cannot see Database queries any more.
Also, the VIEWS tab shows 0, as if there weren't views...but if I click VIEWS then the views are correctly highlighted.

Did anyone experience same issue and know how to solve it? Could it be related to the fact that I load the manager class through a service?

Thank you

Filippo


  Top PHP Frameworks in 2021
Posted by: php_rocs - 02-24-2021, 09:29 AM - Forum: Lounge - Replies (2)

Check out the list (especially CI). https://kinsta.com/blog/php-frameworks/#codeigniter


Sad Message: Call to a member function row() on bool
Posted by: IndexError - 02-24-2021, 02:46 AM - Forum: Issues - No Replies

Hello guys, 

I have using Amazon AWS, and wasnt having any problem, but in order to save some money I tried InfinityFree and I'm getting this error.

The error:
An uncaught Exception was encountered
Type: Error
Message: Call to a member function row() on bool
Filename: htdocs/application/models/Twilio_model.php
Line Number: 32
Backtrace:
               File: htdocs/application/controllers/Auth.php
               Line: 705
               Function: send_sms

               File: htdocs/index.php
               Line: 318
               Function: require_once

A PHP Error was encountered
Severity: Warning
Message: session_write_close(): Failed to write session data using user defined save handler. (session.save_path: /php_sessions)
Filename: Unknown
Line Number: 0
Backtrace:

Fatal error: Uncaught Error: Call to a member function row() on bool in htdocs/system/libraries/Session/drivers/Session_database_driver.php:424
Stack trace: #0 /htdocs/system/libraries/Session/drivers/Session_database_driver.php(281): CI_Session_database_driver->_release_lock()
#1 [internal function]: CI_Session_database_driver->close()
#2 [internal function]: session_write_close()
#3 {main} thrown in 
htdocs/system/libraries/Session/drivers/Session_database_driver.php on line 424


The code of the Twilio_model.php

<?php
defined('BASEPATH') or exit('No direct script access allowed');
// Load the autuloader
require_once FCPATH . './vendor/autoload.php';
use Twilio\Rest\Client;

class Twilio_model extends CI_Model {
    
    private $sid;
    private $token;
    public function __construct()
    {
        parent::__construct();
        $this->db->select('*');
        $this->db->from('tbl_addons_api');
        $this->db->where('name''Twilio');
        $query = $this->db->get();

        //SID and Token Info
        $this->SID = $query->row('public_key');
        $this->token = $query->row('secret_key');

    }

    public function send_sms($phone$body)
    {
        $this->db->select('*');
        $this->db->from('tbl_settings');
        $this->db->where('type''sms_active');
        $result = $this->db->get();

        if($result->row('value') != 0) {
            $this->db->select('*');
            $this->db->from('tbl_settings');
            $this->db->where('type''sms_phone');
            $from_number = $this->db->get()->row('value');

            // Reciever's phone number
            $phone_number = $phone;

            // Create Twilio client
            $client = new Client($this->SID$this->token);

            try{
                $client->messages->create(
                $phone_number,
                  array(
                      'from' => $from_number,
                      'body' => $body
                  )
                );
                //sent successfully
                $response = TRUE;
            }catch(Exception $e){
                //echo $e->getCode() . ' : ' . $e->getMessage()."<br>";
                $response = FALSE;
            }

            return $response;
        }
    }

}
And Session_database_driver.php from line 406

// ------------------------------------------------------------------------

    /**
     * Release lock
     *
     * Releases a previously acquired lock
     *
     * @return  bool
     */
    protected function _release_lock()
    {
        if ( ! $this->_lock)
        {
            return TRUE;
        }

        if ($this->_platform === 'mysql')
        {
            //print_r($result);
            if ($this->_db->query("SELECT RELEASE_LOCK ( '".$this->_lock."' ) AS ci_session_lock")->row()->ci_session_lock)
            {
                $this->_lock = FALSE;
                return TRUE;
            }

            return FALSE;
        }
        elseif ($this->_platform === 'postgre')
        {
            if ($this->_db->simple_query('SELECT pg_advisory_unlock('.$this->_lock.')'))
            {
                $this->_lock = FALSE;
                return TRUE;
            }

            return FALSE;
        }

        return parent::_release_lock();
    }
}

I think thats enough and hope somebody can help me out


  conflict with method name
Posted by: eleumas - 02-23-2021, 02:20 PM - Forum: CodeIgniter 4 Support - Replies (3)

Hi! i use localization in CI 4.1.1. I have a controller for each language and inside any controller there is a method called blog.

Method blog in italian controller:

PHP Code:
    public function blog()
    {
        
$data['title'] = 'blog in italian';
        
$data['articles'] = $this->articlesModel->orderBy('id''DESC')->where('status'1)->where('lang''it')->findAll();
        
$data['categories'] = $this->categoriesModel->where('lang''it')->findAll();

        echo 
view('blog'$data);
    } 

Method blog in english controller:
PHP Code:
    public function blog()
    {
        
$data['title'] = 'blog in english';
        
$data['metaDescription'] = '';
        
$data['articles'] = $this->articlesModel->orderBy('id''DESC')->where('status'1)->where('lang''en')->findAll();
        
$data['categories'] = $this->categoriesModel->where('lang''en')->findAll();

        echo 
view('blog'$data);
    } 

My routes:

PHP Code:
$routes->add('{locale}/blog''It/Main::blog');
$routes->add('{locale}/blog''En/Main::blog'); 

The result is always the same..it is called only the method blog in "italian controller". 
Codeigniter show the first route found, so in this case for the "italian controller".

Thanks for the support.


  Large file upload results in 403 error
Posted by: kyle - 02-23-2021, 01:44 PM - Forum: CodeIgniter 4 Support - Replies (6)

I am troubleshooting my file upload with no success. I have a form that is submitted via AJAX and if a user tries to upload a file that is larger than the upload_max_filesize setting codeigniter will throw a 403 error. Specifically:

PHP Code:
CodeIgniter\Security\Exceptions\SecurityExceptionThe action you requested is not allowed

Currently my max filesize is set to 8M and my file upload validation is at 4M. I am only handling small PDF files that should be no larger than 500KB. If the file supplied is smaller than the upload_max filesize (8M) setting but above what I have specified (4M) my code will handle the large file like it should and show the user an error message but anything above 8M results in the generic Codeigniter 403 error above. Since the exception is thrown before my handler even executes there is so far nothing I have found that I can do.

Realistically, there is no reason for someone to attempt to upload a 8M (or larger) file but I would like to be able to handle the error properly and show a "File is too large" message instead of showing a generic 403 error to the user. Is there anything I am missing or is this something that needs to be fixed in the Framework?


  view cache option doesn't work
Posted by: viracoders - 02-23-2021, 11:28 AM - Forum: CodeIgniter 4 Support - Replies (2)

I have this controller and need to cache view using options method:

PHP Code:
    public function index()
    {
        
helper('text');
        
$settings service('settings');
        
        
$data = array(
            
'title' => $settings->siteMetaTitle,
            
'meta_description' => $settings->siteMetaDescription,
            
'meta_keywords' => $settings->siteMetaKeywords,
        );

        return 
view('index'$data, ['cache'120]);
    } 

But in action I check cache folder but I cant see any cache file. how do can I cache view?

Note: I know, I can work with $this->cachePage($n); method, But in action I need to work with view options method.


  Passing URI Segments to methods
Posted by: eleumas - 02-23-2021, 11:12 AM - Forum: CodeIgniter 4 Support - Replies (3)

Hi! I have a view with this link: 

Code:
<a href="<?php echo base_url('en/article/'.$slug);?>"> Article Title </a>

.tb_button {padding:1px;cursor:pointer;border-right: 1px solid #8b8b8b;border-left: 1px solid #FFF;border-bottom: 1px solid #fff;}.tb_button.hover {borer:2px outset #def; background-color: #f8f8f8 !important;}.ws_toolbar {z-index:100000} .ws_toolbar .ws_tb_btn {cursor:pointer;border:1px solid #555;padding:3px} .tb_highlight{background-color:yellow} .tb_hide {visibility:hidden} .ws_toolbar img {padding:2px;margin:0px}
I would like pass the $slug variable to my method named article but i have an error: Too few arguments to function App\Controllers\En\Main::article(), 0 passed in...

My method:

PHP Code:
public function article($slug)
{
$data['article'] = $this->articlesModel->where('slug'$slug)->first();

// OTHER... 
I have read here: https://codeigniter.com/userguide4/incom...ur-methods 

Someone can help me please? Thanks.


  Add new functions to Redis Handler
Posted by: eelisland - 02-23-2021, 10:03 AM - Forum: CodeIgniter 4 Support - Replies (3)

What is the proper way to add thoses function to the Redis Handler whithout writing it in the System\Cache\Handlers\RedisHandler.php file ?

PHP Code:
    public function getKeysstring $keys "*" )
    {
        return 
$this->redis->keys($keys);
    }

    
//--------------------------------------------------------------------
    
    
public function delWildcardstring $keys )
    {
        if (!
$keys || $keys === "*") return false;
        
        
$this->redis->del(
            
$this->redis->keys($keys)
        );
    } 

I read this from the Documentation here https://codeigniter4.github.io/userguide...asses.html but i have to admit that i don't fully understand how it work.

Can anyone describe me how i can do please ?


  Where in code validate/sanitize inputs?
Posted by: Acuru - 02-23-2021, 09:40 AM - Forum: Model-View-Controller - Replies (3)

What is the best practice to put validation/sanitization logic? In controllers or rather in models? Since from what i understand, controllers operate on users demands and accepts input from them i guess that would be for me logical place to process data there, and keep models for interworking, when data is safe already, but then, i can use same model function for sanitizing data in multiple places. I am kinda new to MVC, and since i am self-taught I am missing so some basic concepts :X

I searched forum but closest answer was posted years ago.



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