############################################################################### # HelpCentre.pm # # $Date: 01.09.2026 $ # ############################################################################### # YaBB: Yet another Bulletin Board # # Open-Source Community Software for Webmasters # # Version: YaBBForum 3.1 # # Packaged: 01 Sep, 2026 # # Distributed by: https://yabbforum.nz # # =========================================================================== # # Copyright (c) 2000-2026 YaBB (yabbforum.nz) - All Rights Reserved. # # Software by: The YaBB Development Team # # with assistance from the YaBB community. # ############################################################################### use CGI::Carp qw(fatalsToBrowser); our $VERSION = '3.1'; $helpcentrepmver = 'YaBBForum 3.1'; if ( $action eq 'detailedversion' ) { return 1; } LoadLanguage('HelpCentre'); require Sources::Menu; $yytitle = $helptxt{'1'}; undef $guest_media_disallowed; @my_modimglist = qw( admin_rem admin_move_split_splice admin_lock hide admin_sticky admin_del ); $my_moding = q{}; foreach (@my_modimglist) { $modimg = SetImage( $_, $UseMenuType ); $mymoding .= qq~$menusep$modimg~; } $mymoding =~ s/\Q$menusep//ism; sub SectionDecide { # This bit decides what section we are in and sets the background accordingly # Also sets the variables are used to open up the correct Help Directory if ($UseHelp_Perms) { $ismod = 0; if ( !exists $memberinfo{$username} ) { LoadUser($username); } foreach my $catid (@categoryorder) { if ($ismod) { last; } $boardlist = $cat{$catid}; (@bdlist) = split /\,/xsm, $boardlist; foreach my $curboard (@bdlist) { if ($ismod) { last; } foreach my $curuser ( split /, ?/sm, ${ $uid . $curboard }{'mods'} ) { if ( $curuser eq $username ) { $ismod = 1; last; } } foreach ( split /, /sm, ${ $uid . $curboard }{'modgroups'} ) { if ( $_ eq ${ $uid . $username }{'position'} ) { $ismod = 1; last; } } } } } if ( $INFO{'section'} eq 'admin' ) { if ( $UseHelp_Perms && !$iamadmin ) { fatal_error( 'no_access', 'HelpCentre->SectionDecide' ); } ${ $INFO{'section'} . _class } = 'selected-bg'; $help_area = 'Admin'; } elsif ( $INFO{'section'} eq 'global_mod' ) { if ( $UseHelp_Perms && !$iamgmod && !$iamadmin ) { fatal_error( 'no_access', 'HelpCentre->SectionDecide' ); } ${ $INFO{'section'} . _class } = 'selected-bg'; $help_area = 'Gmod'; } elsif ( $INFO{'section'} eq 'moderator' ) { if ( $UseHelp_Perms && !$ismod && !$iamgmod && !$iamadmin && !$iamfmod ) { fatal_error( 'no_access', 'HelpCentre->SectionDecide' ); } ${ $INFO{'section'} . _class } = 'selected-bg'; $help_area = 'Moderator'; } else { $UserClass = 'selected-bg'; $help_area = 'User'; } return; } sub SectionPrint { # Prints the navigation bar for the help section $userhlp = qq~$helptxt{'3'}~; if ($UseHelp_Perms) { if ( !$ismod && !$iamgmod && !$iamadmin && !$iamfmod ) { return } if ( $ismod || $iamgmod || $iamadmin || $iamfmod ) { $modhlp = qq~$helptxt{'4'}~; } else { $modhlp = ' '; } if ( $iamgmod || $iamadmin ) { $gmodhlp = qq~$helptxt{'5'}~; } else { $gmodhlp = ' '; } if ($iamadmin) { $adminhlp = qq~$helptxt{'6'}~; } else { $adminhlp = ' '; } } else { $modhlp = qq~$helptxt{'4'}~; $gmodhlp = qq~$helptxt{'5'}~; $adminhlp = qq~$helptxt{'6'}~; } $HelpNavBar =~ s/{user menu}/$userhlp/gsm; $HelpNavBar =~ s/{moderator menu}/$modhlp/gsm; $HelpNavBar =~ s/{global mod menu}/$gmodhlp/gsm; $HelpNavBar =~ s/{admin menu}/$adminhlp/gsm; $HelpNavBar =~ s/{user class}/$UserClass/gsm; $HelpNavBar =~ s/{moderator class}/$moderator_class/gsm; $HelpNavBar =~ s/{global mod class}/$global_mod_class/gsm; $HelpNavBar =~ s/{admin class}/$admin_class/gsm; $yymain .= $HelpNavBar; return $yymain; } sub GetHelpFiles { if ( !$HelpTemplateLoaded ) { get_template('HelpCentre'); } SectionDecide(); # This determines if the order file is present and if it isn't # It creates a new one, in default alphabetical order if ( !-e "$vardir/$help_area.helporder" ) { CreateOrderFile(); } fopen( HELPORDER, "$vardir/$help_area.helporder" ); my @helporderlist = ; fclose(HELPORDER); chomp @helporderlist; foreach (@helporderlist) { if ( -e "$helpfile/$language/$help_area/$_.help" ) { require "$helpfile/$language/$help_area/$_.help"; } elsif ( -e "$helpfile/English/$help_area/$_.help" ) { require "$helpfile/English/$help_area/$_.help"; } else { next; } MainHelp(); DoContents(); } SectionPrint(); ContentContainer(); $yynavigation = qq~› $yytitle~; template(); return; } sub MainHelp { $TempParse = $BodyHeader; $BrdID = $mbname; $BrdID =~ s/ /_/gsm; $SectionName =~ s/{yabb myboardname}/$BrdID/gsm; $SectionName =~ s/ /_/gsm; $TempParse =~ s/{yabb section_anchor}/$SectionName/gsm; $SectionNam = $SectionName; $SectionNam =~ s/_/ /gsm; $TempParse =~ s/{yabb section_name}/$SectionNam/gsm; $Body .= qq~$TempParse~; $i = 1; while ( ${ SectionSub . $i } ) { if ( ${ SectionExcl . $i } eq 'yabbc' && ( !$enable_ubbc || !$showyabbcbutt ) ) { $i++; next; } $TempParse = $BodySubHeader; $BrdID = $mbname; $BrdID =~ s/ /_/gsm; $SectionAnchor = ${ SectionSub . $i }; $SectionSub = ${ SectionSub . $i }; $SectionSub =~ s/_/ /gsm; $SectionAnchor =~ s/{yabb myboardname}/$BrdID/gsm; $SectionAnchor =~ s/ /_/gsm; $TempParse =~ s/{yabb section_anchor}/$SectionAnchor/gsm; $TempParse =~ s/{yabb section_sub}/$SectionSub/gsm; $TempParse =~ s/{yabb myboardname}/$mbname/gsm; $Body .= qq~$TempParse~; $message = ${ SectionBody . $i }; $displayname = ${ $uid . $username }{'realname'}; enable_yabbc(); $message =~ s/\[yabbc\](.*?)\[\/yabbc\]/my($text) = $1; ToHTML($text); DoUBBCTo($text);/sgem; wrap2(); if ( $SectionAnchor eq 'YaBBC_Reference' ) { $yyinlinestyle .= qq~\n~; } $TempParse = $BodyItem; $TempParse =~ s/{yabb item}/$message/gsm; $TempParse =~ s/{yabb mymoding}/$mymoding/sm; $TempParse =~ s/{top_img}/$top_img/gsm; $Body .= qq~$TempParse~; $i++; } $Body .= qq~$BodyFooter~; return $Body; } { my %hpkillhash = ( q{;} => ';', q{!} => '!', q{(} => '(', q{)} => ')', q{-} => '-', q{.} => '.', q{/} => '/', q{:} => ':', q{?} => '?', q{[} => '[', q{\\} => '\', q{]} => ']', q{^} => '^', ); sub codehlp { my ($hcode) = @_; if ( $hcode !~ /&\S*;/xsm ) { $hcode =~ s/;/&\x23059;/gxsm; } $hcode =~ s/([\(\)\-\:\\\/\?\!\]\[\.\^])/$hpkillhash{$1}/gxsm; $hcode =~ s/(&\x2391\;.+?&\x2393\;)/$1<\/span>/isgm; $hcode =~ s/(&\x2391\;&\x2347\;.+?&\x2393\;)/$1<\/span>/isgm; return $hcode; } } sub ContentContainer { $MainLayout =~ s/{yabb contents}/$Contents/gsm; $MainLayout =~ s/{yabb body}/$Body/gsm; $yymain .= qq~$MainLayout~; return $yymain; } sub DoContents { $TempParse = $ContentHeader; $BrdID = $mbname; $BrdID =~ s/ /_/gsm; $SectionName =~ s/{yabb myboardname}/$BrdID/gsm; $TempParse =~ s/{yabb section_anchor}/$SectionName/gsm; $SectionNam = $SectionName; $SectionNam =~ s/_/ /gsm; $TempParse =~ s/{yabb section_name}/$SectionNam/gsm; $TempParse =~ s/{top_img}/$top_img/gsm; $Contents .= qq~$TempParse~; $Contents .= q~
    ~; $i = 1; while ( ${ SectionSub . $i } ) { if ( ${ SectionExcl . $i } eq 'yabbc' && ( !$enable_ubbc || !$showyabbcbutt ) ) { $i++; next; } $SectionAnchor = ${ SectionSub . $i }; ${ SectionSub . $i } =~ s/_/ /gxsm; $TempParse = $ContentItem; $TempParse =~ s/{yabb anchor}/$SectionAnchor/gsm; $TempParse =~ s/{yabb myboardname}/$BrdID/gsm; $TempParse =~ s/{yabb content}/${SectionSub.$i}/gsm; $Contents .= qq~$TempParse~; ${ SectionSub . $i } = q{}; $i++; } $Contents .= q~
~; return $Contents; } sub CreateOrderFile { if ( opendir HELPDIR, "$helpfile/$language/$help_area" ) { @contents = readdir HELPDIR; closedir HELPDIR; } elsif ( opendir HELPDIR, "$helpfile/English/$help_area" ) { @contents = readdir HELPDIR; closedir HELPDIR; } foreach ( sort { uc($a) cmp uc $b } @contents ) { ( $name, $extension ) = split /\./xsm, $_; next if $extension !~ /help/ism; $order_list .= "$name\n"; } fopen( HELPORDER, ">$vardir/$help_area.helporder" ) or croak( "couldn't write order file - check permissions on $vardir and $vardir/$help_area.helporder" ); print {HELPORDER} qq~$order_list~ or croak "$croak{'print'} HELPORDER"; fclose(HELPORDER); return; } 1;