MyBB-Plugins Forums

Full Version: [Release] MyPlaza [code] Thanks 1.0
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7
Hello, this is my first MyPlaza Turbo module.

It hides what is between code tags (in posts) to those who haven't clicked the "Thank you" link (instead of the content inside of the code tags, a Thank You link appears). By clicking the thank you clicking the users are paying a fee (set in the modules options) to the poster in order to view the code.

Quote:Changelog:
alpha 0.1
*initial release
alpha 0.2
*Add Ads
*fix some bugs
alpha 0.3
*add Unhide Groups
beta 0.4
*add $lang support
*English translate.
*Code clear
beta 0.5
*fix some bugs
beta 0.7
*Cost depends on the $mybb->user['postnum']
RC 0.9
*Code clear
1.0
*Security fix (Thanx for Pirata Nervo)
*fix Some bugs
*database query optymalization
*lang update

1.0.1
*bug fix





Hello. I'm try Coding MyPlaza Code THx plugin.

PHP Code:
<?php
/*
CODEthx (MyPlaza)
(c) 2009 by Hajlo.com Dariusz P
Website: http://www.hajlo.com
*/

if(!defined("IN_MYBB")) {
    die(
"This file cannot be accessed directly.");
}

$plugins->add_hook('parse_message_end''mypscode_do');
$plugins->add_hook("xmlhttp""myps_do_action");
$plugins->add_hook("showthread_start","myps_direct_action");



function 
mypscode_info() {
    return array(
        
"name"                => "Myps Code Tnx",
        
"description"        => " ",
        
"website"            => "http://hajlo.com",
        
"author"            => "Taxido",
        
"authorsite"        => "http://hajlo.com",
        
"version"            => "0.1"
    
);
}

function 
mypscode_activate() {
    global 
$db;
require 
MYBB_ROOT.'/inc/adminfunctions_templates.php';
    
    
//Tworze tabele do wstawiania THXów    
    
$query="CREATE TABLE IF NOT EXISTS ".TABLE_PREFIX."mypscodethx (
        txid INT UNSIGNED NOT NULL AUTO_INCREMENT ,
        adduid int( 10 ) NOT NULL ,
        pid int( 10 ) NOT NULL ,
        PRIMARY KEY ( txid ) 
        ) TYPE = MYISAM ;"
    
;
    
    
$db->query($query);
    
    
    

    
$mypscode_group = array(
        
'gid'            => 'NULL',
        
'name'            => 'mypscode',
        
'title'            => 'MyPScodeThnx',
        
'description'    => 'Settings For The MyPScodeThnx Plugin',
        
'disporder'        => '1',
        
'isdefault'        => 'no',
    );

    
$db->insert_query('settinggroups'$mypscode_group);
    
$gid $db->insert_id();

    
$mypscode_group_setting_1 = array(
        
'sid'            => 'NULL',
        
'name'            => 'enablemypscode',
        
'title'            => 'Enable MyPScode',
        
'description'    => 'If set to no, guests will be able to view codeblocks',
        
'optionscode'    => 'yesno',
        
'value'            => 'yes',
        
'disporder'        => 1,
        
'gid'            => intval($gid),
    );

    
$mypscode_setting_2 = array(
        
'sid'            => 'NULL',
        
'name'            => 'mypscode_text',
        
'title'            => 'Text to display  ',
        
'description'    => 'Will show up in the box instead of the code ',
        
'optionscode'    => 'text',
        
'value'            => 'You cannot view this code until you login or register',
        
'disporder'        => 2,
        
'gid'            => intval($gid),
    );

    
$db->insert_query('settings'$mypscode_setting_1);
    
$db->insert_query('settings'$mypscode_setting_2);
    
rebuild_settings();


}

function 
mypscode_deactivate() {
    global 
$db;
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='nocode'");
    
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN(
    'enablemypscode',
        'mypscode_text'
    )"
);
}

function 
mypscode_do() {
    
//global $db, $mybb, $pid, $post, $theme, $templates, $lang;

    /** Sprawdza czy gość, jeżeli nie to czy user podziÄ™kowaÅ‚, jeÅ›li tak wyÅ›wietla zawartość. **/
    
    
global $lang,$mybb,$db;
    
$enable=$mybb->settings['enablemypscode'];

    
    
//Czy zalogowany
    
if ($mybb->user['uid'] != '' OR $enable == '0')
    {
    function 
checkq()
    {
    
$queryTABLE_PREFIX."thx" ;
    
$query1="adduid='{$mybb->user['uid']}' AND pid='$pid'" ;
    
$check_query $db->simple_select($query"*"$query1);
    if(
$db->num_rows($check_query))
    {return;}
    else
    {return 
false;}
    }
    
        if(
checkq())
            {
                return;
            }
        else if (
$mybb->user[MYPLAZA_MONEY_COLUMN])
            {
        
$new1'<b>Masz zbyt ma³o HLN aby ods³oniæ t¹ zawartoϾ</b>';
        
$message=preg_replace("#<code>(.*?)</code>#ims","<code>$new1</code>",$message);
        return 
$message;
            }
    }
    else {
        
$new=$mybb->settings['nocode_text'];
        
$message=preg_replace("#<code>(.*?)</code>#ims","<code>$new</code>",$message);
        return 
$message;
    }

}


function 
thx($post) {
    global 
$db$mybb$lang $altbg,$templates;
    
    
    
$lang->load("thx");
    
    
$b=0//dose user thank this post?
    
$entries=build_thank($post['pid'],$b);
    
    
     if(
$mybb->user['uid'] != && $mybb->user['uid'] != $post['uid']) 
    {
        if(!
$b)  //show thank button 
            
$post['thanks'] = "<a id=\"a{$post['pid']}\" onclick=\"javascript:return thx({$post['pid']});\" href=\"showthread.php?action=mypsthank&tid={$post['tid']}&pid={$post['pid']}\">
            <img 
            src=\"images/
{$lang->language}/postbit_thx.gif\" border=\"0\" alt=\"$lang->thx_main\" id=\"i{$post['pid']}\" /></a>";
        
    
    }


    
    
        
    
$display$entries ?  """none" ;
        
    
                        
    
    
}

//sprawdzanie czy user ma kase
$cost 1;
    if(
$cost && $cost $mybb->user[MYPLAZA_MONEY_COLUMN])
    {
        
$buyRtnMsg $lang->insufficient_money;
        return 
false;
    }
    
    
    
    

function 
direct_action()
{
    
    global 
$mybb,$lang;
    if(
$mybb->input['action'] != "thank")
        return;
        
    
$lang->load("thx");
    
$pid=intval($mybb->input['pid']);
    
    if (
$mybb->input['action'] == "thank" )
        {
        
$cost 1;
        if(
$cost $mybb->user[MYPLAZA_MONEY_COLUMN])
            {
                
$buyRtnMsg $lang->insufficient_money;
                return 
false;
            }
        else
        {
            
do_thank($pid); 
            
redirect($_SERVER['HTTP_REFERER']);
        }
}

}

/*
function build_thank($pid,&$is_thx)
{
    $is_thx=0;
    global $db,$mybb;
    $query=$db->query( "SELECT  th.* , u.username ,u.usergroup ,u.displaygroup
                        FROM ".TABLE_PREFIX."thx th
                        JOIN ".TABLE_PREFIX."users u ON(th.adduid=u.uid)
                        WHERE th.pid='$pid'
                        ORDER BY th.time ASC");
    
    

    while($record = $db->fetch_array($query))
    {
        $is_thx+=$record['adduid']==$mybb->user['uid'];
        $date=my_date($mybb->settings['dateformat'].' '.$mybb->settings['timeformat'],$record['time']);
        $url=get_profile_link($record['adduid']);
        $name=format_name($record['username'], $record['usergroup'], $record['displaygroup']);
        $entries .= "".$r1comma."<a href=\"$url\">$name</a> <span class=\"smalltext\">(".$date.")</span>";
            
        $r1comma =", ";
    }
    
    return $entries;
}

*/

//Funkcja dziêkowania

function do_thank($pid)
{


    global 
$db,$mybb;
    
$check_query $db->simple_select(TABLE_PREFIX."thx","*" ,"adduid='{$mybb->user['uid']}' AND pid='$pid'");
    if(
$db->num_rows($check_query))
        return;
    
$check_query $db->simple_select(TABLE_PREFIX."posts","uid","pid='$pid'");
    if(
$db->num_rows($check_query)==1)//  post exsits
    
{
        
$tmp=$db->fetch_array($check_query);    
        
$database = array (
            
"uid" =>$tmp['uid'], 
            
"adduid" => $mybb->user['uid'],
            
"pid" => $pid            
        
);
        
$db->insert_query(TABLE_PREFIX."thx"$database); //add thank to thx table
        
}    


But don't work. I'm don't know what I'm doing bad. Please help

Sorry for my bad english. I'm from Poland[/code]
What should the plugin do? And what isn't it doing?
Lol and you use MyPS in your code, this isn't MyPS it's MyPlaza Turbo lol...
- Shadows.
(06-21-2009, 03:13 AM)Shadows Wrote: [ -> ]Lol and you use MyPS in your code, this isn't MyPS it's MyPlaza Turbo lol...
- Shadows.

First I'm coded this plugin for myps but MyPlaza is the best.

This plugin is fusion MyPlaza, ThankMod and Nocode.
Users may unhide Code in Post per Myps
So what's not working? the payment part? This is great
After install I have
Code:
Fatal error: Call to a member function simple_select() on a non-object in /home/hajlo/domains/hajlo.com/public_html/inc/plugins/mypscode.php on line 113
I don't know how check is user thanked
what's the line 113? Looks like you forgot to add global $db
Thanks.
I have one more question.

PHP Code:
function checkq()
    {
    global 
$mybb$db$pid;
    
$pid=$post['pid'];
    
$check_query $db->simple_select("thx" "*""adduid='{$mybb->user['uid']}' AND pid='$pid'");
    if(
$db->num_rows($check_query)>0)
    {return 
true;}
    else
    {return 
false;}
    } 

Please tell me what I'm doing wrong in this function?
are you getting any errors?
No, but function not return any variable.

table thx

uid adduid pid
3 1 117061
647 1 116887
21 1 117211

PHP Code:
function myplazacode_checkq($pid$adduid)
    {
    global 
$mybb$db$pid;
    
$check_query $db->simple_select("thx" "*""adduid='$adduid' AND pid='$pid'");
    if(
$db->num_rows($check_query))
        return ;
    } 

PHP Code:
$adduid=$mybb->user['uid'];
    
$pid=$post['pid'];
        if(
myplazacode_checkq($pid$adduid)==OR $mybb->user['uid'] == $post['uid'])
            {
                return;
            } 
Pages: 1 2 3 4 5 6 7