2024.8.23
Loading...
Searching...
No Matches
class.tool.ngrok.php
Go to the documentation of this file.
1
<?php
2
/*
3
* Copyright (c) 2021-2024 Bearsampp
4
* License: GNU General Public License version 3 or later; see LICENSE.txt
5
* Author: Bear
6
* Website: https://bearsampp.com
7
* Github: https://github.com/Bearsampp
8
*/
9
10
/**
11
* Class ToolNgrok
12
*
13
* This class represents the Ngrok tool module in the Bearsampp application.
14
* It extends the Module class and provides functionalities specific to Ngrok,
15
* such as loading configurations, setting versions, and retrieving executable paths.
16
*/
17
class
ToolNgrok
extends
Module
18
{
19
/**
20
* Configuration key for the Ngrok version in the root configuration.
21
*/
22
const
ROOT_CFG_VERSION
=
'ngrokVersion'
;
23
24
/**
25
* Configuration key for the Ngrok executable in the local configuration.
26
*/
27
const
LOCAL_CFG_EXE
=
'ngrokExe'
;
28
29
/**
30
* @var string Path to the Ngrok executable.
31
*/
32
private
$exe
;
33
34
/**
35
* Constructor for the ToolNgrok class.
36
*
37
* @param string $id The ID of the module.
38
* @param string $type The type of the module.
39
*/
40
public
function
__construct
(
$id
,
$type
) {
41
Util::logInitClass
($this);
42
$this->
reload
(
$id
,
$type
);
43
}
44
45
/**
46
* Reloads the Ngrok module configuration based on the provided ID and type.
47
*
48
* @param string|null $id The ID of the module. If null, the current ID is used.
49
* @param string|null $type The type of the module. If null, the current type is used.
50
*/
51
public
function
reload
(
$id
=
null
,
$type
=
null
) {
52
global
$bearsamppConfig
,
$bearsamppLang
;
53
Util::logReloadClass
($this);
54
55
$this->name =
$bearsamppLang
->getValue(
Lang::NGROK
);
56
$this->version =
$bearsamppConfig
->getRaw(self::ROOT_CFG_VERSION);
57
parent::reload(
$id
,
$type
);
58
59
if
($this->bearsamppConfRaw !==
false
) {
60
$this->exe = $this->symlinkPath .
'/'
. $this->bearsamppConfRaw[
self::LOCAL_CFG_EXE
];
61
}
62
63
if
(!$this->enable) {
64
Util::logInfo
($this->name .
' is not enabled!'
);
65
return
;
66
}
67
if
(!is_dir($this->currentPath)) {
68
Util::logError
(sprintf(
$bearsamppLang
->getValue(
Lang::ERROR_FILE_NOT_FOUND
), $this->name .
' '
. $this->version, $this->currentPath));
69
}
70
if
(!is_dir($this->symlinkPath)) {
71
Util::logError
(sprintf(
$bearsamppLang
->getValue(
Lang::ERROR_FILE_NOT_FOUND
), $this->name .
' '
. $this->version, $this->symlinkPath));
72
return
;
73
}
74
if
(!is_file($this->bearsamppConf)) {
75
Util::logError
(sprintf(
$bearsamppLang
->getValue(
Lang::ERROR_CONF_NOT_FOUND
), $this->name .
' '
. $this->version, $this->bearsamppConf));
76
}
77
if
(!is_file($this->exe)) {
78
Util::logError
(sprintf(
$bearsamppLang
->getValue(
Lang::ERROR_EXE_NOT_FOUND
), $this->name .
' '
. $this->version, $this->exe));
79
}
80
}
81
82
/**
83
* Sets the version of the Ngrok module and reloads the configuration.
84
*
85
* @param string $version The version to set.
86
*/
87
public
function
setVersion
(
$version
) {
88
global
$bearsamppConfig
;
89
$this->version =
$version
;
90
$bearsamppConfig
->replace(self::ROOT_CFG_VERSION,
$version
);
91
$this->
reload
();
92
}
93
94
/**
95
* Gets the path to the Ngrok executable.
96
*
97
* @return string The path to the Ngrok executable.
98
*/
99
public
function
getExe
() {
100
return
$this->exe
;
101
}
102
}
$bearsamppLang
global $bearsamppLang
Definition
ajax.apache.php:16
Lang\ERROR_FILE_NOT_FOUND
const ERROR_FILE_NOT_FOUND
Definition
class.lang.php:160
Lang\NGROK
const NGROK
Definition
class.lang.php:150
Lang\ERROR_CONF_NOT_FOUND
const ERROR_CONF_NOT_FOUND
Definition
class.lang.php:158
Lang\ERROR_EXE_NOT_FOUND
const ERROR_EXE_NOT_FOUND
Definition
class.lang.php:159
Module
Definition
class.module.php:15
Module\$type
$type
Definition
class.module.php:18
Module\$version
$version
Definition
class.module.php:22
Module\$id
$id
Definition
class.module.php:19
ToolNgrok
Definition
class.tool.ngrok.php:18
ToolNgrok\getExe
getExe()
Definition
class.tool.ngrok.php:99
ToolNgrok\reload
reload($id=null, $type=null)
Definition
class.tool.ngrok.php:51
ToolNgrok\$exe
$exe
Definition
class.tool.ngrok.php:32
ToolNgrok\__construct
__construct($id, $type)
Definition
class.tool.ngrok.php:40
ToolNgrok\setVersion
setVersion($version)
Definition
class.tool.ngrok.php:87
ToolNgrok\ROOT_CFG_VERSION
const ROOT_CFG_VERSION
Definition
class.tool.ngrok.php:22
ToolNgrok\LOCAL_CFG_EXE
const LOCAL_CFG_EXE
Definition
class.tool.ngrok.php:27
Util\logReloadClass
static logReloadClass($classInstance)
Definition
class.util.php:822
Util\logError
static logError($data, $file=null)
Definition
class.util.php:802
Util\logInitClass
static logInitClass($classInstance)
Definition
class.util.php:812
Util\logInfo
static logInfo($data, $file=null)
Definition
class.util.php:778
$bearsamppConfig
global $bearsamppConfig
Definition
homepage.php:26
Bearsampp-development
sandbox
core
classes
tools
class.tool.ngrok.php
Generated by
1.11.0