Create cookie.txt file if possible, and add better errors if not creatable or writable. Fixes #3
This commit is contained in:
@@ -26,11 +26,18 @@ function login($usr, $pwd){
|
|||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||||
|
|
||||||
$cookie_file_path = 'cookies.txt';
|
$cookie_file_path = 'cookies.txt';
|
||||||
|
|
||||||
if (!file_exists($cookie_file_path) || !is_writable($cookie_file_path)){
|
if (!file_exists($cookie_file_path)){
|
||||||
echo 'Cookie file missing or not writable.';
|
fopen($cookie_file_path, "w");
|
||||||
die;
|
if (!file_exists($cookie_file_path)){
|
||||||
}
|
echo "Cookie file missing and can't be created.\n";
|
||||||
|
die;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!is_writable($cookie_file_path)){
|
||||||
|
echo 'Cookie file not writable- chmod to the user writing the script\n.';
|
||||||
|
die;
|
||||||
|
}
|
||||||
|
|
||||||
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
|
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
|
||||||
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
|
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
|
||||||
|
|||||||
Reference in New Issue
Block a user