View Single Post
Old 01-21-2006, 04:58 PM
whoiam whoiam is offline
Join Date: Jun 2005
Location: Birmingham Uni
Posts: 832
Send a message via MSN to whoiam

Okay, I just spent awhile sketching out the first half of an idea...
(this needs mod_rewrite - ask your host if that's available)

First up, the two example files I made you can find at

Now, the way I made this section of the mod work is to move all the contents of the /templates//images/ folder to a new folder (I used /templates//target/ when I was writing it). Then edit the .htaccess file so that it contains the proper URL for the folder you moved the images to. (There's only one URL in the file, so just change that to the URL you've used), and place it in the now-empty images folder.

Next, you need to edit the spic.php file. The 6 variables at the top will need to be replaced with ones that will allow read access to the phpbb_users table (or whatever you named your equivalent).

The first variable ($field) needs to be set to the field in the users table that will be used to store the person's choice of picture. the second, $default, is the picture you want someone to see if they haven't made a selection yet.

The spic.exe file then goes into the 'target' folder along with the images.

This system also needs you to add one field to the user table (remember to allow this to be null, or you'll have to modify the signup process as well), and to modify the profile page to allow people to chose options from a drop-down box to go into that field.

*grins* That was an hour well-wasted, I think.

Anyway, this is the code from the two files, feel free to play around with it.

Originally Posted by .htaccess
Options All
RewriteEngine on
RewriteRule ^(.*)/?$$1 [R=301,L]
Originally Posted by spic.php
$field = "replace_me";
$default = "defaultpic.gif";
$hostname_con1 = "localhost";
$database_con1 = "forum";
$table_con1 = "phpbb_users";
$username_con1 = "root";
$password_con1 = "xxx";

// File
$filename = $_GET['file'];

if (eregi ("logo_phpbb.gif", $filename)) {

define('IN_PHPBB', true);
$phpbb_root_path = '../../../';
include($phpbb_root_path . '');
include($phpbb_root_path . 'common.'.$phpEx);
$userdata = session_pagestart($user_ip, PAGE_PROFILE);

$user = $userdata['user_id'];

$con1 = mysql_connect($hostname_con1, $username_con1, $password_con1) or trigger_error(mysql_error(),E_USER_ERROR);

$query_Recordset1 = "SELECT `$field` FROM `$table_con1` where `user_id` = '$user'";
$Recordset1 = mysql_query($query_Recordset1, $con1) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

$filename = $row_Recordset1[$field];
if($filename=='') { $filename = $default; }
// Content type
header('Content-type: image/gif');

// Load
$source = imagecreatefromgif($filename);

// Output

}elseif (eregi ("\.jpg", $filename)) {

header('Content-type: image/jpg');

// Load
$source = imagecreatefromjpeg($filename);

// Output

}elseif(eregi ("\.gif", $filename))
// Content type
header('Content-type: image/gif');

// Load
$source = imagecreatefromgif($filename);

// Output
}elseif(eregi ("\.htm", $filename)) {
Me, singing: Krieg, huh... wozu ist der gut?
Um Europa zu übernehmen!

Vote Morphine - the party for Not Crushing Opium!

Yoda, to his ice-cream: The sauce is upon you, and soon, sprinkles must fall!
Reply With Quote