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

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 8,636
» Latest member: suge.nagoya
» Forum threads: 65,996
» Forum posts: 414,444

Full Statistics

Latest Threads
Community Auth - a databa...
Forum: Addins
2 hours ago
» Replies: 16   » Views: 578
Last URI segment is zero ...
Forum: General Help
4 hours ago
» Replies: 2   » Views: 46
Community Auth - Database...
Forum: Addins
4 hours ago
» Replies: 5   » Views: 88
modify calendar library
Forum: Libraries & Helpers
9 hours ago
» Replies: 3   » Views: 149
How to handle DB connecti...
Forum: General Help
Today, 05:33 AM
» Replies: 5   » Views: 218
Codeigniter Search and fi...
Forum: General Help
Today, 05:11 AM
» Replies: 4   » Views: 258
New developer to complete...
Forum: Jobs
Today, 04:59 AM
» Replies: 4   » Views: 461
need help about database ...
Forum: General Help
Today, 04:42 AM
» Replies: 2   » Views: 95
How CodeIgniter close db ...
Forum: Libraries & Helpers
Today, 04:12 AM
» Replies: 2   » Views: 207
Codeigniter Website Showi...
Forum: General Help
Today, 02:58 AM
» Replies: 10   » Views: 386

 
  Undefined Index
Posted by: cupboy1 - 05-13-2017, 02:20 PM - Forum: General Help - Replies (2)

How can I debug an undefined index problem? I've done everything I can think of to debug this.

The good code and the bad code look the same to me. The data looks the same.  Here is all the code. Maybe someone sees something I don't. I've spent hours on this. See the bottom box of Code.

In the meantime I've done a sloppy fix. It works but I don't know why I couldn't do it the other way. Here's the fix:

Code:
     if (isset($ddjuris)) {
       try {
         foreach ($ddjuris as $x) :
           // show be 15 rows or more
           $count1++;
           for ($i = 0; $i < count($x); $i++) {        
           $idx = $x[$i]['shortjuris'];
           if (trim($x[$i]['ddcase']) != '')
             $options[$idx] = $x[$i]['ddcase'];  // add key value pair to array ($idx is the key)      
             }  
         endforeach;
         log_message("info", "case view ddjuris items count: $count1");
       }
       catch (Exception $e) {
         log_message("info", "case view error: ".$e->getMessage());
       }
     }
     else
       log_message("info","case view could not find variable \$ddjuris or it was empty");




Code:
Good Code vs. Bad Code

bad code:

 function ddjuris() {
   $ddjuris = funcGetJurisDD();    
   $results['ddjuris'] = $ddjuris;   //  shortjuris, ddcase
   return $results;
 }  
   
     $count1 = 0;
     if (isset($ddjuris)) {
       try {
         foreach ($ddjuris as $x) :
           // show be 15 rows or more
           $count1++;
           $x = (array)$x;
           $idx = $x['shortjuris'];       // Message: Undefined index: shortjuris
           if (trim($x['ddcase']) != '')  // Message: Undefined index: ddcase
             $options[$idx] = $x['ddcase'];  // add key value pair to array ($idx is the key)        
         endforeach;
         log_message("info", "case view ddjuris items count: $count1");
       }
       catch (Exception $e) {
         log_message("info", "case view error: ".$e->getMessage());
       }
     }
     
     
good code:

   $formsdd = funcGetFormsDD();    
   $data['formsdd'] = $formsdd;
   return $data;

   $options = array(); // create a php array
   $idx = -1;
   $options[$idx] = "Select";
   if (isset($formsdd)) {
     foreach($formsdd as $x) :
       $x = (array)$x;
       $idx = $x['form_value'];
       $options[$idx] = $x['form_text'];
       //echo $options[$idx];
     endforeach;
     

function funcGetFormsDD() {
 $retval = false;
 $val = 0;
 $mysqli = ConnectToDB();
 $ddforms = array();
 $sql = "call getformsdd"; //  form_value, form_text
 log_message("info"," functions/funcGetJuris SQL = $sql ");
 try {

   if ($q = $mysqli->query($sql)) {
      $countRows = $q->num_rows;
        /* Fetch a result row as an associative array */
      while ($row = $q->fetch_assoc()) {        
        $ddforms[] = $row;  
      }
      if ($mysqli->more_results())
        $mysqli->next_result();        
      /* free result set */
      $q->free();    
     }
   }
   catch (Exception $ex)
   {
     echo $ex->getMessage();
     return true;
   }  

 $mysqli->close();
 log_message("info"," functions/funcGetFormsDD returned: ".print_r($ddforms, TRUE));
 return $ddforms;
}    

function funcGetJurisDD() {
 $retval = false;
 $val = 0;
 $mysqli = ConnectToDB();
 $ddjuris = array();
 $sql = "call getjurisdd"; //  shortjuris, ddcase
 log_message("info"," functions/funcGetJurisDD SQL = $sql ");
 $countRows = -1;
 try {

   if ($q = $mysqli->query($sql)) {
      $countRows = $q->num_rows;
        /* Fetch a result row as an associative array */
      while ($row = $q->fetch_assoc()) {        
        $ddjuris[] = $row;  
      }
      if ($mysqli->more_results())
        $mysqli->next_result();        
      /* free result set */
      $q->free();    
     }
   }
   catch (Exception $ex)
   {
     echo $ex->getMessage();
     return true;
   }  

 $mysqli->close();  
 log_message("info"," functions/funcGetJurisDD returned: ".print_r($ddjuris, TRUE));
 return $ddjuris;
}  

INFO - 2017-05-13 13:48:35 -->  functions/funcGetJurisDD returned: Array
(
   [0] => Array
       (
           [shortjuris] => dgd
           [ddcase] => DaggettD
       )

   [1] => Array
       (
           [shortjuris] => dgj
           [ddcase] => DaggettJ
       )



)

INFO - 2017-05-13 14:07:54 -->  functions/funcGetFormsDD returned: Array
(
   [0] => Array
       (
           [form_value] => information
           [form_text] => Information
       )

   [1] => Array
       (
           [form_value] => motion_continue
           [form_text] => Motion: Continue
       )


)


  [split] ocmod?
Posted by: faizanrupani - 05-13-2017, 10:36 AM - Forum: CodeIgniter 4 Feature Requests - No Replies

Will you include ocmod?
And please include in system to load one container to another container.
Like we use in opencart
    

Code:
$this->load->container("container_folder/container_file");

This will be very useful and I need this now.

Can you share some link where it shows how to load header, footer, column_left and column_right from single file that will help my work to do all that from one file. Because I cant load controller how to do this?


Wink [split] Multiple application support?
Posted by: fadsel - 05-13-2017, 09:36 AM - Forum: CodeIgniter 4 Feature Requests - Replies (1)

This sounds awesome  Smile  hopefully this year , Keep up the good work !
 
Hope we will also be able to run multiple applications using the same codeigniter instance  i.e Modular Apps Smile

Cheers


Brick Deploying Codeigniter to AWS EBS
Posted by: RedRepublic01 - 05-13-2017, 08:41 AM - Forum: General Help - Replies (10)

Hello everyone,

So basically I have this website that I've literally slaved over the last 3 months. I tried it using the localhost (XAMPP) and it works like a beauty. I thought I'd give AWS EBS a shot.

I created an instance and I uploaded the website files (.ZIP file - application folder, system folder, assets folder, and .htaccess). However it keeps throwing me a "Forbidden you do not have permission to access / on this server" error.

I've already tried changing the base url in the config file but to no avail. Any help would be most appreciated.


  Parse handlebar help
Posted by: MoFish - 05-13-2017, 06:10 AM - Forum: General Help - Replies (1)

Hi,

I have an empty view with the following mark-up inside.

Code:
{{ edit|codeignitor }}

I am trying to find every instance of {{edit}} in my view and then create a record in the database with the second parameter which i pass in, in this case is 'codeignitor'. {{edit|codeignitor}}. Database stuff aside (thats the long term goal) I set out coding and got a little confused on how best to parse the handlebars. I started by loading the view into a variable named $html

PHP Code:
$html $this->load->view("web/layouts/" $data['data']->template''true); 

I then figured doing a preg_match_all to find the {{edit}} tags would be a good starting point, however struggled with this part, and dont have much of an idea how to best find the string after the pipe.  Huh

PHP Code:
preg_match_all('~\{(.*?)\}~'$html$matches); 

Could anyone give me any guidance on how best this can be done?

Regards,

MoFish


  Divide different type of requests
Posted by: mt19 - 05-13-2017, 04:43 AM - Forum: CodeIgniter 4 Feature Requests - Replies (3)

Hello,

this idea comes from ExpressJS (on top of NodeJS).

To define a route in ExpressJS you can do something like the following:

Code:
router.get('/welcome', function(..){..})
router.post('/welcome', function(..){..})
router.put('/welcome', function(..){..})
router.delete('/welcome', function(..){..})
...


I really love this method division, since it helps keeping everything even more organised.
Actually I have mocked this function creating MY_Router.php in application/core with the following:

PHP Code:
class MY_Router extends CI_Router {

 
       public function __construct()
 
       {
 
               parent::__construct();
 
               // Default route method: METHOD_index
 
               $this->set_method('index');
 
       }

 
       public function set_method($method)
    {
 
               $request_method $_SERVER['REQUEST_METHOD'] . '_';
        
$this->method $request_method $method;
    }


Now if I perform a GET request to /welcome/, the Class welcome will be loaded and the Method GET_index will be called.


I think that it would be cool to have this feature in Codeigniter 4 (maybe with a settings that permits to enable and disable it)


  logs folder permission 777 gives me 408 Timeout
Posted by: mt19 - 05-13-2017, 03:18 AM - Forum: Installation & Setup - No Replies

Hello guys!

I'm on the localhost of my mac and I have a fresh new installation of the latest CI version (3.1.4).

Just changed the base_url with the correct address and log_threshold to 4. If I try to connect to the sites it displays me the welcome message, however it doesn't log anything due to the fact that the user "_www" has not enough permission to write in the logs folder. 

If I try to give the write permissions (tried with many permissions), for example 777, the sites start loading without never show me anything. 

In the Apache log "access_log" I obtain:

127.0.0.1 - - [13/May/2017:10:54:32 +0200] "-" 408 -

As soon as I remove the write permission, it works as expected.


Can someone suggest me something?

Thanks in advance!


  Error - Severity: Notice-->Undefined property: stdClass
Posted by: cndunga - 05-12-2017, 08:02 AM - Forum: Choosing CodeIgniter - Replies (1)

I am getting the following error messages

Severity: Notice  --> Undefined property: stdClass::$service_name /home/examprep/public_html/application/controllers/payment.php 194
ERROR - 2017-05-12 01:21:11 --> Severity: Notice  --> Undefined property: stdClass::$transaction_reference /home/examprep/public_html/application/controllers/payment.php 196
ERROR - 2017-05-12 01:21:11 --> Severity: Notice  --> Undefined property: stdClass::$internal_transaction_id /home/examprep/public_html/application/controllers/payment.php 197
ERROR - 2017-05-12 01:21:11 --> Severity: Notice  --> Undefined property: stdClass::$transaction_timestamp /home/examprep/public_html/application/controllers/payment.php 198
ERROR - 2017-05-12 01:21:11 --> Severity: Notice  --> Undefined property: stdClass::$transaction_type /home/examprep/public_html/application/controllers/payment.php 199
ERROR - 2017-05-12 01:21:11 --> Severity: Notice  --> Undefined property: stdClass::$amount /home/examprep/public_html/application/controllers/payment.php 200
ERROR - 2017-05-12 01:21:11 --> Severity: Notice  --> Undefined property: stdClass::$first_name /home/examprep/public_html/application/controllers/payment.php 201
ERROR - 2017-05-12 01:21:11 --> Severity: Notice  --> Undefined property: stdClass::$last_name /home/examprep/public_html/application/controllers/payment.php 202
ERROR - 2017-05-12 01:21:11 --> Severity: Notice  --> Undefined property: stdClass::$middle_name /home/examprep/public_html/application/controllers/payment.php 203
ERROR - 2017-05-12 01:21:11 --> Severity: Notice  --> Undefined property: stdClass::$sender_phone /home/examprep/public_html/application/controllers/payment.php 204
ERROR - 2017-05-12 01:21:11 --> Severity: Notice  --> Undefined property: stdClass::$currency /home/examprep/public_html/application/controllers/payment.php 205
ERROR - 2017-05-12 01:21:11 --> Severity: Notice  --> Undefined property: stdClass::$account_number /home/examprep/public_html/application/controllers/payment.php 206
ERROR - 2017-05-12 01:21:11 --> Severity: Notice  --> Undefined property: stdClass::$signature /home/examprep/public_html/application/controllers/payment.php 212


My payment controller is as follows

     $base_string =  "service_name=".$callBack->service_name.
                        "&business_number=".$callBack->business_number.
                        "&transaction_reference=".$callBack->transaction_reference.
                        "&internal_transaction_id=".$callBack->internal_transaction_id.
                        "&transaction_timestamp=".$callBack->transaction_timestamp.
                        "&transaction_type=".$callBack->transaction_type.
                        "&amount=".$callBack->amount.
                        "&first_name=".$callBack->first_name.
                        "&last_name=".$callBack->last_name.
                        "&middle_name=".$callBack->middle_name.
                        "&sender_phone=".$callBack->sender_phone.
                        "&currency=".$callBack->currency.
                        "&account_number=".$callBack->account_number;
        //$payment_info->mpesa_api_key;
        $symmetric_key =$payment_info->mpesa_api_key;
        $signature_created = base64_encode( hash_hmac("sha1",$base_string,$symmetric_key,true));

How do I resolve the error message?


  Select CI3 Encrypted data directly from MySQL database
Posted by: eflyerman - 05-11-2017, 10:43 PM - Forum: General Help - Replies (4)

I have an app that has several MySQL fields encrypted with AES-128-CBC using the CI3 Encryption->Encrypt() function.  I need to do some extensive reporting and would like to use a BI tool like Jaspersoft or similar product.  This requires a direct connection and non CI SQL query to the database.

The MySQL query should look something like the code snippet below but it always returns a null.

Code:
SET block_encryption_mode = 'aes-128-cbc';
SELECT  
   AES_DECRYPT(weight,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',random_bytes(16)) as ue_weight,
   AES_DECRYPT(height,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',random_bytes(16)) as ue_height,
   AES_DECRYPT(social_history,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',random_bytes(16)) as ue_social_history
    FROM health_profiles;

A little research on Codeigniter Docs says:

Quote:However, the encryption_key is not used as is.
If you are somewhat familiar with cryptography, you should already know that a HMAC also requires a secret key and using the same key for both encryption and authentication is a bad practice.
Because of that, two separate keys are derived from your already configured encryption_key: one for encryption and one for authentication. This is done via a technique called HMAC-based Key Derivation Function (HKDF).


So the question is, how do I get the "actual" key used for the encryption?

THX in advance!!!


  Facebook Webhooks API
Posted by: tan87 - 05-11-2017, 10:41 PM - Forum: General Help - Replies (5)

Not sure whether you guys can help me out here.

I have worked on CI for other project and it is working perfectly fine.

However, when I am trying to use CI for one of my Facebook Webhooks projects, it seems that CI is filtering the data posted from Facebook but if i create a standalone PHP file using the same code (except the GET/POST function which using CI $this->input), it is working fine.

When I enable CI debug mode, this is the debug log available:
DEBUG - 2017-05-12 02:18:51 --> Global POST, GET and COOKIE data sanitized

I have checked the HTTP log as well, HTTP 403 is returned for all Facebook post to CI.

I would really like to use CI for all my project. Hope someone out there will have some idea



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