Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sarun Mungthanya
SpnPatch-Laravel
Commits
ecb4cce7
Commit
ecb4cce7
authored
Sep 06, 2024
by
Sarun Mungthanya
Browse files
add update patch finish
parent
1b502c77
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/Http/Controllers/SmartUpdateController.php
View file @
ecb4cce7
...
@@ -2,8 +2,13 @@
...
@@ -2,8 +2,13 @@
namespace
App\Http\Controllers
;
namespace
App\Http\Controllers
;
use
App\Models\ConfServerLicense
;
use
App\Models\ConfServerLicenseJavaversion
;
use
App\Models\ConfServerLicenseOrgcontrol
;
use
App\Models\ConfServerLicenseOrglist
;
use
Illuminate\Support\Facades\File
;
use
Illuminate\Support\Facades\File
;
use
App\Models\ConfServerPendding
;
use
App\Models\ConfServerPendding
;
use
App\Models\HscodeStatus
;
use
App\Models\TabPatchFile
;
use
App\Models\TabPatchFile
;
use
Exception
;
use
Exception
;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
...
@@ -30,6 +35,8 @@ class SmartUpdateController extends Controller
...
@@ -30,6 +35,8 @@ class SmartUpdateController extends Controller
$this
->
listPatch
(
$request
);
$this
->
listPatch
(
$request
);
}
else
if
(
$action
===
'UPDATE_PATCH'
)
{
}
else
if
(
$action
===
'UPDATE_PATCH'
)
{
$this
->
updatePatch
(
$request
);
$this
->
updatePatch
(
$request
);
}
else
if
(
$action
===
'FINISH_PATCH'
)
{
$this
->
finishPatch
(
$request
);
}
}
}
}
...
@@ -250,7 +257,6 @@ class SmartUpdateController extends Controller
...
@@ -250,7 +257,6 @@ class SmartUpdateController extends Controller
$file_data_0
=
''
;
$file_data_0
=
''
;
}
}
$patchCode
=
$patchDetails
->
PATCHCODE
;
$patchCode
=
$patchDetails
->
PATCHCODE
;
$patchCode
=
str_replace
(
'updatePatchFile("$$file_name_0", "$$file_data_0");'
,
''
,
$patchCode
);
$patchCode
=
str_replace
(
'updatePatchFile("$$file_name_0", "$$file_data_0");'
,
''
,
$patchCode
);
...
@@ -260,7 +266,7 @@ class SmartUpdateController extends Controller
...
@@ -260,7 +266,7 @@ class SmartUpdateController extends Controller
eval
(
'$patchCode=<<<EOF2'
.
chr
(
13
)
.
$patchCode
.
chr
(
13
)
.
'EOF2;'
.
chr
(
13
));
eval
(
'$patchCode=<<<EOF2'
.
chr
(
13
)
.
$patchCode
.
chr
(
13
)
.
'EOF2;'
.
chr
(
13
));
$patchCode
=
str_replace
(
'#'
,
'$'
,
$patchCode
);
$patchCode
=
str_replace
(
'#'
,
'$'
,
$patchCode
);
if
(
isset
(
$mode
)
&&
$mode
===
'AUTO'
)
{
if
(
isset
(
$mode
)
&&
$mode
===
'AUTO'
)
{
$pid
=
DB
::
table
(
'conf_server_pendding as t0'
)
$pid
=
DB
::
table
(
'conf_server_pendding as t0'
)
->
join
(
'conf_smartupdate as t1'
,
't0.PatchID'
,
'='
,
't1.PID'
)
->
join
(
'conf_smartupdate as t1'
,
't0.PatchID'
,
'='
,
't1.PID'
)
...
@@ -298,12 +304,162 @@ class SmartUpdateController extends Controller
...
@@ -298,12 +304,162 @@ class SmartUpdateController extends Controller
->
update
([
'TaskStatus'
=>
2
]);
->
update
([
'TaskStatus'
=>
2
]);
echo
base64_encode
(
$patchCode
);
echo
base64_encode
(
$patchCode
);
}
else
{
}
else
{
echo
base64_encode
(
'$PATCH_STATUS="DONE";'
);
echo
base64_encode
(
'$PATCH_STATUS="DONE";'
);
}
}
}
}
public
function
finishPatch
(
$request
)
{
$serverKeyClient
=
$request
->
input
(
'SERVERKEYCLIENT'
);
$action
=
$request
->
input
(
'ACTION'
);
$clientVersion
=
$request
->
input
(
'CLIENTVERSION'
);
$patchId
=
$request
->
input
(
'PATCHID'
);
$feedback
=
$request
->
input
(
'FEEDBACK'
);
$userRunner
=
$request
->
input
(
'RUNNER'
);
$serverId
=
DB
::
table
(
'conf_server_license'
)
->
where
(
'SNKEY'
,
$serverKeyClient
)
->
value
(
'ID'
);
if
(
$feedback
!=
''
)
{
$total
=
explode
(
';'
,
$feedback
);
$total_tariff
=
'2397'
;
$total_imduty
=
'325087'
;
$total_stat
=
'19943'
;
$count_tariff
=
$total
[
0
]
??
null
;
$count_statcode
=
$total
[
1
]
??
null
;
$count_imduty
=
$total
[
2
]
??
null
;
if
(
$count_tariff
!=
''
)
{
$status_tariff
=
$total_tariff
==
$count_tariff
?
'master_tariff : successful'
:
'master_tariff : failed'
;
HscodeStatus
::
updateOrCreate
(
[
'id'
=>
1
,
'serverkey'
=>
$serverKeyClient
],
[
'recordtotal'
=>
$total_tariff
,
'recordcustoms'
=>
$count_tariff
,
'status'
=>
$status_tariff
,
'finishtime'
=>
now
()]
);
}
if
(
$count_imduty
!=
''
)
{
$status_imduty
=
$total_imduty
==
$count_imduty
?
'master_imduty : successful'
:
'master_imduty : failed'
;
HscodeStatus
::
updateOrCreate
(
[
'id'
=>
2
,
'serverkey'
=>
$serverKeyClient
],
[
'recordtotal'
=>
$total_imduty
,
'recordcustoms'
=>
$count_imduty
,
'status'
=>
$status_imduty
,
'finishtime'
=>
now
()]
);
}
if
(
$count_statcode
!=
''
)
{
$status_statcode
=
$total_stat
==
$count_statcode
?
'master_statcode : successful'
:
'master_statcode : failed'
;
HscodeStatus
::
updateOrCreate
(
[
'id'
=>
3
,
'serverkey'
=>
$serverKeyClient
],
[
'recordtotal'
=>
$total_stat
,
'recordcustoms'
=>
$count_statcode
,
'status'
=>
$status_statcode
,
'finishtime'
=>
now
()]
);
}
if
(
strpos
(
$feedback
,
':'
))
{
$arr_
=
explode
(
':'
,
$feedback
);
if
(
$arr_
[
0
]
==
'FEEDBACK_FILE'
)
{
$directoryPath
=
"FEEDBACKFILE/
$serverKeyClient
"
;
if
(
!
Storage
::
exists
(
$directoryPath
))
{
Storage
::
makeDirectory
(
$directoryPath
);
}
$filePath
=
$directoryPath
.
"/"
.
$arr_
[
1
];
Storage
::
put
(
$filePath
,
gzuncompress
(
base64_decode
(
$arr_
[
2
])));
}
}
$serverLicense
=
ConfServerLicense
::
where
(
'SNKEY'
,
$serverKeyClient
)
->
first
();
if
(
$serverLicense
->
BACKUP_FEEDBACK
!=
''
&&
$patchId
!=
env
(
'PATCH_DOWNLOADFILE_ID'
))
{
// Insert history
DB
::
table
(
'conf_server_backup_history'
)
->
insert
([
'SNKEY'
=>
$serverKeyClient
,
'BACKUP_VERSION'
=>
$serverLicense
->
BACKUP_DATE
,
'BACKUP_DATA'
=>
$serverLicense
->
BACKUP_FEEDBACK
,
'BACKUP_BY'
=>
$serverLicense
->
BACKUP_STATUS
,
]);
}
ConfServerLicense
::
where
(
'SNKEY'
,
$serverKeyClient
)
->
update
([
'BACKUP_DATE'
=>
now
(),
'BACKUP_STATUS'
=>
$userRunner
,
'BACKUP_FEEDBACK'
=>
$feedback
]);
}
if
(
!
empty
(
$clientVersion
))
{
if
(
is_array
(
$clientVersion
))
{
if
(
!
empty
(
$clientVersion
[
'PHPVERSION'
]))
{
$serverkeyPHPVersion
=
$clientVersion
[
'PHPVERSION'
];
$PHP_VERSION_ID
=
strpos
(
$serverkeyPHPVersion
,
"5.2"
)
!==
false
?
1
:
2
;
ConfServerLicense
::
where
(
'SNKEY'
,
$serverKeyClient
)
->
update
([
'PHP_VERSION_ID'
=>
$PHP_VERSION_ID
]);
}
if
(
!
empty
(
$clientVersion
[
'JAVAVERSION'
]))
{
$fullText
=
implode
(
" || "
,
$clientVersion
[
'JAVAVERSION'
]);
$javaVersion
=
new
ConfServerLicenseJavaversion
;
$javaVersion
->
SNKEY
=
$serverKeyClient
;
$javaVersion
->
javaversion
=
$clientVersion
[
'JAVAVERSION'
][
0
];
$javaVersion
->
javaVersionFullText
=
$fullText
;
$javaVersion
->
lastUpdate
=
now
();
$javaVersion
->
save
();
ConfServerLicenseJavaVersion
::
where
(
'id'
,
'<'
,
$javaVersion
->
id
)
->
where
(
'SNKEY'
,
$serverKeyClient
)
->
delete
();
}
if
(
!
empty
(
$clientVersion
[
'GETORGANIZE'
]))
{
$checkDuplicate
=
ConfServerLicenseOrgcontrol
::
where
(
'SNKEY'
,
$serverKeyClient
)
->
whereDate
(
'createDate'
,
now
())
->
first
();
if
(
$checkDuplicate
)
{
$this
->
deleteGetOrganize
(
$checkDuplicate
->
id
);
}
$controlId
=
DB
::
table
(
'conf_server_license_orgcontrol'
)
->
insertGetId
([
'SNKEY'
=>
$serverKeyClient
,
'createDate'
=>
now
(),
]);
foreach
(
$clientVersion
[
'GETORGANIZE'
]
as
$arrayData
)
{
ConfServerLicenseOrglist
::
create
([
'controlId'
=>
$controlId
,
'spnOrganize'
=>
$arrayData
[
'ORG'
],
]);
}
}
}
else
{
ConfServerLicense
::
where
(
'SNKEY'
,
$serverKeyClient
)
->
update
([
'cur_version'
=>
$clientVersion
]);
}
}
DB
::
table
(
'log_history'
)
->
insert
([
'HDATE'
=>
now
(),
'HSID'
=>
$serverId
,
'HACTION'
=>
"
$action
$patchId
"
]);
DB
::
table
(
'conf_server_pendding'
)
->
where
(
'ServerId'
,
$serverId
)
->
where
(
'PatchId'
,
$patchId
)
->
update
([
'TaskStatus'
=>
999
,
'TaskFinish'
=>
now
(),
'TaskRunner'
=>
$userRunner
]);
$patchName
=
DB
::
table
(
'conf_smartupdate'
)
->
where
(
'pid'
,
$patchId
)
->
value
(
'PATCHNAME'
);
echo
base64_encode
(
"
\$
PATCHNAME=
\"
$patchName
\"
;"
);
}
public
static
function
processPatchCode
(
$patchCode
)
public
static
function
processPatchCode
(
$patchCode
)
{
{
$patchCode
=
str_replace
(
'$'
,
'#'
,
$patchCode
);
$patchCode
=
str_replace
(
'$'
,
'#'
,
$patchCode
);
...
@@ -352,7 +508,6 @@ class SmartUpdateController extends Controller
...
@@ -352,7 +508,6 @@ class SmartUpdateController extends Controller
}
}
}
}
return
$DATA
;
return
$DATA
;
}
}
public
static
function
getDirVersion
(
$version
)
public
static
function
getDirVersion
(
$version
)
{
{
...
...
resources/views/smartupdate/patch_update.blade.php
View file @
ecb4cce7
...
@@ -24,6 +24,88 @@
...
@@ -24,6 +24,88 @@
.update-btn
:active
{
.update-btn
:active
{
background-color
:
#1a3855
;
background-color
:
#1a3855
;
}
}
/* CSS */
.button-80
{
background
:
#fff
;
backface-visibility
:
hidden
;
border-radius
:
.375rem
;
border-style
:
solid
;
border-width
:
.125rem
;
box-sizing
:
border-box
;
color
:
#212121
;
cursor
:
pointer
;
display
:
inline-block
;
font-family
:
Circular
,
Helvetica
,
sans-serif
;
font-size
:
.8rem
;
font-weight
:
700
;
letter-spacing
:
-.01em
;
line-height
:
1.3
;
padding
:
.475rem
.6rem
;
position
:
relative
;
text-align
:
left
;
text-decoration
:
none
;
transform
:
translateZ
(
0
)
scale
(
1
);
transition
:
transform
.2s
;
user-select
:
none
;
-webkit-user-select
:
none
;
touch-action
:
manipulation
;
}
.button-80
:not
(
:disabled
)
:hover
{
transform
:
scale
(
1.05
);
background-color
:
#e7e7e7
}
.button-80
:not
(
:disabled
)
:hover:active
{
transform
:
scale
(
1.05
)
translateY
(
.125rem
);
background-color
:
#e7e7e7
}
.button-80
:focus
{
outline
:
0
solid
transparent
;
background-color
:
#e7e7e7
}
.button-80
:focus:before
{
content
:
""
;
left
:
calc
(
-1
*
.375rem
);
pointer-events
:
none
;
position
:
absolute
;
top
:
calc
(
-1
*
.375rem
);
transition
:
border-radius
;
user-select
:
none
;
}
.button-80
:focus:not
(
:focus-visible
)
{
outline
:
0
solid
transparent
;
}
.button-80
:focus:not
(
:focus-visible
)
:before
{
border-width
:
0
;
}
.button-80
:not
(
:disabled
)
:active
{
transform
:
translateY
(
.125rem
);
}
.button-2
{
border-radius
:
8px
;
border-width
:
0
;
color
:
#292929
;
display
:
inline-block
;
font-size
:
12px
;
font-weight
:
500
;
line-height
:
10px
;
list-style
:
none
;
margin
:
0
;
padding
:
5px
6px
;
text-align
:
center
;
transition
:
all
200ms
;
vertical-align
:
baseline
;
white-space
:
nowrap
;
}
</style>
</style>
<div
class=
"card"
>
<div
class=
"card"
>
{{-- @if ($cannotUpdateAll)
{{-- @if ($cannotUpdateAll)
...
@@ -60,9 +142,9 @@
...
@@ -60,9 +142,9 @@
$encryptedData = Crypt::encrypt($data);
$encryptedData = Crypt::encrypt($data);
@endphp
@endphp
<a
href=
"data_defaulttemplate.php?UID={{ $uId }}&UCODE={{ $uCode }}&SERVICENAME=IMCORESERVICE&ACTION=SMART_UPDATE&PATCHID={{ $update->PatchID }}"
<a
href=
"data_defaulttemplate.php?UID={{ $uId }}&UCODE={{ $uCode }}&SERVICENAME=IMCORESERVICE&ACTION=SMART_UPDATE&PATCHID={{ $update->PatchID }}"
class=
"btn
update-btn
"
>
Update
</a>
class=
"btn
button-80
"
>
Update
</a>
@else
@else
<
span
class=
"
text-muted"
>
{{ $update->Action }}
</
span
>
<
p
class=
"
button-2"
>
{{ $update->Action }}
</
p
>
@endif
@endif
</td>
</td>
</tr>
</tr>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment