0.0) {
if ($minval == 0.0 || $minval > $outs) $minval=$outs;
if ($maxval == 0.0 || $maxval < $outs) $maxval=$outs;
}
if ($xrange == "") {
if (isset($_GET['min']) && isset($_GET['max'])) {
$xrange=" (" . $_GET['min'] . " <= " . $reportmode . " <= " . $_GET['max'] . ")";
} else if (isset($_GET['min'])) {
$xrange=" (" . $_GET['min'] . " <= " . $reportmode . ")";
} else if (isset($_GET['max'])) {
$xrange=" (" . $reportmode . " <= " . $_GET['max'] . ")";
}
}
if (isset($_GET['min']) && isset($_GET['max'])) {
if ($thisyear != $oneyear) { //$firstyear <= 0) {
if (str_replace("," . $thisc . ",","","," . $okvaluelist . ",") != "," . $okvaluelist . ",") {
return $outs;
} else {
$othercnt+=$outs;
return "0";
}
}
if ($outs < $_GET['min'] || $outs > $_GET['max']) {
$othercnt+=$outs;
return "0";
} else if ($thisyear == $oneyear && $valuelist != "") {
$vls=explode(",",$valuelist);
if (str_replace("," . $vls[0] . ",","","," . $okvaluelist . ",") == "," . $okvaluelist . ",") {
if ($okvaluelist == "") {
$okvaluelist=$vls[0];
} else {
$prevok=$okvaluelist;
$okvaluelist=$vls[0] . "," . $prevok;
}
}
}
} else if (isset($_GET['min'])) {
if ($thisyear != $oneyear) { //$firstyear <= 0) {
if (str_replace("," . $thisc . ",","","," . $okvaluelist . ",") != "," . $okvaluelist . ",") {
return $outs;
} else {
$othercnt+=$outs;
return "0";
}
}
if ($outs < $_GET['min']) {
$othercnt+=$outs;
return "0";
} else if ($thisyear == $oneyear && $valuelist != "") {
$vls=explode(",",$valuelist);
if (str_replace("," . $vls[0] . ",","","," . $okvaluelist . ",") == "," . $okvaluelist . ",") {
if ($okvaluelist == "") {
$okvaluelist=$vls[0];
} else {
$prevok=$okvaluelist;
$okvaluelist=$vls[0] . "," . $prevok;
}
}
}
} else if (isset($_GET['max'])) {
if ($thisyear != $oneyear) { //$firstyear <= 0) {
if (str_replace("," . $thisc . ",","","," . $okvaluelist . ",") != "," . $okvaluelist . ",") {
return $outs;
} else {
$othercnt+=$outs;
// if ($thisc != "China") {
// echo "
";
// exit;
// }
return "0";
}
}
if ($outs > $_GET['max']) {
$othercnt+=$outs;
return "0";
} else if ($thisyear == $oneyear && $valuelist != "") {
$vls=explode(",",$valuelist);
if (str_replace("," . $vls[0] . ",","","," . $okvaluelist . ",") == "," . $okvaluelist . ",") {
if ($okvaluelist == "") {
$okvaluelist=$vls[0];
} else {
$prevok=$okvaluelist;
$okvaluelist=$vls[0] . "," . $prevok;
}
}
}
}
return $outs;
}
function rangeget($basis) {
global $reportmode;
$cookie_name = "Worldbank_" . str_replace(" ","_",$reportmode) . "_" . $basis;
if (isset($_COOKIE[$cookie_name])) {
return $_COOKIE[$cookie_name];
}
return 0.0;
}
function rangeset($basis, $val) {
global $reportmode, $startswith;
if ($startswith == "") {
$cookie_name = "Worldbank_" . str_replace(" ","_",$reportmode) . "_" . $basis;
$cookie_value = $val;
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/PHP/"); // 86400 = 1 day
return $val;
}
return rangeget($basis);
}
function noe($inn) {
$zeroes="";
$neg="";
$zinn=$inn;
if (substr($inn,0,1) == '-') {
$neg="-";
$zinn=substr($inn,1);
}
$ninn=explode("E",$zinn);
if (sizeof($ninn) == 2) {
$qd=explode(".",$ninn[0]);
$hm=str_replace("+","",$ninn[1]);
if (sizeof($qd) == 1) {
for ($ii=1; $ii<=abs($hm); $ii++) {
$zeroes.="0";
}
if ($hm >= 0) {
return $neg . $qd[0] . $zeroes;
} else {
return $neg . "0." . $zeroes . $qd[0];
}
} else {
if ($hm >= 0) {
for ($ii=1; $ii<=(abs($hm) - strlen($qd[1])); $ii++) {
$zeroes.="0";
}
return $neg . $qd[0] . $qd[1] . $zeroes;
} else {
for ($ii=1; $ii<=(abs($hm) - strlen($qd[0])); $ii++) {
$zeroes.="0";
}
return $neg . "0." . $zeroes . $qd[0] . $qd[1];
}
}
}
return $inn;
}
function thesmallest($y1, $y2) {
if (strpos($y2, "-") !== false) {
return min($y1, -$y2);
} else if ($y2 != "") {
return $y1; //min($y1, $y2);
}
return $y1;
}
function thebiggest($y1, $y2) {
if (strpos($y2, "-") !== false) {
return max($y1, -$y2);
} else if ($y2 != "") {
return $y1; //max($y1, $y2);
}
return $y1;
}
function andto($y1, $y2, $otheridea) {
global $xrange;
if (thebiggest($y1, $y2) != thesmallest($y1, $y2)) {
if (strpos($y2, "-") !== false) {
return thesmallest($y1, $y2) . " to " . thebiggest($y1, $y2) . $xrange;
} else {
return $y2 . " and " . $y1 . $xrange;
}
}
return str_replace("%2d","",str_replace("%2D","",str_replace("-","",str_replace($y1 . " and " . $y2,$y2 . " and " . $y1,str_replace($y1 . "%20and%20" . $y2,$y2 . "%20and%20" . $y1,$otheridea)))));
}
$minval=0.0;
$maxval=0.0;
$thisc="";
$xrange="";
$lookforis="Population, tot";
$reportmode="Population";
$reportmode2="Population";
$indicator="SP.POP.TOTL";
$cn="Pie Chart";
$idata2="";
$udiff="";
$ddiff="";
$page=1;
$valuelist="";
$okvaluelist="";
$firstyear=-1;
$oneyear=0;
$thisyear=0;
$valuedelim="";
$othercnt=0;
$pagecontent="";
$poplist="";
$popdelim=",%20";
$idelim="';
$wf="600px";
$recit=false;
$regexpok=1;
if (isset($_GET['regex']) || isset($_POST['regex'])) {
$right="right"; //"RIGHT";
} else {
$right="right";
}
if (isset($_GET['indicator'])) {
$indicator=$_GET['indicator'];
if ($indicator != "") {
$reportmode=str_replace("EG.ELC.ACCS.ZS","Access to electricity (% of population)",str_replace("NY.GDP.MKTP.CD","Gross Domestic Product",$indicator));
$reportmode2=str_replace("EG.ELC.ACCS.ZS","Access to electricity (% of population)",str_replace("NY.GDP.MKTP.CD","Gross Domestic Product (US$)",$indicator));
$lookforis=str_replace("EG.ELC.ACCS.ZS","Population (%",str_replace("NY.GDP.MKTP.CD","GDP (current US",$indicator));
if (strpos($reportmode,"Access to electricity") !== false) { $recit=true; }
}
}
if (isset($_POST['indicator'])) {
$indicator=$_POST['indicator'];
if ($indicator != "") {
$reportmode=str_replace("EG.ELC.ACCS.ZS","Access to electricity (% of population)",str_replace("NY.GDP.MKTP.CD","Gross Domestic Product",$indicator));
$reportmode2=str_replace("EG.ELC.ACCS.ZS","Access to electricity (% of population)",str_replace("NY.GDP.MKTP.CD","Gross Domestic Product (US$)",$indicator));
$lookforis=str_replace("EG.ELC.ACCS.ZS","Population (%",str_replace("NY.GDP.MKTP.CD","GDP (current US",$indicator));
if (strpos($reportmode,"Access to electricity") !== false) { $recit=true; }
}
}
if (isset($_GET['year'])) $year=$_GET['year'];
if (isset($_POST['year'])) $year=$_POST['year'];
if (isset($_GET['yearvs'])) $yearvs=str_replace("%2d","-",str_replace("%2D","-",$_GET['yearvs']));
if (isset($_POST['yearvs'])) $yearvs=str_replace("%2d","-",str_replace("%2D","-",$_POST['yearvs']));
if (isset($_GET['yearvs'])) $xyearvs=" and " . str_replace("%2d","",str_replace("%2D","",str_replace("-","",$_GET['yearvs'])));
if (isset($_POST['yearvs'])) $xyearvs=" and " . str_replace("%2d","",str_replace("%2D","",str_replace("-","",$_POST['yearvs'])));
$zrange=our_str_replace("decimal","0","decimal0");
$tbit=andto($year, $yearvs, $year . $xyearvs . $xrange);
$preudiff="//www.rjmprogramming.com.au/PHP/PieChart/pie_chart";
if (strpos($yearvs, "-") !== false) {
$mopt="";
$preudiff="//www.rjmprogramming.com.au/PHP/LineChart/line_chart";
$cn="Line Chart";
if (isset($_GET['chart'])) {
if (strpos(strtolower($_GET['chart']), "column") !== false) {
$preudiff="//www.rjmprogramming.com.au/PHP/ColumnChart/column_chart";
$cn="Column Chart";
} else if (strpos(strtolower($_GET['chart']), "bar") !== false) {
$preudiff="//www.rjmprogramming.com.au/PHP/BarChart/bar_chart";
$cn="Bar Chart";
} else if (strpos(strtolower($_GET['chart']), "area") !== false) {
$preudiff="//www.rjmprogramming.com.au/PHP/AreaChart/area_chart";
$cn="Area Chart";
}
}
if (isset($_POST['chart'])) {
if (strpos(strtolower($_POST['chart']), "column") !== false) {
$preudiff="//www.rjmprogramming.com.au/PHP/ColumnChart/column_chart";
$cn="Column Chart";
} else if (strpos(strtolower($_POST['chart']), "bar") !== false) {
$preudiff="//www.rjmprogramming.com.au/PHP/BarChart/bar_chart";
$cn="Bar Chart";
} else if (strpos(strtolower($_POST['chart']), "area") !== false) {
$preudiff="//www.rjmprogramming.com.au/PHP/AreaChart/area_chart";
$cn="Area Chart";
}
}
} else if ($yearvs != "") {
$onclick="";
$wf="900px";
$udiff="_diff";
if (strpos($preudiff, "pie_chart") !== false) {
$mopt="&moreopt=" . urlencode(' width: ' . $widea . ', height: 1200, chartArea: { width: "86%", height: "70%" }, legend: { position: "' . $right . '" }, ');
}
$ddiff="&data0=";
$idata2="";
}
$startswith='';
if (isset($_GET['startswith'])) $startswith=urldecode($_GET['startswith']);
if (isset($_POST['startswith'])) $startswith=urldecode($_POST['startswith']);
$url=$preudiff . $udiff . ".php?title=" . str_replace("+","%20",urlencode($reportmode2)) . "%20by%20World%20Country%20" . $startswith . "%20for%20Year%20" . urldecode(andto($year, $yearvs, $year . $xyearvs . $xrange)) . $mopt . "&onclick=y&label=Year&value=&task=" . str_replace("+","%20",urlencode($reportmode)) . "&desc=" . str_replace("+","%20",urlencode($reportmode)) . "&data=";
$urlextra="";
$tso=thesmallest($year, $yearvs);
$tbo=thebiggest($year, $yearvs);
while (strpos($pagecontent, "', '', $entries[$i]))[0], '*' . $startswith) !== false || strpos('*' . $pentries[$zero], '*' . $startswith) !== false)) {
if ($idelim == $lookforis) {
if (strpos($yearvs, "-") !== false) {
$prevc="," . $valuelist . ",";
$thisc=retflagflag(str_replace("%27","",str_replace(".","",str_replace("+","%20",urlencode($pentries[$zero])))));
if (strpos($prevc, "," . retflagflag(str_replace("%27","",str_replace(".","",str_replace("+","%20",urlencode($pentries[$zero]))))) . ",") === false) {
$prevc=$valuelist;
$valuelist=retflagflag(str_replace("%27","",str_replace(".","",str_replace("+","%20",urlencode($pentries[$zero]))))) . $valuedelim . $prevc;
$valuedelim=",";
//echo $valuelist;
} //else {
//echo str_replace("%27","",str_replace(".","",str_replace("+","%20",urlencode($pentries[$zero])))) . " vs " . $prevc;
//}
if ($pentries[$one] == "decimal") {
$thisyear=$pentries[6 + $one];
} else {
$thisyear=$pentries[$eight];
}
if ($firstyear < 0) {
$firstyear=$thisyear;
$oneyear=$thisyear;
} else if ($thisyear != $oneyear) {
$firstyear=0;
}
if ($poplist == "") {
for ($jy=$tso; $jy<=$tbo; $jy++) {
$poplist.=$popdelim . "[~" . $jy . "~]";
}
}
if (strpos($poplist, "~" . $thisyear . "~") !== false) {
if ($regexpok != 0) $poplist=str_replace("[~" . $thisyear . "~", "[~" . $thisyear . "~," . our_str_replace("decimal","0",explode($cdelim, $pentries[$one])[0]), $poplist);
} else {
$prevc=$poplist;
if ($regexpok != 0) $poplist=$popdelim . "[~" . $thisyear . "~," . our_str_replace("decimal","0",explode($cdelim, $pentries[$one])[0]) . "]" . $prevc;
}
} else {
if ($regexpok != 0) {
//echo "2 " . $regexpok . " ... " . $regexp . " " . $thisc . " " . str_replace("%27","",str_replace(".","",str_replace("+","%20",urlencode($pentries[$zero]))));
//exit;
$poplist.=$popdelim . "[~" . retflagflag(str_replace("%27","",str_replace(".","",str_replace("+","%20",urlencode($pentries[$zero]))))) . "~," . our_str_replace("decimal","0",$pentries[$one]) . "]";
}
}
} else {
if (strpos($yearvs, "-") !== false) {
$prevc="," . $valuelist . ",";
$thisc=retflagflag(str_replace("%27","",str_replace(".","",str_replace("+","%20",explode('"', explode($cdelim, str_replace('">', '', urlencode($entries[$i])))[$zero])[0]))));
$regexpok=1;
if (isset($_GET['regex'])) {
$thisc=retflagflag(str_replace("%27","",str_replace(".","",str_replace("+","%20",urlencode($pentries[$zero]))))); //new
$regexp="/" . urldecode($_GET['regex']) . "/i";
//echo $regexp . " " . $thisc . " " . preg_match($regexp,$thisc) . " " . preg_match($regexp,urldecode($thisc));
//exit;
$regexpok=preg_match($regexp,$thisc);
//if (preg_match($regexp,$thisc)) $regexpok=preg_match($regexp,$thisc);
} else if (isset($_POST['regex'])) {
$thisc=retflagflag(str_replace("%27","",str_replace(".","",str_replace("+","%20",urlencode($pentries[$zero]))))); // new
$regexp="/" . urldecode($_POST['regex']) . "/i";
$regexpok=preg_match($regexp,$thisc);
//if (preg_match($regexp,$thisc)) $regexpok=preg_match($regexp,$thisc);
}
if (strpos($prevc, "," . retflagflag(str_replace("%27","",str_replace(".","",str_replace("+","%20",explode('"', explode($cdelim, str_replace('">', '', urlencode($entries[$i])))[$zero])[0])))) . ",") === false) {
$prevc=$valuelist;
$valuelist=retflagflag(str_replace("%27","",str_replace(".","",str_replace("+","%20",explode('"', explode($cdelim, str_replace('">', '', urlencode($entries[$i])))[$zero])[0])))) . $valuedelim . $prevc;
$valuedelim=",";
//echo $valuelist;
} //else {
//echo str_replace("%27","",str_replace(".","",str_replace("+","%20",explode('"', explode($cdelim, str_replace('">', '', urlencode($entries[$i])))[$zero])[0]))) . " vs " . $prevc;
//}
if ($pentries[$one] == "decimal") {
$thisyear=$pentries[6 + $one];
} else {
$thisyear=$pentries[$eight];
}
if ($firstyear < 0) {
$firstyear=$thisyear;
$oneyear=$thisyear;
} else if ($thisyear != $oneyear) {
$firstyear=0;
}
if ($poplist == "") {
for ($jy=$tso; $jy<=$tbo; $jy++) {
$poplist.=$popdelim . "[~" . $jy . "~]";
}
}
if (strpos($poplist, "~" . $thisyear . "~") !== false) {
if ($regexpok != 0) $poplist=str_replace("[~" . $thisyear . "~", "[~" . $thisyear . "~," . our_str_replace("decimal","0",explode($cdelim, $pentries[$one])[0]), $poplist);
} else {
$prevc=$poplist;
if ($regexpok != 0) $poplist=$popdelim . "[~" . $thisyear . "~," . our_str_replace("decimal","0",explode($cdelim, $pentries[$one])[0]) . "]" . $prevc;
}
} else {
if ($regexpok != 0) {
//echo "1 " . $thisc;
//exit;
$poplist.=$popdelim . "[~" . retflagflag(str_replace("%27","",str_replace(".","",str_replace("+","%20",explode('"', explode($cdelim, str_replace('">', '', urlencode($entries[$i])))[$zero])[0])))) . "~," . our_str_replace("decimal","0",explode($cdelim, $pentries[$one])[0]) . "]";
}
}
}
$popdelim=",%20";
} else if (strpos($yearvs, "-") === false) {
if ($idelim == $lookforis) {
$othercnt+=str_replace("decimal","0",$pentries[$one]);
} else {
$othercnt+=str_replace("decimal","0",explode($cdelim, $pentries[$one])[0]);
}
}
}
}
$pagecontent=" 0 && !isset($_GET['justletters']) && !isset($_POST['justletters'])) {
$url.=ourfilter($poplist) . $popdelim . "[~Non-" . $startswith . "~," . noe($othercnt) . "]";
} else {
$url.=ourfilter($poplist);
}
if (strpos($yearvs, "-") !== false) $yearvs="";
$page=1;
$pagecontent="';
$poplist="";
$popdelim=",%20";
$idelim="', '', $entries[$i]))[0], '*' . $startswith) !== false || strpos('*' . $pentries[$zero], '*' . $startswith) !== false)) {
if ($idelim == $lookforis) {
if ($regexpok != 0) $poplist.=$popdelim . "[~" . retflagflag(str_replace("%27","",str_replace(".","",str_replace("+","%20",urlencode($pentries[$zero]))))) . "~," . our_str_replace("decimal","0",$pentries[$one]) . "]";
} else {
if ($regexpok != 0) $poplist.=$popdelim . "[~" . retflagflag(str_replace("%27","",str_replace(".","",str_replace("+","%20",explode('"', explode($cdelim, str_replace('">', '', urlencode($entries[$i])))[$zero])[0])))) . "~," . our_str_replace("decimal","0",explode($cdelim, $pentries[$one])[0]) . "]";
}
$popdelim=",%20";
} else {
if ($idelim == $lookforis) {
$othercnt+=str_replace("decimal","0",$pentries[$one]);
} else {
$othercnt+=str_replace("decimal","0",explode($cdelim, $pentries[$one])[0]);
}
}
}
}
$pagecontent="";
// exit;
$valuelist=$okvaluelist;
$poplist=str_replace(",0","",$poplist);
$urlextra=str_replace(",0","",$urlextra);
$url=str_replace(",0","",$url);
}
if ($othercnt > 0 && !isset($_GET['justletters']) && !isset($_POST['justletters'])) {
$urlextra.=$poplist . $popdelim . "[~Non-" . $startswith . "~," . $othercnt . "]";
$idata2="";
} else if ($poplist != "") {
$urlextra.=$poplist;
$idata2="";
}
echo "World Bank API " . $reportmode . " Data Google Chart " . $cn . " - RJM Programming - February, 2016
var butis='mysubmit';
var repfrom=' action=\"//www.';
var repto=' action=\"https://www.';
var url='" . explode("&data=",$url)[1] . "';
var urlextra=\"" . str_replace('"','" + String.fromCharCode(34) + "',$urlextra) . "\";
function preiframeviaurl() {
if (document.getElementById('data').value != '') url=document.getElementById('data').value;
return true;
}
function iframeviaurl() {
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPod|iPad|Opera Mini|IEMobile/i)) {
document.getElementById('moreopt').value=('' + document.getElementById('moreopt').value).replace('86%','300%');
url=url.replace('86','300');
//alert(document.getElementById('moreopt').value + ' ' + url);
}
if (parent.document.getElementById('maxrange')) {
parent.document.getElementById('maxrange').value='" . rangeset('max',$maxval) . "';
}
if (parent.document.getElementById('minrange')) {
parent.document.getElementById('minrange').value='" . rangeset('min',$minval) . "';
}
if (parent.document.getElementById('childiframe')) {
document.body.style.backgroundColor='lightblue';
}
if (('" . str_replace('&value=&','&value=' . str_replace('%2c','',str_replace('%2C','',str_replace("%09","%20",$valuelist))) . '&',explode("&data=",$url)[0]) . "&data=' + url + '" . $urlextra . "').length > 750) {
document.getElementById('myiframe').style.display='block';
document.getElementById('data').value=decodeURIComponent(url);
document.getElementById('mysubmit').click();
} else if (url != '') {
document.getElementById('myiframe').style.display='block';
document.getElementById('myiframe').src='" . str_replace('&value=&','&value=' . str_replace('%2c','',str_replace('%2C','',str_replace("%09","%20",$valuelist))) . '&',explode("&data=",$url)[0]) . "&data=' + url + '" . $urlextra . "';
}
return true;
}
function shareviaemail() {
var prefix=document.getElementById('aemail').href.split('body=');
if (('' + prefix[0] + 'body=' + encodeURIComponent(document.URL)).length <= 750) {
document.getElementById('aemail').href=prefix[0] + 'body=' + encodeURIComponent(document.URL);
document.getElementById('aemail').click();
} else {
var huhemail=prompt('Please enter email address to send email to', '');
if (huhemail == null) { huhemail=''; }
if (huhemail.indexOf('@') != -1) {
document.getElementById('tdto').value=huhemail;
document.getElementById('tdhuhta').value='' + document.body.innerHTML.replace(' onsubmit=', ' data-onsubmit=').replace(repfrom,repto) + '';
document.getElementById('fsubm').click();
}
}
}
World Bank API " . $reportmode . " Data Google Chart " . $cn . " 📧
RJM Programming - February, 2016
Share via Email
";
?>