Skip to content

Instantly share code, notes, and snippets.

@iBasit
Created October 6, 2011 20:14
Show Gist options
  • Save iBasit/1268522 to your computer and use it in GitHub Desktop.
Save iBasit/1268522 to your computer and use it in GitHub Desktop.
GlobalQuran.com - without css auto-html for TheTruthGate.com - conflicting main. so unhiding the main
<?php
// html url to the application
$api_url = 'http://GlobalQuran.com/';
$api_key = '';
################## DO NOT EDIT BELOW THIS ###################################
if (!$api_url)
{
die('missing vaules, please fill the configuration values and try again!');
}
$_REQUEST['apiKey'] = $api_key;
$urlstring = NULL;
build_string($_REQUEST, $urlstring);
$ch = curl_init($api_url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $urlstring);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
$html = str_ireplace('<div id="main" style="display:none;">', '<div id="main">', strip_only($data, 'head', true));
$html = str_ireplace('<!DOCTYPE html>', '', $html);
$html = str_ireplace('<html lang="en" dir="lrt">', '', $html);
$html = str_ireplace('<body class="ltr ">', '', $html);
$html = str_ireplace('<body class="ltr ">', '', $html);
$html = str_ireplace('</body>', '', $html);
$html = str_ireplace('</html>', '', $html);
print $html;
function build_string ($array, &$urlstring)
{
foreach ($array as $key => $value)
{
if (is_array($value))
{
foreach ($value as $key2 => $value2)
{
$urlstring .= $key . '[' . $key2 . ']=' . $value2 . '&';
}
}
else
$urlstring .= "$key=$value&";
}
}
function strip_only ($str, $tags, $stripContent = false)
{
$content = '';
if(!is_array($tags)) {
$tags = (strpos($str, '>') !== false ? explode('>', str_replace('<', '', $tags)) : array($tags));
if(end($tags) == '') array_pop($tags);
}
foreach($tags as $tag) {
if ($stripContent)
$content = '(.+</'.$tag.'[^>]*>|)';
$str = preg_replace('#</?'.$tag.'[^>]*>'.$content.'#is', '', $str);
}
return $str;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment