public function getPayload()
 {
     $code = Input::get('code');
     $api_key = Input::get('api_key');
     $license_key = Input::get('license');
     $activate = Input::get('activate');
     $current_url = url("admin/licenses/payload?code={$code}&api_key={$api_key}&license={$license_key}");
     // Page Title
     $this->_data['page_title'] = "Licenses - Get Payload";
     $this->_data['license_key'] = $license_key;
     $this->_data['uses'] = LicensesUses::getAllUsage($license_key);
     // Include libraries
     require_once app_path() . "/libraries/Curl/Curl.php";
     $params = array("code" => $code, "license" => $license_key);
     $curl = new Curl();
     if ($activate) {
         $params['guid'] = time();
     }
     $params['key'] = DKHelpers::GenerateHash($params, $api_key);
     if ($activate) {
         $response = $curl->simple_post(url('api/v1/license-manager/activate'), $params, array(CURLOPT_BUFFERSIZE => 10));
         $response = json_decode($response);
         if (isset($response->success) and $response->success == 'false') {
             if (isset($response->overusage) and $response->overusage == 'true') {
                 Session::flash('alert_error', '<strong>Alert!</strong> License cannot be activated due to overusage.');
                 return Redirect::to($current_url);
             }
         } else {
             Session::flash('alert_message', '<strong>Done!</strong> License has been activated successfully.');
             return Redirect::to($current_url);
         }
     }
     // Get Payload
     $this->_data['payload'] = $curl->simple_post(url('api/v1/license-manager'), $params, array(CURLOPT_BUFFERSIZE => 10));
     $this->_data['activate_url'] = $current_url . '&activate=true';
     return View::make('admin.licenses.payload', $this->_data)->nest('header', 'admin.common.header', $this->_data)->nest('footer', 'admin.common.footer', $this->_data);
 }
Ejemplo n.º 2
0
 /**
  * Get user licenses
  *
  * Lists all licenses of a use for a product
  */
 public function postGetUserLicenses()
 {
     if ($this->_isValidRequest()) {
         $email = Input::get('email');
         $product_code = Input::get('code');
         if (!$email or !$product_code) {
             $this->_invalidRequest();
         }
         $product = Product::where('code', '=', $product_code)->first();
         if (!$product) {
             $this->_invalidRequest();
         }
         $licenses = License::search($email, 'email', $product->code);
         $data = array();
         foreach ($licenses as $key => $license) {
             $usage = LicensesUses::getAllUsage($license->license_key);
             $data[] = array('license' => $license, 'usage' => $usage);
         }
         return Response::json($data);
     }
 }