Welcome Guest, Not a member yet? Register   Sign In
Controller extension error

A client project which I have taken over has the /app/libraries/MY_controller.php object:

if (!defined('BASEPATH')) exit('No direct script access allowed');

class MY_Controller extends Controller {

function MY_Controller() {



function wrapOutput($content,$title=null,$desc=null,$keywords=null,$metaRobot=null,$bodyClass=null) {
       empty($title) ? $title = "" : $title=$title;
       empty($desc) ? $desc = "" : $desc=$desc;
       empty($keywords) ? $keywords = "" : $keywords=$keywords;
       empty($metaRobot) ? $metaRobot = "index, follow" : $metaRobot=$metaRobot;
       empty($bodyClass) ? $bodyClass = "default" : $bodyClass=$bodyClass;
       //$flash = $this->db_session->flashdata('flashMessage');
       $lpage = $this->uri->total_segments();
   $booking =$this->session->userdata('booking');
       $data = array(
      'metaTitle' => $title,
      'metaDesc' => $desc,
      'metaKeyWords' => $keywords,
      'metaRobot' => $metaRobot,
      'content' => $content,
      'bodyClass' => $bodyClass,

   if($bodyClass == 'root'){
   } else {

function get_convio_content($page) {
  $url = "http://www.clientsite.com/stars/$page.html";
  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20070725 Firefox/");
  $output = curl_exec($ch);
  //need to parse out content:
  $page = array();
  $page['title'] = "";
  $page['body'] = "";

  //strip out hard references
  $output = preg_replace("#http://www.clientsite.com#s", "", $output);
  //step 1. get <title></title>
  if(preg_match("/&lt;title&gt;(.*?)<\/title>/s", $output, $m)) {
   $page['title'] = $m[1];

  //step 2. get  <div id="contentDiv"><p>Welcome!</p></div>
  if(preg_match("/<div id=\"contentDiv\">.*?<\/script>.*?<\/script>(.*?)<\/div>/s", $output, $m)) {
   $page['body'] = $m[1];

  return $page;  

After a year of proper functioning, with no known code changes, this scraping has recently begun failing. (Grabbing some javascript from the source page, rather than the contents of contentDiv.)

I have found a solution that works outside the codeigniter paradigm, on a test system, but when I try the exact same solution in the above object, it fails. Hard. (Rather than blank content, the whole page is blank, indicating some sort of PHP error.) This is the code with which I tried to replace "step 2":

$domd = new DOMDocument(); // fails here
$div = $domd->getElementById("contentDiv");
if ($div) {
  $dom2 = new DOMDocument();
    $dom2->appendChild($dom2->importNode($div, true));
mail('[email protected]', 'success', $dom2->saveHTML());
} else {
mail('[email protected]', 'failure', 'did not provide a properly constructed contentDiv');

Any idea why that failure might occur?

I know this is not strictly a codeigniter issue, but hours of Googling make me no wiser, so I am hoping for some help here.



Theme © iAndrew 2016 - Forum software by © MyBB