preg_replace_callback(): Requires argument 2, 'chr("\1")', to be a valid callbac

Started by MESWEB, July 21, 2014, 12:33:53 PM

Previous topic - Next topic

MESWEB


$cleaned[0]['body'] = preg_replace_callback('~&#x([0-9a-f]+);~i', 'chr(hexdec("\\1"))', $cleaned[0]['body']);
$cleaned[0]['body'] = preg_replace_callback('~&#([0-9]+);~', 'chr("\\1")', $cleaned[0]['body']);

margarett

So...

That text isn't part of a standard SMF install. You just pasted that here without further explanations, what exactly should we do about it?
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

NanoSector

I suppose this is another case why we need a mind reading mod. It's not finished, feel free to contribute.
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

MESWEB

Yes this is for secure mod.
I solution only one:
Replace:
$cleaned[0]['body'] = preg_replace_callback('~&#([0-9]+);~', 'chr("\\1")', $cleaned[0]['body']);
With:
$cleaned[0]['body'] = preg_replace_callback('~&#([0-9]+);~', create_function ('$matches', 'return chr($matches[1]);'), $cleaned[0]['body']);
But this
$cleaned[0]['body'] = preg_replace_callback('~&#x([0-9a-f]+);~e', create_function ('$matches', 'return chr(hexdec($matches[1]));'), $cleaned[0]['body']);
Give me error:
Quotepreg_replace_callback(): Modifier /e cannot be used with replacement callback
What is wrong?

Arantor

You can't use the /e option with preg_replace_callback, nor can you use it with preg_replace any more.

But as ever, more details about what you're actually trying to do would be useful because we're still not mind readers.

MESWEB

Quote from: ‽ on July 21, 2014, 01:09:02 PM
You can't use the /e option with preg_replace_callback, nor can you use it with preg_replace any more.

But as ever, more details about what you're actually trying to do would be useful because we're still not mind readers.

I just update mod which one is for php 5.3 or less. My host have php 5.5. I got error every day if just any viewing post.

Arantor

Yes because we're mind readers and know exactly what you're talking about.

Oh, wait, no we don't.

Ninja ZX-10RR

Omg MESWEB you have been politely asked to provide FULL details of what you are trying to achieve and you can either do it and we (may) support you after you doing it or you could also check if you need support with your native language because no offense dude but your English is quite bad. Post here if you choose the second option: http://www.simplemachines.org/community/index.php?board=97.0
Quote from: BeastMode topic=525177.msg3720020#msg3720020
It's so powerful that on this post and even in the two PMs you sent me,you still answered my question very quickly and you're apologizing for the delay. You're the #1 support I've probably ever encountered man, so much respect for that. Thank you, and get better soon.

I'll keep this in my siggy for a while just to remind me that someone appreciated what I did while others didn't.

♥ Jess ♥

STOP EDITING MY PROFILE

MESWEB

Quote from: Flavio93Zena on July 21, 2014, 02:03:13 PM
Omg MESWEB you have been politely asked to provide FULL details of what you are trying to achieve and you can either do it and we (may) support you after you doing it or you could also check if you need support with your native language because no offense dude but your English is quite bad. Post here if you choose the second option: http://www.simplemachines.org/community/index.php?board=97.0

What are You don't understand? OMG. Look at the subject. What You see? Yes You will see:
Quotepreg_replace_callback(): Requires argument 2, 'chr("\1")', to be a valid callback
So what is that mind? It's a ERROR message from logs. WOW. Why MESWEB write that subject? Because he  f**king need help. Help what? He need help with this f**king code:
$cleaned[0]['body'] = preg_replace_callback('~&#x([0-9a-f]+);~e', create_function ('$matches', 'return chr(hexdec($matches[1]));'), $cleaned[0]['body']);

I so sorry for asking help with codding. If any one don't know PHP they should don't answer - this is just simple and clever.

Arantor

Oh, I know PHP. I am actually certified as a Zend Certified Engineer. I'm also formerly an SMF dev and one of the people who worked on doing this stuff for SMF itself to be compatible with PHP 5.5. I presume that's enough of a qualification for you?

The problem is we don't have enough material to work on, you've provided bits of code without any context as to what the code is supposed to do or what mod it's from so we can look at what code might work better for the job at hand.

Ninja ZX-10RR

Actually I am requesting lock on this for you being the most rude user I had ever met and also for still not explaining the problem that you have.
Quote from: BeastMode topic=525177.msg3720020#msg3720020
It's so powerful that on this post and even in the two PMs you sent me,you still answered my question very quickly and you're apologizing for the delay. You're the #1 support I've probably ever encountered man, so much respect for that. Thank you, and get better soon.

I'll keep this in my siggy for a while just to remind me that someone appreciated what I did while others didn't.

♥ Jess ♥

STOP EDITING MY PROFILE

MESWEB


Arantor

Thank you for not providing enough information to be able to help you. Sorry you didn't get the help you were looking for.

Antes

Its a regex not a simple php code, regex suppose to find unique things or things has common parts. So the thing here, probably most of the people reading this topic cannot solve the issue or help you. Actually, our rules says if this code is a part of a modification you must ask mod author to make his/her mod compatible with PHP5.5, or you can skip this issues with asking your host to downgrade your host to PHP 5.4

Advertisement: