Online Chat
 Call Us: 
1-877-744-1221
Browse Submit a Ticket
 
Advanced Search
Tools
Rss Categories

Basic HTTP authentication support for cron script

Author: Edward Hardin Reference Number: AA-00398 Views: 8657 Last Updated: 01/27/2012 11:43 AM 0 Rating/ Voters

If you're using basic http authentication on your server, you will need to add access credentials to cron script. Cron script uses cURL and that's why you need to add following two lines to the /admin/CRON/cron.php file:

curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, 'login:password');

Replace "login" and "password" are your actual http authentication credentials.

After these changes, your cron.php file will look similar to following:

<?php
chdir(dirname(__FILE__)."/../");
define("BASEPATH", true);
include 'config.inc.php';
$sysConfig = __getConfig();
$base_url = $sysConfig['base_url'];
// create a new cURL resource
$ch = curl_init();         
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, $base_url . 'cron/start');
curl_setopt($ch, CURLOPT_HEADER, 0); 
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, 'websitescripts:hello!');
// grab URL and pass it to the browser
curl_exec($ch);         
// close cURL resource, and free up system resources
curl_close($ch);
?>

CURLAUTH_NTLM vs CURLAUTH_BASIC

If that won't work try to use CURLAUTH_NTLM instead of CURLAUTH_BASIC:

curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);

Note
You might need to add those two lines to the /admin/CRON/cron.php once again after KnowledgeBase Manager Pro - this file may be overwritten after update.