--- /tmp/dsg/dolibarr/htdocs/website/samples/github_19.0.3_wrapper.php +++ /tmp/dsg/dolibarr/htdocs/website/samples/client_wrapper.php @@ -2 +1,0 @@ - @@ -5,6 +4,2 @@ -if (strpos($_SERVER["PHP_SELF"], 'website/samples/wrapper.php')) { - die("Sample file for website module. Can't be called directly."); -} -if (!defined('USEDOLIBARRSERVER') && !defined('USEDOLIBARREDITOR')) { - require_once './master.inc.php'; -} // Load master if not already loaded +if (strpos($_SERVER["PHP_SELF"], 'website/samples/wrapper.php')) die("Sample file for website module. Can be called directly."); +if (!defined('USEDOLIBARRSERVER') && !defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load master if not already loaded @@ -18 +13 @@ -$entity = GETPOST('entity', 'int') ? GETPOST('entity', 'int') : $conf->entity; +$entity = GETPOST('entity', 'int') ?GETPOST('entity', 'int') : $conf->entity; @@ -25,3 +20 @@ -if ($rss) { - $original_file = 'blog.rss'; -} +if ($rss) $original_file = 'blog.rss'; @@ -30 +23,2 @@ -if (!empty($hashp)) { +if (!empty($hashp)) +{ @@ -34 +28,2 @@ - if ($result > 0) { + if ($result > 0) + { @@ -37 +32,2 @@ - if (is_numeric($tmp[0])) { // If first tmp is numeric, it is subdir of company for multicompany, we take next part. + if (is_numeric($tmp[0])) // If first tmp is numeric, it is subdir of company for multicompany, we take next part. + { @@ -42,2 +38,4 @@ - if ($modulepart) { // Not required, so often not defined, for link using public hashp parameter. - if ($moduleparttocheck == $modulepart) { + if ($modulepart) // Not required, so often not defined, for link using public hashp parameter. + { + if ($moduleparttocheck == $modulepart) + { @@ -47 +45,3 @@ - } else { + } + else + { @@ -50 +50,3 @@ - } else { + } + else + { @@ -54 +56,3 @@ - } else { + } + else + { @@ -62,9 +66,3 @@ -if (preg_match('/\.(html|htm)$/i', $original_file)) { - $attachment = false; -} -if (isset($_GET["attachment"])) { - $attachment = (GETPOST("attachment", 'alphanohtml') ? true : false); -} -if (getDolGlobalString('MAIN_DISABLE_FORCE_SAVEAS_WEBSITE')) { - $attachment = false; -} +if (preg_match('/\.(html|htm)$/i', $original_file)) $attachment = false; +if (isset($_GET["attachment"])) $attachment = GETPOST("attachment", 'none') ?true:false; +if (!empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS_WEBSITE)) $attachment = false; @@ -74,5 +72,2 @@ -if (GETPOSTISSET('type')) { - $type = GETPOST('type', 'alpha'); -} else { - $type = dol_mimetype($original_file); -} +if (GETPOSTISSET('type')) $type = GETPOST('type', 'alpha'); +else $type = dol_mimetype($original_file); @@ -84 +79,2 @@ -if (GETPOST("cache", 'aZ09') || image_format_supported($original_file) >= 0) { +if (GETPOST("cache", 'none') || image_format_supported($original_file) >= 0) +{ @@ -108,4 +104,2 @@ - $filters = array('type_container'=>'blogpost', 'status'=>1); - if ($l) { - $filters['lang'] = $l; - } + $filters = array('type_container'=>'blogpost'); + if ($l) $filters['lang'] = $l; @@ -130 +124,2 @@ - if (!$filename) { + if (!$filename) + { @@ -143 +138,2 @@ - if ($cachedelay) { + if ($cachedelay) + { @@ -146 +142,2 @@ - if (dol_filemtime($outputfile) > ($nowgmt - $cachedelay)) { + if (dol_filemtime($outputfile) > ($nowgmt - $cachedelay)) + { @@ -152,5 +149,4 @@ - if ($buildfile) { - $outputlangs = new Translate('', $conf); - $outputlangs->setDefaultLang($l); - $outputlangs->loadLangs(array("main", "other")); - $title = $desc = $outputlangs->transnoentities('LatestBlogPosts'); + if ($buildfile) + { + $langs->load("other"); + $title = $desc = $langs->transnoentities('LatestBlogPosts'); @@ -160 +156 @@ - dolChmod($outputfiletmp); + @chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK)); @@ -165,4 +161,5 @@ - if ($result >= 0) { - if (dol_move($outputfiletmp, $outputfile, 0, 1, 0, 0)) { - $result = 1; - } else { + if ($result >= 0) + { + if (dol_move($outputfiletmp, $outputfile, 0, 1)) $result = 1; + else + { @@ -175 +172,3 @@ - } else { + } + else + { @@ -184 +183,2 @@ - if ($result >= 0) { + if ($result >= 0) + { @@ -186,3 +186 @@ - if (isset($_GET["attachment"])) { - $attachment = $_GET["attachment"]; - } + if (isset($_GET["attachment"])) $attachment = $_GET["attachment"]; @@ -191,3 +189 @@ - if (isset($_GET["contenttype"])) { - $contenttype = $_GET["contenttype"]; - } + if (isset($_GET["contenttype"])) $contenttype = $_GET["contenttype"]; @@ -197,6 +193,2 @@ - if ($contenttype) { - header('Content-Type: '.$contenttype.($outputencoding ? '; charset='.$outputencoding : '')); - } - if ($attachment) { - header('Content-Disposition: attachment; filename="'.$filename.'"'); - } + if ($contenttype) header('Content-Type: '.$contenttype.($outputencoding ? '; charset='.$outputencoding : '')); + if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); @@ -207,5 +199,2 @@ - if ($cachedelay) { - header('Cache-Control: max-age='.$cachedelay.', private, must-revalidate'); - } else { - header('Cache-Control: private, must-revalidate'); - } + if ($cachedelay) header('Cache-Control: max-age='.$cachedelay.', private, must-revalidate'); + else header('Cache-Control: private, must-revalidate'); @@ -216,3 +205 @@ - if (!$result) { - print 'File '.$outputfile.' was empty.'; - } + if (!$result) print 'File '.$outputfile.' was empty.'; @@ -223,2 +210,4 @@ -} elseif ($modulepart == "mycompany" && preg_match('/^\/?logos\//', $original_file)) { - // Get logos +} +// Get logos +elseif ($modulepart == "mycompany" && preg_match('/^\/?logos\//', $original_file)) +{ @@ -226 +215,3 @@ -} else { +} +else +{ @@ -229,5 +220,6 @@ - $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, null, $refname); - $accessallowed = empty($check_access['accessallowed']) ? '' : $check_access['accessallowed']; - $sqlprotectagainstexternals = empty($check_access['sqlprotectagainstexternals']) ? '' : $check_access['sqlprotectagainstexternals']; - $fullpath_original_file = empty($check_access['original_file']) ? '' : $check_access['original_file']; // $fullpath_original_file is now a full path name - if ($hashp) { + $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, $refname); + $accessallowed = $check_access['accessallowed']; + $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; + $fullpath_original_file = $check_access['original_file']; // $fullpath_original_file is now a full path name + if ($hashp) + { @@ -240 +232,2 @@ - if (!$accessallowed) { + if (!$accessallowed) + { @@ -254,2 +247,3 @@ - if (!file_exists($fullpath_original_file_osencoded)) { - print "ErrorFileDoesNotExists: ".dol_escape_htmltag($original_file); + if (!file_exists($fullpath_original_file_osencoded)) + { + print "ErrorFileDoesNotExists: ".$original_file; @@ -263,3 +257 @@ - if ($encoding) { - header('Content-Encoding: '.$encoding); - } + if ($encoding) header('Content-Encoding: '.$encoding); @@ -267,5 +259,2 @@ - if ($attachment) { - header('Content-Disposition: attachment; filename="'.$filename.'"'); - } else { - header('Content-Disposition: inline; filename="'.$filename.'"'); - } + if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); + else header('Content-Disposition: inline; filename="'.$filename.'"'); @@ -276,3 +265 @@ -if (is_object($db)) { - $db->close(); -} +if (is_object($db)) $db->close();