ONO::Scripts::Admin

package ONO::Scripts::Admin;
################################################################################
# COPYRIGHT / LICENSE #
################################################################################
#
# This file is part of the ONO Software Project.
#
# Copyright (C) 2000-2025 Jos KIRPS [ www.kirps.com | jos_AT_kirps_DOT_com ]
# and The Joopita Project [ www.joopita.org | contact_AT_joopita_DOT_com ]
#
# This file, as well as other parts of the ONO Software Project or related
# elements, are FREE SOFTWARE available under the ARTISTIC LICENSE 2.0.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# For the full license, see /ono/osr/license/LICENSE.txt, or write to
# jos_AT_kirps_DOT_com or contact_AT_joopita_DOT_com.
#
################################################################################
# END OF COPYRIGHT / LICENSE, HERE COMES THE CODE ... #
################################################################################


use strict;

use ONO::Apps::Admin::Init;

use ONO::ToolBox::Auth::ToolBox;
use ONO::Render::Simple;

use ONO::Lib::Parser;
use ONO::IO;
use ONO::DB;
use ONO::ToolBox::Input;

###############################################################################
# RUN
###############################################################################

sub run {

#: This module will display the ONO Administration environment.

my ($vars_ref,%vars) = ONO::ToolBox::Input->get;

my $community = "ono";
my $db;
if (ONO::IO->exists("etc/sql/ono.conf")) {
$db = ONO::DB->connect($community);
}

if ($vars{'username'} && $vars{'password'}) {

$vars_ref = ONO::ToolBox::Auth::ToolBox->login($db,$community,\%vars);
%vars = %$vars_ref;

}

ONO::Render::Simple->render_pre($vars{'cookie_sid'},qq~<link rel="stylesheet" type="text/css" href="/ono/osr/css/admin.css">\n~);

my $WEB = ONO::Apps::Admin::Init->init($db,$community,$vars_ref);
my ($status,$WEB) = ONO::Lib::Parser->parse($WEB,$vars_ref);

my ($BODY,$ONLOAD);

my $whilecounter;

while ($WEB =~ s/<script_head (.*?)><\/script>// && $whilecounter < 256) {
$whilecounter++;
if ($1) {
print qq~<script $1></script>\n~;
}
}
while ($WEB =~ s/<link_head (.*?)>// && $whilecounter < 256) {
$whilecounter++;
if ($1) {
print qq~<link $1>\n~;
}
}

while ($WEB =~ s~\<onload="(.*?)"\>~~ && $whilecounter < 256) {

$ONLOAD .= "$1;";
$whilecounter++;

}

if ($ONLOAD) {
$BODY .= qq~ onload="$ONLOAD"~;
}

ONO::Render::Simple->render($WEB,$BODY);

}

###############################################################################
# end of script
###############################################################################

1;

__END__