Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - gondie

Pages: [1]
1
Coding / Coding some 'new' items...
« on: March 08, 2007, 03:05:23 am »
Hey... We'll I havent been working with PHP all that long, so I was wondering if anyone could help me out with these? Honestly, I didnt put all that much Work into these considering all the snipplets I found and used.

Anyways, Here is the first one I tried (yesterday) and failed so horribly in doing so...

This item is similar to the other Group items, but I made some changes. I plan on adding different instances of this item but with a different value for $item_info[2] so that they can purchase the item for a longer period of time.

(As you can see, Im not using any code to automatically remove them from the group once the time has ran up, I am having a PM sent to my account on the forums and I will take note of the date they used the item and remove the membership when it runs out)

Any ideas? Tips? Suggestions? Fixes?

<?php

if (!defined('SMF'))
	
die(
'Hacking attempt...');

class 
item_ChangeMembergroupLimited extends itemTemplate
{
	
function 
getItemDetails()
	
{
	
	
$this->authorName 'Gondie';
	
	
$this->authorWeb 'http://mizzro.inceptiongs.com';
	
	
$this->authorEmail 'thegondie@gmail.com';

	
	
$this->name 'Premium Membership (xxx days)';
	
	
$this->desc 'Become a Premium Member for xxx days!';
	
	
$this->price 4500;

	
	
$this->require_input false;
	
	
$this->can_use_item true;
	
}


	
function 
getAddInput()
	
	
	
{

	
	
global 
$item_info$groupname$db_prefix;
	
	

	
$selectBox '<select name="info1">';

	
$result db_query("SELECT ID_GROUP, groupName
	
	
	
	
	
	
	
FROM 
{$db_prefix}membergroups
	
	
	
	
	
	
	
WHERE minPosts = -1"
,
	
	
	
	
	
	
	
	
__FILE____LINE__);
	

	
while (
$row mysql_fetch_assoc($result)) {
	
	
$selectBox .= "<option value='{$row['ID_GROUP']}'>{$row['groupName']}</option>";
	
}

	
$selectBox .= "</select>";
        return 
"Membergroup: ".$selectBox;
	
	

	
	
if (
$item_info[2] == 0$item_info[2] = 30;
	
	
'Time to stay Changed: <input type="text" name="info2" value="' $item_info[2] . '" />';
	
	
	
}


	
function 
onUse()
	
	
	
{

	
	
global 
$db_prefix$memberName$ID_MEMBER$ID_GROUP;

	
	
db_query("
	
	
	
UPDATE 
{$db_prefix}members
	
	
	
SET ID_GROUP = 
{$item_info[2]}
	
	
	
WHERE ID_MEMBER = 
{$ID_MEMBER}"__FILE____LINE__);
	
	
return 
'Upgraded to "  for ' $item_info[1] . ' days!';

	
$result db_query("SELECT money, memberName, realName
	
	
	
FROM 
{$db_prefix}members
	
	
	
WHERE ID_MEMBER = 
{$ID_MEMBER}
	
	
	
LIMIT 1"
__FILE____LINE__);
	
	
	

	
$row mysql_fetch_array($resultMYSQL_ASSOC);
	
$membersUserName $row['memberName'];
	
$membersName $row['realName'];

	
$pmfrom = array(
	
	
'id' => $ID_MEMBER,
	
	
'name' => $membersName,
	
	
'username' => $membersUserName
	
);

	
$pmto = array(
	
	
'to' => array(1),
	
	
'bcc' => array()
	
);

	
$subject "Item Log: Prem Member Upgrade";
	
$message "from has Upgraded to group for time days.";
	
$vreplacekeys = array('from''group''time');
	
$vreplaceto = array($pmfrom$item_info[2], $item_info[1]
	
);
	
$message  str_replace($vreplacekeys $vreplaceto $message);
	
sendpm($pmto$subject$message0$pmfrom);
	
	
	
}
}

?>


(Just so you know, I just got this mod yesterday as well)

And I do believe I am missing the GetUseInput function in that one...

-------------------------------------------------------------------------------------------------

Here is the one I started working on a little bit ago...

This one is somewhat similar to the above one but still rather different. This one will allow them to request a custom Graphic or Web Design for points. I have a textbox for the type they want (graphic or web) and a text area so they can give me details on the project.

I dont really know whats going on with this one.. When I try to load the Add/Edit/Delete page in the admin cp I get this error...

Quote
ERROR: Could not create instance of 'GetDesign' item!

Any ideas? Tips? Suggestions? Fixes?

<?php

if (!defined('SMF'))
	
die(
'Hacking attempt...');

class 
item_RequestDesign extends itemTemplate
{

	
function 
getItemDetails()
	
{
	
	
$this->authorName 'Gondie';
	
	
$this->authorWeb 'http://mizzro.inceptiongs.com';
	
	
$this->authorEmail 'thegondie@gmail.com';

	
	
$this->name 'Custom Design';
	
	
$this->desc 'Get a custom Graphic or Web Design for gPoints';
	
	
$this->price 1000;
	
	

	
	
$this->require_input true;
	
	
$this->can_use_item true;
	
	
$this->addInput_editable true;
	
}

	
function 
getAddInput()
	
{
	
	
global 
$item_info;
	
	
if (
$item_info[1] == ''$item_info[1] = 'Type of Project: <input type="text" name="type" /> (Graphic or Design)';
	
	
if (
$item_info[2] == ''$item_info[2] = 'Please give some details for this. Dimensions, colors, text, etc.';
	
	

	
	
	
	
return 
'Type of Project: <input type="text" name="info2" size="50" value="' $item_info[2] . '" /> (Graphic or Design)<br />
	
	
	
	
Additional fields needed:<br />
	
	
	
	
	
<textarea name="info2" rows="6" cols="40">
$item_info[2] . '
	
	
	
	
	
</textarea><br />'
;
	
}

	
function 
getUseInput()
	
{
	
	
global 
$item_info;
	
	
// The 'additional fields needed' entered during item setup
	
	
return 
$item_info[1];
	
	
return 
$item_info[2];
	
}

	
function 
onUse()
	
{
	
	
$result db_query("SELECT money, memberName, realName
	
	
	
	
	
FROM 
{$db_prefix}members
	
	
	
	
	
WHERE ID_MEMBER = 
{$ID_MEMBER}
	
	
	
	
	
LIMIT 1"
__FILE____LINE__);

	
	
$row mysql_fetch_array($resultMYSQL_ASSOC);
	
	
$membersUserName $row['memberName'];
	
	
$membersName $row['realName'];

	
	
$pmfrom = array(
	
	
	
	
'id' => $ID_MEMBER,
	
	
	
	
'name' => $membersName,
	
	
	
	
'username' => $membersUserName
);
	
	

	
	
$pmto = array(
	
	
	
	
'to' => array(1),
	
	
	
	
'bcc' => array()
);
	
	

	
	
$subject "[name] requests [type]";
	
	
$vreplacekeys = array('[name''type');
	
	
$vreplaceto = array($username$item_info[1], '
'
);

	
	
$subject  str_replace($vreplacekeys $vreplaceto $subject);
	
	
$message "[desc]";
	
	
$vreplacekeys = array('[name');
	
	
$vreplaceto = array($item_info[2], '
'
);
	
	
$message str_replace($vreplacekeys$vreplaceto$message);
	
	
sendpm($pmto$subject$message0$pmfrom);
	
}
}

?>



Say as you wish of me and my horrid coding, It wont bother me. Just trying to learn what I can.

Thanks for your time.

Pages: [1]