Gossamer Forum
Home : Products : DBMan : Customization :

Short URL redirect

Quote Reply
Short URL redirect
I've added some simple code to html_home:


if ($in{'goto'}) {
print "Location: $db_script_link_url&ID=$in{'goto'}&format=long&view_records=1&ww=1\n\n";
exit;
}


This mod allows you to link to something like this:
http://www.foo.com/cgi-bin/dbman.cgi?goto=1025
and after you are logged in, it takes you straight to record number 1025.

The mod works great, but the print "Location: code seems to be slow, about a 1-2 sec delay.
I've tried to replace it with:
&get_record($in{'goto'});
and other combinations, but it returns back to the html_home routine and ends up printing double footers and headers.

Any ideas?

Quote Reply
Re: Short URL redirect In reply to
One suggestion is adding these codes in the sub main routine in the db.cgi using the $per_add variable, like the following:

New Codes: Updated: July 21,2000 @ 15:40:00

Code:

elsif ($in{'goto'}) { if {$per_add) { &view_goto; } else { &html_unauth; }}


Then create a new sub called sub view_goto in the html.pl file. It should look like the following:

Code:

sub view_goto {
#--------------------------------------------------
# Redirection to short URL.

&html_print_headers;
print "Location: $db_script_link_url&ID=$in{'goto'}&format=long&view_records=1&ww=1\n\n";
exit;
}


Hope this helps.

Regards,

Eliot Lee
Quote Reply
Re: Short URL redirect In reply to
Good one fella !

thanks for all your other mods and help also :)

tom

Quote Reply
Re: Short URL redirect In reply to
I dont know about you guys, but I get a 500 error with your code Eliot.

My question is, what is the &subroutine equivalent to the print location.
Quote Reply
Re: Short URL redirect In reply to
Welp...try the above edited codes! Notice that I changed the print location to a sub call. Then you will have to add a new subroutine WITHOUT printing the header and footer.

Regards,

Eliot Lee

Quote Reply
Re: Short URL redirect In reply to
Thanks, but same effect. The print location code gives us a 2 second delay.

This works much faster:
&html_record_long(&get_record($in{goto}));

I'm all set now, ,thanks :)
Quote Reply
Re: Short URL redirect In reply to
Welp...whatever works. Wink

Regards,

Eliot

Quote Reply
Re: Short URL redirect In reply to
I modify but fail...

I add code to html_home

if ($in{'goto'}) {
print "Location: $db_script_link_url&PhotoID=$in{'goto'}&view_records=1&ww=1\n\n";
exit;
}



sub html_home {
# --------------------------------------------------------
# The database manager home page.

$in{'Userid'}=$db_userid;
$in{'ww'} = 1;
$in{'cs'} = 1;
my ($status, @hits) = &query("view");
if ($status ne "ok") {
#auto send user to add form after signup
print "Location: $db_script_url?db=photo&uid=$db_uid&add_form=1\n\n";
return;
}

else ($in{'goto'}) {
print "Location: $db_script_link_url&PhotoID=$in{'goto'}&&view_records=1&ww=1\n\n";
exit;
}

$page_title = "Main Menu";
&html_page_top;

# < -- Start page text -- >
print qq|
<P>

<$font></font></p>
|;
# < -- End page text -->

&html_footer;
&html_page_bottom;
}

Then in .cgi add code at sub main

elsif ($in{'goto'}) { if {$per_add) { &view_goto; } else { &html_unauth; }}


Then
Then create a new sub called sub view_goto in the html.pl file. It should look like the following:



sub view_goto {
#--------------------------------------------------
# Redirection to short URL.&html_print_headers;
print "Location: $db_script_link_url&PhotoID=$in{'goto'}&&view_records=1&ww=1\n\n";exit;
}

But I got error.
I also try change $db_script_link_url to $db_script_url?db=photo&uid=$db_uid,and it failed aswell.
Any help 'd be appreciated.




Regards,
Act.
I am new to cgi, Thank you for your help.
Quote Reply
Re: Short URL redirect In reply to
I've followed Eliot's instructions and have added Katana Man's first html.pl home lines, but
I get the login screen -- login -- then get sent to the main menu and no search done for me ....

Where should Katana Man's lines be put in ??? before teh $page_title after this area, after the print "view ..." statements or does this really matter at all, or even better yet, do I need these lines.

so, far no errors but no views either, hmmmm . ... I gotta be missing something.

Any help would be appreciated.

PS, act did you get this working?

thanks all

Quote Reply
Re: Short URL redirect In reply to
no, it is not working.I need it indeed.

Regards,
Act.
I am new to cgi, Thank you for your help.
Quote Reply
Re: Short URL redirect In reply to
okay, posting from here will make the threads look strange but I can cut and paste easier ....

Ok, act I did find these:

else ($in{'goto'}) { ----- you have this but I do believe it was supposed to be if ($in .....
did you change this to match the if statement above it ???

and

{ if {$per_add) { &view_goto; } ---- notice that after add it's a parenthesis")" instead of a bracket "}"
I wonder if this is a typo or not, and if it's a typo which is proper ) or } .... I found this, this morning wonder why I got errors, I used a ) but nothing is being passed I wonder if it's supposed to be }

unlike you I'm not new to cgi or perl, I just don't know how to program .... :(

If I get anything going I'll post what ever got it to work, hopefully somebody will come along and inform us.

Quote Reply
Re: Short URL redirect In reply to
act, did you get things working a bit or were you waiting .... Smile

I think I found out a way around all this, first follow Eliot's mod, nothing against Katana Man, just that I couldn't get the frigging print to work in the address/location box to work in either Explorer or Netscape.

OK I did this,

sub view_goto {
#--------------------------------------------------
# Redirection to short URL.
print "Location: $db_script_link_url&Title=$in{'goto'}&view_records=1&ww=on&nh=1&mh=1\n\n";
#exit;
}

and in db.cgi main used:

elsif ($in{'goto'}) { if ($per_view) { &view_goto; } else { &html_unauth; } }

notice: I change the per_add to per_view (does this make a difference ???? I have no idea, I've changed so many different things that I forgot if this actually makes a difference ... like I said I don't know how to code perl .... Frown )

I actually put this sub in db.cgi ... I don't know just seemed logical and took less time to upload versus html.pl

go ahead and read the post in dbman installition forum :::: Logging in via URL (I added a question there too).

I went through all the trouble of adding the extra mods, but I don't think they were necessary and I wasted a whole day on that Frown

I made a extra config file ..... admin.cfg
with this changed to
$auth_no_authentication = 0;

the original default.cfg can stay at
$auth_no_authentication = 1;
for regular users

Call the sub as normal: http://www. I-like-DBMAN.com/cgi-bin/db/db.cgi?goto=3333333

and call the admin as : http://www.I-like-DBMAN.com/cgi-bin/db/db.cgi?db=admin

Sure this is a bit of a hassle but it gets you the best of both worlds.

Permissions can be set the way you like, also check www.jpdeni.com/dbman for more info on that.

Hope this helps somebody.
Quote Reply
Re: Short URL redirect In reply to
LoisC posted her answer for the configuration of using the mods in the DBMAN installation forum.

http://gossamer-threads.com/perl/forum/showflat.pl?Cat=&Board=DBInst&Number=120701&page=0&view=collapsed&sb=5

or for those who don't want to go through the mod process the above should work

Quote Reply
Re: Short URL redirect In reply to
Hi,jdunes

Could you please renew the mod step by step that work! I still get lost.please start it dont refer to above,i really want to get it work.


Regards,
Act.
I am new to cgi, Thank you for your help.
Quote Reply
Re: Short URL redirect In reply to
Act, sorry I still have Katana Man's lines in my html.pl

What I wrote on 23-Jan-01 is pretty much all that I did, I'll try to rewrite this over the weekend just that I got tons to do befoe I can cut and paste all this informaiton again.

sorry, I really don't know perl, I just played with putting things and in here and there and uploaded, uploaded, and uploaded until something worked out.

the post that you put up actually helped me.

Hold on, I'll get back

Quote Reply
Re: Short URL redirect In reply to
OK,re startup all.
in .html I add code below to html_home
if ($in{'goto'}) {
print "Location: $db_script_link_url&ID=$in{'goto'}&view_records=1&ww=on&nh=1&mh=1\n\n";
exit;
}

add new sub
sub view_goto {
#--------------------------------------------------
# Redirection to short URL.
print "Location: $db_script_link_url&ID=$in{'goto'}&view_records=1&ww=on&nh=1&mh=1\n\n";
#exit;
}

add code to db.cgi
elsif ($in{'goto'}) { if ($per_view) { &view_goto; } else { &html_unauth; } }

then I can not success calling short url.


Regards,
Act.
I am new to cgi, Thank you for your help.
Quote Reply
Re: Short URL redirect In reply to
Act sorry for not getting back I got in lots of trouble with a different script and couldn't for the life of me figure out, and still can't Frown

in html_home I have:

print "Location: $db_script_link_url&ID=$in{'goto'}&format=long&view_records=1&ww=1\n\n";

in view_goto i have:

print "Location: $db_script_link_url&TITLE=$in{'goto'}&view_records=1&ww=on&nh=1&mh=1\n\n";

and I call my search with:

http://www.iLIKEdbMAN/cgi-bin/dbman/db.cgi?goto=MARS

These are my differeneces from you .... I don't what the differences are (between what you have and I have). BUT !!!! I wonder what are you searching for ??? I do believe that this calls a search to show the record ... ie, I do a search on my field called """ TITLE """ and use the goto to call record """ MARS """ which is one of my TITLE data.

I hope this helps beyond this I'm totally lost Frown I wish I could help more Frown

goodluck