CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
Perl code correction

 



cellton
New User

Apr 15, 2004, 12:08 PM

Post #1 of 1 (1238 views)
Perl code correction Can't Post

Look at the part of amateur code, flat Perl database(its obsoleted enough, but it works) Code has a lack, its made a little clumsily, and loses functionality after the 30day period. How to correct a code to change this part that it did not lose working after 30 days?

Code
 #****** BEGIN ADMIN SUBROUTINE ******  
sub admin {
pop(@value);
&checkpass;
open(FIELDS,"<$fieldnames") or &error("Content-type: text/html\n\n
<BODY BGCOLOR=WHITE> <h2>Could not open <font color=blue>$fieldnames</font> <P>
Make sure the path is correct. If you have moved the data files, you can
correct this by changing lines 10 and 11 in the cgi script.<P><BR></P>
<P><BR></P><P><BR></P><P><BR></P></h2><font size=3>This cgi error was ");
@cache = <FIELDS>;
close FIELDS;
chop($cache[0]);
&checkcrypt();
$cacheval = substr(@cache[0],0,7);
$tmp=&getFields;
print "$tmp";
if (&fieldnames($cache[0]) ne 'true') {
if ($cacheval eq "webdata") {
$num=substr(@cache[0],7,99);
$num = int(30-((time()-($b/307))/86400));
@parse=(82,101,103,105,115,116,114,97,116,105,111,110,32,21,101,120,112,105,114,101,100);
print "

<font size=4 color=green><B>";
for ($m=0;$m<67;$m++) {print chr(hex($import[$m]))};
print "$num";
for ($m=66;$m<101;$m++) {print chr(hex($import[$m]))};
$url=escape("$ENV{SERVER_NAME}$ENV{SCRIPT_NAME} $ENV{SERVER_ADMIN}");
print "<BR><B>ID Code=$code</B>
<A HREF=\"http://www.tarkan.net/webdata/register.htm?code=$code&v=$vendor&site=$url\">
Click here to Register</A>
</B></font>
<BR>
<form name=\"form3\" action=\"$cgilocation\" method=post>
Enter your code:<input name=\"box1\" type=text size=15>
<input name=\"cgifunction\" type=hidden value=\"cache\">
<input type=submit value=\"submit registration\">
</form>
";
if($num<0) {foreach (@parse) {print (chr($_))};$iCache=1;exit;}


} else {
@parse=(84,104,101,114,101,32,105,115,32,97,32,112,114,111,98,108,101,109,32);
push(@parse,119,105,116,104,32,116,104,101,32,114,101,103,105,115,116,114,97,116,105,111,110,32,99,111,100,101);
foreach (@parse) {print (chr($_))};
exit;
};
};
print "<script>document.cookie=\"admin=$password\"</script>\n";
print "

";
@fields=();
@types=();
open(FIELDS,"<$fieldnames") or &error("Could not open $fieldnames");
@fieldsData=<FIELDS>;
close FIELDS;
$usemulti=0;
foreach (@fieldsData) {
($field,$type)=split(/::/);
push(@fields,"$field\n");
push(@types,"$type");
$usemulti=1 if $type=~/upload/;
};
shift(@fields);
shift(@types);
local $tmp=eval("\$k"."ey/307");
local $tmp2=eval("\$n"."um");
if ($tmp2>0) {if ($tmp2 != int(30-((time()-($b/307))/86400))) {$tmp=1.25}};
if ($tmp != int($tmp)) {
@parse=(84,104,101,114,101,32,105,115,32,97,32,112,114,111,98,108,101,109,32);
push(@parse,119,105,116,104,32,116,104,101,32,114,101,103,105,115,116,114,97,116,105,111,110,32,99,111,100,101);
foreach (@parse) {print (chr($_))};
exit;
};
if ($num>30) {die "Invalid Date function"};
print "
<HEAD><TITLE>Webdata Admin Page</TITLE></HEAD>
<BODY BGCOLOR=\"beige\">
<H1 align=center> Administration Page </H1>";
if (length($reqfields)>0) {
print "<font color=red><B>* </B>indicates required fields</font><BR>";
}
print "
<form name=\"form1\" action=\"$cgilocation\" method=post";
print " ENCTYPE=\"multipart/form-data\"" if $usemulti==1;
print ">
<TABLE BORDER=0>";
$ftcount=0;
print "<TR><TD><font color=orange><B>Date Created</B></font></TD><TD><input type=text size=15 name=\"date_created\"> (Date is added automatically, use for Search/modify only)</TD></TR>\n";
print "<TR><TD><font color=orange><B>Owned by</B></font></TD><TD><input type=text size=15 name=\"record_owned_by\"> (Find records owned by a specific member. Use for Search/modify only)</TD></TR>\n";
foreach $field (@fields) {
&gettype($types[$ftcount]);
chop($field);
print "<TR><TD>";
print "<font color=red><B>* </B></font>" if $reqfields=~/(^|\,)$ftcount($|\,)/;
print "<B>$field</B></TD>";
if ($type eq "text") {
print "<TD><input type=$type name=\"$field\" size=$typesize></TD></TR>\n";
};
if ($type eq "checkbox") {
print "<TD><input type=checkbox name=\"$field\" value=\"yes\"></TD></TR>\n";
};
if ($type eq "list") {
print "<TD><SELECT NAME=\"$field\" SIZE=1>\n";
print "<OPTION VALUE=\"\">\n";
foreach (@typelistvals) {
print "<OPTION>$_\n";
};
print "</SELECT></TD></TR>\n";
};
if ($type eq "comment") {
print "<TD><TEXTAREA NAME=\"$field\" COLS=60 ROWS=$typerows></TEXTAREA></TD></TR>\n";
};
if ($type eq "upload") {
print "<TD><INPUT NAME=\"$field\" TYPE=\"file\"></TD></TR>\n";
};
if ($type eq "variance") {
print "<TD>
<small>Enter each option with a comma in-between.</small><BR>
<input type=text name=\"$field\" size=80></TD></TR>\n";
};
if ($type eq "price-variance") {
print "<TD>
<small>Alternate option and price with a comma in-between.<BR>
for example: small,9.95,medium,12.95,large,15.95,X-large,18.95</small><BR>
<input type=text name=\"$field\" size=80></TD></TR>\n";
};
$ftcount++;
};


print "
</TABLE>
<INPUT TYPE=SUBMIT NAME=\"cgifunction\" VALUE=\"Add\">
<INPUT TYPE=SUBMIT NAME=\"cgifunction\" VALUE=\"Search/modify\">
<INPUT TYPE=HIDDEN NAME=\"query\" VALUE=\"$querystring\">
<INPUT TYPE=RESET VALUE=\"Clear Form\"></FORM><P><HR>
<FORM NAME=\"form2\" ACTION=\"$cgilocation\" METHOD=POST>
";
print qq(<INPUT TYPE=HIDDEN NAME="qtfield" VALUE="1">) if (
(length($url))||(length($registereddb)));
print "
<INPUT TYPE=SUBMIT NAME=\"cgifunction\" VALUE=\"Import data\">
<INPUT TYPE=SUBMIT NAME=\"cgifunction\" VALUE=\"Export data\">
<INPUT TYPE=SUBMIT NAME=\"cgifunction\" VALUE=\"Modify fields\">";
#if ($useCart) {
#print " <INPUT TYPE=SUBMIT NAME=\"cgifunction\" VALUE=\"Retrieve Orders\">";
#}
print "<P>
<INPUT TYPE=SUBMIT NAME=\"cgifunction\" VALUE=\"Members\">
<INPUT TYPE=SUBMIT NAME=\"cgifunction\" VALUE=\"Customize Pages\">";
if ($useCart) {
print "<P><INPUT TYPE=SUBMIT NAME=\"cgifunction\" VALUE=\"Configure Shopping Cart\">
<INPUT TYPE=SUBMIT NAME=\"cgifunction\" VALUE=\"Retrieve Orders\">";
}
print "</FORM>


<h2>
Click \'Add\' to add a record to the database.

<P>To modify or delete a record: Search for the record, then click on the record in the search results window.</h2>
<A HREF=\"$searchPage\">
Go to the user search page</A><BR>
<A HREF=\"$homepage\">
Return to home page</A><BR>
<A HREF=\"javascript:logout()\">Log out</A>
<center><font size=2>Webteacher\'s Webdata, version $version</font></center>
";
print qq(<SCRIPT>
function setCookie(name, value, expire) {
document.cookie = name + "=" + escape(value)
+ ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
}
function logout() {
setCookie('admin',"");
location="$homepage";
}
</SCRIPT>
);
};


#********END ADMIN SUBROUTINE***************



(This post was edited by cellton on Apr 16, 2004, 3:48 AM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives