function css_edit_raw() { global $event, $step; $default_name = safe_field('css', 'txp_section', "name = 'default'"); extract(gpsa(array('name', 'newname', 'copy', 'savenew'))); if ($step == 'css_delete' || empty($name) && $step != 'pour' && !$savenew) { $name = $default_name; } elseif (($copy || $savenew) && trim(preg_replace('/[<>&"\']/', '', $newname))) { $name = $newname; } if (empty($name)) { $buttons = '<div class="edit-title">' . gTxt('name_for_this_style') . ': ' . fInput('text', 'newname', '', 'edit', '', '', 20) . hInput('savenew', 'savenew') . '</div>'; $thecss = gps('css'); } else { $buttons = '<div class="edit-title">' . gTxt('you_are_editing_css') . sp . strong(htmlspecialchars($name)) . '</div>'; $thecss = fetch("css", 'txp_css', 'name', $name); } if (!empty($name)) { $copy = '<span class="copy-as"><label for="copy-css">' . gTxt('copy_css_as') . '</label>' . sp . fInput('text', 'newname', '', 'edit', '', '', '', '', 'copy-css') . sp . fInput('submit', 'copy', gTxt('copy'), 'smallerbox') . '</span>'; } else { $copy = ''; } $right = '<div id="content_switcher">' . hed(gTxt('all_stylesheets'), 2) . graf(sLink('css', 'pour', gTxt('create_new_css')), ' class="action-create smallerbox"') . css_list($name, $default_name) . '</div>'; echo '<div id="' . $event . '_container" class="txp-container txp-edit">' . startTable('edit') . tr(td(form('<div id="main_content">' . $buttons . '<textarea id="css" class="code" name="css" cols="78" rows="32">' . htmlspecialchars($thecss) . '</textarea>' . br . fInput('submit', '', gTxt('save'), 'publish') . eInput('css') . sInput('css_save') . hInput('name', $name) . $copy . '</div>', '', '', 'post', 'edit-form', '', 'style_form'), '', 'column') . tdtl($right, ' class="column"')) . endTable() . '</div>'; }
/** * The main Page editor panel. * * @param string|array $message The activity message */ function page_edit($message = '') { global $event, $step; pagetop(gTxt('edit_pages'), $message); extract(array_map('assert_string', gpsa(array('copy', 'save_error', 'savenew')))); $name = sanitizeForPage(assert_string(gps('name'))); $newname = sanitizeForPage(assert_string(gps('newname'))); if ($step == 'page_delete' || empty($name) && $step != 'page_new' && !$savenew) { $name = safe_field('page', 'txp_section', "name = 'default'"); } elseif ((($copy || $savenew) && $newname || $newname && $newname != $name) && !$save_error) { $name = $newname; } $buttons = n . tag(gTxt('page_name'), 'label', array('for' => 'new_page')) . br . fInput('text', 'newname', $name, 'input-medium', '', '', INPUT_MEDIUM, '', 'new_page', false, true); if ($name) { $buttons .= span(href(gTxt('duplicate'), '#', array('id' => 'txp_clone', 'class' => 'clone', 'title' => gTxt('page_clone'))), array('class' => 'txp-actions')); } else { $buttons .= hInput('savenew', 'savenew'); } $html = !$save_error ? fetch('user_html', 'txp_page', 'name', $name) : gps('html'); // Format of each entry is popTagLink -> array ( gTxt() string, class/ID). $tagbuild_items = array('page_article' => array('page_article_hed', 'article-tags'), 'page_article_nav' => array('page_article_nav_hed', 'article-nav-tags'), 'page_nav' => array('page_nav_hed', 'nav-tags'), 'page_xml' => array('page_xml_hed', 'xml-tags'), 'page_misc' => array('page_misc_hed', 'misc-tags'), 'page_file' => array('page_file_hed', 'file-tags')); $tagbuild_links = ''; foreach ($tagbuild_items as $tb => $item) { $tagbuild_links .= wrapRegion($item[1] . '_group', taglinks($tb), $item[1], $item[0], 'page_' . $item[1]); } echo hed(gTxt('tab_pages'), 1, array('class' => 'txp-heading')); echo n . tag(n . tag(hed(gTxt('tagbuilder'), 2) . $tagbuild_links, 'div', array('id' => 'tagbuild_links', 'class' => 'txp-layout-cell txp-layout-1-4')) . n . tag(form(graf($buttons) . graf(tag(gTxt('page_code'), 'label', array('for' => 'html')) . br . '<textarea class="code" id="html" name="html" cols="' . INPUT_LARGE . '" rows="' . TEXTAREA_HEIGHT_LARGE . '" dir="ltr">' . txpspecialchars($html) . '</textarea>') . graf(fInput('submit', '', gTxt('save'), 'publish') . eInput('page') . sInput('page_save') . hInput('name', $name)), '', '', 'post', 'edit-form', '', 'page_form'), 'div', array('id' => 'main_content', 'class' => 'txp-layout-cell txp-layout-2-4')) . n . tag(graf(sLink('page', 'page_new', gTxt('create_new_page')), ' class="action-create"') . page_list($name) . n, 'div', array('id' => 'content_switcher', 'class' => 'txp-layout-cell txp-layout-1-4')) . n, 'div', array('id' => $event . '_container', 'class' => 'txp-layout-grid')); }
/** * Renders and outputs a login form. * * This function outputs a full HTML document, * including <head> and footer. * * @param string|array $message The activity message */ function doLoginForm($message) { global $textarray_script, $event, $step; include txpath . '/lib/txplib_head.php'; $event = 'login'; if (gps('logout')) { $step = 'logout'; } elseif (gps('reset')) { $step = 'reset'; } pagetop(gTxt('login'), $message); $stay = (cs('txp_login') and !gps('logout') ? 1 : 0); $reset = gps('reset'); $name = join(',', array_slice(explode(',', cs('txp_login')), 0, -1)); $out = array(); if ($reset) { $out[] = hed(gTxt('password_reset'), 2, array('id' => 'txp-login-heading')) . graf(n . span(tag(gTxt('name'), 'label', array('for' => 'login_name')), array('class' => 'txp-label')) . n . span(fInput('text', 'p_userid', $name, '', '', '', INPUT_REGULAR, '', 'login_name'), array('class' => 'txp-value')), ' class="login-name"') . graf(fInput('submit', '', gTxt('password_reset_button'), 'publish') . n) . graf(href(gTxt('back_to_login'), 'index.php'), array('class' => 'login-return')) . hInput('p_reset', 1); } else { $out[] = hed(gTxt('login_to_textpattern'), 2, array('id' => 'txp-login-heading')) . graf(n . span(tag(gTxt('name'), 'label', array('for' => 'login_name')), array('class' => 'txp-label')) . n . span(fInput('text', 'p_userid', $name, '', '', '', INPUT_REGULAR, '', 'login_name'), array('class' => 'txp-value')), array('class' => 'login-name')) . graf(n . span(tag(gTxt('password'), 'label', array('for' => 'login_password')), array('class' => 'txp-label')) . n . span(fInput('password', 'p_password', '', '', '', '', INPUT_REGULAR, '', 'login_password'), array('class' => 'txp-value')), array('class' => 'login-password')) . graf(checkbox('stay', 1, $stay, '', 'login_stay') . n . tag(gTxt('stay_logged_in'), 'label', array('for' => 'login_stay')) . popHelp('remember_login') . n, array('class' => 'login-stay')) . graf(fInput('submit', '', gTxt('log_in_button'), 'publish') . n) . graf(href(gTxt('password_forgotten'), '?reset=1'), array('class' => 'login-forgot')); if (gps('event')) { $out[] = eInput(gps('event')); } } echo form(tag(join('', $out), 'section', array('role' => 'region', 'class' => 'txp-login', 'aria-labelledby' => 'txp-login-heading')), '', '', 'post', '', '', 'login_form') . script_js('textpattern.textarray = ' . json_encode($textarray_script)) . n . '</main><!-- /txp-body -->' . n . '</body>' . n . '</html>'; exit(0); }
function doLoginForm($message) { include txpath . '/lib/txplib_head.php'; pagetop(gTxt('login'), $message); $stay = (cs('txp_login') and !gps('logout') ? 1 : 0); $reset = gps('reset'); $name = join(',', array_slice(explode(',', cs('txp_login')), 0, -1)); echo n . '<div id="login_container" class="txp-container">'; echo form('<div class="txp-login">' . n . hed(gTxt($reset ? 'password_reset' : 'login_to_textpattern'), 2) . n . graf('<span class="login-label"><label for="login_name">' . gTxt('name') . '</label></span>' . n . '<span class="login-value">' . fInput('text', 'p_userid', $name, '', '', '', INPUT_REGULAR, '', 'login_name') . '</span>', ' class="login-name"') . ($reset ? '' : n . graf('<span class="login-label"><label for="login_password">' . gTxt('password') . '</label></span>' . n . '<span class="login-value">' . fInput('password', 'p_password', '', '', '', '', INPUT_REGULAR, '', 'login_password') . '</span>', ' class="login-password"')) . ($reset ? '' : graf(checkbox('stay', 1, $stay, '', 'login_stay') . n . '<label for="login_stay">' . gTxt('stay_logged_in') . '</label>' . sp . popHelp('remember_login'), ' class="login-stay"')) . ($reset ? n . hInput('p_reset', 1) : '') . n . graf(fInput('submit', '', gTxt($reset ? 'password_reset_button' : 'log_in_button'), 'publish')) . n . ($reset ? graf('<a href="index.php">' . gTxt('back_to_login') . '</a>', ' class="login-return"') : graf('<a href="?reset=1">' . gTxt('password_forgotten') . '</a>', ' class="login-forgot"')) . (gps('event') ? eInput(gps('event')) : '') . '</div>', '', '', 'post', '', '', 'login_form') . '</div>' . n . script_js(<<<EOSCR // Focus on either username or password when empty \$(document).ready( \tfunction() { \t\tvar has_name = \$("#login_name").val().length; \t\tvar password_box = \$("#login_password").val(); \t\tvar has_password = (password_box) ? password_box.length : 0; \t\tif (!has_name) { \t\t\t\$("#login_name").focus(); \t\t} else if (!has_password) { \t\t \t\$("#login_password").focus(); \t\t} \t} ); EOSCR ) . n . '</div><!-- /txp-body -->' . n . '</body>' . n . '</html>'; exit(0); }
function wet_sample_textfilter_postprocessor($event, $step, &$thing, &$context) { // Add a license notice to the body if ($context['field'] === 'Body') { $thing .= graf('Licensed under the terms of CC-BY-SA. Copyright © ' . date('Y') . '.'); } }
function clean($message = '') { global $prefs; extract($prefs); pagetop("Cache Cleaner", ps("txp_token") === md5($lastmod) ? "Successful" : "Token expired. Please try again."); if (ps("txp_token") === md5($lastmod)) { echo "<div align=\"center\" style=\"margin-top:3em\">"; printf("Deleted %s files. Cache is clean.", '' . txp_flushdir(true)); echo "</div>"; } echo "<div align=\"center\" style=\"margin-top:3em\">"; echo form(tag("Cache-Cleaner", "h3") . graf("Usually you don't need to do that. Cache is <b>automatically</b> cleared <br />1)\n\t\t\t\t after a certain amount of time <br />2) when a comment is posted, edited or moderated\n\t\t\t <br />3) after a page-template or form-tag is modified.<br />4) after template import.<br />5) after article update.<br /><br />" . fInput("hidden", "txp_token", md5($lastmod)) . fInput("submit", "clean_cache", "Clean all cached Files", "smallerbox") . eInput("cache") . sInput("clean"), " style=\"text-align:center\"")); echo tag("Cache Statistics", "h3"); global $path_to_site; $count = array('size' => 0, 'num' => 0); $txp_cache_dir = txpath . "/cache"; if (!empty($txp_cache_dir) and $fp = opendir($txp_cache_dir)) { while (false !== ($file = readdir($fp))) { if ($file[0] != ".") { $count['size'] += filesize("{$txp_cache_dir}/{$file}"); ++$count['num']; } } closedir($fp); printf("There are %d cache files with a total size of %d kb.", $count['num'], floor($count['size'] / 1000)); } else { echo "Cache is empty."; } include $path_to_site . '/textpattern/lib/txp_cache/cache-config.php'; echo "</div>"; }
function doTxpValidate() { global $logout, $txpcfg; $p_userid = ps('p_userid'); $p_password = ps('p_password'); $logout = gps('logout'); $stay = ps('stay'); if ($logout) { setcookie('txp_login', '', time() - 3600); } if (!empty($_COOKIE['txp_login']) and !$logout) { // cookie exists @(list($c_userid, $cookie_hash) = split(',', $_COOKIE['txp_login'])); $nonce = safe_field('nonce', 'txp_users', "name='{$c_userid}'"); if (md5($c_userid . $nonce) === $cookie_hash && $nonce) { // check nonce $GLOBALS['txp_user'] = $c_userid; // cookie is good, create $txp_user return ''; } else { // something's gone wrong $GLOBALS['txp_user'] = ''; setcookie('txp_login', '', time() - 3600); return gTxt('bad_cookie'); } } elseif ($p_userid and $p_password) { // no cookie, but incoming login vars sleep(3); // should grind dictionary attacks to a halt if (txp_validate($p_userid, $p_password)) { $nonce = safe_field('nonce', 'txp_users', "name='{$p_userid}'"); if (!$nonce) { define('TXP_UPDATE', 1); include_once txpath . '/update/_update.php'; exit(graf('Please reload')); } if ($stay) { // persistent cookie required setcookie('txp_login', $p_userid . ',' . md5($p_userid . $nonce), time() + 3600 * 24 * 365); // expires in 1 year } else { // session-only cookie required setcookie('txp_login', $p_userid . ',' . md5($p_userid . $nonce)); setcookie('txp_nostay', '1', time() + 3600 * 24 * 365); // remember nostay for 1 year } $GLOBALS['txp_user'] = $p_userid; // login is good, create $txp_user return ''; } else { $GLOBALS['txp_user'] = ''; return gTxt('could_not_log_in'); } } else { $GLOBALS['txp_user'] = ''; return gTxt('login_to_textpattern'); } }
function footer() { global $txp_user; $out[] = '<a id="mothership" href="http://textpattern.com/" title="' . gTxt('go_txp_com') . '" rel="external"><img src="' . $this->url . 'carver.png" width="40" height="40" alt="Textpattern" /></a>' . n . graf('Textpattern CMS · ' . txp_version); if ($txp_user) { $out[] = graf(gTxt('logged_in_as') . ' ' . span(txpspecialchars($txp_user)) . br . '<a href="index.php?logout=1">' . gTxt('logout') . '</a>', ' id="moniker"'); } return join(n, $out); }
function footer() { global $txp_user; $out[] = href('Textpattern CMS', 'http://textpattern.com', ' title="' . gTxt('go_txp_com') . '" rel="external" target="_blank"') . n . span('·', array('role' => 'separator')) . n . txp_version; if ($txp_user) { $out[] = graf(gTxt('logged_in_as') . ' ' . span(txpspecialchars($txp_user)) . br . href(gTxt('logout'), 'index.php?logout=1', ' onclick="return verify(\'' . gTxt('are_you_sure') . '\')"'), ' id="moniker"'); } return join(n, $out); }
function doLoginForm($message) { global $txpcfg; include txpath . '/lib/txplib_head.php'; pagetop(gTxt('login')); $stay = !(cs('txp_nostay') == 1); echo form(startTable('edit') . n . n . tr(n . td() . td(graf($message))) . n . n . tr(n . fLabelCell('name', '', 'name') . n . fInputCell('p_userid', '', 1, '', '', 'name')) . n . n . tr(n . fLabelCell('password', '', 'password') . n . td(fInput('password', 'p_password', '', 'edit', '', '', '', 2, 'password'))) . n . n . tr(n . td() . td(graf(checkbox('stay', 1, $stay, 3, 'stay') . '<label for="stay">' . gTxt('stay_logged_in') . '</label>' . sp . popHelp('remember_login')))) . n . n . tr(n . td() . td(fInput('submit', '', gTxt('log_in_button'), 'publish', '', '', '', 4))) . endTable() . (gps('event') ? eInput(gps('event')) : '')) . n . '</div>' . n . n . '</body>' . n . '</html>'; exit(0); }
function footer() { global $txp_user; $out[] = '<div id="end_page">' . n . '<a href="http://textpattern.com/" id="mothership"><img src="' . $this->url . 'carver.gif" width="60" height="48" border="0" alt="" /></a>' . n . graf('Textpattern · ' . txp_version); if ($txp_user) { $out[] = graf(gTxt('logged_in_as') . ' ' . span(htmlspecialchars($txp_user)) . br . '<a href="index.php?logout=1">' . gTxt('logout') . '</a>', ' id="moniker"'); } $out[] = '</div>'; return join(n, $out); }
function doTxpValidate() { global $logout, $txpcfg; $p_userid = ps('p_userid'); $p_password = ps('p_password'); $logout = gps('logout'); $stay = ps('stay'); if ($logout) { setcookie('txp_login', ' ', time() - 3600); } if (isset($_COOKIE['txp_login']) and !$logout) { // cookie exists list($c_userid, $cookie_hash) = split(',', $_COOKIE['txp_login']); $nonce = safe_field('nonce', 'txp_users', "name='{$c_userid}'"); if (md5($c_userid . $nonce) == $cookie_hash) { // check secret word $GLOBALS['txp_user'] = $c_userid; // cookie is good, create $txp_user return ''; } else { // something's gone wrong $GLOBALS['txp_user'] = ''; setcookie('txp_login', '', time() - 3600); return gTxt('bad_cookie'); } } elseif ($p_userid and $p_password) { // no cookie, but incoming login vars sleep(3); // should grind dictionary attacks to a halt if (txp_validate($p_userid, $p_password)) { $nonce = safe_field('nonce', 'txp_users', "name='{$p_userid}'"); if (!$nonce) { exit(graf('Missing authentication information. Please run _update.php')); } if ($stay) { // persistent cookie required setcookie('txp_login', $p_userid . ',' . md5($p_userid . $nonce), time() + 3600 * 24 * 365); // expires in 1 year } else { // session-only cookie required setcookie('txp_login', $p_userid . ',' . md5($p_userid . $nonce)); } $GLOBALS['txp_user'] = $p_userid; // login is good, create $txp_user return ''; } else { $GLOBALS['txp_user'] = ''; return gTxt('could_not_log_in'); } } else { $GLOBALS['txp_user'] = ''; return gTxt('login_to_textpattern'); } }
function doLoginForm($message) { global $txpcfg; include txpath . '/lib/txplib_head.php'; pagetop(gTxt('login')); $stay = (cs('txp_login') and !gps('logout') ? 1 : 0); $reset = gps('reset'); list($name) = split(',', cs('txp_login')); echo form(startTable('edit') . n . n . tr(n . td() . td(graf($message))) . n . n . tr(n . fLabelCell('name', '', 'name') . n . fInputCell('p_userid', $name, 1, '', '', 'name')) . ($reset ? '' : n . n . tr(n . fLabelCell('password', '', 'password') . n . td(fInput('password', 'p_password', '', 'edit', '', '', '', 2, 'password')))) . ($reset ? '' : n . n . tr(n . td() . td(graf(checkbox('stay', 1, $stay, 3, 'stay') . '<label for="stay">' . gTxt('stay_logged_in') . '</label>' . sp . popHelp('remember_login'))))) . n . n . tr(n . td() . td(($reset ? hInput('p_reset', 1) : '') . fInput('submit', '', gTxt($reset ? 'password_reset_button' : 'log_in_button'), 'publish', '', '', '', 4) . ($reset ? '' : graf('<a href="?reset=1">' . gTxt('password_forgotten') . '</a>')))) . endTable() . (gps('event') ? eInput(gps('event')) : '')) . n . '</body>' . n . '</html>'; exit(0); }
function lista($message = '') { global $prefs; extract($prefs); $template = new template(); pagetop(gTxt('template'), $message); print "\n <style type='text/css'>\n .success { color: #009900; }\n .failure { color: #FF0000; }\n </style>\n\t\t\t\n <table cellpadding='0' cellspacing='0' border='0' id='list' align='center'>\n <tr>\n <td>\n "; $importlist = $template->getTemplateList(); print "\n <h1>Import Templates</h1>\n " . form(graf('Which template set would you like to import?' . selectInput('import_dir', $importlist, '', 1) . fInput('submit', 'go', 'Go', 'smallerbox') . eInput('template') . sInput('import'))); print "\n <h1>Export Templates</h1>\n " . form(graf('Name this export:' . fInput('text', 'export_dir', '') . fInput('submit', 'go', 'Go', 'smallerbox') . eInput('template') . sInput('export'))); print "\n </td>\n </tr>\n </table>\n "; }
function show_mentions() { global $id; if ($id) { $rs = safe_rows("*", "txp_log_mention", "article_id='{$id}'"); if ($rs) { foreach ($rs as $a) { extract($a); $out[] = '<a href="http://' . $refpage . '" title="' . $excerpt . '">' . $reftitle . '</a>'; } return hed(gTxt('mentions'), 3) . graf(join(br, $out)); } } }
function switch_tool() { global $vars, $event, $step, $tools; extract(gpsa($vars)); pagetop(gTxt('txp_import'), ''); echo '<h1 class="txp-heading">' . gTxt('tab_import') . '</h1>'; ?> <script type="text/javascript"> <!--// function showHideFields($sel) { if(document.getElementById){ document.getElementById('mtblogid').style.display = ($sel=='mtdb') ? 'block': 'none'; document.getElementById('wponly').style.display = ($sel=='wp') ? 'block': 'none'; document.getElementById('databased').style.display = ($sel=='wp' || $sel=='mtdb' || $sel=='b2')? 'block':'none'; } } //--> </script> <?php $content = '<div class="txp-edit">'; $content .= hed(gTxt('txp_import'), 2); //Select tool $content .= inputLabel('import_from', tag(type_options($tools), 'select', ' id="import_from" name="import_tool" onchange="showHideFields(this.value);"'), 'select_tool', 'import'); //Some data we collect $content .= inputLabel('import_section', import_section_popup(''), 'import_section', 'import_section'); $status_options = array(STATUS_LIVE => gTxt('live'), STATUS_DRAFT => gTxt('draft'), STATUS_HIDDEN => gTxt('hidden'), STATUS_PENDING => gTxt('pending')); $content .= inputLabel('import_status', tag(type_options($status_options), 'select', ' id="import_status"'), 'import_status', 'import_status'); $content .= inputLabel('import_comment', fInput('text', 'import_comments_invite', gTxt('comments'), '', '', '', INPUT_REGULAR, '', 'import_comment'), 'import_invite', 'import_invite'); //DataBase imports only $databased = hed(gTxt('database_stuff'), 2) . inputLabel('import_database', fInput('text', 'importdb', '', '', '', '', INPUT_REGULAR, '', 'import_database'), 'import_database', 'import_database') . inputLabel('import_login', fInput('text', 'importdblogin', '', '', '', '', INPUT_REGULAR, '', 'import_login'), 'import_login', 'import_login') . inputLabel('import_password', fInput('text', 'importdbpass', '', '', '', '', INPUT_REGULAR, '', 'import_password'), 'import_password', 'import_password') . inputLabel('import_host', fInput('text', 'importdbhost', '', '', '', '', INPUT_REGULAR, '', 'import_host'), 'import_host', 'import_host'); $content .= tag($databased, 'div', ' id="databased" style="display: none;"'); //MT-DB Specific $mtblogid = inputLabel('import_blogid', fInput('text', 'import_blog_id', '', '', '', '', INPUT_REGULAR, '', 'import_blogid'), 'import_blogid', 'import_blogid'); $content .= tag($mtblogid, 'div', ' id="mtblogid" style="display: none;"'); //WordPress specific option $wponly = inputLabel('import_wpprefix', fInput('text', 'wpdbprefix', 'wp_', '', '', '', INPUT_REGULAR, '', 'import_wpprefix'), 'import_wpprefix', 'import_wpprefix') . inputLabel('import_wpdbcharset', selectInput('wpdbcharset', array('utf8' => gTxt('utf8'), 'latin1' => gTxt('latin1')), 'utf8', '', '', 'import_wpdbcharset'), 'import_wpdbcharset', 'import_wpdbcharset'); $content .= tag($wponly, 'div', ' id="wponly" style="display: none;"'); $content .= graf(fInput('submit', 'choose', gTxt('continue'), 'publish')); $content .= sInput('start_import') . eInput('import'); $content .= '</div>'; echo '<div id="' . $event . '_container" class="txp-container">' . form($content, '', '', 'post', '', '', 'import') . '</div>'; }
function page_edit($message = '') { global $event, $step; pagetop(gTxt('edit_pages'), $message); extract(gpsa(array('name', 'newname', 'copy', 'savenew'))); if ($step == 'page_delete' || empty($name) && $step != 'page_new' && !$savenew) { $name = safe_field('page', 'txp_section', "name = 'default'"); } elseif (($copy || $savenew) && trim(preg_replace('/[<>&"\']/', '', $newname))) { $name = $newname; } // Format of each entry is popTagLink -> array ( gTxt() string, class/ID) $tagbuild_items = array('page_article' => array('page_article_hed', 'article-tags'), 'page_article_nav' => array('page_article_nav_hed', 'article-nav-tags'), 'page_nav' => array('page_nav_hed', 'nav-tags'), 'page_xml' => array('page_xml_hed', 'xml-tags'), 'page_misc' => array('page_misc_hed', 'misc-tags'), 'page_file' => array('page_file_hed', 'file-tags')); $tagbuild_options = ''; foreach ($tagbuild_items as $tb => $item) { $tagbuild_options .= n . n . '<div class="' . $item[1] . '">' . hed('<a href="#' . $item[1] . '">' . gTxt($item[0]) . '</a>', 3, ' class="plain lever' . (get_pref('pane_page_' . $item[1] . '_visible') ? ' expanded' : '') . '"') . n . '<div id="' . $item[1] . '" class="toggle" style="display:' . (get_pref('pane_page_' . $item[1] . '_visible') ? 'block' : 'none') . '">' . taglinks($tb) . '</div></div>'; } echo '<div id="' . $event . '_container" class="txp-container txp-edit">' . startTable('edit', '', 'edit-pane') . tr(tda('<div id="tagbuild_links">' . n . hed(gTxt('tagbuilder'), 2) . $tagbuild_options . n . '</div>', ' class="column"') . tda(page_edit_form($name), ' class="column"') . tda('<div id="content_switcher">' . hed(gTxt('all_pages'), 2) . graf(sLink('page', 'page_new', gTxt('create_new_page')), ' class="action-create smallerbox"') . page_list($name) . '</div>', ' class="column"')) . endTable() . '</div>'; }
/** * Performs searching and returns results. * * This is now performed by doArticles(). * * @param string $q * @deprecated in 4.0.4 * @see doArticles() */ function search($q) { global $prefs; $url = $prefs['siteurl']; extract($prefs); $s_filter = filterSearch(); $form = fetch('form', 'txp_form', 'name', 'search_results'); // Lose this eventually - only used if search_results form is missing. $form = !$form ? legacy_form() : $form; $rs = safe_rows("*, ID AS thisid, UNIX_TIMESTAMP(Posted) AS posted, Title AS title,\n MATCH (Title,Body) AGAINST ('{$q}') AS score", 'textpattern', "(Title RLIKE '{$q}' OR Body RLIKE '{$q}') {$s_filter}\n AND Status = 4 AND Posted <= " . now('posted') . " ORDER BY score DESC LIMIT 40"); if ($rs) { $result_rows = count($rs); $text = $result_rows == 1 ? gTxt('article_found') : gTxt('articles_found'); } else { $result_rows = 0; $text = gTxt('articles_found'); } $results[] = graf($result_rows . ' ' . $text); if ($result_rows > 0) { foreach ($rs as $a) { extract($a); $result_date = safe_strftime($archive_dateformat, $posted); $uTitle = $url_title ? $url_title : stripSpace($Title); $hurl = permlinkurl($a); $result_url = '<a href="' . $hurl . '">' . $hurl . '</a>'; $result_title = '<a href="' . $hurl . '">' . $Title . '</a>'; $result = preg_replace("/>\\s*</", "> <", $Body_html); preg_match_all("/\\s.{1,50}" . preg_quote($q) . ".{1,50}\\s/i", $result, $concat); $concat = join(" ... ", $concat[0]); $concat = strip_tags($concat); $concat = preg_replace('/^[^>]+>/U', "", $concat); $concat = preg_replace("/({$q})/i", "<strong>\$1</strong>", $concat); $result_excerpt = $concat ? "... " . $concat . " ..." : ''; $glob['search_result_title'] = $result_title; $glob['search_result_excerpt'] = $result_excerpt; $glob['search_result_url'] = $result_url; $glob['search_result_date'] = $result_date; $GLOBALS['this_result'] = $glob; $thisresult = $form; $results[] = parse($thisresult); } } return is_array($results) ? join('', $results) : ''; }
function search($q) { global $prefs; $url = $prefs['siteurl']; extract($prefs); $s_filter = filterSearch(); $form = fetch('form', 'txp_form', 'name', 'search_results'); // lose this eventually - only used if search_results form is missing $form = !$form ? legacy_form() : $form; $rs = safe_rows("*, ID as thisid, unix_timestamp(Posted) as posted, Title as title,\n\t\t\tmatch (Title,Body) against ('{$q}') as score", "textpattern", "(Title rlike '{$q}' or Body rlike '{$q}') {$s_filter}\n\t\t\tand Status = 4 and Posted <=now() order by score desc limit 40"); if ($rs) { $result_rows = count($rs); $text = $result_rows == 1 ? gTxt('article_found') : gTxt('articles_found'); } else { $result_rows = 0; $text = gTxt('articles_found'); } $results[] = graf($result_rows . ' ' . $text); if ($result_rows > 0) { foreach ($rs as $a) { extract($a); $result_date = safe_strftime($archive_dateformat, $posted); $uTitle = $url_title ? $url_title : stripSpace($Title); $hurl = permlinkurl($a); $result_url = '<a href="' . $hurl . '">' . $hurl . '</a>'; $result_title = '<a href="' . $hurl . '">' . $Title . '</a>'; $result = preg_replace("/>\\s*</", "> <", $Body_html); preg_match_all("/\\s.{1,50}" . preg_quote($q) . ".{1,50}\\s/i", $result, $concat); $concat = join(" ... ", $concat[0]); $concat = strip_tags($concat); $concat = preg_replace('/^[^>]+>/U', "", $concat); $concat = preg_replace("/({$q})/i", "<strong>\$1</strong>", $concat); $result_excerpt = $concat ? "... " . $concat . " ..." : ''; $glob['search_result_title'] = $result_title; $glob['search_result_excerpt'] = $result_excerpt; $glob['search_result_url'] = $result_url; $glob['search_result_date'] = $result_date; $GLOBALS['this_result'] = $glob; $thisresult = $form; $results[] = parse($thisresult); } } return is_array($results) ? join('', $results) : ''; }
function asy_jpcachecleaner($event, $step) { global $lastmod, $prefs, $path_to_site; // ps() returns the contents of POST vars, if any; if (ps("step") === "clean") { pagetop("JPCache Cleaner", ps("asy_token") === md5($lastmod) ? "Successful" : "Token expired. Please try again."); if (ps("asy_token") === md5($lastmod)) { echo "<div align=\"center\" style=\"margin-top:3em\">"; printf("Deleted %s files. Cache is clean.", '' . asy_flushdir(true)); echo "</div>"; } } else { pagetop("JPCache Cleaner"); } echo "<div align=\"center\" style=\"margin-top:3em\">"; echo form(tag("JPCache-Cleaner", "h3") . graf("Usually you don't need to do that. Cache is <b>automatically</b> cleared <br />1)\n\t\t\t\t after a certain amount of time <br />2) when a comment is posted, edited or moderated\n\t\t\t <br />3) after a page-template or form-tag is is modified.<br /><br />" . fInput("hidden", "asy_token", md5($lastmod)) . fInput("submit", "clean_cache", "Clean all cached Files", "smallerbox") . eInput("asy_jpcache") . sInput("clean"), " style=\"text-align:center\"")); echo tag("Cache Statistics", "h3"); global $path_to_site; $count = array('size' => 0, 'num' => 0); $asy_cache_dir = $path_to_site . '/jpcache/cache'; if (!empty($asy_cache_dir) and $fp = opendir($asy_cache_dir)) { while (false !== ($file = readdir($fp))) { if ($file[0] != ".") { $count['size'] += filesize("{$asy_cache_dir}/{$file}"); ++$count['num']; } } closedir($fp); printf("There are %d cache files with a total size of %d kb.", $count['num'], floor($count['size'] / 1000)); } else { echo "Cache is empty."; } include $path_to_site . '/jpcache/jpcache-config.php'; /* if (@$JPCACHE_TXPLOG_DO == 1 && $prefs['logging']=='all'){ echo tag("Read-Write-Ratio<sup>1</sup>","h3");; $cachehits = safe_field('COUNT( id ) as hit', 'txp_log', "page LIKE '%#cachehit'"); $totalhits = getThing("SELECT MIN(time) FROM ".PFX."txp_log WHERE page LIKE '%#cachehit'"); $totalhits = getThing("SELECT COUNT(id) FROM ".PFX."txp_log WHERE time > '". $totalhits."'"); printf("There were <b>%d</b> cache-reads recorded and <b>%d</b> possible cache-writes. <br />Average number of reads per write: <b>%01.2f</b>",$cachehits, $totalhits-$cachehits, (($totalhits-$cachehits) > 0) ? ($cachehits/($totalhits-$cachehits)) : '0'); echo "<br /><br /><sup>1</sup>This is a (low) Approximation. Initially wait a week before numbers become meaningful."; } */ echo "</div>"; }
function log_list() { pagetop(gTxt('visitor_logs')); extract(get_prefs()); safe_delete("txp_log", "`time` < date_sub(now(),interval " . $expire_logs_after . " day)"); safe_optimize("txp_log"); safe_repair("txp_log"); $page = gps('page'); $total = getCount('txp_log', "1"); $limit = 50; $numPages = ceil($total / $limit); $page = !$page ? 1 : $page; $offset = ($page - 1) * $limit; $nav[] = $page > 1 ? PrevNextLink("log", $page - 1, gTxt('prev'), 'prev') : ''; $nav[] = sp . small($page . '/' . $numPages) . sp; $nav[] = $page != $numPages ? PrevNextLink("log", $page + 1, gTxt('next'), 'next') : ''; $rs = safe_rows_start("*, unix_timestamp(time) as stamp", "txp_log", "1 order by time desc limit {$offset},{$limit}"); if ($rs) { echo startTable('list'), assHead('time', 'host', 'page', 'referrer'); $stamp = ''; while ($a = nextRow($rs)) { extract($a); if ($refer) { $referprint = preg_replace("/^www\\./", "", chunk(htmlspecialchars($refer), 50)); $referprint = '<a href="http://' . htmlspecialchars($refer) . '">' . $referprint . '</a>'; } else { $referprint = ' '; } $pageprint = preg_replace('/\\/$/', '', htmlspecialchars(substr($page, 1))); $pageprint = $pageprint == '' ? '' : '<a href="' . htmlspecialchars($page) . '" target="_blank">' . chunk($pageprint, 50) . '</a>'; if ($method == 'POST') { $pageprint = '<b>' . $pageprint . '</b>'; } $fstamp = date("n/j g:i a", $stamp + tz_offset()); $hostprint = chunk($host, 40); echo tr(td($fstamp) . td($hostprint) . td($pageprint) . td($referprint)); unset($refer, $referprint, $page, $pageprint); } echo '<tr><td colspan="4" align="right" style="padding:10px">', join('', $nav), "</td></tr>", endTable(); } else { echo graf(gTxt('no_refers_recorded'), ' align="center"'); } }
function page_edit_form($name) { global $step; if ($step == 'div_edit') { list($html_array, $html, $start_pos, $stop_pos) = extract_div(); $html_array = serialize($html_array); $outstep = 'div_save'; } else { $html = safe_field('user_html', 'txp_page', "name='{$name}'"); $outstep = 'page_save'; } $out[] = textarea('500', '600', $html, 'html') . graf(fInput('submit', 'save', gTxt('save'), 'publish') . eInput('page') . sInput($outstep) . hInput('name', $name)); if ($step == 'div_edit') { $out[] = hInput('html_array', $html_array) . hInput('start_pos', $start_pos) . hInput('stop_pos', $stop_pos) . hInput('name', $name); } else { $out[] = graf(gTxt('copy_page_as') . fInput('text', 'newname', '', 'edit') . fInput('submit', 'copy', gTxt('copy'), 'smallerbox')); } return form(join('', $out)); }
function search($q) { global $prefs; $url = $prefs['siteurl']; extract($prefs); $s_filter = filterSearch(); $form = fetch('form', 'txp_form', 'name', 'search_results'); // lose this eventually - only used if search_results form is missing $form = !$form ? legacy_form() : $form; $rs = safe_rows("ID, Title, Body_html, Section, unix_timestamp(Posted) as uPosted, \n\t\t\tmatch (Title,Body) against ('{$q}') as score", "textpattern", "Title rlike '{$q}' or Body rlike '{$q}' {$s_filter}\n\t\t\tand Status = 4 and Posted <=now() order by score desc limit 40"); if ($rs) { $result_rows = count($rs); $text = $result_rows == 1 ? gTxt('article_found') : gTxt('articles_found'); } else { $result_rows = 0; $text = gTxt('articles_found'); } $results[] = graf($result_rows . ' ' . $text); if ($result_rows > 0) { foreach ($rs as $a) { extract($a); $result_date = date("j M Y", $uPosted); $hurl = $url_mode ? $siteurl . $path_from_root . $Section . '/' . $ID . '/' . stripSpace($Title) : $siteurl . $path_from_root . 'index.php?id=' . $ID; $result_url = '<a href="http://' . $hurl . '">' . $hurl . '</a>'; $result_title = '<a href="http://' . $hurl . '">' . $Title . '</a>'; $result = preg_replace("/>\\s*</", "> <", $Body_html); preg_match_all("/\\s.{0,50}" . $q . ".{0,50}\\s/i", $result, $concat); $concat = implode(" ... ", $concat[0]); $concat = strip_tags($concat); $concat = preg_replace('/^[^>]+>/U', "", $concat); $concat = preg_replace("/({$q})/i", "<strong>\$1</strong>", $concat); $result_excerpt = $concat ? "... " . $concat . " ..." : ''; $glob['search_result_title'] = $result_title; $glob['search_result_excerpt'] = $result_excerpt; $glob['search_result_url'] = $result_url; $glob['search_result_date'] = $result_date; $GLOBALS['this_result'] = $glob; $thisresult = $form; $results[] = parse($thisresult); } } return is_array($results) ? join('', $results) : ''; }
function page_edit_form($name) { global $step; if ($step == 'div_edit') { list($html_array, $html, $start_pos, $stop_pos) = extract_div(); $html_array = serialize($html_array); $outstep = 'div_save'; } else { $html = safe_field('user_html', 'txp_page', "name='" . doSlash($name) . "'"); $outstep = 'page_save'; } $divline = $step == 'div_edit' ? graf(gTxt('you_are_editing_div') . sp . strong($div)) : ''; $out[] = '<p>' . gTxt('you_are_editing_page') . sp . strong($name) . $divline . br . '<textarea id="html" class="code" name="html" cols="84" rows="36">' . htmlspecialchars($html) . '</textarea>' . br . n . fInput('submit', 'save', gTxt('save'), 'publish') . n . eInput('page') . n . sInput($outstep) . n . hInput('name', $name); if ($step == 'div_edit') { $out[] = n . hInput('html_array', $html_array) . n . hInput('start_pos', $start_pos) . n . hInput('stop_pos', $stop_pos) . n . hInput('name', $name); } else { $out[] = n . '<label for="copy-page">' . gTxt('copy_page_as') . '</label>' . sp . n . fInput('text', 'newname', '', 'edit', '', '', '', '', 'copy-page') . n . fInput('submit', 'copy', gTxt('copy'), 'smallerbox') . '</p>'; } return form(join('', $out)); }
function form_edit($message = '') { global $step; pagetop(gTxt('edit_forms'), $message); extract(gpsa(array('Form', 'name', 'type'))); if ($step == 'form_create') { $Form = ''; $name = ''; $type = ''; $inputs = fInput('submit', 'savenew', gTxt('save_new'), 'publish') . eInput("form") . sInput('form_save'); } else { $name = (!$name or $step == 'form_delete') ? 'default' : $name; $rs = safe_row("*", "txp_form", "name='{$name}'"); if ($rs) { extract($rs); $inputs = fInput('submit', 'save', gTxt('save'), 'publish') . eInput("form") . sInput('form_save') . hInput('oldname', $name); } } $out = startTable('edit') . tr(tdtl(hed(gTxt('useful_tags'), 2) . graf(gTxt('articles') . sp . popHelp('form_place_article') . br . popTagLinks('article')) . graf(gTxt('links') . sp . popHelp('form_place_link') . br . popTagLinks('link')) . graf(gTxt('displayed_comments') . sp . popHelp('form_place_comment') . br . popTagLinks('comment')) . graf(gTxt('comment_form') . sp . popHelp('form_place_input') . br . popTagLinks('comment_form')) . graf(gTxt('search_input_form') . sp . popHelp('form_place_search_input') . br . popTagLinks('search_input')) . graf(gTxt('search_results_form') . sp . popHelp('form_place_search_results') . br . popTagLinks('search_result')) . graf(tag('<strong>' . gTxt('file_download_tags') . '</strong>', 'a', ' href="#" onclick="toggleDisplay(\'downloadtags\');"') . sp . popHelp('form_file_download_tags')) . graf(popTagLinks('file_download'), ' style="display:none;" id="downloadtags"')) . tdtl('<form action="index.php" method="post">' . input_textarea($Form) . graf(gTxt('form_name') . br . fInput('text', 'name', $name, 'edit', '', '', 15)) . graf(gTxt('form_type') . br . formtypes($type)) . graf(gTxt('only_articles_can_be_previewed')) . fInput('submit', 'preview', gTxt('preview'), 'smallbox') . graf($inputs) . '</form>') . tdtl(form_list($name))) . endTable(); echo $out; }
function link_list($message = "") { global $step, $link_list_pageby; extract(get_prefs()); $page = gps('page'); $total = getCount('txp_link', "1"); $limit = $link_list_pageby; $numPages = ceil($total / $limit); $page = !$page ? 1 : $page; $offset = ($page - 1) * $limit; $sort = gps('sort'); $dir = gps('dir'); $sort = $sort ? $sort : 'linksort'; $dir = $dir ? $dir : 'asc'; if ($dir == "desc") { $dir = "asc"; } else { $dir = "desc"; } $nav[] = $page > 1 ? PrevNextLink("link", $page - 1, gTxt('prev'), 'prev') : ''; $nav[] = sp . small($page . '/' . $numPages) . sp; $nav[] = $page != $numPages ? PrevNextLink("link", $page + 1, gTxt('next'), 'next') : ''; $rs = safe_rows("*", "txp_link", "1 order by {$sort} {$dir} limit {$offset},{$limit}"); if ($rs) { echo '<form action="index.php" method="post" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">', startTable('list'), tr(column_head('link_name', 'linksort', 'link', 1, $dir) . column_head('description', 'description', 'link', 1, $dir) . column_head('link_category', 'category', 'link', 1, $dir) . td()); foreach ($rs as $a) { extract($a); $elink = eLink('link', 'link_edit', 'id', $id, $linkname); $cbox = fInput('checkbox', 'selected[]', $id); echo tr(td($elink) . td($description) . td($category) . td($cbox)); } echo tr(tda(link_multiedit_form(), ' colspan="4" style="border:0px;text-align:right"')); echo endTable(), '</form>'; echo pageby_form('link', $link_list_pageby); echo graf(join('', $nav), ' align="center"'); } }
function rss_admin_editlink($event, $step) { global $rss_ae_cookie; include txpath . '/include/txp_prefs.php'; if (!isset($rss_ae_cookie)) { $rss_ae_cookie = "rss_article_edit"; $rs = safe_insert('txp_prefs', "name='rss_ae_cookie', val='{$rss_ae_cookie}', prefs_id='1'"); } if (gps("add")) { safe_update("txp_prefs", "val = '" . addslashes(ps('rss_ae_cookie')) . "'", "name = 'rss_ae_cookie' and prefs_id ='1'"); setcookie($rss_ae_cookie, $rss_ae_cookie, time() + 31536000, "/"); header("Location: index.php?event=editlink"); } else { if (gps("rem")) { safe_update("txp_prefs", "val = '" . addslashes(ps('rss_ae_cookie')) . "'", "name = 'rss_ae_cookie' and prefs_id ='1'"); setcookie($rss_ae_cookie, $rss_ae_cookie, time() - 3600, "/"); header("Location: index.php?event=editlink"); } } pagetop("Edit Link"); $aeset = isset($_COOKIE[$rss_ae_cookie]) ? "" : " not"; $tdaStyle = ' style="text-align:right;vertical-align:middle"'; echo form(startTable("list") . tr(tdcs(hed("Add/Remove Public Site Article Edit Link", 1), 2)) . tr(tda(graf('Cookie ' . $rss_ae_cookie . ' is' . $aeset . ' set.', ' align="center"'), ' colspan="2"')) . tr(tda(gTxt('Cookie Name:'), ' style="text-align:right;vertical-align:middle"') . tda(text_input("rss_ae_cookie", $rss_ae_cookie, '20'), ' ')) . tr(tda(graf(fInput("submit", "add", gTxt("Add Edit Link"), "publish") . fInput("submit", "rem", gTxt("Remove Edit Link"), "publish") . eInput("editlink"), ' align="center"'), ' colspan="2"')) . endTable()); }
/** * Renders a panel for selecting the import tool. * * Lets users select the tool and provide required * configuration options. */ function switch_tool() { global $vars, $event, $step, $tools; extract(gpsa($vars)); pagetop(gTxt('txp_import'), ''); echo hed(gTxt('tab_import'), 1, array('class' => 'txp-heading')); $content = '<section class="txp-edit">'; $content .= hed(gTxt('txp_import'), 2); // Select tool. $content .= inputLabel('import_from', tag(type_options($tools), 'select', ' id="import_from" name="import_tool"'), 'select_tool', 'import'); // Some data we collect. $content .= inputLabel('import_section', import_section_popup(''), 'import_section', 'import_section'); $status_options = array(STATUS_LIVE => gTxt('live'), STATUS_DRAFT => gTxt('draft'), STATUS_HIDDEN => gTxt('hidden'), STATUS_PENDING => gTxt('pending')); $content .= inputLabel('import_status', tag(type_options($status_options), 'select', ' id="import_status"'), 'import_status', 'import_status'); $content .= inputLabel('import_comment', fInput('text', 'import_comments_invite', gTxt('comments'), '', '', '', INPUT_REGULAR, '', 'import_comment'), 'import_invite', 'import_invite'); // Database imports only. $databased = hed(gTxt('database_stuff'), 2) . inputLabel('import_database', fInput('text', 'importdb', '', '', '', '', INPUT_REGULAR, '', 'import_database'), 'import_database', 'import_database') . inputLabel('import_login', fInput('text', 'importdblogin', '', '', '', '', INPUT_REGULAR, '', 'import_login'), 'import_login', 'import_login') . inputLabel('import_password', fInput('text', 'importdbpass', '', '', '', '', INPUT_REGULAR, '', 'import_password'), 'import_password', 'import_password') . inputLabel('import_host', fInput('text', 'importdbhost', '', '', '', '', INPUT_REGULAR, '', 'import_host'), 'import_host', 'import_host'); $content .= tag($databased, 'div', ' id="databased" style="display: none;"'); // Movable Type (MySQL DB) specific. $mtblogid = inputLabel('import_blogid', fInput('text', 'import_blog_id', '', '', '', '', INPUT_REGULAR, '', 'import_blogid'), 'import_blogid', 'import_blogid'); $content .= tag($mtblogid, 'div', ' id="mtblogid" style="display: none;"'); // WordPress specific. $wponly = inputLabel('import_wpprefix', fInput('text', 'wpdbprefix', 'wp_', '', '', '', INPUT_REGULAR, '', 'import_wpprefix'), 'import_wpprefix', 'import_wpprefix') . inputLabel('import_wpdbcharset', selectInput('wpdbcharset', array('utf8' => gTxt('utf8'), 'latin1' => gTxt('latin1')), 'utf8', '', '', 'import_wpdbcharset'), 'import_wpdbcharset', 'import_wpdbcharset'); $content .= tag($wponly, 'div', ' id="wponly" style="display: none;"'); $content .= graf(fInput('submit', 'choose', gTxt('continue'), 'publish')); $content .= sInput('start_import') . eInput('import'); $content .= '</section>'; echo '<div id="' . $event . '_container" class="txp-container">' . form($content, '', '', 'post', '', '', 'import') . '</div>'; }
function fbCreate() { if ($GLOBALS['txp_install_successful'] === false) { return '<div width="450" valign="top" style="margin-right: auto; margin-left: auto;">' . graf(gTxt('errors_during_install', array('{num}' => $GLOBALS['txp_err_count'])), ' style="margin-top: 3em;"') . '</div>'; } else { return '<div width="450" valign="top" style="margin-right: auto; margin-left: auto;">' . graf(gTxt('that_went_well'), ' style="margin-top:3em"') . graf(gTxt('you_can_access', array('index.php' => $GLOBALS['rel_siteurl'] . '/textpattern/index.php'))) . graf(gTxt('thanks_for_interest')) . '</div>'; } }
function css_edit_raw() { global $step; $name = gps('name'); $default_name = safe_field('css', 'txp_section', "name = 'default'"); $name = (!$name or $step == 'css_delete') ? $default_name : $name; if (gps('copy') && trim(preg_replace('/[<>&"\']/', '', gps('newname')))) { $name = gps('newname'); } if ($step == 'pour') { $buttons = gTxt('name_for_this_style') . ': ' . fInput('text', 'newname', '', 'edit', '', '', 20) . hInput('savenew', 'savenew'); $thecss = ''; } else { $buttons = ''; $thecss = base64_decode(fetch("css", 'txp_css', 'name', $name)); } if ($step != 'pour') { $left = graf(gTxt('you_are_editing_css') . br . strong($name)) . graf(eLink('css', 'css_edit_form', 'name', $name, gTxt('edit_css_in_form'))) . graf(sLink('css', 'pour', gTxt('bulkload_existing_css'))); $copy = gTxt('copy_css_as') . sp . fInput('text', 'newname', '', 'edit') . sp . fInput('submit', 'copy', gTxt('copy'), 'smallerbox'); } else { $left = ' '; $copy = ''; } $right = hed(gTxt('all_stylesheets'), 2) . css_list($name, $default_name); echo startTable('edit') . tr(tdtl($left) . td(form(graf($buttons) . '<textarea id="css" class="code" name="css" cols="78" rows="32">' . htmlspecialchars($thecss) . '</textarea>' . br . fInput('submit', '', gTxt('save'), 'publish') . eInput('css') . sInput('css_save') . hInput('name', $name) . $copy)) . tdtl($right)) . endTable(); }