function BuildPage($page) { global $DB, $C, $L; $GLOBALS['_counters']['thumbnails'] = 0; $GLOBALS['_counters']['galleries'] = 0; $t = new Template(); $t->assign_by_ref('this_page', $page); $t->assign_by_ref('config', $C); $t->assign_by_ref('page_category', $GLOBALS['CATEGORY_CACHE_ID'][$page['category_id']]); $t->assign_by_ref('search_categories', $GLOBALS['CATEGORY_CACHE_TAG']); $t->assign('category', array()); $t->assign('total_galleries', $GLOBALS['_totals']['galleries']); $t->assign('total_thumbnails', $GLOBALS['_totals']['thumbnails']); $t->assign('total_categories', $GLOBALS['_totals']['categories']); $t->assign('page_galleries', '{$galleries}'); $t->assign('page_thumbnails', '{$thumbnails}'); $mode = is_file($page['filename']) ? 'r+' : 'w'; $fd = fopen($page['filename'], $mode); flock($fd, LOCK_EX); // Parse the template $generated = $t->parse_compiled($page['compiled']); $generated = str_replace('{$galleries}', number_format($GLOBALS['_counters']['galleries'], 0, $C['dec_point'], $C['thousands_sep']), $generated); $generated = str_replace('{$thumbnails}', number_format($GLOBALS['_counters']['thumbnails'], 0, $C['dec_point'], $C['thousands_sep']), $generated); fwrite($fd, trim($generated)); fflush($fd); ftruncate($fd, ftell($fd)); flock($fd, LOCK_UN); fclose($fd); @chmod($page['filename'], $C['page_permissions']); $t->cleanup(); unset($fd); unset($generated); unset($t); unset($page); }
function BuildPage($page) { global $DB, $C, $L; $t = new Template(); $t->assign_by_ref('this_page', $page); $t->assign_by_ref('config', $C); $t->assign_by_ref('page_category', $GLOBALS['CATEGORY_CACHE'][$page['category_id']]); $t->assign('total_accounts', $GLOBALS['_total_accounts']); $fd = fopen("{$C['document_root']}/{$page['filename']}", 'w'); flock($fd, LOCK_EX); // Parse the template $generated = $t->parse_compiled($page['compiled']); fwrite($fd, trim($generated)); flock($fd, LOCK_UN); fclose($fd); @chmod("{$C['document_root']}/{$page['filename']}", $C['page_permissions']); $t->cleanup(); }