src/Controller/HostingController.php line 307

Open in your IDE?
  1. <?php
  2. // src/Controller/EntrepriseController.php
  3. namespace App\Controller;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\HttpFoundation\JsonResponse;
  9. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  10. /**
  11.  * @Route("/{_locale}/hosting")
  12.  */
  13. class HostingController extends AbstractController
  14. {    
  15.     private $session;
  16.     
  17.     public function __construct(SessionInterface $session)
  18.     {
  19.         $this->session $session;
  20.     }
  21.     
  22.     /**
  23.      * @Route("/check-domain", name="check_domain")
  24.      */
  25.     public function checkDomainAction(Request $request)
  26.     {
  27.         $tlds = array('com''net''online''org''store''site''tech''xyz',
  28.         'biz''fun''info''pro''fr''be''eu');
  29.         $requestResults = array(
  30.             'data' => array(),
  31.             'ok' => ''
  32.         );
  33.         $results = array();
  34.         $domain '';
  35.        
  36.         //$this->session->set('cart', array());
  37.         if('POST' == $request->getMethod()){
  38.             $domain $_POST['domain'];
  39.         
  40.         $api = new DomainNameAPI_PHPLibrary();
  41.         $api->setConnectionMethod('SOAP');
  42.         // Set Domain Name API Username and Password
  43.         $api->setUser("Famian""ComputerAngel");
  44.     
  45.         // Enabling caching is recommended
  46.         $api->useCaching(true);
  47.         $api->useTestMode(false);
  48.         
  49.         // Check domain(s)
  50.         if($domain != ''){
  51.             $requestResults $api->CheckAvailability(
  52.         
  53.                     // Second level domain as string array
  54.                     array(
  55.                         $domain
  56.                     ),
  57.                     
  58.                     // TLD as string array
  59.                     $tlds,
  60.                     //Period
  61.                     "1",
  62.                     //Command (create,renew,transfer,restore)
  63.                     "create"
  64.                 
  65.                 );
  66.             }
  67.             //var_dump($requestResults);
  68.             /* requestResults est un tableau qui contient un ensemble d'élément pour chaque domaine
  69.              Exemple pour chaque domaine
  70.              'DomainName' => string 'njk' (length=3)
  71.               'TLD' => string 'org' (length=3)
  72.               'Status' => string 'notavailable' (length=12)
  73.               'IsFee' => boolean false
  74.               'Currency' => string 'USD' (length=3)
  75.               'Command' => string 'create' (length=6)
  76.               'Period' => int 1
  77.               'Price' => string '9.0100' (length=6)
  78.               'ClassKey' => null
  79.               'Reason' => string 'In use' (length=6)
  80.             */
  81.         }
  82.         return $this->render('hosting/check_domain.html.twig', [
  83.                'results' => $requestResults['data'],
  84.                'domain' => $domain,
  85.             ]);
  86.           
  87.     }
  88.     
  89.    
  90.     
  91.     /**
  92.      * @Route("/add-to-cart", name="add_to_card")
  93.      */
  94.     public function addToCartAction($element 'domain')
  95.     {
  96.         
  97.         $requestStack $this->get('request_stack');
  98.         $request $requestStack->getCurrentRequest();
  99.     
  100.         $em $this->getDoctrine()
  101.                     ->getManager();
  102.         
  103.         $nombreProduit = (int)$this->session->get('nombreProduit');
  104.         $cart = (array)$this->session->get('cart');
  105.         $nomDeDomaine '';
  106.         $tld '';
  107.         $prix '';
  108.         if('POST' == $request->getMethod() ){
  109.             $nomDeDomaine $request->get('nom_de_domaine');
  110.             $tld $request->get('tld');
  111.             $prix $request->get('prix');
  112.             
  113.             $leDomaine = array();
  114.             if(array_key_exists($nomDeDomaine.$tld$cart)){
  115.                 $cart[$nomDeDomaine.$tld]['year'] += 1;
  116.             } else{
  117.                 $leDomaine['nomDeDomaine'] = $nomDeDomaine;
  118.                 $leDomaine['tld'] = $tld;
  119.                 $leDomaine['prix'] = $prix;
  120.                 $leDomaine['year'] = 1;
  121.                 $leDomaine['id'] = $nomDeDomaine.$tld;
  122.                 $cart[$nomDeDomaine.$tld] = $leDomaine;
  123.             }
  124.             
  125.             $nombreProduit count($cart);
  126.             
  127.             $montantDomaine 0;
  128.             foreach($cart  as $domaine){
  129.                 $montantDomaine += $domaine['prix'] * $domaine['year'] ;
  130.             }
  131.             
  132.             $montantCommande = (float)$this->session->get('montantCommande');
  133.             $montantHebergement = (float)$this->session->get('montantHebergement');
  134.             $couponValue = (float)$this->session->get('couponValue');
  135.             $montantCommande $montantDomaine $couponValue $montantHebergement;
  136.             $this->session->set('cart'$cart);
  137.             $this->session->set('montantDomaine'$montantDomaine);
  138.             $this->session->set('montantCommande'$montantCommande);
  139.             $this->session->set('montantHebergement'$montantHebergement);
  140.             $this->session->set('nombreProduit'$nombreProduit 1);
  141.         }
  142.         
  143.         return new Response();
  144.     }
  145.      /**
  146.      * @Route("/register-domain", name="register_domain")
  147.      */
  148.     public function registerDomainAction(Request $request)
  149.     {
  150.         
  151.         
  152.         $api = new DomainNameAPI_PHPLibrary();
  153.         $api->setConnectionMethod('SOAP');
  154.         // Set Domain Name API Username and Password
  155.         $api->setUser("Famian""ComputerAngel");
  156.     
  157.         // Enabling caching is recommended
  158.         $api->useCaching(true);
  159.         $api->useTestMode(false);
  160.         
  161.         // Register Domain
  162.     $result $api->RegisterWithContactInfo(
  163.         // Domain name
  164.         "ofiber.pro"
  165.         
  166.         // Years
  167.         1
  168.         
  169.         // Contact informations
  170.         array(
  171.             // Administrative contact
  172.             "Administrative" => array(
  173.                 "FirstName" => "Arnaud",
  174.                 "LastName" => "Kadio",
  175.                 "Company" => "Assie Group",
  176.                 "EMail" => "contact@assiemail.com",
  177.                 "AddressLine1" => "Port-Bouet SIPIM",
  178.                 "State" => "CI-Cote d'ivoire (Ivory Coast)",
  179.                 "City" => "Abidjan",
  180.                 "Country" => "CI",
  181.                 "Fax" => "",
  182.                 "FaxCountryCode" => "225",
  183.                 "Phone" => "0748946939",
  184.                 "PhoneCountryCode" => "225",
  185.                 "Type" => "Contact",
  186.                 "ZipCode" => "12 BP 245 Abidjan 12",
  187.                 "Status" => ""
  188.             ),
  189.             
  190.             // Billing contact
  191.             "Billing" => array(
  192.                 "FirstName" => "Arnaud",
  193.                 "LastName" => "Kadio",
  194.                 "Company" => "Assie Group",
  195.                 "EMail" => "contact@assiemail.com",
  196.                 "AddressLine1" => "Port-Bouet SIPIM",
  197.                 "State" => "CI-Cote d'ivoire (Ivory Coast)",
  198.                 "City" => "Abidjan",
  199.                 "Country" => "CI",
  200.                 "Fax" => "",
  201.                 "FaxCountryCode" => "225",
  202.                 "Phone" => "0748946939",
  203.                 "PhoneCountryCode" => "225",
  204.                 "Type" => "Contact",
  205.                 "ZipCode" => "12 BP 245 Abidjan 12",
  206.                 "Status" => ""
  207.             ),
  208.             
  209.             // Technical contact
  210.             "Technical" => array(
  211.                 "FirstName" => "Arnaud",
  212.                 "LastName" => "Kadio",
  213.                 "Company" => "Assie Group",
  214.                 "EMail" => "contact@assiemail.com",
  215.                 "AddressLine1" => "Port-Bouet SIPIM",
  216.                 "State" => "CI-Cote d'ivoire (Ivory Coast)",
  217.                 "City" => "Abidjan",
  218.                 "Country" => "CI",
  219.                 "Fax" => "",
  220.                 "FaxCountryCode" => "225",
  221.                 "Phone" => "0748946939",
  222.                 "PhoneCountryCode" => "225",
  223.                 "Type" => "Contact",
  224.                 "ZipCode" => "12 BP 245 Abidjan 12",
  225.                 "Status" => ""
  226.             ),
  227.             
  228.             // Registrant contact
  229.             "Registrant" => array(
  230.                 "FirstName" => "Arnaud",
  231.                 "LastName" => "Kadio",
  232.                 "Company" => "Assie Group",
  233.                 "EMail" => "contact@assiemail.com",
  234.                 "AddressLine1" => "Port-Bouet SIPIM",
  235.                 "State" => "CI-Cote d'ivoire (Ivory Coast)",
  236.                 "City" => "Abidjan",
  237.                 "Country" => "CI",
  238.                 "Fax" => "",
  239.                 "FaxCountryCode" => "225",
  240.                 "Phone" => "0748946939",
  241.                 "PhoneCountryCode" => "225",
  242.                 "Type" => "Contact",
  243.                 "ZipCode" => "12 BP 245 Abidjan 12",
  244.                 "Status" => ""
  245.             ),
  246.             
  247.         ),
  248.         
  249.         // Nameservers
  250.         array("ns327485.ip-37-187-110.eu""ns.kimsufi.com"),
  251.     
  252.         // Theft protection lock enabled
  253.         true,
  254.     
  255.         // Privacy Protection enabled
  256.         true
  257.         
  258.     );
  259.     var_dump($result);
  260.         return $this->render('hosting/register_domain.html.twig', [
  261.                
  262.                
  263.             ]);
  264.           
  265.     }
  266.     
  267.     /**
  268.      * @Route("/cart", name="cart")
  269.      */
  270.     public function cartAction(Request $request)
  271.     {
  272.         
  273.         $results = array();
  274.         $domain '';
  275.         $plans = array();
  276.         $cart = (array)$this->session->get('cart');
  277.         $montantCommande $this->session->get('montantCommande');
  278.         $montantHebergement $this->session->get('montantHebergement');
  279.         $nombreProduit $this->session->get('nombreProduit');
  280.         return $this->render('hosting/cart.html.twig', [
  281.                'plans' => $plans,
  282.                'cart' => $cart,
  283.                'montantCommande' => $montantCommande,
  284.                'montantHebergement' => $montantHebergement,
  285.                'nombreProduit' => $nombreProduit
  286.             ]);
  287.           
  288.     }
  289.     
  290.     /**
  291.      * @Route("/top-menu-cart", name="top_menu_cart")
  292.      */
  293.     public function topMenucartAction(Request $request)
  294.     {
  295.         $nombreProduit $this->session->get('nombreProduit');
  296.         return $this->render('hosting/top_menu_cart.html.twig', [
  297.                'nombreProduit' => $nombreProduit
  298.             ]);
  299.           
  300.     }
  301.     /**
  302.      * @Route("/update-cart/", name="update_cart")
  303.      */
  304.     public function updateCartAction()
  305.     {
  306.         
  307.         $requestStack $this->get('request_stack');
  308.         $request $requestStack->getCurrentRequest();
  309.     
  310.         $em $this->getDoctrine()
  311.                     ->getManager();
  312.         
  313.         $cart = (array)$this->session->get('cart');
  314.         $product '';
  315.         $price '';
  316.         
  317.         if('POST' == $request->getMethod() ){
  318.             
  319.             $product $request->get('product');
  320.             $year $request->get('year');
  321.             
  322.             $leProduct = array();
  323.             $cart[$product]['year'] = $year;
  324.             
  325.             $montantDomaine 0;
  326.             foreach($cart  as $prod){
  327.                 $montantDomaine += $prod['prix'] *  $prod['year'];
  328.             }
  329.             
  330.             $couponValue = (float)$this->session->get('couponValue');
  331.             $montantHebergement = (float)$this->session->get('montantHebergement');
  332.             
  333.             $montantCommande $montantDomaine $couponValue $montantHebergement;
  334.             $this->session->set('cart'$cart);
  335.             $this->session->set('montantDomaine'$montantDomaine);
  336.             $this->session->set('montantCommande'$montantCommande);
  337.             $this->session->set('montantHebergement'$montantHebergement);
  338.         }
  339.         
  340.         return $this->redirectToRoute('cart');
  341.     }
  342.     
  343.     /**
  344.      * @Route("/cart-side-section", name="cart_side_session")
  345.      */
  346.     public function cartSideSessionAction()
  347.     {
  348.         
  349.         $requestStack $this->get('request_stack');
  350.         $request $requestStack->getCurrentRequest();
  351.     
  352.         $em $this->getDoctrine()
  353.                     ->getManager();
  354.         
  355.         $nombreProduit = (int)$this->session->get('nombreProduct');
  356.         $montantCommande = (float)$this->session->get('montantCommande');
  357.         $montantHebergement = (float)$this->session->get('montantHebergement');
  358.         $montantDomaine = (float)$this->session->get('montantDomaine');
  359.         $couponValue = (float)$this->session->get('couponValue');
  360.         $cart = (array)$this->session->get('cart');
  361.         
  362.         
  363.         return $this->render('hosting/cart_side_session.html.twig', [
  364.             'cart' => $cart,
  365.             'nombreProduit' => $nombreProduit,
  366.             'montantDomaine' => $montantDomaine,
  367.             'montantCommande' => $montantCommande,
  368.             'montantHebergement' => $montantHebergement,
  369.             'couponValue' => $couponValue
  370.         ]);
  371.     }
  372.     
  373.     /**
  374.      * @Route("/apply-coupon", name="apply_coupon")
  375.      */
  376.     public function applayCouponAction()
  377.     {
  378.         $requestStack $this->get('request_stack');
  379.         $request $requestStack->getCurrentRequest();
  380.     
  381.         $em $this->getDoctrine()
  382.                     ->getManager();
  383.         if('POST' == $request->getMethod() ){
  384.             $coupon $request->get('coupon');
  385.             
  386.             $coupon $em->getRePository(Coupon::class)
  387.                         ->findOneByCode($coupon);
  388.             if(null != $coupon){
  389.                 $toDay = new \DateTime();
  390.                     
  391.                 if($coupon->getDateDebut() <= $toDay
  392.                     && $toDay <= $coupon->getDateFin()
  393.                     //&& $coupon->getUsageLimit() > (integer)$coupon->getActualUsage()
  394.                     ){
  395.                         
  396.                         $codePromo $this->session->get('codePromo');
  397.                         
  398.                         if($codePromo != $coupon->getCode()){
  399.                             $this->session->set('codePromo'$coupon->getCode());
  400.                             $montantCommande = (float)$this->session->get('montantCommande');
  401.                             if($coupon->getIsPercentage()){
  402.                                 
  403.                                 $couponValue = ($montantCommande *  $coupon->getCouponValue())/100;
  404.                             } else{
  405.                                 $couponValue $coupon->getCouponValue();
  406.                             }
  407.                             $this->session->set('couponValue'$couponValue);
  408.                             $montantCommande $montantCommande $couponValue;
  409.                             $this->session->set('montantCommande'$montantCommande);
  410.                         } else{
  411.                             
  412.                         }
  413.                     } else{
  414.                         
  415.                     }
  416.             }
  417.         }
  418.         
  419.         return $this->redirectToRoute('cart');
  420.         //return new Response();
  421.     }
  422.     
  423.     
  424.     /**
  425.      * @Route("/delete-cart-item/{product}", name="delete_cart_item")
  426.      */
  427.     public function deleteCartItemAction($product)
  428.     {
  429.         
  430.         $requestStack $this->get('request_stack');
  431.         $request $requestStack->getCurrentRequest();
  432.     
  433.         $em $this->getDoctrine()
  434.                     ->getManager();
  435.         
  436.         $nombreProduct = (int)$this->session->get('nombreProduct');
  437.         $cart = (array)$this->session->get('cart');
  438.         
  439.         $montantProduct $this->session->get('montantProduct');
  440.         $couponValue = (float)$this->session->get('couponValue');
  441.         $montantOrder = (float)$this->session->get('montantOrder');
  442.         $montantProduct $montantProduct - ($cart[$product]['year'] * $cart[$product]['prix']);
  443.         unset($cart[$product]);
  444.             
  445.         $nombreProduct count($cart);
  446.         $montantOrder $montantProduct  $couponValue;
  447.         
  448.         $this->session->set('cart'$cart);
  449.         $this->session->set('nombreProduct'$nombreProduct);
  450.         $this->session->set('montantProduct'$montantProduct);
  451.         $this->session->set('montantOrder'$montantOrder);
  452.         
  453.         return $this->redirectToRoute('cart');
  454.           
  455.     }
  456.     
  457.     /**
  458.      * @Route("/empty-cart", name="empty_cart")
  459.      */
  460.     public function emptycartAction()
  461.     {
  462.         
  463.             $this->emptyRealCart();
  464.         
  465.         return $this->redirectToRoute('cart');
  466.     }
  467.     
  468.     public function emptyRealCart()
  469.     {
  470.         $this->session->set('cart', array());
  471.         $this->session->set('nombreProduit''');
  472.         $this->session->set('montantProduct'0);
  473.         $this->session->set('montantHebergement'0);
  474.         $this->session->set('montantDomaine'0);
  475.         $this->session->set('montantCommande'0);
  476.         $this->session->set('paymentMethod''');
  477.         $this->session->set('couponValue'0);
  478.         $this->session->set('codePromo''');
  479.     }
  480.     
  481.     /**
  482.      * @Route("/choose-hosting-plan", name="choose_hosting_plan")
  483.      */
  484.     public function chooseHostingPlanAction(Request $request)
  485.     {
  486.         
  487.         $results = array();
  488.         $domain '';
  489.         $plans = array();
  490.         return $this->render('hosting/choose_hosting_plan.html.twig', [
  491.                'plans' => $plans
  492.             ]);
  493.           
  494.     }
  495.     
  496. }
  497. // BASE CONNECTION (ABSTRACT)
  498. abstract class APIConnection
  499. {
  500.     abstract public function CheckAvailability($parameters);
  501.     abstract public function ModifyNameServer($parameters);
  502.     
  503.     abstract public function GetList($parameters);
  504.     abstract public function GetDetails($parameters);
  505.     
  506.     abstract public function EnableTheftProtectionLock($parameters);
  507.     abstract public function DisableTheftProtectionLock($parameters);
  508.     
  509.     abstract public function ModifyPrivacyProtectionStatus($parameters);
  510.     
  511.     abstract public function AddChildNameServer($parameters);
  512.     abstract public function DeleteChildNameServer($parameters);
  513.     abstract public function ModifyChildNameServer($parameters);
  514.     
  515.     abstract public function GetContacts($parameters);
  516.     abstract public function SaveContacts($parameters);
  517.     abstract public function Transfer($parameters);
  518.     abstract public function CancelTransfer($parameters);
  519.     abstract public function RegisterWithContactInfo($parameters);
  520.     abstract public function Renew($parameters);
  521.     abstract public function Delete($parameters);
  522.     
  523.     abstract public function SyncFromRegistry($parameters);
  524.     abstract public function CheckTransfer($parameters);
  525. }
  526. // SOAP CONNECTION
  527. class APIConnection_SOAP extends APIConnection
  528. {
  529.     // VARIABLES
  530.     private $service null;
  531.     private $URL_SERVICE "";
  532.     // CONSTRUCTORS
  533.     function __construct($Service_URL
  534.     {
  535.         // Set settings
  536.         $this->URL_SERVICE $Service_URL;
  537.         // Set WSDL caching enabled     
  538.         ini_set('soap.wsdl_cache_enabled''1'); ini_set('soap.wsdl_cache_ttl''86400'); 
  539.         // Create unique connection
  540.         $this->service = new \SoapClient($this->URL_SERVICE "?singlewsdl", array("cache_wsdl" => WSDL_CACHE_MEMORY,  "encoding"=>"UTF-8")); 
  541.     }
  542.     function APIConnection_SOAP($Service_URL
  543.     {
  544.         // Set settings
  545.         $this->URL_SERVICE $Service_URL//05 85 152 077
  546.         
  547.         // Set WSDL caching enabled
  548.         ini_set('soap.wsdl_cache_enabled''1');  ini_set('soap.wsdl_cache_ttl''86400'); 
  549.         // Create unique connection
  550.         $this->service = new \SoapClient($this->URL_SERVICE "?singlewsdl", array("cache_wsdl" => WSDL_CACHE_MEMORY,  "encoding"=>"UTF-8")); 
  551.     }
  552.     
  553.     // Convert object to array
  554.     private function objectToArray($o
  555.     {
  556.         try { $o json_decode(json_encode($o), true); } catch(Exception $ex) { }
  557.         return $o;
  558.     }
  559.     
  560.     // Get error if exists
  561.     private function parseError($response)
  562.     {
  563.         $result false;
  564.         if(is_null($response))
  565.         {
  566.             // Set error data
  567.             $result = array();
  568.             $result["Code"] = "INVALID_RESPONSE";
  569.             $result["Message"] = "Invalid response or no response received from server!";
  570.             $result["Details"] = "SOAP Connection returned null value!";
  571.         }
  572.         elseif(!is_array($response))
  573.         {
  574.             // Set error data
  575.             $result = array();
  576.             $result["Code"] = "INVALID_RESPONSE";
  577.             $result["Message"] = "Invalid response or no response received from server!";
  578.             $result["Details"] = "SOAP Connection returned non-array value!";
  579.         }
  580.         elseif(strtolower(key($response)) == "faultstring")
  581.         {
  582.             // Handle soap fault
  583.             
  584.             $result = array();
  585.             $result["Code"] = "";
  586.             $result["Message"] = "";
  587.             $result["Details"] = "";
  588.             
  589.             // Set error data
  590.             if(isset($response["faultcode"])) { $result["Code"] = $response["faultcode"]; }
  591.             if(isset($response["faultstring"])) { $result["Message"] = $response["faultstring"]; }
  592.             if(isset($response["detail"])) {
  593.                 if(is_array($response["detail"])) {
  594.                     if(isset($response["detail"]["ExceptionDetail"])) {
  595.                         if(is_array($response["detail"]["ExceptionDetail"])) {
  596.                             if(isset($response["detail"]["ExceptionDetail"]["StackTrace"]))
  597.                             { $result["Details"] = $response["detail"]["ExceptionDetail"]["StackTrace"]; }
  598.                         }
  599.                     }
  600.                 
  601.                 }
  602.             }
  603.             
  604.         }
  605.         elseif(count($response) != 1)
  606.         {
  607.             // Set error data
  608.             $result = array();
  609.             $result["Code"] = "INVALID_RESPONSE";
  610.             $result["Message"] = "Invalid response or no response received from server!";
  611.             $result["Details"] = "Response data contains more than one result! Only one result accepted!";
  612.         }
  613.         elseif(!isset($response[key($response)]["OperationResult"]) || !isset($response[key($response)]["ErrorCode"]))
  614.         {
  615.             // Set error data
  616.             $result = array();
  617.             $result["Code"] = "INVALID_RESPONSE";
  618.             $result["Message"] = "Invalid response or no response received from server!";
  619.             $result["Details"] = "Operation result or Error code not received from server!";
  620.         }
  621.         elseif(strtoupper($response[key($response)]["OperationResult"]) != "SUCCESS")
  622.         {
  623.             // Set error data
  624.             $result = array();
  625.             $result["Code"] = "";
  626.             $result["Message"] = "";
  627.             $result["Details"] = "";
  628.             
  629.             $result["Message"] = "Operation can not completed successfully!";
  630.             if(isset($response[key($response)]["OperationMessage"]))
  631.             { $result["Code"] = "API_" $response[key($response)]["ErrorCode"]; }
  632.             if(isset($response[key($response)]["OperationResult"]))
  633.             { $result["Code"] .= "_" $response[key($response)]["OperationResult"]; }
  634.             if(isset($response[key($response)]["OperationMessage"]))
  635.             { $result["Details"] = $response[key($response)]["OperationMessage"]; }
  636.             
  637.         }
  638.         else
  639.         {
  640.             
  641.         }
  642.         return $result;
  643.     }
  644.     
  645.     // Check if response contains error
  646.     private function hasError($response)
  647.     { return ($this->parseError($response) === false) ? false true; }
  648.     
  649.     // Set error message
  650.     private function setError($Code$Message$Details)
  651.     {
  652.         $result = array();
  653.         $result["Code"] = $Code;
  654.         $result["Message"] = $Message;
  655.         $result["Details"] = $Details;
  656.         return $result;
  657.     }
  658.     
  659.     // Parse domain info
  660.     private function parseDomainInfo($data)
  661.     {
  662.         $result = array();
  663.         $result["ID"] = "";
  664.         $result["Status"] = "";
  665.         $result["DomainName"] = "";
  666.         $result["AuthCode"] = "";
  667.         $result["LockStatus"] = "";
  668.         $result["PrivacyProtectionStatus"] = "";
  669.         $result["IsChildNameServer"] = "";
  670.         $result["Contacts"] = array();
  671.         $result["Contacts"]["Billing"] = array();
  672.         $result["Contacts"]["Technical"] = array();
  673.         $result["Contacts"]["Administrative"] = array();
  674.         $result["Contacts"]["Registrant"] = array();
  675.         $result["Contacts"]["Billing"]["ID"] = "";
  676.         $result["Contacts"]["Technical"]["ID"] = "";
  677.         $result["Contacts"]["Administrative"]["ID"] = "";
  678.         $result["Contacts"]["Registrant"]["ID"] = "";
  679.         $result["Dates"] = array();
  680.         $result["Dates"]["Start"] = "";
  681.         $result["Dates"]["Expiration"] = "";
  682.         $result["Dates"]["RemainingDays"] = "";
  683.         $result["NameServers"] = array();
  684.         $result["Additional"] = array();
  685.         $result["ChildNameServers"] = array();
  686.         
  687.         foreach($data as $attrName => $attrValue)
  688.         {
  689.             switch($attrName)
  690.             {
  691.                 case "Id":
  692.                 {
  693.                     if(is_numeric($attrValue)) { $result["ID"] = $attrValue; }
  694.                     break;
  695.                 }
  696.                 
  697.                 case "Status":
  698.                 { $result["Status"] = $attrValue; break; }
  699.                     
  700.                 case "DomainName":
  701.                 { $result["DomainName"] = $attrValue; break; }
  702.                 
  703.                 case "AdministrativeContactId":
  704.                 { 
  705.                     if(is_numeric($attrValue)) { $result["Contacts"]["Administrative"]["ID"] = $attrValue;  }
  706.                     break; 
  707.                 }
  708.                 
  709.                 case "BillingContactId":
  710.                 { 
  711.                     if(is_numeric($attrValue)) { $result["Contacts"]["Billing"]["ID"] = $attrValue;  }
  712.                     break; 
  713.                 }
  714.                 
  715.                 case "TechnicalContactId":
  716.                 { 
  717.                     if(is_numeric($attrValue)) { $result["Contacts"]["Technical"]["ID"] = $attrValue;  }
  718.                     break; 
  719.                 }
  720.                 
  721.                 case "RegistrantContactId":
  722.                 { 
  723.                     if(is_numeric($attrValue)) { $result["Contacts"]["Registrant"]["ID"] = $attrValue;  }
  724.                     break; 
  725.                 }
  726.                 
  727.                 case "Auth":
  728.                 {
  729.                     if(is_string($attrValue) && !is_null($attrValue))
  730.                     { $result["AuthCode"] = $attrValue; }
  731.                     break;
  732.                 }
  733.                 
  734.                 case "StartDate":
  735.                 { $result["Dates"]["Start"] = $attrValue; break; }
  736.                 
  737.                 case "ExpirationDate":
  738.                 { $result["Dates"]["Expiration"] = $attrValue; break; }
  739.                 
  740.                 case "LockStatus":
  741.                 { 
  742.                     if(is_bool($attrValue))
  743.                     { $result["LockStatus"] = var_export($attrValuetrue); }
  744.                     break; 
  745.                 }
  746.                 
  747.                 case "PrivacyProtectionStatus":
  748.                 { 
  749.                     if(is_bool($attrValue))
  750.                     { $result["PrivacyProtectionStatus"] = var_export($attrValuetrue); }
  751.                     break; 
  752.                 }
  753.                 
  754.                 case "IsChildNameServer":
  755.                 { 
  756.                     if(is_bool($attrValue))
  757.                     { $result["IsChildNameServer"] = var_export($attrValuetrue); }
  758.                     break; 
  759.                 }
  760.                 
  761.                 case "RemainingDay":
  762.                 { 
  763.                     if(is_numeric($attrValue))
  764.                     { $result["Dates"]["RemainingDays"] = $attrValue; }
  765.                     break; 
  766.                 }
  767.                 
  768.                 case "NameServerList":
  769.                 { 
  770.                     if(is_array($attrValue))
  771.                     {
  772.                         foreach($attrValue as $nameserverValue)
  773.                         {
  774.                             array_push($result["NameServers"], $nameserverValue);
  775.                         }
  776.                     }
  777.                     break; 
  778.                 }
  779.                 
  780.                 case "AdditionalAttributes":
  781.                 { 
  782.                     if(is_array($attrValue))
  783.                     {
  784.                         if(isset($attrValue["KeyValueOfstringstring"]))
  785.                         {
  786.                             foreach($attrValue["KeyValueOfstringstring"] as $attribute)
  787.                             {
  788.                                 if(isset($attribute["Key"]) && isset($attribute["Value"]))
  789.                                 {
  790.                                     $result["Additional"][$attribute["Key"]] = $attribute["Value"];
  791.                                 }
  792.                             }
  793.                         }
  794.                     }
  795.                     break; 
  796.                 }
  797.                 
  798.                 case "ChildNameServerInfo":
  799.                 {
  800.                     if(is_array($attrValue))
  801.                     {
  802.                     
  803.                         if(isset($attrValue["ChildNameServerInfo"]["IpAddress"]))
  804.                         {
  805.                             $attribute $attrValue["ChildNameServerInfo"];
  806.                         
  807.                             $ns "";
  808.                             $IpAddresses = array();
  809.                             // Name of NameServer
  810.                             if(!is_null($attribute["NameServer"]) && is_string($attribute["NameServer"]))
  811.                             { $ns $attribute["NameServer"]; }
  812.                              
  813.                             // IP adresses of NameServer
  814.                             if(is_array($attribute["IpAddress"]) && isset($attribute["IpAddress"]["string"]))
  815.                             {
  816.                                     
  817.                                 if(is_array($attribute["IpAddress"]["string"]))
  818.                                 {
  819.                                     
  820.                                     foreach($attribute["IpAddress"]["string"] as $ip)
  821.                                     {
  822.                                         if(isset($ip) && !is_null($ip) && is_string($ip))
  823.                                         {
  824.                                             array_push($IpAddresses$ip);
  825.                                         }
  826.                                     }
  827.                                 
  828.                                 }
  829.                                 elseif(is_string($attribute["IpAddress"]["string"]))
  830.                                 {
  831.                                     array_push($IpAddresses$attribute["IpAddress"]["string"]);
  832.                                 }
  833.                                 
  834.                             }
  835.                             
  836.                             array_push($result["ChildNameServers"], 
  837.                                 array(
  838.                                     "NameServer" => $ns,
  839.                                     "IPAddresses" => $IpAddresses
  840.                                 )
  841.                             );
  842.                             
  843.                         }
  844.                         else
  845.                         {
  846.                             if(count($attrValue["ChildNameServerInfo"])>0)
  847.                             {
  848.                                 foreach($attrValue["ChildNameServerInfo"] as $attribute)
  849.                                 {
  850.         
  851.                                     if(isset($attribute["NameServer"]) && isset($attribute["IpAddress"]))
  852.                                     {
  853.                                         $ns "";
  854.                                         $IpAddresses = array();
  855.         
  856.                                         // Name of NameServer
  857.                                         if(!is_null($attribute["NameServer"]) && is_string($attribute["NameServer"]))
  858.                                         { $ns $attribute["NameServer"]; }
  859.                                          
  860.                                         // IP adresses of NameServer
  861.                                         if(is_array($attribute["IpAddress"]) && isset($attribute["IpAddress"]["string"]))
  862.                                         {
  863.                                                 
  864.                                             if(is_array($attribute["IpAddress"]["string"]))
  865.                                             {
  866.                                                 
  867.                                                 foreach($attribute["IpAddress"]["string"] as $ip)
  868.                                                 {
  869.                                                     if(isset($ip) && !is_null($ip) && is_string($ip))
  870.                                                     {
  871.                                                         array_push($IpAddresses$ip);
  872.                                                     }
  873.                                                 }
  874.                                             
  875.                                             }
  876.                                             elseif(is_string($attribute["IpAddress"]["string"]))
  877.                                             {
  878.                                                 array_push($IpAddresses$attribute["IpAddress"]["string"]);
  879.                                             }
  880.                                             
  881.                                         }
  882.                                         
  883.                                         array_push($result["ChildNameServers"], 
  884.                                             array(
  885.                                                 "NameServer" => $ns,
  886.                                                 "IPAddresses" => $IpAddresses
  887.                                             )
  888.                                         );
  889.                                         
  890.                                         
  891.                                         
  892.                                     }
  893.                                     
  894.                                 }    
  895.                                 
  896.                             }                    
  897.                         }
  898.                         
  899.                     }
  900.                     break;
  901.                 }
  902.             }
  903.         }
  904.         return $result;
  905.     }
  906.     
  907.     
  908.     
  909.     // Parse Contact info
  910.     private function parseContactInfo($data)
  911.     {
  912.         $result = array();
  913.         $result["ID"] = "";
  914.         $result["Status"] = "";
  915.         $result["Additional"] = array();
  916.         $result["Address"] = array();
  917.         $result["Address"]["Line1"] = "";
  918.         $result["Address"]["Line2"] = "";
  919.         $result["Address"]["Line3"] = "";
  920.         $result["Address"]["State"] = "";
  921.         $result["Address"]["City"] = "";
  922.         $result["Address"]["Country"] = "";
  923.         $result["Address"]["ZipCode"] = "";
  924.         $result["Phone"] = array();
  925.         $result["Phone"]["Phone"] = array();
  926.         $result["Phone"]["Phone"]["Number"] = "";
  927.         $result["Phone"]["Phone"]["CountryCode"] = "";
  928.         $result["Phone"]["Fax"]["Number"] = "";
  929.         $result["Phone"]["Fax"]["CountryCode"] = "";
  930.         $result["AuthCode"] = "";
  931.         $result["FirstName"] = "";
  932.         $result["LastName"] = "";
  933.         $result["Company"] = "";
  934.         $result["EMail"] = "";
  935.         $result["Type"] = "";
  936.         
  937.         foreach($data as $attrName => $attrValue)
  938.         {
  939.             switch($attrName)
  940.             {
  941.                 case "Id":
  942.                 {
  943.                     if(is_numeric($attrValue)) { $result["ID"] = $attrValue; }
  944.                     break;
  945.                 }
  946.                 
  947.                 case "Status":
  948.                 { $result["Status"] = $attrValue; break; }
  949.                 case "AdditionalAttributes":
  950.                 { 
  951.                     if(is_array($attrValue))
  952.                     {
  953.                         if(isset($attrValue["KeyValueOfstringstring"]))
  954.                         {
  955.                             foreach($attrValue["KeyValueOfstringstring"] as $attribute)
  956.                             {
  957.                                 if(isset($attribute["Key"]) && isset($attribute["Value"]))
  958.                                 {
  959.                                     $result["Additional"][$attribute["Key"]] = $attribute["Value"];
  960.                                 }
  961.                             }
  962.                         }
  963.                     }
  964.                     break; 
  965.                 }
  966.                 case "AddressLine1":
  967.                 { 
  968.                     if(is_string($attrValue) && !is_null($attrValue)) { $result["Address"]["Line1"] = $attrValue;  }
  969.                     break; 
  970.                 }
  971.                 
  972.                 case "AddressLine2":
  973.                 { 
  974.                     if(is_string($attrValue) && !is_null($attrValue)) { $result["Address"]["Line2"] = $attrValue;  }
  975.                     break; 
  976.                 }
  977.                 
  978.                 case "AddressLine3":
  979.                 { 
  980.                     if(is_string($attrValue) && !is_null($attrValue)) { $result["Address"]["Line3"] = $attrValue;  }
  981.                     break; 
  982.                 }
  983.                 
  984.                 case "Auth":
  985.                 {
  986.                     if(is_string($attrValue) && !is_null($attrValue))
  987.                     { $result["AuthCode"] = $attrValue; }
  988.                     break;
  989.                 }
  990.                 
  991.                 case "City":
  992.                 { 
  993.                     if(is_string($attrValue) && !is_null($attrValue)) { $result["Address"]["City"] = $attrValue;  }
  994.                     break; 
  995.                 }
  996.                 
  997.                 case "Company":
  998.                 { 
  999.                     if(is_string($attrValue) && !is_null($attrValue)) { $result["Company"] = $attrValue;  }
  1000.                     break; 
  1001.                 }
  1002.                 
  1003.                 case "Country":
  1004.                 { 
  1005.                     if(is_string($attrValue) && !is_null($attrValue)) { $result["Address"]["Country"] = $attrValue;  }
  1006.                     break; 
  1007.                 }
  1008.                 
  1009.                 case "EMail":
  1010.                 { 
  1011.                     if(is_string($attrValue) && !is_null($attrValue)) { $result["EMail"] = $attrValue;  }
  1012.                     break; 
  1013.                 }
  1014.                 
  1015.                 case "Fax":
  1016.                 { 
  1017.                     if(is_string($attrValue) && !is_null($attrValue)) { $result["Phone"]["Fax"]["Number"] = $attrValue;  }
  1018.                     break; 
  1019.                 }
  1020.                 
  1021.                 case "FaxCountryCode":
  1022.                 { 
  1023.                     if(is_string($attrValue) && !is_null($attrValue)) { $result["Phone"]["Fax"]["CountryCode"] = $attrValue;  }
  1024.                     break; 
  1025.                 }
  1026.                 
  1027.                 case "Phone":
  1028.                 { 
  1029.                     if(is_string($attrValue) && !is_null($attrValue)) { $result["Phone"]["Phone"]["Number"] = $attrValue;  }
  1030.                     break; 
  1031.                 }
  1032.                 
  1033.                 case "PhoneCountryCode":
  1034.                 { 
  1035.                     if(is_string($attrValue) && !is_null($attrValue)) { $result["Phone"]["Phone"]["CountryCode"] = $attrValue;  }
  1036.                     break; 
  1037.                 }
  1038.                 
  1039.                 case "FirstName":
  1040.                 { 
  1041.                     if(is_string($attrValue) && !is_null($attrValue)) { $result["FirstName"] = $attrValue;  }
  1042.                     break; 
  1043.                 }
  1044.                 
  1045.                 case "LastName":
  1046.                 { 
  1047.                     if(is_string($attrValue) && !is_null($attrValue)) { $result["LastName"] = $attrValue;  }
  1048.                     break; 
  1049.                 }
  1050.                 
  1051.                 case "State":
  1052.                 { 
  1053.                     if(is_string($attrValue) && !is_null($attrValue)) { $result["Address"]["State"] = $attrValue;  }
  1054.                     break; 
  1055.                 }
  1056.                 
  1057.                 case "ZipCode":
  1058.                 { 
  1059.                     if(is_string($attrValue) && !is_null($attrValue)) { $result["Address"]["ZipCode"] = $attrValue;  }
  1060.                     break; 
  1061.                 }
  1062.                 
  1063.                 case "Type":
  1064.                 { 
  1065.                     if(is_string($attrValue) && !is_null($attrValue)) { $result["Type"] = $attrValue;  }
  1066.                     break; 
  1067.                 }
  1068.                 
  1069.             }
  1070.         }
  1071.         return $result;
  1072.     }
  1073.     
  1074.     // API METHODs
  1075.     
  1076.     // Check domain is available?
  1077.     public function CheckAvailability($parameters)
  1078.     {
  1079.         $result = array();
  1080.         $TldSayisi=count($parameters["request"]["TldList"]);
  1081.         
  1082.         try
  1083.         {
  1084.             // SOAP method which is same as current function name called
  1085.             $response $this->service->__soapCall(__FUNCTION__, array($parameters));
  1086.         
  1087.             // Serialize as array
  1088.             $response $this->objectToArray($response);
  1089.             
  1090.             // Check is there any error?
  1091.                 if(!$this->hasError($response))
  1092.                     { 
  1093.                         if($TldSayisi>1){
  1094.                                 $data $response[key($response)];
  1095.                                 
  1096.                                 if(isset($data["DomainAvailabilityInfoList"]["DomainAvailabilityInfo"])) {
  1097.                                     if(is_array($data["DomainAvailabilityInfoList"]["DomainAvailabilityInfo"])) {
  1098.                                         $result["data"] = array();
  1099.                                         
  1100.                                         foreach($data["DomainAvailabilityInfoList"]["DomainAvailabilityInfo"] as $name => $value) {
  1101.                                             array_push($result["data"], 
  1102.                                                 array(  "DomainName" => $value["DomainName"],//Domain adı
  1103.                                                         "TLD" => $value["Tld"], // Uzantı
  1104.                                                         "Status" => $value["Status"], // Domain alınabilirlik durumu available notavailable
  1105.                                                         "IsFee" => $value["IsFee"], // Domain Premium mu True /False
  1106.                                                         "Currency" => $value["Currency"],// Doviz kuru
  1107.                                                         "Command" => $value["Command"], // Komut create,renew,transfer,restore fiyatlarının çekilmesi
  1108.                                                         "Period" => $value["Period"], // Domain Periyodu
  1109.                                                         "Price" => $value["Price"], // Domain Fiyatı
  1110.                                                         "ClassKey" => $value["ClassKey"], //Premium domainin açıklaması
  1111.                                                         "Reason" => $value["Reason"//Domain ile ilgili özel durumlar rezerve dilmiş  veya alınamıyor gibi
  1112.                                                 )
  1113.                                             );
  1114.                                         }
  1115.                                         $result["result"] = "OK";
  1116.                                     }
  1117.                                     else
  1118.                                     {
  1119.                                         $result["result"] = "ERROR";
  1120.                                         $result["error"] = $this->setError("INVALID_DOMAIN_LIST""Invalid response received from server!""Domain list is not valid!");;
  1121.                                     }
  1122.                                 }
  1123.                                 else
  1124.                                 {
  1125.                                     $result["result"] = "ERROR";
  1126.                                     $result["error"] = $this->setError("INVALID_DOMAIN_LIST""Invalid response received from server!""Domain list is not valid!");;
  1127.                                 } 
  1128.                             }else{
  1129.                                $data $response[key($response)];
  1130.                                 
  1131.                                 if(isset($data["DomainAvailabilityInfoList"]["DomainAvailabilityInfo"])) {
  1132.                                     if(is_array($data["DomainAvailabilityInfoList"]["DomainAvailabilityInfo"])) {
  1133.                                         $result["data"] = array(); 
  1134.                                             array_push($result["data"], 
  1135.                                                 array(  "DomainName" => $data["DomainAvailabilityInfoList"]["DomainAvailabilityInfo"]["DomainName"],//Domain adı
  1136.                                                         "TLD" => $data["DomainAvailabilityInfoList"]["DomainAvailabilityInfo"]["Tld"], // Uzantı
  1137.                                                         "Status" => $data["DomainAvailabilityInfoList"]["DomainAvailabilityInfo"]["Status"], // Domain alınabilirlik durumu available notavailable
  1138.                                                         "IsFee" => $data["DomainAvailabilityInfoList"]["DomainAvailabilityInfo"]["IsFee"], // Domain Premium mu True /False
  1139.                                                         "Currency" => $data["DomainAvailabilityInfoList"]["DomainAvailabilityInfo"]["Currency"],// Doviz kuru
  1140.                                                         "Command" => $data["DomainAvailabilityInfoList"]["DomainAvailabilityInfo"]["Command"], // Komut create,renew,transfer,restore fiyatlarının çekilmesi
  1141.                                                         "Period" => $data["DomainAvailabilityInfoList"]["DomainAvailabilityInfo"]["Period"], // Domain Periyodu
  1142.                                                         "Price" => $data["DomainAvailabilityInfoList"]["DomainAvailabilityInfo"]["Price"], // Domain Fiyatı
  1143.                                                         "ClassKey" => $data["DomainAvailabilityInfoList"]["DomainAvailabilityInfo"]["ClassKey"], //Premium domainin açıklaması
  1144.                                                         "Reason" => $data["DomainAvailabilityInfoList"]["DomainAvailabilityInfo"]["Reason"//Domain ile ilgili özel durumlar rezerve dilmiş  veya alınamıyor gibi
  1145.                                                 )
  1146.                                             );
  1147.                                         
  1148.                                         $result["result"] = "OK";
  1149.                                     }
  1150.                                     else
  1151.                                     {
  1152.                                         $result["result"] = "ERROR";
  1153.                                         $result["error"] = $this->setError("INVALID_DOMAIN_LIST""Invalid response received from server!""Domain list is not valid!");;
  1154.                                     }
  1155.                                 }
  1156.                                 else
  1157.                                 {
  1158.                                     $result["result"] = "ERROR";
  1159.                                     $result["error"] = $this->setError("INVALID_DOMAIN_LIST""Invalid response received from server!""Domain list is not valid!");;
  1160.                                 }
  1161.                             }
  1162.                     }
  1163.             else
  1164.             {
  1165.                 // Hata mesajini dondur
  1166.                 $result["result"] = "ERROR";
  1167.                 $result["error"] = $this->parseError($response);
  1168.             }
  1169.             
  1170.         }
  1171.         catch(Exception $ex)
  1172.         {
  1173.             $result["result"] = "ERROR";
  1174.             $result["error"] = $this->parseError($this->objectToArray($ex));
  1175.         }
  1176.         
  1177.         return $result;
  1178.     }
  1179.     
  1180.     // Get domain list
  1181.     public function GetList($parameters)
  1182.     {
  1183.         $result = array();
  1184.         
  1185.         try
  1186.         {
  1187.             // SOAP method which is same as current function name called
  1188.             $response $this->service->__soapCall(__FUNCTION__, array($parameters));
  1189.             // Serialize as array
  1190.             $response $this->objectToArray($response);
  1191.             
  1192.             // Check is there any error?
  1193.             if(!$this->hasError($response))
  1194.             {
  1195.                 $data $response[key($response)];
  1196.                 // If DomainInfo a valid array
  1197.                 if(isset($data["TotalCount"]) && is_numeric($data["TotalCount"]))
  1198.                 {
  1199.                     $result["data"]["Domains"] = array();
  1200.                     
  1201.                     if(isset($data["DomainInfoList"]) && is_array($data["DomainInfoList"]))
  1202.                     {
  1203.                         if(isset($data["DomainInfoList"]["DomainInfo"]["Id"]))
  1204.                         {
  1205.                             array_push($result["data"]["Domains"], $data["DomainInfoList"]["DomainInfo"]);
  1206.                         }
  1207.                         else
  1208.                         {
  1209.                             // Parse multiple domain info
  1210.                             foreach($data["DomainInfoList"]["DomainInfo"] as $domainInfo)
  1211.                             {
  1212.                                 array_push($result["data"]["Domains"], $this->parseDomainInfo($domainInfo));
  1213.                             }                    
  1214.                         }
  1215.                     
  1216.                     }
  1217.                     
  1218.                     $result["result"] = "OK";
  1219.                     
  1220.                 }
  1221.                 else
  1222.                 {
  1223.                     // Set error
  1224.                     $result["result"] = "ERROR";
  1225.                     $result["error"] = $this->setError("INVALID_DOMAIN_LIST""Invalid response received from server!""Domain info is not a valid array or more than one domain info has returned!");;                        
  1226.                 }
  1227.             }
  1228.             else
  1229.             {
  1230.                 // Hata mesajini dondur
  1231.                 $result["result"] = "ERROR";
  1232.                 $result["error"] = $this->parseError($response);
  1233.             }
  1234.             
  1235.         }
  1236.         catch(Exception $ex)
  1237.         {
  1238.             $result["result"] = "ERROR";
  1239.             $result["error"] = $this->parseError($this->objectToArray($ex));
  1240.         }
  1241.         
  1242.         return $result;
  1243.     }
  1244.     
  1245.     
  1246.     // Get domain details
  1247.     public function GetDetails($parameters)
  1248.     {
  1249.         $result = array();
  1250.         
  1251.         try
  1252.         {
  1253.             // SOAP method which is same as current function name called
  1254.             $response $this->service->__soapCall(__FUNCTION__, array($parameters));
  1255.             // Serialize as array
  1256.             $response $this->objectToArray($response);
  1257.             
  1258.             // Check is there any error?
  1259.             if(!$this->hasError($response))
  1260.             {
  1261.                 $data $response[key($response)];
  1262.                 // If DomainInfo a valid array
  1263.                 if(isset($data["DomainInfo"]) && is_array($data["DomainInfo"]))
  1264.                 {
  1265.                     // Parse domain info
  1266.                     $result["data"] = $this->parseDomainInfo($data["DomainInfo"]);
  1267.                     $result["result"] = "OK";
  1268.                     
  1269.                 }
  1270.                 else
  1271.                 {
  1272.                     // Set error
  1273.                     $result["result"] = "ERROR";
  1274.                     $result["error"] = $this->setError("INVALID_DOMAIN_LIST""Invalid response received from server!""Domain info is not a valid array or more than one domain info has returned!");;                        
  1275.                 }
  1276.             }
  1277.             else
  1278.             {
  1279.                 // Hata mesajini dondur
  1280.                 $result["result"] = "ERROR";
  1281.                 $result["error"] = $this->parseError($response);
  1282.             }
  1283.             
  1284.         }
  1285.         catch(Exception $ex)
  1286.         {
  1287.             $result["result"] = "ERROR";
  1288.             $result["error"] = $this->parseError($this->objectToArray($ex));
  1289.         }
  1290.         
  1291.         return $result;
  1292.     }
  1293.     
  1294.     
  1295.     
  1296.     
  1297.     
  1298.     // Modify name servers
  1299.     public function ModifyNameServer($parameters)
  1300.     {
  1301.         $result = array();
  1302.         
  1303.         try
  1304.         {
  1305.             // SOAP method which is same as current function name called
  1306.             $response $this->service->__soapCall(__FUNCTION__, array($parameters));
  1307.             // Serialize as array
  1308.             $response $this->objectToArray($response);
  1309.             
  1310.             // Check is there any error?
  1311.             if(!$this->hasError($response))
  1312.             {
  1313.                 $result["data"] = array();
  1314.                 $result["data"]["NameServers"] = array();
  1315.                 $result["data"]["NameServers"] = $parameters["request"]["NameServerList"];
  1316.                 $result["result"] = "OK";
  1317.             }
  1318.             else
  1319.             {
  1320.                 // Hata mesajini dondur
  1321.                 $result["result"] = "ERROR";
  1322.                 $result["error"] = $this->parseError($response);
  1323.             }
  1324.             
  1325.         }
  1326.         catch(Exception $ex)
  1327.         {
  1328.             $result["result"] = "ERROR";
  1329.             $result["error"] = $this->parseError($this->objectToArray($ex));
  1330.         }
  1331.         
  1332.         return $result;
  1333.     }   
  1334.     
  1335.    
  1336.     // Enable Theft Protection Lock
  1337.     public function EnableTheftProtectionLock($parameters)
  1338.     {
  1339.         $result = array();
  1340.         
  1341.         try
  1342.         {
  1343.             // SOAP method which is same as current function name called
  1344.             $response $this->service->__soapCall(__FUNCTION__, array($parameters));
  1345.             // Serialize as array
  1346.             $response $this->objectToArray($response);
  1347.             
  1348.             // Check is there any error?
  1349.             if(!$this->hasError($response))
  1350.             {
  1351.                 $result["data"] = array();
  1352.                 $result["data"]["LockStatus"] = var_export(truetrue);
  1353.                 $result["result"] = "OK";
  1354.             }
  1355.             else
  1356.             {
  1357.                 // Hata mesajini dondur
  1358.                 $result["result"] = "ERROR";
  1359.                 $result["error"] = $this->parseError($response);
  1360.             }
  1361.             
  1362.         }
  1363.         catch(Exception $ex)
  1364.         {
  1365.             $result["result"] = "ERROR";
  1366.             $result["error"] = $this->parseError($this->objectToArray($ex));
  1367.         }
  1368.         
  1369.         return $result;
  1370.     }   
  1371.     
  1372.     // Disable Theft Protection Lock
  1373.     public function DisableTheftProtectionLock($parameters)
  1374.     {
  1375.         $result = array();
  1376.         
  1377.         try
  1378.         {
  1379.             // SOAP method which is same as current function name called
  1380.             $response $this->service->__soapCall(__FUNCTION__, array($parameters));
  1381.             // Serialize as array
  1382.             $response $this->objectToArray($response);
  1383.             
  1384.             // Check is there any error?
  1385.             if(!$this->hasError($response))
  1386.             {
  1387.                 $result["data"] = array();
  1388.                 $result["data"]["LockStatus"] = var_export(falsetrue);
  1389.                 $result["result"] = "OK";
  1390.             }
  1391.             else
  1392.             {
  1393.                 // Hata mesajini dondur
  1394.                 $result["result"] = "ERROR";
  1395.                 $result["error"] = $this->parseError($response);
  1396.             }
  1397.             
  1398.         }
  1399.         catch(Exception $ex)
  1400.         {
  1401.             $result["result"] = "ERROR";
  1402.             $result["error"] = $this->parseError($this->objectToArray($ex));
  1403.         }
  1404.         
  1405.         return $result;
  1406.     }   
  1407.     
  1408.     
  1409.     // Modify privacy protection status
  1410.     public function ModifyPrivacyProtectionStatus($parameters)
  1411.     {
  1412.         $result = array();
  1413.         
  1414.         try
  1415.         {
  1416.             // SOAP method which is same as current function name called
  1417.             $response $this->service->__soapCall(__FUNCTION__, array($parameters));
  1418.             // Serialize as array
  1419.             $response $this->objectToArray($response);
  1420.             
  1421.             // Check is there any error?
  1422.             if(!$this->hasError($response))
  1423.             {
  1424.                 $result["data"] = array();
  1425.                 $result["data"]["PrivacyProtectionStatus"] = var_export($parameters["request"]["ProtectPrivacy"], true);
  1426.                 $result["result"] = "OK";
  1427.             }
  1428.             else
  1429.             {
  1430.                 // Hata mesajini dondur
  1431.                 $result["result"] = "ERROR";
  1432.                 $result["error"] = $this->parseError($response);
  1433.             }
  1434.             
  1435.         }
  1436.         catch(Exception $ex)
  1437.         {
  1438.             $result["result"] = "ERROR";
  1439.             $result["error"] = $this->parseError($this->objectToArray($ex));
  1440.         }
  1441.         
  1442.         return $result;
  1443.     }   
  1444.     
  1445.     // CHILD NAMESERVER MANAGEMENT
  1446.     
  1447.     // Add Child Nameserver
  1448.     public function AddChildNameServer($parameters)
  1449.     {
  1450.         $result = array();
  1451.         
  1452.         try
  1453.         {
  1454.             // SOAP method which is same as current function name called
  1455.             $response $this->service->__soapCall(__FUNCTION__, array($parameters));
  1456.             // Serialize as array
  1457.             $response $this->objectToArray($response);
  1458.             
  1459.             // Check is there any error?
  1460.             if(!$this->hasError($response))
  1461.             {
  1462.                 $result["data"] = array();
  1463.                 $result["data"]["NameServer"] = $parameters["request"]["ChildNameServer"];
  1464.                 $result["data"]["IPAdresses"] = array();
  1465.                 $result["data"]["IPAdresses"] = $parameters["request"]["IpAddressList"];
  1466.                 $result["result"] = "OK";
  1467.             }
  1468.             else
  1469.             {
  1470.                 // Hata mesajini dondur
  1471.                 $result["result"] = "ERROR";
  1472.                 $result["error"] = $this->parseError($response);
  1473.             }
  1474.             
  1475.         }
  1476.         catch(Exception $ex)
  1477.         {
  1478.             $result["result"] = "ERROR";
  1479.             $result["error"] = $this->parseError($this->objectToArray($ex));
  1480.         }
  1481.         
  1482.         return $result;
  1483.     }   
  1484.     
  1485.     
  1486.     // Delete Child Nameserver
  1487.     public function DeleteChildNameServer($parameters)
  1488.     {
  1489.         $result = array();
  1490.         
  1491.         try
  1492.         {
  1493.             // SOAP method which is same as current function name called
  1494.             $response $this->service->__soapCall(__FUNCTION__, array($parameters));
  1495.             // Serialize as array
  1496.             $response $this->objectToArray($response);
  1497.             
  1498.             // Check is there any error?
  1499.             if(!$this->hasError($response))
  1500.             {
  1501.                 $result["data"] = array();
  1502.                 $result["data"]["NameServer"] = $parameters["request"]["ChildNameServer"];
  1503.                 $result["result"] = "OK";
  1504.             }
  1505.             else
  1506.             {
  1507.                 // Hata mesajini dondur
  1508.                 $result["result"] = "ERROR";
  1509.                 $result["error"] = $this->parseError($response);
  1510.             }
  1511.             
  1512.         }
  1513.         catch(Exception $ex)
  1514.         {
  1515.             $result["result"] = "ERROR";
  1516.             $result["error"] = $this->parseError($this->objectToArray($ex));
  1517.         }
  1518.         
  1519.         return $result;
  1520.     }   
  1521.     // Modify Child Nameserver
  1522.     public function ModifyChildNameServer($parameters)
  1523.     {
  1524.         $result = array();
  1525.         try
  1526.         {
  1527.             // SOAP method which is same as current function name called
  1528.             $response $this->service->__soapCall(__FUNCTION__, array($parameters));
  1529.             // Serialize as array
  1530.             $response $this->objectToArray($response);
  1531.             
  1532.             // Check is there any error?
  1533.             if(!$this->hasError($response))
  1534.             {
  1535.                 $result["data"] = array();
  1536.                 $result["data"]["NameServer"] = $parameters["request"]["ChildNameServer"];
  1537.                 $result["data"]["IPAdresses"] = array();
  1538.                 $result["data"]["IPAdresses"] = $parameters["request"]["IpAddressList"];
  1539.                 $result["result"] = "OK";
  1540.             }
  1541.             else
  1542.             {
  1543.                 // Hata mesajini dondur
  1544.                 $result["result"] = "ERROR";
  1545.                 $result["error"] = $this->parseError($response);
  1546.             }
  1547.             
  1548.         }
  1549.         catch(Exception $ex)
  1550.         {
  1551.             $result["result"] = "ERROR";
  1552.             $result["error"] = $this->parseError($this->objectToArray($ex));
  1553.         }
  1554.         
  1555.         return $result;
  1556.     }   
  1557.     // CONTACT MANAGEMENT
  1558.     
  1559.     // Get Contact
  1560.     public function GetContacts($parameters)
  1561.     {
  1562.         $result = array();
  1563.         try
  1564.         {
  1565.             // SOAP method which is same as current function name called
  1566.             $response $this->service->__soapCall(__FUNCTION__, array($parameters));
  1567.             // Serialize as array
  1568.             $response $this->objectToArray($response);
  1569.             
  1570.             // Check is there any error?
  1571.             if(!$this->hasError($response))
  1572.             {
  1573.                 $data $response[key($response)];
  1574.                 // If ContactInfo a valid array
  1575.                 if(isset($data["AdministrativeContact"]) && is_array($data["AdministrativeContact"]) && isset($data["TechnicalContact"]) && is_array($data["TechnicalContact"]) && isset($data["RegistrantContact"]) && is_array($data["RegistrantContact"]) && isset($data["BillingContact"]) && is_array($data["BillingContact"]))
  1576.                 {
  1577.                     // Parse domain info
  1578.                     $result["data"] = array();
  1579.                     $result["data"]["contacts"] = array();
  1580.                     $result["data"]["contacts"]["Administrative"] = $this->parseContactInfo($data["AdministrativeContact"]);
  1581.                     $result["data"]["contacts"]["Billing"] = $this->parseContactInfo($data["BillingContact"]);
  1582.                     $result["data"]["contacts"]["Registrant"] = $this->parseContactInfo($data["RegistrantContact"]);
  1583.                     $result["data"]["contacts"]["Technical"] = $this->parseContactInfo($data["TechnicalContact"]);
  1584.                     $result["result"] = "OK";
  1585.                 }
  1586.                 else
  1587.                 {
  1588.                     // Set error
  1589.                     $result["result"] = "ERROR";
  1590.                     $result["error"] = $this->setError("INVALID_CONTACT_INTO""Invalid response received from server!""Contact info is not a valid array or more than one contact info has returned!");;                     
  1591.                 }
  1592.             }
  1593.             else
  1594.             {
  1595.                 // Hata mesajini dondur
  1596.                 $result["result"] = "ERROR";
  1597.                 $result["error"] = $this->parseError($response);
  1598.             }
  1599.             
  1600.         }
  1601.         catch(Exception $ex)
  1602.         {
  1603.             $result["result"] = "ERROR";
  1604.             $result["error"] = $this->parseError($this->objectToArray($ex));
  1605.         }
  1606.         
  1607.         return $result;
  1608.     }   
  1609.     // Save contact informations
  1610.     public function SaveContacts($parameters)
  1611.     {
  1612.         $result = array();
  1613.         try
  1614.         {
  1615.             // SOAP method which is same as current function name called
  1616.             $response $this->service->__soapCall(__FUNCTION__, array($parameters));
  1617.             // Serialize as array
  1618.             $response $this->objectToArray($response);
  1619.             
  1620.             // Check is there any error?
  1621.             if(!$this->hasError($response))
  1622.             {
  1623.                 $data $response[key($response)];
  1624.                 // If ContactInfo a valid array
  1625.                 if(== 1)
  1626.                 {
  1627.                     $result["result"] = "OK";
  1628.                 }
  1629.                 else
  1630.                 {
  1631.                     // Set error
  1632.                     $result["result"] = "ERROR";
  1633.                     $result["error"] = $this->setError("INVALID_DOMAIN_LIST""Invalid response received from server!""Domain info is not a valid array or more than one domain info has returned!");;                        
  1634.                 }
  1635.             }
  1636.             else
  1637.             {
  1638.                 // Hata mesajini dondur
  1639.                 $result["result"] = "ERROR";
  1640.                 $result["error"] = $this->parseError($response);
  1641.             }
  1642.             
  1643.         }
  1644.         catch(Exception $ex)
  1645.         {
  1646.             $result["result"] = "ERROR";
  1647.             $result["error"] = $this->parseError($this->objectToArray($ex));
  1648.         }
  1649.         
  1650.         return $result;
  1651.     }   
  1652.     // Start domain transfer
  1653.     public function Transfer($parameters)
  1654.     {
  1655.         $result = array();
  1656.         try
  1657.         {
  1658.             // SOAP method which is same as current function name called
  1659.             $response $this->service->__soapCall(__FUNCTION__, array($parameters));
  1660.             // Serialize as array
  1661.             $response $this->objectToArray($response);
  1662.             
  1663.             // Check is there any error?
  1664.             if(!$this->hasError($response))
  1665.             {
  1666.                 $data $response[key($response)];
  1667.                 // If DomainInfo a valid array
  1668.                 if(isset($data["DomainInfo"]) && is_array($data["DomainInfo"]))
  1669.                 {
  1670.                     // Parse domain info
  1671.                     $result["data"] = $this->parseDomainInfo($data["DomainInfo"]);
  1672.                     $result["result"] = "OK";
  1673.                     
  1674.                 }
  1675.                 else
  1676.                 {
  1677.                     // Set error
  1678.                     $result["result"] = "ERROR";
  1679.                     $result["error"] = $this->setError("INVALID_DOMAIN_LIST""Invalid response received from server!""Domain info is not a valid array or more than one domain info has returned!");;                        
  1680.                 }
  1681.             }
  1682.             else
  1683.             {
  1684.                 // Hata mesajini dondur
  1685.                 $result["result"] = "ERROR";
  1686.                 $result["error"] = $this->parseError($response);
  1687.             }
  1688.             
  1689.         }
  1690.         catch(Exception $ex)
  1691.         {
  1692.             $result["result"] = "ERROR";
  1693.             $result["error"] = $this->parseError($this->objectToArray($ex));
  1694.         }
  1695.         
  1696.         return $result;
  1697.     }   
  1698.     // Cancel domain transfer
  1699.     public function CancelTransfer($parameters)
  1700.     {
  1701.         $result = array();
  1702.         try
  1703.         {
  1704.             // SOAP method which is same as current function name called
  1705.             $response $this->service->__soapCall(__FUNCTION__, array($parameters));
  1706.             // Serialize as array
  1707.             $response $this->objectToArray($response);
  1708.             
  1709.             // Check is there any error?
  1710.             if(!$this->hasError($response))
  1711.             {
  1712.                 // Parse domain info
  1713.                 $result["data"] = array();
  1714.                 $result["data"]["DomainName"] = $parameters["request"]["DomainName"];
  1715.                 $result["result"] = "OK";
  1716.             
  1717.             }
  1718.             else
  1719.             {
  1720.                 // Hata mesajini dondur
  1721.                 $result["result"] = "ERROR";
  1722.                 $result["error"] = $this->parseError($response);
  1723.             }
  1724.             
  1725.         }
  1726.         catch(Exception $ex)
  1727.         {
  1728.             $result["result"] = "ERROR";
  1729.             $result["error"] = $this->parseError($this->objectToArray($ex));
  1730.         }
  1731.         
  1732.         return $result;
  1733.     }   
  1734.         // Cancel domain transfer
  1735.     public function CheckTransfer($parameters)
  1736.     {
  1737.         $result = array();
  1738.         try
  1739.         {
  1740.             // SOAP method which is same as current function name called
  1741.             $response $this->service->__soapCall(__FUNCTION__, array($parameters));
  1742.             // Serialize as array
  1743.             $response $this->objectToArray($response);
  1744.             
  1745.             // Check is there any error?
  1746.             if(!$this->hasError($response))
  1747.             {
  1748.                 // Parse domain info
  1749.                 $result["data"] = array();
  1750.                 $result["data"]["DomainName"] = $parameters["request"]["DomainName"];
  1751.                 $result["result"] = "OK";
  1752.             
  1753.             }
  1754.             else
  1755.             {
  1756.                 // Hata mesajini dondur
  1757.                 $result["result"] = "ERROR";
  1758.                 $result["error"] = $this->parseError($response);
  1759.             }
  1760.             
  1761.         }
  1762.         catch(Exception $ex)
  1763.         {
  1764.             $result["result"] = "ERROR";
  1765.             $result["error"] = $this->parseError($this->objectToArray($ex));
  1766.         }
  1767.         
  1768.         return $result;
  1769.     } 
  1770.     
  1771.     
  1772.     // Register domain with contact informations
  1773.     public function RegisterWithContactInfo($parameters)
  1774.     {
  1775.         $result = array();
  1776.         try
  1777.         {
  1778.             // SOAP method which is same as current function name called
  1779.             $response $this->service->__soapCall(__FUNCTION__, array($parameters));
  1780.             // Serialize as array
  1781.             $response $this->objectToArray($response);
  1782.             
  1783.             // Check is there any error?
  1784.             if(!$this->hasError($response))
  1785.             {
  1786.                 $data $response[key($response)];
  1787.                 // If DomainInfo a valid array
  1788.                 if(isset($data["DomainInfo"]) && is_array($data["DomainInfo"]))
  1789.                 {
  1790.                     // Parse domain info
  1791.                     $result["data"] = $this->parseDomainInfo($data["DomainInfo"]);
  1792.                     $result["result"] = "OK";
  1793.                     
  1794.                 }
  1795.                 else
  1796.                 {
  1797.                     // Set error
  1798.                     $result["result"] = "ERROR";
  1799.                     $result["error"] = $this->setError("INVALID_DOMAIN_LIST""Invalid response received from server!""Domain info is not a valid array or more than one domain info has returned!");;                        
  1800.                 }
  1801.             }
  1802.             else
  1803.             {
  1804.                 // Hata mesajini dondur
  1805.                 $result["result"] = "ERROR";
  1806.                 $result["error"] = $this->parseError($response);
  1807.             }
  1808.             
  1809.         }
  1810.         catch(Exception $ex)
  1811.         {
  1812.             $result["result"] = "ERROR";
  1813.             $result["error"] = $this->parseError($this->objectToArray($ex));
  1814.         }
  1815.         
  1816.         return $result;
  1817.     }   
  1818.     // Renew domain
  1819.     public function Renew($parameters)
  1820.     {
  1821.         $result = array();
  1822.         try
  1823.         {
  1824.             // SOAP method which is same as current function name called
  1825.             $response $this->service->__soapCall(__FUNCTION__, array($parameters));
  1826.             // Serialize as array
  1827.             $response $this->objectToArray($response);
  1828.             
  1829.             // Check is there any error?
  1830.             if(!$this->hasError($response))
  1831.             {
  1832.                 $data $response[key($response)];
  1833.                 $result["data"] = array();
  1834.                 $result["data"]["ExpirationDate"] = "";
  1835.                 if(isset($data["ExpirationDate"]))
  1836.                 {
  1837.                     $result["data"]["ExpirationDate"] = $data["ExpirationDate"];
  1838.                 }
  1839.                 $result["result"] = "OK";
  1840.             
  1841.             }
  1842.             else
  1843.             {
  1844.                 // Hata mesajini dondur
  1845.                 $result["result"] = "ERROR";
  1846.                 $result["error"] = $this->parseError($response);
  1847.             }
  1848.             
  1849.         }
  1850.         catch(Exception $ex)
  1851.         {
  1852.             $result["result"] = "ERROR";
  1853.             $result["error"] = $this->parseError($this->objectToArray($ex));
  1854.         }
  1855.         
  1856.         return $result;
  1857.     }   
  1858.     // Delete domain
  1859.     public function Delete($parameters)
  1860.     {
  1861.         $result = array();
  1862.         try
  1863.         {
  1864.             // SOAP method which is same as current function name called
  1865.             $response $this->service->__soapCall(__FUNCTION__, array($parameters));
  1866.             // Serialize as array
  1867.             $response $this->objectToArray($response);
  1868.             
  1869.             // Check is there any error?
  1870.             if(!$this->hasError($response))
  1871.             {
  1872.                 $result["result"] = "OK";
  1873.             }
  1874.             else
  1875.             {
  1876.                 // Hata mesajini dondur
  1877.                 $result["result"] = "ERROR";
  1878.                 $result["error"] = $this->parseError($response);
  1879.             }
  1880.             
  1881.         }
  1882.         catch(Exception $ex)
  1883.         {
  1884.             $result["result"] = "ERROR";
  1885.             $result["error"] = $this->parseError($this->objectToArray($ex));
  1886.         }
  1887.         
  1888.         return $result;
  1889.     }   
  1890.     
  1891.     // Sync domain details
  1892.     public function SyncFromRegistry($parameters)
  1893.     {
  1894.         $result = array();
  1895.         
  1896.         try
  1897.         {
  1898.             // SOAP method which is same as current function name called
  1899.             $response $this->service->__soapCall(__FUNCTION__, array($parameters));
  1900.             // Serialize as array
  1901.             $response $this->objectToArray($response);
  1902.             
  1903.             // Check is there any error?
  1904.             if(!$this->hasError($response))
  1905.             {
  1906.                 $data $response[key($response)];
  1907.                 // If DomainInfo a valid array
  1908.                 if(isset($data["DomainInfo"]) && is_array($data["DomainInfo"]))
  1909.                 {
  1910.                     // Parse domain info
  1911.                     $result["data"] = $this->parseDomainInfo($data["DomainInfo"]);
  1912.                     $result["result"] = "OK";
  1913.                     
  1914.                 }
  1915.                 else
  1916.                 {
  1917.                     // Set error
  1918.                     $result["result"] = "ERROR";
  1919.                     $result["error"] = $this->setError("INVALID_DOMAIN_LIST""Invalid response received from server!""Domain info is not a valid array or more than one domain info has returned!");;                        
  1920.                 }
  1921.             }
  1922.             else
  1923.             {
  1924.                 // Hata mesajini dondur
  1925.                 $result["result"] = "ERROR";
  1926.                 $result["error"] = $this->parseError($response);
  1927.             }
  1928.             
  1929.         }
  1930.         catch(Exception $ex)
  1931.         {
  1932.             $result["result"] = "ERROR";
  1933.             $result["error"] = $this->parseError($this->objectToArray($ex));
  1934.         }
  1935.         
  1936.         return $result;
  1937.     }
  1938.     
  1939.     
  1940.     
  1941. }
  1942. class DomainNameAPI_PHPLibrary
  1943. {
  1944.     // VARIABLES
  1945.     public $_VERSION_ "1.2";
  1946.     private $_USERDATA_USERNAME "ownername";
  1947.     private $_USERDATA_PASSWORD "ownerpass";
  1948.     //private $_URL_SERVICE = "http://api-ote.domainnameapi.com/DomainAPI.svc";
  1949.     private $_URL_SERVICE "http://api.domainnameapi.com/DomainAPI.svc";
  1950.    //  https://api.domainnameapi.com/DomainAPI.svc
  1951.     private $_CONNECTION_METHOD "APIConnection_SOAP";
  1952.     private $_VERSION "1.0.0.0";
  1953.     private $con null;
  1954.     private $_useTestMode true;
  1955.     private $_useCaching false;
  1956.     private $_cache = array();
  1957.     public $__REQUEST = array();
  1958.     public $__RESPONSE = array();
  1959.         
  1960.     // CONSTRUCTORS
  1961.     // Default constructors
  1962.     function __construct() 
  1963.     { 
  1964.         $this->useTestMode(true);
  1965.         $this->useCaching(false);
  1966.         //$this->setConnectionMethod("Auto"); //Old value edited by Kadjo Famian
  1967.         $this->setConnectionMethod("SOAP"); 
  1968.     }
  1969.     function DomainNameAPI_PHPLibrary() 
  1970.     {
  1971.         $this->useTestMode(true);
  1972.         $this->useCaching(false);
  1973.         //$this->setConnectionMethod("Auto"); //Old value edited by Kadjo Famian
  1974.         $this->setConnectionMethod("SOAP");
  1975.     }
  1976.     
  1977.     // METHODS  
  1978.     
  1979.     // USE TEST PLATFORM OR REAL PLATFORM
  1980.     // if value equals false, use real platform, otherwise use test platform
  1981.     public function useTestMode($value)
  1982.     { 
  1983.         if($value === false)
  1984.         {
  1985.             // REAL MODE
  1986.             $this->_useTestMode false;
  1987.             $this->_URL_SERVICE "http://api.domainnameapi.com/domainapi.svc";
  1988.         }
  1989.         else
  1990.         {
  1991.             // TEST MODE
  1992.             $this->_useTestMode true;
  1993.             $this->_URL_SERVICE "http://api.domainnameapi.com/DomainAPI.svc";
  1994.             $this->_USERDATA_USERNAME "ownername";
  1995.             $this->_USERDATA_PASSWORD "ownerpass";
  1996.         }
  1997.         
  1998.         $this->setConnectionMethod("Auto");
  1999.     }
  2000.     // CACHING 
  2001.     
  2002.     // Caching will be enabled or not
  2003.     public function useCaching($value)
  2004.     { 
  2005.         if($value === true)
  2006.         { $this->_useCaching true; }
  2007.         else
  2008.         { $this->_useCaching false; }
  2009.     }
  2010.     
  2011.     // Remove domain's value from cache
  2012.     public function removeDomainFromCache($DomainName)
  2013.     {
  2014.         if(isset($this->_cache[$DomainName]))
  2015.         { unset($this->_cache[$DomainName]); }
  2016.     }
  2017.     
  2018.     // Get used mode? TEST => true, REAL => false
  2019.     public function isTestMode() 
  2020.     { return ($this->_useTestMode === false) ? false true; }
  2021.     
  2022.     // SET Username and Password
  2023.     public function setUser($UserName$Password)
  2024.     {
  2025.         $this->_USERDATA_USERNAME $UserName;
  2026.         $this->_USERDATA_PASSWORD $Password;
  2027.     }
  2028.     
  2029.     // Get connection method
  2030.     public function getConnectionMethod()
  2031.     {
  2032.         return $this->_CONNECTION_METHOD;
  2033.     }
  2034.     
  2035.     // Set connection method
  2036.     public function setConnectionMethod($Method)
  2037.     {
  2038.         switch(strtoupper(trim($Method)))
  2039.         {
  2040.               case "SOAP":
  2041.                 $this->_CONNECTION_METHOD "APIConnection_SOAP";
  2042.                 
  2043.                 $this->con = new APIConnection_SOAP($this->_URL_SERVICE);
  2044.                 break;
  2045.                 
  2046.             case "CURL";
  2047.                 $this->_CONNECTION_METHOD "APIConnection_CURL";
  2048.                 
  2049.                 $this->con = new APIConnection_CURL($this->_URL_SERVICE);
  2050.                 break;
  2051.                 
  2052.             default:
  2053.                 if(class_exists("SoapClient")){
  2054.                     $this->_CONNECTION_METHOD "APIConnection_SOAP";
  2055.                     $this->con = new APIConnection_SOAP($this->_URL_SERVICE);
  2056.                 }
  2057.                 elseif(function_exists("curl_init")){ 
  2058.                     $this->_CONNECTION_METHOD "APIConnection_CURL";
  2059.                     $this->con = new APIConnection_CURL($this->_URL_SERVICE);
  2060.                 }
  2061.                 else
  2062.                 { 
  2063.                     // DUZELT
  2064.                     $this->_CONNECTION_METHOD "ALL_OF_CONNECTION_METHODS_NOT_AVAILABLE";
  2065.                     
  2066.                     $this->con = new ALL_OF_CONNECTION_METHODS_NOT_AVAILABLE($this->_URL_SERVICE);
  2067.                 }
  2068.                 break;
  2069.         }
  2070.         // Prepare connection
  2071.         //$this->con = new $this->_CONNECTION_METHOD($this->_URL_SERVICE);
  2072.         
  2073.     }
  2074.     
  2075.     
  2076.     
  2077.     
  2078.     
  2079.     // API METHODS
  2080.     
  2081.     // Check domain is avaliable? Ex: ('example1', 'example2'), ('com', 'net', 'org')
  2082.     public function CheckAvailability($Domains$TLDs$Period $Command)
  2083.     {
  2084.         $parameters = array(
  2085.             "request" => array(
  2086.                 "Password" => $this->_USERDATA_PASSWORD,
  2087.                 "UserName" => $this->_USERDATA_USERNAME,
  2088.                 "DomainNameList" => $Domains,
  2089.                 "TldList" => $TLDs,
  2090.                 "Period" =>  $Period
  2091.                 "Commad" => $Command
  2092.             )
  2093.         );
  2094.         
  2095.         // Check availability via already prepared connection
  2096.         $response $this->con->CheckAvailability($parameters);
  2097.         // Log last request and response
  2098.         $this->__REQUEST $parameters$this->__RESPONSE $response;
  2099.         return $response;
  2100.     }
  2101.     
  2102.     
  2103.     
  2104.     
  2105.     // Get domain details
  2106.     public function GetList()
  2107.     {
  2108.         $parameters = array(
  2109.             "request" => array(
  2110.                 "Password" => $this->_USERDATA_PASSWORD,
  2111.                 "UserName" => $this->_USERDATA_USERNAME
  2112.             )
  2113.         );
  2114.         
  2115.         // Get domain id via already prepared connection
  2116.         $response $this->con->GetList($parameters);
  2117.         // Log last request and response
  2118.         $this->__REQUEST $parameters$this->__RESPONSE $response;
  2119.         return $response;
  2120.     }
  2121.     
  2122.     
  2123.     // Get domain details
  2124.     public function GetDetails($DomainName)
  2125.     {
  2126.     
  2127.         // If caching enabled  
  2128.         if($this->_useCaching == true)
  2129.         {
  2130.             
  2131.             // If is there any cached value for this domain?
  2132.             if(isset($this->_cache[$DomainName]["result"]))
  2133.             {
  2134.                 // Return cached value
  2135.                 $result $this->_cache[$DomainName]["result"];
  2136.                 $result["fromCache"] = true;
  2137.                 return $result;
  2138.             }
  2139.             
  2140.         }
  2141.         
  2142.         $parameters = array(
  2143.             "request" => array(
  2144.                 "Password" => $this->_USERDATA_PASSWORD,
  2145.                 "UserName" => $this->_USERDATA_USERNAME,
  2146.                 "DomainName" => $DomainName
  2147.             )
  2148.         );
  2149.         
  2150.         // Get domain id via already prepared connection
  2151.         $response $this->con->GetDetails($parameters);
  2152.         // Log last request and response
  2153.         $this->__REQUEST $parameters$this->__RESPONSE $response;
  2154.         // If caching enabled  
  2155.         if($this->_useCaching == true)
  2156.         {
  2157.             $this->_cache[$DomainName]["result"] = $response;
  2158.             $this->_cache[$DomainName]["date"] = date("Y-m-d H:i:s");
  2159.         }
  2160.         
  2161.         return $response;
  2162.     }
  2163.     
  2164.     
  2165.     
  2166.     
  2167.     // Modify nameservers
  2168.     public function ModifyNameServer($DomainName$NameServers)
  2169.     {
  2170.         $parameters = array(
  2171.             "request" => array(
  2172.                 "Password" => $this->_USERDATA_PASSWORD,
  2173.                 "UserName" => $this->_USERDATA_USERNAME,
  2174.                 "DomainName" => $DomainName,
  2175.                 "NameServerList" => $NameServers
  2176.             )
  2177.         );
  2178.         
  2179.         // We will modify domain, so remove it from cache
  2180.         $this->removeDomainFromCache($DomainName);
  2181.         
  2182.         // Check availability via already prepared connection
  2183.         $response $this->con->ModifyNameServer($parameters);
  2184.         // Log last request and response
  2185.         $this->__REQUEST $parameters$this->__RESPONSE $response;
  2186.         return $response;
  2187.     }
  2188.     
  2189.     // Enable Theft Protection Lock
  2190.     public function EnableTheftProtectionLock($DomainName)
  2191.     {
  2192.         $parameters = array(
  2193.             "request" => array(
  2194.                 "Password" => $this->_USERDATA_PASSWORD,
  2195.                 "UserName" => $this->_USERDATA_USERNAME,
  2196.                 "DomainName" => $DomainName
  2197.             )
  2198.         );
  2199.         
  2200.         // We will modify domain, so remove it from cache
  2201.         $this->removeDomainFromCache($DomainName);
  2202.         
  2203.         // Enable theft protection lock via already prepared connection
  2204.         $response $this->con->EnableTheftProtectionLock($parameters);
  2205.         // Log last request and response
  2206.         $this->__REQUEST $parameters$this->__RESPONSE $response;
  2207.         return $response;
  2208.     }
  2209.             
  2210.     // Disable Theft Protection Lock
  2211.     public function DisableTheftProtectionLock($DomainName)
  2212.     {
  2213.         $parameters = array(
  2214.             "request" => array(
  2215.                 "Password" => $this->_USERDATA_PASSWORD,
  2216.                 "UserName" => $this->_USERDATA_USERNAME,
  2217.                 "DomainName" => $DomainName
  2218.             )
  2219.         );
  2220.         
  2221.         // We will modify domain, so remove it from cache
  2222.         $this->removeDomainFromCache($DomainName);
  2223.         
  2224.         // Disable theft protection lock via already prepared connection
  2225.         $response $this->con->DisableTheftProtectionLock($parameters);
  2226.         // Log last request and response
  2227.         $this->__REQUEST $parameters$this->__RESPONSE $response;
  2228.         return $response;
  2229.     }
  2230.     
  2231.     // CHILD NAMESERVER MANAGEMENT
  2232.     
  2233.     // Add Child Nameserver
  2234.     public function AddChildNameServer($DomainName$NameServer$IPAdresses)
  2235.     {
  2236.         $parameters = array(
  2237.             "request" => array(
  2238.                 "Password" => $this->_USERDATA_PASSWORD,
  2239.                 "UserName" => $this->_USERDATA_USERNAME,
  2240.                 "DomainName" => $DomainName,
  2241.                 "ChildNameServer" => $NameServer,
  2242.                 "IpAddressList" => $IPAdresses
  2243.             )
  2244.         );
  2245.         
  2246.         // We will modify domain, so remove it from cache
  2247.         $this->removeDomainFromCache($DomainName);
  2248.         
  2249.         // Add child nameserver via already prepared connection
  2250.         $response $this->con->AddChildNameServer($parameters);
  2251.         // Log last request and response
  2252.         $this->__REQUEST $parameters$this->__RESPONSE $response;
  2253.         return $response;
  2254.     }
  2255.     
  2256.     
  2257.     
  2258.     // Delete Child Nameserver
  2259.     public function DeleteChildNameServer($DomainName$NameServer)
  2260.     {
  2261.         $parameters = array(
  2262.             "request" => array(
  2263.                 "Password" => $this->_USERDATA_PASSWORD,
  2264.                 "UserName" => $this->_USERDATA_USERNAME,
  2265.                 "DomainName" => $DomainName,
  2266.                 "ChildNameServer" => $NameServer
  2267.             )
  2268.         );
  2269.         
  2270.         // We will modify domain, so remove it from cache
  2271.         $this->removeDomainFromCache($DomainName);
  2272.         
  2273.         // Delete child nameserver via already prepared connection
  2274.         $response $this->con->DeleteChildNameServer($parameters);
  2275.         // Log last request and response
  2276.         $this->__REQUEST $parameters$this->__RESPONSE $response;
  2277.         return $response;
  2278.     }
  2279.     
  2280.     
  2281.     // Modify Child Nameserver
  2282.     public function ModifyChildNameServer($DomainName$NameServer$IPAdresses)
  2283.     {
  2284.         $parameters = array(
  2285.             "request" => array(
  2286.                 "Password" => $this->_USERDATA_PASSWORD,
  2287.                 "UserName" => $this->_USERDATA_USERNAME,
  2288.                 "DomainName" => $DomainName,
  2289.                 "ChildNameServer" => $NameServer,
  2290.                 "IpAddressList" => $IPAdresses
  2291.             )
  2292.         );
  2293.         
  2294.         // We will modify domain, so remove it from cache
  2295.         $this->removeDomainFromCache($DomainName);
  2296.         
  2297.         // Add child nameserver via already prepared connection
  2298.         $response $this->con->ModifyChildNameServer($parameters);
  2299.         // Log last request and response
  2300.         $this->__REQUEST $parameters$this->__RESPONSE $response;
  2301.         return $response;
  2302.     }
  2303.     
  2304.     
  2305.     
  2306.     
  2307.     // CONTACT MANAGEMENT
  2308.     
  2309.     // Get Domain Contact informations
  2310.     public function GetContacts($DomainName)
  2311.     {
  2312.         $parameters = array(
  2313.             "request" => array(
  2314.                 "Password" => $this->_USERDATA_PASSWORD,
  2315.                 "UserName" => $this->_USERDATA_USERNAME,
  2316.                 "DomainName" => $DomainName
  2317.             )
  2318.         );
  2319.         
  2320.         // Get Domain Contact informations via already prepared connection
  2321.         $response $this->con->GetContacts($parameters);
  2322.         // Log last request and response
  2323.         $this->__REQUEST $parameters$this->__RESPONSE $response;
  2324.         return $response;
  2325.     }
  2326.     
  2327.     
  2328.     
  2329.     // Set domain cantacts
  2330.     public function SaveContacts($DomainName$Contacts)
  2331.     {
  2332.         $parameters = array(
  2333.             "request" => array(
  2334.                 "Password" => $this->_USERDATA_PASSWORD,
  2335.                 "UserName" => $this->_USERDATA_USERNAME,
  2336.                 "DomainName" => $DomainName,
  2337.                 "AdministrativeContact" => $Contacts["Administrative"],
  2338.                 "BillingContact" => $Contacts["Billing"],
  2339.                 "TechnicalContact" => $Contacts["Technical"],
  2340.                 "RegistrantContact" => $Contacts["Registrant"]
  2341.             )
  2342.         );
  2343.         
  2344.         // We will modify domain, so remove it from cache
  2345.         $this->removeDomainFromCache($DomainName);
  2346.         
  2347.         // Register domain via already prepared connection
  2348.         $response $this->con->SaveContacts($parameters);
  2349.         // Log last request and response
  2350.         $this->__REQUEST $parameters$this->__RESPONSE $response;
  2351.         return $response;
  2352.     }
  2353.     
  2354.     
  2355.     
  2356.     // DOMAIN TRANSFER (INCOMING DOMAIN)
  2357.     
  2358.     // Start domain transfer (Incoming domain)
  2359.     public function Transfer($DomainName$AuthCode)
  2360.     {
  2361.         $parameters = array(
  2362.             "request" => array(
  2363.                 "Password" => $this->_USERDATA_PASSWORD,
  2364.                 "UserName" => $this->_USERDATA_USERNAME,
  2365.                 "DomainName" => $DomainName,
  2366.                 "AuthCode" => $AuthCode
  2367.             )
  2368.         );
  2369.         
  2370.         // We will modify domain, so remove it from cache
  2371.         $this->removeDomainFromCache($DomainName);
  2372.         
  2373.         // Start domain transfer via already prepared connection
  2374.         $response $this->con->Transfer($parameters);
  2375.         // Log last request and response
  2376.         $this->__REQUEST $parameters$this->__RESPONSE $response;
  2377.         return $response;
  2378.     }
  2379.     
  2380.     
  2381.     // Cancel domain transfer (Incoming domain)
  2382.     public function CancelTransfer($DomainName)
  2383.     {
  2384.         $parameters = array(
  2385.             "request" => array(
  2386.                 "Password" => $this->_USERDATA_PASSWORD,
  2387.                 "UserName" => $this->_USERDATA_USERNAME,
  2388.                 "DomainName" => $DomainName
  2389.             )
  2390.         );
  2391.         
  2392.         // We will modify domain, so remove it from cache
  2393.         $this->removeDomainFromCache($DomainName);
  2394.         
  2395.         // Cancel domain transfer via already prepared connection
  2396.         $response $this->con->CancelTransfer($parameters);
  2397.         // Log last request and response
  2398.         $this->__REQUEST $parameters$this->__RESPONSE $response;
  2399.         return $response;
  2400.     }
  2401.     
  2402.     
  2403.     // Cancel domain transfer (Incoming domain)
  2404.     public function CheckTransfer($DomainName)
  2405.     {
  2406.         $parameters = array(
  2407.             "request" => array(
  2408.                 "Password" => $this->_USERDATA_PASSWORD,
  2409.                 "UserName" => $this->_USERDATA_USERNAME,
  2410.                 "DomainName" => $DomainName
  2411.             )
  2412.         );
  2413.         
  2414.         // We will modify domain, so remove it from cache
  2415.         $this->removeDomainFromCache($DomainName);
  2416.         
  2417.         // Cancel domain transfer via already prepared connection
  2418.         $response $this->con->CheckTransfer($parameters);
  2419.         // Log last request and response
  2420.         $this->__REQUEST $parameters$this->__RESPONSE $response;
  2421.         return $response;
  2422.     }
  2423.     // Renew domain
  2424.     public function Renew($DomainName$Period)
  2425.     {
  2426.         $parameters = array(
  2427.             "request" => array(
  2428.                 "Password" => $this->_USERDATA_PASSWORD,
  2429.                 "UserName" => $this->_USERDATA_USERNAME,
  2430.                 "DomainName" => $DomainName,
  2431.                 "Period" => $Period
  2432.             )
  2433.         );
  2434.         
  2435.         // We will modify domain, so remove it from cache
  2436.         $this->removeDomainFromCache($DomainName);
  2437.         
  2438.         // Renew domain via already prepared connection
  2439.         $response $this->con->Renew($parameters);
  2440.         // Log last request and response
  2441.         $this->__REQUEST $parameters$this->__RESPONSE $response;
  2442.         return $response;
  2443.     }
  2444.     
  2445.     
  2446.     
  2447.     // Register domain with contact informations
  2448.     public function RegisterWithContactInfo($DomainName$Period$Contacts$NameServers = array("dns.domainnameapi.com""web.domainnameapi.com"), $TheftProtectionLock true$PrivacyProtection false)
  2449.     {
  2450.         $parameters = array(
  2451.             "request" => array(
  2452.                 "Password" => $this->_USERDATA_PASSWORD,
  2453.                 "UserName" => $this->_USERDATA_USERNAME,
  2454.                 "DomainName" => $DomainName,
  2455.                 "Period" => $Period,
  2456.                 "NameServerList" => $NameServers,
  2457.                 "LockStatus" => $TheftProtectionLock,
  2458.                 "PrivacyProtectionStatus" => $PrivacyProtection,
  2459.                 "AdministrativeContact" => $Contacts["Administrative"],
  2460.                 "BillingContact" => $Contacts["Billing"],
  2461.                 "TechnicalContact" => $Contacts["Technical"],
  2462.                 "RegistrantContact" => $Contacts["Registrant"]
  2463.             )
  2464.         );
  2465.         
  2466.         // We will modify domain, so remove it from cache
  2467.         $this->removeDomainFromCache($DomainName);
  2468.         
  2469.         // Register domain via already prepared connection
  2470.         $response $this->con->RegisterWithContactInfo($parameters);
  2471.         // Log last request and response
  2472.         $this->__REQUEST $parameters$this->__RESPONSE $response;
  2473.         return $response;
  2474.     }
  2475.     
  2476.     // Modify privacy protection status of domain
  2477.     public function ModifyPrivacyProtectionStatus($DomainName$Status$Reason "Owner request")
  2478.     {
  2479.         if(trim($Reason) == "") { $Reason "Owner request"; }
  2480.         
  2481.         $parameters = array(
  2482.             "request" => array(
  2483.                 "Password" => $this->_USERDATA_PASSWORD,
  2484.                 "UserName" => $this->_USERDATA_USERNAME,
  2485.                 "DomainName" => $DomainName,
  2486.                 "ProtectPrivacy" => $Status,
  2487.                 "Reason" => $Reason
  2488.             )
  2489.         );
  2490.         
  2491.         // We will modify domain, so remove it from cache
  2492.         $this->removeDomainFromCache($DomainName);
  2493.         
  2494.         // Modify privacy protection status of domain via already prepared connection
  2495.         $response $this->con->ModifyPrivacyProtectionStatus($parameters);
  2496.         // Log last request and response
  2497.         $this->__REQUEST $parameters$this->__RESPONSE $response;
  2498.         return $response;
  2499.     }
  2500.     
  2501.     
  2502.     // Sync domain
  2503.     public function SyncFromRegistry($DomainName)
  2504.     {
  2505.         $parameters = array(
  2506.             "request" => array(
  2507.                 "Password" => $this->_USERDATA_PASSWORD,
  2508.                 "UserName" => $this->_USERDATA_USERNAME,
  2509.                 "DomainName" => $DomainName
  2510.             )
  2511.         );
  2512.         
  2513.         // We will modify domain, so remove it from cache
  2514.         $this->removeDomainFromCache($DomainName);
  2515.         
  2516.         // Sync domain via already prepared connection
  2517.         $response $this->con->SyncFromRegistry($parameters);
  2518.         // Log last request and response
  2519.         $this->__REQUEST $parameters$this->__RESPONSE $response;
  2520.         return $response;
  2521.     }
  2522.     
  2523.     
  2524. }