I have a mailing system that I am trying to include in a PHP site. A PHP site loads a content area and also loads scripts to the top of the page. This works great for the code generated for the site, but now I have a newsletter that I am trying to include.
I was originally going to use iFrame, but the number of AJAX and jQuery calls makes this pretty complicated.
So I thought I could use cURL to load the newsletter page as a variable. Then I was going to use RegEx to capture content between body tags and put it in the content area. Finally, I was going to use RegEx again to search in my head and capture any scripts.
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $config_live_site."lib/alerts/user/ update.php?email=test@test.com.au ");
This works most of the time, but if there is a script in the document body, it is committed to the last / script '.
My question is double, I think ...
a. Is there a better general approach (my deadline is very short, so it should be a quick solution without editing the newsletter too much)?
Q. Which RegEx will I need to use to just grab the first script?
source share