#!/usr/bin/perl BEGIN { ($0 =~ m!(.*)(\\|/)[^/\\]+!) && unshift(@INC, $1, "$1$2Modules"); eval { require bytes; import bytes; } } use lib ("./Modules", "."); #in case $0 is weird use CGI qw/-no_xhtml -nosticky :standard/; use CGI::Carp qw(fatalsToBrowser); use File::Path; use strict; # If you see this message in your browser, your hosting provider # has not properly mapped the .cgi file extension to Perl. Please # contact the provider for more information. Mapping .cgi is a # simple process and usually takes just a few seconds. # ***************************************************************** # ** ** # ** LEGAL NOTICE ** # ** ** # ** The entire suite of Big Medium perl scripts is copyright ** # ** Global Moxie and Josh Clark. All rights reserved. ** # ** ** # ** For more information on Big Medium content management ** # ** software and other Global Moxie products, visit our ** # ** website at: http://www.globalmoxie.com ** # ** ** # ** You may not distribute this program in any manner, ** # ** modified or otherwise, without the express, written ** # ** consent from Global Moxie. ** # ** ** # ** You may make modifications, but only for your own use and ** # ** within the confines of the Big Medium License Agreement ** # ** (see our website for the full license). ** # ** ** # ** You may not distribute "hacks" for Big Medium without ** # ** approval from Global Moxie. ** # ** ** # ** NOTE: We regret that if you modify any code within your ** # ** installation of Big Medium that we cannot offer you tech ** # ** support or assistance. ** # ** ** # ***************************************************************** # ***************************************************************** # ** ** # ** ABOUT THIS SCRIPT ** # ** ** # ** bm_sections.cgi ** # ** Part of the Big Medium suite of perl scripts that allow ** # ** the authoring, formatting and publication of content to ** # ** your website. Big Medium is a product of Global Moxie. ** # ** ** # ** Purpose: This script allows the user to browse, create ** # ** and edit section (and sub-section) settings, directories ** # ** and html templates. ** # ** ** # ** Author: Josh Clark ** # ** Copyright 2002-2003 Josh Clark and Global Moxie ** # ** ** # ** service@globalmoxie.com ~~ http://www.globalmoxie.com ** # ** ** # ***************************************************************** # ***************************************************************** # ** ** # ** VERSION INFO ** # ** Current version: 1.3.3 ** # ** ** # ** Fixed since 1.3.2 ** # ** - Load bm_setup.pl before loading bm_lib.pl. ** # ** - Close filehandle after reading template uploads in ** # ** section editor; prevents Windows systems from incorrectly** # ** hanging onto temp files. ** # ** ** # ** Fixed since 1.2.2 ** # ** - Use File::Path and rmtree to delete section html files ** # ** for improved support under Windows servers. ** # ** - Removed FTP option from section editor. ** # ** - Fixed incorrect display of vertical rollover dimensions ** # ** - Delete document downloads when deleting sections ** # ** ** # ***************************************************************** # ================================================================= # LOAD LIBRARIES # ================================================================= require "bm_setup.pl"; require "bm_lib.pl"; require "bm_vetting.pl"; require "moxie_profiles.pl"; # ================================================================= # BAIL OUT IF BIG MEDIUM POWER SWITCH IS OFF # ================================================================= if ($bmSetup::AllUsage eq "off") { &bmLib::bmHTML("Please Try Back Later...", $bmSetup::AllOff); } package bmSection; &bmSection::main; exit; sub main { # routine: main================================================ # DECLARE/INITIALIZE GLOBAL VARIABLES # ============================================================= # Gather user info that may have been submitted at login ($bmSection::UserName, $bmSection::Password, $bmSection::ProfileNumber) = &MoxieProf::getinput( CGI::param("UserName"), CGI::param("Password"), CGI::param("ProfileNumber") ); # initialize variables used to build section edit pages $bmSection::required = qq~*~; # routine: main================================================ # CONFIRM IDENTITY AND CHECK PRIVILEGES # ============================================================= ($bmSection::Privileges, $bmSection::UserName ) = &MoxieProf::admin_confirm( "the Big Medium section editor", "bm_sections.cgi", $bmSection::UserName, $bmSection::Password, $bmSection::ProfileNumber ); &bmLib::check_privileges( $bmSection::Privileges, "section", $bmSection::UserName ); #Note: Other scripts get checked here for whether SiteUsage has #site turned on; don't do that here because SiteUsage should #allow all template-related functions to continue; just no new #content additions/editing. # routine: main================================================ # LOAD INFO ABOUT THE SITE AND ROUTE USER TO DESTINATION # ============================================================= &bmLib::LoadSectionInfo; if (CGI::param("login_now") eq "login") { &bmSection::section_menu; } elsif (CGI::param("home") == 1) { &bmSection::homepage_editor; } elsif (CGI::param("save_home") eq "Save") { &bmSection::save_homepage; } elsif (CGI::param("set") ) { &bmSection::edit_settings; } elsif (CGI::param("save_set") eq "Save") { &bmSection::save_settings; } elsif (CGI::param("template") ne "") { &bmSection::display_template; } elsif (CGI::param("do_not_delete") eq "Cancel") { &bmSection::section_menu("
Your deletion request was canceled.
"); } elsif (CGI::param("delete_subsecs") eq "Delete") { &bmSection::do_section_delete; } elsif (CGI::param("ContinueDelete") eq "delete") { &bmSection::update_deleted_articledata; } elsif ( CGI::param("update") eq "Update Menu" || CGI::param("delete") > 0) { #note: this option has to come after the other delete #options above, since others also use 'delete' parameter &bmSection::confirm_delete; } elsif (CGI::param("move") ne "") { &bmSection::rearrange_secs; } elsif (CGI::param("rearrange") eq "Save") { &bmSection::do_rearrange; } elsif (CGI::param("edfeed") == 1) { &bmSection::edit_newsfeeds; } elsif (CGI::param("savefeed") == 1) { &bmSection::save_newsfeeds; } else { &bmLib::bump_to_signin( "the Big Medium section editor", "bm_sections.cgi" ); } exit; } #end main routine #### ROUTINES BEGIN sub section_menu { ############################################################### ## ROUTINE: section_menu ## ## This routine displays all section-editing options for the ## homepage and current sections and subsections. ## ############################################################### # routine: section_menu======================================== # DECLARE VARIABLES # ============================================================= my $confirm_msg = shift; #message confirming previous action #html-building my $table; #contents of the section table my $html; #contents of the html page #section info my @subsecs; #subsection indices for each section #misc utility variables my $filename; #holds template filename my $bgcolor; #holds color of current row (main secs) my $subcount; #used to alternate colors (subsecs) my $subcolor; #holds color of current row (subsecs) my $linktext; #holds add/edit text for subsections # routine: section_menu======================================== # BUILD THE PAGE HEADER # ============================================================= #display confirmation message if we have one if ($confirm_msg) { $html = &bmLib::box_it_headline( "Update Status", $confirm_msg); } $html .= CGI::start_form("post","$bmSetup::BigMedURL/bm_sections.cgi"); #display main page options $table = qq~Edit Homepage New Main Section Rearrange Main Sections| Subsections | ||||||
| Delete | Subsection | Slug | Status | HTML | Annc | News Feed |
| ~; ## Section name $table .= qq~ | $bmSetup::SectionShort{$_} | ~; ## Slug name $table .= qq~$bmSetup::SectionSlug{$_} | ~; ## Status $bmSetup::SectionActive{$_} = "Off" if $bmSetup::SectionActive{$_} eq ""; $bmSetup::SectionActive{$_} .= " (alias)" if $bmSetup::SectionAlias{$_}; $table .= qq~\u$bmSetup::SectionActive{$_} | ~; ## template link $filename = $_ . "ind.template"; if (-e "$bmSetup::DataDir/templates/$_.template" || -e "$bmSetup::DataDir/templates/$filename") { $linktext = "Custom"; } else { $linktext = "Default"; } $table .= qq~$linktext | ~; ## Announcement link if (-e "$bmSetup::DataDir/templates/$_.annc") { $linktext = "Custom"; } else { $linktext = "Default"; } $table .= qq~$linktext | ~; ## News Feed if (index($bmSetup::SectionSuppress{$_}, "s") < 0) { $table .= "yes"; } else { $table .= "no"; } $table .= qq~ |
Your deletion request was canceled
~); exit; } if (@delete == 1 && $delete[0] !~ /_/) { # routine: do_section_delete=============================== # DELETE MAIN SECTIONS # ========================================================= &bmSection::delete_main(@delete); } else { # routine: do_section_delete=============================== # START SUBSECTION DELETION # ========================================================= foreach (@delete) { #be sure we're only dealing with subsections; #discard any main sections that are in the mix next if $_ !~ /_/ || $_ =~ /_0$/; $delete_sub{$_} = 1; } # routine: do_section_delete=============================== # UPDATE MASTER SECTION INDEX # ========================================================= &bmLib::FileLock; @secindex = &bmLib::LoadFile("$bmSetup::DataDir/templates/Sections.setup"); #add section lines to updated index unless marked for del foreach (@secindex) { ($sec) = split (/ /); push (@updated_sections, $_) if ($delete_sub{$sec} != 1); } # routine: do_section_delete=============================== # SAVE UPDATED INDEX TO DISK # ========================================================= open (SECTIONFILE, ">$bmSetup::DataDir/templates/Sections.setup") or die("Unable to write to $bmSetup::DataDir/templates/Sections.setup. $!."); flock(SECTIONFILE, 2) or die("Could not do flock 2 exclusive lock on $bmSetup::DataDir/templates/Sections.setup. $!."); foreach (@updated_sections) { print SECTIONFILE "$_\n"; } close (SECTIONFILE); chmod 0666, "$bmSetup::DataDir/templates/Sections.setup"; &bmLib::FileUnlock; # routine: do_section_delete=============================== # UPDATE DELETED SECTION LOG # ========================================================= open (DELETELIST, ">>$bmSetup::DataDir/deleted_sections.txt") or die("Unable to write to deleted section log at $bmSetup::DataDir/deleted_sections.txt. $!."); flock(DELETELIST, 2) or die("Could not do flock 2 exclusive lock on deleted section log at $bmSetup::DataDir/deleted_sections.txt. $!"); foreach (keys %delete_sub) { print DELETELIST "$_\n"; } close (DELETELIST); chmod 0666, "$bmSetup::DataDir/deleted_sections.txt"; # routine: do_section_delete=============================== # DELETE ALL ASSOCIATED FILES FOR THE SUBSECTIONS # ========================================================= &bmSection::delete_sub(@delete); # routine: do_section_delete================================ # UPDATE NAVIGATION SETTINGS # ========================================================== #reload section data to reflect updates &bmLib::LoadSectionInfo; require "bm_navigation.pl"; &bmNav::create_nav_files; # routine: do_section_delete=============================== # UPDATE ARTICLE DATA FILES # ========================================================= &bmSection::update_deleted_articledata(@delete); } } #end do_section_delete sub delete_main { ############################################################### ## ROUTINE: delete_main ## ## This routine deletes a main section, all of its subsections ## and all associated files and directories. ## ############################################################### # routine: delete_main========================================= # DECLARE VARIABLES # ============================================================= my $maindel = shift; #section to delete my @subs_to_delete; #subsections of this deleted section my @secindex; #the section index file my @updated_sections; #the new updated sections file my $sec; #section getting added to section index my $mainsec; #parent section of the section my $file; #filename of file to delete # routine: delete_main========================================= # UPDATE THE DELETED SECTIONS LOG # ============================================================= open (DELETELIST, ">>$bmSetup::DataDir/deleted_sections.txt") or die("Unable to write to deleted sections log at $bmSetup::DataDir/deleted_sections.txt. $!."); flock(DELETELIST, 2) or die("Could not do flock 2 exclusive lock on deleted sections log at $bmSetup::DataDir/deleted_sections.txt. $!."); print DELETELIST "$maindel\n"; close (DELETELIST); chmod 0666, "$bmSetup::DataDir/deleted_sections.txt"; # routine: delete_main========================================= # UPDATE SECTION INDEX, REMOVING SECTION AND SUBSECTIONS # ============================================================= &bmLib::FileLock; @secindex = &bmLib::LoadFile("$bmSetup::DataDir/templates/Sections.setup"); foreach (@secindex) { ($sec) = split (/ /); ($mainsec) = split (/\_/,$sec); push (@updated_sections, $_) if ($mainsec ne $maindel); } #end foreach # routine: delete_main========================================= # WRITE TO SECTION INDEX # ============================================================= open (SECTIONFILE, ">$bmSetup::DataDir/templates/Sections.setup") or die("Unable to write to section index at $bmSetup::DataDir/Sections.setup. $!."); flock(SECTIONFILE, 2) or die("Could not do flock 2 exclusive lock on section index at $bmSetup::DataDir/templates/Sections.setup. $!"); foreach (@updated_sections) { print SECTIONFILE "$_\n"; } close (SECTIONFILE); chmod 0666, "$bmSetup::DataDir/templates/Sections.setup"; &bmLib::FileUnlock; # routine: delete_main========================================= # DELETE THE SUBSECTIONS # ============================================================= (undef, @subs_to_delete) = &bmLib::GetAllSubs($maindel); &bmSection::delete_sub(@subs_to_delete); # routine: delete_main========================================= # DELETE MAIN SECTION TEMPLATES # ============================================================= foreach ( "_0.template", "sub.template", "ind.template", "_0.annc", "sub.annc") { if (-e "$bmSetup::DataDir/templates/$maindel$_") { unlink ("$bmSetup::DataDir/templates/$maindel$_") or die("Unable to unlink $bmSetup::DataDir/templates/$maindel$_. $!."); } } # routine: delete_main========================================= # DELETE MAIN DIRECTORY AND REMAINING CONTENTS # ============================================================= if (-e "$bmSetup::htmlDir/$bmSetup::SectionSlug{$maindel}" && $bmSetup::SectionSlug{$maindel}) { main::rmtree("$bmSetup::htmlDir/$bmSetup::SectionSlug{$maindel}", 0, 1); } # routine: delete_main====================================== # UPDATE NAVIGATION SETTINGS # ========================================================== #reload section data to reflect updates &bmLib::LoadSectionInfo; require "bm_navigation.pl"; &bmNav::create_nav_files; # routine: delete_main========================================= # UPDATE ARTICLE INDEX AND DATA FILES # ============================================================= &bmSection::update_deleted_articledata($maindel); } # End delete_main routine sub delete_sub { ############################################################### ## ROUTINE: delete_sub ## ## This routine deletes template and html files for ## the subsections whose ids are passed ## to the routine in an array. (Article data is updated ## elsewhere, ## ############################################################### # routine: delete_sub========================================== # DECLARE VARIABLES # ============================================================= my (@sections) = @_; #subsections to delete my $p; #parent section of each section my $html_delete; #html directory of each section my $file; #filename to delete my $del_sec; #current section to delete foreach (@sections) { #be sure we're only dealing with subsections; #discard any main sections next if $_ !~ /_/ || $_ =~ /_0$/; $del_sec = $_; # routine: delete_sub====================================== # DELETE CUSTOM SUBSECTION TEMPLATES IF ANY # ========================================================= foreach (".template", ".annc", "ind.annc") { if (-e "$bmSetup::DataDir/templates/$del_sec$_") { unlink ("$bmSetup::DataDir/templates/$del_sec$_"); } } # routine: delete_sub====================================== # DELETE HTML DIRECTORY AND CONTENTS # ========================================================= ($p) = split (/_/, $del_sec); #parent section $html_delete = "$bmSetup::htmlDir/$bmSetup::SectionSlug{$p}/$bmSetup::SectionSlug{$del_sec}"; if (-e "$html_delete" && $bmSetup::SectionSlug{$del_sec}) { # delete the entire html directory and its contents main::rmtree("$html_delete", 0, 1); } } } #end delete_subsection routine sub LoadTemplate { ############################################################### ## ROUTINE: LoadTemplate ## ## Similar to the LoadFile routine in bm_lib.pl but this one ## loads in a single scalar variable instead of an array ## of lines from the file. Also, only loads files from ## the site's templates directory. ## ############################################################### # routine: LoadTemplate======================================== # DECLARE VARIABLES # ============================================================= my $filename = shift; my $file_contents; $filename = "$bmSetup::DataDir/templates/$filename"; &bmLib::CheckBadChars($filename); undef $/; #put into slurp mode to read whole file as single line if (-e "$filename") { open (DATA, "$filename") or die( "Could not open $filename. $!"); flock(DATA, 1) or die("Could not do flock 1 shared lock on $filename. $!"); $file_contents = ; close (DATA); } $/ = "\n"; #return to regular mode to read file as array $file_contents; } #end LoadTemplate routine sub display_template { ############################################################### ## ROUTINE: display_template ## ## This routine loads one of the page templates, converts all ## html into entities and displays as html within a browser. ## ############################################################### # routine: display_template==================================== # DECLARE VARIABLES # ============================================================= my $sec_index = CGI::param("template"); my $type = CGI::param("t"); my $filename; my $file; #make sure that we have a valid section if ($sec_index ne "h") { $sec_index = &bmSection::vet_index($sec_index); } my %template = ("" => "homepage template", "t" => "section template for the $bmSetup::SectionShort{$sec_index} section", "s" => "default subsection template for the $bmSetup::SectionShort{$sec_index} section", "i" => "custom subsection index template for the $bmSetup::SectionShort{$sec_index} section" ); # routine: display_template==================================== # LOAD TEMPLATE # ============================================================= if ($sec_index eq "h") { #homepage template $file = &bmSection::LoadTemplate("home.template"); } elsif ($type eq "t") { #section template $sec_index .= "_0" if $sec_index !~ /_/; $file = &bmSection::LoadTemplate("$sec_index.template"); } elsif ($type eq "s") { #default subsection template $filename = $sec_index . "sub.template"; $file = &bmSection::LoadTemplate($filename); } elsif ($type eq "i") { #custom subsection index $filename = $sec_index . "ind.template"; $file = &bmSection::LoadTemplate($filename); } else { &bmLib::bmHTML("Didn't Understand", "Could not complete your request, because of a formatting problem. It appears that the \"t\" parameter in the URL is invalid."); } # routine: display_template==================================== # DISPLAY HTML-SAFE TEMPLATE IN BROWSER # ============================================================= if ($file eq "") { &bmLib::bmHTML("No Template Loaded", "Sorry, there is no $template{$type} to display."); } ($file) = &bmLib::make_it_html_safe($file); print qq~Content-type: text/html; charset=UTF-8\n\n \n$file\n~; } #end display_template routine sub vet_index { ############################################################### ## ROUTINE: vet_index ## ## This routine scrubs an index number to make sure that it ## is valid. ############################################################### my $sec_index = shift; #make sure that only numbers and underscore are in section id $sec_index =~ s/[^\d_]//g; if ($sec_index eq "") { &bmLib::bmHTML("Invalid Section", "Unable to load the section information for the requested section. The submitted section does not appear to be valid. Consult your website administrator if you continue to receive this message."); } if ($bmSetup::SectionName{$sec_index} eq "") { &bmLib::bmHTML("Invalid Section", "Could not locate a record of a section with index $sec_index. It does not appear to exist. If you believe this is an error, consult your website administrator."); } return $sec_index; } #end vet_index routine sub vet_text_file { ############################################################### ## ROUTINE: vet_text_file ## ## This routine checks an array of CGI file upload params and ## confirms that they're UTF-8 text files. ## ## Input: ## Array alternating text label ($type) with CGI param. ## ## Returns the files as an array of scrubbed values. ## ############################################################### # routine: vet_text_file======================================= # DECLARE VARIABLES # ============================================================= my (@files) = @_; my $mime; # mime type (must be text/plain or text/html) my $info_hash; # header info of passed file my $clean; # scrubbed file contents my $type; #the description of the file being parsed my $file; #the filehandle of the file being parsed my @results; #the array of file contents returned # routine: vet_text_file======================================= # STEP THROUGH FILES TO CHECK # ============================================================= while (@files) { $type = shift(@files); $file = shift(@files); if ($file eq "") { #only do it if we have an upload push (@results, undef); next; } #get and confirm mime type $info_hash = CGI::uploadInfo($file); $mime = $info_hash->{'Content-Type'}; if ( $mime ne "text/plain" && $mime ne "text/html" && $mime ne "" ) { &bmLib::bmHTML ("Templates Must Be Text Files", "The $type file you submitted was not a plain text file (you sent a file of type: $mime). Please click your browser's Back button to select a different file."); } undef $/; #read whole file as single line $clean = <$file>; $/ = "\n"; #return to regular mode close ($file); #make sure that the file is UTF-8 my $encoding = &bmLib::check_utf8(0, $clean); if ($encoding ne "UTF-8") { &bmLib::bmHTML("Bad characters in $type", qq~The $type you submitted appears to contain characters that are not encoded in the UTF-8 format of Unicode, the Web's international alphabet. To fix the problem, review this checklist:
After making appropriate changes, please click your browser's Back button to try again.
Need help? Visit the Global Moxie support forums.
~); } #clean file and convert to unix line feeds ($clean) = &bmVet::prep_for_html($clean); $clean =~ s/ /\n/g; push (@results, $clean); } @results; } #end vet_text_file routine sub vet_slug { ############################################################### ## ROUTINE: vet_slug ## ## This routine checks the format and uniqueness of section ## slugs submitted through the section settings page for ## new or existing sections and subsections. ## ############################################################### # routine: vet_slug============================================ # DECLARE VARIABLES # ============================================================= my ($newslug, $type, $newid) = @_; my $err_message; # routine: vet_slug============================================ # CHECK SLUG FORMAT # ============================================================= if ($newslug =~ /[^a-zA-Z0-9_\-]/) { ($newslug) = &bmLib::make_it_html_safe($newslug); &bmLib::bmHTML("Please Choose Another Slug Name", "Sorry, you cannot use the slug $newslug for $type. The slug for your new subsections must be only one word and may contain only letters, numbers, hyphens (-) and underscores (_). The slug is used as the name of the directory in which all the subsection articles are stored and also for the Web address of all subsection articles.
Please click your browser's Back button to review your entry.
"); } # routine: vet_slug============================================ # CHECK VALID LENGTH FOR SLUG # ============================================================= if (length($newslug) > 250) { &bmLib::bmHTML("Slug Name Too Long", "The slug for $type is too long. Slugs may not be longer than 250 characters. Please click your browser's Back button to review your entry."); } # routine: vet_slug============================================ # CHECK ILLEGAL NAMES # ============================================================= if ( $newslug eq "bmadmin" || $newslug eq "tips" || $newslug eq "moxiepix" || $newslug eq "bigmed_pix" || $newslug eq "affiliate" || $newslug eq "rssLatest") { &bmLib::bmHTML("Reserved Slug Name", "Sorry, you cannot use the slug $newslug for $type because Big Medium reserves that directory name for administrative purposes. This list of slugs are reserved:The $confirm_msg section and all of its contents have been permanently deleted. Unless you have other section changes to make, you should now rebuild all pages for all sections.
~; &bmLib::LoadSectionInfo; &bmSection::section_menu($confirm_msg); exit; } else { $confirm_msg = qq~The subsection(s) you indicated have been permanently deleted, and all of your other changes have been saved. Unless you have other section changes to make, you should now rebuild all pages for the parent section(s) of the deleted subsection(s). Click here for the Rebuild Pages menu.
~; &bmLib::LoadSectionInfo; &bmSection::section_menu($confirm_msg); exit; } } else { # set up a meta refresh page to keep coming back to this # routine until we've scanned all articles if (keys %main_del) { $confirm_msg = $bmSetup::SectionName{(keys %main_del)[0]} . " section"; } else { $confirm_msg = "the subsection(s) you indicated"; } $i = 0; foreach (@delete_sec) { $i++; $section_insert .= "&d$i=$_"; } $confirm_msg = qq~We have deleted all html files, directories and templates for the $confirm_msg, and we are now updating the article data files and the image directory to reflect these changes.Select a new order for the ~ . lc($label) . qq~. This determines the order in which the sections appear in navigation bars.
\n~; for (1..@sections) { $order = $_; $thisfield .= qq~You can offer multiple news feeds to allow your visitors to subscribe to very general or very focused content on your site. Check the news-feed content you would like to offer, and click the "Save" button at the bottom of the list:
\n~; &bmLib::bmHTML("Select Your News Feeds", $html); } #end edit_newsfeeds routine sub save_newsfeeds { ############################################################### ## ROUTINE: save_newsfeeds ## ## Sets/removes the "s" flag from the SectionSuppress hash ## for each non-aliased section of the site, based on user ## input from the edit_newsfeeds routine. ## ############################################################### my %feed; # routine: save_newsfeeds====================================== # MARK SECTIONS FOR WHICH WE WANT TO OFFER A FEED # ============================================================= foreach (CGI::param("feed")) { $feed{$_} = 1; } # routine: save_newsfeeds====================================== # LOCK AND LOAD # ============================================================= &bmLib::FileLock; my @secindex= &bmLib::LoadFile("$bmSetup::DataDir/templates/Sections.setup"); # routine: save_newsfeeds====================================== # MAKE SURE THERE'S AVAILABLE DISK SPACE # ============================================================= #don't need much, 512k should be fine &bmLib::DiskSpace("$bmSetup::DataDir/templates", 512); # routine: save_newsfeeds====================================== # REBUILD SECTION INDEX AND WRITE TO DISK # ============================================================= open (SECTIONFILE, ">$bmSetup::DataDir/templates/Sections.setup") or die("Unable to write to section index at $bmSetup::DataDir/templates/Sections.setup. $!."); flock(SECTIONFILE, 2) or die("Could not do flock 2 exclusive lock on section index at $bmSetup::DataDir/templates/Sections.setup. $!"); #update all sections (unaliased sections get no feed) foreach (@secindex) { my @line = split(/ /); if ($feed{$line[0]}) { #remove the feed-suppress flag $line[6] =~ s/s//; $_ = join(" ", @line); } elsif (index($line[6], "s") < 0) { $line[6] .= "s"; $_ = join(" ", @line); } print SECTIONFILE "$_\n"; } close (SECTIONFILE); chmod 0666, "$bmSetup::DataDir/templates/Sections.setup"; &bmLib::FileUnlock; # routine: save_newsfeeds====================================== # CONFIRM THE SAVE # ============================================================= &bmLib::bmHTML("News Feed Settings Saved", qq~Your news-feed content settings have been saved (please rebuild top-level pages to refresh your feeds). Close this window to continue.~); }