View Single Post
  #191  
Old 09-08-2009, 02:28 PM
Najoh Najoh is offline
 
Join Date: Aug 2009
Posts: 15
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have modified the xml and its working on the last version 3.8.4 :

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>

<product productid="dice" active="1">
	<title>Dice Roller</title>
	<description>Rolls dice in postbit</description>
	<version>1.0</version>
	<codes>
		<code version="1.0">
			<installcode><![CDATA[$vbulletin->db->query_write("ALTER TABLE `vbulletin_thread` ADD `dice` MEDIUMTEXT NOT NULL");
$vbulletin->db->query_write("ALTER TABLE `vbulletin_post` ADD `dice` mediumtext not null");]]></installcode>
			<uninstallcode><![CDATA[$vbulletin->db->query_write("ALTER TABLE `thread` DROP COLUMN `dice`");
$vbulletin->db->query_write("ALTER TABLE `vbulletin_post` DROP COLUMN `dice` ");]]></uninstallcode>
		</code>
	</codes>
	<templates>
		<template name="dice" templatetype="template" date="1145915902" username="admin" version="3.5.4"><![CDATA[<img src="images/dice/$point.gif" width="63" height="62" />]]></template>
		<template name="postbit_dice" templatetype="template" date="1145915990" username="admin" version="3.5.4"><![CDATA[<table border="0" align="center" width="90%" cellpadding="3" cellspacing="1">
<tr>
  <td><smallfont><b>Dice roll with $dicesno dices of $dicesfaces faces: $dicepoints points</b></smallfont></td>
</tr>
<tr>
  <td style="BORDER: #000000 1px solid; FONT-SIZE: 11px; COLOR: #000000; BACKGROUND-COLOR: #D7D7D7;">
$dicedata
</td>
</tr>
</table><br/>]]></template>
	</templates>
	<plugins>
		<plugin active="1">
			<title>dice_process_data</title>
			<hookname>newpost_process</hookname>
			<phpcode><![CDATA[// Hack
                if (@eregi("\[dice",$post['message']))
                {
                        $diceresult = array();
                        preg_match_all("/\[dice=([1-5])\]([0-9]?[0-9])\[\/dice\]/",$post['message'],$diceresult);
                        
                        $dices = $diceresult[1];
                        $faces = $diceresult[2];

                        $dicedetail = array();
                        $rollcount = count($dices);
                        
                        $validdice = 0;
                        for ($i = 0; $i < $rollcount; $i++)
                        {
                                if ($faces[$i] >= 2 && $faces[$i] <= 30)
                                {
                                        $diceresult[0][$i] = str_replace("[","\[",$diceresult[0][$i]);
                                        $diceresult[0][$i] = str_replace("]","\]",$diceresult[0][$i]);
                                        $diceresult[0][$i] = str_replace("/","\/",$diceresult[0][$i]);                                                
                                        $post['message'] = preg_replace("/".$diceresult[0][$i]."/","[dice".($validdice)."]",$post['message'],1);
                                
                                        $dicedetail[$validdice]['dices'] = $dices[$i];
                                        $dicedetail[$validdice]['faces'] = $faces[$i];
                                        $dicedetail[$validdice]['data'] = array();
                                        for ($j = 0; $j < $dices[$i]; $j++)
                                        {
                                                $dicedetail[$validdice]['data'][] = rand(1,$faces[$i]);         
                                        }
                                        $validdice++;
                                }
                        }
                        
                        if (!empty($dicedetail))
                        {
                                   $dataman->set('dice',serialize($dicedetail));
                        }
                }
                // End Hack]]></phpcode>
		</plugin>
		<plugin active="1">
			<title>dice_postbit_convert</title>
			<hookname>postbit_display_complete</hookname>
			<phpcode><![CDATA[// Hack: dice
	if ($post['dice'])
        {
        	$dicearray = unserialize($post['dice']);
		$totalroll = count($dicearray);
                
		for ($i = 0; $i < $totalroll; $i++)
                {
			$dicedata = "";                
	                $dicepoints = 0;
	                $dicesno = $dicearray[$i]['dices'];
	                $dicesfaces = $dicearray[$i]['faces'];
                        
	                foreach ($dicearray[$i]['data'] as $point)
	                {
	                        eval('$dicedata .= "' . fetch_template("dice") . '";');
	                        $dicepoints += $point;                  
	                }
	                eval('$dice = "' . fetch_template("postbit_dice") . '";');

	                $post['message'] = preg_replace("/\[dice$i\]/i","$dice",$post['message']);
                }
        }]]></phpcode>
		</plugin>
		<plugin active="1">
			<title>dice_set_valid_fields</title>
			<hookname>postdata_start</hookname>
			<phpcode><![CDATA[$this->validfields['dice'] = array(TYPE_STR, REQ_NO);]]></phpcode>
		</plugin>
		<plugin active="1">
			<title>dice_set_valid_fields_new_thread</title>
			<hookname>threadfpdata_start</hookname>
			<phpcode><![CDATA[$this->validfields['dice'] = array(TYPE_STR, REQ_NO);]]></phpcode>
		</plugin>
	</plugins>
	<phrases>
	</phrases>
	<options>
	</options>
</product>
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01722 seconds
  • Memory Usage 1,798KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete