############################################################## ## MOD Title: MOD Playing cards ## MOD Author: Merlin Sythove Dennis www.pimpmyforum.nl ## MOD Description: Display playing cards from BBCode-like playing card codes ## MOD Version: 0.9.0 ## ## Installation Level: Easy ## Installation Time: 5 Minutes ## Files To Edit: ## includes/bbcode.php, ## includes/topic_review.php, ## search.php ## posting.php ## viewtopic.php ## Included Files: N/A ## License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2 ############################################################## ## For security purposes, please check: http://www.phpbb.com/mods/ ## for the latest version of this MOD. Although MODs are checked ## before being allowed in the MODs Database there is no guarantee ## that there are no security problems within the MOD. No support ## will be given for MODs not found within the MODs Database which ## can be found at http://www.phpbb.com/mods/ ############################################################## ## Author Notes: ## This mod changes the playing card codes to card images just prior to displaying a post. ## Card codes look like [9d Ah 7d] i.e. enclosed in square brackets are n 2-letter codes. ## Codes consist of A 2-9 T K Q J (Ace, 2-9, Ten, King, Queen, Knight) for the first letter ## and c h d s for clubs hearts diamonds spades for the second letter. ## For each card and each code there must be 1 image, Ace of hearts is Ah so ## in the folder /images/cards/Ah.gif must exist. Please note the capitalisation. ## So put 52 images in a new folder called images/cards. ## ## A single preg_replace will replace two-character card codes found between brackets ## with their image equivalent. ## Pattern syntax notes concerning the function in bbcode.php: ## ([A2-9TKQJ][cdhs]) This is the pattern for a card 2-letter code ## which will be replaced with the image file ## (?=[\w| ]*\]) This is the code that looks if the card code is followed by ## words and spaces only, plus a closing ]. ## ## ############################################################## ## MOD History: ## ## 2007-09-02 - Version 0.9.0 ## - Initial release, no updates to be expected. ## ############################################################## ## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD ############################################################## # #-----[ OPEN ]------------------------------------------ # includes/bbcode.php # #-----[ FIND ]------------------------------------------ # ?> # #-----[ BEFORE, ADD ]------------------------------------------ # function decode_playing_cards ($message) { //Replace card codes by images, IF followed by (more card code characters or spaces and) a closing ] $regexp = '([A2-9TKQJ][cdhs])(?=[A2-9TKQJ cdhs]*\])'; $message = preg_replace('/' . $regexp . '/', '', $message); //Get rid of the enclosing [] in the message around any card images $message = preg_replace('/\[(