function showcategoryrow($key, $level = 0, $last = '') { global $_G; loadcache('yuexiamen'); $value = $_G['cache']['yuexiamen'][$key]; $return = ''; // include_once libfile('function/portalcp'); $value['articles'] = category_get_num('portal', $key); $publish = ''; if (empty($_G['cache']['portalcategory'][$key]['disallowpublish'])) { $publish = ' <a href="portal.php?mod=portalcp&ac=article&catid=' . $key . '" target="_blank">' . cplang('portalcategory_publish') . '</a>'; } if ($level == 2) { $class = $last ? 'lastchildboard' : 'childboard'; $return = '<tr class="hover" id="cat' . $value['catid'] . '"><td> </td><td class="td25"><input type="text" class="txt" name="neworder[' . $value['catid'] . ']" value="' . $value['displayorder'] . '" /></td><td><div class="' . $class . '">' . '<input type="text" class="txt" name="name[' . $value['catid'] . ']" value="' . $value['catname'] . '" />' . '</div>' . '</td><td>' . $value['articles'] . '</td>' . '<td>' . (empty($value['disallowpublish']) ? cplang('yes') : cplang('no')) . '</td>' . '<td>' . (!empty($value['allowcomment']) ? cplang('yes') : cplang('no')) . '</td>' . '<td>' . (empty($value['closed']) ? cplang('yes') : cplang('no')) . '</td>' . '<td><input class="radio" type="radio" name="newsetindex" value="' . $value['catid'] . '" ' . ($value['caturl'] == $_G['setting']['defaultindex'] ? 'checked="checked"' : '') . ' /></td>' . '<td><a href="' . $value['caturl'] . '" target="_blank">' . cplang('view') . '</a> <a href="' . ADMINSCRIPT . '?action=portalcategory&operation=edit&catid=' . $value['catid'] . '">' . cplang('edit') . '</a> <a href="' . ADMINSCRIPT . '?action=portalcategory&operation=move&catid=' . $value['catid'] . '">' . cplang('portalcategory_move') . '</a> <a href="' . ADMINSCRIPT . '?action=portalcategory&operation=delete&catid=' . $value['catid'] . '">' . cplang('delete') . '</a> <a href="' . ADMINSCRIPT . '?action=diytemplate&operation=perm&targettplname=portal/list_' . $value['catid'] . '&tpldirectory=' . getdiydirectory($value['primaltplname']) . '">' . cplang('portalcategory_blockperm') . '</a></td> <td><a href="' . ADMINSCRIPT . '?action=article&operation=list&&catid=' . $value['catid'] . '">' . cplang('portalcategory_articlemanagement') . '</a> <a href="' . ADMINSCRIPT . '?action=portalcategory&operation=perm&catid=' . $value['catid'] . '">' . cplang('portalcategory_articleperm') . '</a>' . $publish . '</td></tr>'; } elseif ($level == 1) { $return = '<tr class="hover" id="cat' . $value['catid'] . '"><td> </td><td class="td25"><input type="text" class="txt" name="neworder[' . $value['catid'] . ']" value="' . $value['displayorder'] . '" /></td><td><div class="board">' . '<input type="text" class="txt" name="name[' . $value['catid'] . ']" value="' . $value['catname'] . '" />' . '<a class="addchildboard" href="' . ADMINSCRIPT . '?action=portalcategory&operation=add&upid=' . $value['catid'] . '">' . cplang('portalcategory_addthirdcategory') . '</a></div>' . '</td><td>' . $value['articles'] . '</td>' . '<td>' . (empty($value['disallowpublish']) ? cplang('yes') : cplang('no')) . '</td>' . '<td>' . (!empty($value['allowcomment']) ? cplang('yes') : cplang('no')) . '</td>' . '<td>' . (empty($value['closed']) ? cplang('yes') : cplang('no')) . '</td>' . '<td><input class="radio" type="radio" name="newsetindex" value="' . $value['catid'] . '" ' . ($value['caturl'] == $_G['setting']['defaultindex'] ? 'checked="checked"' : '') . ' /></td>' . '<td><a href="' . $value['caturl'] . '" target="_blank">' . cplang('view') . '</a> <a href="' . ADMINSCRIPT . '?action=portalcategory&operation=edit&catid=' . $value['catid'] . '">' . cplang('edit') . '</a> <a href="' . ADMINSCRIPT . '?action=portalcategory&operation=move&catid=' . $value['catid'] . '">' . cplang('portalcategory_move') . '</a> <a href="' . ADMINSCRIPT . '?action=portalcategory&operation=delete&catid=' . $value['catid'] . '">' . cplang('delete') . '</a> <a href="' . ADMINSCRIPT . '?action=diytemplate&operation=perm&targettplname=portal/list_' . $value['catid'] . '&tpldirectory=' . getdiydirectory($value['primaltplname']) . '">' . cplang('portalcategory_blockperm') . '</a></td> <td><a href="' . ADMINSCRIPT . '?action=article&operation=list&&catid=' . $value['catid'] . '">' . cplang('portalcategory_articlemanagement') . '</a> <a href="' . ADMINSCRIPT . '?action=portalcategory&operation=perm&catid=' . $value['catid'] . '">' . cplang('portalcategory_articleperm') . '</a>' . $publish . '</td></tr>'; for ($i = 0, $L = count($value['children']); $i < $L; $i++) { $return .= showcategoryrow($value['children'][$i], 2, $i == $L - 1); } } else { $childrennum = count($_G['cache']['portalcategory'][$key]['children']); $toggle = $childrennum > 25 ? ' style="display:none"' : ''; $return = '<tbody><tr class="hover" id="cat' . $value['catid'] . '"><td onclick="toggle_group(\'group_' . $value['catid'] . '\')"><a id="a_group_' . $value['catid'] . '" href="javascript:;">' . ($toggle ? '[+]' : '[-]') . '</a></td>' . '<td class="td25"><input type="text" class="txt" name="neworder[' . $value['catid'] . ']" value="' . $value['displayorder'] . '" /></td><td><div class="parentboard">' . '<input type="text" class="txt" name="name[' . $value['catid'] . ']" value="' . $value['catname'] . '" />' . '</div>' . '</td><td>' . $value['articles'] . '</td>' . '<td>' . (empty($value['disallowpublish']) ? cplang('yes') : cplang('no')) . '</td>' . '<td>' . (!empty($value['allowcomment']) ? cplang('yes') : cplang('no')) . '</td>' . '<td>' . (empty($value['closed']) ? cplang('yes') : cplang('no')) . '</td>' . '<td><input class="radio" type="radio" name="newsetindex" value="' . $value['catid'] . '" ' . ($value['caturl'] == $_G['setting']['defaultindex'] ? 'checked="checked"' : '') . ' /></td>' . '<td><a href="' . $value['caturl'] . '" target="_blank">' . cplang('view') . '</a> <a href="' . ADMINSCRIPT . '?action=portalcategory&operation=edit&catid=' . $value['catid'] . '">' . cplang('edit') . '</a> <a href="' . ADMINSCRIPT . '?action=portalcategory&operation=move&catid=' . $value['catid'] . '">' . cplang('portalcategory_move') . '</a> <a href="' . ADMINSCRIPT . '?action=portalcategory&operation=delete&catid=' . $value['catid'] . '">' . cplang('delete') . '</a> <a href="' . ADMINSCRIPT . '?action=diytemplate&operation=perm&targettplname=portal/list_' . $value['catid'] . '&tpldirectory=' . getdiydirectory($value['primaltplname']) . '">' . cplang('portalcategory_blockperm') . '</a></td> <td><a href="' . ADMINSCRIPT . '?action=article&operation=list&&catid=' . $value['catid'] . '">' . cplang('portalcategory_articlemanagement') . '</a> <a href="' . ADMINSCRIPT . '?action=portalcategory&operation=perm&catid=' . $value['catid'] . '">' . cplang('portalcategory_articleperm') . '</a>' . $publish . '</td></tr></tbody> <tbody id="group_' . $value['catid'] . '"' . $toggle . '>'; for ($i = 0, $L = count($value['children']); $i < $L; $i++) { $return .= showcategoryrow($value['children'][$i], 1, ''); } $return .= '</tdoby><tr><td> </td><td colspan="9"><div class="lastboard"><a class="addtr" href="' . ADMINSCRIPT . '?action=portalcategory&operation=add&upid=' . $value['catid'] . '">' . cplang('portalcategory_addsubcategory') . '</a></td></div>'; } return $return; }
$subtitle[] = 'operation'; showformheader('topic'); showtableheader('topic_list'); showsubtitle($subtitle); $multipage = ''; $count = C::t('portal_topic')->count_by_search_where($wherearr); if ($count) { require_once libfile('function/portal'); $repairs = array(); foreach (C::t('portal_topic')->fetch_all_by_search_where($wherearr, $ordersql, $start, $perpage) as $topicid => $value) { if ($maketopichtml && $value['htmlmade'] && ($htmlname = fetch_topic_url($value)) && !file_exists(DISCUZ_ROOT . './' . $htmlname)) { $value['htmlmade'] = 0; $repairs[$topicid] = $topicid; } $tablerow = array("<input type=\"checkbox\" class=\"checkbox\" name=\"ids[]\" value=\"{$topicid}\">", ($value['htmlmade'] ? "[<a href='{$htmlname}' target='_blank'>HTML</a>]" : '') . "<a href=\"portal.php?mod=topic&topicid={$topicid}\" target=\"_blank\">" . $value[title] . "</a>" . ($value['closed'] ? ' [' . cplang('topic_closed_yes') . ']' : ''), $value['domain'] && !empty($_G['setting']['domain']['root']['topic']) ? 'http://' . $value['domain'] . '.' . $_G['setting']['domain']['root']['topic'] : '', $value['name'], "<a href=\"home.php?mod=space&uid={$value['uid']}&do=profile\" target=\"_blank\">{$value['username']}</a>", dgmdate($value[dateline])); if ($maketopichtml) { $tablerow[] = "<span id='mkhtml_{$value['topicid']}' style='color:" . ($value['htmlmade'] ? "blue;'>" . cplang('setting_functions_makehtml_made') : "red;'>" . cplang('setting_functions_makehtml_dismake')) . "</span>"; } $tablerow[] = ($maketopichtml ? $maketopichtml && !$value['closed'] ? "<a href='javascript:void(0);' onclick=\"make_html('portal.php?mod=topic&topicid={$value['topicid']}', \$('mkhtml_{$value['topicid']}'))\">" . cplang('setting_functions_makehtml_make') . "</a>" : cplang('setting_functions_makehtml_make_has_closed') : '') . " <a href=\"portal.php?mod=portalcp&ac=topic&topicid={$topicid}\" target=\"_blank\">" . cplang('topic_edit') . "</a> " . "<a href=\"portal.php?mod=topic&topicid={$topicid}&diy=yes\" target=\"_blank\">DIY</a>" . ' <a href="' . ADMINSCRIPT . '?action=diytemplate&operation=perm&targettplname=portal/portal_topic_content_' . $value['topicid'] . '&tpldirectory=' . getdiydirectory($value['primaltplname']) . '">' . cplang('topic_perm') . '</a>'; showtablerow('', array('class="td25"', 'class=""', 'class="td28"'), $tablerow); } $multipage = multi($count, $perpage, $page, $mpurl); if ($repairs) { C::t('portal_topic')->repair_htmlmade($repairs); } } $ops = cplang('operation') . ': ' . "<input type='radio' class='radio' name='optype' value='open' id='op_close' /><label for='op_close'>" . cplang('topic_closed_no') . "</label> " . "<input type='radio' class='radio' name='optype' value='close' id='op_open' /><label for='op_open'>" . cplang('topic_closed_yes') . "</label> " . "<input type='radio' class='radio' name='optype' value='delete' id='op_delete' /><label for='op_delete'>" . cplang('delete') . "</label> "; showsubmit('', '', '', '<input type="checkbox" name="chkall" id="chkall" class="checkbox" onclick="checkAll(\'prefix\', this.form, \'ids\')" /><label for="chkall">' . cplang('select_all') . '</label> ' . $ops . '<input type="submit" class="btn" name="opsubmit" value="' . cplang('submit') . '" />', $multipage); showtablefooter(); showformfooter(); }
function updatetopic($topic = '') { global $_G; $topicid = empty($topic) ? '' : $topic['topicid']; include_once libfile('function/home'); $_POST['title'] = getstr(trim($_POST['title']), 255); $_POST['name'] = getstr(trim($_POST['name']), 255); $_POST['domain'] = getstr(trim($_POST['domain']), 255); if (empty($_POST['title'])) { return 'topic_title_cannot_be_empty'; } if (empty($_POST['name'])) { $_POST['name'] = $_POST['title']; } if (!$topicid || $_POST['name'] != $topic['name']) { if ($value = C::t('portal_topic')->fetch_by_name($_POST['name'])) { return 'topic_name_duplicated'; } } if ($topicid && !empty($topic['domain'])) { require_once libfile('function/delete'); deletedomain($topicid, 'topic'); } if (!empty($_POST['domain'])) { require_once libfile('function/domain'); domaincheck($_POST['domain'], $_G['setting']['domain']['root']['topic'], 1); } $setarr = array('title' => $_POST['title'], 'name' => $_POST['name'], 'domain' => $_POST['domain'], 'summary' => getstr($_POST['summary']), 'keyword' => getstr($_POST['keyword']), 'useheader' => $_POST['useheader'] ? '1' : '0', 'usefooter' => $_POST['usefooter'] ? '1' : '0', 'allowcomment' => $_POST['allowcomment'] ? 1 : 0, 'closed' => $_POST['closed'] ? 0 : 1); if ($_POST['deletecover'] && $topic['cover']) { if ($topic['picflag'] != '0') { pic_delete(str_replace('portal/', '', $topic['cover']), 'portal', 0, $topic['picflag'] == '2' ? '1' : '0'); } $setarr['cover'] = ''; } else { if ($_FILES['cover']['tmp_name']) { if ($topic['cover'] && $topic['picflag'] != '0') { pic_delete(str_replace('portal/', '', $topic['cover']), 'portal', 0, $topic['picflag'] == '2' ? '1' : '0'); } $pic = pic_upload($_FILES['cover'], 'portal'); if ($pic) { $setarr['cover'] = 'portal/' . $pic['pic']; $setarr['picflag'] = $pic['remote'] ? '2' : '1'; } } else { if (!empty($_POST['cover']) && $_POST['cover'] != $topic['cover']) { if ($topic['cover'] && $topic['picflag'] != '0') { pic_delete(str_replace('portal/', '', $topic['cover']), 'portal', 0, $topic['picflag'] == '2' ? '1' : '0'); } $setarr['cover'] = $_POST['cover']; $setarr['picflag'] = '0'; } } } $primaltplname = ''; if (empty($topicid) || empty($topic['primaltplname']) || $topic['primaltplname'] && $topic['primaltplname'] != $_POST['primaltplname']) { $primaltplname = $_POST['primaltplname']; if (!isset($_POST['signs'][dsign($primaltplname)])) { return 'diy_sign_invalid'; } $checktpl = checkprimaltpl($primaltplname); if ($checktpl !== true) { return $checktpl; } $setarr['primaltplname'] = $primaltplname; } if ($topicid) { C::t('portal_topic')->update($topicid, $setarr); C::t('common_diy_data')->update('portal/portal_topic_content_' . $topicid, getdiydirectory($topic['primaltplname']), array('name' => $setarr['title'])); } else { $setarr['uid'] = $_G['uid']; $setarr['username'] = $_G['username']; $setarr['dateline'] = $_G['timestamp']; $setarr['closed'] = '1'; $topicid = addtopic($setarr); if (!$topicid) { return 'topic_created_failed'; } } if (!empty($_POST['domain'])) { C::t('common_domain')->insert(array('domain' => $_POST['domain'], 'domainroot' => $_G['setting']['domain']['root']['topic'], 'id' => $topicid, 'idtype' => 'topic')); } $tpldirectory = ''; if ($primaltplname && $topic['primaltplname'] != $primaltplname) { $targettplname = 'portal/portal_topic_content_' . $topicid; if (strpos($primaltplname, ':') !== false) { list($tpldirectory, $primaltplname) = explode(':', $primaltplname); } C::t('common_diy_data')->update($targettplname, getdiydirectory($topic['primaltplname']), array('primaltplname' => $primaltplname, 'tpldirectory' => $tpldirectory)); updatediytemplate($targettplname); } if ($primaltplname && empty($topic['primaltplname'])) { $tpldirectory = $tpldirectory ? $tpldirectory : $_G['cache']['style_default']['tpldir']; $content = file_get_contents(DISCUZ_ROOT . $tpldirectory . '/' . $primaltplname . '.htm'); $tplfile = DISCUZ_ROOT . './data/diy/' . $tpldirectory . '/portal/portal_topic_content_' . $topicid . '.htm'; $tplpath = dirname($tplfile); if (!is_dir($tplpath)) { dmkdir($tplpath); } file_put_contents($tplfile, $content); } include_once libfile('function/cache'); updatecache(array('diytemplatename', 'setting')); return $topicid; }
\t\t\t\t\t\t<option value="20"{$perpages['20']}>{$searchlang['perpage_20']}</option> \t\t\t\t\t\t<option value="50"{$perpages['50']}>{$searchlang['perpage_50']}</option> \t\t\t\t\t\t<option value="100"{$perpages['100']}>{$searchlang['perpage_100']}</option> \t\t\t\t\t\t</select> \t\t\t\t\t\t<input type="hidden" name="action" value="topic"> \t\t\t\t\t\t<input type="submit" name="searchsubmit" value="{$searchlang['search']}" class="btn"> \t\t\t\t\t</td> \t\t\t\t</tr> \t\t\t</table> \t\t</div> \t</form> SEARCH; $start = ($page - 1) * $perpage; $mpurl .= '&perpage=' . $perpage; $perpages = array($perpage => ' selected'); showformheader('topic'); showtableheader('topic_list'); showsubtitle(array('', 'topic_title', 'topic_domain', 'topic_name', 'topic_creator', 'topic_dateline', 'operation')); $multipage = ''; $count = C::t('portal_topic')->count_by_search_where($wherearr); if ($count) { foreach (C::t('portal_topic')->fetch_all_by_search_where($wherearr, $ordersql, $start, $perpage) as $topicid => $value) { showtablerow('', array('class="td25"', 'class=""', 'class="td28"'), array("<input type=\"checkbox\" class=\"checkbox\" name=\"ids[]\" value=\"{$topicid}\">", "<a href=\"portal.php?mod=topic&topicid={$topicid}\" target=\"_blank\">" . $value[title] . "</a>" . ($value['closed'] ? ' [' . cplang('topic_closed_yes') . ']' : ''), $value['domain'] && !empty($_G['setting']['domain']['root']['topic']) ? 'http://' . $value['domain'] . '.' . $_G['setting']['domain']['root']['topic'] : '', $value['name'], "<a href=\"home.php?mod=space&uid={$value['uid']}&do=profile\" target=\"_blank\">{$value['username']}</a>", dgmdate($value[dateline]), "<a href=\"portal.php?mod=portalcp&ac=topic&topicid={$topicid}\" target=\"_blank\">" . cplang('topic_edit') . "</a> " . "<a href=\"portal.php?mod=topic&topicid={$topicid}&diy=yes\" target=\"_blank\">DIY</a>" . ' <a href="' . ADMINSCRIPT . '?action=diytemplate&operation=perm&targettplname=portal/portal_topic_content_' . $value['topicid'] . '&tpldirectory=' . getdiydirectory($value['primaltplname']) . '">' . cplang('topic_perm') . '</a>')); } $multipage = multi($count, $perpage, $page, $mpurl); } $ops = cplang('operation') . ': ' . "<input type='radio' class='radio' name='optype' value='open' id='op_close' /><label for='op_close'>" . cplang('topic_closed_no') . "</label> " . "<input type='radio' class='radio' name='optype' value='close' id='op_open' /><label for='op_open'>" . cplang('topic_closed_yes') . "</label> " . "<input type='radio' class='radio' name='optype' value='delete' id='op_delete' /><label for='op_delete'>" . cplang('delete') . "</label> "; showsubmit('', '', '', '<input type="checkbox" name="chkall" id="chkall" class="checkbox" onclick="checkAll(\'prefix\', this.form, \'ids\')" /><label for="chkall">' . cplang('select_all') . '</label> ' . $ops . '<input type="submit" class="btn" name="opsubmit" value="' . cplang('submit') . '" />', $multipage); showtablefooter(); showformfooter(); }