Gossamer Forum
Home : Products : Links 2.0 : Customization :

Modify.cgi does'nt modify!

Quote Reply
Modify.cgi does'nt modify!
Only one problem with modify.cgi!

It works fine (it calls the data to be modified) but when I click to modify it turns to my own default error page.

It seems to me a problem of permissions...

Try to connect to:

http://tuonome.com/.../pannello/modify.cgi

and

try to modify:

ID: 1
Pwd: lollo

Thanks for anyone helping this italian perl girl fun!

Andrea
Quote Reply
Re: [Andreaf] Modify.cgi does'nt modify! In reply to
It may help if I knew what the message....

Torna indietro e prova di nuovo

....actually meant Wink

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Modify.cgi does'nt modify! In reply to
Crazy...Yes...
You're right!
The message "Torna indietro e prova di nuovo " is the one that is in the modify_error page and just means "go back and try again" in italian...

The problem is that I get the error message!

Why?

I'm trying to use LINKS as a customer panel for some customers where they can update their datas and I can make the changes when I receive their request....

This the text of modify.cgi:

eval {
($0 =~ m,(.*)/[^/]+,) && unshift (@INC, "$1"); # Get the script location: UNIX /
($0 =~ m,(.*)\\[^\\]+,) && unshift (@INC, "$1"); # Get the script location: Windows \

require "admin/links.cfg"; # Change this to full path to links.cfg if you have problems.
require "$db_lib_path/db_utils.pl";
require "$db_lib_path/links.def";
$build_use_templates ?
require "$db_lib_path/site_html_templates.pl" :
require "$db_lib_path/site_html.pl";
};
if ($@) {
print "Content-type: text/plain\n\n";
print "Error including libraries: $@\n";
print "Make sure they exist, permissions are set properly, and paths are set correctly.";
exit;
}

# ========================================================

eval { &main; }; # Trap any fatal errors so the program hopefully
if ($@) { &cgierr("fatal error: $@"); } # never produces that nasty 500 server error page.
exit; # There are only two exit calls in the script, here and in in &cgierr.

sub main {
# --------------------------------------------------------
local (%in) = &parse_form;

# We are processing the form.
if ($in{'Submit'}) {
&process_form;
}
# Otherwise we are displaying the form (in site_html.pl), displaying
# the entrance (Asks for Link ID and Password)
else {
if ($in{'ID'} =~ /^\d+$/) {
my (%rec) = &get_record ($in{'ID'});

if ($rec{$db_key} eq $in{'ID'}) {
if ($rec{'Password'} eq $in{'password'}) {
&site_html_modify_form (%rec);
}
else {
&site_html_modify_failure ("Password Invalid: $in{'password'}");
}
}
else {
&site_html_modify_failure ("Unkown Link ID: $in{'ID'}");
}
}
else {
&site_html_modify_first;
}
}
}

sub process_form {
# --------------------------------------------------------
my ($key, $status, @values, $found);
local (%original);

# Make sure we have a link to modify.
# !$in{'Current URL'} and &site_html_modify_failure ("non hai specificato il link da modificare") and return;

# Let's check to make sure the link we want to update is actually
# in the database.
open (DB, "<$db_file_name") or &cgierr("errore nel validate_records. impossibile aprire il db file: $db_file_name. Motivo: $!");
$found = 0;
LINE: while (<DB>) {
(/^#/) and next LINE;
(/^\s*$/) and next LINE;
chomp;
@data = &split_decode($_);
if ($data[$db_key] eq $in{'ID'}) {
$in{$db_key} = $data[0];
$found = 1;
%original = &array_to_hash (0, @data);
last LINE;
}
}
close DB;
!$found and &site_html_modify_failure ("il link non č stato trovato nel database") and return;

# Since we have a valid link, let's make sure the system fields are set to their
# proper values. We will simply copy over the original field values. This is to stop
# people from trying to modify system fields like number of hits, etc.
foreach $key (keys %add_system_fields) {
$in{$key} = $original{$key};
}

# Set date variable to today's date.
$in{$db_cols[$db_modified]} = &get_date;

# Validate the form input..
$status = &validate_record(%in);
if ($status eq "ok") {
# First make sure the link isn't already in there.
open (MOD, "<$db_modified_name") or &cgierr ("impossibile aprire modified database: $db_modified_name. Motivo: $!");
while (<MOD>) {
chomp;
@values = split /\|/;
if ($values[0] eq $in{$db_key}) {
close MOD;
&site_html_modify_failure("Una richiesta per apportare delle modifiche a questo link č giā stata ricevuta. Si prega di riprovare pių tardi.");
return;
}
}
close MOD;

# Print out the modified record to a "modified database" where it is stored until
# the admin decides to add it into the real database.
open (MOD, ">>$db_modified_name") or &cgierr("errore nel modify.cgi. impossibile aprire modification database: $db_modified_name. Motivo: $!");
flock(MOD, $LOCK_EX) unless (!$db_use_flock);
print MOD &join_encode(%in);
close MOD; # automatically removes file lock

# Send the admin an email message notifying of new addition.
&send_email;
# Send the visitor to the success page.
&site_html_modify_success;
}
else {
# Let's change that error message from a comma delimted list to an html
# bulleted list.
&site_html_modify_failure($status);
}
}

sub send_email {
# --------------------------------------------------------
# Sends an email to the admin, letting him know that there is
# a new link waiting to be validated.

# Check to make sure that there is an admin email address defined.
$db_admin_email or &cgierr("Indirizzo Email Amministratore Database Non E' Definito Nel Config File!");
my $to = $db_admin_email;
my $from = $in{$db_cols[$db_contact_email]};
my $subject = "Tuonome.com - Modifica al Database: $in{'Title'}";
my $msg = qq|
Il seguente link č stato modificato ed č in attesa di essere attivato:

LINK ORIGINALE:
===============================================

Azienda: $original{'Azienda'}
Cognome: $original{'Cognome'}
Nome: $original{'contact_name'}
Telefono: $original{'Telefono'}
Fax: $original{'Fax'}
Email: $original{'contact_email'}
Indirizzo: $original{'Indirizzo'}
Cittā: $original{'Citta'}
Provincia: $original{'Provincia'}
Cap: $original{'CAP'}
Cognome CA: $original{'CognomeCA'}
Nome CA: $original{'NomeCA'}
Telefono CA: $original{'TelefonoCA'}
Fax CA: $original{'FaxCA'}
Email Ca: $original{'EmailCA'}
Indirizzo CA: $original{'IndirizzoCA'}
CittāCA: $original{'CittaCA'}
Provincia CA: $original{'ProvinciaCA'}
CAP CA: $original{'CAPCA'}
Name System: $original{'NS0'}
Name System: $original{'NS1'}
Name System: $original{'NS2'}
Name System: $original{'NS3'}

LINK NUOVO:
===============================================

Azienda: $in{'Azienda'}
Cognome: $in{'Cognome'}
Nome: $in{'contact_name'}
Telefono: $in{'Telefono'}
Fax: $in{'Fax'}
Email: $in{'contact_email'}
Indirizzo: $in{'Indirizzo'}
Cittā: $in{'Citta'}
Provincia: $in{'Provincia'}
Cap: $in{'CAP'}
Cognome CA: $in{'CognomeCA'}
Nome CA: $in{'NomeCA'}
Telefono CA: $in{'TelefonoCA'}
Fax CA: $in{'FaxCA'}
Email Ca: $in{'EmailCA'}
Indirizzo CA: $in{'IndirizzoCA'}
CittāCA: $in{'CittaCA'}
Provincia CA: $in{'ProvinciaCA'}
CAP CA: $in{'CAPCA'}
Name System: $in{'NS0'}
Name System: $in{'NS1'}
Name System: $in{'NS2'}
Name System: $in{'NS3'}

Remote Host: $ENV{'REMOTE_HOST'}
Referer: $ENV{'HTTP_REFERER'}

Per aggiornare, collegati a:
$db_script_url

Saluti,

Amministratore Database.
|;

# Then mail it away!
require "$db_lib_path/Mailer.pm";
my $mailer = new Mailer ( { smtp => $db_smtp_server,
sendmail => $db_mail_path,
from => $from,
subject => $subject,
to => $to,
msg => $msg,
log => $db_mailer_log
} ) or return undef;
$mailer->send or return undef;
}


I did'nt go to sleep tonite working on the script and I'm almost next to suicide...
Frown

Thanks...
Andrea
Quote Reply
Re: [Andreaf] Modify.cgi does'nt modify! In reply to
Well, looking at the source code for your pages shows me only the code for the form box, no info like
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html>

<head>
<title>Site Title ģ Page Name</title>
</head>
or anything like that. So technically, the browser shouldn't display it, but it operates under the assumption that the page contents are HTML.

Are you using templates or not? Are you using header/footer text files along with them? If so, that may be part of the problem; does your code for the modify form have <%include header.txt%>?

Does your add form work? If so, compare the HTML code (view source) from that page to this one, and note if there are major differences (besides the actual form data).

Let us know how it looks. I know how this stuff can boil the brain...


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Modify.cgi does'nt modify! In reply to
...even tonite I went to bed a 3 a.m. due to the fact that I can't let the LINKS 2.0 win against me...

I've looked in my site_html_templates.pl and I've found that:[/code]sub site_html_modify_form {
# --------------------------------------------------------
# This routine determines how the modify form page will look like.

my $category = &build_select_field ("Category", "$in{'Category'}");

&html_print_headers;
print &load_template ('modify.html', {
Category => $category,
%globals
});
}

sub site_html_modify_success {
# --------------------------------------------------------
# This routine determines how the modify success page will look like.

&html_print_headers;
print &load_template ('modify_success.html', {
%in,
%globals
});
}

sub site_html_modify_failure {
# --------------------------------------------------------
# This routine determines how the modify failure page will look like.

my $errormsg = shift;
$in{'Category'} = &build_select_field ("Category", $in{'Category'});

&html_print_headers;
print &load_template ('modify_error.html', {
error => $errormsg,
%in,
%globals
});
}
Code:
Is it the sub site_html_modify_form O.K. or should I have to add all my fields here as the category one?

In case this does'nt work I'll switch to the NON template way...

Andrea

P.s.
Life could be easier...
Quote Reply
Re: [Andreaf] Modify.cgi does'nt modify! In reply to
Is this is the mod from Paul Wilson (wiredon.net)? If so, you are missing this (red) part:

Code:
sub site_html_modify_form {
# --------------------------------------------------------
# This routine determines how the modify form page will look like.
my (%record) = @_;
my $cat = &build_select_field
("Category", "$record{'Category'}");
&html_print_headers;
print &load_template ('modify.html', {
Cat => $cat,
%record,
%globals
});
}


The code that I previously said is missing is in the template directory, modify.html, modify_success.html, modify_error.html, etc pages. You need this to be in the template:

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html>
<head>
<title><%site_title%>: Modify a Resource</title>
<link rel=stylesheet href="<%css%>" type="text/css" title="style sheet">
</head>
<body>


YOUR FORM CODE HERE

</body>
</html>
You are missing the red part.


Leonard
aka PerlFlunkie

Last edited by:

PerlFlunkie: Dec 5, 2002, 12:05 PM
Quote Reply
Re: [PerlFlunkie] Modify.cgi does'nt modify! In reply to
actually, I think she is using the other password mod...I think someone named phoenix created it in 1999?. I have a copy somewhere on my hard drive.


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."
Quote Reply
Re: [esm] Modify.cgi does'nt modify! In reply to
Perhaps...

I tried using that one before, and couldn't get it to fly right, either. Paul's has many more features, and I have it working on the site in my signature.


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Modify.cgi does'nt modify! In reply to
yep, I agree with you. I had the other one working then it just stopped. and I replaced it with paul's. it's the best!


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."