devopssantana /
aapanel
| 1 | <?php |
||
| 2 | |||
| 3 | namespace DevOpsSantana\AAPanel; |
||
| 4 | |||
| 5 | /** |
||
| 6 | * Class AAPanelVhost |
||
| 7 | * @package DevOpsSantana\AAPanel |
||
| 8 | * @author Rogério Santana <https://github.com/devopssantana> |
||
| 9 | * @since : 2022 |
||
| 10 | */ |
||
| 11 | class AAPanelVhost extends AAPanelConnect |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @description Class Construct |
||
| 15 | */ |
||
| 16 | public function __construct() |
||
| 17 | { |
||
| 18 | parent::__construct(); |
||
| 19 | } |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @param string $domain |
||
| 23 | * @return mixed |
||
| 24 | */ |
||
| 25 | public function Rewrite(string $domain): mixed |
||
| 26 | { |
||
| 27 | $url = $this->serverUrl . '/site?action=GetRewriteList'; |
||
| 28 | |||
| 29 | $this->data['siteName'] = $domain; |
||
| 30 | return (parent::Execute($url, $this->data)); |
||
| 31 | } |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @description Read Data Vhosts Rewrite |
||
| 35 | * @param string $subdomain |
||
| 36 | * @return mixed |
||
| 37 | */ |
||
| 38 | public function Read(string $subdomain): mixed |
||
| 39 | { |
||
| 40 | $url = $this->serverUrl . '/files?action=GetFileBody'; |
||
| 41 | |||
| 42 | $this->data['path'] = '/www/server/panel/vhost/rewrite/' . $subdomain . '.conf'; |
||
| 43 | return (parent::Execute($url, $this->data)); |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @description Insert Data Vhosts Rewrite |
||
| 48 | * @param string $subdomain |
||
| 49 | * @param string $server |
||
| 50 | * @param string $encoding |
||
| 51 | * @return mixed |
||
| 52 | */ |
||
| 53 | public function Write(string $subdomain, string $server, string $encoding = 'utf-8'): mixed |
||
| 54 | { |
||
| 55 | $url = $this->serverUrl . '/files?action=SaveFileBody'; |
||
| 56 | |||
| 57 | $this->data['data'] = $this->server($server); |
||
| 58 | $this->data['path'] = '/www/server/panel/vhost/rewrite/' . $subdomain . '.conf'; |
||
| 59 | $this->data['encoding'] = $encoding; |
||
| 60 | return (parent::Execute($url, $this->data)); |
||
| 61 | } |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @description Rewrite Text |
||
| 65 | * @param $server |
||
| 66 | * @return string|void |
||
| 67 | */ |
||
| 68 | private function server($server) |
||
| 69 | { |
||
| 70 | switch ($server) { |
||
| 71 | case 'nginx': |
||
| 72 | return 'autoindex off; |
||
| 73 | location / { |
||
| 74 | if ($request_uri !~ "-f"){ |
||
| 75 | rewrite ^(.*)$ /index.php?route=$1; |
||
| 76 | } |
||
| 77 | } |
||
| 78 | |||
| 79 | location ~ ^\.(htaccess|htpasswd|env|gitignore|ini)$ { |
||
| 80 | deny all; |
||
| 81 | }'; |
||
| 82 | break; |
||
|
0 ignored issues
–
show
|
|||
| 83 | } |
||
| 84 | } |
||
| 85 | } |
The
breakstatement is not necessary if it is preceded for example by areturnstatement:If you would like to keep this construct to be consistent with other
casestatements, you can safely mark this issue as a false-positive.