public function Login() { if (isset($_REQUEST['LoginId'])) { $user = $this->loadModel('OpenSms_Model_User', [0 => $_REQUEST['LoginId'], 1 => $_REQUEST['Password']]); if ($user->IsValidated) { $_SESSION['loginId'] = $user->LoginId; $_SESSION['role'] = $user->Role; if (isset($_REQUEST['callback'])) { echo $this->jsonp(array('error' => FALSE, 'message' => 'success', 'balance' => $user->Balance, 'role' => $user->Role)); exit; } OpenSms::redirectToAction('index', 'dashboard', 'dashboard'); } else { $errorMsg = 'Invalid Credential'; if (isset($_REQUEST['callback'])) { echo jsonp(array('error' => TRUE, 'message' => $errorMsg, 'balance' => 0)); exit; } //OpenSms::redirectToAction('index', 'dashboard', 'dashboard'); } } else { if (isset($_REQUEST['callback'])) { echo $this->jsonp(array('error' => TRUE, 'message' => 'Invalid request param', 'balance' => 0)); exit; } //die('Invalid request param'); } $this->data['pageTitle'] = 'Login | ' . OpenSms::getSystemSetting(OpenSms::SITE_NAME); $this->renderTemplate(); }
public function Index() { $this->data['user'] = $this->checkLogin(); $this->data['transactions'] = $this->data['user']->GetTransactions(); $this->data['pageTitle'] = 'My Transactions | ' . OpenSms::getSystemSetting(OpenSms::SITE_NAME); $this->renderTemplate(); }
public function Detail($key) { $this->data['user'] = $this->checkLogin(OpenSms::OPEN_ROLE_ADMIN); $this->data['pageTitle'] = 'Manage Theme | ' . OpenSms::getSystemSetting(OpenSms::SITE_NAME); $this->data['theme'] = new OpenSms_Model_System_Theme($key); $this->renderTemplate(); }
public function index($_page = 0) { $user = $this->checkLogin(); //########==paging==########// $rec_limit = 50; $count = OpenSms::callModelStaticMethod('OpenSms_Model_BulkSms', 'GetBulkSMSCount', [0 => $user->LoginId]); $no = $count / $rec_limit; if ($count % $rec_limit == 0) { $no -= 1; } $link = '<ul class="pagination">'; for ($i = 0; $i <= $no; $i++) { if ($i == $_page - 1 || $i == 0 && $_page == 0) { $link .= '<li class="active"><a href="#">Page ' . ($i + 1) . '</a></li>'; } else { $link .= '<li><a href="' . OpenSms::getActionUrl('index', 'sent', 'sms', [0 => $i + 1]) . '">Page ' . ($i + 1) . '</a></li>'; } } $link .= '</ul>'; $this->data['link'] = $link; if ($_page != 0) { $page = stripslashes($_page) - 1; $offset = $page * $rec_limit; } else { $page = 0; $offset = 0; } $this->data['bulkSmsList'] = OpenSms::callModelStaticMethod('OpenSms_Model_BulkSms', 'GetBulkSMS', [0 => $user->LoginId, 1 => $offset, 2 => $rec_limit]); $this->data['pageTitle'] = 'Sent Messages | ' . OpenSms::getSystemSetting(OpenSms::SITE_NAME); $this->data['user'] = $user; $this->renderTemplate(); }
public function Detail($key) { $this->data['user'] = $this->checkLogin(OpenSms::OPEN_ROLE_ADMIN); $this->data['module'] = OpenSms_Model_System_Module::getModule($key); $this->data['pageTitle'] = 'Module Detail | ' . OpenSms::getSystemSetting(OpenSms::SITE_NAME); //var_dump($this->data['module']); die(); $this->renderTemplate(); }
public function Index() { $this->getCurrentUri(); $user = $this->checkLogin(); $this->data['user'] = $user; $this->data['transactions'] = $user->GetTransactions(); $this->data['pageTitle'] = 'Dashboard | ' . OpenSms::getSystemSetting(OpenSms::SITE_NAME); $this->renderTemplate('body'); }
public function Manage($id) { $this->data['user'] = $this->checkLogin(); $this->data['transaction'] = OpenSms::loadModel('OpenSms_Model_Transaction', [0 => $id]); $this->data['pageTitle'] = 'Manage Transaction'; $this->data['returnUrl'] = isset($_REQUEST['returnUrl']) ? $_REQUEST['returnUrl'] : ''; $this->data['payments'] = OpenSms::getPaymentMethods(); $this->data['pageTitle'] = 'Manage Transaction | ' . OpenSms::getSystemSetting(OpenSms::SITE_NAME); $this->renderTemplate(); }
public function manage($_loginId) { $this->data['user'] = $this->checkLogin(OpenSms::OPEN_ROLE_ADMIN); $this->data['pageTitle'] = 'Manage user | ' . OpenSms::getSystemSetting(OpenSms::SITE_NAME); if (!empty($_loginId)) { $this->data['curUser'] = $this->loadModel('OpenSms_Model_User', [0 => $_loginId]); } if (!isset($this->data['curUser']) || !isset($this->data['curUser']->LoginId)) { $this->setError('No user to show', 'manage_users'); $this->data['curUser'] = $this->loadModel('OpenSms_Model_User'); } $this->data['transactions'] = $this->data['curUser']->GetTransactions(); $this->data['payments'] = OpenSms::getPaymentMethods(); $this->renderTemplate(); }
public static function getClassDb() { if (self::$db != NULL) { return self::$db; } // set the (optional) options of the PDO connection. in this case, we set the fetch mode to // "objects", which means all results will be objects, like this: $result->user_name ! // For example, fetch mode FETCH_ASSOC would return results like this: $result["user_name] ! // @see http://www.php.net/manual/en/pdostatement.fetch.php $options = array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING); // generate a database connection, using the PDO connector // @see http://net.tutsplus.com/tutorials/php/why-you-should-be-using-phps-pdo-for-database-access/ self::$db = new PDO(OpenSms::getSystemSetting(OpenSms::DB_TYPE) . ':host=' . OpenSms::getSystemSetting(OpenSms::DB_HOST) . ';dbname=' . OpenSms::getSystemSetting(OpenSms::DB_NAME), OpenSms::getSystemSetting(OpenSms::DB_USERNAME), OpenSms::getSystemSetting(OpenSms::DB_PASSWORD), $options); return self::$db; }
public function Save() { $user = $this->checkLogin(); //create a transaction $trans = $this->loadModel("OpenSms_Model_Transaction"); foreach ($_POST as $key => $value) { $trans->{$key} = $value; } $trans->Unit = $trans->Amount / OpenSms::getSystemSetting(OpenSms::OPEN_PRICE_PER_UNIT); $trans->LoginId = $user->LoginId; //get the selected payment $payment = OpenSms::getPaymentMethod($_POST['PaymentMethod'], true); //var_dump($payment); die(); //set the order status to that of the payment method $trans->Status = $payment->order_status; $trans->Type = OpenSms::OPEN_TRANSACTION_TYPE_CREDIT; //save the order $trans->Save(); //put the transaction in session $_SESSION[OpenSms::LAST_TRANSACTION] = $trans; //make payment $paymentController = new $payment->controller(); $paymentController->{$payment->action}(); }
<?php /** * Created by PhpStorm. * User: Gabriel * Date: 3/20/2015 * Time: 2:03 AM */ ?> <!-- Logo --> <a href="/admin/install" class="logo"><?php echo OpenSms::getSystemSetting(OpenSms::SITE_NAME); ?> </a> <!-- Header Navbar: style can be found in header.less --> <nav class="navbar navbar-static-top" role="navigation"> <!-- Sidebar toggle button--> <a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button"> <span class="sr-only">Toggle navigation</span> </a> <div class="navbar-custom-menu"> <ul class="nav navbar-nav"> <!-- Messages: style can be found in dropdown.less--> <li class="dropdown messages-menu"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> <i class="fa fa-envelope-o"></i> <span class="label label-success">4</span> </a> <ul class="dropdown-menu"> <li class="header">You have 4 messages</li>
public function Send() { $user = $this->checkLogin(); //var_dump($_POST); die(); if (isset($_POST['sendmessage'])) { $hasErro = FALSE; if ($_POST['sender'] == '' || $_POST['message'] == '') { $notification = 'Sender and message cannot be empty'; $hasErro = TRUE; } else { //sending message $recepients = ''; //getting recipiet from the txtbox if (isset($_POST['recipient'])) { $contactInput = preg_split('/(\\r?\\n)+/', trim($_POST['recipient'])); foreach ($contactInput as $ci) { $recepients .= $ci . ','; } } //getting recipient from the uploaded file if (!empty($_FILES['to_file']['name'])) { //chicking file type $allowedTxt = array('txt', 'TXT'); $allowedXls = array('xls', 'XLS'); $filename = $_FILES['to_file']['name']; $ext = pathinfo($filename, PATHINFO_EXTENSION); if (in_array($ext, $allowedTxt)) { $fp = fopen($_FILES['to_file']['tmp_name'], 'rb'); while (($line = fgets($fp)) !== false) { if (strlen(trim($line)) > 4) { $f = substr($line, 0, 1); if ($f != '0' && $f != '2') { $line = '0' . $line; } $recepients .= $line . ','; } } } elseif (in_array($ext, $allowedXls)) { //excel sheet require_once 'app/code/opensms/helper/excel_reader2.php'; $data = new Spreadsheet_Excel_Reader($_FILES['to_file']['tmp_name']); for ($i = 0; $i < count($data->sheets); $i++) { if (count($data->sheets[$i]['cells']) > 0) { for ($j = 1; $j <= count($data->sheets[$i]['cells']); $j++) { $num = $data->sheets[$i]['cells'][$j][1]; if (strlen(trim($num)) > 4) { $f = substr($num, 0, 1); if ($f != '0' && $f != '2') { $num = '0' . $num; } $recepients .= $num . ','; } } } } } else { $notification = 'Error! Please upload a text or an excel(xls) file'; $hasErro = TRUE; } } //getting recipient from group if (isset($_POST['groupid']) && trim($_POST['groupid']) != '-1') { $g = $this->loadModel('OpenSms_Model_Group', [0 => $_POST['groupid']]); $recepients .= $g->SerializeContacts(); } //senitizing number $recepients = str_replace(' ', '', trim($recepients)); //take out spcae $recepients = str_replace(PHP_EOL, '', trim($recepients)); //take out new lines $recepients = str_replace('+', '', $recepients); if (substr($recepients, 0, 1) == '0') { $recepients = '234' . substr($recepients, 1); } $recepients = str_replace(',0', ',234', $recepients); //take away the 1st and last comma if (substr($recepients, 0, 1) == ',') { $recepients = '' . substr($recepients, 1); } if (substr($recepients, strlen($recepients) - 1, 1) == ',') { $recepients = '' . substr($recepients, 0, strlen($recepients) - 1); } //balanc check $len = strlen($_POST['message']); $lenPerSMS = $len < 160 ? 160 : 153; $msgNo = $len < $lenPerSMS ? 1 : ($len - $len % $lenPerSMS) / $lenPerSMS; $msgNo = $len > $lenPerSMS && $len % $lenPerSMS != 0 ? $msgNo + 1 : $msgNo; //dskljfsaddlkl mk $notification = ''; $hasErro = FALSE; $count = ceil(count(explode(',', $recepients)) * $msgNo); $avu = $user->Balance * 1; $uneeded = $count * OpenSms::getSystemSetting(OpenSms::OPEN_UNITS_PER_SMS); if ($avu < $uneeded) { $notification = 'Insufficient SMS unit!'; $hasErro = TRUE; } else { if ($count > 0 && !$hasErro) { /* $url = API_URL.'api/SAPI/sendMessage?returnDetails=1&loginId='.API_USERNAME.'&password='******'&senderId='. urlencode($_POST["sender"]).'&message='.urlencode($_POST['message']). '&Recipients='.trim($recepients).'&sendOnDate=2/2/2'; */ $url = OpenSms::getField('Sms_Send_Api')->value; //replace username, password, senderId, message, recipients, sendOnDate $url = str_replace('@username@', OpenSms::getField('Sms_Api_Username')->value, $url); $url = str_replace('@password@', OpenSms::getField('Sms_Api_Password')->value, $url); $url = str_replace('@senderId@', urlencode($_POST["sender"]), $url); $url = str_replace('@message@', urlencode($_POST["message"]), $url); $url = str_replace('@recipients@', trim($recepients), $url); //die($url); //messge scheduling &sendondate=13-04-2014T12:03:20 if (isset($_POST['send_later']) && $_POST['send_later'] == 1) { $y = $_POST['schedule_year']; $mnt = $_POST['schedule_month']; $d = $_POST['schedule_day']; $h = $_POST['schedule_hour']; $m = $_POST['schedule_munite']; $now = new DateTime(); $selectedDateStr = $d . '-' . $mnt . '-' . $y . 'T' . $h . ':' . $m . ':00'; $sendDate = '&sendondate=' . urlencode($selectedDateStr); $url .= $sendDate; $url = str_replace('@sendOnDate@', $sendDate, $url); } else { $url = str_replace('@sendOnDate@', '2/2/2', $url); } //die($url); $xml = file_get_contents($url); //var_dump($xml);die(); //<result>True</result> //1701 //check if message sent and deduct //strpos(strtolower($xml), strtolower(OpenSms::getField('Sms_Api_Success_Keyword')) if (strpos(strtolower($xml), strtolower(OpenSms::getField('Sms_Api_Success_Keyword')->value))) { $user->Balance -= $count * OpenSms::getSystemSetting(OpenSms::OPEN_UNITS_PER_SMS); $user->Save(); $notification = "Message sent"; $bulksSMS = $this->loadModel('OpenSms_Model_BulkSms'); $bulksSMS->LoginId = $user->LoginId; $bulksSMS->Message = $_POST['message']; $bulksSMS->Sender = $_POST['sender']; $bulksSMS->Status = 1701; $bulksSMS->Count = $count; $bulksSMS->Save(); $messages = array(); $nos = explode(',', $recepients); foreach ($nos as $no) { if (empty($no)) { continue; } $message = $this->loadModel('OpenSms_Model_Message'); $message->BulkSMSId = $bulksSMS->Id; $message->Number = $no; $message->Message = $_POST['message']; $message->Sender = $_POST['sender']; $message->RefId = -1; $message->Status = 1701; $messages[] = $message; } $bulksSMS->SaveMessages($messages); } else { $notification = "Error! Message not sent"; } } else { if (!$hasErro) { $notification = 'Please enter at least one number'; } } } } } else { $notification = 'Invalid request param'; $hasErro = TRUE; } if ($hasErro) { $this->setError($notification, 'compose_send'); } else { $this->setNotification($notification, 'compose_send'); } OpenSms::redirectToAction('Index'); }
public function detail($groupId, $_page = 0) { $user = $this->checkLogin(); $group = $this->loadModel('OpenSms_Model_Group', [0 => $groupId]); if ($group->GroupExits == TRUE) { //########==paging==########// $rec_limit = 100; $count = $group->GetContactCount(); $no = $count / $rec_limit; if ($count % $rec_limit == 0) { $no -= 1; } $link = '<ul class="pagination">'; for ($i = 0; $i <= $no; $i++) { if ($i == $_page - 1 || $i == 0 && $_page == 0) { $link .= '<li class="active"><a href="#">Page ' . ($i + 1) . '</a></li>'; } else { $link .= '<li><a href="' . OpenSms::getActionUrl('detail', '*', 'group', ['parameter1' => $groupId, 'parameter2' => $i + 1]) . '">Page ' . ($i + 1) . '</a></li>'; } } $link .= '</ul>'; if ($_page != 0) { $page = stripslashes($_page) - 1; $offset = $page * $rec_limit; } else { $page = 0; $offset = 0; } //\paging if ($rec_limit == 0) { $contacts = $group->GetContacts(); } else { $contacts = $group->GetContacts($offset, $rec_limit); } $this->data['user'] = $user; $this->data['group'] = $group; $this->data['contacts'] = $contacts; $this->data['link'] = $link; } else { $this->setError('Group not found', 'group_detail'); OpenSms::redirectToAction('Index'); } $this->data['pageTitle'] = "Groups | " . $this->data['group']->Name . " -> " . OpenSms::getSystemSetting(OpenSms::SITE_NAME); $this->renderTemplate('body'); }
= <?php echo 1000 * OpenSms::getSystemSetting(OpenSms::OPEN_UNITS_PER_SMS); ?> UNITS <br/> For <?php echo 1000 * OpenSms::getSystemSetting(OpenSms::OPEN_UNITS_PER_SMS) . ' X ' . OpenSms::getSystemSetting(OpenSms::OPEN_PRICE_PER_UNIT); ?> = <?php echo 1000 * OpenSms::getSystemSetting(OpenSms::OPEN_UNITS_PER_SMS) * OpenSms::getSystemSetting(OpenSms::OPEN_PRICE_PER_UNIT); ?> Naira </li> </ol> </div><!-- /.box-body --> </div><!-- /.box --> </div><!--/.col (right) --> </div> </section><!-- /.content --> <!-- global js variable ---> <script> var UNITS_PER_SMS = <?php echo OpenSms::getSystemSetting(OpenSms::OPEN_UNITS_PER_SMS); ?> ; var PRICE_PER_UNIT = <?php echo OpenSms::getSystemSetting(OpenSms::OPEN_PRICE_PER_UNIT); ?> ; </script>
public function Index() { $this->data['pageTitle'] = OpenSms::getSystemSetting(OpenSms::SITE_NAME); $this->renderTemplate(); }
<li class="dropdown user user-menu"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> <img src="<?php echo OpenSms::getSystemSetting(OpenSms::SITE_URL) . (empty($this->data['user']->Image) ? 'app/skin/system/user.jpg' : $this->data['user']->Image); ?> " class="user-image" alt="User Image"/> <span class="hidden-xs"><?php echo $this->data['user']->Name; ?> </span> </a> <ul class="dropdown-menu"> <!-- User image --> <li class="user-header"> <img src="<?php echo OpenSms::getSystemSetting(OpenSms::SITE_URL) . (empty($this->data['user']->Image) ? 'app/skin/system/user.jpg' : $this->data['user']->Image); ?> " class="img-circle" alt="User Image" /> <p> <?php echo $this->data['user']->Name; ?> <small>Member since <?php echo $this->data['user']->DateRegistered; ?> </small> </p> </li> <!-- Menu Footer--> <li class="user-footer">