diff --git a/htdocs/admin/websites.php b/htdocs/admin/websites.php index ee75a811347..f4eddfbf092 100644 --- a/htdocs/admin/websites.php +++ b/htdocs/admin/websites.php @@ -114,7 +114,7 @@ $tabfieldcheck[1] = array(); $elementList = array(); $sourceList=array(); -// Actions add or modify an entry into a dictionary +// Actions add or modify a website if (GETPOST('actionadd','alpha') || GETPOST('actionmodify','alpha')) { $listfield=explode(',',$tabfield[$id]); @@ -133,7 +133,7 @@ if (GETPOST('actionadd','alpha') || GETPOST('actionmodify','alpha')) $fieldnamekey=$listfield[$f]; setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); } - if ($value == 'ref' && (preg_match('/[a-zA-Z0-9]/', $_POST[$value]))) + if ($value == 'ref' && ! preg_match('/^[a-z0-9]+$/i', $_POST[$value])) { $ok=0; $fieldnamekey=$listfield[$f]; @@ -141,6 +141,12 @@ if (GETPOST('actionadd','alpha') || GETPOST('actionmodify','alpha')) } } + // Clean parameters + if (! empty($_POST['ref'])) + { + $websitekey=strtolower($_POST['ref']); + } + // Si verif ok et action add, on ajoute la ligne if ($ok && GETPOST('actionadd','alpha')) { @@ -160,6 +166,12 @@ if (GETPOST('actionadd','alpha') || GETPOST('actionmodify','alpha')) } } + /* $website=new Website($db); + $website->ref= + $website->description= + $website->virtualhost= + $website->create($user); */ + // Add new entry $sql = "INSERT INTO ".$tabname[$id]." ("; // List of fields @@ -178,6 +190,9 @@ if (GETPOST('actionadd','alpha') || GETPOST('actionmodify','alpha')) if ($value == 'entity') { $_POST[$listfieldvalue[$i]] = $conf->entity; } + if ($value == 'ref') { + $_POST[$listfieldvalue[$i]] = strtolower($_POST[$listfieldvalue[$i]]); + } if ($i) $sql.=","; if ($_POST[$listfieldvalue[$i]] == '') $sql.="null"; else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'"; @@ -189,6 +204,29 @@ if (GETPOST('actionadd','alpha') || GETPOST('actionmodify','alpha')) $result = $db->query($sql); if ($result) // Add is ok { + global $dolibarr_main_data_root; + $pathofwebsite=$dolibarr_main_data_root.'/websites/'.$websitekey; + $filehtmlheader=$pathofwebsite.'/htmlheader.html'; + $filecss=$pathofwebsite.'/styles.css.php'; + $filetpl=$pathofwebsite.'/page'.$pageid.'.tpl.php'; + $fileindex=$pathofwebsite.'/index.php'; + + // Css file + $csscontent = ''."\n"; + $csscontent.= ''."\n"; + $csscontent.= '"."\n"; + $csscontent.= ''."\n"; + $csscontent.= 'body { margin: 0; }'."\n"; + + dol_syslog("Save file css into ".$filecss); + + dol_mkdir($pathofwebsite); + $result = file_put_contents($filecss, $csscontent); + if (! empty($conf->global->MAIN_UMASK)) + @chmod($filecss, octdec($conf->global->MAIN_UMASK)); + setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); unset($_POST); // Clean $_POST array, we keep only } diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index 3a03c16a17c..b937337e95c 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -130,7 +130,7 @@ if ($pageid > 0 && $action != 'add') global $dolibarr_main_data_root; $pathofwebsite=$dolibarr_main_data_root.'/websites/'.$website; -$filehtmlheader=$pathofwebsite.'/header.html'; +$filehtmlheader=$pathofwebsite.'/htmlheader.html'; $filecss=$pathofwebsite.'/styles.css.php'; $filetpl=$pathofwebsite.'/page'.$pageid.'.tpl.php'; $fileindex=$pathofwebsite.'/index.php'; @@ -433,7 +433,7 @@ if ($action == 'updatemeta') $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; - $tplcontent.= 'ref.'/header.html"); ?>'."\n"; + $tplcontent.= 'ref.'/htmlheader.html"); ?>'."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; @@ -592,7 +592,7 @@ if ($action == 'updatecontent' || ($action == 'preview' && (GETPOST('refreshsite $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; - $tplcontent.= 'ref.'/header.html"); ?>'."\n"; + $tplcontent.= 'ref.'/htmlheader.html"); ?>'."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; @@ -845,12 +845,10 @@ if (count($object->records) > 0) { print '   '; - if ($object->fk_default_home > 0 && $pageid == $object->fk_default_home) print ''; - else print ''; print ''; print ''; - //print ''.dol_escape_htmltag($langs->trans("EditPageMeta")).''; - //print ''.dol_escape_htmltag($langs->trans("EditPageContent")).''; + if ($object->fk_default_home > 0 && $pageid == $object->fk_default_home) print ''; + else print ''; print ''; } } @@ -973,7 +971,7 @@ if ($action == 'editcss') // Clean the php css file to remove php code and get only css part $csscontent = preg_replace('//s', '', $csscontent); - if (! trim($csscontent)) $csscontent='/* CSS content (all website) */'; + if (! trim($csscontent)) $csscontent='/* CSS content (all website) */'."\n".'body { margin: 0; }'; $htmlheader = @file_get_contents($filehtmlheader); // Clean the php css file to remove php code and get only html part