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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 23,061
» Latest member: simeonhollis
» Forum threads: 73,113
» Forum posts: 374,269

Full Statistics

Latest Threads
Admin Panel for website
Forum: General Help
1 hour ago
» Replies: 1   » Views: 37
"Class 'App\Models\UserMo...
Forum: CodeIgniter 4 Support
3 hours ago
» Replies: 2   » Views: 56
HTTPS site losing PHP con...
Forum: CodeIgniter 4 Support
5 hours ago
» Replies: 0   » Views: 27
A way to override the ins...
Forum: CodeIgniter 4 Feature Requests
6 hours ago
» Replies: 5   » Views: 177
Why the $this->find( $id ...
Forum: CodeIgniter 4 Support
8 hours ago
» Replies: 4   » Views: 1,223
Helper - Call to undefine...
Forum: General Help
Today, 09:33 AM
» Replies: 7   » Views: 685
Best practice in SEO
Forum: Best Practices
Today, 07:49 AM
» Replies: 2   » Views: 140
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,863

 
  URL translation, is it possible?
Posted by: superior - 02-27-2021, 02:49 AM - Forum: CodeIgniter 4 Support - No Replies

Hello,

I've been trying to translate one of my URL's in example '/nl/wachtwoord-vergeten/' in English it should be '/en/forgot-password/'. The translation switch is working correctly, i'm able to change the App\defaultLocale.

In my baseController i've setup the following:

PHP Code:
$language = \Config\Services::language();
$language->setLocale$lang }; 

This is working correctly, i've checked this by calling getLocale() in my view to be shure it's loaded. Next up is routing the URL, i've been reading about route_to();  and absolutly love it! Makes it so much easier to manage.

My routes looks like this:
PHP Code:
$routes->add("{locale}/" lang('Auth.forgotPasswordUri'), 'Accounts::resetPassword', ['as' => 'forgot_password']); 

Now i must admit, don't know if you can use the lang() helper in the routes, but we can always change this if needed.

Did anyone had the same issue and resolved this, would love to get this working Smile 

Kind Regards


Heart Codeigniter official extension for Visual Studio Code (VS Code)
Posted by: huangnam - 02-26-2021, 08:16 PM - Forum: CodeIgniter 4 Discussion - No Replies

Love to see a Codeigniter official extension for VS Code.
Please vote!  Heart  Heart  Heart


  Using the new Encryption library throws "MySQL server has gone away" error
Posted by: asantoli - 02-26-2021, 09:04 AM - Forum: Libraries & Helpers - Replies (1)

I have code that currently runs without error. When I introduce the "Encryption" library and call the encrypt or decrypt functions, the MySQL call  to update the ci_sessions table fail with the error "MySQL has gone away". Note: MySQL ssl is being used. Its seems like the openssl used in Encryption library is overwriting the mysqli key or chiper?

Does anyone have an history with this or ideas? Thanks

The Code is currently running on:

PHP 5.6
CI 3.1.6
MySQL 5.6


Here is the database.php setup

'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' =>FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt'  => array(
    'ssl_key'  => $db_ssl_key,
    'ssl_cert'  => $db_ssl_cert,
    'ssl_ca'    => $db_ssl_ca,
),
'compress' => FALSE,
'stricton' =>FALSE,


Information form helper [type=email]
Posted by: brabus - 02-26-2021, 08:24 AM - Forum: CodeIgniter 3.x - Replies (2)

Hello, i do not want to create many topics (please don't ban, i'm giving this info maybe to improve?), but i want to ask:
1. how i can make input [type=email] with in form helper ? when i try to add to extra ['type' => 'email'], it's ignoring it
2. second thing when i changed password in this forum should not i get message - green alert 'successfully changed'?
3. this login modal looks in my monitor like that (1440x900) ^_^

   


  Thousands of files with __ci_last_regenerate|i:1614347926;
Posted by: sswarnkar - 02-26-2021, 07:56 AM - Forum: General Help - Replies (3)

We would appreciate any help/advice to solve this problem.
ProblemEvery second 2-5 session files are created.
Each file is about 34 bytes and has an entry like this: __ci_last_regenerate|i:1614347926;

Background: We are developing an Android app that connects to MySQL in the CentOS server. Only a couple of engineers are testing it now.

We have spent countless hours trying to figure out why these session files are created non-stop. We are not able to figure out how to stop it or slow down the file creation.  We are not sure if there is something wrong with our Native App or the backend PHP files or with our configuration.

Details here - 

CI_VERSION: 3.1.0
PHP Version: 7.0.33
Apache Version: 2.4.46

Our Config.php looks like this:
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'Del_ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = APPPATH.'session/';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300; /* We changed to to 0, and onlything it did was started creating empty files */
$config['sess_regenerate_destroy'] = TRUE; /* Tried FALSE and TRUE - but no difference */
Huh
php.ini has the following entries:
session.gc_probability = 1
session.gc_divisor = 1000 /* We tried with number as low as 10 */
session.gc_maxlifetime = 1440 /* We tried with 60 seconds also */


/* But the files are never deleted */


autoload.php has this entry: /* we tried to remove sessions from this list - but did not help */
$autoload['libraries'] =  array('database','Template','QueryGenerator','FormGenerator','upload','email','Generate_uid','form_validation','SearchLib','Auth','Crontab');


  how to implement custom exception management in CodeIgniter 4?
Posted by: yuma2020 - 02-25-2021, 07:03 PM - Forum: CodeIgniter 4 Support - Replies (1)

how to implement custom exception management in CodeIgniter 4?
Function in the 200 is working all ok, 

PHP Code:
public function hx2getData($data)
    {
        if ($data->link_id)
        {
            $id = (string) $data->link_id;
            $url 'https://www.hx2.xyz/api/v1/links/'.((string)$id);
            $client = \Config\Services::curlrequest();
                                    

            $response 
$client->request('GET'$url, [
                'headers' => [
                        'Accept'     => 'application/json',
                        'Authorization' => 'Bearer ZDEcp8bptOz3Hi6RFXGry0JnUmbqvNC316IRbUOrwXH7Z85PVXEhnGTutcps'
                ],
                'timeout' => 5,
        ]); 
            //
            $code   $response->getStatusCode();    // Code result : 200, 403
            $reason $response->getReason();      // if OK or Error   
            
                 
try {
            
                        
if (strpos($response->getHeader('content-type'), 'application/json') !== false)
                            {
                                    $result json_decode($response->getBody());
                            }
                        } catch (\Exception $e)
                        {
                            die($e->getMessage());
                        }
                        
                        
return (object) $result ? (object)  $result 0
                
                
            
}

        
    

Calling:
Code:
$this->getapi->hx2getData((object) $data);
but in HTTP status 404 gives me the following error is result:
PHP Code:
{
 
"title""CodeIgniter\\HTTP\\Exceptions\\HTTPException",
  "type""CodeIgniter\\HTTP\\Exceptions\\HTTPException",
  "code"500,
  "message""22 : The requested URL returned error: 404 ",
  "file""D:\\laragon\\www\\marketineros\\V3\\system\\HTTP\\Exceptions\\HTTPException.php",
  "line"100,
  "trace": [
    {
      "file""D:\\laragon\\www\\marketineros\\V3\\system\\HTTP\\CURLRequest.php",
      "line"823,
      "function""forCurlError",
      "class""CodeIgniter\\HTTP\\Exceptions\\HTTPException",
      "type""::",
      "args": [
        "22",
        "The requested URL returned error: 404 "
      ]
    },
    {
      "file""D:\\laragon\\www\\marketineros\\V3\\system\\HTTP\\CURLRequest.php",
      "line"449,
      "function""sendRequest",
      "class""CodeIgniter\\HTTP\\CURLRequest",
      "type""->",
      "args": [
        {
          "10002""https://www.hx2.xyz/api/v1/links/110",
          "19913"true,
          "42"true,
          "74"true,
          "-1"true,
          "64"true,
          "155"5000,
          "156"150000,
          "45"true,
          "10036""GET",
          "10023": [
            "Accept: application/json",
            "Authorization: Bearer ZDEcp8bptOz3Hi6RFXGry0JnUmbqvNC316IRbUOrwXH7Z85PVXEhnGTutcps"
          ]
        }
      ]
    },
    {
      "file""D:\\laragon\\www\\marketineros\\V3\\system\\HTTP\\CURLRequest.php",
      "line"158,
      "function""send",
      "class""CodeIgniter\\HTTP\\CURLRequest",
      "type""->",
      "args": [
        "GET",
        "https://www.hx2.xyz/api/v1/links/110"
      ]
    },
    {
      "file""D:\\laragon\\www\\marketineros\\V3\\app\\Libraries\\GetLocateLibrary.php",
      "line"40,
      "function""request",
      "class""CodeIgniter\\HTTP\\CURLRequest",
      "type""->",
      "args": [
        "GET",
        "https://www.hx2.xyz/api/v1/links/110",
        {
          "headers": {
            "Accept""application/json",
            "Authorization""Bearer ZDEcp8bptOz3Hi6RFXGry0JnUmbqvNC316IRbUOrwXH7Z85PVXEhnGTutcps"
          },
          "timeout"5
        
}
      ]
    

(02-25-2021, 07:03 PM)yuma2020 Wrote: how to implement custom exception management in CodeIgniter 4?
Function in the 200 is working all ok, 
PHP Code:
public function hx2getData($data)
    {
        if ($data->link_id)
        {
            $id = (string) $data->link_id;
            $url 'https://www.hx2.xyz/api/v1/links/'.((string)$id);
            $client = \Config\Services::curlrequest();
                                    

            $response 
$client->request('GET'$url, [
                'headers' => [
                        'Accept'     => 'application/json',
                        'Authorization' => 'Bearer ZDEcp8bptOz3Hi6RFXGry0JnUmbqvNC316IRbUOrwXH7Z85PVXEhnGTutcps'
                ],
                'timeout' => 5,
        ]); 
            //
            $code   $response->getStatusCode();    // Code result : 200, 403
            $reason $response->getReason();      // if OK or Error   
            
                 
try {
            
                        
if (strpos($response->getHeader('content-type'), 'application/json') !== false)
                            {
                                    $result json_decode($response->getBody());
                            }
                        } catch (\Exception $e)
                        {
                            die($e->getMessage());
                        }
                        
                        
return (object) $result ? (object)  $result 0
                
                
            
}

        
    

Calling:
Code:
$this->getapi->hx2getData((object) $data);
but in HTTP status 404 gives me the following error is result:
PHP Code:
{
 
"title""CodeIgniter\\HTTP\\Exceptions\\HTTPException",
  "type""CodeIgniter\\HTTP\\Exceptions\\HTTPException",
  "code"500,
  "message""22 : The requested URL returned error: 404 ",
  "file""D:\\laragon\\www\\marketineros\\V3\\system\\HTTP\\Exceptions\\HTTPException.php",
  "line"100,
  "trace": [
    {
      "file""D:\\laragon\\www\\marketineros\\V3\\system\\HTTP\\CURLRequest.php",
      "line"823,
      "function""forCurlError",
      "class""CodeIgniter\\HTTP\\Exceptions\\HTTPException",
      "type""::",
      "args": [
        "22",
        "The requested URL returned error: 404 "
      ]
    },
    {
      "file""D:\\laragon\\www\\marketineros\\V3\\system\\HTTP\\CURLRequest.php",
      "line"449,
      "function""sendRequest",
      "class""CodeIgniter\\HTTP\\CURLRequest",
      "type""->",
      "args": [
        {
          "10002""https://www.hx2.xyz/api/v1/links/110",
          "19913"true,
          "42"true,
          "74"true,
          "-1"true,
          "64"true,
          "155"5000,
          "156"150000,
          "45"true,
          "10036""GET",
          "10023": [
            "Accept: application/json",
            "Authorization: Bearer ZDEcp8bptOz3Hi6RFXGry0JnUmbqvNC316IRbUOrwXH7Z85PVXEhnGTutcps"
          ]
        }
      ]
    },
    {
      "file""D:\\laragon\\www\\marketineros\\V3\\system\\HTTP\\CURLRequest.php",
      "line"158,
      "function""send",
      "class""CodeIgniter\\HTTP\\CURLRequest",
      "type""->",
      "args": [
        "GET",
        "https://www.hx2.xyz/api/v1/links/110"
      ]
    },
    {
      "file""D:\\laragon\\www\\marketineros\\V3\\app\\Libraries\\GetLocateLibrary.php",
      "line"40,
      "function""request",
      "class""CodeIgniter\\HTTP\\CURLRequest",
      "type""->",
      "args": [
        "GET",
        "https://www.hx2.xyz/api/v1/links/110",
        {
          "headers": {
            "Accept""application/json",
            "Authorization""Bearer ZDEcp8bptOz3Hi6RFXGry0JnUmbqvNC316IRbUOrwXH7Z85PVXEhnGTutcps"
          },
          "timeout"5
        
}
      ]
    

Sorry stupid error is solved with move of line try
PHP Code:
public function hx2getData($data)
    {
        if (
$data->link_id)
        {
                 try {
            
$id = (string) $data->link_id;
            
$url 'https://www.hx2.xyz/api/v1/links/'.((string)$id);
            
$client = \Config\Services::curlrequest();
                                    

            
$response $client->request('GET'$url, [
                
'headers' => [
                        
'Accept'     => 'application/json',
                        
'Authorization' => 'Bearer ZDEcp8bptOz3Hi6RFXGry0JnUmbqvNC316IRbUOrwXH7Z85PVXEhnGTutcps'
                
],
                
'timeout' => 5,
        ]); 
            
//
            
$code   $response->getStatusCode();    // Code result : 200, 403
            
$reason $response->getReason();      // if OK or Error   
            

            
                        
if (strpos($response->getHeader('content-type'), 'application/json') !== false)
                            {
                                    
$result json_decode($response->getBody());
                            }
                        } catch (\
Exception $e)
                        {
                            die(
$e->getMessage());
                        }
                        
                        return (object) 
$result ? (object)  $result 0
                
                
            }

        
    } 


  source code says Request::getMethod() is deprecated, what to use?
Posted by: sneakyimp - 02-25-2021, 05:42 PM - Forum: CodeIgniter 4 Support - Replies (2)

The source code says Request::getMethod() is deprecated. What should we use instead?

PHP Code:
    /**
     * Get the request method.
     *
     * @param boolean $upper Whether to return in upper or lower case.
     *
     * @return string
     *
     * @deprecated The $upper functionality will be removed and this will revert to its PSR-7 equivalent
     */
    
public function getMethod(bool $upper false): string
    
{
        return (
$upper) ? strtoupper($this->method) : strtolower($this->method);
    } 


  passing variable in model
Posted by: eleumas - 02-25-2021, 02:54 AM - Forum: CodeIgniter 4 Support - Replies (1)

PHP Code:
function get_articles() {
    $articles $this->db->query("SELECT * FROM tbl_articles WHERE status = '1' AND lang = '$this->locale' ORDER BY id DESC");    foreach($articles->getResult('array') as $a) {
      $articleId $a['id']; // I would like pass this variable to get_ip function
    }
    return $articles;
  }  

function get_ip() {
    $test $this->db->query("SELECT * FROM tbl_images_preview WHERE article_id = ".$articleId."");
    return $test;
  

I have this snippet in my model. How can I pass the variable $articleId to get_ip function?

Thanks. Smile


  Could CI4 benefit with JIT.
Posted by: John_Betong - 02-24-2021, 05:32 PM - Forum: CodeIgniter 4 Feature Requests - No Replies

I’ve yet to experiment with the new PHP 8 JIT feature and wondering if there are any CI4 sections that would benefit?


  what does fourth parameter ($escape) actually do for $builder->like?
Posted by: sneakyimp - 02-24-2021, 05:31 PM - Forum: CodeIgniter 4 Support - Replies (1)

I was expecting that the fourth parameter for the Builder::like function would cause special characters in the $match parameter to be escaped. I was quite surprised to see that supplying FALSE for this parameter results in no quotation marks for the $match parameter. Is this a bug?

An example. I would expect the % in 'H%' to be escaped:

PHP Code:
    function test2() {
        
$db = \Config\Database::connect("tests");
        
$builder $db->table("my_table");
        
$builder->like('col1''20%''none'false);
        die(
$builder->testMode()->getCompiledSelect());
    } 
The output of this function is:
Code:
SELECT * FROM `db_my_table` WHERE col1 LIKE 20%
whereas I was expecting an $escape of false to suppress escaping of special characters, perhaps yielding something like this:
Code:
SELECT * FROM `db_my_table` WHERE col1 LIKE '20%'
whereas an $escape value of true
PHP Code:
        $builder->like('col1''20%''none'true); 
yields this:
Code:
SELECT * FROM `db_my_table` WHERE `col1` LIKE '20%' ESCAPE '!'
when I thought it would escape the special wildcard char % like so:
Code:
SELECT * FROM `db_my_table` WHERE col1 LIKE '20!%' ESCAPE '!'

NOTE that in every case the table is surrounded by backticks, and the $escape parameter turns on/off the backticks around the column name and the quotes around the pattern to be matched.

Can someone explain to me what the $escape parameter is really doing? The documentation is not very clear at all:
Quote:$escape (bool) – Whether to escape values and identifiers



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