forked from summerblue/phphub5
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4cfee18
Showing
3,725 changed files
with
74,799 additions
and
0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
# coding styles between different editors and IDEs | ||
# editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
|
||
# Change these settings to your own preference | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
# We recommend you to keep these unchanged | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = false | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
APP_ENV=local | ||
APP_DEBUG=true | ||
APP_KEY=SomeRandomString | ||
APP_URL=http://phphub5.app | ||
TIMEZONE=Asia/Shanghai | ||
LOCALE=zh-CN | ||
|
||
DB_CONNECTION=mysql | ||
DB_HOST=127.0.0.1 | ||
DB_DATABASE=phphub5 | ||
DB_USERNAME=homestead | ||
DB_PASSWORD=secret | ||
|
||
CACHE_KEY_PREFIX=local | ||
CACHE_DRIVER=redis | ||
SESSION_DRIVER=redis | ||
QUEUE_DRIVER=redis | ||
|
||
REDIS_HOST=127.0.0.1 | ||
REDIS_PASSWORD=null | ||
REDIS_PORT=6379 | ||
|
||
MAIL_DRIVER=smtp | ||
MAIL_HOST=mailtrap.io | ||
MAIL_PORT=2525 | ||
MAIL_USERNAME=null | ||
MAIL_PASSWORD=null | ||
MAIL_ENCRYPTION=null | ||
|
||
// Github oauth | ||
CLIENT_ID=eefd4111fbcb0e1d0fb9 | ||
CLIENT_SECRET=3dce7078f20bc10a1f6bef559b81787648f1b372 | ||
|
||
// Github Card | ||
GITHUB_CARD_CLIENT_ID=eefd4111fbcb0e1d0fb9 | ||
GITHUB_CARD_CLIENT_SECRET=3dce7078f20bc10a1f6bef559b81787648f1b372 | ||
|
||
#URL_STATIC=https://dn-phphub.qbox.me/ | ||
#USER_STATIC=https://dn-phphub.qbox.me/ | ||
|
||
GA_Tracking_ID=xxxxx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* text=auto | ||
*.css linguist-vendored | ||
*.less linguist-vendored |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/vendor | ||
/node_modules | ||
Homestead.yaml | ||
Homestead.json | ||
.env | ||
.DS_Store | ||
|
||
/public/build | ||
/public/rev-manifest.json | ||
/storage/administrator_settings | ||
|
||
.DS_Store | ||
.idea | ||
_ide_helper.php | ||
_ide_helper_models.php | ||
|
||
Envoy.blade.php | ||
|
||
public/uploads/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php namespace App\Console\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
use Ubench; | ||
use App; | ||
|
||
class BaseCommand extends Command | ||
{ | ||
public $bench; | ||
|
||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
|
||
$this->bench = new Ubench; | ||
$this->bench->start(); | ||
|
||
$this->is_ask = false; | ||
} | ||
|
||
public function printBenchInfo() | ||
{ | ||
// 统计结束,可以打印出信息了 | ||
$this->bench->end(); | ||
|
||
$this->info('-------'); | ||
$this->info('-------'); | ||
$this->info(sprintf("Command execution completed, time consuming: %s, memory usage: %s ", | ||
$this->bench->getTime(), | ||
$this->bench->getMemoryUsage() | ||
)); | ||
$this->info('-------'); | ||
$this->info('-------'); | ||
} | ||
|
||
public function execShellWithPrettyPrint($command) | ||
{ | ||
$this->info('---'); | ||
$this->info($command); | ||
$output = shell_exec($command); | ||
$this->info($output); | ||
$this->info('---'); | ||
} | ||
|
||
public function productionCheckHint($message = '') | ||
{ | ||
$message = $message ?: 'This is a "very dangerous" operation'; | ||
if (App::environment('production') | ||
&& !$this->option('force') | ||
&& !$this->confirm('Your are in「Production」environment, '.$message.'! Are you sure you want to do this? [y|N]') | ||
) { | ||
exit('Command termination'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php namespace App\Console\Commands; | ||
|
||
use DB; | ||
|
||
class ESTDatabaseNukeCommand extends BaseCommand | ||
{ | ||
protected $signature = 'est:dbnuke {--force : enforce}'; | ||
|
||
protected $description = 'Delete all tables'; | ||
|
||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
} | ||
|
||
public function handle() | ||
{ | ||
$this->productionCheckHint(); | ||
|
||
$colname = 'Tables_in_' . env('DB_DATABASE'); | ||
|
||
$tables = DB::select('SHOW TABLES'); | ||
|
||
foreach ($tables as $table) { | ||
$droplist[] = $table->$colname; | ||
$this->info('Will delete table - ' . $table->$colname); | ||
} | ||
if (!isset($droplist)) { | ||
$this->error('No table'); | ||
return; | ||
} | ||
$droplist = implode(',', $droplist); | ||
|
||
DB::beginTransaction(); | ||
//turn off referential integrity | ||
DB::statement('SET FOREIGN_KEY_CHECKS = 0'); | ||
DB::statement("DROP TABLE $droplist"); | ||
//turn referential integrity back on | ||
DB::statement('SET FOREIGN_KEY_CHECKS = 1'); | ||
DB::commit(); | ||
|
||
$this->comment("All the tables have been deleted".PHP_EOL); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php namespace App\Console\Commands; | ||
|
||
class ESTDatabaseResetCommand extends BaseCommand | ||
{ | ||
protected $signature = 'est:dbreset {--force : enforce}'; | ||
|
||
protected $description = "Delete all tables(use est:dbnuke ), and run the 'migrate' and 'db:seed' commands"; | ||
|
||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
} | ||
|
||
public function handle() | ||
{ | ||
$this->productionCheckHint("Will delete all tables, and run the 'migrate' and 'db:seed' commands"); | ||
|
||
$this->call('est:dbnuke', [ | ||
'--force' => 'yes' | ||
]); | ||
|
||
$this->call('migrate', [ | ||
'--seed' => 'yes', | ||
'--force' => 'yes' | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php namespace App\Console\Commands; | ||
|
||
use App\Models\Permission; | ||
use App\Models\Role; | ||
use App\Models\User; | ||
use App; | ||
use Illuminate\Database\Eloquent\Collection; | ||
|
||
class ESTInitRBAC extends BaseCommand | ||
{ | ||
// Entrust is an RBAC library... RBAC = "Role Based Access Control" | ||
protected $signature = 'est:init-rbac'; | ||
|
||
protected $description = 'Initialize Role Based Access Control'; | ||
|
||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
} | ||
|
||
public function handle() | ||
{ | ||
// 如果没有第一个用户的话,创建新的,允许此命令多次运行 | ||
$user = User::first(); | ||
if (!$user) { | ||
$this->error("Users table is empty"); | ||
return; | ||
} | ||
$founder = Role::addRole('Founder', 'Founder'); | ||
$maintainer = Role::addRole('Maintainer', 'Maintainer'); | ||
$contributor = Role::addRole('Contributor', 'Contributor'); | ||
|
||
$visit_admin = Permission::addPermission('visit_admin', 'Visit Admin'); | ||
$manage_users = Permission::addPermission('manage_users', 'Manage Users'); | ||
$manage_topics = Permission::addPermission('manage_topics', 'Manage Topics'); | ||
|
||
$this->attachPermissions($founder, [ | ||
$visit_admin, | ||
$manage_users, | ||
$manage_topics | ||
]); | ||
|
||
$this->attachPermissions($maintainer, [ | ||
$visit_admin, | ||
$manage_topics | ||
]); | ||
|
||
if (!$user->hasRole($founder->name)) { | ||
$user->attachRole($founder); | ||
} | ||
|
||
$this->info('--'); | ||
$this->info("Initialize RABC success -- ID: 1 and Name “{$user->name}” has founder permission"); | ||
$this->info('--'); | ||
} | ||
|
||
/** | ||
* @param Role $role | ||
* @param Permission[] $permissions | ||
*/ | ||
public function attachPermissions(Role $role, array $permissions) | ||
{ | ||
$attach = []; | ||
|
||
$permissions = new Collection($permissions); | ||
|
||
$detach = []; | ||
foreach ($role->perms()->get() as $permission) { | ||
if ($permissions->where('name', $permission->name)->isEmpty()) { | ||
$detach[] = $permission; | ||
} | ||
} | ||
|
||
foreach ($permissions as $permission) { | ||
if (!$role->hasPermission($permission->name)) { | ||
$attach[] = $permission; | ||
} | ||
} | ||
|
||
$role->detachPermissions($detach); | ||
$role->attachPermissions($attach); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php namespace App\Console\Commands; | ||
|
||
class ESTInstallCommand extends BaseCommand | ||
{ | ||
protected $signature = 'est:install {--force : enforce}'; | ||
|
||
protected $description = 'Project Initialize Command'; | ||
|
||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
} | ||
|
||
public function handle() | ||
{ | ||
$this->execShellWithPrettyPrint('php artisan key:generate'); | ||
$this->execShellWithPrettyPrint('php artisan migrate --seed'); | ||
$this->execShellWithPrettyPrint('php artisan est:init-rbac'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php namespace App\Console\Commands; | ||
|
||
class ESTReinstallCommand extends BaseCommand | ||
{ | ||
protected $signature = 'est:reinstall {--force : enforce}'; | ||
|
||
protected $description = "Reset database, reset RABC. Only use in local environment"; | ||
|
||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
} | ||
|
||
public function handle() | ||
{ | ||
$this->productionCheckHint('Reset database and reset RABC'); | ||
|
||
$this->execShellWithPrettyPrint('php artisan est:dbreset --force'); | ||
$this->execShellWithPrettyPrint('php artisan est:init-rbac'); | ||
|
||
$this->printBenchInfo(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
use Illuminate\Foundation\Inspiring; | ||
|
||
class Inspire extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'inspire'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Display an inspiring quote'; | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return mixed | ||
*/ | ||
public function handle() | ||
{ | ||
$this->comment(PHP_EOL.Inspiring::quote().PHP_EOL); | ||
} | ||
} |
Oops, something went wrong.