\!/ KyuuKazami \!/

Path : /home/kohli/public_html/application/controllers/
Upload :
Current File : /home/kohli/public_html/application/controllers/content.php

<?php if (! defined('BASEPATH')) exit('No direct script access allowed');

class Content extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->load->library(["common_lib", 'session','form_validation']);
        $this->load->model("contentm");
        $this->load->helper(array('form', 'url', 'captcha'));
        $this->load->model("commonm");
        error_reporting(E_ALL);
ini_set('display_errors', '1');

    }
    /**
     * Index Page for this controller.
     *
     * Maps to the following URL
     * 		http://example.com/index.php/welcome
     *	- or -  
     * 		http://example.com/index.php/welcome/index
     *	- or -
     * Since this controller is set as the default controller in 
     * config/routes.php, it's displayed at http://example.com/
     *
     * So any other public methods not prefixed with an underscore will
     * map to /index.php/welcome/<method_name>
     * @see http://codeigniter.com/user_guide/general/urls.html
     */

    public function index()
    {
        redirect("content/aboutus");
        exit;
    }

    public function aboutus()
    {
        $data = array();
        $description = $this->contentm->get_description("About Us");
        $data['description'] = $description;
        $data['inner_template'] = "content/aboutus";
        $this->load->view('layout/layout_main.php', $data);
    }

    public function catalog()
    {
        $data = array();
        $data['inner_template'] = "content/catalog";
        $this->load->view('layout/layout_main.php', $data);
    }

    public function contactus()
    {
        if ($this->common_lib->run_feedback_information()) {
            $feed_back = array();

            $feed_back['your_name'] =  $this->common_lib->get_post("f_name");
            $feed_back['email'] = $this->common_lib->get_post("f_email");
            $feed_back['phone'] = $this->common_lib->get_post("f_phone");
            $feed_back['best_time'] = $this->common_lib->get_post("best_time");
            // $feed_back['item'] = $this->common_lib->get_post("item");
            $feed_back['message'] = $this->common_lib->get_post("f_message");
            $this->common_lib->feedback_information_email($feed_back, $feed_back['email']);
            $this->common_lib->set_session(array("success-msg" => "<b>Thank you</b><br>For sending feedback information.<br>"));
        } else {
            $this->common_lib->set_session(array("danger-msg" => validation_errors()));
        }
        $data = array();
        $description = $this->contentm->get_description("Contact Us");
        $data['description'] = $description;
        //delete old image than 2.30 min
        $dir = './assets/image_for_captcha';
        $expirationTime = 150; // 1 hour in seconds

        foreach (glob($dir . '/*') as $file) {

            if (is_file($file) && (filemtime($file) < time() - $expirationTime)) {
                unlink($file); // Delete the file
            }
        }
        //generate captcha

        $config = array(
            'img_url' => base_url() . 'assets/image_for_captcha/',
            'img_path' => 'assets/image_for_captcha/',
            'img_height' => 50,
            'img_width' => '200',
            'font_size' => 28
        );
        $captcha = create_captcha($config);
        $this->session->unset_userdata('valuecaptchaCode');
        $this->session->set_userdata('valuecaptchaCode', $captcha['word']);
        $data['captchaImg'] = $captcha['image'];
        $data['inner_template'] = "content/contactus";
        $this->load->view('layout/layout_main.php', $data);
    }
    public function refresh()
    {
        $config = array(
            'img_url' => base_url() . 'assets/image_for_captcha/',
            'img_path' => 'assets/image_for_captcha/',
            'img_height' => 50,
            'img_width' => '200',
            'font_size' => 28
        );
        $captcha = create_captcha($config);
        $this->session->unset_userdata('valuecaptchaCode');
        $this->session->set_userdata('valuecaptchaCode', $captcha['word']);
        echo $captcha['image'];
    }
    public function validate_captcha()
    {
        if ($this->input->post('captcha') != $this->session->userdata['valuecaptchaCode']) {
            $this->form_validation->set_message('validate_captcha', 'Captcha Code is wrong');
            return false;
        } else {
            return true;
        }
    }

    public function testinomial()
    {
        if ($this->common_lib->run_testinomial_information()) {
            $feed_back = array();

            $feed_back['your_name'] =  $this->common_lib->get_post("f_name");
            $feed_back['email'] = $this->common_lib->get_post("f_email");
            $feed_back['phone'] = $this->common_lib->get_post("f_phone");
            $feed_back['message'] = $this->common_lib->get_post("f_message");
            $this->common_lib->testinomial_information_email($feed_back, $feed_back['email']);
            $this->common_lib->set_session(array("success-msg" => "<b>Thank you</b><br>For sending feedback information.<br>"));
        } else {
            $this->common_lib->set_session(array("danger-msg" => validation_errors()));
        }
        $data = array();
        $data['inner_template'] = "content/testinomials";
        $this->load->view('layout/layout_main.php', $data);
    }
    public function faq()
    {
        $data = array();
        $description = $this->contentm->get_description("Faq's");
        $data['description'] = $description;
        $data['inner_template'] = "content/faq";
        $this->load->view('layout/layout_main.php', $data);
    }
    public function envelop()
    {
        $data = array();
        $description = $this->contentm->get_description("Envelop Order");
        $data['description'] = $description;
        $data['inner_template'] = "content/enveloporder";
        $this->load->view('layout/layout_main.php', $data);
    }
    public function customer()
    {
        $data = array();
        $description = $this->contentm->get_description("Customer Service");
        $data['description'] = $description;
        $data['inner_template'] = "content/customerservice";
        $this->load->view('layout/layout_main.php', $data);
    }

    public function privacypolicy()
    {
        $data = array();
        $description = $this->contentm->get_description("Privacy Policy");
        $data['description'] = $description;
        $data['inner_template'] = "content/privacypolicy";
        $this->load->view('layout/layout_main.php', $data);
    }
    public function matter($id, $name)
    {
        $data = array();
        $content_detail = $this->contentm->get_content($id, $name);
        $data['content_detail'] = $content_detail;
        $data['inner_template'] = "content/detail";
        $this->load->view('layout/layout_main.php', $data);
    }
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */

@KyuuKazami