vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Parsing HTML code from a template, to PM. Help?? (https://vborg.vbsupport.ru/showthread.php?t=45078)

Velocd 10-27-2002 09:03 PM

Parsing HTML code from a template, to PM. Help??
 
I'm creating a hack that during one of the processes it takes HTML code from a template and sends it to a specified user as a personal message.

The only problem is the HTML code is not parsed.

Say my template called priv_forwardpost contains:
Code:

<a href="http://www.lycos.com">hello</a>
Well, in the PM to that user, when he reads it will show exactly as:
Code:

<a href="http://www.lycos.com">hello</a>
With not links. I have tried using htmlspecialchars() or bbcodeparse() or addslashes(), just to see if they would do anything put they don't :(

Basically here is the small part of my code where the problem exists:
PHP Code:

eval("\$message = \"".gettemplate("priv_forwardpost",1,0)."\";");

$DB_site->query("INSERT INTO privatemessage (privatemessageid,userid,touserid,fromuserid,title,message,dateline,messageread,folderid) VALUES (NULL,$pm_userid,$pm_userid,$bbuserinfo[userid],'".addslashes(htmlspecialchars($pm_title))."','".addslashes($message)."',".time().",0,0)"); 

So how can I get it when the user views the PM, the $message is parsed and HTML shows?

Thanks if you can help.

NTLDR 10-27-2002 09:07 PM

I would have thought the problem would have been that the PM system doesn't parse HTML (for security reasons) which is why it is appearing as the source.

Velocd 10-27-2002 09:33 PM

I've found this more than likely to be the problem after viewing private.php.

What I'm needing help for then is a way to bypass the block just for my hack, but not to interfer with regular PM messanging.


For example, say my template priv_forwardpost contained this:
Code:

[_url]http://www.lycos.com[/url]
(without the underscore)

Now, wouldn't it seem logical that if I sent this into the database using addslashes(), then it would produce normal when viewing the PM? As parsed?

Only problem is that I can't even get this submitted into the database without recieving a database error, something about it containing bbcode in the template is interferring...

NTLDR 10-27-2002 09:44 PM

This should work, I don't see why it shouldn't (I don't know if the " around $message will make a difference or not?).

PHP Code:

$DB_site->query("INSERT INTO privatemessage (privatemessageid,userid,touserid,fromuserid,title,message,dateline,messageread,folderid) VALUES (NULL,$pm_userid,$pm_userid,$bbuserinfo[userid],'".addslashes(htmlspecialchars($pm_title))."','".addslashes("$message")."',".time().",0,0)"); 

It should parse the vB Code like it would if a user was sending it.

Velocd 10-27-2002 10:08 PM

Ok..lol, I've found the error but now I'm pondering on a way to fix it.

It error was in the [_url][/url] tag, because in my real code the url contains variables, such as $userid. And code between [_url][/url] cannot contain variables, because they don't get parsed.

Now I'm thinking of a way to get these variables parsed before being submitted into the database..

Velocd 10-27-2002 11:06 PM

BUAHAH!!
Finally figured it out, thanks for your help anyway NTLDR

:p


All times are GMT. The time now is 10:26 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01042 seconds
  • Memory Usage 1,731KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete