rendered paste body<?php
class CEODirectory {
function getQueryCheck() {
$firstQuery = true;
$query = '';
foreach($_GET as $key => $value) {
if($key == 'city' || $key == 'state' || $key == 'zip' || $key == 'industry' || $key == 'keyword' || $key == 'alpha' || $key == 'submit' || $key == 'Submit' || $key == 'currentPage') {
if(is_array($value)) {
foreach($value as $vValue) {
if($firstQuery == true) {
$query .= '?';
$firstQuery = false;
} else {
$query .= '&';
}
$query .= $key.'='.$vValue;
}
} else {
if($firstQuery == true) {
$query .= '?';
$firstQuery = false;
} else {
$query .= '&';
}
$query .= $key.'='.$value;
}
}
}
return $query;
}
function printDirectory() {
$url = "http://www.ceo-oec.org/directory/index.asp".$this->getQueryCheck();
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$contents = curl_exec($ch);
curl_close($ch);
$contents = explode('<script language="JavaScript">', $contents);
$contents = '<script language="JavaScript">'.$contents[1].'<script language="JavaScript">'.$contents[2];
$contents = explode('</form>', $contents);
//print(count($contents)."\n");
if(count($contents) == 2) {
$contents = $contents[0].'</form>';
} else {
$contents = $contents[0].'</form>'.$contents[1].'</form>'.$contents[2].'</form>';
}
$contents = preg_replace('/name="city"/','name="city[]"',$contents);
$contents = preg_replace('/name="state"/','name="state[]"',$contents);
$contents = preg_replace('/name="zip"/','name="zip[]"',$contents);
$contents = preg_replace('/\/directory\/index.asp/','',$contents);
$contents = preg_replace('/\/directory\/fr\/index.asp/','',$contents);
$contents = preg_replace('/QC, QC, /','QC,QC,',$contents);
$contents = preg_replace('/QC, , /','QC,,',$contents);
return($contents);
}
}
?>