Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: cpg user subdomain  (Read 8136 times)

0 Members and 1 Guest are viewing this topic.

kreasta

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
cpg user subdomain
« on: January 07, 2007, 08:32:19 pm »

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

Code: [Select]
<?
// 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??
« Last Edit: January 10, 2007, 08:05:49 am by GauGau »
Logged

kreasta

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Re: cpg user subdomain
« Reply #1 on: January 07, 2007, 08:37:46 pm »

    this is the second option for getting my subdomain.

    mabye this help you out...

Quote from: richardk
To 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.)
Code: [Select]
<?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.)
Code: [Select]
Options +FollowSymLinks

RewriteEngine On

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

Logged

Nibbler

  • Guest
Re: cpg user subdomain
« Reply #2 on: January 07, 2007, 10:10:36 pm »

No support in feature requests, locking.

http://forum.coppermine-gallery.net/index.php?topic=15866.0
Logged
Pages: [1]   Go Up
 

Page created in 0.025 seconds with 19 queries.