#!/usr/local/bin/perl # ---------------------------------------------------------------------------- # Page Publisher # Developed by interactivetools.com, inc. # ---------------------------------------------------------------------------- # interactivetools.com is a new media software company which specializes in # developing custom web based applications and publishing tools. We provide # fast, friendly support and creative solutions for anyone doing business on # the web. If you would like to find out how we can help you with your next # internet project don't hesitate to contact us at info@interactivetools.com # or visit our website at http://www.interactivetools.com/ # ---------------------------------------------------------------------------- ($cgidir,$cgiurl)=&tl();unless($cgidir){print"Content-type: text/html\n\nUnable to determine cgidir!"; exit}%hd=("cgidir"=>$cgidir,"cgiurl"=>$cgiurl,"datadir"=>"$cgidir/data","filelock"=>"filelock.lock","tbcolor"=>"003399","bgcolor"=>"003366","product"=>"Page Publisher","ver"=>"1.22","prod_id"=>"11","prog_build"=>"***BUILD_NUMBER***","imageurl"=>"images/",); $SIG{__DIE__}=$SIG{__WARN__}=\&sl;srand(time+$$+($$<<15));$|++;%hh=("datafile"=>"$hd{'datadir'}/page.dat","fields"=>"num name path url updated users allow_all_users","search"=>"name","sortcode"=>sub{ lc((split(/\¡/,$a,3))[1])cmp lc((split(/\¡/,$b,3))[1])});%ho=("datafile"=>"$hd{'datadir'}/setup.dat.cgi","fields"=>"num product ver titlebar tbcolor1 tbcolor2 tbcolor3 bgcolor1 bgcolor2 bgcolor3 imageurl "."helpurl client_id client_pw admin_id admin_pw login_timeout login_timeout_min logoff_action "."logoff_url client_add client_edithtml client_remove confirm_erase confirm_erased confirm_saved "."license_name license_domain license_id d c f demo footerbar branding perpage "."client_upload upload_max upload_max_filesize image_max image_max_width image_max_height upload_allowed_extensions upload_dir upload_url");%hn=("datafile"=>"$hd{'datadir'}/user.dat.cgi","search"=>"name","filelock"=>"filelock.lock","fields"=>"num name login_id login_pw created_mon created_day created_year expires_mon expires_day "."expires_year expires_date expires_never disabled notes","sortcode"=>sub{ lc((split(/\¡/,$a,3))[1])cmp lc((split(/\¡/,$b,3))[1])});%hm=("filelock"=>"filelock.lock","fields"=>"num url");sub sg{my($filelock)=$_[0]||"$hd{'datadir'}/$hd{'filelock'}"; my($i);my($pdir)=$filelock;$pdir=~s/\\/\//g;if($pdir=~m/^(.*?)[^\/]+$/&&!-w $1){&sz('dirnotwritable',$1)}if(-e $filelock&&(stat($filelock))[9]<$^T-300){&sz("persistentfilelock",$filelock)} while(!mkdir($filelock,0777)){sleep 1;if(++$i>3){&sz('serverbusy')}}}sub si{my($filelock)=$_[0]||"$hd{'datadir'}/$hd{'filelock'}"; rmdir($filelock)}sub sa{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"}my($datafile)="$_[0]->{'datafile'}";my(@fields)=split(/ /,$_[0]->{'fields'}); my($in)=$_[1];my($newnum)=int$_[2];my(@aa);my(@ab);my(%hs);if((-e $datafile)&&$backup){&sb($_[0])}&sg();if(-e $datafile){ open(F,"<$datafile")||die("DB_Add : Error,Can't open '$datafile'.$!\n");@aa=;close(F)}foreach(@aa){/^\d/||next;$hs{(split(/\¡/))[0]}=1} if($newnum&&$hs{$newnum}){&si();return&sh(@_)}elsif($newnum){$nnum=$newnum}else{$nnum=1;while($hs{$nnum}){$nnum++}}open(F,">$datafile.tmp$$")||die("DB_Add : Can't create temp file $datafile.tmp$$.$!\n"); print F qq|#!$^X\n|;print F qq|print"Location: http://www.interactivetools.com/\\n\\n";\n__END__\n|;foreach(@aa){/^\d/||next; s/[^¡]+$//;print F"$_\n"}my($line)="$nnum¡";for$i(1..$#fields){my($enc)=$in->{$fields[$i]};$enc=~s/([\x1a\r\n\¡\¿])/sprintf("¿%02x",ord($1))/egx; $line.="$enc¡"}print F"$line\n";close(F)||die("DB_Add : Can't write $datafile : $!");rename("$datafile.tmp$$",$datafile)||die("DB_Add : Can't write $datafile : $!"); &si();return$nnum}sub sf{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"} my($datafile)="$_[0]->{'datafile'}";my(@fields)=split(/ /,$_[0]->{'fields'});my($out)=$_[1];my($rnum)=int$_[2];my(@aa);my(@ab); unless(-e $datafile){return(0)}if($_[0]->{'backup'}){&sb($_[0])}if(-e "$datafile"){&sg();open(F,"<$datafile")||die("DB_Load : Error,Can't open '$datafile'.$!\n"); @aa=;close(F);&si()}foreach(@aa){/^$rnum\¡/||next;s/[^¡]+$//;undef %$out;@ab=split(/\¡/);for$i(0..$#fields){$out->{$fields[$i]}=$ab[$i]; $out->{$fields[$i]}=~s/¿([A-F0-9]{2})/pack("C",hex($1))/egix}return1}return0}sub sc{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"}my($datafile)="$_[0]->{'datafile'}";my(@fields)=split(/ /,$_[0]->{'fields'}); my($rnum)=int$_[1];my(%hs);my($erased)=0;for(1..$#_){$hs{$_[$_]}++}my(@aa);unless(-e $datafile){return(0)}if($_[0]->{'backup'}){&sb($_[0])} &sg();if(-e "$datafile"){open(F,"<$datafile")||die("DB_Del : Error,Can't open '$datafile'.$!\n");@aa=;close(F)}open(F,">$datafile.tmp$$")||die("DB_Del : Can't create temp file $datafile.tmp$$.$!\n"); print F qq|#!$^X\n|;print F qq|print"Location: http://www.interactivetools.com/\\n\\n";\n__END__\n|;foreach(@aa){/^(\d+)\¡/||next; if($hs{$1}){$erased++; next}s/[^¡]+$//;print F"$_\n"}close(F)||die("DB_Del : Can't write $datafile : $!");rename("$datafile.tmp$$",$datafile)||die("DB_Del : Can't write $datafile : $!"); &si();return$erased}sub sd{my($datafile)="$_[0]->{'datafile'}";my(@fields)=split(/ /,$_[0]->{'fields'});my($out)=$_[1];my($sortcode)=$_[2]; my($rowcode)=$_[3];my($rcount)=0;my(@aa);my(@ab);unless(defined &$rowcode){die("DB_List : no rowcode defined!")}unless(-e $datafile){ die("DB_List : $datafile does not exist!")}if($_[0]->{'backup'}){&sb($_[0])}&sg();open(F,"<$datafile")||die("DB_List : Can't open '$datafile'.$!\n"); @aa=;close(F);&si();if($sortcode&&&$sortcode ne""){@aa=sort{&$sortcode} @aa}foreach(@aa){/^\d/||next;$rcount++;s/[^\¡]+$//; undef %$out;@ab=split(/\¡/);for$i(0..$#fields){$out->{$fields[$i]}=$ab[$i];$out->{$fields[$i]}=~s/¿([A-F0-9]{2})/pack("C",hex($1))/egix} if($rowcode){&$rowcode}}return($rcount)}sub se{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($_[3])ne"CODE"&&$_[3]){die"DB_ListPage : The fourth 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"}my($datafile)="$_[0]->{'datafile'}"; my(@fields)=split(/ /,$_[0]->{'fields'});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($_[0]->{'backup'}){&sb($_[0])}&sg();open(F,"<$datafile")||die("DB_List : Can't open '$datafile'.$!\n"); @aa=;close(F);&si();if($sortcode&&&$sortcode ne""){@aa=sort{&$sortcode} @aa}foreach(@aa){/^\d/||next;$rcount++;s/[^\¡]+$//; undef %$out;@ab=split(/\¡/);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 sq{ my($in)=$_[0];my(@ar)=((A..Z,a..z,0..9),'+','/');my($out)=unpack("B*",$in);$out=~s/(\d{6}|\d+$)/$ar[ord(pack"B*","00$1")]/ge; while(length($out)%4){$out.="="}return$out}sub sp{my($in)=$_[0];my(%if);my($out);for((A..Z,a..z,0..9),'+','/'){$if{$_}=$i++}$in=$_[0]||return"MIME64 : Nothing to decode"; $in=~s/[^A-Za-z0-9+\/]//g;$in=~s/([A-Za-z0-9+\/])/unpack"B*",chr($if{$1})/ge;$in=~s/\d\d(\d{6})/$1/g;$in=~s/(\d{8})/$out.=pack("B*",$1)/ge; return$out}sub td{my($text)=$_[0];$text=~s/([^A-Za-z0-9\*\.\@\_\-])/uc sprintf('%%%02x',ord($1))/egx;$text=~tr/ /+/;return$text} sub tc{my($text)=$_[0];$text=~tr/+/ /;$text=~s/%([A-F0-9]{2})/pack('C',hex($1))/egi;return$text}sub sh{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"}my($datafile)="$_[0]->{'datafile'}";my(@fields)=split(/ /,$_[0]->{'fields'}); my($in)=$_[1];my($rnum)=int$_[2];my($saved)=0;my(@aa);my(@ab);if(!-e $datafile){return&sa(@_)}if($_[0]->{'backup'}){&sb($_[0])} &sg();open(F,"<$datafile")||die("DB_Save : Error,Can't open '$datafile'.$!\n");@aa=;close(F);open(F,">$datafile.tmp$$")||die("DB_Save : Can't create temp file $datafile.tmp$$.$!\n"); print F qq|#!$^X\n|;print F qq|print"Location: http://www.interactivetools.com/\\n\\n";\n__END__\n|;foreach(@aa){/^\d/||next; if(/^$rnum\¡/){my($line)="$rnum¡";for$i(1..$#fields){my($enc)=$in->{$fields[$i]};$enc=~s/([\x1a\r\n\¡\¿])/sprintf("¿%02x",ord($1))/egx; $line.="$enc¡"}print F"$line\n";$saved++;next}s/[^¡]+$//;print F"$_\n"}close(F)||die("DB_Save : Can't write $datafile : $!"); rename("$datafile.tmp$$",$datafile)||die("DB_Save : Can't write $datafile : $!");&si();unless($saved){return&sa(@_)}}sub sj{ my$str=$_[0];my$time=$_[1];my$GMT=$_[2];if(!$time||$time ne int($time)){returnundef}my($sec,$min,$hour,$day,$mon,$year,$wday); if($GMT){($sec,$min,$hour,$day,$mon,$year,$wday)=gmtime($time)}else{($sec,$min,$hour,$day,$mon,$year,$wday)=localtime($time)} my(%ib,%ic,%ia,%id);my(@ak)=qw(Sun Mon Tue Wed Thu Fri Sat);my(@aj)=qw(Sunday Monday Tuesday Wednesday Thursday Friday Saturday); my(@ac)=qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);my(@ag)=qw(January February March April May June July August September October November December); foreach(@ak){$ib{lc$_}++}foreach(@aj){$ic{lc$_}++}foreach(@ac){$ia{lc$_}++}foreach(@ag){$id{lc$_}++}$str=~s/(\b[A-Za-z]{3,9}\b)/if($ib{ lc$1}){if(uc($1)eq$1){uc $ak[$wday]}elsif(lc($1)eq$1){lc$ak[$wday]}else{ucfirst lc$ak[$wday]}}elsif($ic{lc$1}){if(uc($1)eq$1){ uc $aj[$wday]}elsif(lc($1)eq$1){lc$aj[$wday]}else{ucfirst lc$aj[$wday]}}elsif($ia{lc$1}){if(uc($1)eq$1){uc $ac[$mon]}elsif(lc($1)eq$1){ lc$ac[$mon]}else{ucfirst lc$ac[$mon]}}elsif($id{lc$1}){if(uc($1)eq$1){uc $ag[$mon]}elsif(lc($1)eq$1){lc$ag[$mon]}else{ucfirst lc$ag[$mon]}} else{$1}/ge;$str=~s/(\d{1,4}\b)/if(length $1==4){$year+1900}elsif(length $1<=2){if(substr($1,0,1)eq 0){sprintf("%02d",$day)} else{$day}}else{$1}/ge;$str=~s/(\d{1,2})(st|nd|rd|th)/if($day==1||$day==21||$day==31){$day."st"}elsif($day==2||$day==22){ $day."nd"}elsif($day==3||$day==23){$day."rd"}else{$day."th"}/gei;$str=~s/SS/sprintf("%02d",$sec)/gei;$str=~s/MM/sprintf("%02d",$min)/gei; $str=~s/HH/sprintf("%02d",$hour)/gei;return$str}sub f{my($script,@as)=@_;my$data;my$fh=do{local *F; *F};if(open($fh,"<$cgidir/$script")){<$fh>; binmode($fh);$data.=join '',<$fh>;close($fh)}foreach(@as){if(open($fh,"<$cgidir/$_")){binmode($fh);$data.=join '',<$fh>; close($fh)}}$data=~tr/\r\n//d;return(unpack('%32C*',$data))}sub tq{use Socket;my($reginfo);my$host=$ENV{'HTTP_HOST'}||$ENV{'SERVER_NAME'}||$ENV{'SERVER_ADDR'}; my$path=$ENV{'SCRIPT_NAME'}||$ENV{'PATH_INFO'};$reginfo.='&'.'reg1='.&td($hc{'license_name'});$reginfo.='&'.'reg2='.&td($hc{'license_domain'}); $reginfo.='&'.'lnum='.&td(&ug($hc{'license_id'}));$reginfo.='&'.'prog='.'pp';$reginfo.='&'.'ver='.&td($hd{'ver'});$reginfo.='&'.'url='.&td("$host$path"); $reginfo.='&'.'csum='.&td(&f($file));my$paddr=gethostbyname('www.interactivetools.com')||return;my$sock=&uw();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: '.$ENV{'HTTP_REFERER'}."\n";print$sock 'User-Agent: itools_software'."\n\n";my$reply=join("",<$sock>); close($sock);if($reply=~/itools\.license\.invalid/){$hc{'d'}=1}if($reply=~/itools\.license\.valid/){$hc{'d'}=0}&sh(\%ho,\%hc,1); if($hc{'d'}){&sz('expired')}}sub ty{my$fh=&uw();my$filepath=shift;my$data;open($fh,"<$filepath")||return;binmode($fh);read($fh,$data,-s $fh); close($fh);return$data}sub uw{local *F;return*F}sub sk{my$html=shift;$html=~s/&/&/g;$html=~s/"/"/g;$html=~s//>/g;return$html}sub tz{my($filename,$image_type)=@_;$image_type||=$filename;if($image_type=~/\.gif(\.|$)/i){ return&ua($filename)}elsif($image_type=~/\.jpe?g(\.|$)/i){return&uc($filename)}elsif($image_type=~/\.png(\.|$)/i){return&ud($filename)} else{return()}}sub ud{my($filename)=@_;my($buf);open(PNG,$filename)||return(undef,undef,"PNG - Couldn't Open $filename"); binmode(PNG);seek(PNG,12,0);read(PNG,$buf,4);if($buf ne"IHDR"){close PNG; return(undef,undef,"PNG - Missing Image Header - $buf")} read(PNG,$buf,8);close PNG;returnunpack("NN",$buf)}sub uc{my($filename)=@_;my($buf,$segheader,$marker,$code,$len);open(JPEG,$filename)||return(undef,undef,"JPEG - Couldn't Open $filename"); binmode(JPEG);read(JPEG,$buf,2);while(1){read(JPEG,$segheader,4);($marker,$code,$len)=unpack("a a n",$segheader);if($marker ne"\xFF"){ close JPEG; return(undef,undef,"JPEG - Marker not Found")}if((ord($code)>=0xC0)&&(ord($code)<=0xC3)){read(JPEG,$buf,5);close(JPEG); my($y,$x)=unpack("xnn",$buf);return($x,$y)}else{read(JPEG,$buf,$len - 2)}}}sub ub{my($fh,$skip)=@_;my($lbuf);read($fh,$lbuf,$skip); while(1){if(eof($fh)){close GIF; return(undef)}read($fh,$lbuf,1);last if ord($lbuf)==0;read($fh,$lbuf,ord($lbuf))}1}sub ua{ my($filename)=@_;my($buf,$type,$cmapsize,$mapdata,$x,$w,$y,$h);open(GIF,$filename)||return(undef,undef,"GIF - Couldn't Open $filename"); binmode(GIF);read(GIF,$type,6);read(GIF,$buf,7);if(length($buf)!=7){close GIF; return(undef,undef,"GIF - Corrupted Header")}($x)=unpack("x4 C",$buf); if($x & 0x80){$cmapsize=3 * (2**(($x & 0x07)+1));read(GIF,$mapdata,$cmapsize);if(!$mapdata){close GIF; return(undef,undef,"GIF - Corrupted Colour Map")}} while(1){if(eof(GIF)){close GIF; return(undef,undef,"GIF - EOF at BlockStart")}read(GIF,$buf,1);($x)=unpack("C",$buf);if($x==0x2c){ read(GIF,$buf,8);if(length($buf)!=8){close GIF; return(undef,undef,"GIF - Missing Image Header")}($x,$w,$y,$h)=unpack("x4 C4",$buf); close(GIF);return($x+$w * 256,$y+$h * 256)}if($x==0x21){read(GIF,$buf,1);($x)=unpack("C",$buf);if($x==0xF9){read(GIF,$buf,6)} elsif($x==0xFE){&ub(\*GIF,0)||return(undef,undef,"GIF - Bad Block - skip=0")}elsif($x==0x01){&ub(\*GIF,13)||return(undef,undef,"GIF - Bad Block - skip=13")} elsif($x==0xFF){&ub(\*GIF,12)||return(undef,undef,"GIF - Bad Block - skip=12")}else{close GIF; return(undef,undef,"GIF - Unknown Block Extension")}} else{close GIF;return(undef,undef,"GIF - Unknown Block Type")}}}1;@ac=qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); @ag=qw(January February March April May June July August September October November December);%hb=&su();%hq=&st();&ts();%hc=&sv(); if($hc{'ver'}<$hd{'ver'}){&tr($hc{'ver'})}if($ENV{'QUERY_STRING'}eq"r"){&tq()}if($hc{'d'}){$hd{'header_license_num'}=&ug($hc{'license_id'}); &sz('expired')}&ue();$hd{'header_license_name'}=$hc{'license_name'};$hd{'header_license_domain'}=$hc{'license_domain'};$hd{'header_license_num'}=&ug($hc{'license_id'}); if($hb{"logoff"}){&so}elsif($hb{"nojavascript"}){&sz('nojs')}elsif($hb{"about"}){&sz('about')}else{&sn}if($hc{'demo'}){if($hb{"demo_no_browse"}){&sz('demo_no_browse')} if($hb{'browse'}&&$hb{'dir'}){&sz('demo_no_browse_redir')}if($hb{'setup_save'}){&sz('demo_no_setup_save')}if($hb{"page_add"}){&sz('demo_no_page_add')} if($hb{"page_save"}){&sz('demo_no_page_add')}}if($hb{"editpage"}){&um()}if($hb{"savepage"}){&ur()}if($hd{'cuser_admin'}||$hc{'client_edithtml'}){ if($hb{"edithtml"}){&ul()}if($hb{"savehtml"}){&uq()}}if($hd{'cuser_admin'}||$hc{'client_remove'}){if($hb{"page_confirm_erase"}){&uk()} if($hb{"page_erase"}){&un()}}if($hd{'cuser_admin'}||$hc{'client_add'}){if($hb{"page_add"}){&uj()}if($hb{"browse"}){&tw()} if($hb{"page_save"}){&up()}}if($hb{"page_listall"}){&uo()}if($hb{"page_list"}){&uo()}if($hb{'browse_file'}){&tw()}if($hb{"add_image_select"}){&tu()} if($hb{"add_image_select_save"}){&tv()}if($hb{"add_file_select"}){&tt()}if($hb{"add_file_select_save"}){&tv()}if($hb{"remove_image_select"}){&ut()} if($hb{"remove_image_select_confirm"}){&uu()}if($hb{"remove_file_select"}){&ut()}if($hb{"remove_file_select_confirm"}){&uu()} if($hd{'cuser_admin'}){if($hb{"setup_edit"}){&sx()}if($hb{"setup_save"}){&sy()}if($hb{'browse_file'}||$hb{'browse_dir'}){&tw()} if($hb{"user_list"}||$hb{'user_keyname'}||$hb{'search_user_list'}||$hb{'user_listall'}){&tj()}if($hb{'user_add'}){&tf()} if($hb{'user_edit'}){&th()}if($hb{'user_save'}){&tk()}if($hb{'user_confirm_erase'}){&tg()}if($hb{'user_erase'}){&ti()}if($hb{'page_settings_edit'}){&sr()} if($hb{'page_settings_save'}){&ss()}}&uo;exit;sub sr{unless($hd{'cuser_admin'}){&sl("Must be logged in as administrator.")} unless($hb{'page_settings_edit'}){die("Page_Settings_Edit : Page number not received from form.")}my(%ha);&ta('_page_menus.html'); &sf(\%hh,\%ha,$hb{'page_settings_edit'});if($hd{'cuser_admin'}){my$user_menu=&tm($ha{'users'});my$checked_radio='allow_all_users_checked_'.$ha{'allow_all_users'}; my%hz=('user_menu'=>$user_menu,$checked_radio=>' checked');$ha{'users'}=&tb('user_menu',\%hz);$ha{'name_he'}=&sk($ha{'name'}); $ha{'path_he'}=&sk($ha{'path'});$ha{'url_he'}=&sk($ha{'url'})}print"Content-type: text/html\n\n" unless($ContentType++); print&sm("edit_users",\%ha);exit}sub ss{if(!$hb{'name'}){$ha{'msg'}="You must specify a page name"}elsif(!$hb{'path'}){$ha{'msg'}="You must specify a filepath"} elsif(!$hb{'url'}||$hb{'url'}eq"http://"){$ha{'msg'}="You must specify a page URL"}if($ha{'msg'}){print"Content-type: text/html\n\n" unless($ContentType++); print&tb("showmsg",\%ha);exit}unless($hd{'cuser_admin'}){&sl("Must be logged in as administrator.")}unless($hb{'num'}){die("Page_Settings_Save : Page number not received from form.")} my%ii;unless(&sf(\%hh,\%ii,$hb{'num'})){die("Page_Settings_Save : Invalid record number.")}$hb{'updated'}=$ii{'updated'}; &sh(\%hh,\%hb,$hb{'num'})}sub ti{unless($hd{'cuser_admin'}){&sl("Must be logged in as administrator.")}unless($hb{'num'}){ die("User_Erase : User record number not received from form.")}&sc(\%hn,$hb{'num'});my%hx;my$remove_user=sub{if($hx{'users'}=~s/(^|,)$hb{'num'},/$1/x){&sh(\%hh,\%hx,$hx{'num'})}}; &sd(\%hh,\%hx,undef,$remove_user);&tj()}sub tg{unless($hb{'user_confirm_erase'}){die("User_Confirm_Erase : User record number not received from form.")} my%ha;&ta('_user_menus.html');unless(&sf(\%hn,\%ha,$hb{'user_confirm_erase'})){die("User_Confirm_Erase : User number not found in DB.")} print"Content-type: text/html\n\n" unless($ContentType++);print&sm("confirm_erase",\%ha);exit}sub tk{unless($hd{'cuser_admin'}){&sl("Must be logged in as administrator.")} my%ha=%hb;&ta('_user_menus.html');unless(length($ha{'name'})){$ha{'error'}=&tb('no_user_name')}unless(length($ha{'login_id'})){ $ha{'error'}.=&tb('no_login_name')}unless(length($ha{'login_pw'})){$ha{'error'}.=&tb('no_login_pw')}my$duplicate_username=0; my%hi;if(lc($hb{'login_id'}eq lc($hc{'admin_id'}))){$duplicate_username=1} elsif($hb{'rnum'}){$check_login=sub{if(($hi{'num'}!=$hb{'rnum'})&&(lc($hb{'login_id'})eq lc($hi{'login_id'}))){ $duplicate_username=1}};&sd(\%hn,\%hi,undef,$check_login)}else{$check_login=sub{if(lc($hb{'login_id'})eq lc($hi{'login_id'})){ $duplicate_username=1}};&sd(\%hn,\%hi,undef,$check_login)}if($duplicate_username){$ha{'error'}.=&tb('duplicate_username')} if($ha{'error'}){$ha{"created_mon_$ha{'created_mon'}_selected"}="selected";$ha{"created_day_$ha{'created_day'}_selected"}="selected"; $ha{"created_year_$ha{'created_year'}_selected"}="selected";$ha{"expires_mon_$ha{'expires_mon'}_selected"}="selected";$ha{"expires_day_$ha{'expires_day'}_selected"}="selected"; $ha{"expires_year_$ha{'expires_year'}_selected"}="selected";$ha{"expires_never_checked"}="checked"if$ha{'expires_never'}; $ha{"disabled_$ha{'disabled'}_checked"}="checked";$ha{'name_he'}=&sk($ha{'name'});$ha{'login_id_he'}=&sk($ha{'login_id'}); $ha{'login_pw_he'}=&sk($ha{'login_pw'});$ha{'notes_he'}=&sk($ha{'notes'});print"Content-type: text/html\n\n" unless($ContentType++); if($hb{'rnum'}){print&sm("edit",\%ha)}else{print&sm("add",\%ha)}exit}else{my@am=qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); $ha{'expires_date'}="$ha{'expires_day'} $am[$ha{'expires_mon'} - 1] $ha{'expires_year'}";if($hb{'rnum'}){&sh(\%hn,\%ha,$hb{'rnum'})} else{&sa(\%hn,\%ha)}&tj()}}sub th{unless($hd{'cuser_admin'}){&sl("Must be logged in as administrator.")}&ta('_user_menus.html'); my%ha;unless(&sf(\%hn,\%ha,$hb{'user_edit'})){die("User_Edit : User number not found in DB.")}$ha{"created_mon_$ha{'created_mon'}_selected"}="selected"; $ha{"created_day_$ha{'created_day'}_selected"}="selected";$ha{"created_year_$ha{'created_year'}_selected"}="selected";$ha{"expires_mon_$ha{'expires_mon'}_selected"}="selected"; $ha{"expires_day_$ha{'expires_day'}_selected"}="selected";$ha{"expires_year_$ha{'expires_year'}_selected"}="selected";$ha{"expires_never_checked"}="checked"if$ha{'expires_never'}; $ha{"disabled_$ha{'disabled'}_checked"}="checked";$ha{'name_he'}=&sk($ha{'name'});$ha{'login_id_he'}=&sk($ha{'login_id'}); $ha{'login_pw_he'}=&sk($ha{'login_pw'});$ha{'notes_he'}=&sk($ha{'notes'});print"Content-type: text/html\n\n" unless($ContentType++); print&sm("edit",\%ha);exit}sub tf{unless($hd{'cuser_admin'}){&sl('Must be logged in as administrator.')}&ta('_user_menus.html'); my($day,$mon,$year)=(localtime)[3,4,5];$mon++; $year+=1900;$ha{'created_day_'.$day.'_selected'}='selected';$ha{'created_mon_'.$mon.'_selected'}='selected'; $ha{'created_year_'.$year.'_selected'}='selected';$year++;$ha{'expires_day_'.$day.'_selected'}='selected';$ha{'expires_mon_'.$mon.'_selected'}='selected'; $ha{'expires_year_'.$year.'_selected'}='selected';print"Content-type: text/html\n\n" unless($ContentType++);print&sm("add",\%ha); exit}sub tj{unless($hd{'cuser_admin'}){&sl("Must be logged in as administrator.")}my($sortcode)=${'hn'}{'sortcode'}||die("User_List : no sort routine defined\n"); my(@an)=split(/ /,${'hn'}{'search'});&ta('_user_menus.html');my(%he,%ha);$perpage=$hc{"perpage"}||10;$pagenum=$hb{'pagenum'}||$hq{"user_pagenum"}||1; if(defined $hb{'user_keyname'}){$user_keyname=$hb{'user_keyname'}; $pagenum=1}else{$user_keyname=$hq{"user_keyname"}}if($hb{"user_listall"}){ $user_keyname=""; $pagenum=1}&sw("user_pagenum",$pagenum);&sw("user_keyname",$user_keyname);$ha{'user_keyname_he'}=&sk($user_keyname); my%hi;my$user_match_code=sub{if($hi{'expires_never'}){$hi{'expires'}='Never'}else{$hi{'expires'}=$hi{'expires_date'}}$ha{'list'}.=&tb("user",\%hi)}; my$keyname_query=sub{return(!length($user_keyname)||$hi{'name'}=~/$user_keyname/i)};($ha{'pcount'},$ha{'mcount'},$ha{'rcount'},$ha{'cpage'},$ha{'lpage'},$ha{'npage'})=&se(\%{'hn'},$keyname_query,$user_match_code,$sortcode,\%hi,$pagenum,$perpage); unless($ha{'list'}){$ha{'list'}=&tb("not_found")}print"Content-type: text/html\n\n" unless($ContentType++);print&sm("list",\%ha); exit}sub tm{my$page_users=$_[0]||0;my%ha;my$options;my$rowcode;if($page_users){$rowcode=sub{$options.=qq|\n"}}else{$rowcode=sub{$options.=qq|