cpg user subdomain cpg user subdomain
 

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

cpg user subdomain

Started by kreasta, January 07, 2007, 08:32:19 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

kreasta

ok, i have a question !

is possible like every user from my cpgallery to have a subdomain? ex user1.sitename.com user2.sitename.com ?

i saw something for 4images that worked.... but i like more cpg... so i wanna know if here works to.

this is the code

<?
// Settings
///////////////////////////////////////////

$url = "http://user.com/folder";
$table = "4images_users"; //do not edit if you have not changed table prefix

// Code
///////////////////////////////////////////

include "config.php";
$a_url = $_SERVER["REQUEST_URI"];
$i = explode("/", $a_url);
$b = count($i);
$b = $b-1;
$i = str_replace(array("%20"), " ", $i[$b]);
if (($i != "") and ($i != "guest"))
{
$db = mysql_connect("$db_host", "$db_user", "$db_password") or die ("Error");
@mysql_select_db("$db_name", $db) or die ("DB not found");
$result = mysql_query("SELECT user_id FROM `$table` WHERE user_name='$i'");
$row = mysql_fetch_array($result);
$id = $row['user_id'];
header("Location: ".$url."/member.php?action=showprofile&user_id=".$id."");
}
else
{
header("Location: ".$url."");
}
?>


with this httacces ErrorDocument 404 /who.php

... is there any possible way to do something like that for cpg??

kreasta

    this is the second option for getting my subdomain.

    mabye this help you out...

Quote from: richardkTo change the username to user ID (kreasta to 1), you have the following options:
[list=1]
  • If you have access to the httpd.conf file you could use a RewriteMap.
  • You could include the user ID after the username (eg kreaste-1) and ignore the username.
  • You could edit the PHP script to query the database using the username instead of the user ID.
  • Or you could create a PHP script the took the username, got the user ID, then include()d the main script with the new GET parameters (like the script above but not a redircet).
If i was you, i'd go for Option 4. It would be something like this: (In a file called mod_rewrite.php in the /4i directory.)
<?php

// Settings
$mr['url']    = 'http://www.kreasta.be/4i';
$mr['table']  = '4images_users';
$mr['dbhost'] = 'xxx';
$mr['dbpass'] = 'xxx';
$mr['dbuser'] = 'xxx';
$mr['dbname'] = 'xxx';


// Code

$mr['username'] = explode('.'getenv('HTTP_HOST'));
if(
count($mr['username']) != 3)
{
  
header('Location: ' $mr['url'] . '/'true301);
  exit();
}
$mr['username'] = $mr['username'][0];

if(!empty(
$mr['username']) && $mr['username'] != 'guest')
{
  
$mr['db'] = @mysql_connect($mr['dbhost'], $mr['dbuser'], $mr['dbpass'])
        or die(
'MySQL Error: ' mysql_error());
  @
mysql_select_db($mr['dbname'], $mr['db'])
        or die(
'MySQL Error: ' mysql_error());
  
$mr['row'] = mysql_fetch_array(mysql_query('SELECT user_id FROM ' $mr['table']
        . 
' WHERE user_name="' $mr['username'] .'"'));
  
$_GET['user_id'] = $mr['row']['user_id'];
  
$_GET['action']  = 'showprofile';
  unset(
$mr);
  include(
'member.php');
}
else
{
  
header('Location: ' $mr['url'] . '/'true301);
  exit();
}


For the subdomains you need DNS to point them to the server. Then you need them pointed to your main document root (or possibly the /4i directory) on the server. If this is not the case by default, you'll have to ask your host. Then you could use the following mod_rewrite (to work with Option 4 and the subdomains pointed to your main document root): (In a .htaccess file in your document root.)
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} !^(www\.)?kreasta\.be$ [NC]
RewriteCond %{HTTP_HOST}  ^[^\.]+\.kreasta\.be$ [NC]
RewriteRule ^$ /4i/mod_rewrite.php [QSA,L]