<%args> $c => 'login' $page => '1' <%flags> inherit => undef <%shared> my %IARGS; my $linesperpage = '99'; my $database ='chaliceart'; my $database_login = 'chaliceart'; my $database_pass = 'greendog11'; my $dbh; my $cookieName = 'chalice_login'; my $domainName = 'www.chaliceart.com'; my $login_info; <%init> %IARGS = %ARGS; $IARGS{'page'} = 1 if ($IARGS{page} eq ''); $dbh = DBI->connect("DBI:mysql:$database", $database_login, $database_pass) || $m->comp("error_noreturn", message => "Database name,
login, or password is incorrect."); #$m->comp("check_date_delete"); use Apache::Cookie; my %cookies = Apache::Cookie->fetch; if ($cookies{$cookieName}) { my $cookie_id = $cookies{$cookieName}->value; $login_info = $dbh->selectrow_hashref("Select * From Classified_users Where user_id = ?",undef,$cookie_id); } <& $c&> <%def default> <%def manage_menu> <%init> $m->redirect("?c=noaccess") if ($login_info->{user_type} ne 'Admin'); my $drop_time = $dbh->selectrow_array("Select config_ad_drop_time from Classified_config where config_id = 1");
%# %# %# %# %# %# %# %# %# %#
Administration
%# %#
%# %#
Back to Listing
<%def manage_users> <%init> my $data_ref; my $sth = $dbh->prepare("Select * From Classified_users where user_type != 'Admin' "); $sth->execute;
% while ($data_ref = $sth->fetchrow_hashref) { <& user_row, 'data_ref' => $data_ref&> % } % $sth->finish;
User Management
ID# Name Company Email
Back to Menu
<%def user_row> <%args> $data_ref <%init> <% $data_ref->{user_id} %> <% $data_ref->{user_name} %> <% $data_ref->{user_company} %> <% $data_ref->{user_email} %> <%def edit_user> <%init> my $data_ref = $dbh->selectrow_hashref("Select * From Classified_users where user_id = ? ",undef,$IARGS{id});
User Info
User Login:
User Pass:
Full Name:
Address:
Phone #:
Fax #:
Cell #:
Email Addres:
Company Name:


Delete this User?  
Back to Users
<%def update_user> <%init> my @valid_fields = qw| user_login_name user_password user_name user_address user_fax user_phone user_cell user_email user_company |; foreach (@valid_fields) { $dbh->do("Update Classified_users set $_ = ? where user_id = ?",undef,$IARGS{$_},$IARGS{id}); } $m->redirect("?c=manage_users"); <%def add_new_user> <%init> $dbh->do("Insert into Classified_users set user_type = 'user'"); my $last_id = $dbh->selectrow_array("Select LAST_INSERT_ID() from Classified_users"); $m->redirect("?c=edit_user&id=$last_id"); <%def delete_user> <%init> if ($IARGS{delete_check} eq $IARGS{id}) { $dbh->do("Delete from Classified_users where user_id = ?",undef,$IARGS{id}); } $m->redirect("?c=manage_users"); <%def manage_ads> <%init> my $data_ref; my $sth = $dbh->prepare("Select * From Classified_ad where ad_is_advertisement = 0 AND suspend = 0 ORDER BY ad_title"); $sth->execute; my $num_listings = $dbh->selectrow_array("Select COUNT(ad_id) from Classified_ad ad_is_advertisement = 0");
<%$num_listings%> listings in the database

%my $count =1; % while ($data_ref = $sth->fetchrow_hashref) { <& ad_row, 'data_ref' => $data_ref,'count' => $count&> % $count++; % } % $sth->finish;
Item Management
ID# Title Picture Category Enabled
Back to Menu
<%def edit_ad> <%init> my $data_ref = $dbh->selectrow_hashref("Select * From Classified_ad where ad_id = ? ",undef,$IARGS{id});
Item Info
Step 1
Fill in the Title, Description, and select the Category.
Use the Update Text button to update the fields.
This will not affect the picture uploading process, and will only update the fields mentioned above.
Title:
Description:
Category:
Image Side:
Use Keywords
URL




Step 2
This is the picture upload process.
Use the Browse button below to select the picture from your harddrive.
Use the Update Picture button below to upload the picture.
The Administrator must approve the picture each time a new one is uploaded.

Picture:
% if(!$data_ref->{ad_picture_data}) { No Picture Uploaded % } else { % }
  {ad_id}%>>



% if ($data_ref->{ad_picture_aproval} eq '') { This image has Not been approved. % } else { This image has been Approved % }       
% if ($data_ref->{ad_enabled} == 0) { This item is Disabled % } else { This item is Enabled % }       
Delete this Item?  
Back to Listing
<%def new_ad> <%init> use Date::Calc qw(:all); my $timestamp = sprintf("%04d%02d%02d",Today_and_Now()); print $timestamp; $dbh->do("Insert into Classified_ad set ad_user_id = ?, ad_date = ?, ad_enabled = ?, ad_image_side = ?",undef,$login_info->{user_id},$timestamp,1,'right'); my $last_id = $dbh->selectrow_array("Select LAST_INSERT_ID() From Classified_ad"); $m->redirect("?c=edit_ad&id=$last_id"); <%def delete_ad> <%init> if ($IARGS{delete_check} eq $IARGS{id}) { $dbh->do("Delete from Classified_ad where ad_id = ?",undef,$IARGS{id}); } $m->redirect("?c=manage_ads"); <%def delete_advertisement> <%init> if ($IARGS{delete_check} eq $IARGS{id}) { $dbh->do("Delete from Classified_ad where ad_id = ?",undef,$IARGS{id}); } $m->redirect("?c=manage_advertisements"); <%def update_ad> <%init> my @valid_fields = qw| ad_title ad_description ad_category ad_image_side ad_none_image ad_is_advertisement ad_keywords ad_url |; foreach (@valid_fields) { $dbh->do("Update Classified_ad set $_ = ? where ad_id = ?",undef,$IARGS{$_},$IARGS{id}); } $m->redirect("?c=admin_preview&id=$IARGS{id}"); <%def update_advertisement> <%init> my @valid_fields = qw| ad_title ad_description ad_category ad_image_side ad_none_image ad_is_advertisement ad_keywords ad_url ad_priority |; foreach (@valid_fields) { $dbh->do("Update Classified_ad set $_ = ? where ad_id = ?",undef,$IARGS{$_},$IARGS{id}); } $m->redirect("?c=admin_preview_advertisement&id=$IARGS{id}"); <%def admin_preview_advertisement> <%init>
<& advertisement_html, id => $IARGS{id} &>
Back to Edit
Back to Listing
<%def advertisement_html> <%args> $id <%init> my $data_ref = $dbh->selectrow_hashref("Select * from Classified_ad where ad_id = ?",undef,$id); my ($domain) = ($data_ref->{ad_url} =~ /(?:http:\/\/)?(.*?)(\/|$).*/); my $http; $http = 'http://' if ($data_ref->{ad_url} !~ /^http:\/\//i); % if ($data_ref->{ad_image_side} eq 'left') { % } % if ($data_ref->{ad_image_side} eq 'right') { % }
% if ($data_ref->{ad_picture_aproval} eq 'Yes') { % }
<%$data_ref->{ad_title}%>
<%$data_ref->{ad_description}%>
% if ($data_ref->{ad_picture_aproval} eq 'Yes') { % }
<%def ad_row> <%args> $data_ref $count <%init> <% $count %> % my $text = substr($data_ref->{ad_title},0,20); <% $text %> % if ($data_ref->{ad_picture_aproval} eq 'Yes') { Yes % } else { No %} %my $cat_name = $m->comp('get_category_name', id => $data_ref->{ad_category}); <%$cat_name%> % if ($data_ref->{ad_enabled}) { Yes % } else { No %} <%def update_drop_time> <%init> $dbh->do("Update Classified_config set config_ad_drop_time = ? where config_id = 1",undef,$IARGS{drop_time}); $m->redirect("?c=manage_menu"); <%def simple_list> <%init> my ($num_records,$sth2) = $m->comp('category_search',first_cat_id => $IARGS{cat}); my $count = 0; my $cols = 5; my $data_ref; % while ($data_ref = $sth2->fetchrow_hashref) { <%( ($count % $cols) ? "" : "")%> % $count++; <%( ($count % $cols) ? "" : "")%> % }
<&check_image_coming_soon,data_ref => $data_ref&>
<%$data_ref->{ad_title}%>
<%def listing> <%init>
% if ($login_info->{user_type} eq 'user') {
Welcome back <%$login_info->{user_name}%>.
You currently have <%$login_info->{user_listing_count}%> listings.

My Profile | My Listings | Logout

% } elsif($login_info->{user_type} eq 'Admin') {
Welcome back Administrator
Administrator Menu ·List All · Logout

% } else { % }
<%doc>  
Or list by Category
% my $cat_name = $dbh->selectrow_array("Select category_name from Classified_categories where category_id = ?",undef,$m->request_args->{cat_sort});
<%$cat_name%>

<%perl> my $count =1; my $sth2; my $num_records; if ($IARGS{keywords}) { ($num_records, $sth2) = $m->comp('keyword_search'); } else { ($num_records,$sth2) = $m->comp('category_search',first_cat_id => 1); } <%doc> %my @search_word_list = split(' ',$IARGS{keywords}); %my $where_clause; %foreach my $word (@search_word_list) { %$where_clause .= ' AND ad_keywords REGEXP "[[:<:]]'.$word.'[[:>:]]"'; %} % my $current_cat = $m->request_args->{cat_sort} || $first_cat_id; % $where_clause = " AND a.ad_category = " . $current_cat if ($IARGS{keywords} eq ''); % my $count =1; % my $startingRow = (int($IARGS{page})-1) * $linesperpage; % my $from_clause = 'Classified_ad as a '; % $first_cat_id = $m->request_args->{cat_sort} if ($m->request_args->{cat_sort}); % $from_clause .= ', Classified_connect as b '; % $where_clause .= " AND a.ad_id = b.ad_id"; % my $sth2 = $dbh->prepare("Select * from $from_clause where ad_enabled = 1 $where_clause ORDER BY end,ad_title LIMIT $startingRow,$linesperpage"); % $sth2->execute; <%doc> % if ($IARGS{cat_sort} eq '' ) { % $sth = $dbh->prepare("Select * from Classified_ad where ad_enabled = 1 $where_clause ORDER BY end,ad_title LIMIT $startingRow,$linesperpage"); % $sth->execute; % } else { % $sth = $dbh->prepare("Select * from Classified_ad where ad_category = ? AND ad_enabled = 1 $where_clause ORDER BY end,ad_title LIMIT $startingRow,$linesperpage"); % $sth->execute($IARGS{cat_sort}); % } % if (!$num_records && ($IARGS{cat_sort} ne '')) { % }
<& navigation , count => $num_records&>
% my $data_ref; % while ($data_ref = $sth2->fetchrow_hashref) { <& "listing_data", 'data_ref' => $data_ref , 'sort' => $IARGS{cat_sort}, 'count' => $count&> % $count++; % if ( ($count % 5) == 0) { % } % }
There are no entries for this category
<& navigation , count => $num_records&>
<%def listing_data> <%init>
<&check_image_coming_soon,data_ref => $ARGS{data_ref}&>
<%$ARGS{data_ref}->{ad_title}%>
<%def listing_row_image_right> <%init> my @table_colors = qw|eaeff8 FFFFFF|; my $category_name = $dbh->selectrow_array("Select category_name from Classified_categories where category_id = ?",undef,$ARGS{data_ref}->{ad_category}); >
> >
<%$ARGS{data_ref}->{ad_title}%>
<%$ARGS{data_ref}->{ad_description}%>
<%$ARGS{data_ref}->{ad_url}%>
<%def navigation> <%init> my $numRows = $ARGS{'count'}; my $prevPage = $IARGS{page}-1; my $nextPage = $IARGS{page}+1; my @pages = @{$m->comp('smart_page_count',page => $m->request_args->{page} || 1, count => $numRows, per_page => $linesperpage)};
% if (int($prevPage) >= 1) { Previous % } % if (int($nextPage) < (($numRows / $linesperpage)+1)) { Next % }
<%def manage_categories> <%init> my $data_ref; my $sth = $dbh->prepare("Select * From Classified_categories"); $sth->execute;
% while ($data_ref = $sth->fetchrow_hashref) { <& category_row, 'data_ref' => $data_ref&> % } % $sth->finish;
Category Management
ID# Name
Back to Menu
<%def category_row> <%args> $data_ref <%init> <% $data_ref->{category_id} %> <% $data_ref->{category_name} %> <%def add_new_cat> <%init> $dbh->do("Insert Into Classified_categories set category_name = ''"); my $last_id = $dbh->selectrow_array("Select LAST_INSERT_ID() from Classified_categories"); $m->redirect("?c=edit_cat&id=$last_id"); <%def edit_cat> <%init> my $data_ref = $dbh->selectrow_hashref("Select * From Classified_categories where category_id = ? ",undef,$IARGS{id});
Category Info
Category Name


Delete this Category?  
Back to Categories
<%def update_cat> <%init> my @valid_fields = qw| category_name |; foreach (@valid_fields) { $dbh->do("Update Classified_categories set $_ = ? where category_id = ?",undef,$IARGS{$_},$IARGS{id}); } $m->redirect("?c=manage_categories"); <%def delete_cat> <%init> if ($IARGS{delete_check} eq $IARGS{id}) { $dbh->do("Delete from Classified_categories where category_id = ?",undef,$IARGS{id}); } $m->redirect("?c=manage_categories"); <%def user_edit_info> <%init> my $data_ref = $dbh->selectrow_hashref("Select * From Classified_users where user_id = ? ",undef,$login_info->{user_id}); <%def update_picture_advertisement> <%init> use File::MMagic; use Image::Magick; my $IncommingImage; if ($IARGS{'pic_upload'}){ my $data = $r->upload->fh; while (<$data>) { $IncommingImage .= $_ } } else { $m->redirect("?c=no_photo"); } my $mm = File::MMagic->new(); my $thumb = Image::Magick->new(); my $image = Image::Magick->new(); $thumb->BlobToImage($IncommingImage); $image->BlobToImage($IncommingImage); my $tempHeight = $thumb->Get('height'); my $tempWidth = $thumb->Get('width'); my $imageHeight = $image->Get('height'); my $imageWidth = $image->Get('width'); #print $tempHeight; #$m->flush_buffer; #$m->abort; if ($tempHeight > 200) { #keep the image $tempWidth = $tempWidth / ($tempHeight / 200); $thumb->Resize(height => 200, width => $tempWidth); } if ($imageHeight >200) { $imageWidth = $imageWidth / ($imageHeight / 200); $image->Resize(height => 200, width => $imageWidth); } my $image_data = $image->ImageToBlob; my $thumb_data = $thumb->ImageToBlob; my $thumb_mime = $mm->checktype_contents($thumb_data); my $image_mime = $mm->checktype_contents($IncommingImage); $dbh->do("Update Classified_ad set ad_picture_data = ?, ad_picture_mime = ?, ad_thumbnail_mime = ?, ad_thumbnail_data = ?, ad_picture_aproval = ? where ad_id = ?", undef, $image_data, $image_mime, $thumb_mime, $thumb_data, 'Yes', $IARGS{id}); $m->redirect("?c=admin_preview_advertisement&id=$IARGS{id}"); <%def admin> <%init> if (!$login_info) { print "You must be logged in"; $m->flush_buffer; $m->abort; }
Personal Information
Full Name:
Address:
Phone #:
Fax #:
Cell #:
Email Addres:
Company Name:


Back to listing
<%def new_user> <%init> <%def listing_row_image_left_old> <%init> my @table_colors = qw|eaeff8 FFFFFF|; my $category_name = $dbh->selectrow_array("Select category_name from Classified_categories where category_id = ?",undef,$ARGS{data_ref}->{ad_category}); > <%def login> <& login_page &> <%def ad_list> <%init> #Get the list of ads that match this keyword my @search_word_list = split(' ',$IARGS{keywords});#$m->request_args->{keywords}); #$search_word_list[0] =~ s/'/\['\]/g; my $where_clause; $where_clause = " AND ad_category = $IARGS{cat_sort} " if ($IARGS{cat_sort}); $where_clause = " " if ($IARGS{keywords}); foreach my $word (@search_word_list) { $where_clause .= ' AND ad_keywords REGEXP "[[:<:]]'.$word.'[[:>:]]"'; } my $add_list_ref; $add_list_ref = $dbh->selectall_arrayref("Select * from Classified_ad where ad_is_advertisement = 1 AND ad_enabled = 1 $where_clause ORDER BY ad_priority DESC",{ Columns=>{}}); if ($IARGS{cat_sort}) { $add_list_ref = $dbh->selectall_arrayref("Select * from Classified_ad,Classified_connect where ad_is_advertisement = 1 AND ad_enabled = 1 AND category_id = $IARGS{cat_sort} and Classified_ad.ad_id = Classified_connect.ad_id ORDER BY ad_priority DESC",{ Columns=>{}}); } % foreach my $ad (@$add_list_ref) { <& advertisement_html, id => $ad->{ad_id} &>
%} <%def manage_advertisements> <%init> my $data_ref; my $sth = $dbh->prepare("Select * From Classified_ad where ad_is_advertisement = 1"); $sth->execute; my $num_listings = $dbh->selectrow_array("Select COUNT(ad_id) from Classified_ad where ad_is_advertisement = 1");
Login Information
Fields with * are required fields.
*User Login:   (Numbers and letters, at least 3 characters)
*User Pass:   (Numbers and letters, at least 3 characters)

Personal Information
*Full Name:
*Address:
*Phone #:
Fax #:
Cell #:
Email Addres:
Company Name:


No thanks, back to the listing.
<%def new_user_submit> <%init> my $user_login_error; my $user_password_error; my $user_name_error; my $user_address_error; my $user_phone_error; my $good_info = 1; my $data_ref = $dbh->selectrow_hashref("Select * From Classified_users where user_login_name = ? ",undef,$IARGS{user_login_name}); if ( $IARGS{user_login_name} =~ /\W/) { $user_login_error = "This login name contains invalid characters"; $good_info = 0; } if ( length($IARGS{user_login_name}) < 3) { $user_login_error = "This login name has less than 3 characters"; $good_info = 0; } if ( $data_ref->{user_login_name} ne '') { $user_login_error = "This login name is alreasy taken."; $good_info = 0; } if ( $IARGS{user_password} =~ /\W/) { $user_password_error = "This password contains invalid characters"; $good_info = 0; } if ( length($IARGS{user_password}) < 3) { $user_password_error = "This password has less than 3 characters"; $good_info = 0; } if ( $IARGS{user_name} =~ /[^A-Z,a-z,0-9,\ ]/) { $user_name_error = "Full name is not valid"; $good_info = 0; } if ( $IARGS{user_name} eq '') { $user_name_error = "Full name is required"; $good_info = 0; } if ( $IARGS{user_address} eq '') { $user_address_error = "Address is required"; $good_info = 0; } #print $IARGS{user_phone} =~ /[^0-9,\),\(,\-]/; if ( $IARGS{user_phone} =~ /[^0-9,\),\(,\-,\ ]/g) { $user_phone_error = "User phone is invalid"; $good_info = 0; } if ( $IARGS{user_phone} eq '') { $user_phone_error = "User phone is required"; $good_info = 0; } if ($good_info) { $dbh->do("Insert into Classified_users set user_type = ?, user_login_name = ?, user_password = ?, user_name = ?, user_address = ?, user_fax = ?, user_phone = ?, user_cell = ?, user_email = ?, user_company = ?", undef, 'user', $IARGS{user_login_name}, $IARGS{user_password}, $IARGS{user_name}, $IARGS{user_address}, $IARGS{user_fax}, $IARGS{user_phone}, $IARGS{user_cell}, $IARGS{user_email}, $IARGS{user_company}); my $email_address = $dbh->selectrow_array("Select config_email from Classified_config"); #print $email_address; #$m->flush_buffer; #$m->abort; use MIME::Lite; my $email = MIME::Lite->new( To => $email_address, Subject => 'New Classified User', From => 'classified@cwebcomm.com', Type => 'TEXT', Data =>" A New Classified User has created an account. Login: $IARGS{user_login_name} Pass: $IARGS{user_password} Name: $IARGS{user_name} Address: $IARGS{user_address} Fax: $IARGS{user_fax} Phone: $IARGS{user_phone} Cell: $IARGS{user_cell} Email $IARGS{user_email} Company: $IARGS{user_company} " ); #$email->delete("date"); $email->send; $m->redirect("?c=new_user_greeting"); } {ad_enabled} ? "eaeff8" :"D4D4E5") %>> <%def user_edit_ad> <%init> my $data_ref = $dbh->selectrow_hashref("Select * From Classified_ad where ad_id = ? ",undef,$IARGS{id});
Login Information
Fields with * are required fields.
*User Login:   (Numbers and letters, at least 3 characters)
<%$user_login_error%>
*User Pass:   (Numbers and letters, at least 3 characters)
<%$user_password_error%>

Personal Information
*Full Name:
<% $user_name_error %>
*Address:
<% $user_address_error%>
*Phone #:
<% $user_phone_error %>
Fax #:
Cell #:
Email Addres:
Company Name:


No thanks, back to the listing.
<%def new_user_greeting> <%init>
Registration Accepted
Your account has been created.

You may return to the Listing or Login.
<%def login_page> <%init>
Admin Login
Login:
Pass:
<%def login_submit> <%init> my $sth; my $login_ref; $sth = $dbh->prepare("Select user_id,user_login_name, user_password From Classified_users Where user_login_name=?"); $sth->execute($IARGS{'login_name'}); $login_ref = $sth->fetchrow_hashref; $sth->finish; if ( $IARGS{'login_name'} eq '') { $m->redirect("?c=badlogin"); } if ( $login_ref->{'user_login_name'} ne $IARGS{'login_name'} ){ $m->redirect("?c=badlogin"); } if ($login_ref->{'user_password'} ne $IARGS{'login_pass'}) { $m->redirect("?c=badlogin"); } #print $cookieName . "\n"; #print $login_ref->{user_id} . "\n"; #print $domainName . "\n"; #$m->flush_buffer; #$m->abort; my $cookie = Apache::Cookie->new( $r, -name => $cookieName, -value => $login_ref->{user_id}, -expires => '+100h', -domain => $domainName, -path => '/', ); $cookie->bake; $m->redirect("?c=admin"); <%def badlogin> %$m->comp("error_noreturn",message => "Your login name or pass is invalid"); <%def error_noreturn> <%args> $message => 'Error' <%init>
!
<%$message%>
%$m->flush_buffer; %$m->abort; <%def logout> <%init> my $cookie = Apache::Cookie->new( $r, -name => $cookieName, -value => -1, -expires => '-100h', -domain => $domainName, -path => '/', ); $cookie->bake; $m->redirect("?"); <%def user_update_user> <%init> my @valid_fields = qw| user_name user_address user_fax user_phone user_cell user_email user_company |; foreach (@valid_fields) { $dbh->do("Update Classified_users set $_ = ? where user_id = ?",undef,$IARGS{$_},$IARGS{id}); }
Your profile has been updated successfully.
<%def user_manage_ads> <%init> my $data_ref; my $sth = $dbh->prepare("Select * From Classified_ad where ad_user_id = ?"); $sth->execute($login_info->{user_id}); my $listings = $dbh->selectrow_array("select user_listing_count from Classified_users where user_id = ?",undef,$login_info->{user_id}); my $max_listings = $dbh->selectrow_array("select config_listing_per_user from Classified_config");
You curently have <%$listings%> of <%$max_listings%> listings.


% my $count=1; % while ($data_ref = $sth->fetchrow_hashref) { <& user_ad_row, 'data_ref' => $data_ref , 'count' => $count&> % $count++; % } % $sth->finish;
Ad Management
# Title Aproved Date Days Left

Back to listing
<%def user_ad_row> <%args> $data_ref $count <%init>
<% $count %> <% $data_ref->{ad_title} %> % if ($data_ref->{ad_picture_aproval} eq 'Yes') { Yes % } else { No %} % my ($year,$month,$day) = ($data_ref->{ad_date} =~ /(\d\d\d\d)(\d\d)(\d\d)/); <% $month %>/<% $day %>/<% $year %> <%perl> my $Dd = Delta_Days($year,$month,$day,Today); my $config_days = $dbh->selectrow_array("select config_ad_drop_time from Classified_config"); <% (($config_days - $Dd) < 0 ? "0" : ($config_days - $Dd)) %>
Ad Info
Step 1
Fill in the Title, Description, and select the Category.
Use the Update Text button to update the fields.
This will not affect the picture uploading process, and will only update the fields mentioned above.
Title:
Description:
Category:




Step 2
This is the picture upload process.
Use the Browse button below to select the picture from your harddrive.
Use the Update Picture button below to upload the picture.
The Administrator must approve the picture each time a new one is uploaded.

Picture: % if(!$data_ref->{ad_picture_data}) { No Picture Uploaded % } else { % }
  {ad_id}%>>


Delete this Ad?  
Return to My Listings
<%def user_update_ad> <%init> my @valid_fields = qw| ad_title ad_description ad_category |; foreach (@valid_fields) { $dbh->do("Update Classified_ad set $_ = ? where ad_id = ?",undef,$IARGS{$_},$IARGS{id}); } $m->redirect("?c=user_preview&id=$IARGS{id}"); <%def user_update_picture> <%init> use File::MMagic; use Image::Magick; my $IncommingImage; if ($IARGS{'pic_upload'}){ my $data = $r->upload->fh; while (<$data>) { $IncommingImage .= $_ } } else { $m->redirect("?c=no_photo"); } my $mm = File::MMagic->new(); my $thumb = Image::Magick->new(); $thumb->BlobToImage($IncommingImage); my $tempHeight = $thumb->Get('height'); my $tempWidth = $thumb->Get('width'); #print $tempHeight; #$m->flush_buffer; #$m->abort; if ($tempHeight > 100) { #keep the image $tempWidth = $tempWidth / ($tempHeight / 100); $thumb->Resize(height => 100, width => $tempWidth); } my $thumb_data = $thumb->ImageToBlob; my $thumb_mime = $mm->checktype_contents($thumb_data); my $image_mime = $mm->checktype_contents($IncommingImage); $dbh->do("Update Classified_ad set ad_picture_data = ?, ad_picture_mime = ?, ad_thumbnail_mime = ?, ad_thumbnail_data = ? where ad_id = ?", undef, $IncommingImage, $image_mime, $thumb_mime, $thumb_data, $IARGS{id}); $m->redirect("?c=user_preview&id=$IARGS{id}"); <%def get_thumbnail> <%init> my $hash_ref; my $sth = $dbh->prepare("Select ad_thumbnail_data,ad_thumbnail_mime From Classified_ad Where ad_id = ?"); $sth->execute($IARGS{'id'}); $hash_ref = $sth->fetchrow_hashref; $sth->finish; $m->clear_buffer; $r->content_type($hash_ref->{'ad_thumbnail_mime'}); $r->send_http_header; print $hash_ref->{'ad_thumbnail_data'}; $m->flush_buffer; $m->abort; <%def user_delete_ad> <%init> if ($IARGS{delete_check} eq $IARGS{id}) { $dbh->do("Delete from Classified_ad where ad_id = ? AND ad_user_id = ? ",undef,$IARGS{id},$login_info->{user_id}); $dbh->do("Update Classified_users set user_listing_count = user_listing_count -1 where user_id = ?",undef,$login_info->{user_id}); } $m->redirect("?c=user_manage_ads"); <%def update_picture> <%init> use File::MMagic; use Image::Magick; my $IncommingImage; if ($IARGS{'pic_upload'}){ my $data = $r->upload->fh; while (<$data>) { $IncommingImage .= $_ } } else { $m->redirect("?c=no_photo"); } my $mm = File::MMagic->new(); my $thumb = Image::Magick->new(); my $image = Image::Magick->new(); $thumb->BlobToImage($IncommingImage); $image->BlobToImage($IncommingImage); my $tempHeight = $thumb->Get('height'); my $tempWidth = $thumb->Get('width'); my $imageHeight = $image->Get('height'); my $imageWidth = $image->Get('width'); #print $tempHeight; #$m->flush_buffer; #$m->abort; if ($tempHeight > 72) { #keep the image $tempWidth = $tempWidth / ($tempHeight / 72); $thumb->Resize(height => 72, width => $tempWidth); } if ($imageHeight >292) { $imageWidth = $imageWidth / ($imageHeight / 292); $image->Resize(height => 292, width => $imageWidth); } my $image_data = $image->ImageToBlob; my $thumb_data = $thumb->ImageToBlob; my $thumb_mime = $mm->checktype_contents($thumb_data); my $image_mime = $mm->checktype_contents($IncommingImage); $dbh->do("Update Classified_ad set ad_picture_data = ?, ad_picture_mime = ?, ad_thumbnail_mime = ?, ad_thumbnail_data = ?, ad_picture_aproval = ? where ad_id = ?", undef, $image_data, $image_mime, $thumb_mime, $thumb_data, 'Yes', $IARGS{id}); $m->redirect("?c=admin_preview&id=$IARGS{id}"); <%def toggle_picture> <%init> my $state = $dbh->selectrow_array("Select ad_picture_aproval from Classified_ad where ad_id = ?",undef,$IARGS{id}); if ($state eq 'Yes') { $dbh->do("Update Classified_ad set ad_picture_aproval = ? where ad_id = ?", undef, '', $IARGS{id}); } else { $dbh->do("Update Classified_ad set ad_picture_aproval = ? where ad_id = ?", undef, 'Yes', $IARGS{id}); } $m->redirect("?c=edit_ad&id=$IARGS{id}"); <%def toggle_picture_advertisement> <%init> my $state = $dbh->selectrow_array("Select ad_picture_aproval from Classified_ad where ad_id = ?",undef,$IARGS{id}); if ($state eq 'Yes') { $dbh->do("Update Classified_ad set ad_picture_aproval = ? where ad_id = ?", undef, '', $IARGS{id}); } else { $dbh->do("Update Classified_ad set ad_picture_aproval = ? where ad_id = ?", undef, 'Yes', $IARGS{id}); } $m->redirect("?c=edit_advertisement&id=$IARGS{id}"); <%def toggle_enable> <%init> my $state = $dbh->selectrow_array("Select ad_enabled from Classified_ad where ad_id = ?",undef,$IARGS{id}); if ($state == 1) { $dbh->do("Update Classified_ad set ad_enabled = ? where ad_id = ?", undef, 0, $IARGS{id}); } else { $dbh->do("Update Classified_ad set ad_enabled = ? where ad_id = ?", undef, 1, $IARGS{id}); } $m->redirect("?c=edit_ad&id=$IARGS{id}"); <%def toggle_enable_advertisement> <%init> my $state = $dbh->selectrow_array("Select ad_enabled from Classified_ad where ad_id = ?",undef,$IARGS{id}); if ($state == 1) { $dbh->do("Update Classified_ad set ad_enabled = ? where ad_id = ?", undef, 0, $IARGS{id}); } else { $dbh->do("Update Classified_ad set ad_enabled = ? where ad_id = ?", undef, 1, $IARGS{id}); } $m->redirect("?c=edit_advertisement&id=$IARGS{id}"); <%def noaccess>
!
Function Denied
<%def descriptive_item_list> <%init> my $related_ids = $dbh->selectall_arrayref("Select * from Classified_related_items where rel_ad_id = ?",{Columns=>{}},$IARGS{id});
Product Detail

<& full_description, id => $IARGS{id} &> % if ($#{$related_ids} > -1) {
Related Items

% } % foreach my $id (@$related_ids) { <& full_description, id => $id->{rel_ad_related_to_id} &> % }
<%def full_description> <%init> my $data_ref = $dbh->selectrow_hashref("Select * from Classified_ad where ad_id =?",undef,$ARGS{id}); my $sku_data = $dbh->selectrow_array("Select ad_sku_colors from Classified_ad where ad_id = ?",undef,$ARGS{id}); my @lines = split("\n",$sku_data); my %product; my ($first_sku,$fist_color) = ($lines[0] =~ /([^\s]*)\s*([^\s]*)/g); foreach my $text (@lines) { my ($sku_text, $color_text) = ($text =~ /([^\s]*)\s*([^\s]*)/g); $product{$color_text} = $sku_text; }
% if ($data_ref->{ad_picture_aproval} eq 'Yes' ) { % } else { Image Coming Soon! % }
<% $data_ref->{ad_title} %>
<% $data_ref->{ad_short_description} %>
% foreach my $color (keys %product) { SKU/Item Number: <%$product{$color}%> <%$color%>
% }
$<%$data_ref->{ad_price}%>
% if ($#lines > 0) { Color % }
% $data_ref->{ad_description} =~ s/\n/
/g;
<%$data_ref->{ad_description}%>
<%def full_description_old2> <%init> my $data_ref = $dbh->selectrow_hashref("Select * from Classified_ad where ad_id =?",undef,$IARGS{id}); my $sku_data = $dbh->selectrow_array("Select ad_sku_colors from Classified_ad where ad_id = ?",undef,$IARGS{id}); my @lines = split("\n",$sku_data); my %product; my ($first_sku,$fist_color) = ($lines[0] =~ /([^\s]*)\s*([^\s]*)/g); foreach my $text (@lines) { my ($sku_text, $color_text) = ($text =~ /([^\s]*)\s*([^\s]*)/g); $product{$color_text} = $sku_text; }
Product Detail

% if ($data_ref->{ad_picture_aproval} eq 'Yes' ) { % } else { Image Coming Soon! % }
<% $data_ref->{ad_title} %>
<% $data_ref->{ad_short_description} %>
% foreach my $color (keys %product) { SKU/Item Number: <%$product{$color}%> <%$color%>
% }
$<%$data_ref->{ad_price}%>
% if ($#lines > 0) { Color % }
% $data_ref->{ad_description} =~ s/\n/
/g;
<%$data_ref->{ad_description}%>
<%def full_description_old> <%init> my $data_ref = $dbh->selectrow_hashref("Select * from Classified_ad where ad_id =?",undef,$IARGS{id});
<% $data_ref->{ad_title} %>

% $data_ref->{ad_description} =~ s/\n/
/g; <% $data_ref->{ad_description} %>
% if ($data_ref->{ad_picture_aproval} eq 'Yes' ) { % } else { % }


Back to Listings
% if ($login_info->{user_type} eq 'Admin') {



Edit This Listing
% }
<%def get_fullimage> <%init> my $hash_ref; my $sth = $dbh->prepare("Select ad_picture_data,ad_picture_mime From Classified_ad Where ad_id = ?"); $sth->execute($IARGS{'id'}); $hash_ref = $sth->fetchrow_hashref; $sth->finish; $m->clear_buffer; $r->content_type($hash_ref->{'ad_picture_mime'}); $r->send_http_header; print $hash_ref->{'ad_picture_data'}; $m->flush_buffer; $m->abort; <%def manage_misc> <%init> my $data_ref = $dbh->selectrow_hashref("Select * from Classified_config");
Config Management
Current Ad drop time is    days from posting.
Email Address:  
Maximum number of listings per user:  


Back to Menu
<%def update_config> <%init> $dbh->do("Update Classified_config set config_ad_drop_time = ?, config_email = ?, config_listing_per_user = ? where config_id = ?",undef, $IARGS{config_ad_drop_time}, $IARGS{config_email}, $IARGS{config_listing_per_user}, '1'); $m->redirect("?c=manage_misc"); <%def user_preview> <%init> my $data_ref = $dbh->selectrow_hashref("Select * from Classified_ad where ad_id =?",undef,$IARGS{id});
<% $data_ref->{ad_title} %>

% $data_ref->{ad_description} =~ s/\n/
/g; <% $data_ref->{ad_description} %>
% if ($data_ref->{ad_picture_aproval} eq 'Yes' ) { % } else { % }


Back to Edit Page
<%def no_photo> There was no photo Uploaded, please press the back button and try again. <%def admin_preview> <%init> my $data_ref = $dbh->selectrow_hashref("Select * from Classified_ad where ad_id =?",undef,$IARGS{id});
<% $data_ref->{ad_title} %>

% $data_ref->{ad_description} =~ s/\n/
/g; <% $data_ref->{ad_description} %>
% if ($data_ref->{ad_picture_aproval} eq 'Yes' ) { % } else { % }


Back to Edit Page
Back to Listing
<%def max_listings> <%init>
You have reached the Maximum number of Listings.
<%def check_date_delete> <%init> use Date::Calc qw(:all); my $timestamp = sprintf("%04d%02d%02d",Today_and_Now()); my ($last_delete_date,$config_drop) = $dbh->selectrow_array("select config_last_delete,config_ad_drop_time from Classified_config"); if ($timestamp > $last_delete_date) { my $dropdate = sprintf("%04d%02d%02d",Add_Delta_YMD(Today(),0,0,-$config_drop)); $dbh->do("Update Classified_ad set ad_enabled = 0 where ad_date < ?",undef,$dropdate); $dbh->do("Update Classified_config set config_last_delete = ?",undef,$timestamp) } <%def create_an_ad> <%init> if ($login_info->{user_type} eq 'Admin') { $m->redirect("?c=manage_ads"); } if ($login_info->{user_id} ne '') { $m->redirect("?c=user_manage_ads"); } $m->redirect("?c=new_user"); <%def no_access> Function Denied <%def check_image_coming_soon> % if ($ARGS{data_ref}->{ad_picture_aproval} eq 'Yes') { % } else { Image % } <%def form_non_color>
<%def listing_row_image_left> <%init> my @table_colors = qw|eaeff8 FFFFFF|; my $category_name = $dbh->selectrow_array("Select category_name from Classified_categories where category_id = ?",undef,$ARGS{data_ref}->{ad_category}); # # Create the SKU numbers, and color dropdown my $sku_data = $dbh->selectrow_array("Select ad_sku_colors from Classified_ad where ad_id = ?",undef,$ARGS{data_ref}->{ad_id}); my @lines = split("\n",$sku_data); my %product; my ($first_sku,$fist_color) = ($lines[0] =~ /([^\s]*)\s*([^\s]*)/g); foreach my $text (@lines) { my ($sku_text, $color_text) = ($text =~ /([^\s]*)\s*([^\s]*)/g); $product{$color_text} = $sku_text; }

<&check_image_coming_soon,data_ref => $ARGS{data_ref}&>
<%$ARGS{data_ref}->{ad_title}%>
<%$ARGS{data_ref}->{ad_short_description}%>
% foreach my $color (keys %product) { SKU/Item Number: <%$product{$color}%> <%$color%>
% }
% if ($#lines > 0) { Color
% } •   More details...
Price: $<%$ARGS{data_ref}->{ad_price}%>
>
% if ($ARGS{data_ref}->{ad_picture_aproval} eq 'Yes') { % } else { % } <%$ARGS{data_ref}->{ad_title}%>
<%$ARGS{data_ref}->{ad_description}%>
<%$num_listings%> listings in the database

%my $count =1; % while ($data_ref = $sth->fetchrow_hashref) { <& advertisement_row, 'data_ref' => $data_ref,'count' => $count&> % $count++; % } % $sth->finish;
Advertisements Management
ID# Title Picture Category Enabled
Back to Menu
<%def edit_advertisement> <%init> my $data_ref = $dbh->selectrow_hashref("Select * From Classified_ad where ad_id = ? ",undef,$IARGS{id});
Item Info
Step 1
Title:
List Description:
Description:
Image Side:
Category:
Use Keywords
URL
Priority
Highest Number Lists First




Step 2
This is the picture upload process.
Use the Browse button below to select the picture from your harddrive.
Use the Update Picture button below to upload the picture.
The Administrator must approve the picture each time a new one is uploaded.

Picture:
% if(!$data_ref->{ad_picture_data}) { No Picture Uploaded % } else { % }
  {ad_id}%>>



% if ($data_ref->{ad_picture_aproval} eq '') { This image has Not been approved. % } else { This image has been Approved % }       
% if ($data_ref->{ad_enabled} == 0) { This item is Disabled % } else { This item is Enabled % }       
Delete this Item?  
Back to Listing
<%def new_advertisement> <%init> use Date::Calc qw(:all); my $timestamp = sprintf("%04d%02d%02d",Today_and_Now()); print $timestamp; $dbh->do("Insert into Classified_ad set ad_is_advertisement = 1 ,ad_user_id = ?, ad_date = ?, ad_enabled = ?, ad_image_side = ?",undef,$login_info->{user_id},$timestamp,1,'right'); my $last_id = $dbh->selectrow_array("Select LAST_INSERT_ID() From Classified_ad"); $m->redirect("?c=edit_advertisement&id=$last_id"); <%def user_new_ad> <%init> my $listings = $dbh->selectrow_array("select user_listing_count from Classified_users where user_id = ?",undef,$login_info->{user_id}); my $max_listings = $dbh->selectrow_array("select config_listing_per_user from Classified_config"); if ($listings >= $max_listings) { $m->redirect("?c=max_listings"); } use Date::Calc qw(:all); my $timestamp = sprintf("%04d%02d%02d",Today_and_Now()); $dbh->do("Insert into Classified_ad set ad_user_id = ?, ad_date = ?, ad_enabled = 1",undef,$login_info->{user_id},$timestamp,1); $dbh->do("Update Classified_users set user_listing_count = user_listing_count +1 where user_id = ?",undef,$login_info->{user_id}); my $last_id = $dbh->selectrow_array("Select LAST_INSERT_ID() From Classified_ad"); $m->redirect("?c=user_edit_ad&id=$last_id"); <%def advertisement_row> <%args> $data_ref $count <%init>
<% $count %> % my $text = substr($data_ref->{ad_title},0,20); <% $text %> % if ($data_ref->{ad_picture_aproval} eq 'Yes') { Yes % } else { No %} %my $cat_name = $m->comp('get_category_name', id => $data_ref->{ad_category}); <%$cat_name%> % if ($data_ref->{ad_enabled}) { Yes % } else { No %}
<& admin_cat_selected &> <& admin_cat_list &> <& admin_shipping &> <& admin_email &> <& admin_ad_list&>
<%def admin_email> <%init> my $data = $dbh->selectrow_hashref("select * from Merchant");
Authorize.net Merchant Information
and Shopping Cart Information
--------Authorize.net-------------- Warning editing this information
can cause your credit card processing to not function properly!!!
Merchant Login Id
Merchant Password
Merchant Tranaction Key
Merchant Test Mode
Warning editing the above
information can cause
your credit card processing to not function properly!!!
-----------------------------------
Merchant Shopping Cart Title
Merchant Business Name
Merchant Name
Merchant Business Address
Merchant Contact Phone
Merchant Fax
Merchant Extra Phone
Merchant Receipt Description
Merchant Shopping Cart Description
Merchant Email
<%def update_merchant> <%init> foreach(keys %{$m->request_args}){ if($_ =~ /merchant/){ $dbh->do("update Merchant set $_ = ? where merchant_id = ?", undef, $m->request_args->{$_}, '1' ); } } $m->redirect("?c=admin&cat_id=".$m->request_args->{'cat_id'}); <%def admin_shipping> <%init> my $call = $ARGS{'call'}; my $options = $dbh->selectall_arrayref("select * from shipping",{ Columns=>{}}); my $count = 0;
Shipping Options
 
You must have at least one shipping method defined
or the shopping cart will not function.
 
<&'admin_shipping_'.($m->request_args->{'admin_shipping'} || 'methods')&>
 
<%def java_alert> <%def admin_shipping_add_method>
Add Shipping Method
Shipping Method
Shipping Fee
<%def admin_shipping_edit_method> <%init> my $option = $dbh->selectrow_hashref("select * from shipping where shipping_id = ?",undef,$m->request_args->{'shipping_id'});
Edit Shipping Method
Shipping Method
Shipping Fee {'price'})%>">
<%def delete_admin_shipping> <%init> $dbh->do("delete from shipping where shipping_id = ?",undef,$m->request_args->{'shipping_id'}); $m->redirect("?c=admin&cat_id=".$m->request_args->{'cat_id'}); <%def admin_shipping_input_method> <%init> #print "
";
#print Dumper(\%{$m->request_args});
#$m->flush_buffer;
#$m->abort;
my $shipping_id = $dbh->selectrow_array("select max(shipping_id) from shipping");
   $shipping_id++;
$dbh->do("insert into shipping (shipping_id,method,price) values(?,?,?)",undef,$shipping_id,$m->request_args->{'method'},$m->request_args->{'price'});
$m->redirect("?c=admin&cat_id=".$m->request_args->{'cat_id'});



<%def admin_shipping_update_method>
<%init>
$dbh->do("update shipping set
                        method = ?,
                        price = ?
                  where shipping_id = ?",
                        undef,
                        $m->request_args->{'method'},
                        $m->request_args->{'price'},
                        $m->request_args->{'shipping_id'});
$m->redirect("?c=admin&cat_id=".$m->request_args->{'cat_id'});



<%def admin_shipping_methods>
<%init>
my $options = $dbh->selectall_arrayref("select * from shipping",{ Columns=>{}});
my $count = 0;

<&java_alert&>

%foreach my $option (@$options){
% $count++;

%}
Options Method Fee
> 4Edit 4Delete > <%$option->{'method'}%> >$<%sprintf("%.2f",$option->{'price'})%>
<%def admin_cat_list> <%init> %foreach my $cat (@{$m->comp('get_category_listing')}) { %}
Category List
request_args->{cat_id} eq '' ? "class=selected" : "")%>> 4All
{category_id} eq $m->request_args->{cat_id} ? "class=selected" : "")%>> 4<%$cat->{category_name}%>
<%def admin_ad_list> <%init> my $num_listings = $dbh->selectrow_array("Select COUNT(ad_id) from Classified_ad where ad_is_advertisement = 0"); my $num_ads = $dbh->selectrow_array("Select COUNT(ad_id) from Classified_ad where ad_is_advertisement = 1"); my $total = $dbh->selectrow_array("Select COUNT(ad_id) from Classified_ad"); #my $data_ref; #my $sth = $dbh->prepare("Select * From Classified_ad where ad_is_advertisement = 0"); #$sth->execute; my $page = $m->request_args->{page} || 1; my $how_many = $m->request_args->{pp} || 25; my $from = ($page - 1) * $how_many; my $where = 'where 1 = 1 '; my %typeHash = ('listing' => ' AND ad_is_advertisement = 0','ad' => ' AND ad_is_advertisement = 1'); $where .= $typeHash{$m->request_args->{in}}; if ($m->request_args->{where} eq 'keywords') { my @search_word_list = split(' ',$m->request_args->{keywords}); foreach my $word (@search_word_list) { $where .= ' AND a.ad_keywords REGEXP "[[:<:]]'.$word.'[[:>:]]"'; } } if ($m->request_args->{where} eq 'titles') { my @search_word_list = split(' ',$m->request_args->{keywords}); foreach my $word (@search_word_list) { $where .= " AND a.ad_title LIKE '%".$word."%'"; } } if ($m->request_args->{where} eq 'ids') { $where .= ' AND a.ad_id = '.$m->request_args->{keywords}; } my $sqlfrom = 'Classified_ad as a '; if ($m->request_args->{cat_id}) { $sqlfrom .= ', Classified_connect as b'; $where .= 'AND a.ad_id = b.ad_id AND b.category_id = '.$m->request_args->{cat_id}; } my $list_ref = $dbh->selectall_arrayref("Select * From $sqlfrom $where ORDER BY end,ad_title LIMIT $from,$how_many",{Columns => {}}); #my $list_ref = $dbh->selectall_arrayref("Select * From Classified_ad $where ORDER BY end,ad_title LIMIT $from,$how_many",{Columns => {}}); my $hit_count = $dbh->selectrow_array("Select COUNT(*) From $sqlfrom $where");
<%$num_listings%> Products Listed
<& admin_nav , count => $hit_count &>
<& admin_ad_listing, list_ref => $list_ref &>
<& admin_nav , count => $hit_count&>
<%def get_category_listing> <%init> my $cats; $cats = $dbh->selectall_arrayref("Select * from Classified_categories ORDER BY category_name",{Columns=>{}}); return $cats; <%def admin_nav> <%init> my @page = @{$m->comp('smart_page_count',page => $m->request_args->{page} || '1', count => $ARGS{count}, per_page => $m->request_args->{pp} || '25')}; <%def admin_ad_listing> <%init> % my $count = 0; % foreach my $list ( @{$ARGS{list_ref}}) { % $count++; %}
ID Title Category Type Enabled Hits
> <%$list->{ad_id}%> > <%$list->{ad_title}%> > <%$m->comp('get_num_categories', id => $list->{ad_id})%> > % if ($list->{ad_is_advertisement}) { Paying %} else { %} > %if ($list->{ad_enabled}) { Yes % } else { No %} > <%$list->{ad_hit_count}%>
<%def listing_edit> <%init>
Listing Menu
Listing Info
Listing Related Items
Listing Picture
Listing Control
Listing Categories
 
Delete Listing
 
Return to Main
<& $m->request_args->{menu} || "listing_info" &>
<%def listing_rel_items> <%init> my $info = $dbh->selectrow_hashref("Select * from Classified_ad where ad_id = ?",undef,$m->request_args->{id});
Listing Related Items
Add related items to:
<%$info->{ad_title}%>
<& related_item_list &>
<%def listing_update_rel_items> <%init> my $array; if (ref ($m->request_args->{assigned_built_form}) eq '') { push(@$array, $m->request_args->{assigned_built_form}); } else { $array = $m->request_args->{assigned_built_form}; } $dbh->do("Delete from Classified_related_items where rel_ad_id = ?",undef,$m->request_args->{id}); foreach my $cat (@$array) { $dbh->do("Insert into Classified_related_items set rel_ad_id = ?, rel_ad_related_to_id = ?",undef,$m->request_args->{id},$cat); } my $id = $m->request_args->{id}; $m->redirect("?c=listing_edit&menu=listing_rel_items&id=$id"); <%def related_item_list> <%init> my $all = $dbh->selectall_arrayref("Select ad_title, ad_id from Classified_ad where ad_id <> ? ORDER BY end,ad_title",{ Columns => {}},$m->request_args->{id}); #my $used = $dbh->selectall_arrayref("Select a.category_id as category_id,a.category_name as category_name, b.ad_id as ad_id from Classified_categories as a, Classified_connect as b where b.category_id = a.category_id AND b.ad_id = ? ORDER BY category_name",{ Columns =>{}},$m->request_args->{id}); my $used = $dbh->selectall_arrayref("Select a.ad_title as ad_title, a.ad_id as ad_id from Classified_ad as a, Classified_related_items as b where a.ad_id = b.rel_ad_related_to_id AND b.rel_ad_id = ? ORDER BY a.ad_title", { Columns =>{}},$m->request_args->{id});
Related Items


Available Items
<%def listing_info> <%init> my $info = $dbh->selectrow_hashref("Select * from Classified_ad where ad_id = ?",undef,$m->request_args->{id});
Listing Info
Title <%doc>
Small Description <%doc>
Description
<&option_instructions&>
Options
Shipping
Background Color
request_args->{id}%>>
<%def option_instructions>
  1. Option input is as follows:
    Header
    Option description title | Option description | Option Price | Extra Info
    Header
    The Header should be followed by a return(a new line Character).
    Example:
    Sterling Silver
    Pendant with matching chain | Swiss Blue Topaz 16.,18",20", or 24. inch chain - write choice in box & click on buy button| 95 | 1
    Option description title:
    The title that you wish to give the option description . (will be displayed in bold)
    Example:
    Sterling Silver
    Pendant with matching chain| Swiss Blue Topaz 16.,18",20", or 24. inch chain - write choice in box & click on buy button| 95 | 1
    Option description:
    Any text excluding the program delimiters | ~ [ ]
    Example:
    Sterling Silver
    Pendant with matching chain| Swiss Blue Topaz 16.,18",20", or 24. inch chain - write choice in box & click on buy button| 95 | 1
    Option Price:
    The price of the option
    Example:
    Sterling Silver
    Pendant with matching chain| Swiss Blue Topaz 16.,18",20", or 24. inch chain - write choice in box & click on buy button| 95 | 1
    Extra Info:
    Example:
    Sterling Silver
    Pendant with matching chain| Swiss Blue Topaz 16.,18",20", or 24. inch chain - write choice in box & click on buy button| 95 | 1
    This field has 3 possible values blank, 1, or 2
    Blank = no extra info
    1 = show a text box
    2 = show a select drop-down box
    if you choose 2 on extra info you will need to set the values for your select drop-down box.
    To do this you will need to define an ARRAY
    to define an array use the characters [ ] and delimit the values inside by ,
    the values inside the array are as follows:
    [1st option value,1st option text,2nd option value,2nd option text,3rd option value,3rd option text]
    option value: is the value(price) that you want sent to cart
    option text: is the value that you want displayed in the select drop-down box
    Both must be present
    to set the default option text use the ~
    example:
    ~Choose Option~
    Default option will have a null value. If option text is omitted then the default option text will be blank.
    example:
    ~Choose Option~[201,16" $201.00,207,18" $207.00,213,20" $213.00,219,24" $219.00]
    The select drop-down box below is rendered with the above code
    example options with all elements:
    14K Yellow Gold
    Pendant | Swiss Blue Topaz | 195
    Pendant | Raspberry Garnet | 195
    | ~Choose Length~[201,16" $201.00,207,18" $207.00,213,20" $213.00,219,24" $219.00] 16.,18",20", or 24. 14K Gold chain sold separately | 6 per inch | 2
<%def get_header> <%init> use Data::Dumper; my $header = $dbh->selectrow_array("select category_name from Classified_categories where category_id = ?",undef,$IARGS{'cat'}); #print "
";
#print Dumper($header,$m->request_args);
#$m->flush_buffer;
#$m->abort;

<%$header%>


<%def categories_nav_links>
<%init>
use Data::Dumper;
my $cats = $dbh->selectall_arrayref("Select * from Classified_categories where category_id != ?ORDER BY category_name",{ Columns => {}}, $IARGS{'cat'});

#print "
";
#print Dumper(\%IARGS);
#$m->flush_buffer;
#$m->abort;

%for(0..$#$cats){
<%$cats->[$_]->{'category_name'}%>
%  if($_ != $#$cats){
 - 
%  }
%}


<%def listing_categories>
<%init>
my $all = $dbh->selectall_arrayref("Select * from Classified_categories ORDER BY category_name",{ Columns => {}});
my $used = $dbh->selectall_arrayref("Select a.category_id as category_id,a.category_name as category_name, b.ad_id as ad_id from Classified_categories as a, Classified_connect as b where b.category_id = a.category_id AND b.ad_id = ? ORDER BY category_name",{ Columns =>{}},$m->request_args->{id});




Categories
Avaliable


Assigned
<%def listing_pic> <%init> my $info = $dbh->selectrow_hashref("Select * from Classified_ad where ad_id = ?",undef,$m->request_args->{id});
Logo
% if(!$info->{ad_picture_data}) { No Picture Uploaded % } else { % }
Image Side
<%def listing_enable> <%init> my $info = $dbh->selectrow_hashref("Select * from Classified_ad where ad_id = ?",undef,$m->request_args->{id});
Control
This listing is:
{ad_enabled} eq '1' ? "checked='checked'" : "")%>>Enabled
{ad_enabled} eq '0' ? "checked='checked'" : "")%>>Disabled
<%def get_category_name> <%init> my $cat_name = ''; $cat_name = $dbh->selectrow_array("Select category_name from Classified_categories where category_id = ?",undef,$ARGS{id}); return $cat_name; <%def smart_page_count> <%init> use POSIX qw(ceil floor); my @page; $page[0] = '1'; $page[1] = $ARGS{page} - 1; $page[1] = '' if ($page[1] < 2); $page[2] = $ARGS{page}; $page[3] = $ARGS{page} + 1; $page[3] = '' if ( $page[3] > ( ceil($ARGS{count} / $ARGS{per_page} ) ) ); $page[4] = ceil($ARGS{count} / $ARGS{per_page}); return \@page; <%def listing_preview> <%init> my $data_ref = $dbh->selectrow_hashref("Select * from Classified_ad where ad_id =?",undef,$m->request_args->{id});
<% $data_ref->{ad_title} %>

% $data_ref->{ad_description} =~ s/\n/
/g;  <% $data_ref->{ad_description} %>
% if ($data_ref->{ad_picture_aproval} eq 'Yes' ) { % } else {   % }


<%def update_listing_info> <%init> #print "
";
#print Dumper(\%{$m->request_args});
#$m->flush_buffer;
#$m->abort;
my $id = $m->request_args->{id};
my $redirect_url = '?c=listing_edit&menu=listing_info&id='.$id;
$dbh->do("update Classified_ad set
                        ad_background_color=?,
                        ad_description=?,
                        ad_title=?,
                        ad_short_description=?,
                        ad_shipping=?,
                        ad_sku_colors=?
                 where  ad_id=?",
                        undef,
                        $m->request_args->{'f_ad_background_color'},
                        $m->request_args->{'f_ad_description'},
                        $m->request_args->{'f_ad_title'},
                        $m->request_args->{'f_ad_short_description'},
                        $m->request_args->{'f_ad_shipping'},
                        $m->request_args->{'f_ad_sku_colors'},
                        $m->request_args->{id}) || die($dbh->errstr);


#foreach my $name( keys %IARGS) {
#if ($name =~ /^f_/) {
#print Dumper($name);
#my ($column) = ( $name =~ /^f_(.*)/ );
##$dbh->do("Update Classified_ad set $column = ? where ad_id = ?",undef,$m->request_args->{$name},$m->request_args->{id});# if($column ne 'ad_sku_colors');
#}
#}
#print "hi";
#print Dumper(\%{$m->request_args});
#$m->flush_buffer;
#$m->abort;
#print "
";
#print Dumper($redirect_url);
#$m->flush_buffer;
#$m->abort;
#$m->clear_buffer;
#$m->redirect('www.yahoo.com');#$redirect_url);







<%def listing_update_picture>
<%init>
use File::MMagic;
use Image::Magick;


my $IncommingImage;

$m->comp('listing_image_side_only') if (!$m->request_args->{'pic_upload'});
my $data = $r->upload->fh;
while (<$data>) { $IncommingImage .= $_ }


my $mm = File::MMagic->new();
my $thumb = Image::Magick->new();
my $image = Image::Magick->new();

$thumb->BlobToImage($IncommingImage);
$image->BlobToImage($IncommingImage);

my $tempHeight = $thumb->Get('height');
my $tempWidth  = $thumb->Get('width');

my $imageHeight = $image->Get('height');
my $imageWidth  = $image->Get('width');

#print $tempHeight;
#$m->flush_buffer;
#$m->abort;

if ($tempHeight > 72) {
#keep the image

$tempWidth = $tempWidth / ($tempHeight / 72);
$thumb->Resize(height => 72, width => $tempWidth);
}


if ($imageHeight >292) {

$imageWidth = $imageWidth / ($imageHeight / 292);
$image->Resize(height => 292, width => $imageWidth);

}
my $image_data = $image->ImageToBlob;
my $thumb_data = $thumb->ImageToBlob;
my $thumb_mime = $mm->checktype_contents($thumb_data);
my $image_mime = $mm->checktype_contents($IncommingImage);



$dbh->do("Update Classified_ad set
ad_picture_data = ?,
ad_picture_mime = ?,
ad_thumbnail_mime = ?,
ad_thumbnail_data = ?,
ad_picture_aproval = ?,
ad_image_side = ?
where
ad_id = ?", undef,
$image_data,
$image_mime,
$thumb_mime,
$thumb_data,
'Yes',
$m->request_args->{ad_image_side},
$m->request_args->{id});

my $id = $m->request_args->{id};
$m->redirect("?c=listing_edit&menu=listing_pic&id=$id");




<%def listing_image_side_only>
<%init>
$dbh->do("Update Classified_ad set
ad_image_side = ?
where
ad_id = ?", undef,

$m->request_args->{ad_image_side},
$m->request_args->{id});

my $id = $m->request_args->{id};
$m->redirect("?c=listing_edit&menu=listing_pic&id=$id");



<%def remove_picture>
<%init>
$dbh->do("Update Classified_ad set
ad_picture_data = ?,
ad_picture_mime = ?,
ad_thumbnail_mime = ?,
ad_thumbnail_data = ?,
ad_picture_aproval = ?
where
ad_id = ?", undef,
'',
'',
'',
'',
'No',
$m->request_args->{id});

my $id = $m->request_args->{id};
$m->redirect("?c=listing_edit&menu=listing_pic&id=$id");





<%def listing_update_enabled>
<%init>
$dbh->do("Update Classified_ad set
ad_enabled = ?
where
ad_id = ?", undef,
$m->request_args->{ad_enabled},
$m->request_args->{id});

my $id = $m->request_args->{id};
$m->redirect("?c=listing_edit&menu=listing_enable&id=$id");




<%def listing_update_categories>
<%init>

my $array;
if (ref ($m->request_args->{assigned_built_form}) eq '') {
push(@$array, $m->request_args->{assigned_built_form});
} else {
$array = $m->request_args->{assigned_built_form};
}
$dbh->do("Delete from Classified_connect where ad_id = ?",undef,$m->request_args->{id});
foreach my $cat (@$array) {
$dbh->do("Insert into Classified_connect set ad_id = ?, category_id = ?",undef,$m->request_args->{id},$cat);
}
my $id = $m->request_args->{id};
$m->redirect("?c=listing_edit&menu=listing_categories&id=$id");





<%def listing_delete>
<%init>
my $info = $dbh->selectrow_hashref("Select * from Classified_ad where ad_id = ?",undef,$m->request_args->{id});

Deletion
Delete This listing?
 
<%def get_num_categories> <%init> my $num = 0; $num = $dbh->selectrow_array("Select COUNT(ad_id) from Classified_connect where ad_id = ?",undef, $ARGS{id}); if ($num == 1) { return 'in '.$num." category"; } else { return 'in '.$num." categories"; } <%def delete_listing> <%init> $dbh->do("Delete from Classified_connect where ad_id = ?",undef,$m->request_args->{id}); $dbh->do("Delete from Classified_ad where ad_id = ?",undef,$m->request_args->{id}); $m->redirect("?c=admin"); <%def add_category> <%init> $dbh->do("Insert into Classified_categories set category_name = ?",undef,$m->request_args->{cat_name}); $m->redirect("?c=admin"); <%def admin_cat_selected> <%init> my $info = $dbh->selectrow_hashref("Select * from Classified_categories where category_id = ?",undef,$m->request_args->{cat_id}); % if ($m->request_args->{cat_id}) {
Selected Category

%} <%def edit_category> <%init> $dbh->do("Update Classified_categories set category_name = ? where category_id = ?",undef,$m->request_args->{cat_name},$m->request_args->{id}); $m->redirect("?c=admin&cat_id=".$m->request_args->{id}); <%def delete_category> <%init> $dbh->do("Delete From Classified_categories where category_id = ?",undef,$m->request_args->{id}); $dbh->do("Delete From Classified_connect where category_id = ?",undef,$m->request_args->{id}); $m->redirect("?c=admin"); <%def new_listing> <%init> $dbh->do("Insert into Classified_ad set ad_enabled = ?",undef,1); my $last_id = $dbh->selectrow_array("Select LAST_INSERT_ID() From Classified_ad"); $m->redirect("?c=listing_edit&id=$last_id"); <%def do_category_switch> <%init> my $all = $dbh->selectall_arrayref("Select ad_id, ad_category from Classified_ad",{Columns=>{}}); foreach my $bill (@$all) { $dbh->do("Insert into Classified_connect set ad_id = ?, category_id = ?",undef,$bill->{ad_id},$bill->{ad_category}); } <%def keyword_search> <%init> my @search_word_list = split(' ',$m->request_args->{keywords}); my $where_clause; foreach my $word (@search_word_list) { $where_clause .= ' AND ad_keywords REGEXP "[[:<:]]'.$word.'[[:>:]]"'; } my $startingRow = (int($IARGS{page})-1) * $linesperpage; my $from_clause = 'Classified_ad as a '; my $sth2 = $dbh->prepare("Select * from $from_clause where ad_enabled = 1 $where_clause ORDER BY end,ad_title LIMIT $startingRow,$linesperpage"); $sth2->execute; my $num_records = $dbh->selectrow_array("Select COUNT(*) from $from_clause where ad_enabled = 1 $where_clause"); return ($num_records,$sth2); <%def category_search> <%init> my $current_cat = $m->request_args->{cat_sort} || $ARGS{first_cat_id}; my $where_clause = " AND b.category_id = " . $current_cat; my $startingRow = (int($IARGS{page})-1) * $linesperpage; my $from_clause = 'Classified_ad as a , Classified_connect as b'; $where_clause .= " AND a.ad_id = b.ad_id"; my $sth2 = $dbh->prepare("Select * from $from_clause where ad_enabled = 1 $where_clause ORDER BY end,ad_title LIMIT $startingRow,$linesperpage"); $sth2->execute; my $num_records = $dbh->selectrow_array("Select COUNT(*) from $from_clause where ad_enabled = 1 $where_clause"); return ($num_records,$sth2); <%def listall> <%init> my $sth2 = $dbh->prepare("Select * from Classified_ad where ad_enabled = 1 ORDER BY end,ad_title"); $sth2->execute(); my $data_ref; my $count = 0;
This listing may take a while to load.
Back to main listing
% while ($data_ref = $sth2->fetchrow_hashref) { <& "listing_row_all", 'data_ref' => $data_ref, 'count' => $count&> % $count++; % }
<%$count%> total records.
<%def listing_row_all> <%init> my @table_colors = qw|eaeff8 FFFFFF|; my $category_name = $dbh->selectrow_array("Select category_name from Classified_categories where category_id = ?",undef,$ARGS{data_ref}->{ad_category}); my $http = $ARGS{data_ref}->{ad_url}; $http = "http://".$http if ($ARGS{data_ref}->{ad_url} !~ /^http:\/\//i); >
> >
<%$ARGS{data_ref}->{ad_title}%>
<%$ARGS{data_ref}->{ad_description}%>
<%$ARGS{data_ref}->{ad_url}%>
<%def hit_count> <%init> my $redirect = $dbh->selectrow_array("Select ad_url from Classified_ad where ad_id = ?",undef,$m->request_args->{id}); $dbh->do("Update Classified_ad set ad_hit_count = ad_hit_count + 1 where ad_id = ?",undef,$m->request_args->{id}); my $lowerc = lc($redirect); if ($lowerc !~ /^http:\/\//) { $redirect = 'http://'.$redirect; } $m->redirect($redirect);