示例#1
0
文件: payment.php 项目: nebjak/GoCart
 function settings($module)
 {
     $this->load->library('payment/' . $module . '/' . $module);
     //ok, in order for the most flexibility, and in case someone wants to use javascript or something
     //the form gets pulled directly from the library.
     if (count($_POST) > 0) {
         $check = $this->{$module}->check();
         if (!$check) {
             $this->session->set_flashdata('message', $module . ' settings have been updated');
             secure_redirect($this->config->item('admin_folder') . '/payment');
         } else {
             //set the error data and form data in the flashdata
             $this->session->set_flashdata('message', $check);
             $this->session->set_flashdata('post', $_POST);
             secure_redirect($this->config->item('admin_folder') . '/payment/settings/' . $module);
         }
     } elseif ($this->session->flashdata('post')) {
         $data['form'] = $this->{$module}->form($this->session->flashdata('post'));
     } else {
         $data['form'] = $this->{$module}->form();
     }
     $data['module'] = $module;
     $data['page_title'] = '"' . $module . '" Payment Settings';
     $this->load->view($this->config->item('admin_folder') . '/payment_module_settings', $data);
 }
示例#2
0
文件: login.php 项目: nebjak/GoCart
 function logout()
 {
     $this->auth->logout();
     //when someone logs out, automatically redirect them to the login page.
     $this->session->set_flashdata('message', 'You have been logged out.');
     secure_redirect($this->config->item('admin_folder') . '/login');
 }
示例#3
0
文件: Auth.php 项目: nebjak/GoCart
 function is_logged_in($redirect = false, $default_redirect = true)
 {
     //var_dump($this->CI->session->userdata('session_id'));
     //$redirect allows us to choose where a customer will get redirected to after they login
     //$default_redirect points is to the login page, if you do not want this, you can set it to false and then redirect wherever you wish.
     $admin = $this->CI->session->userdata('admin');
     if (!$admin) {
         if ($redirect) {
             $this->CI->session->set_flashdata('redirect', $redirect);
         }
         if ($default_redirect) {
             secure_redirect($this->CI->config->item('admin_folder') . '/login');
         }
         return false;
     } else {
         //check if the session is expired if not reset the timer
         if ($admin['expire'] && $admin['expire'] < time()) {
             $this->logout();
             if ($redirect) {
                 $this->CI->session->set_flashdata('redirect', $redirect);
             }
             if ($default_redirect) {
                 secure_redirect($this->CI->config->item('admin_folder') . '/login');
             }
             return false;
         } else {
             //update the session expiration to last more time if they are not remembered
             if ($admin['expire']) {
                 $admin['expire'] = time() + $this->session_expire;
                 $this->CI->session->set_userdata(array('admin' => $admin));
             }
         }
         return true;
     }
 }
示例#4
0
文件: pp_gate.php 项目: nebjak/GoCart
 function pp_cancel()
 {
     //make sure they're logged in if the config file requires it
     if ($this->config->item('require_login')) {
         $this->Customer_model->is_logged_in();
     }
     // User canceled using paypal, send them back to the payment page
     $cart = $this->session->userdata('cart');
     $this->session->set_flashdata('message', "<div>Paypal transaction canceled, select another payment method</div>");
     secure_redirect('scheckout');
 }
示例#5
0
 function is_logged_in($redirect = false, $default_redirect = 'secure/login/')
 {
     //$redirect allows us to choose where a customer will get redirected to after they login
     //$default_redirect points is to the login page, if you do not want this, you can set it to false and then redirect wherever you wish.
     $customer = $this->go_cart->customer();
     if (!isset($customer['id'])) {
         //this tells gocart where to go once logged in
         if ($redirect) {
             $this->session->set_flashdata('redirect', $redirect);
         }
         if ($default_redirect) {
             secure_redirect($default_redirect);
         }
         return false;
     } else {
         //check if the session is expired if not reset the timer
         if ($customer['expire'] && $customer['expire'] < time()) {
             $this->logout();
             if ($redirect) {
                 $this->session->set_flashdata('redirect', $redirect);
             }
             if ($default_redirect) {
                 redirect('login');
             }
             return false;
         } else {
             //update the session expiration to last more time if they are not remembered
             if ($customer['expire']) {
                 $customer['expire'] = time() + $this->session_expire;
                 $this->go_cart->save_customer($customer);
             }
         }
         return true;
     }
 }
示例#6
0
文件: secure.php 项目: nebjak/GoCart
 function my_account($offset = 0)
 {
     //make sure they're logged in
     $this->Customer_model->is_logged_in('secure/my_account/');
     $data['gift_cards_enabled'] = $this->gift_cards_enabled;
     $data['customer'] = $this->go_cart->customer();
     $data['addresses'] = $this->Customer_model->get_address_list($this->customer['id']);
     $data['page_title'] = 'Welcome ' . $data['customer']['firstname'] . ' ' . $data['customer']['lastname'];
     $data['customer_addresses'] = $this->Customer_model->get_address_list($data['customer']['id']);
     // load other page content
     //$this->load->model('banner_model');
     $this->load->model('order_model');
     $this->load->helper('directory');
     $this->load->helper('date');
     //if they want to limit to the top 5 banners and use the enable/disable on dates, add true to the get_banners function
     //	$data['banners']	= $this->banner_model->get_banners();
     //	$data['ads']		= $this->banner_model->get_banners(true);
     $data['categories'] = $this->Category_model->get_categories_tierd(0);
     // paginate the orders
     $this->load->library('pagination');
     $config['base_url'] = secure_base_url() . 'secure/my_account';
     $config['total_rows'] = $this->order_model->count_customer_orders($this->customer['id']);
     $config['per_page'] = '15';
     $this->pagination->initialize($config);
     $data['orders_pagination'] = $this->pagination->create_links();
     $data['orders'] = $this->order_model->get_customer_orders($this->customer['id'], $offset);
     //if they're logged in, then we have all their acct. info in the cookie.
     /*
     This is for the customers to be able to edit their account information
     */
     $this->load->library('form_validation');
     $this->form_validation->set_rules('company', 'Company', 'trim|max_length[128]');
     $this->form_validation->set_rules('firstname', 'First Name', 'trim|required|max_length[32]');
     $this->form_validation->set_rules('lastname', 'Last Name', 'trim|required|max_length[32]');
     $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email|max_length[128]|callback_check_email');
     $this->form_validation->set_rules('phone', 'Phone', 'trim|required|max_length[32]');
     $this->form_validation->set_rules('email_subscribe', 'Subscribe', 'trim|numeric|max_length[1]');
     if ($this->input->post('password') != '' || $this->input->post('confirm') != '') {
         $this->form_validation->set_rules('password', 'Password', 'required|min_length[6]|sha1');
         $this->form_validation->set_rules('confirm', 'Confirm Password', 'required|matches[password]');
     } else {
         $this->form_validation->set_rules('password', 'Password');
         $this->form_validation->set_rules('confirm', 'Confirm Password');
     }
     if ($this->form_validation->run() == FALSE) {
         $this->load->view('my_account', $data);
     } else {
         $customer = array();
         $customer['id'] = $this->customer['id'];
         $customer['company'] = set_value('company');
         $customer['firstname'] = set_value('firstname');
         $customer['lastname'] = set_value('lastname');
         $customer['email'] = set_value('email');
         $customer['phone'] = set_value('phone');
         $customer['email_subscribe'] = set_value('email_subscribe');
         if ($this->input->post('password') != '') {
             $customer['password'] = set_value('password');
         }
         $this->customer['company'] = set_value('company');
         $this->customer['firstname'] = set_value('firstname');
         $this->customer['lastname'] = set_value('lastname');
         $this->customer['email'] = set_value('email');
         $this->customer['phone'] = set_value('phone');
         $this->customer['email_subscribe'] = set_value('email_subscribe');
         $this->go_cart->save_customer($this->customer);
         $this->Customer_model->save($customer);
         $this->session->set_flashdata('message', 'Your account has been updated');
         secure_redirect('secure/my_account');
         //$this->load->view('my_account', $data);
     }
 }
示例#7
0
 function place_order()
 {
     // retrieve the payment method
     $payment = $this->go_cart->payment_method();
     //die(var_dump($payment));
     // verify that we intend to place the order
     if (!$this->input->post('process_order') && !isset($payment['confirmed'])) {
         redirect('/');
         // otherwise, send them packing
     }
     //make sure they're logged in if the config file requires it
     if ($this->config->item('require_login')) {
         $this->Customer_model->is_logged_in();
     }
     // are we processing an empty cart?
     $contents = $this->go_cart->contents();
     if (empty($contents)) {
         redirect('cart/view_cart');
     } else {
         // do some secondary validation on cart contents before we continue
         //  - check to see if we have a payment method set, if we need one
         if (empty($payment) && $this->go_cart->total() > 0) {
             secure_redirect('checkout');
         }
     }
     // Is payment bypassed? (total is zero, or processed flag is set)
     if ($this->go_cart->total() > 0 && !isset($payment['confirmed'])) {
         //lost the payment module
         $this->load->library('payment/' . $payment['module'] . '/' . $payment['module']);
         //run the payment
         $error_status = $this->{$payment}['module']->process_payment();
         if ($error_status !== false) {
             // send them back to the checkout page with the error
             $this->session->set_flashdata('error', $error_status);
             secure_redirect('checkout');
         }
     }
     //// save the order
     $order_id = $this->go_cart->save_order();
     $data['order_id'] = $order_id;
     $data['shipping'] = $this->go_cart->shipping_method();
     $data['payment'] = $this->go_cart->payment_method();
     $data['customer'] = $this->go_cart->customer();
     $data['additional_details'] = $this->go_cart->additional_details();
     $data['hide_menu'] = true;
     // Send the user a confirmation email
     // - get the email template
     $this->load->model('messages_model');
     $row = $this->messages_model->get_message(7);
     $row['content'] = html_entity_decode($row['content']);
     // set replacement values for subject & body
     // {customer_name}
     $row['subject'] = str_replace('{customer_name}', $data['customer']['firstname'] . ' ' . $data['customer']['lastname'], $row['subject']);
     $row['content'] = str_replace('{customer_name}', $data['customer']['firstname'] . ' ' . $data['customer']['lastname'], $row['content']);
     // {url}
     $row['subject'] = str_replace('{url}', $this->config->item('base_url'), $row['subject']);
     $row['content'] = str_replace('{url}', $this->config->item('base_url'), $row['content']);
     // {site_name}
     $row['subject'] = str_replace('{site_name}', $this->config->item('company_name'), $row['subject']);
     $row['content'] = str_replace('{site_name}', $this->config->item('company_name'), $row['content']);
     // {order_summary}
     $row['content'] = str_replace('{order_summary}', $this->load->view('order_email', $data, true), $row['content']);
     $this->load->library('email');
     $config['mailtype'] = 'html';
     $this->email->initialize($config);
     $this->email->from($this->config->item('email'), $this->config->item('company_name'));
     if ($this->Customer_model->is_logged_in(false, false)) {
         $this->email->to($data['customer']['email']);
     } else {
         $this->email->to($data['customer']['ship_address']['email']);
     }
     //email the admin
     $this->email->bcc($this->config->item('email'));
     $this->email->subject($row['subject']);
     $this->email->message($row['content']);
     $this->email->send();
     $data['page_title'] = 'Thanks for shopping with ' . $this->config->item('company_name');
     $data['gift_cards_enabled'] = $this->gift_cards_enabled;
     // show final confirmation page
     $this->load->view('order_placed', $data);
     //remove the cart from the session
     $this->go_cart->destroy();
 }
示例#8
0
 function delete_message($id)
 {
     $this->Messages_model->delete_message($id);
     secure_redirect($this->config->item('admin_folder') . '/settings');
 }