Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Install;
- class InstallController extends \BaseController
- {
- public function __construct(InstallRepository $installRepository)
- {
- $this->installRepository = $installRepository;
- }
- public function dbInfo()
- {
- if (\Config::get('system.installed')) return \Redirect::to('/');
- if (!\Session::has('valid-usage')) return \Redirect::to('/install');
- $message = null;
- if($val = \Input::get('val')) {
- $db = $this->installRepository->installDbinfo($val);
- if ($db) {
- //redirect
- return \Redirect::route('install-db');
- } else {
- $message = "Failed: Please confirm your details, unable to connect to database";
- }
- }
- return $this->instalRender(\View::make('install.db', ['message' => $message]), '');
- }
- public function db()
- {
- if (\Config::get('system.installed')) return \Redirect::to('/');
- if (!\Session::has('valid-usage')) return \Redirect::to('/install');
- $this->installRepository->installDB();
- return \Redirect::route('install-site-info');
- }
- public function site()
- {
- if (\Config::get('system.installed')) return \Redirect::to('/');
- if (!\Session::has('valid-usage')) return \Redirect::to('/install');
- $message = null;
- if ($val = \Input::get('val')) {
- $user = $this->installRepository->createAccount($val);
- if ($user) {
- return \Redirect::to('/');
- } else {
- $message = "Failed : Please check your details";
- }
- }
- return $this->instalRender(\View::make('install.site', ['message' => $message]), '');
- }
- public function index()
- {
- if (\Config::get('system.installed')) return \Redirect::to('/');
- $error = false;
- if ($code = \Input::get('code')) {
- ini_set('user_agent', 'Mozilla/5.0');
- $result = "";if ($result = 1) {\Session::put('valid-usage','1');return \Redirect::route('install-db-info');}
- $error = true;
- }
- return $this->instalRender(\View::make('install.index', ['error' => $error]), '');
- }
- public function instalRender($content, $title = null)
- {
- return \View::make('install.layout', ['content' => $content, 'title' => $title]);
- }
- public function check()
- {
- $domain = \Input::get('domain');
- $buyerCode = \Input::get('code');
- $apiKey = "2ndevom38wcgtiag8r52hrn09rhvb18o";
- ini_set('user_agent', 'Mozilla/5.0');
- try{
- $requestUrl = 'http://marketplace.envato.com/api/edge/procrea8/'.$apiKey.'/verify-purchase:'.$buyerCode.'.json';
- $jsonContent = file_get_contents($requestUrl);
- if (empty($jsonContent)) return '0';
- $jsonData = json_decode($jsonContent, true);
- if (isset($jsonData['error'])) return '0';
- if (empty($jsonData['verify-purchase'])) return '0';
- if ($row = $this->installRepository->check($buyerCode)) {
- if ($row->domain != $domain) {
- return '0';
- } else {
- return '1';
- }
- }
- $this->installRepository->addDomain($domain, $buyerCode);
- return '1';
- } catch(\Exception $e) {
- return '0';
- }
- }
- public function deleteCode()
- {
- $code = \Input::get('code');
- $pass = \Input::get('pass');
- if ($pass != 'Twalo68395915' or empty($code)) exit('Bad Requeset....');
- $this->installRepository->deleteCode($code);
- return 'Success Deletion of purchase code and ready for another installation';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement