Author Topic: Question on "Steal Credits"  (Read 9048 times)

Offline geezmo

Question on "Steal Credits"
« on: May 06, 2006, 07:07:40 pm »
My members are asking if it's possible to know who attempted to stole one's credits. Of course, once they knew who stole their credits, they can fight back!  ;D Hopefully this is possible.

Offline tazpot

Re: Question on "Steal Credits"
« Reply #1 on: May 06, 2006, 09:39:43 pm »
I don't think there is but i think it would only take a small piece of code that sends a PM to whoever is the chosen victim

Offline geezmo

Re: Question on "Steal Credits"
« Reply #2 on: May 06, 2006, 10:35:24 pm »
I'll appreciate it if someone can code this :)

Offline Basil Beard

Re: Question on "Steal Credits"
« Reply #3 on: May 07, 2006, 01:06:44 am »
Insert this code at the top of all your items, right below the <?php line.
Code: [Select]
global $sourcedir;
require_once($sourcedir . '/Subs-Post.php');

And insert this code at the end of the code for the actual item before the return line.
Code: [Select]

    $result = db_query("SELECT memberName
FROM {$db_prefix}members
        WHERE ID_MEMBER = {$ID_MEMBER}'", __FILE__, __LINE__);               
$row = mysql_fetch_array($result, MYSQL_ASSOC);
                        $theif = $row['memberName'];
    $result = db_query("SELECT ID_MEMBER
FROM {$db_prefix}members
        WHERE memberName = '{$_POST['stealfrom']}'}'", __FILE__, __LINE__);               
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$pmfrom = array(
'id' => 1,
'name' => 'Your name',
'username' => 'Your name'
);
$pmto = array(
'to' => array($row['ID_MEMBER']),
'bcc' => array()
);
sendpm($pmto, 'PM Subject', "Pm body. Use {$theif} for the name of the guy who stole, and {$steal_amount} for the amount of points stolen", 0, $pmfrom);
Arrrrr!

Offline geezmo

Re: Question on "Steal Credits"
« Reply #4 on: May 07, 2006, 02:52:24 am »
Hmm sorry but when you said

Quote
Insert this code at the top of all your items

did you mean add it to all .php files that are in shop items, as in AddToPostCount.php, ChangeOtherTitle.php, etc? Hmm that's a lot of files to edit...  :)

And this one, I didn't get this. Which template do I need to edit and I'll add this at the end of which code again?  ???
Quote
And insert this code at the end of the code for the actual item before the return line.

And in the last line,
Quote
sendpm($pmto, 'PM Subject', "Pm body. Use {$theif} for the name

Should I really use that spelling for thief cos the correct spelling is "thief"  :)

Thanks for the help!

Offline Basil Beard

Re: Question on "Steal Credits"
« Reply #5 on: May 07, 2006, 05:04:16 am »
No, just the item php files. Which are found in the scoures/shop/items directory. The file you should be editing for this would be steal.php.

And yeah, use theif because I used theif to define the variable eariler in the code
Code: [Select]
                        $theif = $row['memberName'];=P
Arrrrr!

Offline geezmo

Re: Question on "Steal Credits"
« Reply #6 on: May 07, 2006, 05:21:33 am »
Hmm sorry I still don't get it.

Code: [Select]
global $sourcedir;
require_once($sourcedir . '/Subs-Post.php');

So I add the code above in all of the php files in Sources/ shop/ items ?

Quote
Code: [Select]
$result = db_query("SELECT memberName
FROM {$db_prefix}members
  WHERE ID_MEMBER = {$ID_MEMBER}'", __FILE__, __LINE__);
$row = mysql_fetch_array($result, MYSQL_ASSOC);
 $theif = $row['memberName'];
$result = db_query("SELECT ID_MEMBER
FROM {$db_prefix}members
  WHERE memberName = '{$_POST['stealfrom']}'}'", __FILE__, __LINE__);
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$pmfrom = array(
'id' => 1,
'name' => 'Your name',
'username' => 'Your name'
);
$pmto = array(
'to' => array($row['ID_MEMBER']),
'bcc' => array()
);
sendpm($pmto, 'PM Subject', "Pm body. Use {$theif} for the name of the guy who stole, and {$steal_amount} for the amount of points stolen", 0, $pmfrom);

Then this code above I should add only to steal.php, is that correct?

Offline Basil Beard

Re: Question on "Steal Credits"
« Reply #7 on: May 07, 2006, 09:30:17 am »
You only need to add the
Code: [Select]
global $sourcedir;
require_once($sourcedir . '/Subs-Post.php');
Line before any item that sends PM. So in this case, just the steal item. If you were to make another item that sent PMs, you would need to include that code at the top as well as all the array stuff in the item code itself.
Arrrrr!

Offline lelele

Re: Question on "Steal Credits"
« Reply #8 on: May 08, 2006, 10:08:38 am »
Basil Beard,

Can you help me with a code that sends a pm to the Admin when each item is used? Thanks!

Offline Basil Beard

Re: Question on "Steal Credits"
« Reply #9 on: May 08, 2006, 11:45:50 pm »
There are two ways you could do this. You could add the sendpm stuff on each item you want sent to you, and make sure that the
to line of the sendpm array reads
Code: [Select]
    'to' => array(1), .

The other way is to add some sendpm code to the shop.php file itself, where the code that deletes the item is. If you were to do it this way, you could not say, record how much was stolen or things like that and it would not send if you used the die(); line to prevent the item from being deleted, but it would save a bunch lines of code.
Arrrrr!

Offline lelele

Re: Question on "Steal Credits"
« Reply #10 on: May 09, 2006, 12:29:41 pm »
Thanks a lot! I will try it as soon as possible

Offline tazpot

Re: Question on "Steal Credits"
« Reply #11 on: May 22, 2006, 04:33:38 am »
 ??? after trying the steal PM thing i had this message

Code: [Select]
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''' at line 5
File: /home/site name/public_html/smf/Sources/shop/items/Steal.php
Line: 155

I choose a person to stal from and press steal then that pops up

it refers to the WHERE ID_MEMBER  line

Code: [Select]
$result = db_query("SELECT memberName

                               FROM {$db_prefix}members

                               WHERE ID_MEMBER = {$ID_MEMBER}'", __FILE__, __LINE__);

            $row = mysql_fetch_array($result, MYSQL_ASSOC);
                        $theif = $row['memberName'];

Any ideas?

Offline tazpot

Re: Question on "Steal Credits"
« Reply #12 on: May 22, 2006, 08:53:23 pm »
Sorry my mistake i had forgot to add the

Code: [Select]
global $sourcedir;
require_once($sourcedir . '/Subs-Post.php');

but even with that fixed it doesn't send a PM ?

Offline Basil Beard

Re: Question on "Steal Credits"
« Reply #13 on: May 22, 2006, 11:26:16 pm »
Code: [Select]

                               WHERE ID_MEMBER = {$ID_MEMBER}", __FILE__, __LINE__);

Looks like it had an extra quote mark or something. Sorry about that.
Arrrrr!

Offline tazpot

Re: Question on "Steal Credits"
« Reply #14 on: May 23, 2006, 07:18:42 pm »
thanks Basil but it still won't send a pm although everything else works with no errors. I was looking through the code and was curious about this line and the extra exclamation and wavy bracket after 'stealfrom'  ?

Code: [Select]
WHERE memberName = '{$_POST['stealfrom']}'}'", __FILE__, __LINE__);
« Last Edit: May 23, 2006, 07:59:30 pm by tazpot »