Current time: 02-10-2012, 07:27 AM Hello There, Guest! (LoginRegister)




MySubscriptions, Donation Bar, MyDownloads, MyAchievements and support for our free and paid plugins. All that for $7!

Advertise Here!
Are you looking to advertise on this forum? Please read this announcement thread.


 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Release] MyPlaza [code] Thanks 1.0
06-21-2009, 02:56 AM (This post was last modified: 08-27-2009 05:09 PM by taxido.)
Post: #1
[Release] MyPlaza [code] Thanks 1.0
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]


Attached File(s)
.php  myplazacodethx.php (Size: 8.71 KB / Downloads: 23)
Find all posts by this user

06-21-2009, 03:00 AM
Post: #2
RE: MyPlaza CODE THX [Developement]
What should the plugin do? And what isn't it doing?

[Image: s.png]
Find all posts by this user
06-21-2009, 03:13 AM
Post: #3
RE: MyPlaza CODE THX [Developement]
Lol and you use MyPS in your code, this isn't MyPS it's MyPlaza Turbo lol...
- Shadows.

[Image: userbar.php?uid=259]
Geekhelps.net, the home of all geeks and webmasters!
Find all posts by this user
06-21-2009, 03:35 AM
Post: #4
RE: MyPlaza CODE THX [Developement]
(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
Find all posts by this user

06-21-2009, 03:43 AM
Post: #5
RE: MyPlaza CODE THX [Developement]
So what's not working? the payment part? This is great

[Image: s.png]
Find all posts by this user
06-21-2009, 04:18 AM
Post: #6
RE: MyPlaza CODE THX [Developement]
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
Find all posts by this user
06-21-2009, 08:40 AM
Post: #7
RE: MyPlaza CODE THX [Developement]
what's the line 113? Looks like you forgot to add global $db

[Image: s.png]
Find all posts by this user

06-22-2009, 09:48 PM
Post: #8
RE: MyPlaza CODE THX [Developement]
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?
Find all posts by this user
06-23-2009, 03:31 AM
Post: #9
RE: MyPlaza CODE THX [Developement]
are you getting any errors?

[Image: s.png]
Find all posts by this user
06-23-2009, 05:48 PM (This post was last modified: 06-23-2009 05:48 PM by taxido.)
Post: #10
RE: MyPlaza CODE THX [Developement]
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;
            } 
Find all posts by this user



Forum Jump:


User(s) browsing this thread: 1 Guest(s)