<?php function solr_get_client($override_options=[]) { $options = array ( 'hostname' => SOLR_SERVER_HOSTNAME, 'port' => SOLR_SERVER_PORT, 'secure' => SOLR_SECURE, 'path' => SOLR_SERVER_PATH, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD ); $options = array_merge($options, $override_options); return new SolrClient($options); } function geocoding( $location ) { // PLZ-Erkennung: Wenn nur 5 Ziffern eingegeben, ", Deutschland" anhaengen // Damit findet Google Maps z.B. "92318, Deutschland" statt zu scheitern if ( !empty( $ort ) && preg_match( '/^\d{5}$/', trim( $ort ) ) ) { $ort = trim( $ort ) . ', Deutschland'; } $currLocation = geoip_detect2_get_info_from_current_ip(); $currCountryCode = $currLocation && !$currLocation->isEmpty ? $currLocation->country->isoCode : "DE"; $currCountry = "Deutschland"; switch($currCountryCode) { case "AT": $currCountry = "Österreich"; break; case "CH": $currCountry = "Schweiz"; break; } $query = GOOGLE_API_URL . '?address=' . $location . ' '. $currCountry .'&key=' . GOOGLE_API_KEY_SERVER; $response = wp_remote_get( $query ); if(is_array( $response ) ) { $body = json_decode($response['body']); if( $body->results && $body->results[0]->geometry->location ) { return array( 'lat' => $body->results[0]->geometry->location->lat, 'lng' => $body->results[0]->geometry->location->lng ); } } }< // PLZ-Suche Fix: 5-stellige PLZ -> ", Deutschland" anhaengen if(isset($_GET['search_ort'])&&preg_match('/^\d{5}$/',trim($_GET['search_ort']))){$_GET['search_ort']=trim($_GET['search_ort']).', Deutschland';} ?php /** * Template Name: Jobs Page Template * BUGFIX v5: Session mit Job-IDs füllen für Vor/Zurück-Navigation */ require_once('jobboerse/init.php'); // Lucene Query aufbauen $q_parts = array(); // Initiativbewerbung immer ausblenden (interne Stellen) $q_parts[] = 'NOT title:Initiativbewerbung'; if (!empty($jobTitle)) { $safe = addslashes($jobTitle); $q_parts[] = 'title:(*' . $safe . '* OR ' . $safe . '~2)'; } if (!empty($jobType)) { $q_parts[] = 'jobType:"' . addslashes($jobType) . '"'; } else { $q_parts[] = 'NOT jobType:Recruiting'; } if (!empty($jobHours)) { $q_parts[] = 'weeklyHours:"' . addslashes($jobHours) . '"'; } if (!empty($jobCategory) && defined('JOB_CATEGORIES') && isset(JOB_CATEGORIES[$jobCategory])) { $q_parts[] = 'jobCategory:"' . addslashes(JOB_CATEGORIES[$jobCategory]) . '"'; } if (!empty($jobSalary)) { $q_parts[] = 'salaryAmount:[1 TO *]'; } $geo_coords = null; if (!empty($jobLocation)) { if (function_exists('geocoding')) { $geocode = geocoding($jobLocation); if (is_array($geocode)) { $geo_coords = $geocode; } else { $q_parts[] = 'placeOfWork:"' . addslashes($jobLocation) . '"'; } } else { $q_parts[] = 'placeOfWork:"' . addslashes($jobLocation) . '"'; } } $q = implode(' AND ', $q_parts); $base_url = defined('ZC_AWS_PROXY_URL') ? ZC_AWS_PROXY_URL : 'https://q8x8m6hl0b.execute-api.eu-central-1.amazonaws.com/default/zeitconcept-job-proxy'; $proxy_url = $base_url . '?q=' . rawurlencode($q) . '&rows=' . intval($rows) . '&start=' . intval($start) . '&sort=' . rawurlencode('updated_dateFrom desc'); $cache_key = 'zc_jobs_' . md5($proxy_url); $jobs_data = wp_cache_get($cache_key); if (false === $jobs_data) { $response = wp_remote_get($proxy_url, array('timeout' => 15)); if (!is_wp_error($response)) { $body = wp_remote_retrieve_body($response); $decoded = json_decode($body); if (is_array($decoded)) { $envelope = new stdClass(); $envelope->response = new stdClass(); $envelope->response->docs = $decoded; $jobs_data = $envelope; } elseif (isset($decoded->response->docs)) { $jobs_data = $decoded; } else { $jobs_data = null; } if ($jobs_data) wp_cache_set($cache_key, $jobs_data, '', 300); } } // Umkreissuche: Ergebnisse per Haversine-Formel nach Entfernung filtern if ($geo_coords && $jobs_data && isset($jobs_data->response->docs)) { $jobs_data->response->docs = array_values(array_filter($jobs_data->response->docs, function($job) use ($geo_coords, $jobDistance) { if (empty($job->placeOfWork_coords)) return false; $parts = explode(',', $job->placeOfWork_coords); if (count($parts) !== 2) return false; $lat2 = (float) trim($parts[0]); $lng2 = (float) trim($parts[1]); $R = 6371; $dLat = deg2rad($lat2 - $geo_coords['lat']); $dLng = deg2rad($lng2 - $geo_coords['lng']); $a = sin($dLat/2)*sin($dLat/2) + cos(deg2rad($geo_coords['lat']))*cos(deg2rad($lat2))*sin($dLng/2)*sin($dLng/2); $dist = $R * 2 * atan2(sqrt($a), sqrt(1-$a)); return $dist <= intval($jobDistance); })); } // API ignoriert rows= Parameter – auf 30 begrenzen if ($jobs_data && isset($jobs_data->response->docs)) { $jobs_data->response->docs = array_slice($jobs_data->response->docs, 0, intval($rows)); } // Job-IDs in Session speichern für Vor/Zurück-Navigation auf Detailseiten if ($jobs_data && isset($jobs_data->response->docs)) { if (!session_id()) session_start(); $_SESSION['last_search_results'] = array_values(array_filter(array_map(function($job) { if (isset($job->id_i) && !empty($job->id_i)) return (string) intval($job->id_i); if (isset($job->id) && !empty($job->id)) { $raw = (string) $job->id; return (strlen($raw) > 7) ? (string) zc_remove_ID_timestamp($raw) : $raw; } return ''; }, $jobs_data->response->docs))); } if ($jobs_data && isset($jobs_data->response->docs)) { $list_items = array(); foreach ($jobs_data->response->docs as $index => $job) { $job_id = $job->id ?? null; $real_url = home_url('/job/' . $job_id); $list_items[] = array("@type" => "ListItem", "position" => $index + 1, "url" => $real_url); } $list_schema = array( "@context" => "https://schema.org", "@type" => "ItemList", "name" => "Stellenangebote zeitconcept GmbH Personaldienstleistungen", "itemListElement" => $list_items ); add_action('wp_head', function() use ($list_schema) { echo '<script type="application/ld+json">' . json_encode($list_schema, JSON_UNESCAPED_UNICODE) . '</script>'; }); } // SEO: Suchresultat-Seiten mit Parametern auf noindex setzen (Duplicate Content vermeiden) if (!empty($jobTitle) || !empty($jobLocation) || !empty($jobType) || !empty($jobHours)) { add_action('wp_head', function() { echo '<meta name="robots" content="noindex, follow">' . "\n"; }, 1); } get_header(); ?> <!-- ZC-DEBUG: q=[<?php echo esc_html($q); ?>] type=[<?php echo esc_html($jobType); ?>] hours=[<?php echo esc_html($jobHours); ?>] --> <div id="container"> <?php get_template_part('components/social-buttons'); ?> <?php if (has_post_thumbnail(get_the_ID())) : $image = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'single-post-thumbnail'); $image = $image[0]; include 'page-templates/partials/o-image.php'; endif; ?> <div> <div id="primary" class="content-area"> <main id="main" class="site-main" role="main"> <div class="container"> <div class="columns"> <div class="column is-8"> <div class="box"> <?php set_query_var('zc_jobs_data', $jobs_data); set_query_var('zc_use_real_links', true); include 'jobboerse/partials/listings.php'; ?> </div> </div> </div> </div> </main> </div> </div> </div> <?php get_footer(); ?>