#!/usr/bin/perl # ---------------------------------------------------------------------------- # This software is Copyright (C) 2006, All Rights Reserved # ---------------------------------------------------------------------------- # This program is protected by local and international copyright laws. Any # use of this program is subject to the the terms of the license agreement # included as part of this distribution archive. Any other uses are strictly # prohibited without the written permission of the Vendor and all # other rights are reserved. # ----------------------------------------------------------------------------- # Warning : Modifying this program violates your license agreement! # ----------------------------------------------------------------------------- use strict; ### Check Perl Version BEGIN { my $perlVersion = $^V ? join('.', unpack('C*', $^V)) : $]; # get perl version my $isOldPerl = ($] < 5.008_000); # backwards compatible way to write v5.8.0 if ($isOldPerl) { print "Content-type: text/plain\n\n\n\n"; print " *** SERVER DOESN'T MEET BASIC SOFTWARE REQUIREMENTS ***\n\n"; print " This software requires Perl 5.8.0+ (released 5 years ago), this server has Perl $perlVersion.\n\n"; print " Please have Perl upgraded to a more modern version or switch to a different hosting provider.\n\n"; print " If you've just upgraded the software you can downgrade by re-installing the previous version.\n\n"; exit; } }; ### Get Script Directory use vars qw($CGIDIR); BEGIN { foreach my $scriptFilepath ($0, $ENV{'SCRIPT_FILENAME'}) { if ($scriptFilepath =~ m/^\./) { next; } # skip relative paths (eg: ./admin.cgi) unless ($scriptFilepath =~ m|^(.+)[\\\/]|) { next; } # match path but not filename $CGIDIR = $1; $CGIDIR =~ s|\\|/|g; last; } }; ### Load Modules use Time::Local; use lib ("$CGIDIR/modules/"); use IT::AutoLoader; use IT::Globals; ### Define Globals $PROGRAM_VERSION = '2.14'; $PROGRAM_BUILD = '11'; $PROGRAM_KEY = 35797; $PROGRAM_ID = 15; ### Run Program eval { &main(); }; if ($@) { # display program errors print "Content-type: text/html\n\n" unless $IT::COMMON::CONTENT_HEADERS_SENT; print "

Alert: $IT::App::ALERT_MESSAGES

\n" if $IT::App::ALERT_MESSAGES; print "

Error: $@

\n"; # eval error print "

Debug: $IT::App::DEBUG_MESSAGES

\n" if $IT::App::DEBUG_MESSAGES; } exit; # ---------------------------------------------------------------------------- # Function : main # Description : main program # ---------------------------------------------------------------------------- sub main { # initialize program &IT::App::Init::loadCustomPatches('customPatches.pl'); &IT::ArtMan::Init::appInit(); &IT::App::Init::appInit(); &IT::ArtMan::Install::installIfNeeded(); &IT::App::Register::registerIfNeeded(); &IT::ArtMan::Upgrade::upgradeIfNeeded(); # dispatch actions my $action = &IT::App::getRequestedAction(); &dispatchAction($action); exit; } # ------------------------------------------------------------------------ # Function : dispatchAction # Description : # Usage : &dispatchAction($action); # ------------------------------------------------------------------------ sub dispatchAction { my $action = shift; # dispatch public actions (no login required) &_dispatchPublicActions($action); # dispatch user actions (login required) &IT::App::Menu::Login::requireValidLogin(); &_dispatchUserActions($action) if ($CURRENT_USER->{'accessLevel'} >= 1); &_dispatchAdminActions($action) if ($CURRENT_USER->{'accessLevel'} >= 9); &IT::App::home("Unknown action '$action'"); # display error for unknown actions exit; } # ------------------------------------------------------------------------ # Function : _dispatchPublicActions # Description : # Usage : &_dispatchPublicActions($action); # ------------------------------------------------------------------------ sub _dispatchPublicActions { my $action = shift; if ($action eq 'help') { &IT::App::displayHelp(); } if ($action eq 'showLicense') { &IT::App::License::displayLicensePage(); } if ($action eq 'loginForm') { &IT::App::Menu::Login::showLoginForm(); } if ($action eq 'loginCookieTest') { &IT::App::Menu::Login::testCookies(); } if ($action eq 'loginRequirements') { &IT::App::Menu::Login::showDialog('loginRequirements', 'none'); } if ($action eq 'loginAbout') { &IT::App::Menu::Login::showDialog('loginAbout', 'about'); } if ($action eq 'logoff') { &IT::App::Menu::Login::logoff(); } if ($action eq 'passwordReminderForm') { &IT::App::Menu::Login::passwordReminderForm(); } if ($action eq 'passwordReminderSubmit') { &IT::App::Menu::Login::passwordReminderSubmit(); } } # ------------------------------------------------------------------------ # Function : _dispatchUserActions # Description : Dispath actions that require login access of various levels # Usage : &_dispatchUserActions($action); # ------------------------------------------------------------------------ sub _dispatchUserActions { my $action = shift; ### Home Menu if ($action eq 'home') { &IT::App::home(); } if ($action eq '') { &IT::App::home(); } ### Upload Files (shared actions) if ($action eq "uploadForm") { &IT::App::Menu::uploadForm(); } if ($action eq "submitUploadForm") { &IT::App::Menu::submitUploadForm(); } if ($action eq "modifyUploadAttributes") { &IT::App::Menu::modifyUploadAttributesForm(); } ### Publish (shared actions) if ($action eq "publish") { &IT::ArtMan::CustomMenus::Publish::publish($FORM->{'publishType'}); } if ($action eq "publishUpdated") { &IT::ArtMan::CustomMenus::Publish::publish('updated'); } if ($action eq "publishTimeout") { &IT::ArtMan::CustomMenus::Publish::publishTimeout(); } ### User Preferences { my $menuName = 'userPreferences'; unless ($action =~ /^$menuName/) { last; } # Define menu attributes and custom handlers &IT::App::Menu::setMenuAttribute($menuName, 'all', 'template', "admin/menus/$menuName.html"); &IT::App::Menu::setMenuAttribute($menuName, 'all', 'selectedMenuOption', "none"); &IT::App::Menu::setMenuAttribute($menuName, 'all', 'tableNameWithPrefix', $TABLE_PREFIX . "accounts"); &IT::App::Menu::setMenuAttribute($menuName, 'all', 'recordNum', $CURRENT_USER->{'num'}); &IT::App::Menu::setMenuAttribute($menuName, 'list', 'function', sub { &IT::App::Menu::edit(@_) }); &IT::App::Menu::setMenuAttribute($menuName, 'save', 'preErrorChecking', sub { &IT::App::Menu::UserPreferences::saveErrorChecking(@_); }); &IT::App::Menu::setMenuAttribute($menuName, 'save', 'limitUpdatableFields', ['email', 'password']); &IT::App::Menu::setMenuAttribute($menuName, 'save', 'postSave', sub { &IT::App::alert("User Preferences have been saved."); }); # dispatch menu functions if ($action eq "${menuName}Edit") { &IT::App::Menu::edit($menuName); } if ($action eq "${menuName}Save") { &IT::App::Menu::save($menuName); } }; ### Article Menu { my $menuName = 'article'; unless ($action =~ /^$menuName/) { last; } # Define menu attributes and custom handlers &IT::App::Menu::setMenuAttribute($menuName, 'all', 'template', "admin/menus/$menuName.html"); &IT::App::Menu::setMenuAttribute($menuName, 'all', 'selectedMenuOption', "$menuName"); &IT::App::Menu::setMenuAttribute($menuName, 'all', 'tableNameWithPrefix', $TABLE_PREFIX . "$menuName"); &IT::App::Menu::setMenuAttribute($menuName, 'list', 'whereQuery', &IT::ArtMan::CustomMenus::Article::createDbWhereQuery()); &IT::App::Menu::setMenuAttribute($menuName, 'list', 'function', sub { my($attr, $errors) = @_; &IT::App::home($errors); }) if ($CURRENT_USER->{'accessLevel'} < 3); &IT::App::Menu::setMenuAttribute($menuName, 'list', 'postResetSearch', sub { &IT::ArtMan::CustomMenus::Article::list_resetSearchQuery(@_); }); &IT::App::Menu::setMenuAttribute($menuName, 'list', 'init', sub { &IT::ArtMan::CustomMenus::Category::getHashOfCategoryRecords(); # cache category records &IT::ArtMan::CustomMenus::Article::list_getQueryValues(@_); }); &IT::App::Menu::setMenuAttribute($menuName, 'list', 'postSetGlobalPlaceholders', sub { &IT::ArtMan::CustomMenus::Article::list_setQueryPlaceholders(@_); }); &IT::App::Menu::setMenuAttribute($menuName, 'list', 'saveLastQueryToCookie', sub { &IT::ArtMan::CustomMenus::Article::list_saveLastQueryToCookie(@_); }); &IT::App::Menu::setMenuAttribute($menuName, 'list', 'createUserSearchDbQuery', sub { &IT::ArtMan::CustomMenus::Article::list_createUserSearchDbQuery(@_); }); &IT::App::Menu::setMenuAttribute($menuName, 'list', 'preRowCode', sub { &IT::ArtMan::CustomMenus::Article::list_loadCategoryPlaceholders(@_); }); &IT::App::Menu::setMenuAttribute($menuName, 'confirmErase', 'preErrorChecking', sub { &IT::ArtMan::CustomMenus::Article::eraseErrorChecking(@_); }); &IT::App::Menu::setMenuAttribute($menuName, 'erase', 'preErrorChecking', sub { &IT::ArtMan::CustomMenus::Article::eraseErrorChecking(@_); }); &IT::App::Menu::setMenuAttribute($menuName, 'edit', 'preErrorChecking', sub { &IT::ArtMan::CustomMenus::Article::edit_errorChecking(@_); }); &IT::App::Menu::setMenuAttribute($menuName, 'save', 'postErrorChecking', sub { &IT::ArtMan::CustomMenus::Article::save_errorChecking(@_); }); &IT::App::Menu::setMenuAttribute($menuName, 'save', 'preSave', sub { &IT::ArtMan::CustomMenus::Article::displayErrorOnFilenameCollisions(@_); &IT::ArtMan::CustomMenus::Article::setNeedsPublishFieldValue(@_); &IT::ArtMan::CustomMenus::Article::setNeedsPublishForArticleListsOnCategory(@_); &IT::ArtMan::CustomMenus::Publish::eraseOldPublishedFilesFor('article', @_); }); &IT::App::Menu::setMenuAttribute($menuName, 'save', 'postSave', sub { &IT::ArtMan::CustomMenus::Article::updateLastUpdatedTime(); &IT::ArtMan::EmailAlerts::onArticleSave(@_); }); &IT::App::Menu::setMenuAttribute($menuName, 'erase', 'preErase', sub { &IT::ArtMan::CustomMenus::Article::setNeedsPublishForArticleListsOnCategory(@_); &IT::ArtMan::CustomMenus::Publish::eraseOldPublishedFilesFor('article', @_); }); &IT::App::Menu::setMenuAttribute($menuName, 'erase', 'postErase', sub { &IT::ArtMan::CustomMenus::Article::updateLastUpdatedTime(); &IT::ArtMan::EmailAlerts::onArticleErase(@_); }); &IT::App::Menu::setMenuAttribute($menuName, 'all', 'publish', sub { &IT::ArtMan::CustomMenus::Publish::publish('updated', "${menuName}List"); }); # dispatch menu functions if ($action eq "${menuName}Add") { &IT::App::Menu::add($menuName); } if ($action eq "${menuName}Edit") { &IT::App::Menu::edit($menuName); } if ($action eq "${menuName}ConfirmErase") { &IT::App::Menu::confirmErase($menuName); } if ($action eq "${menuName}Erase") { &IT::App::Menu::erase($menuName); } if ($action eq "${menuName}Save") { &IT::App::Menu::save($menuName); } if ($action eq "${menuName}List") { &IT::App::Menu::list($menuName); } if ($action eq "${menuName}Search") { &IT::App::Menu::list($menuName); } if ($action eq "${menuName}ResetSearch") { &IT::App::Menu::list($menuName); } if ($action eq "${menuName}Preview") { &IT::ArtMan::CustomMenus::Article::preview($menuName); } }; } # ------------------------------------------------------------------------ # Function : _dispatchAdminActions # Description : Dispath actions that require admin access # Usage : &_dispatchAdminActions($action); # ------------------------------------------------------------------------ sub _dispatchAdminActions { my $action = shift; ### Shared Actions (available on one or more menus) if ($action eq 'browseForDir') { &IT::App::BrowseForDirOrFile::browseFor('dir'); } if ($action eq 'browseForFile') { &IT::App::BrowseForDirOrFile::browseFor('file'); } if ($action eq 'admin_testmail') { &IT::App::Menu::Admin::testMail(); } ### Admin Menu if ($action eq 'admin') { &IT::App::Menu::Admin::showMenu('homepage'); } if ($action eq 'admin_general') { &IT::App::Menu::Admin::showMenu('general'); } if ($action eq 'admin_placeholders') { &IT::App::Menu::Admin::showMenu('placeholders'); } if ($action eq 'admin_regional') { &IT::App::Menu::Admin::showMenu('regional'); } if ($action eq 'admin_server') { &IT::App::Menu::Admin::showMenu('server'); } if ($action eq 'admin_vendor') { &IT::App::Menu::Admin::showMenu('vendor'); } if ($action eq 'admin_save') { &IT::App::Menu::Admin::saveSettings(); } ### Publish if ($action eq "publishAll") { &IT::ArtMan::CustomMenus::Publish::publish('all'); } ### Categories Menu { my $menuName = 'category'; unless ($action =~ /^$menuName/) { last; } # Define menu attributes and custom handlers &IT::App::Menu::setMenuAttribute($menuName, 'all', 'template', "admin/menus/$menuName.html"); &IT::App::Menu::setMenuAttribute($menuName, 'all', 'selectedMenuOption', "$menuName"); &IT::App::Menu::setMenuAttribute($menuName, 'all', 'tableNameWithPrefix', $TABLE_PREFIX . "$menuName"); &IT::App::Menu::setMenuAttribute($menuName, 'add', 'postSetGlobalPlaceholders', sub { &IT::ArtMan::CustomMenus::Category::setPlaceholdersOnAdd(@_); }); &IT::App::Menu::setMenuAttribute($menuName, 'confirmErase', 'alwaysRequireEraseConfirm', 1); # require confirmation because of cascading effects (child categories get erased, etc) &IT::App::Menu::setMenuAttribute($menuName, 'confirmErase', 'init', sub { &IT::ArtMan::CustomMenus::Category::getHashOfCategoryRecords(); }); # cache category records &IT::App::Menu::setMenuAttribute($menuName, 'confirmErase', 'getSelectedRecords', sub { &IT::ArtMan::CustomMenus::Category::getSelectedCategoriesAndDescendants(@_); }); &IT::App::Menu::setMenuAttribute($menuName, 'confirmErase', 'preSetGlobalPlaceholders', sub { &IT::ArtMan::CustomMenus::Category::preCacheCountsOfArticlesToBeErasedByCategory(@_); }); &IT::App::Menu::setMenuAttribute($menuName, 'confirmErase', 'preRowCode', sub { &IT::ArtMan::CustomMenus::Category::createBreadcrumbPlaceholder(@_); &IT::ArtMan::CustomMenus::Category::createArticleCountPlaceholder(@_); }); # erase category articles first so if it times out the category will still exist and the remaining records can be erased on another attempt &IT::App::Menu::setMenuAttribute($menuName, 'erase', 'preErase', sub { &IT::ArtMan::CustomMenus::Category::eraseCategoryArticles(@_); &IT::ArtMan::CustomMenus::Publish::eraseOldPublishedFilesFor('category', @_); &IT::ArtMan::CustomMenus::Category::setNeedsPublishForAllCategories(@_); }); &IT::App::Menu::setMenuAttribute($menuName, 'erase', 'postErase', sub { &IT::ArtMan::CustomMenus::Category::updateDepthOrderAndLineageFields(@_); }); &IT::App::Menu::setMenuAttribute($menuName, 'save', 'postErrorChecking', sub { &IT::ArtMan::CustomMenus::Category::saveErrorChecking(@_); }); &IT::App::Menu::setMenuAttribute($menuName, 'save', 'preSave', sub { &IT::ArtMan::CustomMenus::Category::displayErrorOnFilenameCollisions(@_); &IT::ArtMan::CustomMenus::Category::setSiblingOrderFieldValue(@_); &IT::ArtMan::CustomMenus::Publish::eraseOldPublishedFilesFor('category', @_); }); &IT::App::Menu::setMenuAttribute($menuName, 'save', 'postSave', sub { &IT::ArtMan::CustomMenus::Category::updateDepthOrderAndLineageFields(@_); &IT::ArtMan::CustomMenus::Category::setNeedsPublishForCategoriesAndArticles(@_); }); &IT::App::Menu::setMenuAttribute($menuName, 'all', 'publish', sub { &IT::ArtMan::CustomMenus::Publish::publish('updated',"${menuName}List"); }); # dispatch menu functions if ($action eq "${menuName}Add") { &IT::App::Menu::add($menuName); } if ($action eq "${menuName}Edit") { &IT::App::Menu::edit($menuName); } if ($action eq "${menuName}ConfirmErase") { &IT::App::Menu::confirmErase($menuName); } if ($action eq "${menuName}Erase") { &IT::App::Menu::erase($menuName); } if ($action eq "${menuName}Save") { &IT::App::Menu::save($menuName); } if ($action eq "${menuName}ResetSearch") { &IT::App::Menu::list($menuName); } if ($action eq "${menuName}List") { &IT::App::Menu::list($menuName); } if ($action eq "${menuName}Search") { &IT::App::Menu::list($menuName); } if ($action eq "${menuName}Move") { &IT::ArtMan::CustomMenus::Category::move($menuName); } if ($action eq "${menuName}SortAtoZ") { &IT::ArtMan::CustomMenus::Category::sortAtoZ($menuName); } }; ### Accounts Menu { my $menuName = 'accounts'; unless ($action =~ /^$menuName/) { last; } # Define menu attributes and custom handlers &IT::App::Menu::setMenuAttribute($menuName, 'all', 'template', "admin/menus/admin/$menuName.html"); &IT::App::Menu::setMenuAttribute($menuName, 'all', 'selectedMenuOption', "admin"); &IT::App::Menu::setMenuAttribute($menuName, 'all', 'tableNameWithPrefix', $TABLE_PREFIX . "$menuName"); &IT::App::Menu::setMenuAttribute($menuName, 'confirmErase', 'preErrorChecking', sub { &IT::App::Menu::Accounts::eraseErrorChecking(@_); }); &IT::App::Menu::setMenuAttribute($menuName, 'erase', 'preErrorChecking', sub { &IT::App::Menu::Accounts::eraseErrorChecking(@_); }); &IT::App::Menu::setMenuAttribute($menuName, 'save', 'preErrorChecking', sub { &IT::App::Menu::Accounts::saveErrorChecking(@_); }); # dispatch menu functions if ($action eq "${menuName}Add") { &IT::App::Menu::add($menuName); } if ($action eq "${menuName}Edit") { &IT::App::Menu::edit($menuName); } if ($action eq "${menuName}ConfirmErase") { &IT::App::Menu::confirmErase($menuName); } if ($action eq "${menuName}Erase") { &IT::App::Menu::erase($menuName); } if ($action eq "${menuName}Save") { &IT::App::Menu::save($menuName); } if ($action eq "${menuName}List") { &IT::App::Menu::list($menuName); } if ($action eq "${menuName}Search") { &IT::App::Menu::list($menuName); } if ($action eq "${menuName}ResetSearch") { &IT::App::Menu::list($menuName); } }; ### Database Editor if ($action =~ /^databaseEditor/) { &IT::App::Menu::Admin::DatabaseEditor::main($action); } ### Template Editor if ($action eq "templateEditor") { &IT::App::Menu::Admin::TemplateEditor::main(); } ### PublishRules Menu { my $menuName = 'publishRules'; unless ($action =~ /^$menuName/) { last; } # Define menu attributes and custom handlers &IT::App::Menu::setMenuAttribute($menuName, 'all', 'template', "admin/menus/admin/$menuName.html"); &IT::App::Menu::setMenuAttribute($menuName, 'all', 'selectedMenuOption', "admin"); &IT::App::Menu::setMenuAttribute($menuName, 'all', 'tableNameWithPrefix', $TABLE_PREFIX . lc $menuName); &IT::App::Menu::setMenuAttribute($menuName, 'list', 'recordsPerPage', 1_000_000); &IT::App::Menu::setMenuAttribute($menuName, 'list', 'postSetGlobalPlaceholders', sub { &IT::ArtMan::CustomMenus::Admin::PublishRules::defineSettingsPlaceholders(@_); }); &IT::App::Menu::setMenuAttribute($menuName, 'list', 'preRowCode', sub { &IT::ArtMan::CustomMenus::Admin::PublishRules::createPublishedAsFilenamesPlaceholder(@_); }); &IT::App::Menu::setMenuAttribute($menuName, 'add', 'preSetGlobalPlaceholders', sub { &IT::ArtMan::CustomMenus::Admin::PublishRules::createAddMenuDefaultValuePlaceholders(@_); &IT::ArtMan::CustomMenus::Admin::PublishRules::createPulldownPlaceholders(@_); }); &IT::App::Menu::setMenuAttribute($menuName, 'edit', 'preSetGlobalPlaceholders', sub { &IT::ArtMan::CustomMenus::Admin::PublishRules::createPulldownPlaceholders(@_); }); &IT::App::Menu::setMenuAttribute($menuName, 'save', 'preErrorChecking', sub { &IT::ArtMan::CustomMenus::Admin::PublishRules::saveErrorChecking(@_); }); # dispatch menu functions if ($action eq "${menuName}") { &IT::App::Menu::list($menuName); } if ($action eq "${menuName}List") { &IT::App::Menu::list($menuName); } if ($action eq "${menuName}Add") { &IT::App::Menu::add($menuName); } if ($action eq "${menuName}Edit") { &IT::App::Menu::edit($menuName); } if ($action eq "${menuName}ConfirmErase") { &IT::App::Menu::confirmErase($menuName); } if ($action eq "${menuName}Erase") { &IT::App::Menu::erase($menuName); } if ($action eq "${menuName}Save") { &IT::App::Menu::save($menuName); } if ($action eq "${menuName}ResetSearch") { &IT::App::Menu::list($menuName); } if ($action eq "${menuName}SaveAndCopy") { &IT::ArtMan::CustomMenus::Admin::PublishRules::saveAndCopy($menuName); } if ($action eq "${menuName}SaveSettings") { &IT::ArtMan::CustomMenus::Admin::PublishRules::savePublishSettings($menuName); } if ($action eq "${menuName}DisableSelected") { &IT::ArtMan::CustomMenus::Admin::PublishRules::changeDisabledStatusOnRules($menuName, 1); } if ($action eq "${menuName}EnableSelected") { &IT::ArtMan::CustomMenus::Admin::PublishRules::changeDisabledStatusOnRules($menuName, 0); } if ($action eq "${menuName}PublishSelected") { &IT::ArtMan::CustomMenus::Admin::PublishRules::publishSelected($menuName); } if ($action eq "${menuName}PlaceholderHelp") { &IT::ArtMan::CustomMenus::Admin::PublishRules::showPlaceholderHelp(); } if ($action eq "${menuName}ConvertSSIsToPHPIncludes") { &IT::ArtMan::CustomMenus::Admin::PublishRules::convertSSIsToPHPIncludes($menuName); } if ($action eq "${menuName}ConvertPHPIncludesToSSIs") { &IT::ArtMan::CustomMenus::Admin::PublishRules::convertPHPIncludesToSSIs($menuName); } }; } # ---------------------------------------------------------------------------- # Function : defineGlobalPlaceholders # Description : # Usage : &defineGlobalPlaceholders() # ---------------------------------------------------------------------------- sub defineGlobalPlaceholders { # Define default global placeholders &IT::App::defineGlobalTemplatePlaceholders(); # Define application specific global placeholders &IT::Template::setGlobalPlaceholder('category.optionListForSearchEngineAsBranches', &IT::ArtMan::CustomMenus::Category::createCategoryOptionListForSearchEngineAs('branches')); &IT::Template::setGlobalPlaceholder('category.optionListForSearchEngineAsBreadcrumbs', &IT::ArtMan::CustomMenus::Category::createCategoryOptionListForSearchEngineAs('breadcrumbs')); } # ---------------------------------------------------------------------------- # end of file 1;