Bearsampp 2026.9.23
Loading...
Searching...
No Matches
class.tool.ngrok.php
Go to the documentation of this file.
1<?php
2/*
3 * Copyright (c) 2021-2026 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
17class ToolNgrok extends Module
18{
22 const ROOT_CFG_VERSION = 'ngrokVersion';
23
27 const LOCAL_CFG_EXE = 'ngrokExe';
28
32 private $exe;
33
40 public function __construct($id, $type)
41 {
42 Log::initClass($this);
43 $this->reload($id, $type);
44 }
45
52 public function reload($id = null, $type = null)
53 {
55 Log::reloadClass($this);
56
57 $this->name = $bearsamppLang->getValue(Lang::NGROK);
58 $this->version = $bearsamppConfig->getRaw(self::ROOT_CFG_VERSION);
59 parent::reload($id, $type);
60
61 if ($this->bearsamppConfRaw !== false) {
62 $this->exe = $this->symlinkPath . '/' . $this->bearsamppConfRaw[self::LOCAL_CFG_EXE];
63 }
64
65 if (!$this->enable) {
66 Log::info($this->name . ' is not enabled!');
67
68 return;
69 }
70 if (!is_dir($this->currentPath)) {
71 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_FILE_NOT_FOUND), $this->name . ' ' . $this->version, $this->currentPath));
72 }
73 if (!is_dir($this->symlinkPath)) {
74 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_FILE_NOT_FOUND), $this->name . ' ' . $this->version, $this->symlinkPath));
75
76 return;
77 }
78 if (!is_file($this->bearsamppConf)) {
79 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_CONF_NOT_FOUND), $this->name . ' ' . $this->version, $this->bearsamppConf));
80 }
81 if (!is_file($this->exe)) {
82 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_EXE_NOT_FOUND), $this->name . ' ' . $this->version, $this->exe));
83 }
84 }
85
91 public function setVersion($version)
92 {
93 global $bearsamppConfig;
94 $this->version = $version;
95 $bearsamppConfig->replace(self::ROOT_CFG_VERSION, $version);
96 $this->reload();
97 }
98
104 public function getExe()
105 {
106 return $this->exe;
107 }
108}
109
global $bearsamppLang
const ERROR_EXE_NOT_FOUND
const ERROR_CONF_NOT_FOUND
const NGROK
const ERROR_FILE_NOT_FOUND
static info($data, $file=null)
static reloadClass($classInstance)
static error($data, $file=null)
static initClass($classInstance)
setVersion($version)
reload($id=null, $type=null)
const ROOT_CFG_VERSION
__construct($id, $type)
global $bearsamppConfig
Definition homepage.php:46