Moved to _dev
This commit is contained in:
58
crater/app/Space/DateFormatter.php
Normal file
58
crater/app/Space/DateFormatter.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace Crater\Space;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class DateFormatter
|
||||
{
|
||||
protected static $formats = [
|
||||
[
|
||||
"carbon_format" => "Y M d",
|
||||
"moment_format" => "YYYY MMM DD",
|
||||
],
|
||||
[
|
||||
"carbon_format" => "d M Y",
|
||||
"moment_format" => "DD MMM YYYY",
|
||||
],
|
||||
[
|
||||
"carbon_format" => "d/m/Y",
|
||||
"moment_format" => "DD/MM/YYYY",
|
||||
],
|
||||
[
|
||||
"carbon_format" => "d.m.Y",
|
||||
"moment_format" => "DD.MM.YYYY",
|
||||
],
|
||||
[
|
||||
"carbon_format" => "d-m-Y",
|
||||
"moment_format" => "DD-MM-YYYY",
|
||||
],
|
||||
[
|
||||
"carbon_format" => "m/d/Y",
|
||||
"moment_format" => "MM/DD/YYYY",
|
||||
],
|
||||
[
|
||||
"carbon_format" => "Y/m/d",
|
||||
"moment_format" => " YYYY/MM/DD",
|
||||
],
|
||||
[
|
||||
"carbon_format" => "Y-m-d",
|
||||
"moment_format" => "YYYY-MM-DD",
|
||||
],
|
||||
];
|
||||
|
||||
public static function get_list()
|
||||
{
|
||||
$new = [];
|
||||
|
||||
foreach (static::$formats as $format) {
|
||||
$new[] = [
|
||||
"display_date" => Carbon::now()->format($format['carbon_format']) ,
|
||||
"carbon_format_value" => $format['carbon_format'],
|
||||
"moment_format_value" => $format['moment_format'],
|
||||
];
|
||||
}
|
||||
|
||||
return $new;
|
||||
}
|
||||
}
|
||||
583
crater/app/Space/EnvironmentManager.php
Executable file
583
crater/app/Space/EnvironmentManager.php
Executable file
@@ -0,0 +1,583 @@
|
||||
<?php
|
||||
|
||||
namespace Crater\Space;
|
||||
|
||||
use Crater\Http\Requests\DatabaseEnvironmentRequest;
|
||||
use Crater\Http\Requests\DiskEnvironmentRequest;
|
||||
use Crater\Http\Requests\DomainEnvironmentRequest;
|
||||
use Crater\Http\Requests\MailEnvironmentRequest;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class EnvironmentManager
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $envPath;
|
||||
|
||||
/**
|
||||
* Set the .env and .env.example paths.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->envPath = base_path('.env');
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the database content to the .env file.
|
||||
*
|
||||
* @param DatabaseEnvironmentRequest $request
|
||||
* @return array
|
||||
*/
|
||||
public function saveDatabaseVariables(DatabaseEnvironmentRequest $request)
|
||||
{
|
||||
$oldDatabaseData =
|
||||
'DB_CONNECTION='.config('database.default')."\n";
|
||||
|
||||
$newDatabaseData =
|
||||
'DB_CONNECTION='.$request->database_connection."\n";
|
||||
|
||||
if ($request->has('database_username') && $request->has('database_password')) {
|
||||
if (env('DB_USERNAME') && env('DB_HOST')) {
|
||||
$oldDatabaseData = $oldDatabaseData.
|
||||
'DB_HOST='.config('database.connections.'.config('database.default').'.host')."\n".
|
||||
'DB_PORT='.config('database.connections.'.config('database.default').'.port')."\n".
|
||||
'DB_DATABASE='.config('database.connections.'.config('database.default').'.database')."\n".
|
||||
'DB_USERNAME='.config('database.connections.'.config('database.default').'.username')."\n".
|
||||
'DB_PASSWORD="'.config('database.connections.'.config('database.default').'.password')."\"\n\n";
|
||||
} else {
|
||||
$oldDatabaseData = $oldDatabaseData.
|
||||
'DB_DATABASE='.config('database.connections.'.config('database.default').'.database')."\n\n";
|
||||
}
|
||||
|
||||
$newDatabaseData = $newDatabaseData.
|
||||
'DB_HOST='.$request->database_hostname."\n".
|
||||
'DB_PORT='.$request->database_port."\n".
|
||||
'DB_DATABASE='.$request->database_name."\n".
|
||||
'DB_USERNAME='.$request->database_username."\n".
|
||||
'DB_PASSWORD="'.$request->database_password."\"\n\n";
|
||||
} else {
|
||||
if (env('DB_USERNAME') && env('DB_HOST')) {
|
||||
$oldDatabaseData = $oldDatabaseData.
|
||||
'DB_HOST='.config('database.connections.'.config('database.default').'.host')."\n".
|
||||
'DB_PORT='.config('database.connections.'.config('database.default').'.port')."\n".
|
||||
'DB_DATABASE='.config('database.connections.'.config('database.default').'.database')."\n".
|
||||
'DB_USERNAME='.config('database.connections.'.config('database.default').'.username')."\n".
|
||||
'DB_PASSWORD="'.config('database.connections.'.config('database.default').'.password')."\"\n\n";
|
||||
} else {
|
||||
$oldDatabaseData = $oldDatabaseData.
|
||||
'DB_DATABASE='.config('database.connections.'.config('database.default').'.database')."\n\n";
|
||||
}
|
||||
|
||||
$newDatabaseData = $newDatabaseData.
|
||||
'DB_DATABASE='.$request->database_name."\n\n";
|
||||
}
|
||||
|
||||
try {
|
||||
$conn = $this->checkDatabaseConnection($request);
|
||||
|
||||
// $requirement = $this->checkVersionRequirements($request, $conn);
|
||||
|
||||
// if ($requirement) {
|
||||
// return [
|
||||
// 'error' => 'minimum_version_requirement',
|
||||
// 'requirement' => $requirement,
|
||||
// ];
|
||||
// }
|
||||
|
||||
if (\Schema::hasTable('users')) {
|
||||
return [
|
||||
'error' => 'database_should_be_empty',
|
||||
];
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'error_message' => $e->getMessage(),
|
||||
];
|
||||
}
|
||||
|
||||
try {
|
||||
file_put_contents($this->envPath, str_replace(
|
||||
$oldDatabaseData,
|
||||
$newDatabaseData,
|
||||
file_get_contents($this->envPath)
|
||||
));
|
||||
|
||||
file_put_contents($this->envPath, str_replace(
|
||||
'APP_URL='.config('app.url'),
|
||||
'APP_URL='.$request->app_url,
|
||||
file_get_contents($this->envPath)
|
||||
));
|
||||
|
||||
file_put_contents($this->envPath, str_replace(
|
||||
'SANCTUM_STATEFUL_DOMAINS='.env('SANCTUM_STATEFUL_DOMAINS'),
|
||||
'SANCTUM_STATEFUL_DOMAINS='.$request->app_domain,
|
||||
file_get_contents($this->envPath)
|
||||
));
|
||||
|
||||
|
||||
file_put_contents($this->envPath, str_replace(
|
||||
'SESSION_DOMAIN='.config('session.domain'),
|
||||
'SESSION_DOMAIN='.explode(':', $request->app_domain)[0],
|
||||
file_get_contents($this->envPath)
|
||||
));
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'error' => 'database_variables_save_error',
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'success' => 'database_variables_save_successfully',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param DatabaseEnvironmentRequest $request
|
||||
* @return bool
|
||||
*/
|
||||
private function checkDatabaseConnection(DatabaseEnvironmentRequest $request)
|
||||
{
|
||||
$connection = $request->database_connection;
|
||||
|
||||
$settings = config("database.connections.$connection");
|
||||
$settings = config("database.connections.$connection");
|
||||
|
||||
$connectionArray = array_merge($settings, [
|
||||
'driver' => $connection,
|
||||
'database' => $request->database_name,
|
||||
]);
|
||||
|
||||
if ($request->has('database_username') && $request->has('database_password')) {
|
||||
$connectionArray = array_merge($connectionArray, [
|
||||
'username' => $request->database_username,
|
||||
'password' => $request->database_password,
|
||||
'host' => $request->database_hostname,
|
||||
'port' => $request->database_port,
|
||||
]);
|
||||
}
|
||||
|
||||
config([
|
||||
'database' => [
|
||||
'migrations' => 'migrations',
|
||||
'default' => $connection,
|
||||
'connections' => [$connection => $connectionArray],
|
||||
],
|
||||
]);
|
||||
|
||||
return DB::connection()->getPdo();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param DatabaseEnvironmentRequest $request
|
||||
* @return bool
|
||||
*/
|
||||
private function checkVersionRequirements(DatabaseEnvironmentRequest $request, $conn)
|
||||
{
|
||||
$connection = $request->database_connection;
|
||||
|
||||
$checker = new RequirementsChecker();
|
||||
|
||||
$phpSupportInfo = $checker->checkPHPVersion(
|
||||
config('crater.min_php_version')
|
||||
);
|
||||
|
||||
if (! $phpSupportInfo['supported']) {
|
||||
return $phpSupportInfo;
|
||||
}
|
||||
|
||||
$dbSupportInfo = [];
|
||||
|
||||
switch ($connection) {
|
||||
case 'mysql':
|
||||
$dbSupportInfo = $checker->checkMysqlVersion($conn);
|
||||
|
||||
break;
|
||||
|
||||
case 'pgsql':
|
||||
$conn = pg_connect("host={$request->database_hostname} port={$request->database_port} dbname={$request->database_name} user={$request->database_username} password={$request->database_password}");
|
||||
$dbSupportInfo = $checker->checkPgsqlVersion(
|
||||
$conn,
|
||||
config('crater.min_pgsql_version')
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
case 'sqlite':
|
||||
$dbSupportInfo = $checker->checkSqliteVersion(
|
||||
config('crater.min_sqlite_version')
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (! $dbSupportInfo['supported']) {
|
||||
return $dbSupportInfo;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the mail content to the .env file.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function saveMailVariables(MailEnvironmentRequest $request)
|
||||
{
|
||||
$mailData = $this->getMailData($request);
|
||||
|
||||
try {
|
||||
file_put_contents($this->envPath, str_replace(
|
||||
$mailData['old_mail_data'],
|
||||
$mailData['new_mail_data'],
|
||||
file_get_contents($this->envPath)
|
||||
));
|
||||
|
||||
if ($mailData['extra_old_mail_data']) {
|
||||
file_put_contents($this->envPath, str_replace(
|
||||
$mailData['extra_old_mail_data'],
|
||||
$mailData['extra_mail_data'],
|
||||
file_get_contents($this->envPath)
|
||||
));
|
||||
} else {
|
||||
file_put_contents(
|
||||
$this->envPath,
|
||||
"\n".$mailData['extra_mail_data'],
|
||||
FILE_APPEND
|
||||
);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'error' => 'mail_variables_save_error',
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'success' => 'mail_variables_save_successfully',
|
||||
];
|
||||
}
|
||||
|
||||
private function getMailData($request)
|
||||
{
|
||||
$mailFromCredential = "";
|
||||
$extraMailData = "";
|
||||
$extraOldMailData = "";
|
||||
$oldMailData = "";
|
||||
$newMailData = "";
|
||||
|
||||
if (env('MAIL_FROM_ADDRESS') !== null && env('MAIL_FROM_NAME') !== null) {
|
||||
$mailFromCredential =
|
||||
'MAIL_FROM_ADDRESS='.config('mail.from.address')."\n".
|
||||
'MAIL_FROM_NAME="'.config('mail.from.name')."\"\n\n";
|
||||
}
|
||||
|
||||
switch ($request->mail_driver) {
|
||||
case 'smtp':
|
||||
|
||||
$oldMailData =
|
||||
'MAIL_DRIVER='.config('mail.driver')."\n".
|
||||
'MAIL_HOST='.config('mail.host')."\n".
|
||||
'MAIL_PORT='.config('mail.port')."\n".
|
||||
'MAIL_USERNAME='.config('mail.username')."\n".
|
||||
'MAIL_PASSWORD='.config('mail.password')."\n".
|
||||
'MAIL_ENCRYPTION='.config('mail.encryption')."\n\n".
|
||||
$mailFromCredential;
|
||||
|
||||
$newMailData =
|
||||
'MAIL_DRIVER='.$request->mail_driver."\n".
|
||||
'MAIL_HOST='.$request->mail_host."\n".
|
||||
'MAIL_PORT='.$request->mail_port."\n".
|
||||
'MAIL_USERNAME='.$request->mail_username."\n".
|
||||
'MAIL_PASSWORD='.$request->mail_password."\n".
|
||||
'MAIL_ENCRYPTION='.$request->mail_encryption."\n\n".
|
||||
'MAIL_FROM_ADDRESS='.$request->from_mail."\n".
|
||||
'MAIL_FROM_NAME="'.$request->from_name."\"\n\n";
|
||||
|
||||
break;
|
||||
|
||||
case 'mailgun':
|
||||
$oldMailData =
|
||||
'MAIL_DRIVER='.config('mail.driver')."\n".
|
||||
'MAIL_HOST='.config('mail.host')."\n".
|
||||
'MAIL_PORT='.config('mail.port')."\n".
|
||||
'MAIL_USERNAME='.config('mail.username')."\n".
|
||||
'MAIL_PASSWORD='.config('mail.password')."\n".
|
||||
'MAIL_ENCRYPTION='.config('mail.encryption')."\n\n".
|
||||
$mailFromCredential;
|
||||
|
||||
$newMailData =
|
||||
'MAIL_DRIVER='.$request->mail_driver."\n".
|
||||
'MAIL_HOST='.$request->mail_host."\n".
|
||||
'MAIL_PORT='.$request->mail_port."\n".
|
||||
'MAIL_USERNAME='.config('mail.username')."\n".
|
||||
'MAIL_PASSWORD='.config('mail.password')."\n".
|
||||
'MAIL_ENCRYPTION='.$request->mail_encryption."\n\n".
|
||||
'MAIL_FROM_ADDRESS='.$request->from_mail."\n".
|
||||
'MAIL_FROM_NAME="'.$request->from_name."\"\n\n";
|
||||
|
||||
$extraMailData =
|
||||
'MAILGUN_DOMAIN='.$request->mail_mailgun_domain."\n".
|
||||
'MAILGUN_SECRET='.$request->mail_mailgun_secret."\n".
|
||||
'MAILGUN_ENDPOINT='.$request->mail_mailgun_endpoint."\n";
|
||||
|
||||
if (env('MAILGUN_DOMAIN') !== null && env('MAILGUN_SECRET') !== null && env('MAILGUN_ENDPOINT') !== null) {
|
||||
$extraOldMailData =
|
||||
'MAILGUN_DOMAIN='.config('services.mailgun.domain')."\n".
|
||||
'MAILGUN_SECRET='.config('services.mailgun.secret')."\n".
|
||||
'MAILGUN_ENDPOINT='.config('services.mailgun.endpoint')."\n";
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'ses':
|
||||
$oldMailData =
|
||||
'MAIL_DRIVER='.config('mail.driver')."\n".
|
||||
'MAIL_HOST='.config('mail.host')."\n".
|
||||
'MAIL_PORT='.config('mail.port')."\n".
|
||||
'MAIL_USERNAME='.config('mail.username')."\n".
|
||||
'MAIL_PASSWORD='.config('mail.password')."\n".
|
||||
'MAIL_ENCRYPTION='.config('mail.encryption')."\n\n".
|
||||
$mailFromCredential;
|
||||
|
||||
$newMailData =
|
||||
'MAIL_DRIVER='.$request->mail_driver."\n".
|
||||
'MAIL_HOST='.$request->mail_host."\n".
|
||||
'MAIL_PORT='.$request->mail_port."\n".
|
||||
'MAIL_USERNAME='.config('mail.username')."\n".
|
||||
'MAIL_PASSWORD='.config('mail.password')."\n".
|
||||
'MAIL_ENCRYPTION='.$request->mail_encryption."\n\n".
|
||||
'MAIL_FROM_ADDRESS='.$request->from_mail."\n".
|
||||
'MAIL_FROM_NAME="'.$request->from_name."\"\n\n";
|
||||
|
||||
$extraMailData =
|
||||
'SES_KEY='.$request->mail_ses_key."\n".
|
||||
'SES_SECRET='.$request->mail_ses_secret."\n";
|
||||
|
||||
if (env('SES_KEY') !== null && env('SES_SECRET') !== null) {
|
||||
$extraOldMailData =
|
||||
'SES_KEY='.config('services.ses.key')."\n".
|
||||
'SES_SECRET='.config('services.ses.secret')."\n";
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'mail':
|
||||
$oldMailData =
|
||||
'MAIL_DRIVER='.config('mail.driver')."\n".
|
||||
'MAIL_HOST='.config('mail.host')."\n".
|
||||
'MAIL_PORT='.config('mail.port')."\n".
|
||||
'MAIL_USERNAME='.config('mail.username')."\n".
|
||||
'MAIL_PASSWORD='.config('mail.password')."\n".
|
||||
'MAIL_ENCRYPTION='.config('mail.encryption')."\n\n".
|
||||
$mailFromCredential;
|
||||
|
||||
$newMailData =
|
||||
'MAIL_DRIVER='.$request->mail_driver."\n".
|
||||
'MAIL_HOST='.config('mail.host')."\n".
|
||||
'MAIL_PORT='.config('mail.port')."\n".
|
||||
'MAIL_USERNAME='.config('mail.username')."\n".
|
||||
'MAIL_PASSWORD='.config('mail.password')."\n".
|
||||
'MAIL_ENCRYPTION='.config('mail.encryption')."\n\n".
|
||||
'MAIL_FROM_ADDRESS='.$request->from_mail."\n".
|
||||
'MAIL_FROM_NAME="'.$request->from_name."\"\n\n";
|
||||
|
||||
break;
|
||||
|
||||
case 'sendmail':
|
||||
$oldMailData =
|
||||
'MAIL_DRIVER='.config('mail.driver')."\n".
|
||||
'MAIL_HOST='.config('mail.host')."\n".
|
||||
'MAIL_PORT='.config('mail.port')."\n".
|
||||
'MAIL_USERNAME='.config('mail.username')."\n".
|
||||
'MAIL_PASSWORD='.config('mail.password')."\n".
|
||||
'MAIL_ENCRYPTION='.config('mail.encryption')."\n\n".
|
||||
$mailFromCredential;
|
||||
|
||||
$newMailData =
|
||||
'MAIL_DRIVER='.$request->mail_driver."\n".
|
||||
'MAIL_HOST='.config('mail.host')."\n".
|
||||
'MAIL_PORT='.config('mail.port')."\n".
|
||||
'MAIL_USERNAME='.config('mail.username')."\n".
|
||||
'MAIL_PASSWORD='.config('mail.password')."\n".
|
||||
'MAIL_ENCRYPTION='.config('mail.encryption')."\n\n".
|
||||
'MAIL_FROM_ADDRESS='.$request->from_mail."\n".
|
||||
'MAIL_FROM_NAME="'.$request->from_name."\"\n\n";
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return [
|
||||
'old_mail_data' => $oldMailData,
|
||||
'new_mail_data' => $newMailData,
|
||||
'extra_mail_data' => $extraMailData,
|
||||
'extra_old_mail_data' => $extraOldMailData,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the disk content to the .env file.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function saveDiskVariables(DiskEnvironmentRequest $request)
|
||||
{
|
||||
$diskData = $this->getDiskData($request);
|
||||
|
||||
try {
|
||||
if (! $diskData['old_default_driver']) {
|
||||
file_put_contents($this->envPath, $diskData['default_driver'], FILE_APPEND);
|
||||
} else {
|
||||
file_put_contents($this->envPath, str_replace(
|
||||
$diskData['old_default_driver'],
|
||||
$diskData['default_driver'],
|
||||
file_get_contents($this->envPath)
|
||||
));
|
||||
}
|
||||
|
||||
if (! $diskData['old_disk_data']) {
|
||||
file_put_contents($this->envPath, $diskData['new_disk_data'], FILE_APPEND);
|
||||
} else {
|
||||
file_put_contents($this->envPath, str_replace(
|
||||
$diskData['old_disk_data'],
|
||||
$diskData['new_disk_data'],
|
||||
file_get_contents($this->envPath)
|
||||
));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'error' => 'disk_variables_save_error',
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'success' => 'disk_variables_save_successfully',
|
||||
];
|
||||
}
|
||||
|
||||
private function getDiskData($request)
|
||||
{
|
||||
$oldDefaultDriver = "";
|
||||
$defaultDriver = "";
|
||||
$oldDiskData = "";
|
||||
$newDiskData = "";
|
||||
|
||||
if ($request->default_driver) {
|
||||
if (env('FILESYSTEM_DRIVER') !== null) {
|
||||
$defaultDriver = "\n".'FILESYSTEM_DRIVER='.$request->default_driver."\n";
|
||||
|
||||
$oldDefaultDriver =
|
||||
"\n".'FILESYSTEM_DRIVER='.config('filesystems.default')."\n";
|
||||
} else {
|
||||
$defaultDriver =
|
||||
"\n".'FILESYSTEM_DRIVER='.$request->default_driver."\n";
|
||||
}
|
||||
}
|
||||
|
||||
switch ($request->selected_driver) {
|
||||
case 's3':
|
||||
if (env('AWS_KEY') !== null) {
|
||||
$oldDiskData = "\n".
|
||||
'AWS_KEY='.config('filesystems.disks.s3.key')."\n".
|
||||
'AWS_SECRET="'.config('filesystems.disks.s3.secret')."\"\n".
|
||||
'AWS_REGION='.config('filesystems.disks.s3.region')."\n".
|
||||
'AWS_BUCKET='.config('filesystems.disks.s3.bucket')."\n".
|
||||
'AWS_ROOT='.config('filesystems.disks.s3.root')."\n";
|
||||
}
|
||||
|
||||
$newDiskData = "\n".
|
||||
'AWS_KEY='.$request->aws_key."\n".
|
||||
'AWS_SECRET="'.$request->aws_secret."\"\n".
|
||||
'AWS_REGION='.$request->aws_region."\n".
|
||||
'AWS_BUCKET='.$request->aws_bucket."\n".
|
||||
'AWS_ROOT='.$request->aws_root."\n";
|
||||
|
||||
break;
|
||||
|
||||
case 'doSpaces':
|
||||
if (env('DO_SPACES_KEY') !== null) {
|
||||
$oldDiskData = "\n".
|
||||
'DO_SPACES_KEY='.config('filesystems.disks.doSpaces.key')."\n".
|
||||
'DO_SPACES_SECRET="'.config('filesystems.disks.doSpaces.secret')."\"\n".
|
||||
'DO_SPACES_REGION='.config('filesystems.disks.doSpaces.region')."\n".
|
||||
'DO_SPACES_BUCKET='.config('filesystems.disks.doSpaces.bucket')."\n".
|
||||
'DO_SPACES_ENDPOINT='.config('filesystems.disks.doSpaces.endpoint')."\n";
|
||||
'DO_SPACES_ROOT='.config('filesystems.disks.doSpaces.root')."\n";
|
||||
}
|
||||
|
||||
$newDiskData = "\n".
|
||||
'DO_SPACES_KEY='.$request->do_spaces_key."\n".
|
||||
'DO_SPACES_SECRET="'.$request->do_spaces_secret."\"\n".
|
||||
'DO_SPACES_REGION='.$request->do_spaces_region."\n".
|
||||
'DO_SPACES_BUCKET='.$request->do_spaces_bucket."\n".
|
||||
'DO_SPACES_ENDPOINT='.$request->do_spaces_endpoint."\n";
|
||||
'DO_SPACES_ROOT='.$request->do_spaces_root."\n\n";
|
||||
|
||||
break;
|
||||
|
||||
case 'dropbox':
|
||||
if (env('DROPBOX_TOKEN') !== null) {
|
||||
$oldDiskData = "\n".
|
||||
'DROPBOX_TOKEN='.config('filesystems.disks.dropbox.token')."\n".
|
||||
'DROPBOX_KEY='.config('filesystems.disks.dropbox.key')."\n".
|
||||
'DROPBOX_SECRET="'.config('filesystems.disks.dropbox.secret')."\"\n".
|
||||
'DROPBOX_APP='.config('filesystems.disks.dropbox.app')."\n".
|
||||
'DROPBOX_ROOT='.config('filesystems.disks.dropbox.root')."\n";
|
||||
}
|
||||
|
||||
$newDiskData = "\n".
|
||||
'DROPBOX_TOKEN='.$request->dropbox_token."\n".
|
||||
'DROPBOX_KEY='.$request->dropbox_key."\n".
|
||||
'DROPBOX_SECRET="'.$request->dropbox_secret."\"\n".
|
||||
'DROPBOX_APP='.$request->dropbox_app."\n".
|
||||
'DROPBOX_ROOT='.$request->dropbox_root."\n";
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return [
|
||||
'old_disk_data' => $oldDiskData,
|
||||
'new_disk_data' => $newDiskData,
|
||||
'default_driver' => $defaultDriver,
|
||||
'old_default_driver' => $oldDefaultDriver,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Save sanctum statful domain to the .env file.
|
||||
*
|
||||
* @param DomainEnvironmentRequest $request
|
||||
* @return array
|
||||
*/
|
||||
public function saveDomainVariables(DomainEnvironmentRequest $request)
|
||||
{
|
||||
try {
|
||||
file_put_contents($this->envPath, str_replace(
|
||||
'SANCTUM_STATEFUL_DOMAINS='.env('SANCTUM_STATEFUL_DOMAINS'),
|
||||
'SANCTUM_STATEFUL_DOMAINS='.$request->app_domain,
|
||||
file_get_contents($this->envPath)
|
||||
));
|
||||
|
||||
file_put_contents($this->envPath, str_replace(
|
||||
'SESSION_DOMAIN='.config('session.domain'),
|
||||
'SESSION_DOMAIN='.explode(':', $request->app_domain)[0],
|
||||
file_get_contents($this->envPath)
|
||||
));
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'error' => 'domain_verification_failed'
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'success' => 'domain_variable_save_successfully'
|
||||
];
|
||||
}
|
||||
}
|
||||
83
crater/app/Space/FilePermissionChecker.php
Normal file
83
crater/app/Space/FilePermissionChecker.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace Crater\Space;
|
||||
|
||||
class FilePermissionChecker
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $results = [];
|
||||
|
||||
/**
|
||||
* Set the result array permissions and errors.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->results['permissions'] = [];
|
||||
|
||||
$this->results['errors'] = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for the folders permissions.
|
||||
*
|
||||
* @param array $folders
|
||||
* @return array
|
||||
*/
|
||||
public function check(array $folders)
|
||||
{
|
||||
foreach ($folders as $folder => $permission) {
|
||||
if (! ($this->getPermission($folder) >= $permission)) {
|
||||
$this->addFileAndSetErrors($folder, $permission, false);
|
||||
} else {
|
||||
$this->addFile($folder, $permission, true);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a folder permission.
|
||||
*
|
||||
* @param $folder
|
||||
* @return string
|
||||
*/
|
||||
private function getPermission($folder)
|
||||
{
|
||||
return substr(sprintf('%o', fileperms(base_path($folder))), -4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the file to the list of results.
|
||||
*
|
||||
* @param $folder
|
||||
* @param $permission
|
||||
* @param $isSet
|
||||
*/
|
||||
private function addFile($folder, $permission, $isSet)
|
||||
{
|
||||
array_push($this->results['permissions'], [
|
||||
'folder' => $folder,
|
||||
'permission' => $permission,
|
||||
'isSet' => $isSet,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the file and set the errors.
|
||||
*
|
||||
* @param $folder
|
||||
* @param $permission
|
||||
* @param $isSet
|
||||
*/
|
||||
private function addFileAndSetErrors($folder, $permission, $isSet)
|
||||
{
|
||||
$this->addFile($folder, $permission, $isSet);
|
||||
|
||||
$this->results['errors'] = true;
|
||||
}
|
||||
}
|
||||
231
crater/app/Space/ModuleInstaller.php
Normal file
231
crater/app/Space/ModuleInstaller.php
Normal file
@@ -0,0 +1,231 @@
|
||||
<?php
|
||||
|
||||
namespace Crater\Space;
|
||||
|
||||
use Artisan;
|
||||
use Crater\Events\ModuleEnabledEvent;
|
||||
use Crater\Events\ModuleInstalledEvent;
|
||||
use Crater\Http\Resources\ModuleResource;
|
||||
use Crater\Models\Module as ModelsModule;
|
||||
use Crater\Models\Setting;
|
||||
use File;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use Nwidart\Modules\Facades\Module;
|
||||
use ZipArchive;
|
||||
|
||||
// Implementation taken from Akaunting - https://github.com/akaunting/akaunting
|
||||
class ModuleInstaller
|
||||
{
|
||||
use SiteApi;
|
||||
|
||||
public static function getModules()
|
||||
{
|
||||
$data = null;
|
||||
if (env('APP_ENV') === 'development') {
|
||||
$url = 'api/marketplace/modules?is_dev=1';
|
||||
} else {
|
||||
$url = 'api/marketplace/modules';
|
||||
}
|
||||
|
||||
$token = Setting::getSetting('api_token');
|
||||
$response = static::getRemote($url, ['timeout' => 100, 'track_redirects' => true], $token);
|
||||
|
||||
if ($response && ($response->getStatusCode() == 401)) {
|
||||
return response()->json(['error' => 'invalid_token']);
|
||||
}
|
||||
|
||||
if ($response && ($response->getStatusCode() == 200)) {
|
||||
$data = $response->getBody()->getContents();
|
||||
}
|
||||
|
||||
$data = json_decode($data);
|
||||
|
||||
return ModuleResource::collection(collect($data->modules));
|
||||
}
|
||||
|
||||
public static function getModule($module)
|
||||
{
|
||||
$data = null;
|
||||
if (env('APP_ENV') === 'development') {
|
||||
$url = 'api/marketplace/modules/'.$module.'?is_dev=1';
|
||||
} else {
|
||||
$url = 'api/marketplace/modules/'.$module;
|
||||
}
|
||||
|
||||
$token = Setting::getSetting('api_token');
|
||||
$response = static::getRemote($url, ['timeout' => 100, 'track_redirects' => true], $token);
|
||||
|
||||
if ($response && ($response->getStatusCode() == 401)) {
|
||||
return (object)['success' => false, 'error' => 'invalid_token'];
|
||||
}
|
||||
|
||||
if ($response && ($response->getStatusCode() == 200)) {
|
||||
$data = $response->getBody()->getContents();
|
||||
}
|
||||
|
||||
$data = json_decode($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function upload($request)
|
||||
{
|
||||
// Create temp directory
|
||||
$temp_dir = storage_path('app/temp-'.md5(mt_rand()));
|
||||
|
||||
if (! File::isDirectory($temp_dir)) {
|
||||
File::makeDirectory($temp_dir);
|
||||
}
|
||||
|
||||
$path = $request->file('avatar')->storeAs(
|
||||
'temp-'.md5(mt_rand()),
|
||||
$request->module.'.zip',
|
||||
'local'
|
||||
);
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
public static function download($module, $version)
|
||||
{
|
||||
$data = null;
|
||||
$path = null;
|
||||
|
||||
if (env('APP_ENV') === 'development') {
|
||||
$url = "api/marketplace/modules/file/{$module}?version={$version}&is_dev=1";
|
||||
} else {
|
||||
$url = "api/marketplace/modules/file/{$module}?version={$version}";
|
||||
}
|
||||
|
||||
$token = Setting::getSetting('api_token');
|
||||
$response = static::getRemote($url, ['timeout' => 100, 'track_redirects' => true], $token);
|
||||
|
||||
// Exception
|
||||
if ($response instanceof RequestException) {
|
||||
return [
|
||||
'success' => false,
|
||||
'error' => 'Download Exception',
|
||||
'data' => [
|
||||
'path' => $path,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
if ($response && ($response->getStatusCode() == 401 || $response->getStatusCode() == 404 || $response->getStatusCode() == 500)) {
|
||||
return json_decode($response->getBody()->getContents());
|
||||
}
|
||||
|
||||
if ($response && ($response->getStatusCode() == 200)) {
|
||||
$data = $response->getBody()->getContents();
|
||||
}
|
||||
|
||||
// Create temp directory
|
||||
$temp_dir = storage_path('app/temp-'.md5(mt_rand()));
|
||||
|
||||
if (! File::isDirectory($temp_dir)) {
|
||||
File::makeDirectory($temp_dir);
|
||||
}
|
||||
|
||||
$zip_file_path = $temp_dir.'/upload.zip';
|
||||
|
||||
// Add content to the Zip file
|
||||
$uploaded = is_int(file_put_contents($zip_file_path, $data)) ? true : false;
|
||||
|
||||
if (! $uploaded) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
'path' => $zip_file_path
|
||||
];
|
||||
}
|
||||
|
||||
public static function unzip($module, $zip_file_path)
|
||||
{
|
||||
if (! file_exists($zip_file_path)) {
|
||||
throw new \Exception('Zip file not found');
|
||||
}
|
||||
|
||||
$temp_extract_dir = storage_path('app/temp2-'.md5(mt_rand()));
|
||||
|
||||
if (! File::isDirectory($temp_extract_dir)) {
|
||||
File::makeDirectory($temp_extract_dir);
|
||||
}
|
||||
// Unzip the file
|
||||
$zip = new ZipArchive();
|
||||
|
||||
if ($zip->open($zip_file_path)) {
|
||||
$zip->extractTo($temp_extract_dir);
|
||||
}
|
||||
|
||||
$zip->close();
|
||||
|
||||
// Delete zip file
|
||||
File::delete($zip_file_path);
|
||||
|
||||
return $temp_extract_dir;
|
||||
}
|
||||
|
||||
public static function copyFiles($module, $temp_extract_dir)
|
||||
{
|
||||
if (! File::isDirectory(base_path('Modules'))) {
|
||||
File::makeDirectory(base_path('Modules'));
|
||||
}
|
||||
|
||||
// Delete Existing Module directory
|
||||
if (! File::isDirectory(base_path('Modules').'/'.$module)) {
|
||||
File::deleteDirectory(base_path('Modules').'/'.$module);
|
||||
}
|
||||
|
||||
if (! File::copyDirectory($temp_extract_dir, base_path('Modules').'/')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Delete temp directory
|
||||
File::deleteDirectory($temp_extract_dir);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function deleteFiles($json)
|
||||
{
|
||||
$files = json_decode($json);
|
||||
|
||||
foreach ($files as $file) {
|
||||
\File::delete(base_path($file));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function complete($module, $version)
|
||||
{
|
||||
Module::register();
|
||||
|
||||
Artisan::call("module:migrate $module --force");
|
||||
Artisan::call("module:seed $module --force");
|
||||
Artisan::call("module:enable $module");
|
||||
|
||||
$module = ModelsModule::updateOrCreate(['name' => $module], ['version' => $version, 'installed' => true, 'enabled' => true]);
|
||||
|
||||
ModuleInstalledEvent::dispatch($module);
|
||||
ModuleEnabledEvent::dispatch($module);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function checkToken(String $token)
|
||||
{
|
||||
$url = 'api/marketplace/ping';
|
||||
$response = static::getRemote($url, ['timeout' => 100, 'track_redirects' => true], $token);
|
||||
|
||||
if ($response && ($response->getStatusCode() == 200)) {
|
||||
$data = $response->getBody()->getContents();
|
||||
|
||||
return response()->json(json_decode($data));
|
||||
}
|
||||
|
||||
return response()->json(['error' => 'invalid_token']);
|
||||
}
|
||||
}
|
||||
236
crater/app/Space/RequirementsChecker.php
Executable file
236
crater/app/Space/RequirementsChecker.php
Executable file
@@ -0,0 +1,236 @@
|
||||
<?php
|
||||
|
||||
namespace Crater\Space;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use PDO;
|
||||
use SQLite3;
|
||||
|
||||
class RequirementsChecker
|
||||
{
|
||||
/**
|
||||
* Minimum PHP Version Supported (Override is in installer.php config file).
|
||||
*
|
||||
* @var _minPhpVersion
|
||||
*/
|
||||
private $_minPhpVersion = '7.0.0';
|
||||
|
||||
/**
|
||||
* Check for the server requirements.
|
||||
*
|
||||
* @param array $requirements
|
||||
* @return array
|
||||
*/
|
||||
public function check(array $requirements)
|
||||
{
|
||||
$results = [];
|
||||
|
||||
foreach ($requirements as $type => $requirement) {
|
||||
switch ($type) {
|
||||
// check php requirements
|
||||
case 'php':
|
||||
foreach ($requirements[$type] as $requirement) {
|
||||
$results['requirements'][$type][$requirement] = true;
|
||||
|
||||
if (! extension_loaded($requirement)) {
|
||||
$results['requirements'][$type][$requirement] = false;
|
||||
|
||||
$results['errors'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
// check apache requirements
|
||||
case 'apache':
|
||||
foreach ($requirements[$type] as $requirement) {
|
||||
// if function doesn't exist we can't check apache modules
|
||||
if (function_exists('apache_get_modules')) {
|
||||
$results['requirements'][$type][$requirement] = true;
|
||||
|
||||
if (! in_array($requirement, apache_get_modules())) {
|
||||
$results['requirements'][$type][$requirement] = false;
|
||||
|
||||
$results['errors'] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check PHP version requirement.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function checkPHPVersion(string $minPhpVersion = null)
|
||||
{
|
||||
$minVersionPhp = $minPhpVersion;
|
||||
$currentPhpVersion = $this->getPhpVersionInfo();
|
||||
$supported = false;
|
||||
|
||||
if ($minPhpVersion == null) {
|
||||
$minVersionPhp = $this->getMinPhpVersion();
|
||||
}
|
||||
|
||||
if (version_compare($currentPhpVersion['version'], $minVersionPhp) >= 0) {
|
||||
$supported = true;
|
||||
}
|
||||
|
||||
$phpStatus = [
|
||||
'full' => $currentPhpVersion['full'],
|
||||
'current' => $currentPhpVersion['version'],
|
||||
'minimum' => $minVersionPhp,
|
||||
'supported' => $supported,
|
||||
];
|
||||
|
||||
return $phpStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current Php version information.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private static function getPhpVersionInfo()
|
||||
{
|
||||
$currentVersionFull = PHP_VERSION;
|
||||
preg_match("#^\d+(\.\d+)*#", $currentVersionFull, $filtered);
|
||||
$currentVersion = $filtered[0];
|
||||
|
||||
return [
|
||||
'full' => $currentVersionFull,
|
||||
'version' => $currentVersion,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get minimum PHP version ID.
|
||||
*
|
||||
* @return string _minPhpVersion
|
||||
*/
|
||||
protected function getMinPhpVersion()
|
||||
{
|
||||
return $this->_minPhpVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check PHP version requirement.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function checkMysqlVersion($conn)
|
||||
{
|
||||
$version_info = $conn->getAttribute(PDO::ATTR_SERVER_VERSION);
|
||||
|
||||
$isMariaDb = Str::contains($version_info, 'MariaDB');
|
||||
|
||||
$minVersionMysql = $isMariaDb ? config('crater.min_mariadb_version') : config('crater.min_mysql_version');
|
||||
|
||||
$currentMysqlVersion = $this->getMysqlVersionInfo($conn);
|
||||
|
||||
$supported = false;
|
||||
|
||||
if (version_compare($currentMysqlVersion, $minVersionMysql) >= 0) {
|
||||
$supported = true;
|
||||
}
|
||||
|
||||
$phpStatus = [
|
||||
'current' => $currentMysqlVersion,
|
||||
'minimum' => $minVersionMysql,
|
||||
'supported' => $supported,
|
||||
];
|
||||
|
||||
return $phpStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current Mysql version information.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function getMysqlVersionInfo($pdo)
|
||||
{
|
||||
$version = $pdo->query('select version()')->fetchColumn();
|
||||
|
||||
preg_match("/^[0-9\.]+/", $version, $match);
|
||||
|
||||
return $match[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Sqlite version requirement.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function checkSqliteVersion(string $minSqliteVersion = null)
|
||||
{
|
||||
$minVersionSqlite = $minSqliteVersion;
|
||||
$currentSqliteVersion = $this->getSqliteVersionInfo();
|
||||
$supported = false;
|
||||
|
||||
if (version_compare($currentSqliteVersion, $minVersionSqlite) >= 0) {
|
||||
$supported = true;
|
||||
}
|
||||
|
||||
$phpStatus = [
|
||||
'current' => $currentSqliteVersion,
|
||||
'minimum' => $minVersionSqlite,
|
||||
'supported' => $supported,
|
||||
];
|
||||
|
||||
return $phpStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current Sqlite version information.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function getSqliteVersionInfo()
|
||||
{
|
||||
$currentVersion = SQLite3::version();
|
||||
|
||||
return $currentVersion['versionString'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Pgsql version requirement.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function checkPgsqlVersion($conn, string $minPgsqlVersion = null)
|
||||
{
|
||||
$minVersionPgsql = $minPgsqlVersion;
|
||||
$currentPgsqlVersion = $this->getPgsqlVersionInfo($conn);
|
||||
$supported = false;
|
||||
|
||||
if (version_compare($currentPgsqlVersion, $minVersionPgsql) >= 0) {
|
||||
$supported = true;
|
||||
}
|
||||
|
||||
$phpStatus = [
|
||||
'current' => $currentPgsqlVersion,
|
||||
'minimum' => $minVersionPgsql,
|
||||
'supported' => $supported,
|
||||
];
|
||||
|
||||
return $phpStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current Pgsql version information.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function getPgsqlVersionInfo($conn)
|
||||
{
|
||||
$currentVersion = pg_version($conn);
|
||||
|
||||
return $currentVersion['server'];
|
||||
}
|
||||
}
|
||||
35
crater/app/Space/SiteApi.php
Normal file
35
crater/app/Space/SiteApi.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Crater\Space;
|
||||
|
||||
use Crater\Models\Setting;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
|
||||
// Implementation taken from Akaunting - https://github.com/akaunting/akaunting
|
||||
trait SiteApi
|
||||
{
|
||||
protected static function getRemote($url, $data = [], $token = null)
|
||||
{
|
||||
$client = new Client(['verify' => false, 'base_uri' => config('crater.base_url').'/']);
|
||||
|
||||
$headers['headers'] = [
|
||||
'Accept' => 'application/json',
|
||||
'Referer' => url('/'),
|
||||
'crater' => Setting::getSetting('version'),
|
||||
'Authorization' => "Bearer {$token}",
|
||||
];
|
||||
|
||||
$data['http_errors'] = false;
|
||||
|
||||
$data = array_merge($data, $headers);
|
||||
|
||||
try {
|
||||
$result = $client->get($url, $data);
|
||||
} catch (RequestException $e) {
|
||||
$result = $e;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
431
crater/app/Space/TimeZones.php
Normal file
431
crater/app/Space/TimeZones.php
Normal file
@@ -0,0 +1,431 @@
|
||||
<?php
|
||||
|
||||
namespace Crater\Space;
|
||||
|
||||
class TimeZones
|
||||
{
|
||||
public static function get_list()
|
||||
{
|
||||
return [
|
||||
['value' => 'Pacific/Midway', 'key' => '(UTC-11:00) Midway'],
|
||||
['value' => 'Pacific/Niue', 'key' => '(UTC-11:00) Niue'],
|
||||
['value' => 'Pacific/Pago_Pago', 'key' => '(UTC-11:00) Pago Pago'],
|
||||
['value' => 'America/Adak', 'key' => '(UTC-10:00) Adak'],
|
||||
['value' => 'Pacific/Honolulu', 'key' => '(UTC-10:00) Honolulu'],
|
||||
['value' => 'Pacific/Johnston', 'key' => '(UTC-10:00) Johnston'],
|
||||
['value' => 'Pacific/Rarotonga', 'key' => '(UTC-10:00) Rarotonga'],
|
||||
['value' => 'Pacific/Tahiti', 'key' => '(UTC-10:00) Tahiti'],
|
||||
['value' => 'Pacific/Marquesas', 'key' => '(UTC-09:30) Marquesas'],
|
||||
['value' => 'America/Anchorage', 'key' => '(UTC-09:00) Anchorage'],
|
||||
['value' => 'Pacific/Gambier', 'key' => '(UTC-09:00) Gambier'],
|
||||
['value' => 'America/Juneau', 'key' => '(UTC-09:00) Juneau'],
|
||||
['value' => 'America/Nome', 'key' => '(UTC-09:00) Nome'],
|
||||
['value' => 'America/Sitka', 'key' => '(UTC-09:00) Sitka'],
|
||||
['value' => 'America/Yakutat', 'key' => '(UTC-09:00) Yakutat'],
|
||||
['value' => 'America/Dawson', 'key' => '(UTC-08:00) Dawson'],
|
||||
['value' => 'America/Los_Angeles', 'key' => '(UTC-08:00) Los Angeles'],
|
||||
['value' => 'America/Metlakatla', 'key' => '(UTC-08:00) Metlakatla'],
|
||||
['value' => 'Pacific/Pitcairn', 'key' => '(UTC-08:00) Pitcairn'],
|
||||
['value' => 'America/Santa_Isabel', 'key' => '(UTC-08:00) Santa Isabel'],
|
||||
['value' => 'America/Tijuana', 'key' => '(UTC-08:00) Tijuana'],
|
||||
['value' => 'America/Vancouver', 'key' => '(UTC-08:00) Vancouver'],
|
||||
['value' => 'America/Whitehorse', 'key' => '(UTC-08:00) Whitehorse'],
|
||||
['value' => 'America/Boise', 'key' => '(UTC-07:00) Boise'],
|
||||
['value' => 'America/Cambridge_Bay', 'key' => '(UTC-07:00) Cambridge Bay'],
|
||||
['value' => 'America/Chihuahua', 'key' => '(UTC-07:00) Chihuahua'],
|
||||
['value' => 'America/Creston', 'key' => '(UTC-07:00) Creston'],
|
||||
['value' => 'America/Dawson_Creek', 'key' => '(UTC-07:00) Dawson Creek'],
|
||||
['value' => 'America/Denver', 'key' => '(UTC-07:00) Denver'],
|
||||
['value' => 'America/Edmonton', 'key' => '(UTC-07:00) Edmonton'],
|
||||
['value' => 'America/Hermosillo', 'key' => '(UTC-07:00) Hermosillo'],
|
||||
['value' => 'America/Inuvik', 'key' => '(UTC-07:00) Inuvik'],
|
||||
['value' => 'America/Mazatlan', 'key' => '(UTC-07:00) Mazatlan'],
|
||||
['value' => 'America/Ojinaga', 'key' => '(UTC-07:00) Ojinaga'],
|
||||
['value' => 'America/Phoenix', 'key' => '(UTC-07:00) Phoenix'],
|
||||
['value' => 'America/Shiprock', 'key' => '(UTC-07:00) Shiprock'],
|
||||
['value' => 'America/Yellowknife', 'key' => '(UTC-07:00) Yellowknife'],
|
||||
['value' => 'America/Bahia_Banderas', 'key' => '(UTC-06:00) Bahia Banderas'],
|
||||
['value' => 'America/Belize', 'key' => '(UTC-06:00) Belize'],
|
||||
['value' => 'America/North_Dakota/Beulah', 'key' => '(UTC-06:00) Beulah'],
|
||||
['value' => 'America/Cancun', 'key' => '(UTC-06:00) Cancun'],
|
||||
['value' => 'America/North_Dakota/Center', 'key' => '(UTC-06:00) Center'],
|
||||
['value' => 'America/Chicago', 'key' => '(UTC-06:00) Chicago'],
|
||||
['value' => 'America/Costa_Rica', 'key' => '(UTC-06:00) Costa Rica'],
|
||||
['value' => 'Pacific/Easter', 'key' => '(UTC-06:00) Easter'],
|
||||
['value' => 'America/El_Salvador', 'key' => '(UTC-06:00) El Salvador'],
|
||||
['value' => 'Pacific/Galapagos', 'key' => '(UTC-06:00) Galapagos'],
|
||||
['value' => 'America/Guatemala', 'key' => '(UTC-06:00) Guatemala'],
|
||||
['value' => 'America/Indiana/Knox', 'key' => '(UTC-06:00) Knox'],
|
||||
['value' => 'America/Managua', 'key' => '(UTC-06:00) Managua'],
|
||||
['value' => 'America/Matamoros', 'key' => '(UTC-06:00) Matamoros'],
|
||||
['value' => 'America/Menominee', 'key' => '(UTC-06:00) Menominee'],
|
||||
['value' => 'America/Merida', 'key' => '(UTC-06:00) Merida'],
|
||||
['value' => 'America/Mexico_City', 'key' => '(UTC-06:00) Mexico City'],
|
||||
['value' => 'America/Monterrey', 'key' => '(UTC-06:00) Monterrey'],
|
||||
['value' => 'America/North_Dakota/New_Salem', 'key' => '(UTC-06:00) New Salem'],
|
||||
['value' => 'America/Rainy_River', 'key' => '(UTC-06:00) Rainy River'],
|
||||
['value' => 'America/Rankin_Inlet', 'key' => '(UTC-06:00) Rankin Inlet'],
|
||||
['value' => 'America/Regina', 'key' => '(UTC-06:00) Regina'],
|
||||
['value' => 'America/Resolute', 'key' => '(UTC-06:00) Resolute'],
|
||||
['value' => 'America/Swift_Current', 'key' => '(UTC-06:00) Swift Current'],
|
||||
['value' => 'America/Tegucigalpa', 'key' => '(UTC-06:00) Tegucigalpa'],
|
||||
['value' => 'America/Indiana/Tell_City', 'key' => '(UTC-06:00) Tell City'],
|
||||
['value' => 'America/Winnipeg', 'key' => '(UTC-06:00) Winnipeg'],
|
||||
['value' => 'America/Atikokan', 'key' => '(UTC-05:00) Atikokan'],
|
||||
['value' => 'America/Bogota', 'key' => '(UTC-05:00) Bogota'],
|
||||
['value' => 'America/Cayman', 'key' => '(UTC-05:00) Cayman'],
|
||||
['value' => 'America/Detroit', 'key' => '(UTC-05:00) Detroit'],
|
||||
['value' => 'America/Grand_Turk', 'key' => '(UTC-05:00) Grand Turk'],
|
||||
['value' => 'America/Guayaquil', 'key' => '(UTC-05:00) Guayaquil'],
|
||||
['value' => 'America/Havana', 'key' => '(UTC-05:00) Havana'],
|
||||
['value' => 'America/Indiana/Indianapolis', 'key' => '(UTC-05:00) Indianapolis'],
|
||||
['value' => 'America/Iqaluit', 'key' => '(UTC-05:00) Iqaluit'],
|
||||
['value' => 'America/Jamaica', 'key' => '(UTC-05:00) Jamaica'],
|
||||
['value' => 'America/Lima', 'key' => '(UTC-05:00) Lima'],
|
||||
['value' => 'America/Kentucky/Louisville', 'key' => '(UTC-05:00) Louisville'],
|
||||
['value' => 'America/Indiana/Marengo', 'key' => '(UTC-05:00) Marengo'],
|
||||
['value' => 'America/Kentucky/Monticello', 'key' => '(UTC-05:00) Monticello'],
|
||||
['value' => 'America/Montreal', 'key' => '(UTC-05:00) Montreal'],
|
||||
['value' => 'America/Nassau', 'key' => '(UTC-05:00) Nassau'],
|
||||
['value' => 'America/New_York', 'key' => '(UTC-05:00) New York'],
|
||||
['value' => 'America/Nipigon', 'key' => '(UTC-05:00) Nipigon'],
|
||||
['value' => 'America/Panama', 'key' => '(UTC-05:00) Panama'],
|
||||
['value' => 'America/Pangnirtung', 'key' => '(UTC-05:00) Pangnirtung'],
|
||||
['value' => 'America/Indiana/Petersburg', 'key' => '(UTC-05:00) Petersburg'],
|
||||
['value' => 'America/Port-au-Prince', 'key' => '(UTC-05:00) Port-au-Prince'],
|
||||
['value' => 'America/Thunder_Bay', 'key' => '(UTC-05:00) Thunder Bay'],
|
||||
['value' => 'America/Toronto', 'key' => '(UTC-05:00) Toronto'],
|
||||
['value' => 'America/Indiana/Vevay', 'key' => '(UTC-05:00) Vevay'],
|
||||
['value' => 'America/Indiana/Vincennes', 'key' => '(UTC-05:00) Vincennes'],
|
||||
['value' => 'America/Indiana/Winamac', 'key' => '(UTC-05:00) Winamac'],
|
||||
['value' => 'America/Caracas', 'key' => '(UTC-04:30) Caracas'],
|
||||
['value' => 'America/Anguilla', 'key' => '(UTC-04:00) Anguilla'],
|
||||
['value' => 'America/Antigua', 'key' => '(UTC-04:00) Antigua'],
|
||||
['value' => 'America/Aruba', 'key' => '(UTC-04:00) Aruba'],
|
||||
['value' => 'America/Asuncion', 'key' => '(UTC-04:00) Asuncion'],
|
||||
['value' => 'America/Barbados', 'key' => '(UTC-04:00) Barbados'],
|
||||
['value' => 'Atlantic/Bermuda', 'key' => '(UTC-04:00) Bermuda'],
|
||||
['value' => 'America/Blanc-Sablon', 'key' => '(UTC-04:00) Blanc-Sablon'],
|
||||
['value' => 'America/Boa_Vista', 'key' => '(UTC-04:00) Boa Vista'],
|
||||
['value' => 'America/Campo_Grande', 'key' => '(UTC-04:00) Campo Grande'],
|
||||
['value' => 'America/Cuiaba', 'key' => '(UTC-04:00) Cuiaba'],
|
||||
['value' => 'America/Curacao', 'key' => '(UTC-04:00) Curacao'],
|
||||
['value' => 'America/Dominica', 'key' => '(UTC-04:00) Dominica'],
|
||||
['value' => 'America/Eirunepe', 'key' => '(UTC-04:00) Eirunepe'],
|
||||
['value' => 'America/Glace_Bay', 'key' => '(UTC-04:00) Glace Bay'],
|
||||
['value' => 'America/Goose_Bay', 'key' => '(UTC-04:00) Goose Bay'],
|
||||
['value' => 'America/Grenada', 'key' => '(UTC-04:00) Grenada'],
|
||||
['value' => 'America/Guadeloupe', 'key' => '(UTC-04:00) Guadeloupe'],
|
||||
['value' => 'America/Guyana', 'key' => '(UTC-04:00) Guyana'],
|
||||
['value' => 'America/Halifax', 'key' => '(UTC-04:00) Halifax'],
|
||||
['value' => 'America/Kralendijk', 'key' => '(UTC-04:00) Kralendijk'],
|
||||
['value' => 'America/La_Paz', 'key' => '(UTC-04:00) La Paz'],
|
||||
['value' => 'America/Lower_Princes', 'key' => '(UTC-04:00) Lower Princes'],
|
||||
['value' => 'America/Manaus', 'key' => '(UTC-04:00) Manaus'],
|
||||
['value' => 'America/Marigot', 'key' => '(UTC-04:00) Marigot'],
|
||||
['value' => 'America/Martinique', 'key' => '(UTC-04:00) Martinique'],
|
||||
['value' => 'America/Moncton', 'key' => '(UTC-04:00) Moncton'],
|
||||
['value' => 'America/Montserrat', 'key' => '(UTC-04:00) Montserrat'],
|
||||
['value' => 'Antarctica/Palmer', 'key' => '(UTC-04:00) Palmer'],
|
||||
['value' => 'America/Port_of_Spain', 'key' => '(UTC-04:00) Port of Spain'],
|
||||
['value' => 'America/Porto_Velho', 'key' => '(UTC-04:00) Porto Velho'],
|
||||
['value' => 'America/Puerto_Rico', 'key' => '(UTC-04:00) Puerto Rico'],
|
||||
['value' => 'America/Rio_Branco', 'key' => '(UTC-04:00) Rio Branco'],
|
||||
['value' => 'America/Santiago', 'key' => '(UTC-04:00) Santiago'],
|
||||
['value' => 'America/Santo_Domingo', 'key' => '(UTC-04:00) Santo Domingo'],
|
||||
['value' => 'America/St_Barthelemy', 'key' => '(UTC-04:00) St. Barthelemy'],
|
||||
['value' => 'America/St_Kitts', 'key' => '(UTC-04:00) St. Kitts'],
|
||||
['value' => 'America/St_Lucia', 'key' => '(UTC-04:00) St. Lucia'],
|
||||
['value' => 'America/St_Thomas', 'key' => '(UTC-04:00) St. Thomas'],
|
||||
['value' => 'America/St_Vincent', 'key' => '(UTC-04:00) St. Vincent'],
|
||||
['value' => 'America/Thule', 'key' => '(UTC-04:00) Thule'],
|
||||
['value' => 'America/Tortola', 'key' => '(UTC-04:00) Tortola'],
|
||||
['value' => 'America/St_Johns', 'key' => '(UTC-03:30) St. Johns'],
|
||||
['value' => 'America/Araguaina', 'key' => '(UTC-03:00) Araguaina'],
|
||||
['value' => 'America/Bahia', 'key' => '(UTC-03:00) Bahia'],
|
||||
['value' => 'America/Belem', 'key' => '(UTC-03:00) Belem'],
|
||||
['value' => 'America/Argentina/Buenos_Aires', 'key' => '(UTC-03:00) Buenos Aires'],
|
||||
['value' => 'America/Argentina/Catamarca', 'key' => '(UTC-03:00) Catamarca'],
|
||||
['value' => 'America/Cayenne', 'key' => '(UTC-03:00) Cayenne'],
|
||||
['value' => 'America/Argentina/Cordoba', 'key' => '(UTC-03:00) Cordoba'],
|
||||
['value' => 'America/Fortaleza', 'key' => '(UTC-03:00) Fortaleza'],
|
||||
['value' => 'America/Godthab', 'key' => '(UTC-03:00) Godthab'],
|
||||
['value' => 'America/Argentina/Jujuy', 'key' => '(UTC-03:00) Jujuy'],
|
||||
['value' => 'America/Argentina/La_Rioja', 'key' => '(UTC-03:00) La Rioja'],
|
||||
['value' => 'America/Maceio', 'key' => '(UTC-03:00) Maceio'],
|
||||
['value' => 'America/Argentina/Mendoza', 'key' => '(UTC-03:00) Mendoza'],
|
||||
['value' => 'America/Miquelon', 'key' => '(UTC-03:00) Miquelon'],
|
||||
['value' => 'America/Montevideo', 'key' => '(UTC-03:00) Montevideo'],
|
||||
['value' => 'America/Paramaribo', 'key' => '(UTC-03:00) Paramaribo'],
|
||||
['value' => 'America/Recife', 'key' => '(UTC-03:00) Recife'],
|
||||
['value' => 'America/Argentina/Rio_Gallegos', 'key' => '(UTC-03:00) Rio Gallegos'],
|
||||
['value' => 'Antarctica/Rothera', 'key' => '(UTC-03:00) Rothera'],
|
||||
['value' => 'America/Argentina/Salta', 'key' => '(UTC-03:00) Salta'],
|
||||
['value' => 'America/Argentina/San_Juan', 'key' => '(UTC-03:00) San Juan'],
|
||||
['value' => 'America/Argentina/San_Luis', 'key' => '(UTC-03:00) San Luis'],
|
||||
['value' => 'America/Santarem', 'key' => '(UTC-03:00) Santarem'],
|
||||
['value' => 'America/Sao_Paulo', 'key' => '(UTC-03:00) Sao Paulo'],
|
||||
['value' => 'Atlantic/Stanley', 'key' => '(UTC-03:00) Stanley'],
|
||||
['value' => 'America/Argentina/Tucuman', 'key' => '(UTC-03:00) Tucuman'],
|
||||
['value' => 'America/Argentina/Ushuaia', 'key' => '(UTC-03:00) Ushuaia'],
|
||||
['value' => 'America/Noronha', 'key' => '(UTC-02:00) Noronha'],
|
||||
['value' => 'Atlantic/South_Georgia', 'key' => '(UTC-02:00) South Georgia'],
|
||||
['value' => 'Atlantic/Azores', 'key' => '(UTC-01:00) Azores'],
|
||||
['value' => 'Atlantic/Cape_Verde', 'key' => '(UTC-01:00) Cape Verde'],
|
||||
['value' => 'America/Scoresbysund', 'key' => '(UTC-01:00) Scoresbysund'],
|
||||
['value' => 'Africa/Abidjan', 'key' => '(UTC+00:00) Abidjan'],
|
||||
['value' => 'Africa/Accra', 'key' => '(UTC+00:00) Accra'],
|
||||
['value' => 'Africa/Bamako', 'key' => '(UTC+00:00) Bamako'],
|
||||
['value' => 'Africa/Banjul', 'key' => '(UTC+00:00) Banjul'],
|
||||
['value' => 'Africa/Bissau', 'key' => '(UTC+00:00) Bissau'],
|
||||
['value' => 'Atlantic/Canary', 'key' => '(UTC+00:00) Canary'],
|
||||
['value' => 'Africa/Casablanca', 'key' => '(UTC+00:00) Casablanca'],
|
||||
['value' => 'Africa/Conakry', 'key' => '(UTC+00:00) Conakry'],
|
||||
['value' => 'Africa/Dakar', 'key' => '(UTC+00:00) Dakar'],
|
||||
['value' => 'America/Danmarkshavn', 'key' => '(UTC+00:00) Danmarkshavn'],
|
||||
['value' => 'Europe/Dublin', 'key' => '(UTC+00:00) Dublin'],
|
||||
['value' => 'Africa/El_Aaiun', 'key' => '(UTC+00:00) El Aaiun'],
|
||||
['value' => 'Atlantic/Faroe', 'key' => '(UTC+00:00) Faroe'],
|
||||
['value' => 'Africa/Freetown', 'key' => '(UTC+00:00) Freetown'],
|
||||
['value' => 'Europe/Guernsey', 'key' => '(UTC+00:00) Guernsey'],
|
||||
['value' => 'Europe/Isle_of_Man', 'key' => '(UTC+00:00) Isle of Man'],
|
||||
['value' => 'Europe/Jersey', 'key' => '(UTC+00:00) Jersey'],
|
||||
['value' => 'Europe/Lisbon', 'key' => '(UTC+00:00) Lisbon'],
|
||||
['value' => 'Africa/Lome', 'key' => '(UTC+00:00) Lome'],
|
||||
['value' => 'Europe/London', 'key' => '(UTC+00:00) London'],
|
||||
['value' => 'Atlantic/Madeira', 'key' => '(UTC+00:00) Madeira'],
|
||||
['value' => 'Africa/Monrovia', 'key' => '(UTC+00:00) Monrovia'],
|
||||
['value' => 'Africa/Nouakchott', 'key' => '(UTC+00:00) Nouakchott'],
|
||||
['value' => 'Africa/Ouagadougou', 'key' => '(UTC+00:00) Ouagadougou'],
|
||||
['value' => 'Atlantic/Reykjavik', 'key' => '(UTC+00:00) Reykjavik'],
|
||||
['value' => 'Africa/Sao_Tome', 'key' => '(UTC+00:00) Sao Tome'],
|
||||
['value' => 'Atlantic/St_Helena', 'key' => '(UTC+00:00) St. Helena'],
|
||||
['value' => 'UTC', 'key' => '(UTC+00:00) UTC'],
|
||||
['value' => 'Africa/Algiers', 'key' => '(UTC+01:00) Algiers'],
|
||||
['value' => 'Europe/Amsterdam', 'key' => '(UTC+01:00) Amsterdam'],
|
||||
['value' => 'Europe/Andorra', 'key' => '(UTC+01:00) Andorra'],
|
||||
['value' => 'Africa/Bangui', 'key' => '(UTC+01:00) Bangui'],
|
||||
['value' => 'Europe/Belgrade', 'key' => '(UTC+01:00) Belgrade'],
|
||||
['value' => 'Europe/Berlin', 'key' => '(UTC+01:00) Berlin'],
|
||||
['value' => 'Europe/Bratislava', 'key' => '(UTC+01:00) Bratislava'],
|
||||
['value' => 'Africa/Brazzaville', 'key' => '(UTC+01:00) Brazzaville'],
|
||||
['value' => 'Europe/Brussels', 'key' => '(UTC+01:00) Brussels'],
|
||||
['value' => 'Europe/Budapest', 'key' => '(UTC+01:00) Budapest'],
|
||||
['value' => 'Europe/Busingen', 'key' => '(UTC+01:00) Busingen'],
|
||||
['value' => 'Africa/Ceuta', 'key' => '(UTC+01:00) Ceuta'],
|
||||
['value' => 'Europe/Copenhagen', 'key' => '(UTC+01:00) Copenhagen'],
|
||||
['value' => 'Africa/Douala', 'key' => '(UTC+01:00) Douala'],
|
||||
['value' => 'Europe/Gibraltar', 'key' => '(UTC+01:00) Gibraltar'],
|
||||
['value' => 'Africa/Kinshasa', 'key' => '(UTC+01:00) Kinshasa'],
|
||||
['value' => 'Africa/Lagos', 'key' => '(UTC+01:00) Lagos'],
|
||||
['value' => 'Africa/Libreville', 'key' => '(UTC+01:00) Libreville'],
|
||||
['value' => 'Europe/Ljubljana', 'key' => '(UTC+01:00) Ljubljana'],
|
||||
['value' => 'Arctic/Longyearbyen', 'key' => '(UTC+01:00) Longyearbyen'],
|
||||
['value' => 'Africa/Luanda', 'key' => '(UTC+01:00) Luanda'],
|
||||
['value' => 'Europe/Luxembourg', 'key' => '(UTC+01:00) Luxembourg'],
|
||||
['value' => 'Europe/Madrid', 'key' => '(UTC+01:00) Madrid'],
|
||||
['value' => 'Africa/Malabo', 'key' => '(UTC+01:00) Malabo'],
|
||||
['value' => 'Europe/Malta', 'key' => '(UTC+01:00) Malta'],
|
||||
['value' => 'Europe/Monaco', 'key' => '(UTC+01:00) Monaco'],
|
||||
['value' => 'Africa/Ndjamena', 'key' => '(UTC+01:00) Ndjamena'],
|
||||
['value' => 'Africa/Niamey', 'key' => '(UTC+01:00) Niamey'],
|
||||
['value' => 'Europe/Oslo', 'key' => '(UTC+01:00) Oslo'],
|
||||
['value' => 'Europe/Paris', 'key' => '(UTC+01:00) Paris'],
|
||||
['value' => 'Europe/Podgorica', 'key' => '(UTC+01:00) Podgorica'],
|
||||
['value' => 'Africa/Porto-Novo', 'key' => '(UTC+01:00) Porto-Novo'],
|
||||
['value' => 'Europe/Prague', 'key' => '(UTC+01:00) Prague'],
|
||||
['value' => 'Europe/Rome', 'key' => '(UTC+01:00) Rome'],
|
||||
['value' => 'Europe/San_Marino', 'key' => '(UTC+01:00) San Marino'],
|
||||
['value' => 'Europe/Sarajevo', 'key' => '(UTC+01:00) Sarajevo'],
|
||||
['value' => 'Europe/Skopje', 'key' => '(UTC+01:00) Skopje'],
|
||||
['value' => 'Europe/Stockholm', 'key' => '(UTC+01:00) Stockholm'],
|
||||
['value' => 'Europe/Tirane', 'key' => '(UTC+01:00) Tirane'],
|
||||
['value' => 'Africa/Tripoli', 'key' => '(UTC+01:00) Tripoli'],
|
||||
['value' => 'Africa/Tunis', 'key' => '(UTC+01:00) Tunis'],
|
||||
['value' => 'Europe/Vaduz', 'key' => '(UTC+01:00) Vaduz'],
|
||||
['value' => 'Europe/Vatican', 'key' => '(UTC+01:00) Vatican'],
|
||||
['value' => 'Europe/Vienna', 'key' => '(UTC+01:00) Vienna'],
|
||||
['value' => 'Europe/Warsaw', 'key' => '(UTC+01:00) Warsaw'],
|
||||
['value' => 'Africa/Windhoek', 'key' => '(UTC+01:00) Windhoek'],
|
||||
['value' => 'Europe/Zagreb', 'key' => '(UTC+01:00) Zagreb'],
|
||||
['value' => 'Europe/Zurich', 'key' => '(UTC+01:00) Zurich'],
|
||||
['value' => 'Europe/Athens', 'key' => '(UTC+02:00) Athens'],
|
||||
['value' => 'Asia/Beirut', 'key' => '(UTC+02:00) Beirut'],
|
||||
['value' => 'Africa/Blantyre', 'key' => '(UTC+02:00) Blantyre'],
|
||||
['value' => 'Europe/Bucharest', 'key' => '(UTC+02:00) Bucharest'],
|
||||
['value' => 'Africa/Bujumbura', 'key' => '(UTC+02:00) Bujumbura'],
|
||||
['value' => 'Africa/Cairo', 'key' => '(UTC+02:00) Cairo'],
|
||||
['value' => 'Europe/Chisinau', 'key' => '(UTC+02:00) Chisinau'],
|
||||
['value' => 'Asia/Damascus', 'key' => '(UTC+02:00) Damascus'],
|
||||
['value' => 'Africa/Gaborone', 'key' => '(UTC+02:00) Gaborone'],
|
||||
['value' => 'Asia/Gaza', 'key' => '(UTC+02:00) Gaza'],
|
||||
['value' => 'Africa/Harare', 'key' => '(UTC+02:00) Harare'],
|
||||
['value' => 'Asia/Hebron', 'key' => '(UTC+02:00) Hebron'],
|
||||
['value' => 'Europe/Helsinki', 'key' => '(UTC+02:00) Helsinki'],
|
||||
['value' => 'Europe/Istanbul', 'key' => '(UTC+02:00) Istanbul'],
|
||||
['value' => 'Asia/Jerusalem', 'key' => '(UTC+02:00) Jerusalem'],
|
||||
['value' => 'Africa/Johannesburg', 'key' => '(UTC+02:00) Johannesburg'],
|
||||
['value' => 'Europe/Kiev', 'key' => '(UTC+02:00) Kiev'],
|
||||
['value' => 'Africa/Kigali', 'key' => '(UTC+02:00) Kigali'],
|
||||
['value' => 'Africa/Lubumbashi', 'key' => '(UTC+02:00) Lubumbashi'],
|
||||
['value' => 'Africa/Lusaka', 'key' => '(UTC+02:00) Lusaka'],
|
||||
['value' => 'Africa/Maputo', 'key' => '(UTC+02:00) Maputo'],
|
||||
['value' => 'Europe/Mariehamn', 'key' => '(UTC+02:00) Mariehamn'],
|
||||
['value' => 'Africa/Maseru', 'key' => '(UTC+02:00) Maseru'],
|
||||
['value' => 'Africa/Mbabane', 'key' => '(UTC+02:00) Mbabane'],
|
||||
['value' => 'Asia/Nicosia', 'key' => '(UTC+02:00) Nicosia'],
|
||||
['value' => 'Europe/Riga', 'key' => '(UTC+02:00) Riga'],
|
||||
['value' => 'Europe/Simferopol', 'key' => '(UTC+02:00) Simferopol'],
|
||||
['value' => 'Europe/Sofia', 'key' => '(UTC+02:00) Sofia'],
|
||||
['value' => 'Europe/Tallinn', 'key' => '(UTC+02:00) Tallinn'],
|
||||
['value' => 'Europe/Uzhgorod', 'key' => '(UTC+02:00) Uzhgorod'],
|
||||
['value' => 'Europe/Vilnius', 'key' => '(UTC+02:00) Vilnius'],
|
||||
['value' => 'Europe/Zaporozhye', 'key' => '(UTC+02:00) Zaporozhye'],
|
||||
['value' => 'Africa/Addis_Ababa', 'key' => '(UTC+03:00) Addis Ababa'],
|
||||
['value' => 'Asia/Aden', 'key' => '(UTC+03:00) Aden'],
|
||||
['value' => 'Asia/Amman', 'key' => '(UTC+03:00) Amman'],
|
||||
['value' => 'Indian/Antananarivo', 'key' => '(UTC+03:00) Antananarivo'],
|
||||
['value' => 'Africa/Asmara', 'key' => '(UTC+03:00) Asmara'],
|
||||
['value' => 'Asia/Baghdad', 'key' => '(UTC+03:00) Baghdad'],
|
||||
['value' => 'Asia/Bahrain', 'key' => '(UTC+03:00) Bahrain'],
|
||||
['value' => 'Indian/Comoro', 'key' => '(UTC+03:00) Comoro'],
|
||||
['value' => 'Africa/Dar_es_Salaam', 'key' => '(UTC+03:00) Dar es Salaam'],
|
||||
['value' => 'Africa/Djibouti', 'key' => '(UTC+03:00) Djibouti'],
|
||||
['value' => 'Africa/Juba', 'key' => '(UTC+03:00) Juba'],
|
||||
['value' => 'Europe/Kaliningrad', 'key' => '(UTC+03:00) Kaliningrad'],
|
||||
['value' => 'Africa/Kampala', 'key' => '(UTC+03:00) Kampala'],
|
||||
['value' => 'Africa/Khartoum', 'key' => '(UTC+03:00) Khartoum'],
|
||||
['value' => 'Asia/Kuwait', 'key' => '(UTC+03:00) Kuwait'],
|
||||
['value' => 'Indian/Mayotte', 'key' => '(UTC+03:00) Mayotte'],
|
||||
['value' => 'Europe/Minsk', 'key' => '(UTC+03:00) Minsk'],
|
||||
['value' => 'Africa/Mogadishu', 'key' => '(UTC+03:00) Mogadishu'],
|
||||
['value' => 'Africa/Nairobi', 'key' => '(UTC+03:00) Nairobi'],
|
||||
['value' => 'Asia/Qatar', 'key' => '(UTC+03:00) Qatar'],
|
||||
['value' => 'Asia/Riyadh', 'key' => '(UTC+03:00) Riyadh'],
|
||||
['value' => 'Antarctica/Syowa', 'key' => '(UTC+03:00) Syowa'],
|
||||
['value' => 'Asia/Tehran', 'key' => '(UTC+03:30) Tehran'],
|
||||
['value' => 'Asia/Baku', 'key' => '(UTC+04:00) Baku'],
|
||||
['value' => 'Asia/Dubai', 'key' => '(UTC+04:00) Dubai'],
|
||||
['value' => 'Indian/Mahe', 'key' => '(UTC+04:00) Mahe'],
|
||||
['value' => 'Indian/Mauritius', 'key' => '(UTC+04:00) Mauritius'],
|
||||
['value' => 'Europe/Moscow', 'key' => '(UTC+04:00) Moscow'],
|
||||
['value' => 'Asia/Muscat', 'key' => '(UTC+04:00) Muscat'],
|
||||
['value' => 'Indian/Reunion', 'key' => '(UTC+04:00) Reunion'],
|
||||
['value' => 'Europe/Samara', 'key' => '(UTC+04:00) Samara'],
|
||||
['value' => 'Asia/Tbilisi', 'key' => '(UTC+04:00) Tbilisi'],
|
||||
['value' => 'Europe/Volgograd', 'key' => '(UTC+04:00) Volgograd'],
|
||||
['value' => 'Asia/Yerevan', 'key' => '(UTC+04:00) Yerevan'],
|
||||
['value' => 'Asia/Kabul', 'key' => '(UTC+04:30) Kabul'],
|
||||
['value' => 'Asia/Aqtau', 'key' => '(UTC+05:00) Aqtau'],
|
||||
['value' => 'Asia/Aqtobe', 'key' => '(UTC+05:00) Aqtobe'],
|
||||
['value' => 'Asia/Ashgabat', 'key' => '(UTC+05:00) Ashgabat'],
|
||||
['value' => 'Asia/Dushanbe', 'key' => '(UTC+05:00) Dushanbe'],
|
||||
['value' => 'Asia/Karachi', 'key' => '(UTC+05:00) Karachi'],
|
||||
['value' => 'Indian/Kerguelen', 'key' => '(UTC+05:00) Kerguelen'],
|
||||
['value' => 'Indian/Maldives', 'key' => '(UTC+05:00) Maldives'],
|
||||
['value' => 'Antarctica/Mawson', 'key' => '(UTC+05:00) Mawson'],
|
||||
['value' => 'Asia/Oral', 'key' => '(UTC+05:00) Oral'],
|
||||
['value' => 'Asia/Samarkand', 'key' => '(UTC+05:00) Samarkand'],
|
||||
['value' => 'Asia/Tashkent', 'key' => '(UTC+05:00) Tashkent'],
|
||||
['value' => 'Asia/Colombo', 'key' => '(UTC+05:30) Colombo'],
|
||||
['value' => 'Asia/Kolkata', 'key' => '(UTC+05:30) Kolkata'],
|
||||
['value' => 'Asia/Kathmandu', 'key' => '(UTC+05:45) Kathmandu'],
|
||||
['value' => 'Asia/Almaty', 'key' => '(UTC+06:00) Almaty'],
|
||||
['value' => 'Asia/Bishkek', 'key' => '(UTC+06:00) Bishkek'],
|
||||
['value' => 'Indian/Chagos', 'key' => '(UTC+06:00) Chagos'],
|
||||
['value' => 'Asia/Dhaka', 'key' => '(UTC+06:00) Dhaka'],
|
||||
['value' => 'Asia/Qyzylorda', 'key' => '(UTC+06:00) Qyzylorda'],
|
||||
['value' => 'Asia/Thimphu', 'key' => '(UTC+06:00) Thimphu'],
|
||||
['value' => 'Antarctica/Vostok', 'key' => '(UTC+06:00) Vostok'],
|
||||
['value' => 'Asia/Yekaterinburg', 'key' => '(UTC+06:00) Yekaterinburg'],
|
||||
['value' => 'Indian/Cocos', 'key' => '(UTC+06:30) Cocos'],
|
||||
['value' => 'Asia/Rangoon', 'key' => '(UTC+06:30) Rangoon'],
|
||||
['value' => 'Asia/Bangkok', 'key' => '(UTC+07:00) Bangkok'],
|
||||
['value' => 'Indian/Christmas', 'key' => '(UTC+07:00) Christmas'],
|
||||
['value' => 'Antarctica/Davis', 'key' => '(UTC+07:00) Davis'],
|
||||
['value' => 'Asia/Ho_Chi_Minh', 'key' => '(UTC+07:00) Ho Chi Minh'],
|
||||
['value' => 'Asia/Hovd', 'key' => '(UTC+07:00) Hovd'],
|
||||
['value' => 'Asia/Jakarta', 'key' => '(UTC+07:00) Jakarta'],
|
||||
['value' => 'Asia/Novokuznetsk', 'key' => '(UTC+07:00) Novokuznetsk'],
|
||||
['value' => 'Asia/Novosibirsk', 'key' => '(UTC+07:00) Novosibirsk'],
|
||||
['value' => 'Asia/Omsk', 'key' => '(UTC+07:00) Omsk'],
|
||||
['value' => 'Asia/Phnom_Penh', 'key' => '(UTC+07:00) Phnom Penh'],
|
||||
['value' => 'Asia/Pontianak', 'key' => '(UTC+07:00) Pontianak'],
|
||||
['value' => 'Asia/Vientiane', 'key' => '(UTC+07:00) Vientiane'],
|
||||
['value' => 'Asia/Brunei', 'key' => '(UTC+08:00) Brunei'],
|
||||
['value' => 'Antarctica/Casey', 'key' => '(UTC+08:00) Casey'],
|
||||
['value' => 'Asia/Choibalsan', 'key' => '(UTC+08:00) Choibalsan'],
|
||||
['value' => 'Asia/Chongqing', 'key' => '(UTC+08:00) Chongqing'],
|
||||
['value' => 'Asia/Harbin', 'key' => '(UTC+08:00) Harbin'],
|
||||
['value' => 'Asia/Hong_Kong', 'key' => '(UTC+08:00) Hong Kong'],
|
||||
['value' => 'Asia/Kashgar', 'key' => '(UTC+08:00) Kashgar'],
|
||||
['value' => 'Asia/Krasnoyarsk', 'key' => '(UTC+08:00) Krasnoyarsk'],
|
||||
['value' => 'Asia/Kuala_Lumpur', 'key' => '(UTC+08:00) Kuala Lumpur'],
|
||||
['value' => 'Asia/Kuching', 'key' => '(UTC+08:00) Kuching'],
|
||||
['value' => 'Asia/Macau', 'key' => '(UTC+08:00) Macau'],
|
||||
['value' => 'Asia/Makassar', 'key' => '(UTC+08:00) Makassar'],
|
||||
['value' => 'Asia/Manila', 'key' => '(UTC+08:00) Manila'],
|
||||
['value' => 'Australia/Perth', 'key' => '(UTC+08:00) Perth'],
|
||||
['value' => 'Asia/Shanghai', 'key' => '(UTC+08:00) Shanghai'],
|
||||
['value' => 'Asia/Singapore', 'key' => '(UTC+08:00) Singapore'],
|
||||
['value' => 'Asia/Taipei', 'key' => '(UTC+08:00) Taipei'],
|
||||
['value' => 'Asia/Ulaanbaatar', 'key' => '(UTC+08:00) Ulaanbaatar'],
|
||||
['value' => 'Asia/Urumqi', 'key' => '(UTC+08:00) Urumqi'],
|
||||
['value' => 'Australia/Eucla', 'key' => '(UTC+08:45) Eucla'],
|
||||
['value' => 'Asia/Dili', 'key' => '(UTC+09:00) Dili'],
|
||||
['value' => 'Asia/Irkutsk', 'key' => '(UTC+09:00) Irkutsk'],
|
||||
['value' => 'Asia/Jayapura', 'key' => '(UTC+09:00) Jayapura'],
|
||||
['value' => 'Pacific/Palau', 'key' => '(UTC+09:00) Palau'],
|
||||
['value' => 'Asia/Pyongyang', 'key' => '(UTC+09:00) Pyongyang'],
|
||||
['value' => 'Asia/Seoul', 'key' => '(UTC+09:00) Seoul'],
|
||||
['value' => 'Asia/Tokyo', 'key' => '(UTC+09:00) Tokyo'],
|
||||
['value' => 'Australia/Adelaide', 'key' => '(UTC+09:30) Adelaide'],
|
||||
['value' => 'Australia/Broken_Hill', 'key' => '(UTC+09:30) Broken Hill'],
|
||||
['value' => 'Australia/Darwin', 'key' => '(UTC+09:30) Darwin'],
|
||||
['value' => 'Australia/Brisbane', 'key' => '(UTC+10:00) Brisbane'],
|
||||
['value' => 'Pacific/Chuuk', 'key' => '(UTC+10:00) Chuuk'],
|
||||
['value' => 'Australia/Currie', 'key' => '(UTC+10:00) Currie'],
|
||||
['value' => 'Antarctica/DumontDUrville', 'key' => '(UTC+10:00) DumontDUrville'],
|
||||
['value' => 'Pacific/Guam', 'key' => '(UTC+10:00) Guam'],
|
||||
['value' => 'Australia/Hobart', 'key' => '(UTC+10:00) Hobart'],
|
||||
['value' => 'Asia/Khandyga', 'key' => '(UTC+10:00) Khandyga'],
|
||||
['value' => 'Australia/Lindeman', 'key' => '(UTC+10:00) Lindeman'],
|
||||
['value' => 'Australia/Melbourne', 'key' => '(UTC+10:00) Melbourne'],
|
||||
['value' => 'Pacific/Port_Moresby', 'key' => '(UTC+10:00) Port Moresby'],
|
||||
['value' => 'Pacific/Saipan', 'key' => '(UTC+10:00) Saipan'],
|
||||
['value' => 'Australia/Sydney', 'key' => '(UTC+10:00) Sydney'],
|
||||
['value' => 'Asia/Yakutsk', 'key' => '(UTC+10:00) Yakutsk'],
|
||||
['value' => 'Australia/Lord_Howe', 'key' => '(UTC+10:30) Lord Howe'],
|
||||
['value' => 'Pacific/Efate', 'key' => '(UTC+11:00) Efate'],
|
||||
['value' => 'Pacific/Guadalcanal', 'key' => '(UTC+11:00) Guadalcanal'],
|
||||
['value' => 'Pacific/Kosrae', 'key' => '(UTC+11:00) Kosrae'],
|
||||
['value' => 'Antarctica/Macquarie', 'key' => '(UTC+11:00) Macquarie'],
|
||||
['value' => 'Pacific/Noumea', 'key' => '(UTC+11:00) Noumea'],
|
||||
['value' => 'Pacific/Pohnpei', 'key' => '(UTC+11:00) Pohnpei'],
|
||||
['value' => 'Asia/Sakhalin', 'key' => '(UTC+11:00) Sakhalin'],
|
||||
['value' => 'Asia/Ust-Nera', 'key' => '(UTC+11:00) Ust-Nera'],
|
||||
['value' => 'Asia/Vladivostok', 'key' => '(UTC+11:00) Vladivostok'],
|
||||
['value' => 'Pacific/Norfolk', 'key' => '(UTC+11:30) Norfolk'],
|
||||
['value' => 'Asia/Anadyr', 'key' => '(UTC+12:00) Anadyr'],
|
||||
['value' => 'Pacific/Auckland', 'key' => '(UTC+12:00) Auckland'],
|
||||
['value' => 'Pacific/Fiji', 'key' => '(UTC+12:00) Fiji'],
|
||||
['value' => 'Pacific/Funafuti', 'key' => '(UTC+12:00) Funafuti'],
|
||||
['value' => 'Asia/Kamchatka', 'key' => '(UTC+12:00) Kamchatka'],
|
||||
['value' => 'Pacific/Kwajalein', 'key' => '(UTC+12:00) Kwajalein'],
|
||||
['value' => 'Asia/Magadan', 'key' => '(UTC+12:00) Magadan'],
|
||||
['value' => 'Pacific/Majuro', 'key' => '(UTC+12:00) Majuro'],
|
||||
['value' => 'Antarctica/McMurdo', 'key' => '(UTC+12:00) McMurdo'],
|
||||
['value' => 'Pacific/Nauru', 'key' => '(UTC+12:00) Nauru'],
|
||||
['value' => 'Antarctica/South_Pole', 'key' => '(UTC+12:00) South Pole'],
|
||||
['value' => 'Pacific/Tarawa', 'key' => '(UTC+12:00) Tarawa'],
|
||||
['value' => 'Pacific/Wake', 'key' => '(UTC+12:00) Wake'],
|
||||
['value' => 'Pacific/Wallis', 'key' => '(UTC+12:00) Wallis'],
|
||||
['value' => 'Pacific/Chatham', 'key' => '(UTC+12:45) Chatham'],
|
||||
['value' => 'Pacific/Apia', 'key' => '(UTC+13:00) Apia'],
|
||||
['value' => 'Pacific/Enderbury', 'key' => '(UTC+13:00) Enderbury'],
|
||||
['value' => 'Pacific/Fakaofo', 'key' => '(UTC+13:00) Fakaofo'],
|
||||
['value' => 'Pacific/Tongatapu', 'key' => '(UTC+13:00) Tongatapu'],
|
||||
['value' => 'Pacific/Kiritimati', 'key' => '(UTC+14:00) Kiritimati'],
|
||||
];
|
||||
}
|
||||
}
|
||||
159
crater/app/Space/Updater.php
Normal file
159
crater/app/Space/Updater.php
Normal file
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
|
||||
namespace Crater\Space;
|
||||
|
||||
use Artisan;
|
||||
use Crater\Events\UpdateFinished;
|
||||
use File;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use ZipArchive;
|
||||
|
||||
// Implementation taken from Akaunting - https://github.com/akaunting/akaunting
|
||||
class Updater
|
||||
{
|
||||
use SiteApi;
|
||||
|
||||
public static function checkForUpdate($installed_version)
|
||||
{
|
||||
$data = null;
|
||||
if (env('APP_ENV') === 'development' || env('APP_ENV') === 'local') {
|
||||
$url = 'downloads/check/latest/'.$installed_version.'?type=update&is_dev=1';
|
||||
} else {
|
||||
$url = 'downloads/check/latest/'.$installed_version.'?type=update';
|
||||
}
|
||||
|
||||
$response = static::getRemote($url, ['timeout' => 100, 'track_redirects' => true]);
|
||||
|
||||
if ($response && ($response->getStatusCode() == 200)) {
|
||||
$data = $response->getBody()->getContents();
|
||||
}
|
||||
|
||||
$data = json_decode($data);
|
||||
|
||||
if ($data->success && $data->version && property_exists($data->version, 'extensions')) {
|
||||
$extensions = $data->version->extensions;
|
||||
$extensionData = [];
|
||||
foreach (json_decode($extensions) as $extension) {
|
||||
$extensionData[$extension] = phpversion($extension) ? true : false;
|
||||
}
|
||||
$extensionData['php'.'('.$data->version->minimum_php_version.')'] = version_compare(phpversion(), $data->version->minimum_php_version, ">=");
|
||||
$data->version->extensions = $extensionData;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function download($new_version, $is_cmd = 0)
|
||||
{
|
||||
$data = null;
|
||||
$path = null;
|
||||
|
||||
if (env('APP_ENV') === 'development') {
|
||||
$url = 'downloads/file/'.$new_version.'?type=update&is_dev=1&is_cmd='.$is_cmd;
|
||||
} else {
|
||||
$url = 'downloads/file/'.$new_version.'?type=update&is_cmd='.$is_cmd;
|
||||
}
|
||||
|
||||
$response = static::getRemote($url, ['timeout' => 100, 'track_redirects' => true]);
|
||||
|
||||
// Exception
|
||||
if ($response instanceof RequestException) {
|
||||
return [
|
||||
'success' => false,
|
||||
'error' => 'Download Exception',
|
||||
'data' => [
|
||||
'path' => $path,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
if ($response && ($response->getStatusCode() == 200)) {
|
||||
$data = $response->getBody()->getContents();
|
||||
}
|
||||
|
||||
// Create temp directory
|
||||
$temp_dir = storage_path('app/temp-'.md5(mt_rand()));
|
||||
|
||||
if (! File::isDirectory($temp_dir)) {
|
||||
File::makeDirectory($temp_dir);
|
||||
}
|
||||
|
||||
$zip_file_path = $temp_dir.'/upload.zip';
|
||||
|
||||
// Add content to the Zip file
|
||||
$uploaded = is_int(file_put_contents($zip_file_path, $data)) ? true : false;
|
||||
|
||||
if (! $uploaded) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $zip_file_path;
|
||||
}
|
||||
|
||||
public static function unzip($zip_file_path)
|
||||
{
|
||||
if (! file_exists($zip_file_path)) {
|
||||
throw new \Exception('Zip file not found');
|
||||
}
|
||||
|
||||
$temp_extract_dir = storage_path('app/temp2-'.md5(mt_rand()));
|
||||
|
||||
if (! File::isDirectory($temp_extract_dir)) {
|
||||
File::makeDirectory($temp_extract_dir);
|
||||
}
|
||||
// Unzip the file
|
||||
$zip = new ZipArchive();
|
||||
|
||||
if ($zip->open($zip_file_path)) {
|
||||
$zip->extractTo($temp_extract_dir);
|
||||
}
|
||||
|
||||
$zip->close();
|
||||
|
||||
// Delete zip file
|
||||
File::delete($zip_file_path);
|
||||
|
||||
return $temp_extract_dir;
|
||||
}
|
||||
|
||||
public static function copyFiles($temp_extract_dir)
|
||||
{
|
||||
if (! File::copyDirectory($temp_extract_dir.'/Crater', base_path())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Delete temp directory
|
||||
File::deleteDirectory($temp_extract_dir);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function deleteFiles($json)
|
||||
{
|
||||
$files = json_decode($json);
|
||||
|
||||
foreach ($files as $file) {
|
||||
\File::delete(base_path($file));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function migrateUpdate()
|
||||
{
|
||||
Artisan::call('migrate --force');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function finishUpdate($installed, $version)
|
||||
{
|
||||
event(new UpdateFinished($installed, $version));
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
'error' => false,
|
||||
'data' => [],
|
||||
];
|
||||
}
|
||||
}
|
||||
196
crater/app/Space/helpers.php
Normal file
196
crater/app/Space/helpers.php
Normal file
@@ -0,0 +1,196 @@
|
||||
<?php
|
||||
|
||||
use Crater\Models\CompanySetting;
|
||||
use Crater\Models\Currency;
|
||||
use Crater\Models\CustomField;
|
||||
use Crater\Models\Setting;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Get company setting
|
||||
*
|
||||
* @param $company_id
|
||||
* @return string
|
||||
*/
|
||||
function get_company_setting($key, $company_id)
|
||||
{
|
||||
if (\Storage::disk('local')->has('database_created')) {
|
||||
return CompanySetting::getSetting($key, $company_id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get app setting
|
||||
*
|
||||
* @param $company_id
|
||||
* @return string
|
||||
*/
|
||||
function get_app_setting($key)
|
||||
{
|
||||
if (\Storage::disk('local')->has('database_created')) {
|
||||
return Setting::getSetting($key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get page title
|
||||
*
|
||||
* @param $company_id
|
||||
* @return string
|
||||
*/
|
||||
function get_page_title($company_id)
|
||||
{
|
||||
$routeName = Route::currentRouteName();
|
||||
|
||||
$pageTitle = null;
|
||||
$defaultPageTitle = 'Crater - Self Hosted Invoicing Platform';
|
||||
|
||||
if (\Storage::disk('local')->has('database_created')) {
|
||||
if ($routeName === 'customer.dashboard') {
|
||||
$pageTitle = CompanySetting::getSetting('customer_portal_page_title', $company_id);
|
||||
|
||||
return $pageTitle ? $pageTitle : $defaultPageTitle;
|
||||
}
|
||||
|
||||
$pageTitle = Setting::getSetting('admin_page_title');
|
||||
|
||||
return $pageTitle ? $pageTitle : $defaultPageTitle;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Active Path
|
||||
*
|
||||
* @param $path
|
||||
* @param string $active
|
||||
* @return string
|
||||
*/
|
||||
function set_active($path, $active = 'active')
|
||||
{
|
||||
return call_user_func_array('Request::is', (array)$path) ? $active : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $path
|
||||
* @return mixed
|
||||
*/
|
||||
function is_url($path)
|
||||
{
|
||||
return call_user_func_array('Request::is', (array)$path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @return string
|
||||
*/
|
||||
function getCustomFieldValueKey(string $type)
|
||||
{
|
||||
switch ($type) {
|
||||
case 'Input':
|
||||
return 'string_answer';
|
||||
|
||||
case 'TextArea':
|
||||
return 'string_answer';
|
||||
|
||||
case 'Phone':
|
||||
return 'number_answer';
|
||||
|
||||
case 'Url':
|
||||
return 'string_answer';
|
||||
|
||||
case 'Number':
|
||||
return 'number_answer';
|
||||
|
||||
case 'Dropdown':
|
||||
return 'string_answer';
|
||||
|
||||
case 'Switch':
|
||||
return 'boolean_answer';
|
||||
|
||||
case 'Date':
|
||||
return 'date_answer';
|
||||
|
||||
case 'Time':
|
||||
return 'time_answer';
|
||||
|
||||
case 'DateTime':
|
||||
return 'date_time_answer';
|
||||
|
||||
default:
|
||||
return 'string_answer';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $money
|
||||
* @return formated_money
|
||||
*/
|
||||
function format_money_pdf($money, $currency = null)
|
||||
{
|
||||
$money = $money / 100;
|
||||
|
||||
if (! $currency) {
|
||||
$currency = Currency::findOrFail(CompanySetting::getSetting('currency', 1));
|
||||
}
|
||||
|
||||
$format_money = number_format(
|
||||
$money,
|
||||
$currency->precision,
|
||||
$currency->decimal_separator,
|
||||
$currency->thousand_separator
|
||||
);
|
||||
|
||||
$currency_with_symbol = '';
|
||||
if ($currency->swap_currency_symbol) {
|
||||
$currency_with_symbol = $format_money.'<span style="font-family: DejaVu Sans;">'.$currency->symbol.'</span>';
|
||||
} else {
|
||||
$currency_with_symbol = '<span style="font-family: DejaVu Sans;">'.$currency->symbol.'</span>'.$format_money;
|
||||
}
|
||||
|
||||
return $currency_with_symbol;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $string
|
||||
* @return string
|
||||
*/
|
||||
function clean_slug($model, $title, $id = 0)
|
||||
{
|
||||
// Normalize the title
|
||||
$slug = Str::upper('CUSTOM_'.$model.'_'.Str::slug($title, '_'));
|
||||
|
||||
// Get any that could possibly be related.
|
||||
// This cuts the queries down by doing it once.
|
||||
$allSlugs = getRelatedSlugs($model, $slug, $id);
|
||||
|
||||
// If we haven't used it before then we are all good.
|
||||
if (! $allSlugs->contains('slug', $slug)) {
|
||||
return $slug;
|
||||
}
|
||||
|
||||
// Just append numbers like a savage until we find not used.
|
||||
for ($i = 1; $i <= 10; $i++) {
|
||||
$newSlug = $slug.'_'.$i;
|
||||
if (! $allSlugs->contains('slug', $newSlug)) {
|
||||
return $newSlug;
|
||||
}
|
||||
}
|
||||
|
||||
throw new \Exception('Can not create a unique slug');
|
||||
}
|
||||
|
||||
function getRelatedSlugs($type, $slug, $id = 0)
|
||||
{
|
||||
return CustomField::select('slug')->where('slug', 'like', $slug.'%')
|
||||
->where('model_type', $type)
|
||||
->where('id', '<>', $id)
|
||||
->get();
|
||||
}
|
||||
|
||||
function respondJson($error, $message)
|
||||
{
|
||||
return response()->json([
|
||||
'error' => $error,
|
||||
'message' => $message
|
||||
], 422);
|
||||
}
|
||||
Reference in New Issue
Block a user