Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1] 2 3   Go Down

Author Topic: user's album by url http://site.com/gallery/username  (Read 65045 times)

0 Members and 1 Guest are viewing this topic.

newbie

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Posts: 3
    • Hommingberger Gepardenforelle Zucht
user's album by url http://site.com/gallery/username
« 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
« Last Edit: December 16, 2005, 03:25:25 pm by Nibbler »
Logged

Tranz

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Female
  • Posts: 6149
Re: user's album by url http://site.com/gallery/username
« Reply #1 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.
Logged

Nibbler

  • Guest
Re: user's album by url http://site.com/gallery/username
« Reply #2 on: April 05, 2005, 07:50:59 pm »

It is yabbse specific, but can be modded for any bridge or standalone.
Logged

newbie

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Posts: 3
    • Hommingberger Gepardenforelle Zucht
Re: user's album by url http://site.com/gallery/username
« Reply #3 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
Logged

solei

  • Coppermine newbie
  • Offline Offline
  • Posts: 1
Re: user's album by url http://site.com/gallery/username
« Reply #4 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.
Logged

Nibbler

  • Guest
Re: user's album by url http://site.com/gallery/username
« Reply #5 on: July 13, 2005, 02:13:29 am »

Did you change 'gallery' to the actual location of coppermine ?
Logged

nazcar

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 5
Re: user's album by url http://site.com/gallery/username
« Reply #6 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
Logged
(http://www.danasoft.com/sig/nazcar.jpg)

mustang_lex

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 34
    • Stangette.com
Re: user's album by url http://site.com/gallery/username
« Reply #7 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
Logged
Alex
www.stangette.com/showcase
my Coppermine Gallery!

Nibbler

  • Guest
Re: user's album by url http://site.com/gallery/username
« Reply #8 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));
Logged

mustang_lex

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 34
    • Stangette.com
Re: user's album by url http://site.com/gallery/username
« Reply #9 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 as example
Logged
Alex
www.stangette.com/showcase
my Coppermine Gallery!

andrewshu329

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 29
    • sasphotos.net
Re: user's album by url http://site.com/gallery/username
« Reply #10 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
Logged
CPG 1.4.2
Apache 2.0.54
PHP 5.0.5
MySql 4.1

Nibbler

  • Guest
Re: user's album by url http://site.com/gallery/username
« Reply #11 on: December 17, 2005, 09:34:24 am »

If it doesn't exist create it.
Logged

andrewshu329

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 29
    • sasphotos.net
Re: user's album by url http://site.com/gallery/username
« Reply #12 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
Logged
CPG 1.4.2
Apache 2.0.54
PHP 5.0.5
MySql 4.1

Nibbler

  • Guest
Re: user's album by url http://site.com/gallery/username
« Reply #13 on: December 17, 2005, 05:01:28 pm »

Verify your server actually supports mod_rewrite
Logged

andrewshu329

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 29
    • sasphotos.net
Re: user's album by url http://site.com/gallery/username
« Reply #14 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
Logged
CPG 1.4.2
Apache 2.0.54
PHP 5.0.5
MySql 4.1

Tranz

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Female
  • Posts: 6149
Re: user's album by url http://site.com/gallery/username
« Reply #15 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.
Logged

andrewshu329

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 29
    • sasphotos.net
Re: user's album by url http://site.com/gallery/username
« Reply #16 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
Logged
CPG 1.4.2
Apache 2.0.54
PHP 5.0.5
MySql 4.1

mustang_lex

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 34
    • Stangette.com
Re: user's album by url http://site.com/gallery/username
« Reply #17 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

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

Logged
Alex
www.stangette.com/showcase
my Coppermine Gallery!

mustang_lex

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 34
    • Stangette.com
Re: user's album by url http://site.com/gallery/username
« Reply #18 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.
Logged
Alex
www.stangette.com/showcase
my Coppermine Gallery!

Nibbler

  • Guest
Re: user's album by url http://site.com/gallery/username
« Reply #19 on: December 20, 2005, 03:52:27 pm »

You've got your site url setup wrong in config.
Logged
Pages: [1] 2 3   Go Up
 

Page created in 0.032 seconds with 20 queries.