package Pm::Html;
#/
# functions for displaying HTML elements
#/
my $DEBUGGER = 0;
my $TABLE_BORDER = "0";
########################
use strict;
use warnings;
use Exporter;
use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS);
use URI::Escape;
########################
use Pm::Bc_chef qw(cookie_get);
use Pm::Bc_sql qw(get_race_asWord
get_zodiacs get_themes
get_constant
get_theme_data
get_config
get_cities
get_countries
sql_execute
get_users
get_site_name
get_home_page
user_exists
get_location
get_phrase
);
use Pm::Bc_misc qw(get_param
add_numeric_suffix
shorten_str
);
use Pm::Date qw(expand_date
determine_zodiac
get_today
get_month
);
use Pm::Search qw(search_terms);
use Pm::User qw(get_user_stats
get_user_friend_requests
get_user_blocked_users
get_user_unread_messages
get_user_stat
get_user_fuck_alert_count
get_user_pic
get_user_dp
get_user_stats_asIcons
get_user_friends
);
########################
our $VERSION = 1.00;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(
_tests
pre_html_header
header
footer
table
fieldset
fieldset_constricted
div
tdata
trow
radio
checkbox
textarea
unordered_list
ordered_list
li
href
img
dropdown
input
display_404_page
display_about_page
display_chat
display_city_names
display_city_names_asDropdown
display_country_names
display_country_names_asDropdown
display_forgot_page
display_blocked
display_friends
display_fuck_me_alerts
display_homepage
display_mail
display_navbar
display_pay_page
display_photos_page
display_searchbar
display_signup_page
display_stats_page
display_theme_names
display_theme_names_asDropdown
display_titlebar
display_todays_birthdays
display_user_card
display_user_card_mini
display_user_list
display_admin_page
display_admin_ustats_editor
display_admin_uphotos_editor
display_admin_uflags_editor
display_admin_umsgs_editor
display_years_forDropdowns
display_users_forDropdowns
display_config_forDropdowns
display_zodiac_icon
display_debug_one
display_debug_many
display_debug_code
display_debug_large
get_config_forDropdowns
:debug
);
%EXPORT_TAGS = (
debug => [qw(display_debug_one display_debug_many display_debug_code display_debug_large _tests)],
);
########################
####
package Pm::Redir;
#/
# Client Redirections
#/
use strict;
use warnings;
use CGI::Carp qw(fatalsToBrowser);
use URI::Escape;
use Exporter;
use vars qw($VERSION @ISA @EXPORT_OK);
use Pm::Bc_chef qw(cookie_set);
use Pm::Html qw(display_debug_one
display_debug_many
display_debug_code
display_debug_large
pre_html_header
); # i'm not using :debug cuz that don't work either!
$VERSION = 1.00;
@ISA = qw(Exporter);
@EXPORT_OK = qw(
_tests
redir
redir3
error_redir
notice_redir
);
##############################
sub redir($$) {
#*
# redirects a client browser to a specified URL (may include a msg)
#*
my ($url, $msg) = @_; # a url to redirect to && a msg
my $html = pre_html_header();
$html =~ s/content-type\: text\/html\n\n//i;
if ($msg)
{ $html .= "status: 302 $msg\n"; } else
{ $html .= "status: 302 redir ok\n"; }
$html .= "location: $url\n\n";
return $html; # a scalar
#usage print redir("/", "invalid page");
}
##############################
sub redir3($$$) {
#*
# redirects a client browser to a specified URL (may include a msg)
# can add a cookie to the redirect (for errors or msgs or other things you deem necessary)
# this is NOT version 3 of the redir command. it's a 3 param command!
#*
my ($url, $msg, $type) = @_; # a url to redirect to && a msg && a msg type ('e' or 'n', or whatever else you like)
my $html = "";
if ($type) { $html = cookie_set($type, $msg, 0); }
my $html .= pre_html_header();
$html =~ s/content-type\: text\/html\n\n//i;
$msg = uri_escape($msg);
$html .= "status: 302 $msg\n";
$html .= "location: $url\n\n";
return $html; # a scalar
#usage: print redir3("/", "Access Denied by redir3", 'e')
}
##############################
sub error_redir($$) {
#*
# redirects a client browser to a specified URL (may include a msg)
# adds an 'error' cookie to the redirect
#*
my ($url, $msg) = @_; # a url to redirect to && a msg
my $html = redir3($url, $msg . " by?", 'e');
return $html; # a scalar
#usage: print error_redir("/subscribe.pl", "you must subscribe to access this area");
}
##############################
sub notice_redir($$) {
#*
# redirects a client browser to a specified URL (may include a msg)
# adds a 'notice' cookie to the redirect
#*
my ($url, $msg) = @_; # a url to redirect to && a msg
my $html = redir3($url, $msg, 'n');
return $html; # a scalar
#usage: print notice_redir("/', "file updated!");
}
##############################
sub _tests(;$) {
#*
# to test all Pm::Redir functions
#*
my ($extended) = @_; # show extended data (optional)
my $rv = "";
my $loggedin = cookie_get("loggedin");
my $test = "";
my $test2 = "";
my $test3 = "";
my $db = sql_connect("ns.db");
if ($db) {
$test = "/index.pl";
$test2 = "Test Redirection";
$test3 = "n";
$rv .= display_debug_code("error_redir(\"$test\", \"$test2\")", error_redir($test, $test2));
$rv .= display_debug_code("notice_redir(\"$test\", \"$test2\")", notice_redir($test, $test2));
$rv .= display_debug_code("redir(\"$test\", \"$test2\")", redir($test, $test2));
$rv .= display_debug_code("redir3(\"$test\", \"$test2\", \"$test3\")", redir3($test, $test2, $test3));
} else {
$rv .= "DB connection error!
\n";
}
return $rv; # a scalar of the results of all tests
#usage: print _tests();
}
##############################
##############################
##############################
##############################
##############################
##############################
##############################
##############################
##############################
##############################
##############################
##############################
##############################
##############################
##############################
##############################
##############################
##############################
1;