Пример #1
0
 public function finish_install()
 {
     $braintree_cse = $stripe_publishable_key = $url = $timezone = $website_title = $s3_bucket = $twillo_account_sid = $twillo_auth_token = $twillo_number = $default_payment = $stripe_secret_key = $braintree_environment = $braintree_merchant_id = $braintree_public_key = $braintree_private_key = $customer_certy_url = $customer_certy_pass = $customer_certy_type = $provider_certy_url = $provider_certy_pass = $provider_certy_type = $gcm_browser_key = $key_provider = $key_user = $key_taxi = $key_trip = $key_currency = $total_trip = $cancelled_trip = $total_payment = $completed_trip = $card_payment = $credit_payment = $key_ref_pre = $android_client_app_url = $android_provider_app_url = $ios_client_app_url = $ios_provider_app_url = NULL;
     $braintree_environment = Config::get('app.braintree_environment');
     $braintree_merchant_id = Config::get('app.braintree_merchant_id');
     $braintree_public_key = Config::get('app.braintree_public_key');
     $braintree_private_key = Config::get('app.braintree_private_key');
     $braintree_cse = Config::get('app.braintree_cse');
     $twillo_account_sid = Config::get('app.twillo_account_sid');
     $twillo_auth_token = Config::get('app.twillo_auth_token');
     $twillo_number = Config::get('app.twillo_number');
     $timezone = Config::get('app.timezone');
     $stripe_publishable_key = Config::get('app.stripe_publishable_key');
     $url = Config::get('app.url');
     $website_title = Config::get('app.website_title');
     $s3_bucket = Config::get('app.s3_bucket');
     $default_payment = Config::get('app.default_payment');
     $stripe_secret_key = Config::get('app.stripe_secret_key');
     $mail_driver = Config::get('mail.driver');
     $email_name = Config::get('mail.from.name');
     $email_address = Config::get('mail.from.address');
     $mandrill_secret = Config::get('services.mandrill.secret');
     $host = Config::get('mail.host');
     /* DEVICE PUSH NOTIFICATION DETAILS */
     $customer_certy_url = Config::get('app.customer_certy_url');
     $customer_certy_pass = Config::get('app.customer_certy_pass');
     $customer_certy_type = Config::get('app.customer_certy_type');
     $provider_certy_url = Config::get('app.provider_certy_url');
     $provider_certy_pass = Config::get('app.provider_certy_pass');
     $provider_certy_type = Config::get('app.provider_certy_type');
     $gcm_browser_key = Config::get('app.gcm_browser_key');
     /* DEVICE PUSH NOTIFICATION DETAILS END */
     $install = array('braintree_environment' => $braintree_environment, 'braintree_merchant_id' => $braintree_merchant_id, 'braintree_public_key' => $braintree_public_key, 'braintree_private_key' => $braintree_private_key, 'braintree_cse' => $braintree_cse, 'twillo_account_sid' => $twillo_account_sid, 'twillo_auth_token' => $twillo_auth_token, 'twillo_number' => $twillo_number, 'stripe_publishable_key' => $stripe_publishable_key, 'stripe_secret_key' => $stripe_secret_key, 'mail_driver' => $mail_driver, 'email_address' => $email_address, 'email_name' => $email_name, 'mandrill_secret' => $mandrill_secret, 'default_payment' => $default_payment, 'customer_certy_url' => $customer_certy_url, 'customer_certy_pass' => $customer_certy_pass, 'customer_certy_type' => $customer_certy_type, 'provider_certy_url' => $provider_certy_url, 'provider_certy_pass' => $provider_certy_pass, 'provider_certy_type' => $provider_certy_type, 'gcm_browser_key' => $gcm_browser_key);
     // Modifying Database Config
     if (isset($_POST['sms'])) {
         $twillo_account_sid = Input::get('twillo_account_sid');
         $twillo_auth_token = Input::get('twillo_auth_token');
         $twillo_number = Input::get('twillo_number');
         $appfile = fopen(app_path() . "/config/app.php", "w") or die("Unable to open file!");
         /* $appfile_config = generate_app_config($braintree_cse, $stripe_publishable_key, $url, $timezone, $website_title, $s3_bucket, $twillo_account_sid, $twillo_auth_token, $twillo_number, $default_payment, $stripe_secret_key, $braintree_environment, $braintree_merchant_id, $braintree_public_key, $braintree_private_key); */
         $appfile_config = generate_app_config($braintree_cse, $stripe_publishable_key, $url, $timezone, $website_title, $s3_bucket, $twillo_account_sid, $twillo_auth_token, $twillo_number, $default_payment, $stripe_secret_key, $braintree_environment, $braintree_merchant_id, $braintree_public_key, $braintree_private_key, $customer_certy_url, $customer_certy_pass, $customer_certy_type, $provider_certy_url, $provider_certy_pass, $provider_certy_type, $gcm_browser_key, $key_provider, $key_user, $key_taxi, $key_trip, $key_currency, $total_trip, $cancelled_trip, $total_payment, $completed_trip, $card_payment, $credit_payment, $key_ref_pre, $android_client_app_url, $android_provider_app_url, $ios_client_app_url, $ios_provider_app_url);
         fwrite($appfile, $appfile_config);
         fclose($appfile);
     }
     if (isset($_POST['payment'])) {
         $default_payment = Input::get('default_payment');
         if ($default_payment == 'stripe') {
             if ($stripe_secret_key != trim(Input::get('stripe_secret_key')) || $stripe_publishable_key != trim(Input::get('stripe_publishable_key'))) {
                 /* DELETE CUSTOMER CARDS FROM DATABASE */
                 $delete_un_rq = DB::delete("DELETE FROM payment WHERE 1;");
                 /* DELETE CUSTOMER CARDS FROM DATABASE END */
                 $stripe_secret_key = Input::get('stripe_secret_key');
                 $stripe_publishable_key = Input::get('stripe_publishable_key');
                 $braintree_environment = '';
                 $braintree_merchant_id = '';
                 $braintree_public_key = '';
                 $braintree_private_key = '';
                 $braintree_cse = '';
                 $appfile = fopen(app_path() . "/config/app.php", "w") or die("Unable to open file!");
                 /* $appfile_config = generate_app_config($braintree_cse, $stripe_publishable_key, $url, $timezone, $website_title, $s3_bucket, $twillo_account_sid, $twillo_auth_token, $twillo_number, $default_payment, $stripe_secret_key, $braintree_environment, $braintree_merchant_id, $braintree_public_key, $braintree_private_key); */
                 $appfile_config = generate_app_config($braintree_cse, $stripe_publishable_key, $url, $timezone, $website_title, $s3_bucket, $twillo_account_sid, $twillo_auth_token, $twillo_number, $default_payment, $stripe_secret_key, $braintree_environment, $braintree_merchant_id, $braintree_public_key, $braintree_private_key, $customer_certy_url, $customer_certy_pass, $customer_certy_type, $provider_certy_url, $provider_certy_pass, $provider_certy_type, $gcm_browser_key, $key_provider, $key_user, $key_taxi, $key_trip, $key_currency, $total_trip, $cancelled_trip, $total_payment, $completed_trip, $card_payment, $credit_payment, $key_ref_pre, $android_client_app_url, $android_provider_app_url, $ios_client_app_url, $ios_provider_app_url);
                 fwrite($appfile, $appfile_config);
                 fclose($appfile);
             }
         } else {
             if ($braintree_environment != trim(Input::get('braintree_environment')) || $braintree_merchant_id != trim(Input::get('braintree_merchant_id')) || $braintree_public_key != trim(Input::get('braintree_public_key')) || $braintree_private_key != trim(Input::get('braintree_private_key')) || $braintree_cse != trim(Input::get('braintree_cse'))) {
                 /* DELETE CUSTOMER CARDS FROM DATABASE */
                 $delete_un_rq = DB::delete("DELETE FROM payment WHERE 1;");
                 /* DELETE CUSTOMER CARDS FROM DATABASE END */
                 $stripe_secret_key = '';
                 $stripe_publishable_key = '';
                 $braintree_environment = Input::get('braintree_environment');
                 $braintree_merchant_id = Input::get('braintree_merchant_id');
                 $braintree_public_key = Input::get('braintree_public_key');
                 $braintree_private_key = Input::get('braintree_private_key');
                 $braintree_cse = Input::get('braintree_cse');
                 $appfile = fopen(app_path() . "/config/app.php", "w") or die("Unable to open file!");
                 /* $appfile_config = generate_app_config($braintree_cse, $stripe_publishable_key, $url, $timezone, $website_title, $s3_bucket, $twillo_account_sid, $twillo_auth_token, $twillo_number, $default_payment, $stripe_secret_key, $braintree_environment, $braintree_merchant_id, $braintree_public_key, $braintree_private_key); */
                 $appfile_config = generate_app_config($braintree_cse, $stripe_publishable_key, $url, $timezone, $website_title, $s3_bucket, $twillo_account_sid, $twillo_auth_token, $twillo_number, $default_payment, $stripe_secret_key, $braintree_environment, $braintree_merchant_id, $braintree_public_key, $braintree_private_key, $customer_certy_url, $customer_certy_pass, $customer_certy_type, $provider_certy_url, $provider_certy_pass, $provider_certy_type, $gcm_browser_key, $key_provider, $key_user, $key_taxi, $key_trip, $key_currency, $total_trip, $cancelled_trip, $total_payment, $completed_trip, $card_payment, $credit_payment, $key_ref_pre, $android_client_app_url, $android_provider_app_url, $ios_client_app_url, $ios_provider_app_url);
                 fwrite($appfile, $appfile_config);
                 fclose($appfile);
             }
         }
     }
     // Modifying Mail Config File
     if (isset($_POST['mail'])) {
         $mail_driver = Input::get('mail_driver');
         $email_name = Input::get('email_name');
         $email_address = Input::get('email_address');
         $mandrill_secret = Input::get('mandrill_secret');
         $mandrill_hostname = "";
         if ($mail_driver == 'mail') {
             $mandrill_hostname = "localhost";
         } elseif ($mail_driver == 'mandrill') {
             $mandrill_hostname = Input::get('host_name');
         }
         $mailfile = fopen(app_path() . "/config/mail.php", "w") or die("Unable to open file!");
         $mailfile_config = generate_mail_config($mandrill_hostname, $mail_driver, $email_name, $email_address);
         fwrite($mailfile, $mailfile_config);
         fclose($mailfile);
         if ($mail_driver == 'mandrill') {
             $mandrill_username = Input::get('user_name');
             $servicesfile = fopen(app_path() . "/config/services.php", "w") or die("Unable to open file!");
             $servicesfile_config = generate_services_config($mandrill_secret, $mandrill_username);
             fwrite($servicesfile, $servicesfile_config);
             fclose($servicesfile);
         }
     }
     $install = array('braintree_environment' => $braintree_environment, 'braintree_merchant_id' => $braintree_merchant_id, 'braintree_public_key' => $braintree_public_key, 'braintree_private_key' => $braintree_private_key, 'braintree_cse' => $braintree_cse, 'twillo_account_sid' => $twillo_account_sid, 'twillo_auth_token' => $twillo_auth_token, 'twillo_number' => $twillo_number, 'stripe_publishable_key' => $stripe_publishable_key, 'stripe_secret_key' => $stripe_secret_key, 'mail_driver' => $mail_driver, 'email_address' => $email_address, 'email_name' => $email_name, 'mandrill_secret' => $mandrill_secret, 'default_payment' => $default_payment, 'customer_certy_url' => $customer_certy_url, 'customer_certy_pass' => $customer_certy_pass, 'customer_certy_type' => $customer_certy_type, 'provider_certy_url' => $provider_certy_url, 'provider_certy_pass' => $provider_certy_pass, 'provider_certy_type' => $provider_certy_type, 'gcm_browser_key' => $gcm_browser_key);
     return Redirect::to('/admin/settings?success=1')->with('install', $install);
 }
 public function finish_install()
 {
     // Modifying Database Config
     $host = Session::get('host');
     $username = Session::get('username');
     $password = Session::get('password');
     $database = Session::get('database');
     $dbfile = fopen(app_path() . "/config/database.php", "w") or die("Unable to open file!");
     $dbfile_config = generate_db_config($host, $username, $password, $database);
     fwrite($dbfile, $dbfile_config);
     fclose($dbfile);
     // Modifying App Config File
     $url = Session::get('url');
     $website_title = Session::get('website_title');
     $timezone = Session::get('timezone');
     $twillo_account_sid = Session::get('twillo_account_sid');
     $twillo_auth_token = Session::get('twillo_auth_token');
     $twillo_number = Session::get('twillo_number');
     $default_payment = Session::get('default_payment');
     $default_storage = Session::get('default_storage');
     if ($default_payment == 'stripe') {
         $stripe_secret_key = Session::get('stripe_secret_key');
         $stripe_publishable_key = Session::get('stripe_publishable_key');
         $braintree_environment = '';
         $braintree_merchant_id = '';
         $braintree_public_key = '';
         $braintree_private_key = '';
         $braintree_cse = '';
     } else {
         $stripe_secret_key = '';
         $stripe_publishable_key = '';
         $braintree_environment = Session::get('braintree_environment');
         $braintree_merchant_id = Session::get('braintree_merchant_id');
         $braintree_public_key = Session::get('braintree_public_key');
         $braintree_private_key = Session::get('braintree_private_key');
         $braintree_cse = Session::get('braintree_cse');
     }
     if ($default_storage == 2) {
         $s3_bucket = Session::get('s3_bucket');
     } else {
         $s3_bucket = '';
     }
     $appfile = fopen(app_path() . "/config/app.php", "w") or die("Unable to open file!");
     $appfile_config = generate_app_config($braintree_cse, $stripe_publishable_key, $url, $timezone, $website_title, $s3_bucket, $twillo_account_sid, $twillo_auth_token, $twillo_number, $default_payment, $stripe_secret_key, $braintree_environment, $braintree_merchant_id, $braintree_public_key, $braintree_private_key);
     fwrite($appfile, $appfile_config);
     fclose($appfile);
     // Importing Database
     $re = mysqli_connect($host, $username, $password, $database);
     $result = mysqli_query($re, "SHOW TABLES FROM {$database}");
     if (!$result) {
         import_db($username, $password, $host, $database);
     }
     // Modifying Mail Config File
     $mail_driver = Session::get('mail_driver');
     $email_name = Session::get('email_name');
     $email_address = Session::get('email_address');
     $mandrill_secret = Session::get('mandrill_secret');
     $mailfile = fopen(app_path() . "/config/mail.php", "w") or die("Unable to open file!");
     $mailfile_config = generate_mail_config($host, $mail_driver, $email_name, $email_address);
     fwrite($mailfile, $mailfile_config);
     fclose($mailfile);
     if ($mail_driver == 'mandrill') {
         $mandrill_username = Input::get('mandrill_username');
         $servicesfile = fopen(app_path() . "/config/services.php", "w") or die("Unable to open file!");
         $servicesfile_config = generate_services_config($mandrill_secret, $mandrill_username);
         fwrite($servicesfile, $servicesfile_config);
         fclose($servicesfile);
     }
     return View::make("installer.step7");
 }