$folder_time ) {
$myfile = fopen("age.txt", "w") or die("Unable to open file!");
fwrite($myfile, time());
fclose($myfile);
$now = time();
$files = glob("cache-data/*.*");
foreach ($files as $file) {
if (is_file($file)) {
if ($now - filemtime($file) >= 60 * 60 * 24 * 1) { // 7 hari
unlink($file);
}
}
}
$files = glob("cache/*.*");
foreach ($files as $file) {
if (is_file($file)) {
if ($now - filemtime($file) >= 60 * 60 * 24 * 1) { // 7 hari
unlink($file);
}
}
}
}
$service->get_popular();
//settings CACHE
$cache_ext = '.html'; //file extension
$cache_time = 28800; //Cache file expires after these seconds (1 hour = 3600 sec) (8 hour = 28800 sec) (12 hour = 43200 sec)
$cache_folder = './cache/'; //folder to store Cache files
$ignore_pages = array('', '');
$dynamic_url = 'http://'.$_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . $_SERVER['QUERY_STRING']; // requested dynamic page (full url)
$cache_file = $cache_folder.md5($dynamic_url).$cache_ext; // construct a cache file
$ignore = (in_array($dynamic_url,$ignore_pages))?true:false; //check if url is in ignore list
//END settings CACHE
$popular_arr = json_decode(file_get_contents(__DIR__ . "/popular.json"), 1);
if ($page == "sitemap" || $page == "sitemap.xml") {
include_once "./sitemap.php";
die;
}
if (isset($_GET["q"])) {
$location = SITE_HOST . "/job-category/" . urlencode($_GET["q"]);
echo "";
die;
}
if (substr($page, 0, 1) == "?") {
header("location:" . SITE_HOST);
}
if ($page == "about") {
$title = 'About Us - '.SITE_TITLE;
$desc = DESCRYPTION;
}
if ($page == "contact") {
$title = 'Contact Us - '.SITE_TITLE;
$desc = DESCRYPTION;
}
if ($page == "privacy") {
$title = 'Privacy Policy - '.SITE_TITLE;
$desc = DESCRYPTION;
}
if ($page == "term") {
$title = 'Terms & Conditions - '.SITE_TITLE;
$desc = DESCRYPTION;
}
if ($page == "home") {
$jobData = $service->getDataHome();
$result = $jobData;
$title = "Home - ". SITE_TITLE;
$desc = DESCRYPTION;
}
if ($page == "job") {
$jobKeyArr = explode("-", $id);
//$jobKey = $jobKeyArr[0];
$jobKey = $jobKeyArr[count($jobKeyArr) -2];
$deathhost = str_replace('/workspread', '', $_SERVER['REQUEST_URI']);
if (strpos($jobKey, 'jktk') === false) {
header('Location: ' . SITE_HOST.$deathhost.'-'.$urlkey, true, 301);
#echo '';
die();
}
$arr = explode("jktk", $jobKey);
$jkArr = explode("_", $arr[0]);
$jk = count($jkArr) < 2 ? $arr[0] : $jkArr[1];
$tk = $arr[1];
if(strlen($tk) > 1){
$deathhost = str_replace('/workspread', '', $_SERVER['REQUEST_URI']);
$deathhost = str_replace($tk, '', $deathhost);
header('Location: ' . SITE_HOST.$deathhost, true, 301);
die();
}
$country = $service->get_country(COUNTRY);
$country = $country[3];
$country = parse_url($country);
$url = 'https://'.$country['host'];
$urlOut = $url."/viewjob?jk={$jk}&from=serp&vjs=3";
unset($jobKeyArr[0]);
$slug = implode("-", $jobKeyArr);
if (file_exists(__DIR__ . "/cache-data/{$jk}.json")) {
$jobDetail = json_decode(file_get_contents(__DIR__ . "/cache-data/{$jk}.json"), 1);
if (!isset($jobDetail["description"])) {
$jobDetail["description"] = $service->getDetail($urlOut);
$jobDetail["jk"] = $jk;
$jobDetail["tk"] = $tk;
file_put_contents(__DIR__ . "/cache-data/{$jk}.json", json_encode($jobDetail));
}
}
if (!file_exists(__DIR__ . "/cache-data/{$jk}.json")) {
$jobDetail = $service->getDetail($urlOut, 1);
$jobDetail["jk"] = $jk;
$jobDetail["tk"] = $tk;
file_put_contents(__DIR__ . "/cache-data/{$jk}.json", json_encode($jobDetail));
}
if (!isset($jobDetail["address"])) {
for ($i = 0; $i < 3; $i++) {
$address = $faker->streetAddress;
$zip = $faker ->postcode;
//$currency = $faker ->currency_code;
$currency = \NumberFormatter::create(LOCALE,\NumberFormatter::CURRENCY)->getTextAttribute(\NumberFormatter::CURRENCY_CODE);
$jobDetail["address"] = $address;
$jobDetail["zip"] = $zip;
$jobDetail["currency"] = $currency;
file_put_contents(__DIR__ . "/cache-data/{$jk}.json", json_encode($jobDetail));
}
}
if(strlen($jobDetail['title']) < 1){
header('Location: ' . SITE_HOST, true, 301);
die();
}
if(strlen($jobDetail['company']) < 1){
header('Location: ' . SITE_HOST, true, 301);
die();
}
$jobDetail["url_out"] = $urlOut;
$jobDetail["jobkey"] = $jk;
$thisUrl = SITE_HOST . '/job/' . $service->slugify($jobDetail['title']).'-at-'.$service->slugify($jobDetail['company']). '-'.$service->slugify($jobDetail['location']). '-' . $jobDetail['jk'].'jktk'.$jobDetail['tk'];
$sessionArr = scandir(__DIR__ . "/cache-data", SCANDIR_SORT_DESCENDING);
unset($sessionArr[0]);
unset($sessionArr[1]);
$sessionArr= array_slice($sessionArr, 0, 300);
$result = $service->shuffle_assoc($sessionArr);
$slug = $service->slugify($jobDetail["title"]);
if (str_contains($jobDetail["title"], '","')) {
$newtitle = explode('","',$jobDetail["title"]);
$jobDetail["title"] = $newtitle[0];
$jobDetail["slug"] = $service->slugify($jobDetail["title"] );
file_put_contents(__DIR__ . "/cache-data/{$jobDetail["jk"]}.json", json_encode($jobDetail));
}
if (str_contains($jobDetail["company"], '","')) {
$newtitle = explode('","',$jobDetail["company"]);
$jobDetail["company"] = $newtitle[0];
file_put_contents(__DIR__ . "/cache-data/{$jobDetail["jk"]}.json", json_encode($jobDetail));
}
if (str_contains($jobDetail["location"], '","')) {
$newtitle = explode('","',$jobDetail["location"]);
$jobDetail["location"] = $newtitle[0];
file_put_contents(__DIR__ . "/cache-data/{$jobDetail["jk"]}.json", json_encode($jobDetail));
}
$expired = 'false';
if ($jobDetail['expired'] == 'true'){
$expired = 'false';
//echo '';
}
$title = $jobDetail["title"].' job at '.$jobDetail["company"]. ' in '.$jobDetail["location"]. ' - '.SITE_TITLE;
$desc = $jobDetail["company"].' is now hiring a '. $jobDetail["title"].' in '.$jobDetail["location"]. '. View job listing details and apply now. '.$jobDetail["sumary"];
}
if ($page == "job-category") {
$titleHead = ucwords(str_replace("-", " ", $service->slugify($id)));
$title = "Browse ".ucwords($id)." Jobs - ".SITE_TITLE;
$desc = "Browse ".ucwords($id)." Jobs - ".SITE_TITLE;
}
if ($page == "job-location") {
$titleHead = ucwords(str_replace("-", " ", $service->slugify($id)));
$title = "Browse Jobs at ".ucwords($id)." - ".SITE_TITLE;
$desc = "Browse Jobs at ".ucwords($id)." - ".SITE_TITLE;
}
include_once "./header.php";
if ($page == "job-category" || $page == "job-location") {
$caching = True;
if (file_exists($cache_file) && time() - $cache_time > filemtime($cache_file)) {
for($i=0; $i < 10; $i++) {
try {
$jobData = $service->getSearch($id);
if(in_array("warz0ne", $jobData));
break;
}
catch (Exception $e) {
echo '';
}
}
$result = $jobData;
}
if (!file_exists($cache_file)) {
for($i=0; $i < 10; $i++) {
try {
$jobData = $service->getSearch($id);
if(in_array("warz0ne", $jobData));
break;
}
catch (Exception $e) {
echo '';
}
}
$result = $jobData;
}
//print_r($result);
}
include_once "./{$page}.php";
include_once "./footer.php";
?>