Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
Imldeployment
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
Imldeployment
Commits
d8580ffc
Commit
d8580ffc
authored
10 months ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
plugin classes: php8 only; added variable types (WIP)
parent
6f5de738
No related branches found
No related tags found
1 merge request
!66
php8 only; added variable types; short array syntax; remove glyphicons
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
public_html/deployment/classes/plugins_renderer.class.php
+2
-0
2 additions, 0 deletions
public_html/deployment/classes/plugins_renderer.class.php
public_html/deployment/classes/plugins_shellcmd_request.class.php
+55
-40
55 additions, 40 deletions
...tml/deployment/classes/plugins_shellcmd_request.class.php
with
57 additions
and
40 deletions
public_html/deployment/classes/plugins_renderer.class.php
+
2
−
0
View file @
d8580ffc
...
@@ -17,6 +17,8 @@ require_once('plugins.class.php');
...
@@ -17,6 +17,8 @@ require_once('plugins.class.php');
*
*
*
*
* @author axel
* @author axel
*
* 2024-08-23 v1.1 Axel Hahn php8 only; added variable types
*/
*/
class
plugin_renderer
extends
ciplugins
class
plugin_renderer
extends
ciplugins
{
{
...
...
This diff is collapsed.
Click to expand it.
public_html/deployment/classes/plugins_shellcmd_request.class.php
+
55
−
40
View file @
d8580ffc
...
@@ -5,51 +5,53 @@
...
@@ -5,51 +5,53 @@
*
*
* Used in ../plugins/shellcmd/getdata.php
* Used in ../plugins/shellcmd/getdata.php
*
*
* 2024-08-23 v1.1 Axel Hahn php8 only; added variable types
*/
*/
require_once
(
'plugins.class.php'
);
require_once
(
'plugins.class.php'
);
class
req_shellcmd
{
class
req_shellcmd
{
/**
/**
* plugin name
* plugin name
* @var string
* @var string
*/
*/
protected
$_sPlugin
=
false
;
protected
string
$_sPlugin
=
''
;
/**
/**
* pligin object
* pligin object
* @var object
* @var object
*/
*/
protected
$_oPlugin
=
false
;
protected
object
$_oPlugin
;
/**
/**
* Array of return items
* Array of return items
* TODO: might be removed
* TODO: might be removed
* @var array
* @var array
protected array $_aReturn = [];
*/
*/
protected
$_aReturn
=
[];
/**
/**
* Configuration for the plugin
* Configuration for the plugin
* @var array
* @var array
*/
*/
protected
$_aPluginConfig
=
[];
protected
array
$_aPluginConfig
=
[];
/**
/**
* Result after execution
* Result after execution
* @var array
* @var array
*/
*/
protected
$_aResult
=
[];
protected
array
$_aResult
=
[];
/**
/**
* Flag: enable debug? Default: false
* Flag: enable debug? Default: false
* @var bool
* @var bool
*/
*/
protected
$_debug
=
false
;
protected
bool
$_debug
=
false
;
/**
/**
* plugins class instance
*
ci
plugins class instance
* @var object
* @var object
*/
*/
protected
$CI_plugins
=
false
;
protected
$CI_plugins
=
false
;
...
@@ -61,7 +63,8 @@ class req_shellcmd {
...
@@ -61,7 +63,8 @@ class req_shellcmd {
/**
/**
* Constructor
* Constructor
*/
*/
public
function
__construct
(){
public
function
__construct
()
{
$this
->
detectPlugin
();
$this
->
detectPlugin
();
}
}
...
@@ -70,11 +73,13 @@ class req_shellcmd {
...
@@ -70,11 +73,13 @@ class req_shellcmd {
// ---------------------------------------------------------------
// ---------------------------------------------------------------
/**
/**
*
h
elper execute a given command and return array with executed
*
H
elper
:
execute a given command and return array with executed
* command, returncode, output
* command, returncode, output
* @param string $sCmd command to execute
* @return
* @return
*/
*/
protected
function
_execCommand
(
$sCmd
){
protected
function
_execCommand
(
string
$sCmd
):
array
{
exec
(
"
$sCmd
"
,
$aOut
,
$iResult
);
exec
(
"
$sCmd
"
,
$aOut
,
$iResult
);
return
[
return
[
'command'
=>
$sCmd
,
'command'
=>
$sCmd
,
...
@@ -86,22 +91,26 @@ class req_shellcmd {
...
@@ -86,22 +91,26 @@ class req_shellcmd {
/**
/**
*
i
nitialize the shellcmd plugin
*
I
nitialize the shellcmd plugin
* @returm boolean
* @returm boolean
*/
*/
protected
function
_loadPlugin
(){
protected
function
_loadPlugin
():
bool
{
$this
->
CI_plugins
=
new
ciplugins
();
$this
->
CI_plugins
=
new
ciplugins
();
$this
->
CI_plugins
->
setPlugin
(
$this
->
_sPlugin
,
'shellcmd'
);
$this
->
CI_plugins
->
setPlugin
(
$this
->
_sPlugin
,
'shellcmd'
);
$sPluginclass
=
$this
->
CI_plugins
->
getPluginClassname
();
$sPluginclass
=
$this
->
CI_plugins
->
getPluginClassname
();
$this
->
_oPlugin
=
new
$sPluginclass
();
$this
->
_oPlugin
=
new
$sPluginclass
();
return
true
;
}
}
/**
/**
* write debug output ... if enabled
* Write debug output ... if enabled
* @return void
*/
*/
protected
function
_wd
(
$s
){
protected
function
_wd
(
$s
):
void
{
echo
$this
->
_debug
?
'DEBUG '
.
__CLASS__
.
' '
.
$s
.
"<br>
\n
"
:
''
;
echo
$this
->
_debug
?
'DEBUG '
.
__CLASS__
.
' '
.
$s
.
"<br>
\n
"
:
''
;
}
}
...
@@ -110,24 +119,27 @@ class req_shellcmd {
...
@@ -110,24 +119,27 @@ class req_shellcmd {
// ---------------------------------------------------------------
// ---------------------------------------------------------------
/**
/**
* detect plugin name to load from GET param "plugin"
* Detect plugin name to load from GET param "plugin"
* @return bool
*/
*/
public
function
detectPlugin
(){
public
function
detectPlugin
():
bool
{
$this
->
_sPlugin
=
isset
(
$_GET
[
'plugin'
])
&&
$_GET
[
'plugin'
]
?
preg_replace
(
'/^a-z0-9/'
,
''
,
$_GET
[
'plugin'
])
:
false
;
$this
->
_sPlugin
=
isset
(
$_GET
[
'plugin'
])
&&
$_GET
[
'plugin'
]
?
preg_replace
(
'/^a-z0-9/'
,
''
,
$_GET
[
'plugin'
])
:
false
;
$this
->
_wd
(
"detected plugin: "
.
$this
->
_sPlugin
);
$this
->
_wd
(
"detected plugin: "
.
$this
->
_sPlugin
);
return
true
;
return
true
;
}
}
/**
/**
*
g
et data from plugin command and return array with executed
*
G
et data from plugin command and return array with executed
* command, returncode, output, parsed data
* command, returncode, output, parsed data
* @return array
* @return array
*/
*/
public
function
get
(){
public
function
get
():
array
{
$this
->
_loadPlugin
();
$this
->
_loadPlugin
();
if
(
!
$this
->
_oPlugin
)
{
if
(
!
$this
->
_oPlugin
)
{
return
$this
->
_aReturn
;
// return $this->_aReturn;
return
[];
}
}
$this
->
CI_plugins
->
getPluginConfig
();
$this
->
CI_plugins
->
getPluginConfig
();
$sCmd
=
$this
->
CI_plugins
->
getConfigitem
(
'command'
);
$sCmd
=
$this
->
CI_plugins
->
getConfigitem
(
'command'
);
...
@@ -141,9 +153,12 @@ class req_shellcmd {
...
@@ -141,9 +153,12 @@ class req_shellcmd {
}
}
/**
/**
* send response as json
* Send response as json.
* It sends http response header and json data in body
* @return void
*/
*/
public
function
sendResponse
(){
public
function
sendResponse
():
void
{
header
(
'Content-Type: application/json'
);
header
(
'Content-Type: application/json'
);
echo
json_encode
(
$this
->
get
(),
JSON_PRETTY_PRINT
);
echo
json_encode
(
$this
->
get
(),
JSON_PRETTY_PRINT
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment