I am writing a whmcs plugin that will communicate with the csf firewall. As far as i know, there is no web api for csf, thus I am forced to post data to the cgi script located at https://hostname:2087/cgi/addon_csf.cgi. Anyway, I have everything written, but I cant seem to be able to use the WHM access key has to remotely login through curl. Here is a snippet of my code and I sincerely appreciate any help:
All i get back is the login screen for whm, so its definitely not logging in. Suggestions?Code:<?php $url = "https://$hostname:2087/cgi/addon_csf.cgi"; $username = 'root'; $hash = str_replace("\r\n",'',$hash); # Strip newlines from the hash $postfields["action"] = $action; $postfields["ip"] = $ip; $ch = curl_init(); $auth_header[0] = "Authorization: Basic ".$username.":".$hash; # set up the Header Array curl_setopt($curl, CURLOPT_HTTPHEADER, &$auth_header); # tell curl to use the header array curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 100); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); $data = curl_exec($ch); curl_close($ch); var_dump($data); ?>


LinkBack URL
About LinkBacks
Reply With Quote