function sec_section_list($message = '') { pagetop(gTxt('sections'), $message); global $wlink; $pageslist = safe_column("name", "txp_page", "1=1"); $styleslist = safe_column("name", "txp_css", "1=1"); $out[] = tr(tdcs(strong(gTxt('section_head')) . popHelp('section_category'), 3)); $out[] = tr(tdcs(form(fInput('text', 'name', '', 'edit', '', '', 10) . fInput('submit', '', gTxt('Create'), 'smallerbox') . eInput('section') . sInput('section_create')), 3)); $defrow = safe_row("page, css", "txp_section", "name like 'default'"); $out[] = form(tr(td(gTxt('default')) . td(startTable('edit', 'left', '') . tr(fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pageslist, $defrow['page']) . popHelp('section_uses_page'), '', 'noline')) . tr(fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styleslist, $defrow['css']) . popHelp('section_uses_css'), '', 'noline')) . tr(tda(fInput('submit', '', gTxt('save_button'), 'smallerbox'), ' colspan="2" style="border:0"')) . endTable()) . td()) . eInput('section') . sInput('section_save') . hInput('name', 'default')); $rs = safe_rows_start("*", "txp_section", "name!='' order by name"); if ($rs) { while ($a = nextRow($rs)) { extract($a); if ($name == 'default') { continue; } $deletelink = dLink('section', 'section_delete', 'name', $name, '', 'type', 'section'); $form = startTable('edit') . stackRows(fLabelCell(gTxt('section_name') . ':') . fInputCell('name', $name, 1, 20), fLabelCell(gTxt('section_longtitle') . ':') . fInputCell('title', $title, 1, 20), fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pageslist, $page) . popHelp('section_uses_page'), '', 'noline'), fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styleslist, $css) . popHelp('section_uses_css'), '', 'noline'), fLabelCell(gTxt('selected_by_default') . '?') . td(yesnoradio('is_default', $is_default) . popHelp('section_is_default'), '', 'noline'), fLabelCell(gTxt('on_front_page') . '?') . td(yesnoradio('on_frontpage', $on_frontpage) . popHelp('section_on_frontpage'), '', 'noline'), fLabelCell(gTxt('syndicate') . '?') . td(yesnoradio('in_rss', $in_rss) . popHelp('section_syndicate'), '', 'noline'), fLabelCell(gTxt('include_in_search') . '?') . td(yesnoradio('searchable', $searchable) . popHelp('section_searchable'), '', 'noline'), tda(fInput('submit', '', gTxt('save_button'), 'smallerbox'), ' colspan="2" style="border:0"')) . endTable() . eInput('section') . sInput('section_save') . hInput('old_name', $name); $form = form($form); $out[] = tr(td($name) . td($form) . td($deletelink)); } } echo startTable('list') . join('', $out) . endTable(); }
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>'; }
function doLoginForm($message) { global $txpcfg; include $txpcfg['txpath'] . '/lib/txplib_head.php'; pagetop('log in'); echo form(startTable('edit') . tr(td() . td(graf($message))) . tr(fLabelCell('name') . fInputCell('p_userid')) . tr(fLabelCell('password') . td(fInput('password', 'p_password', '', 'edit'))) . tr(td() . td(graf(checkbox('stay', 1, 1) . gTxt('stay_logged_in') . popHelp('remember_login')))) . tr(fLabelCell('') . td(fInput('submit', '', gTxt('log_in_button'), 'publish'))) . endTable()); exit("</div></body></html>"); }
function plugin_edit_form($name = '') { $sub = fInput('submit', '', gTxt('save'), 'publish'); $code = $name ? fetch('code', 'txp_plugin', 'name', $name) : ''; $thing = $code ? $code : ''; $textarea = '<textarea id="plugin-code" class="code" name="code" rows="28" cols="90">' . htmlspecialchars($thing) . '</textarea>'; return form(startTable('edit') . tr(td($textarea)) . tr(td($sub)) . endTable() . sInput('plugin_save') . eInput('plugin') . hInput('name', $name)) . n . '<script type="text/javascript">' . n . 'if(jQuery.browser.mozilla){$("#plugin-code").attr("spellcheck", false);}' . n . '</script>'; }
function plugin_edit_form($name = '') { $sub = fInput('submit', '', gTxt('save'), 'publish'); $code = $name ? fetch('code', 'txp_plugin', 'name', $name) : ''; $thing = $code ? $code : ''; $textarea = '<textarea id="plugin-code" class="code" name="code" rows="28" cols="90">' . htmlspecialchars($thing) . '</textarea>'; return form(startTable('edit') . tr(td($textarea)) . tr(td($sub)) . endTable() . sInput('plugin_save') . eInput('plugin') . hInput('name', $name)); }
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 plugin_list($message = '') { global $event; pagetop(gTxt('tab_plugins'), $message); echo '<h1 class="txp-heading">' . gTxt('tab_plugins') . '</h1>'; echo '<div id="' . $event . '_control" class="txp-control-panel">'; echo n . plugin_form() . n . '</div>'; extract(gpsa(array('sort', 'dir'))); if ($sort === '') { $sort = get_pref('plugin_sort_column', 'name'); } if ($dir === '') { $dir = get_pref('plugin_sort_dir', 'asc'); } $dir = $dir == 'desc' ? 'desc' : 'asc'; if (!in_array($sort, array('name', 'status', 'author', 'version', 'modified', 'load_order'))) { $sort = 'name'; } $sort_sql = $sort . ' ' . $dir; set_pref('plugin_sort_column', $sort, 'plugin', 2, '', 0, PREF_PRIVATE); set_pref('plugin_sort_dir', $dir, 'plugin', 2, '', 0, PREF_PRIVATE); $switch_dir = $dir == 'desc' ? 'asc' : 'desc'; $rs = safe_rows_start('name, status, author, author_uri, version, description, length(help) as help, abs(strcmp(md5(code),code_md5)) as modified, load_order, flags', 'txp_plugin', '1 order by ' . $sort_sql); if ($rs and numRows($rs) > 0) { echo n . '<div id="' . $event . '_container" class="txp-container">'; echo '<form action="index.php" id="plugin_form" class="multi_edit_form" method="post" name="longform">' . n . '<div class="txp-listtables">' . n . startTable('', '', 'txp-list') . n . '<thead>' . tr(n . hCell(fInput('checkbox', 'select_all', 0, '', '', '', '', '', 'select_all'), '', ' title="' . gTxt('toggle_all_selected') . '" class="multi-edit"') . n . column_head('plugin', 'name', 'plugin', true, $switch_dir, '', '', ('name' == $sort ? "{$dir} " : '') . 'name') . n . column_head('author', 'author', 'plugin', true, $switch_dir, '', '', ('author' == $sort ? "{$dir} " : '') . 'author') . n . column_head('version', 'version', 'plugin', true, $switch_dir, '', '', ('version' == $sort ? "{$dir} " : '') . 'version') . n . column_head('plugin_modified', 'modified', 'plugin', true, $switch_dir, '', '', ('modified' == $sort ? "{$dir} " : '') . 'modified') . n . hCell(gTxt('description'), '', ' class="description"') . n . column_head('active', 'status', 'plugin', true, $switch_dir, '', '', ('status' == $sort ? "{$dir} " : '') . 'status') . n . column_head('order', 'load_order', 'plugin', true, $switch_dir, '', '', ('load_order' == $sort ? "{$dir} " : '') . 'load-order') . n . hCell(gTxt('manage'), '', ' class="manage actions"')) . n . '</thead>'; echo '<tbody>'; while ($a = nextRow($rs)) { foreach ($a as $key => $value) { ${$key} = txpspecialchars($value); } // Fix up the description for clean cases $description = preg_replace(array('#<br />#', '#<(/?(a|b|i|em|strong))>#', '#<a href="(https?|\\.|\\/|ftp)([A-Za-z0-9:/?.=_]+?)">#'), array('<br />', '<$1>', '<a href="$1$2">'), $description); $help = !empty($help) ? '<a class="plugin-help" href="?event=plugin' . a . 'step=plugin_help' . a . 'name=' . urlencode($name) . '">' . gTxt('help') . '</a>' : ''; $plugin_prefs = $flags & PLUGIN_HAS_PREFS ? '<a class="plugin-prefs" href="?event=plugin_prefs.' . urlencode($name) . '">' . gTxt('plugin_prefs') . '</a>' : ''; $manage = array(); if ($help) { $manage[] = $help; } if ($plugin_prefs) { $manage[] = $plugin_prefs; } $manage_items = $manage ? join(tag(sp . '|' . sp, 'span'), $manage) : '-'; $edit_url = eLink('plugin', 'plugin_edit', 'name', $name, $name); echo tr(n . td(fInput('checkbox', 'selected[]', $name), '', 'multi-edit') . td($edit_url, '', 'name') . td(href($author, $author_uri, ' rel="external"'), '', 'author') . td($version, '', 'version') . td($modified ? '<span class="warning">' . gTxt('yes') . '</span>' : '', '', 'modified') . td($description, '', 'description') . td(status_link($status, $name, yes_no($status)), '', 'status') . td($load_order, '', 'load-order') . td($manage_items, '', 'manage'), $status ? ' class="active"' : ''); unset($name, $page, $deletelink); } echo '</tbody>', n, endTable(), n, '</div>', n, plugin_multiedit_form('', $sort, $dir, '', ''), n, tInput(), n, '</form>', n, '</div>'; // Show/hide "Options" link by setting the appropriate class on the plugins TR echo script_js(<<<EOS textpattern.Relay.register('txpAsyncHref.success', function(event, data) { \t\$(data['this']).closest('tr').toggleClass('active'); }); EOS ); } }
function plugin_edit_form($name = '') { $sub = fInput('submit', '', gTxt('save'), 'publish'); $code = $name ? fetch('code', 'txp_plugin', 'name', $name) : ''; $help = $name ? fetch('help', 'txp_plugin', 'name', $name) : ''; $thing = $code ? $code : ''; $textarea = '<textarea name="code" rows="30" cols="90">' . $thing . '</textarea>'; return form(startTable('edit') . tr(td($textarea)) . tr(td($sub)) . tr(td($help)) . endTable() . sInput('plugin_save') . eInput('plugin') . hInput('name', $name)); }
function list_list($message = "", $post = '') { extract(get_prefs()); $lvars = array("page", "sort", "dir", "crit", 'method'); extract(gpsa($lvars)); global $statuses, $step; pagetop("Textpattern", $message); $total = getCount('textpattern', "1"); $limit = $article_list_pageby ? $article_list_pageby : 25; $numPages = ceil($total / $limit); $page = !$page ? 1 : $page; $offset = ($page - 1) * $limit; if (!$sort) { $sort = "Posted"; } if (!$dir) { $dir = "desc"; } if ($dir == "desc") { $linkdir = "asc"; } else { $linkdir = "desc"; } if ($crit) { $critsql = array('title_body' => "Title rlike '{$crit}' or Body rlike '{$crit}'", 'author' => "AuthorID rlike '{$crit}'", 'categories' => "Category1 rlike '{$crit}' or Category2 rlike '{$crit}'", 'section' => "Section rlike '{$crit}'", 'status' => "Status rlike '{$crit}'"); $criteria = $critsql[$method]; $limit = 500; } else { $criteria = 1; } $rs = safe_rows("*, unix_timestamp(Posted) as uPosted", "textpattern", "{$criteria} order by {$sort} {$dir} limit {$offset},{$limit}"); echo !$crit ? list_nav_form($page, $numPages, $sort, $dir) : '', list_searching_form($crit, $method); if ($rs) { echo '<form action="index.php" method="post" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">', startTable('list'), '<tr>', column_head('posted', 'Posted', 'list', 1, $linkdir), column_head('title', 'Title', 'list', 1, $linkdir), $use_sections ? column_head('section', 'Section', 'list', 1, $linkdir) : '', $use_categories ? column_head('category1', 'Category1', 'list', 1, $linkdir) . column_head('category2', 'Category2', 'list', 1, $linkdir) : '', hCell(gTxt('Author')), column_head(gTxt('status'), 'Status', 'list', 1, $linkdir), td(), '</tr>'; foreach ($rs as $a) { extract($a); if ($use_categories == 1) { $cat1 = $Category1; $cat2 = $Category2; } $stat = !empty($Status) ? $statuses[$Status] : ''; if ($use_sections == 1) { $sect = $Section; } $adate = date("d M y", $uPosted + $timeoffset); $alink = eLink('article', 'edit', 'ID', $ID, $adate); $tlink = eLink('article', 'edit', 'ID', $ID, $Title); $modbox = fInput('checkbox', 'selected[]', $ID); echo "<tr>" . n, td($alink), td($tlink, 200), $use_sections ? td($sect, 75) : '', $use_categories ? td($cat1, 75) . td($cat2, 75) : '', td($AuthorID), td($stat, 45), td($modbox), '</tr>' . n; } echo tr(tda(list_multiedit_form(), ' colspan="8" style="text-align:right;border:0px"')); echo "</table></form>"; echo pageby_form('list', $article_list_pageby); unset($sort); } }
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 page_list($current) { $rs = safe_rows_start("name", "txp_page", "name != '' order by name"); while ($a = nextRow($rs)) { extract($a); $dlink = $name != 'default' ? dLink('page', 'page_delete', 'name', $name) : ''; $link = '<a href="?event=page' . a . 'name=' . $name . '">' . $name . '</a>'; $out[] = $current == $name ? tr(td($name) . td($dlink)) : tr(td($link) . td($dlink)); } return startTable('list') . join(n, $out) . endTable(); }
function page_list($current) { $protected = safe_column('DISTINCT page', 'txp_section', '1=1') + array('error_default'); $rs = safe_rows_start('name', 'txp_page', "1 order by name asc"); while ($a = nextRow($rs)) { extract($a); $link = eLink('page', '', 'name', $name, $name); $dlink = !in_array($name, $protected) ? dLink('page', 'page_delete', 'name', $name) : ''; $out[] = $current == $name ? tr(td($name) . td($dlink)) : tr(td($link) . td($dlink)); } return startTable('list') . join(n, $out) . endTable(); }
function image_edit($message = '', $id = '') { if (!$id) { $id = gps('id'); } global $path_from_root, $txpcfg, $img_dir; pagetop('image', $message); $categories = getTree("root", "image"); $rs = safe_row("*", "txp_image", "id='{$id}'"); if ($rs) { extract($rs); echo startTable('list'), tr(td('<img src="' . $path_from_root . $img_dir . '/' . $id . $ext . '" height="' . $h . '" width="' . $w . '" alt="" />' . br . upload_form(gTxt('replace_image'), 'replace_image_form', 'image_replace', $id))), tr(td(join('', array($thumbnail ? '<img src="' . $path_from_root . $img_dir . '/' . $id . 't' . $ext . '" alt="" />' . br : '', upload_form(gTxt('upload_thumbnail'), 'upload_thumbnail', 'thumbnail_insert', $id))))), tr(td(form(graf(gTxt('image_name') . br . fInput('text', 'name', $name)) . graf(gTxt('image_category') . br . treeSelectInput('category', $categories, $category)) . graf(gTxt('alt_text') . br . fInput('text', 'alt', $alt, '', '', '', 50)) . graf(gTxt('caption') . br . text_area('caption', '100', '400', $caption)) . graf(fInput('submit', '', gTxt('save'))) . hInput('id', $id) . eInput('image') . sInput('image_save')))), endTable(); } }
function element_list($event, $step) { $message = ''; pagetop(gTxt('element'), $message); echo startTable('list') . assHead('element', 'version', 'date', 'active', 'checksum'); $rs = safe_rows('*', 'txp_element', '1=1'); foreach ($rs as $row) { extract($row); if ($hash) { $checksum = md5_file(txpath . '/elements/' . $name . '.php') == $hash ? gTxt('ok') : gTxt('modified'); } else { $checksum = gTxt('unknown'); } echo tr(td($name) . td($version) . td($modified) . td($status ? gTxt('yes') : gTxt('no')) . td($checksum)); } echo endTable(); }
function sec_section_list($message = '') { global $wlink; pagetop(gTxt('sections'), $message); $default = safe_row('page, css', 'txp_section', "name = 'default'"); $pages = safe_column('name', 'txp_page', "1 = 1"); $styles = safe_column('name', 'txp_css', "1 = 1"); echo n . n . startTable('list') . n . n . tr(tda(n . n . hed(gTxt('section_head') . sp . popHelp('section_category'), 1) . n . n . form(fInput('text', 'name', '', 'edit', '', '', 10) . fInput('submit', '', gTxt('create'), 'smallerbox') . eInput('section') . sInput('section_create')), ' colspan="3"')) . n . n . tr(td(gTxt('default')) . td(form('<table>' . tr(fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pages, $default['page']) . sp . popHelp('section_uses_page'), '', 'noline')) . tr(fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styles, $default['css']) . sp . popHelp('section_uses_css'), '', 'noline')) . tr(tda(fInput('submit', '', gTxt('save_button'), 'smallerbox') . eInput('section') . sInput('section_save') . hInput('name', 'default'), ' colspan="2" class="noline"')) . endTable())) . td()); $rs = safe_rows_start('*', 'txp_section', "name != 'default' order by name"); if ($rs) { while ($a = nextRow($rs)) { extract($a); echo n . n . tr(n . td($name) . n . td(form('<table>' . n . n . tr(fLabelCell(gTxt('section_name') . ':') . fInputCell('name', $name, 1, 20)) . n . n . tr(fLabelCell(gTxt('section_longtitle') . ':') . fInputCell('title', $title, 1, 20)) . n . n . tr(fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pages, $page) . sp . popHelp('section_uses_page'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styles, $css) . sp . popHelp('section_uses_css'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('selected_by_default')) . td(yesnoradio('is_default', $is_default, '', $name) . sp . popHelp('section_is_default'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('on_front_page')) . td(yesnoradio('on_frontpage', $on_frontpage, '', $name) . sp . popHelp('section_on_frontpage'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('syndicate')) . td(yesnoradio('in_rss', $in_rss, '', $name) . sp . popHelp('section_syndicate'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('include_in_search')) . td(yesnoradio('searchable', $searchable, '', $name) . sp . popHelp('section_searchable'), '', 'noline')) . n . n . tr(tda(fInput('submit', '', gTxt('save_button'), 'smallerbox') . eInput('section') . sInput('section_save') . hInput('old_name', $name), ' colspan="2" class="noline"')) . endTable(), '', '', 'post', '', 'section-' . $name)) . td(dLink('section', 'section_delete', 'name', $name, '', 'type', 'section')), " id=\"section-{$name}\""); } } echo n . n . endTable(); }
function sec_section_list($message = '') { global $wlink; pagetop(gTxt('sections'), $message); $default = safe_row('page, css', 'txp_section', "name = 'default'"); $home = safe_row('page, css', 'txp_section', "name = 'home'"); $pages = safe_column('name', 'txp_page', "1 = 1"); $styles = safe_column('name', 'txp_css', "1 = 1"); echo n . n . startTable('list') . n . n . tr(tda(n . n . hed(gTxt('section_head') . sp . popHelp('section_category'), 1) . n . n . form(fInput('text', 'name', '', 'edit', '', '', 10) . fInput('submit', '', gTxt('create'), 'smallerbox') . eInput('section') . sInput('section_create')), ' colspan="3"')) . n . n . tr(tda(gTxt('home'), ' onclick="toggleDisplay(\'section_home\'); return false;"') . td(form('<table id="section_home">' . tr(fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pages, $home['page']) . sp . popHelp('section_uses_page'), '', 'noline')) . tr(fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styles, $home['css']) . sp . popHelp('section_uses_css'), '', 'noline')) . pluggable_ui('section_ui', 'extend_detail_form', '', $home) . tr(tda(fInput('submit', '', gTxt('save_button'), 'smallerbox') . eInput('section') . sInput('section_save') . hInput('name', 'home'), ' colspan="2" class="noline"')) . endTable())) . td()) . n . n . tr(tda(gTxt('default'), ' onclick="toggleDisplay(\'section_default\'); return false;"') . td(form('<table id="section_default">' . tr(fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pages, $default['page']) . sp . popHelp('section_uses_page'), '', 'noline')) . tr(fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styles, $default['css']) . sp . popHelp('section_uses_css'), '', 'noline')) . pluggable_ui('section_ui', 'extend_detail_form', '', $default) . tr(tda(fInput('submit', '', gTxt('save_button'), 'smallerbox') . eInput('section') . sInput('section_save') . hInput('name', 'default'), ' colspan="2" class="noline"')) . endTable())) . td()); $rs = safe_rows_start('*', 'txp_section', "name != 'default' AND name != 'home' order by name"); if ($rs) { while ($a = nextRow($rs)) { extract($a); echo n . n . tr(n . tda($name, ' onclick="toggleDisplay(\'section_' . $name . '\'); return false;"') . n . td(form('<table id="section_' . $name . '">' . n . n . tr(fLabelCell(gTxt('section_name') . ':') . fInputCell('name', $name, 1, 20)) . n . n . tr(fLabelCell(gTxt('section_longtitle') . ':') . fInputCell('title', $title, 1, 20)) . n . n . tr(fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pages, $page) . sp . popHelp('section_uses_page'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styles, $css) . sp . popHelp('section_uses_css'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('selected_by_default')) . td(yesnoradio('is_default', $is_default, '', $name) . sp . popHelp('section_is_default'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('on_front_page')) . td(yesnoradio('on_frontpage', $on_frontpage, '', $name) . sp . popHelp('section_on_frontpage'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('syndicate')) . td(yesnoradio('in_rss', $in_rss, '', $name) . sp . popHelp('section_syndicate'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('include_in_search')) . td(yesnoradio('searchable', $searchable, '', $name) . sp . popHelp('section_searchable'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('section_descr') . ':') . fTextCell('descr', $descr, 1, 4, 20)) . n . n . tr(fLabelCell(gTxt('section_metakey') . ':') . fInputCell('metakey', $metakey, 1, 20)) . n . n . tr(fLabelCell(gTxt('section_metadesc') . ':') . fTextCell('metadesc', $metadesc, 1, 4, 20)) . pluggable_ui('section_ui', 'extend_detail_form', '', $a) . n . n . tr(tda(fInput('submit', '', gTxt('save_button'), 'smallerbox') . eInput('section') . sInput('section_save') . hInput('old_name', $name), ' colspan="2" class="noline"')) . endTable(), '', '', 'post', '', 'section-' . $name)) . td(dLink('section', 'section_delete', 'name', $name, '', 'type', 'section')), " id=\"section-{$name}\" class=\"jsection\" "); } } echo n . n . endTable(); }
function sec_section_list($message = '') { global $wlink, $event; pagetop(gTxt('sections'), $message); $default = safe_row('page, css, name', 'txp_section', "name = 'default'"); echo n . '<div id="' . $event . '_container" class="txp-container txp-list">'; echo n . n . startTable('list') . n . n . tr(tda(n . n . hed(gTxt('section_head') . sp . popHelp('section_category'), 2) . n . '<div id="' . $event . '_control" class="txp-control-panel">' . n . n . form(fInput('text', 'name', '', 'edit', '', '', 10) . fInput('submit', '', gTxt('create'), 'smallerbox') . eInput('section') . sInput('section_create'), '', '', 'post', 'edit-form', '', 'section_create') . n . '</div>', ' colspan="3"')) . n . n . tr(td(gTxt('default'), '', 'label') . n . td(section_detail_partial($default)) . n . td(), ' class="section default"'); $rs = safe_rows_start('*', 'txp_section', "name != 'default' order by name"); if ($rs) { $ctr = 1; while ($a = nextRow($rs)) { extract($a); echo n . n . tr(n . td($name, '', 'label') . n . td(section_detail_partial($a), '', 'main') . td(dLink('section', 'section_delete', 'name', $name, '', 'type', 'section'), '', 'actions'), ' id="section-' . $name . '" class="section ' . ($ctr % 2 == 0 ? 'even' : 'odd') . '"'); $ctr++; } } echo n . n . endTable() . '</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 sec_section_list($message = '') { global $wlink, $event; pagetop(gTxt('sections'), $message); $default = safe_row('page, css', 'txp_section', "name = 'default'"); $pages = safe_column('name', 'txp_page', "1 = 1"); $styles = safe_column('name', 'txp_css', "1 = 1"); echo n . '<div id="' . $event . '_container" class="txp-container txp-list">'; echo n . n . startTable('list') . n . n . tr(tda(n . n . hed(gTxt('section_head') . sp . popHelp('section_category'), 2) . n . '<div id="' . $event . '_control" class="txp-control-panel">' . n . n . form(fInput('text', 'name', '', 'edit', '', '', 10) . fInput('submit', '', gTxt('create'), 'smallerbox') . eInput('section') . sInput('section_create'), '', '', 'post', 'edit-form', '', 'section_create') . n . '</div>', ' colspan="3"')) . n . n . tr(td(gTxt('default'), '', 'label') . td(form('<table>' . tr(fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pages, $default['page']) . sp . popHelp('section_uses_page'), '', 'noline'), ' class="uses-page"') . tr(fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styles, $default['css']) . sp . popHelp('section_uses_css'), '', 'noline'), ' class="uses-style"') . pluggable_ui('section_ui', 'extend_detail_form', '', $default) . tr(tda(fInput('submit', '', gTxt('save_button'), 'smallerbox') . eInput('section') . sInput('section_save') . hInput('name', 'default'), ' colspan="2" class="noline"')) . endTable())) . td(), ' class="section default"'); $rs = safe_rows_start('*', 'txp_section', "name != 'default' order by name"); if ($rs) { $ctr = 1; while ($a = nextRow($rs)) { extract($a); echo n . n . tr(n . td($name, '', 'label') . n . td(form('<table>' . n . n . tr(fLabelCell(gTxt('section_name') . ':') . fInputCell('name', $name, 1, 20), ' class="name"') . n . n . tr(fLabelCell(gTxt('section_longtitle') . ':') . fInputCell('title', $title, 1, 20), ' class="title"') . n . n . tr(fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pages, $page) . sp . popHelp('section_uses_page'), '', 'noline'), ' class="uses-page"') . n . n . tr(fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styles, $css) . sp . popHelp('section_uses_css'), '', 'noline'), ' class="uses-style"') . n . n . tr(fLabelCell(gTxt('selected_by_default')) . td(yesnoradio('is_default', $is_default, '', $name) . sp . popHelp('section_is_default'), '', 'noline'), ' class="option is-default"') . n . n . tr(fLabelCell(gTxt('on_front_page')) . td(yesnoradio('on_frontpage', $on_frontpage, '', $name) . sp . popHelp('section_on_frontpage'), '', 'noline'), ' class="option on-frontpage"') . n . n . tr(fLabelCell(gTxt('syndicate')) . td(yesnoradio('in_rss', $in_rss, '', $name) . sp . popHelp('section_syndicate'), '', 'noline'), ' class="option in-rss"') . n . n . tr(fLabelCell(gTxt('include_in_search')) . td(yesnoradio('searchable', $searchable, '', $name) . sp . popHelp('section_searchable'), '', 'noline'), ' class="option is-searchable"') . pluggable_ui('section_ui', 'extend_detail_form', '', $a) . n . n . tr(tda(fInput('submit', '', gTxt('save_button'), 'smallerbox') . eInput('section') . sInput('section_save') . hInput('old_name', $name), ' colspan="2" class="noline"')) . endTable(), '', '', 'post', '', 'section-' . $name), '', 'main') . td(dLink('section', 'section_delete', 'name', $name, '', 'type', 'section'), '', 'actions'), ' id="section-' . $name . '" class="section ' . ($ctr % 2 == 0 ? 'even' : 'odd') . '"'); $ctr++; } } echo n . n . endTable() . '</div>'; }
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_edit($message = "") { global $vars, $step; extract(gpsa($vars)); pagetop(gTxt('edit_links', $message)); $id = gps('id'); if ($id && $step == 'link_edit') { extract(safe_row("*", "txp_link", "id = {$id}")); } if ($step == 'link_save' or $step == 'link_post') { foreach ($vars as $var) { ${$var} = ''; } } $textarea = '<textarea name="description" cols="40" rows="7" tabindex="4">' . $description . '</textarea>'; $selects = linkcategory_popup($category); $editlink = ' [' . eLink('category', 'list', '', '', gTxt('edit')) . ']'; $out = startTable('edit') . tr(fLabelCell('title') . fInputCell('linkname', $linkname, 1, 30)) . tr(fLabelCell('sort_value') . fInputCell('linksort', $linksort, 2, 15)) . tr(fLabelCell('url', 'link_url') . fInputCell('url', $url, 3, 30)) . tr(fLabelCell('link_category', 'link_category') . td($selects . $editlink)) . tr(fLabelCell('description', 'link_description') . tda($textarea, ' valign="top"')) . tr(td() . td(fInput("submit", '', gTxt('save'), "publish"))) . endTable() . eInput('link') . sInput($step == 'link_edit' ? 'link_save' : 'link_post') . hInput('id', $id); echo form($out); echo link_list(); }
function tc_shopping_cart_detail($atts) { session_start(); extract(lAtts(array('checkout_section' => 'checkout'), $atts)); $cart = $_SESSION['cart']; if (empty($cart)) { $cart = new bckCart(); } if (isset($_REQUEST['empty_cart'])) { $cart->empty_cart(); $_SESSION['cart'] = $cart; } $cartHTML = startTable("shopping_cart") . tr(n . hCell("Item") . n . hCell("Quantity") . n . hCell("Price") . n . hCell("Subtotal")); foreach ($cart->items as $product) { $image = '<img src="' . product_image_display($product['image'], "small") . '" alt="Product Detail" class="thumb"/>'; $link = "<a href='" . permlinkurl_id($product['ID']) . "' title='View product detail'>" . $product['name'] . "</a>"; $cartHTML .= tr(n . td($image . $link) . n . td($product['qty']) . n . td(_tc_price_format($product['price'])) . n . td(_tc_price_format($product['price']))); } $cartHTML .= endTable(); $cartHTML .= tag(tag(tag("Empty Cart", "a", " href='?empty_cart=true' class='cartAction' id='emptyCart'"), "li") . tag(tag("Continue Shopping", "a", " href='#' class='cartAction' id='continueShopping'"), "li") . tag(tag("Checkout", "a", " href='/{$checkout_section}/' class='cartAction' id='checkout'"), "li") . tag(tag(_tc_price_format($cart->total), "span", " class='cartTotal'"), "li"), "ul"); return $cartHTML; }
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()); }
/** * Processes the selected import tool action. * * Basically does the importing. */ function start_import() { global $event, $vars; extract(psa($vars)); $insert_into_section = $import_section; $insert_with_status = $import_status; $default_comment_invite = $import_comments_invite; include_once txpath . '/include/import/import_' . $import_tool . '.php'; $ini_time = ini_get('max_execution_time'); @ini_set('max_execution_time', 300 + intval($ini_time)); switch ($import_tool) { case 'mtdb': $out = doImportMTDB($importdblogin, $importdb, $importdbpass, $importdbhost, $import_blog_id, $insert_into_section, $insert_with_status, $default_comment_invite); rebuild_tree('root', 1, 'article'); break; case 'mt': $file = check_import_file(); if (!empty($file)) { $out = doImportMT($file, $insert_into_section, $insert_with_status, $import_comments_invite); // Rebuilding category tree. rebuild_tree('root', 1, 'article'); } else { $out = 'Import file not found'; } break; case 'b2': $out = doImportB2($importdblogin, $importdb, $importdbpass, $importdbhost, $insert_into_section, $insert_with_status, $default_comment_invite); break; case 'wp': $out = doImportWP($importdblogin, $importdb, $importdbpass, $importdbhost, $wpdbprefix, $insert_into_section, $insert_with_status, $default_comment_invite, $wpdbcharset); rebuild_tree('root', 1, 'article'); break; case 'blogger': $file = check_import_file(); if (!empty($file)) { $out = doImportBLOGGER($file, $insert_into_section, $insert_with_status, $import_comments_invite); } else { $out = gTxt('import_file_not_found'); } break; } $out = tag('max_execution_time = ' . ini_get('max_execution_time'), 'p', ' class="highlight"') . $out; pagetop(gTxt('txp_import')); $content = '<div id="' . $event . '_container" class="txp-container">'; $content .= startTable('', '', 'txp-list'); $content .= tr(tdcs(hed(gTxt('txp_import'), 2), 2)); $content .= tr(td($out)); $content .= endTable(); $content .= '</div>'; echo $content; $rs = safe_rows_start('parentid, count(*) as thecount', 'txp_discuss', 'visible=1 group by parentid'); if (numRows($rs) > 0) { while ($a = nextRow($rs)) { safe_update('textpattern', "comments_count=" . $a['thecount'], "ID=" . $a['parentid']); } } }
function customers_list($event = '', $step = '', $message = '') { global $statuses, $comments_disabled_after, $step, $txp_user; pagetop("Customers", $message); extract(get_prefs()); extract(gpsa(array('page', 'sort', 'dir', 'crit', 'qty', 'search_method'))); $sesutats = array_flip($statuses); $dir = $dir == 'desc' ? 'desc' : 'asc'; switch ($sort) { case 'RealName': $sort_sql = 'RealName ' . $dir; break; case 'orders': $sort_sql = 'orders ' . $dir; break; default: $dir = 'desc'; $sort_sql = 'user_id ' . $dir; break; } $switch_dir = $dir == 'desc' ? 'asc' : 'desc'; $criteria = "privs = 0"; if ($search_method and $crit) { $crit_escaped = doSlash($crit); $critsql = array('id' => "ID = '{$crit_escaped}'", 'title_body' => "Title rlike '{$crit_escaped}' or Body rlike '{$crit_escaped}'", 'section' => "Section rlike '{$crit_escaped}'", 'categories' => "Category1 rlike '{$crit_escaped}' or Category2 rlike '{$crit_escaped}'", 'status' => "Status = '" . @$sesutats[gTxt($crit_escaped)] . "'", 'author' => "AuthorID rlike '{$crit_escaped}'"); if (array_key_exists($search_method, $critsql)) { $criteria = $critsql[$search_method]; $limit = 500; } else { $search_method = ''; $crit = ''; } } else { $search_method = ''; $crit = ''; } $total = safe_count('txp_users', "{$criteria}"); if (isset($qty)) { $customers_list_pageby = $qty; } else { $customers_list_pageby = 15; } $limit = max(@$customers_list_pageby, 15); list($page, $offset, $numPages) = pager($total, $limit, $page); $rs = safe_rows_start('*', 'txp_users', "{$criteria} order by {$sort_sql} limit {$offset}, {$limit}"); $customersOnPage = $offset + $limit; if ($rs) { echo n . n . '<form name="longform" method="post" action="index.php" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">' . n . startTable('list', '', '', '', '700') . n . tr(n . tda("Displaying {$offset} - {$customersOnPage} of {$total} customers", ' colspan="2" style="border: none; padding-bottom: 15px;"') . n . tda('<a href="?event=customers&step=edit_customer" class="navlink">Add a new customer</a> <a href="?event=customers&step=export_customer" class="navlink">Export customers</a>', ' colspan="2" style="text-align: right; border: none; padding-bottom: 15px;"')) . n . tr(n . column_head('Customer', 'RealName', 'customers', true, $switch_dir, $crit, $search_method) . column_head('Phone', 'shipping_phone', 'customers', true, $switch_dir, $crit, $search_method) . column_head('Email', 'email', 'customers', true, $switch_dir, $crit, $search_method) . column_head('Orders', 'order_num', 'customers', true, $switch_dir, $crit, $search_method)); include_once txpath . '/publish/taghandlers.php'; while ($a = nextRow($rs)) { extract($a); $order_num = safe_count("orders", "user_id = {$user_id}"); $RealName = eLink('customers', 'edit_customer', 'user_id', $user_id, $RealName); $Orders = eLink('order', 'edit', 'customer', $name, $order_num); echo n . n . tr(n . td($RealName, "25%") . td($billing_phone, "25%") . td($email, "25%") . td($Orders, "25%")); } echo n . endTable() . n . '</form>' . n . nav_form('customers', $page, $numPages, $sort, $dir, $crit, $search_method) . n . pageby_form('customers', $customers_list_pageby); } }
function getTxpLogin() { $carry = postDecode(ps('carry')); extract($carry); $GLOBALS['textarray'] = setup_load_lang($lang); @(include txpath . '/config.php'); if (!isset($txpcfg) || $txpcfg['db'] != $ddb || $txpcfg['table_prefix'] != $dprefix) { echo graf(strong(gTxt('before_you_proceed')) . ', ' . gTxt('create_config', array('{txpath}' => txpath))), '<textarea style="width:400px;height:200px" name="config" rows="1" cols="1">', makeConfig($carry), '</textarea>', '<form action="' . $GLOBALS['rel_siteurl'] . '/textpattern/setup/index.php" method="post">', fInput('submit', 'submit', gTxt('did_it'), 'smallbox'), sInput('getTxpLogin'), hInput('carry', postEncode($carry)), '</form>'; return; } echo '<form action="' . $GLOBALS['rel_siteurl'] . '/textpattern/setup/index.php" method="post">', startTable('edit'), tr(tda(graf(gTxt('thanks')) . graf(gTxt('about_to_create')), ' width="400" colspan="2" align="center"')), tr(fLabelCell(gTxt('your_full_name')) . fInputCell('RealName')), tr(fLabelCell(gTxt('setup_login')) . fInputCell('name')), tr(fLabelCell(gTxt('choose_password')) . fInputCell('pass')), tr(fLabelCell(gTxt('your_email')) . fInputCell('email')), tr(td() . td(fInput('submit', 'Submit', gTxt('next'), 'publish'))), endTable(), sInput('createTxp'), hInput('lang', htmlspecialchars($lang)), hInput('siteurl', htmlspecialchars($siteurl)), '</form>'; }
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(); }
function tag_file_download_link() { global $step, $endform, $name; $invars = gpsa(array('filename', 'id')); extract($invars); $out = form(startTable('list') . tr(tdcs(hed(gTxt('tag_file_download_link'), 3), 2)) . tagRow('id', fInput('text', 'id', $id, 'edit', '', '', 4)) . tagRow('filename', fInput('text', 'filename', $filename, 'edit', '', '', 15)) . $endform); $out .= tdb(tb('file_download_link', $invars, gTxt('text_or_tag'))); return $out; }
function article_edit($message = '', $concurrent = FALSE) { global $vars, $txp_user, $comments_disabled_after, $txpcfg, $prefs; extract($prefs); extract(gpsa(array('view', 'from_view', 'step'))); if (!empty($GLOBALS['ID'])) { // newly-saved article $ID = $GLOBALS['ID']; $step = 'edit'; } else { $ID = gps('ID'); } include_once txpath . '/lib/classTextile.php'; $textile = new Textile(); // switch to 'text' view upon page load and after article post if (!$view || gps('save') || gps('publish')) { $view = 'text'; } if (!$step) { $step = "create"; } if ($step == "edit" && $view == "text" && !empty($ID) && $from_view != 'preview' && $from_view != 'html' && !$concurrent) { $pull = true; //-- it's an existing article - off we go to the db $ID = assert_int($ID); $rs = safe_row("*, unix_timestamp(Posted) as sPosted,\n\t\t\t\tunix_timestamp(Expires) as sExpires,\n\t\t\t\tunix_timestamp(LastMod) as sLastMod", "textpattern", "ID={$ID}"); extract($rs); $reset_time = $publish_now = $Status < 4; } else { $pull = false; //-- assume they came from post if ($from_view == 'preview' or $from_view == 'html') { $store_out = array(); $store = unserialize(base64_decode(ps('store'))); foreach ($vars as $var) { if (isset($store[$var])) { $store_out[$var] = $store[$var]; } } } else { $store_out = gpsa($vars); if ($concurrent) { $store_out['sLastMod'] = safe_field('unix_timestamp(LastMod) as sLastMod', 'textpattern', 'ID=' . $ID); } } extract($store_out); } $GLOBALS['step'] = $step; if ($step == 'create') { $textile_body = $use_textile; $textile_excerpt = $use_textile; } if ($step != 'create') { // Previous record? $prev_id = checkIfNeighbour('prev', $sPosted); // Next record? $next_id = checkIfNeighbour('next', $sPosted); } $page_title = $Title ? $Title : gTxt('write'); pagetop($page_title, $message); echo n . n . '<form name="article" method="post" action="index.php">'; if (!empty($store_out)) { echo hInput('store', base64_encode(serialize($store_out))); } echo hInput('ID', $ID) . eInput('article') . sInput($step) . '<input type="hidden" name="view" />' . startTable('edit') . '<tr>' . n . '<td id="article-col-1">'; if ($view == 'text') { //-- markup help -------------- echo side_help($textile_body, $textile_excerpt) . '<h3 class="plain"><a href="#advanced" onclick="toggleDisplay(\'advanced\'); return false;">' . gTxt('advanced_options') . '</a></h3>', '<div id="advanced" class="toggle" style="display:none">', n . graf('<label for="markup-body">' . gTxt('article_markup') . '</label>' . br . pref_text('textile_body', $textile_body, 'markup-body')), n . graf('<label for="markup-excerpt">' . gTxt('excerpt_markup') . '</label>' . br . pref_text('textile_excerpt', $textile_excerpt, 'markup-excerpt')), $allow_form_override ? graf('<label for="override-form">' . gTxt('override_default_form') . '</label>' . sp . popHelp('override_form') . br . form_pop($override_form, 'override-form')) : '', $custom_1_set ? custField(1, $custom_1_set, $custom_1) : '', $custom_2_set ? custField(2, $custom_2_set, $custom_2) : '', $custom_3_set ? custField(3, $custom_3_set, $custom_3) : '', $custom_4_set ? custField(4, $custom_4_set, $custom_4) : '', $custom_5_set ? custField(5, $custom_5_set, $custom_5) : '', $custom_6_set ? custField(6, $custom_6_set, $custom_6) : '', $custom_7_set ? custField(7, $custom_7_set, $custom_7) : '', $custom_8_set ? custField(8, $custom_8_set, $custom_8) : '', $custom_9_set ? custField(9, $custom_9_set, $custom_9) : '', $custom_10_set ? custField(10, $custom_10_set, $custom_10) : '', n . graf('<label for="keywords">' . gTxt('keywords') . '</label>' . sp . popHelp('keywords') . br . n . '<textarea id="keywords" name="Keywords" cols="18" rows="5">' . htmlspecialchars(str_replace(',', ', ', $Keywords)) . '</textarea>'), n . graf('<label for="article-image">' . gTxt('article_image') . '</label>' . sp . popHelp('article_image') . br . fInput('text', 'Image', $Image, 'edit', '', '', 22, '', 'article-image')), n . graf('<label for="url-title">' . gTxt('url_title') . '</label>' . sp . popHelp('url_title') . br . fInput('text', 'url_title', $url_title, 'edit', '', '', 22, '', 'url-title')), '</div> <h3 class="plain"><a href="#recent" onclick="toggleDisplay(\'recent\'); return false;">' . gTxt('recent_articles') . '</a>' . '</h3>' . '<div id="recent" class="toggle" style="display:none">'; $recents = safe_rows_start("Title, ID", 'textpattern', "1=1 order by LastMod desc limit 10"); if ($recents) { echo '<ul class="plain-list">'; while ($recent = nextRow($recents)) { if (!$recent['Title']) { $recent['Title'] = gTxt('untitled') . sp . $recent['ID']; } echo n . t . '<li><a href="?event=article' . a . 'step=edit' . a . 'ID=' . $recent['ID'] . '">' . escape_title($recent['Title']) . '</a></li>'; } echo '</ul>'; } echo '</div>'; } else { echo sp; } echo '</td>' . n . '<td id="article-main">'; //-- title input -------------- if ($view == 'preview') { echo hed(gTxt('preview'), 2) . hed($Title, 1); } elseif ($view == 'html') { echo hed('XHTML', 2) . hed($Title, 1); } elseif ($view == 'text') { echo n . '<p><label for="title">' . gTxt('title') . '</label>' . sp . popHelp('title') . br . '<input type="text" id="title" name="Title" value="' . escape_title($Title) . '" class="edit" size="40" tabindex="1" />'; if ($step != 'create') { include_once txpath . '/publish/taghandlers.php'; $url = permlinkurl_id($ID); if ($Status != 4 and $Status != 5) { $url .= (strpos($url, '?') === FALSE ? '?' : '&') . 'txpreview=' . intval($ID) . '.' . time(); } echo sp . sp . '<a href="' . $url . '" class="article-view">' . gTxt('view') . '</a>'; } echo '</p>'; } //-- body -------------------- if ($view == 'preview') { if ($textile_body == USE_TEXTILE) { echo $textile->TextileThis($Body); } else { if ($textile_body == CONVERT_LINEBREAKS) { echo nl2br($Body); } else { if ($textile_body == LEAVE_TEXT_UNTOUCHED) { echo $Body; } } } } elseif ($view == 'html') { if ($textile_body == USE_TEXTILE) { $bod = $textile->TextileThis($Body); } else { if ($textile_body == CONVERT_LINEBREAKS) { $bod = nl2br($Body); } else { if ($textile_body == LEAVE_TEXT_UNTOUCHED) { $bod = $Body; } } } echo tag(str_replace(array(n, t), array(br, sp . sp . sp . sp), htmlspecialchars($bod)), 'code'); } else { echo n . graf('<label for="body">' . gTxt('body') . '</label>' . sp . popHelp('body') . br . '<textarea id="body" name="Body" cols="55" rows="31" tabindex="2">' . htmlspecialchars($Body) . '</textarea>'); } //-- excerpt -------------------- if ($articles_use_excerpts) { if ($view == 'text') { echo n . graf('<label for="excerpt">' . gTxt('excerpt') . '</label>' . sp . popHelp('excerpt') . br . '<textarea id="excerpt" name="Excerpt" cols="55" rows="5" tabindex="3">' . htmlspecialchars($Excerpt) . '</textarea>'); } else { echo n . '<hr width="50%" />'; echo $textile_excerpt == USE_TEXTILE ? $view == 'preview' ? graf($textile->textileThis($Excerpt)) : tag(str_replace(array(n, t), array(br, sp . sp . sp . sp), htmlspecialchars($textile->TextileThis($Excerpt))), 'code') : graf($Excerpt); } } //-- author -------------- if ($view == "text" && $step != "create") { echo '<p class="small">' . gTxt('posted_by') . ': ' . htmlspecialchars($AuthorID) . ' · ' . safe_strftime('%d %b %Y · %X', $sPosted); if ($sPosted != $sLastMod) { echo br . gTxt('modified_by') . ': ' . htmlspecialchars($LastModID) . ' · ' . safe_strftime('%d %b %Y · %X', $sLastMod); } echo '</p>'; } echo hInput('from_view', $view), '</td>'; echo '<td id="article-tabs">'; //-- layer tabs ------------------- echo $use_textile == USE_TEXTILE || $textile_body == USE_TEXTILE ? '<ul>' . (tab('text', $view) . tab('html', $view) . tab('preview', $view)) . '</ul>' : ' '; echo '</td>'; echo '<td id="article-col-2">'; if ($view == 'text') { if ($step != 'create') { echo n . graf(href(gtxt('create_new'), 'index.php?event=article')); } //-- prev/next article links -- if ($step != 'create' and ($prev_id or $next_id)) { echo '<p>', $prev_id ? prevnext_link('‹' . gTxt('prev'), 'article', 'edit', $prev_id, gTxt('prev')) : '', $next_id ? prevnext_link(gTxt('next') . '›', 'article', 'edit', $next_id, gTxt('next')) : '', '</p>'; } //-- status radios -------------- echo n . n . '<fieldset id="write-status">' . n . '<legend>' . gTxt('status') . '</legend>' . n . status_radio($Status) . n . '</fieldset>'; //-- category selects ----------- echo n . n . '<fieldset id="write-sort">' . n . '<legend>' . gTxt('sort_display') . '</legend>' . n . graf('<label for="category-1">' . gTxt('category1') . '</label> ' . '<span class="small">[' . eLink('category', '', '', '', gTxt('edit')) . ']</span>' . br . n . category_popup('Category1', $Category1, 'category-1')) . n . graf('<label for="category-2">' . gTxt('category2') . '</label>' . br . n . category_popup('Category2', $Category2, 'category-2')); //-- section select -------------- if (!$from_view && !$pull) { $Section = getDefaultSection(); } echo n . graf('<label for="section">' . gTxt('section') . '</label> ' . '<span class="small">[' . eLink('section', '', '', '', gTxt('edit')) . ']</span>' . br . section_popup($Section, 'section')) . n . '</fieldset>' . n . n . '<h3 class="plain"><a href="#more" onclick="toggleDisplay(\'more\'); return false;">' . gTxt('more') . '</a></h3>', '<div id="more" class="toggle" style="display:none">'; //-- comments stuff -------------- if ($step == "create") { //Avoiding invite disappear when previewing $AnnotateInvite = !empty($store_out['AnnotateInvite']) ? $store_out['AnnotateInvite'] : $comments_default_invite; if ($comments_on_default == 1) { $Annotate = 1; } } if ($use_comments == 1) { echo n . n . '<fieldset id="write-comments">' . n . '<legend>' . gTxt('comments') . '</legend>'; $comments_expired = false; if ($step != 'create' && $comments_disabled_after) { $lifespan = $comments_disabled_after * 86400; $time_since = time() - $sPosted; if ($time_since > $lifespan) { $comments_expired = true; } } if ($comments_expired) { echo n . n . graf(gTxt('expired')); } else { echo n . n . graf(onoffRadio('Annotate', $Annotate)) . n . n . graf('<label for="comment-invite">' . gTxt('comment_invitation') . '</label>' . br . fInput('text', 'AnnotateInvite', $AnnotateInvite, 'edit', '', '', '', '', 'comment-invite')); } echo n . n . '</fieldset>'; } if ($step == "create" and empty($GLOBALS['ID'])) { //-- timestamp ------------------- //Avoiding modified date to disappear $persist_timestamp = !empty($store_out['year']) ? safe_strtotime($store_out['year'] . '-' . $store_out['month'] . '-' . $store_out['day'] . ' ' . $store_out['hour'] . ':' . $store_out['minute'] . ':' . $store_out['second']) : time(); echo n . n . '<fieldset id="write-timestamp">' . n . '<legend>' . gTxt('timestamp') . '</legend>' . n . graf(checkbox('publish_now', '1', $publish_now, '', 'publish_now') . '<label for="publish_now">' . gTxt('set_to_now') . '</label>') . n . graf(gTxt('or_publish_at') . sp . popHelp('timestamp')) . n . graf(gtxt('date') . sp . tsi('year', '%Y', $persist_timestamp) . ' / ' . tsi('month', '%m', $persist_timestamp) . ' / ' . tsi('day', '%d', $persist_timestamp)) . n . graf(gTxt('time') . sp . tsi('hour', '%H', $persist_timestamp) . ' : ' . tsi('minute', '%M', $persist_timestamp) . ' : ' . tsi('second', '%S', $persist_timestamp)) . n . '</fieldset>'; //-- expires ------------------- $persist_timestamp = !empty($store_out['exp_year']) ? safe_strtotime($store_out['exp_year'] . '-' . $store_out['exp_month'] . '-' . $store_out['exp_day'] . ' ' . $store_out['exp_hour'] . ':' . $store_out['exp_minute'] . ':' . $store_out['second']) : NULLDATETIME; echo n . n . '<fieldset id="write-expires">' . n . '<legend>' . gTxt('expires') . '</legend>' . n . graf(gtxt('date') . sp . tsi('exp_year', '%Y', $persist_timestamp) . ' / ' . tsi('exp_month', '%m', $persist_timestamp) . ' / ' . tsi('exp_day', '%d', $persist_timestamp)) . n . graf(gTxt('time') . sp . tsi('exp_hour', '%H', $persist_timestamp) . ' : ' . tsi('exp_minute', '%M', $persist_timestamp) . ' : ' . tsi('exp_second', '%S', $persist_timestamp)) . n . '</fieldset>' . n . n . '</div>'; //-- publish button -------------- echo has_privs('article.publish') ? fInput('submit', 'publish', gTxt('publish'), "publish", '', '', '', 4) : fInput('submit', 'publish', gTxt('save'), "publish", '', '', '', 4); } else { //-- timestamp ------------------- if (!empty($year)) { $sPosted = safe_strtotime($year . '-' . $month . '-' . $day . ' ' . $hour . ':' . $minute . ':' . $second); } echo n . n . '<fieldset id="write-timestamp">' . n . '<legend>' . gTxt('timestamp') . '</legend>' . n . graf(checkbox('reset_time', '1', $reset_time, '', 'reset_time') . '<label for="reset_time">' . gTxt('reset_time') . '</label>') . n . graf(gTxt('published_at') . sp . popHelp('timestamp')) . n . graf(gtxt('date') . sp . tsi('year', '%Y', $sPosted) . ' / ' . tsi('month', '%m', $sPosted) . ' / ' . tsi('day', '%d', $sPosted)) . n . graf(gTxt('time') . sp . tsi('hour', '%H', $sPosted) . ' : ' . tsi('minute', '%M', $sPosted) . ' : ' . tsi('second', '%S', $sPosted)) . n . hInput('sPosted', $sPosted), n . hInput('sLastMod', $sLastMod), n . hInput('AuthorID', $AuthorID), n . hInput('LastModID', $LastModID), n . '</fieldset>'; //-- expires ------------------- if (!empty($exp_year)) { if (empty($exp_month)) { $exp_month = 1; } if (empty($exp_day)) { $exp_day = 1; } if (empty($exp_hour)) { $exp_hour = 0; } if (empty($exp_minute)) { $exp_minute = 0; } if (empty($exp_second)) { $exp_second = 0; } $sExpires = safe_strtotime($exp_year . '-' . $exp_month . '-' . $exp_day . ' ' . $exp_hour . ':' . $exp_minute . ':' . $exp_second); } echo n . n . '<fieldset id="write-expires">' . n . '<legend>' . gTxt('expires') . '</legend>' . n . graf(gtxt('date') . sp . tsi('exp_year', '%Y', $sExpires) . ' / ' . tsi('exp_month', '%m', $sExpires) . ' / ' . tsi('exp_day', '%d', $sExpires)) . n . graf(gTxt('time') . sp . tsi('exp_hour', '%H', $sExpires) . ' : ' . tsi('exp_minute', '%M', $sExpires) . ' : ' . tsi('exp_second', '%S', $sExpires)) . n . hInput('sExpires', $sExpires) . n . '</fieldset>' . n . n . '</div>'; //-- save button -------------- if ($Status >= 4 and has_privs('article.edit.published') or $Status >= 4 and $AuthorID == $txp_user and has_privs('article.edit.own.published') or $Status < 4 and has_privs('article.edit') or $Status < 4 and $AuthorID == $txp_user and has_privs('article.edit.own')) { echo fInput('submit', 'save', gTxt('save'), "publish", '', '', '', 4); } } } echo '</td></tr></table></form>'; }
function form_edit($message = '') { global $step, $essential_forms; pagetop(gTxt('edit_forms'), $message); extract(gpsa(array('Form', 'name', 'type'))); $name = trim(preg_replace('/[<>&"\']/', '', $name)); if ($step == 'form_create') { $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='" . doSlash($name) . "'"); extract($rs); $inputs = fInput('submit', 'save', gTxt('save'), 'publish') . eInput("form") . sInput('form_save') . hInput('oldname', $name); } if (!in_array($name, $essential_forms)) { $changename = graf(gTxt('form_name') . br . fInput('text', 'name', $name, 'edit', '', '', 15)); } else { $changename = graf(gTxt('form_name') . br . tag($name, 'em') . hInput('name', $name)); } $out = startTable('edit') . tr(tdtl(hed(gTxt('tagbuilder'), 2) . hed('<a href="#article-tags" onclick="toggleDisplay(\'article-tags\'); return false;">' . gTxt('articles') . '</a>' . sp . popHelp('form_articles'), 3, ' class="plain"') . '<div id="article-tags" class="toggle on" style="display:block">' . popTagLinks('article') . '</div>' . hed('<a href="#link-tags" onclick="toggleDisplay(\'link-tags\'); return false;">' . gTxt('links') . '</a>' . sp . popHelp('form_place_link'), 3, ' class="plain"') . '<div id="link-tags" class="toggle" style="display:none">' . popTagLinks('link') . '</div>' . hed('<a href="#comment-tags" onclick="toggleDisplay(\'comment-tags\'); return false;">' . gTxt('comments') . '</a>' . sp . popHelp('form_comments'), 3, ' class="plain"') . '<div id="comment-tags" class="toggle" style="display:none">' . popTagLinks('comment') . '</div>' . hed('<a href="#comment-detail-tags" onclick="toggleDisplay(\'comment-detail-tags\'); return false;">' . gTxt('comment_details') . '</a>' . sp . popHelp('form_comment_details'), 3, ' class="plain"') . '<div id="comment-detail-tags" class="toggle" style="display:none">' . popTagLinks('comment_details') . '</div>' . hed('<a href="#comment-form-tags" onclick="toggleDisplay(\'comment-form-tags\'); return false;">' . gTxt('comment_form') . '</a>' . sp . popHelp('form_comment_form'), 3, ' class="plain"') . '<div id="comment-form-tags" class="toggle" style="display:none">' . popTagLinks('comment_form') . '</div>' . hed('<a href="#search-result-tags" onclick="toggleDisplay(\'search-result-tags\'); return false;">' . gTxt('search_results_form') . '</a>' . sp . popHelp('form_search_results'), 3, ' class="plain"') . '<div id="search-result-tags" class="toggle" style="display:none">' . popTagLinks('search_result') . '</div>' . hed('<a href="#file-tags" onclick="toggleDisplay(\'file-tags\'); return false;">' . gTxt('file_download_tags') . '</a>' . sp . popHelp('form_file_download_tags'), 3, ' class="plain"') . '<div id="file-tags" class="toggle" style="display:none">' . popTagLinks('file_download') . '</div>' . hed('<a href="#category-tags" onclick="toggleDisplay(\'category-tags\'); return false;">' . gTxt('category_tags') . '</a>' . sp . popHelp('form_category_tags'), 3, ' class="plain"') . '<div id="category-tags" class="toggle" style="display:none">' . popTagLinks('category') . '</div>' . hed('<a href="#section-tags" onclick="toggleDisplay(\'section-tags\'); return false;">' . gTxt('section_tags') . '</a>' . sp . popHelp('form_section_tags'), 3, ' class="plain"') . '<div id="section-tags" class="toggle" style="display:none">' . popTagLinks('section') . '</div>') . tdtl('<form action="index.php" method="post">' . '<textarea id="form" class="code" name="Form" cols="60" rows="20">' . htmlspecialchars($Form) . '</textarea>' . $changename . graf(gTxt('form_type') . br . formtypes($type)) . graf(gTxt('only_articles_can_be_previewed')) . fInput('submit', 'form_preview', gTxt('preview'), 'smallbox') . graf($inputs) . '</form>') . tdtl(form_list($name))) . endTable(); echo $out; }