1
Items / Re: Avatar Upload Item
« on: May 21, 2007, 11:19:19 pm »
try this one. Its a modified version of Change DisplayName item. What it does is that it gives the user the ability to specify the remote/external location of the image file to be use as avatar, and only usable one time. past the code below to ChangeAvatar.php file and place inside your shop item folder.
Code: [Select]
<?php
/**********************************************************************************
* SMFShop item *
***********************************************************************************
* SMFShop: Shop MOD for Simple Machines Forum *
* =============================================================================== *
* Software Version: SMFShop 3.0 (Build 12) *
* $Date:: 2007-01-18 19:26:55 +1100 (Thu, 18 Jan 2007) $ *
* $Id:: ChangeAvatar.php 79 2007-01-18 08:26:55Z daniel15 $ *
* Software by: DanSoft Australia (http://www.dansoftaustralia.net/)*
* Copyright 2005-2007 by: DanSoft Australia (http://www.dansoftaustralia.net/)*
* Support, News, Updates at: http://www.dansoftaustralia.net/ *
* *
* Forum software by: Simple Machines (http://www.simplemachines.org) *
* Copyright 2006-2007 by: Simple Machines LLC (http://www.simplemachines.org) *
* 2001-2006 by: Lewis Media (http://www.lewismedia.com) *
***********************************************************************************
* This program is free software; you may redistribute it and/or modify it under *
* the terms of the provided license as published by Simple Machines LLC. *
* *
* This program is distributed in the hope that it is and will be useful, but *
* WITHOUT ANY WARRANTIES; without even any implied warranty of MERCHANTABILITY *
* or FITNESS FOR A PARTICULAR PURPOSE. *
* *
* See the "license.txt" file for details of the Simple Machines license. *
* The latest version of the license can always be found at *
* http://www.simplemachines.org. *
**********************************************************************************/
if (!defined('SMF'))
die('Hacking attempt...');
class item_ChangeAvatar extends itemTemplate
{
function getItemDetails()
{
$this->authorName = 'Azahari Zaman';
$this->authorWeb = 'http://www.zianafolks.net/';
$this->authorEmail = 'azaharizaman{at}gmail{dot}com';
$this->name = 'Change Avatar';
$this->desc = 'Change your avatar!';
$this->price = 50;
$this->require_input = true;
$this->can_use_item = true;
$this->addInput_editable = true;
}
function getAddInput()
{
global $item_info;
if ($item_info[1] == 0) $item_info[1] = 5;
return 'Minimum length of avatar: <input type="text" name="info1" value="' . $item_info[1] . '" />';
}
function getUseInput()
{
// Use length of 5 as default
if (!isset($item_info[1]) || $item_info[1] == 0) $item_info[1] = 5;
return 'New Avatar: <input type="text" name="newAvatar" size="50" /><br />
Please enter avatar new location at least ' . $item_info[1] . ' characters long.';
}
function onUse()
{
global $db_prefix, $ID_MEMBER, $item_info;
// Use a length of 5 as default
if (!isset($item_info[1]) || $item_info[1] == 0) $item_info[1] = 5;
if (strlen($_POST['newAvatar']) < $item_info[1])
die('ERROR: The Avatar you chose was not long enough! Please go back and enter an avatar which is at least '
. $item_info[1] . ' characters long.');
$result = db_query("
UPDATE {$db_prefix}members
SET avatar = '{$_POST['newAvatar']}'
WHERE ID_MEMBER = {$ID_MEMBER}", __FILE__, __LINE__);
return 'Successfully changed your Avatar to ' . $_POST['newAvatar'];
}
}
?>