⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 setforums.cgi

📁 绿叶网络小学校园网-完全适合小学的网站
💻 CGI
📖 第 1 页 / 共 4 页
字号:
#!/usr/bin/perl

#############################################################
# Ikonboard v2.1
# Copyright 2000 Ikondiscussion.com - All Rights Reserved
# Ikondiscussion is a trademark of Ikondiscussion.com
#
# Software Distributed by: Ikondiscussion.com
# Visit us online at http://www.ikondiscussion.com
# Email us on boards@ikondiscussion.com
#
# All files written by Matthew Mecham
# This file co-written with ArmandoG
#############################################################

#use CGI::Carp "fatalsToBrowser";          # Output errors to browser
use CGI qw(:standard);                    # Saves loads of work
$CGI::POST_MAX=1024 * 150;                # limit post data
$CGI::DISABLE_UPLOADS = 1;                # Disable uploads

eval {
($0 =~ m,(.*)/[^/]+,)   and unshift (@INC, "$1");
($0 =~ m,(.*)\\[^\\]+,) and unshift (@INC, "$1");
require "ikon.lib";          # Require ikonboard ()
require "ikonadmin.lib";     # Require Admin func()
require "data/progs.cgi";    # Require prog names
require "data/boardinfo.cgi";# Require board info
require "data/styles.cgi";   # Require styles info
};
if ($@) {
    print header(-charset=>"gb2312"); print start_html(-title=>"ib2000 出错!");
    print "不能够找到文件:$@\n如果您使用的是 Windows 类操作系统,请在每一个程序中更改 require 的设置,填入绝对路径!";
    print end_html; exit;
}

$|++;                                     # Unbuffer the output

#################--- Begin the program ---###################

$thisprog = "setforums.cgi";

$inmembername = cookie("adminname");
$inpassword   = cookie("adminpass");


    $query = new CGI;

    &checkVALIDITY;
    
	@params = $query->param;
	foreach $param(@params) {
		$theparam = $query->param($param);
        $theparam = &cleaninput("$theparam");
		$PARAM{$param} = $theparam;
	    }

$boardurltemp =$boardurl;

$boardurltemp =~ s/http\:\/\/(\S+?)\/(.*)/\/$2/;
$cookiepath = $boardurltemp;
    $cookiepath =~ s/$thisprog//sg;

    $action      =  $PARAM{'action'};
    $inforum     =  $PARAM{'forum'};
    $incategory  =  $PARAM{'category'};
    $checkaction =  $PARAM{'checkaction'};

    $new_categoryname     = $PARAM{'categoryname'};
    $new_categorynumber   = $PARAM{'categorynumber'};
    $new_forumname        = $PARAM{'forumname'};
    $new_forumdescription = $PARAM{'forumdescription'};
    $new_forummoderator   = $PARAM{'forummoderator'};
    $new_htmlstate        = $PARAM{'htmlstate'};
    $new_idmbcodestate    = $PARAM{'idmbcodestate'};
    $new_privateforum     = $PARAM{'privateforum'};
    $new_startnewthreads  = $PARAM{'startnewthreads'};
    $new_forumgraphic     = $PARAM{'forumgraphic'};
   


print header(-charset=>"gb2312");

&admintitle;
        
&getmember("$inmembername");
        
        if (($membercode eq "ad") && ($inpassword eq $password) && ($inmembername eq $membername)) { #s1
            
            my %Mode = ( 
            'addforum'            =>    \&addforum,
            'processnew'          =>    \&createforum,
            'edit'                =>    \&editform,
            'doedit'              =>    \&doedit,       
            'addcategory'         =>    \&catform,
            'doaddcategory'       =>    \&doaddcategory,
            'editcatname'         =>    \&editcatname,
            'reordercategories'   =>    \&reordercats,
            'recount'             =>    \&recount
            );


            if($Mode{$action}) { 
               $Mode{$action}->();
               }
                elsif (($action eq "delete") && ($checkaction ne "yes")) { &warning; }
                elsif (($action eq "delete") && ($checkaction eq "yes")) { &deleteforum; }
                else { &forumlist; }
            
            } #e1
                
                else {
                    &adminlogin;
                    }
        

##################################################################################
######## Subroutes (forum list)

sub forumlist {
    $highest = 0;
    print qq~
    <tr><td bgcolor=#333333 colspan=3><font face=宋体 color=#FFFFFF>
    <b>欢迎来到论坛管理中心 / 论坛管理</b>
    </td></tr>
    <tr><td bgcolor=#FFFFFF colspan=3><font face=宋体 color=#333333>
    <b>注意事项:</b><br><br>
    在下面,您将看到目前所有的论坛分类。您可以编辑论坛分类名或是增加一个新的论坛到这个分类中。 
    也可以编辑或删除目前存在的论坛。您可以对目前的分类重新进行排列。<br>
    </td></tr>
    ~;

    $filetoopen = "$ikondir" . "data/allforums.cgi";
    open(FILE, "$filetoopen");
    @forums = <FILE>;
    close(FILE);

    foreach $forum (@forums) { #start foreach @forums
        chomp $forum;
        ($forumid, $category, $categoryplace, $forumname, $forumdescription, $forummoderator ,$htmlstate ,$idmbcodestate ,$privateforum, $startnewthreads ,$lastposter ,$lastposttime, $threads, $posts, $forumgraphic) = split(/\|/,$forum);
        $rearrange = ("$categoryplace|$category|$forumname|$forumdescription|$forumid|$threads|$posts");
        push (@rearrangedforums, $rearrange);

    } # end foreach (@forums)

    @finalsortedforums = sort(@rearrangedforums);

    foreach $sortedforums (@finalsortedforums) { #start foreach @finalsortedforums

        ($categoryplace, $category, $forumname, $forumdescription, $forumid, $threads, $posts) = split(/\|/,$sortedforums);
    
        if ($categoryplace ne $lastcategoryplace) { #start if $categoryplace
            print qq~
            <tr>
            <td bgcolor=#FFFFFF colspan=3 ><font face=宋体 color=#333333><hr noshade>
            </td></tr>
            <tr>
            <td bgcolor=#EEEEEE width=20% nowrap><font face=宋体 color=#333333>
            分类名: <b>$category</b><td bgcolor=#EEEEEE width=15% align=center nowrap><font face=宋体 color=#333333><a href="$thisprog?action=editcatname&category=$categoryplace">编辑分类名称</a></td><td bgcolor=#EEEEEE width=25% align=left><font face=宋体 color=#333333><a href="$thisprog?action=addforum&category=$categoryplace">增加论坛到此分类中</a></font></td>
            </td></tr>
            <tr>
            <td bgcolor=#FFFFFF colspan=3 align=left nowrap><font face=宋体 color=#333333>
            论坛名: <b>$forumname</b><br>主题数: <b>$threads</b> <--> <font face=宋体 color=#333333>回复数: <b>$posts</b><br><br><a href="$thisprog?action=edit&forum=$forumid">编辑此论坛</a> | <font face=宋体 color=#333333><a href="$thisprog?action=delete&forum=$forumid">删除此论坛</a> | <a href="$thisprog?action=recount&forum=$forumid">重新计算主题和回复数 / 修复此论坛</a></font></td>
             </font></td></tr>
            ~;
            } # end if
            else {
                print qq~
                <tr>
                <td bgcolor=#FFFFFF colspan=3 align=left nowrap><hr noshade width=70% size=1><font face=宋体 color=#333333>
                论坛名: <b>$forumname</b><br>主题数: <b>$threads</b> <--> <font face=宋体 color=#333333>回复数: <b>$posts</b><br><br><a href="$thisprog?action=edit&forum=$forumid">编辑此论坛</a> | <font face=宋体 color=#333333><a href="$thisprog?action=delete&forum=$forumid">删除此论坛</a> | <a href="$thisprog?action=recount&forum=$forumid">重新计算主题和回复数 / 修复此论坛</a></font></td>
                </font></td></tr>
                ~;
                }
            $lastcategoryplace = $categoryplace;
            if ($categoryplace > $highest) { $highest = $categoryplace; }
            } # end foreach
    
        $highest++;
        
        print qq~
        <td bgcolor=#FFFFFF colspan=3 ><font face=宋体 color=#333333><hr noshade>
        </td></tr>
        <tr>
        <td bgcolor=#EEEEEE colspan=3 align=center><font face=宋体 color=#333333>
        <a href="$thisprog?action=reordercategories">论坛分类重新排序</a>
        &nbsp;&nbsp;&nbsp;&nbsp;--&nbsp;&nbsp;&nbsp;&nbsp;
        <a href="$thisprog?action=addcategory&category=$highest">增加分类(同时增加一个论坛)</a>
        </font></td>
        </tr>
        </tr></table></td></tr></table>~;
    
} # end routine.

##################################################################################
######## Recount forum posts


sub recount { #start

        
        $dirtoopen = "$ikondir" . "forum$inforum";
        
        opendir (DIR, "$dirtoopen"); 
        @dirdata = readdir(DIR);
        closedir (DIR);
        
        @thd = grep(/thd$/,@dirdata);
        $topiccount = @thd;
        

        foreach $topic (@thd) {
        
            $filetoopen = "$ikondir" . "forum$inforum/$topic";

            open (FILE, "$filetoopen");
            @threads = <FILE>;
            close (FILE);

            $newthreads = @threads;
            $newthreads--;
            $threadcount = $threadcount + $newthreads;
         }
       
         $threadcount = "0" if (!$threadcount);
         $topiccount  = "0" if (!$topiccount);
                    
        
         $filetoopen = "$ikondir" . "data/allforums.cgi";
         open(FILE,"$filetoopen") or &systemerror("不能够找到 $filetoopen");
         @allforums = <FILE>;
         close(FILE);

         $filetomake = "$ikondir" . "data/allforums.cgi";
         open(FILE, ">$filetomake");
         flock(FILE, 2) if ($OS_USED eq "Unix");
         foreach $forum (@allforums) { #start foreach @forums
         chomp($forum);
            ($tempno, $trash) = split(/\|/,$forum);
                if ($inforum eq $tempno) {
                    ($forumid, $category, $categoryplace, $forumname, $forumdescription, $forummoderator ,$htmlstate ,$idmbcodestate ,$privateforum, $startnewthreads ,$lastposter ,$lastposttime, $threads, $posts, $forumgraphic) = split(/\|/,$forum);
                    $posts = $threadcount;
                    $threads = $topiccount;
                    print FILE "$forumid|$category|$categoryplace|$forumname|$forumdescription|$forummoderator|$htmlstate|$idmbcodestate|$privateforum|$startnewthreads|$lastposter|$lastposttime|$threads|$posts|$forumgraphic\n";
                }
            else { print FILE "$forum\n"; }
         }
         close(FILE);
    
         rebuildLIST(-Forum=>"$inforum");

         print qq~
         <tr><td bgcolor=#333333" colspan=2><font face=宋体 color=#FFFFFF>
         <b>欢迎来到论坛管理中心 / 重计算主题和回复数</b>
         </td></tr>
         <tr>
         <td bgcolor=#FFFFFF valign=middle align=left colspan=2>
         <font face=宋体 color=#990000>
         <center><b>论坛更新成功</b></center><p>
         主题数: $topiccount<p>
         回复数: $threadcount
         </td></tr></table></td></tr></table>
         ~;


} # routine ends

##################################################################################
######## Subroutes ( Add forum Form )


sub addforum {

        print qq~
        <tr><td bgcolor=#333333" colspan=2><font face=宋体 color=#FFFFFF>
        <b>欢迎来到论坛管理中心 / 增加论坛</b>
        </td></tr>
        ~;

        $filetoopen = "$ikondir" . "data/allforums.cgi";
        open(FILE, "$filetoopen");
        @forums = <FILE>;
        close(FILE);


# Find the category name from the number

        foreach (@forums) {
            ($trash, $tempcategoryname, $tempcategoryplace, $trash) = split(/\|/, $_);
            if ($incategory eq $tempcategoryplace) {
                $category = $tempcategoryname;
                }
            }
        
        
# Present the form to be filled in


        print qq~
        
        <tr>
        <td bgcolor=#EEEEEE valign=middle align=center colspan=2>
        <font face=宋体 color=#990000><b>在 '$category' 分类中增加新论坛</b>
        </td></tr>
                
        <form action="$thisprog" method="post">
        <input type=hidden name="categorynumber" value="$incategory">
        <input type=hidden name="categoryname" value="$category">
        <input type=hidden name="action" value="processnew">       
        <tr>
        <td bgcolor=#FFFFFF valign=middle align=left width=40%>
        <font face=宋体 color=#333333><b>论坛名称</b><br>请输入新论坛的名称<BR>(请控制在 20 个汉字内)</font></td>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -