Bearsampp
2025.8.29
Loading...
Searching...
No Matches
class.homepage.php
Go to the documentation of this file.
1
<?php
2
/*
3
*
4
* * Copyright (c) 2021-2024 Bearsampp
5
* * License: GNU General Public License version 3 or later; see LICENSE.txt
6
* * Website: https://bearsampp.com
7
* * Github: https://github.com/Bearsampp
8
*
9
*/
10
17
class
Homepage
18
{
19
const
PAGE_INDEX
=
'index'
;
20
const
PAGE_PHPINFO
=
'phpinfo'
;
21
22
private
$page
;
23
27
private
$pageList
= array(
28
self::PAGE_INDEX,
29
self::PAGE_PHPINFO,
30
);
31
36
public
function
__construct
()
37
{
38
Util::logInitClass
($this);
39
40
$page
=
Util::cleanGetVar
(
'p'
);
41
$this->page = !empty(
$page
) && in_array(
$page
, $this->pageList) ?
$page
: self::PAGE_INDEX;
42
}
43
49
public
function
getPage
()
50
{
51
return
$this->page
;
52
}
53
60
public
function
getPageQuery
($query)
61
{
62
if
(empty($query)) {
63
return
''
;
64
}
65
66
if
(in_array($query, $this->pageList)) {
67
return
$query !== self::PAGE_INDEX ?
'?p='
. $query :
'index.php'
;
68
}
69
70
return
''
;
71
}
72
79
public
function
getPageUrl
($query)
80
{
81
global
$bearsamppRoot
;
82
return
$bearsamppRoot
->getLocalUrl($this->
getPageQuery
($query));
83
}
84
90
public
function
getHomepagePath
()
91
{
92
global
$bearsamppCore
;
93
return
$bearsamppCore
->getResourcesPath(
false
) .
'/homepage'
;
94
}
95
101
public
function
getImagesPath
()
102
{
103
return
$this->
getResourcesPath
(
false
) .
'/img/'
;
104
}
105
111
public
function
getIconsPath
()
112
{
113
return
$this->
getResourcesPath
(
false
) .
'/img/icons/'
;
114
}
115
121
public
function
getResourcesPath
()
122
{
123
global
$bearsamppCore
;
124
return
md5(
APP_TITLE
);
125
}
126
132
public
function
getResourcesUrl
()
133
{
134
global
$bearsamppRoot
;
135
return
$bearsamppRoot
->getLocalUrl($this->
getResourcesPath
());
136
}
137
143
public
function
refreshAliasContent
()
144
{
145
global
$bearsamppBins
;
146
147
$result
=
$bearsamppBins
->getApache()->getAliasContent(
148
$this->
getResourcesPath
(),
149
$this->
getHomepagePath
()
150
);
151
152
return
file_put_contents($this->
getHomepagePath
() .
'/alias.conf'
,
$result
) !==
false
;
153
}
154
158
public
function
refreshCommonsJsContent
()
159
{
160
Util::replaceInFile
($this->
getHomepagePath
() .
'/js/_commons.js'
, array(
161
'/^\s\surl:.*/'
=>
' url: "'
. $this->
getResourcesPath
() .
'/ajax.php"'
,
162
'/AJAX_URL.*=.*/'
=>
'const AJAX_URL = "'
. $this->
getResourcesPath
() .
'/ajax.php"'
,
163
));
164
}
165
}
$result
$result
Definition
ajax.apache.php:19
$bearsamppBins
global $bearsamppBins
Definition
ajax.apache.php:16
$bearsamppRoot
global $bearsamppRoot
Definition
ajax.apache.php:16
$bearsamppCore
global $bearsamppCore
Definition
ajax.latestversion.php:24
Homepage
Definition
class.homepage.php:18
Homepage\PAGE_PHPINFO
const PAGE_PHPINFO
Definition
class.homepage.php:20
Homepage\__construct
__construct()
Definition
class.homepage.php:36
Homepage\$page
$page
Definition
class.homepage.php:22
Homepage\getResourcesUrl
getResourcesUrl()
Definition
class.homepage.php:132
Homepage\getPage
getPage()
Definition
class.homepage.php:49
Homepage\getResourcesPath
getResourcesPath()
Definition
class.homepage.php:121
Homepage\refreshAliasContent
refreshAliasContent()
Definition
class.homepage.php:143
Homepage\getHomepagePath
getHomepagePath()
Definition
class.homepage.php:90
Homepage\getPageUrl
getPageUrl($query)
Definition
class.homepage.php:79
Homepage\getImagesPath
getImagesPath()
Definition
class.homepage.php:101
Homepage\refreshCommonsJsContent
refreshCommonsJsContent()
Definition
class.homepage.php:158
Homepage\$pageList
$pageList
Definition
class.homepage.php:27
Homepage\getPageQuery
getPageQuery($query)
Definition
class.homepage.php:60
Homepage\PAGE_INDEX
const PAGE_INDEX
Definition
class.homepage.php:19
Homepage\getIconsPath
getIconsPath()
Definition
class.homepage.php:111
Util\logInitClass
static logInitClass($classInstance)
Definition
class.util.php:801
Util\cleanGetVar
static cleanGetVar($name, $type='text')
Definition
class.util.php:78
Util\replaceInFile
static replaceInFile($path, $replaceList)
Definition
class.util.php:378
APP_TITLE
const APP_TITLE
Definition
root.php:13
Bearsampp-development
sandbox
core
classes
class.homepage.php
Generated by
1.14.0