"; $root_element ="homepage"; $xml .= "<$root_element>"; error_reporting(0); require '../../include/asset.php'; require '../../include/Conn.php'; require '../../include/config.php'; $main_img_path="393x213"; //$thumb_img_path="155x81"; $thumb_img_path="150x81"; $q="SELECT ID,Name FROM ncategories WHERE ID=6 ORDER BY ID DESC LIMIT 1"; $r=mysql_query($q) or die(mysql_error()); while($w=mysql_fetch_assoc($r)){ $id=$w['ID']; $url="http://api.alarab.com/api/mothercategory/".$w['ID']."/"; $xml.=""; $xml.=" {$w['Name']} {$url} {$id} "; $sub="SELECT ID,Name FROM ncategories WHERE MainCat=6 ORDER BY ID DESC LIMIT 6"; $sresult=mysql_query($sub) or die(mysql_error()); while($srow=mysql_fetch_assoc($sresult)){ $surl="http://api.alarab.com/api/category/".$srow['ID']."/"; $srow['Name']=text_summarise($srow['Name'], 2); $sqqql="OR srow={$row[ID]} "; $xml.="{$srow['Name']}".$srow['ID']." {$surl} "; } $query="SELECT ID,smalltitle,sData,picture,picPath,links,mobilevideo,udate FROM news where mStatus=1 AND mCat=6 AND sCat!=2235 ORDER BY udate DESC limit 20"; $result=mysql_query($query) or die(mysql_error()); while($row=mysql_fetch_assoc($result)){ //$row['smalltitle']=htmlentities($row['smalltitle']); //$row['title']=htmlentities($row['title']); //$row['sData']=htmlentities($row['sData']); $sdata=$row['sData']; if($row['links']){ $goto=htmlspecialchars($row['links']); $target="target=\"_blank\""; } else{ $goto="/Article/".$row['ID']; $target="target=\"_self\""; } $image="https://images.alarab.com/data/news/{$row['picPath']}/{$main_img_path}/{$row['picture']}"; $thumb="https://images.alarab.com/data/news/{$row['picPath']}/{$thumb_img_path}/{$row['picture']}"; if ($row[mobilevideo] !="" ){ if (strpos($row[mobilevideo], 'youtube') !== false) { $row[mobilevideo]=$row[mobilevideo]; }else{ $mp4file=basename($row['mobilevideo']); $mp4file=str_replace(".mp4","",$mp4file); $mp4file=str_replace(" ","",$mp4file); if($mp4file < 122212) { $row[mobilevideo] = "https://cdn.alarab.com/".$mp4file.".mp4/index-v1-a1.m3u8"; } if($mp4file > 122211 AND $mp4file < 150000) { $row[mobilevideo] = "https://cdn.alarab.com/".$mp4file.".mp4/index-v1-a1.m3u8"; } if($mp4file > 151496) { $url='http://conv.alarab.com/indicator.php?id='.$mp4file; //file_get_contents() reads remote webpage content $lines_string=file_get_contents($url); //output, you can also save it locally on the server htmlspecialchars($lines_string); $lines_string=preg_replace('/\s+/', ' ', $lines_string); $data=explode(":",$lines_string); $renderations=str_replace(" ","",$data[0]); $renderations=str_replace("0p","",$renderations); $row[mobilevideo]= "https://cdn.alarab.com/h264/".$mp4file."_,".$renderations.",0p.mp4.urlset/playlist.m3u8"; if($renderations=="SD"){ $row[mobilevideo]= "https://cdn.alarab.com/h264/".$mp4file."_".$renderations.",,,.mp4.urlset/playlist.m3u8"; } } } $v=$row[mobilevideo]; }else{ $v="no"; } $row['articleviews']=$row[ID]; $xml .="
{$row['ID']} {$row['smalltitle']} {$row['sData']} {$thumb} {$image} {$goto} {$target} {$row['articleviews']} {$row['udate']}
"; } } $xml.="
"; $xml .= ""; $xml = simplexml_load_string($xml); // where $xml_string is the XML data you'd like to use (a well-formatted XML string). If retrieving from an external source, you can use file_get_contents to retrieve the data and populate this variable. $json = json_encode($xml,JSON_UNESCAPED_UNICODE); // convert the XML string to JSON $array = json_decode($json,TRUE); echo $json; mysql_close($conn); $fp = fopen($cachefile, 'w'); // save the contents of output buffer to the file fwrite($fp, ob_get_contents()); // close the file fclose($fp); // Send the output to the browser ob_end_flush(); ?>