#!/usr/bin/perl use CGI::Carp qw(fatalsToBrowser); use strict; use vars qw($quota $dwsupport $csspath $cssurl %yu $flock $userfile $windows $fsize @rext @txtext @fext @text @iext @li $libraryurl $librarypath $templateurl $templatepath $fperm $dperm $rootpath $rooturl %in %cookie $basepath $cgipath $cgiurl $htmlpath $htmlurl $username $password $nosetup $imageurl); # # csPublisher - 3.0 - 111802B # ##################################################################### # # # Copyright © 1999-2002 CGISCRIPT.NET - All Rights Reserved # # # ##################################################################### # # # THIS COPYRIGHT INFORMATION MUST REMAIN INTACT # # AND MAY NOT BE MODIFIED IN ANY WAY # # # ##################################################################### # # When you downloaded this script you agreed to accept the terms # of this Agreement. This Agreement is a legal contract, which # specifies the terms of the license and warranty limitation between # you and CGISCRIPT.NET. You should carefully read the following # terms and conditions before installing or using this software. # Unless you have a different license agreement obtained from # CGISCRIPT.NET, installation or use of this software indicates # your acceptance of the license and warranty limitation terms # contained in this Agreement. If you do not agree to the terms of this # Agreement, promptly delete and destroy all copies of the Software. # # Versions of the Software # Only one copy of the registered version of CGISCRIPT.NET # may used on one web site. # # License to Redistribute # Distributing the software and/or documentation with other products # (commercial or otherwise) or by other than electronic means without # CGISCRIPT.NET's prior written permission is forbidden. # All rights to the CGISCRIPT.NET software and documentation not expressly # granted under this Agreement are reserved to CGISCRIPT.NET. # # Disclaimer of Warranty # THIS SOFTWARE AND ACCOMPANYING DOCUMENTATION ARE PROVIDED "AS IS" AND # WITHOUT WARRANTIES AS TO PERFORMANCE OF MERCHANTABILITY OR ANY OTHER # WARRANTIES WHETHER EXPRESSED OR IMPLIED. BECAUSE OF THE VARIOUS HARDWARE # AND SOFTWARE ENVIRONMENTS INTO WHICH CGISCRIPT.NET MAY BE USED, NO WARRANTY # OF FITNESS FOR A PARTICULAR PURPOSE IS OFFERED. THE USER MUST ASSUME THE # ENTIRE RISK OF USING THIS PROGRAM. ANY LIABILITY OF CGISCRIPT.NET WILL BE # LIMITED EXCLUSIVELY TO PRODUCT REPLACEMENT OR REFUND OF PURCHASE PRICE. # IN NO CASE SHALL CGISCRIPT.NET BE LIABLE FOR ANY INCIDENTAL, SPECIAL OR # CONSEQUENTIAL DAMAGES OR LOSS, INCLUDING, WITHOUT LIMITATION, LOST PROFITS # OR THE INABILITY TO USE EQUIPMENT OR ACCESS DATA, WHETHER SUCH DAMAGES ARE # BASED UPON A BREACH OF EXPRESS OR IMPLIED WARRANTIES, BREACH OF CONTRACT, # NEGLIGENCE, STRICT TORT, OR ANY OTHER LEGAL THEORY. THIS IS TRUE EVEN IF # CGISCRIPT.NET IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. IN NO CASE WILL # CGISCRIPT.NET' LIABILITY EXCEED THE AMOUNT OF THE LICENSE FEE ACTUALLY PAID # BY LICENSEE TO CGISCRIPT.NET. # # Credits: # Andy Angrick - Programmer - angrick@cgiscript.net # Mike Barone - Design - mbarone@cgiscript.net # # For information about this script or other scripts see # http://www.cgiscript.net # # Thank you for trying out our script. # If you have any suggestions or ideas for a new innovative script # please direct them to suggest@cgiscript.net. Thanks. # ######################################################################## $basepath = './'; (! -e "$basepath/setup.cgi")?($nosetup=1):(require("$basepath/setup.cgi")); require("$basepath/libs.cgi"); $in{'cgiurl'} = $cgiurl."/csPublisher.cgi"; $in{'imageurl'} = $imageurl; (!$in{'siteurl'})&&($in{'siteurl'} = $rooturl); (!$in{'sitepath'})&&($in{'sitepath'} = $rootpath); $dperm = 0755; $fperm = 0664; $dwsupport = 1; $flock=1; &main; exit; # _____________________________________________________________________________ sub main{ ($ENV{'CONTENT_TYPE'} =~ /multipart\/form-data/i)?(&getdata(1)):(&getdata()); $in{'d'} =~ s/%(..)/pack("c",hex($1))/ge; $in{'nd'} =~ s/%(..)/pack("c",hex($1))/ge; $in{'nf'} =~ s/%(..)/pack("c",hex($1))/ge; &clearcommands; ($in{'command'} eq 'download')&&(&DoDownload); ($in{'command'} eq 'tdownload')&&(&DoDownload); ($in{'command'} eq 'idownload')&&(&DoDownload); print "Content-type: text/html\n"; print "Set-cookie: isLogged=1\n\n"; ($in{'command'} eq '')&&($nosetup)&&(&Setup); ($in{'command'} eq 'savesetup')&&(($nosetup)?(&SaveSetup):(&PError("Error. Permission denied."))); ($in{'command'} eq 'login')&&(&Login); ($in{'command'} eq '')&&(&Login); &GetLogin; ($in{'command'} eq 'saveconfig')&&(&SaveConfig); &GetConfig; ($in{'command'} eq 'dodownload')&&(&DoDownload); ($in{'command'} eq 'manage')&&(&Manage); ($in{'command'} eq 'tmanage')&&(&Manage); ($in{'command'} eq 'imanage')&&(&Manage); ($in{'command'} eq 'smanage')&&(&SManage); ($in{'command'} eq 'uo')&&(&UO); ($in{'command'} eq 'tuo')&&(&UO); ($in{'command'} eq 'iuo')&&(&UO); ($in{'command'} eq 'showrename')&&(&ShowRename); ($in{'command'} eq 'tshowrename')&&(&ShowRename); ($in{'command'} eq 'ishowrename')&&(&ShowRename); ($in{'command'} eq 'showupload')&&(&ShowUpload); ($in{'command'} eq 'tshowupload')&&(&ShowUpload); ($in{'command'} eq 'ishowupload')&&(&ShowUpload); ($in{'command'} eq 'sshowupload')&&(&SShowUpload); ($in{'command'} eq 'upload')&&(&Upload); ($in{'command'} eq 'tupload')&&(&Upload); ($in{'command'} eq 'iupload')&&(&Upload); ($in{'command'} eq 'supload')&&(&SUpload); ($in{'command'} eq 'showconfig')&&(&ShowConfig); ($in{'command'} eq 'showcopy')&&(&ShowCopy); ($in{'command'} eq 'tshowcopy')&&(&ShowCopy); ($in{'command'} eq 'ishowcopy')&&(&ShowCopy); ($in{'command'} eq 'rename')&&(&Rename); ($in{'command'} eq 'trename')&&(&Rename); ($in{'command'} eq 'irename')&&(&Rename); ($in{'command'} eq 'copy')&&(&Copy); ($in{'command'} eq 'tcopy')&&(&Copy); ($in{'command'} eq 'icopy')&&(&Copy); ($in{'command'} eq 'deleted')&&(&DeleteD); ($in{'command'} eq 'tdeleted')&&(&DeleteD); ($in{'command'} eq 'ideleted')&&(&DeleteD); ($in{'command'} eq 'deletef')&&(&DeleteF); ($in{'command'} eq 'tdeletef')&&(&DeleteF); ($in{'command'} eq 'ideletef')&&(&DeleteF); ($in{'command'} eq 'sdeletef')&&(&SDeleteF); ($in{'command'} eq 'createnewd')&&(&CreateNewD); ($in{'command'} eq 'tcreatenewd')&&(&CreateNewD); ($in{'command'} eq 'icreatenewd')&&(&CreateNewD); ($in{'command'} eq 'createnewf')&&(&CreateNewF); ($in{'command'} eq 'tcreatenewf')&&(&CreateNewF); ($in{'command'} eq 'createdir')&&(&CreateDir); ($in{'command'} eq 'tcreatedir')&&(&CreateDir); ($in{'command'} eq 'icreatedir')&&(&CreateDir); ($in{'command'} eq 'createfile')&&(&CreateFile); ($in{'command'} eq 'tcreatefile')&&(&CreateFile); ($in{'command'} eq 'showedit')&&(&ShowEdit); ($in{'command'} eq 'tshowedit')&&(&ShowEdit); ($in{'command'} eq 'showeditraw')&&(&ShowEditRAW); ($in{'command'} eq 'savechanges')&&(&SaveChanges); ($in{'command'} eq 'savechangese')&&(&SaveChanges); ($in{'command'} eq 'tsavechanges')&&(&SaveChanges); ($in{'command'} eq 'tsavechangese')&&(&SaveChanges); ($in{'command'} eq 'showform')&&(&ShowForm); ($in{'command'} eq 'showtext')&&(&ShowText); ($in{'command'} eq 'showtextarea')&&(&ShowTextArea); ($in{'command'} eq 'showhidden')&&(&ShowHidden); ($in{'command'} eq 'showbutton')&&(&ShowButton); ($in{'command'} eq 'showcheckbox')&&(&ShowCheckBox); ($in{'command'} eq 'showradio')&&(&ShowRadio); ($in{'command'} eq 'showdropdown')&&(&ShowDropdown); ($in{'command'} eq 'showspecial')&&(&ShowSpecial); ($in{'command'} eq 'showhr')&&(&ShowHR); ($in{'command'} eq 'showtable')&&(&ShowTable); ($in{'command'} eq 'showcell')&&(&ShowCell); ($in{'command'} eq 'showimage')&&(&ShowImage); ($in{'command'} eq 'showpage')&&(&ShowPage); ($in{'command'} eq 'showhtml')&&(&ShowHTML); ($in{'command'} eq 'showeditable')&&(&ShowEditable); ($in{'command'} eq 'showusers')&&(&TShowUsers); ($in{'command'} eq 'saveform')&&(&SaveForm); ($in{'command'} eq 'savetext')&&(&SaveText); ($in{'command'} eq 'savetextarea')&&(&SaveTextArea); ($in{'command'} eq 'savehidden')&&(&SaveHidden); ($in{'command'} eq 'savebutton')&&(&SaveButton); ($in{'command'} eq 'savecheckbox')&&(&SaveCheckBox); ($in{'command'} eq 'saveradio')&&(&SaveRadio); ($in{'command'} eq 'savedropdown')&&(&SaveDropdown); ($in{'command'} eq 'savehr')&&(&SaveHR); ($in{'command'} eq 'savetable')&&(&SaveTable); ($in{'command'} eq 'savecell')&&(&SaveCell); ($in{'command'} eq 'saveimage')&&(&SaveImage); ($in{'command'} eq 'savepage')&&(&SavePage); ($in{'command'} eq 'savehtml')&&(&SaveHTML); ($in{'command'} eq 'saveeditable')&&(&SaveEditable); ($in{'command'} eq 'removeeditable')&&(&RemoveEditable); ($in{'command'} eq 'saveusers')&&(&TSaveUsers); ($in{'command'} eq 'preview')&&(&Preview); } sub Preview{ $in{'body'} =~ s/\+/ /g; $in{'body'} =~ s/%(..)/pack("c",hex($1))/ge; $in{'body'} =~ s/\>/>/g; $in{'body'} =~ s/\</){ print; } close F; exit; } sub clearcommands{ $in{'easyMode'} = ''; $in{'editablesarray'}=''; $in{'et'}=''; $in{'hasDW'} = ''; $in{'atype'} = ''; $in{'basehref'} = ''; $in{'vhtml'} = ''; } sub ShowHTML{ &PageOut("$cgipath/t_html.htm"); exit; } sub SaveHTML{ $in{'tagstart'} =~ s/"/\\"/g; $in{'tagend'} =~ s/"/\\"/g; print <<"EOF"; EOF exit; } sub ShowConfig{ ($in{'atype'} ne 'admin')&&(&PError("Error. Permission denied")); &PageOut("$cgipath/t_global_config.htm"); exit; } sub SaveConfig{ ($in{'atype'} ne 'admin')&&(&PError("Error. Permission denied")); $in{'fextensions'} =~ tr/A-Z/a-z/; ($in{'fextensions'} =~ /[^a-z,]/)&&(&PError("Error. Invalid file extensions")); ($in{'fsize'} =~ /[^\d\.]/)&&(&PError("Error. Invalid file size limit")); $in{'textensions'} =~ tr/A-Z/a-z/; ($in{'textensions'} =~ /[^a-z,]/)&&(&PError("Error. Invalid template extensions")); ($in{'tsize'} =~ /[^\d\.]/)&&(&PError("Error. Invalid template size limit")); $in{'iextensions'} =~ tr/A-Z/a-z/; ($in{'iextensions'} =~ /[^a-z,]/)&&(&PError("Error. Invalid image extensions")); ($in{'isize'} =~ /[^\d\.]/)&&(&PError("Error. Invalid image size limit")); ($in{'rextensions'} =~ /[^a-z,]/)&&(&PError("Error. Invalid raw edit extensions")); ($in{'txt'} =~ /[^a-z,]/)&&(&PError("Error. Invalid text edit extensions")); open(DB,">$cgipath/data/config.cgi"); print DB "$in{'fextensions'}\t$in{'fsize'}\t$in{'textensions'}\t$in{'tsize'}\t$in{'iextensions'}\t$in{'isize'}\t$in{'rextensions'}\t$in{'txt'}\t$in{'pdownload'}"; close DB; if(($in{'newpassword'})&&($in{'UserName'} eq $username)){ ($in{'newpassword'} ne $in{'newpassword2'})&&(&PError("Error. Please retype passwords")); $in{'dnp'} = qq|document.cookie="PassWord=$in{'newpassword'}";|; ($in{'newpassword'} =~ /\W/)&&(&PError("Error. Password can only contain alpha-numberic characters")); if(!$windows){ $in{'newpassword'} = crypt($in{'newpassword'},'CS'); } my ($buffer); open(SETUP,"+<$basepath/setup.cgi"); while(){ $buffer .= $_; } seek(SETUP,0,0); $buffer =~ s/password\s*=\s*'.*'/password='$in{'newpassword'}'/i; print SETUP $buffer; truncate (SETUP, tell(SETUP)); close SETUP; } print <<"EOF"; EOF exit; } sub SaveDropdown{ (!$in{'size'})&&($in{'size'} = '1'); if($in{'mtype'} eq 'insert'){ (!$in{'name'})&&($in{'name'} = 'dropdown'); my (@options) = split(/\r*\n/,$in{'options'}); my ($opt,$optv,$sel); for my $i (@options){ if($i =~ /^\*/){ $sel = 'selected'; $i =~ s/^\*//; } if($i =~ /\|/){ ($optv,$i) = split(/\|/,$i); $optv = "value=\\\"$optv\\\""; } $opt .= ""; $optv=''; $sel=''; } my $newfield = ""; print <<"EOF"; EOF } else{ my (@options) = split(/\r*\n/,$in{'options'}); my ($opt,$optv,$sel,$idx); $idx=0; for my $i (@options){ if($i =~ /^\*/){ $sel = "window.opener.myFld.options.selectedIndex=$idx"; $i =~ s/^\*//; } if($i =~ /\|/){ ($optv,$i) = split(/\|/,$i); } $opt .= qq|window.opener.AddNewOption('$i','$optv',$idx);\n|; $optv=''; $idx++; } print <<"EOF"; EOF } exit; } sub SaveUsers{ my(@l,$found,$page); $page = "$rootpath/$in{'d'}/$in{'nd'}"; $page =~ s/\/+/\//g; $in{'uwa'} =~ s/^~//; if(! -e "$cgipath/data/security.cgi"){ open(DB,">$cgipath/data/security.cgi"); print DB "$page\t$in{'uwa'}\t$in{'name'}\n"; close DB; } else{ open(DB,"+<$cgipath/data/security.cgi"); ($flock)&&(flock(DB,2)); while(){ chomp; my($f,$u,$n) = split("\t",$_); if($in{'command'} eq 'saveusers'){ (($f eq $page)&&(!$n))?(($found=1)&&(push(@l,"$page\t$in{'uwa'}\t$in{'name'}"))):(push(@l,$_)); } else{ (($f eq $page)&&($n eq $in{'name'}))?(($found=1)&&(push(@l,"$page\t$in{'uwa'}\t$in{'name'}"))):(push(@l,$_)); } } } seek(DB,0,0); foreach my $i (@l){ print DB "$i\n"; } if(!$found){ print DB "$page\t$in{'uwa'}\t$in{'name'}\n"; } truncate(DB, tell(DB)); close DB; ($flock)&&(flock(DB,8)); } sub RemoveUsers{ my($page) = @_; my(@l); $page = "$rootpath/$in{'d'}/$page"; $page =~ s/\/+/\//g; open(DB,"+<$cgipath/data/security.cgi"); ($flock)&&(flock(DB,2)); while(){ chomp; my($f,$u,$n) = split("\t",$_); ($f ne $page)&&(push(@l,$_)); } seek(DB,0,0); foreach my $i (@l){ print DB "$i\n"; } truncate(DB, tell(DB)); close DB; ($flock)&&(flock(DB,8)); } sub CheckForAccess{ my($page) = @_; my($access); $page = "$rootpath/$in{'d'}/$page"; $page =~ s/\/+/\//g; open(DB,"<$cgipath/data/security.cgi"); while(){ chomp; my($f,$u,$n) = split("\t",$_); if($f eq $page){ my(@users) = split("~",$u); foreach my $i (@users){ ($i eq $in{'UserName'})&&($access=1); if($n){ $in{'editablesarray'} .= "myEditables[myEditables.length]=\"$n\";\n" unless ($i ne $in{'UserName'}); } else{ $in{'et'} = 'hp'; } } } } close DB; ($access)?(return 0):(return 1); } sub GetUsers{ my($page); $page = "$rootpath/$in{'d'}/$in{'nd'}"; $page =~ s/\/+/\//g; open(DB,"<$cgipath/data/security.cgi"); while(){ chomp; my($f,$u,$n) = split("\t",$_); if(($f eq $page)&&(!$n)){ my(@users) = split("~",$u); foreach my $i (@users){ $in{'user2'} .= qq||; $yu{$i} =1; } } } close DB; } sub GetUsers2{ my($page); $page = "$rootpath/$in{'d'}/$in{'nd'}"; $page =~ s/\/+/\//g; open(DB,"<$cgipath/data/security.cgi"); while(){ chomp; my($f,$u,$n) = split("\t",$_); if(($f eq $page)&&($in{'name'})&&($in{'name'} eq $n)){ my(@users) = split("~",$u); foreach my $i (@users){ $in{'user2'} .= qq||; $yu{$i} =1; } } } close DB; } sub GetEditables{ my($page); $page = "$rootpath/$in{'d'}/$in{'nd'}"; $page =~ s/\/+/\//g; open(DB,"<$cgipath/data/security.cgi"); while(){ chomp; my($f,$u,$n) = split("\t",$_); if(($f eq $page)&&($n)){ $in{'editablesarray'} .= "myEditables[myEditables.length]=\"$n\";\n"; } } close DB; } sub SavePage{ if($in{'file'}){ my $rn = &GetRealName($in{'file'}); $in{'fta'} = 'gif,jpg'; &CheckExt($rn); &SaveFile($in{'file'},"$librarypath/$rn"); $in{'src'} = "$libraryurl/$rn"; } ($in{'bgcolor'})?($in{'bgcolor'} = "window.opener.editSRC.document.body.bgColor = \"$in{'bgcolor'}\";"):($in{'bgcolor'} = "window.opener.editSRC.document.body.bgColor = \"\";"); ($in{'watermark'} eq 'Yes' )?($in{'bgproperties'} = "window.opener.editSRC.document.body.bgProperties = \"fixed\";"):($in{'bgproperties'} = "window.opener.editSRC.document.body.bgProperties = \"\";"); ($in{'src'})?($in{'background'} = "window.opener.editSRC.document.body.background = \"$in{'src'}\";"):($in{'background'} = "window.opener.editSRC.document.body.background = \"\";"); ($in{'textcolor'})?($in{'textcolor'} = "window.opener.editSRC.document.body.text = \"$in{'textcolor'}\";"):($in{'textcolor'} = "window.opener.editSRC.document.body.text = \"\";"); ($in{'hyperlinkcolor'})?($in{'hyperlinkcolor'} = "window.opener.editSRC.document.body.link = \"$in{'hyperlinkcolor'}\";"):($in{'hyperlinkcolor'} = "window.opener.editSRC.document.body.link = \"\";"); ($in{'ahyperlinkcolor'})?($in{'ahyperlinkcolor'} = "window.opener.editSRC.document.body.aLink = \"$in{'ahyperlinkcolor'}\";"):($in{'ahyperlinkcolor'} = "window.opener.editSRC.document.body.aLink = \"\";"); ($in{'vhyperlinkcolor'})?($in{'vhyperlinkcolor'} = "window.opener.editSRC.document.body.vLink = \"$in{'vhyperlinkcolor'}\";"):($in{'vhyperlinkcolor'} = "window.opener.editSRC.document.body.vLink = \"\";"); ($in{'topmargin'})?($in{'topmargin'} = "window.opener.editSRC.document.body.topMargin = \"$in{'topmargin'}\";"):($in{'topmargin'} = "window.opener.editSRC.document.body.topMargin = \"\";"); ($in{'leftmargin'})?($in{'leftmargin'} = "window.opener.editSRC.document.body.leftMargin = \"$in{'leftmargin'}\";"):($in{'leftmargin'} = "window.opener.editSRC.document.body.leftMargin = \"\";"); ($in{'scrollbararrowcolor'})?($in{'scrollbararrowcolor'} = "window.opener.editSRC.document.body.style.scrollbarArrowColor = \"$in{'scrollbararrowcolor'}\";"):($in{'scrollbararrowcolor'} = "window.opener.editSRC.document.body.style.scrollbarArrowColor = \"\";"); ($in{'scrollbartrackcolor'})?($in{'scrollbartrackcolor'} = "window.opener.editSRC.document.body.style.scrollbarTrackColor = \"$in{'scrollbartrackcolor'}\";"):($in{'scrollbartrackcolor'} = "window.opener.editSRC.document.body.style.scrollbarTrackColor = \"\";"); ($in{'scrollbarshadowcolor'})?($in{'scrollbarshadowcolor'} = "window.opener.editSRC.document.body.style.scrollbarShadowColor = \"$in{'scrollbarshadowcolor'}\";"):($in{'scrollbarshadowcolor'} = "window.opener.editSRC.document.body.style.scrollbarShadowColor = \"\";"); ($in{'scrollbarfacecolor'})?($in{'scrollbarfacecolor'} = "window.opener.editSRC.document.body.style.scrollbarFaceColor = \"$in{'scrollbarfacecolor'}\";"):($in{'scrollbarfacecolor'} = "window.opener.editSRC.document.body.style.scrollbarFaceColor = \"\";"); ($in{'scrollbarhighlightcolor'})?($in{'scrollbarhighlightcolor'} = "window.opener.editSRC.document.body.style.scrollbarHighlightColor = \"$in{'scrollbarhighlightcolor'}\";"):($in{'scrollbarhighlightcolor'} = "window.opener.editSRC.document.body.style.scrollbarHighlightColor = \"\";"); ($in{'scrollbardarkshadowcolor'})?($in{'scrollbardarkshadowcolor'} = "window.opener.editSRC.document.body.style.scrollbarDarkShadowColor = \"$in{'scrollbardarkshadowcolor'}\";"):($in{'scrollbardarkshadowcolor'} = "window.opener.editSRC.document.body.style.scrollbarDarkShadowColor = \"\";"); ($in{'scrollbar3dlightcolor'})?($in{'scrollbar3dlightcolor'} = "window.opener.editSRC.document.body.style.scrollbar3dLightColor = \"$in{'scrollbar3dlightcolor'}\";"):($in{'scrollbar3dlightcolor'} = "window.opener.editSRC.document.body.style.scrollbar3dLightColor = \"\";"); if($in{'title'}){ $in{'title1'} = "window.opener.editSRC.document.title = \"$in{'title'}\";"; $in{'title2'} = qq| var newMeta = window.opener.editSRC.document.createElement(''); if(window.opener.TitleE == null){ var myHead = window.opener.editSRC.document.getElementsByTagName("HEAD"); myHead[0].appendChild(newMeta); } else{ window.opener.TitleE.replaceNode(newMeta); } |; } else{ $in{'title1'} = "window.opener.document.title = \"\";"; $in{'title2'} = qq| var newMeta = window.opener.editSRC.document.createElement(''); if(window.opener.TitleE == null){ var myHead = window.opener.editSRC.document.getElementsByTagName("HEAD"); myHead[0].appendChild(newMeta); } else{ window.opener.TitleE.replaceNode(newMeta); } |; } if($in{'author'}){ $in{'author'} = qq| var newMeta = window.opener.editSRC.document.createElement(''); if(window.opener.AuthorE == null){ var myHead = window.opener.editSRC.document.getElementsByTagName("HEAD"); myHead[0].appendChild(newMeta); } else{ window.opener.AuthorE.replaceNode(newMeta); } |; } else{ $in{'author'} = qq| if(window.opener.AuthorE != null){ window.opener.AuthorE.removeNode(true); } |; } if($in{'owner'}){ $in{'owner'} = qq| var newMeta = window.opener.editSRC.document.createElement(''); if(window.opener.OwnerE == null){ var myHead = window.opener.editSRC.document.getElementsByTagName("HEAD"); myHead[0].appendChild(newMeta); } else{ window.opener.OwnerE.replaceNode(newMeta); } |; } else{ $in{'owner'} = qq| if(window.opener.OwnerE != null){ window.opener.OwnerE.removeNode(true); } |; } if($in{'subject'}){ $in{'subject'} = qq| var newMeta = window.opener.editSRC.document.createElement(''); if(window.opener.SubjectE == null){ var myHead = window.opener.editSRC.document.getElementsByTagName("HEAD"); myHead[0].appendChild(newMeta); } else{ window.opener.SubjectE.replaceNode(newMeta); } |; } else{ $in{'subject'} = qq| if(window.opener.SubjectE != null){ window.opener.SubjectE.removeNode(true); } |; } if($in{'rating'}){ $in{'rating'} = qq| var newMeta = window.opener.editSRC.document.createElement(''); if(window.opener.RatingE == null){ var myHead = window.opener.editSRC.document.getElementsByTagName("HEAD"); myHead[0].appendChild(newMeta); } else{ window.opener.RatingE.replaceNode(newMeta); }|; } else{ $in{'rating'} = qq| if(window.opener.RatingE != null){ window.opener.RatingE.removeNode(true); } |; } if($in{'description'}){ $in{'description'} = qq| var newMeta = window.opener.editSRC.document.createElement(''); if(window.opener.DescriptionE == null){ var myHead = window.opener.editSRC.document.getElementsByTagName("HEAD"); myHead[0].appendChild(newMeta); } else{ window.opener.DescriptionE.replaceNode(newMeta); } |; } else{ $in{'description'} = qq| if(window.opener.DescriptionE != null){ window.opener.DescriptionE.removeNode(true); } |; } if($in{'keywords'}){ $in{'keywords'} = qq| var newMeta = window.opener.editSRC.document.createElement(''); if(window.opener.KeywordsE == null){ var myHead = window.opener.editSRC.document.getElementsByTagName("HEAD"); myHead[0].appendChild(newMeta); } else{ window.opener.KeywordsE.replaceNode(newMeta); } |; } else{ $in{'keywords'} = qq| if(window.opener.KeywordsE != null){ window.opener.KeywordsE.removeNode(true); } |; } if($in{'revisit'}){ $in{'revisit'} = qq| var newMeta = window.opener.editSRC.document.createElement(''); if(window.opener.RevisitAfterE == null){ var myHead = window.opener.editSRC.document.getElementsByTagName("HEAD"); myHead[0].appendChild(newMeta); } else{ window.opener.RevisitAfterE.replaceNode(newMeta); } |; } else{ $in{'revisit'} = qq| if(window.opener.RevisitAfterE != null){ window.opener.RevisitAfterE.removeNode(true); } |; } if($in{'language'}){ $in{'language'} = qq| var newMeta = window.opener.editSRC.document.createElement(''); if(window.opener.LanguageE == null){ var myHead = window.opener.editSRC.document.getElementsByTagName("HEAD"); myHead[0].appendChild(newMeta); } else{ window.opener.LanguageE.replaceNode(newMeta); } |; } else{ $in{'language'} = qq| if(window.opener.LanguageE != null){ window.opener.LanguageE.removeNode(true); } |; } if($in{'copyright'}){ $in{'copyright'} = qq| var newMeta = window.opener.editSRC.document.createElement(''); if(window.opener.CopyrightE == null){ var myHead = window.opener.editSRC.document.getElementsByTagName("HEAD"); myHead[0].appendChild(newMeta); } else{ window.opener.CopyrightE.replaceNode(newMeta); } |; } else{ $in{'copyright'} = qq| if(window.opener.CopyrightE != null){ window.opener.CopyrightE.removeNode(true); } |; } if($in{'robots'}){ $in{'robots'} = qq| var newMeta = window.opener.editSRC.document.createElement(''); if(window.opener.RobotsE == null){ var myHead = window.opener.editSRC.document.getElementsByTagName("HEAD"); myHead[0].appendChild(newMeta); } else{ window.opener.RobotsE.replaceNode(newMeta); } |; } else{ $in{'robots'} = qq| if(window.opener.RobotsE != null){ window.opener.RobotsE.removeNode(true); } |; } if($in{'cache'}){ $in{'nocache'} = qq| var newMeta = window.opener.editSRC.document.createElement(''); var myHead = window.opener.editSRC.document.getElementsByTagName("HEAD"); myHead[0].appendChild(newMeta); |; } else{ $in{'nocache'} = qq| if(window.opener.NoCacheE != null){ window.opener.NoCacheE.removeNode(true); } |; } if($in{'refresh'}){ $in{'refresh'} = qq| var newMeta = window.opener.editSRC.document.createElement(''); if(window.opener.myRefreshE == null){ var myHead = window.opener.editSRC.document.getElementsByTagName("HEAD"); myHead[0].appendChild(newMeta); } else{ window.opener.myRefreshE.replaceNode(newMeta); } |; } else{ $in{'refresh'} = qq| if(window.opener.myRefreshE != null){ window.opener.myRefreshE.removeNode(true); } |; } print <<"EOF"; EOF exit; } sub SaveCell{ if($in{'file'}){ my $rn = &GetRealName($in{'file'}); $in{'fta'} = 'gif,jpg'; &CheckExt($rn); &SaveFile($in{'file'},"$librarypath/$rn"); $in{'gallery'} = "$libraryurl/$rn"; $in{'ub'} = 'checked'; } ($in{'width'})&&($in{'width_percent'} eq 'percent')&&($in{'width'} .= '%'); ($in{'height'})&&($in{'height_percent'} eq 'percent')&&($in{'height'} .= '%'); ($in{'width'})&&($in{'width'} = "window.opener.myFld.width = \"$in{'width'}\";"); ($in{'height'})&&($in{'height'} = "window.opener.myFld.height = \"$in{'height'}\";"); ($in{'align'} ne 'default')?($in{'align'} = "window.opener.myFld.align = \"$in{'align'}\";"):($in{'align'} = "window.opener.myFld.align = \"\";"); ($in{'bgcolor'})?($in{'bgcolor'} = "window.opener.myFld.bgColor = \"$in{'bgcolor'}\";"):($in{'bgcolor'} = "window.opener.myFld.bgColor = \"\";"); ($in{'bordercolor'})?($in{'bordercolor'} = "window.opener.myFld.borderColor = \"$in{'bordercolor'}\";"):($in{'bordercolor'} = "window.opener.myFld.borderColor = \"\";"); ($in{'bordercolorlight'})?($in{'bordercolorlight'} = "window.opener.myFld.borderColorLight = \"$in{'bordercolorlight'}\";"):($in{'bordercolorlight'} = "window.opener.myFld.borderColorLight = \"\";"); ($in{'bordercolordark'})?($in{'bordercolordark'} = "window.opener.myFld.borderColorDark = \"$in{'bordercolordark'}\";"):($in{'bordercolordark'} = "window.opener.myFld.borderColorDark = \"\";"); ($in{'background'})?($in{'background'} = "window.opener.myFld.background = \"$in{'background'}\";"):($in{'background'} = "window.opener.myFld.background = \"\";"); (($in{'gallery'})&&($in{'ub'}))?($in{'background'} = "window.opener.myFld.background = \"$in{'gallery'}\";"):($in{'background'} = "window.opener.myFld.background = \"\";"); ($in{'wrap'})?($in{'wrap'} = "window.opener.myFld.noWrap = true;"):($in{'wrap'} = "window.opener.myFld.noWrap = false;"); print <<"EOF"; EOF exit; } sub SaveImage{ if($in{'file'}){ my $rn = &GetRealName($in{'file'}); $in{'fta'} = 'gif,jpg'; &CheckExt($rn); &SaveFile($in{'file'},"$librarypath/$rn"); $in{'src'} = "$libraryurl/$rn"; } if($in{'mtype'} eq 'insert'){ if($in{'ud'} eq 'No'){ if($in{'width'}){ ($in{'width'})&&($in{'width'} = "width=\\\"$in{'width'}\\\""); } if($in{'height'}){ ($in{'height'})&&($in{'height'} = "height=\\\"$in{'height'}\\\""); } } else{ if(($in{'src'})&&(!$in{'aheight'})&&(!$in{'awidth'})){ if($in{'src'} !~ /^http:/i){ if($in{'src'} !~ /^\//){ my(@f) = split("/",$in{'location'}); pop(@f); $in{'location'} = join("/",@f); $in{'nsrc'} = "$in{'location'}/$in{'src'}"; } else{ $in{'nsrc'} = "http://$ENV{'HTTP_HOST'}/$in{'src'}"; } } else{ $in{'nsrc'} = $in{'src'}; } my $rpath = $in{'nsrc'}; $rpath =~ s/$in{'siteurl'}//i; $rpath = "$in{'sitepath'}/$rpath"; ($rpath =~ /\.\./)&&(&PError("Error.Invalid filename")); ($rpath =~ /\|/)&&(&PError("Error.Invalid filename")); if( -e "$rpath"){ my ($nw,$nh,$height,$width) = &psize("$rpath",50); $in{'width'} = "width=\\\"$width\\\"" unless($width == 0); $in{'height'} = "height=\\\"$height\\\"" unless($height == 0); } } else{ if($in{'width'}){ ($in{'width'})&&($in{'width'} = "width=\\\"$in{'awidth'}\\\""); } if($in{'height'}){ ($in{'height'})&&($in{'height'} = "height=\\\"$in{'aheight'}\\\""); } } } if($in{'align'} ne 'Default'){ ($in{'align'})&&($in{'align'} = "align=\\\"$in{'align'}\\\""); } else{ $in{'align'} = ''; } ($in{'border'})&&($in{'border'} = "border=\\\"$in{'border'}\\\""); ($in{'hspace'})&&($in{'hspace'} = "hspace=\\\"$in{'vspace'}\\\""); ($in{'vspace'})&&($in{'vspace'} = "vspace=\\\"$in{'vspace'}\\\""); ($in{'alttext'})&&($in{'alttext'} = "alt=\\\"$in{'alttext'}\\\""); my $newfield = ""; print <<"EOF"; EOF } else{ if($in{'ud'} eq 'No'){ ($in{'width'})&&($in{'width'} = "window.opener.myFld.width = \"$in{'width'}\";"); ($in{'height'})&&($in{'height'} = "window.opener.myFld.height = \"$in{'height'}\";"); } else{ ($in{'width'})&&($in{'width'} = "window.opener.myFld.width = \"$in{'awidth'}\";"); ($in{'height'})&&($in{'height'} = "window.opener.myFld.height = \"$in{'aheight'}\";"); } ($in{'align'} ne 'Default')?($in{'align'} = "window.opener.myFld.align = \"$in{'align'}\";"):($in{'align'} = "window.opener.myFld.align = \"\";"); ($in{'alttext'})?($in{'alttext'} = "window.opener.myFld.altText = \"$in{'alttext'}\";"):($in{'alttext'} = "window.opener.myFld.altText = \"\";"); ($in{'border'})?($in{'border'} = "window.opener.myFld.border = \"$in{'border'}\";"):($in{'border'} = "window.opener.myFld.border = \"\";"); ($in{'vspace'})?($in{'vspace'} = "window.opener.myFld.vspace = \"$in{'vspace'}\";"):($in{'vspace'} = "window.opener.myFld.vspace = \"\";"); ($in{'hspace'})?($in{'hspace'} = "window.opener.myFld.hspace = \"$in{'hspace'}\";"):($in{'hspace'} = "window.opener.myFld.hspace = \"\";"); $in{'src'} = "window.opener.myFld.src = \"$in{'src'}\";"; print <<"EOF"; EOF } exit; } sub SaveTable{ if($in{'file'}){ my $rn = &GetRealName($in{'file'}); $in{'fta'} = 'gif,jpg'; &CheckExt($rn); &SaveFile($in{'file'},"$librarypath/$rn"); $in{'gallery'} = "$libraryurl/$rn"; $in{'ub'} = 'checked'; } if($in{'mtype'} eq 'insert'){ if($in{'width'}){ ($in{'width_percent'} eq 'percent')&&($in{'width'} .= '%'); ($in{'width'})&&($in{'width'} = "width=\\\"$in{'width'}\\\""); } if($in{'height'}){ ($in{'height_percent'} eq 'percent')&&($in{'height'} .= '%'); ($in{'height'})&&($in{'height'} = "height=\\\"$in{'height'}\\\""); } if($in{'align'} ne 'default'){ ($in{'align'})&&($in{'align'} = "align=\\\"$in{'align'}\\\""); } else{ $in{'align'} = ''; } ($in{'border'})&&($in{'border'} = "border=\\\"$in{'border'}\\\""); ($in{'cellpadding'})&&($in{'cellpadding'} = "cellpadding=\\\"$in{'cellpadding'}\\\""); ($in{'cellspacing'})&&($in{'cellspacing'} = "cellspacing=\\\"$in{'cellspacing'}\\\""); ($in{'bgcolor'})&&($in{'bgcolor'} = "bgcolor=\\\"$in{'bgcolor'}\\\""); ($in{'bordercolor'})&&($in{'bordercolor'} = "bordercolor=\\\"$in{'bordercolor'}\\\""); ($in{'bordercolorlight'})&&($in{'bordercolorlight'} = "bordercolorlight=\\\"$in{'bordercolorlight'}\\\""); ($in{'bordercolordark'})&&($in{'bordercolordark'} = "bordercolordark=\\\"$in{'bordercolordark'}\\\""); (($in{'gallery'})&&($in{'ub'}))&&($in{'background'} = "background=\\\"$in{'gallery'}\\\""); my($innertable); for my $x (1..$in{'rows'}){ $innertable .= ''; for my $y (1..$in{'cols'}){ $innertable .= ''; } $innertable .= ''; } my $newfield = "$innertable
"; print <<"EOF"; EOF } else{ ($in{'width'})&&($in{'width_percent'} eq 'percent')&&($in{'width'} .= '%'); ($in{'height'})&&($in{'height_percent'} eq 'percent')&&($in{'height'} .= '%'); ($in{'width'})&&($in{'width'} = "window.opener.myFld.width = \"$in{'width'}\";"); ($in{'height'})&&($in{'height'} = "window.opener.myFld.height = \"$in{'height'}\";"); ($in{'align'} ne 'default')?($in{'align'} = "window.opener.myFld.align = \"$in{'align'}\";"):($in{'align'} = "window.opener.myFld.align = \"\";"); $in{'border'} = "window.opener.myFld.border = \"$in{'border'}\";"; ($in{'border'} gt '0')&&($in{'rborder'} = 'window.opener.RB999();'); ($in{'bgcolor'})?($in{'bgcolor'} = "window.opener.myFld.bgColor = \"$in{'bgcolor'}\";"):($in{'bgcolor'} = "window.opener.myFld.bgColor = \"\";"); ($in{'bordercolor'})?($in{'bordercolor'} = "window.opener.myFld.borderColor = \"$in{'bordercolor'}\";"):($in{'bordercolor'} = "window.opener.myFld.borderColor = \"\";"); ($in{'bordercolorlight'})?($in{'bordercolorlight'} = "window.opener.myFld.borderColorLight = \"$in{'bordercolorlight'}\";"):($in{'bordercolorlight'} = "window.opener.myFld.borderColorLight = \"\";"); ($in{'bordercolordark'})?($in{'bordercolordark'} = "window.opener.myFld.borderColorDark = \"$in{'bordercolordark'}\";"):($in{'bordercolordark'} = "window.opener.myFld.borderColorDark = \"\";"); ($in{'background'})?($in{'background'} = "window.opener.myFld.background = \"$in{'background'}\";"):($in{'background'} = "window.opener.myFld.background = \"\";"); ($in{'cellpadding'})?($in{'cellpadding'} = "window.opener.myFld.cellPadding = \"$in{'cellpadding'}\";"):($in{'cellpadding'} = "window.opener.myFld.cellPadding = \"\";"); ($in{'cellspacing'})?($in{'cellspacing'} = "window.opener.myFld.cellSpacing = \"$in{'cellspacing'}\";"):($in{'cellspacing'} = "window.opener.myFld.cellSpacing = \"\";"); (($in{'gallery'})&&($in{'ub'}))?($in{'background'} = "window.opener.myFld.background = \"$in{'gallery'}\";"):($in{'background'} = "window.opener.myFld.background = \"\";"); print <<"EOF"; EOF } exit; } sub SaveHR{ if($in{'mtype'} eq 'insert'){ ($in{'size'})&&($in{'size'} = "size=\\\"$in{'size'}\\\""); ($in{'width_percent'} eq 'percent')&&($in{'width'} .= '%'); ($in{'width'})&&($in{'width'} = "width=\\\"$in{'width'}\\\""); ($in{'noshade'})&&($in{'noshade'} = "noshade"); ($in{'color'})&&($in{'color'} = "color=\\\"$in{'color'}\\\""); ($in{'align'})&&($in{'align'} = "align=\\\"$in{'align'}\\\""); my $newfield = "
"; print <<"EOF"; EOF } else{ ($in{'noshade'})?($in{'noshade'} = 'true'):($in{'noshade'} = 'false'); ($in{'width'})&&($in{'width_percent'} eq 'percent')&&($in{'width'} .= '%'); ($in{'size'})&&($in{'size'} = "window.opener.myFld.size = \"$in{'size'}\";"); ($in{'width'})&&($in{'width'} = "window.opener.myFld.width = \"$in{'width'}\";"); ($in{'noshade'})&&($in{'noshade'} = "window.opener.myFld.noShade = $in{'noshade'};"); ($in{'color'})&&($in{'color'} = "window.opener.myFld.color = \"$in{'color'}\";"); ($in{'align'})&&($in{'align'} = "window.opener.myFld.align = \"$in{'align'}\";"); print <<"EOF"; EOF } exit; } sub SaveRadio{ if($in{'mtype'} eq 'insert'){ (!$in{'name'})&&($in{'name'} = 'radio'); (!$in{'value'})&&($in{'value'} = 'ON'); $in{'value'} =~ s/\\/\\\\/g; my $newfield = ""; print <<"EOF"; EOF } else{ ($in{'checked'})?($in{'ischecked'} = 'true'):($in{'ischecked'} = 'false'); print <<"EOF"; EOF } exit; } sub SaveCheckBox{ if($in{'mtype'} eq 'insert'){ (!$in{'name'})&&($in{'name'} = 'checkbox'); (!$in{'value'})&&($in{'value'} = 'ON'); $in{'value'} =~ s/\\/\\\\/g; my $newfield = ""; print <<"EOF"; EOF } else{ ($in{'checked'})?($in{'ischecked'} = 'true'):($in{'ischecked'} = 'false'); print <<"EOF"; EOF } exit; } sub SaveButton{ if($in{'mtype'} eq 'insert'){ (!$in{'name'})&&($in{'name'} = 'button'); (!$in{'type'})&&($in{'type'} = 'submit'); $in{'value'} =~ s/\\/\\\\/g; my $newfield = ""; print <<"EOF"; EOF } else{ print <<"EOF"; EOF } exit; } sub SaveHidden{ if($in{'mtype'} eq 'insert'){ (!$in{'name'})&&($in{'name'} = 'hidden'); $in{'value'} =~ s/\\/\\\\/g; my $newfield = ""; print <<"EOF"; EOF } else{ print <<"EOF"; EOF } exit; } sub SaveTextArea{ (!$in{'rows'})&&($in{'rows'} = '3'); (!$in{'cols'})&&($in{'cols'} = '20'); if($in{'mtype'} eq 'insert'){ (!$in{'name'})&&($in{'name'} = 'textarea'); my $newfield = ""; print <<"EOF"; EOF } else{ print <<"EOF"; EOF } exit; } sub SaveText{ if($in{'mtype'} eq 'insert'){ (!$in{'size'})&&($in{'size'} = '20'); (!$in{'name'})&&($in{'name'} = 'textfield'); my $newfield = ""; print <<"EOF"; EOF } else{ print <<"EOF"; EOF } exit; } sub SaveForm{ if($in{'formtype'} eq 'new'){ my ($enc); ($in{'enctype'} =~ /multipart\/form-data/i)?($enc='enctype="multipart/form-data"'):($enc=''); my $newform = "

"; print <<"EOF"; EOF } else{ my ($enc); ($in{'enctype'} =~ /multipart\/form-data/i)?($enc='mform.enctype="multipart/form-data";'):($enc=''); print <<"EOF"; EOF } exit; } sub ShowForm{ if($in{'enctype'} =~ /multipart\/form-data/i){ $in{'MPSEL'} = 'selected'; } ($in{'method'} =~ /GET/i)?($in{'GSel'} = 'selected'):($in{'PSel'} = 'selected'); &PageOut("$cgipath/t_form.htm"); exit; } sub ShowText{ ($in{'type'} =~ /PASSWORD/i)&&($in{'PSel'} = 'selected'); ($in{'type'} =~ /TEXT/i)&&($in{'TSel'} = 'selected'); ($in{'type'} =~ /FILE/i)&&($in{'FSel'} = 'selected'); &PageOut("$cgipath/t_text.htm"); exit; } sub ShowCheckBox{ ($in{'checked'} =~ /true/i)?($in{'checked'}='checked'):($in{'checked'}=''); &PageOut("$cgipath/t_checkbox.htm"); exit; } sub ShowSpecial{ &PageOut("$cgipath/t_special_characters.htm"); exit; } sub RemoveEditable{ my($page,@l); $page = "$in{'d'}/$in{'nd'}"; $page =~ s/\/\//\//g; (!$in{'name'})&&(&PError("Error. Please enter a name.")); open(DB,"+<$cgipath/data/security.cgi")||print "$!:security.cgi
"; ($flock)&&(flock(DB,2)); while(){ chomp; my @fields = split("\t",$_); (($fields[0] ne $page)||($fields[2] ne $in{'name'}))&&(push(@l,$_)); } seek(DB,0,0); foreach my $i (@l){ print DB "$i\n"; } truncate(DB, tell(DB)); close DB; ($flock)&&(flock(DB,8)); print <<"EOF"; EOF } sub SaveEditable{ (!$in{'name'})&&(&PError("Error. Please enter a name.")); ($in{'name'} =~ /[^\w]/)&&(&PError("Error. Only alpha-numeric characters are allowed for name.")); if($in{'mtype'} eq 'insert'){ ##already exist? my($page,$exists); $page = "$in{'d'}/$in{'nd'}"; $page =~ s/\/\//\//g; open(DB,"<$cgipath/data/security.cgi")||print "$!:security.cgi
"; while(){ chomp; my @fields = split("\t",$_); ($fields[0] eq $page)&&($fields[2] eq $in{'name'})&&($exists=1); } close DB; ($exists)&&(&PError("Error. Editable name exists on page.")); &SaveUsers; print <<"EOF"; EOF } else{ &SaveUsers; print <<"EOF"; EOF } exit; } sub ShowEditable{ &GetUsers2; ##get users open(DB,"<$cgipath/data/users.cgi"); while(){ chomp; my @fields = split("\t",$_); ($fields[2] ne 'User')&&(next); $in{'user1'} .= qq|| unless ($yu{$fields[0]}); } close DB; &PageOut("$cgipath/t_editable.htm"); exit; } sub TSaveUsers{ &SaveUsers; print <<"EOF"; EOF exit; } sub TShowUsers{ &GetUsers; ##get users open(DB,"<$cgipath/data/users.cgi"); while(){ chomp; my @fields = split("\t",$_); ($fields[2] ne 'User')&&(next); $in{'user1'} .= qq|| unless ($yu{$fields[0]}); } close DB; &PageOut("$cgipath/t_users.htm"); exit; } sub ShowPage{ &GetUsers; foreach my $i (keys %in){ ($in{$i} eq 'undefined')&&($in{$i}=''); ($in{$i} eq 'null')&&($in{$i}=''); } ($in{'robots'})&&($in{'robsel'} = ""); $in{'r'.$in{'refresh'}} = 'selected'; $in{'bgcolor'} =~ tr/a-z/A-Z/; $in{'textcolor'} =~ tr/a-z/A-Z/; $in{'hyperlinkcolor'} =~ tr/a-z/A-Z/; $in{'vhyperlinkcolor'} =~ tr/a-z/A-Z/; $in{'ahyperlinkcolor'} =~ tr/a-z/A-Z/; $in{'scrollbararrowcolor'} =~ tr/a-z/A-Z/; $in{'scrollbartrackcolor'} =~ tr/a-z/A-Z/; $in{'scrollbarshadowcolor'} =~ tr/a-z/A-Z/; $in{'scrollbarfacecolor'} =~ tr/a-z/A-Z/; $in{'scrollbarhighlightcolor'} =~ tr/a-z/A-Z/; $in{'scrollbardarkshadowcolor'} =~ tr/a-z/A-Z/; $in{'scrollbar3dlightcolor'} =~ tr/a-z/A-Z/; ($in{'bgcolor'})&&($in{'bgcolorsel'} = ""); ($in{'textcolor'})&&($in{'textcolorsel'} = ""); ($in{'hyperlinkcolor'})&&($in{'hyperlinkcolorsel'} = ""); ($in{'vhyperlinkcolor'})&&($in{'vhyperlinkcolorsel'} = ""); ($in{'ahyperlinkcolor'})&&($in{'ahyperlinkcolorsel'} = ""); ($in{'bgproperties'} =~ /fixed/i)?($in{'YSel'} = "checked"):($in{'NSel'} = "checked"); ($in{'nocache'} eq "NO-CACHE")&&($in{'CSel'} = "checked"); ($in{'background'})&&($in{'cimage'} = ""); $in{'revisit'} =~ s/days//i; ($in{'background'})&&($in{'USel'} = 'checked'); ($in{'scrollbararrowcolor'})&&($in{'scrollbararrowcolorsel'} = ""); ($in{'scrollbartrackcolor'})&&($in{'scrollbartrackcolorsel'} = ""); ($in{'scrollbarshadowcolor'})&&($in{'scrollbarshadowcolorsel'} = ""); ($in{'scrollbarfacecolor'})&&($in{'scrollbarfacecolorsel'} = ""); ($in{'scrollbarhighlightcolor'})&&($in{'scrollbarhighlightcolorsel'} = ""); ($in{'scrollbardarkshadowcolor'})&&($in{'scrollbardarkshadowcolorsel'} = ""); ($in{'scrollbar3dlightcolor'})&&($in{'scrollbar3dlightcolorsel'} = ""); ##get users open(DB,"<$cgipath/data/users.cgi"); while(){ chomp; my @fields = split("\t",$_); ($fields[2] ne 'User')&&(next); $in{'user1'} .= qq|| unless ($yu{$fields[0]}); } close DB; (!$in{'bgcolorsel'})&&($in{'bgcolorsel'} = qq||); (!$in{'textcolorsel'})&&($in{'textcolorsel'} = qq||); (!$in{'vhyperlinkcolorsel'})&&($in{'vhyperlinkcolorsel'} = qq||); (!$in{'hyperlinkcolorsel'})&&($in{'hyperlinkcolorsel'} = qq||); (!$in{'ahyperlinkcolorsel'})&&($in{'ahyperlinkcolorsel'} = qq||); (!$in{'scrollbararrowcolorsel'})&&($in{'scrollbararrowcolorsel'} = qq||); (!$in{'scrollbartrackcolorsel'})&&($in{'scrollbartrackcolorsel'} = qq||); (!$in{'scrollbarshadowcolorsel'})&&($in{'scrollbarshadowcolorsel'} = qq||); (!$in{'scrollbarfacecolorsel'})&&($in{'scrollbarfacecolorsel'} = qq||); (!$in{'scrollbarhighlightcolorsel'})&&($in{'scrollbarhighlightcolorsel'} = qq||); (!$in{'scrollbardarkshadowcolorsel'})&&($in{'scrollbardarkshadowcolorsel'} = qq||); (!$in{'scrollbar3dlightcolorsel'})&&($in{'scrollbar3dlightcolorsel'} = qq||); &PageOut("$cgipath/t_page_properties.htm"); exit; } sub ShowImage{ foreach my $i (keys %in){ ($in{$i} eq 'undefined')&&($in{$i}=''); } if($in{'src'}){ if($in{'src'} !~ /^http:/i){ if($in{'src'} !~ /^\//){ my(@f) = split("/",$in{'location'}); pop(@f); $in{'location'} = join("/",@f); $in{'nsrc'} = "$in{'location'}/$in{'src'}"; } else{ $in{'nsrc'} = "http://$ENV{'HTTP_HOST'}/$in{'src'}"; } } else{ $in{'nsrc'} = $in{'src'}; } my ($nw,$nh,$height,$width,@s,$rn); my $rpath = $in{'nsrc'}; $rpath =~ s/$in{'siteurl'}//i; $rpath = "$in{'sitepath'}/$rpath"; ($rpath =~ /\.\./)&&(&PError("Error.Invalid filename")); ($rpath =~ /\|/)&&(&PError("Error.Invalid filename")); if( -e "$rpath"){ ($nw,$nh,$height,$width) = &psize("$rpath",50); (@s) = stat("$rpath"); } (($height != $in{'height'})||($width != $in{'width'}))?($in{'No'} = 'checked'):($in{'Yes'} = 'checked'); $in{'aheight'} = $height; $in{'awidth'} = $width; (!$nh)&&($nh = 50); $rn = &GetRealName($rpath); $in{'cimage'} = qq||; my($dimensions,$filesize); ((!$height)||(!$width))?(($filesize='unknown')&&($dimensions = 'unknown')):(($filesize = "$s[7] bytes")&&($dimensions = "$height h x $width w")); $in{'idetails'} = qq|
View Full Size Image
File Name: $rn
Dimensions: $dimensions
File Size: $filesize
|; } ($in{'align'})&&($in{'aselect'} = ""); (!$in{'No'})&&(!$in{'Yes'})&&($in{'Yes'} = 'checked'); (!$in{'aheight'})&&($in{'aheight'} = '0'); (!$in{'awidth'})&&($in{'awidth'} = '0'); ($in{'aheight'})&&(!$in{'height'})&&($in{'height'}=$in{'aheight'}); ($in{'awidth'})&&(!$in{'width'})&&($in{'width'}=$in{'awidth'}); (!$in{'border'})&&($in{'border'} = '0'); ($in{'mtype'} eq 'insert')&&($in{'type'} = 'insert'); &PageOut("$cgipath/t_insert_image.htm"); exit; } sub ShowTable{ $in{'bordercolorlight'} =~ tr/a-z/A-Z/; $in{'bordercolor'} =~ tr/a-z/A-Z/; $in{'bordercolordark'} =~ tr/a-z/A-Z/; $in{'bgcolor'} =~ tr/a-z/A-Z/; foreach my $i (keys %in){ ($in{$i} eq 'undefined')&&($in{$i}=''); } (!$in{'rows'})?($in{'rows'} = '2'):($in{'disr'} = 'readonly'); (!$in{'cols'})?($in{'cols'} = '2'):($in{'disc'} = 'readonly'); if($in{'width'}){ ($in{'width'} =~ /\%/)?($in{'PeSel'} = 'checked'):($in{'PiSel'} = 'checked'); $in{'width'} =~ s/\%//g; } else{ $in{'PeSel'} = 'checked'; } if($in{'height'}){ ($in{'height'} =~ /\%/)?($in{'HPeSel'} = 'checked'):($in{'HPiSel'} = 'checked'); $in{'height'} =~ s/\%//g; } else{ $in{'HPeSel'} = 'checked'; } (!$in{'align'})&&($in{'AD'} = 'checked'); ($in{'align'} =~ /left/i)&&($in{'AL'} = 'checked'); ($in{'align'} =~ /center/i)&&($in{'AC'} = 'checked'); ($in{'align'} =~ /right/i)&&($in{'AR'} = 'checked'); if($in{'background'}){ $in{'ub'} = 'checked'; $in{'cimage'} = $in{'background'}; } if($in{'bgcolor'}){ $in{'bgcolorsel'} = ""; } if($in{'bordercolor'}){ $in{'bordercolorsel'} = ""; } if($in{'bordercolorlight'}){ $in{'bordercolorlightsel'} = ""; } if($in{'bordercolordark'}){ $in{'bordercolordarksel'} = ""; } if($in{'type'} ne 'insert'){ $in{'norows'} = ''; } ($in{'background'})&&($in{'cimage'} = qq||); (!$in{'bordercolorlightsel'})&&($in{'bordercolorlightsel'} = qq||); (!$in{'bordercolorsel'})&&($in{'bordercolorsel'} = qq||); (!$in{'bordercolordarksel'})&&($in{'bordercolordarksel'} = qq||); (!$in{'bgcolorsel'})&&($in{'bgcolorsel'} = qq||); &PageOut("$cgipath/t_insert_table.htm"); exit; } sub ShowCell{ $in{'bordercolor'} =~ tr/a-z/A-Z/; $in{'bordercolorlight'} =~ tr/a-z/A-Z/; $in{'bordercolordark'} =~ tr/a-z/A-Z/; $in{'bgcolor'} =~ tr/a-z/A-Z/; foreach my $i (keys %in){ ($in{$i} eq 'undefined')&&($in{$i}=''); } if($in{'width'}){ ($in{'width'} =~ /\%/)?($in{'PeSel'} = 'checked'):($in{'PiSel'} = 'checked'); $in{'width'} =~ s/\%//g; } else{ $in{'PeSel'} = 'checked'; } if($in{'height'}){ ($in{'height'} =~ /\%/)?($in{'HPeSel'} = 'checked'):($in{'HPiSel'} = 'checked'); $in{'height'} =~ s/\%//g; } else{ $in{'HPeSel'} = 'checked'; } (!$in{'align'})&&($in{'AD'} = 'checked'); ($in{'align'} =~ /left/i)&&($in{'AL'} = 'checked'); ($in{'align'} =~ /center/i)&&($in{'AC'} = 'checked'); ($in{'align'} =~ /right/i)&&($in{'AR'} = 'checked'); ($in{'nowrap'} =~ /true/i)&&($in{'WSel'} = 'checked'); if($in{'background'}){ $in{'ub'} = 'checked'; $in{'cimage'} = $in{'background'}; } if($in{'bgcolor'}){ $in{'bgcolorsel'} = ""; } if($in{'bordercolor'}){ $in{'bordercolorsel'} = ""; } if($in{'bordercolorlight'}){ $in{'bordercolorlightsel'} = ""; } if($in{'bordercolordark'}){ $in{'bordercolordarksel'} = ""; } ($in{'background'})&&($in{'cimage'} = qq||); (!$in{'bordercolorsel'})&&($in{'bordercolorsel'} = qq||); (!$in{'bordercolorlightsel'})&&($in{'bordercolorlightsel'} = qq||); (!$in{'bordercolordarksel'})&&($in{'bordercolordarksel'} = qq||); (!$in{'bgcolorsel'})&&($in{'bgcolorsel'} = qq||); &PageOut("$cgipath/t_cell.htm"); exit; } sub ShowHR{ if($in{'width'}){ ($in{'width'} =~ /\%/)?($in{'PeSel'} = 'checked'):($in{'PiSel'} = 'checked'); $in{'width'} =~ s/\%//g; } else{ $in{'PeSel'} = 'checked'; } (!$in{'align'})&&($in{'ACSel'} = 'checked'); ($in{'align'} =~ /left/i)&&($in{'ALSel'} = 'checked'); ($in{'align'} =~ /center/i)&&($in{'ACSel'} = 'checked'); ($in{'align'} =~ /right/i)&&($in{'ARSel'} = 'checked'); ($in{'color'})&&($in{'csel'} = qq||); ($in{'noshade'} eq 'true')&&($in{'NSSel'} = 'checked'); (!$in{'csel'})&&($in{'csel'} = qq||); &PageOut("$cgipath/t_HR.htm"); exit; } sub ShowDropdown{ my (@mt) = split(/\\0/,$in{'mt'}); my (@mv) = split(/\\0/,$in{'mv'}); (!$in{'size'})&&($in{'size'} = '1'); ($in{'multiple'} eq 'true')?($in{'YSel'} = 'checked'):($in{'NSel'} = 'checked'); for my $i (0..$#mt){ my ($s,$v); if($mv[$i]){ $v = "$mv[$i]\|"; } if($in{'si'} == $i){ $s = '*'; } $in{'options'} .= "$s$v$mt[$i]\n"; $s='';$v=''; } &PageOut("$cgipath/t_dropdown.htm"); exit; } sub ShowRadio{ ($in{'checked'} =~ /true/i)?($in{'checked'}='checked'):($in{'checked'}=''); &PageOut("$cgipath/t_radio.htm"); exit; } sub ShowButton{ (!$in{'type'})&&($in{'type'} = 'submit'); ($in{'type'} =~ /submit/i)&&($in{'SSel'} = 'checked'); ($in{'type'} =~ /reset/i)&&($in{'RSel'} = 'checked'); ($in{'type'} =~ /button/i)&&($in{'BSel'} = 'checked'); &PageOut("$cgipath/t_button.htm"); exit; } sub ShowTextArea{ &PageOut("$cgipath/t_textarea.htm"); exit; } sub ShowHidden{ &PageOut("$cgipath/t_hidden.htm"); exit; } sub SaveChanges{ my $tmpc = $in{'command'}; &CF; if($in{'command'} =~ /^t/){ $rootpath = $templatepath; $in{'command'} = 'tmanage'; $in{'ccommand'} = 'tshowedit'; } else{ $in{'command'} = 'manage'; $in{'ccommand'} = 'showedit'; } ###module functions require("$basepath/modsc.cgi"); my($mf) = &ModSC; my(@mods); foreach my $i (keys %in){ $in{$i} =~ s/\&/\&/g; eval($mf); } foreach my $i (@mods){ if($in{$i}){ $in{'contentSave'} =~ s/(\s*<\/IFRAME>)/$in{$i}/i; } } ### end module functions ($fsize)&&(length($in{'contentSave'})>$fsize)&&(&PError("Error. Maximum filesize exceeded")); if($in{'editType'} eq 'text'){ $in{'contentSave'} =~ s/\r*\n/\n/g; } else{ &TagSSISave("$rootpath/$in{'d'}/$in{'nd'}"); } open(PAGE,">$rootpath/$in{'d'}/$in{'nd'}")||(&PError("$!")); print PAGE $in{'contentSave'}; close PAGE; $in{'contentSave'}=''; if($in{'pet'}){ my($url) = "$in{'d'}/$in{'nd'}"; $url =~ s/\/\//\//g; $url =~ s/^\///g; print <<"EOF"; EOF } else{ if($tmpc =~ /e$/){ $in{'command'} = $in{'ccommand'}; &ShowEdit; } else{ &Manage; } } } sub TagSSI{ my($f) = @_; my ($buff,$buffer,$x); open(F,"+<$f"); while(){ $buff .= $_; } $buff =~ s/\<\!\-\- ssi \-\-\>\s*\(.*?)<\/SPAN>\s*\<\!\-\- essi \-\-\>/$1/gsi; #tag dreamweaver if(($dwsupport)&&($in{'atype'} ne 'admin')){ #remove $buff =~ s/\s*//gi; $buff =~ s/<\/span>\s*//gi; $buff =~ s/\s*//gi; $buff =~ s/<\/span>\s*//gi; #add $buff =~ s/(.*?)/$1<\/span>/gsi; if($buff =~ //){ $in{'hasDW'} = "YES"; $in{'vhtml'} = "hiddenForm" unless (($in{'atype'} eq 'admin')||($in{'command'} eq 'tsavechanges')); } $buff =~ s/(.*?)/$2<\/span>/gsi; if($buff =~ /\s*//gi; $in{'contentSave'} =~ s/<\/span>\s*//gi; $in{'contentSave'} =~ s/\s*//gi; $in{'contentSave'} =~ s/<\/span>\s*//gi; } } sub ShowEditRAW{ &CF; &GetPath; $in{'path'} .= "/$in{'nd'}"; if($in{'command'} eq 'tshowedit'){ $rooturl = $templateurl; $rootpath = $templatepath; $in{'command'} = 'tsavechanges'; $in{'ccommand'} = 'tmanage'; } else{ $in{'command'} = 'savechanges'; $in{'ccommand'} = 'manage'; } if($in{'atype'} eq 'user'){ &CheckForAccess($in{'nd'}); } open(F,"<$rootpath/$in{'d'}/$in{'nd'}"); my ($body); while(){ $body =~ s/\n*//i; $body .= $_; } close F; $in{'basehref'} ="$rooturl/$in{'d'}"; $in{'basehref'} =~ s/([^\:])\/+/$1\//g; ($in{'basehref'} !~ /\/$/)&&($in{'basehref'} .= '/'); print "\n$body"; exit; } sub ShowEditTXT{ open(F,"<$rootpath/$in{'d'}/$in{'nd'}"); while(){ $in{'contentSave'} .= $_; } close F; } sub ShowEdit{ srand; my $rnd = int(rand(1000)); &CF; &GetPath; $in{'path'} .= "/$in{'nd'}"; if($in{'command'} eq 'tshowedit'){ $rooturl = $templateurl; $rootpath = $templatepath; $in{'command'} = 'tsavechanges'; $in{'ccommand'} = 'tmanage'; } else{ $in{'command'} = 'savechanges'; $in{'ccommand'} = 'manage'; } if(! -e "$rootpath/$in{'d'}/$in{'nd'}"){ &PError("Error. File doesn't exist"); exit; } if(! -f "$rootpath/$in{'d'}/$in{'nd'}"){ &PError("Error. You can only edit files."); exit; } if(&EditRaw){ $in{'editsrc'} = "command=showeditraw&d=$in{'d'}&nd=$in{'nd'}&rnd=$rnd"; $in{'editsrc'} =~ s/([^\w&=])/'%'.sprintf("%.2x",ord($1))/ge; $in{'editsrc'} = "$in{'cgiurl'}?$in{'editsrc'}"; $in{'isRAW'} = 1; } else{ &TagSSI("$rootpath/$in{'d'}/$in{'nd'}"); my($tu) = "$in{'d'}/$in{'nd'}?rnd=$rnd"; $tu =~ s/\/\//\//g; $in{'editsrc'} = $rooturl . $tu; } &GetStyles; if($in{'atype'} eq 'admin'){ $in{'adminf'} = qq| |; } if($in{'ueditor'} eq 'e'){ $in{'easyMode'} = 'true'; $in{'editTRow'} = 'hiddenForm'; $in{'editMRow'} = 'hiddenForm'; } else{ $in{'easyMode'} = 'false'; $in{'easyRow'} = 'hiddenForm'; } if($in{'atype'} eq 'user'){ &CheckForAccess($in{'nd'}); } if($in{'atype'} eq 'admin'){ &GetEditables; } ($in{'atype'} ne 'user')&&($in{'et'} = 'hp'); if($in{'et'} ne 'hp'){ $in{'vhtml'} = 'hiddenForm'; } #start module menu insert if($in{'et'} eq 'hp'){ opendir(DIR,"$cgipath/mod"); my(@m) = readdir(DIR); closedir DIR; foreach my $i (@m){ if(-e "$cgipath/mod/$i/mod.cgi"){ require("$cgipath/mod/$i/mod.cgi"); } } } #end module menu insert if(&TextEdit){ &ShowEditTXT; &PageOut("$cgipath/t_edit_txt.htm"); } else{ &PageOut("$cgipath/t_edit.htm"); } exit; } sub EditRaw{ (!$in{'rextensions'})&&(return 0); my ($good) = 0; my ($oext) = $in{'nd'} =~ /\.(.*)$/; $oext =~ tr/A-Z/a-z/; foreach my $i (@rext){ ($i eq $oext)&&($good=1); } return $good; } sub TextEdit{ (!$in{'txt'})&&(return 0); my ($good) = 0; my ($oext) = $in{'nd'} =~ /\.(.*)$/; $oext =~ tr/A-Z/a-z/; foreach my $i (@txtext){ ($i eq $oext)&&($good=1); } return $good; } sub GetStyles{ opendir(DIR,"$csspath"); my (@files) = readdir(DIR); close DIR; $cssurl =~ s/\/$//; foreach my $i (sort @files){ next if ($i !~ /\.css$/i); my $q = $i; $q =~ s/\.css$//; $in{'styles'} .= qq||; } $in{'styles'} = "\n$in{'styles'}"; } sub CreateFile{ &CF; if($in{'command'} eq 'tcreatefile'){ $rootpath = $templatepath; $in{'command'} = 'tmanage'; } else{ $in{'command'} = 'manage'; } if(!$in{'template'}){ ($in{'nf'} !~ /\./)&&(&PError("Please enter a file extension")); (-e "$rootpath/$in{'d'}/$in{'nf'}")&&(&PError("Error. File already exists")); open(FILE,">$rootpath/$in{'d'}/$in{'nf'}")||&PError("$!"); print FILE <<"EOF"; Maintained by csPublisher :: WWW.CGISCRIPT.NET, LLC EOF close FILE; } else{ if($in{'nf'} !~ /\./){ my $rn = &GetRealName($in{'template'}); my ($ext) = $rn =~ /\.(.*)$/; $in{'nf'} .= '.'.$ext; } use File::Copy; (-e "$rootpath/$in{'d'}/$in{'nf'}")&&(&PError("Error. File already exists")); copy("$templatepath/$in{'template'}","$rootpath/$in{'d'}/$in{'nf'}")||&PError("$!"); } if($in{'atype'} eq 'user'){ $in{'nd'} = $in{'nf'}; $in{'uwa'} = $in{'UserName'}; &SaveUsers; $in{'nd'} = ''; } chmod "$rootpath/$in{'d'}/$in{'nf'}", $fperm unless ($windows); &Manage; } sub CreateDir{ if($in{'command'} eq 'tcreatedir'){ $rootpath = $templatepath; $in{'command'} = 'tmanage'; } elsif($in{'command'} eq 'icreatedir'){ $rootpath = $librarypath; $in{'command'} = 'imanage'; } else{ $in{'command'} = 'manage'; } &CF; (-e "$rootpath/$in{'d'}/$in{'nf'}")&&(&PError("Error. File or directory already exists.")); mkdir "$rootpath/$in{'d'}/$in{'nf'}", $dperm; &Manage; } sub SDeleteF{ ($in{'atype'} ne 'admin')&&(&PError("Error. Access denied")); $rootpath = $csspath; ($in{'nd'} !~ /\.css$/i)&&(&PError("Error. Invalid filename")); unlink("$rootpath/$in{'nd'}")||&PError("$!"); &SManage; } sub DeleteF{ if($in{'command'} eq 'tdeletef'){ $rootpath = $templatepath; $in{'command'} = 'tmanage'; } elsif($in{'command'} eq 'ideletef'){ $rootpath = $librarypath; $in{'command'} = 'imanage'; } else{ $in{'command'} = 'manage'; } &CF; unlink("$rootpath/$in{'d'}/$in{'nd'}")||&PError("$!"); &RemoveUsers($in{'nd'}); &Manage; } sub DeleteD{ if($in{'command'} eq 'tdeleted'){ $rootpath = $templatepath; $in{'command'} = 'tmanage'; } elsif($in{'command'} eq 'ideleted'){ $rootpath = $librarypath; $in{'command'} = 'imanage'; } &CF; rmdir("$rootpath/$in{'d'}/$in{'nd'}")||&PError("$!"); &Manage; } sub SUpload{ ($in{'atype'} ne 'admin')&&(&PError("Error. Access denied")); my ($fname); $rootpath = $csspath; $fname = &GetRealName($in{'file'}); ($fname !~ /\.css/i)&&(&PError("Error. Only css extensions allowed in styles section")); &SaveFile($in{'file'},"$rootpath/$fname"); chmod "$rootpath/$fname",$fperm unless ($windows); &SManage; } sub Upload{ my ($fname); $fname = $in{'filename'}; if(!$fname){ $fname = &GetRealName($in{'file'}); &CF($fname); } else{ &CF($fname); &CF($in{'file'}); } if($in{'command'} eq 'tupload'){ $rootpath = $templatepath; $in{'command'} = 'tmanage'; } elsif($in{'command'} eq 'iupload'){ $rootpath = $librarypath; $in{'command'} = 'imanage'; } else{ $in{'command'} = 'manage'; } if($in{'atype'} eq 'user'){ $in{'nd'} = $fname; $in{'uwa'} = $in{'UserName'}; &SaveUsers; $in{'nd'} = ''; } &SaveFile($in{'file'},"$rootpath/$in{'d'}/$fname"); chmod "$rootpath/$in{'d'}/$fname", $fperm unless ($windows); &Manage; } sub Rename{ if($in{'command'} eq 'trename'){ $rootpath = $templatepath; } if($in{'command'} eq 'irename'){ $rootpath = $librarypath; } if(! -d "$rootpath/$in{'d'}/$in{'nd'}"){ &CF; } else{ ($in{'nf'} =~ /\.\./)&&(&PError("Error. Invalid directory path")); ($in{'nf'} =~ /\|/)&&(&PError("Error. Invalid directory path")); ($in{'nf'} =~ /\//)&&(&PError("Error. Invalid directory path")); } if($in{'command'} eq 'trename'){ $in{'command'} = 'tmanage'; } if($in{'command'} eq 'irename'){ $in{'command'} = 'imanage'; } if($in{'command'} eq 'rename'){ $in{'command'} = 'manage'; } if(($in{'nf'} !~ /\./)&&(! -d "$rootpath/$in{'d'}/$in{'nd'}")){ my $rn = &GetRealName($in{'nd'}); my ($ext) = $rn =~ /\.(.*)$/; $in{'nf'} .= '.'.$ext; } (-e "$rootpath/$in{'d'}/$in{'nf'}")&&(&PError("Error. File already exists")); rename("$rootpath/$in{'d'}/$in{'nd'}","$rootpath/$in{'d'}/$in{'nf'}")||&PError("$!"); chmod "$rootpath/$in{'d'}/$in{'nf'}",$fperm unless ($windows); &RemoveUsers($in{'nd'}); if($in{'atype'} eq 'user'){ $in{'nd'} = $in{'nf'}; $in{'uwa'} = $in{'UserName'}; &SaveUsers; } &Manage; } sub Copy{ &CF; if($in{'command'} eq 'tcopy'){ $rootpath = $templatepath; $in{'command'} = 'tmanage'; } elsif($in{'command'} eq 'icopy'){ $rootpath = $librarypath; $in{'command'} = 'imanage'; } else{ $in{'command'} = 'manage'; } use File::Copy; if($in{'nf'} !~ /\./){ my $rn = &GetRealName($in{'nd'}); my ($ext) = $rn =~ /\.(.*)$/; $in{'nf'} .= '.'.$ext; } (-e "$rootpath/$in{'d'}/$in{'nf'}")&&(&PError("Error. File already exists")); copy("$rootpath/$in{'d'}/$in{'nd'}","$rootpath/$in{'d'}/$in{'nf'}")||&PError("$!"); chmod "$rootpath/$in{'d'}/$in{'nf'}",$fperm unless ($windows); if($in{'atype'} eq 'user'){ $in{'nd'} = $in{'nf'}; $in{'uwa'} = $in{'UserName'}; &SaveUsers; } &Manage; } sub CreateNewD{ &CF; &GetPath; if($in{'command'} eq 'tcreatenewd'){ $in{'command'} = 'tcreatedir'; $in{'ccommand'} = 'tmanage'; } elsif($in{'command'} eq 'icreatenewd'){ $in{'command'} = 'icreatedir'; $in{'ccommand'} = 'imanage'; } else{ $in{'command'} = 'createdir'; $in{'ccommand'} = 'manage'; } &PageOut("$cgipath/t_create_dir.htm"); exit; } sub CreateNewF{ &CF; &GetPath; &GetTemplates; if($in{'command'} eq 'tcreatenewf'){ $in{'command'} = 'tcreatefile'; $in{'ccommand'} = 'tmanage'; } else{ $in{'command'} = 'createfile'; $in{'ccommand'} = 'manage'; } &PageOut("$cgipath/t_create.htm"); exit; } sub ShowRename{ &CF; &GetPath; if($in{'command'} eq 'tshowrename'){ $in{'command'} = 'trename'; $in{'ccommand'} = 'tmanage'; } elsif($in{'command'} eq 'ishowrename'){ $in{'command'} = 'irename'; $in{'ccommand'} = 'imanage'; } else{ $in{'command'} = 'rename'; $in{'ccommand'} = 'manage'; } &PageOut("$cgipath/t_rename.htm"); exit; } sub SShowUpload{ ($in{'atype'} ne 'admin')&&(&PError("Error. Access denied")); $in{'ccommand'} = 'smanage'; &PageOut("$cgipath/t_cssupload.htm"); exit; } sub ShowUpload{ &CF; &GetPath; if($in{'command'} eq 'tshowupload'){ $in{'command'} = 'tupload'; $in{'ccommand'} = 'tmanage'; } elsif($in{'command'} eq 'ishowupload'){ $in{'command'} = 'iupload'; $in{'ccommand'} = 'imanage'; } else{ $in{'command'} = 'upload'; $in{'ccommand'} = 'manage'; } &PageOut("$cgipath/t_upload.htm"); exit; } sub ShowCopy{ &CF; &GetPath; if($in{'command'} eq 'ishowcopy'){ $in{'command'} = 'icopy'; $in{'ccommand'} = 'imanage'; } elsif($in{'command'} eq 'tshowcopy'){ $in{'command'} = 'tcopy'; $in{'ccommand'} = 'tmanage'; } else{ $in{'command'} = 'copy'; $in{'ccommand'} = 'manage'; } &PageOut("$cgipath/t_copy.htm"); exit; } sub UO{ &CF; my(@f) = split("/",$in{'d'}); pop(@f); $in{'d'} = join("/",@f); if($in{'command'} eq 'tuo'){ $in{'command'} = 'tmanage'; &Manage; } elsif($in{'command'} eq 'iuo'){ $in{'command'} = 'imanage'; &Manage; } else{ $in{'command'} = 'manage'; &Manage; } } sub SManage{ $rootpath = $csspath; $rooturl = $cssurl; opendir(DIR,"$rootpath"); my (@files) = readdir(DIR); close DIR; foreach my $i (sort @files){ next if ($i !~ /\.css$/i); my($size,$date,@s); @s = stat("$rootpath/$in{'d'}/$i"); $size = $s[7]; $date = &ctime($s[9]); my($url) = "$rooturl/$in{'d'}/$i"; $url =~ s/http:\/\///i; $url =~ s/\/+/\//g; $url = 'http://'.$url; $in{'line'} .= qq| $i $size $date |; } (!$in{'line'})&&($in{'line'} = 'no styles uploaded'); &PageOut("$cgipath/t_css.htm"); exit; } sub Manage{ srand; my $rnd = int(rand(1000)); if($in{'command'} eq 'tmanage'){ $rootpath = $templatepath; $rooturl = $templateurl; } if($in{'command'} eq 'imanage'){ $rootpath = $librarypath; $rooturl = $libraryurl; } &CF; (!$in{'d'})&&($in{'d'} = '/'); $in{'d'} =~ s/\/+/\//g; opendir(DIR,"$rootpath/$in{'d'}"); my (@files) = readdir(DIR); close DIR; foreach my $i (sort @files){ next if ($i =~ /^\./); next if ($i =~ /\.cgi$/i); next if ($i =~ /^\_/); my($size,$date,@s); @s = stat("$rootpath/$in{'d'}/$i"); $size = $s[7]; $date = &ctime($s[9]); if (-d "$rootpath/$in{'d'}/$i"){ if(($in{'command'} eq 'imanage')&&(($in{'atype'} eq 'admin')||($in{'uiwrite'} eq 'checked'))){ $in{'renameline'} = qq||; $in{'deleteline'} = qq||; } if(($in{'command'} eq 'tmanage')&&(($in{'atype'} eq 'admin')||($in{'utwrite'} eq 'checked'))){ $in{'renameline'} = qq||; $in{'deleteline'} = qq||; } if(($in{'command'} eq 'manage')&&(($in{'atype'} eq 'admin')||($in{'ufwrite'} eq 'checked'))){ $in{'renameline'} = qq||; $in{'deleteline'} = qq||; } if($in{'atype'} eq 'user'){ $in{'renameline'} = ''; $in{'deleteline'} = ''; } $in{'dirline'} .= qq| $i $size $date $in{'renameline'} $in{'deleteline'} |; } else{ $in{'et'} = ''; if(($in{'atype'} eq 'user')&&($in{'command'} eq 'manage')){ next if (&CheckForAccess($i)); } if($in{'command'} eq 'imanage'){ next if (($i !~ /gif$/i)&&($i !~ /jpg$/i)); push(@li,"$in{'d'}/$i"); } my($url) = "$rooturl/$in{'d'}/$i"; $url =~ s/http:\/\///i; $url =~ s/\/+/\//g; $url = 'http://'.$url; if($in{'command'} eq 'imanage'){ &GetImages2($i); if(($in{'command'} eq 'imanage')&&(($in{'atype'} eq 'admin')||($in{'uiwrite'} eq 'checked'))){ $in{'copyline'} = qq|
|; $in{'renameline'} = qq||; $in{'deleteline'} = qq||; } if(($in{'atype'} eq 'user')&&($in{'et'} ne 'hp')){ $in{'copyline'} = ''; $in{'renameline'} = ''; $in{'deleteline'} = ''; } if($in{'pdownload'}){ $in{'copyline'} .= qq| | . $in{'copyline'}; } $in{'fline'} .= qq| $in{'imgline'} $in{'ilink'}$i$in{'ilink2'}
$in{'idem'}
$size $date $in{'copyline'} $in{'renameline'} $in{'deleteline'} |; } else{ if(($in{'command'} eq 'manage')&&(($in{'atype'} eq 'admin')||($in{'ufwrite'} eq 'checked'))){ $in{'editline'} = qq||; $in{'copyline'} = qq||; $in{'renameline'} = qq||; $in{'deleteline'} = qq||; } if(($in{'command'} eq 'tmanage')&&(($in{'atype'} eq 'admin')||($in{'utwrite'} eq 'checked'))){ $in{'editline'} = qq||; $in{'copyline'} = qq||; $in{'renameline'} = qq||; $in{'deleteline'} = qq||; } if($in{'atype'} eq 'user'){ $in{'copyline'} = ''; $in{'renameline'} = ''; $in{'deleteline'} = ''; } if($in{'pdownload'}){ $in{'copyline'} .= qq| | . $in{'copyline'}; } my($dimage); if(($in{'command'} eq 'manage')&&($in{'atype'} eq 'admin')){ $dimage = qq||; } else{ $dimage = qq||; } $in{'fline'} .= qq| $dimage $i $size $date $in{'editline'} $in{'copyline'} $in{'renameline'} $in{'deleteline'} |; } } } ($in{'command'} eq 'manage')&&($in{'atype'} ne 'admin')&&($in{'ufread'} ne 'checked')&&($in{'fline'} = ''); ($in{'command'} eq 'imanage')&&($in{'atype'} ne 'admin')&&($in{'uiread'} ne 'checked')&&($in{'fline'} = ''); ($in{'command'} eq 'tmanage')&&($in{'atype'} ne 'admin')&&($in{'utread'} ne 'checked')&&($in{'fline'} = ''); $in{'line'} = $in{'dirline'}.$in{'fline'}; &GetPath; if($in{'atype'} eq 'admin'){ $in{'omenus'} = qq|Admin  »  ::

|; } &DoMenus; if($in{'command'} eq 'tmanage'){ &PageOut("$cgipath/t_templates.htm"); } elsif($in{'command'} eq 'imanage'){ #&GetImages; &PageOut("$cgipath/t_images.htm"); } else{ &PageOut("$cgipath/t_manage.htm"); } exit; } sub DoMenus{ if(($in{'command'} eq 'manage')&&(($in{'atype'} eq 'admin')||($in{'ufwrite'} eq 'checked'))){ $in{'commands'} = qq|
Commands » :: :: ::
|; } if(($in{'command'} eq 'tmanage')&&(($in{'atype'} eq 'admin')||($in{'utwrite'} eq 'checked'))){ $in{'commands'} = qq|
Commands » :: :: ::
|; } if(($in{'command'} eq 'imanage')&&(($in{'atype'} eq 'admin')||($in{'uiwrite'} eq 'checked'))){ $in{'commands'} = qq|
Commands » :: ::
|; } if($in{'atype'} eq 'user'){ $in{'commands'} = qq|
Commands »
|; } if(!$in{'commands'}){ $in{'commands'} = qq|
Commands »
|; } my (@tt); if(($in{'command'} eq 'manage')&&($in{'atype'} eq 'admin')){ $in{'si'} = qq| |; push(@tt,$in{'si'}); } if(($in{'command'} eq 'manage')&&(($in{'atype'} eq 'admin')||($in{'uiwrite'} eq 'checked'))){ $in{'il'} = qq| |; push(@tt,$in{'il'}); } if(($in{'command'} eq 'manage')&&(($in{'atype'} eq 'admin')||($in{'utwrite'} eq 'checked'))){ $in{'tl'} = qq||; push(@tt,$in{'tl'}); } $in{'tl'} = join(qq|::|,@tt); if($in{'tl'}){ $in{'management'} = qq|
$in{'omenus'} $in{'tl'}
Management »
|; } } sub GetImages2{ my($i) = @_; my $rn = &GetRealName($i); my($url) = "$rooturl/$in{'d'}/$rn"; $url =~ s/http:\/\///i; $url =~ s/\/+/\//g; $url = 'http://'.$url; my($size,$date,@s); @s = stat("$rootpath/$rn"); $size = $s[7]; $date = &ctime($s[9]); return if(! -e "$rootpath/$rn"); my ($nw,$nh,$height,$width) = &psize("$rootpath/$rn",50); if($in{'type'} eq ''){ $in{'imgline'} = qq||; } elsif($in{'type'} eq 'ii'){ $in{'ilink'} = qq||; $in{'imgline'} = qq||; $in{'ilink2'} = qq||; } elsif($in{'type'} eq 'iii'){ $in{'ilink'} = qq||; $in{'imgline'} = qq||; $in{'ilink2'} = qq||; } else{ $in{'ilink'} = qq||; $in{'imgline'} = qq||; $in{'ilink2'} = qq||; } $in{'idem'} = qq|Dimensions: $height h x $width w|; } sub GetPath{ my($dir,@p2); $in{'path'} = "$in{'d'}"; my (@f) = split("/",$in{'path'}); $in{'path'} = '/'; foreach my $i (@f){ $dir .= "/$i"; $dir =~ s/\/+/\//g; push(@p2,"$i"); } if($in{'command'} =~ /^t/){ $in{'path'} = "/templates".join("/",@p2); } elsif($in{'command'} =~ /^i/){ $in{'path'} = "/images".join("/",@p2); } else{ $in{'path'} = "/rootpath".join("/",@p2); } } sub CF{ my($fname) = @_; my($ftc,@ext,$bad, $extensions); ($in{'nd'} =~ /\.\./)&&(&PError("Error. Invalid directory path")); ($in{'nd'} =~ /\|/)&&(&PError("Error. Invalid directory path")); ($in{'nd'} =~ /\//)&&(&PError("Error. Invalid directory path")); ($in{'nf'} =~ /\.\./)&&(&PError("Error. Invalid directory path")); ($in{'nf'} =~ /\|/)&&(&PError("Error. Invalid directory path")); ($in{'nf'} =~ /\//)&&(&PError("Error. Invalid directory path")); ($in{'filename'} =~ /\.\./)&&(&PError("Error. Invalid directory path")); ($in{'filename'} =~ /\|/)&&(&PError("Error. Invalid directory path")); ($in{'filename'} =~ /\//)&&(&PError("Error. Invalid directory path")); ($in{'d'} =~ /\.\./)&&(&PError("Error. Invalid directory path")); ($in{'d'} =~ /\|/)&&(&PError("Error. Invalid directory path")); ($in{'file'} =~ /\.\./)&&(&PError("Error. Invalid directory path")); ($in{'file'} =~ /\|/)&&(&PError("Error. Invalid directory path")); $bad=1; if($in{'command'} eq 'tcopy'){ @ext = @text; $ftc = $in{'nf'}; $extensions = $in{'textensions'}; } elsif($in{'command'} eq 'icopy'){ @ext = @iext; $ftc = $in{'nf'}; $extensions = $in{'iextensions'}; } elsif($in{'command'} eq 'copy'){ @ext = @fext; $ftc = $in{'nf'}; $extensions = $in{'fextensions'}; } elsif($in{'command'} eq 'trename'){ @ext = @text; $ftc = $in{'nf'}; $extensions = $in{'textensions'}; } elsif($in{'command'} eq 'irename'){ @ext = @iext; $ftc = $in{'nf'}; $extensions = $in{'iextensions'}; } elsif($in{'command'} eq 'rename'){ @ext = @fext; $ftc = $in{'nf'}; $extensions = $in{'fextensions'}; } elsif($in{'command'} eq 'tupload'){ @ext = @text; $ftc = $fname; $fsize = $in{'tsize'}*1000000; $extensions = $in{'textensions'}; } elsif($in{'command'} eq 'iupload'){ @ext = @iext; $ftc = $fname; $fsize = $in{'isize'}*1000000; $extensions = $in{'iextensions'}; } elsif($in{'command'} eq 'upload'){ @ext = @fext; $ftc = $fname; $fsize = $in{'fsize'}*1000000; $extensions = $in{'fextensions'}; } elsif($in{'command'} eq 'createfile'){ @ext = @fext; $ftc = $in{'nf'}; $fsize = $in{'fsize'}*1000000; $extensions = $in{'fextensions'}; } elsif($in{'command'} eq 'tcreatefile'){ @ext = @text; $ftc = $in{'nf'}; $fsize = $in{'tsize'}*1000000; $extensions = $in{'textensions'}; } elsif($in{'command'} eq 'savechanges'){ @ext = @fext; $ftc = $in{'nd'}; $fsize = $in{'fsize'}*1000000; $extensions = $in{'fextensions'}; } elsif($in{'command'} eq 'tsavechanges'){ @ext = @text; $ftc = $in{'nd'}; $fsize = $in{'tsize'}*1000000; $extensions = $in{'textensions'}; } else{ $bad=0; } my ($oext) = $ftc =~ /\.(.*)$/; $oext =~ tr/A-Z/a-z/; foreach my $i (@ext){ ($i eq $oext)&&($bad=0); } ($extensions)&&($bad)&&(&PError("Error. You are only allowed $extensions file extensions.")); } sub GetConfig{ open(DB,"<$cgipath/data/config.cgi"); my $config = ; close DB; ($in{'fextensions'},$in{'fsize'},$in{'textensions'},$in{'tsize'},$in{'iextensions'},$in{'isize'},$in{'rextensions'},$in{'txt'},$in{'pdownload'}) = split("\t",$config); ($in{'ufextensions'})&&($in{'fextensions'} = $in{'ufextensions'}); ($in{'utextensions'})&&($in{'textensions'} = $in{'utextensions'}); ($in{'uiextensions'})&&($in{'iextensions'} = $in{'uiextensions'}); ($in{'ufsize'})&&($in{'fsize'} = $in{'ufsize'}); ($in{'utsize'})&&($in{'tsize'} = $in{'utsize'}); ($in{'uisize'})&&($in{'isize'} = $in{'uisize'}); @fext = split(/,\s*/,$in{'fextensions'}); @text = split(/,\s*/,$in{'textensions'}); @iext = split(/,\s*/,$in{'iextensions'}); @rext = split(/,\s*/,$in{'rextensions'}); @txtext = split(/,\s*/,$in{'txt'}); } sub GetTemplates{ if(($in{'atype'} eq 'admin')||($in{'utread'} eq 'checked')){ &GetFiles(); } } sub GetFiles{ my($dir) = @_; my(@files); ("$templatepath/$dir" =~ /\.\./)&&(&PError("Error. Invalid path name.")); ("$templatepath/$dir" =~ /\|/)&&(&PError("Error. Invalid path name.")); opendir(DIR,"$templatepath/$dir"); @files = readdir(DIR); close dir; foreach my $i (@files){ next if ($i =~ /^\./); next if ($i =~ /^\_/); $dir =~ s/\/+/\//g; (-d "$templatepath/$dir/$i")?(&GetFiles("/$dir/$i")):($in{'templates'} .= qq|\n|); } } sub GetLogin{ &GetCookies; $in{'UserName'} = $cookie{'UserName'}; $in{'PassWord'} = $cookie{'PassWord'}; # if no password, then output the login screen if(!$in{'UserName'}){ (!$in{'command'})&&($in{'command'} = 'manage'); &PageOut("$cgipath/t_login.htm"); exit; } # otherwise check to see if username and password are correct if($windows){ if(($in{'UserName'} eq $username)&&($in{'PassWord'} eq $password)){ #good to go. $in{'atype'} = 'admin'; return 1; } } else{ if(($in{'UserName'} eq $username)&&(crypt($in{'PassWord'},'CS') eq $password)){ #good to go. $in{'atype'} = 'admin'; return 1; } } # check other users (&CheckUserLogin)&&(return 1); # password failed &PError("Error. Invalid username or password"); } sub CheckUserLogin{ my(@fields); open(DB,"<$cgipath/data/users.cgi"); while(){ chomp; @fields = split("\t",$_); if($fields[0] eq $in{'UserName'}){ $in{'atype'} = $fields[2]; $in{'atype'} =~ tr/A-Z/a-z/; $in{'ufdirectory'} = $fields[3]; $in{'ufread'} = $fields[4]; $in{'ufwrite'} = $fields[5]; $in{'ufextensions'} = $fields[6]; $in{'ufsize'} = $fields[7]; $in{'utdirectory'} = $fields[8]; $in{'utread'} = $fields[9]; $in{'utwrite'} = $fields[10]; $in{'utextensions'} = $fields[11]; $in{'utsize'} = $fields[12]; $in{'uidirectory'} = $fields[13]; $in{'uiread'} = $fields[14]; $in{'uiwrite'} = $fields[15]; $in{'uiextensions'} = $fields[16]; $in{'uisize'} = $fields[17]; $in{'ueditor'} = $fields[18]; $in{'furl'} = $fields[19]; $in{'turl'} = $fields[20]; $in{'iurl'} = $fields[21]; $in{'fquota'} = $fields[22]; $in{'lquota'} = $fields[23]; if($in{'fquota'}){ if((!$cookie{'isLogged'})||(($in{'command'} !~ /show/)&&($in{'command'} !~ /uo$/))){ &RecalQuota; } } ($in{'fquota'})&&(&CheckQuota); last; } } close DB; if($windows){ if(($in{'UserName'} eq $fields[0])&&($in{'PassWord'} eq $fields[1])){ ($in{'furl'})&&($rooturl = $in{'furl'}); ($in{'turl'})&&($templateurl = $in{'turl'}); ($in{'iurl'})&&($libraryurl = $in{'iurl'}); ($in{'ufdirectory'})&&($rootpath = $in{'ufdirectory'}); ($in{'utdirectory'})&&($templatepath = $in{'utdirectory'}); ($in{'uidirectory'})&&($librarypath = $in{'uidirectory'}); $in{'UserName'} = $fields[0]; return 1; } } else{ if(($in{'UserName'} eq $fields[0])&&(crypt($in{'PassWord'},'CS') eq $fields[1])){ #good to go. ($in{'furl'})&&($rooturl = $in{'furl'}); ($in{'turl'})&&($templateurl = $in{'turl'}); ($in{'iurl'})&&($libraryurl = $in{'iurl'}); ($in{'ufdirectory'})&&($rootpath = $in{'ufdirectory'}); ($in{'utdirectory'})&&($templatepath = $in{'utdirectory'}); ($in{'uidirectory'})&&($librarypath = $in{'uidirectory'}); $in{'UserName'} = $fields[0]; return 1; } } return 0; } sub RecalQuota{ &RecalcQuotas2($in{'ufdirectory'}); chdir($cgipath); ##update global used my(@l); open(DB,"+<$cgipath/data/users.cgi"); while(){ my @f = split("\t",$_); if($f[0] ne $in{'UserName'}){ push(@l,$_); } else{ $f[23]=$quota; my $newentry = join("\t",@f); push(@l,"$newentry\n"); } } seek(DB,0,0); if(@l){ foreach my $i (@l){ print DB $i; } } truncate(DB,tell(DB)); close DB; } sub RecalcQuotas2{ my($cdir) = @_; my(@files,$i); opendir(DIR,$cdir); @files = readdir(DIR); close DIR; ($cdir eq '.')?($cdir=''):($cdir .= '/'); foreach my $i (@files){ next if ($i =~ /^\./); next if ($i =~ /^\_/); if(-d "$cdir$i"){&RecalcQuotas2("$cdir$i");} else{ $quota += (stat("$cdir$i"))[7]; } } } sub CheckQuota{ if(($in{'fquota'})&&($in{'lquota'} > ($in{'fquota'} * 1000000))){ if($in{'command'} =~ /copy/){ &PError("Quota Exceeded! Please remove some of your files before proceeding"); } if($in{'command'} =~ /create/){ &PError("Quota Exceeded! Please remove some of your files before proceeding"); } if($in{'command'} =~ /save/){ &PError("Quota Exceeded! Please remove some of your files before proceeding"); } if($in{'command'} =~ /upload/){ &PError("Quota Exceeded! Please remove some of your files before proceeding"); } } else{ my $limit = ($in{'fquota'} * 1000000) - $in{'lquota'}; $limit = sprintf("%.2f",$limit/1000000); $in{'showquota'} = "

Disk Useage: $limit MB Remaining

"; } } sub Login{ $in{'command'} = 'manage'; &PageOut("$cgipath/t_login.htm"); exit; } sub GetRealName{ my($filename) = @_; my(@array,$real_name); if ($filename =~ /\//) { @array = split(/\//, $filename); $real_name = pop(@array); } elsif ($filename =~ /\\/) { @array = split(/\\/, $filename); $real_name = pop(@array); } else { $real_name = "$filename"; } return $real_name; } sub Setup{ use Cwd; $in{'cgipath'} = Cwd::cwd(); $in{'cgiurl'} = "$ENV{'HTTP_HOST'}/$ENV{'SCRIPT_NAME'}"; $in{'cgiurl'} =~ s/\/\//\//g; $in{'cgiurl'} = "http://".$in{'cgiurl'}; $in{'cgiurl'} =~ s/\/csPublisher\.cgi//i; $in{'rooturl'} = "http://$ENV{'HTTP_HOST'}"; $in{'rootpath'} = "$ENV{'DOCUMENT_ROOT'}"; if(($^O !~ /win/i)&&($in{'cgipath'} =~ /cgi\-bin/i)){ $in{'templateurl'} = "http://$ENV{'HTTP_HOST'}/cgi-script/csPublisher/templates"; $in{'templatepath'} = "$ENV{'DOCUMENT_ROOT'}/cgi-script/csPublisher/templates"; $in{'libraryurl'} = "http://$ENV{'HTTP_HOST'}/cgi-script/csPublisher/library"; $in{'librarypath'} = "$ENV{'DOCUMENT_ROOT'}/cgi-script/csPublisher/library"; $in{'csspath'} = "http://$ENV{'HTTP_HOST'}/cgi-script/csPublisher/css"; $in{'cssurl'} = "$ENV{'DOCUMENT_ROOT'}/cgi-script/csPublisher/css"; $in{'imageurl'} = "http://$ENV{'HTTP_HOST'}/cgi-script/csPublisher/images"; } else{ $in{'templateurl'} = "$in{'cgiurl'}/templates"; $in{'templatepath'} = "$in{'cgipath'}/templates"; $in{'libraryurl'} = "$in{'cgiurl'}/library"; $in{'librarypath'} = "$in{'cgipath'}/library"; $in{'csspath'} = "$in{'cgipath'}/css"; $in{'cssurl'} = "$in{'cgiurl'}/css"; $in{'imageurl'} = "$in{'cgiurl'}/images"; } &PageOut("t_setup.htm"); exit; } # _____________________________________________________________________________ sub SaveSetup{ (-e "$basepath/setup.cgi")&&(&PError("Error. Access Denied")); $in{'setup'} =~ s/\r*\n/\n/g; (!$in{'susername'})&&(&PError("Error. Please enter a username.")); (!$in{'spassword'})&&(&PError("Error. Please enter a password.")); ($in{'spassword'} ne $in{'spassword'})&&(&PError("Error. Please retype password.")); if($^O !~ /win/i){ $in{'spassword'} = crypt($in{'spassword'},'CS'); } open(SETUP,">$basepath/setup.cgi")||(($^O !~ /win/i)?(&PError("Error. Permission denied saving setup.cgi file. \\nPlease contact your systems administrator to give the webserve write access to the csPublisher directory.")):(&PError("Error. Permission denied saving setup.cgi file. \\nYou will need to chmod the csPublisher directory to 777"))); ($flock)&&(flock(SETUP,2)); print SETUP "\$cgiurl='$in{'scgiurl'}';\n"; print SETUP "\$cgipath='$in{'scgipath'}';\n"; print SETUP "\$rooturl='$in{'srooturl'}';\n"; print SETUP "\$rootpath='$in{'srootpath'}';\n"; print SETUP "\$templateurl='$in{'stemplateurl'}';\n"; print SETUP "\$templatepath='$in{'stemplatepath'}';\n"; print SETUP "\$libraryurl='$in{'slibraryurl'}';\n"; print SETUP "\$librarypath='$in{'slibrarypath'}';\n"; print SETUP "\$cssurl='$in{'scssurl'}';\n"; print SETUP "\$csspath='$in{'scsspath'}';\n"; print SETUP "\$imageurl='$in{'simageurl'}';\n"; print SETUP "\$username='$in{'susername'}';\n"; print SETUP "\$password='$in{'spassword'}';\n"; print SETUP "1;\n"; ($flock)&&(flock(SETUP,8)); print <<"EOF"; EOF exit; }