<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class SMS{



    public function sendSMS($from,$to,$content,$mclass,$smppId){

       switch($smppId){
		   
		   case 1 : $command ='lynx -dump "'.'http://localhost:13013/cgi-bin/sendsms?username=absivoire&password=absivoire&to='.$to.'&from='.$from.'&text='.$content.'&mclass='.$mclass.'&smsc=sva1&dlr-mask=2"';
		             break; // KANNEL
		   case 2 : $command ='lynx -dump "'.'http://localhost:13013/cgi-bin/sendsms?username=absivoire&password=absivoire&to='.$to.'&from='.$from.'&text='.$content.'&mclass='.$mclass.'&smsc=sva2&dlr-mask=2"';
		             break; // KANNEL
		   case 3 : $command ='lynx -dump "'.'http://localhost:13013/cgi-bin/sendsms?username=absivoire&password=absivoire&to='.$to.'&from='.$from.'&text='.$content.'&mclass='.$mclass.'&smsc=sva3&dlr-mask=2"';
		             break; // KANNEL
		   case 4 :  $command ='lynx -dump "'.'http://121.241.242.114:8080/bulksms/bulksms?username=fko-fkonan&password=kfnnnn&type=0&dlr=Y&destination='.$to.'&message='.$content.'&source=CIE"'; 
		        break; // Http API
		   
		   default : 
		   if(strlen($to)==8){
			   // Format National 
			   //$prefix = trim($phoneNumber[0].$phoneNumber[1]);
			    $to="225".$to; 
								
				
				}
		    $command ='lynx -dump "'.'http://121.241.242.114:8080/bulksms/bulksms?username=fko-cieci&password=cie2000&type=0&dlr=Y&destination='.$to.'&message='.$content.'&source=CIE"';
		   

	   }

        

           // echo $command;

            exec($command,$data_res);
            $res = trim($data_res[1]);
            
            $resData = explode(":",$res);
            
            $accepted = trim($resData[0]);
           
            return  $accepted;


    }


    public function sendSmsAll($from,$to,$content){
$content = urlencode($content);

        $command ='lynx -dump "'.'http://121.241.242.114:8080/bulksms/bulksms?username=fko-fkonan&password=kfnnnn&type=0&dlr=Y&destination='.$to.'&message='.$content.'&source=CIE"';

            echo $command;

            exec($command,$data_res);
            $res = trim($data_res[1]);
            
            $resData = explode(":",$res);
            
            $accepted = trim($resData[0]);
           
            return  $accepted;


    }


    public function sendSmsAll11($from, $to, $content){
  $content = urlencode($content);
  $url = "http://196.5.254.66/http/sendmsg?user=akura2011&password=akura123456&api_id=3340518&to=$to&text=$content";
  echo $url;
  $fp = fopen($url,"r");
  if($fp) {
  $rawData ="";
    while(!feof($fp)){
		$rawData.= fgets($fp);
	}
  
  
  fclose($fp);
  
  }
  return $rawData;
  
	
}


    public function sendSmsWindows($from, $to, $content,$msgType){
  $content = urlencode($content);
  $url = 'http://192.168.10.2:14013/cgi-bin/sendsms?username=digital&password=digital&to='.$to.'&from='.$from.'&text='.$content.'&smsc=ivr1&dlr-mask=2&mclass='.$msgType;
  echo $url;
  $fp = fopen($url,"r");
  if($fp) {
  $rawData ="";
    while(!feof($fp)){
		$rawData.= fgets($fp);
	}
  
  
  fclose($fp);
  
  }
  return $rawData;
  
	
}

    public function sendSMSOffers($from, $to, $content){
        $data_res = NULL;
        $command ='lynx -dump "'.'http://localhost:13013/cgi-bin/sendsms?username=svam&password=svam&to='.$to.'&from='.$from.'&text='.$content.'&smsc=sva1"';
        
           exec($command,$data_res);
            $res = trim($data_res[1]);
            
            $resData = explode(":",$res);
            
            $accepted = trim($resData[0]);
           
            return  $accepted;
        
    }

}


?>
