public function processAction() { $ns = new Zend_Session_Namespace("default"); $request = $this->getRequest(); $form = new Default_Form_ContactsForm(array('action' => '/contacts/process', 'method' => 'post')); $this->view->form = $form; // Check if we have a POST request if (!$request->isPost()) { return $this->_helper->redirector('index', 'contacts', 'default'); } if ($form->isValid($request->getPost())) { // Get the values posted $params = $form->getValues(); $captcha = $params['captcha']; // Actually it's an array, so both the ID and the submitted word // is in it with the corresponding keys // So here's the ID... $captchaId = $captcha['id']; // And here's the user submitted word... $captchaInput = $captcha['input']; // We are accessing the session with the corresponding namespace // Try overwriting this, hah! $captchaSession = new Zend_Session_Namespace('Zend_Form_Captcha_' . $captchaId); // To access what's inside the session, we need the Iterator // So we get one... $captchaIterator = $captchaSession->getIterator(); // And here's the correct word which is on the image... $captchaWord = $captchaIterator['word']; // Now just compare them... if ($captchaInput == $captchaWord) { $isp = Shineisp_Registry::get('ISP'); Shineisp_Commons_Utilities::sendEmailTemplate($isp->email, 'contact', array('fullname' => $params['fullname'], 'company' => $params['company'], 'email' => $params['email'], 'subject' => $params['subject'], 'message' => $params['message']), null, null, null, null, $ns->langid); // Redirect the visitor to the contact page return $this->_helper->redirector('index', 'contacts', 'default', array('mex' => 'The task requested has been executed successfully.', 'status' => 'success')); } } return $this->_helper->viewRenderer('index'); }
/** * saveData * Save the record * @param posted var from the form * @return Boolean */ public static function saveData($record, $sendemail = false) { // Set the new values if (!empty($record['review_id']) && is_numeric($record['review_id'])) { $review = self::getbyId($record['review_id']); } else { $review = new Reviews(); $review->ip = $_SERVER['REMOTE_ADDR']; } // Get the latitude and longitude coordinates $coords = Shineisp_Commons_Utilities::getCoordinates($record['city']); $review->product_id = $record['product_id']; $review->publishedat = date('Y-m-d H:i:s'); $review->nick = $record['nick']; $review->city = !empty($coords['results'][0]['formatted_address']) ? $coords['results'][0]['formatted_address'] : $record['city']; $review->referer = $record['referer']; $review->subject = $record['subject']; $review->latitude = !empty($coords['results'][0]['geometry']['location']['lat']) ? $coords['results'][0]['geometry']['location']['lat'] : $record['latitude']; $review->longitude = !empty($coords['results'][0]['geometry']['location']['lng']) ? $coords['results'][0]['geometry']['location']['lng'] : $record['longitude']; $review->email = $record['email']; $review->stars = $record['stars']; $review->active = isset($record['active']) ? $record['active'] : 0; $review->review = $record['review']; if ($review->trySave()) { if ($sendemail) { // Send the email to confirm the subscription $isp = Isp::getActiveISP(); $placeholders['review'] = $record['review']; $placeholders['nick'] = $record['nick']; $placeholders['referer'] = $record['referer']; $placeholders['subject'] = $record['subject']; $placeholders['email'] = $record['email']; $placeholders['stars'] = $record['stars']; $placeholders['product'] = products::getAllInfo($record['product_id']); // Send a message to the administrator Shineisp_Commons_Utilities::sendEmailTemplate($isp['email'], 'review_new', $placeholders); } return $review->review_id; } return false; }
public static function sendOrder($orderid, $customURL = null) { $bank = ""; if (is_numeric($orderid)) { $order = self::getAllInfo($orderid, null, true); //if customer comes from reseller if ($order[0]['Customers']['parent_id']) { $customer_email = Contacts::getEmails($order[0]['Customers']['parent_id']); $invoice_dest = Customers::getAllInfo($order[0]['Customers']['parent_id']); $customer = $invoice_dest['firstname'] . " " . $invoice_dest['lastname']; $customer .= !empty($invoice_dest['company']) ? " - " . $invoice_dest['company'] : ""; $fastlink = Fastlinks::findlinks($orderid, $order[0]['Customers']['parent_id'], 'orders'); $language_id = $invoice_dest['language_id']; } else { $customer_email = Contacts::getEmails($order[0]['Customers']['customer_id']); $customer = $order[0]['Customers']['firstname'] . " " . $order[0]['Customers']['lastname']; $customer .= !empty($order[0]['Customers']['company']) ? " - " . $order[0]['Customers']['company'] : ""; $fastlink = Fastlinks::findlinks($orderid, $order[0]['Customers']['customer_id'], 'orders'); $language_id = $order[0]['Customers']['language_id']; } $email = $order[0]['Isp']['email']; $bankInfo = Banks::getBankInfo(); if (!empty($bankInfo['description'])) { $bank = $bankInfo['description']; } if (!empty($customURL)) { $url = $customURL; } else { if (!empty($fastlink[0]['code'])) { $url = "http://" . $_SERVER['HTTP_HOST'] . "/index/link/id/" . $fastlink[0]['code']; } else { $url = "http://" . $_SERVER['HTTP_HOST']; } } $date = explode("-", $order[0]['order_date']); Shineisp_Commons_Utilities::sendEmailTemplate($customer_email, 'order_new', array('orderid' => $order[0]['order_number'], 'fullname' => $customer, 'email' => $email, 'bank' => $bank, 'url' => $url, ':shineisp:' => $order[0]['Customers'], 'conditions' => strip_tags(Settings::findbyParam('conditions'))), null, null, null, null, $language_id); return true; } return false; }
/** * CREATE THE ORDER FOR ALL THE AUTORENEWABLE DOMAINS/SERVICES * Check all the services [domains, products] and create the orders for each customer only if the service has been set as renewable * @return void */ public static function checkServices() { try { $i = 0; $customers = array(); /* We have to start to get all the domains that them expiring date is today then we have to create a custom array sorted by customerID in order to group services and domains of a specific customer. */ // Get all the active domains that expire in 1 day $domains = Domains::getExpiringDomainsByDays(1, Statuses::id("active", "domains")); if ($domains) { Shineisp_Commons_Utilities::log("There are (" . count($domains) . ") new domains to renew"); // Create the customer group list for the email summary foreach ($domains as $domain) { if (is_numeric($domain['reseller'])) { $invoice_dest = Customers::getAllInfo($domain['reseller']); $customers[$domain['customer_id']]['id'] = $invoice_dest['customer_id']; $customers[$domain['customer_id']]['fullname'] = $invoice_dest['firstname'] . " " . $invoice_dest['lastname'] . " " . $invoice_dest['company']; $customers[$domain['customer_id']]['email'] = $invoice_dest['email']; $customers[$domain['customer_id']]['language_id'] = $invoice_dest['language_id']; } else { $customers[$domain['customer_id']]['id'] = $domain['customer_id']; $customers[$domain['customer_id']]['fullname'] = $domain['fullname']; $customers[$domain['customer_id']]['email'] = $domain['email']; $customers[$domain['customer_id']]['language_id'] = $domain['language_id']; } $customers[$domain['customer_id']]['products'][$i]['name'] = $domain['domain']; $customers[$domain['customer_id']]['products'][$i]['type'] = "domain"; $customers[$domain['customer_id']]['products'][$i]['renew'] = $domain['renew']; $customers[$domain['customer_id']]['products'][$i]['expiring_date'] = $domain['expiringdate']; $customers[$domain['customer_id']]['products'][$i]['days'] = $domain['days']; // Get the last old order item id if (!empty($domain['oldorders'])) { // find the domain foreach ($domain['oldorders'] as $olditemorder) { // Get all the information from the old order $olditem = OrdersItems::getAllInfo($olditemorder['orderitem_id']); // Check if the old order item refers to the domain selected if (!empty($olditem['parameters']) && !empty($olditem['Orders']['OrdersItemsDomains'][0]['Domains']['tld_id'])) { // Get the old configuration parameters $params = json_decode($olditem['parameters'], true); // Zend_Debug::dump($olditem); // Zend_Debug::dump($params); // Zend_Debug::dump($domain['domain']); // Extract the domain name and match it with the domain selected if (!empty($params['domain']) && $params['domain']['name'] == $domain['domain']) { $customers[$domain['customer_id']]['products'][$i]['oldorderitemid'] = $olditemorder['orderitem_id']; } } } } Shineisp_Commons_Utilities::log("- " . $domain['domain']); $i++; } } /* * Now we have to get the services expired and we have to sum the previous $customers array with these * new information. */ // Get all the services active that expire the day after $services = OrdersItems::getExpiringServicesByDays(1, Statuses::id("complete", "orders")); if ($services) { Shineisp_Commons_Utilities::log("There are (" . count($services) . ") new services to renew"); // Create the customer group list for the email summary foreach ($services as $service) { if (is_numeric($service['reseller'])) { $invoice_dest = Customers::getAllInfo($service['reseller']); $customers[$service['customer_id']]['id'] = $invoice_dest['customer_id']; $customers[$service['customer_id']]['fullname'] = $invoice_dest['firstname'] . " " . $invoice_dest['lastname'] . " " . $invoice_dest['company']; $customers[$service['customer_id']]['email'] = $invoice_dest['email']; $customers[$service['customer_id']]['password'] = $invoice_dest['password']; $customers[$service['customer_id']]['language_id'] = $invoice_dest['language_id']; } else { $customers[$service['customer_id']]['id'] = $service['id']; $customers[$service['customer_id']]['fullname'] = $service['fullname']; $customers[$service['customer_id']]['email'] = $service['email']; $customers[$service['customer_id']]['password'] = $service['password']; $customers[$service['customer_id']]['language_id'] = $service['language_id']; } $customers[$service['customer_id']]['products'][$i]['name'] = $service['product']; $customers[$service['customer_id']]['products'][$i]['type'] = "service"; $customers[$service['customer_id']]['products'][$i]['renew'] = $service['renew']; $customers[$service['customer_id']]['products'][$i]['expiring_date'] = $service['expiringdate']; $customers[$service['customer_id']]['products'][$i]['days'] = $service['days']; $customers[$service['customer_id']]['products'][$i]['oldorderitemid'] = $service['detail_id']; Shineisp_Commons_Utilities::log("- " . $service['product']); $i++; } } // Create the email messages for the customers if (count($customers) > 0) { foreach ($customers as $customer) { $items = ""; // **** CREATE THE ORDER FOR ALL THE AUTORENEWABLE DOMAINS/SERVICES *** // ============================================================ // Renew all the services and domain where the customer has choosen the autorenew of the service. $orderID = Orders::renewOrder($customer['id'], $customer['products']); if (is_numeric($orderID)) { $link = Fastlinks::findlinks($orderID, $customer['id'], 'orders'); // Create the fast link to include in the email if (!empty($link[0]['code'])) { $url = "http://" . $_SERVER['HTTP_HOST'] . "/index/link/id/" . $link[0]['code']; } else { $url = "http://" . $_SERVER['HTTP_HOST']; } Shineisp_Commons_Utilities::sendEmailTemplate($customer['email'], 'order_renew', array('fullname' => $customer['fullname'], ':shineisp:' => $customer, 'url' => $url), null, null, null, null, $customer['language_id'], Settings::findbyParam('cron_notify')); } } } /* * Now we have to set as expired all the domains records that the date is the date of the expiring of the domain * // Expired */ $dq = Doctrine_Query::create()->update('Domains d')->set('d.status_id', Statuses::id('expired', 'domains'))->where('DATEDIFF(d.expiring_date, CURRENT_DATE) <= ?', 0)->addWhere('DATEDIFF(d.expiring_date, CURRENT_DATE) >= ?', 0); $dq->execute(null, Doctrine::HYDRATE_ARRAY); /* * Now we have to set as closed all the domains records that the date is older of -2 days * // Closed */ $dq = Doctrine_Query::create()->update('Domains d')->set('d.status_id', Statuses::id('suspended', 'domains'))->where('DATEDIFF(d.expiring_date, CURRENT_DATE) <= ?', -2); $dq->execute(null, Doctrine::HYDRATE_ARRAY); /* * Now we have to set as expired all the services records * // Expired */ $dq = Doctrine_Query::create()->update('OrdersItems oi')->set('oi.status_id', Statuses::id('expired', 'orders'))->where('DATEDIFF(oi.date_end, CURRENT_DATE) <= ?', 0); $dq->execute(null, Doctrine::HYDRATE_ARRAY); /* * Now we have to set as deleted all the services records * // Deleted */ $dq = Doctrine_Query::create()->update('OrdersItems oi')->set('oi.status_id', Statuses::id('deleted', 'orders'))->where('DATEDIFF(oi.date_end, CURRENT_DATE) <= ?', -2); $dq->execute(null, Doctrine::HYDRATE_ARRAY); Shineisp_Commons_Utilities::sendEmailTemplate(null, 'cron', array('cronjob' => 'Check Services'), null, null, null, null, null, Settings::findbyParam('cron_notify')); } catch (Exception $e) { Shineisp_Commons_Utilities::logs($e->getMessage(), "cron.log"); return false; } return true; }
/** * Send the email profile to the user */ public function sendMail($task) { $ISP = ISP::getByCustomerId($task['customer_id']); if (!$ISP || !isset($ISP['isp_id']) || !is_numeric($ISP['isp_id'])) { // ISP not found, can't send mail return false; } // Get the service details $service = OrdersItems::getAllInfo($task['orderitem_id']); // If the setup has been written by the task action then ... if (!empty($service['setup'])) { $setup = json_decode($service['setup'], true); // Get the service/product name $productname = !empty($service['Products']['ProductsData'][0]['name']) ? $service['Products']['ProductsData'][0]['name'] : ""; $welcome_mail = !empty($service['Products']['welcome_mail_id']) && intval($service['Products']['welcome_mail_id']) > 0 ? intval($service['Products']['welcome_mail_id']) : 'new_hosting'; // new_hosting = fallback to old method if no template is set // Check if the customer is present in the service and if there is a welcome_mail set for the bought product if (!empty($service['Orders']['Customers'])) { // Getting the customer $customer = $service['Orders']['Customers']; $strSetup = ""; foreach ($setup as $section => $details) { $strSetup .= strtoupper($section) . "<hr/>"; foreach ($details as $label => $detail) { $strSetup .= "{$label}: " . $detail . "<br/>"; } $strSetup .= "<br/>"; } Shineisp_Commons_Utilities::sendEmailTemplate($ISP['email'], $welcome_mail, array('setup' => $strSetup, 'fullname' => $customer['firstname'] . " " . $customer['lastname'], 'hostingplan' => $productname, 'controlpanel' => $ISP['website'] . ":8080", 'signature' => $ISP['company']), null, null, null, $ISP, $customer['language_id']); } } }
public function resetpwdAction() { $request = $this->getRequest(); $resetKey = $request->getParam('id'); $registry = Shineisp_Registry::getInstance(); $translator = $registry->Zend_Translate; $customer = Customers::getCustomerByResetKey($resetKey); if ($customer) { $newPwd = Shineisp_Commons_Utilities::GenerateRandomPassword(); try { // Update the record Customers::setCustomerPassword($customer[0]['customer_id'], $newPwd); // Force expire of reset link Customers::deleteResetPasswordKey($customer[0]['customer_id']); } catch (Exception $e) { echo $e->getMessage(); die; } $customer[0]['password'] = $newPwd; // Getting the email template Shineisp_Commons_Utilities::sendEmailTemplate($customer[0]['email'], 'password_new', array('fullname' => $customer[0]['lastname'], 'email' => $customer[0]['email'], ':shineisp:' => $customer, 'password' => $newPwd), null, null, null, null, $customer[0]['language_id']); $this->view->mextype = "success"; $this->view->mex = $translator->translate('Email sent'); } else { $this->view->mextype = "alert"; $this->view->mex = $translator->translate('An error occurred while setting your password. Please try again.'); } return $this->_helper->viewRenderer('password'); }
/** * Send the welcome email to the selected user and reset the password * @param integer $customerid * @return Boolean */ public static function welcome_mail($customerid, $passwd = "") { $data = self::getAllInfo($customerid); $isp = Isp::getActiveISP(); // Reset password if (empty($passwd)) { $passwd = Shineisp_Commons_Utilities::GenerateRandomPassword(); self::reset_password($customerid, $passwd); } Shineisp_Commons_Utilities::sendEmailTemplate($data['email'], 'account_new', array('storename' => $isp['company'], 'website' => $isp['website'], 'email' => $data['email'], 'fullname' => $data['fullname'], 'signature' => $isp['company'], 'password' => $passwd), null, null, null, null, $data['language_id']); }
/** * Send a message using a template * * @param string $tpl Name of the template without the extension * @param string $to Email address * @param array $placeholders */ public static function sendMessage($tpl, $to, array $placeholders, $language_id = null) { Shineisp_Commons_Utilities::sendEmailTemplate($to, $tpl, $placeholders, null, null, null, null, $language_id); return true; }
/** * Send the email as renew confirm. * * * @param $domain_id * @return void */ public static function sendCreateConfirm($domain_id) { if (is_numeric($domain_id)) { $domain = self::getAllInfo($domain_id, null, "domain_id, customer_id, CONCAT(c.firstname, ' ', c.lastname) as fullname, c.language_id as language_id, c.email as email, CONCAT(d.domain, '.', d.tld) as domain", true); if (!empty($domain[0])) { Shineisp_Commons_Utilities::sendEmailTemplate($domain[0]['email'], 'domain_created', array(':shineisp:' => $domain), null, null, null, null, $domain['language_id']); } } }
/** * Process the response of the banks gateways * * @return void */ public function responseAction() { $request = $this->getRequest(); $response = $request->getParams(); if (!empty($response['custom']) && is_numeric(trim($response['custom']))) { $isp = Shineisp_Registry::get('ISP'); // Orderid back from the bank $order_id = trim($response['custom']); // Getting the md5 value in order to match with the class name. $classrequest = $request->gateway; // Get the bank selected using the MD5 code $bank = Banks::findbyMD5($classrequest); if (!empty($bank[0]['classname'])) { if (!empty($bank[0]['classname']) && class_exists($bank[0]['classname'])) { $class = $bank[0]['classname']; $payment = new $class($order_id); // Check if the method "Response" exists in the Payment class and send all the bank information to the payment module if (method_exists($class, "Response")) { $OrderID = $payment->Response($response); } else { $OrderID = false; } } } // Check if the OrderID is a number because it // means that the order has been executed correctly if (is_numeric($OrderID)) { // Sending an email to the customer and the administrator with the order details. $order = Orders::getAllInfo($OrderID, null, true); Shineisp_Commons_Utilities::sendEmailTemplate($order[0]['Customers']['email'], 'order_confirm', array('fullname' => $order[0]['Customers']['fullname'], 'orderid' => $OrderID, 'order' => $order), null, null, null, null, $order[0]['Customers']['language_id']); // Redirect the user in the The task requested has been executed successfully. page $this->_helper->redirector('list', 'orders', 'default', array('mex' => 'The task requested has been executed successfully.', 'status' => 'success')); } } $this->_helper->redirector('list', 'orders', 'default', array('mex' => 'There was a problem during the payment process.', 'status' => 'danger')); }
public static function sendInvoice($invoiceid, $urlEmail = "") { if (is_numeric($invoiceid)) { $invoice = self::getAllInfo($invoiceid, null, true); if (!empty($invoice[0])) { $invoiceNum = $invoice[0]['number']; $orderid = $invoice[0]['order_id']; $customerid = $invoice[0]['customer_id']; } else { return false; } $fastlink = self::getFastlinksInvoice($invoiceid, $orderid, $customerid); $order = Orders::getAllInfo($orderid, null, true); //if customer comes from reseller if ($order[0]['Customers']['parent_id']) { $invoice_dest = Customers::getAllInfo($order[0]['Customers']['parent_id']); $customer = $invoice_dest['firstname'] . " " . $invoice_dest['lastname']; $customer .= !empty($invoice_dest['company']) ? " - " . $invoice_dest['company'] : ""; $customer_email = $invoice_dest['email']; $language_id = $invoice_dest['language_id']; } else { $customer = $order[0]['Customers']['firstname'] . " " . $order[0]['Customers']['lastname']; $customer .= !empty($order[0]['Customers']['company']) ? " - " . $order[0]['Customers']['company'] : ""; $customer_email = Contacts::getEmails($customerid); $language_id = $order[0]['Customers']['language_id']; } $email = $order[0]['Isp']['email']; $signature = $order[0]['Isp']['company']; if ($urlEmail == "") { $url = "http://" . $_SERVER['HTTP_HOST'] . "/index/link/id/" . $fastlink; } else { $url = $urlEmail; } $date = explode("-", $order[0]['order_date']); Shineisp_Commons_Utilities::sendEmailTemplate($customer_email, 'new_invoice', array('orderid' => $order[0]['order_number'], 'invoiceid' => sprintf("%03s", $invoiceNum) . "/" . $date[0], 'fullname' => $customer, 'email' => $email, 'url' => $url, ':shineisp:' => $order[0]['Customers'], 'conditions' => strip_tags(Settings::findbyParam('conditions'))), null, null, null, null, $language_id); return true; } return false; }
/** * Send ticket by email * * @param integer $id * @param boolean $isTicket * @param string $attachment */ public static function send($id, $isTicket = true, $attachment = null) { $isp = Isp::getActiveISP(); $placeholders = array(); $customer_url = ""; $admin_url = ""; if ($isTicket) { $ticket = self::getAllInfo($id, null, true); $customer = $ticket[0]['Customers']; $operator = AdminUser::getAllInfo($ticket[0]['user_id']); } else { $ticket = TicketsNotes::getAllInfo($id); $customer = $ticket[0]['Tickets']['Customers']; $operator = AdminUser::getAllInfo($ticket[0]['Tickets']['user_id']); } if (!empty($ticket[0])) { if ($isp) { $ispmail = explode("@", $isp['email']); $retval = Shineisp_Commons_Utilities::getEmailTemplate('ticket_message'); if ($retval) { $s = $retval['subject']; $ticketid = $ticket[0]['ticket_id']; $in_reply_to = md5($ticketid); $ispmail = "noreply@" . $ispmail[1]; $rec = Fastlinks::findlinks($ticketid, $customer['customer_id'], 'tickets'); if (!empty($rec[0]['code'])) { $customer_url = "http://" . $_SERVER['HTTP_HOST'] . "/index/link/id/" . $rec[0]['code']; $admin_url = "http://" . $_SERVER['HTTP_HOST'] . "/admin/login/link/id/" . $rec[0]['code']; } // Check the attachments if (!empty($attachment) && file_exists(PUBLIC_PATH . $attachment)) { $attachment = PUBLIC_PATH . $attachment; } if ($isTicket) { $placeholders['subject'] = $ticket[0]['subject']; $placeholders['description'] = $ticket[0]['description']; $placeholders['date_open'] = Shineisp_Commons_Utilities::formatDateOut($ticket[0]['date_open']); $placeholders['status'] = $ticket[0]['Statuses']['status']; } else { $placeholders['subject'] = $ticket[0]['Tickets']['subject']; $placeholders['description'] = $ticket[0]['note']; $placeholders['date_open'] = Shineisp_Commons_Utilities::formatDateOut($ticket[0]['Tickets']['date_open']); $placeholders['status'] = $ticket[0]['Tickets']['Statuses']['status']; } $placeholders['customer'] = $customer['firstname'] . " " . $customer['lastname'] . " " . $customer['company']; $placeholders['link'] = $customer_url; $placeholders['company'] = $isp['company']; $placeholders['issue_number'] = $ticketid; $placeholders['operator'] = $operator['lastname'] . " " . $operator['firstname']; // Send a message to the customer Shineisp_Commons_Utilities::sendEmailTemplate(Contacts::getEmails($customer['customer_id']), 'ticket_message', $placeholders, $in_reply_to, $attachment, null, $isp, $customer['language_id']); // Update the link for the administrator email $placeholders['link'] = $admin_url . "/keypass/" . Shineisp_Commons_Hasher::hash_string($operator['email']); Shineisp_Commons_Utilities::sendEmailTemplate($isp['email'], 'ticket_message', $placeholders, $in_reply_to, $attachment, null, $isp); return true; } } } return false; }