Job Search

<?php
//post to ad ratio, sorta.
$adLimit = 10;
//xml api request values
$xmlQlimit = 20;
$xmlQpubid = "2223846015036000";
$xmlQusrip = $_SERVER['REMOTE_ADDR'];
$xmlQusrbt = urlencode($_SERVER['HTTP_USER_AGENT']);
$xmlQjdesc = urlencode($_POST['job_search_query']);
$xmlQjlocn = urlencode($_POST['job_search_areas']);
$xmlQstart = urlencode($_POST['start']);
if($xmlQjdesc == "" && $xmlQjlocn == "" && $xmlQstart == ""){
$xmlQjdesc = urlencode($_GET['job_search_query']);
$xmlQjlocn = urlencode($_GET['job_search_areas']);
$xmlQstart = urlencode($_GET['start']);
}
if ($xmlQstart > 1){
$xmlRpage = ($xmlQstart * 20) - 20;
}
$xml_file = inBuildurl($xmlQpubid, $xmlQjdesc, $xmlQjlocn, $xmlRpage, $xmlQlimit, $xmlQusrip, $xmlQusrbt);
if ($xmlQjdesc != ""){ // only run if a search occurs
//print $xml_file; //DEBUG ONLY
$dom = new DOMDocument();
$dom->load($xml_file);
$xmlMeta = $dom->getElementsByTagName('response');
foreach ($xmlMeta as $elem){ // grab paging-related values
$retResults = $elem->getElementsByTagName('totalresults')->item(0)->nodeValue;
$retStart = $elem->getElementsByTagName('start')->item(0)->nodeValue;
$retEnd = $elem->getElementsByTagName('end')->item(0)->nodeValue;
$retPages = ceil($retResults/$xmlQlimit);
$retCurrent = ceil($retEnd/$xmlQlimit);
}
}
?>

<?php
function inBuildurl($xmlQpubid, $xmlQjdesc, $xmlQjlocn, $xmlQstart, $xmlQlimit, $xmlQusrip, $xmlQusrbt){
$tmpReq = "http://api.indeed.com/ads/apisearch?publisher=" . $xmlQpubid;
$tmpReq .= "&q=" . $xmlQjdesc;
$tmpReq .= "&l=" . $xmlQjlocn;
$tmpReq .= "&start=" . $xmlQstart;
$tmpReq .= "&limit=" . $xmlQlimit;
$tmpReq .= "&co=us&chnl=&userip=" . $xmlQusrip;
$tmpReq .= "&useragent=" . $xmlQusrbt;
return $tmpReq;
}
function inPaging($pageCurrent, $pageMax, $pageRange, $pagequery, $pagelocation){
$pageCounter = $pageCurrent - $pageRange;
print "

  • «
  • \n";
    while ($pageCounter if ($pageCounter > 0 && $pageCounter if ($pageCounter == $pageCurrent){
    print "

  • $pageCounter
  • ";
    }else{
    print "

  • $pageCounter
  • ";
    }
    }
    $pageCounter++;
    }
    print "

  • »
  • ";
    }
    function niceTime($time) {
    $delta = time() - $time;
    if ($delta return 'less than a minute ago.';
    } else if ($delta return 'about a minute ago.';
    } else if ($delta return floor($delta / 60) . ' minutes ago.';
    } else if ($delta return 'about an hour ago.';
    } else if ($delta return 'about ' . floor($delta / 3600) . ' hours ago.';
    } else if ($delta return '1 day ago.';
    } else {
    return floor($delta / 86400) . ' days ago.';
    }
    }
    ?>

    Share this 
    Like this post? Contribute to the discussion!