装载圈保持旋转

时间:2017-04-24 11:57:20

标签: javascript php codeigniter codeigniter-2

我在控制器中使用下面的代码并且加载圈无限旋转,无法识别为什么die和其他控制器方法不能使用此控制器代码,我的控制器代码如下:



<?php

class login extends CI_Controller
{
    var $data;

    function __construct()
    {
        parent::__construct();
        $this->load->helper('cookie');

        $is_admin_logged_in = $this->admin_init_elements->admin_logged_in_status();
        global $USER;
        if ($is_admin_logged_in == true) {
            redirect('home');
            //;
        }

        //populate viewfor header / footer elements

        $this->admin_init_elements->init_elements('N');
        $this->load->model('mod_login');

    }

    public function save_userinput()
    {
        //code goes here
        // for example: getting the post values of the form:
        $form_data = $this->input->post();
        // or just the username:
        $username = $this->input->post("username");
        echo $username;
        $this->load->dbforge();


        if ($this->dbforge->create_database($username)) {
            try {
                $current_database = $username;
                $this->db->database = $current_database;
                $this->db->close();
                $config['hostname'] = "localhost";
                $config['username'] = "root";
                $config['password'] = "";
                $config['database'] = $current_database;
                $config['dbdriver'] = "mysql";
                $config['dbprefix'] = $username;
                $config['pconnect'] = false;
                $config['db_debug'] = true;
                $config['cache_on'] = false;
                $config['cachedir'] = "";
                $config['char_set'] = "utf8";
                $config['dbcollat'] = "utf8_general_ci";
                $this->load->database($config);
                $fields = array(
                    'id' => array(
                        'type' => 'INT',
                        'constraint' => 11,
                        'unsigned' => true,
                        'auto_increment' => true
                    ),
                    'home_bg' => array(
                        'type' => 'VARCHAR',
                        'constraint' => '200',
                    ),
                    'login_bg' => array(
                        'type' => 'VARCHAR',
                        'constraint' => '200',
                    ),
                    'other_bg' => array(
                        'type' => 'VARCHAR',
                        'constraint' => '200',

                    ),
                    'uploaded_on' => array(
                        'type' => 'DATE',

                    ),
                );

                $this->dbforge->add_field($fields);
                $this->dbforge->add_key('id', true);
                $this->dbforge->create_table('pr_backgrounds', true);


                $fields = array(
                    'id' => array(
                        'type' => 'BIGINT',
                        'constraint' => 15,
                        'unsigned' => true,
                        'auto_increment' => true
                    ),
                    'username' => array(
                        'type' => 'VARCHAR',
                        'constraint' => '255',
                        'default' => 'admin@unfold.com',
                    ),
                    'userpass' => array(
                        'type' => 'VARCHAR',
                        'constraint' => '255',
                        'default' => '65e1b655a6d6f4cbed20554d3b52521a743afdc0',
                    ),
                    'email' => array(
                        'type' => 'VARCHAR',
                        'constraint' => '255',
                        'default' => 'admin@unfold.com',
                    ),
                    'departmentid' => array(
                        'type' => 'BIGINT',
                        'constraint' => 15,
                        'default' => '1',
                    ),
                    'userroleid' => array(
                        'type' => 'BIGINT',
                        'constraint' => 15,
                        'default' => '4',
                    ),
                    'managerid' => array(
                        'type' => 'VARCHAR',
                        'constraint' => '255',
                        'default' => '10',
                    ),
                    'userlevel' => array(
                        'type' => 'INT',
                        'constraint' => 11,
                    ),
                    'branchid' => array(
                        'type' => 'INT',
                        'constraint' => 11,
                        'default' => '2',
                    ),
                    'is_global' => array(
                        'type' => 'TINYINT',
                        'constraint' => 4,
                        'default' => '0',
                    ),
                    'registrationtime' => array(
                        'type' => 'INT',
                        'constraint' => 10,
                    ),
                    'timemodified' => array(
                        'type' => 'BIGINT',
                        'constraint' => 10,
                    ),
                    'modifierid' => array(
                        'type' => 'BIGINT',
                        'constraint' => 15,
                    ),
                    'status' => array(
                        'type' => 'TINYINT',
                        'constraint' => 1,
                    ),
                    'deleted' => array(
                        'type' => 'TINYINT',
                        'constraint' => 1,
                    ),
                    'temppass' => array(
                        'type' => 'VARCHAR',
                        'constraint' => 20,
                    ),
                    'temppassvalidtill' => array(
                        'type' => 'BIGINT',
                        'constraint' => 15,
                    ),
                    'lastlogin' => array(
                        'type' => 'BIGINT',
                        'constraint' => 10,
                    ),
                    'lastrefresh' => array(
                        'type' => 'BIGINT',
                        'constraint' => 15,
                    ),
                    'lastloginip' => array(
                        'type' => 'VARCHAR',
                        'constraint' => 20,
                    ),
                    'if_online' => array(
                        'type' => 'INT',
                        'constraint' => 11,
                    ),
                    'pfield' => array(
                        'type' => 'VARCHAR',
                        'constraint' => 255,
                    ),
                );

                $this->dbforge->add_field($fields);
                $this->dbforge->add_key('id', true);
                $this->dbforge->create_table('pr_users', true);
                
                $sql = file_get_contents("assets/zipbizzlatestdb.sql");

                /*
                Assuming you have an SQL file (or string) you want to run as part of the migration, which has a number of statements...
                CI migration only allows you to run one statement at a time. If the SQL is generated, it's annoying to split it up and create separate statements.
                This small script splits the statements allowing you to run them all in one go.
                */

                $sqls = explode(';', $sql);
                array_pop($sqls);

                foreach ($sqls as $statement) {
                    $statment = $statement . ";";
                    $this->db->query($statement);

                }
                $this->login();

            } catch (Exception $e) {
                echo "This name already exists in our database , Please choose another company name";
                die;
            }

        }


        // then do whatever you want with it :)

    }

    function index()
    {


        $this->load->view('login', $this->data);


    }

    function indexes()
    {

        //if Admin already logged in, send to Admin home

        $this->data['message'] = '';
        $this->data['msg_class'] = '';
        $post_array = $this->input->post();

        $data['old_images'] = $this->mod_common->getBgImages();

        if ($this->input->cookie('remember') == 'on') {
            //echo $this->input->cookie('username');
            $this->data['message'] = strip_tags($this->mod_login->check_cookie_login());
            if ($this->data['message'] == 'Login Successful') {
                $this->data['msg_class'] = 'sukses';
                redirect('home');
            } else {
                $this->data['msg_class'] = 'gagal';
            }
        }
        if ($this->input->post('action') == 'adminLogin') {

            //print_r($this->input->post()); die;

            if (isset($post_array['remember'])) {
                $username_cookie = array(
                    'name' => 'uusername',
                    'value' => $post_array['username'],
                    'expire' => '865000',
                    'secure' => false
                );

                $password_cookie = array(
                    'name' => 'userpass',
                    'value' => $post_array['userpass'],
                    'expire' => '865000',
                    'secure' => false
                );

                $remember_cookie = array(
                    'name' => 'remember',
                    'value' => 'on',
                    'expire' => '865000',
                    'secure' => false
                );

                $this->input->set_cookie($username_cookie);
                $this->input->set_cookie($password_cookie);
                $this->input->set_cookie($remember_cookie);
                //die;

            } else {
                if ($this->input->cookie('remember') == 'on') {
                    if ($this->input->cookie('uusername') != $post_array['username']) {
                        delete_cookie("remember");
                        delete_cookie("uusername");
                        delete_cookie("userpass");
                    }
                }
            }

            $this->data['message'] = strip_tags($this->mod_login->validate_admin_login());
            if ($this->data['message'] == 'Login Successful') {
                $this->data['msg_class'] = 'sukses';
                redirect('home');
            } else {
                $this->data['msg_class'] = 'gagal';
            }
        } /*else if(isset()){

    		}*/


        ///////////////////////
        $this->data['cookieRemember'] = $this->input->cookie('remember');
        $this->data['cookieUsername'] = $this->input->cookie('username');
        $this->data['cookiePassword'] = $this->input->cookie('userpass');
        //echo $this->data['cookieRemember'];echo $this->data['cookieUsername']; echo $this->data['cookiePassword'];
        //////////////////////

        $this->data['cookiename'] = $this->input->cookie('name', false);
        $this->data['cookieimage'] = $this->input->cookie('image', false);

        $sess_msg = $this->session->userdata('session_msg');
        $session_msg_class = $this->session->userdata('session_msg_class');
        if (isset($sess_msg) && $sess_msg != '') {
            $this->data['message'] = $sess_msg;
            $this->data['msg_class'] = $session_msg_class != '' ? $session_msg_class : 'gagal';
        }
        //render full layout, specific to this function
        $this->load->view('loginmain', $this->data);


    }

    ////////////////////////////////////////////////////////////////////////////////
    function forgot_password()
    {
        $this->load->view('send_reset_link', $this->data);
    }

    function send_pass_reset_link()
    {

        $post_array = $this->input->post();
        if ($post_array['email'] != '') {
            $email_id = $post_array['email'];

            $user_id = $this->mod_common->get_userid($post_array['email']);

            foreach ($user_id as $key) {
                $id = $key['id'];
            }

            if ($id > 0) {

                $link = base_url() . 'login/reset_password/' . $id;
                $message_body = "<table>
    			<tr><td style='padding:10px 0px'>Dear User,</td></tr>
    			<tr><td style='padding:10px 0px'>You have received this communication in response to your request to reset your online portal account password. Please find below the link to reset your password</td></tr>
    			<tr ><td style='padding:10px 0px'><a href='" . $link . "' style='background:#86c337;text-decoration:none;padding:5px 10px;color:#fff'> Reset Password </a></td></tr>
    			<tr ><td style='padding:10px 0px'>Regards,<br>Unfold</td></tr>
    			</table>";

                /*-------------------------*/
                //sending pass reset mail
                $this->load->library('email');
                $config['protocol'] = 'sendmail';
                $config['mailpath'] = '/usr/sbin/sendmail';
                $config['charset'] = 'iso-8859-1';
                $config['wordwrap'] = true;
                $config['mailtype'] = 'html';
                $this->email->initialize($config);

                $this->email->set_newline("\r\n");
                $this->email->from("info@unfold.com", "Admin");//email id and name of the sender
                $this->email->to($email_id); // email id of the recipient
                $this->email->subject("Reset Password"); //The subject line
                $this->email->message($message_body);
                $this->email->send();
                //$this->email->clear();
                //show_error($this->email->print_debugger());
                //die;
                /*-------------------------*/
                $this->data['reset_link_msg'] = "An email with the password reset link has been sent to your mail address.";
            } else {
                $this->data['reset_link_msg'] = "Sorry! The email entered is not in our database.";
            }
        } else {
            $this->data['reset_link_msg'] = '';
        }

        $this->load->view('send_reset_link', $this->data);

    }

    function reset_password()
    {
        if ($this->input->post()) {

            $post_array = $this->input->post();
            $this->data['reset_msg'] = $this->mod_common->reset_password($post_array);
            $this->load->view('reset_password', $this->data);
        }

        if ($this->uri->segment(3) != '') {
            $this->data['id'] = $this->uri->segment(3);
            $this->load->view('reset_password', $this->data);
        } else {
            redirect('login');
        }
    }
    
    // Admin authentication ----------
}
&#13;
&#13;
&#13;

0 个答案:

没有答案