and they are evaluated, and php inserts done as required require_once ZDEF_PATH_TO_LIBRARY . 'org.global.functions.inc.php'; ob_start(); if(defined('FORCE_FULL_GENERATE_FOR_CDN') || !ZDEF_XHR_GET_PAGE){ ?>
'; } if(defined('PASSED_LOGIN_AUTH') && JENISYS==1 && !defined('FORCE_FULL_GENERATE_FOR_CDN')){ echo '
'; dbSel($db,ZDEF_DATA_DB_NAME,'ssv21a');// select the 'data' data base require ZDEF_PATH_TO_LIBRARY.'jenisys/jenisys.controls.php'; require ZDEF_PATH_TO_LIBRARY.'jenisys/jenisys.message.center.php'; require ZDEF_PATH_TO_LIBRARY.'jenisys/resource.panel.php'; if(SITE_HAS_OUTAGE_MAPS==1){ require ZDEF_PATH_TO_LIBRARY.'outage.maps/outage.panel.php'; } echo '
'; } // ============== Define which webpage fn we will load $webpage=ZDEF_PATH_TO_WEBPAGE_SOURCE; $a=explode('/',$webpage); // === get rid of any page and page number $i = array_search('page',$a); if($i!==false) { $a=array_slice($a, 0, $i); $webpage=implode('/',$a).'.inc.php'; } if(!file_exists($webpage)){ if(SITE_TEST_MODE==1 || FLAG_FORCEVARS===SITE_TEST_FLAG_PW){ echo getcwd(); echo ' (from generateHTML) body path was '.$webpage.' '; echo PHP_EOL . 'ZDEF_PATH_TO_WEBPAGE_SOURCE '.ZDEF_PATH_TO_WEBPAGE_SOURCE; echo PHP_EOL . 'ZDEF_HUB_HANDLE '.ZDEF_HUB_HANDLE.' ORG_HANDLE '.ORG_HANDLE; echo PHP_EOL . str_repeat('ERR ',2000);ob_flush();flush();die; } if(!defined('WEBPAGE_NOT_FOUND'))define('WEBPAGE_NOT_FOUND',1); } require_once 'jenisys/insert.PHP.markers.inc.php'; // ================================================================================================================================== // ================ Produce webpage HTML ====================== // generate breadcrumbs if required $breadcrumbs=''; if(ORG_SHOW_BREADCRUMBS && JENISYS_PARM_IS_APP != 1){// no breadcrumbs needed in app versions if(ZDEF_ON_HOME_PAGE==1){ $breadcrumbs.= ''; }else{ $breadcrumbs.= ''; } } // get the item section header code if a section exists $sectionHeader=''; if(WEBPAGE_ITEMDEF_ID!=0){// get the item section header code if a section exists and we're not on the item directory $fn=ZDEF_PATH_TO_SUBDOMAIN.'published/'.WEBPAGE_ITEM_TYPE.'/~~'.WEBPAGE_ITEM_TYPE.'.header.inc.php'; if(file_exists($fn)){ $sectionHeader = getParsedHTML($db,$fn); } } // get webpage contents and strip
tags $webpageHTML=getParsedHTML($db,$webpage); $start=strpos($webpageHTML, ''); if($end < $start){ echo('generateHTML 23809fj: Webpage Contents HTML malformed, contains tag or php before
',$mainContent)[0]; // get section footer if it exists $sectionFooter=''; if(WEBPAGE_ITEMDEF_ID!=0){// get the item section header code if a section exists and we're not on the item directory $fn=ZDEF_PATH_TO_SUBDOMAIN.'published/'.WEBPAGE_ITEM_TYPE.'/~~'.WEBPAGE_ITEM_TYPE.'.footer.inc.php'; if(file_exists($fn)){ $sectionFooter = getParsedHTML($db,$fn); } } // assemble html in
$webpageHTML=$openingMainTag.$breadcrumbs.$sectionHeader.$mainContent.$sectionFooter.'
'; // This contains all html in
INCLUDING breadcrumbs, section header, page content, section footer $fn=ZDEF_PATH_TO_HUB.'tmp/temp.html'; file_put_contents($fn,$webpageHTML); require $fn; // (do not use require_once) // writing and requiring HTML is safer than eval() unlink($fn); if(defined('FORCE_FULL_GENERATE_FOR_CDN') || !ZDEF_XHR_GET_PAGE){ if( !WEBPAGE_IS_LANDING_PAGE && !JENISYS_PARM_IS_APP ){ $foot = (WEBPAGE_SERVE_FROM_SHARED_DOMAIN?ZDEF_PATH_TO_HUB_ROOT.ORG_HANDLE.'/':ZDEF_PATH_TO_SUBDOMAIN).'source/gbl/foot.inc.php'; // if WEBPAGE_SERVE_FROM_SHARED_DOMAIN then ZDEF_PATH_TO_SUBDOMAIN is the sharing domain. Footer always comes from the current domain if(!file_exists($foot))STErr(' Footer not Found: '.$foot); include $foot; if(ORG_PRIVACY_POPUP!=='')require ZDEF_PATH_TO_SUBDOMAIN.'published/'.ORG_PRIVACY_POPUP; } echo '
'; echo '';/* closes wpg */ } $output=ob_get_clean(); /* *********** Modify all imgs. Change src by replacing with blank base 64 image and storing the img src in data-src so we can use javascript to send requests for the correct image size*/ //preg_match_all('/]*class="[^"]*img_[^"]*"[^>]*>\s*]+>\s*<\/picture>/i', $output, $matches); preg_match_all('/(]*>)/i', $output, $matches); if(!defined('DATAIMG')){ // on a publish generateHTML is required twice define('DATAIMG','data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/wcAAwAB/0PdR6kAAAAASUVORK5CYII='); } foreach ($matches[0] as $imgTag) { preg_match('/src="([^"]+)"/i', $imgTag, $srcMatch); if (isset($srcMatch[1])) { $src = $srcMatch[1]; if( (strpos($src,"https://".ORG_CDN_ORIGINALS_URL) === 0 || strpos($src,"https://") === false ) ) { // on domain image (OFF DOMAIN IMAGES NOT ALLOWED) $newImgTag = defined('FORCE_FULL_GENERATE_FOR_CDN') && FORCE_FULL_GENERATE_FOR_CDN ? $imgTag :str_replace($srcMatch[0], 'src= "'.DATAIMG.'" data-src="'.$src.'"', $imgTag); $row=[]; // create image data-max using the dimensions of the ORIGINAL image from the resource table. Data-max is needed for publish to CDN and that script removes it $sql='SELECT resource_extension, resource_image_width, resource_image_height, resource_focus FROM resource WHERE resource_active = 1 AND resource_server_name = \''.dbEsc($db,$src).'\' AND resource$org_id = '.ORG_ID; $r=dbQry($db,$sql,'genh3894'); if(dbNR($r)>0){ $row=dbRN($r); if(strtolower($row['resource_extension']) != 'svg'){ // create a data-max tag from resource_image_width, resource_image_height, using 10000x10000 for svg which doesn't have either $imgWidth = !empty($row['resource_image_width']) ? (string) round((float) $row['resource_image_width']) : '10000'; $imgHeight = !empty($row['resource_image_height']) ? (string) round((float) $row['resource_image_height']) : '10000'; $newImgTag = preg_replace(['/\\s*data-max="[^"]*"/', '/ tags preg_match_all('/.*?<\/video>/is', $output, $matches); foreach ($matches[0] as $match) { $dom = new DOMDocument(); libxml_use_internal_errors(true); // Wrap match with a generic root element $dom->loadHTML('
' . $match . '
', LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); libxml_clear_errors(); $videoElements = $dom->getElementsByTagName('video'); if($videoElements->length == 0){ continue; // something wrong with the parsing } foreach ($videoElements as $videoElement) { foreach ($videoElement->getElementsByTagName('source') as $sourceElement) { if ($sourceElement->hasAttribute('src')) { $srcValue = $sourceElement->getAttribute('src'); $sourceElement->setAttribute('data-src', $srcValue); $sourceElement->setAttribute('src', ''); // Clear original src } } $modifiedVideoHtml = $dom->saveHTML($videoElement); $output = str_replace($match, $modifiedVideoHtml, $output); } } return $output; } function getParsedHTML($db, $fn){ // get the content of a file without executing its php, add php markers to content as required, write and require the content to execute the php, return the resulting content //$db is passed because it may be needed in required code $contents = file_get_contents($fn); if (strpos($contents, '