Skip to content

Instantly share code, notes, and snippets.

@iBasit
Created October 6, 2011 20:01
Show Gist options
  • Save iBasit/1268486 to your computer and use it in GitHub Desktop.
Save iBasit/1268486 to your computer and use it in GitHub Desktop.
GlobalQuran.com - without css auto-html
<?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);
print strip_only($data, 'head', true);
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