2017-03-19 08:02:14 +08:00
|
|
|
<?php
|
|
|
|
/**
|
2023-10-12 16:55:42 +08:00
|
|
|
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
|
|
|
* by https://t.me/ibnux
|
|
|
|
**/
|
|
|
|
|
2017-03-19 08:02:14 +08:00
|
|
|
_admin();
|
2022-10-13 15:00:54 +08:00
|
|
|
$ui->assign('_title', 'Pages');
|
2017-03-19 08:02:14 +08:00
|
|
|
$ui->assign('_system_menu', 'pages');
|
|
|
|
|
|
|
|
$action = $routes['1'];
|
|
|
|
$admin = Admin::_info();
|
|
|
|
$ui->assign('_admin', $admin);
|
|
|
|
|
2023-10-20 11:34:24 +08:00
|
|
|
if(strpos($action,"-reset")!==false){
|
|
|
|
$action = str_replace("-reset","",$action);
|
|
|
|
$path = "pages/".str_replace(".","",$action).".html";
|
|
|
|
$temp = "pages_template/".str_replace(".","",$action).".html";
|
|
|
|
if(file_exists($temp)){
|
|
|
|
if(!copy($temp, $path)){
|
|
|
|
file_put_contents($path, Http::getData('https://raw.githubusercontent.com/hotspotbilling/phpnuxbill/master/pages_template/'.$action.'.html'));
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
file_put_contents($path, Http::getData('https://raw.githubusercontent.com/hotspotbilling/phpnuxbill/master/pages_template/'.$action.'.html'));
|
|
|
|
}
|
|
|
|
r2(U . 'pages/'.$action);
|
|
|
|
}else if(strpos($action,"-post")===false){
|
2023-09-18 16:03:25 +08:00
|
|
|
$path = "pages/".str_replace(".","",$action).".html";
|
2017-03-19 08:02:14 +08:00
|
|
|
//echo $path;
|
2022-09-18 01:00:40 +08:00
|
|
|
run_hook('view_edit_pages'); #HOOK
|
2023-09-18 16:03:25 +08:00
|
|
|
if(!file_exists($path)){
|
2023-09-20 15:27:15 +08:00
|
|
|
$temp = "pages_template/".str_replace(".","",$action).".html";
|
|
|
|
if(file_exists($temp)){
|
|
|
|
if(!copy($temp, $path)){
|
|
|
|
touch($path);
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
touch($path);
|
|
|
|
}
|
2023-09-18 16:03:25 +08:00
|
|
|
}
|
2017-03-19 08:02:14 +08:00
|
|
|
if(file_exists($path)){
|
|
|
|
$html = file_get_contents($path);
|
|
|
|
$ui->assign("htmls",str_replace(["<div","</div>"],"",$html));
|
|
|
|
$ui->assign("writeable",is_writable($path));
|
2023-09-18 16:03:25 +08:00
|
|
|
$ui->assign("pageHeader",str_replace('_', ' ', $action));
|
2017-03-19 08:02:14 +08:00
|
|
|
$ui->assign("PageFile",$action);
|
|
|
|
$ui->display('page-edit.tpl');
|
|
|
|
}else
|
|
|
|
$ui->display('a404.tpl');
|
|
|
|
}else{
|
|
|
|
$action = str_replace("-post","",$action);
|
2023-09-18 16:03:25 +08:00
|
|
|
$path = "pages/".str_replace(".","",$action).".html";
|
2017-03-19 08:02:14 +08:00
|
|
|
if(file_exists($path)){
|
|
|
|
$html = _post("html");
|
2022-09-18 01:00:40 +08:00
|
|
|
run_hook('save_pages'); #HOOK
|
2017-03-19 08:02:14 +08:00
|
|
|
if(file_put_contents($path, str_replace(["<div","</div>"],"",$html))){
|
2024-02-13 14:54:01 +08:00
|
|
|
r2(U . 'pages/'.$action, 's', Lang::T("Saving page success"));
|
2017-03-19 08:02:14 +08:00
|
|
|
}else{
|
2024-02-13 14:54:01 +08:00
|
|
|
r2(U . 'pages/'.$action, 'e', Lang::T("Failed to save page, make sure i can write to folder pages, <i>chmod 664 pages/*.html<i>"));
|
2017-03-19 08:02:14 +08:00
|
|
|
}
|
|
|
|
}else
|
|
|
|
$ui->display('a404.tpl');
|
|
|
|
}
|