update v1.0.7.7

This commit is contained in:
Sujit Prasad
2016-06-23 11:32:26 +05:30
parent 91a72ea438
commit 6b0e2384fe
435 changed files with 36399 additions and 79 deletions

View File

@@ -63,21 +63,12 @@ class InstallerApiController extends Controller
return ['response' => 'fail', 'reason' => $return_data, 'status' => '0'];
}
$path1 = base_path().DIRECTORY_SEPARATOR.'.env';
$path2 = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'database.php';
$path3 = base_path().DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'Http'.DIRECTORY_SEPARATOR.'routes.php';
$path4 = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'lfm.php';
$f1 = substr(sprintf('%o', fileperms($path1)), -3);
$f2 = substr(sprintf('%o', fileperms($path2)), -3);
$f3 = substr(sprintf('%o', fileperms($path3)), -3);
$f4 = substr(sprintf('%o', fileperms($path4)), -3);
if ($f1 != '777' || $f2 != '777' || $f3 != '777' || $f4 != '777') {
return ['response' => 'fail', 'reason' => 'File permission issue.', 'status' => '0'];
}
// dd($validator->messages());
// error_reporting(E_ALL & ~E_NOTICE);
// Check for pre install
if (\Config::get('database.install') == '%0%') {
$directory = base_path();
if (file_exists($directory.DIRECTORY_SEPARATOR.'.env') && \Config::get('database.install') != '%0%') {
return ['response' => 'fail', 'reason' => 'this system is already installed', 'status' => '0'];
} else {
$default = $request->database;
$host = $request->host;
$database = $request->databasename;
@@ -86,15 +77,18 @@ class InstallerApiController extends Controller
$port = $request->port;
if (isset($default) && isset($host) && isset($database) && isset($dbusername)) {
// Setting environment values
$ENV['APP_ENV'] = 'local';
$ENV['APP_ENV'] = 'production';
$ENV['APP_DEBUG'] = 'false';
$ENV['APP_KEY'] = 'SomeRandomString';
$ENV['APP_URL'] = 'http://localhost';
$ENV['APP_BUGSNAG'] = 'true';
$ENV['DB_TYPE'] = $default;
$ENV['DB_HOST'] = $host;
$ENV['DB_PORT'] = $port;
$ENV['DB_DATABASE'] = $database;
$ENV['DB_USERNAME'] = $dbusername;
$ENV['DB_PASSWORD'] = $dbpassword;
$ENV['DB_INSTALL'] = '%0%';
$ENV['MAIL_DRIVER'] = 'smtp';
$ENV['MAIL_HOST'] = 'mailtrap.io';
$ENV['MAIL_PORT'] = '2525';
@@ -109,16 +103,15 @@ class InstallerApiController extends Controller
$config .= "{$key}={$val}\n";
}
// Write environment file
$fp = fopen(base_path().'/.env', 'w');
$fp = fopen(base_path().DIRECTORY_SEPARATOR.'example.env', 'w');
fwrite($fp, $config);
fclose($fp);
rename(base_path().DIRECTORY_SEPARATOR.'example.env', base_path().DIRECTORY_SEPARATOR.'.env');
return ['response' => 'success', 'status' => '1'];
} else {
return ['response' => 'fail', 'reason' => 'insufficient parameters', 'status' => '0'];
}
} else {
return ['response' => 'fail', 'reason' => 'this system is already installed', 'status' => '0'];
}
}
@@ -211,7 +204,7 @@ class InstallerApiController extends Controller
// Setting database installed status
$value = '1';
$install = app_path('../config/database.php');
$install = base_path().DIRECTORY_SEPARATOR.'.env';
$datacontent = File::get($install);
$datacontent = str_replace('%0%', $value, $datacontent);
File::put($install, $datacontent);
@@ -219,21 +212,13 @@ class InstallerApiController extends Controller
// Applying email configuration on route
$smtpfilepath = "\App\Http\Controllers\Common\SettingsController::smtp()";
$lfmpath = "url('photos').'/'";
$path22 = app_path('Http/routes.php');
$path23 = base_path('config/lfm.php');
$content23 = File::get($path22);
$content24 = File::get($path23);
$content23 = str_replace('"%smtplink%"', $smtpfilepath, $content23);
$content24 = str_replace("'%url%'", $lfmpath, $content24);
$link = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$pos = strpos($link, 'api/v1/system-config');
$pos = strpos($link, 'final');
$link = substr($link, 0, $pos);
$app_url = app_path('../config/app.php');
$app_url = base_path().DIRECTORY_SEPARATOR.'.env';
$datacontent2 = File::get($app_url);
$datacontent2 = str_replace('http://localhost', $link, $datacontent2);
File::put($app_url, $datacontent2);
File::put($path22, $content23);
File::put($path23, $content24);
Artisan::call('key:generate');
// If user created return success
if ($user) {

View File

@@ -192,7 +192,7 @@ class InstallController extends Controller
$dbpassword = Input::get('password');
$port = Input::get('port');
$ENV['APP_ENV'] = 'local';
$ENV['APP_ENV'] = 'production';
$ENV['APP_DEBUG'] = 'false';
$ENV['APP_KEY'] = 'SomeRandomString';
$ENV['APP_BUGSNAG'] = 'true';
@@ -218,9 +218,10 @@ class InstallController extends Controller
$config .= "{$key}={$val}\n";
}
// Write environment file
$fp = fopen(base_path().'/.env', 'w');
$fp = fopen(base_path().DIRECTORY_SEPARATOR.'example.env', 'w');
fwrite($fp, $config);
fclose($fp);
rename(base_path().DIRECTORY_SEPARATOR.'example.env', base_path().DIRECTORY_SEPARATOR.'.env');
return 1;
}
@@ -273,7 +274,10 @@ class InstallController extends Controller
try {
$check_for_pre_installation = System::all();
if ($check_for_pre_installation) {
return redirect()->back()->with('fails', 'The data in database already exist. Please provide fresh database');
rename(base_path().DIRECTORY_SEPARATOR.'.env', base_path().DIRECTORY_SEPARATOR.'example.env');
Cache::put('fails', 'The data in database already exist. Please provide fresh database', 2);
return redirect()->route('configuration');
}
} catch (Exception $e) {
}
@@ -358,13 +362,7 @@ class InstallController extends Controller
File::put($install, $datacontent);
// setting email settings in route
$smtpfilepath = "\App\Http\Controllers\Common\SettingsController::smtp()";
$lfmpath = "url('photos').'/'";
$path22 = app_path('Http/routes.php');
$path23 = base_path('config/lfm.php');
$content23 = File::get($path22);
$content24 = File::get($path23);
$content23 = str_replace('"%smtplink%"', $smtpfilepath, $content23);
$content24 = str_replace("'%url%'", $lfmpath, $content24);
$link = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$pos = strpos($link, 'final');
$link = substr($link, 0, $pos);
@@ -372,8 +370,6 @@ class InstallController extends Controller
$datacontent2 = File::get($app_url);
$datacontent2 = str_replace('http://localhost', $link, $datacontent2);
File::put($app_url, $datacontent2);
File::put($path22, $content23);
File::put($path23, $content24);
try {
Cache::flush();

View File

@@ -34,6 +34,7 @@ class Kernel extends HttpKernel
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
//\App\Http\Middleware\VerifyCsrfToken::class,
\App\Http\Middleware\LanguageMiddleware::class,
],
'api' => [
'throttle:60,1',
@@ -59,5 +60,6 @@ class Kernel extends HttpKernel
'jwt.refresh' => \Tymon\JWTAuth\Middleware\RefreshToken::class,
'update' => \App\Http\Middleware\CheckUpdate::class,
'board' => \App\Http\Middleware\CheckBoard::class,
'install' => \App\Http\Middleware\Install::class,
];
}

View File

@@ -0,0 +1,26 @@
<?php
namespace App\Http\Middleware;
use Closure;
class Install
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
*/
public function handle($request, Closure $next)
{
$env = base_path('.env');
if (\File::exists($env)) {
return $next($request);
} else {
return redirect('step1');
}
}
}

View File

@@ -11,7 +11,7 @@
|
*/
Route::group(['middleware' => ['web']], function () {
Route::group(['middleware' => 'update'], function () {
Route::group(['middleware' => 'update', 'middleware' => 'install'], function () {
Route::controllers([
'auth' => 'Auth\AuthController',
'password' => 'Auth\PasswordController',
@@ -29,7 +29,7 @@ Route::group(['middleware' => ['web']], function () {
| Here is defining entire routes for the Admin Panel
|
*/
Route::group(['middleware' => 'roles', 'middleware' => 'auth', 'middleware' => 'update'], function () {
Route::group(['middleware' => 'roles', 'middleware' => 'auth', 'middleware' => 'install', 'middleware' => 'update'], function () {
//Notification marking
Route::post('mark-read/{id}', 'Common\NotificationController@markRead');
@@ -562,7 +562,7 @@ Route::group(['middleware' => ['web']], function () {
|
|
*/
Route::group(['middleware' => 'role.agent', 'middleware' => 'auth', 'middleware' => 'update'], function () {
Route::group(['middleware' => 'role.agent', 'middleware' => 'auth', 'middleware' => 'install', 'middleware' => 'update'], function () {
Route::post('chart-range/{date1}/{date2}', ['as' => 'post.chart', 'uses' => 'Agent\helpdesk\DashboardController@ChartData']);
Route::get('agen1', 'Agent\helpdesk\DashboardController@ChartData');