src/Controller/HostingController.php line 510

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