mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-03 14:10:57 +08:00
add reset user id auto_increment command
This commit is contained in:
90
app/Console/Commands/UserResetIdAutoIncrement.php
Normal file
90
app/Console/Commands/UserResetIdAutoIncrement.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Repositories\UserRepository;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class UserResetIdAutoIncrement extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'user:reset_id_auto_increment {--auto_increment=} {--admin=} {--email=} {--password=}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Reset user table PRIMARY KEY auto_increment, options: --auto_increment, --admin, --email, --password';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$options = $this->options();
|
||||
$requires = ['auto_increment', 'admin', 'password', 'email'];
|
||||
foreach ($requires as $option) {
|
||||
if (empty($options[$option])) {
|
||||
$this->error("Require --$option");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
$log = "options: " . json_encode($options);
|
||||
$this->info($log);
|
||||
|
||||
$tablesToTruncate = [
|
||||
'adclicks', 'attachments', 'attendance', 'attendance_logs', 'bitbucket', 'blocks', 'bonus_logs', 'bookmarks', 'cheaters', 'chronicle',
|
||||
'claims', 'comments', 'complain_replies', 'complains', 'exam_progress', 'exam_users', 'forummods', 'friends', 'fun', 'funds', 'funvotes',
|
||||
'hit_and_runs', 'invites', 'iplog', 'loginattempts', 'lucky_draw_winning_records', 'magic', 'messages', 'offers', 'offervotes', 'peers',
|
||||
'pmboxes', 'pollanswers', 'posts', 'prolinkclicks', 'readposts', 'reports', 'requests', 'seed_box_records', 'shoutbox', 'snatched',
|
||||
'staffmessages', 'sticky_promotion_appends', 'sticky_promotion_participators', 'sticky_promotions', 'subs', 'suggest', 'thanks', 'topics',
|
||||
'torrent_operation_logs', 'torrent_secrets', 'torrents', 'user_ban_logs', 'user_medals', 'user_metas', 'user_permissions', 'user_roles',
|
||||
'username_change_logs', 'users',
|
||||
];
|
||||
$allTables = DB::select('show tables');
|
||||
foreach ($allTables as $tableObj) {
|
||||
$tableName = current($tableObj);
|
||||
if (in_array($tableName, $tablesToTruncate)) {
|
||||
$this->info("truncate table: $tableName ...");
|
||||
DB::table($tableName)->truncate();
|
||||
}
|
||||
}
|
||||
$statement = "alter table users auto_increment = " . $options['auto_increment'];
|
||||
$this->info($statement);
|
||||
$result = DB::statement($statement);
|
||||
|
||||
$userRep = new UserRepository();
|
||||
$insert = [
|
||||
'username' => $options['admin'],
|
||||
'email' => $options['email'],
|
||||
'password' => $options['password'],
|
||||
'password_confirmation' => $options['password'],
|
||||
'class' => User::CLASS_STAFF_LEADER,
|
||||
'id' => 1,
|
||||
];
|
||||
$userRep->store($insert);
|
||||
|
||||
$log = sprintf('[%s], %s, result: %s', nexus()->getRequestId(), __METHOD__, var_export($result, true));
|
||||
$this->info($log);
|
||||
do_log($log);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,13 @@
|
||||
<?php
|
||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.7.22');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-08-17');
|
||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.7.23');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-08-19');
|
||||
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
||||
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
||||
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
||||
defined('NEXUSWIKIURL') || define("NEXUSWIKIURL","https://doc.nexusphp.org");
|
||||
defined('VERSION') || define("VERSION","Powered by <a href=\"aboutnexus.php\">".PROJECTNAME."</a>");
|
||||
defined('THISTRACKER') || define("THISTRACKER","General");
|
||||
defined('CONTENT_WIDTH') || define("CONTENT_WIDTH", 1200);
|
||||
defined('ROOT_PATH') || define('ROOT_PATH', dirname(__DIR__) . '/');
|
||||
defined('DEFAULT_TRACKER_URI') || define('DEFAULT_TRACKER_URI', '/announce.php');
|
||||
if (!defined('RUNNING_IN_OCTANE')) {
|
||||
|
||||
@@ -615,7 +615,7 @@ function begin_main_frame($caption = "", $center = false, $width = 100)
|
||||
$tdextra .= " align=\"center\"";
|
||||
|
||||
if (!str_ends_with($width, '%')) {
|
||||
$width = 1200 * $width / 100;
|
||||
$width = CONTENT_WIDTH * $width / 100;
|
||||
}
|
||||
|
||||
print("<table class=\"main\" width=\"".$width."\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" .
|
||||
@@ -2551,7 +2551,7 @@ foreach (\Nexus\Nexus::getAppendHeaders() as $value) {
|
||||
<script type="text/javascript" src="vendor/layer-v3.5.1/layer/layer.js<?php echo $cssupdatedate?>"></script>
|
||||
</head>
|
||||
<body>
|
||||
<table class="head" cellspacing="0" cellpadding="0" align="center">
|
||||
<table class="head" cellspacing="0" cellpadding="0" align="center" style="width: <?php echo CONTENT_WIDTH + 28.66 ?>px">
|
||||
<tr>
|
||||
<td class="clear">
|
||||
<?php
|
||||
@@ -2586,7 +2586,7 @@ if ($enabledonation == 'yes'){?>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table class="mainouter" width="1200" cellspacing="0" cellpadding="5" align="center">
|
||||
<table class="mainouter" width="<?php echo CONTENT_WIDTH ?>" cellspacing="0" cellpadding="5" align="center">
|
||||
<tr><td id="nav_block" class="text" align="center">
|
||||
<?php if (!$CURUSER) { ?>
|
||||
<a href="login.php"><font class="big"><b><?php echo $lang_functions['text_login'] ?></b></font></a> / <a href="signup.php"><font class="big"><b><?php echo $lang_functions['text_signup'] ?></b></font></a>
|
||||
|
||||
@@ -117,7 +117,7 @@ $limit";
|
||||
|
||||
print("<h1 align=\"center\">".$count.$lang_ipsearch['text_users_used_the_ip'].$ip."</h1>");
|
||||
|
||||
print("<table width=1200 border=1 cellspacing=0 cellpadding=5 align=center>\n");
|
||||
print("<table width=".CONTENT_WIDTH." border=1 cellspacing=0 cellpadding=5 align=center>\n");
|
||||
print("<tr><td class=colhead align=center><a class=colhead href=\"?ip=$ip&mask=$mask&order=username\">".$lang_ipsearch['col_username']."</a></td>".
|
||||
"<td class=colhead align=center><a class=colhead href=\"?ip=$ip&mask=$mask&order=last_ip\">".$lang_ipsearch['col_last_ip']."</a></td>".
|
||||
"<td class=colhead align=center><a class=colhead href=\"?ip=$ip&mask=$mask&order=last_access\">".$lang_ipsearch['col_last_access']."</a></td>".
|
||||
|
||||
@@ -161,7 +161,7 @@ if ($action){
|
||||
}
|
||||
|
||||
usercpmenu ("personal");
|
||||
print ("<table border=0 cellspacing=0 cellpadding=5 width=1200>");
|
||||
print ("<table border=0 cellspacing=0 cellpadding=5 width=".CONTENT_WIDTH.">");
|
||||
if ($type == 'saved')
|
||||
print("<tr><td colspan=2 class=\"heading\" valign=\"top\" align=\"center\"><font color=red>".$lang_usercp['text_saved']."</font></td></tr>\n");
|
||||
|
||||
@@ -395,7 +395,7 @@ if ($showprocessing) $processings = searchbox_item_list("processings");
|
||||
if ($showteam) $teams = searchbox_item_list("teams");
|
||||
if ($showaudiocodec) $audiocodecs = searchbox_item_list("audiocodecs");
|
||||
}
|
||||
print ("<table border=0 cellspacing=0 cellpadding=5 width=1200>");
|
||||
print ("<table border=0 cellspacing=0 cellpadding=5 width=".CONTENT_WIDTH.">");
|
||||
form ("tracker");
|
||||
if ($type == 'saved')
|
||||
print("<tr><td colspan=2 class=\"heading\" valign=\"top\" align=\"center\"><font color=red>".$lang_usercp['text_saved']."</font></td></tr>\n");
|
||||
@@ -640,7 +640,7 @@ tr_small($lang_usercp['row_funbox'],"<input type=checkbox name=showfb".($CURUSER
|
||||
}
|
||||
stdhead($lang_usercp['head_control_panel'].$lang_usercp['head_forum_settings'],true);
|
||||
usercpmenu ("forum");
|
||||
print ("<table border=0 cellspacing=0 cellpadding=5 width=1200>");
|
||||
print ("<table border=0 cellspacing=0 cellpadding=5 width=".CONTENT_WIDTH.">");
|
||||
form ("forum");
|
||||
if ($type == 'saved')
|
||||
print("<tr><td colspan=2 class=\"heading\" valign=\"top\" align=\"center\"><font color=red>".$lang_usercp['text_saved']."</font></td></tr>\n");
|
||||
@@ -819,7 +819,7 @@ EOD;
|
||||
}
|
||||
stdhead($lang_usercp['head_control_panel'].$lang_usercp['head_security_settings']);
|
||||
usercpmenu ("security");
|
||||
print ("<table border=0 cellspacing=0 cellpadding=5 width=1200>");
|
||||
print ("<table border=0 cellspacing=0 cellpadding=5 width=".CONTENT_WIDTH.">");
|
||||
if ($type == 'save') {
|
||||
print("<form method=post action=usercp.php><input type=hidden name=action value=security><input type=hidden name=type value=confirm>");
|
||||
$resetpasskey = $_POST["resetpasskey"];
|
||||
@@ -919,7 +919,7 @@ if ($forumposts)
|
||||
$percentages = round($forumposts*100/$postcount, 3)."%";
|
||||
}
|
||||
?>
|
||||
<table border="0" cellspacing="0" cellpadding="5" width=1200>
|
||||
<table border="0" cellspacing="0" cellpadding="5" width=<?php echo CONTENT_WIDTH ?>>
|
||||
<?php
|
||||
tr_small($lang_usercp['row_join_date'], $joindate, 1);
|
||||
tr_small($lang_usercp['row_email_address'], $CURUSER['email'], 1);
|
||||
@@ -1073,13 +1073,13 @@ if ($forumposts)
|
||||
tr($lang_usercp['row_forum_posts'], $forumposts." [<a href=\"userhistory.php?action=viewposts&id=".$CURUSER['id']."\" title=\"".$lang_usercp['link_view_posts']."\">".$lang_usercp['text_view']."</a>] (".$dayposts.$lang_usercp['text_posts_per_day']."; ".$percentages.$lang_usercp['text_of_total_posts'].")", 1);
|
||||
?>
|
||||
</table>
|
||||
<table border="0" cellspacing="0" cellpadding="5" width=1200>
|
||||
<table border="0" cellspacing="0" cellpadding="5" width=<?php echo CONTENT_WIDTH ?>>
|
||||
<?php
|
||||
print("<td align=center class=tabletitle><b>".$lang_usercp['text_recently_read_topics']."</b></td>");
|
||||
?>
|
||||
</table>
|
||||
<?php
|
||||
print("<table border=0 cellspacing=0 cellpadding=3 width=1200><tr>".
|
||||
print("<table border=0 cellspacing=0 cellpadding=3 width=".CONTENT_WIDTH."><tr>".
|
||||
"<td class=colhead align=left width=80%>".$lang_usercp['col_topic_title']."</td>".
|
||||
"<td class=colhead align=center><nobr>".$lang_usercp['col_replies']."/".$lang_usercp['col_views']."</nobr></td>".
|
||||
"<td class=colhead align=center>".$lang_usercp['col_topic_starter']."</td>".
|
||||
|
||||
Reference in New Issue
Block a user