short url to user albums short url to user albums
 

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]

Main Menu

short url to user albums

Started by Kfmook, November 17, 2003, 09:40:02 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Kfmook

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:

$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:

/**
* 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

Joachim Müller

moved to Modifications/Add-Ons/Hacks/

Thanks for your contribution

GauGau

MaThIbUs

great! can this be included in a feature version of Coppermine? (1.2.1 or maybe even 1.3?)

jdbaranger

To accept names with a space, modify the script :

$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
Jean-Denis

MaThIbUs

and this replaces all weird characters by its URL code :)

**removed**

Joachim Müller

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...

GauGau

MaThIbUs

woops!

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

can anyone code this then?

FishnReef

I can't make this mod work  :?   I just keep getting a critical error.

Thanks in advance.

FishnReef

Maybe it is because Im using the gallery with phpbb. Is there a way to make it work?

Thanks ind advance ;)

Joachim Müller

please post your actual error message, might help solving this. I guess this is not related to the question "bbs-integration yes/no".

GauGau

FishnReef

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

Joachim Müller

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

MaThIbUs

$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

achtungbaby

Hello, will this hack work with subdomains?

ferlo

I've tried this mod, and seems working smooth (the one from MaThIbUs)
however, if someone posts a wrong name this error appears:

Parse error: parse error in /home/virtual/site15/fst/var/www/html/index.php on line 505

MaThIbUs

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 ;)

ferlo

I see.
However if something does not works I just hope users will try to access my site by the main page )

gmarik

great - so this works on the lates version as well?
will try to get it with vbulletin as well ...

SlammedDime

Error checking code -

$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);
}

WreckRman2

Anyone have the code to do this if intergrated with vb?
David Smith
Indy Web Design - http://www.indywebdesign.com
317-573-2486

We offer web hosting that includes easy installation for Coppermine Photo Gallery, phpBB2, PHP-Nuke, and a lot more...