Gossamer Forum
Home : Products : Others : Gossamer Community :

Redirect bug when using different template?

Quote Reply
Redirect bug when using different template?
When using the following URL:
http://mysite.com/cgi-bin/gcomm/community.cgi?do=user_profile;t=mytmpl
GComm is displaying the original template, instead of the 'mytmpl' template defined on previous page.
Redirected URL is:
http://mysite.com/cgi-bin/gcomm/community.cgi?url=http%3A%2F%2Fmysite.com%2Fcgi-bin%2Fgcomm%2Fcommunity.cgi%3Fdo%3Duser_profile%3Bt%3Dmytmpl

Well, the redirect URL is good, but the displayed template not.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...

Last edited by:

webmaster33: Jul 16, 2004, 1:53 PM
Quote Reply
Re: [webmaster33] Redirect bug when using different template? In reply to
Any solutions for this issue yet?

Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.
Quote Reply
Re: [ManuGermany] Redirect bug when using different template? In reply to
No, yet.
I'm middle of a development. But if I fix it or find a workaround, I will post it.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [ManuGermany] Redirect bug when using different template? In reply to
Furthermore, there is one more bug, when changing a bit the originating url
by renanimg community.cgi to my.cgi.

When using the following URL:
http://mysite.com/cgi-bin/gcomm/my.cgi?do=user_profile;t=mytmpl
GComm is displaying the original template, instead of the 'mytmpl' template defined on previous page.
Redirected URL is:
http://mysite.com/cgi-bin/gcomm/community.cgi?url=http%3A%2F%2Fmysite.com%2Fcgi-bin%2Fgcomm%2Fmy.cgi%3Fdo%3Duser_profile%3Bt%3Dmytmpl


So the redirected cgi script is still community.cgi, while I would like to use my.cgi instead of it.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [ManuGermany] Redirect bug when using different template? In reply to
I made the fix.
Will post soon... typing...

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [ManuGermany] (FIX) Redirect bug when using different template In reply to
The fix is finished.
There may be possible to create better fix, but this one had the least changes in the core code.

Note: The fix is ONLY for GCommunity v1.0.2 release!!!
It fixes the "template" & "renamed community.cgi" problems after some URL redirect points of GCommunity, i.e. when displaying pages: logout page, signup page, login page, user profile page.

Warning: The code was not really tested yet, so may be possible that may change some behaviours of GCommunity which I did not test (for example when using remotely, on different domains & subdomains).
The profile page was tested, the others was not.
So make backup of your code, before doing the changes!

Deleted code parts are highlighted by BLUE, added code parts are by RED.

Change 'user_profile' subroutine code in \private\lib\Community\Web\User.pm file to following code.
Code:
sub user_profile {
# -------------------------------------------------------------------
my $user = _authenticate();
if (! $user) {
# my $url = $CFG->{path_cgi_url} . '?' . $IN->query_string; # Original
my $url = $IN->url( query_string => 1, absolute => 1 ); # Fix by Webmaster33
my $redirect_url = comm_login_url( return_to => $url );
my $template = $IN->param('t'); # Fix by Webmaster33
if ($template) { # Fix by Webmaster33
$redirect_url .= ";t=" . $template; # Fix by Webmaster33
} # Fix by Webmaster33

print $IN->redirect($redirect_url);
return;
}
if (! $IN->param('user_profile_submit')) {
return ('user_profile.html', $user);
}


# Take the list of restricted profile fields
# and convert it into a hashref that can be used as a lookup
# to quickly determine matches.
my $restricted_fields = { map {($_=>1)} @{$CFG->{signup_restricted_profile}} };

my $cgi = $IN->get_hash;
foreach my $key (keys %$cgi) {
next unless ($key =~ /^prof_/);

# Do not accept any column names that are noted in the signup_restricted_profile option
next if $restricted_fields->{$key};

if ($key =~ /(.*)-(?:day|mon|year)$/) {
my $col = $1;
$user->{$col} = $cgi->{"$col-year"} . "-" . $cgi->{"$col-mon"} . "-" . $cgi->{"$col-day"};
$IN->param($col, $user->{$col});
}
else {
$user->{$key} = $cgi->{$key};
}
}

# If we are updating the password, we need to do a few more steps.
my $new_pass = $cgi->{comm_password_new};
my $new_confirm = $cgi->{comm_password_new_confirm};
my $orig_pass = $cgi->{comm_password_orig};
$new_pass =~ s/^\s*|\s*$//g;
$new_confirm =~ s/^\s*|\s*$//g;
$orig_pass =~ s/^\s*|\s*$//g;

require Community::User;
if ($new_pass and $new_pass =~ /\S+/) {
if ($new_pass ne $new_confirm) {
$user->{error} = comm_language('SIGNUP_CONFIRM_PASS');
return ('user_profile.html', $user);
}
elsif ( my $error = Community::User::cuser_pw_validate_error($new_pass) ) {
$user->{error} = comm_language( $error );
return ('user_profile.html', $user);
}
local $^W; # Would be much uglier to test definedness on all these for little gain.
if ($orig_pass and (
($orig_pass eq $user->{comm_clr_pass}) or
(comm_compare_pass($orig_pass, $user->{comm_password})) or
($user->{comm_tmp_pass} and comm_compare_pass($orig_pass, $user->{comm_tmp_pass}))))
{
if ($CFG->{system_store_clear_pass}) {
$user->{comm_clr_pass} = $new_pass;
}
$user->{comm_password} = comm_encrypt($new_pass);
comm_debug("user |$user->{comm_username}| changed password.") if ($CFG->{debug});
}
else {
comm_debug("user |$user->{comm_username}| password change failed.") if ($CFG->{debug});
$user->{error} = comm_language('PROFILE_CONFIRM_PASS');

return ('user_profile.html', $user);
}
}

# If we are changing our email address, verify it if requested.
my $orig_email = $user->{comm_email};
my $new_email = $IN->param('comm_email');
if ($orig_email ne $new_email) {
my $error = Community::User::cuser_email_validate_error($new_email);
if ($error) {
comm_debug("unable to update to new email |$new_email|: $error");

$user->{error} = comm_language($error, $new_email);
return ('user_profile.html', $user);
}
if ($CFG->{signup_validate_email}) {
my $error = Community::User::cuser_email_validate_error($new_email);
if ($error) {

return ('user_profile.html', { error => comm_language($error, $new_email)});
}
$user->{comm_email_code} = _generate_email_code();
$user->{comm_email_tmp} = $new_email;
$user->{verify} = 1;
}
else {
$user->{comm_email} = $new_email;
}
}

# We don't use cuser_update as a regular user can't update application settings, the
# application must handle it's own setting changes.
local $GT::SQL::ERRORS->{ILLEGALVAL} = comm_language('SIGNUP_ILLEGALVAL');
local $GT::SQL::ERRORS->{UNIQUE} = comm_language('SIGNUP_UNIQUE');
local $GT::SQL::ERRORS->{NOTNULL} = comm_language('SIGNUP_NOTNULL');

my $res = Community::User::cuser_update($user);
if (! $res) {
comm_debug("user |$user->{comm_username}| profile updated failed: |$GT::SQL::error|") if ($CFG->{debug});
$user->{error} = $GT::SQL::error;

return ('user_profile.html', $user);
}
if ($user->{verify}) {
comm_debug("user |$user->{comm_username}| email change request sent to |$new_email| with |$user->{comm_email_code}| code.") if ($CFG->{debug});
send_email('user_email_change.eml', $user);
}
comm_debug("user |$user->{comm_username}| profile updated") if ($CFG->{debug});
$user->{success} = 1;

return ('user_profile.html', $user);
}


Change 'comm_login_url' subroutine code in \private\lib\Community.pm file to following code.
Code:
sub comm_login_url {
# -------------------------------------------------------------------
my $opts = ref $_[0] eq 'HASH' ? shift : { @_ };
my $return = delete $opts->{return_to};
if (keys %$opts) {
comm_fatal("comm_login_url: invalid arguments passed to comm_login_url: " . join(",", keys %$opts));
}
# my $url = $CFG->{path_cgi_url}; # Original
my $url = (split('\?', $ENV{REQUEST_URI}))[0]; # Fix by Webmaster33
if ($return) {
$url .= "?url=" . $IN->escape($return);
}
return $url;
}


Change 'comm_signup_url' subroutine code in \private\lib\Community.pm file to following code.
Code:
sub comm_signup_url {
# -------------------------------------------------------------------
my $opts = ref $_[0] eq 'HASH' ? shift : { @_ };
my $return = delete $opts->{return_to};
if (keys %$opts) {
comm_fatal("comm_signup_url: invalid arguments passed to comm_signup_url: " . join(",", keys %$opts));
}
# my $url = $CFG->{path_cgi_url} . '?do=user_signup'; # Original
my $url = (split('\?', $ENV{REQUEST_URI}))[0] . '?do=user_signup'; # Fix by Webmaster33

if ($return) {
$url .= ";url=" . $IN->escape($return);
}
return $url;
}


Change 'comm_logout_url' subroutine code in \private\lib\Community.pm file to following code.
Code:
sub comm_logout_url {
# -------------------------------------------------------------------
# return $CFG->{path_cgi_url} . '?do=user_logout'; # Original
return (split('\?', $ENV{REQUEST_URI}))[0] . '?do=user_logout'; # Fix by Webmaster33
}


As I wrote already, the code was not really tested, so I may post further updates/changes later if needed.
But at the moment that's all.
Report any problem in this thread.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [ManuGermany] Redirect bug when using different template? In reply to
Let me know if anybody tried the fix.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [ManuGermany] Redirect bug when using different template? In reply to
As I mentioned earlier, unfortunately the fix causes several problems, when using it between LSQL & GComm both on different domains.
So I recommend not to use this fix until I create a better solution... Sorry Frown

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] Redirect bug when using different template? In reply to
Hi,

Thanks for the bug reports. For the first issue (where template set is not being passed back to community page), a fix could be to edit Community.pm with the following patch:

Code:
Index: Community.pm
===================================================================
RCS file: /usr/local/gossamer/community/private/lib/Community.pm,v
retrieving revision 1.39
diff -u -r1.39 Community.pm
--- Community.pm 10 Jun 2004 23:06:39 -0000 1.39
+++ Community.pm 23 Sep 2004 22:05:55 -0000
@@ -355,6 +355,10 @@
if ($return) {
$url .= "?url=" . $IN->escape($return);
}
+ if ($IN->param('t')) {
+ my $set = $IN->escape($IN->param('t'));
+ $url .= $return ? ";t=$set" : "?t=$set";
+ }
return $url;
}

@@ -369,12 +373,21 @@
if ($return) {
$url .= ";url=" . $IN->escape($return);
}
+ if ($IN->param('t')) {
+ my $set = $IN->escape($IN->param('t'));
+ $url .= $return ? ";t=$set" : "?t=$set";
+ }
return $url;
}

sub comm_logout_url {
# -------------------------------------------------------------------
- return $CFG->{path_cgi_url} . '?do=user_logout';
+ my $url = $CFG->{path_cgi_url} . '?do=user_logout';
+ if ($IN->param('t')) {
+ my $set = $IN->escape($IN->param('t'));
+ $url .= ";t=$set";
+ }
+ return $url;
}

sub comm_get_profile {

As for it returning community.cgi instead of my.cgi, that should just be a matter of updating the config and setting path_cgi_url properly.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Redirect bug when using different template? In reply to
Quote:
For the first issue (where template set is not being passed back to community page), a fix could be to edit Community.pm with the following patch
Thanks for the fix!

Quote:
As for it returning community.cgi instead of my.cgi, that should just be a matter of updating the config and setting path_cgi_url properly.
Well, for LinksSQL there is possible to copy add.cgi, etc to another.cgi script name (e.g. a translated one), while I can keep original add.cgi. Unfortunately, this is not possible in GCommunity, since {path_cgi_url} contains the full script path, including script name.
Thus if I rename community.cgi to another.cgi in {path_cgi_url}, then community.cgi will be no longer well usable, because if we call community.cgi will be redirected to another.cgi soon.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [Alex] Redirect bug when using different template? In reply to
Hi Alex

I am successfully using GComm from a number of GLinks 3.x installations. The redirect for login works fine but I can't get the redirect for logout to work. It only needs to use the default (luna) template set.

Thanks