#!/usr/bin/perl
use CGI::Carp qw( fatalsToBrowser );
use DBI;
use CGI qw/:standard/;
use strict;
use CGI::Cookie;
# Create new cookies and send them
my %cookies;
my $cartid;
my $enumerated_checks1;
my $enumerated_checks2;
############ GIMME VARS START ######################
require "../config/digiprint_configs.pl" or die("Can't require digiprint_configs.pl");
my $config_store_name = &gimme_vars(1); my $config_store_taxrate = &gimme_vars(2);
my $config_store_pickuplocation = &gimme_vars(3); my $config_store_abbrev = &gimme_vars(4);
my $config_abbrev_path = &gimme_vars(5); my $config_dbhost = &gimme_vars(6);
my $config_dbname = &gimme_vars(7); my $config_dbusername = &gimme_vars(8);
my $config_dbpassword = &gimme_vars(9); my $config_dbdriver = &gimme_vars(10);
my $config_store_filepath = &gimme_vars(11); my $config_store_httppath = &gimme_vars(12);
my $config_store_httpserver = &gimme_vars(13); my $config_store_authnet_loginid = &gimme_vars(14);
my $config_store_authnet_trankey = &gimme_vars(15); my $config_store_smtpserver = &gimme_vars(16);
my $config_store_smtpfrom = &gimme_vars(17); my $config_store_smtpusername = &gimme_vars(18);
my $config_store_smtppassword = &gimme_vars(19); my $config_store_notify = &gimme_vars(20);
my $config_store_ftpserver = &gimme_vars(21); my $config_store_ftpusername = &gimme_vars(22);
my $config_store_id = &gimme_vars(23);
############ GIMME VARS END ######################
my $funge = 0;
my $funge_type;
if ($funge = 1) {
$funge_type = "Blueprints";
} else {
$funge_type = "Pictures";
}
my $dbhost = 'localhost';
my $dbname = $config_dbname;
my $dbpassword = $config_dbpassword;
my $dbusername = 'hampt2_hpa';
#my $dbdriver = 'mysql';
########## enable / disable
my ($pecial,$toggle_enabled);
#my $dbz2 = DBI->connect("dbi:mysql:salesadmin:localhost:3306", $dbusername, $dbpassword);
#my $stz2 = $dbz2->prepare("select * from acct_clients where ID= " . $config_store_id);
#$stz2->execute();
#my $special_entry = $stz2->fetchrow_hashref();
#if($special_entry->{acct_online} != 0)
#{$pecial = 0; $toggle_enabled="images/red.gif";}
#else
$pecial = 1; #$toggle_enabled="images/green.gif";}
if ($pecial eq 0) { goto forgetit; }
########################
# initial calls
my $query = new CGI;
# LIMIT TO 40 MB
$CGI::POST_MAX = 40960;
#my $login = $query->param('name');
#my $passw = $query->param('pass');
#my $ihash = $query->param('hash');
#my $cover = $query->param('coverimg');
#my $loginstatus = &is_authorized($login,$passw);
#if ($loginstatus eq 3 || $loginstatus eq 4) {
#my $loginmarker = &files_processed(8);
#$ihash = &full_hash($login,$passw);
#}
#if ($loginstatus != 3 && $loginstatus != 4) {
#$loginstatus = &is_hashed($ihash);
#}
#if (length($ihash) < 5) {
#$ihash = &create_hash($login,$passw);
#}
#my $fullname = &full_name($ihash);
#my $job = $query->param('id');
#my $logintitle;
#my $fullid = &full_id($ihash);
#my $c_template = &client_template;
#my $p_template = &printer_template;
#my $l_template = &login_template;
my $ipage2;
my $surf_pages;
my $ipage = $query->param('page');
my $ishowall = $query->param('showall');
my $show9 = $query->param('show9');
my $template;
my $toggle_page;
if (length($ipage) < 1) {
$ipage = 1;
$toggle_page = qq{ Page ( $ipage ) }
} else {
$toggle_page = qq{ Page ( $ipage ) };
}
$ipage2 = ($ipage * 12);
my $job = $ENV{'QUERY_STRING'};
if (length($query->param('id')) > 0) {
$job = $query->param('id');
}
my $type = uc(substr($job,0,3));
my $d_template = &photostore_template($type);
my $sharelink = "http://$config_store_httppath/share/?" . uc($job);
my $also_to_add;
$job = substr($job,3,length($job) - 3);
#print $type . "." . $job;
my $mote;
my $dir;
$mote = "_hpa";
$dir = "../online/";
my $modjob = "$config_store_abbrev$job";
my $img_count = 0;
if ($ENV{'REQUEST_METHOD'} eq "GET" && (length($job) > 3) && ($job > 1332)) {
# logged a post
#if ($loginstatus eq 3 || $loginstatus eq 4) {
my $new_body;
my $new_page;
my $album_title;
my $album_description;
my $album_contents;
my $cnt3 = 0;
my $album_stuff;
my $album_cover;
my $album_owner;
my $album_owner2;
my $album_cost;
my $album_owner3;
my $count_again = 0;
my $count_xtra = 0;
my $count_page = 1;
my $count_pagez = 0;
$job = $job - 1332;
my $friggin_cart;
my $cookie1;
my $due2cart = 0;
if (&allow_buy($job) eq 1) {
%cookies = fetch CGI::Cookie;
$cartid = ( ref($cookies{'ID'}) ? $cookies{'ID'}->value : '0' );
if ($cartid eq 0) {
my ($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $DayOfYear, $IsDST) = localtime(time);
my $newyear = ($Year + 1900);
my $new_month = $Month;
my $new_day = $Day;
my $newer_month;
if ($Month eq 0) { $new_month = "00"; $newer_month = "January"; }
if ($Month eq 1) { $new_month = "01"; $newer_month = "February"; }
if ($Month eq 2) { $new_month = "02"; $newer_month = "March"; }
if ($Month eq 3) { $new_month = "03"; $newer_month = "April"; }
if ($Month eq 4) { $new_month = "04"; $newer_month = "May"; }
if ($Month eq 5) { $new_month = "05"; $newer_month = "June"; }
if ($Month eq 6) { $new_month = "06"; $newer_month = "July"; }
if ($Month eq 7) { $new_month = "07"; $newer_month = "August"; }
if ($Month eq 8) { $new_month = "08"; $newer_month = "September"; }
if ($Month eq 9) { $new_month = "09"; $newer_month = "October"; }
if ($Month eq 10) { $newer_month = "November"; }
if ($Month eq 11) { $newer_month = "December"; }
if ($Day eq 0) { $new_day = "01"; }
if ($Day eq 1) { $new_day = "01"; }
if ($Day eq 2) { $new_day = "02"; }
if ($Day eq 3) { $new_day = "03"; }
if ($Day eq 4) { $new_day = "04"; }
if ($Day eq 5) { $new_day = "05"; }
if ($Day eq 6) { $new_day = "06"; }
if ($Day eq 7) { $new_day = "07"; }
if ($Day eq 8) { $new_day = "08"; }
if ($Day eq 9) { $new_day = "09"; }
my $iDatestring = $newyear . $new_month . $new_day . $Hour . $Minute;
my $cart_id = &cart_number;
my $dbn = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $sqn = "INSERT INTO shopping_cart_public VALUES (0,'$iDatestring',$cart_id,0)";
my $stn = $dbn->prepare($sqn);
$stn->execute();
$dbn->disconnect();
my $tbh = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $tth = $tbh->prepare("select * from shopping_cart_public where created like '$iDatestring' and cart=$cart_id");
$tth->execute();
while ( my $entry = $tth->fetchrow_hashref ) {
$cartid = $entry->{'id'};
}
$cookie1 = new CGI::Cookie(-name=>'ID',-value=>$cartid);
}
$friggin_cart = &get_cart($cartid);
# define variables
#print "Content-type: text/html\n\n";
print header(-cookie=>$cookie1);
$due2cart = 1;
} else {
# define variables
print "Content-type: text/html\n\n";
$friggin_cart = '';
}
if (&real_gallery($job) eq 1 && &allow_view($job,$show9) eq 1) {
#print $job;
#if ($loginstatus eq 3) {
#$template = $c_template;
#if (length($cover) > 0 && $cover > 0) {
# my $dbrc = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
#my $sqrc = qq{ UPDATE albums SET image=$cover WHERE id=$job };
#$dbrc->do($sqrc);
#$dbrc->disconnect()
#}
my $tbh = DBI->connect("dbi:mysql:hampt2_hpa:localhost:3306", $config_dbusername, $config_dbpassword) or die "Unable to open database:\n\n$DBI::errstr\n";
my $tth = $tbh->prepare("select * from albums where id=$job");
$tth->execute();
while ( my $entry = $tth->fetchrow_hashref ) {
$album_title = $entry->{'title'};
$album_description = $entry->{'description'};
$album_cover = $entry->{'image'};
$album_owner = &user_fullname($entry->{'client'}, $type);
$album_owner2 = &user_level($entry->{'client'});
$album_owner3 = $entry->{'client'};
$album_cost = $entry->{'profit'};
#print $album_title;
}
if (length($album_title) > 1) {
#my $tbhr = DBI->connect("dbi:mysql:digiprint$mote:localhost:3306", $config_dbusername, $config_dbpassword);
my $tbhr = DBI->connect("dbi:mysql:hampt2_hpa:localhost:3306", $config_dbusername, $config_dbpassword) or die "Unable to open database:\n\n$DBI::errstr\n";
my $tthr = $tbhr->prepare("select * from saved_files where album=$job");
$tthr->execute();
while ( my $entry = $tthr->fetchrow_hashref ) {
$img_count++;
$cnt3++;
my $allow_check;
if ($album_cover eq $entry->{id}) {
$album_cover = $entry->{thumb};
}
if ($ishowall eq 1) {
if ($due2cart eq 1) {
if (&in_cart($entry->{id}, $cartid) eq 1) {
$allow_check = " {id}\" checked>";
} else {
$allow_check = " {id}\">";
}
} else {
$allow_check = "";
}
$enumerated_checks1 .= qq~
var chk$img_count = document.getElementById('img_$img_count');
chk$img_count.checked=true;
~;
$enumerated_checks2 .= qq~
var chk$img_count = document.getElementById('img_$img_count');
chk$img_count.checked=false;
~;
$album_stuff .= "
$allow_check {id}&pg=$ipage&showall=$ishowall\"> {thumb}\" border=0>" . &shorter_title($entry->{oldpath}) . " \n";
$album_stuff .= " {id}\">";
if ($cnt3 eq 3) {
$cnt3 = 0;
$album_contents .= "" . $album_stuff . " \n";
$album_stuff = '';
}
} else {
if ($img_count <= $ipage2 && $img_count >= ($ipage2 - 11)) {
$count_again++;
if ($count_again <= 12) {
if ($due2cart eq 1) {
if (&in_cart($entry->{id}, $cartid) eq 1) {
$allow_check = " {id}\" checked>";
} else {
$allow_check = " {id}\">";
}
} else {
$allow_check = "";
}
$enumerated_checks1 .= qq~
var chk$img_count = document.getElementById('img_$img_count');
chk$img_count.checked=true;
~;
$enumerated_checks2 .= qq~
var chk$img_count = document.getElementById('img_$img_count');
chk$img_count.checked=false;
~;
$album_stuff .= "$allow_check {id}&pg=$ipage&showall=$ishowall\"> {thumb}\" border=0>" . &shorter_title($entry->{oldpath}) . " \n";
$album_stuff .= " {id}\">";
} else {
$count_xtra++;
if (&in_cart($entry->{id}, $cartid) eq 1) {
$also_to_add .= " {id}\">";
}
}
} else { $count_again = 0; }
if ($cnt3 eq 3) {
$cnt3 = 0;
$album_contents .= "" . $album_stuff . " \n";
$album_stuff = '';
}
}
}
#$album_contents .= "" . $album_stuff . " \n";
if (length($album_cover) > 1) {
$album_cover = " ";
} else {
$album_cover = " ";
}
}
if ($ishowall != 1) {
#######3
my $cntxtra = 0;
my $cnt12 = 0;
while ($cntxtra < $img_count) {
$cntxtra++;
$cnt12++;
if ($cnt12 eq 12) {
$surf_pages .= qq{ $count_page };
$count_page++;
$count_pagez++;
$cnt12 = 0;
}
}
if ($cnt12 > 0 && $count_page != 1) {
$surf_pages .= qq{ $count_page };
$count_pagez++;
}
if ($count_again <= 12) {
$album_contents .= "" . $album_stuff . " \n";
}
if (length($surf_pages) > 0) {
if ($ipage eq 1 || $ipage < $count_pagez) {
$surf_pages .= " > ";
}
if ($ipage >= 2) {
$surf_pages = " < " . $surf_pages;
}
}
if ($img_count > 12) {
$surf_pages = "Show ALL Images or view: " . $surf_pages . " ";
}
} else {
if ($img_count > 12) {
$surf_pages = "Show PAGES of Images ";
}
}
my $toggle_desc = "";
if (length($album_description) > 1) {
$toggle_desc = qq~
~;
}
my $a_current_4x5;
my $a_current_4x6;
my $a_current_5x7;
my $a_current_6x8;
my $a_current_8x10;
my $a_current_8x12;
my $a_current_11x14;
my $a_current_12x18;
my $add_this_pricez;
if ($album_cost > 0) {
my $tbh = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $tth = $tbh->prepare("select * from price_templates where id=$album_cost");
$tth->execute();
#print "Content-type: text/html\n\n";
#print $a_template . " ";
#print $a_size . " ";
while ( my $entry = $tth->fetchrow_hashref ) {
$a_current_4x5 = $entry->{opt1};
$a_current_4x6 = $entry->{opt2};
$a_current_5x7 = $entry->{opt3};
$a_current_6x8 = $entry->{opt4};
$a_current_8x10 = $entry->{opt5};
$a_current_8x12 = $entry->{opt6};
$a_current_11x14 = $entry->{opt7};
$a_current_12x18 = $entry->{opt8};
}
}
my $you_level;
if (&user_level($album_owner3) eq 0) { $you_level = ""; }
if (&user_level($album_owner3) eq 2) { $you_level = "_2"; }
my $current_4x5;
my $current_4x6;
my $current_5x7;
my $current_6x8;
my $current_8x10;
my $current_8x12;
my $current_11x14;
my $current_12x18;
my $tbh1 = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $tth1 = $tbh1->prepare("select * from print_options where w=4 and l=5");
$tth1->execute();
while ( my $entry = $tth1->fetchrow_hashref ) {
$current_4x5 = $entry->{'price' . $you_level};
}
my $tbh2 = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $tth2 = $tbh2->prepare("select * from print_options where w=4 and l=6");
$tth2->execute();
while ( my $entry = $tth2->fetchrow_hashref ) {
$current_4x6 = $entry->{'price' . $you_level};
}
my $tbh3 = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $tth3 = $tbh3->prepare("select * from print_options where w=5 and l=7");
$tth3->execute();
while ( my $entry = $tth3->fetchrow_hashref ) {
$current_5x7 = $entry->{'price' . $you_level};
}
my $tbh4 = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $tth4 = $tbh4->prepare("select * from print_options where w=6 and l=8");
$tth4->execute();
while ( my $entry = $tth4->fetchrow_hashref ) {
$current_6x8 = $entry->{'price' . $you_level};
}
my $tbh5 = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $tth5 = $tbh5->prepare("select * from print_options where w=8 and l=10");
$tth5->execute();
while ( my $entry = $tth5->fetchrow_hashref ) {
$current_8x10 = $entry->{'price' . $you_level};
}
my $tbh6 = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $tth6 = $tbh6->prepare("select * from print_options where w=8 and l=12");
$tth6->execute();
while ( my $entry = $tth6->fetchrow_hashref ) {
$current_8x12 = $entry->{'price' . $you_level};
}
my $tbh7 = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $tth7 = $tbh7->prepare("select * from print_options where w=11 and l=14");
$tth7->execute();
while ( my $entry = $tth7->fetchrow_hashref ) {
$current_11x14 = $entry->{'price' . $you_level};
}
my $tbh8 = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $tth8 = $tbh8->prepare("select * from print_options where w=12 and l=18");
$tth8->execute();
while ( my $entry = $tth8->fetchrow_hashref ) {
$current_12x18 = $entry->{'price' . $you_level};
}
my $outputted;
if (($you_level eq "_2" && $a_current_4x5 > 0) || $you_level eq "") {
$a_current_4x5 = $a_current_4x5 + $current_4x5;
$outputted .= qq~
4x5 --- \$$a_current_4x5
~;
}
if (($you_level eq "_2" && $a_current_4x6 > 0) || $you_level eq "") {
$a_current_4x6 = $a_current_4x6 + $current_4x6;
$outputted .= qq~
4x6 --- \$$a_current_4x6
~;
}
if (($you_level eq "_2" && $a_current_5x7 > 0) || $you_level eq "") {
$a_current_5x7 = $a_current_5x7 + $current_5x7;
$outputted .= qq~
5x7 --- \$$a_current_5x7
~;
}
if (($you_level eq "_2" && $a_current_6x8 > 0) || $you_level eq "") {
$a_current_6x8 = $a_current_6x8 + $current_6x8;
$outputted .= qq~
6x8 --- \$$a_current_6x8
~;
}
if (($you_level eq "_2" && $a_current_8x10 > 0) || $you_level eq "") {
$a_current_8x10 = $a_current_8x10 + $current_8x10;
$outputted .= qq~
8x10 --- \$$a_current_8x10
~;
}
if (($you_level eq "_2" && $a_current_8x12 > 0) || $you_level eq "") {
$a_current_8x12 = $a_current_8x12 + $current_8x12;
$outputted .= qq~
8x12 --- \$$a_current_8x12
~;
}
if (($you_level eq "_2" && $a_current_11x14 > 0) || $you_level eq "") {
$a_current_11x14 = $a_current_11x14 + $current_11x14;
$outputted .= qq~
11x14 --- \$$a_current_11x14
~;
}
if (($you_level eq "_2" && $a_current_12x18 > 0) || $you_level eq "") {
$a_current_12x18 = $a_current_12x18 + $current_12x18;
$outputted .= qq~
12x18 --- \$$a_current_12x18
~;
}
$add_this_pricez = qq~
Album Pricing:
$outputted
~;
if (&allow_buy($job) != 1) {
$add_this_pricez = "";
}
$new_body = qq~
$toggle_desc
$surf_pages
~;
my $toggle_hangon;
if ($due2cart eq 1) {
$new_body = qq~
~;
$toggle_hangon = qq~
$friggin_cart
~;
}
my $other_shite = qq~
$add_this_pricez$toggle_page -- $img_count Images in this Album $surf_pages $toggle_hangon
~;
my $album_owner5;
if ($album_owner2 eq 2) {
$album_owner5 = qq{ $album_owner };
$album_owner = qq{ Back to Albums };
} else {
$album_owner5 = qq{ $album_owner };
$album_owner = qq{ };
}
my $album_shit = qq~
Album: $album_title
Photographer: $album_owner5
~;
$template = $d_template;
# END ALL THE FUN CODE
#$logintitle = "Logged In As: $fullname";
$template =~ s/xTITLEx/$other_shite/g;
$template =~ s/xBODYx/$new_body/g;
$template =~ s/xTITLE1x/$album_owner/g;
$template =~ s/xPAGEx/$album_shit/g;
#} else {
# NOT LOGGED IN
#if ($loginstatus eq 2) {
#$logintitle = "Incorrect Username and Password combination."
#}
#if ($loginstatus eq 1) {
#$logintitle = "No such username on file.";
#}
#$template = $d_template;
#$template =~ s/xTITLEx/Error Logging Into DigiPrints!/g;
#$template =~ s/xBODYx/$logintitle/g;
#}
} else {
#invalid gallery
$new_body = qq~
Invalid Album ID
~;
$template = $d_template;
# END ALL THE FUN CODE
#$logintitle = "Logged In As: $fullname";
$template =~ s/xTITLEx/ Invalid Album ID/g;
$template =~ s/xBODYx/$new_body/g;
$template =~ s/xTITLE1x/ /g;
$template =~ s/xPAGEx/ /g;
}
} else {
# NO LOGIN SUBMITTED - SHOW LOGIN FORM
$template = $d_template;
$template =~ s/xTITLEx/Invalid Request..../g;
$template =~ s/xTITLE1x/ERROR..../g;
$template =~ s/xBODYx/Invalid Request..../g;
$template =~ s/xPAGEx/ERROR/g;
}
#print the real results
my $checkallscript = qq~
~;
$template =~ s/<\/HEAD>/$checkallscript<\/HEAD>/g;
print $template;
forgetit:
if ($pecial eq 0) {
print "Content-type: text/html\n\n";
print " This account has been disabled.";
}
# ALL DONE #
sub is_authorized {
my $user = $_[0];
my $code = $_[1];
my $tbg = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $ttg = $tbg->prepare("select * from clients where Username LIKE '$user'");
$ttg->execute();
my $allowed = 0;
while ( my $entry = $ttg->fetchrow_hashref ) {
if ($entry->{Username} eq $user) {
if ($entry->{Password} eq $code) {
if ($entry->{Level} eq 0){
$allowed = 3;
# logged in as client
} else {
$allowed = 4;
# logged in as printer
}
} else {
$allowed = 2;
# bad pass
}
} else {
$allowed = 1;
# bad login
}
}
return $allowed;
}
sub is_hashed{
my $code = $_[0];
my $tbg = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $ttg = $tbg->prepare("select * from clients where Hash LIKE '$code'");
$ttg->execute();
my $allowed = 2;
while ( my $entry = $ttg->fetchrow_hashref ) {
if ($entry->{Level} eq 0){
$allowed = 3;
# logged in as client
} else {
$allowed = 4;
# logged in as printer
}
}
return $allowed;
}
sub full_name {
my $user = $_[0];
my $tbg = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $ttg = $tbg->prepare("select * from clients where Hash LIKE '$user'");
$ttg->execute();
my $newname = 0;
while ( my $entry = $ttg->fetchrow_hashref ) {
$newname = "$entry->{'Fullname'}";
# retrieved login
}
return $newname;
}
sub user_name {
my $user = $_[0];
my $mope = $_[0];
my $tbg = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $ttg = $tbg->prepare("select * from clients where ID=$user");
$ttg->execute();
my $newname = 0;
while ( my $entry = $ttg->fetchrow_hashref ) {
$newname = "$entry->{'Username'}";
# retrieved login
}
return $newname;
}
sub user_fullname {
my $user = $_[0];
my $mope = $_[0];
my $tbg = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $ttg = $tbg->prepare("select * from clients where ID=$user");
$ttg->execute();
my $newname = 0;
while ( my $entry = $ttg->fetchrow_hashref ) {
$newname = "$entry->{'Fullname'}";
# retrieved login
}
return $newname;
}
sub full_id {
my $user = $_[0];
my $tbg = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $ttg = $tbg->prepare("select * from clients where Hash LIKE '$user'");
$ttg->execute();
my $newname = 0;
while ( my $entry = $ttg->fetchrow_hashref ) {
$newname = "$entry->{'ID'}";
# retrieved login
}
return $newname;
}
sub user_level {
my $user = $_[0];
my $tbg = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $ttg = $tbg->prepare("select * from clients where id=$user");
$ttg->execute();
my $newname = 0;
while ( my $entry = $ttg->fetchrow_hashref ) {
$newname = "$entry->{Level}";
# retrieved login
}
return $newname;
}
sub real_gallery {
my $user = $_[0];
my $tbg = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $ttg = $tbg->prepare("select * from albums where id=$user");
$ttg->execute();
my $newname = 0;
while ( my $entry = $ttg->fetchrow_hashref ) {
$newname = 1;
# retrieved login
}
return $newname;
}
sub file_totals {
my $user = $_[0];
my $tbg = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $ttg = $tbg->prepare("select * from clients where Hash LIKE '$user'");
$ttg->execute();
my $newname = 0;
my $newername = 0;
while ( my $entry = $ttg->fetchrow_hashref ) {
$newname = $entry->{'files'};
# retrieved login
}
$newername = $newname;
$newername++;
my $dbr = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $sqr = qq{ UPDATE clients SET files=$newername WHERE Hash Like '$user' };
$dbr->do($sqr);
$dbr->disconnect();
return $newername;
}
sub files_processed {
my $typez = $_[0];
my $money = $_[1];
#typez:
#
# 1 - total clients
# 2 - total days running
# 3 - total pictures processed
# 4 - total documents processed
# 5 - total blueprints processed
# 6 - total jobs
# 7 - financial total
# 8 - logins
my $tbg = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $ttg = $tbg->prepare("select * from stats where id=$typez");
$ttg->execute();
my $newname = 0;
my $newername = 0;
while ( my $entry = $ttg->fetchrow_hashref ) {
if ($typez != 7) {
$newname = $entry->{'count'};
} else {
$newname = $entry->{'amount'};
}
# retrieved login
}
if ($typez != 7) {
$newername = $newname;
$newername++;
} else {
$newername = ($newname) + $money;
}
my $dbr = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $sqr;
if ($typez != 7) {
$sqr = qq{ UPDATE stats SET count=$newername WHERE id=$typez };
} else {
$sqr = qq{ UPDATE stats SET amount='$newername' WHERE id=$typez }
}
$dbr->do($sqr);
$dbr->disconnect();
return $newername;
}
sub full_hash {
my $user = $_[0];
my $code = $_[1];
my $tbg = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $ttg = $tbg->prepare("select * from clients where Username LIKE '$user'");
$ttg->execute();
my $newname = 0;
while ( my $entry = $ttg->fetchrow_hashref ) {
if ($entry->{Username} eq $user) {
if ($entry->{Password} eq $code) {
$newname = "$entry->{'HASH'}";
# retrieved login
} else {
$newname = 0;
# bad pass
}
} else {
$newname = 0;
# bad login
}
}
return $newname;
}
sub get_print_options {
my $thefilenum = $_[0];
my $thefile = $_[1];
my $thefilesname = $_[2];
my $oldfilename = $_[3];
my $thetype = $_[4];
my $papetype = $_[5];
my $thumbn = $_[6];
my $tbh = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $tth = $tbh->prepare("select * from print_options where availability=$thetype and medium=$papetype");
$tth->execute();
my $print_page = '';
my $print_pages = '';
if ($thetype eq 2) { $thumbn = "digiprint/img/doc.gif"; }
while ( my $entry = $tth->fetchrow_hashref ) {
my $checkboxname = $thefilenum . "_" . $entry->{id};
my $checkytwo = $checkboxname . "_1";
my $checkythree = $checkboxname . "_x";
my $checkythumb = $checkboxname . "_t";
my $lengthwidth = "$entry->{w} in. X $entry->{l} in.";
my $the_price = "\$" . $entry->{price};
$print_page = qq~
$lengthwidth
$the_price
~;
$print_pages .= $print_page;
}
return qq~
$thefile
QTY Size Price
$print_pages
~;
}
sub get_jobs {
my $tbh = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $tth = $tbh->prepare("select * from jobs where status=1");
$tth->execute();
my $job_page = '';
my $job_pages = '';
while ( my $entry = $tth->fetchrow_hashref ) {
$job_page = qq~
$entry->{client} Pages price
~;
$job_pages .= $job_page;
}
return $job_pages;
}
sub get_medium {
my $median = $_[0];
my $tbh = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $tth = $tbh->prepare("select * from print_medium where id=$median");
$tth->execute();
my $print_opt = '';
while ( my $entry = $tth->fetchrow_hashref ) {
$print_opt = "$entry->{medium}";
}
return $print_opt;
}
sub client_template {
my $tbh = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $tth = $tbh->prepare("select * from templates");
$tth->execute();
my $template_page = '';
while ( my $entry = $tth->fetchrow_hashref ) {
if ($entry->{template} eq "1") {
$template_page = "$entry->{text}";
}
}
return $template_page;
}
sub printer_template {
my $tbh = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $tth = $tbh->prepare("select * from templates");
$tth->execute();
my $template_page = '';
while ( my $entry = $tth->fetchrow_hashref ) {
if ($entry->{template} eq "2") {
$template_page = "$entry->{text}";
}
}
return $template_page;
}
sub default_template {
my $mope = $_[0];
my $tbh = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $tth = $tbh->prepare("select * from templates");
$tth->execute();
my $template_page = '';
while ( my $entry = $tth->fetchrow_hashref ) {
if ($entry->{template} eq "3") {
$template_page = "$entry->{text}";
}
}
return $template_page;
}
sub login_template {
my $tbh = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $tth = $tbh->prepare("select * from templates");
$tth->execute();
my $template_page = '';
while ( my $entry = $tth->fetchrow_hashref ) {
if ($entry->{template} eq "4") {
$template_page = "$entry->{text}";
}
}
return $template_page;
}
sub create_hash {
#
# Blowfish Encryption
#
use Crypt::CBC;
use Crypt::Blowfish;
# The Cipher Settings
my $cipher = Crypt::CBC->new({'key'=> '0xDxIxGxIxPxRxIxNxTxSx0',
'cipher' => 'Blowfish',
'iv' => '![$`2}%q',
'regenerate_key' => 0,
'padding'=> 'space',
'prepend_iv' => 0
});
#
# End
#
my $user = $_[0];
my $code = $_[1];
my $ciphertext;
my $strsize;
my $strconvert;
my $strhex;
my $hexcode;
my $test;
my $i;
my $value;
my @test;
$ciphertext = $cipher->encrypt("$user $code");
chop($ciphertext);
$strsize = length($ciphertext);
for($i = $strsize; $i >= 0; $i--)
{
$test[$i] = substr($ciphertext, $i, 1);
}
foreach $value (@test)
{
$strconvert = ord($value);
$strhex = hex($strconvert);
$hexcode = ("$hexcode" . "\x5C\x78" . "$strhex");
}
$ciphertext = substr($hexcode, 0, length($hexcode) - 3);
$ciphertext =~ s/\\//g;
return $ciphertext;
}
sub upload_buttons {
my $code = $_[0];
my $totalbuttons = qq~
~;
return $totalbuttons;
}
sub shorter_title {
# pic_id, client_id
my $item_a = $_[0];
my $t_count = 0;
my $kar;
my $kount = 0;
my $maxkount = 110;
my $new_ttl;
my @words = split(/ /, $item_a);
my $wordcount = @words;
my $word_item = 0;
my $thingy;
my $full_new_string;
while ($word_item <= $wordcount) {
$thingy = @words[$word_item];
$t_count = 0;
$kount = 0;
$kar = '';
while ($t_count <= length($thingy)) {
$kar = substr($thingy,$t_count,1);
if ($kar eq "a") { $kount = $kount + 5; }
if ($kar eq "b") { $kount = $kount + 5; }
if ($kar eq "c") { $kount = $kount + 5; }
if ($kar eq "d") { $kount = $kount + 5; }
if ($kar eq "e") { $kount = $kount + 5; }
if ($kar eq "f") { $kount = $kount + 4; }
if ($kar eq "g") { $kount = $kount + 5; }
if ($kar eq "h") { $kount = $kount + 5; }
if ($kar eq "i") { $kount = $kount + 1; }
if ($kar eq "j") { $kount = $kount + 3; }
if ($kar eq "k") { $kount = $kount + 5; }
if ($kar eq "l") { $kount = $kount + 1; }
if ($kar eq "m") { $kount = $kount + 9; }
if ($kar eq "n") { $kount = $kount + 5; }
if ($kar eq "o") { $kount = $kount + 5; }
if ($kar eq "p") { $kount = $kount + 5; }
if ($kar eq "q") { $kount = $kount + 5; }
if ($kar eq "r") { $kount = $kount + 3; }
if ($kar eq "s") { $kount = $kount + 5; }
if ($kar eq "t") { $kount = $kount + 3; }
if ($kar eq "u") { $kount = $kount + 5; }
if ($kar eq "v") { $kount = $kount + 5; }
if ($kar eq "w") { $kount = $kount + 9; }
if ($kar eq "x") { $kount = $kount + 5; }
if ($kar eq "y") { $kount = $kount + 5; }
if ($kar eq "z") { $kount = $kount + 5; }
if ($kar eq "1") { $kount = $kount + 3; }
if ($kar eq "2") { $kount = $kount + 6; }
if ($kar eq "3") { $kount = $kount + 6; }
if ($kar eq "4") { $kount = $kount + 6; }
if ($kar eq "5") { $kount = $kount + 6; }
if ($kar eq "7") { $kount = $kount + 5; }
if ($kar eq "8") { $kount = $kount + 6; }
if ($kar eq "9") { $kount = $kount + 6; }
if ($kar eq "0") { $kount = $kount + 6; }
if ($kar eq "-") { $kount = $kount + 2; }
if ($kar eq "_") { $kount = $kount + 5; }
if ($kar eq "(") { $kount = $kount + 3; }
if ($kar eq ")") { $kount = $kount + 3; }
if ($kar eq "[") { $kount = $kount + 2; }
if ($kar eq "]") { $kount = $kount + 2; }
if ($kar eq "'") { $kount = $kount + 1; }
if ($kar eq ".") { $kount = $kount + 1; }
if ($kar eq ";") { $kount = $kount + 2; }
if ($kar eq "A") { $kount = $kount + 9; }
if ($kar eq "B") { $kount = $kount + 7; }
if ($kar eq "C") { $kount = $kount + 7; }
if ($kar eq "D") { $kount = $kount + 7; }
if ($kar eq "E") { $kount = $kount + 7; }
if ($kar eq "F") { $kount = $kount + 6; }
if ($kar eq "G") { $kount = $kount + 8; }
if ($kar eq "H") { $kount = $kount + 7; }
if ($kar eq "I") { $kount = $kount + 1; }
if ($kar eq "J") { $kount = $kount + 5; }
if ($kar eq "K") { $kount = $kount + 8; }
if ($kar eq "L") { $kount = $kount + 6; }
if ($kar eq "M") { $kount = $kount + 9; }
if ($kar eq "N") { $kount = $kount + 7; }
if ($kar eq "0") { $kount = $kount + 8; }
if ($kar eq "P") { $kount = $kount + 7; }
if ($kar eq "Q") { $kount = $kount + 8; }
if ($kar eq "R") { $kount = $kount + 7; }
if ($kar eq "S") { $kount = $kount + 7; }
if ($kar eq "T") { $kount = $kount + 7; }
if ($kar eq "U") { $kount = $kount + 7; }
if ($kar eq "V") { $kount = $kount + 9; }
if ($kar eq "W") { $kount = $kount + 13; }
if ($kar eq "X") { $kount = $kount + 7; }
if ($kar eq "Y") { $kount = $kount + 7; }
if ($kar eq "Z") { $kount = $kount + 7; }
if ($kount > $maxkount) {
$new_ttl .= $kar;
$new_ttl .= " ";
#$t_count = length($thingy);
$kount = 0;
} else {
$new_ttl .= $kar;
}
$t_count++;
}
$full_new_string .= " " . $new_ttl;
$new_ttl = '';
$word_item++;
}
return $full_new_string;
}
sub get_cart {
my $code = $_[0];
my $possible = "";
my $the_count = 0;
my $the_carts = '';
my $tbh = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $tth = $tbh->prepare("select * from shopping_item_public where cart=$code");
$tth->execute();
while ( my $entry = $tth->fetchrow_hashref ) {
$the_count++;
}
$the_carts = qq{ View ($the_count) Checkout };
if (length($the_carts) > 5) {
$possible = qq{ Shopping Cart $the_carts };
}
return $possible;
}
sub get_new_cart {
my $code = $_[0];
my $possible = "";
my ($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $DayOfYear, $IsDST) = localtime(time);
my $newyear = ($Year + 1900);
my $new_month = $Month;
my $new_day = $Day;
my $newer_month;
if ($Month eq 0) { $new_month = "00"; $newer_month = "January"; }
if ($Month eq 1) { $new_month = "01"; $newer_month = "February"; }
if ($Month eq 2) { $new_month = "02"; $newer_month = "March"; }
if ($Month eq 3) { $new_month = "03"; $newer_month = "April"; }
if ($Month eq 4) { $new_month = "04"; $newer_month = "May"; }
if ($Month eq 5) { $new_month = "05"; $newer_month = "June"; }
if ($Month eq 6) { $new_month = "06"; $newer_month = "July"; }
if ($Month eq 7) { $new_month = "07"; $newer_month = "August"; }
if ($Month eq 8) { $new_month = "08"; $newer_month = "September"; }
if ($Month eq 9) { $new_month = "09"; $newer_month = "October"; }
if ($Month eq 10) { $newer_month = "November"; }
if ($Month eq 11) { $newer_month = "December"; }
if ($Day eq 0) { $new_day = "01"; }
if ($Day eq 1) { $new_day = "01"; }
if ($Day eq 2) { $new_day = "02"; }
if ($Day eq 3) { $new_day = "03"; }
if ($Day eq 4) { $new_day = "04"; }
if ($Day eq 5) { $new_day = "05"; }
if ($Day eq 6) { $new_day = "06"; }
if ($Day eq 7) { $new_day = "07"; }
if ($Day eq 8) { $new_day = "08"; }
if ($Day eq 9) { $new_day = "09"; }
my $iDatestring = $newyear . $new_month . $new_day . $Hour . $Minute;
my $cart_id = 0; #&cart_number;
my $newer_id;
my $dbn = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $sqn = "INSERT INTO shopping_cart_public VALUES (0,'$iDatestring',$cart_id,0)";
my $stn = $dbn->prepare($sqn);
$stn->execute();
$dbn->disconnect();
my $tbh = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $tth = $tbh->prepare("select * from shopping_cart_public where created like '$iDatestring' and cart=$cart_id");
$tth->execute();
while ( my $entry = $tth->fetchrow_hashref ) {
$newer_id = $entry->{'id'};
}
return $newer_id;
}
sub cart_number {
my $tbgg = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $ttgg = $tbgg->prepare("select * from public_settings where id=1");
$ttgg->execute();
my $newname = 0;
my $newername = 0;
while ( my $entry = $ttgg->fetchrow_hashref ) {
$newname = $entry->{'count'};
# retrieved login
}
$newername = $newname;
$newername++;
my $dbr = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $sqr = qq{ UPDATE public_settings SET count=$newername WHERE id=1 };
$dbr->do($sqr);
$dbr->disconnect();
return $newername;
}
sub allow_buy {
my $code = $_[0];
my $tbh = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $tth = $tbh->prepare("select * from albums where id=$code");
$tth->execute();
my $can_buy = 0;
while ( my $entry = $tth->fetchrow_hashref ) {
$can_buy = $entry->{'allow_buy'};
}
return $can_buy;
}
sub allow_view {
my $code = $_[0];
my $code2 = $_[1];
my $tbh = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $tth = $tbh->prepare("select * from albums where id=$code");
$tth->execute();
my $can_buy = 0;
while ( my $entry = $tth->fetchrow_hashref ) {
$can_buy = $entry->{'allow_view'};
}
if ($code2 eq "biuyre580jd") { $can_buy = 1; }
return $can_buy;
}
sub in_cart {
my $file = $_[0];
my $cart = $_[1];
my $tbh = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $tth = $tbh->prepare("select * from shopping_item_public where file=$file and cart=$cart");
$tth->execute();
my $can_buy = 0;
while ( my $entry = $tth->fetchrow_hashref ) {
$can_buy = 1;
}
return $can_buy;
}
sub photostore_template {
my $mope = $_[0];
my $tbh = DBI->connect("dbi:mysql:$config_dbname:localhost:3306", $config_dbusername, $config_dbpassword);
my $tth = $tbh->prepare("select * from templates");
$tth->execute();
my $template_page = '';
while ( my $entry = $tth->fetchrow_hashref ) {
if ($entry->{template} eq "6") {
$template_page = "$entry->{text}";
}
}
return $template_page;
}