Hi folks,
a few days back, we enabled SSL on our office server and the intranet migrated to https. Everything is ok on the intranet.
On the public internet, we noticed today that the page on our website, which connects to our office server to fetch and display data was throwing an error, which I presumed was a Security Certificate issue… An area that’s like the Dark Side of the Moon for me…
the webpage - Live Connections - We place People First - List of Cream Jobs, Top Jobs, Hot Jobs
Anycase, the internet was willing to help and so I updated the code to a curl function. The Data is not displaying still…
However, when I try to access the office server by loading the php page in my localhost, the data is displayed.
Here’s the code… where am i going wrong ?
<?php
//error_reporting(E_ERROR | E_PARSE | E_ALL);
//$cpg="jobs-listing";
?>
<header class="section background-livec text-center">
<h3 class="text-white margin-bottom-0 text-size-40 text-thin text-line-height-1">Current & Hot Jobs</h3>
</header>
<?php
$industry = $_GET['industry'];
$location = $_GET['location'];
$expMin = $_GET['expMin'];
$expMax = $_GET['expMax'];
$sortBy = $_GET['sortBy'];
$cpg = $_GET['page'];
if(empty($cpg) || $cpg==1)
$npl = 1;
else {
//$npl = (($cpg+1)*10) - 9;
$npl = $_GET['startingRowNo'];
}
$industry = str_replace(' ', '%20', $industry);
$location = str_replace(' ', '%20', $location);
$url = "http://xxx.xxx.xxx.xxx/LCWebService/rest/";
function file_get_contents_curl($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser.
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
if(!empty($sortBy)) {
$json = file_get_contents_curl($url.'getHeadersBySearch?industry='.$industry.'&location='.$location.'&expMin='.$expMin.'&expMax='.$expMax.'&sortBy='.$sortBy.'&startingRowNo='.$npl.'&noOfRows=1000000');
$data = json_decode($json);
} else if(!empty($industry) || !empty($location) || !empty($expMin) || !empty($expMax)) {
$json = file_get_contents_curl($url.'getHeadersBySearch?industry='.$industry.'&location='.$location.'&expMin='.$expMin.'&expMax='.$expMax.'&sortBy=&startingRowNo='.$npl.'&noOfRows=1000000');
$data = json_decode($json);
} else {
//$json = file_get_contents_curl($url.'getOnlineWebPosting');
$json = file_get_contents_curl($url.'getHeadersBySearch?industry='.$industry.'&location='.$location.'&expMin='.$expMin.'&expMax='.$expMax.'&sortBy=&startingRowNo='.$npl.'&noOfRows=1000000');
$data = json_decode($json);
echo 'Data : ' . $data;
//if (!$data) echo "Data Not Found" ;
}
if($sortBy=='DESC' || $sortBy=='') {
$aclass = 'down_arrow';
} else {
$aclass = 'up_arrow';
}
$json2 = file_get_contents_curl($url.'getSearchData');
$data2 = json_decode($json2);
$industry = str_replace('%20', ' ', $industry);
$location = str_replace('%20', ' ', $location);
if($industry=='F amp A - BPO') {
$industry = 'F & A - BPO';
}
if($industry=='OIL amp GAS') {
$industry = 'OIL & GAS';
}
?>
<div class="section background-white">
<div class="background-white">
<p class="text-padding-bot text-letter-spacing1">A cross-section of Jobs currently available. We recommend you to contact our Executives for further info. <br />
More details available when the Job is '<strong>View'</strong>ed. </p>
</div>
<?php
//$data='';
if($data!=''){ ?>
<?php //if ($checkyear>2017) { ?>
<div class="subJobs">
<ul>
<li> Industry <br />
<select name="industry" id="industry" class="sel">
<option value="">Select Industry Name</option>
<?php for($i=0; $i<count($data2[0]); $i++) { ?>
<?php if(isset($industry) && $industry==$data2[0][$i]) { ?>
<option selected value="<?php echo $data2[0][$i];?>"><?php echo $data2[0][$i];?></option>
<?php } else { ?>
<option value="<?php echo $data2[0][$i];?>"><?php echo $data2[0][$i];?></option>
<?php }
} ?>
</select>
</li>
<li>Location<br />
<select name="city" id="city" class="sel">
<option value="">Select City Name</option
><?php $m=0; for($j=0; $j<count($data2[1]); $j++) { ?>
<?php $locat = explode(",",$location); ?>
<?php if($locat[$m]!="" && $locat[$m]==$data2[1][$j]) { ?>
<option selected value="<?php echo $data2[1][$j];?>"><?php echo $data2[1][$j];?></option>
<?php ++$m; } else { ?>
<option value="<?php echo $data2[1][$j];?>"><?php echo $data2[1][$j];?></option>
<?php }
} ?>
</select>
</li>
<li>Experience <br />
<select name="minyear" class="sel2" id="minyear">
<option value="">Min</option>
<?php for($ii=0; $ii<46; $ii++) { ?>
<?php if($expMin!="" && $expMin==$ii) { ?>
<option selected value="<?php echo $ii; ?>"><?php echo $ii; ?></option>
<?php } else { ?>
<option value="<?php echo $ii; ?>"><?php echo $ii; ?></option>
<?php }
} ?>
</select>
<select name="maxyear" class="sel2" id="maxyear" onchange="return select_max();">
<option value="">Max</option>
<?php for($ii=0; $ii<51; $ii++) { ?>
<?php if($expMax!="" && $expMax==$ii) { ?>
<option selected value="<?php echo $ii; ?>"><?php echo $ii; ?></option>
<?php } else { ?>
<option value="<?php echo $ii; ?>"><?php echo $ii; ?></option>
<?php }
} ?>
</select>
<!-- select name="" class="sel2" id="sort">
<option value="">Select</option>
<option value="ASC">ASC</option>
<option value="DESC">DESC</option>
</select -->
</li>
<li class="ser"><button type="button" onclick="search_by_category()" class="btn btn-default" style="margin-top:25px;"><i class="fa fa-search"></i> Search</button></li>
</ul>
</div>
<!-- Selected Jobs Headline Info -->
<div class="line">
<p class="text-dark text-center text-size-16">
<?php if($industry) echo 'Showing ' . '<b>' . $industry .'</b>' . ' Jobs' ; ?>
<?php if($location) echo ' at ' . '<b>' . $location .'</b>' ; ?>
<?php if($expMin) echo ' with Min ' . '<b>' . $expMin .'</b>' ; ?>
<?php if($expMax) echo ' to Max '. '<b>' . $expMax.'</b>' ; ?>
<?php if($expMin | $expMax) echo ' Years Experience' ;?>
</p>
</div>
<!-- Jobs Table -->
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th class="jobs_noshow text-center" width="5%">S.No</th>
<th class="text-center" width="15%">Posted On</th>
<th class="text-center" width="30%">Job Title</th>
<th class="jobs_noshow text-center" width="15%">Level</th>
<th class="jobs_noshow text-center" width="15%">Location</th>
<th class="jobs_noshow text-center" width="15%">Job Code</th>
<th class="text-center" width="5%">Action</th>
</tr>
</thead>
<tbody>
<?php $ri=1; foreach($data as $kk=>$d) { ?>
<?php
$date_posted = $d->postedDate; // get the Posted Date
$date_posted_year=date("Y",strtotime($date_posted)); // Get the Year from the date and store in a variable
//if ($date_posted_year>$jobs_restrict_year) { // Show only Jobs posted after this year ?>
<tr>
<td class="jobs_noshow text-center"><?php echo $ri; ?></td>
<td class="text-center"><?php echo $d->postedDate; ?></td>
<td><?php echo $d->title; ?></td>
<td class="jobs_noshow ctext notreq"><?php echo $d->level; ?></td>
<td class="jobs_noshow text-center notreq"><?php echo $d->location; ?></td>
<td class="jobs_noshow text-center"><?php echo $d->requirementID; ?></td>
<td class="text-center"><a class="button background-livec border-radius text-white" style="color:white" data-fancybox="ajax" href="?contentid=jobs-detail&requirementID=<?php echo $d->requirementID; ?>&requirementSeqNo=<?php echo $d->requirementSeqNo; ?>" data-type="ajax">View</a></td>
</tr>
<?php // } ?>
<?php $ri=$ri+1; } ?>
</tbody>
</table>
<script type="text/javascript">
$(document).ready(function () {
var table = $('#example').DataTable( {
"pageLength": 25,
"sPaginationType":"full_numbers",
"oLanguage": {
"sInfo": 'Showing _START_ to _END_ of _TOTAL_ Jobs.',
"sInfoEmpty": '',
"sEmptyTable": "No Jobs found currently",
}
});
$('#example').removeClass( 'display' ).addClass('table table-striped table-bordered');
});
</script>
<style> .dataTables_filter { display: none; } </style>
<!-- End of Table -->
</div>
<?php } else { ?>
<div style="margin: 20px 0 40px 0px;height:200px;text-align:center;">
<h1 style="font-size:16px;">Server is unavailable at the moment. Please try after some time.</h1>
</div>
<?php }?>
</div>
<!--jobs end-->
<script type="text/javascript">
function search_by_category() {
industry = $('#industry option:selected').val();
//city1 = $('#city option:selected').val();
minyear = $('#minyear option:selected').val();
maxyear = $('#maxyear option:selected').val();
//sortBy = $('#sort option:selected').val();
var city = $('select#city').val();
var cur_pg = "<?php echo $cpg; ?>";
var tot = "<?php echo $total; ?>";
var tot_pgs = Math.ceil(tot/25);
//if(cur_pg=="")
cur_pg = 1;
var last_pg = tot_pgs - cur_pg;
if(last_pg==0)
records = tot - ((tot_pgs -1) * 25);
else
records = 25;
var strt_val = ((cur_pg-1) * 25) + 1;
if(industry=='F & A - BPO')
industry ='F amp A - BPO';
if(industry=='OIL & GAS')
industry ='OIL amp GAS';
city1 = document.getElementById("city").value;
if(city1=="" || city1=="null") {
city="";
}
if(industry!="" || city!="" || minyear!="" || maxyear!="") {
location.href="hotjobs.php?contentid=hotjobs&industry="+industry+"&location="+city+"&expMin="+minyear+"&expMax="+maxyear+"&sortBy=&startingRowNo=1"+"&noOfRows="+records+"&page="+cur_pg;
} else {
//alert("Please select any one of the fields");
location.href="hotjobs.php?contentid=hotjobs&industry="+industry+"&location="+city+"&expMin="+minyear+"&expMax="+maxyear+"&sortBy=&startingRowNo=1"+"&noOfRows="+records+"&page="+cur_pg;
}
}
function sort_by_location() {
var order = '<?php echo $sortBy; ?>';
industry = $('#industry option:selected').val();
city = $('#city option:selected').val();
minyear = $('#minyear option:selected').val();
maxyear = $('#maxyear option:selected').val();
city1 = document.getElementById("city").value;
if(industry=='F & A - BPO')
industry ='F amp A - BPO';
if(industry=='OIL & GAS')
industry ='OIL amp GAS';
if(city1=="") {
city="";
} else {
city = $('select#city').val();
}
if(order=="" || order=="DESC") {
location.href="hotjobs.php?contentid=hotjobs&industry="+industry+"&location="+city+"&expMin="+minyear+"&expMax="+maxyear+"&sortBy=ASC"+"&startingRowNo=1&noOfRows=10";
} else {
location.href="hotjobs.php?contentid=hotjobs&industry="+industry+"&location="+city+"&expMin="+minyear+"&expMax="+maxyear+"&sortBy=DESC"+"&startingRowNo=1&noOfRows=10";
}
}
function select_max() {
minyear = document.getElementById("minyear").value;
maxyear = document.getElementById("maxyear").value;
if(parseInt(maxyear)>=parseInt(minyear)) {
return true;
} else {
if(maxyear!="") {
alert("Maximum year must be equal or greater than minimum year");
$('#maxyear').val("");
return false;
}
}
}
</script>
The data as seen when accessed on my localhost