<?php
/* Ulyxex version 1.6.7.8 ***************/
/* code http://ulyxex.logz.org **********/
/* Andre Lozano http://andre-lozano.org */
class AdminSite extends Admin {
public object $h;
public object $t;
public object $tree;
function __construct(){
$this->h = New Htmlz();
$this->t = New Translate();
$this->tree = New Tree();
}
public function site_params(){
$h = $this->h;$t = $this->t;
if ($_SESSION['userid'] == 1){
if (file_exists("version.txt")) {
$Lines = file("version.txt");
if ($Lines) {
foreach($Lines as $Line) {
$params = explode("=",$Line);
if ($params[0] == "date") {
$dateVersion = $h->classicDate($params[1]);
}
}
}
} else {
$dateVersion = "no date";
}
$query = SELECT.
PARAMS.".*,".PAGES.".NAME".
FROM.
PARAMS.
INNERJOIN.PAGES._ON_.PAGES.".ID = ".PARAMS.".PAGEID";
WHERE.
PARAMS.".ID = 1"._AND_.PAGES.".ID = ".PARAMS.".PAGEID";
$query = $this->q($query);
$dat = $this->fetch($query);
$query = SELECT.USERS.".MAIL,".USERS.".USERNAME".FROM.USERS.WHERE.USERS.".ID = 1";
$query = $this->q($query);
$user = $this->fetch($query);
$_[] = $h->h3($t->wr("Version:").$t->wr("Ulyxex").VERSION.",".$h->_($dateVersion));
$_[] = $h->input("hidden","update",1);
$_[] = $h->p($h->b("-".str_pad("Site",40,"-")));
$cssIput = $h->v("readonly","readonly").$h->v("style","border:dotted black 2px;font-weight:bold;text-align:center;");
$reloadButton = $h->button("⟳",$h->v("onclick","location.reload(true);").$h->alt($t->w("refresh")));
$refreshButton = $h->button("⟳",$h->v("onclick","location.href='admin.php?action=admin_home';").$h->alt($t->w("refresh")));
$_tmp = $h->p(
$h->span(
$t->wr("home page in use").
$t->wlr("name").$h->input("text","nameaccueil",$h->safeVal($dat['NAME']),$h->v("size",(strlen($dat['NAME']))).$cssIput).
$t->wlr("type").$h->input("text","typeaccueil",$dat['TYPEPAGE'],$h->v("size",(mb_strlen($dat['TYPEPAGE']))).$cssIput).
" id ".
$h->input("text","paramaccueil",$dat['PAGEID'],$h->v("size",(strlen($dat['PAGEID']))).$cssIput)
,$h->v("style","background-color: Gainsboro;padding: 6px;font-weight: bold;width: fit-content;"))
." ".
$h->ahref(
"index.php?k=".$dat['TYPEPAGE']."&v=".$dat['PAGEID'],
$t->w("show"),
$h->v("target","blank").$h->v("class","linkbtn")
)
);
$_tmp .= $h->p(
$h->lbl($t->wr("select new home page"),"pageId")
,$h->v("style","font-weight: bold;")
);
$_tmp .= $h->p(
$t->wlr("name").$h->input("text","name",$h->safeVal($dat['NAME']),$h->v("size",(strlen($dat['NAME']))).$cssIput).
$t->wlr("type").$h->input("text","type",$dat['TYPEPAGE'],$h->v("size",(mb_strlen($dat['TYPEPAGE']))).$cssIput).
" id ".
$h->input("text","param",$dat['PAGEID'],$h->v("size",(strlen($dat['PAGEID']))).$cssIput)." ".
$h->span(
$h->ahref("index.php?k=".$dat['TYPEPAGE']."&v=".$dat['PAGEID'],$t->w("show"),$h->v("target","blank").$h->v("class","linkbtn")),
$h->v("id","homelink")
)
,$h->v("style","margin-bottom:5px;"));
$_tmp .= $h->p($this->tree->pathsSelectSiteParams($dat['PAGEID'],"pageId"));
$options = array(
$t->w("dropdown form")=>"tree",
$t->w("inline")=>"one_line",
$t->w("inline + navigation")=>"line_nav",
$t->w("ul drop-down list")=>"ul_list",
$t->w("ol drop-down list")=>"ol_list"
);
$_tmp .= $h->p(
$h->lbl($t->wr("select navigation menu"),"navtype").
$h->select($options,"navtype",$dat['NAVTYPE']),
$h->alt($t->w("others than ul-ol"))
);
$options = array();
$css_files = $this->css_files();
foreach($css_files as $css) {$options[$css] = $css;}
$_tmp .= $h->p($h->lbl($t->wr("select main css"),"css").$h->select($options,"css",$dat['CSS']));
$_[] = $h->div(
$_tmp,
$h->v("style","border-radius:5px;border: 2px solid DarkGray;padding: 4px;font-weight: bold;width: fit-content;").$h->alt($t->w("website params control"))
);
$sitetab = empty($dat['SITETAB'])?"↳":html_entity_decode($dat['SITETAB']);// ↳
$ideovals = array(" ","↳","⤷","↪","⤿","⤹","⤥","↘","→","⤳","↝","▶","▷","▸","▹","▻","·","-","_",":","/","⚛","☯","☮","☭","☠");
foreach($ideovals as $ideo) {$ideograms[$ideo] = $ideo;}
$ideoSelect = $h->select($ideograms,"ideogram",$sitetab,$h->v("onchange","updateSubValue(this.value)"));
$subentity = "&#".mb_ord($sitetab,"UTF-8").";";
$_[] = $h->p(
$h->lbl($t->wr("submenu icon"),"tab").$ideoSelect.$h->input("text","tab",$sitetab,$h->v("size","6").$h->v("class","centered")).
$t->wlr("html entity").
$h->input("text","subentity",$subentity,$h->v("size","8").$h->v("readonly","readonly").$cssIput,
$h->alt($t->w("separator submenus")))
);
$checked = ($dat['HTTPS'])?$h->v("checked","checked"):null;
$https = $h->span($h->lbl($t->wr("https in local links"),"https").$h->input("checkbox","https","on",$checked),$h->alt($t->w("https links")))." ";
$_[] = $h->p(
$https." -- ".
$h->lbl($t->wr("articles by page"),"articlespage").
$h->input("text","articlespage",$dat['ARTICLESPAGE'],$h->v("size","4").$h->v("class","centered"))
);
$_[] = $h->p(
"favicon.png : ".$h->img("favicon.png",$h->v("alt","No Favicon").$h->v("align","absmiddle"))." ".$reloadButton." (png) "
);
$_[] = $h->p(
$h->label($t->wr("modify favicon"),"addfile").$h->input("file","addFavicon",null,$h->v("accept","image/png"))
);
$tdTimeZone = $h->lbl($t->wr("time zone").$t->wr("website"),"timezone").$this->selectTimeZone();
$serverTime = date('Y-m-d H:i:s');
$serverZone = date('e');
$dt = new DateTime("now", new DateTimeZone(TIMEZONE));
$date = $dt->format('Y-m-d H:i:s');
$dateZone = $dt->format('e');
$_[] = $h->table(
$h->tr(
$h->td($tdTimeZone ,$h->v("colspan","4"))
).
$h->tr(
$h->td($t->wx("browser",":")).
$h->th("none",$h->v("id","browsertimezone")).
$h->td("none",$h->v("id","browserdate").$h->v("style","text-align:left;")).
$h->td($refreshButton,$h->v("rowspan","3").$h->v("style","vertical-align:middle"))
).
$h->tr(
$h->td($t->wx("website",":")).
$h->th($dateZone.":").
$h->td($date,$h->v("style","text-align:left;"))
).
$h->tr(
$h->td($t->wx("server",":")).
$h->th($serverZone.":").
$h->td($serverTime,$h->v("style","text-align:left;"))
)
,$h->v("class","time"));
$_[] = $h->p($h->b("-".str_pad("Admin",40,"-")));
$options = array("english"=>"0","français"=>"1","español"=>"2");
$_[] = $h->p($h->lbl($t->wr("website main language"),"lang").$h->select($options,"lang",$dat['LANG'])." ".$refreshButton);
$_[] = $h->p(
$h->lbl($t->wr("items by page admin"),"items").
$h->input("text","items",$dat['ITEMS'],$h->v("size","4").$h->v("class","centered"))
);
$_[] = $h->p(
$t->wr("admin data")."(admin) : ".
$h->ahref(
"admin.php?action=modify_user&user=1",$user['USERNAME'],
$h->v("class","linkbtn").$h->alt($t->wz("modify").$h->slash($user['USERNAME']))
)
);
$size = $h->v("size",(mb_strlen($user['MAIL'])));
$_[] = $h->p(
$h->lbl($t->wr("website administrator mail"),"mail").
$h->input("text","mail",$user['MAIL'],$size.$h->v("readonly","readonly"))
);
$_[] = $h->p($h->input("submit",null,$t->w("update all")));
$inputs = implode("",$_);
return $h->form($inputs,"home","post","admin.php?action=admin_home","multipart/form-data").$h->p(SP_);
}
}
function css_files(){
$list = array();
$handle = opendir("css/");
while ($file = readdir($handle)){
$file_parts = pathinfo($file);
if (isset($file_parts['extension']) && $file_parts['extension'] == "css" && $file != "admin_style.css") {
$list[] = "css/".$file;
}
} // end while
closedir($handle);
sort($list);
return $list;
}
public function update_site_params(){
$h = $this->h;$t = $this->t;
$vals = explode("&",$_POST['pageId']);
$typePage = explode("=",$vals[0]);
$typePage = $typePage[1];
$paramId = explode("=",$vals[1]);
$paramId = $paramId[1];
if (isset($_POST['https'])) {
$https = 1;
} else {
$https = 0;
}
$query = UPDATE.PARAMS.
SET."PAGEID = '".$h->word($paramId).
"',TYPEPAGE = '".$h->word($typePage).
"',LANG = '".$h->word($_POST['lang']).
"',NAVTYPE = '".$h->word($_POST['navtype']).
"',CSS = '".$h->word($_POST['css']).
"',SITETAB = '".$h->safe($_POST['tab']).
"',HTTPS = '".$https.
"',ARTICLESPAGE = '".$h->num($_POST['articlespage']).
"',ITEMS = '".$h->num($_POST['items']).
"',MAIL = '".$h->safe($_POST['mail']).
"',TIMEZONE = '".$h->safe($_POST['timezone']).
"'".
WHERE."ID = 1";
$query = $this->q($query);
if (!empty($_FILES['addFavicon']["name"])) {
$fileName = $_FILES['addFavicon']["name"];
$ext = $h->get_ext($fileName);
if ($ext == "png"){;
$fileName = "favicon.png";
$sendFile = move_uploaded_file($_FILES['addFavicon']["tmp_name"],$fileName);
//~ echo ($sendFile)?"file uploaded":"error";
}
}
return $h->h3($t->w("some vals been modified !"),$h->v("class","warning"));
}
public function selectTimeZone(){
$h = $this->h;$t = $this->t;
$query = SELECT.PARAMS.".TIMEZONE".FROM.PARAMS.WHERE.PARAMS.".ID = 1;";
$query = $this->q($query);
while ( $line = $this->fetch($query) ){
$TIMEZONE = $line['TIMEZONE'];
}
$_["Pacific/Midway"] = "UTC-11 ";
$_["Pacific/Tahiti"] = "UTC-10 ";
$_["America/Anchorage"] = "UTC-9 ";
$_["America/Los_Angeles"] = "UTC-8 ";
$_["America/Denver"] = "UTC-7 ";
$_["America/Mexico_City"] = "UTC-6 ";
$_["America/Havana"] = "UTC-5 ";
$_["America/Santiago"] = "UTC-4 ";
$_["America/Sao_Paulo"] = "UTC-3 ";
$_["America/Noronha"] = "UTC-2 ";
$_["Atlantic/Azores"] = "UTC-1 ";
$_["Europe/London"] = "UTC+0 ";
$_["Europe/Paris"] = "UTC+1 ";
$_["Africa/Cairo"] = "UTC+2 ";
$_["Asia/Baghdad"] = "UTC+3 ";
$_["Europe/Moscow"] = "UTC+4 ";
$_["Asia/Dushanbe"] = "UTC+5 ";
$_["Asia/Almaty"] = "UTC+6 ";
$_["Asia/Bangkok"] = "UTC+7 ";
$_["Asia/Singapore"] = "UTC+8 ";
$_["Asia/Tokyo"] = "UTC+9 ";
$_["Australia/Sydney"] = "UTC+10 ";
$_["Asia/Vladivostok"] = "UTC+11 ";
$_["Pacific/Auckland"] = "UTC+12 ";
$_["Pacific/Tongatapu"] = "UTC+13 ";
$_["Pacific/Kiritimati"] = "UTC+14 ";
$options = array();
$optionSelectect = null;
foreach ($_ as $timeZone => $utc){
if ($timeZone == $TIMEZONE){
$optionSelectect = $TIMEZONE;
$options[$utc.$timeZone] = $timeZone;
} else {
$options[$utc.$timeZone] = $timeZone;
}
}
return $h->select($options,"timezone",$optionSelectect);
}
public function list_pages_select($pageId,$name){
$h = $this->h;$t = $this->t;
$query = SELECT.PAGES.".ID,".PAGES.".NAME,".PAGES.".TYPEPAGE".FROM.PAGES;
$query = $this->q($query);
$options = array();
$optionSelectect = null;
while ( $line = $this->fetch($query) ){
if ($line['ID'] == $pageId){
$optionSelectect = "k=".$line['TYPEPAGE']."&v=".$line['ID'];
$options[$line['NAME']] = "k=".$line['TYPEPAGE']."&v=".$line['ID'];
} else {
$options[$line['NAME']] = "k=".$line['TYPEPAGE']."&v=".$line['ID'];
}
}
return $h->select($options,$name,$optionSelectect,$h->v("onchange","fillFieldSite(this.value)"));
}
}
?>