forum.coppermine-gallery.net

No Support => Modifications/Add-Ons/Hacks => Mods: Searching => Topic started by: Kfmook on November 17, 2003, 09:40:02 am

Title: short url to user albums
Post by: Kfmook on November 17, 2003, 09:40:02 am
I cant post in 'Modifications/Add-Ons/Hacks' and i post my hack here

With this hack your registered users can access to her albuma with short url:
http://www.domain.com/gallery/?UserName
where http://www.domain.com/gallery/ - url to your gallery
UserName - registered user name (if UserName not contain '=')

hack:
add this code:
Code: [Select]
$qq=$HTTP_SERVER_VARS["QUERY_STRING"];
if (!strstr($qq,'=') and !empty($qq)) {
  $sql = "SELECT user_id " . "FROM {$CONFIG['TABLE_USERS']} " . "WHERE user_name = '". mysql_escape_string($qq) . "'";
  $result1 = db_query($sql);
  if (mysql_num_rows($result1)>0) {
    $u = mysql_fetch_array($result1);
    $HTTP_GET_VARS['cat'] = sprintf("1%04d",$u[0]);
  }
  mysql_free_result($result1);
}
before:
Code: [Select]
/**
 * Main code
 */

if (isset($HTTP_GET_VARS['page'])) {
    $PAGE = max((int)$HTTP_GET_VARS['page'], 1);
    $USER['lap'] = $PAGE;
} elseif (isset($USER['lap'])) {
    $PAGE = max((int)$USER['lap'], 1);
} else {
    $PAGE = 1;
}
in index.php
Title: HACK: short url to user albums
Post by: Joachim Müller on November 17, 2003, 08:27:12 pm
moved to Modifications/Add-Ons/Hacks/

Thanks for your contribution

GauGau
Title: HACK: short url to user albums
Post by: MaThIbUs on November 19, 2003, 10:36:56 pm
great! can this be included in a feature version of Coppermine? (1.2.1 or maybe even 1.3?)
Title: HACK: short url to user albums
Post by: jdbaranger on November 21, 2003, 10:58:14 pm
To accept names with a space, modify the script :

Code: [Select]
$qq=$HTTP_SERVER_VARS["QUERY_STRING"];
if (!strstr($qq,'=') and !empty($qq)) {
  $qq = eregi_replace ( '%20', ' ', $qq);
  $sql = "SELECT user_id " . "FROM {$CONFIG['TABLE_USERS']} " . "WHERE user_name = '". mysql_escape_string($qq) . "'";
  $result1 = db_query($sql);
  if (mysql_num_rows($result1)>0) {
    $u = mysql_fetch_array($result1);
    $HTTP_GET_VARS['cat'] = sprintf("1%04d",$u[0]);
  }
  mysql_free_result($result1);
}  


Jean-Denis Baranger
Title: HACK: short url to user albums
Post by: MaThIbUs on November 22, 2003, 09:37:13 pm
and this replaces all weird characters by its URL code :)

**removed**
Title: HACK: short url to user albums
Post by: Joachim Müller on November 23, 2003, 02:17:04 am
above code is a nice try, but not recommended: there are very simple php commands that accomplish the very same with only two lines of code and a fraction of script load (read: much faster).
Instead, the usage of "Characters forbidden in filenames" from the coppermine config screen is advisable or rawurlencode (http://www.php.net/rawurlencode)...

GauGau
Title: HACK: short url to user albums
Post by: MaThIbUs on November 23, 2003, 12:21:36 pm
woops!

as you all know i'm a beginner at php :?

can anyone code this then?
Title: HACK: short url to user albums
Post by: FishnReef on December 18, 2003, 03:49:36 am
I can't make this mod work  :?   I just keep getting a critical error.

Thanks in advance.
Title: HACK: short url to user albums
Post by: FishnReef on December 18, 2003, 03:54:16 am
Maybe it is because Im using the gallery with phpbb. Is there a way to make it work?

Thanks ind advance ;)
Title: HACK: short url to user albums
Post by: Joachim Müller on December 18, 2003, 12:47:33 pm
please post your actual error message, might help solving this. I guess this is not related to the question "bbs-integration yes/no".

GauGau
Title: HACK: short url to user albums
Post by: FishnReef on December 19, 2003, 07:35:01 pm
Error crítico
There was an error while processing a database query
 


The integration works perfectly, this is the only problem I have had.

 :D
Title: HACK: short url to user albums
Post by: Joachim Müller on December 20, 2003, 07:38:56 am
you'll have to switch on debug_mode (and it'd be nice if you could switch to english momentarily as well) - copy and paste the debug output into this thread.

GauGau
Title: HACK: short url to user albums
Post by: MaThIbUs on December 30, 2003, 06:38:29 pm
Code: [Select]
$qq=$HTTP_SERVER_VARS["QUERY_STRING"];
if (!strstr($qq,'=') and !empty($qq)) {
  $qq = urlencode($qq)
  $sql = "SELECT user_id " . "FROM {$CONFIG['TABLE_USERS']} " . "WHERE user_name = '". mysql_escape_string($qq) . "'";
  $result1 = db_query($sql);
  if (mysql_num_rows($result1)>0) {
    $u = mysql_fetch_array($result1);
    $HTTP_GET_VARS['cat'] = sprintf("1%04d",$u[0]);
  }
  mysql_free_result($result1);
}


/m_aTh!bUs
Title: HACK: short url to user albums
Post by: achtungbaby on January 07, 2004, 03:47:25 am
Hello, will this hack work with subdomains?
Title: HACK: short url to user albums
Post by: ferlo on January 08, 2004, 01:53:45 pm
I've tried this mod, and seems working smooth (the one from MaThIbUs)
however, if someone posts a wrong name this error appears:

Code: [Select]
Parse error: parse error in /home/virtual/site15/fst/var/www/html/index.php on line 505
Title: HACK: short url to user albums
Post by: MaThIbUs on January 09, 2004, 07:33:41 pm
achtungbaby > why don't you just try and let us know if it worked ;)?

ferlo > I think it won't be easy to add a error handling feature... Just make sure that everyone uses the right names ;)
Title: HACK: short url to user albums
Post by: ferlo on January 09, 2004, 07:44:01 pm
I see.
However if something does not works I just hope users will try to access my site by the main page )
Title: HACK: short url to user albums
Post by: gmarik on January 17, 2004, 02:26:38 pm
great - so this works on the lates version as well?
will try to get it with vbulletin as well ...
Title: HACK: short url to user albums
Post by: SlammedDime on February 18, 2004, 02:02:43 am
Error checking code -

Code: [Select]
$qq=$HTTP_SERVER_VARS["QUERY_STRING"];
 if (!strstr($qq,'=') and !empty($qq)) {
   $qq = urlencode($qq);
   $sql = "SELECT user_id " . "FROM {$CONFIG['TABLE_USERS']} " . "WHERE user_name = '". mysql_escape_string($qq) . "'";
   $result1 = db_query($sql);
   if (mysql_num_rows($result1)>0) {
     $u = mysql_fetch_array($result1);
     $HTTP_GET_VARS['cat'] = sprintf("1%04d",$u[0]);
   }
   else {
     cpg_die(ERROR, '"' . $qq . '" is an invalid username.  Please try again.', __FILE__, __LINE__);
   }
   mysql_free_result($result1);
}
Title: HACK: short url to user albums
Post by: WreckRman2 on February 23, 2004, 04:26:28 am
Anyone have the code to do this if intergrated with vb?
Title: share private album mod?
Post by: newage40 on February 25, 2004, 02:32:10 am
Anyone working on having this feature available?

Like yahoo photos where you have your album private and only the people you send the secret link can view that private album.

Can anyone mod this?

[edit GauGau]
do not try to hijack other's threads, and do not double-post nor cross-post.
You have posted exactly the same question (http://forum.coppermine-gallery.net/index.php?topic=4015) already in feature requests (where it belongs) :evil:
[/edit]
[/b]
Title: HACK: short url to user albums
Post by: spellspoil on February 28, 2004, 08:57:06 pm
Is there a way to make the url to be:

http://www.domain.com/gallery/party

to go the album thats named party or something...
Title: HACK: short url to user albums
Post by: Ravage on February 29, 2004, 03:29:31 am
Would be great to have this work with vb intergration.
Title: HACK: short url to user albums
Post by: WreckRman2 on February 29, 2004, 04:13:02 am
I'll share what I did for vb intergration... it's more an addon than a hack.

I created a folder called "user" then add this code to a file called index.php


Code: [Select]


<?php

$dbuser 
"";
$dbpass "";
$dbname "";
$domain "";

$db mysql_connect&#40;"localhost", $dbuser, $dbpass&#41;;
mysql_select_db&#40;$dbname,$db&#41;;

$username=$HTTP_SERVER_VARS["QUERY_STRING"&#93;;
$username eregi_replace &#40; '%20', ' ', $username&#41;;

$user_result mysql_query&#40;"SELECT * FROM user WHERE username='$username'"&#41;;
while &#40;$user = mysql_fetch_array &#40;$user_result&#41;&#41; &#123;

        
$u $user["userid"&#93;; 
    
$cat sprintf&#40;"1%04d",$u&#41;;

        
header &#40;"Location&#58;http&#58;//www.".$domain."/gallery/index.php?cat=$cat"&#41;;

&#125;

mysql_free_result &#40;$user_result&#41;;

?>




Edit the variables... then you can view a users gallery with the URL:

http://www.yourdomain.com/gallery/user?MEMBERNAME

Substitute MEMBERNAME for your members username.


All this code does is convert the username to the gallery id and redirects the user to that page. Nothing fancy but it's a temp solution until someone comes up wit something better.
Title: HACK: short url to user albums
Post by: EliteRides on February 29, 2004, 10:21:59 pm
Quote from: "FishnReef"
Error crítico
There was an error while processing a database query


Quote from: "gaugau"
you'll have to switch on debug_mode


I get the same thing with YaBBSE.  Here's what my errors say in debug_mode:

Quote
There was an error while processing a database query.

While executing query "SELECT user_id FROM **ERROR** WHERE user_name = 'damon'" on 0

mySQL error: You have an error in your SQL syntax near '**ERROR** WHERE user_name = 'damon'' at line 1

Debug info
USER:
Array
(
    [ID] => 46025dc00ee3bd09acc1a8272ee0f64e
    [am] => 1
    [liv] => Array
        (
           
  • => 31
  • [1] => 38
                [2] => 43
                [3] => 44
                [4] => 45
            )

    )

     
    GET :
    Array
    (
        [damon] =>
    )

     
    POST :
    Array
    (
    )
Title: Re: HACK: short url to user albums
Post by: pkulak on May 04, 2004, 09:12:12 am
Is there a way to make the url to be:

http://www.domain.com/gallery/party

to go the album thats named party or something...

You can do it with mod_rewrite. Something like this in a .htaccess file:

Code: [Select]
RewriteEngine On
RewriteBase /gallery/
RewriteRule ^([A-Za-z_0-9\-]+)\/*$ /gallery/index.php?album=$1 [R]

Then you would have to add a bit to index to have it look up the album by it's name and return the number, but it's really not much different then by user. What I would love to do is make it toally mod_rewrite compatible so that /user/album works and the links all work that way to.
Title: Re: HACK: short url to user albums
Post by: cerberus on May 19, 2004, 02:44:04 pm
I'll share what I did for vb intergration... it's more an addon than a hack.
but it's a temp solution until someone comes up wit something better.
It isn't working with YaBB SE ???
Title: Re: HACK: short url to user albums
Post by: XBleed on May 19, 2004, 05:38:05 pm
I'll share what I did for vb intergration... it's more an addon than a hack.

I created a folder called "user" then add this code to a file called index.php


Code: [Select]

<?php

$dbuser 
"";
$dbpass "";
$dbname "";
$domain "";

$db mysql_connect("localhost"$dbuser$dbpass);
mysql_select_db($dbname,$db);

$username=$HTTP_SERVER_VARS["QUERY_STRING"];
$username eregi_replace '%20'' '$username);

$user_result mysql_query("SELECT * FROM user WHERE username='$username'");
while (
$user mysql_fetch_array ($user_result)) {

        
$u $user["userid"]; 
    
$cat sprintf("1%04d",$u);

        
header ("Location:http://www.".$domain."/gallery/index.php?cat=$cat");

}

mysql_free_result ($user_result);

?>



Edit the variables... then you can view a users gallery with the URL:

http://www.yourdomain.com/gallery/user?MEMBERNAME

Substitute MEMBERNAME for your members username.


All this code does is convert the username to the gallery id and redirects the user to that page. Nothing fancy but it's a temp solution until someone comes up wit something better.

I tried this but there are a bunch of errors in the code..   The "%04d" things.   They're everyhwere!
Does anyone know what they are in actual php code so I can attempt this again?
Title: Vbulletin 3.0.0 integration???
Post by: jarekn on June 16, 2004, 05:58:00 am
Hello,

Was anyone able to get this to work with vbulletin 3.0?

I'd like to have a link from user's profile to their own gallery.

THANX
Title: Re: HACK: short url to user albums
Post by: dafreak on June 17, 2004, 02:25:38 am
Well I got Wreckmans deal to work *thanks wreckman!*

i couldnt get it to work via ..gallery/user?Username :(  *going to try to figure out why

in the meantime i just used his code and made user.php and put it in the gallery folder.. so it works as ..gallery/user.php?Username

btw i'm using VB3.01

Title: Re: HACK: short url to user albums
Post by: elBarto on July 14, 2004, 11:04:54 pm
After reading a lot of posts in the past few days, I still have a bit confuse to doing something like this:

http://www.domain.com/coppermine/user/ <- Users' home

http://www.domain.com/coppermine/user/gallery_1 <- User's gallery 1

Would that be possible? ???
Title: Re: HACK: short url to user albums
Post by: Moodi on July 18, 2004, 12:40:45 am
My change for work with PHPBB intregration

Look the original post
http://forum.coppermine-gallery.net/index.php?topic=1659.msg7910#msg7910
and change the code by

Code: [Select]

$qq=$HTTP_SERVER_VARS["QUERY_STRING"];
if (!strstr($qq,'=') and !empty($qq)) {
  $qq = urlencode($qq);
      $sql = "SELECT user_id " . "FROM " . $UDB_DB_NAME_PREFIX . PHPBB_TABLE_PREFIX . PHPBB_USER_TABLE . " " . "WHERE username = '". mysql_escape_string($qq) ."'";

    $result = db_query($sql, $UDB_DB_LINK_ID);

    if (mysql_num_rows($result)>0) {
        $u = mysql_fetch_array($result);
        $HTTP_GET_VARS['cat'] = sprintf("1%04d",$u[0]);
  }
  else {
    cpg_die(ERROR, '"' . $qq . '" YOUR ERROR MESSAGE HERE', __FILE__, __LINE__);
  }

}


Title: Re: HACK: short url to user albums
Post by: Moodi on July 18, 2004, 12:53:35 am
My change for work with vbulletin3 intregration

Look the original post
http://forum.coppermine-gallery.net/index.php?topic=1659.msg7910#msg7910
and change the code by

Code: [Select]

$qq=$HTTP_SERVER_VARS["QUERY_STRING"];
if (!strstr($qq,'=') and !empty($qq)) {
  $qq = urlencode($qq);
    $sql = "SELECT userid as user_id " . "FROM " . $UDB_DB_NAME_PREFIX . VB_TABLE_PREFIX . VB_USER_TABLE . " " . "WHERE username = '". mysql_escape_string($qq) ."'";

    $result = db_query($sql, $UDB_DB_LINK_ID);

    if (mysql_num_rows($result)>0) {
        $u = mysql_fetch_array($result);
        $HTTP_GET_VARS['cat'] = sprintf("1%04d",$u[0]);
  }
  else {
    cpg_die(ERROR, '"' . $qq . '" YOUR ERROR MESSAGE HERE.', __FILE__, __LINE__);
  }

}


Title: Re: HACK: short url to user albums
Post by: Moodi on July 18, 2004, 12:58:41 am
My change for work with Invision Power Board v1.1 Integration

Look the original post
http://forum.coppermine-gallery.net/index.php?topic=1659.msg7910#msg7910
and change the code by

Code: [Select]

$qq=$HTTP_SERVER_VARS["QUERY_STRING"];
if (!strstr($qq,'=') and !empty($qq)) {
  $qq = urlencode($qq);
      $sql = "SELECT id as user_id " . "FROM " . $UDB_DB_NAME_PREFIX . IB_TABLE_PREFIX . IB_USER_TABLE . " " . "WHERE name = '". mysql_escape_string($qq) ."'";

    $result = db_query($sql, $UDB_DB_LINK_ID);

    if (mysql_num_rows($result)>0) {
        $u = mysql_fetch_array($result);
        $HTTP_GET_VARS['cat'] = sprintf("1%04d",$u[0]);
  }
  else {
    cpg_die(ERROR, '"' . $qq . '" YOUR ERROR MESSAGE HERE.', __FILE__, __LINE__);
  }

}


Title: Re: HACK: short url to user albums
Post by: Moodi on July 18, 2004, 01:09:05 am
My change for YaBB SE 1.5.4 Integration

Look the original post
http://forum.coppermine-gallery.net/index.php?topic=1659.msg7910#msg7910
and change the code by

Code: [Select]
$qq=$HTTP_SERVER_VARS["QUERY_STRING"];
if (!strstr($qq,'=') and !empty($qq)) {
  $qq = urlencode($qq);
    $sql = "SELECT ID_MEMBER as user_id " . "FROM " . $UDB_DB_NAME_PREFIX . YS_TABLE_PREFIX . YS_USER_TABLE . " " . "WHERE realName = '". mysql_escape_string($qq) ."'";

    $result = db_query($sql, $UDB_DB_LINK_ID);

    if (mysql_num_rows($result)>0) {
        $u = mysql_fetch_array($result);
        $HTTP_GET_VARS['cat'] = sprintf("1%04d",$u[0]);
  }
  else {
    cpg_die(ERROR, '"' . $qq . '" YOUR ERROR MESSAGE HERE', __FILE__, __LINE__);
  }

}
Title: Re: HACK: short url to user albums
Post by: Casper on July 18, 2004, 01:16:29 am
Hi Moodi,

If you have made mods to the code that will make these bridges work better, then you help is much appreciated, but please explain on each post, to which file you are refering, and show not just the new code, but the old code it is replacing, or if just additional code, where to put it.

Thanks.
Title: Re: HACK: short url to user albums
Post by: Moodi on July 18, 2004, 01:31:01 am
Yes Casper !! ;)

I modified my post 

it's better like that? :-[
Title: Re: HACK: short url to user albums
Post by: hevangel on August 13, 2004, 10:29:13 am
Hi,

I found a bug (or feature) of this hack.
If I change the theme, I got bounce back to the main page.
So I modified the code by introducing a user_gallery option that overwrite the cat option in URL.

The shortcut URL become
http://www.yourdomain.com/album/user_gallery=user_name

Replace the orginial code with
Code: [Select]
if (isset($HTTP_GET_VARS['user_gallery'])) {
$user_gallery = $HTTP_GET_VARS['user_gallery'];
$sql = "SELECT user_id " . "FROM {$CONFIG['TABLE_USERS']} " .
"WHERE user_name = '". mysql_escape_string($user_gallery) . "'";
 
$result1 = db_query($sql);
    if (mysql_num_rows($result1)>0) {
    $u = mysql_fetch_array($result1);
    $HTTP_GET_VARS['cat'] = sprintf("1%04d",$u[0]);
  }
mysql_free_result($result1);
}
Title: Re: HACK: short url to user albums
Post by: Allo on August 18, 2004, 06:05:18 am
Error checking code -

Code: [Select]
$qq=$HTTP_SERVER_VARS["QUERY_STRING"];
 if (!strstr($qq,'=') and !empty($qq)) {
   $qq = urlencode($qq);
   $sql = "SELECT user_id " . "FROM {$CONFIG['TABLE_USERS']} " . "WHERE user_name = '". mysql_escape_string($qq) . "'";
   $result1 = db_query($sql);
   if (mysql_num_rows($result1)>0) {
     $u = mysql_fetch_array($result1);
     $HTTP_GET_VARS['cat'] = sprintf("1%04d",$u[0]);
   }
   else {
     cpg_die(ERROR, '"' . $qq . '" is an invalid username.  Please try again.', __FILE__, __LINE__);
   }
   mysql_free_result($result1);
}


I still have problem with this.

The site is: www.artsrater.com

the gallery is in first page but when i'm typing  www.artsrater.com/?allo   (where  "allo" is the username)

I receive this:

There was an error while processing a database query.

While executing query "SELECT user_id FROM nuke_users WHERE user_name = 'allo'" on 0

mySQL error: Unknown column 'user_name' in 'where clause'


Nuke ver is 7 and coppermine 1.2
 :-\\ i'm totally out.
Title: Re: HACK: short url to user albums
Post by: kegobeer on August 18, 2004, 06:11:08 am
Quote
Nuke ver is 7 and coppermine 1.2
i'm totally out.

This isn't for the nuke version.  This is for the standalone version.  Nuke support can be found at http://www.nukephotogallery.com.
Title: Re: HACK: short url to user albums
Post by: Allo on August 18, 2004, 06:53:07 am
Thank you. but sometimes i found more here than in other place.  ;)
Title: Re: short url to user albums
Post by: foei on September 07, 2004, 07:06:41 am
how to short  last member album on first page
Title: Re: short url to user albums
Post by: itang on November 04, 2004, 03:35:41 am
I have found this mod_rewrite solution for cpg 1.1.x to make the short url for members work like this:

http://yourdomain.com/peter

point to the user album -->  http://yourdomain.com/index.php?cat=10013

However, I am using 1.3.2 and it seems that there are some problems. Would any programming expert help solving this problem?

The related topic is here:

http://forum.coppermine-gallery.net/index.php?topic=11343.0

Thanks for your attention.

Title: Re: short url to user albums
Post by: FearlessX on December 14, 2004, 03:51:58 pm
hi. i'm new to php. what does the ? in ?username does? Possible to make subdomains work?  ???
Title: Re: short url to user albums
Post by: Fonz on January 26, 2005, 01:01:56 am
nice i can use that !!!
Title: Re: short url to user albums
Post by: rubbersoul on February 27, 2005, 04:38:59 am
Can any1 tell me how to get rid of the voting table and features....I don't want any voting functions. Thanks!
Title: Re: short url to user albums
Post by: Tranz on February 27, 2005, 04:55:40 am
Go to group manager and say No to allowing rating.
Title: Re: short url to user albums
Post by: Tarique Sani on February 27, 2005, 05:45:02 am
One question per thread please
Title: Re: short url to user albums
Post by: TheGamer1701 on July 05, 2005, 08:57:49 pm
Hey,

that doesn't completly work for me.
I applied the hack and when I try it, coppermine shows me the 4 lst uploaded pictures (album=lastub???), but not the the users private category as it should.

Any idea how to change this?
There are currently no other hacks than this one and a watermarking hack.
Thx,

André
Title: Re: short url to user albums
Post by: TheGamer1701 on July 08, 2005, 03:36:31 pm
any solution here?
Or a hint?
Anything would be great, otherwise I would have to make a work-around by acessing the coppermine tables directly (which I really don't want to do...)
Title: Re: short url to user albums
Post by: FaizanQ on July 14, 2005, 02:11:36 am
I cant post in 'Modifications/Add-Ons/Hacks' and i post my hack here

With this hack your registered users can access to her albuma with short url:
http://www.domain.com/gallery/?UserName
where http://www.domain.com/gallery/ - url to your gallery
UserName - registered user name (if UserName not contain '=')

hack:
add this code:
Code: [Select]
$qq=$HTTP_SERVER_VARS["QUERY_STRING"];
if (!strstr($qq,'=') and !empty($qq)) {
  $sql = "SELECT user_id " . "FROM {$CONFIG['TABLE_USERS']} " . "WHERE user_name = '". mysql_escape_string($qq) . "'";
  $result1 = db_query($sql);
  if (mysql_num_rows($result1)>0) {
    $u = mysql_fetch_array($result1);
    $HTTP_GET_VARS['cat'] = sprintf("1%04d",$u[0]);
  }
  mysql_free_result($result1);
}
before:
Code: [Select]
/**
 * Main code
 */

if (isset($HTTP_GET_VARS['page'])) {
    $PAGE = max((int)$HTTP_GET_VARS['page'], 1);
    $USER['lap'] = $PAGE;
} elseif (isset($USER['lap'])) {
    $PAGE = max((int)$USER['lap'], 1);
} else {
    $PAGE = 1;
}
in index.php

I cant really find those lines in my index.php, any suggestions?
Title: Re: short url to user albums
Post by: kegobeer on July 14, 2005, 02:46:23 am
If you can't find

Code: [Select]
if (isset($HTTP_GET_VARS['page'])) {
in index.php, then you aren't running a standard Coppermine gallery.  If you used Fantastico, then you should download 1.3.3 from our site and preform an upgrade.
Title: Re: HACK: short url to user albums
Post by: stardotstar on September 29, 2005, 06:20:59 am
My change for work with PHPBB intregration

Look the original post
http://forum.coppermine-gallery.net/index.php?topic=1659.msg7910#msg7910
and change the code by

Code: [Select]

$qq=$HTTP_SERVER_VARS["QUERY_STRING"];
if (!strstr($qq,'=') and !empty($qq)) {
  $qq = urlencode($qq);
      $sql = "SELECT user_id " . "FROM " . $UDB_DB_NAME_PREFIX . PHPBB_TABLE_PREFIX . PHPBB_USER_TABLE . " " . "WHERE username = '". mysql_escape_string($qq) ."'";

    $result = db_query($sql, $UDB_DB_LINK_ID);

    if (mysql_num_rows($result)>0) {
        $u = mysql_fetch_array($result);
        $HTTP_GET_VARS['cat'] = sprintf("1%04d",$u[0]);
  }
  else {
    cpg_die(ERROR, '"' . $qq . '" YOUR ERROR MESSAGE HERE', __FILE__, __LINE__);
  }

}




I have used this code to link to my member galleries from phpBB and it works fine for all my members except those with spaces in their usernames...
I see that urlencode is used for $qq and the browser correctly encodes the username with %20 but the modification returns the error message...

Why would this be; hyphens and alpha numeric seem to work fine.  Example message - even when I type the URL in:

the username is "mr 3d"

.../cpg133/?mr%203d

yields:

"mr%25203d" YOUR ERROR MESSAGE HERE

so there is this 52 sneaking in between the %2 and 0 and the remainder of the username...

Big daz also gets the same problem:

"Big%2520daz" YOUR ERROR MESSAGE HERE
Title: Re: HACK: short url to user albums
Post by: TheGamer1701 on October 13, 2005, 10:29:26 pm
Is there a way to make the url to be:

http://www.domain.com/gallery/party

to go the album thats named party or something...

You can do it with mod_rewrite. Something like this in a .htaccess file:

Code: [Select]
RewriteEngine On
RewriteBase /gallery/
RewriteRule ^([A-Za-z_0-9\-]+)\/*$ /gallery/index.php?album=$1 [R]

Then you would have to add a bit to index to have it look up the album by it's name and return the number, but it's really not much different then by user. What I would love to do is make it toally mod_rewrite compatible so that /user/album works and the links all work that way to.


Hey,

I want to do a mod that does:
http://www.domain.com/?username
translate to
http://www.domain.com/coppermine/?username (or anything else that points to the user album view)

I found this post and tried to create a .htacces file:

Code: [Select]
RewriteEngine On
RewriteBase /go/
RewriteRule ^([A-Za-z_0-9\-]+)\/*$ /coppermine/index.php?album=$1 [R]

but this does not work and doesn't seem right.

Could anyone help me with this?
Unfortunetly I have absolutely no experiences with ".htaccess" files and "Rewrite"

Thx
Title: Re: short url to user albums
Post by: Lucas Xavier on November 04, 2005, 07:59:52 pm
Thanx. But you have a mod to don't need the "?" on the url?
Title: Re: short url to user albums
Post by: alanlai on November 08, 2005, 11:07:27 am
cool, that's interesting... but most servers storing size are SO limited to share
Title: Re: short url to user albums
Post by: AWJunkies on January 29, 2006, 01:44:38 am
there was another thread about the same thing. Just thought I would update and change the tag to work with 1.4.x as well
Title: Re: short url to user albums
Post by: dEnA on February 13, 2006, 04:05:38 pm
That would be nice. when are you doing that?
Title: Re: short url to user albums
Post by: pcboy123 on March 01, 2006, 05:54:05 am
i get the error!
when
www.domainname.com/gallery/?user

i get this

Fatal error: Call to undefined function: db_query() in /home/xmex/public_html/monica/gallery/index.php on line 1419

Title: Re: short url to user albums
Post by: Joachim Müller on March 02, 2006, 08:27:30 am
then read this thread entirely, you have to apply the version for cpg1.4.x
Title: Re: short url to user albums
Post by: pcboy123 on March 14, 2006, 08:42:38 pm
then read this thread entirely, you have to apply the version for cpg1.4.x


i read this over and over again and i cant find the right code
for cpg 1.4.4?

so if it aint any trouble can you help me??
Title: Re: short url to user albums
Post by: altagame on March 17, 2006, 01:01:37 am
I have run into trouble with this one as well.

I have inserted the following code for phpBB;

Code: [Select]
$qq=$HTTP_SERVER_VARS["QUERY_STRING"];
if (!strstr($qq,'=') and !empty($qq)) {
  $qq = urlencode($qq);
      $sql = "SELECT user_id " . "FROM " . $UDB_DB_NAME_PREFIX . PHPBB_TABLE_PREFIX . PHPBB_USER_TABLE . " " . "WHERE username = '". mysql_escape_string($qq) ."'";

    $result = db_query($sql, $UDB_DB_LINK_ID);

    if (mysql_num_rows($result)>0) {
        $u = mysql_fetch_array($result);
        $HTTP_GET_VARS['cat'] = sprintf("1%04d",$u[0]);
  }
  else {
    cpg_die(ERROR, '"' . $qq . '" YOUR ERROR MESSAGE HERE', __FILE__, __LINE__);
  }

}



//
// Main code

This was the proper code, or so I thought from Moodi on July 18, 2004. Titled; My change for work with PHPBB intregration

After adding this code to the index.php file, I get a blank page returned when going to; ../gallery/?UserName


Any thoughts?

Thanks everyone, I am sure its a great mod, just gotta get it working.

Alta.
Title: Re: short url to user albums
Post by: pandahuang on April 20, 2006, 01:37:59 pm
I had read the subject http://forum.coppermine-gallery.net/index.php?topic=1659.40 (http://forum.coppermine-gallery.net/index.php?topic=1659.40) entirely..

But when I copy the code to index.php and link to the url

 http://gallary/?userid

it didn't work , the page desplayed blank !!

any idea? thanks ^^

my cpg version is : 1.4.4
Title: Re: short url to user albums
Post by: pandahuang on April 20, 2006, 05:01:48 pm
Reply myself ..  ::)

in this code .. cpg132_users is the user table in my cpg.

Code: [Select]
$qq=$HTTP_SERVER_VARS["QUERY_STRING"];
if (!strstr($qq,'=') and !empty($qq)) {
$qq = eregi_replace ( '%20', ' ', $qq);
$qq=mysql_escape_string($qq);
$sql = "SELECT user_id from `cpg132_users` WHERE `user_name` = \"$qq\"";
$result1 = mysql_query($sql);
if (mysql_num_rows($result1)>0) {
 list($uid) = mysql_fetch_array($result1);
 $cat = sprintf("1%04d",$uid);
}
mysql_free_result($result1);
}


maybe it's ugly But it works in my cpg 1.4.4   ;D
Title: Re: short url to user albums
Post by: pcboy123 on April 20, 2006, 05:35:53 pm
Reply myself ..  ::)

in this code .. cpg132_users is the user table in my cpg.

Code: [Select]
$qq=$HTTP_SERVER_VARS["QUERY_STRING"];
if (!strstr($qq,'=') and !empty($qq)) {
$qq = eregi_replace ( '%20', ' ', $qq);
$qq=mysql_escape_string($qq);
$sql = "SELECT user_id from `cpg132_users` WHERE `user_name` = \"$qq\"";
$result1 = mysql_query($sql);
if (mysql_num_rows($result1)>0) {
 list($uid) = mysql_fetch_array($result1);
 $cat = sprintf("1%04d",$uid);
}
mysql_free_result($result1);
}


maybe it's ugly But it works in my cpg 1.4.4   ;D

COOL I been looking for this code..
ill try it out later today and let you know..
Title: Re: short url to user albums
Post by: andyleery on June 13, 2007, 10:53:19 am
Hi I tried to install this hack but it doesent work! www.bollybilder.de/gallery/?Andy.
I want to start soon, hope we will fix it together ^^
Title: Re: short url to user albums
Post by: Joachim Müller on June 13, 2007, 03:13:11 pm
Not very surprising, as http://www.bollybilder.de/gallery/ doesn't exist and returns a "404 not found". Your gallery seems to reside in the webroot. http://www.bollybilder.de/?andy does something (although not what you'd expect), so I guess you made a mistake applying this hack. Undo your changes, then redo them.
Title: Re: short url to user albums
Post by: andyleery on June 13, 2007, 03:23:04 pm
LOL es wrong root ^^ Its because I's sitting on this project for 30 hours in three days...
I just added this code, how it was written in the startpost:

$qq=$HTTP_SERVER_VARS["QUERY_STRING"];
if (!strstr($qq,'=') and !empty($qq)) {
  $sql = "SELECT user_id " . "FROM {$CONFIG['TABLE_USERS']} " . "WHERE user_name = '". mysql_escape_string($qq) . "'";
  $result1 = db_query($sql);
  if (mysql_num_rows($result1)>0) {
    $u = mysql_fetch_array($result1);
    $HTTP_GET_VARS['cat'] = sprintf("1%04d",$u[0]);
  }
  mysql_free_result($result1);
}

Didnt do anything wrong! But how can I fix this error?
Title: Re: short url to user albums
Post by: Joachim Müller on June 13, 2007, 06:13:55 pm
Is $HTTP_SERVER_VARS actually populated on your server?
Title: Re: short url to user albums
Post by: andyleery on June 13, 2007, 06:17:01 pm
Dont know?! Can you see it here? http://www.bollybilder.de/phpinfo.php
Title: Re: short url to user albums
Post by: Joachim Müller on June 13, 2007, 06:24:22 pm
Dont know?! Can you see it here? http://www.bollybilder.de/phpinfo.php
Of course not - I can't access that page - it's admin-only for security reasons. Why don't you take a look at it? Alternatively, edit the code you refered to above, find
Code: [Select]
$qq=$HTTP_SERVER_VARS["QUERY_STRING"]; and temporarily add into a new line before it
Code: [Select]
print_r($HTTP_SERVER_VARS);
die;
Not sure though if you understand the output and if you can interpret it.
Title: Re: short url to user albums
Post by: andyleery on June 13, 2007, 06:55:16 pm
I looked at the PHPINFO but i didnt find anything that helps me. I cant code, just know a little bit of php.
In which section do I have to look in the PHPinfo?

Here is the output:

Quote
Array ( [PATH] => /usr/local/bin:/usr/bin:/bin [DOCUMENT_ROOT] => /kunden/145013_12157/webseiten/bollybilder_de [HTTP_ACCEPT] => text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 [HTTP_ACCEPT_CHARSET] => ISO-8859-1,utf-8;q=0.7,*;q=0.7 [HTTP_ACCEPT_ENCODING] => gzip,deflate [HTTP_ACCEPT_LANGUAGE] => de-de,de;q=0.8,en-us;q=0.5,en;q=0.3 [HTTP_CONNECTION] => keep-alive [HTTP_COOKIE] => __utmz=232593036.1181749878.7.2.utmccn=(referral)|utmcsr=bolly-wood.de|utmcct=/community.htm|utmcmd=referral; __utma=232593036.1832684498.1181732400.1181749878.1181753412.8; cpg143_data=YTo2OntzOjI6IklEIjtzOjMyOiJmNDI5MmI4MGU2MTk1YmQyNWJlYjkzMjkxMzgwNWIxZSI7czoyOiJhbSI7aToxO3M6NDoibGFuZyI7czo2OiJnZXJtYW4iO3M6MzoibGl2IjthOjE6e2k6MDtzOjE6IjQiO31zOjY6InNlYXJjaCI7YTo5OntzOjY6InNlYXJjaCI7czo4OiJBYmhpc2hlayI7czo1OiJhbGJ1bSI7czo2OiJzZWFyY2giO3M6NToidGl0bGUiO3M6Mjoib24iO3M6MTA6Im5ld2VyX3RoYW4iO3M6MDoiIjtzOjc6ImNhcHRpb24iO3M6Mjoib24iO3M6MTA6Im9sZGVyX3RoYW4iO3M6MDoiIjtzOjg6ImtleXdvcmRzIjtzOjI6Im9uIjtzOjQ6InR5cGUiO3M6MzoiQU5EIjtzOjY6InBhcmFtcyI7YTozOntzOjU6InRpdGxlIjtzOjI6Im9uIjtzOjc6ImNhcHRpb24iO3M6Mjoib24iO3M6ODoia2V5d29yZHMiO3M6Mjoib24iO319czozOiJsYXAiO2k6MTt9; cpg143_fav=YTowOnt9; 11568f2cac7d7cbf945a19c2c5278f56=c517319595b0ad996ef963adbccdad47; 9eaaa0a4e39e7a23bd115d7d48462a42=be0b0fecfe2b5b23c6b42d1e2e1cb965; __utmc=232593036; wrfsessionId=9cbce6946b6d0431fcd8cac71e9845e3; __utmb=232593036 [HTTP_HOST] => www.bollybilder.de [HTTP_KEEP_ALIVE] => 300 [HTTP_USER_AGENT] => Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4 [PDFLIBRESOURCE] => /usr/local/fonts/pdflib.upr [REDIRECT_QUERY_STRING] => Andy [REDIRECT_STATUS] => 200 [REDIRECT_URL] => / [REMOTE_ADDR] => 87.160.161.225 [REMOTE_PORT] => 61329 [SCRIPT_FILENAME] => /kunden/145013_12157/webseiten/bollybilder_de/index.php [SCRIPT_URI] => http://www.bollybilder.de/ [SCRIPT_URL] => / [SERVER_ADDR] => 80.67.17.120 [SERVER_ADMIN] => webmaster@www.bollybilder.de [SERVER_NAME] => www.bollybilder.de [SERVER_PORT] => 80 [SERVER_SOFTWARE] => Apache/1.3 (Unix) mod_ssl/2.8.28 OpenSSL/0.9.8d AuthPG/1.3 FrontPage/5.0.2.2635 [SWFFONTPATH] => /usr/lib/libswf/fonts/ [UNIQUE_ID] => RnAg6n8AAAEAACG3WW4 [GATEWAY_INTERFACE] => CGI/1.1 [SERVER_PROTOCOL] => HTTP/1.1 [REQUEST_METHOD] => GET [QUERY_STRING] => Andy [REQUEST_URI] => /?Andy [SCRIPT_NAME] => /index.php [DOCROOT] => /kunden/145013_12157/webseiten/bollybilder_de [DOC_ROOT] => /kunden/145013_12157/webseiten/bollybilder_de [PHPRC] => ./:/etc/php.ini/4/145013/614302:/etc/php.ini/4/145013:/usr/local/lib [PHP_SELF] => /index.php [argv] => Array (
  • => Andy ) [argc] => 1 )
Title: Re: short url to user albums
Post by: Joachim Müller on June 14, 2007, 09:47:40 am
Obviously, HTTP_SERVER_VARS[QUERY_STRING] is not populated. Edit the code suggested above, find
Code: [Select]
$qq=$HTTP_SERVER_VARS["QUERY_STRING"];and replace with
Code: [Select]
$qq=$_GET["QUERY_STRING"];
Title: Re: short url to user albums
Post by: andyleery on June 14, 2007, 01:18:33 pm
I did but now it just opens index.php.
Demo - http://www.bollybilder.de/?webmaster / http://www.bollybilder.de/?Andy
Title: Re: short url to user albums
Post by: andyleery on June 16, 2007, 12:44:07 pm
No more help for me or does it just dont work on my server? :-(
Title: Re: short url to user albums
Post by: andyleery on June 25, 2007, 02:19:44 pm
Last time I hope/ask for help. Please help meeeee  ;D, ist important to have that short url. THX.
Title: Re: short url to user albums
Post by: radium35 on January 15, 2008, 07:51:02 am
how can you have the short link be there when you click on someones album?
Title: Re: short url to user albums
Post by: invisibl3 on February 05, 2008, 04:42:04 am
hi i tried adding the codes required but it just seems to refresh to the same page. currently using stramm mod pack 1.4.13