{ updatetemplate_print_error_page($template_un, construct_phrase($vbphrase['template_eval_error'], fetch_error_array($errors))); exit; } $errors = check_template_errors($vbulletin->GPC['template']); if (!empty($errors)) { updatetemplate_print_error_page($template_un, construct_phrase($vbphrase['template_eval_error'], fetch_error_array($errors))); exit; } $errors = check_template_conflict_error($vbulletin->GPC['template']); if (!empty($errors)) { updatetemplate_print_error_page($template_un, $errors); exit; } } $old_template = $db->query_first(" SELECT title, styleid, dateline, username, template_un FROM " . TABLE_PREFIX . "template WHERE templateid = " . $vbulletin->GPC['templateid'] . " "); if (strtolower($vbulletin->GPC['title']) != strtolower($old_template['title']) AND $db->query_first(" SELECT templateid FROM " . TABLE_PREFIX . "template WHERE styleid = $old_template[styleid] AND title = '" . $db->escape_string($vbulletin->GPC['title']) . "' ")) {
if ($_POST['do'] == 'updatetemplate') { if (!vB::getUserContext()->hasAdminPermission('canadmintemplates')) { print_cp_no_permission(); } $vbulletin->input->clean_array_gpc('p', array('title' => vB_Cleaner::TYPE_STR, 'oldtitle' => vB_Cleaner::TYPE_STR, 'template' => vB_Cleaner::TYPE_NOTRIM, 'group' => vB_Cleaner::TYPE_STR, 'product' => vB_Cleaner::TYPE_STR, 'savehistory' => vB_Cleaner::TYPE_BOOL, 'histcomment' => vB_Cleaner::TYPE_STR, 'string' => vB_Cleaner::TYPE_STR, 'searchstring' => vB_Cleaner::TYPE_STR, 'expandset' => vB_Cleaner::TYPE_NOHTML, 'searchset' => vB_Cleaner::TYPE_NOHTML, 'return' => vB_Cleaner::TYPE_STR, 'confirmerrors' => vB_Cleaner::TYPE_BOOL, 'confirmremoval' => vB_Cleaner::TYPE_BOOL, 'lastedit' => vB_Cleaner::TYPE_UINT, 'hash' => vB_Cleaner::TYPE_STR, 'fromeditconflict' => vB_Cleaner::TYPE_BOOL, 'textonly' => vB_Cleaner::TYPE_BOOL, 'windowScrollTop' => vB_Cleaner::TYPE_UINT, 'textareaScrollTop' => vB_Cleaner::TYPE_UINT)); handle_vbulletin_copyright_removal($vbulletin->GPC, 'updatetemplate'); try { vB_Api::instanceInternal('template')->update($vbulletin->GPC['templateid'], $vbulletin->GPC['title'], $vbulletin->GPC['template'], $vbulletin->GPC['product'], false, $vbulletin->GPC['savehistory'], $vbulletin->GPC['histcomment'], !empty($vbulletin->GPC['confirmerrors']), array('textonly' => $vbulletin->GPC['textonly'])); } catch (vB_Exception_Api $e) { $errors = $e->get_errors(); $error = $errors[0]; if ($error == 'edit_conflict') { $updatetemplate_edit_conflict = true; } else { if ($error[0] == 'template_eval_error' or $error[0] == 'template_compile_error') { updatetemplate_print_error_page($vbulletin->GPC['template'], construct_phrase($vbphrase['template_eval_error'], fetch_error_array($error[1]))); exit; } else { print_stop_message2($error[0]); } } } $args = array('templateid' => $vbulletin->GPC['templateid'], 'group' => $vbulletin->GPC['group'], 'expandset' => $vbulletin->GPC['expandset'], 'searchset' => $vbulletin->GPC['searchset'], 'searchstring' => urlencode($vbulletin->GPC['searchstring'])); if ($vbulletin->GPC['return']) { $args['do'] = 'edit'; $args['windowScrollTop'] = $vbulletin->GPC['windowScrollTop']; $args['textareaScrollTop'] = $vbulletin->GPC['textareaScrollTop']; } else { $args['do'] = 'modify'; } if ($vbulletin->GPC['title'] == $vbulletin->GPC['oldtitle']) {