/** * The default action - show the home page */ public function indexAction() { $ns = new Zend_Session_Namespace(); $uri = $this->getRequest()->getParam('uri'); if (!empty($uri)) { $tld = DomainsTlds::getbyTld($uri, $ns->langid); // If the translation has been not found load the default language if (empty($tld['DomainsTldsData'][0])) { $tld = DomainsTlds::getbyTld($uri); } } else { $this->_redirect('index'); } // Set the page title $this->view->headTitle()->prepend($this->translator->_('.%s domain registration', $tld['DomainsTldsData'][0]['name'])); $this->view->headMeta()->setName('keywords', $this->translator->translate('domain registration') . ", " . $this->translator->_('%s domain', "." . $tld['DomainsTldsData'][0]['name'])); $this->view->headMeta()->setName('description', $this->translator->_('.%s domain registration', $tld['DomainsTldsData'][0]['name'])); $form = new Default_Form_DomainsinglecheckerForm(array('action' => '/domainschk/check', 'method' => 'post')); $form->populate(array('tld' => $tld['tld_id'])); $this->view->form = $form; $this->view->tld = $tld; $this->view->tldslist = DomainsTlds::getList(); }
/** * renewOrder * Renew of Order * @return orderid integer */ public static function renewOrder($customer_id, $products) { $order = new Orders(); $i = 0; $total = 0; $vat = 0; $tldid = null; // Check if there are auto-renewal services/products if (!self::checkAutorenewProducts($products)) { return false; } if (is_numeric($customer_id)) { $customer = Customers::getAllInfo($customer_id); if (count($products) > 0) { $order->customer_id = $customer_id; $order->isp_id = $customer['isp_id']; $order->is_renewal = true; $order->order_date = date('Y-m-d'); $order->status_id = Statuses::id("tobepaid", "orders"); // To be paid $order->uuid = Shineisp_Commons_Uuid::generate(); $order->save(); // Create the public number but I need the order id $order->order_number = self::formatOrderId($order->getIncremented()); $order->save(); // Get the generated order id $orderid = $order->getIncremented(); // Log data Shineisp_Commons_Utilities::log("A new renewal order (" . $order->order_number . ") for " . $customer['fullname'] . " has been created successfully"); // Add a fastlink to a order $link_exist = Fastlinks::findlinks($orderid, $customer_id, 'orders'); if (count($link_exist) == 0) { $link = new Fastlinks(); $link->controller = "orders"; $link->action = "edit"; $link->params = json_encode(array('id' => $orderid)); $link->customer_id = $customer_id; $link->sqltable = "orders"; $link->id = $orderid; $link->code = Shineisp_Commons_Utilities::GenerateRandomString(); $link->save(); } if (count($products) > 0) { foreach ($products as $product) { $orderitem = new OrdersItems(); if (!empty($product['oldorderitemid']) && is_numeric($product['oldorderitemid'])) { // Find the details of the old order item details $oldOrderDetails = OrdersItems::find($product['oldorderitemid'], null, true); // Check if the last order is present in the db and check if the product must be renewed if (!empty($oldOrderDetails[0]) && $product['renew']) { // Set the new order details fields $orderitem->order_id = $orderid; $orderitem->product_id = $oldOrderDetails[0]['product_id']; $orderitem->billing_cycle_id = $oldOrderDetails[0]['billing_cycle_id']; if ($product['type'] == "service") { // Get the number of the months to be sum to the expiration date of the service $date_end = Shineisp_Commons_Utilities::add_date(date($oldOrderDetails[0]['date_end']), null, BillingCycle::getMonthsNumber($oldOrderDetails[0]['billing_cycle_id']) * $oldOrderDetails[0]['quantity']); $orderitem->date_start = $oldOrderDetails[0]['date_end']; // The new order will have the date_end as date_start $orderitem->date_end = Shineisp_Commons_Utilities::formatDateIn($date_end); $orderitem->price = $oldOrderDetails[0]['price']; $orderitem->vat = $oldOrderDetails[0]['vat']; $orderitem->percentage = $oldOrderDetails[0]['percentage']; $orderitem->subtotal = $oldOrderDetails[0]['subtotal']; $orderitem->cost = $oldOrderDetails[0]['cost']; } elseif ($product['type'] == "domain") { // Get the number of the months to be sum to the expiration date of the domain $parameters = json_decode($oldOrderDetails[0]['parameters'], true); $tldid = !empty($parameters['tld']) ? $parameters['tld'] : NULL; $domain = !empty($parameters['domain']['name']) ? $parameters['domain']['name'] : NULL; // get the tld information $arrdomain = Shineisp_Commons_Utilities::getTld($domain); if (!empty($arrdomain[1])) { $tld = DomainsTlds::getbyTld($arrdomain[1]); if (!empty($tld['tld_id'])) { $tax = Taxes::getTaxbyTldID($tld['tld_id']); // Check if the product has some tax to be added $orderitem->tld_id = $tld['tld_id']; if (!empty($tld['tax_id'])) { $vat = $tld['renewal_price'] * $tax['percentage'] / 100; $subtotal = $tld['renewal_price'] * ($tax['percentage'] + 100) / 100; $percentage = $tax['percentage']; } else { $vat = 0; $subtotal = $tld['renewal_price']; $percentage = 0; } } } $date_end = Shineisp_Commons_Utilities::add_date(date($product['expiring_date']), null, BillingCycle::getMonthsNumber($oldOrderDetails[0]['billing_cycle_id']) * $oldOrderDetails[0]['quantity']); $orderitem->date_start = $product['expiring_date']; // The new order will have the date_end as date_start $orderitem->date_end = Shineisp_Commons_Utilities::formatDateIn($date_end); $orderitem->parameters = json_encode(array('domain' => array('name' => trim($domain), 'tld' => $tldid, 'action' => 'renewDomain', 'authinfo' => null))); $orderitem->vat = $vat; $orderitem->percentage = $percentage; $orderitem->subtotal = $subtotal; $orderitem->price = $tld['renewal_price']; $orderitem->cost = $tld['renewal_cost']; } $orderitem->autorenew = $oldOrderDetails[0]['autorenew']; $orderitem->description = $oldOrderDetails[0]['description']; $orderitem->quantity = $oldOrderDetails[0]['quantity']; $orderitem->status_id = Statuses::id("tobepaid", "orders"); // To be payed status set $orderitem->save(); $newOrderItemId = $orderitem->getIncremented(); // Attach all the services, products, and domains with the order $oldOID = OrdersItemsDomains::findIDsByOrderItemID($product['oldorderitemid'], null, true); if (isset($oldOID[0])) { // Some services are not linked to a domain $ordersitemsdomains = new OrdersItemsDomains(); $ordersitemsdomains->domain_id = $oldOID[0]['domain_id']; $ordersitemsdomains->order_id = $orderid; $ordersitemsdomains->orderitem_id = $newOrderItemId; $ordersitemsdomains->save(); } $i++; } } } // If there are items to be save ... if ($i > 0) { // Update Order self::updateTotalsOrder($orderid); } return $orderid; } } } }
/** * Get a record by domain name * @param $domain * @return integer */ public static function findRegistrarIDbyDomain($domainname) { // Get the domain and tld extension from the domain name $arrdomain = Shineisp_Commons_Utilities::getTld($domainname); if (!empty($arrdomain[0]) && !empty($arrdomain[1])) { $domain = $arrdomain[0]; $tld = $arrdomain[1]; } else { throw new Exception('It was not possible get the tld extension from the domain name', "666"); } // Get the code of the tld domain $tld = DomainsTlds::getbyTld($tld); if (empty($tld)) { throw new Exception("Tld extension has not been found or the name of the domain is malformed", "666"); } $registrar = Doctrine_Query::create()->from('Registrars r')->leftJoin('r.Domains d ON d.registrars_id = r.registrars_id')->where("d.domain = ?", $domain)->andWhere('d.tld_id = ?', $tld['tld_id'])->andWhere('r.active = ?', true)->execute(array(), Doctrine_Core::HYDRATE_ARRAY); if (!empty($registrar[0]['registrars_id']) && is_numeric($registrar[0]['registrars_id'])) { return $registrar[0]['registrars_id']; } else { return false; } }
/** * isAvailable * Check the domain if available * @return boolean */ public static function isAvailable($domain) { if (!empty($domain)) { list($name, $tld) = explode(".", $domain); $tldInfo = DomainsTlds::getbyTld($tld); if (!empty($tldInfo['Registrars'])) { $registrar_class = $tldInfo['Registrars']['class']; $reg = new $registrar_class(); if ($reg->checkDomain($domain)) { return true; } else { return false; } } } return false; }