Author Topic: Need help with making an Item  (Read 4103 times)

Offline Sakuragi

Need help with making an Item
« on: January 08, 2007, 06:40:50 am »
Hi,
I need help making a item.

with this item members can purchase an award to display it on this profile
members awards mod

function onUse:

Code: [Select]
         function onUse() {


        global $db_prefix, $ID_MEMBER, $item_info;

       $result = db_query("
INSERT INTO `{$db_prefix}awards_members` VALUES (20003, 2, {$ID_MEMBER}, 2007-01-07, 0);
");
        return "Success!";
    }

when I use this item I see this error

Hacking attempt... 


here is the table structure:
Code: [Select]
ID_AWARD_MEMBER int(8) unsigned NOT NULL DEFAULT '0',
ID_AWARD BIGINT(10) UNSIGNED NOT NULL DEFAULT '0',
ID_MEMBER INT(8) UNSIGNED NOT NULL DEFAULT '0',
dateReceived DATE NOT NULL DEFAULT '0001-01-01',
favorite TINYINT(4) UNSIGNED NOT NULL DEFAULT '0',
UNIQUE KEY ID_AWARD_MEMBER (ID_AWARD_MEMBER),
KEY ID_AWARD (ID_AWARD)

Thanks for your help!

Offline littleone

Re: Need help with making an Item
« Reply #1 on: January 08, 2007, 06:56:49 am »
Its probably due to the fact that you have to had the "permissions" to add an award to a members album.  I was the one requested Jay make this mod.  Sorry have little experience with PHP but I know quite about about the Awards mod since it was made entirely to my specifications ;)

Offline Daniel15

Re: Need help with making an Item
« Reply #2 on: January 08, 2007, 03:49:36 pm »
The problem is this line:
Code: [Select]
INSERT INTO `{$db_prefix}awards_members` VALUES (20003, 2, {$ID_MEMBER}, 2007-01-07, 0);
You need to remove the semicolon at the end:
Code: [Select]
INSERT INTO `{$db_prefix}awards_members` VALUES (20003, 2, {$ID_MEMBER}, 2007-01-07, 0)

Offline Sakuragi

Re: Need help with making an Item
« Reply #3 on: January 08, 2007, 07:52:56 pm »
thank you!

Offline Sakuragi

Re: Need help with making an Item
« Reply #4 on: January 08, 2007, 09:42:11 pm »
now I need to integrate this querie on the BuyMembergroup item

Code: [Select]
<?php
/**********************************************\
| SMFSHOP (Shop MOD for Simple Machines Forum) |
|         (c) 2005 DanSoft Australia           |
|      http://www.dansoftaustralia.com/        |
\**********************************************/

//File: BuyMembergroup.php
//      Item

//VERSION: 1.0 (Build 1)
//DATE: Oct 22, 2006
//Author Chad

class item_BuyMembergroup extends itemTemplate {
    function 
getItemDetails() {
    
$this->authorName "Chad";

$this->authorWeb "http://www.aviary.info/";

$this->authorEmail "generalchad@gmail.com";

        
$this->name "Buy Membergroup";
        
$this->desc "Allows you to buy your way into a membergroup!";
        
$this->price 1500;

        
$this->require_input false;
        
$this->can_use_item true;
    }
    
function 
getAddInput() {
global $db_prefix$item_info;

            
$result db_query("SELECT groupName 
                                FROM 
{$db_prefix}membergroups"__FILE____LINE__);
            
$row mysql_fetch_array($resultMYSQL_ASSOC);

while (
$row mysql_fetch_array($resultMYSQL_NUM)) {
   
$groups.=("<OPTION id='x{$i}' value='{$row[0]}'>{$row[0]}");
   
$i++; 
}
           
return "Which Membergroup ID do you want to grant users access to?: <SELECT name='info1'>{$groups}</SELECT>";

}


    function 
onUse() {
        global 
$db_prefix$ID_MEMBER$item_info$user$sourcedir;

/////////////NOTICE  change the following ID or your item will fail.
$shophistoryID=0;//Set this to 0 if you don't have a shop history forum

//Begin Shop history
if ($shophistoryID)
{
require_once($sourcedir '/Subs-Post.php');
$topicOptions['board'] = $shophistoryID//SHOP history forum
$topicOptions['id']=0//NEW topic
$msgOptions['subject'] = "I just bought my way into the {$item_info[1]} membergroup!"//Subject
$msgOptions['body'] = "Yep!"
$posterOptions['id']=$ID_MEMBER//Current user's ID
createPost(&$msgOptions, &$topicOptions, &$posterOptions); //create the post using the SMF posting function
}
//End Shop history

$groupID mysql_fetch_array(db_query("SELECT `ID_GROUP` FROM {$db_prefix}membergroups WHERE groupName = '{$item_info[1]}'"__FILE____LINE__),MYSQL_ASSOC);
$additionalGroups mysql_fetch_array(db_query("SELECT `additionalGroups` FROM {$db_prefix}members WHERE ID_MEMBER = {$ID_MEMBER}"__FILE____LINE__),MYSQL_ASSOC);

if(
$additionalGroups['additionalGroups']) {
$additionalGroups['additionalGroups'] = $additionalGroups['additionalGroups'].", ".$groupID['ID_GROUP'];
} else {
$additionalGroups['additionalGroups'] = $groupID['ID_GROUP'];
}

echo 
$groupID['ID_GROUP'].":";
echo 
$additionalGroups['additionalGroups'];     


$result db_query("UPDATE {$db_prefix}members SET additionalGroups = '{$additionalGroups['additionalGroups']}'
         WHERE ID_MEMBER=
{$ID_MEMBER}",__FILE____LINE__);


$result db_query("
INSERT INTO `
{$db_prefix}awards_members` VALUES (20003, 2, {$ID_MEMBER}, 2007-01-07, 0)
"
);



        return 
"You're in the new group, {$item_info[1]}!!";
    }
}
?>

but when a user use this item, the second querie doesn't work :(
$result = db_query("
      INSERT INTO `{$db_prefix}awards_members` VALUES (20003, 2, {$ID_MEMBER}, 2007-01-07, 0)
         ");

Offline Sakuragi

Re: Need help with making an Item
« Reply #5 on: January 09, 2007, 11:54:25 pm »
*Bump*