Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

modify.cgi: user modify mod

(Page 1 of 2)
> >
Quote Reply
modify.cgi: user modify mod
ok.. i believe this code is ready for release. It's quite simple and (hopefully) easy to install.

to see a demo..

www.pdamania.com/modify.cgi

login as:

u: pdamania
p: test

then go to

www.pdamania.com/user.cgi?to=/modify.cgi

login as:

u: jsu7785
p: test

anyways.. overall..

ADD CGI: 0
MOD CGI: 2 (add.cgi, modify.cgi)
ADD TEMPLATE: 2 (modify.html, modify_link.html)
MOD TEMPLATE: 2 (modify_form.html, modify_failure.html)

also.. if you guys want delete.cgi just tell me. it's already finished. it's just that you actually have to mod some things in the admin..

anyways..

get the two files.. add.cgi and modify.cgi

www.widgetz.com/sql/add.txt
www.widgetz.com/sql/modify.txt

then you are going to need to add templates..

HTML_Templates.pm
---------------------
add this to @EXPORT

Code:
&site_html_modify &site_html_modify_link

add these subroutines..

Code:
sub site_html_modify {
# --------------------------------------------------------
# This routine displays the user's links to modify.
#
my ($tags, $dynamic) = @_;
my $style = defined $dynamic ? $dynamic->param('t') : undef;
(ref $tags eq 'HASH') or croak "HTML_TEMPLATES: Argument '$tags' must be hash reference";

defined $dynamic and &load_user ($dynamic, $tags);
my $output = &load_template ('modify.html', {
%$tags,
%GLOBALS
}, undef, $style);
defined $dynamic and &clean_output($dynamic, \$output);
print $output;
}

sub site_html_modify_link {
# --------------------------------------------------------
my ($rec, $dynamic) = @_;
my $style = defined $dynamic ? $dynamic->param('t') : undef;
(ref $rec eq 'HASH') or croak "HTML_TEMPLATES: Argument '$rec' must be hash reference";

($rec->{'isDetail'} eq 'Yes') ?
($rec->{'LinkURL'} = "$LINKS{build_detail_url}/${$rec}{'ID'}$LINKS{build_extension}") :
($rec->{'LinkURL'} = $rec->{'URL'});

# defined $dynamic and &load_user ($dynamic, $user);
my $output = &load_template ('modify_link.html', {
%$rec,
%GLOBALS
}, undef, $style);
return $output;
}

get the 4 templates..

www.widgetz.com/sql/modify_html.txt
www.widgetz.com/sql/modify_link_html.txt
www.widgetz.com/sql/modify_form_html.txt
www.widgetz.com/sql/modify_error_html.txt

basically.. the form and the error have 1 hidden tag added (the ID) and then the Current URL taken out..

this is a secure system.. it won't let anyone not logged in slip by and it won't let anyone not authorized to edit a link to edit a link.. keep in mind that this mod doesn't allow admins to edit all the links.. Smile [that's what the administration is for]

oh yea.. you have to add a field to the Links Database..

name: Username
form: 20
max : 35
default: PDAmania (in your case the administrator's name.. so when you add links from the admin.. it will be defaulted to you)

now it should be ready.. some of you might have to fix user.cgi (i had to)

find:

Code:
my $session_cookie = $in->cookie ( -name => 's', -value => $session, -expires => '+3h' );
my $user_cookie = $in->cookie ( -name => 'Username', -value => $user, -expires => '+1y' );

change to

Code:
my $session_cookie = $in->cookie (
-name => 's',
-value => $session,
-expires => '+3h',
-path => '/',
-domain => '.pdamania.com'
);
my $user_cookie = $in->cookie (
-name => 'Username',
-value => $user,
-expires => '+1y',
-path => '/',
-domain => '.pdamania.com'
);

change the domain to yours (yes.. keep the first period).. leave the path alone.. it allows for the cookie to be used anywhere.. (in your domain)..

anyways.. hopefully my instructions are good.. tell me..

i'll make a website with the links sql mods after finals and after my ski trip (i snowboard .. parents/relatives ski).. that's in february for your information Smile so it's a LONG time..


------------------
Jerry Su

[This message has been edited by widgetz (edited January 01, 2000).]
Quote Reply
Re: modify.cgi: user modify mod In reply to
forgot to say..

the links do go through validation..

------------------
Jerry Su
Quote Reply
Re: modify.cgi: user modify mod In reply to
ugh..

Code:
sub display {
# --------------------------------------------------------
my ($in, $dynamic) = @_;
my ($links, $span);

# Get the user's links.
my $db = new Links: BSQL $LINKS{admin_root_path} . "/defs/Links.def";
my $recs = $db->query ({ Username => "$USER->{'Username'}", mh => 10, nh => ($in->param('nh') | | '1'), ww => 1 });

# Change the links into HTML.
if ($db->hits) {
foreach my $rec (@$recs) {
$rec = $db->array_to_hash ($rec);
$links .= &site_html_modify_link ($rec);
}

# Span pages if more than 10 hits.
($db->hits > 10) and ($span = $db->toolbar());
}

# Display the page.
&site_html_modify ({ Links => $links, span => $span }, $dynamic);
}

change the "10"s if you want more links per page.. sorry i didn't make a variable like

Code:
$LINKS{build_links_per_modify} = 10;

and change the "10"s to $LINKS{build_links_per_modify}.. *hint*.

------------------
Jerry Su
Quote Reply
Re: modify.cgi: user modify mod In reply to
This sounds pretty cool. I'm going to see how it works on the FAQ....

------------------
POSTCARDS.COM -- Everything Postcards on the Internet www.postcards.com
LinkSQL FAQ: www.postcards.com/FAQ/LinkSQL/







Quote Reply
Re: modify.cgi: user modify mod In reply to
can you guys either email me or post here that you successfully installed this mod Smile

also.. one of the reasons i am not releasing many of my mods are because they require much modifications to certain scripts.. this one only required you to add a username field.. but usually that means you should get rid of the contact email field too.. but because nph-email.cgi uses that field.. i am not suggesting it unless you know the code to get the username out of the links database then fish the email from the users database..

ok?

------------------
Jerry Su
Links SQL Licensed
------------------
Quote Reply
Re: modify.cgi: user modify mod In reply to
LOL... you know, I forgot in the mess of what was going on. I had trouble with the sessions data, and once I got that fixed, I forgot to finish the mod.

I'll let you know later today <G>

But, _PLEASE_ start releasing the mods. If you'd want me to polish the docs, I'll do it. There are a lot of people waiting for the code, and it's better to get it out there, and worry about the docs later -- Smile Just put a little armour all on your shell.



------------------
POSTCARDS.COM -- Everything Postcards on the Internet www.postcards.com
LinkSQL FAQ: www.postcards.com/FAQ/LinkSQL/








Quote Reply
Re: modify.cgi: user modify mod In reply to
i couldn't find the thread myself.. so you can just find this in user.cgi

Code:
$db->add_record ( $in_r );

and change it to
Code:
$db->add_record ( $in_r ) or &site_html_signup_form ( { error => $Links::DBSQL::error, %{$in_r} }, $dynamic ) and return;

also.. there are many other bugs in user.cgi.. you should go to Pugdog's FAQ and go read all the bugs threads..

------------------
Jerry Su
Links SQL Licensed
------------------



[This message has been edited by widgetz (edited January 22, 2000).]
Quote Reply
Re: modify.cgi: user modify mod In reply to
I am using that mod. There is a little bug in it.
If you add some required fields to the user table user.cgi won't display the DBSQL error and will send the user to the success page because you don't evaluate the return value of the function add_record()

Quote Reply
Re: modify.cgi: user modify mod In reply to
i already gave alex the fix for that...

search this forum for user.cgi bug

there were quite a few..

it's a simple fix

------------------
Jerry Su
Links SQL Licensed
------------------

Quote Reply
Re: modify.cgi: user modify mod In reply to
Thanks, it works fine now.

I left the field Contact_Email in the links Table and then changed add.cgi to fill in this field with the value from authenticate

$in->param ( -name => 'Contact_Email', -value => $USER->{Email} );

By the way do you have an idea how to redirect the user to the page he intended to reach?

Lets say he clicked on modify.cgi; modify sends him to the login; login sends him to login_success;

Is there a way to send him back to modify.cgi or add.cgi where he initially intended to go?

[This message has been edited by Alex404 (edited January 25, 2000).]
Quote Reply
Re: modify.cgi: user modify mod In reply to
the thing i did with the ?to=lala

i just put like

Code:
if ($to) {
print $in->redirect( -uri => "$LINKS{build_root_url}$to" );
}
else {
# regular stuff
}

of course i put the cookie stuff in too..
Quote Reply
Re: modify.cgi: user modify mod In reply to
Hi widgetz,

are you storing the "?to=lala" data in a cookie or passing it as a tag to the different forms?

regards, Alexander
Quote Reply
Re: modify.cgi: user modify mod In reply to
oh.. for that i passed it to the template and said..

Code:
<%if to%>
<input type="hidden" name="to" value="<%to%>">
<%endif%>

------------------
Jerry Su
Links SQL User
------------------
Quote Reply
Re: modify.cgi: user modify mod In reply to
i forgot to mention when you change the cookies to the one with the path and domain.. you need to change the logout cookie too..

just add

Code:
, -path => '/', -domain => '.pdamania.com'

to the middle of that one line in the logout elsif..

------------------
Jerry Su
Links SQL User
------------------
Quote Reply
Re: modify.cgi: user modify mod In reply to
Thanks,

it's perfect now.
I had to modify add.cgi to send the ?ID=Id_No param with the $to

regards, Alexander
Quote Reply
Re: modify.cgi: user modify mod In reply to
Code:
if ($to) { print $in->redirect( -uri => "$LINKS{build_root_url}$to" );}else { # regular stuff}

where do i have to put the code?
I've tried to implant it in add.cgi, but the redirection doesn't work.



Quote Reply
Re: modify.cgi: user modify mod In reply to
Hello,

I jsut installed this mod. It does not redirect to the add or modify page after login. I also could not figure out where to place the following code to redirect me:
Code:
if ($to) {
print $in->redirect( -uri => "$LINKS{build_root_url}$to" );
}
else {
# regular stuff
}

Where do I put that? Please help...



------------------
James L. Murray
VirtueTech, Inc.
www.virtuetech.com


Quote Reply
Re: modify.cgi: user modify mod In reply to
that wasn't part of the mod.. but ok..

in sub login_user..

replace
Code:
print $in->header( -cookie => [$session_cookie, $user_cookie] );
&site_html_login_success ( $user_r, $in );

with
Code:
if ($in->param('to')) {
print $in->redirect( -cookie => [$session_cookie, $user_cookie], -uri => ("$LINKS{build_root_url}" . $in->param('to')) );
}
else {
print $in->header( -cookie => [$session_cookie, $user_cookie] );
&site_html_login_success ( $user_r, $in );
}

then don't forget to put that template thing in..

did i ever show you
http://www.pdamania.com/review2.cgi?ID=1002

it is the complete review.cgi v2.. with posting disabled..

------------------
Jerry Su
Links SQL User
------------------
Quote Reply
Re: modify.cgi: user modify mod In reply to
So Review.cgi 2 is ready Jerry Smile

BTW - I realise there is still code that needs help - if you need a version of Links SQL which is 99.99% unmodified then I have a solution for ya :P

------------------
Michael Bray
Review your webhost or find a new one.
www.webhostarea.com
Links SQL User
------------------






[This message has been edited by Michael_Bray (edited March 02, 2000).]
Quote Reply
Re: modify.cgi: user modify mod In reply to
Hello,

I entered the code above into sub login_user, but what teplate does the following go into:
Code:
<%if to%>
<input type="hidden" name="to" value="<%to%>">
<%endif%>

I did not see it explained anywhere.


------------------
James L. Murray
VirtueTech, Inc.
www.virtuetech.com


Quote Reply
Re: modify.cgi: user modify mod In reply to
It seems like the user.cgi doesn't parse <%to%> tag's correctly.

I got 'Unknown tag to' error.

Quote Reply
Re: modify.cgi: user modify mod In reply to
 So when is Review.cgi v2 planned to be released?

------------------
Robert Blackstone
Webmaster of Scato Search
www.scato.com
Quote Reply
Re: modify.cgi: user modify mod In reply to
jerry,

can I have the delete.cgi file?

thanks

Quote Reply
Re: modify.cgi: user modify mod In reply to
anyone can give the delete.cgi file ?
Quote Reply
Re: modify.cgi: user modify mod In reply to
Could someone be kind enough to post where I could pick up these files?

------------------
Robert Blackstone
Webmaster of Scato Search
www.scato.com
> >