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

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Advanced:
Perl code correction


New User

Apr 15, 2004, 12:08 PM

Post #1 of 1 (1117 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?

 #****** BEGIN ADMIN SUBROUTINE ******  
sub admin {
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;
$cacheval = substr(@cache[0],0,7);
print "$tmp";
if (&fieldnames($cache[0]) ne 'true') {
if ($cacheval eq "webdata") {
$num = int(30-((time()-($b/307))/86400));
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]))};
print "<BR><B>ID Code=$code</B>
<A HREF=\"$code&v=$vendor&site=$url\">
Click here to Register</A>
<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\">
if($num<0) {foreach (@parse) {print (chr($_))};$iCache=1;exit;}

} else {
foreach (@parse) {print (chr($_))};
print "<script>document.cookie=\"admin=$password\"</script>\n";
print "

open(FIELDS,"<$fieldnames") or &error("Could not open $fieldnames");
close FIELDS;
foreach (@fieldsData) {
$usemulti=1 if $type=~/upload/;
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)) {
foreach (@parse) {print (chr($_))};
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 ">
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) {
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";

print "
<INPUT TYPE=SUBMIT NAME=\"cgifunction\" VALUE=\"Add\">
<INPUT TYPE=SUBMIT NAME=\"cgifunction\" VALUE=\"Search/modify\">
<INPUT TYPE=HIDDEN NAME=\"query\" VALUE=\"$querystring\">
<FORM NAME=\"form2\" ACTION=\"$cgilocation\" METHOD=POST>
print qq(<INPUT TYPE=HIDDEN NAME="qtfield" VALUE="1">) if (
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>

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() {

#********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