Example #1
0
 public function display()
 {
     if (Session::get('isLoggedIn')) {
         $user_name = $this->params->values('username');
         $user_password = $this->params->values('password');
         return $user_name;
         echo $user_name;
         echo json_encode($user_name);
         echo json_encode($user_pass);
         return $user_pass;
         echo $user_pass;
         //$imp = implode($user_password);
         $imp = implode($user_password);
         $encrypt = md5($imp);
         $exp = explode(" ", $encrypt);
         $usr = $this->userManager->getUserProfile($user_name, $user_password);
         //echo $user_password . " " . $user_name;
         echo json_encode($usr);
         return $this;
     } else {
         Messages::addMessage("warning", "'user_name' and/or 'password' parameters missing.");
         return null;
         return $usr;
     }
 }
Example #2
0
 public function login()
 {
     if (Session::get('isLoggedIn')) {
         Messages::addMessage("info", "You are already logged in.");
         return null;
     } else {
         $user_name = $this->params->getValue('username');
         $user_password = $this->params->getValue('password');
         if ($user_name != null && $user_password != null) {
             $usr = $this->userManager->findUser($user_name, $user_password);
             //echo $usr;
             if ($usr != null) {
                 return $usr;
                 Messages::addMessage("info", "You're already logged in");
             } else {
                 Messages::addMessage("info", "Log in user and/or password incorrect.");
                 return null;
             }
         } else {
             Messages::addMessage("warning", "'user_name' and/or 'password' parameters missing.");
             return null;
             //return $usr;
         }
     }
 }
 public function customerCheckout()
 {
     if (Session::get('isLoggedIn')) {
         Messages::addMessage("warning", "Not customer");
         return;
     } else {
         $response = array();
         // params have to be there
         //$user_name = $this->params->getValue('user_name');
         $custFirstName = $this->params->getValue('firstname');
         $custLastName = $this->params->getValue('lastname');
         $custPhone = $this->params->getValue('phone');
         $custEmail = $this->params->getValue('email');
         $custAddress = $this->params->getValue('address');
         $custCity = $this->params->getValue('city');
         $cartID = $_SESSION['cart_id'];
         if ($custFirstName != null && $custLastName != null && $custPhone != null && $custEmail != null && $custAddress != null && $custCity != null && $cartID != null) {
             //if($custFirstName != null) {
             $cust = $this->userManager->createCustomer($custFirstName, $custLastName, $custPhone, $custEmail, $custAddress, $custCity, $cartID);
             return $cust;
         } else {
             Messages::addMessage("warning", " parameters missing.");
             return null;
         }
     }
 }
Example #4
0
 public function register()
 {
     $response = array();
     // params have to be there
     $usr = $this->params->getValue('username');
     $pwd = $this->params->getValue('password');
     $encrypt = md5($pwd);
     $fname = $this->params->getValue('firstname');
     $lname = $this->params->getValue('lastname');
     $email = $this->params->getValue('email');
     echo $usr . " " . $pwd . " " . $fname . " " . $lname . " " . $email . " " . $encrypt;
     if ($usr != null && $pwd != null && $fname != null && $lname != null && $email != null) {
         // check if user name and password are correct
         $user = $this->userManager->addUser($fname, $lname, $usr, $encrypt, $email);
         if ($user != null) {
             // log user in
             Session::set("username", $user['username']);
             Session::set("id", $user['ID']);
             Session::set("isLoggedIn", true);
             return $user;
             return $user['ID'];
             return $encrypt;
             //return $response;
         } else {
             Messages::addMessage("warning", "'user_name' and/or 'password' parameters missing.");
             return null;
             return $usr;
         }
     }
 }
Example #5
0
 public function login()
 {
     if (Session::get('isLoggedIn')) {
         Messages::addMessage("info", "You are already logged in.");
         return;
     } else {
         $response = array();
         // params have to be there
         $user_name = $this->params->getValue('user_name');
         $user_password = $this->params->getValue('password');
         if ($user_name != null && $user_password != null) {
             // check if user name and password are correct
             $usr = $this->userManager->findUser($user_name, $user_password);
             if ($usr != null) {
                 // log user in
                 Session::set("user_name", $usr['user_name']);
                 Session::set("id", $usr['ID']);
                 Session::set("isLoggedIn", true);
                 return $usr;
             } else {
                 Messages::addMessage("info", "Log in user and/or password incorrect.");
                 return null;
             }
         } else {
             Messages::addMessage("warning", "'user_name' and/or 'password' parameters missing.");
             return null;
         }
     }
 }
Example #6
0
 public function logout()
 {
     if (Session::get('isLoggedIn')) {
         Session::closeSession();
         Messages::addMessage("info", "Successfully logged out.");
         return true;
     } else {
         Messages::addMessage("warning", "'isLoggedIn' parameter not found.");
         return false;
     }
 }
 public function updateProducts()
 {
     $response = array();
     $sku = $this->params->getValue('sku');
     $desc = $this->params->getValue('desc');
     $price = $this->params->getValue('price');
     $qty = $this->params->getValue('qty');
     if ($sku != null && $desc != null && $price != null && $qty != null) {
         $product = $this->ProductManager->updateProducts($sku, $desc, $price, $qty);
         return $product;
     } else {
         Messages::addMessage("warning", "parameters missing.");
         return null;
     }
 }
 /**
  * @param string $host
  * @param string $username
  * @param string $password
  * @param string $db
  * @param int $port
  */
 public function __construct()
 {
     if (!isset($port)) {
         $port = ini_get('mysqli.default_port');
     }
     if (file_exists("config.php")) {
         include "config.php";
     } else {
         Messages::addMessage("Config file does not exist", Messages::ERRO);
         return;
     }
     $this->_mysqli = new mysqli($db['db_host'], $db['db_user'], $db['db_pass'], $db['db_base'], $port);
     $this->_mysqli->set_charset('utf8');
     self::$_instance = $this;
 }
 public function getProfile()
 {
     if (isset($_POST['method'])) {
         $profile = $this->userManager->getUserProfile();
         if ($profile != null) {
             return $profile;
         } else {
             Messages::addMessage("info", "No user of that name.");
             return null;
         }
     } else {
     }
     // otherwise
     return null;
 }
 public function getProfile()
 {
     if (Session::get('isLoggedIn') && Session::get('user_name')) {
         $profile = $this->userManager->getUserProfile(Session::get('user_name'));
         if ($profile != null) {
             // found a user by that name
             return $profile;
         } else {
             // this shouldn't happen since this is not a log in - this is a
             // profile request. Would be good to report this here as well
             // in a log file
             Messages::addMessage("info", "No user of that name.");
             return null;
         }
     } else {
         // most likely session timed out.
     }
     // otherwise
     return null;
 }
Example #11
0
 public function logout()
 {
     if (Session::get('isLoggedIn')) {
         Session::closeSession();
         Messages::addMessage("info", "Successfully logged out.");
         return true;
         /*
                     $profile = $this->userManager->getUserProfile(Session::get('user_name'));
         
                     if($profile != null) {
                         // log user out
                         Session::closeSession();
                         return true;
         
                     } else {
                         Messages::addMessage("warning", "No user of that name. Logout not performed.");
                     }
         */
     } else {
         Messages::addMessage("warning", "'isLoggedIn' parameter not found.");
         return false;
     }
 }
 public function getProfile()
 {
     // for true/false values, see:
     // http://php.net/manual/en/types.comparisons.php
     if (Session::get('isLoggedIn') && Session::get('username')) {
         // here's where we call the user manager which will talk to
         // the DB for us
         $profile = $this->userManager->getUserProfile(Session::get('username'));
         if ($profile != null) {
             // found a user by that name
             return $profile;
         } else {
             // this shouldn't happen since this is not a log in - this is a
             // profile request. Would be good to report this here as well
             // in a log file
             Messages::addMessage("info", "No user of that name.");
             return null;
         }
     } else {
         // most likely session timed out.
     }
     // otherwise
     return null;
 }
Example #13
0
 public function getTransactionID($sql)
 {
     try {
         if ($this->conn != null) {
             $this->conn->beginTransaction();
             $this->conn->exec($sql);
             // the id of the last inserted row into a table
             $lastID = $this->conn->lastInsertId();
             $this->conn->commit();
             return $lastID;
         } else {
             // connection failed, add that to the messages
             Messages::addMessage("error", "DBConnector 'getTransactionID' failure, PDO Connection was null.");
             return -1;
         }
         return -1;
     } catch (PDOException $e) {
         $this->conn->rollBack();
         Messages::addMessage("error", "DBConnector 'getTransactionID' failure, " . $e->getMessage());
     }
 }
Example #14
0
 /**
  * processAction
  * Update the record previously selected
  * @return unknown_type
  */
 public function processAction()
 {
     $isp = Shineisp_Registry::get('ISP');
     $request = $this->getRequest();
     // Check if we have a POST request
     if (!$request->isPost()) {
         return $this->_helper->redirector('index');
     }
     // Get our form and validate it
     $form = $this->getForm('/admin/orders/process');
     if (!$form->isValid($request->getPost())) {
         // Invalid entries
         $this->view->form = $form;
         $this->view->title = $this->translator->translate("Order process");
         $this->view->description = $this->translator->translate("Check the information posted and then click on the save button.");
         return $this->_helper->viewRenderer('applicantform');
         // re-render the login form
     }
     // Get the values posted
     $params = $form->getValues();
     // Get the id
     $id = $this->getRequest()->getParam('order_id');
     // Save the message note
     if (!empty($params['note'])) {
         // If the order is commentable then go on
         if (Orders::IsCommentable($id)) {
             $order = Orders::getAllInfo($id, null, true);
             $link = Fastlinks::findlinks($id, $this->customer['customer_id'], 'orders');
             if (!empty($link[0]['code'])) {
                 $code = $link[0]['code'];
             } else {
                 $code = Fastlinks::CreateFastlink('orders', 'edit', json_encode(array('id' => $id)), 'orders', $id, $this->customer['customer_id']);
             }
             // Save the message in the database
             Messages::addMessage($params['note'], $this->customer['customer_id'], null, $id);
             $in_reply_to = md5($id);
             $placeholder['messagetype'] = $this->translator->translate('Order');
             $placeholders['subject'] = sprintf("%03s", $id) . " - " . Shineisp_Commons_Utilities::formatDateOut($order[0]['order_date']);
             $placeholders['fullname'] = $this->customer['firstname'] . " " . $this->customer['lastname'];
             $placeholders['orderid'] = $placeholders['subject'];
             $placeholders['conditions'] = Settings::findbyParam('conditions');
             $placeholders['url'] = "http://" . $_SERVER['HTTP_HOST'] . "/index/link/id/" . $code;
             // Send a message to the customer
             Shineisp_Commons_Utilities::sendEmailTemplate($order[0]['Customers']['email'], 'order_message', $placeholders, $in_reply_to, null, null, $isp, $order[0]['Customers']['language_id']);
             $placeholders['url'] = "http://" . $_SERVER['HTTP_HOST'] . "/admin/login/link/id/{$code}/keypass/" . Shineisp_Commons_Hasher::hash_string($isp->email);
             $placeholders['message'] = $params['note'];
             // Send a message to the administrator
             Shineisp_Commons_Utilities::sendEmailTemplate($isp->email, 'order_message_admin', $placeholders, $in_reply_to);
         }
     }
     $this->_helper->redirector('index', 'orders', 'default', array('mex' => 'The requested task has been completed successfully', 'status' => 'success'));
 }
Example #15
0
 /**
  * processAction
  * Update the record previously selected
  * @return unknown_type
  */
 public function processAction()
 {
     $request = $this->getRequest();
     // Check if we have a POST request
     if (!$request->isPost()) {
         return $this->_helper->redirector('index');
     }
     // Get our form and validate it
     $form = $this->getForm('/admin/service/process');
     if (!$form->isValid($request->getPost())) {
         // Invalid entries
         $this->view->form = $form;
         $this->view->title = $this->translator->translate("Service");
         $this->view->description = $this->translator->translate("Check all the fields and click on the save button");
         return $this->_helper->viewRenderer('customform');
         // re-render the login form
     }
     // Get the values posted
     $params = $form->getValues();
     // Get the id
     $id = $this->getRequest()->getParam('detail_id');
     if (is_numeric($id)) {
         OrdersItems::setAutorenew($id, $params['autorenew']);
     }
     // Save the message note
     if (!empty($params['message'])) {
         Messages::addMessage($params['message'], $this->customer['customer_id'], null, null, $id);
         $isp = Shineisp_Registry::get('ISP');
         $placeholder['fullname'] = $this->customer['firstname'] . " " . $this->customer['lastname'];
         $placeholder['messagetype'] = $this->translator->translate('Order Details');
         $placeholder['message'] = $params['message'];
         Messages::sendMessage("message_new", $this->customer['email'], $placeholder);
         Messages::sendMessage("message_admin", $isp->email, $placeholder);
     }
     $this->_helper->redirector('edit', 'services', 'default', array('id' => $id, 'mex' => 'The task requested has been executed successfully.', 'status' => 'success'));
 }
Example #16
0
 public function query($sql, $params = array())
 {
     try {
         if ($this->conn != null) {
             $statement = $this->conn->prepare($sql);
             $statement->execute($params);
             $rows = $statement->fetchAll(PDO::FETCH_ASSOC);
             return $rows;
         } else {
             // connection failed, add that to the messages
             Messages::addMessage("error", "DBConnector 'query' failure, PDO Connection was null.");
         }
         return array();
     } catch (PDOException $e) {
         Messages::addMessage("error", "DBConnector 'query' failure, " . $e->getMessage());
     }
 }
Example #17
0
 /**
  * Create and Retrieve the OrderID
  * @param integer $id
  * @return Orders
  */
 public static function create($customerId, $statusId = "", $note = "")
 {
     $customer = Customers::getAllInfo($customerId);
     $isp_id = $customer['isp_id'];
     if (self::$order) {
         return self::$order;
     }
     if (is_numeric($customerId)) {
         $order = new Orders();
         // Execute a custom event
         self::events()->trigger('orders_create_before', "Orders", array('order' => $order, 'customerid' => $customerId));
         $order['customer_id'] = $customerId;
         $order['order_date'] = date('Y-m-d H:i:s');
         $order['expiring_date'] = date('Y-m-d', strtotime('30 days', strtotime($order['order_date'])));
         $order['isp_id'] = $isp_id;
         $order['status_id'] = is_numeric($statusId) ? $statusId : Statuses::id("tobepaid", "orders");
         $order['uuid'] = Shineisp_Commons_Uuid::generate();
         // Save the data
         $order->save();
         // Save order number
         $order->order_number = self::formatOrderId($order->order_id);
         // Save the order
         if ($order->trySave()) {
             // Log status change
             self::logStatusChange($order->order_id, $order->status_id);
             // Assign the order var to the static var
             self::$order = $order;
             // Create the fastlink for the order
             $fastlink = Fastlinks::CreateFastlink('orders', 'edit', json_encode(array('id' => $order['order_id'])), 'orders', $order['order_id'], $customerId);
             // Add a message within the order
             Messages::addMessage($note, $customerId, null, $order['order_id']);
             // Execute a custom event
             self::events()->trigger('orders_create_after', "Orders", array('order' => $order, 'fastlink' => $fastlink));
             // Return the order object var
             return self::$order;
         } else {
             throw new Exception('There was a problem when I try to create the order', 1003);
         }
     } else {
         throw new Exception('Customer ID has been not found', 1001);
     }
     return null;
 }
initialize($basePath, 'home');
if (!isTraining()) {
    echo ErrorSupportHelper::getJson('4002');
    exit;
}
$telegram = BotHelper::getTelegram();
try {
    $updates = $telegram->getUpdates();
} catch (\Telegram\Bot\Exceptions\TelegramResponseException $e) {
    put($e->getMessage());
    return;
}
$result = [];
$messages = new Messages();
foreach ($updates as $update) {
    $message = MessageHelper::makeMessageByTelegramUpdate($update);
    // 從 updates 來的資料會有許多重覆資料
    // 該確認之後再寫入
    $existMessage = $messages->getMessageByMessageId($message->getMessageId());
    if ($existMessage) {
        continue;
    }
    $id = $messages->addMessage($message);
    $result[] = [$message->getMessageId(), $id];
    // execute command controller
    if ($id) {
        $controller = new \CommandModule\Enter();
        $controller->home($id);
    }
}
echo json_encode($result, true);
Example #19
0
 /**
  * processAction
  * Update the record previously selected
  * @return unknown_type
  */
 public function processAction()
 {
     $request = $this->getRequest();
     try {
         // Check if we have a POST request
         if (!$request->isPost()) {
             return $this->_helper->redirector('index');
         }
         // Get our form and validate it
         $form = $this->getForm('/admin/domains/process');
         if (!$form->isValid($request->getPost())) {
             // Invalid entries
             $this->view->form = $form;
             $this->view->title = $this->translator->translate("Domain Process");
             $this->view->description = $this->translator->translate("Check all the information posted before saving them.");
             return $this->_helper->viewRenderer('customform');
             // re-render the login form
         }
         // Get the values posted
         $params = $form->getValues();
         // Get the id
         $id = $params['domain_id'];
         if (!empty($params['dnsform']['target']) && !empty($params['dnsform']['zones'])) {
             Dns_Zones::addDnsZone($id, $params['dnsform']['subdomain'], $params['dnsform']['target'], $params['dnsform']['zones']);
         }
         // Save the message note
         if (!empty($params['note'])) {
             Messages::addMessage($params['note'], $this->customer['customer_id'], $id);
             $isp = Shineisp_Registry::get('ISP');
             $placeholder['fullname'] = $this->customer['firstname'] . " " . $this->customer['lastname'];
             $placeholder['domain'] = domains::getDomainName($id);
             $placeholder['message'] = $params['note'];
             $placeholder['messagetype'] = $this->translator->translate('Domain');
             Messages::sendMessage("message_new", $this->customer['email'], $placeholder);
             Messages::sendMessage("message_admin", $isp->email, $placeholder);
         }
         Domains::setAuthInfo($id, $params['authinfocode']);
         Domains::setAutorenew($id, $params['autorenew']);
         $this->_helper->redirector('edit', 'domains', 'default', array('id' => $id, 'mex' => 'The task requested has been executed successfully.', 'status' => 'success'));
     } catch (Exception $e) {
         die($e->getMessage());
     }
 }
Example #20
0
 /**
  * Render the method of payment gateway form
  */
 public function redirectAction()
 {
     $session = new Zend_Session_Namespace('Default');
     if (empty($session->cart) || $session->cart->isEmpty()) {
         $this->_helper->redirector('index', 'index', 'default', array('mex' => "Cart is empty"));
     }
     // get the payment method selected
     $payment = $this->getRequest()->getParam('payment');
     // get the payment gateway information
     if (!empty($payment)) {
         $gateway = Banks::getAllInfo($payment, "*", true);
         // check if the payment gateway exists
         if (!empty($gateway[0]['classname']) && class_exists($gateway[0]['classname'])) {
             // update the cart
             $session->cart->update();
             // create the order
             $order = $session->cart->createOrder();
             if ($order) {
                 if ($this->getRequest()->getParam('note')) {
                     Messages::addMessage($this->getRequest()->getParam('note'), $session->cart->getCustomerId(), null, $session->cart->getOrderid());
                 }
                 // clear the cart
                 $session->cart->clearAll();
                 $class = $gateway[0]['classname'];
                 $payment = new $class($order->order_id);
                 // create the form payment gateway
                 $form = $payment->setUrlOk($_SERVER['HTTP_HOST'] . "/orders/response/gateway/" . md5($gateway[0]['classname']))->setUrlKo($_SERVER['HTTP_HOST'] . "/orders/response/" . md5($gateway[0]['classname']))->setUrlCallback($_SERVER['HTTP_HOST'] . "/common/callback/gateway/" . md5($gateway[0]['classname']))->setRedirect(true)->setFormHidden(true)->CreateForm();
                 // push the payment gateway html form in the view
                 $this->view->name = $form['name'];
                 $this->view->html = $form['html'];
             } else {
                 $this->_helper->redirector('index', 'index', 'default', array('mex' => "The order has been not created, please contact the administrator"));
             }
         }
     }
 }