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
3 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

 
Tongue Slice Library to simulate Blade's template system!
Posted by: Gustavo Martins - 05-16-2017, 10:15 PM - Forum: Addins - Replies (1)

Hi guys!  Big Grin

I've been working on a library to simulate Laravel's Blade template system. And I'm happy to share with you this library!

Get it on GitHub: Slice-Library

The main features are:

  • There are more than 30 directives similar to Blade
  • Easy to install and use
  • Manages templates, views, languages
  • compatible with modular extension - HMVC
  • Very well documented!
Some of the directives are:
  • @section()
  • @yield()
  • @if()
  • @foreach()
  • @forelse()
  • And many more!
Please, try it!!  Cool

I hope this can be useful for all of us!

Get it on GitHub: Slice-Library


  validation and pass an id in url to view from controller
Posted by: Ali - 05-15-2017, 11:16 PM - Forum: General Help - Replies (6)

Hello
sorry for my bad english. i really need help  Sad
i am creating a simple help desk and i have one question please answer me.

1: go to new ticket ( ex: localhost/helpdesk/index.php/ticket/show/10 ).

for number 1 i have a function ( public show ) and display all replies in id 10.

2: and show/10 has a form for reply your comment. ( screenshot : http://s6.uplod.ir/i/00880/op3jnntpy1lu.jpg )

then i need validation form when users submit new reply. i wrote validation rules, but i can't pass message error from controller to view (ticket/show/id).

PHP Code:
public function show()
 
   {
 
       $show = array();
 
       $id $this->uri->segment('3');
 
       $groups_id $this->ticket_model->get_groups_id($id);
 
       $show['show_ticket'] = $this->ticket_model->show($id$groups_id);

 
       foreach ($show['show_ticket'] as $show_value){
 
           $show_gorup_id $show_value['department_id'];
 
           $create_by_id $show_value['user_id'];
 
       }

 
       $show['show_ticket_comment'] = $this->ticket_model->get_reply($id);

 
       foreach ($this->aauth->get_user_groups() as $user_groups) {
 
           $user_groups_id $user_groups->id;
 
       }

 
       if (($this->aauth->is_member('Admin')) ||($user_groups_id == $show_gorup_id) || ($create_by_id == $this->aauth->get_user_id())) {
 
           $this->template->load('ticket/show_ticket'$show);
 
       }else{
 
           echo 'Access Denied';
 
       }
 
   
PHP Code:
  public function reply()
 
   {
 
       $this->form_validation->set_rules('comment','Comment','required|trim');
 
       if($this->form_validation->run() == FALSE){
 
           $ticket_id $this->input->post('ticket_id');
 
           //$show['show_ticket_comment'] = $this->ticket_model->get_reply($ticket_id);
 
          // $this->template->load('ticket/show/'.$ticket_id,array('errors' => validation_errors('','<br />')));
 
          // return;
 
           
            
// what code needs here ??????

 
       }else{
 
           if($_FILES['userfile']){
 
               $this->load->library('upload'$config);
 
               //$this->upload->initialize($config);
 
               if($this->upload->do_upload('userfile')){
 
                   $config['upload_path'] = './file_ticket';
 
                   $config['allowed_types'] = 'gif|jpg|png|jpeg|pdf|doc|docx|txt';
 
                   $config['max_size'] = 4000;
 
                   $config['max_width'] = 11024;
 
                   $config['max_height'] = 7168;
 
                   $upload_data $this->upload->data();
 
                   $file_name $upload_data['file_name'];

 
                   $reply_ticket['ticket_comment_id'] = '';
 
                   $reply_ticket['ticket_id'] = $this->input->post('ticket_id');
 
                   $reply_ticket['user_id'] = $this->aauth->get_user_id();
 
                   $reply_ticket['comment'] = $this->input->post('comment');
 
                   $reply_ticket['create_date'] = now();
 
                   $reply_ticket['file'] = $file_name;
 
                   $insert_ticket_comment $this->ticket_model->reply($reply_ticket);
 
                   if ($insert_ticket_comment){
 
                       $show = array();
 
                       $id $this->input->post('ticket_id');
 
                       $groups_id $this->ticket_model->get_groups_id($id);
 
                       $show['show_ticket'] = $this->ticket_model->show($id$groups_id);

 
                       redirect('ticket/show/'.$id);
 
                   }
 
               }else{
 
         //          $error = array('error' => $this->upload->display_errors());
echo '11';
 
           //        $this->load->view('show_ticket', $error);
 
               }
 
           }else{print_r($_POST);}
 
       }
 
   


  How to handle DB connection errors
Posted by: guilhermemuller - 05-15-2017, 12:42 PM - Forum: General Help - Replies (5)

Hello all,

I have developed a superadmin system that manages an admin interface for a lot of users, each with his own database. It is working well, but there's one situation that I'm not able to handle yet. When logging in, the superadmin supplies the ID of the database he will access. There are three alternatives as for the outcome:

  1. The script retrieves the client's DB info and connects successfully;
  2. The script retrieves the client's DB info and does NOT connect successfully;
  3. The script cannot retrieve any data on that client and DB, and returns an error.
For situations #1 and #3, everything is alright. The problem is when the information for the connection is invalid. I'm using the following code:

PHP Code:
$config['hostname'] = $row->server// from the superadmin DB
$config['username'] = $row->user// from the superadmin DB
$config['password'] = $password// from the superadmin DB
$config['database'] = $row->db// from the superadmin DB
$config['dbdriver'] = 'mysqli';
$config['dbprefix'] = '';
$config['pconnect'] = FALSE;
$config['db_debug'] = (ENVIRONMENT !== 'production');
$config['cache_on'] = FALSE;
$config['cachedir'] = '';
$config['char_set'] = 'utf8';
$config['dbcollat'] = 'utf8_general_ci';

$db_config $config;

$this->db $this->load->database($configTRUE);

if(
$this->db->conn_id->connect_error) {
 
   //error
 
   return false;


However, in situation #2 the "conn_id" error is not reached. CodeIgniter steps in with the "Unable to connect to your database server using the provided settings." error and that's it.

Is there a way to handle this kind of connection error, so I can redirect to the previous page and inform the user? I don't want the CI error page to show.

Thank you very much for your help.


Question Execute Oracle procedure with one OUT parameter
Posted by: zashishz - 05-15-2017, 11:12 AM - Forum: CodeIgniter 3.x - Replies (2)

I am able to execute stored procedure in CI with IN params.
But Having problems using a procedure with one or more OUT params in oracle.

Example:

CREATE OR REPLACE PROCEDURE Sample (id IN NUMBERtitle IN VARCHAR2status_code OUT VARCHAR2 )
AS
   lv_status_code VARCHAR2 (500);
BEGIN
    lv_status_code :=
      'SUCCESS'
      || '|~|'
      || id
      || '|~|'
      || title;
   status_code := lv_status_code;
END;


Kindly let me know how i can execute this from codeigniter and to read output value.


Lightbulb SafiCloud - A file sharing platform & a Blog Built on CI
Posted by: fadsel - 05-15-2017, 08:09 AM - Forum: Spotlight - Replies (2)

Hey Everyone,

Thought We'd share our project here, it is a simple File Sharing Platform, SafiCloud built in CodeIgniter, 
It started as a hobby project for a university project ,so we could use it to learn CodeIgniter but over the past couple years it has grown into what it is now.
Your feedback is much appreciated [Image: smile.gif]

Cheers


  Post and routing problem
Posted by: LasLou - 05-15-2017, 06:55 AM - Forum: General Help - Replies (2)

Hi guys.

I'm going through the News app tutorial and have an issue with posting and redirecting to a succes page when I submit a form. The data is not being sent to the database and I'm getting a "unable to be loaded"-page. It tries to load this url: [::1]/news-app/index.php/news/create instead of the success.php. I'm working locally with a mamp server.

Here is my code:


Controller:


Code:
    class News extends CI_Controller
    {
        public function __construct()
        {
            parent::__construct();
            $this->load->model('news_model');
            $this->load->helper('url_helper');
        }

        public function index()
        {
            $data['news'] = $this->news_model->get_news();
            $data['title'] = 'News archive';

            $this->load->view('templates/header', $data);
            $this->load->view('news/index', $data);
            $this->load->view('templates/footer');
        }

        public function view($slug = NULL)
        {
            $data['news_item'] = $this->news_model->get_news($slug);

            if(empty($data[news_item]))
            {
                show_404();
            }
            $data['title'] = $data['news_item']['title'];

            $this->load->view('templates/header', $data);
            $this->load->view('news/view', $data);
            $this->load->view('templates/footer');
        }

        public function create()
        {
            $this->load->helper('form');
            $this->load->library('form_validation');

            $data['title'] = 'Create a news item';

            $this->form_validation->set_rules('title', 'Title', 'required');
            $this->form_validation->set_rules('text', 'Text', 'required');

            if ($this->form_validation->run() === FALSE)
            {
                $this->load->view('templates/header', $data);
                $this->load->view('news/create');
                $this->load->view('templates/footer');

            }
            else
            {
                $this->news_model->set_news();
                $this->load->view('news/success');
            }
}
    }

pages_model:


Code:
class Pages extends CI_Controller {

    public function view($page = 'home')
    {
            if ( ! file_exists(APPPATH.'views/pages/'.$page.'.php'))
            {
                    // Whoops, we don't have a page for that!
                    show_404();
            }

            $data['title'] = ucfirst($page); // Capitalize the first letter

            $this->load->view('templates/header', $data);
            $this->load->view('pages/'.$page, $data);
            $this->load->view('templates/footer', $data);
    }
}

news_model:

Code:
    class News_model extends CI_Model
    {

        public function __construct()
        {

            $this->load->database();
        }

        public function get_news($slug = false)
        {
            if ($slug === FALSE)
            {
                $query = $this->db->get('news');

                return $query->result_array();
            }

            $query = $this->db->get_where('news', array('slug' => $slug));
            return $query->row_array();
        }

        public function set_news()
        {
            $this->load->helper('url');

            $slug = url_title($this->input->post('title'), 'dash', TRUE);

            $data = array(
                'title' => $this->input->post('title'),
                'slug' => $slug,
                'text' => $this->input->post('text')
            );

            return $this->db->insert('news', $data);
        }

    }

Routes:

Code:
$route['news/create'] = 'news/create';
$route['news/(:any)'] = 'news/view/$1';
$route['news'] = 'news';
$route['(:any)'] = 'pages/view/$1';
$route['default_controller'] = 'pages/view';


  Türkçe Paylaşım
Posted by: [email protected] - 05-15-2017, 02:03 AM - Forum: Regional User Groups - Replies (1)

Arkadaşlar Merhaba
Codeigneter 4 ile bir panel yazdım ve aktif kullanıyorum. Tecrübelerimi paylaşmak ve karişlıklı destek almak istiyorum


  Codeigniter Website Showing Blank Page in AWS Elastic Beanstalk
Posted by: RedRepublic01 - 05-15-2017, 12:16 AM - Forum: General Help - Replies (10)

Okay, I've managed to fix my previous problem (https://forum.codeigniter.com/thread-68033.html) regarding the 403 Error popping up whenever I deploy my Codeigniter website to the AWS Elastic Beanstalk. I just tweaked the .htaccess file and the error was solved.

Before anything else, this is the structure of the entire site


myAppFolder
   -> application (contains config file)
   -> assets
   -> system
index.php
.htaccess

However, this time, the website just shows a blank page. My config file's base url has already been set to

xxxxxxx-xxx.xxxxxxxxxx.xx-xxxx-x.xxxxxxxxxxxxxxxx.com/myAppFolder/


When I run it using XAMPP, it works fine and displays the home page. I'm just puzzled as to why after uploading it to elastic beanstalk, it's showing nothing.

Thanks in advance,


  Open Source Web Development
Posted by: thakotagoc - 05-14-2017, 05:10 PM - Forum: NetBeans Plugin - Replies (1)

Need help


  Refresh session in CI 3.1.4
Posted by: eflyerman - 05-13-2017, 06:17 PM - Forum: General Help - Replies (3)

I have added javascript to a CI app to prompt the user 5 min before the session expires.  I'd like to allow the user to respond and reset the session timeout without refreshing the page. 

As an experiment, I've tried an ajax call to regen the session id (its not prod so don't criticize me for bad code, just testing for now).  The session still times out at the original time.

Whats the right way to reset the session without a round trip to the server?

Code:
My config section

$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'redimd_v3';
$config['sess_expiration'] = 305;
$config['sess_save_path'] = 'sessions';
$config['sess_match_ip'] = true;
$config['sess_time_to_update'] = 200;
$config['sess_regenerate_destroy'] = FALSE
Controller
PHP Code:
function ajax_refresh_session(){
        
//check authorized
        
$this->session->grant_access('user|admin|clinic_admin|doctor');
 
               
                
//load json helper
        
$this->load->helper('json');
        
        
//Call the sess_update method to actually regenerate the session ID
        
if( $this->session->is_logged_in() )
            
$this->session->sess_regenerate(false);

        
json_response("Session refreshed");
    } 
Javascript
Code:
       $.ajax({
           url: "/user/ajax_refresh_session",
           type: "POST",
           error: function() {
               if(confirm("Session refresh failed.  Your session will timeout if you do not refresh the page or navigate to another location. Click OK to refresh this page or cancel to return to this page."))
                   location.reload(true);
           },
           success: function(jsondata, status, xhr){
               initTimers();
           }
       });



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