Installation

  • Unrar the SaffaHost-x.x.x.rar file to your local drive.
  • Edit the EDIT.class.config.php file and rename it to class.config.php
  • Upload the contents to a web accessible location.
  • CHMOD /templates/templates_c/ folder to be writable by the server, 655 ideally, some hosts may need 777.
  • Create database in and run saffahost.sql in phpMyAdmin.
  • Login in as user: admin and pass:admin at http://localhost/login.php

Smarty Template Variables

  • {$siteName}returns the site Name as entered in the class.config.php file.
  • {$baseURL}returns the site URL as enetered in the class.config.php file.
  • {$curSymbol}returns the currency symbol as chosen in the class.config.php file.
  • {$plans}returns an array of plans as setup in the admin area ordered from lowest to highest cost.
    • {section name=plan loop=$plans}
      • {$plans[plan].plan_id}
      • {$plans[plan].plan_name}
      • {$plans[plan].plan_package}
      • {$plans[plan].plan_description}
      • {$plans[plan].plan_short}
      • {$plans[plan].plan_amount}
      • {$plans[plan].plan_hdspace}
      • {$plans[plan].plan_bandwidth}
      {/section}
  • {$news} returns an array of news/blog entries, ordered by latest to oldest.
    • {section name=new loop=$news}
      • {$news[new].news_id}
      • {$news[new].news_date}
      • {$news[new].news_title}
      • {$news[new].news_content}
      {/section}

CoZa API beta

basic responses:

<coza>
	<status>1</status>
	<response></response>
</coza>

<coza>
	<status>0</status>
	<response>
		<errMsg></errMsg>
	</response>
</coza>

<?php
////////////////////////////////////////////////////////////
////////Check if domain top-host.co.za is available/////////
////////////////////////////////////////////////////////////

$coza = new Coza();
$domain = 'top-host';
$checkCoza = $coza->availableCoza($domain);
    if($checkCoza->status=='1'){
        if($checkCoza->response->available=='true'){
            echo $domain." is available.";
            }else{
            echo $domain. " is registered.";	
            }	
        echo nl2br($checkCoza->response->info);
        }else{
        echo $checkCoza->response->errMsg;	
            }

//////////////////////////////////////////////////////////////
//////////////Hack for a basic coza lookup Widget/////////////
//////////////////////////////////////////////////////////////

/*I log the lookups for registered API Key holders, as soon as they reach 
their daily limit with the coza.net.za server, they will then be able to able 
to use other ip's in my ip pool.

returns bool true/false;
*/
    function availableCoza($domain){
        $ch = curl_init();
        $query = 'http://www.coza.net.za/cgi-bin/whois.sh?Domain=';
        $query .= $domain;
        curl_setopt($ch, CURLOPT_URL, $query );
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        $response = curl_exec($ch );
        $match = "Match: One";
        $nomatch = "Match: No Matches";
        if(stristr($response,$match)){return false;}elseif(stristr($response,$nomatch)){return true;}
        curl_close($ch);
    }

//////////////////////////////////////////////////////////////



class Coza {
    //contact Ron Darby for an API Key, this will require a free sign up to saffahost client area
	var $apiKey = "xxxx-xxxx-xxxx-xxxx";
	
	function __construct(){		
		}
        
	function __destruct(){}	

	function request($query){
		$q = 'http://saffahost.com/api/?';
		$apiKey = $this->apiKey;
		$q .= 'verify='.$apiKey.'&';
		$q .= $query;			
		$response = $this->doCurl($q);		
		$object = new SimpleXMLElement($response);
		return $object;		
	}    
    
	//newDomain function not working yet, I've only included it for sample purposes (26/04/2010)
	/*
    function newDomain($domain,$regName,$regPostal,$regStreet,$regEmail,$regTel='N/A',$regFax='N/A'){
		
		$request ="cozareg=1&domain=".$domain."&action=N®_name=".urlencode($regName)."®_postalAddress=";
        	$request .= urlencode($regPostal)."®_streetAddress=".urlencode($regStreet)."®_telephoneNum=";
       		$request .= urlencode($regTel)."®_faxNum=".urlencode($regFax)."®_email=".urlencode($regEmail);
		$result = $this->request($request);	
		return $result;
		}
        */
        	
	function availableCoza($domain){
		 $xml = "<?xml version='1.0' encoding='UTF-8'?>";
		$request ='whois=domain&domain='.$domain;		
		$result = $this->request($request);		
		if($result->status=='1'){
		$query = $result->response;
		$response = $this->doCurl($query);	
		$pos1 = stripos($response,'<pre>');
		$pos2 = stripos($response,'</pre>');
		$len = $pos2-$pos1+6;
		$response = substr($response,$pos1,$len);
		$response = strip_tags($response);
		$match = "Match: One";
		$nomatch = "Match: No Matches";
		$reply = "";
		if(stristr($response,$match)){
			$reply .= '<available>false</available><info>'.$response.'</info>';			
		}elseif(stristr($response,$nomatch)){
			$reply .= '<available>true</available><info>'.$response.'</info>';			}
					
		$reply = $xml."<coza><status>1</status><response>".$reply."</response></coza>";
		
		}else{
		$reply = $xml."<coza><status>0</status><response><errMsg>".$result->response->errMsg."</errMsg></response></coza>";
		}
		$reply = new SimpleXMLElement($reply);		
		return $reply;
		}
		
	function doCurl($q){
		$ch = curl_init();		
		curl_setopt($ch, CURLOPT_URL, $q);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
		return curl_exec($ch);	
		curl_close($ch);
		}	

}

?>