<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;"># News Categories Addon
# version 2.0 (enhanced) build 3
# by plushpuffin and wrestlingg@mer
# email: plushpuffin@yahoo.com and wrestlinggamer@houston.rr.com
#
push(@Addons_Loaded, 'News Categories 2.0b3');
push(@Addons_DisplaySubForm, 'NewsCatSubForm');
push(@Addons_PageHandler, 'NewsCatPageHandler');
push(@Addons_BuildNews_Post, 'NewsCatBuild');
push(@Addons_MainPage, 'NewsCat_MainPage');
push(@Addons_NPHTMLFoot, 'NewsCat_HTMLFoot');
push(@Addons_RemoveNews2, 'NewsCatRemoveNews2');
push(@Addons_RemoveNewsSave, 'NewsCatRemoveNewsSave');
push(@Addons_SaveNews_3, 'NewsCatSubmitSaveBuild');
push(@Addons_RemoveNewsSave_2, 'NewsCatRemoveNewsSaveBuild');
$Addons_List{'News Categories 2.0b3'} = ['npa_newscat2.pl',
q~Manages different categories and news files (profiles) from one copy of NewsPro. enhanced by &lt;a href="mailto:plushpuffin@yahoo.com"&gt;plushpuffin&lt;/a&gt; - &lt;b&gt;&lt;a href="http://plushpuffin.virtualave.net"&gt;plushpuffin's addon garden&lt;/a&gt;&lt;/b&gt;~,''];
$filext = $NPConfig{'ArcHtmlExt'};

sub NewsCatBuild {
	&amp;NewsCatLoadConfig;
	foreach $i (sort keys %newsprofiles) {
		if ($newsprofiles{$i}-&gt;[0]) {
			unless($newsprofiles{$i}-&gt;[16] &amp;&amp; $newsprofiles{$i}-&gt;[12]) {
				&amp;BuildProfile;
			}
		}
	}
}

sub NewsCatTotalReBuild {
	&amp;NewsCatLoadConfig;
	&amp;loadND;
	require $ndisplaypl;
	foreach $i (sort keys %newsprofiles) {
		if ($newsprofiles{$i}-&gt;[0]) {
			&amp;BuildProfile;
		}
	}
}

sub NewsCatBuildStatic {
	&amp;NewsCatLoadConfig;
	require $ndisplaypl;
	foreach $i (sort keys %newsprofiles) {
		if ($newsprofiles{$i}-&gt;[0] &amp;&amp; $newsprofiles{$i}-&gt;[12] &amp;&amp; $newsprofiles{$i}-&gt;[16]) {
			&amp;BuildProfile;
		}
	}
}

sub NewsCatSubmitSaveBuild {
	if ($newsktalk) {
		$ktalkURL = $snid;
		$ktalkURL =~ s/[^\d\,]//g;
		$ktalkURL = "$talkbaseURL/$ktalkURL$talkext";
		$ktalknum = 0;
	}
	else {
		$ktalkURL = '';
		$ktalknum = 0;
	}
	local @NewsData;
	local $newsid = $snid;
	&amp;SubmitFormFields;
	my @ffields = @formfields;
	push(@ffields, @ffield_add);
	foreach (@ffields) {
		$NewsData[0]-&gt;{$_} = ${$_};
	}
	&amp;NewsCatBuildStatic;
}

sub NewsCatRemoveNewsSaveBuild {
	NewsCatRNSB2( \@NewsData );
}

sub NewsCatRNSB2 {
	my $reff = shift;
	my( $key, $val );
	local @NewsData;
	while( ($key,$val) = each(%ChangedItems) ) {
		if( $val ) {
			push( @NewsData, $$reff[$key] );
		}
	}
	&amp;NewsCatBuildStatic;
}

sub BuildProfile {
	$prof = $newsprofiles{$i};
	# Filter by category and date.
	my $filtsub;
	if ($prof-&gt;[8]) {$filtsub = $prof-&gt;[8];}
	else {$filtsub = 'NewsCatFilter';}
	@FilteredND = &amp;$filtsub(split(/\!/, $prof-&gt;[2]), $prof-&gt;[3]);
	# Filter by maximum number.
	if (@FilteredND &gt; $prof-&gt;[4] || $prof-&gt;[11]) {
		my $maxnum = $#FilteredND - $prof-&gt;[11];
		my $minnum = $maxnum - $prof-&gt;[4];
		$minnum++;
		$minnum = $minnum &lt; 0 ? 0 : $minnum;
		@FilteredND = @FilteredND[$minnum..$maxnum];
	}
	# Filtered! Build news.
	$newsnum = $#FilteredND;
	$content = '';
	my( $ff, $content );
	if( $prof-&gt;[12] eq 'split' ) {
		my( @stattext, @statsubs, @stattmpl, @statfile, $statfile, $statsubs, $stattmpl, $statnum, $statmax, $filebase );
		@statsubs = ();
		push( @statsubs, $prof-&gt;[5] ) if( $prof-&gt;[5] );
		@stattmpl = ();
		push( @stattmpl, $prof-&gt;[6] ) if( $prof-&gt;[6] );
		@_ = split( /;*\s*;\s*;*/, $prof-&gt;[14] );
		foreach (@_) {
			push( @stattmpl, $_ ) if( $_ );
		}
		@_ = split( /;*\s*;\s*;*/, $prof-&gt;[15] );
		foreach (@_) {
			push( @statsubs, $_ ) if( $_ );
		}
		while ($newsnum &gt;= 0) {
			foreach $ff (keys %{$FilteredND[$newsnum]}) {
				${$ff} = $FilteredND[$newsnum]-&gt;{$ff};
			}
			$newsdate = &amp;GetTheDate($newstime);
			@stattext = split( /&lt;pr&gt;/i, $newstext );
			$statmax = scalar @stattext;
			@statfile = ( &amp;NCMakeFName );
			$filebase = &amp;NCMakePartialFName;
			for( $_ = 2; $_ &lt;= @stattext; $_++ ) {
				$statfile[$_-1] = "$filebase$_.$filext";
			}
			for( $statnum = 0; $statnum &lt; $statmax; $statnum++ ) {
				$newstext = $stattext[$statnum];
				$FileName = $statfile[$statnum];
				$statsubs = $statsubs[$statnum] || $statsubs[$#statsubs];
				$stattmpl = $stattmpl[$statnum] || $stattmpl[$#stattmpl];
				$prevhref = $statnum ? $statfile[$statnum-1] : '';
				$nexthref = $statnum &lt; $statmax ? $statfile[$statnum+1] : '';
				&amp;{$statsubs};
				NPopen(NCFILE, "&gt;$prof-&gt;[9]/$FileName");
				if( $stattmpl ) {
					print NCFILE ProcessTMPL("$NPConfig{'admin_path'}/$stattmpl",$newshtml,$newssubject);
				}
				else {
					print NCFILE $newshtml;
				}
				close(NCFILE);
			}
			$newsnum--;
		}
	}
	elsif( $prof-&gt;[12] eq 'static' ) {
		my( $statfile );
		while ($newsnum &gt;= 0) {
			foreach $ff (keys %{$FilteredND[$newsnum]}) {
				${$ff} = $FilteredND[$newsnum]-&gt;{$ff};
			}
			$newsdate = &amp;GetTheDate($newstime);
			$FileName = &amp;NCMakeFName;
			&amp;{$prof-&gt;[5]};
			$content .= $newshtml;
			NPopen(NCFILE, "&gt;$prof-&gt;[9]/$FileName");
			if( $prof-&gt;[6] ) {
				print NCFILE ProcessTMPL("$NPConfig{'admin_path'}/$prof-&gt;[6]",$newshtml,$newssubject);
			}
			else {
				print NCFILE $newshtml;
			}
			close(NCFILE);
			$newsnum--;
		}
	}
	else {
		$FileName = $prof-&gt;[1];
		while ($newsnum &gt;= 0) {
			foreach $ff (keys %{$FilteredND[$newsnum]}) {
				${$ff} = $FilteredND[$newsnum]-&gt;{$ff};
			}
			$newsdate = &amp;GetTheDate($newstime);
			&amp;{$prof-&gt;[5]};
			if ($prof-&gt;[10]) {$content .= qq~&lt;a name="newsitem$newsid"&gt;&lt;/a&gt;~;}
			$content .= $newshtml;
			$newsnum--;
		}
		# News built. Now open the text file.
		NPopen(NCFILE, "&gt;$prof-&gt;[9]/$prof-&gt;[1]");
		print NCFILE $content;
		close(NCFILE);
		# Done. Now generate HTML.
		if ($prof-&gt;[6]) {
			my $htmlfilename;
			if ($prof-&gt;[1] =~ /(.+)\./) {
				$htmlfilename = $1;
			} else {
				$htmlfilename = $prof-&gt;[1];
			}
			$htmlfilename .= ".$NPConfig{'ArcHtmlExt'}";
			NPopen(NCFILE, "&gt;$prof-&gt;[9]/$htmlfilename");
			print NCFILE ProcessTMPL("$NPConfig{'admin_path'}/$prof-&gt;[6]",$content,$prof-&gt;[7]);
			close(NCFILE);
		}
	}

}

sub NewsCatSubForm {
	push(@formfields, 'newscat');
	$FormFieldsName{'newscat'} = "News Category";
	my @NCats = split(/\|x\|/, $NPConfig{'NewsCategories'});
	$FormFieldsCustom{'newscat'} = q~&lt;select name="newscat"&gt;
	&lt;option value="" selected&gt;(default)&lt;/option&gt;~;
	my $ncat;
	foreach $ncat (sort @NCats) {
		$FormFieldsCustom{'newscat'} .= qq~
		&lt;option value="$ncat"&gt;$ncat&lt;/option&gt;~;
	}
	$FormFieldsCustom{'newscat'} .= q~
	&lt;/select&gt;~;
}

sub NewsCatSaveProf {
	my $prof = $in{'editprofsave'};
	@{$newsprofiles{$prof}} = ($newsprofiles{$prof}-&gt;[0], $in{'textfile'}, join('!', split(/\|x\|/, $in{'newscategories'})),
	$in{'maxage'}, $in{'maxnum'}, $in{'newssub'}, $in{'tmplfile'}, $in{'tmpltitle'}, $in{'filtsub'}, $in{'filepath'},
	$in{'anchors'},$in{'skipnum'},$in{'staticopt'},$in{'staticname'},$in{'statictmpls'},$in{'staticsubs'},$in{'autobuildstatic'});
	&amp;NewsCatSaveConfig;
}

sub NewsCatEditProf {
	my %koption;
	my $prof = $in{'profname'};
	my @selectedcats = split(/\!/, $newsprofiles{$prof}-&gt;[2]);
	my (%selectedcats,$option1,$option2);
	foreach $i (@selectedcats) {
		$selectedcats{$i} = 'selected';
	}
	&amp;NPHTMLHead("Edit profile $prof");
	$_ = 2 + scalar @newscategories;
	$_ = $_ &lt; 15 ? $_ : 15;
	print qq~
	&lt;form action="$scripturl?newscat" method="POST"&gt;
	&lt;input type="hidden" name="editprofsave" value="$prof"&gt;
	Name of generated text file (i.e. $prof.txt): &lt;input type="text" name="textfile" value="$newsprofiles{$prof}-&gt;[1]"&gt;&lt;br&gt;&lt;br&gt;
	Absolute path of directory in which files will be created, with no trailing slash (i.e. $NPConfig{'htmlfile_path'}): &lt;input type="text" name="filepath" value="$newsprofiles{$prof}-&gt;[9]" size="60"&gt;&lt;br&gt;&lt;br&gt;
	
	&lt;table width="80%" border="0"&gt;&lt;tr&gt;&lt;td valign="top"&gt;Include only news from categories: (multiple selections allowed)
	&lt;br&gt;&lt;br&gt;To make multiple selections: Windows users hold down CTRL, Mac users hold down Option, most UNIX users hold down CTRL, users of other operating systems see your browser's help.
	&lt;/td&gt;&lt;td&gt;
	&lt;select name="newscategories" size="$_" multiple&gt;
	&lt;option value="AllCategories" $selectedcats{'AllCategories'}&gt;(All Categories)&lt;/option&gt;
	&lt;option value="(default)" $selectedcats{'(default)'}&gt;(Default Category)&lt;/option&gt;
	~;
	foreach $i (@newscategories) {
		print qq~
		&lt;option value="$i" $selectedcats{$i}&gt;$i&lt;/option&gt;~;
	}
	$option1 = $newsprofiles{$prof}-&gt;[10] ? ' selected' : '';
	$option2 = $newsprofiles{$prof}-&gt;[10] ? '' : ' selected';
	print qq~
	&lt;/select&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br&gt;&lt;br&gt;
	Do not include news older than &lt;input type="text" name="maxage" value="$newsprofiles{$prof}-&gt;[3]"&gt;
	days (to disable filtering by date, enter a large number 10000).&lt;br&gt;&lt;br&gt;
	Include a maximum of &lt;input type="text" name="maxnum" value="$newsprofiles{$prof}-&gt;[4]"&gt;
	news items (to disable filtering by item number, enter a large number like 10000).&lt;br&gt;&lt;br&gt;
	Skip first &lt;input type="text" name="skipnum" value="$newsprofiles{$prof}-&gt;[11]"&gt;
	news items after filtering. (to disable, enter a value of 0).&lt;br&gt;&lt;br&gt;
	EXPERT USERS ONLY! \@NewsData filtering sub. Most users should leave this blank. &lt;input type="text" name="filtsub" value="$newsprofiles{$prof}-&gt;[8]"&gt;&lt;br&gt;&lt;br&gt;
	Generate news using ndisplay.pl subroutine &lt;input type="text" name="newssub" value="$newsprofiles{$prof}-&gt;[5]"&gt;
	(i.e. DoNewsHTML for the general news style, DoHeadlineHTML for headlines).&lt;br&gt;&lt;br&gt;
	Generate HTML file using .tmpl file  &lt;input type="text" name="tmplfile" value="$newsprofiles{$prof}-&gt;[6]"&gt;
	located in your NewsPro directory (to disable HTML file creation, leave blank).&lt;br&gt;
	If generating HTML file, enter page title: &lt;input type="text" name="tmpltitle" value="$newsprofiles{$prof}-&gt;[7]"&gt;&lt;br&gt;
	Create &amp;lt;a name&amp;gt; tags with news? Unless you're going to be including more than one news file on a single HTML page, you should leave this on.
	&lt;select name="anchors"&gt;&lt;option value="1"$option1&gt;Yes&lt;/option&gt;&lt;option value="0"$option2&gt;No&lt;/option&gt;&lt;/select&gt;
	&lt;BR&gt;&lt;BR&gt;&lt;table border="1" cellspacing="2" cellpadding="2" align="center"&gt;
	&lt;tr&gt;&lt;td align="center"&gt;&lt;h3&gt;Static Page Options&lt;/h3&gt;&lt;/td&gt;&lt;/tr&gt;
	~;
	%koption = ();
	$koption{$newsprofiles{$prof}-&gt;[12]} = ' selected';
	print qq~
	&lt;tr&gt;&lt;td&gt;Static page options.
	&lt;select name="staticopt"&gt;
		&lt;option value=""$koption{''}&gt;no static pages (normal)&lt;/option&gt;
		&lt;option value="static"$koption{'static'}&gt;static pages&lt;/option&gt;
		&lt;option value="split"$koption{'split'}&gt;split static pages at &amp;lt;PR&amp;gt; tags&lt;/option&gt;
	&lt;/select&gt;&lt;BR&gt;
	~;
	print q~
	&lt;ul&gt;If you choose &amp;quot;split static pages at &amp;lt;PR&amp;gt; tags&amp;quot;...&lt;BR&gt;
	&lt;li&gt;Put the tag &amp;lt;PR&amp;gt; (uppercase or lowercase - it doesn't matter) in your news text.&lt;BR&gt;
	Your news will be split at the exact locations of these tags into several files.&lt;/li&gt;
	&lt;li&gt;you can refer to the previous and next page in your DoNews subroutine with $prevhref and $nexthref.&lt;BR&gt;
	$prevhref will be blank on the first page, and $nexthref will be blank on the last page.&lt;/li&gt;
	&lt;li&gt;The current file name can be accessed using the variable $FileName.&lt;/li&gt;
	&lt;/ul&gt;&lt;/td&gt;&lt;/tr&gt;
	~;

	&amp;SubmitFormFields;
	push(@formfields, 'newsid', 'newstime', 'newsrand');
	my @selectedfields = split(/\|x\|/, $newsprofiles{$prof}-&gt;[13]);
	my (%bannedfields, %selectedfields );
	my @bannedfields = split(/\|x\|/, $NPConfig{'NCbannedFF'});
	my %bannedfields;
	foreach $i (@bannedfields) {
		$bannedfields{$i} = 1;
	}
	foreach $i (@selectedfields) {
		$selectedfields{$i} = ' selected';
	}
	$bannedfields{'newsname'} = 1;
	$bannedfields{'newsdate'} = 1;
	$bannedfields{'newscat'} = 1;
	print qq~&lt;tr&gt;&lt;td&gt;Select the field to use when generating the static page's file name:
	&lt;select name="staticname"&gt;
	~;
	foreach $i (@formfields) {
		if( $bannedfields{$i} &amp;&amp; ! $selectedfields{$i} ) { next; }
		print qq~
		&lt;option value="$i"$selectedfields{$i}&gt;$i&lt;/option&gt;~;
	}
	$option1 = $newsprofiles{$prof}-&gt;[16] ? ' selected' : '';
	$option2 = $newsprofiles{$prof}-&gt;[16] ? '' : ' selected';
	print qq~
	&lt;/select&gt;
	(only relevant when creating each news item on its own page, or when linking to static pages from another profile)
	&lt;/td&gt;&lt;/tr&gt;
	&lt;tr&gt;&lt;td&gt;
	Auto-rebuild static pages when news is submitted or modified?
	&lt;select name="autobuildstatic"&gt;&lt;option value="1"$option1&gt;Yes&lt;/option&gt;&lt;option value="0"$option2&gt;No&lt;/option&gt;&lt;/select&gt;
	This will only rebuild/create static pages that &lt;i&gt;&lt;b&gt;need&lt;/b&gt;&lt;/i&gt; to be rebuilt/created. Very efficient, highly recommended.
	Please note that if this option is set to &amp;quot;Yes&amp;quot;, and you manually delete static pages or whatever, you
	must then force a total rebuild in order to recreate the pages. Essentially, setting this option will cause this
	static-page-profile to rebuild on submit-save/modify-save and NOT during Build News. If this option is set to
	&amp;quot;No&amp;quot;, then this profile will build normally.
	&lt;/td&gt;&lt;/tr&gt;
	~;

	print qq~
	&lt;tr&gt;&lt;td&gt;&lt;h4&gt;for use with split-static-pages only : Template-Per-Page&lt;/h4&gt;
	&lt;ul&gt;If you like, you can specify a different template to use for every page.
		&lt;li&gt;The default template for this profile will be used for the first page.&lt;/li&gt;
		&lt;li&gt;In the following text field you should list the templates you wish to use for every subsequent page.&lt;/li&gt;
		&lt;li&gt;Separate the file names with semicolons.&lt;/li&gt;
		&lt;li&gt;If a news item has more pages than templates, the last template listed will be used for the remaining pages.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;input type="text" name="statictmpls" value="$newsprofiles{$prof}-&gt;[14]" size="70"&gt;
	&lt;/td&gt;&lt;/tr&gt;
	&lt;tr&gt;&lt;td&gt;&lt;h4&gt;for use with split-static-pages only : Subroutine-Per-Page&lt;/h4&gt;
	&lt;ul&gt;If you like, you can specify a different subroutine to use for every page.
		&lt;li&gt;The default subroutine for this profile will be used for the first page.&lt;/li&gt;
		&lt;li&gt;In the following text field you should list the subroutines you wish to use for every subsequent page.&lt;/li&gt;
		&lt;li&gt;Separate the subroutine names with semicolons.&lt;/li&gt;
		&lt;li&gt;If a news item has more pages than subroutines, the last subroutine listed will be used for the remaining pages.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;input type="text" name="staticsubs" value="$newsprofiles{$prof}-&gt;[15]" size="70"&gt;
	&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
	&lt;br&gt;&lt;br&gt;&lt;input type="submit" name="submit" value="Save Changes"&gt;&lt;/form&gt;
	~;
	&amp;NPHTMLFoot;
}

sub NewsCatFilter {
	my $mintime = pop;
	$mintime = $mintime * 86400;
	my @filtcats = @_;
	my %filtcats;
	my $nd;
	undef @NewNewsData;
	my @NewNewsData;
	foreach $i (@filtcats) {
		unless ($i eq '(default)') {
			$filtcats{$i} = 1;
		}
		else {
			$filtcats{''} = 1;
		}
	}
	foreach $nd (@NewsData) {
		# First, check if it matches the category.
		if ($filtcats{$nd-&gt;{'newscat'}} || $filtcats{'AllCategories'}) {
			# It matches. Now check the time.
			if ($nd-&gt;{'newstime'} &gt;= (time - $mintime)) {
				# It's good. Add to the new array.
				push(@NewNewsData, $nd);
			}
		}
	}
	return @NewNewsData;
}

sub NewsCatFilterReverse {
	my @NND = reverse(&amp;NewsCatFilter(@_));
	return @NND;
}

sub NewsCatFilterAlpha {
	my @NND = &amp;NewsCatFilter(@_);
	my @NNDsorted = map { $_-&gt;[0] }
		sort { $b-&gt;[1] cmp $a-&gt;[1] }
		map { [ $_, ($_-&gt;{'newssubject'})[0] ] } @NND;
	return @NNDsorted;
}

sub NewsCatLoadConfig {
	@newscategories = sort(split(/\|x\|/, $NPConfig{'NewsCategories'}));
	@nprof = split(/\|x\|/, $NPConfig{'NewsProfiles'});
	for( $i = 0; $i &lt; @nprof; $i++ ) {
		@nprof2 = split(/\~/, $nprof[$i]);
		my $j = shift(@nprof2);
		if ($j) {
		$nprof[$i] = $j;
		$newsprofiles{$j} = [];
		@{$newsprofiles{$j}} = @nprof2;
		}
	}
}

sub NewsCatSaveConfig {
	$NPConfig{'NewsCategories'} = join('|x|', @newscategories);
	my @nprof = ('');
	foreach $i (sort keys %newsprofiles) {
		push(@nprof, join('~', $i, @{$newsprofiles{$i}}));
	}
	$NPConfig{'NewsProfiles'} = join('|x|', @nprof);
	&amp;WriteConfigInfo;
}

sub NewsCatMain {
	unless ($UserPermissions{$Cookies{'uname'}} == 3) {
		&amp;NPdie('You are not authorized to access this');
	}
	&amp;NewsCatLoadConfig;
	if ($in{'editprof'} &amp;&amp; $newsprofiles{$in{'profname'}}) {
		&amp;NewsCatEditProf;
		exit;
	}
	if ($in{'editprofsave'}) {
		&amp;NewsCatSaveProf;
	}
	if ($in{'removecat'}) {
		my $new_newscategories;
		foreach $i (@newscategories) {
			unless ($i eq $in{'removecat'}) {
				push(@new_newscategories, $i);
			}
		}
		@newscategories = @new_newscategories;
		&amp;NewsCatSaveConfig;
	}
	if ($in{'removeprof'}) {
		if ($newsprofiles{$in{'profname'}}) {
			delete $newsprofiles{$in{'profname'}};
		}
		&amp;NewsCatSaveConfig;
	}
	if ($in{'addcat'}) {
		$in{'addcat'} =~ s/\W//g;
		if ($in{'addcat'} ne "") {
			push(@newscategories, $in{'addcat'});
		}
		&amp;NewsCatSaveConfig;
	}
	if ($in{'addprof'}) {
		$in{'addprof'} =~ s/\W//g;
		unless ($newsprofiles{$in{'addprof'}} || $in{'addprof'} eq "") {
			$newsprofiles{$in{'addprof'}} = ['0', "$in{'addprof'}.txt", 'AllCategories', '10000', '100000', 'DoNewsHTML', '', '', '', $NPConfig{'htmlfile_path'},'0','0','','newssubject','','','1'];
		}
		&amp;NewsCatSaveConfig;
	}
	if ($in{'savecheck'}) {
		foreach $i (keys %newsprofiles) {
			$newsprofiles{$i}-&gt;[0] = $in{"cc--$i"};
		}
		&amp;NewsCatSaveConfig;
	}
	&amp;NPHTMLHead("News Categories 2");
	print q~
	&lt;div align="center"&gt;&lt;h3&gt;News Categories 2&lt;/h3&gt;&lt;table width="80%" border="0"&gt;
	~;
	foreach $i (@newscategories) {
		print qq~
		&lt;tr&gt; 
		&lt;td&gt;$i&lt;/td&gt;
		&lt;td&gt; &lt;div align="center"&gt; &lt;form action="$scripturl?newscat" method="POST"&gt;
		&lt;input type="hidden" name="removecat" value="$i"&gt;
		&lt;input type="submit" name="Submit" value="Remove"&gt;&lt;/form&gt;
		&lt;/div&gt; &lt;/td&gt; &lt;/tr&gt;
		~;
	}
	print qq~
&lt;/table&gt;
&lt;b&gt;Add new category:&lt;/b&gt;&lt;form action="$scripturl?newscat" method="POST"&gt;
&lt;input type="text" name="addcat" value="Name"&gt;&lt;input type="submit" name="submit" value="Submit"&gt;
&lt;/form&gt;&lt;hr width="75%"&gt;
	~;
	print qq~
	&lt;h3&gt;News Profiles 2&lt;/h3&gt;&lt;table width="80%" border="1" cellpadding="10"&gt;
	&lt;form action="$scripturl?newscat" method="POST"&gt;
	&lt;tr&gt;&lt;td valign="middle" align="center"&gt;&lt;font size="+1"&gt;Profile Name&lt;/font&gt;&lt;/td&gt;
	&lt;td valign="middle" align="center" width="100"&gt;File Creation&lt;/td&gt;
	&lt;td valign="middle" align="center" width="150"&gt;&lt;div align="center"&gt;Enabled / Disabled&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
	~;
	my( $yescheck, $noncheck );
	my @prof = sort keys %newsprofiles;
	my $psize = scalar @prof;
	foreach $i (@prof) {
		$yescheck = $newsprofiles{$i}-&gt;[0] ? ' checked' : '';
		$noncheck = $newsprofiles{$i}-&gt;[0] ? '' : ' checked';
		print qq~&lt;tr&gt;&lt;td valign="middle"&gt;$i&lt;/td&gt;&lt;td width="100" align="center"&gt;~;
		print ( $newsprofiles{$i}-&gt;[0] ? q~&lt;b&gt;enabled&lt;/b&gt;~ : q~&lt;i&gt;disabled&lt;/i&gt;~ );
		print qq~&lt;/td&gt;&lt;td align="center" width="150"&gt;
		&lt;input type="radio" name="cc--$i" value="1"$yescheck&gt; / &lt;input type="radio" name="cc--$i" value="0"$noncheck&gt;
		&lt;/td&gt;&lt;/tr&gt;~;
	}
	$psize++;
	print qq~
	&lt;tr&gt;&lt;td colspan="9" valign="middle"&gt;&lt;div align="center"&gt;
	&lt;input type="submit" name="savecheck" value="Save Enable States"&gt;
	&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/form&gt;
	&lt;/table&gt;&lt;br&gt;&lt;br&gt;
	&lt;table width="80%" border="1" cellpadding="10" cellspacing="10"&gt;&lt;tr&gt;&lt;td align="left"&gt;
	&lt;form action="$scripturl?newscat" method="POST"&gt;
	&lt;input type="submit" name="removeprof" value="Delete Selected Profile"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align="middle"&gt;
	&lt;select name="profname" size="$psize"&gt;&lt;option value="" selected&gt;(none selected)&lt;/option&gt;~;
	foreach $i (@prof) {
		print qq~&lt;option value="$i"&gt;$i&lt;/option&gt;~;
	}
	print q~&lt;/select&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align="right"&gt;
	&lt;input type="submit" name="editprof" value="Edit Selected Profile"&gt;
	&lt;/td&gt;&lt;/tr&gt;&lt;/form&gt;&lt;/table&gt;~;
	print qq~
	&lt;b&gt;Add new profile:&lt;/b&gt;&lt;form action="$scripturl?newscat" method="POST"&gt;
	&lt;input type="text" name="addprof" value="Name"&gt;&lt;br&gt;&lt;input type="submit" name="submit" value="Submit"&gt;
	&lt;/form&gt;
	~;
	&amp;NPHTMLFoot;
}


#	Get the current news item's file name
#	(static page file field must be set for the current profile,
#	even if that profile doesn't do static pages)
sub NCMakeFName
{
	$_ = ${$prof-&gt;[13]} || ${'newsid'};
	$_ =~ s~\W~~g;
	$_ = substr( $_, 0, 24 );
	$_ .= ".$filext";
	return $_;
}

#	Generate file name for the current newsitem,
#	using the name of the field passed in as the
#	file field.
#		eg:	GetFName( 'newssubject' )
sub NCGetFName
{
	$_ = shift || 'newsid';
	$_ = ${$_};
	$_ =~ s~\W~~g;
	$_ = substr( $_, 0, 24 );
	$_ .= ".$filext";
	return $_;
}

#	Same as MakeFName, but it doesn't put the
#	file extension at the end.
sub NCMakePartialFName
{
	$_ = ${$prof-&gt;[13]} || ${'newsid'};
	$_ =~ s~\W~~g;
	$_ = substr( $_, 0, 24 );
	return $_;
}

sub NewsCatPageHandler {
	if (query_string() eq "newscat") {
		&amp;NewsCatMain;
		exit;
	}
	elsif (query_string() eq "newscattotalrebuild") {
		&amp;NPHTMLHead('All Enabled Profiles ReBuilt');
		print q~All currently enabled news profiles have been totally rebuilt.~;
		&amp;NewsCatTotalReBuild;
		&amp;NPHTMLFoot;
		exit;
	}
}

sub NewsCatRemoveNewsSave {
	push(@formfields, 'newscat');
}

sub NewsCatRemoveNews2 {
	my @NCats = split(/\|x\|/, $NPConfig{'NewsCategories'});
	my $nci;
	print qq~ Category:
	&lt;select name="newscat--$newsnum"&gt;&lt;option value=""~;
	unless ($newscat) {
		print " selected";
	}
	print "&gt;(default)&lt;/option&gt;";
	foreach $nci (@NCats) {
		print qq~
		&lt;option value="$nci"~;
		if ($nci eq $newscat) {
			print " selected";
		}
		print qq~&gt;$nci&lt;/option&gt;~;
	}
	print "&lt;/select&gt;";
}

sub NewsCat_HTMLFoot {
	if ($up == 3) {
			print qq~ &lt;a href="$scripturl?newscat" class="navlink"&gt;NewsCat 2&lt;/a&gt; | &lt;a href="$scripturl?newscattotalrebuild" class="navlink"&gt;NewsCat2_Total_Rebuild&lt;/a&gt; |~;
	}
}
sub NewsCat_MainPage {
	if ($up == 3) {
		print qq~
		&lt;b&gt;&lt;a href="$scripturl?newscat"&gt;NewsCat 2&lt;/a&gt;:&lt;/b&gt; Configure news categories and profiles, features that allow you to create multiple news files. enhanced by &lt;a href="mailto:plushpuffin\@yahoo.com"&gt;plushpuffin&lt;/a&gt;&lt;br&gt;&lt;br&gt;
		~;
	}
}
1;</pre></body></html>