forum.coppermine-gallery.net

No Support => Modifications/Add-Ons/Hacks => Mods: Searching => Topic started by: newbie on April 05, 2005, 07:12:52 pm

Title: user's album by url http://site.com/gallery/username
Post by: newbie on April 05, 2005, 07:12:52 pm
Hi!

I wrote a small addon for cpg132 together with the yabbse bridge
which might be usefull for somebody else ;)

If you change the $sql statement and define $boardurl
it can also be used without the yabbse bridge ;)
(standalone see 3 posts below)

create ../gallery/useralb.php:
Code: [Select]
<?php
define
('IN_COPPERMINE'true);
define('USERALB_PHP'true);
require(
'include/init.inc.php');

$sel_user $_GET['user'];
global 
$CONFIG$UDB_DB_NAME_PREFIX$UDB_DB_LINK_ID;
global 
$lang_register_php;

$sel_user mysql_escape_string($sel_user);

//query yabbse db to get userid:
$sql "SELECT ID_MEMBER FROM "$UDB_DB_NAME_PREFIX YS_TABLE_PREFIX YS_USER_TABLE " " .
       
"WHERE MEMBERNAME = '$sel_user'";

$result db_query($sql$UDB_DB_LINK_ID);
$row mysql_fetch_array($result);


$catid FIRST_USER_CAT $row['ID_MEMBER'];

// Free resultset
mysql_free_result($result);

$url $boardurl ."/gallery/index.php?cat=".$catid;

//redirect user:
header("Location: $url");
?>


and add this to .htaccess:
Code: [Select]
RewriteEngine On
RewriteRule ^gallery/([^\./]+)$ gallery/useralb.php?user=$1

Now users can link to their album by using
http://site.com/gallery/newbie

;)

Bye, newbie
Title: Re: user's album by url http://site.com/gallery/username
Post by: Tranz on April 05, 2005, 07:40:21 pm
Thank you for your contribution. So would this work for a standalone? Sounds like a handy mod. However, you would have to have greater restrictions on allowed characters in usernames since certain characters can cause issues when used in URLs.

Also, could you please work with the latest version, 1.3.2, if you want to contribute mods/hacks? This would ensure that whatever fixes that have been made would be included in your code.

Thank you.
Title: Re: user's album by url http://site.com/gallery/username
Post by: Nibbler on April 05, 2005, 07:50:59 pm
It is yabbse specific, but can be modded for any bridge or standalone.
Title: Re: user's album by url http://site.com/gallery/username
Post by: newbie on April 05, 2005, 08:08:41 pm
This should work for standalone coppermine (untestet, i only use it with yabbse):

Code: [Select]
<?php
define
('IN_COPPERMINE'true);
define('USERALB_PHP'true);
require(
'include/init.inc.php');

// ########################################################
// # set this to your website (gallery must be at $boardurl . "/gallery" or change it below)
$boardurl "http://www.your-server.de";

$sel_user $_GET['user'];
global 
$CONFIG;
global 
$lang_register_php;

$sel_user mysql_escape_string($sel_user);

//query db to get userid:
$sql "SELECT user_id FROM {$CONFIG['TABLE_USERS']} WHERE username = '$sel_user'";

$result db_query($sql$UDB_DB_LINK_ID);
$row mysql_fetch_array($result);


$catid FIRST_USER_CAT $row['user_id'];

// Free resultset
mysql_free_result($result);

$url $boardurl ."/gallery/index.php?cat=".$catid;

//redirect user:
header("Location: $url");
?>


and add this to .htaccess:
Code: [Select]
RewriteEngine On
RewriteRule ^gallery/([^\./]+)$ gallery/useralb.php?user=$1

Upps, sorry it was my mistake. I am running cpg 132 ;)

Bye, newbie
Title: Re: user's album by url http://site.com/gallery/username
Post by: solei on July 13, 2005, 01:59:00 am
I'm having some trouble with the quoted additions to the .htaccess file.

I added:
Code: [Select]
RewriteEngine On
RewriteRule ^gallery/([^\./]+)$ gallery/useralb.php?user=$1
Just as described above, but it does nothing at all.

Any ideas as to why this might be?  I'm running apache2.
Title: Re: user's album by url http://site.com/gallery/username
Post by: Nibbler on July 13, 2005, 02:13:29 am
Did you change 'gallery' to the actual location of coppermine ?
Title: Re: user's album by url http://site.com/gallery/username
Post by: nazcar on October 07, 2005, 10:17:11 am
For cpg.1.3.5 the variable username in mysql is user_name u changes this:

search:

Code: [Select]
$sql = "SELECT user_id FROM {$CONFIG['TABLE_USERS']} WHERE username = '$sel_user'";
change for:

Code: [Select]
$sql = "SELECT user_id FROM {$CONFIG['TABLE_USERS']} WHERE user_name = '$sel_user'";
if u cpg isn´t undes gallery change this:

Code: [Select]
$url = $boardurl ."/gallery/index.php?cat=".$catid;
for this if ur cpg is under root server

Code: [Select]
$url = "/index.php?cat=".$catid;
then u can change .httaccess

Code: [Select]
RewriteRule ^gallery/([^\./]+)$ gallery/useralb.php?user=$1
^gallery is a condicion if u want user write url domain/gallery/user or change it for ej:

http://domain/private ptu private in that condition.

Now u can change gallery/useralb.php?user=$1 if u cpg is under root server only write /useralb.php?user=$1 or put path cpg

Thats All
Title: Re: user's album by url http://site.com/gallery/username
Post by: mustang_lex on December 16, 2005, 04:34:45 am
HAs anyone got this hack working for Vbulletin Bridge. Actually has anyone got this working period. I tried changing the
YS_TABLE_PREFIX . YS_USER_TABLE  to VB_TABLE_PREFIX . VB_USER_TABLE  but I get a There was an error while processing a database query   in coppermine. So it looks like the new PHP file is being utilized but somethings wrong. Oh and I used the original PHP and just changed what I mentioned above
Title: Re: user's album by url http://site.com/gallery/username
Post by: Nibbler on December 16, 2005, 03:23:51 pm
This mod seems more complicated than necessary.

1.3.x (untested):

Code: [Select]
define('IN_COPPERMINE', true);
require('include/init.inc.php');

header('Location: ' . rtrim($CONFIG['ecards_more_pic_target'], '/') .'/index.php?cat='.(get_userid($_GET['user']) + FIRST_USER_CAT));

1.4.x

Code: [Select]
define('IN_COPPERMINE', true);
require('include/init.inc.php');

header('Location: ' . $CONFIG['site_url'] .'index.php?cat='.($cpg_udb->get_user_id($_GET['user']) + FIRST_USER_CAT));
Title: Re: user's album by url http://site.com/gallery/username
Post by: mustang_lex on December 16, 2005, 06:30:18 pm
Nibbler kudos to you!!!!!

Heres for anyone else who wants a working version. Don't matter at all what your bridged too!

Create a file called useralb.php


Code: [Select]
<?php
define
('IN_COPPERMINE'true);
require(
'include/init.inc.php');

header('Location: ' rtrim($CONFIG['ecards_more_pic_target'], '/') .'/index.php?cat='.(get_userid($_GET['user']) + FIRST_USER_CAT));

?>

Save and upload to your root coppermine directory

then add this to your .htaccess file on your root (public_html for me) directory

Code: [Select]
RewriteEngine On
RewriteRule ^gallery/([^\./]+)$ gallery/useralb.php?user=$1

MAKE SURE YOU RENAME both "gallery" to your folder you installed coppermine

Mine works and I run 1.3.X  goto http://www.stangette.com/showcase/Nikki  (http://www.stangette.com/showcase/Nikki) as example
Title: Re: user's album by url http://site.com/gallery/username
Post by: andrewshu329 on December 17, 2005, 09:31:59 am
Please help,
I've created the useralb.php file and put it in my coppermine root. However, there is no .htaccess file that i can find. Im running apache on my server w/ cpg 142.

Thanks in advance.
Andew
Title: Re: user's album by url http://site.com/gallery/username
Post by: Nibbler on December 17, 2005, 09:34:24 am
If it doesn't exist create it.
Title: Re: user's album by url http://site.com/gallery/username
Post by: andrewshu329 on December 17, 2005, 04:02:37 pm
Hi nibbler,
Thanks for helping me, but what I did still doesn't work.
I have my cpg install in a folder named "gallery" in my root directory.

I created a useralb.php file in my gallery folder with the code:

Code: [Select]
<?php
define
('IN_COPPERMINE'true);
require(
'include/init.inc.php');

header('Location: ' $CONFIG['site_url'] .'index.php?cat='.($cpg_udb->get_user_id($_GET['user']) + FIRST_USER_CAT));
?>


I didnt have an htaccess file in my root directory, so I created one with only these two lines of code in it:

Code: [Select]
RewriteEngine On
RewriteRule ^gallery/([^\./]+)$ gallery/useralb.php?user=$1

This still doesn't work, so im pretty sure i mucked it up somewhere, please help.

Thanks a lot.
Andrew
Title: Re: user's album by url http://site.com/gallery/username
Post by: Nibbler on December 17, 2005, 05:01:28 pm
Verify your server actually supports mod_rewrite
Title: Re: user's album by url http://site.com/gallery/username
Post by: andrewshu329 on December 17, 2005, 05:22:06 pm
Hi nibbler,
Thanks again for helping.
I just enabled mod_rewrite, but it still doesnt work.
I suspect its something to do with my htaccess file since all i did was copy paste those two lines of code into notepad and saved as an htaccess file. Do i need anything else other than those two line of code?
I put my htaccess file in  \htdocs, whereas my cpg install is in \htdocs\gallery

Thanks for your time
Andrew
Title: Re: user's album by url http://site.com/gallery/username
Post by: Tranz on December 17, 2005, 05:29:01 pm
Did you name it htaccess or .htaccess. There's a difference and the second one is the correct one.
Title: Re: user's album by url http://site.com/gallery/username
Post by: andrewshu329 on December 17, 2005, 05:32:34 pm
Hi,
The filename is .htaccess and I put it in my root.
Is there anything wrong with the code in it?
 
Code: [Select]
RewriteEngine On
RewriteRule ^gallery/([^\./]+)$ gallery/useralb.php?user=$1

Thanks
Andrew
Title: Re: user's album by url http://site.com/gallery/username
Post by: mustang_lex on December 20, 2005, 03:46:50 pm
Are you sure your useralb.php file is in the gallery root?

If you go to mine and use this link. Although you get an error "No image to display" it shows that it works.
http://www.stangette.com/showcase/useralb.php (http://www.stangette.com/showcase/useralb.php)

I'm just assuming here but if you go to your gallery and try the link below. You get a page cannot be displayed error.
Seems like its either not rename correctly or not in the folder or not CHMOD to at least 644

http://www.sasphotos.net/gallery/useralb.php (http://www.sasphotos.net/gallery/useralb.php)

Title: Re: user's album by url http://site.com/gallery/username
Post by: mustang_lex on December 20, 2005, 03:48:52 pm
Also make sure its all lowercase and not useralb.php.txt . Sometimes text editors will do that

I also noticed that http://www.sasphotos.net/gallery/ link doesn't work correctly. your index.php doesn't open up? It goes to a directory tree instead.
Title: Re: user's album by url http://site.com/gallery/username
Post by: Nibbler on December 20, 2005, 03:52:27 pm
You've got your site url setup wrong in config.
Title: Re: user's album by url http://site.com/gallery/username
Post by: Nibbler on December 20, 2005, 04:00:52 pm
http://forum.coppermine-gallery.net/index.php?topic=24217.0
Title: Re: user's album by url http://site.com/gallery/username
Post by: andrewshu329 on December 20, 2005, 08:05:34 pm
Thanks for helping me out everyone, I'm still fairly new to all this.

I forgot to change things around in config after upgrading so I just did that now.

In config, I typed for the fields
URL of your coppermine gallery folder: http://www.sasphotos.net/gallery/
URL of your home page: /gallery/index1.php

The link
http://www.sasphotos.net/gallery/useralb.php (http://www.sasphotos.net/gallery/useralb.php)
works now.

However, typing in a link such as
http://www.sasphotos.net/gallery/andrew (http://www.sasphotos.net/gallery/andrew)
still doesn't.

So my useralbs.php file shouldnt have any problems, my .htaccess file is ok, mod_rewrite is already enabled, where else could there be a problem?

I'm not sure if I should ask two questions in the same thread, but..does anyone know why http://www.sasphotos.net/gallery/ (http://www.sasphotos.net/gallery/) doesn't forward to the index1.php file (my home page) or even the default index.php file?

Thanks everyone!

PS: Thanks for the heads up nibbler.
Title: Re: user's album by url http://site.com/gallery/username
Post by: Nibbler on December 20, 2005, 08:20:21 pm
OK, do a test. Temporarily change the line in your .htaccess to

Code: [Select]
RewriteRule ^.*$ http://www.google.com
If nothing happens then, it means your .htaccess file is not even being read. If you do get directed with that code, then the file just needs tweaking.
Title: Re: user's album by url http://site.com/gallery/username
Post by: andrewshu329 on December 20, 2005, 08:29:33 pm
Hi nibbler,
I just saved the changes and nothing happens.
www.sasphotos.net (http://www.sasphotos.net)

This is what's in my .htaccess file:
Code: [Select]
RewriteEngine On
RewriteRule ^.*$ http://www.google.com

Thanks,
Andrew
Title: Re: user's album by url http://site.com/gallery/username
Post by: Nibbler on December 20, 2005, 08:34:56 pm
Right, so it's matter of server setup in that case.
Title: Re: user's album by url http://site.com/gallery/username
Post by: Scenemusic on December 30, 2005, 04:54:30 pm
well

i added the code and the .htaccess

I have a gallery under the username Christophe.

Coppermine is in a directory called photobook, the alias set is http://www.linkedscene.com/photo/

if i use

Code: [Select]
RewriteRule ^.*$ http://www.google.com
it works fine and i go immediatly to google.

if i use

Code: [Select]
RewriteRule ^photo/([^\./]+)$ photo/useralb.php?user=$1
it doesn't work (The requested URL /photo/christophe/ was not found on this server).

any idea ?  ???
Title: Re: user's album by url http://site.com/gallery/username
Post by: AWJunkies on January 15, 2006, 03:15:04 pm
Quote
I am getting same problems as Scenicmusic. I know it is an issue with the .htaccess file and the redirect. I can manuely put in:
http://www.allwheelphotos.com/cpg143/useralb.php?user=AWJunkies  and it will go to my gallery (so the php file is correct and functional). SO why does it not work when I put in: http://www.allwheelphotos.com/cpg143/AWJunkies  ?? I have tried putting the .htaccess file in root directory of coppermine install which would be (public_html/cpg143/) and I have tried putting it in the (public_html) niether are working but your test with the google .htaccess file works in both of these sections.

Stand alone 1.4.3 Stable

----------------------------------------------------------------------------------------------
I got it to work! Dam awesome mod! Thanks guys. Put the .htaccess file with the following code:

RewriteEngine On
RewriteRule ^([^\./]+)$ useralb.php?user=$1

under your coppermine root directory (public_html/gallery) or (public_html/photos) or in my case (public_html/cpg143)
Hope this helps some of the people who are having issues or would be.

I also have a LOT of mods to share with the community and I will get to it in due time. 

--------------------------------------------------------------------------------------------------------------------------------------
NOW to go even further I changed the .htaccess file too:

RewriteEngine On
RewriteRule ^([^\./]+)$ cpg143/useralb.php?user=$1

and put it into my root directory on server being public_html. This causes http://www.allwheelphotos.com/AWJunkies link to the album for that user rather then having them put in copermine directory. MUCH easier and better for user and looks better. Hope this helps some people as well :)
Title: Re: user's album by url http://site.com/gallery/username
Post by: andrewshu329 on January 16, 2006, 12:41:47 pm
Hi everyone,
I decided to stop tinkering with .htaccess files and just used the apache config file.
Anyways, now it works as advertised.

However, I was wondering if i can make it so that after typing www.mysite.com/username, the url displayed in the box would remain www.mysite.com/username, instead of immediately changing to something like www.mysite.com/gallery/index.php?cat=10037. Also, so that browsing to the user Gallery through the album list view and such would change the displayed url automatically to www.mysite.com/username, and would remain so as long as the viewer is in that user's gallery.

Thanks.
Andrew
Title: Re: user's album by url http://site.com/gallery/username
Post by: dEnA on February 13, 2006, 03:52:38 pm
/useralb.php?user=USERNAME
works for me, but when I try putting the .htaccess file to my server it immediately comes an "500 Internal server error" to the whole site.
No matter whats in that htaccess and where it is. Please help me
thanks
"dEnA"
Title: Re: user's album by url http://site.com/gallery/username
Post by: dEnA on February 18, 2006, 07:18:01 pm
Ok so that solved out to be because of I dont have mod_rewrite and it cant be enabled cause of security issues...
But why doesnt it work to put the php code in the gallerys index.php.
That would make the url to the usergallery more easy
Title: Re: user's album by url http://site.com/gallery/username
Post by: Joachim Müller on February 19, 2006, 11:11:52 am
if you don't have mod_rewrite, then there can't be a feature like that, no workaround possible.
Title: Re: user's album by url http://site.com/gallery/username
Post by: dEnA on February 19, 2006, 06:42:37 pm
Yes, but i meant the useralb.php's code.
Why cant it be put in the gallerys index.
That would make the url to ../gallery?user=USERNAME instead of ../gallery/useralb.php?user=USERNAME
Title: Re: user's album by url http://site.com/gallery/username
Post by: Joachim Müller on February 20, 2006, 12:38:01 am
no difference, the URL will not be any more search engine friendly either way round. If you need that feature, code it. Won't be helpful, as it's not easier to memorize nor more attractive for search engine spiders. Anyway, your question doesn't belong to this thread, please stop replying to it.
Title: Re: user's album by url http://site.com/gallery/username
Post by: dj_wpa on March 05, 2006, 03:55:03 am
Has anyone tried this using IIS on a Windows 2000 server?
Title: Re: user's album by url http://site.com/gallery/username
Post by: Tranz on March 05, 2006, 04:06:50 am
This mod requires using .htaccess, which is specific to apache. You would need to search around to see how to use mod rewrite in IIS.
Title: Re: user's album by url http://site.com/gallery/username
Post by: Dr Preacox on May 28, 2006, 09:28:58 am
Okay well here I go making things hard for myself,

Since my gallery doesn't use private user albums but a Huge public Gallery I needed to modd my code a bit so I changed the following and encountered some problems, just wondering if you could please help.

Useralb.php, now what I have edited in here is I have changed index.php?cat= to profile.php?uid= now the first problem I encounter is, as well as getting the userid I also get 100 before it, which I think is the + FIRST_USER_CAT part of the code, but I cant seem to remove it and get it too work. so is this possible?
Code: [Select]
<?php
define
('IN_COPPERMINE'true);
require(
'include/init.inc.php');

header('Location: ' rtrim($CONFIG['ecards_more_pic_target'], '/') .'/profile.php?uid='.(get_userid($_GET['user']) + FIRST_USER_CAT));

?>

And my .Htaccess
Code: [Select]
RewriteEngine On
RewriteRule ^gallery/([^\./]+)$ gallery/useralb.php?user=$1


also I was wondering if in .htaccess I could make the Url as http://USERNAME.dc-6.com and just have it link to http://www.dc-6.com/gallery/profile.php?userid=USERID

if someone could help me with this I will roll it into a short mod and post it for others,
Title: Re: user's album by url http://site.com/gallery/username
Post by: bitcloud on November 26, 2006, 02:28:44 pm
Regarding andrewshu329's idea:
Having "gallery.com/username" staying in the location bar instead of redirecting immediately to "gallery.com/profile.php?uid=1"

I have heard of a "blind redirect"
I don't how anything about this mythical beast, but if anyone's ever set up a blind redirect to keep the location bar displaying "/username", that would be the next logical step for this mod...

anyone know if this is possible?
Title: Re: user's album by url http://site.com/gallery/username
Post by: bitcloud on November 26, 2006, 02:45:35 pm
Edit: This mod is actually a blind redirect as it is - only it doesn't work that way.

Example:
Code: [Select]
RewriteRule ^gallery$ http://www.gallery.com/thumbnails.php?album=3works fine and you'll be left at gallery.com/gallery

but this mod rewrite rules don't leave you at the username, but instead leave you at the dynamic profile.php URL...

any clues on getting this mod to work the same way as a standard blind redirect?
Title: Re: user's album by url http://site.com/gallery/username
Post by: Nibbler on November 26, 2006, 05:30:24 pm
You can probably do that with a RewriteMap.
Title: Re: user's album by url http://site.com/gallery/username
Post by: bitcloud on November 27, 2006, 06:34:31 am
thanks a heap nibbler... You're always exceptionally helpful - it doesn't go unappreciated...
If I could mod you, you'd have more karma than big mac has calories...

I'll look into it and post my results here
Title: Re: user's album by url http://site.com/gallery/username
Post by: bitcloud on March 27, 2007, 06:44:22 pm
This mod works great, but I have a small problem...
My users are only allowed one gallery, so, while this mod works perfectly, it would be much better if it linked directly to the first (or only) gallery in the album... The only issue is that this gallery isn't based on the UID like the album page, but the number of galleries created before it...

can anyone suggest any way of modding this mod to link directly to the first/only gallery for any given UID?

(incidentally I had no luck with the rewritemap issue to keep the address in the address bar)
Title: Re: user's album by url http://site.com/gallery/username
Post by: raqkp on April 13, 2007, 11:19:29 pm
Great mod, but what do you do if the username has a period in it? (e.g. first.last)

Is there a way to redirect everything after "gallery" with no slash that doesn't end in ".php"? In other words, redirect for every character, including the period, as long as it isn't part of ".php".

I've tried:
Code: [Select]
([^\<\.php\>/]+)$
but it doesn't work right. Any help would be appreciated, thanks :)
Title: Re: user's album by url http://site.com/gallery/username
Post by: Nibbler on April 13, 2007, 11:33:46 pm
Best way is to adopt a different system such as http://site.com/gallery/members/username - then it can't interfere with anything else and you can use a looser regex.
Title: Re: user's album by url http://site.com/gallery/username
Post by: bradenkeith on December 14, 2007, 01:17:18 am
RewriteEngine On
RewriteRule ^([^\./]+)$ useralb.php?user=$1

This worked for me as well. Thanks. Spectacular!
Title: Re: user's album by url http://site.com/gallery/username
Post by: sharif_aly on December 28, 2007, 01:57:11 am
Is this will be added or added to coppermine new versions ?
Title: Re: user's album by url http://site.com/gallery/username
Post by: Joachim Müller on December 28, 2007, 10:43:42 am
Not scheduled. Probably not.
Title: Re: user's album by url http://site.com/gallery/username
Post by: dke on January 23, 2008, 04:21:23 pm
Wonderful modification, thank you.
Title: Re: user's album by url http://site.com/gallery/username
Post by: mommaroodles on December 10, 2008, 12:14:17 pm
Hi All

I've gone over this thread how many times now and I cant seem to get this too work :(

I'm hosting a site that has the following on server:

Apache 2.2.9
PHP 5.2.5
MYSQL 5.0.51a
Coppermine  v1.4.19 - which is installed at http://mydomain.com

I created the useralb.php page and it contains the following and uploaded it to public_html/ folder

Code: [Select]
<?php
define
('IN_COPPERMINE'true);
require(
'include/init.inc.php');

header('Location: ' rtrim($CONFIG['ecards_more_pic_target'], '/') .'/index.php?cat='.(get_userid($_GET['user']) + FIRST_USER_CAT));
?>

then I created the .htaccess file which is also uploaded to the public_html folder

Code: [Select]
RewriteEngine On
RewriteRule ^([^\./]+)$ useralb.php?user=$1

I have a category called "User Galleries" and it contains an album called "test20", however, when I browse to the album it shows up as http://www.mydomain.com/index.php?cat=10005 and not http://www.mydomain.com/test20

I really would like to have this feature working, could someone please help tell me what I'm not doing or should be doing.

I'd really appreciate the assistance.

Regards
mommaroodles
Title: Re: user's album by url http://site.com/gallery/username
Post by: mommaroodles on December 10, 2008, 01:47:48 pm
Hi

I have misunderstood this entire thread - I've been under the impression that after applying the changes the url would remain as http://mydomain.com/test20 instead of reverting to http://mydomain.com/index.php?cat=10005. 

I do have this working.  If I type into the browser's address bar http://mydomain.com/test20 it does go to the users gallery.

Many thanks to those involved for making this possible. :)

Regards
mommaroodles