Gossamer Forum
Home : Products : Links 2.0 : Customization :

Add site into two different sites using same form!

Quote Reply
Add site into two different sites using same form!
Greetings All,
Can a user add his/her site into two different sites using the same form? so the user does not have to re-enter the information again for the second site?
Thanks
Mark..

Quote Reply
Re: Add site into two different sites using same form! In reply to
off the wall idea, copy add.cgi give it a new name like add2.cgi change your html to <form --- the new add2.cgi and check what else needs to be re-configured .... sounds like trouble, or possible try to use hidden variables to pass along the info.

Now, how this is dones actually ... no clue since I don't know perl ... sorry Frown

Quote Reply
Re: Add site into two different sites using same form! In reply to
Yep shouldn't be a problem to do:
First choose which add.cgi from which site you want to use.
then go into add.cgi and change sub process form to the following:

sub process_form {
# --------------------------------------------------------
my ($key, $status, $line, $output);

# Check the referer.
if (@db_referers and $ENV{'HTTP_REFERER'}) {
$found = 0;
foreach (@db_referers) {
$ENV{'HTTP_REFERER'} =~ /$_/i and $found++ and last;
}
if (!$found) {
&site_html_add_failure ("Auto submission is not allowed in this directory. Please visit the site to add your entry.");
return;
}
}

# This will set system fields like Validated to their proper values.
foreach $key (keys %add_system_fields) {
$in{$key} = $add_system_fields{$key};
}

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

open (ID, "<$db_links_id_file_name") or &cgierr("error in process_form. unable to open id file: $db_links_id_file_name. Reason: $!");
$in{$db_key} = <ID> + 1; # Get next ID number
close ID;

open (ID2, "<change to location of the other directory id file ") or &cgierr("error in process_form. unable to open id file: change to location of the
other directory id file
. Reason: $!");
$in{$db_key} = <ID2> + 1; # Get next ID2 number
close ID2;

# Validate the form input..
$status = &validate_record(%in);
if ($status eq "ok") {

# Update the counter.
open (ID, ">$db_links_id_file_name") or &cgierr("error in get_defaults. unable to open id file: $db_links_id_file_name. Reason: $!");
flock(ID, 2) unless (!$db_use_flock);
print ID $in{$db_key}; # update counter.
close ID; # automatically removes file lock

# Update the counter.
open (ID2, ">change to location of the other directory id file") or &cgierr("error in get_defaults. unable to open id file: change to location of the
other directory id file
. Reason: $!");
flock(ID2, 2) unless (!$db_use_flock);
print ID2 $in{$db_key}; # update counter.
close ID2; # automatically removes file lock


# Print out the validate input to a "validation database" where it is stored until
# the admin decides to add it into the real database.
open (VAL, ">>$db_valid_name") or &cgierr("error in add_record. unable to open validate file: $db_valid_name. Reason: $!");
flock(VAL, 2) unless (!$db_use_flock);
print VAL &join_encode(%in);
close VAL; # automatically removes file lock

open (VAL2, ">>change to other validation db. location") or &cgierr("error in add_record. unable to open validate file: change to other
validation db
. location. Reason: $!");
flock(VAL2, 2) unless (!$db_use_flock);
print VAL2 &join_encode(%in);
close VAL2; # 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_add_success;
}
else {
&site_html_add_failure($status);
}
}


Change the pieces marked in red to the locations of the id file and validation.db on your second site. It's just off of the top of my head but it should work.

Good Luck!

Glenn


http://mir.spaceports.com/~glennu/
Quote Reply
Re: Add site into two different sites using same form! In reply to
Correct me if I"m wrong, but that would only work if the two sites are on the same account & domain. For external sites, you'd have to use Net::FTP (or Net:Telnet ?).

--Drew
Quote Reply
Re: Add site into two different sites using same form! In reply to
Yeah your right, if you have an external site it won't work.

Good Luck!

Glenn


http://mir.spaceports.com/~glennu/
Quote Reply
Re: Add site into two different sites using same form! In reply to
Thank you for your help. I will try the change and see if it works.

Thanks
Mark

Quote Reply
Re: Add site into two different sites using same form! In reply to
Will that mod mean the data will have to be validated before it is processed. I would like to know if data entered in the add.cgi process can be only executed upon validation by the Administrator...eg. urlsubmitter script on same server will only process data when the Administrator validates link.

Quote Reply
Re: Add site into two different sites using same form! In reply to
Depends on how you want to set it up. Ie. if you don't want to validate it you could change the paths so it writes to links.db instead of validation.db


Good Luck!

Glenn


http://mir.spaceports.com/~glennu/