function discuss_list($message = '') { pagetop(gTxt('list_discussions'), $message); extract(doSlash(gpsa(array('page', 'crit')))); extract(get_prefs()); $total = safe_count('txp_discuss', "1=1"); $limit = max(@$comment_list_pageby, 25); $numPages = ceil($total / $limit); $page = !$page ? 1 : $page; $offset = ($page - 1) * $limit; $nav[] = $page > 1 ? PrevNextLink("discuss", $page - 1, gTxt('prev'), 'prev') : ''; $nav[] = sp . small($page . '/' . $numPages) . sp; $nav[] = $page != $numPages ? PrevNextLink("discuss", $page + 1, gTxt('next'), 'next') : ''; $criteria = $crit ? "message like '%{$crit}%'" : '1=1'; $rs = safe_rows_start("*, unix_timestamp(posted) as uPosted", "txp_discuss", "{$criteria} order by posted desc limit {$offset}, {$limit}"); echo pageby_form('discuss', $comment_list_pageby); if ($rs) { echo '<form action="index.php" method="post" name="longform" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">', startTable('list'), assHead('date', 'name', 'message', 'parent', ''); while ($a = nextRow($rs)) { extract($a); $dmessage = $visible == SPAM ? short_preview($message) : $message; $date = "" . date("M d, g:ia", $uPosted + tz_offset()) . ""; $editlink = eLink('discuss', 'discuss_edit', 'discussid', $discussid, $date); $cbox = fInput('checkbox', 'selected[]', $discussid); $tq = fetch('Title', 'textpattern', 'ID', $parentid); $parent = !$tq ? gTxt('article_deleted') : $tq; echo assRow(array($editlink => 100, $name => 100, $dmessage => 250, $parent => 100, $cbox => 20), ' class="' . ($visible == VISIBLE ? 'visible' : ($visible == SPAM ? 'spam' : 'moderate')) . '"'); } echo tr(tda(select_buttons() . discuss_multiedit_form(), ' colspan="5" style="text-align:right;border:0px"')); echo endTable() . '</form>'; echo startTable('edit'), tr(td(form(fInput('text', 'crit', '', 'edit') . fInput('submit', 'search', gTxt('search'), 'smallbox') . eInput("discuss") . sInput("list"))) . td(graf(join('', $nav)))) . tr(tda(graf('<a href="index.php?event=discuss' . a . 'step=ipban_list">' . gTxt('list_banned_ips') . '</a>'), ' colspan="2" align="center" valign="middle"')), endTable(); } else { echo graf(gTxt('no_comments_recorded'), ' align="center"'); } }
function plugin_list($message = '') { pagetop(gTxt('edit_plugins'), $message); echo n . n . startTable('edit') . tr(tda(plugin_form(), ' colspan="8" style="height: 30px; border: none;"')) . endTable(); extract(gpsa(array('sort', 'dir'))); $dir = $dir == 'desc' ? 'desc' : 'asc'; if (!in_array($sort, array('name', 'status', 'author', 'version', 'modified', 'load_order'))) { $sort = 'name'; } $sort_sql = $sort . ' ' . $dir; $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 '<form action="index.php" method="post" name="longform" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">' . startTable('list') . tr(column_head('plugin', 'name', 'plugin', true, $switch_dir, '', '', 'name' == $sort ? $dir : '') . column_head('author', 'author', 'plugin', true, $switch_dir, '', '', 'author' == $sort ? $dir : '') . column_head('version', 'version', 'plugin', true, $switch_dir, '', '', 'version' == $sort ? $dir : '') . column_head('plugin_modified', 'modified', 'plugin', true, $switch_dir, '', '', 'modified' == $sort ? $dir : '') . hCell(gTxt('description')) . column_head('active', 'status', 'plugin', true, $switch_dir, '', '', 'status' == $sort ? $dir : '') . column_head('order', 'load_order', 'plugin', true, $switch_dir, '', '', 'load_order' == $sort ? $dir : '') . hCell(gTxt('manage'), '', ' class="manage"') . hCell()); while ($a = nextRow($rs)) { foreach ($a as $key => $value) { ${$key} = htmlspecialchars($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) ? n . t . '<li><a href="?event=plugin' . a . 'step=plugin_help' . a . 'name=' . urlencode($name) . '">' . gTxt('help') . '</a></li>' : ''; $plugin_prefs = $flags & PLUGIN_HAS_PREFS && $status ? n . t . '<li><a href="?event=plugin_prefs.' . urlencode($name) . '">' . gTxt('plugin_prefs') . '</a></li>' : ''; echo tr(n . td($name) . td(href($author, $author_uri)) . td($version, 10) . td($modified ? gTxt('yes') : '') . td($description, 260) . td(status_link($status, $name, yes_no($status)), 30) . td($load_order) . td(n . '<ul class="plugin_manage">' . $help . n . t . '<li>' . eLink('plugin', 'plugin_edit', 'name', $name, gTxt('edit')) . '</li>' . $plugin_prefs . n . '</ul>') . td(fInput('checkbox', 'selected[]', $name), 30)); unset($name, $page, $deletelink); } echo tr(tda(select_buttons() . plugin_multiedit_form('', $sort, $dir, '', ''), ' colspan="10" style="text-align: right; border: none;"')) . n . endTable() . n . '</form>'; } }
function list_list($message = "", $post = '') { extract(get_prefs()); $lvars = array("page", "sort", "dir", "crit", 'method'); extract(gpsa($lvars)); global $statuses, $step; $sesutats = array_flip($statuses); pagetop(gTxt('tab_list'), $message); $total = getCount('textpattern', "1"); $limit = max(@$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 = '" . @$sesutats[$crit] . "'"); $criteria = $critsql[$method]; $limit = 500; } else { $criteria = 1; } $rs = safe_rows_start("*, 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" name="longform" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">', startTable('list'), '<tr>', column_head('posted', 'posted', 'list', 1, $linkdir), column_head('title', 'title', 'list', 1, $linkdir), column_head('section', 'section', 'list', 1, $linkdir), 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>'; while ($a = nextRow($rs)) { extract($a); $stat = !empty($Status) ? $statuses[$Status] : ''; $adate = date("d M y", $uPosted + tz_offset()); $alink = eLink('article', 'edit', 'ID', $ID, $adate); $tlink = eLink('article', 'edit', 'ID', $ID, $Title); $modbox = fInput('checkbox', 'selected[]', $ID, '', '', '', '', '', $ID); echo "<tr>" . n, td($alink), td($tlink, 200), td($Section, 75), td($Category1, 75) . td($Category2, 75), td($AuthorID), td($stat, 45), td($modbox), '</tr>' . n; } echo tr(tda(select_buttons() . list_multiedit_form(), ' colspan="8" style="text-align:right;border:0px"')); echo "</table></form>"; echo pageby_form('list', $article_list_pageby); unset($sort); } }
function link_list($message = "") { global $step, $link_list_pageby; extract(get_prefs()); $page = gps('page'); $total = getCount('txp_link', "1"); $limit = max(@$link_list_pageby, 25); $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_start("*", "txp_link", "1 order by {$sort} {$dir} limit {$offset}, {$limit}"); if ($rs) { echo '<form action="index.php" method="post" name="longform" 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()); while ($a = nextRow($rs)) { 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(select_buttons() . 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 file_list($message = '') { global $txpcfg, $extensions, $file_base_path, $file_statuses, $file_list_pageby; pagetop(gTxt('file'), $message); extract($txpcfg); extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method'))); if (!is_dir($file_base_path) or !is_writeable($file_base_path)) { echo graf(gTxt('file_dir_not_writeable', array('{filedir}' => $file_base_path)), ' id="warning"'); } else { $existing_files = get_filenames(); if (count($existing_files) > 0) { echo form(eInput('file') . sInput('file_create') . graf(gTxt('existing_file') . sp . selectInput('filename', $existing_files, '', 1) . sp . fInput('submit', '', gTxt('Create'), 'smallerbox')), 'text-align: center;'); } echo file_upload_form(gTxt('upload_file'), 'upload', 'file_insert'); } $dir = $dir == 'desc' ? 'desc' : 'asc'; switch ($sort) { case 'id': $sort_sql = 'id ' . $dir; break; case 'description': $sort_sql = 'description ' . $dir . ', filename desc'; break; case 'category': $sort_sql = 'category ' . $dir . ', filename desc'; break; case 'downloads': $sort_sql = 'downloads ' . $dir . ', filename desc'; break; default: $sort = 'filename'; $sort_sql = 'filename ' . $dir; break; } $switch_dir = $dir == 'desc' ? 'asc' : 'desc'; $criteria = 1; if ($search_method and $crit) { $crit_escaped = doSlash($crit); $critsql = array('id' => "ID in ('" . join("','", do_list($crit_escaped)) . "')", 'filename' => "filename like '%{$crit_escaped}%'", 'description' => "description like '%{$crit_escaped}%'", 'category' => "category like '%{$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_file', "{$criteria}"); if ($total < 1) { if ($criteria != 1) { echo n . file_search_form($crit, $search_method) . n . graf(gTxt('no_results_found'), ' class="indicator"'); } else { echo n . graf(gTxt('no_files_recorded'), ' class="indicator"'); } return; } $limit = max($file_list_pageby, 15); list($page, $offset, $numPages) = pager($total, $limit, $page); echo file_search_form($crit, $search_method); $rs = safe_rows_start('*', 'txp_file', "{$criteria} order by {$sort_sql} limit {$offset}, {$limit}"); if ($rs) { echo '<form name="longform" method="post" action="index.php" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">' . startTable('list') . tr(column_head('ID', 'id', 'file', true, $switch_dir, $crit, $search_method, 'id' == $sort ? $dir : '') . hCell() . column_head('file_name', 'filename', 'file', true, $switch_dir, $crit, $search_method, 'filename' == $sort ? $dir : '') . column_head('description', 'description', 'file', true, $switch_dir, $crit, $search_method, 'description' == $sort ? $dir : '') . column_head('file_category', 'category', 'file', true, $switch_dir, $crit, $search_method, 'category' == $sort ? $dir : '') . hCell(gTxt('tags')) . hCell(gTxt('status')) . hCell(gTxt('condition')) . column_head('downloads', 'downloads', 'file', true, $switch_dir, $crit, $search_method, 'downloads' == $sort ? $dir : '') . hCell()); while ($a = nextRow($rs)) { extract($a); $edit_url = '?event=file' . a . 'step=file_edit' . a . 'id=' . $id . a . 'sort=' . $sort . a . 'dir=' . $dir . a . 'page=' . $page . a . 'search_method=' . $search_method . a . 'crit=' . $crit; $file_exists = file_exists(build_file_path($file_base_path, $filename)); $download_link = $file_exists ? '<li>' . make_download_link($id, '', $filename) . '</li>' : ''; $category = $category ? '<span title="' . htmlspecialchars(fetch_category_title($category, 'file')) . '">' . $category . '</span>' : ''; $tag_url = '?event=tag' . a . 'tag_name=file_download_link' . a . 'id=' . $id . a . 'description=' . urlencode($description) . a . 'filename=' . urlencode($filename); $condition = '<span class="'; $condition .= $file_exists ? 'ok' : 'not-ok'; $condition .= '">'; $condition .= $file_exists ? gTxt('file_status_ok') : gTxt('file_status_missing'); $condition .= '</span>'; echo tr(n . td($id) . td('<ul>' . '<li>' . href(gTxt('edit'), $edit_url) . '</li>' . $download_link . '</ul>', 65) . td(href(htmlspecialchars($filename), $edit_url), 125) . td(htmlspecialchars($description), 150) . td($category, 90) . td(n . '<ul>' . n . t . '<li><a target="_blank" href="' . $tag_url . a . 'type=textile" onclick="popWin(this.href, 400, 250); return false;">Textile</a></li>' . n . t . '<li><a target="_blank" href="' . $tag_url . a . 'type=textpattern" onclick="popWin(this.href, 400, 250); return false;">Textpattern</a></li>' . n . t . '<li><a target="_blank" href="' . $tag_url . a . 'type=xhtml" onclick="popWin(this.href, 400, 250); return false;">XHTML</a></li>' . n . '</ul>', 75) . td($file_statuses[$status], 45) . td($condition, 45) . td($downloads == '0' ? gTxt('none') : $downloads, 25) . td(fInput('checkbox', 'selected[]', $id), 10)); } echo tr(tda(select_buttons() . file_multiedit_form($page, $sort, $dir, $crit, $search_method), ' colspan="10" style="text-align: right; border: none;"')) . endTable() . '</form>' . nav_form('file', $page, $numPages, $sort, $dir, $crit, $search_method) . pageby_form('file', $file_list_pageby); } }
function list_list($message = '', $post = '') { global $statuses, $comments_disabled_after, $step, $txp_user, $article_list_pageby; pagetop(gTxt('tab_list'), $message); extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method'))); $sesutats = array_flip($statuses); $dir = $dir == 'asc' ? 'asc' : 'desc'; switch ($sort) { case 'id': $sort_sql = 'ID ' . $dir; break; case 'expires': $sort_sql = 'Expires ' . $dir; break; case 'title': $sort_sql = 'Title ' . $dir . ', Posted desc'; break; case 'section': $sort_sql = 'Section ' . $dir . ', Posted desc'; break; case 'category1': $sort_sql = 'Category1 ' . $dir . ', Posted desc'; break; case 'category2': $sort_sql = 'Category2 ' . $dir . ', Posted desc'; break; case 'status': $sort_sql = 'Status ' . $dir . ', Posted desc'; break; case 'author': $sort_sql = 'AuthorID ' . $dir . ', Posted desc'; break; case 'comments': $sort_sql = 'comments_count ' . $dir . ', Posted desc'; break; case 'lastmod': $sort_sql = 'LastMod ' . $dir . ', Posted desc'; break; default: $sort = 'posted'; $sort_sql = 'Posted ' . $dir; break; } $switch_dir = $dir == 'desc' ? 'asc' : 'desc'; $criteria = 1; if ($search_method and $crit) { $crit_escaped = doSlash($crit); $critsql = array('id' => "ID in ('" . join("','", do_list($crit_escaped)) . "')", 'title_body_excerpt' => "Title rlike '{$crit_escaped}' or Body rlike '{$crit_escaped}' or Excerpt rlike '{$crit_escaped}'", 'section' => "Section rlike '{$crit_escaped}'", 'keywords' => "FIND_IN_SET('" . $crit_escaped . "',Keywords)", 'categories' => "Category1 rlike '{$crit_escaped}' or Category2 rlike '{$crit_escaped}'", 'status' => "Status = '" . @$sesutats[gTxt($crit_escaped)] . "'", 'author' => "AuthorID rlike '{$crit_escaped}'", 'article_image' => "Image in ('" . join("','", do_list($crit_escaped)) . "')", 'posted' => "Posted like '{$crit_escaped}%'", 'lastmod' => "LastMod like '{$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('textpattern', "{$criteria}"); if ($total < 1) { if ($criteria != 1) { echo n . list_search_form($crit, $search_method) . n . graf(gTxt('no_results_found'), ' class="indicator"'); } else { echo graf(gTxt('no_articles_recorded'), ' class="indicator"'); } return; } $limit = max($article_list_pageby, 15); list($page, $offset, $numPages) = pager($total, $limit, $page); echo n . list_search_form($crit, $search_method); $rs = safe_rows_start('*, unix_timestamp(Posted) as posted, unix_timestamp(LastMod) as lastmod, unix_timestamp(Expires) as expires', 'textpattern', "{$criteria} order by {$sort_sql} limit {$offset}, {$limit}"); if ($rs) { $total_comments = array(); // fetch true comment count, not the public comment count // maybe we should have another row in the db? $rs2 = safe_rows_start('parentid, count(*) as num', 'txp_discuss', "1 group by parentid order by parentid"); if ($rs2) { while ($a = nextRow($rs2)) { $pid = $a['parentid']; $num = $a['num']; $total_comments[$pid] = $num; } } echo n . n . '<form name="longform" method="post" action="index.php" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">' . n . startTable('list', '', '', '', '90%') . n . tr(n . column_head('ID', 'id', 'list', true, $switch_dir, $crit, $search_method, 'id' == $sort ? $dir : '') . column_head('posted', 'posted', 'list', true, $switch_dir, $crit, $search_method, 'posted' == $sort ? $dir : '') . column_head('article_modified', 'lastmod', 'list', true, $switch_dir, $crit, $search_method, ('lastmod' == $sort ? "{$dir} " : '') . 'articles_detail') . column_head('expires', 'expires', 'list', true, $switch_dir, $crit, $search_method, ('expires' == $sort ? "{$dir} " : '') . 'articles_detail') . column_head('title', 'title', 'list', true, $switch_dir, $crit, $search_method, 'title' == $sort ? $dir : '') . column_head('section', 'section', 'list', true, $switch_dir, $crit, $search_method, 'section' == $sort ? $dir : '') . column_head('category1', 'category1', 'list', true, $switch_dir, $crit, $search_method, ('category1' == $sort ? "{$dir} " : '') . 'articles_detail') . column_head('category2', 'category2', 'list', true, $switch_dir, $crit, $search_method, ('category2' == $sort ? "{$dir} " : '') . 'articles_detail') . column_head('status', 'status', 'list', true, $switch_dir, $crit, $search_method, 'status' == $sort ? $dir : '') . column_head('author', 'author', 'list', true, $switch_dir, $crit, $search_method, 'author' == $sort ? $dir : '') . column_head('comments', 'comments', 'list', true, $switch_dir, $crit, $search_method, ('comments' == $sort ? "{$dir} " : '') . 'articles_detail') . hCell()); include_once txpath . '/publish/taghandlers.php'; while ($a = nextRow($rs)) { extract($a); if (empty($Title)) { $Title = '<em>' . eLink('article', 'edit', 'ID', $ID, gTxt('untitled')) . '</em>'; } else { $Title = eLink('article', 'edit', 'ID', $ID, $Title); } $Category1 = $Category1 ? '<span title="' . htmlspecialchars(fetch_category_title($Category1)) . '">' . $Category1 . '</span>' : ''; $Category2 = $Category2 ? '<span title="' . htmlspecialchars(fetch_category_title($Category2)) . '">' . $Category2 . '</span>' : ''; $view_url = permlinkurl($a); if ($Status != 4 and $Status != 5) { $view_url .= (strpos($view_url, '?') === FALSE ? '?' : '&') . 'txpreview=' . intval($ID) . '.' . time(); } $manage = n . '<ul class="articles_detail">' . n . t . '<li>' . eLink('article', 'edit', 'ID', $ID, gTxt('edit')) . '</li>' . n . t . '<li><a href="' . $view_url . '" class="article-view">' . gTxt('view') . '</a></li>' . n . '</ul>'; $Status = !empty($Status) ? $statuses[$Status] : ''; $comments = gTxt('none'); if (isset($total_comments[$ID]) and $total_comments[$ID] > 0) { $comments = href(gTxt('manage'), 'index.php?event=discuss' . a . 'step=list' . a . 'search_method=parent' . a . 'crit=' . $ID) . ' (' . $total_comments[$ID] . ')'; } $comment_status = $Annotate ? gTxt('on') : gTxt('off'); if ($comments_disabled_after) { $lifespan = $comments_disabled_after * 86400; $time_since = time() - $posted; if ($time_since > $lifespan) { $comment_status = gTxt('expired'); } } $comments = n . '<ul>' . n . t . '<li>' . $comment_status . '</li>' . n . t . '<li>' . $comments . '</li>' . n . '</ul>'; echo n . n . tr(n . td(eLink('article', 'edit', 'ID', $ID, $ID) . $manage) . td(gTime($posted), '', $posted < time() ? '' : 'unpublished') . td(gTime($lastmod), '', "articles_detail") . td($expires ? gTime($expires) : '', '', 'articles_detail') . td($Title) . td('<span title="' . htmlspecialchars(fetch_section_title($Section)) . '">' . $Section . '</span>', 75) . td($Category1, 100, "articles_detail") . td($Category2, 100, "articles_detail") . td($a['Status'] < 4 ? $Status : '<a href="' . permlinkurl($a) . '">' . $Status . '</a>', 50) . td('<span title="' . htmlspecialchars(get_author_name($AuthorID)) . '">' . htmlspecialchars($AuthorID) . '</span>') . td($comments, 50, "articles_detail") . td(($a['Status'] >= 4 and has_privs('article.edit.published') or $a['Status'] >= 4 and $AuthorID == $txp_user and has_privs('article.edit.own.published') or $a['Status'] < 4 and has_privs('article.edit') or $a['Status'] < 4 and $AuthorID == $txp_user and has_privs('article.edit.own')) ? fInput('checkbox', 'selected[]', $ID) : ' ')); } echo n . n . tr(tda(toggle_box('articles_detail'), ' colspan="2" style="text-align: left; border: none;"') . tda(select_buttons() . list_multiedit_form($page, $sort, $dir, $crit, $search_method), ' colspan="9" style="text-align: right; border: none;"')) . n . endTable() . n . '</form>' . n . nav_form('list', $page, $numPages, $sort, $dir, $crit, $search_method, $total, $limit) . n . pageby_form('list', $article_list_pageby); } }
function link_list($message = '') { global $event, $step, $link_list_pageby, $txp_user; extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method'))); if ($sort === '') { $sort = get_pref('link_sort_column', 'name'); } if ($dir === '') { $dir = get_pref('link_sort_dir', 'asc'); } $dir = $dir == 'desc' ? 'desc' : 'asc'; switch ($sort) { case 'id': $sort_sql = 'id ' . $dir; break; case 'description': $sort_sql = 'description ' . $dir . ', id asc'; break; case 'category': $sort_sql = 'category ' . $dir . ', id asc'; break; case 'date': $sort_sql = 'date ' . $dir . ', id asc'; break; case 'author': $sort_sql = 'author ' . $dir . ', id asc'; break; default: $sort = 'name'; $sort_sql = 'linksort ' . $dir . ', id asc'; break; } set_pref('link_sort_column', $sort, 'link', 2, '', 0, PREF_PRIVATE); set_pref('link_sort_dir', $dir, 'link', 2, '', 0, PREF_PRIVATE); $switch_dir = $dir == 'desc' ? 'asc' : 'desc'; $criteria = 1; if ($search_method and $crit) { $crit_escaped = doSlash(str_replace(array('\\', '%', '_', '\''), array('\\\\', '\\%', '\\_', '\\\''), $crit)); $critsql = array('id' => "ID in ('" . join("','", do_list($crit_escaped)) . "')", 'name' => "linkname like '%{$crit_escaped}%'", 'description' => "description like '%{$crit_escaped}%'", 'category' => "category like '%{$crit_escaped}%'", 'author' => "author like '%{$crit_escaped}%'"); if (array_key_exists($search_method, $critsql)) { $criteria = $critsql[$search_method]; } else { $search_method = ''; $crit = ''; } } else { $search_method = ''; $crit = ''; } $total = getCount('txp_link', $criteria); echo '<div id="' . $event . '_control" class="txp-control-panel">'; if ($total < 1) { if ($criteria != 1) { echo n . link_search_form($crit, $search_method) . n . graf(gTxt('no_results_found'), ' class="indicator"') . '</div>'; } else { echo n . graf(gTxt('no_links_recorded'), ' class="indicator"') . '</div>'; } return; } $limit = max($link_list_pageby, 15); list($page, $offset, $numPages) = pager($total, $limit, $page); echo link_search_form($crit, $search_method) . '</div>'; $rs = safe_rows_start('*, unix_timestamp(date) as uDate', 'txp_link', "{$criteria} order by {$sort_sql} limit {$offset}, {$limit}"); if ($rs) { $show_authors = !has_single_author('txp_link'); echo n . '<div class="txp-list">'; echo n . n . '<form action="index.php" id="links_form" method="post" name="longform" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">', startTable('list', '', 'list') . n . '<thead>' . n . tr(column_head('ID', 'id', 'link', true, $switch_dir, $crit, $search_method, ('id' == $sort ? "{$dir} " : '') . 'id') . hCell('', '', ' class="actions"') . column_head('link_name', 'name', 'link', true, $switch_dir, $crit, $search_method, ('name' == $sort ? "{$dir} " : '') . 'name') . column_head('description', 'description', 'link', true, $switch_dir, $crit, $search_method, ('description' == $sort ? "{$dir} " : '') . 'description') . column_head('link_category', 'category', 'link', true, $switch_dir, $crit, $search_method, ('category' == $sort ? "{$dir} " : '') . 'category') . column_head('date', 'date', 'link', true, $switch_dir, $crit, $search_method, ('date' == $sort ? "{$dir} " : '') . 'date created') . ($show_authors ? column_head('author', 'author', 'link', true, $switch_dir, $crit, $search_method, ('author' == $sort ? "{$dir} " : '') . 'author') : '') . hCell('', '', ' class="multi-edit"')) . n . '</thead>'; $tfoot = n . '<tfoot>' . tr(tda(select_buttons() . link_multiedit_form($page, $sort, $dir, $crit, $search_method), ' class="multi-edit" colspan="' . ($show_authors ? '8' : '7') . '" style="text-align: right; border: none;"')) . n . '</tfoot>'; echo $tfoot; echo '<tbody>'; $ctr = 1; while ($a = nextRow($rs)) { extract($a); $edit_url = '?event=link' . a . 'step=link_edit' . a . 'id=' . $id . a . 'sort=' . $sort . a . 'dir=' . $dir . a . 'page=' . $page . a . 'search_method=' . $search_method . a . 'crit=' . $crit; $can_edit = has_privs('link.edit') || $author == $txp_user && has_privs('link.edit.own'); echo tr(n . td($id, 20, 'id') . td(n . '<ul>' . ($can_edit ? n . t . '<li class="action-edit">' . href(gTxt('edit'), $edit_url) . '</li>' : '') . n . t . '<li class="action-view">' . href(gTxt('view'), $url) . '</li>' . n . '</ul>', 35, 'actions') . td($can_edit ? href($linkname, $edit_url) : $linkname, 125, 'name') . td(htmlspecialchars($description), 150, 'description') . td('<span title="' . htmlspecialchars(fetch_category_title($category, 'link')) . '">' . $category . '</span>', 125, 'category') . td(gTime($uDate), 75, 'date created') . ($show_authors ? td('<span title="' . htmlspecialchars(get_author_name($author)) . '">' . htmlspecialchars($author) . '</span>', '', 'author') : '') . td(fInput('checkbox', 'selected[]', $id), '', 'multi-edit'), ' class="' . ($ctr % 2 == 0 ? 'even' : 'odd') . '"'); $ctr++; } echo '</tbody>' . n . endTable() . n . '</form>' . n . '<div id="' . $event . '_navigation" class="txp-navigation">' . n . nav_form('link', $page, $numPages, $sort, $dir, $crit, $search_method, $total, $limit) . pageby_form('link', $link_list_pageby) . n . '</div>' . n . '</div>'; } }
function jmc_event_manager_events($step = null) { $output_html = null; $filters = jmc_event_get_filters($step); $events = new JmcEvents(); // If there are rows we'll make our table. It'd be nice for every second one to be a little better put together if (sizeof($events->events) > 0) { $output_html .= jmc_nav_form('jmc_event_manager', $step, $filters); // Start the form for multi editing // Start a table with the class 'list' // Set up the headers for the columns $output_html .= '<form action="index.php" method="post" name="longform" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">' . startTable('list') . '<tr>' . jmc_event_column_head($events, 'Category', 'category', true) . jmc_event_column_head($events, 'Event', 'name', true) . jmc_event_column_head($events, 'Start', 'start', true) . jmc_event_column_head($events, 'End', 'end', true) . jmc_event_column_head($events, 'Venue', 'venue', true) . jmc_event_column_head($events, 'Price', 'price', true) . jmc_event_column_head($events, 'Posted By', 'author', true) . td() . '</tr>'; // Foreach of the entries create it's information in the relevant columns foreach ($events->events as $event) { // Output the row $output_html .= "<tr>" . n . td($event->category->name) . td(eLink('jmc_event_manager', 'event_edit', 'id', $event->id, $event->name)) . td(eLink('jmc_event_manager', 'event_edit', 'id', $event->id, date("d M y", $event->start_local())) . " at " . date("g:i a", $event->start_local())) . td(eLink('jmc_event_manager', 'event_edit', 'id', $event->id, date("d M y", $event->end_local())) . " at " . date("g:i a", $event->end_local())) . td(eLink('jmc_event_manager', 'event_edit', 'id', $event->id, $event->venue->name), 100) . td($event->price, 75) . td($event->author_id) . td(fInput('checkbox', 'selected[]', $event->id, '', '', '', '', '', $event->id)) . '</tr>' . n; } // Modified multiedit form based on existing one but with more options $output_html .= tr(tda(select_buttons() . jmc_event_manager_multiedit_form('jmc_event_manager', 'event_multi_edit'), ' colspan="7" style="text-align:right;border:0px"')); $output_html .= "</table></form>"; // Pageby form $output_html .= pageby_form('list', $filters['article_list_pageby']); // Unsure why - was in the article list version... unset($sort); } else { $output_html .= '<p>There are no upcoming entries. Please <a href="?event=jmc_event_manager&step=event_add">add one</a>.</p>'; } return $output_html; }
function author_list() { global $txp_user, $author_list_pageby; extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method'))); if (!in_array($sort, array('name', 'RealName', 'email', 'privs', 'last_login'))) { $sort = 'name'; } $dir = $dir == 'desc' ? 'desc' : 'asc'; $sort_sql = $sort . ' ' . $dir; $switch_dir = $dir == 'desc' ? 'asc' : 'desc'; $total = getCount('txp_users', '1=1'); $limit = max($author_list_pageby, 15); list($page, $offset, $numPages) = pager($total, $limit, $page); $rs = safe_rows_start('*, unix_timestamp(last_access) as last_login', 'txp_users', '1 = 1 order by ' . $sort_sql . ' limit ' . $offset . ', ' . $limit); if ($rs) { echo '<form action="index.php" method="post" name="longform" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">' . startTable('list') . tr(column_head('login_name', 'name', 'admin', true, $switch_dir, '', '', 'name' == $sort ? $dir : '') . column_head('real_name', 'RealName', 'admin', true, $switch_dir, '', '', 'RealName' == $sort ? $dir : '') . column_head('email', 'email', 'admin', true, $switch_dir, '', '', 'email' == $sort ? $dir : '') . column_head('privileges', 'privs', 'admin', true, $switch_dir, '', '', 'privs' == $sort ? $dir : '') . column_head('last_login', 'last_login', 'admin', true, $switch_dir, '', '', 'last_login' == $sort ? $dir : '') . hCell() . hCell()); while ($a = nextRow($rs)) { extract(doSpecial($a)); echo tr(td($name) . td($RealName) . td('<a href="mailto:' . $email . '">' . $email . '</a>') . td(get_priv_level($privs)) . td($last_login ? safe_strftime('%b %Y', $last_login) : '') . td(has_privs('admin.edit') ? eLink('admin', 'author_edit', 'user_id', $user_id, gTxt('edit')) : '') . td((has_privs('admin.edit') and $txp_user != $a['name']) ? fInput('checkbox', 'selected[]', $a['name']) : '')); } echo n . n . tr(tda(select_buttons() . author_multiedit_form($page, $sort, $dir, $crit, $search_method), ' colspan="6" style="text-align: right; border: none;"')) . endTable() . '</form>' . nav_form('admin', $page, $numPages, $sort, $dir, $crit, $search_method) . pageby_form('admin', $author_list_pageby); } }
function image_list($message = '') { global $txpcfg, $extensions, $img_dir, $file_max_upload_size, $image_list_pageby, $txp_user, $event; pagetop(gTxt('images'), $message); extract($txpcfg); extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method'))); if ($sort === '') { $sort = get_pref('image_sort_column', 'id'); } if ($dir === '') { $dir = get_pref('image_sort_dir', 'desc'); } $dir = $dir == 'asc' ? 'asc' : 'desc'; echo '<div id="' . $event . '_control" class="txp-control-panel">'; if (!is_dir(IMPATH) or !is_writeable(IMPATH)) { echo graf(gTxt('img_dir_not_writeable', array('{imgdir}' => IMPATH)), ' id="warning"'); } elseif (has_privs('image.edit.own')) { echo upload_form(gTxt('upload_image'), 'upload_image', 'image_insert', 'image', '', $file_max_upload_size); } switch ($sort) { case 'name': $sort_sql = 'name ' . $dir; break; case 'thumbnail': $sort_sql = 'thumbnail ' . $dir . ', id asc'; break; case 'category': $sort_sql = 'category ' . $dir . ', id asc'; break; case 'date': $sort_sql = 'date ' . $dir . ', id asc'; break; case 'author': $sort_sql = 'author ' . $dir . ', id asc'; break; default: $sort = 'id'; $sort_sql = 'id ' . $dir; break; } set_pref('image_sort_column', $sort, 'image', 2, '', 0, PREF_PRIVATE); set_pref('image_sort_dir', $dir, 'image', 2, '', 0, PREF_PRIVATE); $switch_dir = $dir == 'desc' ? 'asc' : 'desc'; $criteria = 1; if ($search_method and $crit) { $crit_escaped = doSlash(str_replace(array('\\', '%', '_', '\''), array('\\\\', '\\%', '\\_', '\\\''), $crit)); $critsql = array('id' => "ID in ('" . join("','", do_list($crit_escaped)) . "')", 'name' => "name like '%{$crit_escaped}%'", 'category' => "category like '%{$crit_escaped}%'", 'author' => "author like '%{$crit_escaped}%'", 'alt' => "alt like '%{$crit_escaped}%'", 'caption' => "caption like '%{$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_image', "{$criteria}"); if ($total < 1) { if ($criteria != 1) { echo n . image_search_form($crit, $search_method) . n . graf(gTxt('no_results_found'), ' class="indicator"') . '</div>'; } else { echo n . graf(gTxt('no_images_recorded'), ' class="indicator"') . '</div>'; } return; } $limit = max($image_list_pageby, 15); list($page, $offset, $numPages) = pager($total, $limit, $page); echo image_search_form($crit, $search_method); $rs = safe_rows_start('*, unix_timestamp(date) as uDate', 'txp_image', "{$criteria} order by {$sort_sql} limit {$offset}, {$limit}\n\t\t"); echo pluggable_ui('image_ui', 'extend_controls', '', $rs); echo '</div>'; // end txp-control-panel if ($rs) { $show_authors = !has_single_author('txp_image'); echo n . '<div id="' . $event . '_container" class="txp-container txp-list">'; echo n . n . '<form name="longform" id="images_form" method="post" action="index.php" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">' . n . n . startTable('list', '', 'list') . n . '<thead>' . n . tr(column_head('ID', 'id', 'image', true, $switch_dir, $crit, $search_method, ('id' == $sort ? "{$dir} " : '') . 'id') . hCell('', '', ' class="actions"') . column_head('date', 'date', 'image', true, $switch_dir, $crit, $search_method, ('date' == $sort ? "{$dir} " : '') . 'date created') . column_head('name', 'name', 'image', true, $switch_dir, $crit, $search_method, ('name' == $sort ? "{$dir} " : '') . 'name') . column_head('thumbnail', 'thumbnail', 'image', true, $switch_dir, $crit, $search_method, ('thumbnail' == $sort ? "{$dir} " : '') . 'thumbnail') . hCell(gTxt('tags'), '', ' class="tag-build"') . column_head('image_category', 'category', 'image', true, $switch_dir, $crit, $search_method, ('category' == $sort ? "{$dir} " : '') . 'category') . ($show_authors ? column_head('author', 'author', 'image', true, $switch_dir, $crit, $search_method, ('author' == $sort ? "{$dir} " : '') . 'author') : '') . hCell('', '', ' class="multi-edit"')) . n . '</thead>'; $tfoot = n . '<tfoot>' . tr(tda(select_buttons() . image_multiedit_form($page, $sort, $dir, $crit, $search_method), ' class="multi-edit" colspan="' . ($show_authors ? '9' : '8') . '" style="text-align: right; border: none;"')) . n . '</tfoot>'; echo $tfoot; echo '<tbody>'; $ctr = 1; while ($a = nextRow($rs)) { extract($a); $edit_url = '?event=image' . a . 'step=image_edit' . a . 'id=' . $id . a . 'sort=' . $sort . a . 'dir=' . $dir . a . 'page=' . $page . a . 'search_method=' . $search_method . a . 'crit=' . $crit; $name = empty($name) ? gTxt('unnamed') : htmlspecialchars($name); if ($thumbnail) { if ($ext != '.swf') { $thumbnail = '<img src="' . imagesrcurl($id, $ext, true) . "?{$uDate}" . '" alt="" ' . "title='{$id}{$ext} ({$w} × {$h})'" . ($thumb_w ? "width='{$thumb_w}' height='{$thumb_h}'" : '') . ' />'; } else { $thumbnail = ''; } } else { $thumbnail = gTxt('no'); } if ($ext != '.swf') { $tag_url = '?event=tag' . a . 'tag_name=image' . a . 'id=' . $id . a . 'ext=' . $ext . a . 'w=' . $w . a . 'h=' . $h . a . 'alt=' . urlencode($alt) . a . 'caption=' . urlencode($caption); $tagbuilder = '<ul>' . '<li><a target="_blank" href="' . $tag_url . a . 'type=textile" onclick="popWin(this.href); return false;">Textile</a></li>' . '<li><a target="_blank" href="' . $tag_url . a . 'type=textpattern" onclick="popWin(this.href); return false;">Textpattern</a></li>' . '<li><a target="_blank" href="' . $tag_url . a . 'type=xhtml" onclick="popWin(this.href); return false;">XHTML</a></li>' . '</ul>'; } else { $tagbuilder = sp; } $category = $category ? '<span title="' . htmlspecialchars(fetch_category_title($category, 'image')) . '">' . $category . '</span>' : ''; $can_edit = has_privs('image.edit') || $author == $txp_user && has_privs('image.edit.own'); echo n . n . tr(n . td($id, 20, 'id') . td(n . '<ul>' . ($can_edit ? n . t . '<li class="action-edit">' . href(gTxt('edit'), $edit_url) . '</li>' : '') . n . t . '<li class="action-view"><a href="' . imagesrcurl($id, $ext) . '">' . gTxt('view') . '</a></li>' . n . '</ul>', 35, 'actions') . td(gTime($uDate), 75, 'date created') . td($can_edit ? href($name, $edit_url) : $name, 75, 'name') . td(pluggable_ui('image_ui', 'thumbnail', $can_edit ? href($thumbnail, $edit_url) : $thumbnail, $a), 80, 'image thumbnail') . td($tagbuilder, 85, 'tag-build') . td($category, 75, 'category') . ($show_authors ? td('<span title="' . htmlspecialchars(get_author_name($author)) . '">' . htmlspecialchars($author) . '</span>', 75, 'author') : '') . td($can_edit ? fInput('checkbox', 'selected[]', $id) : ' ', 10, 'multi-edit'), ' class="' . ($ctr % 2 == 0 ? 'even' : 'odd') . '"'); $ctr++; } echo '</tbody>' . n . endTable() . n . '</form>' . n . '<div id="' . $event . '_navigation" class="txp-navigation">' . nav_form('image', $page, $numPages, $sort, $dir, $crit, $search_method, $total, $limit) . pageby_form('image', $image_list_pageby) . n . '</div>' . n . '</div>'; } }
function author_list() { global $txp_user, $author_list_pageby; extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method'))); if ($sort === '') { $sort = get_pref('admin_sort_column', 'name'); } if ($dir === '') { $dir = get_pref('admin_sort_dir', 'asc'); } $dir = $dir == 'desc' ? 'desc' : 'asc'; if (!in_array($sort, array('name', 'RealName', 'email', 'privs', 'last_login'))) { $sort = 'name'; } $sort_sql = $sort . ' ' . $dir; set_pref('admin_sort_column', $sort, 'admin', 2, '', 0, PREF_PRIVATE); set_pref('admin_sort_dir', $dir, 'admin', 2, '', 0, PREF_PRIVATE); $switch_dir = $dir == 'desc' ? 'asc' : 'desc'; $total = getCount('txp_users', '1=1'); $limit = max($author_list_pageby, 15); list($page, $offset, $numPages) = pager($total, $limit, $page); $rs = safe_rows_start('*, unix_timestamp(last_access) as last_login', 'txp_users', '1 = 1 order by ' . $sort_sql . ' limit ' . $offset . ', ' . $limit); if ($rs) { echo n . '<div class="txp-list">'; echo '<form action="index.php" id="users_form" method="post" name="longform" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">' . startTable('list', '', 'list') . n . '<thead>' . n . tr(column_head('login_name', 'name', 'admin', true, $switch_dir, '', '', ('name' == $sort ? "{$dir} " : '') . 'name login-name') . column_head('real_name', 'RealName', 'admin', true, $switch_dir, '', '', ('RealName' == $sort ? "{$dir} " : '') . 'name real-name') . column_head('email', 'email', 'admin', true, $switch_dir, '', '', ('email' == $sort ? "{$dir} " : '') . 'email') . column_head('privileges', 'privs', 'admin', true, $switch_dir, '', '', ('privs' == $sort ? "{$dir} " : '') . 'privs') . column_head('last_login', 'last_login', 'admin', true, $switch_dir, '', '', ('last_login' == $sort ? "{$dir} " : '') . 'date last-login modified') . hCell('', '', ' class="actions"') . hCell('', '', ' class="multi-edit"')) . n . '</thead>'; $tfoot = n . '<tfoot>' . tr(tda(has_privs('admin.edit') ? select_buttons() . author_multiedit_form($page, $sort, $dir, $crit, $search_method) : '', ' class="multi-edit" colspan="7" style="text-align: right; border: none;"')) . n . '</tfoot>'; echo $tfoot; echo '<tbody>'; $ctr = 1; while ($a = nextRow($rs)) { extract(doSpecial($a)); echo tr(td($name, '', 'name login-name') . td($RealName, '', 'name real-name') . td('<a href="mailto:' . $email . '">' . $email . '</a>', '', 'email') . td(get_priv_level($privs), '', 'privs') . td($last_login ? safe_strftime('%b %Y', $last_login) : '', '', 'date last-login modified') . td(has_privs('admin.edit') ? eLink('admin', 'author_edit', 'user_id', $user_id, gTxt('edit')) : '', '', 'actions') . td((has_privs('admin.edit') and $txp_user != $a['name']) ? fInput('checkbox', 'selected[]', $a['name'], 'checkbox') : '', '', 'multi-edit'), ' class="' . ($ctr % 2 == 0 ? 'even' : 'odd') . '"'); $ctr++; } echo '</tbody>' . n . endTable() . n . '</form>' . n . '<div id="users_navigation" class="txp-navigation">' . nav_form('admin', $page, $numPages, $sort, $dir, $crit, $search_method) . pageby_form('admin', $author_list_pageby) . n . '</div>' . n . '</div>'; } }
function file_list($message = '') { global $file_base_path, $file_statuses, $file_list_pageby, $txp_user, $event; pagetop(gTxt('file'), $message); extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method'))); if ($sort === '') { $sort = get_pref('file_sort_column', 'filename'); } if ($dir === '') { $dir = get_pref('file_sort_dir', 'asc'); } $dir = $dir == 'desc' ? 'desc' : 'asc'; echo '<div id="' . $event . '_control" class="txp-control-panel">'; if (!is_dir($file_base_path) or !is_writeable($file_base_path)) { echo graf(gTxt('file_dir_not_writeable', array('{filedir}' => $file_base_path)), ' id="warning"'); } elseif (has_privs('file.edit.own')) { $existing_files = get_filenames(); if (count($existing_files) > 0) { echo form(eInput('file') . sInput('file_create') . graf('<label for="file-existing">' . gTxt('existing_file') . '</label>' . sp . selectInput('filename', $existing_files, '', 1, '', 'file-existing') . sp . fInput('submit', '', gTxt('Create'), 'smallerbox'), ' class="existing-file"'), 'text-align: center;', '', 'post', '', '', 'assign_file'); } echo file_upload_form(gTxt('upload_file'), 'upload', 'file_insert'); } switch ($sort) { case 'id': $sort_sql = 'id ' . $dir; break; case 'description': $sort_sql = 'description ' . $dir . ', filename desc'; break; case 'category': $sort_sql = 'category ' . $dir . ', filename desc'; break; case 'title': $sort_sql = 'title ' . $dir . ', filename desc'; break; case 'downloads': $sort_sql = 'downloads ' . $dir . ', filename desc'; break; case 'author': $sort_sql = 'author ' . $dir . ', id asc'; break; default: $sort = 'filename'; $sort_sql = 'filename ' . $dir; break; } set_pref('file_sort_column', $sort, 'file', 2, '', 0, PREF_PRIVATE); set_pref('file_sort_dir', $dir, 'file', 2, '', 0, PREF_PRIVATE); $switch_dir = $dir == 'desc' ? 'asc' : 'desc'; $criteria = 1; if ($search_method and $crit) { $crit_escaped = doSlash(str_replace(array('\\', '%', '_', '\''), array('\\\\', '\\%', '\\_', '\\\''), $crit)); $critsql = array('id' => "ID in ('" . join("','", do_list($crit_escaped)) . "')", 'filename' => "filename like '%{$crit_escaped}%'", 'title' => "title like '%{$crit_escaped}%'", 'description' => "description like '%{$crit_escaped}%'", 'category' => "category like '%{$crit_escaped}%'", 'author' => "author like '%{$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_file', "{$criteria}"); if ($total < 1) { if ($criteria != 1) { echo n . file_search_form($crit, $search_method) . n . graf(gTxt('no_results_found'), ' class="indicator"') . '</div>'; } else { echo n . graf(gTxt('no_files_recorded'), ' class="indicator"') . '</div>'; } return; } $limit = max($file_list_pageby, 15); list($page, $offset, $numPages) = pager($total, $limit, $page); echo file_search_form($crit, $search_method) . '</div>'; $rs = safe_rows_start('*', 'txp_file', "{$criteria} order by {$sort_sql} limit {$offset}, {$limit}"); if ($rs) { $show_authors = !has_single_author('txp_file'); echo n . '<div id="' . $event . '_container" class="txp-container txp-list">'; echo '<form name="longform" id="files_form" method="post" action="index.php" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">' . startTable('list', '', 'list') . n . '<thead>' . tr(column_head('ID', 'id', 'file', true, $switch_dir, $crit, $search_method, ('id' == $sort ? "{$dir} " : '') . 'id') . hCell('', '', ' class="actions"') . column_head('file_name', 'filename', 'file', true, $switch_dir, $crit, $search_method, ('filename' == $sort ? "{$dir} " : '') . 'name') . column_head('title', 'title', 'file', true, $switch_dir, $crit, $search_method, ('title' == $sort ? "{$dir} " : '') . 'title') . column_head('description', 'description', 'file', true, $switch_dir, $crit, $search_method, ('description' == $sort ? "{$dir} " : '') . 'description') . column_head('file_category', 'category', 'file', true, $switch_dir, $crit, $search_method, ('category' == $sort ? "{$dir} " : '') . 'category') . hCell(gTxt('tags'), '', ' class="tag-build"') . hCell(gTxt('status'), '', ' class="status"') . hCell(gTxt('condition'), '', ' class="condition"') . column_head('downloads', 'downloads', 'file', true, $switch_dir, $crit, $search_method, ('downloads' == $sort ? "{$dir} " : '') . 'downloads') . ($show_authors ? column_head('author', 'author', 'file', true, $switch_dir, $crit, $search_method, ('author' == $sort ? "{$dir} " : '') . 'author') : '') . hCell('', '', ' class="multi-edit"')) . n . '</thead>'; $tfoot = n . '<tfoot>' . tr(tda(select_buttons() . file_multiedit_form($page, $sort, $dir, $crit, $search_method), ' class="multi-edit" colspan="' . ($show_authors ? '12' : '11') . '" style="text-align: right; border: none;"')) . n . '</tfoot>'; echo $tfoot; echo '<tbody>'; $ctr = 1; while ($a = nextRow($rs)) { extract($a); $filename = sanitizeForFile($filename); $edit_url = '?event=file' . a . 'step=file_edit' . a . 'id=' . $id . a . 'sort=' . $sort . a . 'dir=' . $dir . a . 'page=' . $page . a . 'search_method=' . $search_method . a . 'crit=' . $crit; $file_exists = file_exists(build_file_path($file_base_path, $filename)); $download_link = $file_exists ? '<li class="action-view">' . make_download_link($id, '', $filename) . '</li>' : ''; $category = $category ? '<span title="' . htmlspecialchars(fetch_category_title($category, 'file')) . '">' . $category . '</span>' : ''; $tag_url = '?event=tag' . a . 'tag_name=file_download_link' . a . 'id=' . $id . a . 'description=' . urlencode($description) . a . 'filename=' . urlencode($filename); $condition = '<span class="'; $condition .= $file_exists ? 'ok' : 'not-ok'; $condition .= '">'; $condition .= $file_exists ? gTxt('file_status_ok') : gTxt('file_status_missing'); $condition .= '</span>'; $can_edit = has_privs('file.edit') || $author == $txp_user && has_privs('file.edit.own'); echo tr(n . td($id, '', 'id') . td('<ul>' . ($can_edit ? '<li class="action-edit">' . href(gTxt('edit'), $edit_url) . '</li>' : '') . $download_link . '</ul>', 65, 'actions') . td($can_edit ? href(htmlspecialchars($filename), $edit_url) : htmlspecialchars($filename), 125, 'name') . td(htmlspecialchars($title), 90, 'title') . td(htmlspecialchars($description), 150, 'description') . td($category, 90, 'category') . td(n . '<ul>' . n . t . '<li><a target="_blank" href="' . $tag_url . a . 'type=textile" onclick="popWin(this.href, 400, 250); return false;">Textile</a></li>' . n . t . '<li><a target="_blank" href="' . $tag_url . a . 'type=textpattern" onclick="popWin(this.href, 400, 250); return false;">Textpattern</a></li>' . n . t . '<li><a target="_blank" href="' . $tag_url . a . 'type=xhtml" onclick="popWin(this.href, 400, 250); return false;">XHTML</a></li>' . n . '</ul>', 75, 'tag-build') . td(in_array($status, array_keys($file_statuses)) ? $file_statuses[$status] : '<span class="not-ok">' . gTxt('none') . '</span>', 45, 'status') . td($condition, 45, 'condition') . td($downloads == '0' ? gTxt('none') : $downloads, 25, 'downloads') . ($show_authors ? td('<span title="' . htmlspecialchars(get_author_name($author)) . '">' . htmlspecialchars($author) . '</span>', '', 'author') : '') . td($can_edit ? fInput('checkbox', 'selected[]', $id) : ' ', 10, 'multi-edit'), ' class="' . ($ctr % 2 == 0 ? 'even' : 'odd') . '"'); $ctr++; } echo '</tbody>' . n . endTable() . n . '</form>' . n . '<div id="' . $event . '_navigation" class="txp-navigation">' . nav_form('file', $page, $numPages, $sort, $dir, $crit, $search_method, $total, $limit) . pageby_form('file', $file_list_pageby) . n . '</div>' . n . '</div>'; } }
function image_list($message = '') { global $txpcfg, $extensions, $img_dir, $file_max_upload_size, $image_list_pageby; pagetop(gTxt('images'), $message); extract($txpcfg); extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method'))); if (!is_dir(IMPATH) or !is_writeable(IMPATH)) { echo graf(gTxt('img_dir_not_writeable', array('{imgdir}' => IMPATH)), ' id="warning"'); } else { echo upload_form(gTxt('upload_image'), 'upload', 'image_insert', 'image', '', $file_max_upload_size); } $dir = $dir == 'asc' ? 'asc' : 'desc'; switch ($sort) { case 'name': $sort_sql = 'name ' . $dir; break; case 'thumbnail': $sort_sql = 'thumbnail ' . $dir . ', id asc'; break; case 'category': $sort_sql = 'category ' . $dir . ', id asc'; break; case 'date': $sort_sql = 'date ' . $dir . ', id asc'; break; case 'author': $sort_sql = 'author ' . $dir . ', id asc'; break; default: $sort = 'id'; $sort_sql = 'id ' . $dir; break; } $switch_dir = $dir == 'desc' ? 'asc' : 'desc'; $criteria = 1; if ($search_method and $crit) { $crit_escaped = doSlash($crit); $critsql = array('id' => "ID in ('" . join("','", do_list($crit_escaped)) . "')", 'name' => "name like '%{$crit_escaped}%'", 'category' => "category like '%{$crit_escaped}%'", 'author' => "author like '%{$crit_escaped}%'", 'alt' => "alt like '%{$crit_escaped}%'", 'caption' => "caption like '%{$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_image', "{$criteria}"); if ($total < 1) { if ($criteria != 1) { echo n . image_search_form($crit, $search_method) . n . graf(gTxt('no_results_found'), ' class="indicator"'); } else { echo n . graf(gTxt('no_images_recorded'), ' class="indicator"'); } return; } $limit = max($image_list_pageby, 15); list($page, $offset, $numPages) = pager($total, $limit, $page); echo image_search_form($crit, $search_method); $rs = safe_rows_start('*, unix_timestamp(date) as uDate', 'txp_image', "{$criteria} order by {$sort_sql} limit {$offset}, {$limit}\n\t\t"); if ($rs) { echo n . n . '<form name="longform" method="post" action="index.php" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">' . n . n . startTable('list') . n . tr(column_head('ID', 'id', 'image', true, $switch_dir, $crit, $search_method, 'id' == $sort ? $dir : '') . hCell() . column_head('date', 'date', 'image', true, $switch_dir, $crit, $search_method, 'date' == $sort ? $dir : '') . column_head('name', 'name', 'image', true, $switch_dir, $crit, $search_method, 'name' == $sort ? $dir : '') . column_head('thumbnail', 'thumbnail', 'image', true, $switch_dir, $crit, $search_method, 'thumbnail' == $sort ? $dir : '') . hCell(gTxt('tags')) . column_head('image_category', 'category', 'image', true, $switch_dir, $crit, $search_method, 'category' == $sort ? $dir : '') . column_head('author', 'author', 'image', true, $switch_dir, $crit, $search_method, 'author' == $sort ? $dir : '') . hCell()); while ($a = nextRow($rs)) { extract($a); $edit_url = '?event=image' . a . 'step=image_edit' . a . 'id=' . $id . a . 'sort=' . $sort . a . 'dir=' . $dir . a . 'page=' . $page . a . 'search_method=' . $search_method . a . 'crit=' . $crit; $name = empty($name) ? gTxt('unnamed') : htmlspecialchars($name); if ($thumbnail) { if ($ext != '.swf') { $thumbnail = '<img src="' . hu . $img_dir . '/' . $id . 't' . $ext . "?{$uDate}" . '" alt="" />'; } else { $thumbnail = ''; } } else { $thumbnail = gTxt('no'); } if ($ext != '.swf') { $tag_url = '?event=tag' . a . 'tag_name=image' . a . 'id=' . $id . a . 'ext=' . $ext . a . 'w=' . $w . a . 'h=' . $h . a . 'alt=' . urlencode($alt) . a . 'caption=' . urlencode($caption); $tagbuilder = '<ul>' . '<li><a target="_blank" href="' . $tag_url . a . 'type=textile" onclick="popWin(this.href); return false;">Textile</a></li>' . '<li><a target="_blank" href="' . $tag_url . a . 'type=textpattern" onclick="popWin(this.href); return false;">Textpattern</a></li>' . '<li><a target="_blank" href="' . $tag_url . a . 'type=xhtml" onclick="popWin(this.href); return false;">XHTML</a></li>' . '</ul>'; } else { $tagbuilder = sp; } $category = $category ? '<span title="' . htmlspecialchars(fetch_category_title($category, 'image')) . '">' . $category . '</span>' : ''; echo n . n . tr(n . td($id, 20) . td(n . '<ul>' . n . t . '<li>' . href(gTxt('edit'), $edit_url) . '</li>' . n . t . '<li><a href="' . hu . $img_dir . '/' . $id . $ext . '">' . gTxt('view') . '</a></li>' . n . '</ul>', 35) . td(gTime($uDate), 75) . td(href($name, $edit_url), 75) . td(href($thumbnail, $edit_url), 80) . td($tagbuilder, 85) . td($category, 75) . td('<span title="' . htmlspecialchars(get_author_name($author)) . '">' . htmlspecialchars($author) . '</span>', 75) . td(fInput('checkbox', 'selected[]', $id), 10)); } echo n . n . tr(tda(select_buttons() . image_multiedit_form($page, $sort, $dir, $crit, $search_method), ' colspan="9" style="text-align: right; border: none;"')) . endTable() . '</form>' . nav_form('image', $page, $numPages, $sort, $dir, $crit, $search_method) . pageby_form('image', $image_list_pageby); } }
function products_list($event = '', $step = '', $message = '') { global $statuses, $comments_disabled_after, $step, $txp_user; $message = ''; pagetop(gTxt('tab_list'), $message); echo poweredit_products(); //echo the poweredit js extract(get_prefs()); extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method'))); $sesutats = array_flip($statuses); $dir = $dir == 'desc' ? 'desc' : 'asc'; echo '<script type="text/javascript" src="http://' . $siteurl . '/js/prototype.js"></script>'; echo '<script type="text/javascript" src="http://' . $siteurl . '/js/scriptaculous.js"></script>'; switch ($sort) { case 'id': $sort_sql = 'ID ' . $dir; break; case 'posted': $sort_sql = 'Posted ' . $dir; break; case 'title': $sort_sql = 'Title ' . $dir . ', Posted desc'; break; case 'section': $sort_sql = 'Section ' . $dir . ', Posted desc'; break; case 'category1': $sort_sql = 'Category1 ' . $dir . ', Posted desc'; break; case 'category2': $sort_sql = 'Category2 ' . $dir . ', Posted desc'; break; case 'status': $sort_sql = 'Status ' . $dir . ', Posted desc'; break; case 'author': $sort_sql = 'AuthorID ' . $dir . ', Posted desc'; break; case 'comments': $sort_sql = 'comments_count ' . $dir . ', Posted desc'; break; default: $dir = 'desc'; $sort_sql = 'Posted ' . $dir; break; } $switch_dir = $dir == 'desc' ? 'asc' : 'desc'; $criteria = "section = 'store'"; 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('textpattern', "{$criteria}"); if ($total < 1) { if ($criteria != 1) { echo n . list_search_form_products($crit, $search_method) . n . graf("No products found", ' style="text-align: center;"'); } else { echo graf("No products found", ' style="text-align: center;"'); } return; } $limit = max(@$article_list_pageby, 15); list($page, $offset, $numPages) = pager($total, $limit, $page); echo n . list_search_form_products($crit, $search_method); $rs = safe_rows_start('*, unix_timestamp(Posted) as posted', 'textpattern', "{$criteria} order by {$sort_sql} limit {$offset}, {$limit}"); if ($rs) { $total_comments = array(); // fetch true comment count, not the public comment count // maybe we should have another row in the db? $rs2 = safe_rows_start('parentid, count(*) as num', 'txp_discuss', "1 group by parentid order by parentid"); if ($rs2) { while ($a = nextRow($rs2)) { $pid = $a['parentid']; $num = $a['num']; $total_comments[$pid] = $num; } } echo n . n . '<form name="longform" method="post" action="index.php" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">' . n . startTable('list', '', '', '', '700') . n . tr(hCell() . n . column_head('ID', 'id', 'products', true, $switch_dir, $crit, $search_method) . column_head('title', 'title', 'products', true, $switch_dir, $crit, $search_method) . column_head('category1', 'category1', 'products', true, $switch_dir, $crit, $search_method) . column_head('category2', 'category2', 'products', true, $switch_dir, $crit, $search_method) . column_head('status', 'status', 'products', true, $switch_dir, $crit, $search_method) . hCell()); include_once txpath . '/publish/taghandlers.php'; while ($a = nextRow($rs)) { extract($a); if (empty($Title)) { $Title = '<em>' . eLink('product', 'edit', 'ID', $ID, gTxt('untitled')) . '</em>'; } else { $Title = eLink('product', 'edit', 'ID', $ID, $Title); } if (!empty($Image)) { $Image = "<img src='{$Image}' alt='Product Image' width='15' height='15'/>"; } $Category1 = '<span title="' . htmlspecialchars(fetch_category_title($Category1)) . '">' . $Category1 . ' </span>'; $Category2 = '<span title="' . htmlspecialchars(fetch_category_title($Category2)) . '">' . $Category2 . ' </span>'; $manage = n . '<ul class="articles_detail">' . n . t . '<li>' . eLink('product', 'edit', 'ID', $ID, gTxt('edit')) . '</li>' . (($Status == 4 or $Status == 5) ? n . t . '<li><a href="' . permlinkurl($a) . '">' . gTxt('view') . '</a></li>' : '') . n . '</ul>'; $Status = !empty($Status) ? $statuses[$Status] : ''; $comments = gTxt('none'); if (isset($total_comments[$ID]) and $total_comments[$ID] > 0) { $comments = href(gTxt('manage'), 'index.php?event=discuss' . a . 'step=list' . a . 'search_method=parent' . a . 'crit=' . $ID) . ' (' . $total_comments[$ID] . ')'; } $comment_status = $Annotate ? gTxt('on') : gTxt('off'); if ($comments_disabled_after) { $lifespan = $comments_disabled_after * 86400; $time_since = time() - $posted; if ($time_since > $lifespan) { $comment_status = gTxt('expired'); } } $comments = n . '<ul>' . n . t . '<li>' . $comment_status . '</li>' . n . t . '<li>' . $comments . '</li>' . n . '</ul>'; echo n . n . tr(n . td($Image, 15) . td(eLink('product', 'edit', 'ID', $ID, $ID) . $manage) . td($Title) . td($Category1, 100) . td($Category2, 100) . td($a['Status'] < 4 ? $Status : '<a href="' . permlinkurl($a) . '">' . $Status . '</a>', 50) . td(($a['Status'] >= 4 and has_privs('article.edit.published') or $a['Status'] >= 4 and $AuthorID == $txp_user and has_privs('article.edit.own.published') or $a['Status'] < 4 and has_privs('article.edit') or $a['Status'] < 4 and $AuthorID == $txp_user and has_privs('article.edit.own')) ? fInput('checkbox', 'selected[]', $ID) : ' ')); } echo n . n . tr(tda(toggle_box('articles_detail'), ' colspan="2" style="text-align: left; border: none;"') . tda(select_buttons() . product_multiedit_form($page, $sort, $dir, $crit, $search_method), ' colspan="5" style="text-align: right; border: none;"')) . n . endTable() . n . '</form>' . n . '<h4 style="font-weight:normal; text-align:center; width:100%;"><a href="#" class="navlink" onclick="if($(\'uploadCSV\').style.display == \'none\'){$(\'uploadCSV\').style.display = \'block\';}else{$(\'uploadCSV\').style.display = \'none\';}">Import Products</a>'; //n. $instructions = tag(tag('<li>Using FTP, upload your product images to <pre>/txp_site_root/images/_import/</pre></li><li>Upload a correctly formatted CSV file using the form below. (CSV must be in UTF-8 character encoding with DOS or UNIX line breaks.)</li><li>Sit back and watch the magic</li>', "ol"), "div", ' id="instructions" style="display:none; width: 380px; text-align:left; margin:0 auto;"'); echo tag('<h4 style="font-weight:normal; text-align:center; width:100%;"><small><a href="http://homeplatewp.com/TextCommerce/file_download/3">Download Example CSV</a> | <a href="javascript:void(0)" onclick="if($(\'instructions\').style.display == \'none\'){$(\'instructions\').style.display = \'block\';}else{$(\'instructions\').style.display = \'none\';}">Import Instructions</a></small></h4>' . $instructions . upload_form("Browse for CSV:", '', 'product_import', 'product'), 'div', ' id="uploadCSV" style="display:none;"'); echo n . nav_form('list', $page, $numPages, $sort, $dir, $crit, $search_method) . n . pageby_form('list', $article_list_pageby); } }
function main() { extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method'))); $event = $this->parent->event; $permlinks = $this->parent->get_all_permlinks(); $total = count($permlinks); if ($total < 1) { echo graf('You haven\'t created any custom permanent links rules yet.', ' style="text-align: center;"') . graf('<a href="' . $this->url(array(gbp_tab => 'build'), true) . '">Click here</a> to add one.', ' style="text-align: center;"'); return; } $limit = max($this->pref('list_pageby'), 15); list($page, $offset, $numPages) = $this->pager($total, $limit, $page); if (empty($sort)) { $sort = 'pl_precedence'; } if (empty($dir)) { $dir = 'desc'; } $dir = $dir == 'desc' ? 'desc' : 'asc'; // Sort the permlinks via the selected column and then their names. foreach ($permlinks as $id => $permlink) { $sort_keys[$id] = $permlink['settings'][$sort]; $name[$id] = $permlink['settings']['pl_name']; } array_multisort($sort_keys, $dir == 'desc' ? SORT_DESC : SORT_ASC, $name, SORT_ASC, $permlinks); $switch_dir = $dir == 'desc' ? 'asc' : 'desc'; $permlinks = array_slice($permlinks, $offset, $limit); if (count($permlinks)) { echo n . n . '<form name="longform" method="post" action="index.php" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">' . n . startTable('list') . n . tr(n . column_head('name', 'pl_name', $event, true, $switch_dir, $crit, $search_method) . hCell() . column_head('preview', 'pl_preview', $event, true, $switch_dir, $crit, $search_method) . column_head('precedence', 'pl_precedence', $event, true, $switch_dir, $crit, $search_method) . hCell()); include_once txpath . '/publish/taghandlers.php'; foreach ($permlinks as $id => $permlink) { extract($permlink['settings']); $manage = n . '<ul' . (version_compare($GLOBALS['thisversion'], '4.0.3', '<=') ? ' style="margin:0;padding:0;list-style-type:none;">' : '>') . n . t . '<li>' . href(gTxt('edit'), $this->url(array(gbp_tab => 'build', gbp_id => $id), true)) . '</li>' . n . '</ul>'; echo n . n . tr(td(href($pl_name, $this->url(array(gbp_tab => 'build', gbp_id => $id), true)), 75) . td($manage, 35) . td($pl_preview, 175) . td($pl_precedence . ' ', 50) . td(fInput('checkbox', 'selected[]', $id))); } echo n . n . tr(tda(select_buttons() . $this->permlinks_multiedit_form($page, $sort, $dir, $crit, $search_method), ' colspan="4" style="text-align: right; border: none;"')) . n . endTable() . n . '</form>' . n . $this->nav_form($event, $page, $numPages, $sort, $dir, $crit, $search_method) . n . pageby_form($event, $this->pref('list_pageby')); } }
function discuss_list($message = '') { global $comment_list_pageby; pagetop(gTxt('list_discussions'), $message); echo graf('<a href="index.php?event=discuss' . a . 'step=ipban_list">' . gTxt('list_banned_ips') . '</a>', ' style="text-align: center;"'); extract(gpsa(array('sort', 'dir', 'page', 'crit', 'search_method'))); $dir = $dir == 'asc' ? 'asc' : 'desc'; switch ($sort) { case 'id': $sort_sql = 'discussid ' . $dir; break; case 'ip': $sort_sql = 'ip ' . $dir; break; case 'name': $sort_sql = 'name ' . $dir; break; case 'email': $sort_sql = 'email ' . $dir; break; case 'website': $sort_sql = 'web ' . $dir; break; case 'message': $sort_sql = 'message ' . $dir; break; case 'status': $sort_sql = 'visible ' . $dir; break; case 'parent': $sort_sql = 'parentid ' . $dir; break; default: $sort = 'date'; $sort_sql = 'txp_discuss.posted ' . $dir; break; } if ($sort != 'date') { $sort_sql .= ', txp_discuss.posted asc'; } $switch_dir = $dir == 'desc' ? 'asc' : 'desc'; $criteria = 1; if ($search_method and $crit) { $crit_escaped = doSlash($crit); $critsql = array('id' => "discussid = '{$crit_escaped}'", 'parent' => "parentid = '{$crit_escaped}'" . (intval($crit_escaped) ? '' : " OR title like '%{$crit_escaped}%'"), 'name' => "name like '%{$crit_escaped}%'", 'message' => "message like '%{$crit_escaped}%'", 'email' => "email like '%{$crit_escaped}%'", 'website' => "web like '%{$crit_escaped}%'", 'ip' => "ip like '%{$crit_escaped}%'"); if (array_key_exists($search_method, $critsql)) { $criteria = $critsql[$search_method]; $limit = 500; } else { $search_method = ''; $crit = ''; } } else { $search_method = ''; $crit = ''; } $counts = getRows('SELECT visible, COUNT(*) AS c' . ' FROM ' . safe_pfx_j('txp_discuss') . ' LEFT JOIN ' . safe_pfx_j('textpattern') . ' ON txp_discuss.parentid = textpattern.ID' . ' WHERE ' . $criteria . ' GROUP BY visible'); $count[SPAM] = $count[MODERATE] = $count[VISIBLE] = 0; if ($counts) { foreach ($counts as $c) { $count[$c['visible']] = $c['c']; } } // grand total comment count $total = $count[SPAM] + $count[MODERATE] + $count[VISIBLE]; if ($total < 1) { if ($criteria != 1) { echo n . discuss_search_form($crit, $search_method) . n . graf(gTxt('no_results_found'), ' class="indicator"'); } else { echo graf(gTxt('no_comments_recorded'), ' class="indicator"'); } return; } // paging through displayed comments $total = (cs('toggle_show_spam') ? $count[SPAM] : 0) + $count[MODERATE] + $count[VISIBLE]; $limit = max($comment_list_pageby, 15); list($page, $offset, $numPages) = pager($total, $limit, $page); echo discuss_search_form($crit, $search_method); $spamq = cs('toggle_show_spam') ? '1=1' : 'visible != ' . intval(SPAM); $rs = safe_query('SELECT txp_discuss.*, unix_timestamp(txp_discuss.posted) as uPosted, ID as thisid, Section as section, url_title, Title as title, Status, unix_timestamp(textpattern.Posted) as posted' . ' FROM ' . safe_pfx_j('txp_discuss') . ' LEFT JOIN ' . safe_pfx_j('textpattern') . ' ON txp_discuss.parentid = textpattern.ID' . ' WHERE ' . $spamq . ' AND ' . $criteria . ' ORDER BY ' . $sort_sql . ' LIMIT ' . $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', '', '', '', '90%') . n . n . tr(column_head('ID', 'id', 'discuss', true, $switch_dir, $crit, $search_method, 'id' == $sort ? $dir : '') . column_head('date', 'date', 'discuss', true, $switch_dir, $crit, $search_method, 'date' == $sort ? $dir : '') . column_head('name', 'name', 'discuss', true, $switch_dir, $crit, $search_method, 'name' == $sort ? $dir : '') . column_head('message', 'message', 'discuss', true, $switch_dir, $crit, $search_method, 'message' == $sort ? $dir : '') . column_head('email', 'email', 'discuss', true, $switch_dir, $crit, $search_method, ('email' == $sort ? "{$dir} " : '') . 'discuss_detail') . column_head('website', 'website', 'discuss', true, $switch_dir, $crit, $search_method, ('website' == $sort ? "{$dir} " : '') . 'discuss_detail') . column_head('IP', 'ip', 'discuss', true, $switch_dir, $crit, $search_method, ('ip' == $sort ? "{$dir} " : '') . 'discuss_detail') . column_head('status', 'status', 'discuss', true, $switch_dir, $crit, $search_method, ('status' == $sort ? "{$dir} " : '') . 'discuss_detail') . column_head('parent', 'parent', 'discuss', true, $switch_dir, $crit, $search_method, 'parent' == $sort ? $dir : '') . hCell()); include_once txpath . '/publish/taghandlers.php'; while ($a = nextRow($rs)) { extract($a); $parentid = assert_int($parentid); $edit_url = '?event=discuss' . a . 'step=discuss_edit' . a . 'discussid=' . $discussid . a . 'sort=' . $sort . a . 'dir=' . $dir . a . 'page=' . $page . a . 'search_method=' . $search_method . a . 'crit=' . $crit; $dmessage = $visible == SPAM ? short_preview($message) : $message; switch ($visible) { case VISIBLE: $comment_status = gTxt('visible'); $row_class = 'visible'; break; case SPAM: $comment_status = gTxt('spam'); $row_class = 'spam'; break; case MODERATE: $comment_status = gTxt('unmoderated'); $row_class = 'moderate'; break; default: break; } if (empty($thisid)) { $parent = gTxt('article_deleted') . ' (' . $parentid . ')'; $view = ''; } else { $parent_title = empty($title) ? '<em>' . gTxt('untitled') . '</em>' : escape_title($title); $parent = href($parent_title, '?event=article' . a . 'step=edit' . a . 'ID=' . $parentid); $view = ''; if ($visible == VISIBLE and in_array($Status, array(4, 5))) { $view = n . t . '<li><a href="' . permlinkurl($a) . '#c' . $discussid . '">' . gTxt('view') . '</a></li>'; } } echo n . n . tr(n . td('<a href="' . $edit_url . '">' . $discussid . '</a>' . n . '<ul class="discuss_detail">' . n . t . '<li><a href="' . $edit_url . '">' . gTxt('edit') . '</a></li>' . $view . n . '</ul>', 50) . td(gTime($uPosted)) . td(htmlspecialchars(soft_wrap($name, 15))) . td(short_preview($dmessage)) . td(htmlspecialchars(soft_wrap($email, 15)), '', 'discuss_detail') . td(htmlspecialchars(soft_wrap($web, 15)), '', 'discuss_detail') . td($ip, '', 'discuss_detail') . td($comment_status, '', 'discuss_detail') . td($parent) . td(fInput('checkbox', 'selected[]', $discussid)), ' class="' . $row_class . '"'); } if (empty($message)) { echo tr(tda(gTxt('just_spam_results_found'), ' colspan="9" style="text-align: left; border: none;"')); } echo tr(tda(toggle_box('discuss_detail'), ' colspan="2" style="text-align: left; border: none;"') . tda(select_buttons() . discuss_multiedit_form($page, $sort, $dir, $crit, $search_method), ' colspan="9" style="text-align: right; border: none;"')) . endTable() . '</form>' . n . cookie_box('show_spam') . nav_form('discuss', $page, $numPages, $sort, $dir, $crit, $search_method) . pageby_form('discuss', $comment_list_pageby); } }
function link_list($message = '') { global $step, $link_list_pageby; extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method'))); $dir = $dir == 'desc' ? 'desc' : 'asc'; switch ($sort) { case 'id': $sort_sql = 'id ' . $dir; break; case 'description': $sort_sql = 'description ' . $dir . ', id asc'; break; case 'category': $sort_sql = 'category ' . $dir . ', id asc'; break; case 'date': $sort_sql = 'date ' . $dir . ', id asc'; break; default: $sort = 'name'; $sort_sql = 'linksort ' . $dir . ', id asc'; break; } $switch_dir = $dir == 'desc' ? 'asc' : 'desc'; $criteria = 1; if ($search_method and $crit) { $crit_escaped = doSlash($crit); $critsql = array('id' => "ID in ('" . join("','", do_list($crit_escaped)) . "')", 'name' => "linkname like '%{$crit_escaped}%'", 'description' => "description like '%{$crit_escaped}%'", 'category' => "category like '%{$crit_escaped}%'"); if (array_key_exists($search_method, $critsql)) { $criteria = $critsql[$search_method]; } else { $search_method = ''; $crit = ''; } } else { $search_method = ''; $crit = ''; } $total = getCount('txp_link', $criteria); if ($total < 1) { if ($criteria != 1) { echo n . link_search_form($crit, $search_method) . n . graf(gTxt('no_results_found'), ' class="indicator"'); } else { echo n . graf(gTxt('no_links_recorded'), ' class="indicator"'); } return; } $limit = max($link_list_pageby, 15); list($page, $offset, $numPages) = pager($total, $limit, $page); echo link_search_form($crit, $search_method); $rs = safe_rows_start('*, unix_timestamp(date) as uDate', 'txp_link', "{$criteria} order by {$sort_sql} limit {$offset}, {$limit}"); if ($rs) { echo n . n . '<form action="index.php" method="post" name="longform" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">', startTable('list') . n . tr(column_head('ID', 'id', 'link', true, $switch_dir, $crit, $search_method, 'id' == $sort ? $dir : '') . hCell() . column_head('link_name', 'name', 'link', true, $switch_dir, $crit, $search_method, 'name' == $sort ? $dir : '') . column_head('description', 'description', 'link', true, $switch_dir, $crit, $search_method, 'description' == $sort ? $dir : '') . column_head('link_category', 'category', 'link', true, $switch_dir, $crit, $search_method, 'category' == $sort ? $dir : '') . column_head('date', 'date', 'link', true, $switch_dir, $crit, $search_method, 'date' == $sort ? $dir : '') . hCell()); while ($a = nextRow($rs)) { extract($a); $edit_url = '?event=link' . a . 'step=link_edit' . a . 'id=' . $id . a . 'sort=' . $sort . a . 'dir=' . $dir . a . 'page=' . $page . a . 'search_method=' . $search_method . a . 'crit=' . $crit; echo tr(n . td($id, 20) . td(n . '<ul>' . n . t . '<li>' . href(gTxt('edit'), $edit_url) . '</li>' . n . t . '<li>' . href(gTxt('view'), $url) . '</li>' . n . '</ul>', 35) . td(href(htmlspecialchars($linkname), $edit_url), 125) . td(htmlspecialchars($description), 150) . td('<span title="' . htmlspecialchars(fetch_category_title($category, 'link')) . '">' . $category . '</span>', 125) . td(gTime($uDate), 75) . td(fInput('checkbox', 'selected[]', $id))); } echo n . n . tr(tda(select_buttons() . link_multiedit_form($page, $sort, $dir, $crit, $search_method), ' colspan="7" style="text-align: right; border: none;"')) . endTable() . '</form>' . n . nav_form('link', $page, $numPages, $sort, $dir, $crit, $search_method, $total, $limit) . pageby_form('link', $link_list_pageby); } }
function log_list($message = '') { pagetop(gTxt('visitor_logs'), $message); extract(get_prefs()); extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method'))); $expire_logs_after = assert_int($expire_logs_after); safe_delete('txp_log', "time < date_sub(now(), interval {$expire_logs_after} day)"); $dir = $dir == 'asc' ? 'asc' : 'desc'; switch ($sort) { case 'ip': $sort_sql = 'ip ' . $dir; break; case 'host': $sort_sql = 'host ' . $dir; break; case 'page': $sort_sql = 'page ' . $dir; break; case 'refer': $sort_sql = 'refer ' . $dir; break; case 'method': $sort_sql = 'method ' . $dir; break; case 'status': $sort_sql = 'status ' . $dir; break; default: $sort = 'time'; $sort_sql = 'time ' . $dir; break; } $switch_dir = $dir == 'desc' ? 'asc' : 'desc'; $criteria = 1; if ($search_method and $crit) { $crit_escaped = doSlash($crit); $critsql = array('ip' => "ip like '%{$crit_escaped}%'", 'host' => "host like '%{$crit_escaped}%'", 'page' => "page like '%{$crit_escaped}%'", 'refer' => "refer like '%{$crit_escaped}%'", 'method' => "method like '%{$crit_escaped}%'", 'status' => "status like '%{$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_log', "{$criteria}"); if ($total < 1) { if ($criteria != 1) { echo n . log_search_form($crit, $search_method) . n . graf(gTxt('no_results_found'), ' style="text-align: center;"'); } else { echo graf(gTxt('no_refers_recorded'), ' style="text-align: center;"'); } return; } $limit = max(@$log_list_pageby, 15); list($page, $offset, $numPages) = pager($total, $limit, $page); echo n . log_search_form($crit, $search_method); $rs = safe_rows_start('*, unix_timestamp(time) as uTime', 'txp_log', "{$criteria} order by {$sort_sql} limit {$offset}, {$limit}"); if ($rs) { echo n . n . '<form action="index.php" method="post" name="longform" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">' . startTable('list', '', '', '', '90%') . n . tr(n . column_head('time', 'time', 'log', true, $switch_dir, $crit, $search_method, 'time' == $sort ? $dir : '') . column_head('IP', 'ip', 'log', true, $switch_dir, $crit, $search_method, ('ip' == $sort ? "{$dir} " : '') . 'log_detail') . column_head('host', 'host', 'log', true, $switch_dir, $crit, $search_method, 'host' == $sort ? $dir : '') . column_head('page', 'page', 'log', true, $switch_dir, $crit, $search_method, 'page' == $sort ? $dir : '') . column_head('referrer', 'refer', 'log', true, $switch_dir, $crit, $search_method, 'refer' == $sort ? $dir : '') . column_head('method', 'method', 'log', true, $switch_dir, $crit, $search_method, ('method' == $sort ? "{$dir} " : '') . 'log_detail') . column_head('status', 'status', 'log', true, $switch_dir, $crit, $search_method, ('status' == $sort ? "{$dir} " : '') . 'log_detail') . hCell()); while ($a = nextRow($rs)) { extract($a, EXTR_PREFIX_ALL, 'log'); if ($log_refer) { $log_refer = htmlspecialchars('http://' . $log_refer); $log_refer = '<a href="' . $log_refer . '" target="_blank">' . soft_wrap($log_refer, 30) . '</a>'; } if ($log_page) { $log_page = htmlspecialchars($log_page); $log_page = '<a href="' . $log_page . '" target="_blank">' . soft_wrap(preg_replace('/\\/$/', '', substr($log_page, 1)), 30) . '</a>'; if ($log_method == 'POST') { $log_page = '<strong>' . $log_page . '</strong>'; } } echo tr(n . td(gTime($log_uTime), 85) . td($log_ip, 20, 'log_detail') . td(soft_wrap($log_host, 30)) . td($log_page) . td($log_refer) . td($log_method, 60, 'log_detail') . td($log_status, 60, 'log_detail') . td(fInput('checkbox', 'selected[]', $log_id))); } echo n . n . tr(tda(toggle_box('log_detail'), ' colspan="2" style="text-align: left; border: none;"') . tda(select_buttons() . log_multiedit_form($page, $sort, $dir, $crit, $search_method), ' colspan="6" style="text-align: right; border: none;"')) . n . endTable() . '</form>' . n . nav_form('log', $page, $numPages, $sort, $dir, $crit, $search_method) . n . pageby_form('log', $log_list_pageby); } }
function log_list($message = '') { global $event, $log_list_pageby, $expire_logs_after; pagetop(gTxt('visitor_logs'), $message); extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method'))); if ($sort === '') { $sort = get_pref('log_sort_column', 'time'); } if ($dir === '') { $dir = get_pref('log_sort_dir', 'desc'); } $dir = $dir == 'asc' ? 'asc' : 'desc'; $expire_logs_after = assert_int($expire_logs_after); safe_delete('txp_log', "time < date_sub(now(), interval {$expire_logs_after} day)"); switch ($sort) { case 'ip': $sort_sql = 'ip ' . $dir; break; case 'host': $sort_sql = 'host ' . $dir; break; case 'page': $sort_sql = 'page ' . $dir; break; case 'refer': $sort_sql = 'refer ' . $dir; break; case 'method': $sort_sql = 'method ' . $dir; break; case 'status': $sort_sql = 'status ' . $dir; break; default: $sort = 'time'; $sort_sql = 'time ' . $dir; break; } set_pref('log_sort_column', $sort, 'log', 2, '', 0, PREF_PRIVATE); set_pref('log_sort_dir', $dir, 'log', 2, '', 0, PREF_PRIVATE); $switch_dir = $dir == 'desc' ? 'asc' : 'desc'; $criteria = 1; if ($search_method and $crit) { $crit_escaped = doSlash(str_replace(array('\\', '%', '_', '\''), array('\\\\', '\\%', '\\_', '\\\''), $crit)); $critsql = array('ip' => "ip like '%{$crit_escaped}%'", 'host' => "host like '%{$crit_escaped}%'", 'page' => "page like '%{$crit_escaped}%'", 'refer' => "refer like '%{$crit_escaped}%'", 'method' => "method like '%{$crit_escaped}%'", 'status' => "status like '%{$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_log', "{$criteria}"); echo '<div id="' . $event . '_control" class="txp-control-panel">'; if ($total < 1) { if ($criteria != 1) { echo n . log_search_form($crit, $search_method) . n . graf(gTxt('no_results_found'), ' class="indicator"') . '</div>'; } else { echo graf(gTxt('no_refers_recorded'), ' class="indicator"') . '</div>'; } return; } $limit = max($log_list_pageby, 15); list($page, $offset, $numPages) = pager($total, $limit, $page); echo n . log_search_form($crit, $search_method) . '</div>'; $rs = safe_rows_start('*, unix_timestamp(time) as uTime', 'txp_log', "{$criteria} order by {$sort_sql} limit {$offset}, {$limit}"); if ($rs) { echo n . '<div id="' . $event . '_container" class="txp-container txp-list">'; echo n . n . '<form action="index.php" id="log_form" method="post" name="longform" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">' . startTable('list', '', 'list', '', '90%') . n . '<thead>' . n . tr(n . column_head('time', 'time', 'log', true, $switch_dir, $crit, $search_method, ('time' == $sort ? "{$dir} " : '') . 'date time') . column_head('IP', 'ip', 'log', true, $switch_dir, $crit, $search_method, ('ip' == $sort ? "{$dir} " : '') . 'log_detail ip') . column_head('host', 'host', 'log', true, $switch_dir, $crit, $search_method, ('host' == $sort ? "{$dir} " : '') . 'host') . column_head('page', 'page', 'log', true, $switch_dir, $crit, $search_method, ('page' == $sort ? "{$dir} " : '') . 'page') . column_head('referrer', 'refer', 'log', true, $switch_dir, $crit, $search_method, ('refer' == $sort ? "{$dir} " : '') . 'refer') . column_head('method', 'method', 'log', true, $switch_dir, $crit, $search_method, ('method' == $sort ? "{$dir} " : '') . 'log_detail method') . column_head('status', 'status', 'log', true, $switch_dir, $crit, $search_method, ('status' == $sort ? "{$dir} " : '') . 'log_detail status') . hCell('', '', ' class="multi-edit"')) . n . '</thead>'; $tfoot = n . '<tfoot>' . tr(tda(toggle_box('log_detail'), ' class="detail-toggle" colspan="2" style="text-align: left; border: none;"') . tda(select_buttons() . log_multiedit_form($page, $sort, $dir, $crit, $search_method), ' class="multi-edit" colspan="6" style="text-align: right; border: none;"')) . n . '</tfoot>'; echo $tfoot; echo '<tbody>'; $ctr = 1; while ($a = nextRow($rs)) { extract($a, EXTR_PREFIX_ALL, 'log'); if ($log_refer) { $log_refer = 'http://' . $log_refer; $log_refer = '<a href="' . htmlspecialchars($log_refer) . '" target="_blank">' . htmlspecialchars(soft_wrap($log_refer, 30)) . '</a>'; } if ($log_page) { $log_anchor = preg_replace('/\\/$/', '', $log_page); $log_anchor = soft_wrap(substr($log_anchor, 1), 30); $log_page = '<a href="' . htmlspecialchars($log_page) . '" target="_blank">' . htmlspecialchars($log_anchor) . '</a>'; if ($log_method == 'POST') { $log_page = '<strong>' . $log_page . '</strong>'; } } echo tr(n . td(gTime($log_uTime), 85, 'date time') . td($log_ip, 20, 'log_detail ip') . td(soft_wrap($log_host, 30), '', 'host') . td($log_page, '', 'page') . td($log_refer, '', 'refer') . td(htmlspecialchars($log_method), 60, 'log_detail method') . td($log_status, 60, 'log_detail status') . td(fInput('checkbox', 'selected[]', $log_id), '', 'multi-edit'), ' class="' . ($ctr % 2 == 0 ? 'even' : 'odd') . '"'); $ctr++; } echo '</tbody>' . n . endTable() . n . '</form>' . n . '<div id="' . $event . '_navigation" class="txp-navigation">' . n . nav_form('log', $page, $numPages, $sort, $dir, $crit, $search_method, $total, $limit) . n . pageby_form('log', $log_list_pageby) . n . '</div>' . n . '</div>'; } }
function discuss_list($message = '') { pagetop(gTxt('list_discussions'), $message); echo graf('<a href="index.php?event=discuss' . a . 'step=ipban_list">' . gTxt('list_banned_ips') . '</a>', ' style="text-align: center;"'); extract(get_prefs()); extract(gpsa(array('sort', 'dir', 'page', 'crit', 'search_method'))); $dir = $dir == 'asc' ? 'asc' : 'desc'; switch ($sort) { case 'id': $sort_sql = 'discussid ' . $dir; break; case 'ip': $sort_sql = 'ip ' . $dir . ', posted asc'; break; case 'name': $sort_sql = 'name ' . $dir . ', posted asc'; break; case 'email': $sort_sql = 'email ' . $dir . ', posted asc'; break; case 'website': $sort_sql = 'web ' . $dir . ', posted asc'; break; case 'message': $sort_sql = 'message ' . $dir . ', posted asc'; break; case 'status': $sort_sql = "visible {$dir}, posted asc"; break; case 'parent': $sort_sql = 'parentid ' . $dir . ', posted asc'; break; default: $sort = 'date'; $sort_sql = 'posted ' . $dir; break; } $switch_dir = $dir == 'desc' ? 'asc' : 'desc'; $criteria = 1; if ($search_method and $crit) { $crit_escaped = doSlash($crit); $critsql = array('id' => "discussid = '{$crit_escaped}'", 'parent' => "parentid = '{$crit_escaped}'", 'name' => "name like '%{$crit_escaped}%'", 'message' => "message like '%{$crit_escaped}%'", 'email' => "email like '%{$crit_escaped}%'", 'website' => "web like '%{$crit_escaped}%'", 'ip' => "ip like '%{$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_discuss', "{$criteria}"); if ($total < 1) { if ($criteria != 1) { echo n . discuss_search_form($crit, $search_method) . n . graf(gTxt('no_results_found'), ' style="text-align: center;"'); } else { echo graf(gTxt('no_comments_recorded'), ' style="text-align: center;"'); } return; } $limit = max(@$comment_list_pageby, 15); list($page, $offset, $numPages) = pager($total, $limit, $page); echo discuss_search_form($crit, $search_method); $spamq = cs('toggle_show_spam') ? '1=1' : 'visible != ' . intval(SPAM); $rs = safe_rows_start('*, unix_timestamp(posted) as uPosted', 'txp_discuss', "{$spamq} and {$criteria} order by {$sort_sql} limit {$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', '', '', '', '90%') . n . n . tr(column_head('ID', 'id', 'discuss', true, $switch_dir, $crit, $search_method, 'id' == $sort ? $dir : '') . column_head('date', 'date', 'discuss', true, $switch_dir, $crit, $search_method, 'date' == $sort ? $dir : '') . column_head('name', 'name', 'discuss', true, $switch_dir, $crit, $search_method, 'name' == $sort ? $dir : '') . column_head('message', 'message', 'discuss', true, $switch_dir, $crit, $search_method, 'message' == $sort ? $dir : '') . column_head('email', 'email', 'discuss', true, $switch_dir, $crit, $search_method, ('email' == $sort ? "{$dir} " : '') . 'discuss_detail') . column_head('website', 'website', 'discuss', true, $switch_dir, $crit, $search_method, ('website' == $sort ? "{$dir} " : '') . 'discuss_detail') . column_head('IP', 'ip', 'discuss', true, $switch_dir, $crit, $search_method, ('ip' == $sort ? "{$dir} " : '') . 'discuss_detail') . column_head('status', 'status', 'discuss', true, $switch_dir, $crit, $search_method, ('status' == $sort ? "{$dir} " : '') . 'discuss_detail') . column_head('parent', 'parent', 'discuss', true, $switch_dir, $crit, $search_method, 'parent' == $sort ? $dir : '') . hCell()); include_once txpath . '/publish/taghandlers.php'; while ($a = nextRow($rs)) { extract($a); $parentid = assert_int($parentid); $tq = safe_row('*, ID as thisid, unix_timestamp(Posted) as posted', 'textpattern', "ID = {$parentid}"); $edit_url = '?event=discuss' . a . 'step=discuss_edit' . a . 'discussid=' . $discussid . a . 'sort=' . $sort . a . 'dir=' . $dir . a . 'page=' . $page . a . 'search_method=' . $search_method . a . 'crit=' . $crit; $dmessage = $visible == SPAM ? short_preview($message) : $message; switch ($visible) { case VISIBLE: $comment_status = gTxt('visible'); $row_class = 'visible'; break; case SPAM: $comment_status = gTxt('spam'); $row_class = 'spam'; break; case MODERATE: $comment_status = gTxt('unmoderated'); $row_class = 'moderate'; break; default: break; } if (empty($tq)) { $parent = gTxt('article_deleted') . ' (' . $parentid . ')'; $view = ''; } else { $parent_title = empty($tq['Title']) ? '<em>' . gTxt('untitled') . '</em>' : escape_title($tq['Title']); $parent = href($parent_title, '?event=list' . a . 'step=list' . a . 'search_method=id' . a . 'crit=' . $tq['ID']); $view = ''; if ($visible == VISIBLE and in_array($tq['Status'], array(4, 5))) { $view = n . t . '<li><a href="' . permlinkurl($tq) . '#c' . $discussid . '">' . gTxt('view') . '</a></li>'; } } echo n . n . tr(n . td('<a href="' . $edit_url . '">' . $discussid . '</a>' . n . '<ul class="discuss_detail">' . n . t . '<li><a href="' . $edit_url . '">' . gTxt('edit') . '</a></li>' . $view . n . '</ul>', 50) . td(gTime($uPosted)) . td(htmlspecialchars(soft_wrap($name, 15))) . td(short_preview($dmessage)) . td(htmlspecialchars(soft_wrap($email, 15)), '', 'discuss_detail') . td(htmlspecialchars(soft_wrap($web, 15)), '', 'discuss_detail') . td($ip, '', 'discuss_detail') . td($comment_status, '', 'discuss_detail') . td($parent) . td(fInput('checkbox', 'selected[]', $discussid)), ' class="' . $row_class . '"'); } echo tr(tda(toggle_box('discuss_detail'), ' colspan="2" style="text-align: left; border: none;"') . tda(select_buttons() . discuss_multiedit_form($page, $sort, $dir, $crit, $search_method), ' colspan="9" style="text-align: right; border: none;"')) . endTable() . '</form>' . n . tag(cookie_box('show_spam'), 'div', ' style="margin:auto;padding:0 0 0 10px; width:90%"') . nav_form('discuss', $page, $numPages, $sort, $dir, $crit, $search_method) . pageby_form('discuss', $comment_list_pageby); } }