Opencart 3

42 views
Skip to first unread message

Alberto Rodriguez

unread,
Jan 18, 2021, 6:21:00 PMJan 18
to htmlpurifier
Hello Guys, 
I would like to stat using this service/code on my development project into an opencart version 3.0.3.6 installation.
So far what I have done is use composer to install it but I don't know what else should I configure or add in order to make it work, is is not already? 
Thanks for the support 

Alberto Rodriguez

unread,
Jan 20, 2021, 10:40:09 AMJan 20
to htmlpurifier
Also, is it compatible with php 7.3

Keith Davis

unread,
Jan 20, 2021, 1:45:51 PMJan 20
to htmlpurifier
Yes, we're using it on 7.4 (and did on 7.3).

Alberto Rodriguez

unread,
Jan 20, 2021, 1:50:45 PMJan 20
to htmlpurifier
Hi Keith, 
Thanks for your reply, Is it possible for you to share how did you implement this?

I tried adding this code into the index.php file but doesn't work correctly for the Admin are and do not work at all in the catalog


require_once('/path/to/htmlpurifier/library/HTMLPurifier.auto.php'); 
 $config = HTMLPurifier_Config::createDefault(); 
$purifier = new HTMLPurifier($config); 
  // Clean user input in GET array 
$_GET = $purifier->purify($_GET); 
  // Clean user input in POST array 
$_POST = $purifier->purify($_POST); 
  // Clean user input in REQUEST array 
$_REQUEST = $purifier->purify($_REQUEST);

Keith Davis

unread,
Jan 21, 2021, 10:06:22 AMJan 21
to htmlpu...@googlegroups.com
$_GET = $purifier->purify($_GET); 

You are passing an array, purify() expects a string.
 


--
You received this message because you are subscribed to a topic in the Google Groups "htmlpurifier" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/htmlpurifier/o5uuO8grIOI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to htmlpurifier...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/htmlpurifier/7fe1f751-ba83-48e2-ad72-86506c6b00d5n%40googlegroups.com.

Chris J. Zähller

unread,
Jan 21, 2021, 10:41:01 AMJan 21
to htmlpurifier
OP: I don't know how familiar you are with PHP, but you should look up the implode() and explode() functions to deal with this. You want to convert the array to a string, and then probably back to an array after that.

Alberto Rodriguez

unread,
Jan 23, 2021, 8:00:24 AMJan 23
to htmlpurifier
Hi, Guys thanks for the answers.
I'm Not a skilled PHP Developer or consider a Developer at all, I'm just an enthusiast that always try to find a way to improve my store.
That said
I know how to install and put in place the code, modules and even create ocmod's pretty simple :) 
That's why I'm asking from the start how do you guys did the implementation and if is possible to share it so I can implement it on my store :)

Thanks again,

Chris J. Zähller

unread,
Jan 23, 2021, 10:10:19 AMJan 23
to htmlpurifier
Hi,

I have no formal training in programming either. Everything I know comes from doing,, searching for answers on the forums, reading the docs, the occasional text or video tutorial asking others for help — like you're doing now. Keep at it — you can only get better.

Since HTMPurifier expects a string, you need to convert your array to one before you pass it through. Use PHP implode() to do that.

Your app probably expects an array, so you'll want to explode() the string back to one before handing it off.

I'm using HTMPurifier on this plugin; you might want to look at my code to see how I implemented it. Specifically, I use it in this file.

Good Luck,

— CZ

Alberto Rodriguez

unread,
Jan 24, 2021, 5:51:24 AMJan 24
to htmlpurifier
Thanks for the extra info  CZ I see is being applied on WordPress which I have never used, I will see if there's something from there I can learn and apply

If anyone one else has done the implementation in Opencart 3 I will kindly appreciate your guidance too.

Kind regards, 

Timothy Green

unread,
Jan 26, 2021, 5:07:21 AMJan 26
to htmlpu...@googlegroups.com
It might be simpler (rather than imploding and exploding), to loop over the array, purifying each element individually.

$purified = [];
foreach ($_GET as $k => $v) {
 $purified[$k] = $purifier->purify($v);
}

And now use $purified instead of $_GET.

You received this message because you are subscribed to the Google Groups "htmlpurifier" group.
To unsubscribe from this group and stop receiving emails from it, send an email to htmlpurifier...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/htmlpurifier/9da6af12-cc1b-4f8a-bb9a-15d9163ca27dn%40googlegroups.com.


--
Timothy Green
Web Developer

Dotser Ltd, The Junction Office Suites, Unit 25J, Axis Business Park, Clara Road, Tullamore, County Offaly, R35 K6C5
Office: 057 932 3262

Chris J. Zähller

unread,
Jan 26, 2021, 9:27:43 AMJan 26
to htmlpurifier
Yep, Tim's solution is much better.
Reply all
Reply to author
Forward
0 new messages