<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">###############################################################################
# ManageCats.pl                                                               #
###############################################################################
# YaBB: Yet another Bulletin Board                                            #
# Open-Source Community Software for Webmasters                               #
# Version:        YaBB 1 Gold - SP 1.3                                        #
# Released:       December 2001; Updated April 6, 2003                        #
# Distributed by: http://www.yabbforum.com                                    #
# =========================================================================== #
# Copyright (c) 2000-2003 YaBB (www.yabbforum.com) - All Rights Reserved.     #
# Software by: The YaBB Development Team                                      #
#              with assistance from the YaBB community.                       #
# Sponsored by: Xnull Internet Media, Inc. - http://www.ximinc.com            #
###############################################################################

$managecatsplver = "1 Gold - SP 1.3";

sub ManageCats {
	&amp;is_admin;
	my $selected = "";
	fopen(FILE, "$vardir/cat.txt");
	@categories = &lt;FILE&gt;;
	fclose(FILE);
	# create a list of categories for reorder
	$catlist="";
	foreach $curcat (@categories) {
		$curcat =~ s/[\n\r]//g;
		$catlist="$catlist\n$curcat";
	}
	# create membergroups dropdown
	my $mgroups = qq~&lt;select multiple name="memgroup" size="3"&gt;~;
	fopen(FILE, "$vardir/membergroups.txt");
	@groups = &lt;FILE&gt;;
	fclose(FILE);
	for($i = 7; $i &lt; @groups; ++$i ) {
		$groups[$i] =~ s/[\n\r]//g;
		chomp $groups[$i];
		$groups[$i] =~ s~\&lt;~&amp;lt;~g;
		$groups[$i] =~ s~\&gt;~&amp;gt;~g;
		$mgroups .= qq~\n&lt;option&gt;$groups[$i]&lt;/option&gt;~;
	}
	$mgroups .= qq~\n&lt;/select&gt;~;
	$yymain .= qq~
&lt;table border="0" cellspacing="1" cellpadding="4" bgcolor="$color{'bordercolor'}" class="bordercolor" align="center" width="680"&gt;
  &lt;tr&gt;
    &lt;td class="titlebg" bgcolor="$color{'titlebg'}" colspan="2"&gt;
    &lt;img src="$imagesdir/cat.gif" border="0" alt=""&gt;
    &lt;font size=2 class="text1" color="$color{'titletext'}"&gt;&lt;b&gt;$txt{'52'}&lt;/b&gt;&lt;/font&gt;&lt;/td&gt;
  &lt;/tr&gt;&lt;tr&gt;
    &lt;td colspan="2" bgcolor="$color{'catbg'}" class="catbg" height="25"&gt;&lt;font size="2"&gt;&lt;b&gt;$txt{'54'}&lt;/B&gt;&lt;/font&gt;&lt;/td&gt;
  &lt;/tr&gt;&lt;tr&gt;
    &lt;td bgcolor="$color{'windowbg'}" class="windowbg" height="25"&gt;
    &lt;BR&gt;&lt;font size="1"&gt;$txt{'738'}&lt;/font&gt;&lt;BR&gt;&lt;BR&gt;&lt;/td&gt;
    &lt;td class="windowbg" bgcolor="$color{'windowbg'}" valign=top&gt;&lt;font size=2&gt;
    &lt;form action="$cgi;action=modifycatorder" method="POST"&gt;
    &lt;textarea name="cats" cols="40" rows="4"&gt;$catlist&lt;/textarea&gt;&lt;br&gt;&lt;BR&gt;
    &lt;input type="submit" value="$txt{'54'}"&gt;
    &lt;/form&gt;&lt;/font&gt;&lt;/td&gt;
  &lt;/tr&gt;&lt;tr&gt;
    &lt;td colspan="2" bgcolor="$color{'catbg'}" class="catbg" height="25"&gt;&lt;font size="2"&gt;
    &lt;b&gt;$txt{'56'}&lt;/b&gt;&lt;/font&gt;&lt;/td&gt;
  &lt;/tr&gt;&lt;tr&gt;
    &lt;td colspan="2" class="windowbg2" bgcolor="$color{'windowbg2'}" valign="top"&gt;
    &lt;form action="$cgi;action=createcat" method="POST"&gt;
    &lt;table border="0" cellspacing="1" cellpadding="4" bgcolor="$color{'bordercolor'}" class="bordercolor" align="center"&gt;
      &lt;tr&gt;
        &lt;td class="windowbg2" bgcolor="$color{'windowbg2'}" valign="top"&gt;&lt;font size="2"&gt;
        &lt;b&gt;$txt{'43'}:&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;font size="1"&gt;$txt{'671'}&lt;/font&gt;&lt;/td&gt;
        &lt;td class="windowbg2" bgcolor="$color{'windowbg2'}" valign="top"&gt;&lt;font size="2"&gt;
        &lt;input type="text" size="15" name="catid"&gt;&lt;/font&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;tr&gt;
        &lt;td class="windowbg2" bgcolor="$color{'windowbg2'}" valign="top"&gt;&lt;font size="2"&gt;
        &lt;b&gt;$txt{'44'}:&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;font size="1"&gt;$txt{'672'}&lt;/font&gt;&lt;/td&gt;
        &lt;td class="windowbg2" bgcolor="$color{'windowbg2'}" valign="top"&gt;&lt;font size="2"&gt;
        &lt;input type="text" size="40" name="catname"&gt;&lt;/font&gt;&lt;/td&gt;
      &lt;/tr&gt;&lt;tr&gt;
        &lt;td class="windowbg2" bgcolor="$color{'windowbg2'}" valign="top" width="50%"&gt;&lt;font size="2"&gt;
        &lt;b&gt;$txt{'57'}:&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;font size="1"&gt;$txt{'673'}&lt;/font&gt;&lt;/td&gt;
        &lt;td class="windowbg2" bgcolor="$color{'windowbg2'}" valign="top" width="50%"&gt;&lt;font size="2"&gt;
        $mgroups&lt;br&gt;&lt;br&gt;
        &lt;input type="submit" value="$txt{'59'}"&gt;    
        &lt;/font&gt;&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/table&gt;
    &lt;/form&gt;&lt;/td&gt;
  &lt;/tr&gt;

~;
	foreach $curcat (@categories) {
		$curcat =~ s~[\n\r]~~g;
		chomp $curcat;
		fopen(CAT, "$boardsdir/$curcat.cat");
		@catinfo = &lt;CAT&gt;;
		fclose(CAT);
		$curcatname = $catinfo[0];
		chomp $curcatname;
		(@curcatgroups) = split(/\,/, $catinfo[1]);
		$mgroups = qq~&lt;select multiple name="catgroups" size="3"&gt;~;
		for($i = 7; $i &lt; @groups; ++$i) {
			$groups[$i] =~ s~[\n\r]~~g;
			chomp $groups[$i];
			$selected = "";
			foreach $cur (@curcatgroups) {
				$cur =~ s~[\n\r]~~g;
				chomp $cur;
				if($cur eq $groups[$i]) { $selected = " selected"; break;}
			}
			$groups[$i] =~ s~\&lt;~&amp;lt;~g;
			$groups[$i] =~ s~\&gt;~&amp;gt;~g;
			$mgroups .= qq~\n&lt;option$selected&gt;$groups[$i]&lt;/option&gt;~;
		}
		$mgroups .= qq~\n&lt;/select&gt;~;
		$yymain .= qq~
  &lt;tr&gt;
    &lt;td colspan="2" bgcolor="$color{'catbg'}" class="catbg" height="25"&gt;&lt;font size="2"&gt;&lt;b&gt;$txt{'43'}: $curcat&lt;/B&gt;&lt;/font&gt;&lt;/td&gt;
  &lt;/tr&gt;&lt;tr&gt;
    &lt;td bgcolor="$color{'windowbg'}" class="windowbg" colspan="2"&gt;
    &lt;form action="$cgi;action=modifycat" method="POST"&gt;
    &lt;table border="0" cellpadding="4" cellspacing="0" width="100%"&gt;
      &lt;tr&gt;
        &lt;td valign="middle"&gt;&lt;font size="2"&gt;
        $txt{'44'}:&lt;BR&gt; &lt;input type="text" value="$curcatname" size="25" name="catname"&gt;&lt;/font&gt;&lt;/td&gt;
        &lt;td valign="middle"&gt;&lt;font size="2"&gt;
        $txt{'57'}:&lt;BR&gt;
        $mgroups
        &lt;/font&gt;&lt;/td&gt;
        &lt;td valign="middle"&gt;
        &lt;input type="hidden" name="id" value="$curcat"&gt;
        &lt;input type="submit" name="moda" value="$txt{'17'}"&gt; &amp;nbsp;&lt;input type="submit" name="moda" value="$txt{'31'}"&gt;&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/table&gt;
    &lt;/form&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
~;
		}
$yymain .= qq~
&lt;/table&gt;
~;
	$yytitle = "$txt{'52'}";
	&amp;template;
	exit;
}

sub ReorderCats {
	&amp;is_admin;
	$FORM{'cats'} =~ s/\r//g;
	$cats = $FORM{'cats'};
	(@cats) = split(/\n/, $cats);
	$thecats = "";
	foreach $ccat (@cats) {
		$ccat =~ s/[\n\r]//g;
		if(-e("$boardsdir/$ccat.cat") &amp;&amp; $ccat !~ /\A\n*\Z/) { $thecats .= "$ccat\n"; }
	}
	$thecats =~ s/\A\n*\r*\Z//g;
	fopen(FILE, "&gt;$vardir/cat.txt", 1);
	print FILE "$thecats";
	fclose(FILE);
	$yySetLocation = qq~$cgi;action=managecats~;
	&amp;redirectexit;
}

sub CreateCat {
	&amp;is_admin;
	$catid = $FORM{'catid'};
	&amp;fatal_error("$txt{'240'} $txt{'43'} $txt{'241'}") if($catid !~ /\A[0-9A-Za-z#%+-\.@^_]+\Z/);
	
	# make sure no board already exists with that id
	fopen(FILE, "$vardir/cat.txt");
	@categories = &lt;FILE&gt;;
	fclose(FILE);
	foreach $curcat (@categories) {
		$curcat =~ s/[\n\r]//g;
		&amp;fatal_error("$txt{'676'} '$catid' $txt{'675'}") if ($catid eq "$curcat");
	}

	fopen(FILE, "$vardir/cat.txt");
	@categories = &lt;FILE&gt;;
	fclose(FILE);
	fopen(FILE, "&gt;$vardir/cat.txt", 1);
	foreach $curcat (@categories) {
		$curcat =~ s/[\n\r]//g;
		print FILE "$curcat\n";
	}
	$catid =~ s/ /_/g;
	$FORM{'memgroup'} =~ s~\A\s?,\s?~~;
	$FORM{'memgroup'} =~ s~,\s~,~g;
	print FILE "$catid";
	fclose(FILE);
	fopen(FILE, "&gt;$boardsdir/$catid.cat");
	print FILE "$FORM{'catname'}\n";
	print FILE "$FORM{'memgroup'}\n";
	fclose(FILE);
	$yySetLocation = qq~$cgi;action=managecats~;
	&amp;redirectexit;
}

sub ConfRemCat {
	$yymain .= qq~
&lt;table border="0" width="100%" cellspacing="1" bgcolor="$color{'bordercolor'}" class="bordercolor"&gt;
  &lt;tr&gt;
    &lt;td class="titlebg" bgcolor="$color{'titlebg'}"&gt;&lt;font size=2 class="text1" color="$color{'titletext'}"&gt;&lt;b&gt;$txt{'31'} - '$FORM{'catname'}'?&lt;/b&gt;&lt;/font&gt;&lt;/td&gt;
  &lt;/tr&gt;&lt;tr&gt;
    &lt;td class="windowbg" bgcolor="$color{'windowbg'}"&gt;&lt;font size=2&gt;
    $txt{'736'}&lt;br&gt;
    &lt;b&gt;&lt;a href="$cgi;action=modifycat;id=$FORM{'id'};moda=$txt{'31'}2"&gt;$txt{'163'}&lt;/a&gt; - &lt;a href="$cgi;action=manageboards"&gt;$txt{'164'}&lt;/a&gt;&lt;/b&gt;
    &lt;/font&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;
~;
	$yytitle = "$txt{'31'} - '$FORM{'catname'}'?";
	&amp;template;
	exit;
}

sub ModifyCat {
	&amp;is_admin;
	if($FORM{'moda'} eq "$txt{'17'}") {
		fopen(FILE, "$boardsdir/$FORM{'id'}.cat");
		@catinfo = &lt;FILE&gt;;
		fclose(FILE);
		fopen(FILE, "&gt;$boardsdir/$FORM{'id'}.cat", 1);
		$FORM{'catgroups'} =~ s~\A\s?,\s?~~;
		$FORM{'catgroups'} =~ s~,\s~,~g;
		print FILE "$FORM{'catname'}\n";
		print FILE "$FORM{'catgroups'}\n";
		for ($i = 2; $i &lt; @catinfo; $i++) {
			chomp @catinfo;
			$catinfo =~ s/[\n\r]//g;
			print FILE "$catinfo[$i]\n";
		}
		fclose(FILE);
		$yySetLocation = qq~$cgi;action=managecats~;
		&amp;redirectexit;
	} else {
		if($FORM{'moda'} eq "$txt{'31'}") { &amp;ConfRemCat; }
		else {
		fopen(FILE, "$vardir/cat.txt");
		@categories = &lt;FILE&gt;;
		fclose(FILE);
		$newcatlist="";
		foreach $curcat (@categories) {
			$curcat =~ s/[\n\r]//g;
			if($curcat ne "$INFO{'id'}") { $newcatlist="$newcatlist$curcat\n"; }
		}
		fopen(FILE, "&gt;$vardir/cat.txt", 1);
		print FILE "$newcatlist";
		fclose(FILE);
		$curcat = "$INFO{'id'}";

		fopen(CAT, "$boardsdir/$curcat.cat") || &amp;fatal_error("$txt{'23'} $curcat.cat");
		@catinfo = &lt;CAT&gt;;
		fclose(CAT);
		$curcatname="$catinfo[0]";
		foreach $curboard (@catinfo) {
			$curboard =~ s/[\n\r]//g;
			if($curboard ne "$catinfo[0]") {
				fopen(BOARDDATA, "$boardsdir/$curboard.txt");
				@messages = &lt;BOARDDATA&gt;;
				fclose(BOARDDATA);
				foreach $curmessage (@messages) {
					($id, $dummy) = split(/\|/, $curmessage);
					unlink("$datadir/$id.txt");
					unlink("$datadir/$id.mail");
					unlink("$datadir/$id.data");
					$yymain .= "$txt{'49'} $id&lt;br&gt;";
					&amp;Sticky_remove($id);
				}
			}
			unlink("$boardsdir/$curboard.txt");
			unlink("$boardsdir/$curboard.mail");
			unlink("$boardsdir/$curboard.dat");
			unlink("$boardsdir/$curboard.ctb");
			unlink("$boardsdir/$curboard.ttl");
			$yymain .= "$txt{'50'}&lt;br&gt;";
		}
		unlink("$boardsdir/$curcat.cat");
		$yymain .= "$txt{'61'}&lt;br&gt;";
		$yymain .= "$txt{'51'}";
		$yytitle = "$txt{'60'}";
		&amp;template;
		exit;
		}
	}
}

1;</pre></body></html>