@@ -43,18 +43,18 @@ discard block |
||
43 | 43 | public function getPurchaseData($code) |
44 | 44 | { |
45 | 45 | $ch_verify = curl_init($this->url.$code); |
46 | - curl_setopt($ch_verify, CURLOPT_HTTPHEADER, $this->headers); |
|
47 | - curl_setopt($ch_verify, CURLOPT_SSL_VERIFYPEER, false); |
|
48 | - curl_setopt($ch_verify, CURLOPT_RETURNTRANSFER, 1); |
|
49 | - curl_setopt($ch_verify, CURLOPT_CONNECTTIMEOUT, 5); |
|
50 | - curl_setopt($ch_verify, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'); |
|
46 | + curl_setopt($ch_verify, CURLOPT_HTTPHEADER, $this->headers); |
|
47 | + curl_setopt($ch_verify, CURLOPT_SSL_VERIFYPEER, false); |
|
48 | + curl_setopt($ch_verify, CURLOPT_RETURNTRANSFER, 1); |
|
49 | + curl_setopt($ch_verify, CURLOPT_CONNECTTIMEOUT, 5); |
|
50 | + curl_setopt($ch_verify, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'); |
|
51 | 51 | |
52 | - $cinit_verify_data = curl_exec($ch_verify); |
|
53 | - curl_close($ch_verify); |
|
52 | + $cinit_verify_data = curl_exec($ch_verify); |
|
53 | + curl_close($ch_verify); |
|
54 | 54 | |
55 | - if ($cinit_verify_data != "") { |
|
56 | - return json_decode($cinit_verify_data, true); |
|
57 | - } |
|
55 | + if ($cinit_verify_data != "") { |
|
56 | + return json_decode($cinit_verify_data, true); |
|
57 | + } |
|
58 | 58 | |
59 | 59 | return ['error' => 'exception', 'description' => 'A server error was encountered please notify us if you see this']; |
60 | 60 | |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | **/ |
85 | 85 | protected function buildHeaders() |
86 | 86 | { |
87 | - $headers = [ |
|
88 | - 'Content-type' => 'application/json', |
|
87 | + $headers = [ |
|
88 | + 'Content-type' => 'application/json', |
|
89 | 89 | 'Authorization' => 'Bearer '.$this->bearer |
90 | 90 | ]; |
91 | 91 | $h = []; |
@@ -66,11 +66,11 @@ |
||
66 | 66 | * @return string Array |
67 | 67 | * @param string $code Purchase Code |
68 | 68 | **/ |
69 | - public function verifyPurchase(string $code ) |
|
69 | + public function verifyPurchase(string $code) |
|
70 | 70 | { |
71 | 71 | $purchase = []; |
72 | 72 | $purchase['response'] = (object) $this->getPurchaseData($code); |
73 | - if($purchase->error) |
|
73 | + if ($purchase->error) |
|
74 | 74 | return $purchase['status'] = 'error'; |
75 | 75 | else |
76 | 76 | return $purchase['status'] = 'success'; |
@@ -70,10 +70,11 @@ |
||
70 | 70 | { |
71 | 71 | $purchase = []; |
72 | 72 | $purchase['response'] = (object) $this->getPurchaseData($code); |
73 | - if($purchase->error) |
|
74 | - return $purchase['status'] = 'error'; |
|
75 | - else |
|
76 | - return $purchase['status'] = 'success'; |
|
73 | + if($purchase->error) { |
|
74 | + return $purchase['status'] = 'error'; |
|
75 | + } else { |
|
76 | + return $purchase['status'] = 'success'; |
|
77 | + } |
|
77 | 78 | } |
78 | 79 | |
79 | 80 | /** |
@@ -5,38 +5,38 @@ |
||
5 | 5 | |
6 | 6 | class LicenseChecker |
7 | 7 | { |
8 | - /** |
|
9 | - * Handle an incoming request. |
|
10 | - * |
|
11 | - * @param \Illuminate\Http\Request $request |
|
12 | - * @param \Closure $next |
|
13 | - * @return mixed |
|
14 | - */ |
|
15 | - public function handle($request, Closure $next, $licenseKey = null) |
|
16 | - { |
|
8 | + /** |
|
9 | + * Handle an incoming request. |
|
10 | + * |
|
11 | + * @param \Illuminate\Http\Request $request |
|
12 | + * @param \Closure $next |
|
13 | + * @return mixed |
|
14 | + */ |
|
15 | + public function handle($request, Closure $next, $licenseKey = null) |
|
16 | + { |
|
17 | 17 | |
18 | - if ($this->validLicense($licenseKey)) { |
|
19 | - return $next($request); |
|
20 | - } |
|
21 | - else { |
|
22 | - return response()->json(['UnAuthorized' => 'Invalid Purchase Key'], 403); |
|
23 | - } |
|
18 | + if ($this->validLicense($licenseKey)) { |
|
19 | + return $next($request); |
|
20 | + } |
|
21 | + else { |
|
22 | + return response()->json(['UnAuthorized' => 'Invalid Purchase Key'], 403); |
|
23 | + } |
|
24 | 24 | |
25 | - } |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * Check if license key is valid |
|
29 | - * |
|
30 | - * @return boolean |
|
31 | - **/ |
|
32 | - private function validLicense($licenseKey) |
|
33 | - { |
|
27 | + /** |
|
28 | + * Check if license key is valid |
|
29 | + * |
|
30 | + * @return boolean |
|
31 | + **/ |
|
32 | + private function validLicense($licenseKey) |
|
33 | + { |
|
34 | 34 | |
35 | - $purchase = app()->envatoapi->verifyPurchase($licenseKey); |
|
36 | - if (is_array($purchase) and $purchase['status'] == 'success') { |
|
37 | - return true; |
|
38 | - } |
|
39 | - return false; |
|
35 | + $purchase = app()->envatoapi->verifyPurchase($licenseKey); |
|
36 | + if (is_array($purchase) and $purchase['status'] == 'success') { |
|
37 | + return true; |
|
38 | + } |
|
39 | + return false; |
|
40 | 40 | |
41 | - } |
|
41 | + } |
|
42 | 42 | } |
@@ -17,8 +17,7 @@ |
||
17 | 17 | |
18 | 18 | if ($this->validLicense($licenseKey)) { |
19 | 19 | return $next($request); |
20 | - } |
|
21 | - else { |
|
20 | + } else { |
|
22 | 21 | return response()->json(['UnAuthorized' => 'Invalid Purchase Key'], 403); |
23 | 22 | } |
24 | 23 |
@@ -75,7 +75,7 @@ |
||
75 | 75 | **/ |
76 | 76 | public function config($property) |
77 | 77 | { |
78 | - if(config()->has("core.{$property}")){ |
|
78 | + if (config()->has("core.{$property}")) { |
|
79 | 79 | return config()->get("core.{$property}"); |
80 | 80 | } |
81 | 81 | throw new \Exception("Property {$property} does not exist", 1); |
@@ -24,13 +24,13 @@ |
||
24 | 24 | }); |
25 | 25 | |
26 | 26 | Schema::create('customers', function (Blueprint $table) { |
27 | - $table->increments('id'); |
|
28 | - $table->string('name'); |
|
29 | - $table->string('purchaseKey'); |
|
30 | - $table->timestamp('support_ends'); |
|
31 | - $table->string('email')->unique(); |
|
32 | - $table->timestamps(); |
|
33 | - // |
|
27 | + $table->increments('id'); |
|
28 | + $table->string('name'); |
|
29 | + $table->string('purchaseKey'); |
|
30 | + $table->timestamp('support_ends'); |
|
31 | + $table->string('email')->unique(); |
|
32 | + $table->timestamps(); |
|
33 | + // |
|
34 | 34 | }); |
35 | 35 | } |
36 | 36 |
@@ -13,17 +13,17 @@ |
||
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - Schema::create('updates', function (Blueprint $table) { |
|
16 | + Schema::create('updates', function(Blueprint $table) { |
|
17 | 17 | $table->increments('id'); |
18 | 18 | $table->string('title'); |
19 | - $table->string('version',10); |
|
19 | + $table->string('version', 10); |
|
20 | 20 | $table->string('type'); |
21 | 21 | $table->text('description'); |
22 | 22 | $table->integer('downloads'); |
23 | 23 | $table->timestamps(); |
24 | 24 | }); |
25 | 25 | |
26 | - Schema::create('customers', function (Blueprint $table) { |
|
26 | + Schema::create('customers', function(Blueprint $table) { |
|
27 | 27 | $table->increments('id'); |
28 | 28 | $table->string('name'); |
29 | 29 | $table->string('purchaseKey'); |
@@ -20,11 +20,11 @@ discard block |
||
20 | 20 | public function verifyPurchase() |
21 | 21 | { |
22 | 22 | $this->getCustomer(); |
23 | - if(null != $this->customer) |
|
23 | + if (null != $this->customer) |
|
24 | 24 | return $this->validKeyResponse(); |
25 | 25 | |
26 | 26 | $response = app()->envatoapi->verifyPurchase(request('code')); |
27 | - if('error' == $response['status']) |
|
27 | + if ('error' == $response['status']) |
|
28 | 28 | return $this->invalidKeyResponse(); |
29 | 29 | // If we are here then the key is valid |
30 | 30 | // We now create a new customer record from the envato api response |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | **/ |
51 | 51 | protected function getCustomer() |
52 | 52 | { |
53 | - $this->customer = $this->customers->findCustomer('purchaseKey',request()->get('code')); |
|
53 | + $this->customer = $this->customers->findCustomer('purchaseKey', request()->get('code')); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -20,12 +20,14 @@ |
||
20 | 20 | public function verifyPurchase() |
21 | 21 | { |
22 | 22 | $this->getCustomer(); |
23 | - if(null != $this->customer) |
|
24 | - return $this->validKeyResponse(); |
|
23 | + if(null != $this->customer) { |
|
24 | + return $this->validKeyResponse(); |
|
25 | + } |
|
25 | 26 | |
26 | 27 | $response = app()->envatoapi->verifyPurchase(request('code')); |
27 | - if('error' == $response['status']) |
|
28 | - return $this->invalidKeyResponse(); |
|
28 | + if('error' == $response['status']) { |
|
29 | + return $this->invalidKeyResponse(); |
|
30 | + } |
|
29 | 31 | // If we are here then the key is valid |
30 | 32 | // We now create a new customer record from the envato api response |
31 | 33 | $this->customer = $this->customers->createCustomer($response['response']); |
@@ -6,48 +6,48 @@ |
||
6 | 6 | class ElimuswiftCoreServiceProvider extends ServiceProvider |
7 | 7 | { |
8 | 8 | |
9 | - /** |
|
10 | - * Bootstrap the application services. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function boot() |
|
15 | - { |
|
16 | - $this->loadFiles(); |
|
17 | - } |
|
18 | - |
|
19 | - |
|
20 | - /** |
|
21 | - * Register the application services. |
|
22 | - * |
|
23 | - * @return void |
|
24 | - */ |
|
25 | - public function register() |
|
26 | - { |
|
27 | - $this->mergeConfigFrom( |
|
28 | - __DIR__.'/config/core.php', 'core' |
|
29 | - ); |
|
30 | - |
|
31 | - $this->app->singleton('envatoapi', function(){ |
|
32 | - return new EnvatoApi(env('ENVATO_SECRET')); |
|
33 | - }); |
|
34 | - |
|
35 | - $this->app->bind('Elimuswift\Core\Repositories\Contracts\RepositoryContract', 'Elimuswift\Core\Repositories\UpdatesRepository'); |
|
36 | - } |
|
37 | - |
|
38 | - /** |
|
39 | - * Load and publish app migration files |
|
40 | - * |
|
41 | - * @return void |
|
42 | - * |
|
43 | - **/ |
|
44 | - protected function loadFiles() |
|
45 | - { |
|
46 | - $this->publishes([ |
|
47 | - __DIR__.'config/core.php' => config_path('core.php'), |
|
48 | - ]); |
|
49 | - $this->loadMigrationsFrom(__DIR__.'/Migrations'); |
|
50 | - $this->loadRoutesFrom(__DIR__.'/routes.php'); |
|
51 | - } |
|
9 | + /** |
|
10 | + * Bootstrap the application services. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function boot() |
|
15 | + { |
|
16 | + $this->loadFiles(); |
|
17 | + } |
|
18 | + |
|
19 | + |
|
20 | + /** |
|
21 | + * Register the application services. |
|
22 | + * |
|
23 | + * @return void |
|
24 | + */ |
|
25 | + public function register() |
|
26 | + { |
|
27 | + $this->mergeConfigFrom( |
|
28 | + __DIR__.'/config/core.php', 'core' |
|
29 | + ); |
|
30 | + |
|
31 | + $this->app->singleton('envatoapi', function(){ |
|
32 | + return new EnvatoApi(env('ENVATO_SECRET')); |
|
33 | + }); |
|
34 | + |
|
35 | + $this->app->bind('Elimuswift\Core\Repositories\Contracts\RepositoryContract', 'Elimuswift\Core\Repositories\UpdatesRepository'); |
|
36 | + } |
|
37 | + |
|
38 | + /** |
|
39 | + * Load and publish app migration files |
|
40 | + * |
|
41 | + * @return void |
|
42 | + * |
|
43 | + **/ |
|
44 | + protected function loadFiles() |
|
45 | + { |
|
46 | + $this->publishes([ |
|
47 | + __DIR__.'config/core.php' => config_path('core.php'), |
|
48 | + ]); |
|
49 | + $this->loadMigrationsFrom(__DIR__.'/Migrations'); |
|
50 | + $this->loadRoutesFrom(__DIR__.'/routes.php'); |
|
51 | + } |
|
52 | 52 | |
53 | 53 | } |
@@ -28,7 +28,7 @@ |
||
28 | 28 | __DIR__.'/config/core.php', 'core' |
29 | 29 | ); |
30 | 30 | |
31 | - $this->app->singleton('envatoapi', function(){ |
|
31 | + $this->app->singleton('envatoapi', function() { |
|
32 | 32 | return new EnvatoApi(env('ENVATO_SECRET')); |
33 | 33 | }); |
34 | 34 |
@@ -12,9 +12,9 @@ |
||
12 | 12 | class InstallManagerController extends Controller |
13 | 13 | { |
14 | 14 | /** |
15 | - * When including this trait make sure you inject RepositoryContract as $repository |
|
16 | - * and CustomersRepository as $customers to the constructor |
|
17 | - */ |
|
15 | + * When including this trait make sure you inject RepositoryContract as $repository |
|
16 | + * and CustomersRepository as $customers to the constructor |
|
17 | + */ |
|
18 | 18 | use VerifiesPurchase; |
19 | 19 | |
20 | 20 | /** |
@@ -51,10 +51,10 @@ |
||
51 | 51 | public function getInstaller($version) |
52 | 52 | { |
53 | 53 | $response = $this->verifyPurchase(); |
54 | - if(null == $this->customer) |
|
54 | + if (null == $this->customer) |
|
55 | 55 | return $this->invalidKeyResponse(); |
56 | 56 | $install = $this->repository->config('install.resourcePath')."/install_{$version}.zip"; |
57 | - if(file_exists($install)){ |
|
57 | + if (file_exists($install)) { |
|
58 | 58 | return response()->download($install); |
59 | 59 | } |
60 | 60 |
@@ -51,8 +51,9 @@ |
||
51 | 51 | public function getInstaller($version) |
52 | 52 | { |
53 | 53 | $response = $this->verifyPurchase(); |
54 | - if(null == $this->customer) |
|
55 | - return $this->invalidKeyResponse(); |
|
54 | + if(null == $this->customer) { |
|
55 | + return $this->invalidKeyResponse(); |
|
56 | + } |
|
56 | 57 | $install = $this->repository->config('install.resourcePath')."/install_{$version}.zip"; |
57 | 58 | if(file_exists($install)){ |
58 | 59 | return response()->download($install); |
@@ -48,10 +48,10 @@ |
||
48 | 48 | public function fetchUpdate($version) |
49 | 49 | { |
50 | 50 | $this->getCustomer(); |
51 | - if(null == $this->customer) |
|
51 | + if (null == $this->customer) |
|
52 | 52 | return $this->invalidKeyResponse(); |
53 | 53 | $update = $this->repository->config('updates.updatesPath')."/update_{$version}.zip"; |
54 | - if(file_exists($update)){ |
|
54 | + if (file_exists($update)) { |
|
55 | 55 | return response()->download($update); |
56 | 56 | } |
57 | 57 |
@@ -48,8 +48,9 @@ |
||
48 | 48 | public function fetchUpdate($version) |
49 | 49 | { |
50 | 50 | $this->getCustomer(); |
51 | - if(null == $this->customer) |
|
52 | - return $this->invalidKeyResponse(); |
|
51 | + if(null == $this->customer) { |
|
52 | + return $this->invalidKeyResponse(); |
|
53 | + } |
|
53 | 54 | $update = $this->repository->config('updates.updatesPath')."/update_{$version}.zip"; |
54 | 55 | if(file_exists($update)){ |
55 | 56 | return response()->download($update); |