Why php function doesn't work inside second <?php ?> - php

Why this works perfect:
<?php
$url = $_SERVER["REQUEST_URI"];
$locale_lang = "pl_PL";
if (substr($url,0,3) == "/pl") { $locale_lang = "pl_PL"; }
if (substr($url,0,3) == "/en") { $locale_lang = "en_US"; }
$lang = substr($locale_lang,0,2);
require_once("lib/streams.php");
require_once("lib/gettext.php");
$locale_file = new FileReader("locale/$locale_lang/LC_MESSAGES/messages.mo");
$locale_fetch = new gettext_reader($locale_file);
function _loc($text) {
global $locale_fetch;
return $locale_fetch->translate($text);
}
echo "<!doctype html>
<html lang=\"$lang\">
<head>
<title>"._loc("Summoners War")."</title>";
?>
when this doesn't work. Function _loc return empty value. There are no php notice/error
<?php
$url = $_SERVER["REQUEST_URI"];
$locale_lang = "pl_PL";
if (substr($url,0,3) == "/pl") { $locale_lang = "pl_PL"; }
if (substr($url,0,3) == "/en") { $locale_lang = "en_US"; }
$lang = substr($locale_lang,0,2);
require_once("lib/streams.php");
require_once("lib/gettext.php");
$locale_file = new FileReader("locale/$locale_lang/LC_MESSAGES/messages.mo");
$locale_fetch = new gettext_reader($locale_file);
function _loc($text) {
global $locale_fetch;
return $locale_fetch->translate($text);
}
?>
<!doctype html>
<html lang="<?php echo $lang; ?>">
<head>
<title><?php _loc("Summoners War"); ?></title>
I can leave it in first (working) form, but then html code is inside php and is difficult to read

In first case you put your _loc function inside echo which is absent in your second example.
change your last line code to:
<title><?php echo _loc("Summoners War"); ?></title>

Put echo before _loc function for printing its output

Related

Opening several javascript link from page

I am using "fabpot/goutte": "^3.2" and use PHP 7.3.5.
I am trying to access the following page and click the link - https://www.forexfactory.com/calendar.php?month=nov.2019 - to open the below box:
I tried to filter all this links, however no links are found:
$subCrawler->filter('td.calendar__cell.calendar__detail.detail > a')->each(function ($node) {
$link = $node->link();
print $link ."\n";
print $node->text() ."\n";
});
Any suggestions how to click the link with goutte and get the source text and usual effect text?
Using Goutte:
<?php
require 'vendor/autoload.php';
use Goutte\Client;
use Symfony\Component\DomCrawler\Crawler;
$x = 1;
$LIMIT = 20;
$client = new Client();
$crawler = $client->request('GET', 'https://www.forexfactory.com/calendar.php?month=nov.2019');
$resArray = array();
$TEMP = array();
$crawler->filter('.calendar_row')->each(function ($node) {
global $x;
global $LIMIT;
global $resArray;
global $TEMP;
$x++;
$EVENTID = $node->attr('data-eventid');
$API_RESPONSE = file_get_contents('https://www.forexfactory.com/flex.php?do=ajax&contentType=Content&flex=calendar_mainCal&details='.$EVENTID);
$API_RESPONSE = str_replace("<![CDATA[","",$API_RESPONSE);
$API_RESPONSE = str_replace("]]>","",$API_RESPONSE);
$html = <<<HTML
<!DOCTYPE html>
<html>
<body>
$API_RESPONSE
</body>
</html>
HTML;
$subcrawler = new Crawler($html);
$subcrawler->filter('.calendarspecs__spec')->each(function ($LEFT_TD) {
global $resArray;
global $TEMP;
$LEFT_TD_INNER_TEXT = trim($LEFT_TD->text());
if($LEFT_TD_INNER_TEXT == "Source"){
$TEMP = array();
$LEFT_TD->nextAll()->filter('a')->each(function ($LINK) {
global $TEMP;
array_push($TEMP,$LINK->text(),$LINK->attr('href'));
});
$EVENT['sourceTEXT'] = $TEMP[0];
$EVENT['sourceURL'] = $TEMP[1];
$EVENT['latestURL'] = $TEMP[3];
array_push($resArray,$EVENT);
}
});
if($x>$LIMIT){
echo "<pre>"; var_dump($resArray); echo "</pre>";
exit;
}
});
Using Simple HTML DOM. You can get it from here.
<?php
include('simple_html_dom.php');
$html = file_get_html('https://www.forexfactory.com/calendar.php?month=nov.2019');
$x = 1;
$LIMIT = 10;
foreach($html->find('.calendar_row') as $e){
$x++;
$EVENTID = $e->attr['data-eventid'];
$EVENTNAME = $e->find('.event')[0]->find('div')[0]->innertext;
echo "<h4>".$EVENTNAME."</h4><br>";
$API_RESPONSE = file_get_html('https://www.forexfactory.com/flex.php?do=ajax&contentType=Content&flex=calendar_mainCal&details='.$EVENTID);
$API_RESPONSE = str_replace("<![CDATA[","",$API_RESPONSE);
$API_RESPONSE = str_replace("]]>","",$API_RESPONSE);
$API_RESPONSE = str_get_html($API_RESPONSE);
foreach($API_RESPONSE->find('.calendarspecs__spec') as $LEFT_TD){
$LEFT_TD_INNER_TEXT = trim($LEFT_TD->innertext);
if($LEFT_TD_INNER_TEXT == "Source" || $LEFT_TD_INNER_TEXT == "Usual Effect"){
echo $LEFT_TD_INNER_TEXT.": ".$LEFT_TD->next_sibling()->innertext."<br>";
}
}
if($x>$LIMIT)
break;
echo "<hr>";
}
Screenshot(Goutte):
Screenshot(SIMPLE HTML DOM):

Translating php webpage using gettext

I am translating this webpage however I the translation will only work when I add the parameter after .php (e.g. http://localhost/fr/about.php?lang=fr_FR)
How can i make it work like (e.g. http://localhost/fr/about.php/?lang=fr_FR)
<?php
/*
* Template Name: Test */
$url = $_SERVER["REQUEST_URI"];
$locale_lang = "en_EN";
if (substr($url,0,3) == "/fr/") { $locale_lang = "fr_FR"; }
if (substr($url,0,3) == "/en/") { $locale_lang = "en_US"; }
$lang = substr($locale_lang,0,2);
require_once("languages/lib/streams.php");
require_once("languages/lib/gettext.php");
$locale_file = new FileReader("languages/lib/$locale_lang/fr_FR.mo");
$locale_fetch = new gettext_reader($locale_file);
function _loc($text) {
global $locale_fetch;
return $locale_fetch->translate($text);
}
?>
<title><?php echo ("Title"); ?></title>
<h1><?php echo _loc("English Version"); ?></h1>

Getting file_put_content into a folder

I am trying to put my files in a folder from the file_put_contents can someone help me with that.
$invoegen_titel=$_POST['titel_form'];
$invoegen_datum=$_POST['datum'];
$invoegen_tekst=$_POST['tekst'];
$html_tekst= $invoegen_titel."</h1>"."<br>"."<p>".$invoegen_datum."</p>"."<br>"."<p>".$invoegen_tekst."</p>";
$previous = $_SERVER['HTTP_REFERER'];
$folder='blog';
var_dump(file_put_contents($folder."/".time().".html","<h1>".$invoegen_titel."</h1>"."<br>"."<p>".$invoegen_datum."</p>"."<br>"."<p>".$invoegen_tekst."</p>"));
make sure that the directory is present. file_put_contents doesn't create the directory if it is not present.
Please specify what problems you are encountering on your code.
change these parts
$folder = time(); //make sure that time() returns string
$folder = "blog/".$folder.'.html';
file_put_contents($folder, $html_tekst);
var_dump(file_get_contents($folder));
Use this:
$lifeTime = 5; // life time, seconds
$cached = TRUE;
$config = array(
'group'=>'default', // dir
'id' => '1', // id cache
'echo' => TRUE, // echo or return
'log'=>false, // echo log, or not
'ext' => 'js' // extention cache file, default .html
);
$CacheFile = new CacheFile('/usr/cache/', $cached);
$CacheFile->config($config, $lifeTime);
if (!$CacheFile->start()){
echo $invoegen_titel."</h1>"."<br>"."<p>".$invoegen_datum."</p>"."<br>"."<p>".$invoegen_tekst."</p>";
$CacheFile->end();
}
PHP class:
class CacheFile{
private $cacheDir = '';
private $cacheSubDir = '';
private $fileName = '';
private $cache = false;
private $lifeTime = 0;
private $echo = true;
private $group = true;
private $log = true;
private $fileExt = 'html';
public function __construct($cacheDir, $cache){
$this->cacheDir = $cacheDir;
$this->cache = $cache;
}
private function createdPatch(){
if ($this->cache){
if (!is_dir($this->cacheSubDir)){
mkdir($this->cacheSubDir, 0777, true);
}
chmod($this->cacheSubDir, 0755);
}
}
private function getSubDir($keyType, $keyValue){
return (($keyType != '')?($keyType.'/'):'').mb_substr($keyValue, 0, 1)."/".mb_substr($keyValue, 1, 1)."/".mb_substr($keyValue, 2, 1)."/";
}
private function getCacheName($key){
return md5($key).".".$this->fileExt;
}
public function config($conf = array('group'=>'post', 'id' => '0', 'echo' => TRUE), $time = 31536000){
$this->group = $conf['group'];
$this->cacheSubDir = $this->cacheDir.$this->getSubDir($conf['group'], md5($conf['id']));
$this->fileName = $this->getCacheName($conf['group'].$conf['id']);
$this->lifeTime = $time;
if (isset($conf['echo']))
$this->echo = $conf['echo'];
if (isset($conf['log']))
$this->log = $conf['log'];
if (isset($conf['ext']))
$this->fileExt = $conf['ext'];
}
public function start(){
if ($data = $this->get()) {
if ($this->echo){
echo $data;
return true;
}else{
return $data;
}
}
ob_start();
ob_implicit_flush(false);
return false;
}
function end(){
$data = ob_get_contents();
ob_end_clean();
if ($this->cache){
$this->save($data.(($this->log)?'<!-- c:'.$this->group.':('.date("Y-m-d H:i:s", (time()+$this->lifeTime)).'/'.date("Y-m-d H:i:s").') -->':""));
}
$return = $data.(($this->log)?'<!-- g:'.$this->group.':('.date("Y-m-d H:i:s", (time()+$this->lifeTime)).'/'.date("Y-m-d H:i:s").') -->':"");
if ($this->echo){
echo $return;
return true;
}
return $return;
}
public function get(){
if (!file_exists($this->cacheSubDir.$this->fileName))
return false;
if (time() >= filemtime($this->cacheSubDir.$this->fileName) + $this->lifeTime){
unlink($this->cacheSubDir.$this->fileName);
return false;
}
if ($this->cache && file_exists($this->cacheSubDir.$this->fileName))
if ($data = file_get_contents($this->cacheSubDir.$this->fileName, false))
return $data;
return false;
}
public function remove(){
if (file_exists($this->cacheSubDir.$this->fileName)){
echo unlink($this->cacheSubDir.$this->fileName);
return true;
}
return false;
}
public function save($data){
$this->createdPatch();
if (file_put_contents($this->cacheSubDir.$this->fileName, $data, LOCK_EX))
return true;
return false;
}
}
I fixed it
<?php $list = file_get_contents('list.json'); $list = json_decode($list, true); $selector = $_POST['selector']; $d_or_t = $_POST['d_or_t']; if (isset($selector) && isset($d_or_t)) { // overwrite the selected domain of the list with the new value if they are not empty if ($d_or_t == "domain") { $list[$selector]['domain'] = $_POST['new']; } if ($d_or_t == "template") { $list[$selector]['template'] = $_POST['new']; } /*else { echo '<script type="text/javascript">alert("U bent vergeten een veld in te voelen!");</script>'; }*/ // store the new json } ?>
<!DOCTYPE html>
<html>
<head>
<title>Json values veranderen</title>
</head>
<body>
<h2>Domain of Template veranderen met PHP script</h2>
<form action="test.php" id="form" method="post">
<select name="selector">
<?php foreach ($list AS $key => $value) : ?>
<option value="<?php echo $key; ?>">
<?php echo $key; ?>
</option>
<?php endforeach; ?>
</select>
<select name="d_or_t">
<option>domain</option>
<option>template</option>
</select>
<input type="text" name="new" placeholder="Nieuw">
<input type="submit" value="Veranderen">
</form>
</body>
</html>
<?php
echo "<ul>";
foreach ($list as $key => $value)
{
echo "<li>".$key."<ul>";
foreach ($value as $key1 => $value1)
{
echo "<li>".$key1.": ".$value1."</li>"; }
echo "</ul>"."</li>";
}
echo "</ul>";
file_put_contents('list.json', json_encode($list));
?>

Change title on page

I have the following code that change Title on the page:
class.php
<?php
class Title_And_Page
{
public $pagekey;
public $title;
public $page;
private $pages = array(
'start_page' => array("Startsida", "start_page.php"),
'products' => array("Produkter", "products.php"),
'max_ot' => array("Max-OT", "max_ot.php"),
'blog' => array("Blogg", "blog.php"),
'tools' => array("Verktyg", "tools.php"),
'about_us' => array("Om oss", "about_us.php"));
public function __construct($pagekey)
{
$this->pagekey = $pagekey;
}
public function setTitle()
{
if(array_key_exists($this->pagekey, $this->pages))
{
$this->title = $this->pages[$this->pagekey][0]; //Returns the value in title, that it gets when the constructs is run
return $this->title;
}
}
public function includePage()
{
if(array_key_exists($this->pagekey, $this->pages))
{
$this->page = $this->pages[$this->pagekey][1]; //Returns the value in page, that will be included
return $this->page;
}
}
}
?>
Here is my some code from my index.php
if(isset($_GET['page']))
{
$page = $_GET['page'];
}
$page_title = new Title_And_Page($page);
<title><?= $page_title->setTitle(); ?></title>
<li id="info"><a href="?page=products" class='clickme'>Produkter</a></li>
<li id="info">MAX-OT</li>
<li id="info">Blogg</li>
<li id="info">Verktyg</li>
<li id="info">Om oss</li>
This works. However, I have articles in the blog page that contains "Read more"-links. When I click on a "Read more"-link, the URL changes to this: index.php?page=blog&readmore_from_firstpage=1&article_header=Vilken kolhydrat är bäst att äta efter träningen?
How can I change the title of the page, to the value in $_GET['article_header'] as you can see above?
Just extend your GET checks:
if(isset($_GET['article_header']))
{
$page = $_GET['article_header'];
}
elseif(isset($_GET['page']))
{
$page = $_GET['page'];
}
But since you're checking in your class whether that page is whitelisted, you'd need to either add another variable to force avoiding such check or simply just to print out the title if article_header is present.
Here's an example of the latter:
$avoidClass = false;
if(isset($_GET['article_header']))
{
$page = $_GET['article_header'];
$avoidClass = true;
}
elseif(isset($_GET['page']))
{
$page = $_GET['page'];
}
Then in HTML:
<title><?= $avoidClass ? $page : $page_title->setTitle(); ?></title>
Or, probably the simplest way:
if(isset($_GET['article_header']))
{
$page_title = $_GET['article_header'];
}
elseif(isset($_GET['page']))
{
$page_title = new Title_And_Page($_GET['page'])->setTitle();
}
else
{
$page_title = 'Default title here';
}
HTML
<title><?= $page_title ?></title>

How to convert PHP to XML output

I have a php code. this code outputs an HTML. I need to modify this code to output an XML.
ANy ideas as to how shall I go about doing this. Is there any XML library available that directly does the job or do i have to manually create each node.?
My php code is:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
a {text-decoration:none; color:black;}
</style>
</head>
<body>
<?php
$a=$_POST["title"];
$b=$_POST["name"];
$c="http://www.imdb.com/search/title?title=".urlencode($a)."&title_type=".urlencode($b);
$d=file_get_contents($c);
preg_match_all('/<div id="main">\n(No results.)/', $d,$nore);
preg_match_all('#<img src="(.*)"#Us', $d, $img);//image
preg_match_all('/<a\s*href="\/title\/tt[0-9]*\/">((?:[a-z]*(?:&*[.]*)?\s*-*[a-z]*[0-9]*[^<])+)/i',$d,$tit); //title
preg_match_all('/<span\sclass="year_type">\s*\(([\d]*)/',$d,$ye); //movie year working fine
preg_match_all('#<span class="credit">\n Dir: (.*)\n(?: With:)?#Us',$d,$dir); //director
preg_match_all('/<span class="rating-rating"><span class="value">([\w]*.[\w]*)/i',$d,$rat); //rating
preg_match_all('/<a\shref="(\/title\/tt[0-9]*\/)"\s*[title]+/i',$d,$lin); //link
for($i=0;$i<5;$i++)
{
if (#$rat[1][$i]=="-")
$rat[1][$i]="N/A";
}
for($i=0;$i<5;$i++)
{
if(#$dir[1][$i]=="")
$dir[1][$i]="N/A";
}
if(count($tit[1])>5)
$cnt=5;
else
$cnt=count($tit[1]);
echo"<center><b>Search Result</b></center>";
echo "<br/>";
echo "<center><b>\"$a\"of type\"$b\":</b></center>";
echo"<br/>";
if(#$nore[1][0]=="No results.")
echo "<center><b>No movies found!</b></center>";
else
{
echo "<center><table border=1><tr><td><center>Image</center></td><td><center>Title</center></td><td><center>Year</center></td><td><center>Director</center></td><td><center>Rating(10)</center></td><td><center>Link to Movie</center></td></tr>";
for($j=0;$j<$cnt;$j++)
{
echo "<tr>";
echo "<td>".#$img[0][$j+2]."</td>";
echo "<td><center>".#$tit[1][$j]."</center></td>";
echo "<td><center>".#$ye[1][$j]."</center></td>";
echo "<td><center>".#$dir[1][$j]."</center></td>";
echo "<td><center>".#$rat[1][$j]."</center></td>";
echo '<td><center><a style="text-decoration:underline; color:blue;" href="http://www.imdb.com'.#$lin[1][$j].'">Details</a></center></td>';
echo "</tr>";
}
echo "</table></center>";
}
?>
</body>
</html>
Expected XML output:
<result cover="http://ia.mediaimdb.com/images
/M/MV5BMjMyOTM4MDMxNV5BMl5BanBnXkFtZTcwNjIyNzExOA##._V1._SX54_
CR0,0,54,74_.jpg" title="The Amazing Spider-Man(2012)"year="2012"
director="Marc Webb" rating="7.5"
details="http://www.imdb.com/title/tt0948470"/>
<result cover="http://ia.mediaimdb.
com/images/M/MV5BMzk3MTE5MDU5NV5BMl5BanBnXkFtZTYwMjY3NTY3._V1._SX54_CR0,
0,54,74_.jpg" title="Spider-Man(2002)" year="2002"director="Sam Raimi"
rating="7.3" details="http://www.imdb.com/title/tt0145487"/>
<result cover="http://ia.mediaimdb.
com/images/M/MV5BODUwMDc5Mzc5M15BMl5BanBnXkFtZTcwNDgzOTY0MQ##._V1._SX54_
CR0,0,54,74_.jpg" title="Spider-Man 3 (2007)" year="2007" director="Sam
Raimi" rating="6.3" details="http://www.imdb.com/title/tt0413300"/>
<result cover="http://i.mediaimdb.
com/images/SF1f0a42ee1aa08d477a576fbbf7562eed/realm/feature.gif" title="
The Amazing Spider-Man 2 (2014)" year="2014" director="Sam Raimi"
rating="6.3" details="http://www.imdb.com/title/tt1872181"/>
<result cover="http://ia.mediaimdb.
com/images/M/MV5BMjE1ODcyODYxMl5BMl5BanBnXkFtZTcwNjA1NDE3MQ##._V1._SX54_
CR0,0,54,74_.jpg" title="Spider-Man 2 (2004)" year="2004" director="Sam
Raimi" rating="7.5" details="http://www.imdb.com/title/tt0316654"/>
</results>
First thing, you're parsing your html result with regex which is inefficient, unnecessary, and... well, you're answering to the cthulhu call!
Second, parsing IMDB HTML to retrieve results, although valid, might be unnecessary. There are some neat 3rd party APIs that do the job for you, like http://imdbapi.org
If you don't want to use any 3rd party API though, IMHO, you should, instead, parse the HTML using a DOM parser/manipulator, like DOMDocument, for instance, which is safer, better and, at the same time, can solve your HTML to XML problem.
Here's the bit you asked (build XML and HTML from results):
function resultsToHTML($results)
{
$doc = new DOMDocumet();
$table = $doc->createElement('table');
foreach ($results as $r) {
$row = $doc->createElement('tr');
$doc->appendChild($row);
$title = $doc->createElement('td', $r['title']);
$row->appendChild($title);
$year = $doc->createElement('td', $r['year']);
$row->appendChild($year);
$rating = $doc->createElement('td', $r['rating']);
$row->appendChild($rating);
$imgTD = $doc->createElement('td');
//Creating a img tag (use only on)
$img = $doc->createElement('img');
$img->setAttribute('src', $r['img_src']);
$imgTD->appendChild($img);
$row->appendChild($imgTD);
$imgTD = $doc->createElement('td');
//Importing directly from the old document
$fauxDoc = new DOMDocument();
$fauxDoc->loadXML($r['img']);
$img = $fauxDoc->getElementsByTagName('img')->index(0);
$importedImg = $doc->importNode('$img', true);
$imgTD->appendChild($importedImg);
$row->appendChild($imgTD);
}
return $doc;
}
function resultsToXML($results)
{
$doc = new DOMDocumet();
$root = $doc->createElement('results');
foreach ($results as $r) {
$element = $root->createElement('result');
$element->setAttribute('cover', $r['img_src']);
$element->setAttribute('title', $r['title']);
$element->setAttribute('year', $r['year']);
$element->setAttribute('rating', $r['rating']);
$root->appendChild($element);
}
$doc->appendChild($root);
return $doc;
}
to print them you just need to
$xml = resultsToXML($results);
print $xml->saveXML();
Same thing with html
Here's a refactor of your code with DOMDocument, based on your post:
<?php
//Mock IMDB Link
$a = 'The Amazing Spider-Man';
$b = 'title';
$c = "http://www.imdb.com/search/title?title=".urlencode($a)."&title_type=".urlencode($b);
// HTML might be malformed so we want DOMDocument to be quiet
libxml_use_internal_errors(true);
//Initialize DOMDocument parser
$doc = new DOMDocument();
//Load previously downloaded document
$doc->loadHTMLFile($c);
//initialize array to store results
$results = array();
// get table of results and extract a list of rows
$listOfTables = $doc->getElementsByTagName('table');
$rows = getResultRows($listOfTables);
$i = 0;
//loop through all rows to retrieve information
foreach ($rows as $row) {
if ($title = getTitle($row)) {
$results[$i]['title'] = $title;
}
if (!is_null($year = getYear($row)) && $year) {
$results[$i]['year'] = $year;
}
if (!is_null($rating = getRating($row)) && $rating) {
$results[$i]['rating'] = $rating;
}
if ($img = getImage($row)) {
$results[$i]['img'] = $img;
}
if ($src = getImageSrc($row)) {
$results[$i]['img_src'] = $src;
}
++$i;
}
//the first result can be a false positive due to the
// results' table header, so we remove it
if (isset($results[0])) {
array_shift($results);
}
FUNCTIONS
function getResultRows($listOfTables)
{
foreach ($listOfTables as $table) {
if ($table->getAttribute('class') === 'results') {
return $table->getElementsByTagName('tr');
}
}
}
function getImageSrc($row)
{
$img = $row->getElementsByTagName('img')->item(0);
if (!is_null($img)) {
return $img->getAttribute('src');
} else {
return false;
}
}
function getImage($row, $doc)
{
$img = $row->getElementsByTagName('img')->item(0);
if (!is_null($img)) {
return $doc->saveHTML($img);
} else {
return false;
}
}
function getTitle($row)
{
$tdInfo = getTDInfo($row->getElementsByTagName('td'));
if (!is_null($tdInfo) && !is_null($as = $tdInfo->getElementsByTagName('a'))) {
return $as->item(0)->nodeValue;
} else {
return false;
}
}
function getYear($row)
{
$tdInfo = getTDInfo($row->getElementsByTagName('td'));
if (!is_null($tdInfo) && !is_null($spans = $tdInfo->getElementsByTagName('span'))) {
foreach ($spans as $span) {
if ($span->getAttribute('class') === 'year_type') {
return str_replace(')', '', str_replace('(', '', $span->nodeValue));
}
}
}
}
function getRating($row)
{
$tdInfo = getTDInfo($row->getElementsByTagName('td'));
if (!is_null($tdInfo) && !is_null($spans = $tdInfo->getElementsByTagName('span'))) {
foreach ($spans as $span) {
if ($span->getAttribute('class') === 'rating-rating') {
return $span->nodeValue;
}
}
}
}
function getTDInfo($tds)
{
foreach ($tds as $td) {
if ($td->getAttribute('class') == 'title') {
return $td;
}
}
}

Categories