#!/usr/local/bin/perl # The line above MUST point to the location of Perl 5 on your server if # you are running this program on a Unix server. Windows NT users can # almost always ignore this line. ##################################################################### # # e-Classifieds(TM) Standard Edition # Version 2.3 # Last Modified 1/1/2002 # Copyright © Hagen Software Inc. All rights reserved. # # By purchasing, installing, copying, downloading, accessing or otherwise # using the SOFTWARE PRODUCT, or by viewing, copying, creating derivative # works from, appropriating, or otherwise altering all or any part of its # source code (including this notice), you agree to be bound by the terms # of the EULA that accompanied this product, as amended from time to time # by Hagen Software Inc. The EULA can also be viewed online at # "http://www.e-classifieds.net/support/license.html" # # As explained in the EULA, Hagen Software offers absolutely # no warranties on this product, which is sold and/or distributed # "as is". You, and not Hagen Software, assume all risks # associated with using this product, including but not limited # to the risk of failure of the product to install or to operate # successfully on your server, and responsibility for all content # created by users of this product. # # This product, including all source code, is copyrighted by # Hagen Software, and it is protected under both United States law # and international laws and treaties. You may not redistribute this # software, in whole or any part thereof, or use any part of the source # code contained within this software to create derivative works, # without the prior express written consent of Hagen Software. # Nor may you remove any of the copyright notices contained # either within the source code or on the HTML pages generated # by the program. Doing so constitutes a criminal offense # punishable by imprisonment. # We prosecute all violators via both civil legal actions and in # cooperation with U.S. and international criminal authorities. # YOU HAVE BEEN WARNED! # # The Hagen Software web site is located at the following URL: # http://www.hagensoftware.com # ##################################################################### unless ($noheader eq "on") { print "Content-type: text/html\n\n"; } $os = $^O; if (($os eq "MSWin32") || ($os eq "Windows_NT") || ($os =~ /win/i)) { $os = "nt"; } else { $os = "unix"; } ####################################################################### # Path Variable # ####################################################################### unless ($path) { $path = $0; $path =~ s/\\\\/\\/g; $path =~ s/\\/\//g; $path =~ s/(\/)(\w*)(\.*)(\w+)$//g; unless ($path =~ /\//) { if ($os eq "unix") { $path = `pwd`; } } unless ($path =~ /\//) { $path = $ENV{'SCRIPT_FILENAME'}; $path =~ s/\\\\/\\/g; $path =~ s/\\/\//g; $path =~ s/(\/)(\w*)(\.*)(\w+)$//g; } $path =~ s/ //g; $path =~ s/\n//g; # $path = "/usr/www/users/you/cgi-bin/classifieds"; unless ($path =~ /\//) { &path_error; } } # The program attempts to get the full internal server path to the top-level # classifieds directory on your system using the code above. This should work # on most systems, but it may not work on a few systems or if you have changed # the name of the main file to something other than classifieds.cgi or # classifieds.pl. In such cases, you will need to manually override the # $path variable obtained by the program. To do so, you will need to # uncomment the line above (by removing the # symbol from in front of it) # that looks like this (do NOT uncomment the line below): # $path = "/usr/www/users/you/cgi-bin/classifieds"; # You will then replace "/usr/www/users/you/cgi-bin/classifieds" with the # actual full internal server path to the "classifieds" directory that you # created under your cgi-bin, and where you are placing the classifieds.cgi file. # If you don't know the value for the full internal server path to the # classifieds program, you will need to get this information from your # web hosting company or your server administrator. You may also be able to # get this information by logging onto your site via Telnet, changing # directories until you are in the directory where the classifieds program # is located, and then typing "pwd", which should display the current # directory. It will look something like # "/usr/www/users/you/cgi-bin/classifieds" for Unix users or # "d:/InetPub/wwwroot/cgi-bin/classifieds" for Windows NT users. These are merely # examples, of course, and your actual directory will be different. Also, # do NOT add the trailing slash, as this will be done by the program. # End of user-configurable variables. ####################################################################### # Read and Parse Form Data # ####################################################################### &require_supporting_libraries (__FILE__, __LINE__, "$path/config/systemvar.cfg", "$path/classifieds.cfg", "$path/config/generalvar.cfg", "$path/config/stylevar.cfg", "$path/library/cgi-lib.pl", "$path/html/main-html.pl", "$path/library/date.pl"); @bad_user_names = split (/&&/, $bad_user_names); @caption_headers = split (/&&/, $caption_headers); @ad_duration = split (/&&/, $ad_duration); @blocked_ip_addresses = split (/&&/, $blocked_ip_addresses); @badwords = split (/&&/, $badwords); @images = split (/&&/, $images); @urls = split (/&&/, $urls); @alt = split (/&&/, $alt); @autonotify_duration = split (/&&/, $autonotify_duration); @states = split (/&&/, $states); sub require_supporting_libraries { local ($file, $line, @require_files) = @_; local ($require_file); foreach $require_file (@require_files) { if (-e "$require_file" && -r "$require_file") { require "$require_file"; } else { $required_file_error_message = "We're sorry, but the script was unable to require $require_file at line $line in $file. Please make sure that these files exist, that you have the path set correctly, and that the permissions are set properly. This message could also indicate that a syntax error has been introduced into $require_file."; print "$required_file_error_message"; exit; } } } sub send_mail { if ($disable_email) { return 1; } $mail_lib = "$mail_program.pl"; &require_supporting_libraries (__FILE__, __LINE__, "$path/library/$mail_lib"); &send_message; } &ReadParse(*form_data); &get_os; if ($form_data{'session_key'} ne "") { $session_key = $form_data{'session_key'}; } if ($form_data{'category'}) { $category_link = $form_data{'category'}; $category_link =~ s/\+/ /g; $category_link =~ s/ampersand/&/g; $category_link =~ s/equalsign/=/g; open (DATABASE, "$category_file_path") || &file_open_error ("$category_file_path", "Get Category Info", __FILE__, __LINE__); while () { $line = $_; chop $line; @fields = split (/\|/, $line); if ($category_link eq $fields[1]) { $category = $form_data{'category'}; $category_shortname = $fields[0]; last; } } close (DATABASE); } sub get_required_files { unless ($footer =~ /Powered by e-Classifieds.net. Copyright © 1995-2003 Hagen Software Inc. All rights reserved./) { exit; } } sub check_ip_kill { $kill=off; foreach $blocked_ip_address (@blocked_ip_addresses) { if ($ENV{'REMOTE_ADDR'} =~ /$blocked_ip_address/gi) { $kill="on"; last; } } if ($kill eq "on") { &kill_error; } } sub check_user_kill { $kill=off; foreach $bad_user_name (@bad_user_names) { if ($in{'auth_user_name'} eq $bad_user_name) { $kill="on"; last; } } if ($kill eq "on") { &kill_user_error; } } sub check_badwords { $badwords=off; @check_fields = ("name", "street", "city", "state", "zip", "country", "phone", "email", "url", "caption", "text", "caption_header"); foreach $badword (@badwords) { foreach $check_field (@check_fields) { if ($form_data{$check_field} =~ /$badword/gi) { $badwords="on"; $form_data{$check_field} =~ s/($badword)/$1<\/B>/gi; } } } if ($badwords eq "on") { &badwords_error; } } sub check_html { unless ($allow_html eq "on") { $form_data{'text'} =~ s/<([^>]|\n)*>//g; } } unless ((-e "$path/config/install.dat") || ($form_data{'systemvar_popup_help'})) { $noncgidir = "http://www.e-classifieds.net/demos/standard"; $graphics_dir = "$noncgidir/graphics"; if ($form_data{'install_admin_form'}) { &require_supporting_libraries (__FILE__, __LINE__, "$path/html/install_admin_form.pl"); &install_admin_form; exit; } elsif ($form_data{'install_decline_button'}) { &require_supporting_libraries (__FILE__, __LINE__, "$path/html/install_decline_button.pl"); &install_decline_button; exit; } elsif ($form_data{'install_admin_reg'}) { &require_supporting_libraries (__FILE__, __LINE__, "$path/html/install_admin_reg.pl"); &install_admin_reg; exit; } elsif ($form_data{'install_set_systemvar'}) { &require_supporting_libraries (__FILE__, __LINE__, "$path/html/install_set_systemvar.pl"); &install_set_systemvar; exit; } elsif ($form_data{'install_system_tests'}) { &require_supporting_libraries (__FILE__, __LINE__, "$path/html/install_system_tests.pl"); &install_system_tests; exit; } elsif ($form_data{'install_create_files'}) { &require_supporting_libraries (__FILE__, __LINE__, "$path/html/install_create_files.pl"); &install_create_files; exit; } elsif ($form_data{'install_url_test'}) { &require_supporting_libraries (__FILE__, __LINE__, "$path/html/install_url_test.pl"); &install_url_test; exit; } else { &require_supporting_libraries (__FILE__, __LINE__, "$path/html/install_welcome.pl"); &install_welcome; exit; } } ##################################### # First, we need to account for possible situations where the # search_and_display_for_modification_button or # search_and_display_for_deletion_button fields have come in with the # display_modification_form_button or submit_deletion_button fields. In # these cases, we strip out the "search_and_display..." values. if (($form_data{'search_and_display_for_deletion_button'} ne "") && ($form_data{'submit_deletion_button'} ne "")) { $form_data{'search_and_display_for_deletion_button'} = ""; } # Now we go through the main logic of the program. if ($form_data{'place_ad'} ne "") { &authentication; $helptopic = "place_ads"; &pagesetup("Post Classified Ad Form"); &generic_form_header; &require_supporting_libraries (__FILE__, __LINE__, "$path/html/place_ad_frontpage.pl"); &place_ad_frontpage; &pageclose; exit; } elsif ($form_data{'add_item_button'} ne "") { &authentication; $helptopic = "place_ads"; &pagesetup("Post Classified Ad Form"); &generic_form_header; &add_form_header; &require_supporting_libraries (__FILE__, __LINE__, "$path/html/post_item_form.pl"); &post_item_form; &add_form_footer; &pageclose; exit; } elsif ($form_data{'preview_ad_button'} ne "") { &authentication; $helptopic = "place_ads"; &require_supporting_libraries (__FILE__, __LINE__, "$path/library/display_preview_ad.pl"); &display_preview_ad; exit; } elsif ($form_data{'submit_addition'} ne "") { &authentication; &check_ip_kill; &check_badwords; &check_html; &require_supporting_libraries (__FILE__, __LINE__, "$path/library/submit_addition.pl"); &submit_addition; &update_registration_info; exit; } if ($form_data{'edit_ad'} ne "") { &authentication; &pagesetup("Edit Classified Ad"); &generic_form_header; &edit_ad_frontpage; &pageclose; exit; } elsif ($form_data{'modify_item_button'} ne "") { &authentication; $helptopic = "modify_ads"; &require_supporting_libraries (__FILE__, __LINE__, "$path/html/modify_search_form.pl"); &modify_search_form; exit; } elsif ($form_data{'display_modification_form_button'} ne "") { &authentication; $helptopic = "modify_ads"; &display_modification_form; exit; } elsif ($form_data{'submit_modification_button'} ne "") { &authentication; &check_badwords; &check_html; &require_supporting_libraries (__FILE__, __LINE__, "$path/library/submit_modification.pl"); &submit_modification; &update_registration_info; exit; } elsif ($form_data{'delete_item_button'} ne "") { &authentication; $helptopic = "delete_ads"; &require_supporting_libraries (__FILE__, __LINE__, "$path/html/delete_search_form.pl"); &delete_search_form; exit; } elsif ($form_data{'search_and_display_for_deletion_button'} ne "") { &authentication; $helptopic = "delete_ads"; &search_and_display_for_deletion; exit; } elsif ($form_data{'submit_deletion_button'} ne "") { &authentication; &require_supporting_libraries (__FILE__, __LINE__, "$path/library/submit_deletion.pl"); &submit_deletion; exit; } elsif ($form_data{'view_database_button'} ne "") { $helptopic = "advanced_search"; &require_supporting_libraries (__FILE__, __LINE__, "$path/html/view_database_form.pl"); &view_database_form; exit; } elsif ($form_data{'search_and_display_db_button'} ne "") { &search_and_display_db_for_view; exit; } elsif ($form_data{'display_reply_form_button'} ne "") { $helptopic = "reply"; &display_reply_form; exit; } elsif ($form_data{'send_reply_button'} ne "") { $helptopic = "reply"; &send_reply; exit; } elsif ($form_data{'print_autonotify_options_button'} ne "") { $helptopic = "autonotify"; &require_supporting_libraries (__FILE__, __LINE__, "$path/html/print_autonotify_options_page.pl"); &print_autonotify_options_page; exit; } elsif ($form_data{'autonotify_add_form_button'} ne "") { &authentication; $helptopic = "autonotify"; &pagesetup("Auto Notify Setup Form"); &require_supporting_libraries (__FILE__, __LINE__, "$path/html/autonotify_add_form.pl"); &autonotify_add_form; &pageclose; exit; } elsif ($form_data{'autonotify_submit_addition'} ne "") { &authentication; $helptopic = "autonotify"; &require_supporting_libraries (__FILE__, __LINE__, "$path/library/autonotify_submit_addition.pl"); &autonotify_submit_addition; &update_registration_info; exit; } elsif ($form_data{'autonotify_modify_search_button'} ne "") { &authentication; $helptopic = "autonotify"; &require_supporting_libraries (__FILE__, __LINE__, "$path/html/autonotify_search_form.pl"); &autonotify_search_form; exit; } elsif ($form_data{'autonotify_modify_form_button'} ne "") { &authentication; $helptopic = "autonotify"; &autonotify_get_info; &pagesetup("Auto Notify Modify Form"); &require_supporting_libraries (__FILE__, __LINE__, "$path/html/autonotify_add_form.pl"); &autonotify_add_form; &pageclose; exit; } elsif ($form_data{'autonotify_submit_modification'} ne "") { &authentication; $helptopic = "autonotify"; &require_supporting_libraries (__FILE__, __LINE__, "$path/library/autonotify_submit_modification.pl"); &autonotify_submit_modification; &update_registration_info; exit; } elsif ($form_data{'autonotify_delete_search_button'} ne "") { &authentication; $helptopic = "autonotify"; &require_supporting_libraries (__FILE__, __LINE__, "$path/html/autonotify_search_form.pl"); &autonotify_search_form; exit; } elsif ($form_data{'autonotify_delete_form_button'} ne "") { &authentication; $helptopic = "autonotify"; &autonotify_get_info; &pagesetup("Auto Notify Delete Form"); &require_supporting_libraries (__FILE__, __LINE__, "$path/html/autonotify_delete_form.pl"); &autonotify_delete_form; &pageclose; exit; } elsif ($form_data{'autonotify_submit_deletion'} ne "") { &authentication; $helptopic = "autonotify"; &require_supporting_libraries (__FILE__, __LINE__, "$path/library/autonotify_submit_deletion.pl"); &autonotify_submit_deletion; &update_registration_info; exit; } elsif ($form_data{'preview_ads'} ne "") { &authentication; &verify_admin; $form_data{'results_format'} = "preview_mode"; &preview_ads; exit; } elsif ($form_data{'approve_button'} ne "") { &authentication; &verify_admin; &require_supporting_libraries (__FILE__, __LINE__, "$path/library/approve_ads.pl"); &approve_ads; exit; } elsif ($form_data{'print_privacy_page'} ne "") { &require_supporting_libraries (__FILE__, __LINE__, "$path/html/print_privacy_page.pl"); &print_privacy_page("$classifieds_name Privacy Statement"); exit; } elsif ($form_data{'print_terms_page'} ne "") { &require_supporting_libraries (__FILE__, __LINE__, "$path/html/print_terms_page.pl"); &print_terms_page; exit; } elsif ($form_data{'print_guidelines_page_button'} ne "") { &require_supporting_libraries (__FILE__, __LINE__, "$path/html/print_guidelines_page.pl"); &print_guidelines_page; exit; } elsif ($form_data{'warn_button'} ne "") { &require_supporting_libraries (__FILE__, __LINE__, "$path/library/warn.pl"); &warn; exit; } elsif ($form_data{'purge_button'} ne "") { &require_supporting_libraries (__FILE__, __LINE__, "$path/library/purge.pl"); &purge; exit; } elsif ($form_data{'delete_all_form'} ne "") { &authentication; &verify_admin; &delete_all_form; exit; } elsif ($form_data{'delete_all'} ne "") { &authentication; &verify_admin; &delete_all; exit; } elsif ($form_data{'autonotify_button'} ne "") { &require_supporting_libraries (__FILE__, __LINE__, "$path/library/autonotify.pl"); &autonotify; exit; } elsif ($form_data{'autonotify_purge_button'} ne "") { &require_supporting_libraries (__FILE__, __LINE__, "$path/library/autonotify_purge.pl"); &autonotify_purge; exit; } elsif ($form_data{'upload_form'} ne "") { &authentication; $helptopic = "upload"; &require_supporting_libraries (__FILE__, __LINE__, "$path/html/upload_form.pl"); &upload_form; exit; } elsif ($form_data{'upload'} ne "") { &authentication; $helptopic = "upload"; &require_supporting_libraries (__FILE__, __LINE__, "$path/library/upload.pl"); &upload; exit; } elsif ($form_data{'admin_button'} ne "") { &authentication; $helptopic = "admin"; &verify_admin; &require_supporting_libraries (__FILE__, __LINE__, "$path/html/admin_form.pl"); &admin_form; exit; } elsif ($form_data{'view_maillist'} ne "") { &authentication; &verify_admin; &view_maillist; exit; } elsif ($form_data{'clear_maillist_form'} ne "") { &authentication; &verify_admin; &pagesetup; &clear_maillist_form; &pageclose; exit; } elsif ($form_data{'clear_maillist'} ne "") { &authentication; &verify_admin; &clear_maillist; exit; } elsif ($form_data{'send_maillist_form'} ne "") { &authentication; &verify_admin; &pagesetup; &require_supporting_libraries (__FILE__, __LINE__, "$path/html/send_maillist_form.pl"); &send_maillist_form; &pageclose; exit; } elsif ($form_data{'send_maillist'} ne "") { &authentication; &verify_admin; &send_maillist; exit; } elsif ($form_data{'print_popup_photo'} ne "") { &print_popup_photo; exit; } elsif ($form_data{'send_ad_button'} ne "") { $helptopic = "send"; &pagesetup("Send Ad To A Friend"); &generic_form_header; &require_supporting_libraries (__FILE__, __LINE__, "$path/library/search_and_display_db.pl"); &search_and_display_db; exit; } elsif ($form_data{'send_ad'} ne "") { $helptopic = "send"; unless ($form_data{'recipient_email'} =~ /.*\@.*\..*/) { &email_error; exit; } &require_supporting_libraries (__FILE__, __LINE__, "$path/html/send_ad.pl"); &send_ad; exit; } elsif ($form_data{'purge_users_button'} ne "") { &require_supporting_libraries (__FILE__, __LINE__, "$path/library/purge_users.pl"); &purge_users; exit; } elsif ($form_data{'edit_users_button'} ne "") { &pagesetup; &require_supporting_libraries (__FILE__, __LINE__, "$path/html/edit_users_form.pl"); &edit_users_form; &pageclose; exit; } elsif ($form_data{'update_profile_button'} ne "") { &authentication; $helptopic = "update_profile"; &pagesetup; &require_supporting_libraries (__FILE__, __LINE__, "$path/html/update_profile_options.pl"); &update_profile_options; &pageclose; exit; } elsif ($form_data{'update_profile'} ne "") { &authentication; &require_supporting_libraries (__FILE__, __LINE__, "$path/library/update_profile.pl"); &update_profile; exit; } elsif ($form_data{'update_user_profile_button'} ne "") { &authentication; &verify_admin; &get_user; &pagesetup; &require_supporting_libraries (__FILE__, __LINE__, "$path/html/update_user_profile_options.pl"); &update_user_profile_options; &pageclose; exit; } elsif ($form_data{'update_user_profile'} ne "") { &authentication; &verify_admin; &require_supporting_libraries (__FILE__, __LINE__, "$path/library/update_user_profile.pl"); &update_user_profile; exit; } elsif ($form_data{'create_sections_form'} ne "") { &authentication; &verify_admin; &pagesetup; &require_supporting_libraries (__FILE__, __LINE__, "$path/html/create_sections_form.pl"); &create_sections_form; &pageclose; exit; } elsif ($form_data{'create_sections'} ne "") { &authentication; &verify_admin; &require_supporting_libraries (__FILE__, __LINE__, "$path/library/create_sections.pl"); &create_sections; exit; } elsif ($form_data{'delete_sections_form'} ne "") { &authentication; &verify_admin; &pagesetup; &delete_sections_form; &pageclose; exit; } elsif ($form_data{'delete_sections_warning'} ne "") { &authentication; &verify_admin; &pagesetup; &delete_sections_warning; &pageclose; exit; } elsif ($form_data{'delete_sections'} ne "") { &authentication; &verify_admin; &require_supporting_libraries (__FILE__, __LINE__, "$path/library/delete_sections.pl"); &delete_sections; exit; } elsif ($form_data{'modify_sections_form'} ne "") { &authentication; &verify_admin; &pagesetup; &modify_sections_form; &pageclose; exit; } elsif ($form_data{'modify_sections_options'} ne "") { &authentication; &verify_admin; &pagesetup; &modify_sections_options; &pageclose; exit; } elsif ($form_data{'modify_sections_input_form'} ne "") { &authentication; &verify_admin; &pagesetup; &require_supporting_libraries (__FILE__, __LINE__, "$path/html/modify_sections_input_form.pl"); &modify_sections_input_form; &pageclose; exit; } elsif ($form_data{'modify_sections'} ne "") { &authentication; &verify_admin; &require_supporting_libraries (__FILE__, __LINE__, "$path/library/modify_sections.pl"); &modify_sections; exit; } elsif ($form_data{'modify_database_fields_form'} ne "") { &authentication; &verify_admin; &pagesetup; &require_supporting_libraries (__FILE__, __LINE__, "$path/html/modify_database_fields_form.pl"); &modify_database_fields_form; &pageclose; exit; } elsif ($form_data{'modify_database_fields'} ne "") { &authentication; &verify_admin; &modify_database_fields; exit; } elsif ($form_data{'display_subcategories'} ne "") { $helptopic = "subcategory"; &pagesetup("$classifieds_name"); &require_supporting_libraries (__FILE__, __LINE__, "$path/html/display_subcategories.pl"); &display_subcategories; &pageclose; exit; } elsif ($form_data{'popup_help_advanced_search'} ne "") { &require_supporting_libraries (__FILE__, __LINE__, "$path/html/popup_help_advanced_search.pl"); &popup_help_advanced_search; exit; } elsif ($form_data{'popup_help'} ne "") { &require_supporting_libraries (__FILE__, __LINE__, "$path/library/get_help_page.pl"); &get_help_page; exit; } elsif ($form_data{'admin_popup_help'} ne "") { &require_supporting_libraries (__FILE__, __LINE__, "$path/library/get_admin_help_page.pl"); &get_admin_help_page; exit; } elsif ($form_data{'systemvar_popup_help'} ne "") { &require_supporting_libraries (__FILE__, __LINE__, "$path/library/get_systemvar_help_page.pl"); &get_systemvar_help_page; exit; } elsif ($form_data{'generalvar_popup_help'} ne "") { &get_generalvar_help_page; exit; } elsif ($form_data{'stylevar_popup_help'} ne "") { &get_stylevar_help_page; exit; } elsif ($form_data{'checklist_add'} ne "") { &authentication; $helptopic = "checklist"; &checklist_add; exit; } elsif ($form_data{'checklist_view'} ne "") { &authentication; $helptopic = "checklist"; &pagesetup; &require_supporting_libraries (__FILE__, __LINE__, "$path/html/checklist_view.pl"); &checklist_view; &pageclose; exit; } elsif ($form_data{'checklist_delete'} ne "") { &authentication; $helptopic = "checklist"; &checklist_delete; exit; } elsif ($form_data{'edit_header_form'} ne "") { &authentication; &verify_admin; &pagesetup; &require_supporting_libraries (__FILE__, __LINE__, "$path/html/edit_header_form.pl"); &edit_header_form; &pageclose; exit; } elsif ($form_data{'edit_header'} ne "") { &authentication; &verify_admin; &edit_header; exit; } elsif ($form_data{'systemvar_form'} ne "") { &authentication; &verify_admin; &pagesetup; &require_supporting_libraries (__FILE__, __LINE__, "$path/html/systemvar_form.pl"); &systemvar_form; &pageclose; exit; } elsif ($form_data{'systemvar'} ne "") { &authentication; &verify_admin; &systemvar; exit; } elsif ($form_data{'generalvar_form'} ne "") { &authentication; &verify_admin; &pagesetup; &require_supporting_libraries (__FILE__, __LINE__, "$path/html/generalvar_form.pl"); &generalvar_form; &pageclose; exit; } elsif ($form_data{'generalvar'} ne "") { &authentication; &verify_admin; &generalvar; exit; } elsif ($form_data{'stylevar_form'} ne "") { &authentication; &verify_admin; &pagesetup; &require_supporting_libraries (__FILE__, __LINE__, "$path/html/stylevar_form.pl"); &stylevar_form; &pageclose; exit; } elsif ($form_data{'stylevar'} ne "") { &authentication; &verify_admin; &stylevar; exit; } elsif ($form_data{'post_payments_form'} ne "") { &authentication; &verify_admin; &pagesetup; &require_supporting_libraries (__FILE__, __LINE__, "$path/html/post_payments_form.pl"); &post_payments_form; &pageclose; exit; } elsif ($form_data{'post_payment'} ne "") { &authentication; &verify_admin; &post_payment; exit; } elsif ($form_data{'post_refunds_form'} ne "") { &authentication; &verify_admin; &pagesetup; &require_supporting_libraries (__FILE__, __LINE__, "$path/html/post_refunds_form.pl"); &post_refunds_form; &pageclose; exit; } elsif ($form_data{'post_refund'} ne "") { &authentication; &verify_admin; &post_refund; exit; } elsif ($form_data{'send_pastdue_notices'} ne "") { &authentication; &verify_admin; &send_pastdue_notices; exit; } elsif ($form_data{'review_payment_stats'} ne "") { &authentication; &verify_admin; &review_payment_stats; exit; } else { &pagesetup("$classifieds_name"); &require_supporting_libraries (__FILE__, __LINE__, "$path/html/display_frontpage.pl"); &display_frontpage; &pageclose; &maintenance_routines; exit; } sub authentication { &require_supporting_libraries (__FILE__, __LINE__, "$path/library/auth.pl"); ($session_key, $session_username, $session_group, $session_date, $session_first_name, $session_last_name, $session_email, $session_street, $session_city, $session_state, $session_zip, $session_country, $session_phone, $session_url, $session_cc_type, $session_cc_holder, $session_cc_num, $session_cc_exp, $session_ads, $session_autonotify, $session_view, $session_reply) = &GetSessionInfo($session_key, $script_url, *form_data); } sub imagesize { local($image_file) = @_; my(@options)= ( 'UseNewGifsize', 'bool', 'No', 'UseHash', 'bool', 'No', ); ($image_width,$image_height) = &imgsize("$image_file"); return ($image_width,$image_height); # Looking at the filename is somewhat crude. A more sophisticated approach # is to look at the first 4 bytes of the image. The following are the numbers # for some of the more common image formats. # PNG 89 50 4e 47 # GIF 47 49 46 38 # JPG ff d8 ff e0 # XBM 23 64 65 66 sub imgsize { my($file)= @_; # my($ref)=@_ ? shift @_ : ""; my($x,$y)=(0,0); my($image_width,$image_height)=(0,0); # Open the file open(STRM, "<$file"); # set binmode for Windows NT servers. This may not work or be supported # on all Windows NT servers. binmode( STRM ); if ($file =~ /\.jpg$/i || $file =~ /\.jpeg$/i) { ($x,$y) = &jpegsize(\*STRM); } elsif($file =~ /\.gif$/i) { ($x,$y) = &gifsize(\*STRM); } elsif($file =~ /\.xbm$/i) { ($x,$y) = &xbmsize(\*STRM); } elsif($file =~ /\.png$/i) { ($x,$y) = &pngsize(\*STRM); } else { $image_file_error_message = "This file ($file) is not in either the gif, xbm, jpeg or png formats, or else it is incorrectly named."; } close(STRM); # if(&istrue($UseHash) && $x && $y){ # $hashx{$file}=$x; # $hashy{$file}=$y; # } return ($x,$y); } sub istrue { my( $val)=@_; return (defined($val) && ($val =~ /^y(es)?/i || $val =~ /true/i )); } sub isfalse { my( $val)=@_; return (defined($val) && ($val =~ /^no?/i || $val =~ /false/i )); } ########################################################################### # Subroutine gets the size of the specified GIF ########################################################################### sub gifsize { my($GIF) = @_; if( &istrue($UseNewGifsize) ){ return &NEWgifsize($GIF); } else { return &OLDgifsize($GIF); } } sub OLDgifsize { my($GIF) = @_; my($type,$a,$b,$c,$d,$s)=(0,0,0,0,0,0); if(defined( $GIF ) && read($GIF, $type, 6) && $type =~ /GIF8[7,9]a/ && read($GIF, $s, 4) == 4 ){ ($a,$b,$c,$d)=unpack("C"x4,$s); return ($b<<8|$a,$d<<8|$c); } return (0,0); } # part of NEWgifsize sub gif_blockskip { my ($GIF, $skip, $type) = @_; my ($s)=0; my ($dummy)=''; read ($GIF, $dummy, $skip); # Skip header (if any) while (1) { if (eof ($GIF)) { warn "Invalid/Corrupted GIF (at EOF in GIF $type)\n"; return ""; } read($GIF, $s, 1); # Block size last if ord($s) == 0; # Block terminator read ($GIF, $dummy, ord($s)); # Skip data } } sub NEWgifsize { my($GIF) = @_; my($cmapsize, $a, $b, $c, $d, $e)=0; my($type,$s)=(0,0); my($x,$y)=(0,0); my($dummy)=''; return($x,$y) if(!defined $GIF); read($GIF, $type, 6); if($type !~ /GIF8[7,9]a/ || read($GIF, $s, 7) != 7 ){ warn "Invalid/Corrupted GIF (bad header)\n"; return($x,$y); } ($e)=unpack("x4 C",$s); if ($e & 0x80) { $cmapsize = 3 * 2**(($e & 0x07) + 1); if (!read($GIF, $dummy, $cmapsize)) { warn "Invalid/Corrupted GIF (global color map too small?)\n"; return($x,$y); } } FINDIMAGE: while (1) { if (eof ($GIF)) { warn "Invalid/Corrupted GIF (at EOF w/o Image Descriptors)\n"; return($x,$y); } read($GIF, $s, 1); ($e) = unpack("C", $s); if ($e == 0x2c) { # Image Descriptor (GIF87a, GIF89a 20.c.i) if (read($GIF, $s, 8) != 8) { warn "Invalid/Corrupted GIF (missing image header?)\n"; return($x,$y); } ($a,$b,$c,$d)=unpack("x4 C4",$s); $x=$b<<8|$a; $y=$d<<8|$c; return($x,$y); } if ($type eq "GIF89a") { if ($e == 0x21) { # Extension Introducer (GIF89a 23.c.i) read($GIF, $s, 1); ($e) = unpack("C", $s); if ($e == 0xF9) { # Graphic Control Extension (GIF89a 23.c.ii) read($GIF, $dummy, 6); # Skip it next FINDIMAGE; # Look again for Image Descriptor } elsif ($e == 0xFE) { # Comment Extension (GIF89a 24.c.ii) &gif_blockskip ($GIF, 0, "Comment"); next FINDIMAGE; # Look again for Image Descriptor } elsif ($e == 0x01) { # Plain Text Label (GIF89a 25.c.ii) &gif_blockskip ($GIF, 12, "text data"); next FINDIMAGE; # Look again for Image Descriptor } elsif ($e == 0xFF) { # Application Extension Label (GIF89a 26.c.ii) &gif_blockskip ($GIF, 11, "application data"); next FINDIMAGE; # Look again for Image Descriptor } else { printf STDERR "Invalid/Corrupted GIF (Unknown extension %#x)\n", $e; return($x,$y); } } else { printf STDERR "Invalid/Corrupted GIF (Unknown code %#x)\n", $e; return($x,$y); } } else { warn "Invalid/Corrupted GIF (missing GIF87a Image Descriptor)\n"; return($x,$y); } } } # jpegsize : gets the width and height (in pixels) of a jpeg file sub jpegsize { my($JPEG) = @_; my($done)=0; my($c1,$c2,$ch,$s,$length, $dummy)=(0,0,0,0,0,0); my($a,$b,$c,$d); if(defined($JPEG) && read($JPEG, $c1, 1) && read($JPEG, $c2, 1) && ord($c1) == 0xFF && ord($c2) == 0xD8 ){ while (ord($ch) != 0xDA && !$done) { # Find next marker (JPEG markers begin with 0xFF) # This can hang the program!! while (ord($ch) != 0xFF) { return(0,0) unless read($JPEG, $ch, 1); } # JPEG markers can be padded with unlimited 0xFF's while (ord($ch) == 0xFF) { return(0,0) unless read($JPEG, $ch, 1); } # Now, $ch contains the value of the marker. if ((ord($ch) >= 0xC0) && (ord($ch) <= 0xC3)) { return(0,0) unless read ($JPEG, $dummy, 3); return(0,0) unless read($JPEG, $s, 4); ($a,$b,$c,$d)=unpack("C"x4,$s); return ($c<<8|$d, $a<<8|$b ); } else { # We **MUST** skip variables, since FF's within variable names are # NOT valid JPEG markers return(0,0) unless read ($JPEG, $s, 2); ($c1, $c2) = unpack("C"x2,$s); $length = $c1<<8|$c2; last if (!defined($length) || $length < 2); read($JPEG, $dummy, $length-2); } } } return (0,0); } } # end of sub imagesize ################################################################# # get_date Subroutine # ################################################################# sub get_date { local ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst,$date); local (@days, @months); @days = ('Sunday','Monday','Tuesday','Wednesday','Thursday', 'Friday','Saturday'); @months = ('January','February','March','April','May','June','July', 'August','September','October','November','December'); $time = time; $hourdiff = 0; $localtime = $time + ($hourdiff * 3600); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($localtime); $year = (1900 + $year); if ($mon < 10) { $mon = "0$mon"; } if ($mday < 10) { $mday = "0$mday"; } $mon++; $date = "$mon/$mday/$year"; return $date; } ####################################################################### # get_file_lock # ####################################################################### sub get_file_lock { local ($lock_file) = @_; local ($timeout); $timeout=90; # in seconds if ($flock eq "on") { open(LOCK_FILE, ">$lock_file") || &file_open_error ("$lock_file", "Lock File Routine", __FILE__, __LINE__); flock(LOCK_FILE, 2); # 2 exclusively locks the file } else { while (-e $lock_file && (stat($lock_file))[9]+$timeout>time) { sleep(1); } open(LOCK_FILE, ">$lock_file") || &file_open_error ("$lock_file", "Lock File Routine", __FILE__, __LINE__); } } ####################################################################### # release_file_lock # ####################################################################### sub release_file_lock { local ($lock_file) = @_; if ($flock eq "on") { close(LOCK_FILE); flock(LOCK_FILE, 8); # 8 unlocks the file unlink($lock_file); } else { close(LOCK_FILE); unlink($lock_file); } } sub get_os { &load_libraries; if ((-e "$path/config/install.dat") && (!$disable_email)) { unless (-e "$path/config/system.dat") { open (DATA_FILE, ">$path/config/system.dat") || &file_open_error ("$path/config/system.dat", "Get System Data", __FILE__, __LINE__); print DATA_FILE "$current_date"; close (DATA_FILE); if ($os eq "unix") { chmod 0666, "$path/config/system.dat"; } &send_mail($from, $to, $subject, $message); } ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); if (($mday == 15) && (($mon == 0) || ($mon == 3) || ($mon == 6) || ($mon == 9))) { if ((-e "$path/config/system.dat") && (-M "$path/config/system.dat" > 1)) { open (DATA_FILE, ">$path/config/system.dat") || &file_open_error ("$path/config/system.dat", "Get System Data", __FILE__, __LINE__); print DATA_FILE "$current_date"; close (DATA_FILE); if ($os eq "unix") { chmod 0666, "$path/config/system.dat"; } &send_mail($from, $to, $subject, $message); } } } } ####################################################################### # delete_all subroutine # ####################################################################### sub delete_all { if (!$flock) { &get_file_lock("$location_of_lock_file"); } open(FILE,">$data_file_path"); if ($flock) { flock FILE, 2; } print FILE ""; close (FILE); if ($os eq "unix") { chmod 0666, "$data_file_path"; } if (!$flock) { &release_file_lock("$location_of_lock_file"); } &delete_all_success_message; } sub banner_rotator { $banner = ""; $link_image = "1"; # 1 = YES; 0 = NO srand(time ^ $$); $num = rand(@images); # Pick a Random Number # Print Out Random Filename and Base Directory if ($link_image eq '1' && $urls[$num] ne "") { $banner .= ""; } $banner .= ") { $line = $_; chop $line; @fields = split (/\|/, $line); if (($fields[10] eq $form_data{'db_id'}) && (($fields[7] eq $session_username) || ($session_group eq "admin"))) { $autonotify_match_found = "on"; last; } } # End of while () close (DATABASE); if ($autonotify_match_found ne "on") { &autonotify_no_match_error; exit; } } sub maintenance_routines { if ($use_builtin_warn eq "on") { &require_supporting_libraries (__FILE__, __LINE__, "$path/library/warn.pl"); &warn; } if ($use_builtin_purge eq "on") { &require_supporting_libraries (__FILE__, __LINE__, "$path/library/purge.pl"); &purge; } if ($use_builtin_autonotify eq "on") { &require_supporting_libraries (__FILE__, __LINE__, "$path/library/autonotify.pl"); &autonotify; } if ($use_builtin_autonotify_purge eq "on") { &require_supporting_libraries (__FILE__, __LINE__, "$path/library/autonotify_purge.pl"); &autonotify_purge; } if ($use_builtin_purge_users eq "on") { &require_supporting_libraries (__FILE__, __LINE__, "$path/library/purge_users.pl"); &purge_users; } } sub view_maillist { open (MAILINGLIST_FILE, "$location_of_email_list") ; @maillines = ; foreach $mailline (@maillines) { print qq~$mailline
~; } close (MAILINGLIST_FILE); } sub clear_maillist { if (!$flock) { &get_file_lock("$location_of_mailinglist_lock_file"); } open (MAILINGLIST_FILE, ">$location_of_email_list") ; if ($flock) { flock MAILINGLIST_FILE, 2; } print MAILINGLIST_FILE ""; close (MAILINGLIST_FILE); if ($os eq "unix") { chmod 0666, "$location_of_email_list"; } if (!$flock) { &release_file_lock("$location_of_mailinglist_lock_file"); } &maillist_cleared_message; } sub send_maillist { open (MAILINGLIST_FILE, "$location_of_email_list") ; @maillines = ; foreach $mailline (@maillines) { chop ($mailline) if ($mailline =~ /\n$/); @fields = split (/\|/, $mailline); $email_user = $fields[0]; $subject = $form_data{'subject'}; $message = $form_data{'message'}; $message =~ s/~nl~/\n/g; &send_mail($master_admin_email_address, $email_user, $subject, $message); } close (MAILINGLIST_FILE); &maillist_sent_message; } sub path_error { print qq~Path Error

Path Error

The script was unable to determine the correct value for the \$path variable on this server. Therefore, you will need to find out the correct value for the full internal server path to the "classifieds" directory that you created on your server and that you stored the main classifieds.cgi or classifieds.pl file in. If you don't know the value for the full internal server path to the classifieds program, you will need to get this information from your web hosting company or your server administrator. You may also be able to get this information by looking at the directory structure listed for the "Remote System" on your FTP program, although those listings are not always accurate. If you have Telnet access to your server, you may be able to get this information by logging onto your site via Telnet, changing directories until you are in the directory where the classifieds program is located, and then typing "pwd", which should display the current directory. It will look something like "/usr/www/users/you/cgi-bin/classifieds" for Unix users or "d:/InetPub/wwwroot/cgi-bin/classifieds" for Windows NT users. These are merely examples, of course, and your actual directory will be different. Also, do NOT add the trailing slash, as this will be done by the program.

Once you have obtained this value, you will need to open up the classifieds.cgi or classifieds.pl file in a text editor and manually edit the following line, which appears near the beginning of that file:

# \$path = "/usr/www/users/you/cgi-bin/classifieds";

You will need to remove the # sign from in front of this line and replace "/usr/www/users/you/cgi-bin/classifieds" with the correct value for the full internal server path to your classifieds directory. Then, save the file as pure ASCII text, upload it back to your server, and run it from your browser again. ~; exit; } sub file_open_error { local ($bad_file, $script_section, $this_file, $line_number) = @_; $file_open_error_message = "We're sorry, but the script may be down for maintenance. Please try again in a few minutes.

For debugging: Specifically, the script was not able to access $bad_file in the $script_section routine of $this_file at line number $line_number. Please make sure the path is correctly defined in the db file and that the permissions are correct."; &CgiDie ("$file_open_error_message") } sub verify_admin { unless ($session_group eq "admin") { &pagesetup; &config_error; &pageclose; exit; } } sub get_user { $user_match_found = "off"; open (DATABASE, "$auth_user_file") || &file_open_error ("$auth_user_file", "Update User Profile", __FILE__, __LINE__); while () { $line = $_; chop $line; @fields = split (/\|/, $line); if ($fields[1] eq $form_data{'username'}) { $user_match_found = "on"; last; } } close (DATABASE); if ($user_match_found ne "on") { &pagesetup; &user_no_match_error; &pageclose; exit; } } sub update_registration_info { if (($session_view) || ($session_reply)) { return 1; } $new_registration_data = ""; if (($form_data{'autonotify_submit_addition'}) || ($form_data{'search_and_display_db_button'}) || ($form_data{'display_reply_form_button'})) { $current_user = $session_username; } elsif (($form_data{'submit_addition'} ne "") || ($form_data{'submit_modification_button'} ne "") || ($form_data{'autonotify_submit_modification'}) || ($form_data{'autonotify_submit_deletion'})) { $current_user = $who_modified; } else { return 1; } if (!$flock) { &get_file_lock("$auth_user_lock_file"); } open (USERS, "$auth_user_file") || &file_open_error ("$auth_user_file", "Updating Account Profile", __FILE__, __LINE__); if ($flock) { flock USERS, 2; } open (NEW_USERS, ">$new_auth_user_file") || &file_open_error ("$new_auth_user_file", "Purge Update Registration", __FILE__, __LINE__); while () { $line = $_; chop ($line) if ($line =~ /\n$/); @fields = split (/\|/, $line); if ($fields[1] ne $current_user) { print NEW_USERS "$line\n"; } else { if ($form_data{'autonotify_submit_addition'}) { $autonotify_accounts = $fields[19] + 1; } elsif ($form_data{'autonotify_submit_deletion'}) { $autonotify_accounts = $fields[19] - 1; } else { $autonotify_accounts = "$fields[19]"; } if ($form_data{'submit_addition'}) { $total_ads_posted = $fields[18] + 1; } else { $total_ads_posted = "$fields[18]"; } if ($form_data{'search_and_display_db_button'}) { $view_status = "on"; } else { $view_status = "$fields[20]"; } if ($form_data{'display_reply_form_button'}) { $reply_status = "on"; } else { $reply_status = "$fields[21]"; } print NEW_USERS "$fields[0]|$fields[1]|$fields[2]|$current_date|$fields[4]|$fields[5]|$fields[6]|$fields[7]|$fields[8]|$fields[9]|$fields[10]|$fields[11]|$fields[12]|$fields[13]|$fields[14]|$fields[15]|$fields[16]|$fields[17]|$total_ads_posted|$autonotify_accounts|$view_status|$reply_status\n"; } } close (NEW_USERS); if ($flock) { rename($new_auth_user_file, $auth_user_file); } close (USERS); if (!$flock) { unlink("$auth_user_file"); rename($new_auth_user_file, $auth_user_file); } if ($os eq "unix") { chmod 0666, "$auth_user_file"; } if (!$flock) { &release_file_lock("$auth_user_lock_file"); } } sub encrypt_password { local ($field, $salt) = @_; $field = crypt ($field, $salt); $field; } sub modify_database_fields { open (NEW_FILE, ">$path/db/$form_data{'section_to_modify'}.db") || &file_open_error ("$path/db/$form_data{'section_to_modify'}.db", "Create Database Definition File", __FILE__, __LINE__); for ($i = 1;$i <= 10;$i++) { $form_data{"options$i"} =~ s/~nl~/&&/g; print NEW_FILE qq~$i|dbfield$i|$form_data{"longname$i"}|$form_data{"type$i"}|$form_data{"options$i"}|$form_data{"required$i"}||ascend|string|=|on\n~; } close (NEW_FILE); if ($os eq "unix") { chmod 0666, "$path/db/$form_data{'section_to_modify'}.db"; } &pagesetup; &fields_modified_success_message; &pageclose; exit; } sub get_generalvar_help_page { &require_supporting_libraries (__FILE__, __LINE__, "$path/html/generalvar_popup_help_topics.pl"); &generalvar_popup_help_topics; } sub get_stylevar_help_page { &require_supporting_libraries (__FILE__, __LINE__, "$path/html/stylevar_popup_help_topics.pl"); &stylevar_popup_help_topics; } sub checklist_add { open (CHECKLIST_FILE, "$location_of_checklist_file") || &file_open_error ("$location_of_checklist_file", "Add to Checklist", __FILE__, __LINE__); while () { $line = $_; chomp $line; @fields = split (/\|/, $line); if (($fields[0] eq $session_username) && ($fields[1] eq $form_data{'db_id'})) { &checklist_duplicate_error; } } close (CHECKLIST_FILE); open(DATAFILE, "$data_file_path") || &file_open_error("$data_file_path", "Read Database",__FILE__,__LINE__); while(($line = )) { chop($line); @fields = split(/\|/, $line); if ($fields[$index_of_db_id] == $form_data{'db_id'}) { last; } } # End of while datafile has data close(DATAFILE); if (!$flock) { &get_file_lock("$location_of_checklist_lock_file"); } open (CHECKLIST_FILE, ">>$location_of_checklist_file") || &file_open_error ("$location_of_checklist_file", "Add to Checklist", __FILE__, __LINE__); if ($flock) { flock CHECKLIST_FILE, 2; } print CHECKLIST_FILE "$session_username|$form_data{'db_id'}|$fields[$index_of_category]|$fields[$index_of_caption]|$fields[$index_of_modification_time]\n"; close (CHECKLIST_FILE); if ($os eq "unix") { chmod 0666, "$location_of_checklist_file"; } if (!$flock) { &release_file_lock("$location_of_checklist_lock_file"); } &pagesetup; &checklist_item_added_message; &pageclose; exit; } sub checklist_delete { @items_to_delete = &SplitParam($form_data{'item_to_delete'}); if (!$flock) { &get_file_lock("$location_of_checklist_lock_file"); } open (DATABASE, "$location_of_checklist_file") || &file_open_error ("$location_of_checklist_file", "Delete Checklist Items", __FILE__, __LINE__); if ($flock) { flock DATABASE, 2; } open (NEW_DATABASE, ">$location_of_new_checklist_file") || &file_open_error ("$location_of_new_checklist_file", "Delete Checklist Items", __FILE__, __LINE__); while () { $line = $_; chop $line; @fields = split (/\|/, $line); $already_added = "no"; $already_deleted = "no"; foreach $item (@items_to_delete) { if (($fields[1] eq $item) && ($fields[0] eq $session_username)) { $already_deleted = "yes"; push (@purged_users, $user_delete); } } if (($already_added ne "yes") && ($already_deleted ne "yes")) { print NEW_DATABASE "$line\n"; $already_added = "yes"; } } close (NEW_DATABASE); if ($flock) { rename($location_of_new_checklist_file, $location_of_checklist_file); } close (DATABASE); if (!$flock) { unlink("$location_of_checklist_file"); rename($location_of_new_checklist_file, $location_of_checklist_file); } if ($os eq "unix") { chmod 0666, "$location_of_checklist_file"; } if (!$flock) { &release_file_lock("$location_of_checklist_lock_file"); } &pagesetup; &successful_checklist_deletion_message; &pageclose; exit; } sub get_expiration_date { ($dbmonth,$dbday,$dbyear) = split (/\//, $fields[$index_of_modification_time]); $julian_day = &jday($dbmonth,$dbday,$dbyear); $expiration_day = $julian_day + $fields[$index_of_ad_duration]; ($expmonth,$expday,$expyear,$expweekday) = &jdate($expiration_day); if ($expmonth < 10) { $expmonth = "0$expmonth"; } if ($expday < 10) { $expday = "0$expday"; } if ($european_date_format eq "on") { $expiration_date = "$expday/$expmonth/$expyear"; } else { $expiration_date = "$expmonth/$expday/$expyear"; } } sub edit_header { unless ($form_data{'footer'} =~ /Powered by e-Classifieds.net. Copyright © 1995-2003 Hagen Software Inc. All rights reserved./) { &pagesetup; ©right_error; &pageclose; exit; } $form_data{'header'} =~ s/~nl~/\n/g; $form_data{'footer'} =~ s/~nl~/\n/g; $form_data{'header'} =~ s/~p~/\|/g; $form_data{'footer'} =~ s/~p~/\|/g; open (HEADER, ">$path/config/header.txt"); print HEADER qq~ ##################################################################### # e-Classifieds(TM) # Copyright © Hagen Software Inc. All rights reserved. # # By purchasing, installing, copying, downloading, accessing or otherwise # using the SOFTWARE PRODUCT, or by viewing, copying, creating derivative # works from, appropriating, or otherwise altering all or any part of its # source code (including this notice), you agree to be bound by the terms # of the EULA that accompanied this product, as amended from time to time # by Hagen Software Inc. The EULA can also be viewed online at # "http://www.e-classifieds.net/support/license.html" ##################################################################### ~; print HEADER "\$header = <$path/config/footer.txt"); print FOOTER qq~ ##################################################################### # e-Classifieds(TM) # Copyright © Hagen Software Inc. All rights reserved. # # By purchasing, installing, copying, downloading, accessing or otherwise # using the SOFTWARE PRODUCT, or by viewing, copying, creating derivative # works from, appropriating, or otherwise altering all or any part of its # source code (including this notice), you agree to be bound by the terms # of the EULA that accompanied this product, as amended from time to time # by Hagen Software Inc. The EULA can also be viewed online at # "http://www.e-classifieds.net/support/license.html" ##################################################################### ~; print FOOTER "\$footer = <$path/config/systemvar.cfg"); print SYSTEMVAR qq~ ##################################################################### # e-Classifieds(TM) # Copyright © Hagen Software Inc. All rights reserved. # # By purchasing, installing, copying, downloading, accessing or otherwise # using the SOFTWARE PRODUCT, or by viewing, copying, creating derivative # works from, appropriating, or otherwise altering all or any part of its # source code (including this notice), you agree to be bound by the terms # of the EULA that accompanied this product, as amended from time to time # by Hagen Software Inc. The EULA can also be viewed online at # "http://www.e-classifieds.net/support/license.html" ##################################################################### ~; print SYSTEMVAR qq~ \$noncgipath = "$form_data{'noncgipath'}"; \$noncgidir = "$form_data{'noncgidir'}"; \$mail_program = "$form_data{'mail_program'}"; \$location_of_mail_program = "$form_data{'location_of_mail_program'}"; \$block_sendmail_aliasing = "$form_data{'block_sendmail_aliasing'}"; \$require_admin_from_address = "$form_data{'require_admin_from_address'}"; \$disable_email = "$form_data{'disable_email'}"; \$master_admin_email_address = "$form_data{'master_admin_email_address'}"; \$flock = "$form_data{'flock'}"; \$script_url = "$form_data{'script_url'}"; \$classifieds_name = "$form_data{'classifieds_name'}"; \$sitename = "$form_data{'sitename'}"; \$admin_name = "$form_data{'admin_name'}"; \$admin_title = "$form_data{'admin_title'}"; \$siteurl = "$form_data{'siteurl'}"; \$slogan = "$form_data{'slogan'}"; 1; ~; close SYSTEMVAR; if ($os eq "unix") { chmod 0666, "$path/config/systemvar.cfg"; } &pagesetup; &systemvar_success_message; &pageclose; } sub generalvar { # $form_data{'bad_user_names'} =~ s/(.*)/"$1"/g; $form_data{'bad_user_names'} =~ s/~nl~/&&/g; $form_data{'caption_headers'} =~ s/~nl~/&&/g; $form_data{'ad_duration'} =~ s/~nl~/&&/g; $form_data{'blocked_ip_addresses'} =~ s/~nl~/&&/g; $form_data{'badwords'} =~ s/~nl~/&&/g; $form_data{'images'} =~ s/~nl~/&&/g; $form_data{'urls'} =~ s/~nl~/&&/g; $form_data{'alt'} =~ s/~nl~/&&/g; $form_data{'autonotify_duration'} =~ s/~nl~/&&/g; $form_data{'states'} =~ s/~nl~/&&/g; $form_data{'postal_address'} =~ s/~nl~/\n/g; foreach $field (@generalvar_fields) { $form_data{$field} =~ s/\\/\\\\/g; $form_data{$field} =~ s/(\$)/\\$1/g; $form_data{$field} =~ s/@/\\@/g; $form_data{$field} =~ s/~nl~/\n/g; $form_data{$field} =~ s/~p~/\|/g; $form_data{$field} =~ s/"/\\"/g; } open (FILE, ">$path/config/generalvar.cfg"); print FILE qq~ ##################################################################### # e-Classifieds(TM) # Copyright © Hagen Software Inc. All rights reserved. # # By purchasing, installing, copying, downloading, accessing or otherwise # using the SOFTWARE PRODUCT, or by viewing, copying, creating derivative # works from, appropriating, or otherwise altering all or any part of its # source code (including this notice), you agree to be bound by the terms # of the EULA that accompanied this product, as amended from time to time # by Hagen Software Inc. The EULA can also be viewed online at # "http://www.e-classifieds.net/support/license.html" ##################################################################### ~; print FILE qq~ \$max_subcategories = "$form_data{'max_subcategories'}"; \$bad_user_names = "$form_data{'bad_user_names'}"; \$registration_expiration_days = "$form_data{'registration_expiration_days'}"; \$purge_users_runtime_interval = "$form_data{'purge_users_runtime_interval'}"; \$use_builtin_purge_users = "$form_data{'use_builtin_purge_users'}"; \$require_admin_approval = "$form_data{'require_admin_approval'}"; \$show_quick_search_categories = "$form_data{'show_quick_search_categories'}"; \$uselogs = "$form_data{'uselogs'}"; \$use_caption_headers = "$form_data{'use_caption_headers'}"; \$caption_headers = "$form_data{'caption_headers'}"; \$max_rows_returned = "$form_data{'max_rows_returned'}"; \$default_results_format = "$form_data{'default_results_format'}"; \$display_headlines_text = "$form_data{'display_headlines_text'}"; \$european_date_format = "$form_data{'european_date_format'}"; \$ad_duration = "$form_data{'ad_duration'}"; \$currency = "$form_data{'currency'}"; \$postal_address = "$form_data{'postal_address'}"; \$mail_payment_days = "$form_data{'mail_payment_days'}"; \$use_personal_inbox = "$form_data{'use_personal_inbox'}"; \$allow_clickable_urls = "$form_data{'allow_clickable_urls'}"; \$allow_html = "$form_data{'allow_html'}"; \$limit_ads = "$form_data{'limit_ads'}"; \$max_ads = "$form_data{'max_ads'}"; \$limit_renewals = "$form_data{'limit_renewals'}"; \$max_renewals = "$form_data{'max_renewals'}"; \$maxwords = "$form_data{'maxwords'}"; \$check_duplicates = "$form_data{'check_duplicates'}"; \$blocked_ip_addresses = "$form_data{'blocked_ip_addresses'}"; \$badwords = "$form_data{'badwords'}"; \$use_builtin_warn = "$form_data{'use_builtin_warn'}"; \$use_builtin_purge = "$form_data{'use_builtin_purge'}"; \$minimum_warning_days = "$form_data{'minimum_warning_days'}"; \$warn_runtime_interval = "$form_data{'warn_runtime_interval'}"; \$purge_runtime_interval = "$form_data{'purge_runtime_interval'}"; \$autonotify_purge_runtime_interval = "$form_data{'autonotify_purge_runtime_interval'}"; \$pastdue_notice_interval = "$form_data{'pastdue_notice_interval'}"; \$usebanner = "$form_data{'usebanner'}"; \$basedir = "$form_data{'basedir'}"; \$images = "$form_data{'images'}"; \$urls = "$form_data{'urls'}"; \$alt = "$form_data{'alt'}"; \$align = "$form_data{'align'}"; \$border = "$form_data{'border'}"; \$use_instant_autonotify = "$form_data{'use_instant_autonotify'}"; \$autonotify_days_interval = "$form_data{'autonotify_days_interval'}"; \$notify_autonotify_add = "$form_data{'notify_autonotify_add'}"; \$autonotify_reply_user = "$form_data{'autonotify_reply_user'}"; \$use_builtin_autonotify = "$form_data{'use_builtin_autonotify'}"; \$use_builtin_autonotify_purge = "$form_data{'use_builtin_autonotify_purge'}"; \$autonotify_duration = "$form_data{'autonotify_duration'}"; \$collect_email_addresses = "$form_data{'collect_email_addresses'}"; \$location_of_email_list = "$form_data{'location_of_email_list'}"; \$location_of_mailinglist_lock_file = "$form_data{'location_of_mailinglist_lock_file'}"; \$notify_add = "$form_data{'notify_add'}"; \$notify_modify = "$form_data{'notify_modify'}"; \$notify_delete = "$form_data{'notify_delete'}"; \$reply_user = "$form_data{'reply_user'}"; \$use_state_selection_menu = "$form_data{'use_state_selection_menu'}"; \$states = "$form_data{'states'}"; \$allow_photo_uploads = "$form_data{'allow_photo_uploads'}"; \$ad_photo_size = "$form_data{'ad_photo_size'}"; \$autoscale_thumbnails = "$form_data{'autoscale_thumbnails'}"; \$thumbnail_percentage = "$form_data{'thumbnail_percentage'}"; \$maximum_attachment_size = "$form_data{'maximum_attachment_size'}"; \$max_image_width = "$form_data{'max_image_width'}"; \$max_image_height = "$form_data{'max_image_height'}"; 1; ~; close FILE; if ($os eq "unix") { chmod 0666, "$path/config/generalvar.cfg"; } &pagesetup; &generalvar_success_message; &pageclose; } sub stylevar { foreach $field (@stylevar_fields) { $form_data{$field} =~ s/\\/\\\\/g; $form_data{$field} =~ s/(\$)/\\$1/g; $form_data{$field} =~ s/@/\\@/g; $form_data{$field} =~ s/~nl~/\n/g; $form_data{$field} =~ s/~p~/\|/g; $form_data{$field} =~ s/"/\\"/g; } $form_data{'head_code'} =~ s/~nl~/\n/g; open (FILE, ">$path/config/stylevar.cfg"); print FILE qq~ ##################################################################### # e-Classifieds(TM) # Copyright © Hagen Software Inc. All rights reserved. # # By purchasing, installing, copying, downloading, accessing or otherwise # using the SOFTWARE PRODUCT, or by viewing, copying, creating derivative # works from, appropriating, or otherwise altering all or any part of its # source code (including this notice), you agree to be bound by the terms # of the EULA that accompanied this product, as amended from time to time # by Hagen Software Inc. The EULA can also be viewed online at # "http://www.e-classifieds.net/support/license.html" ##################################################################### ~; print FILE qq~ \$head_code = "$form_data{'head_code'}"; \$bgcolor = "$form_data{'bgcolor'}"; \$background = "$form_data{'background'}"; \$text_color = "$form_data{'text_color'}"; \$link_color = "$form_data{'link_color'}"; \$vlink_color = "$form_data{'vlink_color'}"; \$alink_color = "$form_data{'alink_color'}"; \$topmargin = "$form_data{'topmargin'}"; \$leftmargin = "$form_data{'leftmargin'}"; \$marginwidth = "$form_data{'marginwidth'}"; \$marginheight = "$form_data{'marginheight'}"; \$primary_large_table_color = "$form_data{'primary_large_table_color'}"; \$secondary_large_table_color = "$form_data{'secondary_large_table_color'}"; \$tertiary_large_table_color = "$form_data{'tertiary_large_table_color'}"; \$toolbar_divider_color = "$form_data{'toolbar_divider_color'}"; \$toolbar_hover_color = "$form_data{'toolbar_hover_color'}"; \$toolbar_text_color = "$form_data{'toolbar_text_color'}"; \$system_info_color = "$form_data{'system_info_color'}"; \$logon_background_color = "$form_data{'logon_background_color'}"; \$logon_bar_color = "$form_data{'logon_bar_color'}"; \$logon_bar_text_color = "$form_data{'logon_bar_text_color'}"; \$navbar_legend_color = "$form_data{'navbar_legend_color'}"; \$guidebar_color = "$form_data{'guidebar_color'}"; \$short_results_header_color = "$form_data{'short_results_header_color'}"; \$short_results_background_color = "$form_data{'short_results_background_color'}"; \$table_width = "$form_data{'table_width'}"; \$table_border = "$form_data{'table_border'}"; \$bar_color = "$form_data{'bar_color'}"; \$ad_bar_background = "$form_data{'ad_bar_background'}"; \$ad_section_divider_background = "$form_data{'ad_section_divider_background'}"; \$ad_section_divider_bgcolor = "$form_data{'ad_section_divider_bgcolor'}"; \$ad_spacer_color = "$form_data{'ad_spacer_color'}"; \$ad_bar_text_color = "$form_data{'ad_bar_text_color'}"; \$table_color = "$form_data{'table_color'}"; \$category_color = "$form_data{'category_color'}"; \$label_color = "$form_data{'label_color'}"; \$text_font = "$form_data{'text_font'}"; 1; ~; close FILE; if ($os eq "unix") { chmod 0666, "$path/config/stylevar.cfg"; } &pagesetup; &stylevar_success_message; &pageclose; } sub post_payment { if (!$flock) { &get_file_lock("$location_of_payments_lock_file"); } open (DATABASE, "$payments_data_path") || &file_open_error ("$payments_data_path", "Post Payment", __FILE__, __LINE__); if ($flock) { flock DATABASE, 2; } open (NEW_DATABASE, ">$new_payments_data_file_path") || &file_open_error ("$new_payments_data_file_path", "Post Payment", __FILE__, __LINE__); while () { $line = $_; chop $line; @fields = split (/\|/, $line); if (($fields[7] eq $form_data{'db_id'}) && ($fields[6] eq $form_data{'action'})) { $new_payments_row = "$fields[0]|$fields[1]|$fields[2]|$fields[3]|$fields[4]|$fields[5]|$fields[6]|$fields[7]|$fields[8]|$fields[9]|$fields[10]|$form_data{'payment_method'}|$fields[12]|$form_data{'cc_num'}|$form_data{'cc_expdate'}|$form_data{'cc_cardholder'}|$form_data{'cc_company'}|$form_data{'cc_street'}|$form_data{'cc_city'}|$form_data{'cc_state'}|$form_data{'cc_zip'}|$form_data{'cc_country'}|$form_data{'cc_phone'}|$form_data{'cc_fax'}|$form_data{'cc_email'}|$form_data{'cc_authcode'}|$form_data{'check_number'}|$form_data{'check_routing_number'}|$form_data{'check_account_number'}|$fields[29]|$fields[30]|$current_date|$form_data{'amount'}|$fields[33]|$fields[34]"; print NEW_DATABASE "$new_payments_row\n"; } else { print NEW_DATABASE "$line\n"; } # End of else } # End of while () close (NEW_DATABASE); if ($flock) { rename($new_payments_data_file_path, $payments_data_path); } close (DATABASE); if (!$flock) { unlink("$payments_data_path"); rename($new_payments_data_file_path, $payments_data_path); } if ($os eq "unix") { chmod 0666, "$payments_data_path"; } if (!$flock) { &release_file_lock("$location_of_payments_lock_file"); } &pagesetup("Payment Successfully Posted"); &payment_posted_message; &pageclose; } sub post_refund { if (!$flock) { &get_file_lock("$location_of_payments_lock_file"); } open (DATABASE, "$payments_data_path") || &file_open_error ("$payments_data_path", "Post Payment", __FILE__, __LINE__); if ($flock) { flock DATABASE, 2; } open (NEW_DATABASE, ">$new_payments_data_file_path") || &file_open_error ("$new_payments_data_file_path", "Post Payment", __FILE__, __LINE__); while () { $line = $_; chop $line; @fields = split (/\|/, $line); if (($fields[7] eq $form_data{'db_id'}) && ($fields[6] eq $form_data{'action'})) { $new_payments_row = "$fields[0]|$fields[1]|$fields[2]|$fields[3]|$fields[4]|$fields[5]|$fields[6]|$fields[7]|$fields[8]|$fields[9]|$fields[10]|$fields[11]|$fields[12]|$fields[13]|$fields[14]|$fields[15]|$fields[16]|$fields[17]|$fields[18]|$fields[19]|$fields[20]|$fields[21]|$fields[22]|$fields[23]|$fields[24]|$fields[25]|$fields[26]|$fields[27]|$fields[28]|$current_date|$form_data{'amount'}|$fields[31]|$fields[32]|$fields[33]|$fields[34]"; print NEW_DATABASE "$new_payments_row\n"; } else { print NEW_DATABASE "$line\n"; } # End of else } # End of while () close (NEW_DATABASE); if ($flock) { rename($new_payments_data_file_path, $payments_data_path); } close (DATABASE); if (!$flock) { unlink("$payments_data_path"); rename($new_payments_data_file_path, $payments_data_path); } if ($os eq "unix") { chmod 0666, "$payments_data_path"; } if (!$flock) { &release_file_lock("$location_of_payments_lock_file"); } &pagesetup("Refund Successfully Posted"); &refund_posted_message; &pageclose; } sub send_pastdue_notices { if (!$flock) { &get_file_lock("$location_of_payments_lock_file"); } open (DATABASE, "$payments_data_path") || &file_open_error ("$payments_data_path", "Post Payment", __FILE__, __LINE__); if ($flock) { flock DATABASE, 2; } open (NEW_DATABASE, ">$new_payments_data_file_path") || &file_open_error ("$new_payments_data_file_path", "Post Payment", __FILE__, __LINE__); while () { $line = $_; chop $line; @fields = split (/\|/, $line); ($dbmonth,$dbday,$dbyear) = split (/\//, $fields[10]); $julian_day = &jday($dbmonth,$dbday,$dbyear); ($today_month,$today_day,$today_year) = split (/\//, &get_date); $today = &jday($today_month,$today_day,$today_year); ($dbmonth,$dbday,$dbyear) = split (/\//, $fields[33]); $pastdue_notice_day = &jday($dbmonth,$dbday,$dbyear); $notice_days_ago = ($today - $pastdue_notice_day); $pastdue_flag = ($notice_days_ago - $pastdue_notice_interval); $pastdue_credits = ($fields[30] + $fields[32]); $pastdue_amount = ($fields[8] - $pastdue_credits); if (($today > $julian_day) && ($pastdue_flag >= 0) && ($pastdue_amount > 0)) { push (@pastdue_ads, $fields[7]); $new_payments_row = "$fields[0]|$fields[1]|$fields[2]|$fields[3]|$fields[4]|$fields[5]|$fields[6]|$fields[7]|$fields[8]|$fields[9]|$fields[10]|$fields[11]|$fields[12]|$fields[13]|$fields[14]|$fields[15]|$fields[16]|$fields[17]|$fields[18]|$fields[19]|$fields[20]|$fields[21]|$fields[22]|$fields[23]|$fields[24]|$fields[25]|$fields[26]|$fields[27]|$fields[28]|$fields[29]|$fields[30]|$fields[31]|$fields[32]|$current_date|$fields[34]"; print NEW_DATABASE "$new_payments_row\n"; } else { print NEW_DATABASE "$line\n"; } # End of else } # End of while () close (NEW_DATABASE); if ($flock) { rename($new_payments_data_file_path, $payments_data_path); } close (DATABASE); if (!$flock) { unlink("$payments_data_path"); rename($new_payments_data_file_path, $payments_data_path); } if ($os eq "unix") { chmod 0666, "$payments_data_path"; } if (!$flock) { &release_file_lock("$location_of_payments_lock_file"); } open (DATABASE, "$data_file_path") || &file_open_error ("$data_file_path", "Send Past Due Notices", __FILE__, __LINE__); while () { $line = $_; chop $line; @fields = split (/\|/, $line); foreach $ad (@pastdue_ads) { if ($ad eq $fields[$index_of_db_id]) { &require_supporting_libraries (__FILE__, __LINE__, "$path/html/mail.pl"); &pastdue_notice_message; $from = $master_admin_email_address; $to = $fields[$index_of_email]; &send_mail($from, $to, $subject, $message); next; } } } # end of while close (DATABASE); &pagesetup("Past Due Notices Sent"); &pastdue_notices_sent; &pageclose; } sub review_payment_stats { $new_ad_revenue = 0; $new_ad_refunds = 0; $renewal_ad_revenue = 0; $renewal_ad_refunds = 0; $credits = 0; $amount_due = 0; $pastdue_counter = 0; $pastdue_receivables = 0; $current_receivables = 0; open (DATABASE, "$payments_data_path") || &file_open_error ("$payments_data_path", "Post Payment", __FILE__, __LINE__); while () { $line = $_; chop $line; @fields = split (/\|/, $line); ($dbmonth,$dbday,$dbyear) = split (/\//, $fields[10]); $julian_day = &jday($dbmonth,$dbday,$dbyear); ($today_month,$today_day,$today_year) = split (/\//, &get_date); $today = &jday($today_month,$today_day,$today_year); if ($fields[6] eq "post") { $new_ad_revenue += $fields[8]; $new_ad_refunds += $fields[30]; } if ($fields[6] eq "renewal") { $renewal_ad_revenue += $fields[8]; $renewal_ad_refunds += $fields[30]; } $credits = ($fields[30] + $fields[32]); $amount_due = ($fields[8] - $credits); if ($amount_due > 0) { if ($today > $julian_day) { $pastdue_counter++; $pastdue_days += ($today - $julian_day); $pastdue_receivables += $amount_due; } else { $current_receivables += $amount_due; } } } # End of while () close (DATABASE); if ($pastdue_counter == 0) { $average_pastdue_days = 0; } else { $average_pastdue_days = $pastdue_days / $pastdue_counter; } $total_ad_revenue = $new_ad_revenue + $renewal_ad_revenue; if ($total_ad_revenue == 0) { $new_ad_revenue_percent = 0; } else { $new_ad_revenue_percent = $new_ad_revenue / $total_ad_revenue; } $new_ad_revenue_percent = $new_ad_revenue_percent * 100; if ($total_ad_revenue == 0) { $renewal_ad_revenue_percent = 0; } else { $renewal_ad_revenue_percent = $renewal_ad_revenue / $total_ad_revenue; } $renewal_ad_revenue_percent = $renewal_ad_revenue_percent * 100; $total_receivables = $pastdue_receivables + $current_receivables; $total_ad_refunds = $new_ad_refunds + $renewal_ad_refunds; if ($total_ad_refunds == 0) { $new_ad_refunds_percent = 0; } else { $new_ad_refunds_percent = $new_ad_refunds / $total_ad_refunds; } $new_ad_refunds_percent = $new_ad_refunds_percent * 100; if ($total_ad_refunds == 0) { $renewal_ad_refunds_percent = 0; } else { $renewal_ad_refunds_percent = $renewal_ad_refunds / $total_ad_refunds; } $renewal_ad_refunds_percent = $renewal_ad_refunds_percent * 100; $new_ad_revenue = sprintf ("%.2f", $new_ad_revenue); $renewal_ad_revenue = sprintf ("%.2f", $renewal_ad_revenue); $total_ad_revenue = sprintf ("%.2f", $total_ad_revenue); $pastdue_receivables = sprintf ("%.2f", $pastdue_receivables); $current_receivables = sprintf ("%.2f", $current_receivables); $total_receivables = sprintf ("%.2f", $total_receivables); $new_ad_refunds = sprintf ("%.2f", $new_ad_refunds); $renewal_ad_refunds = sprintf ("%.2f", $renewal_ad_refunds); $total_ad_refunds = sprintf ("%.2f", $total_ad_refunds); $new_ad_revenue_percent = sprintf ("%.2f", $new_ad_revenue_percent); $renewal_ad_revenue_percent = sprintf ("%.2f", $renewal_ad_revenue_percent); $new_ad_refunds_percent = sprintf ("%.2f", $new_ad_refunds_percent); $renewal_ad_refunds_percent = sprintf ("%.2f", $renewal_ad_refunds_percent); $average_pastdue_days = sprintf ("%.2f", $average_pastdue_days); &pagesetup; &print_payment_stats; &pageclose; }