Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 09-09-2009, 02:44 PM
sparklywater sparklywater is offline
 
Join Date: Jun 2008
Posts: 248
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Parsing smilies in a message

I'm trying to use the following code to parse smilies in a message / text, but the smilies don't appear. What am I doing wrong?

PHP Code:
require_once(DIR '/includes/class_bbcode.php');
    
$bbcode_parser =& new vB_BbCodeParser($vbulletinfetch_tag_list());
    
$message $bbcode_parser->parse($pm['message'], 'privatemessage'true); 
Reply With Quote
  #2  
Old 09-09-2009, 03:28 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You set the $append_custom_tags value to true and I think you want to pass disablesmilies set to false. I'm not positive about that, but true it. (See the functions in includes/class_bbcode.pp around line 160.)
Reply With Quote
  #3  
Old 09-11-2009, 04:47 AM
sparklywater sparklywater is offline
 
Join Date: Jun 2008
Posts: 248
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've tried setting $append_custom_tags to true and disable_smilies to false, but the smilies still don't appear. Other types of bbcode formatting is working, such as bold text / font size, it's just the smilies that don't work. I'm trying to get them to appear inside a page in the AdminCP (a file in the admincp/ folder).
Reply With Quote
  #4  
Old 09-11-2009, 02:27 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It's hard to know if you did it correctly since you didn't paste the text you added.

You may want to post up all the code so someone can test it if they want to help out.
Reply With Quote
  #5  
Old 09-11-2009, 04:08 PM
sparklywater sparklywater is offline
 
Join Date: Jun 2008
Posts: 248
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I changed disable_smilies settings to false in the file class_bbcode.php.

This is how i changed the original code to set $append_custom_tags to true but it didn't work:

PHP Code:
#### parse message
    
require_once(DIR '/includes/class_bbcode.php');
    
$bbcode_parser =& new vB_BbCodeParser($vbulletinfetch_tag_list(), true);
    
$message $bbcode_parser->parse($pm['message'], 'privatemessage'true);
    
################## 

The following is the complete code for the AdminCP file. The part near the middle/top half shows where I made the $append_custom_tags change.

PHP Code:
<?php
// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### PRE-CACHE TEMPLATES AND DATA ######################
$phrasegroups = array('style');
$specialtemplates = array('products');

// ########################## REQUIRE BACK-END ############################
require_once('./global.php');
require_once(
DIR '/includes/adminfunctions_template.php');


$this_script 'read_pms';

$rpm_ver 0.7;

$rpm_mouseover_fontcolor '#D04850';

// ########################## SUPERADMIN CHECK ############################
if (!in_array($vbulletin->userinfo['userid'], preg_split('#\s*,\s*#s'$vbulletin->config['SpecialUsers']['superadministrators'], -1PREG_SPLIT_NO_EMPTY)) ) {
    
rpm_print_stop_back("You don't have permission to access this page.");
}

print_cp_header();





/////////////////////// front page
if ( empty($_REQUEST['do']) ) {
    
print_form_header($this_script'list'01'listForm');
    
print_table_header('Read PMs');
    
print_input_row('User ID or Username''userid');
    
print_submit_row('Read PMs'0);

    
print_form_header($this_script'havepms'01'resetForm');
    
print_submit_row('List Users with PMs'0);

    
print_form_header($this_script'search'01'searchForm');
    
print_table_header('Search for PMs');
    
print_textarea_row('Search for''search');
    
print_radio_row('Match''match', array( 'exact' => 'exact text''all' => 'all words',
'atleastone' => 'at least one of the words' ), 'exact'); 
    
//print_input_row('User ID<br /><div class="smallfont"><em>optional</em></div>', 'userid');
    
print_submit_row('Search for PMs'0);

    
print_form_header($this_script'latest'01'latestForm');
    
print_table_header('Latest PMs');
    
print_input_row('Number of PMs to show''showlatest''100');
    
print_submit_row('Latest PMs'0);
}




/////////////////////// search
if ( $_REQUEST['do'] == 'search' ) {
    if ( empty(
$_REQUEST['search']) ) { rpm_print_stop_back('You must write what you are searching for.'); }
    
    
$match $_REQUEST['match'];
    
$search_for $db->escape_string$_REQUEST['search'] );
    
    
$pms rpm_search_pms($search_for$match);
    
    
// print pms list
    
print_form_header(''''01'pmlistForm');
    
print_table_header('Search Results ('.count($pms).')');
    foreach (
$pms AS $pm) {
        
$userids rpm_get_userids($pm['pmtextid']);
        foreach (
$userids AS $id) {
            
$link $this_script.'.php?do=read&userid='.$id.'&pmtextid='.$pm['pmtextid'];
            
$row '<hr /><div class="smallfont"><a href="'.$link.'">';
            
$row .= ''.htmlspecialchars($pm['title']);
            
$row .= ' - from '.$pm['fromusername'];
            
$row .= ' - owner '.rpm_get_name($id);
            
$row .= ' - '.vbdate($vbulletin->options['dateformat'], $pm['dateline'], true);
            
$row .= ' '.vbdate($vbulletin->options['timeformat'], $pm['dateline']);
  
$to is_array(unserialize($pm['touserarray'])) ? implode(", "array_values(unserialize($pm['touserarray']))) : null;
            
$to = ($to == 'Array') ? htmlspecialchars($pm['touserarray']) : $to;
            
$row .= ' - to '.$to;
            
print_description_row($row.'</a></div>');


#### parse message
    
require_once(DIR '/includes/class_bbcode.php');
    
$bbcode_parser =& new vB_BbCodeParser($vbulletinfetch_tag_list());
    
$message $bbcode_parser->parse($pm['message'], 'privatemessage'true);
    
##################

                
print_label_row('Message''<div class="smallfont">'.$message.'</div>');


        }
    }
    
print_table_footer(2construct_button_code($vbphrase['go_back'], 'javascript:history.back(1)'));
}




/////////////////////// list
if ( $_REQUEST['do'] == 'list' ) {
    if ( empty(
$_REQUEST['userid']) ) { rpm_print_stop_back('Need a User ID or Username.'); }
    
    if ( !
is_numeric($_REQUEST['userid']) ) {
        
$userid rpm_username_exists($_REQUEST['userid']);
        if ( empty(
$userid) ) { rpm_print_stop_back('User '.$_REQUEST['userid'].' does not exist.'.$userid); }
    } else {
        if ( !
rpm_user_exists($_REQUEST['userid']) ) { rpm_print_stop_back('User '.$_REQUEST['userid'].' does not exist.'); }
        
$userid $_REQUEST['userid'];
    }
    
    
$pms rpm_get_pms($userid);
    
    if ( empty(
$pms) ) { rpm_print_stop_back('User '.$_REQUEST['userid'].' has no pms.'); }
    
    
$name rpm_get_name($userid);
    
    
### Separate sent from received
    
$sent = array(); $received = array();
    foreach (
$pms AS $pm) {
        if (
$pm['fromusername'] == $name) {
            
$sent[] = $pm;
        } else {
            
$received[] = $pm;
        }
    }
    
###############################
    
    


    



    // print sent pms list
    
print_form_header(''''01'sentpmlistForm');
    
print_table_header('Sent PMs for: '.$name.' ('.count($sent).' total pms)');
    foreach (
$sent AS $pm) {
        
$link $this_script.'.php?do=read&userid='.$userid.'&pmtextid='.$pm['pmtextid'];
        
$row '<hr /><div class="smallfont"><a href="'.$link.'">';
        
$row .= ''.htmlspecialchars($pm['title']);
        
$row .= ' - from '.$pm['fromusername'];
        
$row .= ' - '.vbdate($vbulletin->options['dateformat'], $pm['dateline'], true);
        
$row .= ' '.vbdate($vbulletin->options['timeformat'], $pm['dateline']);
                
$to is_array(unserialize($pm['touserarray'])) ? implode(", "array_values(unserialize($pm['touserarray']))) : null;
            
$to = ($to == 'Array') ? htmlspecialchars($pm['touserarray']) : $to;
            
$row .= ' - to '.$to;
               
print_description_row($row.'</a></div>');

#### parse message
    
require_once(DIR '/includes/class_bbcode.php');
    
$bbcode_parser =& new vB_BbCodeParser($vbulletinfetch_tag_list(), true);
    
$message $bbcode_parser->parse($pm['message'], 'privatemessage'true);
    
##################

                
print_label_row('Message''<div class="smallfont">'.$message.'</div>');
    }
    
print_table_footer(2construct_button_code($vbphrase['go_back'], 'javascript:history.back(1)'));
    
    
// print received pms list
    
print_form_header(''''01'receivedpmlistForm');
    
print_table_header('Received PMs for: '.$name.' ('.count($received).' total pms)');
    foreach (
$received AS $pm) {
        
$link $this_script.'.php?do=read&userid='.$userid.'&pmtextid='.$pm['pmtextid'];
        
$row '<hr /><div class="smallfont"><a href="'.$link.'">';
        
$row .= ''.htmlspecialchars($pm['title']);
        
$row .= ' - from '.$pm['fromusername'];
        
$row .= ' - '.vbdate($vbulletin->options['dateformat'], $pm['dateline'], true);
        
$row .= ' '.vbdate($vbulletin->options['timeformat'], $pm['dateline']);
  
$to is_array(unserialize($pm['touserarray'])) ? implode(", "array_values(unserialize($pm['touserarray']))) : null;
            
$to = ($to == 'Array') ? htmlspecialchars($pm['touserarray']) : $to;
            
$row .= ' - to '.$to;
        
print_description_row($row.'</a></div>');


#### parse message
    
require_once(DIR '/includes/class_bbcode.php');
    
$bbcode_parser =& new vB_BbCodeParser($vbulletinfetch_tag_list());
    
$message $bbcode_parser->parse($pm['message'], 'privatemessage'true);
    
##################

                
print_label_row('Message''<div class="smallfont">'.$message.'</div>');


    }
    
print_table_footer(2construct_button_code($vbphrase['go_back'], 'javascript:history.back(1)'));
    
    
    
/*echo '<pre>';
    print_r( $pms );
    echo '</pre>';*/
}




/////////////////////// latest
if ( $_REQUEST['do'] == 'latest' ) {
    if ( empty(
$_REQUEST['showlatest']) ) { rpm_print_stop_back('Need a number.'); }
    
    if ( !
is_numeric($_REQUEST['showlatest']) ) { rpm_print_stop_back('Need a number.'); }
    
    
$pms rpm_get_latest_pms($_REQUEST['showlatest']);
    
    if ( empty(
$pms) ) { rpm_print_stop_back('No pms.'); }
    

// print pms list



    
print_form_header(''''01'pmlistForm');
    
print_table_header('Latest '.$n.' PMs ('.count($pms).' total pms)');
    foreach (
$pms AS $pm) {
        
$link $this_script.'.php?do=read&userid='.$pm['userid'].'&pmtextid='.$pm['pmtextid'];
        
$row '<hr /><div class="smallfont"><a href="'.$link.'">';
        
$row .= ''.htmlspecialchars($pm['title']);
        
$row .= ' - from '.$pm['fromusername'];
        
$row .= ' - '.vbdate($vbulletin->options['dateformat'], $pm['dateline'], true);
        
$row .= ' '.vbdate($vbulletin->options['timeformat'], $pm['dateline']);
          
$to is_array(unserialize($pm['touserarray'])) ? implode(", "array_values(unserialize($pm['touserarray']))) : null;
            
$to = ($to == 'Array') ? htmlspecialchars($pm['touserarray']) : $to;
            
$row .= ' - to '.$to;
        
print_description_row($row.'</a></div>');


#### parse message
    
require_once(DIR '/includes/class_bbcode.php');
    
$bbcode_parser =& new vB_BbCodeParser($vbulletinfetch_tag_list());
    
$message $bbcode_parser->parse($pm['message'], 'privatemessage'true);
    
##################

                
print_label_row('Message''<div class="smallfont">'.$message.'</div>');



    }
    
print_table_footer(2construct_button_code($vbphrase['go_back'], 'javascript:history.back(1)'));
    
    
    
/*echo '<pre>';
    print_r( $pms );
    echo '</pre>';*/
}





/////////////////////// read
if ( $_REQUEST['do'] == 'read' ) {
    if ( empty(
$_REQUEST['pmtextid']) ) { rpm_print_stop_back('Need a pmtextid.'); }
    if ( !
is_numeric($_REQUEST['pmtextid']) ) { rpm_print_stop_back('Pmtextid must be a number.'); }
    
    
$pm rpm_get_pm($_REQUEST['pmtextid']);
    
    if ( empty(
$pm) ) { rpm_print_stop_back('Pmtextid '.$_REQUEST['pmtextid'].' does not exist.'); }
    
    
$a $db->query_first("SELECT userid FROM " TABLE_PREFIX "pm WHERE pmtextid = ".$_REQUEST['pmtextid']);
    
    
$name rpm_get_name($a['userid']);
    
    
// show pm
    
print_form_header(''''01'pmlistForm');
    
print_table_header('PM for: '.$name);
    
print_label_row('From'$pm['fromusername'] . ' (userid '.$pm['fromuserid'].')');
    
// print_label_row('To', htmlspecialchars($pm['touserarray']));
    
$to is_array(unserialize($pm['touserarray'])) ? implode(", "array_values(unserialize($pm['touserarray']))) : null;
    
$to = ($to == 'Array') ? htmlspecialchars($pm['touserarray']) : $to;
    
print_label_row('To' $to);
    
print_label_row('Date'vbdate($vbulletin->options['dateformat'], $pm['dateline'], true) .' 'vbdate($vbulletin->options['timeformat'], $pm['dateline']));
    
print_label_row('Title'htmlspecialchars($pm['title']));
    
    
#### parse message
    
require_once(DIR '/includes/class_bbcode.php');
    
$bbcode_parser =& new vB_BbCodeParser($vbulletinfetch_tag_list());
    
$message $bbcode_parser->parse($pm['message'], 'privatemessage'true);
    
##################
    
    
print_label_row('Message''<div class="smallfont">'.$message.'</div>');
    
print_table_footer(2construct_button_code($vbphrase['go_back'], 'javascript:history.back(1)'));
}




/////////////////////// have pms
if ( $_REQUEST['do'] == 'havepms' ) {
    
$havepms rpm_get_users_that_have_pms();
    
    
    
// show list
    
print_form_header(''''01'havepmslistForm');
    
print_table_header('Users with PMs ('.count($havepms).')');
    foreach (
$havepms AS $pms) {
        
$name rpm_get_name($pms['userid']);
        
$link $this_script.'.php?do=list&userid='.$pms['userid'];
        
$row '<div><a href="'.$link.'">'.$name;
        
$row .= ' ('.$pms['numberpms'].' pms)';
        
print_description_row($row.'</a></div>');
    }
    
print_table_footer(2construct_button_code($vbphrase['go_back'], 'javascript:history.back(1)'));
}








#############################################################
############################################################
######## functions

function rpm_get_userids($pmtextid) {
    global 
$db;
    
$sql 
"SELECT userid 
FROM " 
TABLE_PREFIX "pm 
WHERE pmtextid = 
$pmtextid";
    
$result $db->query_read($sql);
    
$userids = array();
    while( 
$a $db->fetch_array$result ) ) {
        
$userids[] = $a['userid'];
    }
    return 
$userids;
}

function 
rpm_search_pms($search_for$match) {
    global 
$db;
    if (
$match == 'exact') {
        
$sql 
"SELECT * 
FROM " 
TABLE_PREFIX "pmtext 
WHERE message LIKE '%
$search_for%'
ORDER BY dateline DESC"
;
    } elseif (
$match == 'all') {
        
$a explode(' '$search_for);
        
$ands implode("%' AND message LIKE '%"$a);
        
$sql 
"SELECT * 
FROM " 
TABLE_PREFIX "pmtext 
WHERE message LIKE '%
$ands%' 
ORDER BY dateline DESC"
;
    } else {
        
$a explode(' '$search_for);
        
$ors implode("%' OR message LIKE '%"$a);
        
$sql 
"SELECT * 
FROM " 
TABLE_PREFIX "pmtext 
WHERE message LIKE '%
$ors%' 
ORDER BY dateline DESC"
;
    }
    
$result $db->query_read($sql);
    
$pms = array();
    while( 
$a $db->fetch_array$result ) ) {
        
$pms[] = $a;
    }
    return 
$pms;
}

function 
rpm_get_users_that_have_pms($orderby 'pmid') {
    global 
$db;
    
$sql 
"SELECT userid, count(pmid) AS numberpms 
FROM " 
TABLE_PREFIX "pm 
GROUP BY userid 
ORDER BY 
$orderby DESC";
    
$result $db->query_read($sql);
    
$r = array();
    while( 
$a $db->fetch_array$result ) ) {
        
$r[] = array( 
        
'userid' => $a['userid'], 
        
'numberpms' => $a['numberpms'
        );
    }
    return 
$r;
}

function 
rpm_get_name ($userid) {
    global 
$db;
    
$result $db->query_first("SELECT username FROM " TABLE_PREFIX "user WHERE userid = $userid");
    return 
$result['username'];
}

function 
rpm_get_pm ($pmtextid) {
    global 
$db;
    return 
$db->query_first("SELECT * FROM " TABLE_PREFIX "pmtext WHERE pmtextid = $pmtextid");
}

function 
rpm_user_exists ($userid) {
    global 
$db;
    
$exists $db->query_first("SELECT userid FROM " TABLE_PREFIX "user WHERE userid = $userid");
    if (
$exists) {return true;} else {return false;}
}

function 
rpm_username_exists ($username) {
    global 
$db;
    
$exists $db->query_first("SELECT userid FROM " TABLE_PREFIX "user WHERE LOWER(username) = LOWER('".$db->escape_string($username)."')");
    if (
$exists) {return $exists['userid'];} else {return false;}
}

function 
rpm_get_pms ($userid) {
    global 
$db;
    
$pmtextids rpm_get_pmtextids($userid);
    if (empty(
$pmtextids)) {return false;}
    
$ors implode(' OR pmtextid = '$pmtextids);
    
$sql 
"SELECT * 
FROM " 
TABLE_PREFIX "pmtext 
WHERE pmtextid = " 
$ors 
ORDER BY dateline DESC"
;
    
$result $db->query_read($sql);
    
$pms = array();
    while( 
$a $db->fetch_array$result ) ) {
        
$pms[] = $a;
    }
    return 
$pms;
}

function 
rpm_get_latest_pms ($n) {
    global 
$db;
    
$sql 
"SELECT * 
FROM " 
TABLE_PREFIX "pmtext 
ORDER BY dateline DESC 
LIMIT 0, "
.$n;
    
$result $db->query_read($sql);
    
$pms = array();
    while( 
$a $db->fetch_array$result ) ) {
        
$pms[] = $a;
    }
    return 
$pms;
}

function 
rpm_get_pmtextids ($userid) {
    global 
$db;
    
$sql 
"SELECT pmtextid 
FROM " 
TABLE_PREFIX "pm 
WHERE userid = 
$userid";
    
$result $db->query_read($sql);
    
$pmtextids = array();
    while( 
$a $db->fetch_array$result ) ) {
        
$pmtextids[] = $a['pmtextid'];
    }
    return 
$pmtextids;
}

function 
rpm_print_stop_back ($text 'error') {
    global 
$vbphrase;
    if (!
defined('DONE_CPHEADER')) { print_cp_header($vbphrase['vbulletin_message']); }
    echo 
'<p>&nbsp;</p><p>&nbsp;</p>';
    
print_form_header(''''01'messageform''65%');
    
print_table_header($vbphrase['vbulletin_message']);
    
print_description_row("<blockquote><br />$text<br /><br /></blockquote>");
    
print_table_footer(2construct_button_code($vbphrase['go_back'], 'javascript:history.back(1)'));
    
rpm_print_footer();
    
print_cp_footer();
}



function 
rpm_print_footer () {
    global 
$rpm_ver;
    echo 
'<p align="center"><a href="https://vborg.vbsupport.ru/showthread.php?t=91369" target="_blank" class="copyright">read pms v'.$rpm_ver.'</a></p>';
}

rpm_print_footer();
print_cp_footer();
?>
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:33 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.08246 seconds
  • Memory Usage 2,432KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete