Boxerman Posted December 8, 2015 Share Posted December 8, 2015 Hi all, Hopefully you guys can help me. I'm having an issue finding out what being outputted from the below class. Can someone please help me echo out what is being grabbing and stored (if any)? I've spent hours look and re-reading and i can't quite put my finger on it CODE: public function getEmbeds($title,$showid,$season,$episode){ $misc = new Misc(); $title = $this->getTitle($title); //some issues look at later $link = "http://projectfreetv.so/".$title."/".$title."-season-".$season."/"; $this->curl->header(true); $page = file_get_contents($link); $code = 200; $page = explode("\r\n\r\n",$page); if (count($page)>1){ $page = $page[1]; } else { $page = $page[0]; } if ($code==200){ $searchstring = "season$season"."episode$episode"; $codes = 1; $ret = array(); $dom = new DOMDocument(); @$dom->loadHTML($page); $xp = new DOMXPath($dom); $tds = $xp->query('//td[@class="mnllinklist dotted"]'); for ($i=0;$i<$tds->length;$i++){ if ($tds){ $td = $tds->item($i); $linktitle = $td->getElementsByTagName('a')->item(0)->getElementsByTagName('div'); if ($linktitle->length){ $linktitle = $linktitle->item(0)->textContent; $linktitle = strtolower(preg_replace("/[^a-zA-Z0-9]/i","",$linktitle)); } else { $linktitle = ''; } $tmp = explode($searchstring,$linktitle); if (count($tmp)==2 && @$tmp[1]==""){ // we have the link I guess $videolink = $td->getElementsByTagName('a')->item(0)->getAttribute("href"); $test = str_replace('http://projectfreetv.so/watch/','',$videolink); $vdlink = urldecode($test); $videolink = substr($vdlink, 0, strpos($vdlink, "&ttl")); if (substr_count($videolink,"/player/")){ $tmp = explode("/player/",$videolink); $tmp = explode(".php?id=",$tmp[1]); if (count($tmp)!=2){ continue; } $host = $tmp[0]; $id = $tmp[1]; $link = $misc->makeLink($host,$id); if ($link){ $embed = $misc->buildEmbed($link); if ($embed){ $ret[$codes] = array(); $ret[$codes]['embed'] = $embed; $ret[$codes]['link'] = $link; $ret[$codes]['language'] = "ENG"; $codes++; } } } } } } return $ret; } else { return array(); } } Thanks in advance! B-Man Quote Link to comment https://forums.phpfreaks.com/topic/299677-not-sure-whats-outputting/ Share on other sites More sharing options...
mikesta707 Posted December 8, 2015 Share Posted December 8, 2015 Seems like that function is scraping a page from freetvproject.so and returning an array with all the embed video html from that page, as well as other information. pretty sure the key part is this part: if ($embed){ $ret[$codes] = array(); $ret[$codes]['embed'] = $embed; $ret[$codes]['link'] = $link; $ret[$codes]['language'] = "ENG"; $codes++; } this kind of shows you the general format of the returned array. Hope this helps. Quote Link to comment https://forums.phpfreaks.com/topic/299677-not-sure-whats-outputting/#findComment-1527701 Share on other sites More sharing options...
Boxerman Posted December 8, 2015 Author Share Posted December 8, 2015 How would one echo these out? adding echo infront just displays a blank page? Quote Link to comment https://forums.phpfreaks.com/topic/299677-not-sure-whats-outputting/#findComment-1527702 Share on other sites More sharing options...
mikesta707 Posted December 8, 2015 Share Posted December 8, 2015 try doing a vardump or print_r to see what exactly you are getting back. Also make sure to turn error reporting on to make sure you aren't getting any errors Quote Link to comment https://forums.phpfreaks.com/topic/299677-not-sure-whats-outputting/#findComment-1527704 Share on other sites More sharing options...
Boxerman Posted December 9, 2015 Author Share Posted December 9, 2015 Hi, im really sorry, but adding var_dump does not work, i've turned display errors on too Quote Link to comment https://forums.phpfreaks.com/topic/299677-not-sure-whats-outputting/#findComment-1527710 Share on other sites More sharing options...
ginerjm Posted December 9, 2015 Share Posted December 9, 2015 You might get a quicker solution if you posted the latest change to your code showing how you used var_dump. 1 Quote Link to comment https://forums.phpfreaks.com/topic/299677-not-sure-whats-outputting/#findComment-1527711 Share on other sites More sharing options...
Boxerman Posted December 9, 2015 Author Share Posted December 9, 2015 I've used the following note to save repeating i and copied them all into one file: note multiple attempts tried in the listed locations. public function getEmbeds($title,$showid,$season,$episode){ $misc = new Misc(); $title = $this->getTitle($title); //some issues look at later $link = "http://projectfreetv.so/".$title."/".$title."-season-".$season."/"; $this->curl->header(true); $page = file_get_contents($link); $code = 200; $page = explode("\r\n\r\n",$page); if (count($page)>1){ $page = $page[1]; } else { $page = $page[0]; } if ($code==200){ $searchstring = "season$season"."episode$episode"; $codes = 1; $ret = array(); $dom = new DOMDocument(); @$dom->loadHTML($page); $xp = new DOMXPath($dom); $tds = $xp->query('//td[@class="mnllinklist dotted"]'); for ($i=0;$i<$tds->length;$i++){ if ($tds){ $td = $tds->item($i); $linktitle = $td->getElementsByTagName('a')->item(0)->getElementsByTagName('div'); if ($linktitle->length){ $linktitle = $linktitle->item(0)->textContent; $linktitle = strtolower(preg_replace("/[^a-zA-Z0-9]/i","",$linktitle)); } else { $linktitle = ''; } $tmp = explode($searchstring,$linktitle); if (count($tmp)==2 && @$tmp[1]==""){ // we have the link I guess $videolink = $td->getElementsByTagName('a')->item(0)->getAttribute("href"); $test = str_replace('http://projectfreetv.so/watch/','',$videolink); $vdlink = urldecode($test); $videolink = substr($vdlink, 0, strpos($vdlink, "&ttl")); if (substr_count($videolink,"/player/")){ $tmp = explode("/player/",$videolink); $tmp = explode(".php?id=",$tmp[1]); if (count($tmp)!=2){ continue; } $host = $tmp[0]; $id = $tmp[1]; $link = $misc->makeLink($host,$id); if ($link){ $embed = $misc->buildEmbed($link); if ($embed){ $ret[$codes] = array(); $ret[$codes]['embed'] = $embed; $ret[$codes]['link'] = $link; $ret[$codes]['language'] = "ENG"; $codes++; //attempt 1 - print_r(array_values($embed)); //attempt 2 - var_dump($embed); //attempt 3 - echo count($embed); } } } } } } //attempt 1 - print_r(array_values($embed)); //attempt 2 - var_dump($embed); //attempt 3 - echo count($embed); return $ret; } else { return array(); } //attempt 1 - print_r(array_values($embed)); //attempt 2 - var_dump($embed); //attempt 3 - echo count($embed); } Quote Link to comment https://forums.phpfreaks.com/topic/299677-not-sure-whats-outputting/#findComment-1527712 Share on other sites More sharing options...
QuickOldCar Posted December 9, 2015 Share Posted December 9, 2015 I don't have the rest of the class but that won't matter. They changed the code since that script was made, is now all js and there is no class="mnllinklist dotted" within a td in the html code. They don't want others scraping their links. Quote Link to comment https://forums.phpfreaks.com/topic/299677-not-sure-whats-outputting/#findComment-1527720 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.