示例#1
0
 public function create()
 {
     if ($_POST) {
         $customer = Stripe_Customer::create(array('email' => $_POST['email']));
         foreach ($_POST as $key => $value) {
             $_POST[$key] = urldecode($value);
         }
         include OTHERS . "PasswordHash.php";
         $new_password = $_POST['password'];
         $salt = $this->_get_random_string(16);
         $hashed_password = create_hash($new_password . $salt);
         $stateSplit = explode(' - ', $_POST['state']);
         $key = $this->_get_random_string(50);
         $user = array('firstname' => $_POST['firstname'], 'lastname' => $_POST['lastname'], 'password' => $hashed_password, 'salt' => $salt, 'phone' => $_POST['phone'], 'email' => $_POST['email'], 'country' => $_POST['country'], 'state' => $stateSplit[1], 'state_abbr' => $stateSplit[0], 'confirmation_key' => $key, 'stripe_customer_id' => $customer->id);
         if (isset($_POST['reg_plan_id'])) {
             $user['stripe_reg_plan_id'] = $_POST['reg_plan_id'];
         } else {
             $this->load->model('settings_model');
             $general = transformArrayToKeyValue($this->settings_model->get(array('category' => 'general')));
             $this->load->model('package_model');
             $package = $this->package_model->getPackage($general['trial_period_package']->v);
             $user['stripe_reg_plan_id'] = $package->stripe_plan_id;
         }
         if ($this->user_model->add($user)) {
             echo "OK";
         }
     } else {
         $this->index();
     }
 }
示例#2
0
 public function settings($page = "general")
 {
     $this->load->model('settings_model');
     $action = $this->input->post('action');
     // Actions for AJAX Call
     if ($action) {
         switch ($action) {
             case 'save_general':
                 $settings = $this->input->post('settings');
                 $result = $this->settings_model->save($settings);
                 break;
             default:
                 $this->output->set_status_header("400");
                 $result = array('success' => false, 'message' => 'Action not found');
                 break;
         }
         echo json_encode($result);
         // Page Rendering
     } else {
         if ($page == "general") {
             $this->load->model('package_model');
             $this->data['packages'] = $this->package_model->getPackage();
             $general = $this->settings_model->get(array('category' => 'general'));
             $this->data['general'] = transformArrayToKeyValue($general);
             $this->_renderA("pages/admin/settings_general", "Settings");
         }
     }
 }