#!/usr/bin/perl
# -----------------------------------------------------------------------------
# This Software is Copyright (C) 1998-2004, All Rights Reserved
# -----------------------------------------------------------------------------
# This program is protected by local and international copyright laws. Any
# use of this program is subject to the the terms of the license agreement
# included as part of this distribution archive. Any other uses are stictly
# prohibited without the written permission of the Vendor and all other
# rights are reserved.
# -----------------------------------------------------------------------------
# Warning : Modifying this program violates your license agreement!
# -----------------------------------------------------------------------------
$SIG{__DIE__}=$SIG{__WARN__}=\&su;
my$cgifile=$0;$cgifile=~s/.*[\\\/]//;my@al=($0,$ENV{'SCRIPT_FILENAME'});my$cgidir=(grep(/$cgifile$/i&&s/^(.*)[\\\/].*/$1/,@al))[0];
$cgidir||=(($^O=~/mswin/i?`cd`:`pwd`)=~/(.*)/)[0];$cgidir=~s/\\/\//g;if(!$cgidir){die("Can't determine cgi directory!\n")}%hc=("progVer"=>"2.52","progRel"=>"June 25th,1999","progUpd"=>"April 19th,2004","perlOS"=>$^O||"Unknown","perlVer"=>$]||"Unknown","cgidir"=>$cgidir,"cgiurl"=>(split("/",$ENV{'SCRIPT_NAME'}))[-1],"ltime"=>time,"stime"=>time,"prod_id"=>18,"prog_build"=>'1966',"templatedir2"=>'../templates/interface',"templatedir3"=>'../templates',"debug"=>0,);%hh=('filelock'=>"$cgidir/../data/filelock.lock",'datadir'=>"$cgidir/../data",);
use Fcntl qw(:DEFAULT :flock);for(0..9){push(@ah,"limage$_")}for(1..75){push(@ah,"lfield$_")}
for(0..9){push(@ai,"himage$_")}for(1..50){push(@ai,"hfield$_")}for(1..50){push(@ac,"lfield$_"."_name");
push(@ac,"lfield$_"."_type");push(@ac,"lfield$_"."_active")}for(51..75){push(@ag,"lfield$_"."_name");
push(@ag,"lfield$_"."_type");push(@ag,"lfield$_"."_active")}for(1..50){push(@ac,"hfield$_"."_name");
push(@ac,"hfield$_"."_type");push(@ac,"hfield$_"."_active")}for(1..50){push(@aj,"hfield$_"."_order")}
for(1..75){push(@aj,"lfield$_"."_order")}for(1..75){push(@ap,"format_lfield$_")}for(1..50){
push(@am,"format_hfield$_")}%ho=("datafile"=>"listing.dat","filelock"=>"filelock.lock","fields"=>[qw(num owner created updated),@ah,'hidden',@ap],"backup"=>"disabled","cgiext"=>".cgi");%hl=("datafile"=>"user.dat","filelock"=>"filelock.lock","fields"=>[qw(num name login_id login_pw access created_mon created_day created_year expires_mon expires_day expires_year expires_date expires_never disabled listings_max listings_unlimited user_listed specify_filename homepage_filename notes),@ai,'listings_hidden',@am],"backup"=>"disabled","cgiext"=>".cgi");%hk=("datafile"=>"setup.dat","filelock"=>"filelock.lock","fields"=>["num",@ac,qw(company_name domain_name product_id publish_listing_index publish_homepage_index publish_listing_image0 publish_homepage_image0 upload_maxk login_timeout listing_perpage homepage_perpage userman_perpage db_sorting titlebar footerbar logoff_url image_url listing_dir listing_url homepage_dir homepage_url search_url time_adjh time_adj_hour time_adjm time_adj_min installed),@ag,qw(d prog_ver max_filelock_duration c demo branding publish_ext thumbnail_create thumbnail_width thumbnail_height ind_industry ind_industry_name ind_program_name ind_login_image ind_template_dir),@aj,qw(ind_program_name_image)],"backup"=>"disabled","cgiext"=>".cgi");%ih=("datafile"=>"help.dat","filelock"=>"filelock.lock","fields"=>[qw(num parent title content)],"backup"=>"disabled","cgiext"=>".cgi");%hd=&uz;%hv=&uy;{
my$datafile="$hc{'cgidir'}/../data/$hk{'datafile'}$hk{'cgiext'}";if(open(FILE,"<$datafile")){
my($data_line)=grep{/^\d/}<FILE>;close(FILE);$ha{'max_filelock_duration'}=(split(/¡/,$data_line))[405]}
if($ha{'max_filelock_duration'}<5){$ha{'max_filelock_duration'}=5}}&sk(\%hk,\%ha,1);$hc{'titlebar'}=$ha{'titlebar'};
$hc{'footerbar'}=$ha{'footerbar'};$hc{'image_url'}=$ha{'image_url'};$hc{'homepage_url'}=$ha{'homepage_url'};
$hc{'listing_url'}=$ha{'listing_url'};$hc{'search_url'}=$ha{'search_url'};$hc{'search_homepage_url'}=$ha{'search_url'};
$hc{'search_homepage_url'}=~s/search\.(\w+)$/search_homepage.$1/i;$hc{'header_product'}=$ha{'ind_program_name'};
$hc{'header_version'}=$hc{'progVer'};$hc{'header_company_name'}=$ha{'company_name'};$hc{'header_domain_name'}=$ha{'domain_name'};
$hc{'header_license_num'}=&we($ha{'product_id'});$hc{'upload_maxk'}=$ha{'upload_maxk'};$hc{'publish_ext'}=$ha{'publish_ext'}||"html";
$hc{'thumbnail_width'}=$ha{'thumbnail_width'};$hc{'thumbnail_height'}=$ha{'thumbnail_height'};
$hc{'templatedir1'}=$ha{'ind_template_dir'};$hc{'ind_industry'}=$ha{'ind_industry'};$hc{'ind_industry_name'}=$ha{'ind_industry_name'};
$hc{'ind_program_name'}=$ha{'ind_program_name'};$hc{'ind_login_image'}=$ha{'ind_login_image'};
$hc{'ind_program_name_image'}=$ha{'ind_program_name_image'};if($ha{'time_adjh'}eq"add"){$hc{'ltime'}+=(int($ha{'time_adj_hour'}*60*60))};
if($ha{'time_adjh'}eq"minus"){$hc{'ltime'}-=(int($ha{'time_adj_hour'}*60*60))};if($ha{'time_adjm'}
eq"add"){$hc{'ltime'}+=(int($ha{'time_adj_min'}*60))};if($ha{'time_adjm'}eq"minus"){$hc{'ltime'}-=(int($ha{'time_adj_min'}*60))};
$hm{'mon'}=(localtime($hc{'ltime'}))[4]+1;$hm{'day'}=(localtime($hc{'ltime'}))[3];$hm{'year'}=(localtime($hc{'ltime'}))[5]+1900;
$hm{'date'}=sprintf("%04d%02d%02d",$hm{'year'},$hm{'mon'},$hm{'day'});$|++;%hj=&tm("$hc{'cgidir'}/config.ini");
umask oct($hj{'umask'})if$hj{'umask'};&tn("$hc{'cgidir'}/vconfig.dat",\%hj);$hc{'_vendor_name'}=$hj{'vendor_name'};
$hc{'_vendor_url'}=$hj{'vendor_url'};$hc{'_vendor_location'}=$hj{'vendor_location'};if($hj{'thumbnailing'}{'disable_thumbnails'}){
$ha{'thumbnail_create'}=0;&sn(\%hk,\%ha,1)}sub tm{local(*FILE);my($file)=$_[0];my(@ad,$ref,%hi);
$ref=\%hi;if(!$_[0]){die"INI_Load : No ini file was specified!\n"}if(!-e $_[0]){return %hi=()}
open(FILE,"<$file")||die("INI_Load : Could open ini file! $!\n");@ad=<FILE>;close(FILE);foreach(@ad){/^\s*#/m&&next;
if(/^\s*\[/m){$ref=\%hi;foreach(/\[(.+?)\]/g){$ref=\%{$ref->{$_}}}next}my$pos=index($_,'=');
if($pos>0){my$name=substr($_,0,$pos);my$value=substr($_,$pos+1);foreach($name,$value){s/^\s+//; s/\s+$//}$name=~/[^\w]/&&die("INI_Load : Invalid key '$name' in ini file '$file'!\n");
defined $ref->{$name}&&die("INI_Load : Key '$name' defined twice in ini file '$file'!\n");
$ref->{$name}=$value}elsif($pos==-1){my$name=$_;for($name){s/^\s+//; s/\s+$//}if(!length $name){
next}defined $ref->{$name}&&die("INI_Load : Key '$name' defined twice in ini file '$file'!\n");
$ref->{$name}=1}}return %hi}sub we{my($w,$x,$y,$z)=split(/-/,shift);my($v)=$w+join("",unpack("C3",$x))+$z;
while(length $v>7){$v>>=1}if(!($w%47)&&$w/20.68==(5*20)&&$x=~/^[A-Z]{3}$/&&!($z%47)&&$y==$v){
if($x eq"\x43\x47\x57"){return(($z/47)+6000)}elsif($x eq"\x55\x50\x47"){return(($z/47)+8000)}
elsif($x eq"\x45\x44\x49"){return(($z/47))}else{return(0)}}else{return(0)}}sub xw{if(!$hc{'contentheader'}++){
print'Content-type: text/html'."\n\n"}print&wk();exit}sub wk{if(&wr($hj{'vendor_name'})){return &ws()}
else{return &vr('_license.html',{})}}sub wr{my$vendor=shift||die("No 'vendor' name specified (make sure it's defined in INI file)");
my$vendor_hash=$vendor;$vendor_hash=~s/^\s+|\s+$//sg;$vendor_hash=~s/(.{1,8})/crypt($1,'AA')/sge;
$vendor_hash=~s/AA//gs;if($vendor_hash eq'WhkMKzyGr7g0JXhsaugam24y7UOthz/E62TMdkIYlsVw'){return 1}
return 0}sub wo{my$s=pack 'H*','3c7461626c6520626f726465723d312063656c6c73706163696e673d3'.'02063656c6c70616464696e673d382077696474683d313030253e3c74'.'723e3c7464206267636f6c6f723d2223454545454545223e3c666f6e7'.'420666163653d226d732073616e732073657269662c20617269616c22'.'2073697a653d323e0a3c703e3c623e506c65617365204e6f74653a3c2'.'f623e20245f76656e646f725f6e616d65242068617320676976656e20'.'796f752074686520726967687420746f203c623e7375626c6963656e7'.'3653c2f623e200a7468697320736f66747761726520756e6465722074'.'6865207465726d73206f6620746865203c6120687265663d222463676'.'975726c243f73686f775f6c6963656e73653d3122207461726765743d'.'225f6e6577223e6c6963656e73652061677265656d656e743c2f613e2'.'e3c2f703e0a0a3c703e466f7220696e737472756374696f6e73206f6e'.'20686f7720746f207375626c6963656e736520616e642f6f722070726'.'976617465206c6162656c207468697320736f6674776172652c20636f'.'6e73756c7420796f757220646f63756d656e746174696f6e206f72206'.'36f6e74616374203c6120687265663d22245f76656e646f725f75726c'.'2422207461726765743d225f6e6577223e245f76656e646f725f6e616'.'d65243c2f613e20666f7220696e666f726d6174696f6e2e3c2f703e0a'.'3c2f666f6e743e3c2f74643e3c2f74723e3c2f7461626c653e';
$s=~s|\$cgiurl\$|$hc{'cgiurl'}|iges;return &wj($s)}sub ws{my$s=pack 'H*','3c68746d6c3e0a3c686561643e0a3c7469746c653e245f76656e646f7'.'25f6e616d6524202d20536f667477617265204c6963656e7365204167'.'7265656d656e743c2f7469746c653e0a3c7374796c6520747970653d2'.'2746578742f637373223e3c212d2d0a2e686561646572202020207b20'.'666f6e742d66616d696c793a20417269616c2c2048656c76657469636'.'12c2073616e732d73657269663b20666f6e742d73697a653a20313670'.'783b20666f6e742d7765696768743a20626f6c643b207d0a2e6d61696'.'e7465787420207b20666f6e742d66616d696c793a2056657264616e61'.'2c20417269616c2c2048656c7665746963612c2073616e732d7365726'.'9663b20666f6e742d73697a653a20313170787d0a2d2d3e3c2f737479'.'6c653e0a3c2f686561643e0a3c626f6479206267636f6c6f723d22234'.'646464646462220746578743d222330303030303022206c696e6b3d22'.'233030303043432220766c696e6b3d22233030303043432220616c696'.'e6b3d222330303030434322206d617267696e77696474683d3135206d'.'617267696e6865696768743d313520746f706d617267696e3d3135206'.'c6566746d617267696e3d3135206f6e6c6f61643d2277696e646f772e'.'666f6375732829223e0a0a3c666f6e7420636c6173733d226d61696e7'.'4657874223e0a0a3c703e3c666f6e7420666163653d22617269616c22'.'2073697a653d3420636c6173733d22686561646572223e3c623e3c666'.'f6e7420636f6c6f723d2223434330303030223e536f66747761726520'.'4c6963656e73652041677265656d656e743c2f666f6e743e3c2f623e3'.'c2f666f6e743e3c62723e0a0a3c703e3c623e494d504f5254414e5420'.'2d2052454144204341524546554c4c593a3c2f623e2054686973204c6'.'963656e73652041677265656d656e742069732061206c6567616c200a'.'61677265656d656e74206265747765656e20596f7520616e642056656'.'e646f722e2052656164206974206361726566756c6c79206265666f72'.'6520636f6d706c6574696e6720746865200a696e7374616c6c6174696'.'f6e2070726f6365737320616e64207573696e672074686520536f6674'.'776172652e2049742070726f76696465732061206c6963656e7365207'.'46f2075736520746865200a536f66747761726520616e6420636f6e74'.'61696e732077617272616e747920696e666f726d6174696f6e20616e6'.'4206c696162696c69747920646973636c61696d6572732e203c623e42'.'59200a494e5354414c4c494e472c20434f5059494e47204f52204f544'.'8455257495345205553494e472054484520534f4654574152452c2059'.'4f552041524520434f4e4649524d494e4720594f5552200a414343455'.'054414e4345204f462054484520534f46545741524520414e44204147'.'524545494e4720544f204245434f4d4520424f554e442042592054484'.'5205445524d53204f462054484953200a41475245454d454e542e2049'.'4620594f5520444f204e4f542041475245452c20444f204e4f5420494'.'e5354414c4c204f5220555345205448452050524f445543542e3c2f62'.'3e0a0a3c703e54686520536f667477617265206973206f776e6564206'.'2792056656e646f7220616e642f6f7220697473206c6963656e736f72'.'7320616e642069732070726f746563746564206279200a636f7079726'.'9676874206c61777320616e6420696e7465726e6174696f6e616c2063'.'6f707972696768742074726561746965732c2061732077656c6c20617'.'3206f74686572200a696e74656c6c65637475616c2070726f70657274'.'79206c61777320616e642074726561746965732e203c623e544845205'.'34f465457415245204953204c4943454e5345442c204e4f54200a534f'.'4c442e3c2f623e0a0a3c703e3c68722073697a653d313e0a0a3c703e3'.'12e203c623e444546494e4954494f4e532e3c2f623e0a0a3c6f6c2074'.'7970653d2261223e0a3c6c693e202256656e646f7222206d65616e732'.'03c6120687265663d22245f76656e646f725f75726c24222074617267'.'65743d225f6e6577223e245f76656e646f725f6e616d65243c2f613e0'.'a3c6c693e2022596f75222c2022596f757222206d65616e7320796f75'.'20616e6420796f757220636f6d70616e792e0a3c6c693e2022536f667'.'47761726522206d65616e73207468652070726f647563742070726f76'.'6964656420746f20596f752c20776869636820696e636c75646573206'.'36f6d707574657220736f6674776172650a616e64206d617920696e63'.'6c756465206173736f636961746564206d656469612c207072696e746'.'564206d6174657269616c732c20616e6420226f6e6c696e6522206f72'.'20656c656374726f6e69630a646f63756d656e746174696f6e2e0a3c2'.'f6f6c3e0a0a3c703e322e203c623e4f574e4552534849502e3c2f623e'.'0a0a54686520536f667477617265206973206f776e656420616e64206'.'36f7079726967687465642062792056656e646f7220616e642f6f7220'.'697473206c6963656e736f72732e20596f7572200a6c6963656e73652'.'0636f6e66657273206e6f207469746c65206f72206f776e6572736869'.'7020696e2074686520536f66747761726520616e64206973206e6f742'.'0612073616c65206f66200a616e792072696768747320696e20746865'.'20536f6674776172652e200a0a3c703e332e203c623e4752414e54204'.'f46204c4943454e53452e3c2f623e200a0a56656e646f72206772616e'.'747320596f752074686520666f6c6c6f77696e6720726967687473207'.'0726f766964656420596f7520636f6d706c79207769746820616c6c20'.'7465726d73200a616e6420636f6e646974696f6e73206f66207468697'.'32061677265656d656e742e2020466f722065616368206c6963656e73'.'6520596f75206861766520616371756972656420666f7220746865200'.'a536f6674776172653a0a3c6f6c20747970653d2261223e0a3c6c693e'.'596f7520617265206772616e7465642061206e6f6e2d6578636c75736'.'9766520726967687420746f2075736520616e6420696e7374616c6c20'.'4f4e4520636f7079206f662074686520736f667477617265206f6e204'.'f4e4520776562736974652e0a3c6c693e596f75206d617920616c6c6f'.'7720616e20756e6c696d69746564206e756d626572206f66207573657'.'27320746f20616363657373206f72206f746865727769736520757469'.'6c697a65207468650a7365727669636573206f722066756e6374696f6'.'e616c697479206f662074686520696e7374616c6c656420736f667477'.'6172652e0a3c6c693e596f75206d6179206d616b65206f6e6520636f7'.'07920666f72206261636b7570206f7220617263686976616c20707572'.'706f7365732e0a3c6c693e596f75206d6179206d6f646966792074686'.'52074656d706c6174652066696c657320636f6e7461696e656420696e'.'207468652074656d706c6174657320666f6c646572202869662061707'.'06c696361626c65292e0a3c2f6f6c3e0a0a3c703e342e203c623e5245'.'5354524943544544205553452e3c2f623e0a0a3c6f6c20747970653d2'.'261223e0a3c6c693e20596f7520616772656520746f20757365207265'.'61736f6e61626c65206566666f72747320746f2070726576656e74207'.'56e617574686f72697a656420636f7079696e67206f66207468652053'.'6f6674776172652e0a3c6c693e20596f75206d6179206e6f742064697'.'361626c6520616e79206c6963656e73696e67206f7220636f6e74726f'.'6c206665617475726573206f662074686520536f667477617265206f7'.'220616c6c6f772074686520536f6674776172650a746f206265207573'.'6564207769746820737563682066656174757265732064697361626c6'.'5642e0a3c6c693e596f75206d6179206e6f742073686172652c207265'.'6e742c206f72206c6561736520596f757220726967687420746f20757'.'3652074686520536f6674776172652e0a3c6c693e20596f75206d6179'.'206e6f74206d6f646966792c207375626c6963656e73652c20636f707'.'92c2072656e742c2073656c6c2c2064697374726962757465206f7220'.'7472616e7366657220616e792070617274200a6f662074686520536f6'.'67477617265206578636570742061732070726f766964656420696e20'.'746869732041677265656d656e742e0a3c6c693e596f75206d6179206'.'e6f74207265766572736520656e67696e6565722c206465636f6d7069'.'6c652c207472616e736c6174652c20637265617465206465726976617'.'469766520776f726b732c200a64656369706865722c20646563727970'.'742c20646973617373656d626c652c206f72206f74686572776973652'.'0636f6e766572742074686520536f66747761726520746f2061206d6f'.'7265200a68756d616e2d7265616461626c6520666f726d20666f72206'.'16e7920726561736f6e2e0a3c6c693e20596f752077696c6c20726574'.'75726e206f722064657374726f7920616c6c20636f70696573206f662'.'074686520536f66747761726520616e642067656e6572617465642063'.'6f6e74656e740a286966206170706c696361626c652920696620616e6'.'4207768656e20596f757220726967687420746f207573652069742065'.'6e64732e200a3c6c693e3c623e596f75206d6179206e6f74207573652'.'074686520536f66747761726520666f7220616e7920707572706f7365'.'207468617420697320756e6c617766756c2e3c2f623e0a3c2f6f6c3e0'.'a0a3c703e352e203c623e4144444954494f4e414c20534f4654574152'.'453c2f623e2054686973206c6963656e7365206170706c69657320746'.'f20757064617465732c2075706772616465732c200a706c75672d696e'.'7320616e6420616e79206f74686572206164646974696f6e7320746f2'.'0746865206f726967696e616c20536f6674776172652070726f766964'.'65642062792056656e646f722c200a756e6c6573732056656e646f722'.'070726f7669646573206f74686572207465726d7320616c6f6e672077'.'69746820746865206164646974696f6e616c20736f6674776172652e0'.'a0a3c703e362e203c623e335244205041525459205345525649434553'.'3c2f623e205468697320536f667477617265206d6179206d616b65207'.'57365206f662c206f72206861766520746865200a6162696c69747920'.'746f206d616b6520757365206f662c206c696e6b20746f2c206f72206'.'96e7465677261746520776974682033726420706172747920636f6e74'.'656e74206f72200a73657276696365732e2054686520617661696c616'.'2696c697479206f662074686520636f6e74656e74206f722073657276'.'696365732069732061742074686520736f6c652064697363726574696'.'f6e200a6f662074686520337264207061727479207365727669636520'.'70726f76696465727320616e64206d6179206265207375626a6563742'.'0746f2075736167652061677265656d656e747320616e64200a6f7468'.'6572207265737472696374696f6e732e2020596f75206167726565207'.'46f20696e64656d6e69667920616e642073617665206861726d6c6573'.'732056656e646f7220616e6420697473200a6c6963656e736f7273206'.'6726f6d20616c6c20636c61696d732c2064616d616765732c20616e64'.'20657870656e736573206f66207768617465766572206e61747572652'.'074686174206d6179206265200a6d61646520616761696e7374205665'.'6e646f7220616e6420697473206c6963656e736f72732062792033726'.'420706172747920636f6e74656e7420616e6420736572766963652070'.'726f766964657273200a6173206120726573756c74206f6620596f757'.'220757365206f662074686520536f6674776172652e0a0a3c703e372e'.'203c623e524547495354524154494f4e2e3c2f623e2054686520736f6'.'674776172652077696c6c20656c656374726f6e6963616c6c79207265'.'67697374657220697473656c66200a647572696e6720696e7374616c6'.'c6174696f6e206f722072656c6f636174696f6e20616e6420636f6e66'.'69726d207468617420596f75206861766520656e74657265642061207'.'6616c6964200a2250726f64756374204944222e205468652072656769'.'7374726174696f6e2070726f63657373206f6e6c792073656e6473207'.'46865206c6963656e736520696e666f726d6174696f6e207468617420'.'0a596f7527766520656e74657265642028436f6d70616e79204e616d6'.'52c20446f6d61696e204e616d652c2050726f64756374204944292061'.'6e6420696e666f726d6174696f6e2061626f757420746865200a736f6'.'6747761726520696e7374616c6c6564202850726f6772616d2049442c'.'2056657273696f6e2c20496e7374616c6c2055524c2c20436865636b7'.'3756d292e20204e6f206f74686572200a696e666f726d6174696f6e20'.'69732073656e742e0a0a3c703e382e203c623e55504752414445532e2'.'03c2f623e204966207468697320636f7079206f662074686520736f66'.'747761726520697320616e20757067726164652066726f6d20616e200'.'a6561726c6965722076657273696f6e206f662074686520736f667477'.'6172652c2069742069732070726f766964656420746f20596f75206f6'.'e2061206c6963656e73652065786368616e6765200a62617369732e20'.'20596f757220757365206f662074686520536f6674776172652075706'.'772616465206973207375626a65637420746f20746865207465726d73'.'206f662074686973200a6c6963656e73652c20616e6420596f7520616'.'772656520627920596f757220696e7374616c6c6174696f6e20616e64'.'20757365206f66207468697320636f7079206f662074686520536f667'.'477617265200a746f20766f6c756e746172696c79207465726d696e61'.'746520596f7572206561726c696572206c6963656e736520616e64207'.'468617420596f752077696c6c206e6f7420636f6e74696e756520746f'.'200a75736520746865206561726c6965722076657273696f6e206f662'.'074686520536f667477617265206f72207472616e7366657220697420'.'746f20616e6f7468657220706572736f6e206f72200a656e746974792'.'e0a0a3c703e392e203c623e5452414e534645522e203c2f623e202059'.'6f75206d6179206d616b652061206f6e652d74696d65207472616e736'.'66572206f662074686520536f667477617265200a616e6420596f7572'.'2072696768747320756e6465722074686973206c6963656e736520746'.'f20616e6f746865722070617274792070726f76696465642074686174'.'3a0a0a3c6f6c20747970653d2261223e0a3c6c693e20596f752070726'.'f766964652074686520706172747920776974682074686520536f6674'.'776172652c20616e79202250726f647563742049442220636f6465732'.'c20616e642074686973206c6963656e73652e0a3c6c693e2054686520'.'7061727479206163636570747320746865207465726d73206f6620746'.'86973206c6963656e7365206173206120636f6e646974696f6e206f66'.'20746865207472616e736665722e0a3c6c693e20596f7520646573747'.'26f7920616e79206f7468657220636f70696573206f66207468652053'.'6f66747761726520616e642067656e65726174656420636f6e74656e7'.'420286966206170706c696361626c652920696e20596f757220706f73'.'73657373696f6e2e0a3c6c693e20596f75206e6f746966792056656e6'.'46f72206f6620746865207472616e736665722e0a3c2f6f6c3e0a0a59'.'6f75722072696768747320756e6465722074686973206c6963656e736'.'5206175746f6d61746963616c6c79207465726d696e6174652075706f'.'6e207472616e736665722e0a0a3c703e31302e203c623e5355424c494'.'3454e53494e472e3c2f623e20596f75206d6179207375626c6963656e'.'73652074686520536f66747761726520616e6420596f7572207269676'.'8747320756e6465720a74686973206c6963656e736520746f20616e6f'.'746865722070617274792070726f766964656420746861743a0a0a3c6'.'f6c20747970653d2261223e0a3c6c693e20596f7520756e6465727374'.'616e6420616e6420616772656520746f20746865207465726d73206f6'.'62074686973206c6963656e73652061677265656d656e742e0a3c6c69'.'3e2054686520536f667477617265206973206f6e6c79207375626c696'.'3656e736564204f4e43452c20746f20612073696e676c652070617274'.'792e0a3c6c693e20596f7520617265206e6f74207573696e672074686'.'520536f667477617265206166746572206772616e74696e6720746865'.'207375626c6963656e73652e0a3c6c693e20546865207375626c69636'.'56e736520697320612076616c69642c2062696e64696e67206c696365'.'6e73652e0a3c6c693e20546865207375626c6963656e736520636f6e7'.'461696e73207465726d73207468617420617265206e6f206c65737320'.'7265737472696374697665207468616e20746869732061677265656d6'.'56e740a20202020286f72207468652073616d65207465726d73206173'.'20746869732061677265656d656e742920616e6420646f6573206e6f7'.'420636f6e7461696e207468697320726967687420746f207375626c69'.'63656e73652e0a3c6c693e20546865206c6567616c206a75726973646'.'96374696f6e20666f7220746865207375626c6963656e736520697320'.'646566696e6564206173206569746865722074686174206f662074686'.'52056656e646f72206f720a202020202074686174206f6620596f7572'.'20636f72706f726174652068656164206f66666963652e0a3c6c693e2'.'0596f7520646f206e6f74206d616b6520616e7920726570726573656e'.'746174696f6e73206f722077617272616e74696573206f6e206265686'.'16c66206f662056656e646f722e0a0a3c6c693e20596f752061677265'.'6520746f20656e666f72636520746865207465726d73206f6620616e7'.'9207375626c6963656e7365207468617420596f752061726520617574'.'686f72697a656420746f206d616b652e200a496620596f75206661696'.'c20746f20646f20736f2c20596f752061677265652074686174205665'.'6e646f72206d61792074616b65207375636820737465707320696e205'.'96f7572206e616d6520616e64200a617320596f7572206167656e742c'.'20696e636c7564696e67206c6567616c2070726f63656564696e67732'.'06966206e65636573736172792c20746f20656e666f72636520746865'.'200a7375626c6963656e7365206772616e74656420627920596f752e0'.'a0a3c6c693e20596f75206e6f746966792056656e646f72206f662074'.'6865207375626c6963656e736520616e6420616e79207375627365717'.'5656e74207472616e736665727320627920746865207375626c696365'.'6e7365642070617274792e0a3c2f6f6c3e0a0a3c703e31312e203c623'.'e5445524d494e4154494f4e2e3c2f623e2056656e646f72206d617920'.'7465726d696e61746520596f7572206c6963656e736520696620596f7'.'520646f206e6f74206162696465200a627920746865206c6963656e73'.'65207465726d732e205465726d696e6174696f6e206f6620746865206'.'c6963656e7365206d617920696e636c7564652c20627574206e6f7420'.'6265206c696d69746564200a746f2c206d61726b696e6720746865205'.'0726f6475637420494420617320696e76616c696420746f2070726576'.'656e74206675727468657220696e7374616c6c6174696f6e732e20557'.'06f6e200a7465726d696e6174696f6e206f66206c6963656e73652c20'.'596f75207368616c6c20696d6d6564696174656c7920646973636f6e7'.'4696e75652074686520757365206f6620746865200a536f6674776172'.'6520616e64207368616c6c2077697468696e2074656e2028313029206'.'46179732072657475726e20746f2056656e646f7220616c6c20636f70'.'696573206f6620746865200a536f667477617265206f7220636f6e666'.'9726d207468617420596f7520686176652064657374726f7965642061'.'6c6c20636f70696573206f662069742e203c623e596f7572200a6f626'.'c69676174696f6e7320746f2070617920616363727565642063686172'.'67657320616e6420666565732c20696620616e792c207368616c6c207'.'375727669766520616e79200a7465726d696e6174696f6e206f662074'.'6869732041677265656d656e742e3c2f623e2056656e646f722773207'.'468697264207061727479206c6963656e736f7273206d61792070726f'.'74656374200a74686569722072696768747320696e207468652065766'.'56e74206f6620616e792076696f6c6174696f6e206f66207468652074'.'65726d7320616e6420636f6e646974696f6e73206f662074686973200'.'a6c6963656e73652e20596f7520616772656520746f20696e64656d6e'.'6966792056656e646f7220616e6420697473206c6963656e736f72732'.'0666f7220726561736f6e61626c65206174746f726e6579200a666565'.'7320696e20656e666f7263696e6720697473207269676874732070757'.'27375616e7420746f2074686973206c6963656e73652e0a0a3c703e31'.'322e203c623e444953434c41494d4552204f462057415252414e54592'.'e3c2f623e2054686520536f6674776172652069732070726f76696465'.'64206f6e20616e2022415320495322200a62617369732c20776974686'.'f75742077617272616e7479206f6620616e79206b696e642c20696e63'.'6c7564696e672c20776974686f7574206c696d69746174696f6e2c207'.'46865200a77617272616e74696573206f66206d65726368616e746162'.'696c6974792c206669746e65737320666f72206120706172746963756'.'c617220707572706f736520616e64206e6f6e2d0a696e6672696e6765'.'6d656e742e2054686520656e74697265207269736b20617320746f207'.'46865207175616c69747920616e6420706572666f726d616e6365206f'.'662074686520536f667477617265200a697320626f726e65206279205'.'96f752e2053686f756c642074686520536f6674776172652070726f76'.'65206465666563746976652c20596f752c206e6f742056656e646f722'.'06f7220697473200a6c6963656e736f72732c20617373756d65207468'.'6520656e7469726520636f7374206f6620616e7920736572766963652'.'0616e64207265706169722e2049662074686520536f66747761726520'.'6973200a696e74656e64656420746f206c696e6b20746f2c206578747'.'261637420636f6e74656e742066726f6d206f72206f74686572776973'.'6520696e7465677261746520776974682061207468697264200a70617'.'2747920736572766963652c2056656e646f72206d616b6573206e6f20'.'726570726573656e746174696f6e206f722077617272616e747920746'.'8617420596f757220706172746963756c6172200a757365206f662074'.'686520536f667477617265206973206f722077696c6c20636f6e74696'.'e756520746f20626520617574686f72697a6564206279206c61772069'.'6e20596f7572200a6a7572697364696374696f6e206f7220746861742'.'074686520746869726420706172747920736572766963652077696c6c'.'20636f6e74696e756520746f20626520617661696c61626c6520746f2'.'00a596f752e205468697320646973636c61696d6572206f6620776172'.'72616e747920636f6e737469747574657320616e20657373656e74696'.'16c2070617274206f66207468652061677265656d656e742e0a0a3c70'.'3e31332e203c623e4c494d49544154494f4e204f46204c494142494c4'.'954592e20554e444552204e4f2043495243554d5354414e4345532041'.'4e4420554e444552204e4f204c4547414c200a5448454f52592c20544'.'f52542c20434f4e54524143542c204f52204f54484552574953452c20'.'5348414c4c2056454e444f52204f5220495453204c4943454e534f525'.'3204245204c4941424c45200a544f20594f55204f5220414e59204f54'.'48455220504552534f4e20464f5220414e5920494e4449524543542c2'.'05350454349414c2c2050554e49544956452c20494e434944454e5441'.'4c2c204f52200a434f4e53455155454e5449414c2044414d414745532'.'04f4620414e592043484152414354455220494e434c5544494e472c20'.'574954484f5554204c494d49544154494f4e2c2044414d41474553200'.'a464f5220574f524b2053544f50504147452c20434f4d505554455220'.'4641494c555245204f52204c4f5353204f4620524556454e5545532c2'.'050524f464954532c20474f4f4457494c4c2c205553452c200a444154'.'41204f52204f5448455220494e54414e4749424c45204f522045434f4'.'e4f4d4943204c4f535345532e20494e204e4f204556454e542057494c'.'4c2056454e444f52204f5220495453200a4c4943454e534f525320424'.'5204c4941424c4520464f5220414e592044414d4147455320494e2045'.'5843455353204f462054484520414d4f554e54205041494420544f204'.'c4943454e534520544845200a534f4654574152452c204556454e2049'.'4620594f55204f5220414e59204f54484552205041525459205348414'.'c4c204841564520494e464f524d45442056454e444f52204f52204954'.'53200a4c4943454e534f5253204f462054484520504f53534942494c4'.'95459204f4620535543482044414d414745532c204f5220464f522041'.'4e5920434c41494d2e204e4f20434c41494d2c200a5245474152444c4'.'55353204f4620464f524d2c204d4159204245204d414445204f522041'.'4354494f4e2042524f5547485420425920594f55204d4f52452054484'.'14e204f4e452059454152200a41465445522054484520424153495320'.'464f522054484520434c41494d204245434f4d4553204b4e4f574e205'.'44f2054484520504152545920415353455254494e472049542e3c2f62'.'3e0a0a3c703e31342e203c623e4150504c494341424c45204c41572e3'.'c2f623e2054686973206c6963656e7365207368616c6c20626520696e'.'74657270726574656420696e206163636f7264616e6365200a7769746'.'820746865206c617773206f6620245f76656e646f725f6c6f63617469'.'6f6e242e20416e792064697370757465732061726973696e67206f757'.'4206f662074686973206c6963656e7365200a7368616c6c2062652061'.'646a756469636174656420696e206120636f757274206f6620636f6d7'.'06574656e74206a7572697364696374696f6e20696e20245f76656e64'.'6f725f6c6f636174696f6e242e0a0a3c703e31352e203c623e474f564'.'5524e494e47204c414e47554147452e3c2f623e20416e79207472616e'.'736c6174696f6e206f662074686973204c6963656e736520697320646'.'f6e6520666f72200a6c6f63616c20726571756972656d656e74732061'.'6e6420696e20746865206576656e74206f66206120646973707574652'.'06265747765656e2074686520456e676c69736820616e6420616e7920'.'0a6e6f6e2d456e676c6973682076657273696f6e732c2074686520456'.'e676c6973682076657273696f6e206f662074686973204c6963656e73'.'65207368616c6c20676f7665726e2e0a0a3c703e31362e203c423e454'.'e544952452041475245454d454e542e3c2f623e2054686973206c6963'.'656e736520636f6e73746974757465732074686520656e74697265206'.'1677265656d656e74200a6265747765656e2074686520706172746965'.'732072656c6174696e6720746f2074686520536f66747761726520616'.'e64207375706572736564657320616e792070726f706f73616c206f72'.'200a7072696f722061677265656d656e742c206f72616c206f7220777'.'2697474656e2c20616e6420616e79206f7468657220636f6d6d756e69'.'636174696f6e2072656c6174696e6720746f20746865200a7375626a6'.'56374206d6174746572206f662074686973206c6963656e73652e2041'.'6e7920636f6e666c696374206265747765656e20746865207465726d7'.'3206f662074686973204c6963656e7365200a41677265656d656e7420'.'616e6420616e79205075726368617365204f726465722c20696e766f6'.'963652c206f7220726570726573656e746174696f6e207368616c6c20'.'6265207265736f6c766564200a696e206661766f7572206f662074686'.'5207465726d73206f662074686973204c6963656e7365204167726565'.'6d656e742e20496e20746865206576656e74207468617420616e79206'.'36c61757365200a6f7220706f7274696f6e206f6620616e7920737563'.'6820636c61757365206973206465636c6172656420696e76616c69642'.'0666f7220616e7920726561736f6e2c20737563682066696e64696e67'.'200a7368616c6c206e6f74206166666563742074686520656e666f726'.'3656162696c697479206f66207468652072656d61696e696e6720706f'.'7274696f6e73206f662074686973204c6963656e7365200a616e64207'.'4686520756e656e666f72636561626c6520636c61757365207368616c'.'6c20626520736576657265642066726f6d2074686973206c6963656e7'.'3652e203c623e416e79200a616d656e646d656e7420746f2074686973'.'2061677265656d656e74206d75737420626520696e2077726974696e6'.'720616e64207369676e656420627920626f746820706172746965732e'.'3c2f623e0a0a0a3c703e536f667477617265204c6963656e736520416'.'77265656d656e742076332e3120284a756e652033302c203230303329'.'0a0a0a3c703e3c68722073697a653d313e0a53686f756c6420796f752'.'06861766520616e79207175657374696f6e7320636f6e6365726e696e'.'672074686973206c6963656e73652c0a6f7220696620796f752064657'.'369726520746f20636f6e7461637420757320666f7220616e79207265'.'61736f6e2c20706c6561736520656d61696c206f722074656c6570686'.'f6e652e0a0a3c2f666f6e743e0a0a3c2f626f64793e3c2f68746d6c3e'.'0a';
return &wj($s)}sub wj{my$s=shift;$s=~s|\$_vendor_name\$|$hc{'_vendor_name'}|iges;$s=~s|\$_vendor_url\$|$hc{'_vendor_url'}|iges;
$s=~s|\$_vendor_location\$|$hc{'_vendor_location'}|iges;return $s}sub wg{my$hash=shift;my$s;
my$key;foreach$key(keys %$hash){my$value=&vx($hash->{$key});$s.="&"if($s);$s.="$key=$value"}$s=unpack('H*',$s);
$s=~tr/[A-F][a-f][0-9]/[A-F][A-F][G-P]/;return $s}sub wf{my$s=shift;my$hash={};$s=~tr/[A-F][G-P]//cd;
$s=~tr/[G-P]/[0-9]/;$s=pack('H*',$s);my$namevalue;foreach$namevalue(split('&',$s)){my($name,$value)=split('=',$namevalue);
$value=&vw($value);$hash->{$name}=$value}return $hash}sub tn{local(*FILE);my($file)=$_[0];
my($ref)=$_[1];my(@ad,$line);if(!$_[0]){die"INI_Load_Vendor : No data file was specified!\n"}
open(FILE,"<$file")||die("INI_Load_Vendor : Could open data file! $!\n");@ad=<FILE>;close(FILE);
my($hash);foreach$line(@ad){next if$line=~/^#/;$hash=&wf($line);my$key;foreach$key(%$hash){
$ref->{$key}=$hash->{$key}}}if(!$ref->{'vendor_name'}||!$ref->{'vendor_url'}||!$ref->{'vendor_location'}){
die("Keys missing from INI_Load_Vendor!\n")}return}$hc{'query'}=$ENV{'QUERY_STRING'};if($hd{'search'}){&va()}
elsif($hd{'view'}){&wh()}else{&us()}exit;sub us{print"Content-type: text/html\n\n" unless($ContentType++);
my$query_template=$hd{'template'}||'_search_query.html';unless(&yd($query_template)){&su("Invalid template name: $query_template")}$rowcode=sub{
if(!$he{'user_listed'}){return(0)}$hb{'userlist'}.=qq|<option value="$he{'num'}">$he{'name'}\n|};
$sortcode="1";&sh(\%hl,$rowcode,$sortcode,\%he);print&vr($query_template ,\%hb);&ya}sub va{
print"Content-type: text/html\n\n" unless($ContentType++);$pagenum=int$hd{'pagenum'}||1;$perpage=int$hd{'perpage'}||10;
my$result_template=$hd{'template'}||'_search_results.html';unless(&yd($result_template)){&su("Invalid template name: $result_template")}
if($hd{'marknew'}){$marknew=time - ($hd{'marknew'}*60*60*24)}if($hd{'shownew'}){$shownew=time - ($hd{'shownew'}*60*60*24)}
my$euro_numbers=$hd{'euro_numbers'};&vr($result_template);$rowcode=sub{$id{$he{'num'}}=$he{'name'};
$ia{$he{'num'}}=$he{'listings_hidden'};if($he{'specify_filename'}&&$he{'homepage_filename'}){
$if{$he{'num'}}=$he{'homepage_filename'}}else{$if{$he{'num'}}=sprintf("h%04d.".$hc{'publish_ext'},$he{'num'})}};
&sh(\%hl,$rowcode,$sortcode,\%he);$query=sub{if($shownew){if($hd{'check_created'}){if($hf{'created'}<$shownew){
return(0)}}else{if($hf{'updated'}<$shownew){return(0)}}}$hf{'user_num'}=$hf{'owner'};$hf{'user_name'}=$id{
$hf{'owner'}};if($hf{'hidden'}||$ia{$hf{'owner'}}){return(0)}if($hd{'user_num'}&&$hd{'user_num'}!=$hf{'user_num'}){
return(0)}if($hd{'user_keyword'}&&$hf{'user_name'}!~/\Q$hd{'user_keyword'}\E/i){return(0)}
if($hd{'user_match'}&&lc$hf{'user_name'}ne lc$hd{'user_match'}){return(0)}if($hd{'listing_num'}
&&$hd{'listing_num'}!=$hf{'num'}){return(0)}for$num(1..75){$val=$hf{"lfield$num"};$nval=$hf{"lfield$num"};
$min=$hd{"lfield$num"."_min"};$max=$hd{"lfield$num"."_max"};$keyword=$hd{"lfield$num"."_keyword"};
$match=$hd{"lfield$num"."_match"};if($euro_numbers){foreach($nval,$min,$max){tr/,./.,/}}foreach($nval,$min,$max){
s/[^0-9\.]//gs}if((length $min)&&$min>$nval){return(0)}if((length $max)&&$max<$nval){return(0)}
if((length $keyword)&&$val!~/\Q$keyword\E/i){return(0)}if((length $match)&&lc$val ne lc$match){
return(0)}}return(1)};my$path="$hc{'cgidir'}/$ha{'listing_dir'}/images";$match=sub{$hf{'user_num'}=$hf{'owner'};
$hf{'user_name'}=$id{$hf{'owner'}};$hf{'user_file'}=$if{$hf{'owner'}};$hf{'file'}=$hf{'limage0'};
$hf{'thumbnail'}=&vu($path,$hf{'file'});$hf{'listing_file'}=sprintf("l%04d.".$hc{'publish_ext'},$hf{'num'});
$hf{'listing_num'}=$hf{'num'};for(1..75){if($hf{"format_lfield$_"}){$hf{"lfield$_"}=~s/(\r\n|\r|\n)/<br>\n/g}}
if($marknew&&(($hd{'check_created'}&&$hf{'created'}>=$marknew)||($hd{'check_created'}==0&&$hf{'updated'}>=$marknew)) ){
if($hf{'limage0'}){$hb{'list'}.=&vs("row_image_new",\%hf)}else{$hb{'list'}.=&vs("row_noimage_new",\%hf)}}
else{if($hf{'limage0'}){$hb{'list'}.=&vs("row_image",\%hf)}else{$hb{'list'}.=&vs("row_noimage",\%hf)}}};
if($ha{'db_sorting'}&&$hd{'sort_order'}){$sort=&wz()+13;($field,$order,$direction)=split(/\,/,$hd{'sort_order'});
$field+=13;if($order=~s/eu//){$euro_numbers++}if($order eq"123"&&$direction=~/^f/i&&!$euro_numbers){
$sort="#$field"}elsif($order eq"123"&&$direction!~/^f/i&&!$euro_numbers){$sort="-#$field"}
elsif($order eq"123"&&$direction=~/^f/i&&$euro_numbers){$sort="#%$field"}elsif($order eq"123"&&$direction!~/^f/i&&$euro_numbers){
$sort="-#%$field"}elsif($order eq"abc"&&$direction=~/^f/i){$sort="$field"}elsif($order eq"abc"&&$direction!~/^f/i){
$sort="-$field"}else{$sort=undef}}else{$sort=&wz()+13}($hb{'pcount'},$hb{'mcount'},$hb{'rcount'},$hb{'cpage'},$hb{'lpage'},$hb{'npage'})=&si(\%ho,$query,$match,$sort,\%hf,$pagenum,$perpage);
if(!$hb{'list'}){$hb{'list'}=&vs("not_found")}$hc{'query'}=~s/[^A-Za-z0-9\+\*\.\@\_\-\&\=\%]/uc sprintf("%%%02x",ord($&))/egx;
print&vr($result_template,\%hb);&ya;exit}sub wh{print"Content-type: text/html\n\n" unless($ContentType++);
my($num)=int$hd{'view'};my$view_template=$hd{'template'}||'_publish_listing.html';unless(&yd($view_template)){&su("Invalid template name: $view_template")}
&vr($view_template);local(%hb);$hb{'num'}=$hb{'listing_num'}=$num;my$found=&sk(\%ho,\%hf,$num);
if(!$found){&su("Listing number $num not found in database")}foreach(1..75){$hb{"lfield$_"}=$hf{"lfield$_"};
if($hf{"format_lfield$_"}){$hb{"lfield$_"}=~s/(\r\n|\r|\n)/<br>\n/g}}if($hf{'owner'}){&sk(\%hl,\%he,$hf{'owner'});
$hb{"user_num"}=$he{'num'};$hb{"user_name"}=$he{'name'}}if($he{'specify_filename'}&&$he{'homepage_filename'}){
$hb{"user_file"}=$he{'homepage_filename'}}else{$hb{"user_file"}=sprintf("h%04d.".$hc{'publish_ext'},$he{'num'})}
foreach(1..50){$hb{"hfield$_"}=$he{"hfield$_"};if($he{"format_hfield$_"}){$hb{"hfield$_"}=~s/(\r\n|\r|\n)/<br>\n/g}}
my($pfile)=sprintf("l%04d.".$hc{'publish_ext'},$num);if($ha{'publish_listing_image0'}){$start_inum=0}
else{$start_inum=1}my$path="$hc{'cgidir'}/$ha{'listing_dir'}/images";for($start_inum..9){$file=$hf{"limage$_"};
$filepath="$path/$file";$thumbnail=&vu($path,$file);open(FILE,"<$filepath.dat");$desc=<FILE>;
close(FILE);$hb{'file'}=$file;$hb{'thumbnail'}=$thumbnail;$hb{'desc'}=$desc;if($file&&-e $filepath){
$hb{'images'}.=&vs("image",\%hb)}}if(!$hb{'images'}){$hb{'images'}=&vs("no_images",\%hb)}foreach(keys %hb){
$hb{$_}=~s/\<\!--#/<!--|/go}my$content=&vr($view_template,\%hb);print$content;&ya}sub yd{my$filename=$_[0];
my$found=0;foreach(grep /^templatedir/,sort keys %hc){if(-e "$hc{'cgidir'}/$hc{$_}/$_[0]"){
$found=1;last}}return $found}sub su{print"Content-type: text/html\n\n" unless($ContentType++);
if(-e $hk{'filelock'}){&so($hk{'filelock'})}foreach(@_){$hb{'error'}.="$_ "}print$hb{'error'};
exit}sub ya{print'<!--'."\n";print$hc{'titlebar'}.' v'.$hc{'header_version'}.' (Build: '.$hc{'prod_id'}.'.'.$hc{'prog_build'}.")\n";
print'License #'.$hc{'header_license_num'}.' ~ '.$hc{'header_company_name'}.' ~ '.$hc{'header_domain_name'}."\n";
printf('Execute time: %01d seconds'."\n",time() - $^T);print'-->'."\n"}sub wz{my$field_index_to_sort_on;
my$user_field_to_sort_on=1;if($ha{'db_sorting'}){my@as=sort{($ha{"lfield$a"."_order"}eq'' ? 999 : $ha{"lfield$a"."_order"}!~/^\d+$/ ? 998 : $ha{"lfield$a"."_order"})<=>($ha{"lfield$b"."_order"}
eq'' ? 999 : $ha{"lfield$b"."_order"}!~/^\d+$/ ? 998 : $ha{"lfield$b"."_order"})||($ha{"lfield$a"."_order"}
eq'' ? 'a' : uc($ha{"lfield$a"."_order"}))cmp($ha{"lfield$b"."_order"}eq'' ? 'a' : uc($ha{"lfield$b"."_order"}))||(length($ha{"lfield$a"."_name"})||length($ha{"lfield$a"."_type"}) ? 1 : 2 )<=>(length($ha{"lfield$b"."_name"})||length($ha{"lfield$b"."_type"}) ? 1 : 2 )||$a<=>$b} (1..75);
$user_field_to_sort_on=$as[0]}return $user_field_to_sort_on}sub sh{if(ref($_[0])ne"HASH"){
die"DB_List : The first argument must be a HASH reference!\n"}if(ref($_[1])ne"CODE"&&$_[1]){
die"DB_List : The second argument must be a CODE reference!\n"}if(ref($_[3])ne"HASH"&&$_[3]){
die"DB_List : The fourth argument must be a HASH reference!\n"}if(!$_[0]->{'datafile'}){die"DB_List : No datafile was specified in the DB definition!\n"}
if(!$_[0]->{'filelock'}){die"DB_List : No filelock was specified in the DB definition!\n"}
if(ref($_[0]->{fields})ne"ARRAY"){die"DB_List : Field names in the DB definition must be a ARRAY reference!\n"}
if($#{$_[0]->{fields}}<0){die"DB_List : No fields were specified in the DB definition!\n"}
my($datafile)="$hc{'cgidir'}/../data/$_[0]->{'datafile'}";my($filelock)="$hc{'cgidir'}/../data/$_[0]->{'filelock'}";
my(@fields)=@{$_[0]->{fields}};my($backup)=$_[0]->{'backup'};$datafile.=$_[0]->{'cgiext'};
my($rowcode)=$_[1];my($sortcode)=$_[2];my($out)=$_[3];my(@aa);my(@ab);unless(-e $datafile){
return(0)}if($backup){&sd($_[0])}&sl($filelock);open(FILE,"<$datafile")||die("DB_List : Can't open '$datafile'.$!\n");@aa=<FILE>;
close(FILE);&so($filelock);if($sortcode){if(ref $sortcode eq'CODE'){@aa=sort{&$sortcode} @aa}
else{@aa=&wy('¡',$sortcode,\@aa)}}foreach(@aa){/^\d/||next;s/[^¡]+$//;undef %$out;@ab=split(/\¡/);
my$i;for$i(0..$#fields){$out->{$fields[$i]}=$ab[$i];$out->{$fields[$i]}=~s/¿([A-F0-9]{2})/pack("C",hex($1))/egix}
&$rowcode}}sub si{if(ref($_[0])ne"HASH"){die"DB_ListPage : The first argument must be a HASH reference!\n"}
if(ref($_[1])ne"CODE"&&$_[1]){die"DB_ListPage : The second argument must be a CODE reference!\n"}
if(ref($_[2])ne"CODE"&&$_[2]){die"DB_ListPage : The third argument must be a CODE reference!\n"}
if(ref($_[4])ne"HASH"&&$_[4]){die"DB_ListPage : The fifth argument must be a HASH reference!\n"}
if($_[5]=~/[^0-9]/){die"DB_ListPage : Page number value contains non-numeric characters!\n"}
if(!$_[6]){die"DB_ListPage : No Records PerPage value was specified!\n"}if($_[6]=~/[^0-9]/){
die"DB_ListPage : Records PerPage value contains non-numeric characters!\n"}if(!$_[0]->{'datafile'}){
die"DB_ListPage : No datafile was specified in the DB definition!\n"}if(!$_[0]->{'filelock'}){
die"DB_ListPage : No filelock was specified in the DB definition!\n"}if(ref($_[0]->{fields})ne"ARRAY"){
die"DB_ListPage : Field names in the DB definition must be a ARRAY reference!\n"}if($#{$_[0]->{
fields}}<0){die"DB_ListPage : No fields were specified in the DB definition!\n"}my($datafile)="$hc{'cgidir'}/../data/$_[0]->{'datafile'}";
my($filelock)="$hc{'cgidir'}/../data/$_[0]->{'filelock'}";my(@fields)=@{$_[0]->{fields}};my($backup)=$_[0]->{'backup'};
$datafile.=$_[0]->{'cgiext'};my($querycode)=$_[1];my($matchcode)=$_[2];my($sortcode)=$_[3];
my($out)=$_[4];my($perpage)=int$_[6];my($pcount)=0;my($mcount)=0;my($rcount)=0;my($cpage)=int$_[5]||1;
my($lpage)=0;my($npage)=0;my(@aa);my(@ab);unless(-e $datafile){return(0,0,0,0,0,0)}if($backup){&sd($_[0])}
&sl($filelock);open(FILE,"<$datafile")||die("DB_List : Can't open '$datafile'.$!\n");@aa=<FILE>;
close(FILE);&so($filelock);if($sortcode){if(ref $sortcode eq'CODE'){@aa=sort{&$sortcode} @aa}
else{@aa=&wy('¡',$sortcode,\@aa)}}foreach(@aa){/^\d/||next;$rcount++;s/[^\¡]+$//;undef %$out;@ab=split(/\¡/);
my$i;for$i(0..$#fields){$out->{$fields[$i]}=$ab[$i];$out->{$fields[$i]}=~s/¿([A-F0-9]{2})/pack("C",hex($1))/egix}
if(&$querycode){$mcount++;my($thispage)=($mcount%$perpage) ?int($mcount/$perpage)+1 : $mcount/$perpage;
if($thispage==$cpage){&$matchcode}}}$pcount=int($mcount / $perpage);if($mcount % $perpage){
$pcount++}if(($cpage-1)<1||($cpage-1)>$pcount){$lpage=$pcount}else{$lpage=$cpage-1}if(($cpage+1)>$pcount){
$npage=1}else{$npage=$cpage+1}if(!$pcount){$cpage=$lpage=$npage=0}return ($pcount,$mcount,$rcount,$cpage,$lpage,$npage)}
sub sj{if(ref($_[0])ne"HASH"){die"DB_ListSave : The first argument must be a HASH reference!\n"}
if(ref($_[1])ne"CODE"&&$_[1]){die"DB_ListSave : The second argument must be a CODE reference!\n"}
if(ref($_[3])ne"HASH"&&$_[3]){die"DB_ListSave : The fourth argument must be a HASH reference!\n"}
if(!$_[0]->{'datafile'}){die"DB_ListSave : No datafile was specified in the DB definition!\n"}
if(!$_[0]->{'filelock'}){die"DB_ListSave : No filelock was specified in the DB definition!\n"}
if(ref($_[0]->{fields})ne"ARRAY"){die"DB_ListSave : Field names in the DB definition must be a ARRAY reference!\n"}
if($#{$_[0]->{fields}}<0){die"DB_ListSave : No fields were specified in the DB definition!\n"}
my($datafile)="$hc{'cgidir'}/../data/$_[0]->{'datafile'}";my($filelock)="$hc{'cgidir'}/../data/$_[0]->{'filelock'}";
my(@fields)=@{$_[0]->{fields}};my($backup)=$_[0]->{'backup'};$datafile.=$_[0]->{'cgiext'};
my($rowcode)=$_[1];my($sortcode)=$_[2];my($out)=$_[3];my(@aa);my(@ab);unless(-e $datafile){
return (0)}if($backup){&sd($_[0])}&sl($filelock);open(FILE,"<$datafile")||die("DB_List : Can't open '$datafile'.$!\n");@aa=<FILE>;
close(FILE);if($sortcode){if(ref $sortcode eq'CODE'){@aa=sort{&$sortcode} @aa}else{@aa=&wy('¡',$sortcode,\@aa)}}
foreach(@aa){/^\d/||next;s/[^¡]+$//;undef %$out;@ab=split (/\¡/);my$i;for$i(0..$#fields){$out->{
$fields[$i]}=$ab[$i];$out->{$fields[$i]}=~s/¿([A-F0-9]{2})/pack("C",hex($1))/egix}&$rowcode;
$_="$ab[$i]¡";for$i(1..$#fields){my($enc)=$out->{$fields[$i]};$enc=~s/[\x1a\r\n\¡\¿]/sprintf("¿%02x",ord($&))/egx;
$_.="$enc¡"}$_.="\n"}open(FILE,">$datafile.tmp$$")||&sg("DB_ListSave : Can't create temp file $datafile.tmp$$.$!\n");
print FILE qq|#!$^X\n| or &sg("DB_ListSave: Can't write header section 1 to $datafile.tmp$$");
print FILE qq|print"Content-type: text/html\\n\\n<html></html>";\n__END__\n| or &sg("DB_ListSave: Can't write header section 2 to $datafile.tmp$$");
foreach(@aa){/^\d/||next;s/[^¡]+$//;print FILE "$_\n" or &sg("DB_ListSave: Can't write record to $datafile.tmp$$");}
close(FILE)||&sg("DB_ListSave: Can't close $datafile.tmp$$");rename("$datafile.tmp$$",$datafile)||&sg("DB_ListSave: Can't rename $datafile.tmp$$ to $datafile");
&so($filelock)}sub sc{if(ref($_[0])ne"HASH"){die"DB_Add : The first argument must be a HASH reference!\n"}
if(ref($_[1])ne"HASH"){die"DB_Add : The second argument must be a HASH reference!\n"}if(!$_[0]->{'datafile'}){
die"DB_Add : No datafile was specified in the DB definition!\n"}if(!$_[0]->{'filelock'}){die"DB_Add : No filelock was specified in the DB definition!\n"}
if(ref($_[0]->{fields})ne"ARRAY"){die"DB_Add : Field names in the DB definition must be a ARRAY reference!\n"}
if($#{$_[0]->{fields}}<0){die"DB_Add : No fields were specified in the DB definition!\n"}my($datafile)="$hc{'cgidir'}/../data/$_[0]->{'datafile'}";
my($filelock)="$hc{'cgidir'}/../data/$_[0]->{'filelock'}";my(@fields)=@{$_[0]->{fields}};my($backup)=$_[0]->{'backup'};
$datafile.=$_[0]->{'cgiext'};my($in)=$_[1];my(@aa);my(@ab);my(%hq);if((-e $datafile)&&$backup){&sd($_[0])}
&sl($filelock);if(-e "$datafile"){open(FILE,"<$datafile")||die("DB_Add : Error,Can't open '$datafile'.$!\n");@aa=<FILE>;
close(FILE)}foreach(@aa){/^\d/||next;$hq{(split (/\¡/))[0]}=1}my($nnum)=1;while($hq{$nnum}){
$nnum++}open(FILE,">$datafile.tmp$$")||die("DB_Add : Can't create temp file $datafile.tmp$$.$!\n");
print FILE qq|#!$^X\n| or &sg("DB_Add: Can't write header section 1 to $datafile.tmp$$");print FILE qq|print"Content-type: text/html\\n\\n<html></html>";\n__END__\n| or &sg("DB_Add: Can't write header section 2 to $datafile.tmp$$");
foreach(@aa){/^\d/||next;s/[^¡]+$//;print FILE "$_\n" or &sg("DB_Add: Can't rewrite record to $datafile.tmp$$")}
my($line)="$nnum¡";my$i;for$i(1..$#fields){my($enc)=$in->{$fields[$i]};$enc=~s/[\x1a\r\n\¡\¿]/sprintf("¿%02x",ord($&))/egx;
$line.="$enc¡"}print FILE "$line\n" or &sg("DB_Add: Can't write new record to $datafile.tmp$$");
close(FILE)||&sg("DB_Add: Can't close $datafile.tmp$$");rename("$datafile.tmp$$",$datafile)||&sg("DB_Add: Can't rename $datafile.tmp$$ to $datafile");
&so($filelock);return $nnum}sub sk{if(ref($_[0])ne"HASH"){die"DB_Load : The first argument must be a HASH reference!\n"}
if(ref($_[1])ne"HASH"){die"DB_Load : The second argument must be a HASH reference!\n"}if(!$_[2]){
die"DB_Load : No record number was specified!\n"}if($_[2]=~/[^0-9]/){die"DB_Load : Record number contains non-numeric characters!\n"}
if(!$_[0]->{'datafile'}){die"DB_Load : No datafile was specified in the DB definition!\n"}
if(!$_[0]->{'filelock'}){die"DB_Load : No filelock was specified in the DB definition!\n"}
if(ref($_[0]->{fields})ne"ARRAY"){die"DB_Load : Field names in the DB definition must be a ARRAY reference!\n"}
if($#{$_[0]->{fields}}<0){die"DB_Load : No fields were specified in the DB definition!\n"}
my$cacheRecords=$_[3];$cacheRecords||=[];my($datafile)="$hc{'cgidir'}/../data/$_[0]->{'datafile'}";
my($filelock)="$hc{'cgidir'}/../data/$_[0]->{'filelock'}";my(@fields)=@{$_[0]->{fields}};my($backup)=$_[0]->{'backup'};
$datafile.=$_[0]->{'cgiext'};my($out)=$_[1];my($rnum)=int$_[2];my(@aa);my(@ab);unless(-e $datafile){
return(0)}if($backup){&sd($_[0])}if(@{$cacheRecords}==0&&-e "$datafile"){&sl($filelock);open(FILE,"<$datafile")||die("DB_Load : Error,Can't open '$datafile'.$!\n");@$cacheRecords=<FILE>;
close(FILE);&so($filelock)}foreach(@$cacheRecords){/^$rnum\¡/||next;s/[^¡]+$//;undef %$out;@ab=split(/\¡/);
my$i;for$i(0..$#fields){$out->{$fields[$i]}=$ab[$i];$out->{$fields[$i]}=~s/¿([A-F0-9]{2})/pack("C",hex($1))/egix}
return(1)}return(0)}sub sf{if(ref($_[0])ne"HASH"){die"DB_Del : The first argument must be a HASH reference!\n"}
if(!$_[1]){die"DB_Del : The second argument must be a record number!\n"}if($_[1]=~/[^0-9]/){
die"DB_Del : Record number contains non-numeric characters!\n"}if(!$_[0]->{'datafile'}){die"DB_Del : No datafile was specified in the DB definition!\n"}
if(!$_[0]->{'filelock'}){die"DB_Del : No filelock was specified in the DB definition!\n"}if(ref($_[0]->{
fields})ne"ARRAY"){die"DB_Del : Field names in the DB definition must be a ARRAY reference!\n"}
if($#{$_[0]->{fields}}<0){die"DB_Del : No fields were specified in the DB definition!\n"}my($datafile)="$hc{'cgidir'}/../data/$_[0]->{'datafile'}";
my($filelock)="$hc{'cgidir'}/../data/$_[0]->{'filelock'}";my(@fields)=@{$_[0]->{fields}};my($backup)=$_[0]->{'backup'};
$datafile.=$_[0]->{'cgiext'};my($rnum)=int$_[1];my(%hq);my($erased)=0;for(1..$#_){$hq{$_[$_]}++}
my(@aa);unless(-e $datafile){return(0)}if($backup){&sd($_[0])}&sl($filelock);if(-e "$datafile"){
open(FILE,"<$datafile")||die("DB_Del : Error,Can't open '$datafile'.$!\n");@aa=<FILE>;close(FILE)}
open(FILE,">$datafile.tmp$$")||die("DB_Del : Can't create temp file $datafile.tmp$$.$!\n");
print FILE qq|#!$^X\n|;print FILE qq|print"Content-type: text/html\\n\\n<html></html>";\n__END__\n|;
foreach(@aa){/^(\d+)\¡/||next;if($hq{$1}){$erased++; next}s/[^¡]+$//;print FILE "$_\n"}close(FILE)||die("DB_Del: Can't write $datafile : $!");
rename("$datafile.tmp$$",$datafile)||die("DB_Del: Can't write $datafile : $!");&so($filelock);
return $erased}sub sn{if(ref($_[0])ne"HASH"){die"DB_Save : The first argument must be a HASH reference!\n"}
if(ref($_[1])ne"HASH"){die"DB_Save : The second argument must be a HASH reference!\n"}if(!$_[2]){
die"DB_Save : No record number was specified!\n"}if($_[2]=~/[^0-9]/){die"DB_Save : Record number contains non-numeric characters!\n"}
if(!$_[0]->{'datafile'}){die"DB_Save : No datafile was specified in the DB definition!\n"}
if(!$_[0]->{'filelock'}){die"DB_Save : No filelock was specified in the DB definition!\n"}
if(ref($_[0]->{fields})ne"ARRAY"){die"DB_Save : Field names in the DB definition must be a ARRAY reference!\n"}
if($#{$_[0]->{fields}}<0){die"DB_Save : No fields were specified in the DB definition!\n"}
my($datafile)="$hc{'cgidir'}/../data/$_[0]->{'datafile'}";my($filelock)="$hc{'cgidir'}/../data/$_[0]->{'filelock'}";
my(@fields)=@{$_[0]->{fields}};my($backup)=$_[0]->{'backup'};$datafile.=$_[0]->{'cgiext'};
my($in)=$_[1];my($rnum)=int$_[2];my($saved)=0;my(@aa);my(@ab);unless(-e $datafile){return(0)}
if($backup){&sd($_[0])}&sl($filelock);open(FILE,"<$datafile")||die("DB_Save : Error,Can't open '$datafile'.$!\n");@aa=<FILE>;
close(FILE);open(FILE,">$datafile.tmp$$")||&sg("DB_Save : Can't create temp file $datafile.tmp$$.$!\n");
print FILE qq|#!$^X\n| or &sg("DB_Save: Can't write header section 1 to $datafile.tmp$$");
print FILE qq|print"Content-type: text/html\\n\\n<html></html>";\n__END__\n| or &sg("DB_Save: Can't write header section 2 to $datafile.tmp$$");
foreach(@aa){/^\d/||next;if(/^$rnum\¡/){my($line)="$rnum¡";my$i;for$i(1..$#fields){my($enc)=$in->{
$fields[$i]};$enc=~s/[\x1a\r\n\¡\¿]/sprintf("¿%02x",ord($&))/egx;$line.="$enc¡"}print FILE "$line\n" or &sg("DB_Save: Can't write updated record to $datafile.tmp$$");
$saved++;next}s/[^¡]+$//;print FILE "$_\n" or &sg("DB_Save: Can't rewrite record to $datafile.tmp$$")}
close(FILE)||&sg("DB_Save: Can't close $datafile");rename("$datafile.tmp$$",$datafile)||&sg("DB_Save: Can't rename $datafile.tmp$$ to $datafile");
&so($filelock);unless($saved){&sc(@_)}}sub sd{my($datafile)="$hc{'cgidir'}/../data/$_[0]->{'datafile'}";
my($filelock)="$hc{'cgidir'}/../data/$_[0]->{'filelock'}";my($backup)=$_[0]->{'backup'};my($cgiext)=$_[0]->{'cgiext'};
my($bkupfile);unless($backup){return}if($backup eq"disabled"){return}if($backup eq"none"){
return}my($hour,$day,$month,$year)=(localtime(time))[2..5];$hour=sprintf("%02d",$hour);$day=sprintf("%02d",$day);
$month=sprintf("%02d",$month+1);$year=sprintf("%04d",$year+1900);if($backup eq"hourly"){$bkupfile="$datafile.$year-$month-$day-$hour-backup$cgiext"}
elsif($backup eq"daily"){$bkupfile="$datafile.$year-$month-$day-backup$cgiext"}elsif($backup eq"monthly"){
$bkupfile="$datafile.$year-$month-backup$cgiext"}elsif($backup eq"yearly"){$bkupfile="$datafile.$year-backup$cgiext"}
else{die("DB_Backup : Unknown backup setting\n")}if(-e $bkupfile){return}$datafile="$datafile$cgiext";
&sl($filelock);open(FILE,"<$datafile")||die("DB_Backup : Can't open '$datafile'.$!\n");open(BKUP,">$bkupfile")||die("DB_Backup : Can't open '$bkupfile'.$!\n");
print BKUP<FILE>||die("DB_Backup : Can't copy file.$!\n");close(FILE)||die("DB_Backup : Can't close '$datafile'.$!\n");;
close(BKUP)||die("DB_Backup : Can't close '$bkupfile'.$!\n");&so($filelock)}sub sm{my($filelock)=$_[0];
my($i);if(!-w "$hc{'cgidir'}/../data/"){die("DB_Lock : $hc{'cgidir'}/../data/ isn't writable,can't create filelock\n")}
if(-d $filelock&&(stat($filelock))[9]<time() - ($ha{'max_filelock_duration'}||300)){rmdir($filelock)}
while(!mkdir($filelock,0777)){sleep 1;if(++$i>50){die("DB_Lock : Can't create filelock : $!\n")}
if(-d $filelock&&(stat($filelock))[9]<time() - ($ha{'max_filelock_duration'}||300)){rmdir($filelock)}}}
sub sp{my($filelock)=$_[0];rmdir($filelock)}sub sl{my$max_filelock_wait=$hj{'max_filelock_wait'}||5;
&xm('exclusive',$max_filelock_wait)}sub so{my$max_filelock_wait=$hj{'max_filelock_wait'}||5;
&yb($max_filelock_wait)}sub xm{return if$hj{'disable_filelocking'};my$subProp=$hh{'_subs'}{'lock'}||={};
$subProp->{'stack'}||=[];my($lock_type,$timeout)=@_;$lock_type||='exclusive';$timeout||=0;
if($lock_type ne'exclusive' and $lock_type ne'shared'){&wi("lock: invalid lock type: '$lock_type'")}
my$previous_lock;if(@{$subProp->{'stack'}}>0){$previous_lock=$subProp->{'stack'}[-1]}if($previous_lock eq'exclusive'){
$lock_type=$previous_lock}if($previous_lock eq$lock_type){push(@{$subProp->{'stack'}},$lock_type);
return 1}my$return_value;if($previous_lock eq'shared' and $lock_type eq'exclusive'){print"point II<br>\n";
&wi("lock: cannot upgrade a 'shared' lock to an 'exclusive' lock")}$return_value=&wm('',$lock_type,$timeout);
if($return_value){push(@{$subProp->{'stack'}},$lock_type)}return $return_value}sub yb{return if$hj{'disable_filelocking'};
my$subProp=$hh{'_subs'}{'lock'}||={};$subProp->{'stack'}||=[];my($timeout)=@_;$timeout||=0;
unless(@{$subProp->{'stack'}}>0){&wi('unlock: nested filelock underrun')}my$previous_lock=pop(@{
$subProp->{'stack'}});return if(@{$subProp->{'stack'}}>0 and $subProp->{'stack'}[-1]eq$previous_lock);
if(@{$subProp->{'stack'}}==0){&wp('')}}sub wm{my$subProp=$hh{'_subs'}{'lock'}||={};my($lock_name,$lock_type,$timeout)=@_;
my$lock_filename;if($lock_name){$lock_filename="$hh{'datadir'}/$lock_name.lock"}else{$lock_filename=$hh{'filelock'}}
if(not exists $subProp->{'lockinfo'}{$lock_name}){$subProp->{'lockinfo'}{$lock_name}{'filename'}=$lock_filename;
$subProp->{'lockinfo'}{$lock_name}{'handle'}=&ss();sysopen($subProp->{'lockinfo'}{$lock_name}{'handle'},$subProp->{'lockinfo'}{
$lock_name}{'filename'},O_RDWR|O_CREAT)||&wi('filelock',"error opening $lock_type file lock $subProp->{'lockinfo'}{
$lock_name}{'filename'}: $!\n")}else{&wi("_lock_flock: already a lock for semaphore '$lock_name'")}
my$operation;if($lock_type eq'shared'){$operation=LOCK_SH}if($lock_type eq'exclusive'){$operation=LOCK_EX}
if($timeout>0){$operation|=LOCK_NB}my$giveup_time=time()+$timeout;until (flock($subProp->{'lockinfo'}{
$lock_name}{'handle'},$operation)){if(time()<$giveup_time){sleep(1)}else{close($subProp->{'lockinfo'}{
$lock_name}{'handle'});&wi('serverbusy')}}return 1}sub wp{my$subProp=$hh{'_subs'}{'lock'}||={};
my($lock_name)=@_;unless(flock($subProp->{'lockinfo'}{$lock_name}{'handle'},LOCK_UN)){&wi('filelock',"error releasing a flock() on file lock $subProp->{'lockinfo'}{
$lock_name}{'filename'}: $!\n")}unless(close($subProp->{'lockinfo'}{$lock_name}{'handle'})){&wi('filelock',"error closing file lock $subProp->{'lockinfo'}{
$lock_name}{'filename'}: $!\n")}delete $subProp->{'lockinfo'}{$lock_name};return 1}sub ss{
my$subProp=$hh{'_subs'}{'FH_Create'}||={};my$num=int++$subProp->{'num'};my$name="FH$num";return (eval "local *$name")}
sub wi{&su(@_)}sub sg{my($msg)=(@_);my($file_error)=$!;if($file_error eq''){$file_error="Unknown error.Maybe disk quota exceeded?"}
&wi('filesystem',"$msg : $file_error\n")}sub xs{my$sort_spec=$_[0];my$offset=$_[1];my@ar=split(/\s/,$sort_spec);
$sort='';foreach$sort_order(@ar){if($sort){$sort.=' '}($field,$order,$direction)=split(/\,/,$sort_order);
$field+=$offset;if($order=~s/eu//){$euro_numbers++}if($order eq"123"&&$direction=~/^f/i&&!$euro_numbers){
$sort.="#$field"}elsif($order eq"123"&&$direction!~/^f/i&&!$euro_numbers){$sort.="-#$field"}
elsif($order eq"123"&&$direction=~/^f/i&&$euro_numbers){$sort.="#%$field"}elsif($order eq"123"&&$direction!~/^f/i&&$euro_numbers){
$sort.="-#%$field"}elsif($order eq"abc"&&$direction=~/^f/i){$sort.="$field"}elsif($order eq"abc"&&$direction!~/^f/i){
$sort.="-$field"}else{return undef}}return $sort}sub wy{my($sep,$order,$arrayref_nopack)=@_;
my($f_nopack,$charcount,$sortcode,$sortcode2,$sortcode3,$i);my($numeric,$reverse,$euro,$modify_fields);
$f_nopack=[];$i=0;foreach(split(/ /,$order)){if(s/\#//g){$numeric=1}elsif(s/n//g){$numeric=1}
else{$numeric=0}if(s/\-//g){$reverse='~'}elsif(s/\+//g){$reverse=''}else{$reverse=''}if(s/\%//g){
$euro=1}else{$euro=0}s/[^0-9]//gs;push(@$f_nopack,$_);if($numeric){$charcount+=15;$sortcode2.='%'.'s';
$modify_fields.="\$str->[$i]=~tr/,./.,/;\n"if$euro;$modify_fields.="\$str->[$i]=~s/[^0-9.]//g;\n";
$sortcode3.=qq|$reverse sprintf('%015s',substr(int(\$str->[$i]*100000),0,15)),|}else{$charcount+=50;
$sortcode2.='%- 50s';$sortcode3.="$reverse substr(\$str->[$i],0,50),"}$i++}$sortcode.="return(map{
substr(\$_,$charcount)} sort map{\n";$sortcode.="my\$str=[(split(/\\$sep/,lc\$_))[\@\$f_nopack]];\n";
$sortcode.=$modify_fields;$sortcode.="sprintf(\"$sortcode2\%"."s\" ,$sortcode3\$_);\n";$sortcode.="} \@\$arrayref_nopack);\n";
eval $sortcode}sub uz{my($max)=$_[0];my($name,$value,$pair,@ae,$buffer,%hi);my($file,$path,$ext);
my($boundary);binmode(STDIN);if($max&&($ENV{'CONTENT_LENGTH'}||length $ENV{'QUERY_STRING'})>$max){
die("ReadForm : Input exceeds max input limit of $max bytes\n")}($boundary)=$ENV{'CONTENT_TYPE'}=~/boundary=(?:"?)(\S+?)(?:"?)$/;
if($ENV{'REQUEST_METHOD'}eq"POST"&&$ENV{'CONTENT_TYPE'}=~m|^multipart/form-data|){while(<STDIN>){
if(/^--$boundary--/){$buffer.="--$boundary"; last}else{$buffer.=$_}}@ae=split(/--$boundary/,$buffer);
foreach$pair(@ae){unless($pair=~/^(\r\n|\n)Content-Disposition/){next}($name,$value)=$pair=~/^(?:\r\n|\n)(.*?)(?:\r\n|\n){2}(.*?)(?:\r\n|\n)$/s;($path)=$name=~/filename="([^"]+)"/;($name)=$name=~/name="([^"]+)"/;($file)=$path=~/([^\/\\]+)$/;($ext)=$path=~/([^\.]+)$/;
$hi{"$name"}=$value;$hi{"$name"."_path"}=$path;$hi{"$name"."_file"}=$file;$hi{"$name"."_ext"}=$ext}}
else{if($ENV{'REQUEST_METHOD'}eq'POST'){read(STDIN,$buffer,$ENV{'CONTENT_LENGTH'})}elsif($ENV{'REQUEST_METHOD'}
eq'GET'){$buffer=$ENV{'QUERY_STRING'}}@ae=split(/&/,$buffer);foreach$pair(@ae){($name,$value)=split(/=/,$pair);
$value=~tr/+/ /;$value=~s/%([A-F0-9]{2})/pack("C",hex($1))/egi;$value=~s/\r\n/\n/go;$hi{$name}=$value}}
foreach(keys %hi){if(/^(.*)(\.x|\.y)$/){$hi{$1}="true"}}return %hi}sub vr{if(!$_[0]){die"Template : No template file was specified!\n"}
if($_[1]&&ref($_[1])ne"HASH"){die"Template : The second argument must be a HASH reference or undefined!\n"}
my($file);my($hashref)=$_[1];my(%hi)=%{$hashref};my($cfile);my($content);local(*FILE);if($hashref){
foreach(keys %hc){$hi{$_}=$hc{$_}}}else{foreach(keys %hc){${$_}=$hc{$_}}}foreach(grep /^templatedir/,sort keys %hc){
if(-e "$hc{'cgidir'}/$hc{$_}/$_[0]"){$file="$hc{'cgidir'}/$hc{$_}/$_[0]";last}}if(!$file){
die"Template : Template file '$_[0]' could not be found!\n"}open(FILE,"<$file")||die"Template : Couldn't open $file! $!\n";
while(<FILE>){$content.=$_}close(FILE);for($content){s/<!-- insert : (.*?) -->/\1/gi;s/<!-- template\s?: insert (.*?) -->/\1/gi;
s/<!-- template insert\s?:\s?(.*?) -->/\1/gi;s/<!-- template\s?:\s?define ([A-Za-z0-9_\.]+) -->(?:\r\n|\n)?(.*?)<!-- template\s?:\s?\/define \1 -->/$hw{
$1}=$2;''/gesi;s/<!-- templatecell\s?:\s?([A-Za-z0-9_\.]+) -->(?:\r\n|\n)?(.*?)<!-- \/templatecell\s?:\s? \1 -->/$hw{
$1}=$2;''/gesi;s[\$(\w+?)(_ue|_he|_nbsp|_je)?\$][my$value=$hashref ? $hi{$1} : ${$1};if($2 eq'_ue'){
$value=&vx($value)}if($2 eq'_he'){$value=&st($value)}if($2 eq'_nbsp'){$value=&st($value); $value=~s/ /&xq;/g}
if($2 eq'_je'){$value=&to($value)}$value;]ge}return $content}sub vs{if(!$_[0]){die"Template : No template cell was specified!\n"}
if(!defined $hw{$_[0]}){die"Template : Template cell '$_[0]' is not defined!\n"}if($_[1]&&ref($_[1])ne"HASH"){
die"Template : The second argument must be a HASH reference or undefined!\n"}my($cellname)=$_[0];
my($hashref)=$_[1];my(%hi)=%{$hashref};my($content)=$hw{$cellname};local(*FILE);if($hashref){
foreach(keys %hc){$hi{$_}=$hc{$_}}}else{foreach(keys %hc){${$_}=$hc{$_}}}$content=~s[\$(\w+?)(_ue|_he|_nbsp|_je)?\$][my$value=$hashref ? $hi{
$1} : ${$1};if($2 eq'_ue'){$value=&vx($value)}if($2 eq'_he'){$value=&st($value)}if($2 eq'_nbsp'){
$value=&st($value); $value=~s/ /&xq;/g}if($2 eq'_je'){$value=&to($value)}$value;]ge;return $content}
sub um{my($in)=$_[0];my(@an)=((A..Z,a..z,0..9),'+','/');my($out)=unpack("B*",$in);$out=~s/(\d{6}|\d+$)/$an[ord(pack"B*","00$1")]/ge;
while(length($out)%4){$out.="="}return $out}sub ul{local($i);my($in)=$_[0];my(%hy);my($out);
for((A..Z,a..z,0..9),'+','/'){$hy{$_}=$i++}$in=$_[0]||return "MIME64 : Nothing to decode";
$in=~s/[^A-Za-z0-9+\/]//g;$in=~s/[A-Za-z0-9+\/]/unpack"B*",chr($hy{$&})/ge;$in=~s/\d\d(\d{6})/$1/g;
$in=~s/\d{8}/$out.=pack("B*",$&)/ge;return $out}sub vx{my($text)=$_[0];$text=~tr/ /+/;$text=~s/[^A-Za-z0-9\+\*\.\@\_\-]/uc sprintf("%%%02x",ord($&))/egx;
return $text}sub vw{my($text)=$_[0];$text=~tr/+/ /;$text=~s/%([A-F0-9]{2})/pack("C",hex($1))/egi;
return $text}sub st{my$html=shift;$html=~s/\x26/\x26amp;/g;$html=~s/"/\x26quot;/g;$html=~s/</\x26lt;/g;
$html=~s/>/\x26gt;/g;return $html}sub to{my$string=shift;$string=~s/\\/\\\\/g;$string=~s/'/\\'/g;
$string=~s/"/\\"/g;$string=~s/\n/\\n/g;$string=~s/\r/\\r/g;$string=~s/\000//g;$string=~s/-->/--'+'>/g;
$string=~s!</script>!</scr'+'ipt>!g;return $string}sub vb{my($cookie_info);my($name,$value,$exp,$path,$domain,$secure)=@_;
my($expires);unless(defined $name){die("SetCookie : Cookie name must be specified\n")}if($exp&&$exp ne int($exp)){
die("SetCookie : Expire Date isn't in seconds using time();\n")}if($exp){my(@ao)=qw(Sun Mon Tue Wed Thu Fri Sat);
my(@aq)=qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);my($SS,$MM,$HH,$DD,$Mon,$YYYY,$Wdy)=gmtime($exp);
foreach($DD,$HH,$MM,$SS){$_=sprintf("%02d",$_)}my($YYYY)=sprintf("%04d",$YYYY+1900);$expires="$ao[$Wdy],$DD-$aq[$Mon]-$YYYY $HH:$MM:$SS GMT"}
if($name){$name=&vx($name)}if($value){$value=&vx($value)}if($exp){$cookie_info.="expires=$expires; "}
if($path){$cookie_info.="path=$path; "}if($domain){$cookie_info.="domain=$domain; "}if($secure){
$cookie_info.="secure; "}print"Set-Cookie: $name=$value; $cookie_info\n"}sub uy{my($cookie,$name,$value,%hu);
foreach$cookie(split(/; /,$ENV{'HTTP_COOKIE'})){($name,$value)=split(/=/,$cookie);foreach($name,$value){
$_=&vw($_)}$hu{$name}=$value}return %hu}sub wn{use Socket;my($script_filename)=$0;$script_filename=~s/.*[\/\\]//;
my($reginfo);my$host=$ENV{'HTTP_HOST'}||$ENV{'SERVER_NAME'}||$ENV{'SERVER_ADDR'};my$path=$ENV{'SCRIPT_NAME'}||$ENV{'PATH_INFO'};
$reginfo.='&'.'reg1='.&vx($ha{'company_name'});$reginfo.='&'.'reg2='.&vx($ha{'domain_name'});
$reginfo.='&'.'lnum='.&vx(&we($ha{'product_id'}));$reginfo.='&'.'prog='.&vx($hc{'prod_id'});
$reginfo.='&'.'ver='.&vx($hc{'progVer'});$reginfo.='&'.'url='.&vx("$host$path");$reginfo.='&'.'csum='.&vx(&ww([$script_filename],[]));
my$paddr=gethostbyname('registersoftware.to')||return;my$sock=&xz();socket ($sock,PF_INET,SOCK_STREAM,0)||die('No Socket: '.$!);
connect ($sock,pack "SnA4x8",PF_INET,80,$paddr)||return;select ($sock); $|=1; select(STDOUT);
print$sock "GET /register/register.cgi?$reginfo HTTP/1.0\n";print$sock 'Referer: '.$host.$path."\n";
print$sock 'User-Agent: software'."\n\n";my$reply=join("",<$sock>);close($sock);if($reply=~/license\.invalid/){
$ha{'d'}=1}if($reply=~/license\.valid/){$ha{'d'}=0}&sn(\%hk,\%ha,1);if($ha{'d'}){print"Content-type: text/html\n\n" unless($ContentType++);
print&vr("\x5F\x6C\x69\x63\x65\x6E\x73\x65\x5F\x64\x69\x73\x61\x62\x6C\x65\x64\x2E\x68\x74\x6D\x6C",{});
exit}}sub xz{local *FILE;return *FILE}sub vv{my($file)=@_;my$thumbfile=$file;$thumbfile=~s/^(.*)(\.\w+)$/$1_t$2/;
return $thumbfile}sub vu{my($path,$file)=@_;my$thumbfile=&vv($file);if(not -e "$path/$thumbfile"){
$thumbfile=$file}return $thumbfile}sub vt{my$filename=shift;if($hj{'thumbnailing'}{'disable_thumbnails'}){
return}if(!&un()){return}if($hh{'core-graph'}{'module'}eq"GD"&&$hh{'core-graph'}{'version'}<1.26){
return}my($thumbfile)=&vv($filename);$filename=~/^(.*)\.([a-z0-9]+)$/i;my($base,$ext)=($1,lc($2));
if($ext eq'gif'&&$hh{'core-graph'}{'gd'}){}else{my$tpic=&uq( $filename,'_t',$ha{'thumbnail_width'},$ha{'thumbnail_height'});
&ur( $tpic,$thumbfile );if(-s $thumbfile>-s $filename&&!$hj{'thumbnailing'}{'allow_larger_thumbnails'}){&sb($filename,$thumbfile)}}}
sub sb{my($from_file,$to_file)=@_;my$data;unless(open(INF,"<$from_file")){return}binmode(INF);
unless(open(OUTF,">$to_file")){close(INF); return}binmode(OUTF);while($data=<INF>){print OUTF $data}
close(INF);close(OUTF)}sub wq{my$old_version=$ha{'prog_ver'}||2.0;my$new_version=$hc{'progVer'};
if($new_version==$old_version){return(undef)}if($old_version!=-1){&wn();if($old_version<2.19){
$ha{'max_filelock_duration'}=300}if($old_version<2.25){$ha{'branding'}=1}if($old_version<2.29){
$ha{'publish_ext'}="html";$ha{'thumbnail_create'}=0;$ha{'thumbnail_width'}=160;$ha{'thumbnail_height'}=120}
if($old_version<2.30){my$old_filelock_dir="$hc{'cgidir'}/../data/filelock.lock";if(-e $old_filelock_dir){
rmdir $old_filelock_dir}}if($old_version<2.50){my$industry;if($ha{'titlebar'}=~/(realty)/i){
$industry=lc($1)}if($ha{'titlebar'}=~/(auto)/i){$industry=lc($1)}$industry||='generic';my%hn=&tm("$cgidir/industry.ini");
$ha{'ind_industry'}=$industry;$ha{'ind_industry_name'}=$hn{$industry}{'industry_name'};$ha{'ind_program_name'}=$hn{
$industry}{'program_name'};$ha{'ind_login_image'}=$ha{'image_url'};$ha{'ind_login_image'}=~s![/\\]$!!;
$ha{'ind_login_image'}="$ha{'ind_login_image'}/$hn{$industry}{'login_image'}";$ha{'ind_template_dir'}='../templates/';
for(1..50){$ha{"hfield$_\_order"}=$_ if(length($ha{"hfield$_"."_name"}));$ha{"lfield$_\_order"}=$_ if(length($ha{"lfield$_"."_name"}))}
for(51..75){$ha{"lfield$_\_order"}=$_ if(length($ha{"lfield$_"."_name"}))}$hc{'header_product'}=$ha{'ind_program_name'};
$hc{'templatedir1'}=$ha{'ind_template_dir'};$hc{'ind_industry'}=$ha{'ind_industry'};$hc{'ind_industry_name'}=$ha{'ind_industry_name'};
$hc{'ind_program_name'}=$ha{'ind_program_name'};$hc{'ind_login_image'}=$ha{'ind_login_image'};
my%he;my$fix_never_expires_flag_sub=sub{if($he{'access'}>=3){$he{'expires_never'}=1}};&sj(\%hl,$fix_never_expires_flag_sub,undef,\%he)}
if($old_version<2.51){my$industry=$ha{'ind_industry'}||'generic';my%hn=&tm("$cgidir/industry.ini");
$ha{'ind_program_name_image'}="$ha{'image_url'}/$hn{$industry}{'program_name_image'}"}}$ha{'prog_ver'}=$new_version;
&sn(\%hk,\%ha,1);return 1}sub ww{my($script_files,$other_files)=@_;my$data;my$fh=do{local *FILE; *FILE};
my$file;foreach$file(@$script_files){if(open($fh,"<$hc{'cgidir'}/$file")){<$fh>;binmode($fh);
$data.=join '',<$fh>;close($fh)}}foreach$file(@$other_files){if(open($fh,"<$hc{'cgidir'}/$file")){
binmode($fh);$data.=join '',<$fh>;close($fh)}}$data=~tr/\r\n//d;return (unpack('%32C*',$data))}
sub ya{print'<!--'."\n";print$hc{'titlebar'}.' v'.$hc{'header_version'}.' (Build: '.$hc{'prod_id'}.'.'.$hc{'prog_build'}.")\n";
print'License #'.$hc{'header_license_num'}.' ~ '.$hc{'header_company_name'}.' ~ '.$hc{'header_domain_name'}."\n";
printf('Execute time: %01d seconds'."\n",time() - $^T);print'-->'."\n"}# ---------------------------------------------------------------------------- 
# eof