your code is good. and i understand this much very well. i'll point out, that d:/apache24/htdocs/ is my 'working' directory - thus, .pl files are stored there, and .pm files are stored in ./pm
and, i noticed i forgot to post my main code, which may be relevant (or critical even?) to my module confusion
debug.pl - d:/apache24/htdocs/debug.pl
#!/perl/bin/perl.exe
###########################
##
## this is a debug script to simply test each module's abilities
##
## if a new subroutine has been added to any module within
## the pm folder AND it requires testing, search THIS
## document for
## "# [modulename] TESTS"
## where [modulename] is the name of a module. eg: "bc_sql"
## add the new test in the same way as other tests found in this sc
+ript
##
###########################
# must have's!
use strict;
use warnings;
use CGI::Carp qw(fatalsToBrowser);
use DBI;
use URI::Escape;
use pm::bc_chef;
use pm::bc_misc;
use pm::bc_sql;
use pm::subdesc;
use pm::redir;
use pm::search;
use pm::security;
my $BORDER = 0;
my $navheight = 20;
my $navcontainerheight = $navheight + 20;
my $loggedin = pm::bc_chef::cookie_get("loggedin");
my $db = sql_connect("ns.db");
if ($loggedin !~ /^A6DE0E8077|7EE22A4BBF$/i) {
if (not isUserAdmin($loggedin)) {
print error_redir("/", "Access Denied");
exit 1;
}
}
######################################################################
+############
######################################################################
+############
######################################################################
+############
######################################################################
+############
######################################################################
+############
# much of the code is redacted here, and only what you need is include
+d
# things like "display_debug_one" and related are redacted, since they
+ just
# display things and have no real affect / effect on the data at all
my $COOL_DOT = "<font size=4> • </font>";
my $rv = "cache-control: no-store\n";
$rv .= "content-type: text/html\n\n";
$rv .= "<html>\n";
$rv .= "<head>\n";
$rv .= " <title>NS Debug Page</title>\n";
$rv .= " <link rel=stylesheet href='css.pl?debugger=1'>\n";
$rv .= "</head>\n";
$rv .= "<body>\n";
# a paramater to capture the selected PM with
my $debug_page = get_constant($db, "QUERY_DEBUG_PAGE");
my $pm = lc(get_param($debug_page));
if (not $pm) {
# this part redacted, since it simply displays a menu...
# end if (not $pm)
} else { # if $pm contains a value
if ($pm eq "chef") {
################################
# bc_chef TESTS
$rv .= display_module("bc_chef", "Chef");
$rv .= "<br><a name=subtests class=anchor></a><br><hr><center><tab
+le border=$BORDER cellpadding=0 cellspacing=0 class=subnavbar><tr><td
+ class=title> Cookie Tests </td></tr></table></center><hr><
+br><br>\n";
$rv .= pm::bc_chef::_tests();
} elsif ($pm eq "date") {
############
# date TESTS
$rv .= display_module("date", "Date");
$rv .= "<br><a name=subtests class=anchor></a><br><hr><center><tab
+le border=$BORDER cellpadding=0 cellspacing=0 class=subnavbar><tr><td
+ class=title> Date Tests </td></tr></table></center><hr><br
+><br>\n";
$rv .= pm::date::_tests();
} elsif ($pm eq "dir") {
############
# bc_dir TESTS
$rv .= display_module("bc_dir", "Directory");
$rv .= "<br><a name=subtests class=anchor></a><br><hr><center><tab
+le border=$BORDER cellpadding=0 cellspacing=0 class=subnavbar><tr><td
+ class=title> Dir Tests </td></tr></table></center><hr><br>
+<br>\n";
$rv .= pm::bc_dir::_tests();
} elsif ($pm eq "misc") {
############
# bc_misc TESTS
$rv .= display_module("bc_misc", "Miscellaneous");
$rv .= "<br><a name=subtests class=anchor></a><br><hr><center><tab
+le border=$BORDER cellpadding=0 cellspacing=0 class=subnavbar><tr><td
+ class=title> Misc Tests </td></tr></table></center><hr><br
+><br>\n";
$rv .= pm::bc_misc::_tests();
} elsif ($pm eq "sql") {
############
# bc_sql TESTS
$rv .= display_module("bc_sql", "SQL");
$rv .= "<br><a name=subtests class=anchor></a><br><hr><center><tab
+le border=$BORDER cellpadding=0 cellspacing=0 class=subnavbar><tr><td
+ class=title> SQL Tests </td></tr></table></center><hr><br>
+<br>\n";
$rv .= pm::bc_sql::_tests();
} elsif ($pm eq "user") {
############
# user TESTS
$rv .= display_module("user", "User");
$rv .= "<br><a name=subtests class=anchor></a><br><hr><center><tab
+le border=$BORDER cellpadding=0 cellspacing=0 class=subnavbar><tr><td
+ class=title> User Tests </td></tr></table></center><hr><br
+><br>\n";
$rv .= pm::user::_tests();
} elsif ($pm eq "html") {
############
# html TESTS
$rv .= display_module("html", "HTML");
$rv .= "<br><a name=subtests class=anchor></a><br><hr><center><tab
+le border=$BORDER cellpadding=0 cellspacing=0 class=subnavbar><tr><td
+ class=title> HTML Tests </td></tr></table></center><hr><br
+><br>\n";
$rv .= pm::html::_tests();
} elsif ($pm eq "redir") {
############
# redir TESTS
$rv .= display_module("redir", "Redirection");
$rv .= "<br><a name=subtests class=anchor></a><br><hr><center><tab
+le border=$BORDER cellpadding=0 cellspacing=0 class=subnavbar><tr><td
+ class=title> Redirection Tests </td></tr></table></center>
+<hr><br><br>\n";
$rv .= pm::redir::_tests();
} elsif ($pm eq "search") {
############
# search TESTS
$rv .= display_module("search", "Search");
$rv .= "<br><a name=subtests class=anchor></a><br><hr><center><tab
+le border=$BORDER cellpadding=0 cellspacing=0 class=subnavbar><tr><td
+ class=title> Search Tests </td></tr></table></center><hr><
+br><br>\n";
$rv .= pm::search::_tests();
} elsif ($pm eq "security") {
############
# security TESTS
$rv .= display_module("security", "Security");
$rv .= "<br><a name=subtests class=anchor></a><br><hr><center><tab
+le border=$BORDER cellpadding=0 cellspacing=0 class=subnavbar><tr><td
+ class=title> Security Tests </td></tr></table></center><hr
+><br><br>\n";
$rv .= pm::security::_tests();
} elsif ($pm eq "subdesc") {
############
# subdesc TESTS
$rv .= display_module("subdesc", "SubDesc");
$rv .= "<br><a name=subtests class=anchor></a><br><hr><center><tab
+le border=$BORDER cellpadding=0 cellspacing=0 class=subnavbar><tr><td
+ class=title> Security Tests </td></tr></table></center><hr
+><br><br>\n";
# no tests needed. "debug.pl" uses the subdesc module EVERYWHERE,
+ so it is tested and if it fails, you'll know...
#$rv .= pm::subdesc::_tests();
$rv .= "no tests performed here: debug.pl is the test!<br>\n";
} elsif ($pm eq "faq") {
$rv .= display_faq();
# no associated debugging output
} elsif ($pm eq "howto") {
$rv .= display_howto();
# no associated debugging output
} elsif ($pm eq "notes") {
$rv .= display_notes();
# no associated debugging output
} elsif ($pm eq "ppdebug") {
$rv .= display_paypal_debugger();
# no additional debugging output
} else {
$rv .= "Unrecognized module selected: $pm<br>\n";
}
# end else of if (not $pm)
}
oh! and i guess you could use a _test() function, too for the example i'm showing. hopefully i've covered it all finally...if i missed something, do let me know, i'll post it. but i gotta get this solved.
i totally get how to use a single pm. i'm wondering why i get these silly errors....
security.pm - d:/apache24/htdocs/pm/security.pm
########################
sub _tests(;$) {
#*
# to test all <i>pm::security</i> functions
#*
my ($extended) = @_; # show extended data (optional)
my $rv = "";
my $loggedin = pm::bc_chef::cookie_get("loggedin");
my $test = "";
my $test2 = "";
my $test3 = "";
my @atest = ();
my %htest = {};
my $db = sql_connect("ns.db");
if ($db) {
$rv .= pm::html::display_debug_code("get_phrase(\$db)", get_phrase
+($db));
$rv .= pm::html::display_debug_code("get_about_page(\$db)", get_ab
+out_page($db));
$rv .= pm::html::display_debug_code("get_home_page(\$db, \"\")", g
+et_home_page($db, ""));
$test = "SITE_NAME";
$rv .= pm::html::display_debug_one("get_constant(\$db, \"$test\")"
+, get_constant($db, $test));
$test = pm::bc_chef::cookie_get("loggedin");
$rv .= pm::html::display_debug_one("user_exists(\$db, \"$test\")",
+ user_exists($db, $test));
$test = "991B146AEC";
$rv .= pm::html::display_debug_one("msg_exists(\$db, \"$test\")",
+user_exists($db, $test));
$test = "31-1";
$rv .= pm::html::display_debug_one("get_city_name(\$db, \"$test\")
+", get_city_name($db, $test));
$rv .= pm::html::display_debug_one("get_country_name(\$db, \"$test
+\")", get_country_name($db, $test));
$test2 = "6132F16686";
#$test3 = "7EE22A4BBF";
$test3 = "1237EE22A4BBF";
@atest = (); push @atest, ($test2, $test3);
$test = "select * from 'ccinfo' where ID = ? and UID = ?";
$rv .= pm::html::display_debug_one("sql_execute_bound(\$db, \"$tes
+t\", \\\@values)", sql_execute_bound($db, $test, \@atest));
$test = "Canada";
$rv .= pm::html::display_debug_one("get_country_id_byName(\$db, \"
+$test\")", get_country_id_byName($db, $test));
$rv .= pm::html::display_debug_one("get_profile_views_count(\$db,
+$loggedin)", get_profile_views_count($db, $loggedin));
$rv .= pm::html::display_debug_one("ipn_exists(\$db, \"$test\")",
+ipn_exists($db, $test));
$rv .= pm::html::display_debug_one("ban_exists(\$db, \"$test\")",
+ban_exists($test));
$rv .= pm::html::display_debug_one("ccid_exists(\$db, \"$test\")",
+ ccid_exists($test));
$test = "index.pl";
$rv .= pm::html::display_debug_one("file_exists(\"$test\")", file_
+exists($test));
$test = "C8E0B9312F";
$rv .= pm::html::display_debug_one("fma_exists(\$db, \"$loggedin\"
+, \"$test\")", fma_exists($db, $loggedin, $test));
$test = 3;
$rv .= pm::html::display_debug_one("get_body_asWord(\$db, $test)",
+ get_body_asWord($db, $test));
$test = "31-20";
$rv .= pm::html::display_debug_one("get_city_id(\"$test\")", get_c
+ity_id($test));
$rv .= pm::html::display_debug_one("get_city_name(\$db, \"$test\")
+", get_city_name($db, $test));
$test = "31-20";
$rv .= pm::html::display_debug_one("get_country_id(\"$test\")", ge
+t_country_id($test));
%htest = pm::user::get_user_stats($loggedin);
$rv .= pm::html::display_debug_one("theme_exists(\$db, \"$htest{TI
+D}\")", theme_exists($db, $htest{TID}));
$rv .= pm::html::display_debug_one("get_default_theme()", get_defa
+ult_theme());
$test = 1;
$rv .= pm::html::display_debug_one("get_eye_clr_asWord(\$db, \"$te
+st\")", get_eye_clr_asWord($db, $test));
$test++;
$rv .= pm::html::display_debug_one("get_hair_clr_asWord(\$db, \"$t
+est\")", get_hair_clr_asWord($db, $test));
$test++;
$rv .= pm::html::display_debug_one("get_gender_asWord(\$db, \"$tes
+t\")", get_gender_asWord($db, $test));
$test++;
$rv .= pm::html::display_debug_one("get_height_asWord(\$db, \"$tes
+t\")", get_height_asWord($db, $test));
$test++;
$rv .= pm::html::display_debug_one("get_weight_asWord(\$db, \"$tes
+t\")", get_weight_asWord($db, $test));
$test++;
$rv .= pm::html::display_debug_one("get_orientation_asWord(\$db, \
+"$test\")", get_orientation_asWord($db, $test));
$test = "31-20";
$rv .= pm::html::display_debug_one("get_location(\$db, \"$test\")"
+, get_location($db, $test));
$rv .= pm::html::display_debug_one("get_profile_views_count(\$db,
+\"$loggedin\")", get_profile_views_count($db, $loggedin));
$test = "genders";
@atest = get_config($db, $test);
$rv .= pm::html::display_debug_many("get_config(\$db, \"$test\")",
+ \@atest, "<br>");
@atest = get_cities($db);
$rv .= pm::html::display_debug_many("get_cities(\$db)", \@atest, "
+, ", 1);
@atest = get_country_cities($db, "31");
$rv .= pm::html::display_debug_many("get_country_cities(\$db)", \@
+atest, ", ", 1);
@atest = get_zodiacs($db);
$rv .= pm::html::display_debug_many("get_zodiacs(\$db)", \@atest,
+", ", 0);
@atest = (); for (my $z = 1; $z <= 12; $z++) { push @atest, get_zo
+diac_icon($z); }
$rv .= pm::html::display_debug_many("get_zodiac_icon([1..12])", \@
+atest, "", 0);
$test = "203537B0FF";
$rv .= pm::html::display_debug_many("get_theme_data(\$db, \"$test\
+")", get_theme_data($db, $test), "<br>", 0);
$test = "select value from 'zodiacs' order by ID";
$rv .= pm::html::display_debug_many("sql_execute(\$db, \"$test\")"
+, sql_execute($db, $test), ", ");
$test = "zodiacs";
@atest = get_config($db, $test);
$rv .= pm::html::display_debug_many("get_config(\$db, \"$test\")",
+ \@atest, ", ");
@atest = get_countries($db);
$rv .= pm::html::display_debug_many("get_countries(\$db)", \@atest
+, ", ", 1);
@atest = get_errors($db);
#push @atest, $test;
#push @atest, \@atest;
$rv .= pm::html::display_debug_large("get_errors(\$db)", \@atest,
+1);
@atest = get_constants($db);
$rv .= pm::html::display_debug_large("get_constants(\$db)", \@ates
+t, 1);
sql_disconnect($db);
} else {
$rv .= "DB connection error!<br>\n";
}
return $rv; # a scalar of the results of all tests
#usage: print _tests();
}