From: Kilian Saffran Date: Sun, 6 Dec 2020 07:05:30 +0000 (+0100) Subject: v20201205 X-Git-Url: http://cloud.dks.lu/git/?a=commitdiff_plain;h=c4da3ec0f7235acebd17be104f2c2fdba8cdbab0;p=oldbell_lu.git v20201205 --- diff --git a/.vscode/snippets.code-snippets b/.vscode/snippets.code-snippets index e2af45f..a7d1f3d 100644 --- a/.vscode/snippets.code-snippets +++ b/.vscode/snippets.code-snippets @@ -57,6 +57,16 @@ "\t", ""] }, + "checkbox": { + "scope":"html", + "prefix": "checkbox", + "body": ["
","\t
", + "\t\t
", + "\t\t\t
", + "\t\t\t\t data-column=\"$3\" data-table=\"$2\" data-id=\"\" value=\"\" type=\"checkbox\" />", + "\t\t\t
", + "\t\t\t
${4: checkbox label text}
","\t\t
","\t
","
"] + }, "textarea": { "scope":"html", "prefix":"textarea", diff --git a/admin/css/theme.css b/admin/css/theme.css index 2dc74f1..036b993 100644 --- a/admin/css/theme.css +++ b/admin/css/theme.css @@ -709,6 +709,11 @@ input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; } +.checkboxlabel{ + font-size: 11pt; + padding: 6px; + padding-left: 1px; +} /* input[type=checkbox]{ appearance: none; display:inline-block; diff --git a/admin/db.php b/admin/db.php index 81e179c..46cce8c 100644 --- a/admin/db.php +++ b/admin/db.php @@ -23,13 +23,16 @@ } if (isset($vars["sid"]) && ($vars["sid"] != "")){ $vars["session"] = $sess->getSession($vars["sid"]); + } else { + error_log("No Session!"); } $params = array(); $html["session"] = $vars["session"]; + error_log(print_r($vars,true)); $params = json_decode(file_get_contents('php://input'), true); //$params =$_GET; $html["params"] = $params; - if(count($vars["session"]) == 0) { + if((!isset($vars["session"]) || !is_array($vars["session"])) || count($vars["session"]) == 0) { header('Content-Type: application/json'); echo json_encode($html); exit(1); diff --git a/admin/index.php b/admin/index.php index 9719cdf..2850bd0 100644 --- a/admin/index.php +++ b/admin/index.php @@ -10,6 +10,7 @@ $vars["config"] = $cfg; $vars["requri"] = $_SERVER["REQUEST_URI"]; $postdata = []; + error_log(print_r(ini_get_all(),true)); if (isset($_POST)){ $postdata = $_POST; } @@ -59,7 +60,7 @@ setcookie($cfg["cookie"], $vars["session"]["id_session"], null, "/", null, false, true ); } } - if(count($vars["session"]) == 0) { + if ((!isset($vars["session"]) || !is_array($vars["session"])) || count($vars["session"]) == 0) { $vars["skeleton"] = 'login.html'; if (($vars["page"] != 'login/forgotpassword.html') && ($vars["page"] != 'login/message.html')){ $vars["page"] = 'login/login.html'; diff --git a/admin/js/modules/gallery.js b/admin/js/modules/gallery.js index 7a0203b..7a699e5 100644 --- a/admin/js/modules/gallery.js +++ b/admin/js/modules/gallery.js @@ -1,5 +1,3 @@ - - let gallery = { id_gallery: null, gallery_folder: null, @@ -66,7 +64,7 @@ let gallery = { selectable: true, selectableRangeMode:"click", - autoResize:false, + //autoResize:false, rowFormatter:function(row, data){ //console.log(row); @@ -91,27 +89,41 @@ let gallery = { add: function(){ myapp.viewdialog("addgalleryitem"); }, - uploadItem: function(){ + uploadItem: async function(){ let data = {}; data["folder"] = "galleries/" + this.gallery_folder; + let publishnow = 0; + if (document.getElementById("addgalleryitem_publishnow").checked){ + publishnow = 1; + } myapp.closedlg("addgalleryitem"); var uplfiles = document.getElementById("addgalleryitem_file"); //console.log("files:",uplfiles.files); - let progresssteps = uplfiles.files.length * 2; - let cstep = 1; - myapp.openDataLoad("Téléchargement en cours","Attendez s.v.p.!",progresssteps); - for (let i = 0; i < uplfiles.files.length; i++) { - console.log("Upload File " + uplfiles.files[i].name,cstep); - myapp.setDataLoadMsg("Upload File " + uplfiles.files[i].name,cstep); - let filedata = postFileSync(uplfiles.files[i],data); - cstep++; - let retdata = postDataSync({"cl":"gallery","fn":"addItem","idgallery":gallery.id_gallery,"filename":filedata.file}); - cstep++; - } - gallery.gettabledata(); - myapp.closeDataLoad(); - return false; + //let progresssteps = uplfiles.files.length; + //let cstep = 1; + myapp.openDataLoad("Téléchargement en cours","Attendez s.v.p.!",null); + postFile(uplfiles,data).then(filesdata => { + console.log(filesdata); + postData({"cl":"gallery","fn":"addItem","idgallery":gallery.id_gallery,"files":filesdata.file,"publish":publishnow}).then(res => { + gallery.gettabledata(); + myapp.closeDataLoad(); + }); + }); }, + // uploadRequest: async function(uplfile,upldata){ + // await postFile(uplfile,upldata).then(filedata => { + // console.log("file uploaded ", filedata.file); + // postData({"cl":"gallery","fn":"addItem","idgallery":gallery.id_gallery,"filename":filedata.file}).then( data => { + // console.log("finally data", data); + // // if (last == true){ + // // gallery.gettabledata(); + // // myapp.closeDataLoad(); + // // } + // // return data.data; + // // }) + // }); + // }); + // }, // addItem: function(filename,last){ // console.log("Add Item " + filename); // postData({"cl":"gallery","fn":"addItem","idgallery":gallery.id_gallery,"filename":filename}).then( data => { @@ -189,7 +201,7 @@ let gallery = { }, changeDefaultImage: function(file){ - document.getElementById("gpreview").src = 'media/galleries/' + file; + document.getElementById("gpreview").src = 'media/galleries/' + file+ "?" + moment().format('YYYYMMDDhhmmss') ; } } diff --git a/admin/js/request.js b/admin/js/request.js index a6acc3b..e2fa6ad 100644 --- a/admin/js/request.js +++ b/admin/js/request.js @@ -20,54 +20,15 @@ async function postData(data = {}) { return response.json(); } -function postDataSync(data = {}) { - const response = await fetch(api + 'db.php', { - method: 'POST', - mode: 'same-origin', - cache: 'no-cache', - credentials: 'same-origin', - headers: { - 'Content-Type': 'application/json' - - }, - redirect: 'follow', - referrerPolicy: 'strict-origin', - body: JSON.stringify(data) - }); - - return response.json(); -} - async function postFile(fileobj,data = {}) { var mfd = new FormData(); for (var o in data){ mfd.append(o,data[o]); } - console.log("Upload:" + fileobj.name); - mfd.append('file', fileobj,fileobj.name); - // } - const response = await fetch(api + 'upload.php', { - method: 'POST', - // mode: 'same-origin', - // cache: 'no-cache', - // credentials: 'same-origin', - // headers: { - // 'Content-Type': undefined - // }, - // redirect: 'follow', - // referrerPolicy: 'strict-origin', - body: mfd - }); - console.log("postFIle response",response); - return response.json(); -} - -function postFileSync(fileobj,data = {}) { - var mfd = new FormData(); - for (var o in data){ - mfd.append(o,data[o]); + for (let i = 0; i < fileobj.files.length; i++) { + mfd.append('file'+ i, fileobj.files[i],fileobj.files[i].name); } - mfd.append('file', fileobj,fileobj.name); + const response = await fetch(api + 'upload.php', { method: 'POST', // mode: 'same-origin', @@ -80,10 +41,23 @@ function postFileSync(fileobj,data = {}) { // referrerPolicy: 'strict-origin', body: mfd }); - console.log("postFIle response",response); + //console.log("postFile response",response); return response.json(); } +// var report ={ +// generate: function(repname,filename,data){ +// showdataloaddlg("Création PDF encours","Attendez s.v.p."); +// postData("report.cgi",{"generate":repname,"file": filename + ".pdf","data":data}).then (data => {closedataloaddlg();report.openreport(data);}); +// return false; +// }, +// openreport(data){ +// if (data && data.file){ +// window.open(api + "report.cgi?open=" + encodeURIComponent(data.file)); +// } +// } +// } + // async function syncData(url,username,password, data = {}) { // //var decodedString = Base64.decode(encodedString); // let hh = {}; diff --git a/admin/lib/database.php b/admin/lib/database.php index 4467d05..c873509 100644 --- a/admin/lib/database.php +++ b/admin/lib/database.php @@ -2,7 +2,7 @@ class database { private $conn; private $dbconf; - private $debug=0; + private $debug=1; public function __construct($pdbconf){ $this->dbconf = $pdbconf; try { diff --git a/admin/lib/modules/Gallery.php b/admin/lib/modules/Gallery.php index 395ed6f..58cf9d2 100644 --- a/admin/lib/modules/Gallery.php +++ b/admin/lib/modules/Gallery.php @@ -18,38 +18,41 @@ class gallery { } public function getItems($id){ - $sql = "select * from galleryitems where id_gallery='".$id."' order by filename;"; + $sql = "select * from galleryitems where id_gallery='".$id."' order by publishdate desc NULLS LAST,filename desc;"; return $this->dbh->queryarray($sql); } public function setDefaultImage($thumbname,$galleryfolder){ $thbinfo = pathinfo($thumbname); - copy($this->cfg["adminmediapath"]."/galleries/".$galleryfolder."/thumb/".$thumbname,$this->cfg["adminmediapath"]."/galleries/".$galleryfolder."/".$galleryfolder.".".$thbinfo['extension']); - copy($this->cfg["webmediapath"]."/galleries/".$galleryfolder."/thumb/".$thumbname,$this->cfg["webmediapath"]."/galleries/".$galleryfolder."/".$galleryfolder.".".$thbinfo['extension']); + copy($this->cfg["adminmediapath"]."/galleries/".$galleryfolder."/thumb/".$thumbname,$this->cfg["adminmediapath"]."/galleries/".$galleryfolder.".".$thbinfo['extension']); + copy($this->cfg["webmediapath"]."/galleries/".$galleryfolder."/thumb/".$thumbname,$this->cfg["webmediapath"]."/galleries/".$galleryfolder.".".$thbinfo['extension']); $sql = "update galleries set picture=".$galleryfolder.".".$thbinfo['extension']." where link=".$galleryfolder.";"; return array("folder" => $galleryfolder, "file" => $galleryfolder.".".$thbinfo['extension']); } - public function addItem($filename,$idgallery){ + public function addItem($files,$idgallery,$publish){ error_log("Add gallery item: ".$filename." => ".$idgallery); $gld = $this->dbh->query("select id,link from galleries where id=".$this->dbh->value($idgallery).";"); - $filepath = $this->cfg["adminmediapath"].'galleries/'.$gld["link"].'/'.$filename; - if (file_exists($filepath)){ - $mt = mime_content_type($filepath); - $newitemid = $this->dbh->newuuid(); - $thumbname = $filename; - if (strpos($mt,'image/') !== 0){ - $findo =pathinfo($filename); - $thumbname=$finfo["basename"].'.png'; + foreach ($files as $filename){ + $filepath = $this->cfg["adminmediapath"].'galleries/'.$gld["link"].'/'.$filename; + if (file_exists($filepath)){ + $mt = mime_content_type($filepath); + $newitemid = $this->dbh->newuuid(); + $thumbname = $filename; + if (strpos($mt,'image/') !== 0){ + $findo =pathinfo($filename); + $thumbname=$finfo["basename"].'.png'; + } + if ($publish == 1){ + + } + $data = array("id" => $newitemid,"id_gallery" => $gld["id"],"filename" => $filename,"filetype" => $mt,"thumbname" => $thumbname, "publishdate" => (($publish==1)?date('Y-m-d'):null)); + $inssql = $this->dbh->createInsertDDL("public","galleryitems",$data); + error_log("SQL:".$inssql); + $this->dbh->exec($inssql); + $this->setItemCopies($newitemid); } - $data = array("id" => $newitemid,"id_gallery" => $gld["id"],"filename" => $filename,"filetype" => $mt,"thumbname" => $thumbname); - $inssql = $this->dbh->createInsertDDL("public","galleryitems",$data); - error_log("SQL:".$inssql); - $this->dbh->exec($inssql); - $this->setItemCopies($newitemid); - } else { - return 0; - } + } return 1; } diff --git a/admin/lib/session.php b/admin/lib/session.php index ec7ec78..558e3c3 100644 --- a/admin/lib/session.php +++ b/admin/lib/session.php @@ -10,6 +10,9 @@ class session { if (($sid !== null) && ($sid != "")){ $this->session = $this->dbh->query("select u.id as id_user, u.username, u.id_usergroup as usergroup, s.id as id_session , s.sessiondata from sessions s join users u on (s.id_user=u.id) where s.id='".$sid."' and s.remote_addr='".$_SERVER["REMOTE_ADDR"]."';"); } + if (count($this->session) == 0){ + return null; + } return $this->session; } diff --git a/admin/tmpl/elements/dialogs/dlgaddgalleryitem.html.mustache b/admin/tmpl/elements/dialogs/dlgaddgalleryitem.html.mustache index 8ebfa09..422c299 100644 --- a/admin/tmpl/elements/dialogs/dlgaddgalleryitem.html.mustache +++ b/admin/tmpl/elements/dialogs/dlgaddgalleryitem.html.mustache @@ -17,6 +17,18 @@ +
+
+
+
+
+ +
+
publier directement
+
+
+
+
diff --git a/admin/tmpl/elements/panels/pnl_galleries.html.mustache b/admin/tmpl/elements/panels/pnl_galleries.html.mustache index 057d113..c45695b 100644 --- a/admin/tmpl/elements/panels/pnl_galleries.html.mustache +++ b/admin/tmpl/elements/panels/pnl_galleries.html.mustache @@ -3,20 +3,20 @@ Home
Galleries
- + - - + +
diff --git a/admin/tmpl/elements/panels/pnl_gallery.html.mustache b/admin/tmpl/elements/panels/pnl_gallery.html.mustache index db1b729..88f9146 100644 --- a/admin/tmpl/elements/panels/pnl_gallery.html.mustache +++ b/admin/tmpl/elements/panels/pnl_gallery.html.mustache @@ -4,7 +4,7 @@
Gallerie
- + diff --git a/admin/upload.php b/admin/upload.php index 23bb36b..45c693d 100644 --- a/admin/upload.php +++ b/admin/upload.php @@ -2,10 +2,12 @@ require("lib/config.php"); require("lib/database.php"); require("lib/session.php"); + ini_set('upload_max_filesize', your_value_here); $db = new database($cfg["db"]); $sess = new session($db); $vars = array(); $html = array(); + if (isset($_COOKIE[$cfg["cookie"]])){ $vars["sid"] = $_COOKIE[$cfg["cookie"]]; } @@ -30,13 +32,19 @@ // error_log("mediafolder: ".$cfg["adminmediapath"].$mfolder." exists!"); // } $cnum = date('YmdHis'); - $cfiles = glob($cfg["adminmediapath"].$mfolder .'/'. "*"); - $xfiles = count($cfiles) + 1; - $cnum = $cnum."_".$xfiles; - $uplfi = pathinfo($_FILES['file']['name']); - $newfilename = basename($mfolder)."_".$cnum.".".strtolower($uplfi['extension']); - move_uploaded_file($_FILES['file']['tmp_name'],$cfg["adminmediapath"].$mfolder.'/'.$newfilename); - $html["file"] = $newfilename; + + $newfnames = array(); + foreach ($_FILES as $file){ + $cfiles = glob($cfg["adminmediapath"].$mfolder .'/'. "*"); + $xfiles = count($cfiles) + 1; + $cnumnew = $cnum."_".$xfiles; + $uplfi = pathinfo($file['name']); + $newfilename = basename($mfolder)."_".$cnumnew.".".strtolower($uplfi['extension']); + move_uploaded_file($file['tmp_name'],$cfg["adminmediapath"].$mfolder.'/'.$newfilename); + array_push($newfnames,$newfilename); + + } + $html["file"] = $newfnames; } header('Content-Type: application/json'); echo json_encode($html); diff --git a/website/db.php b/website/db.php index 25ec36c..c8aab74 100644 --- a/website/db.php +++ b/website/db.php @@ -1,64 +1,71 @@ $value) + { + if ((is_file("lib/".$value) && strpos($value,'.') !== 0) && substr_compare($value, ".php", -strlen(".php")) === 0){ + require("lib/".$value); + } + } + $moduleclasses = scandir("lib/modules"); + foreach ($moduleclasses as $key => $value) + { + if ((is_file("lib/modules/".$value) && strpos($value,'.') !== 0) && substr_compare($value, ".php", -strlen(".php")) === 0){ + require("lib/modules/".$value); + } + } + $db = new database($cfg["db"]); + $vars = array(); $html = array(); - + $params = array(); + $params = json_decode(file_get_contents('php://input'), true); + #$params =$_GET; $html["params"] = $params; - if (isset($params["get"])){ - if (strpos($params["get"], 'rdv_') === 0) { - $rdv = new RendezVous($db); - if ($params["get"] == 'rdv_services'){ - $html["data"] = $rdv->getServices(); - } elseif ($params["get"] == 'rdv_dates'){ - $html["data"] = $rdv->getRDVDates(); - } elseif ($params["get"] == 'rdv_freehours'){ - $html["data"] = $rdv->getRDVDayFreeTimes($db->securetext($params->{daydate})); + + if (isset($params["cl"]) && isset($params["fn"])){ + if (class_exists($params["cl"])) { + $strclass=$params["cl"]; + $cl = new $strclass($db,$cfg); + if (!method_exists($cl,$params["fn"])){ + $html["error"] = "class ".$params["cl"]."->method ".$params["fn"]." does not exist!"; } - } elseif (strpos($params["get"], 'gallery_') === 0){ - $gal = new Gallery($db); - if ($params["get"] == 'gallery_gallery'){ - $html["data"] = $gal->getGallery($params->{name}); - } elseif ($params["get"] == 'gallery_galleries'){ - $html["data"] = $gal->getGalleries($params->{names}); - } elseif ($params["get"] == 'gallery_galleryitems'){ - $html["data"] = $gal->getGalleryItems($params->{name}); + $r = new ReflectionMethod($strclass, $params["fn"]); + $metparams = $r->getParameters(); + $fnp = array(); + $prcnt = 0; + foreach ($metparams as $p) { + if (isset($params[$p->getName()])){ + array_push($fnp,$params[$p->getName()]); + } + if ($p->isOptional() === false){ + $prcnt++; + } + $html["fnparams"][$p->getName()] = (($p->isOptional() === true)?"optional":"required"); } - } elseif (strpos($params["get"], 'shop_') === 0){ - $shop = new Shop($db); - } elseif (strpos($params["get"], 'page_') === 0){ - $shop = new WebPage($db); - } - - } - elseif (isset($params["fn"])){ - if (strpos($params["fn"], 'rdv_') === 0) { - $rdv = new RendezVous($db); - if ($params["fn"] == 'rdv_confirm'){ - - }elseif ($params["fn"] == 'rdv_cancel'){ - + if (count($fnp) < $prcnt){ + $html["error"] = "Function has ".$prcnt." required parameters!"; + } else { + $html["data"] = call_user_func_array(array($cl, $params["fn"]), $fnp); } - } - // else (strpos($params["fn"], 'shop_') === 0){ - // //$shop = new Shop($db); - // if ($params["fn"] == 'shop_order'){ - - // } - // } - + } else { + $html["error"] = "class ".$params["cl"]." does not exist!"; + } + } + // elseif(isset($params["savefield"])){ + // $html["data"] = $db->exec("UPDATE ".$params["table"]." set ".$params["column"]."=".$db->value($params["value"])." where id=".$db->value($params["id"]).";"); + // } + // elseif(isset($params["saveform"])){ + // $updsql = $db->createUpdateDDL($params["schema"],$params["table"],$params["idents"],$params["data"]); + // $html["sql"] = $updsql; + // $html["data"] = $db->exec($updsql); + // } - } - elseif(isset($params["save"])){ - - } header('Content-Type: application/json'); echo json_encode($html); -?> \ No newline at end of file + +?> diff --git a/website/img/IMG_20201029_105226.jpg b/website/img/IMG_20201029_105226.jpg deleted file mode 100644 index cefd546..0000000 Binary files a/website/img/IMG_20201029_105226.jpg and /dev/null differ diff --git a/website/img/events.svg b/website/img/events.svg new file mode 100644 index 0000000..3b9c9dc --- /dev/null +++ b/website/img/events.svg @@ -0,0 +1,422 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Events + diff --git a/website/img/newspaper.svg b/website/img/newspaper.svg new file mode 100644 index 0000000..3b310db --- /dev/null +++ b/website/img/newspaper.svg @@ -0,0 +1,489 @@ + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/website/img/nopic.png b/website/img/nopic.png new file mode 100644 index 0000000..f87b118 Binary files /dev/null and b/website/img/nopic.png differ diff --git a/website/index.php b/website/index.php index ed60d1a..c0b94ad 100644 --- a/website/index.php +++ b/website/index.php @@ -29,25 +29,25 @@ { $vars["page"] = 'error.html'; } - if (file_exists($cfg["templatepath"].'/pages/'.$vars["page"].'.json')){ - $db = new database($cfg["db"]); - $tmpdata = file_get_contents($cfg["templatepath"].'/pages/'.$vars["page"].'.json'); - try { - $vars["data"] = json_decode($tmpdata,true); - foreach ($vars["data"] as $key => $value) { - if ($value["sql"]){ - if ($value["sqltype"] == "query"){ - $vars["data"][$key] = $db->query($value["sql"]); - } elseif ($value["sqltype"] == "queryarray"){ - $vars["data"][$key] = $db->queryarray($value["sql"]); - } - } - } - } catch(JsonException $je){ - fwrite(STDERR, "JSON ERROR: ".$je->getMessage()."\n"); - } + // if (file_exists($cfg["templatepath"].'/pages/'.$vars["page"].'.json')){ + // $db = new database($cfg["db"]); + // $tmpdata = file_get_contents($cfg["templatepath"].'/pages/'.$vars["page"].'.json'); + // try { + // $vars["data"] = json_decode($tmpdata,true); + // foreach ($vars["data"] as $key => $value) { + // if ($value["sql"]){ + // if ($value["sqltype"] == "query"){ + // $vars["data"][$key] = $db->query($value["sql"]); + // } elseif ($value["sqltype"] == "queryarray"){ + // $vars["data"][$key] = $db->queryarray($value["sql"]); + // } + // } + // } + // } catch(JsonException $je){ + // fwrite(STDERR, "JSON ERROR: ".$je->getMessage()."\n"); + // } - } + // } $vars["page"] = 'pages/'.$vars["page"]; $m = new Mustache_Engine(array( 'loader' => new Mustache_Loader_FilesystemLoader($cfg["templatepath"]), @@ -58,7 +58,8 @@ 'entity_flags' => ENT_HTML5 )); - + $fpinfo = pathinfo($vars["page"]); + $vars["pagescript"] = $fpinfo['filename'].".js"; $vars["pagedata"] = $m->render($vars["page"],$vars); $vars["version"] = date("YmdHis"); $mainsite = $m->render('index.html',$vars); diff --git a/website/js/index.js b/website/js/index.js index 528feae..87220fe 100644 --- a/website/js/index.js +++ b/website/js/index.js @@ -1,37 +1,50 @@ -if ('serviceWorker' in navigator) { - navigator.serviceWorker - .register('./js/sw.js'); -} +// if ('serviceWorker' in navigator) { +// navigator.serviceWorker +// .register('./js/sw.js'); +// } -let deferredPrompt; -const addBtn = document.querySelector('.add-button'); -addBtn.style.display = 'none'; +// let deferredPrompt; +// const addBtn = document.querySelector('.add-button'); +// addBtn.style.display = 'none'; -window.addEventListener('beforeinstallprompt', (e) => { -// Prevent Chrome 67 and earlier from automatically showing the prompt -e.preventDefault(); -// Stash the event so it can be triggered later. -deferredPrompt = e; -// Update UI to notify the user they can add to home screen -addBtn.style.display = 'block'; +// window.addEventListener('beforeinstallprompt', (e) => { +// // Prevent Chrome 67 and earlier from automatically showing the prompt +// e.preventDefault(); +// // Stash the event so it can be triggered later. +// deferredPrompt = e; +// // Update UI to notify the user they can add to home screen +// addBtn.style.display = 'block'; -addBtn.addEventListener('click', (e) => { - // hide our user interface that shows our A2HS button - addBtn.style.display = 'none'; - // Show the prompt - deferredPrompt.prompt(); - // Wait for the user to respond to the prompt - deferredPrompt.userChoice.then((choiceResult) => { - if (choiceResult.outcome === 'accepted') { - console.log('User accepted the A2HS prompt'); - } else { - console.log('User dismissed the A2HS prompt'); - } - deferredPrompt = null; - }); -}); -}); +// addBtn.addEventListener('click', (e) => { +// // hide our user interface that shows our A2HS button +// addBtn.style.display = 'none'; +// // Show the prompt +// deferredPrompt.prompt(); +// // Wait for the user to respond to the prompt +// deferredPrompt.userChoice.then((choiceResult) => { +// if (choiceResult.outcome === 'accepted') { +// console.log('User accepted the A2HS prompt'); +// } else { +// console.log('User dismissed the A2HS prompt'); +// } +// deferredPrompt = null; +// }); +// }); +// }); function initpage(){ - + index.init(); +} + +let index= { + init: function(){ + postData({"cl":"webpage","fn":"getsections","page":"index"}).then(data => { + for (var i in data.data){ + if (document.getElementById(i)){ + document.getElementById(i).insertAdjacentHTML('afterbegin', data.data[i]); + } + } + console.log(data); + }); + } } \ No newline at end of file diff --git a/website/lib/database.php b/website/lib/database.php index 80fedb6..c873509 100644 --- a/website/lib/database.php +++ b/website/lib/database.php @@ -22,7 +22,7 @@ class database { if (($text == "") || ($text == null)){ return 'null'; } - return "'".$text."'"; + return "'".$this->securetext($text)."'"; } public function query($sql){ @@ -32,7 +32,10 @@ class database { } try { if ($this->conn){ - return $this->conn->query($sql); + $sth = $this->conn->prepare($sql); + $sth->execute(); + $result = $sth->fetch(PDO::FETCH_ASSOC); + return $result; } } catch(PDOException $e){ error_log("QUERY ERROR: ".$sql); @@ -87,7 +90,7 @@ class database { } try { if ($this->conn){ - return $this->exec($sql); + return $this->conn->exec($sql); } } catch (PDOException $e){ error_log("EXEC ERROR: ".$sql); @@ -95,6 +98,30 @@ class database { return -1; } + public function createUpdateDDL($schema,$table,$idents,$data){ + $da = array(); + $di = array(); + foreach ($data as $col => $val){ + array_push($da,$col."=".$this->value($val)); + } + foreach ($idents as $col => $val){ + array_push($di,$col."=".$this->value($val)); + } + $updsql = "UPDATE ".$schema.".".$table." SET ".join(",",$da)." WHERE ".join(" AND ",$di).";"; + return $updsql; + } + + public function createInsertDDL($schema,$table,$data){ + $dc = array(); + $dv = array(); + foreach ($data as $col => $val){ + array_push($dc,$col); + array_push($dv,$this->value($val)); + } + $inssql = "INSERT INTO ".$schema.".".$table." (".join(",",$dc).") VALUES (".join(",",$dv).");"; + return $inssql; + } + public function newuuid(){ $nid = $this->query("SELECT uuid_in(md5(random()::text || clock_timestamp()::text)::cstring) as id"); return $nid["id"]; diff --git a/website/lib/modules/Gallery.php b/website/lib/modules/Gallery.php index 9e50806..636c999 100644 --- a/website/lib/modules/Gallery.php +++ b/website/lib/modules/Gallery.php @@ -1,5 +1,5 @@ dbh = $dblink; diff --git a/website/lib/modules/Shop.php b/website/lib/modules/Shop.php index e2d6c8e..dcd772c 100644 --- a/website/lib/modules/Shop.php +++ b/website/lib/modules/Shop.php @@ -1,5 +1,5 @@ dbh = $dblink; diff --git a/website/lib/modules/WebArticles.php b/website/lib/modules/WebArticles.php index e80e3ce..10d4fb5 100644 --- a/website/lib/modules/WebArticles.php +++ b/website/lib/modules/WebArticles.php @@ -1,5 +1,5 @@ dbh = $dblink; diff --git a/website/lib/modules/webpage.php b/website/lib/modules/webpage.php new file mode 100644 index 0000000..e6390ca --- /dev/null +++ b/website/lib/modules/webpage.php @@ -0,0 +1,39 @@ +dbh = $dblink; + $this->cfg = $cfg; + } + public function __destruct(){ + $this->dbh = null; + } + + public function getsections($page){ + $sections = $this->dbh->queryarray("select * from sections where page=".$this->dbh->value($page).";"); + $retsections = array(); + $m = new Mustache_Engine(array( + 'loader' => new Mustache_Loader_FilesystemLoader($this->cfg["templatepath"].'/sections'), + 'partials_loader' => new Mustache_Loader_FilesystemLoader($this->cfg["templatepath"].'/blocks'), + 'escape' => function($value) { + return $value; + }, + 'entity_flags' => ENT_HTML5 + )); + + foreach ($sections as $key => $value){ + if (file_exists($this->cfg["templatepath"].'/sections/'.$value["templatefile"].'.html.mustache')){ + $sdata = $this->dbh->query("select * from ".$value["datatable"]." where id=".$this->dbh->value($value["id_data"]).";"); + $data["version"] = date("YmdHis"); + //error_log("sdata: ".print_r($sdata,true)); + $retsections[$value["id_section"]] = $m->render($value["templatefile"].'.html',$sdata); + + } + } + //error_log("sdata: ".print_r($retsections,true)); + return $retsections; + } +} + +?> \ No newline at end of file diff --git a/website/tmpl/index.html.mustache b/website/tmpl/index.html.mustache index 410381a..659994d 100644 --- a/website/tmpl/index.html.mustache +++ b/website/tmpl/index.html.mustache @@ -30,8 +30,6 @@ - @@ -43,9 +41,8 @@
- + diff --git a/website/tmpl/pages/index.html.mustache b/website/tmpl/pages/index.html.mustache index 221ba46..48e8324 100644 --- a/website/tmpl/pages/index.html.mustache +++ b/website/tmpl/pages/index.html.mustache @@ -3,120 +3,26 @@
logo oldbell
Marc de Barbir
Haircuts & Shaves
For Men
-
-
-
-
-
-   -
- -
-   -
-
- +
+
+
-
-
- -
- -
- - Suggestions - -
-
-
- +
-
- -
- -
- -
- - Videos - -
-
-
+
+
-
+
-
-  Events +
+ + +
+ +
+
+
+
+
-
-
+
installer App
Salon
@@ -224,5 +85,3 @@
facebook
- - diff --git a/website/tmpl/sections/galleries_preview.html.mustache b/website/tmpl/sections/galleries_preview.html.mustache new file mode 100644 index 0000000..daee2be --- /dev/null +++ b/website/tmpl/sections/galleries_preview.html.mustache @@ -0,0 +1,14 @@ + +
+ +
+ + + + {{gallery}} + + + +
+
+
\ No newline at end of file