(root)/shared-profile.php - Rev 466
Rev 441 |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
<?php
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* This file is part of Travelsized CMS
* A content management system with modules, based on wiki syntax
*
* Author: Dan Jensen <admin@leinir.dk>
* Copyright 2003/2004
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License is available at: http://www.gnu.org/copyleft/
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
if (file_exists("$setup_folder/profile_options.php"))
include "$setup_folder/profile_options.php";
if( !is_array( $profile_options ) || !array_key_exists( "tiny_width", $profile_options ) )
{
$profile_options = array(
"profiles_view" => "0",
"profiles_contact" => "2",
"profiles_menu" => "100",
"profiles_mypage" => "4",
"avatar_maxwidth" => 800,
"avatar_maxheight" => 600,
"thumbnail_width" => 120,
"thumbnail_height" => 120,
"thumbnail_disable" => "",
"tiny_width" => 16,
"tiny_height" => 16,
"contact_fields" => array(
"MSN" => array(
"name" => "MSN",
"description" => "MSN Messenger",
"image" => "msn.gif",
"url" => "http://www.msn.com/",
"regexp" => ".+@.+\..+."),
"ICQ" => array(
"name" => "ICQ",
"description" => "I Seek U",
"image" => "icq.gif",
"url" => "http://wwp.icq.com/scripts/search.dll?to=$$",
"regexp" => ".*"),
"Y!" => array(
"name" => "Y!",
"description" => "Yahoo! Messenger",
"image" => "yahoo.gif",
"url" => "http://edit.yahoo.com/config/send_webmesg?.target=$$&.src=pg",
"regexp" => ".*"),
"AIM" => array(
"name" => "AIM",
"description" => "AOL Instant Messenger",
"image" => "aim.gif",
"url" => "aim:goim%3Fscreenname=$$&message=Hello+Are+you+there%3F",
"regexp" => ".*"),
"Jabber" => array(
"name" => "Jabber",
"description" => "Jabber XMPP Based Instant Messenger",
"image" => "jabber.gif",
"url" => "http://www.jabber.org/",
"regexp" => ".+@.+\..+."),
"Google Talk" => array(
"name" => "Google Talk",
"description" => "Google's voice-chat enabled Jabber-based Instant Messenger",
"image" => "gtalk.gif",
"url" => "http://www.google.com/talk/",
"regexp" => ".+@gmail\.com"),
"Skype" => array(
"name" => "Skype",
"description" => "Skype Internet Telephony",
"image" => "skype.gif",
"url" => "skype:$$?call",
"regexp" => ".*"),
"WWW" => array(
"name" => "WWW",
"description" => "Homepage address (remember http://)",
"image" => "www.gif",
"url" => "$$",
"regexp" => ".*")
)
);
saveProfileOptions
();
}
/**
* Saves the profile options
*/
function saveProfileOptions
()
{
global $setup_folder, $profile_options;
unlink( "$setup_folder/profile_options.php" );
fileSave
( "$setup_folder/profile_options.php", array_export
( $profile_options, "profile_options" ) );
}
/**
* Make a random password, the usable characters are defined by the salt value
* courtesy of Ian Carter on www.phpfreaks.com
*/
function makeRandomPassword
($n=8, $chars='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890')
{
$m=strlen($chars);
$x = "";
while($n--)
$x.=substr($chars,rand()%$m,1);
return $x;
}
/**
* Check for a valid email address
* courtesy of Patrick and Sven in the php.net manual
*/
function validateEmail
($email){
$exp = ".+@.+\..+.";
if(eregi($exp,$email)){
$exploded = explode("@",$email);
$popped = array_pop($exploded);
if(checkdnsrr($popped,"MX")){
return true;
}else{
return false;
}
} else {
return false;
}
}
/**
* Returns the url to the avatar of the user $username
*
* @param username The username of the user you wish to fetch the avatar for
*
* @return string The filename of the avatar
*/
function getAvatar
( $username = "" )
{
global $userinfo_folder, $setup_folder;
$avatarfile = "$setup_folder/images/noavatar.png";
if( $username == "" )
$avatarfile = $avatarfile;
else if( file_exists("$userinfo_folder/$username/avatar.jpg") )
$avatarfile = "$userinfo_folder/$username/avatar.jpg";
else if( file_exists("$userinfo_folder/$username/avatar.png") )
$avatarfile = "$userinfo_folder/$username/avatar.png";
else if( file_exists("$userinfo_folder/$username/avatar.gif") )
$avatarfile = "$userinfo_folder/$username/avatar.gif";
return $avatarfile;
}
/**
* Returns the url to the avatar thumbnail of the user $username, or if $tiny is true to the avatar's tiny version
*
* @param username The username of the user you wish to fetch the avatar thumbnail for
* @param tiny Wether you wish to fetch the tiny version of the thumbnail
*
* @return string The filename of the avatar thumbnail
*/
function getAvatarThumbnail
( $username, $tiny = false )
{
global $userinfo_folder, $setup_folder, $profile_options;
$avatarfile = getAvatar
( $username );
$avatarthumbfile = "$userinfo_folder/$username/avatar-thumb" . substr( $avatarfile, -4 );
$avatartinyfile = "$userinfo_folder/$username/avatar-tiny" . substr( $avatarfile, -4 );
if( !file_exists($avatarthumbfile) )
$avatarthumbfile = $avatarfile;
if( $tiny )
{
if( !file_exists($avatartinyfile) )
{
if( file_exists( $avatarthumbfile ) )
scaleImage
( $avatarthumbfile, $avatartinyfile, $profile_options["tiny_width"], $profile_options["tiny_height"] );
}
$avatarthumbfile = $avatartinyfile;
}
return $avatarthumbfile;
}
/**
* Returns an array of useful information about images
*
* @param username The username of the user the avatar thumbnail of whom you wish to fetch sizes
* @param tiny Wether you wish to fetch the tiny version of the thumbnail
*
* @return mixed An array containing:
* width in pixels
* height in pixels
*/
function getAvatarThumbSize
( $username, $tiny = false )
{
$avatarfile = getAvatarThumbnail
($username, $tiny);
$avatarinfofile = $avatarfile . ".php";
if( file_exists($avatarinfofile) )
{
include($avatarinfofile);
}
else
{
$avatarsizes = getimagesize($avatarfile);
fileSave
( $avatarinfofile, array_export
( $avatarsizes, "avatarsizes" ) );
}
return $avatarsizes;
}
?>