0) { $row = mysqli_fetch_assoc($result); // ✅ If URL is accessed via ID, redirect permanently to canonical slug if (isset($_GET['id']) && is_numeric($_GET['id'])) { header("HTTP/1.1 301 Moved Permanently"); header("Location: " . $row['url']); exit; } // ✅ Else: proceed normally (already on clean slug) // process $row here to display the post } else { // ❌ No post found header("Location: 404.php"); exit(); } //pageview count query $page=$row['title']; $count="SELECT * FROM page_hits WHERE page='".$page."'";$feedback=mysqli_query($GLOBALS["___mysqli_ston"],$count) or die ( ((is_object($GLOBALS["___mysqli_ston"]))? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ?$___mysqli_res : true))); $roo=mysqli_fetch_assoc($feedback); $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://"; $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost'; $requestUri = $_SERVER['REQUEST_URI']; $pathParts = explode('/', trim($requestUri, '/')); $subdomain = explode('.', $_SERVER['HTTP_HOST'])[0]; $domain = explode('.', $_SERVER['HTTP_HOST'])[1]; $parts = explode('.', $host); $domain1 = $parts[0]; $brand = ucwords(str_replace('-', ' ', $domain1)); $author = isset($row['author']) && trim($row['author']) != '' ? $row['author'] : $brand; if (strcasecmp($author, 'admin') === 0) { $author = $brand; } $currentUrl = $protocol .$host. $requestUri; $currentUrl = urldecode($currentUrl); if (strlen($domain)<4) { $host=$host.str_replace('/single.php','',strtolower($_SERVER['PHP_SELF'])); } //$firstPathSegment = (count($pathParts) > 1) ? '/' . $pathParts[0] : ''; //} //else //{ // $currentUrl = "**".$protocol . $host . $requestUri; //} $image =$row['photo']; if (strpos(strtolower($image),"https://") !== false) { //file_put_contents("links.txt",$image, FILE_APPEND | LOCK_EX); //$image='shit'; //$griditem['photo']; } else { //file_put_contents("nolink.txt",$image.chr(13), FILE_APPEND | LOCK_EX); $image=$protocol . $host.'/blogadmin/images/'.$row['photo']; } $seodesc= str_replace(["\r\n", "\r", "\n"], ' ',preg_replace('/\s+/', ' ',trim(substr(strip_tags($row['content']),0,250)))).'...'; $seodesc = strlen($seodesc) > 150 ? substr($seodesc, 0, 150) : $seodesc; $seodesc .= "..."; if (!isset($row['seo_title']) || trim($row['seo_title']) === '') { $seo_title= $row['title']; } else { $seo_title= $row['seo_title']; } if (!isset($row['seo_tags']) || trim($row['seo_tags']) === '') { if (empty($row['tags']) || $row['tags'] === null || $row['tags'] === 0) { $seo_tags= "Sithars Astrology Software, Best Astrology Software"; } else { $seo_tags =$row['tags']; } } else { $seo_tags= $row['seo_tags']; } if (!isset($row['seo_desc']) || trim($row['seo_desc']) === '') { $seo_desc= $seodesc; } else { $seo_desc= $row['seo_desc']; } $seo_desc = htmlspecialchars($seo_desc, ENT_QUOTES, 'UTF-8'); // -------------------------------- // 3. Language detection (based on category) // -------------------------------- // Default language $langCode = 'en'; $langName = 'English'; // Check for Tamil (safe multibyte check) if (!empty($category_name)) { // Option 1: simple English word check if (preg_match('/tamil/i', $category_name)) { $langCode = 'ta'; $langName = 'Tamil'; } // Option 2: fallback — detect Tamil characters elseif (preg_match('/[\x{0B80}-\x{0BFF}]/u', $category_name)) { $langCode = 'ta'; $langName = 'Tamil'; } } ?>