forum.coppermine-gallery.net
No Support => Modifications/Add-Ons/Hacks => Mods: Searching => Topic started 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:
<?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:
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
-
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.
-
It is yabbse specific, but can be modded for any bridge or standalone.
-
This should work for standalone coppermine (untestet, i only use it with yabbse):
<?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:
RewriteEngine On
RewriteRule ^gallery/([^\./]+)$ gallery/useralb.php?user=$1
Upps, sorry it was my mistake. I am running cpg 132 ;)
Bye, newbie
-
I'm having some trouble with the quoted additions to the .htaccess file.
I added:
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.
-
Did you change 'gallery' to the actual location of coppermine ?
-
For cpg.1.3.5 the variable username in mysql is user_name u changes this:
search:
$sql = "SELECT user_id FROM {$CONFIG['TABLE_USERS']} WHERE username = '$sel_user'";
change for:
$sql = "SELECT user_id FROM {$CONFIG['TABLE_USERS']} WHERE user_name = '$sel_user'";
if u cpg isn´t undes gallery change this:
$url = $boardurl ."/gallery/index.php?cat=".$catid;
for this if ur cpg is under root server
$url = "/index.php?cat=".$catid;
then u can change .httaccess
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
-
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
-
This mod seems more complicated than necessary.
1.3.x (untested):
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
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));
-
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
<?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
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
-
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
-
If it doesn't exist create it.
-
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:
<?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:
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
-
Verify your server actually supports mod_rewrite
-
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
-
Did you name it htaccess or .htaccess. There's a difference and the second one is the correct one.
-
Hi,
The filename is .htaccess and I put it in my root.
Is there anything wrong with the code in it?
RewriteEngine On
RewriteRule ^gallery/([^\./]+)$ gallery/useralb.php?user=$1
Thanks
Andrew
-
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)
-
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.
-
You've got your site url setup wrong in config.
-
http://forum.coppermine-gallery.net/index.php?topic=24217.0
-
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.
-
OK, do a test. Temporarily change the line in your .htaccess to
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.
-
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:
RewriteEngine On
RewriteRule ^.*$ http://www.google.com
Thanks,
Andrew
-
Right, so it's matter of server setup in that case.
-
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
RewriteRule ^.*$ http://www.google.com
it works fine and i go immediatly to google.
if i use
RewriteRule ^photo/([^\./]+)$ photo/useralb.php?user=$1
it doesn't work (The requested URL /photo/christophe/ was not found on this server).
any idea ? ???
-
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 :)
-
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
-
/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"
-
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
-
if you don't have mod_rewrite, then there can't be a feature like that, no workaround possible.
-
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
-
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.
-
Has anyone tried this using IIS on a Windows 2000 server?
-
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.
-
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?
<?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
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,
-
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?
-
Edit: This mod is actually a blind redirect as it is - only it doesn't work that way.
Example:
RewriteRule ^gallery$ http://www.gallery.com/thumbnails.php?album=3
works 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?
-
You can probably do that with a RewriteMap.
-
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
-
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)
-
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:
([^\<\.php\>/]+)$
but it doesn't work right. Any help would be appreciated, thanks :)
-
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.
-
RewriteEngine On
RewriteRule ^([^\./]+)$ useralb.php?user=$1
This worked for me as well. Thanks. Spectacular!
-
Is this will be added or added to coppermine new versions ?
-
Not scheduled. Probably not.
-
Wonderful modification, thank you.
-
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
<?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
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
-
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