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(); }
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 lxAdEdit() { global $DB, $C; VerifyAdministrator(); $v = new Validator(); $v->Register($_REQUEST['weight'], V_NUMERIC, 'The Weight value must be filled in and numeric'); $v->Register($_REQUEST['raw_clicks'], V_NUMERIC, 'The Raw Clicks value must be filled in and numeric'); $v->Register($_REQUEST['unique_clicks'], V_NUMERIC, 'The Unique Clicks value must be filled in and numeric'); $v->Register($_REQUEST['ad_url'], V_URL, 'The Ad URL is not properly formatted'); $v->Register($_REQUEST['ad_html_raw'], V_EMPTY, 'The Ad HTML value must be filled in'); if (!$v->Validate()) { return $v->ValidationError('lxShAdEdit'); } $t = new Template(); $t->assign_by_ref('ad', $_REQUEST); $t->assign_by_ref('config', $C); $_REQUEST['ad_html'] = $t->parse($_REQUEST['ad_html_raw']); $t->cleanup(); $DB->Update('UPDATE `lx_ads` SET ' . '`ad_url`=?, ' . '`ad_html_raw`=?, ' . '`ad_html`=?, ' . '`weight`=?, ' . '`raw_clicks`=?, ' . '`unique_clicks`=?, ' . '`tags`=? ' . 'WHERE `ad_id`=?', array($_REQUEST['ad_url'], $_REQUEST['ad_html_raw'], $_REQUEST['ad_html'], $_REQUEST['weight'], $_REQUEST['raw_clicks'], $_REQUEST['unique_clicks'], $_REQUEST['tags'], $_REQUEST['ad_id'])); $GLOBALS['message'] = 'Advertisement successfully updated'; $GLOBALS['added'] = true; lxShAdEdit(); }