File: D:/HostingSpaces/PvdBoogaard/indoorski.nl/backup/oude-site/cms/styles.php
<?php
// if the site is down for maintenacne we still want to show js as the admin will still use it
// so ignore the down for maintenanace message for this page load
define('IGNORE_MAINTENANCE', true);
define('IGNORE_INSTALL', true);
define('IN_CONTROL_PANEL', true);
require_once(dirname(__FILE__) . '/api/iwp.php');
header('Content-Type: text/css');
$iwp = IWP::Init('basic,outputbuffer,language,whitelabel,functions', true);
function SendCacheHeaders($LastModifiedDate) {
if ($LastModifiedDate) {
//die('Date: '.$LastModifiedDate);
header('Expires: '.gmdate("D, d M Y H:i:s \G\M\T",time()+864000));
if ((isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $LastModifiedDate)) {
$date = gmdate("D, d M Y H:i:s \G\M\T",$LastModifiedDate);
header('Last-Modified: '.$date, true, 304);
exit;
} else {
$date = gmdate("D, d M Y H:i:s \G\M\T",$LastModifiedDate);
header('Last-Modified: '.$date, true, 200);
}
}
}
/**
* This function is used within the module CSS code to reference an image within the module
* It first checks to see if the currently selected template has the image in particular that it wants to use instead of the module's default.
* If there is none, it will return the path to the module's default image.
*
* @param string $imageName This is the name of the image to perform the check with.
*/
function GetModuleImagePath($imageName){
$moduleName = iwp_template::getInstance()->Get('currentModule');
if(file_exists(IWP_BASE_PATH . '/templates/' . iwp_config::Get('template') . '/modules/' . $moduleName . '/images/' . $imageName)){
return iwp_config::Get('appPath') . 'templates/' . iwp_config::Get('template') . '/modules/' . $moduleName . '/images/' . $imageName;
}
return iwp_config::Get('appPath') . 'modules/' . $moduleName . '/images/' . $imageName;
}
/**
* This function is used within the module CSS code to reference an image within the template from a module or a template's module override style
* Its useful to force the use of a template image.
*
* @param string $imageName This is the name of the image to perform the check with.
*/
function GetTemplateImagePath($imageName){
$moduleName = iwp_template::getInstance()->Get('currentModule');
if(file_exists(IWP_BASE_PATH . '/templates/' . iwp_config::Get('template') . '/images/' . $imageName)){
return iwp_config::Get('appPath') . 'templates/' . iwp_config::Get('template') . '/images/' . $imageName;
}
return '';
}
if (iwp_config::Get('AllowTestingCommands') && isset($_GET['tpl'])) {
// change the template by name only, do not save the config
iwp_config::Set('template', $_GET['tpl']);
}
$cacheId = "stylescache";
$cache = new iwp_cache();
$cache->SetDir('modules');
$forceRefresh = false;
$modules = iwp_modules::getInstance();
if(file_exists($cache->GetFullFileName($cacheId))){
$oldTime = filemtime($cache->GetFullFileName($cacheId));
}else{
$oldTime = 0;
}
$commonFile = IWP_BASE_PATH . '/styles/common.css';
if (file_exists($commonFile) && @filemtime($commonFile) > $oldTime) {
$forceRefresh = true;
}
foreach($modules->ModuleList() as $moduleName){
$tplFile = IWP_BASE_PATH . '/templates/' . iwp_config::Get('template') . '/modules/' . $moduleName . '/templates/styles.css';
$moduleFile = IWP_MODULES_PATH . '/' . $moduleName . '/templates/styles.css';
if(file_exists($tplFile)){
if(filemtime($tplFile) > $oldTime) {
$forceRefresh = true;
break;
}
}elseif(file_exists($moduleFile)){
if(filemtime($moduleFile) > $oldTime) {
$forceRefresh = true;
break;
}
}
}
$lastModified = 0;
if($cache->HasExpired($cacheId) || $forceRefresh){
$returnCss = '';
if (file_exists($commonFile) && $thisCss = @file_get_contents($commonFile)) {
$returnCss .= "\n\n/********* Common CSS *********/\n\n" . $iwp->template->ParseInput($thisCss);
}
foreach($modules->ModuleList() as $moduleName){
$module = $modules->GetModule($moduleName);
$iwp->template->Assign('currentModule', $moduleName);
$tplFile = IWP_BASE_PATH . '/templates/' . iwp_config::Get('template') . '/modules/' . $moduleName . '/templates/styles.css';
$moduleFile = IWP_MODULES_PATH . '/' . $moduleName . '/templates/styles.css';
if (file_exists($moduleFile)) {
if ($thisCss = file_get_contents($moduleFile)) {
$returnCss .= "\n\n/********* Module: ".$moduleName." (base) *********/\n\n" . $iwp->template->ParseInput($thisCss);
}
}
if (file_exists($tplFile)) {
if ($thisCss = file_get_contents($tplFile)) {
$returnCss .= "\n\n/********* Module: ".$moduleName." (template: ". iwp_config::Get('template') .") *********/\n\n" . $iwp->template->ParseInput($thisCss);
}
}
}
$cache->WriteCache($cacheId, $returnCss);
$lastModified = time();
} else {
$lastModified = filemtime($cache->GetFullFileName($cacheId));
$returnCss = $cache->ReadCache($cacheId);
}
SendCacheHeaders($lastModified);
echo $returnCss;