I'm making a site crawler/sitemap generator module, that needs to be able to run on CRON. I've finished everything and I'm at the stage where I need to ping search engines my new sitemap file. My module has a web interface and the ping works fine from there, but since it needs to run on CRON I made a CConsoleCommand
that runs it.
So, the problem I'm getting is that I'm passing the $_SERVER['SERVER_NAME']
variable to the ping action. And CConsoleCommand
is throwing an error on Undefined index: SERVER_NAME
.
Now, I've tried:
$_SERVER['HTTP_HOST']
$_SERVER['SERVER_NAME']
Yii::app()->request->getBaseUrl(true) //returns absolute URL
But they all throw errors on SERVER_NAME
. Does CConsoleCommand not have support for these variables?
C:\xampp\htdocs\YiiCrawler>protected\yiic crawler-sitemap crawl
PHP Error[8]: Undefined index: SERVER_NAME
in file C:\xampp\htdocs\YiiCrawler\yii-1.1.16.bca042\framework\web\CHttpRequest.php at line 344
#0 C:\xampp\htdocs\YiiCrawler\yii-1.1.16.bca042\framework\web\CHttpRequest.php(392): CHttpRequest->getHostInfo()
#1 C:\xampp\htdocs\YiiCrawler\protected\modules\AvocadoCrawler\commands\ConsoleCrawlerCommand.php(26): CHttpRequest->getBaseUrl()
#2 unknown(0): ConsoleCrawlerCommand->actionCrawl()
#3 C:\xampp\htdocs\YiiCrawler\yii-1.1.16.bca042\framework\console\CConsoleCommand.php(172): ReflectionMethod->invokeArgs()
#4 C:\xampp\htdocs\YiiCrawler\yii-1.1.16.bca042\framework\console\CConsoleCommandRunner.php(71): ConsoleCrawlerCommand->run()
#5 C:\xampp\htdocs\YiiCrawler\yii-1.1.16.bca042\framework\console\CConsoleApplication.php(92): CConsoleCommandRunner->run()
#6 C:\xampp\htdocs\YiiCrawler\yii-1.1.16.bca042\framework\base\CApplication.php(184): CConsoleApplication->processRequest()
#7 C:\xampp\htdocs\YiiCrawler\yii-1.1.16.bca042\framework\yiic.php(33): CConsoleApplication->run()
#8 C:\xampp\htdocs\YiiCrawler\protected\yiic.php(7): require_once()