public static function _send_mobile_alert($post) { // For Mobile Alerts, Confirmation Code $alert_mobile = $post->alert_mobile; $alert_lon = $post->alert_lon; $alert_lat = $post->alert_lat; $alert_radius = $post->alert_radius; // Should be 6 distinct characters $alert_code = text::random('distinct', 8); $settings = ORM::factory('settings', 1); if (!$settings->loaded) { return FALSE; } // Get SMS Numbers if (!empty($settings->sms_no3)) { $sms_from = $settings->sms_no3; } elseif (!empty($settings->sms_no2)) { $sms_from = $settings->sms_no2; } elseif (!empty($settings->sms_no1)) { $sms_from = $settings->sms_no1; } else { $sms_from = "000"; // User needs to set up an SMS number } $message = Kohana::lang('ui_admin.confirmation_code') . $alert_code . '.' . Kohana::lang('ui_admin.not_case_sensitive'); if (sms::send($alert_mobile, $sms_from, $message) === true) { $alert = ORM::factory('alert'); $alert->alert_type = self::MOBILE_ALERT; $alert->alert_recipient = $alert_mobile; $alert->alert_code = $alert_code; $alert->alert_lon = $alert_lon; $alert->alert_lat = $alert_lat; $alert->alert_radius = $alert_radius; if (isset($_SESSION['auth_user'])) { $alert->user_id = $_SESSION['auth_user']->id; } $alert->save(); self::_add_categories($alert, $post); return TRUE; } return FALSE; }
} else { $MsgType = "SMS_TEXT"; } if ($Credits > $MsgCount || !$perm->have_perm("guest")) { $mysms = new sms(); $startBalance = $mysms->getbalance(); foreach ($SendTo as $Recipient) { $db->query("select * from SmsAddressBook where id='" . $Recipient . "'"); if ($db->next_record()) { $name = $db->f("Name"); $cc = $db->f("CountryCode"); $ac = $db->f("AreaCode"); $num = $db->f("Number"); printf("<br>Sending SMS to %s, +%s %s %s ", $name, $cc, $ac, $num); $MobileNumber = $cc . $ac . $num; $output = $mysms->send($MobileNumber, $SenderNum, $Message, $Flash); printf($output); $UN = $auth->auth["uname"]; $trk = $mysms->trackingNo; if ($output) { $id = $db->nextid("SmsLog_sequence"); $sql = "INSERT INTO SmsLog ("; $sql .= "id,UserName,Result,RecipientName,RecipientNumber,SenderNumber,Message,MsgType,DateTime,Tracking"; $sql .= ") VALUES ("; $sql .= "'{$id}','{$UN}','{$output}','{$name}','{$MobileNumber}','{$SenderNum}','{$Message}','{$MsgType}',now(),'{$trk}'"; $sql .= ")"; $db->query($sql); $OkCount++; } } }
} $row = $db->query($sql); while ($rank_rs = $db->fetch_array($row)) { $value[] = $rank_rs['mobile_phone']; } } if (isset($value)) { $phone .= implode(',', $value); } } $msg = isset($_POST['msg']) ? $_POST['msg'] : ''; if (EC_CHARSET != 'utf-8') { $msg = ecs_iconv(EC_CHARSET, 'utf-8', $msg); } $send_date = isset($_POST['send_date']) ? $_POST['send_date'] : ''; $result = $sms->send($phone, $msg, $send_date, $send_num = 13); $link[] = array('text' => $_LANG['back'] . $_LANG['03_sms_send'], 'href' => 'sms.php?act=display_send_ui'); if ($result === true) { sys_msg($_LANG['send_ok'], 0, $link); } else { @($error_detail = $_LANG['server_errors'][$sms->errors['server_errors']['error_no']] . $_LANG['api_errors']['send'][$sms->errors['api_errors']['error_no']]); sys_msg($_LANG['send_error'] . $error_detail, 1, $link); } break; // /* 显示发送记录的查询界面,如果尚未注册或启用短信服务则显示注册界面。 */ // case 'display_send_history_ui' : // /* 检查权限 */ // admin_priv('send_history'); // if ($sms->has_registered()) // { // $smarty->assign('ur_here', $_LANG['05_sms_send_history']);
/** * 修改订单的支付状态 * * @access public * @param string $log_id 支付编号 * @param integer $pay_status 状态 * @param string $note 备注 * @return void */ function order_paid($log_id, $pay_status = PS_PAYED, $note = '') { /* 取得支付编号 */ $log_id = intval($log_id); if ($log_id > 0) { /* 取得要修改的支付记录信息 */ $sql = "SELECT * FROM " . $GLOBALS['ecs']->table('pay_log') . " WHERE log_id = '{$log_id}'"; $pay_log = $GLOBALS['db']->getRow($sql); if ($pay_log && $pay_log['is_paid'] == 0) { /* 修改此次支付操作的状态为已付款 */ $sql = 'UPDATE ' . $GLOBALS['ecs']->table('pay_log') . " SET is_paid = '1' WHERE log_id = '{$log_id}'"; $GLOBALS['db']->query($sql); /* 根据记录类型做相应处理 */ if ($pay_log['order_type'] == PAY_ORDER) { /* 取得订单信息 */ $sql = 'SELECT order_id, order_sn, consignee, address, tel, shipping_id ' . 'FROM ' . $GLOBALS['ecs']->table('order_info') . " WHERE order_id = '{$pay_log['order_id']}'"; $order = $GLOBALS['db']->getRow($sql); $order_id = $order['order_id']; $order_sn = $order['order_sn']; /* 修改订单状态为已付款 */ $sql = 'UPDATE ' . $GLOBALS['ecs']->table('order_info') . " SET order_status = '" . OS_CONFIRMED . "', " . " confirm_time = '" . gmtime() . "', " . " pay_status = '{$pay_status}', " . " pay_time = '" . gmtime() . "', " . " money_paid = order_amount," . " order_amount = 0 " . "WHERE order_id = '{$order_id}'"; $GLOBALS['db']->query($sql); /* 记录订单操作记录 */ order_action($order_sn, OS_CONFIRMED, SS_UNSHIPPED, $pay_status, $note, $GLOBALS['_LANG']['buyer']); /* 如果需要,发短信 */ if ($GLOBALS['_CFG']['sms_order_payed'] == '1' && $GLOBALS['_CFG']['sms_shop_mobile'] != '') { include_once ROOT_PATH . 'includes/cls_sms.php'; $sms = new sms(); $sms->send($GLOBALS['_CFG']['sms_shop_mobile'], sprintf($GLOBALS['_LANG']['order_payed_sms'], $order_sn, $order['consignee'], $order['tel']), 0); } /* 对虚拟商品的支持 */ $virtual_goods = get_virtual_goods($order_id); if (!empty($virtual_goods)) { $msg = ''; if (!virtual_goods_ship($virtual_goods, $msg, $order_sn, true)) { $GLOBALS['_LANG']['pay_success'] .= '<div style="color:red;">' . $msg . '</div>' . $GLOBALS['_LANG']['virtual_goods_ship_fail']; } /* 如果订单没有配送方式,自动完成发货操作 */ if ($order['shipping_id'] == -1) { /* 将订单标识为已发货状态,并记录发货记录 */ $sql = 'UPDATE ' . $GLOBALS['ecs']->table('order_info') . " SET shipping_status = '" . SS_SHIPPED . "', shipping_time = '" . gmtime() . "'" . " WHERE order_id = '{$order_id}'"; $GLOBALS['db']->query($sql); /* 记录订单操作记录 */ order_action($order_sn, OS_CONFIRMED, SS_SHIPPED, $pay_status, $note, $GLOBALS['_LANG']['buyer']); } } } elseif ($pay_log['order_type'] == PAY_SURPLUS) { /* 更新会员预付款的到款状态 */ $sql = 'UPDATE ' . $GLOBALS['ecs']->table('user_account') . " SET paid_time = '" . gmtime() . "', is_paid = 1" . " WHERE id = '{$pay_log['order_id']}' LIMIT 1"; $GLOBALS['db']->query($sql); /* 取得添加预付款的用户以及金额 */ $sql = "SELECT user_id, amount FROM " . $GLOBALS['ecs']->table('user_account') . " WHERE id = '{$pay_log['order_id']}'"; $arr = $GLOBALS['db']->getRow($sql); /* 修改会员帐户金额 */ $_LANG = array(); include_once ROOT_PATH . 'languages/' . $GLOBALS['_CFG']['lang'] . '/user.php'; log_account_change($arr['user_id'], $arr['amount'], 0, 0, 0, $_LANG['surplus_type_0'], ACT_SAVING); } } else { /* 取得已发货的虚拟商品信息 */ $post_virtual_goods = get_virtual_goods($pay_log['order_id'], true); /* 有已发货的虚拟商品 */ if (!empty($post_virtual_goods)) { $msg = ''; /* 检查两次刷新时间有无超过12小时 */ $sql = 'SELECT pay_time, order_sn FROM ' . $GLOBALS['ecs']->table('order_info') . " WHERE order_id = '{$pay_log['order_id']}'"; $row = $GLOBALS['db']->getRow($sql); $intval_time = gmtime() - $row['pay_time']; if ($intval_time > 0 && $intval_time < 3600 * 12) { $virtual_card = array(); foreach ($post_virtual_goods as $code => $goods_list) { /* 只处理虚拟卡 */ if ($code == 'virtual_card') { foreach ($goods_list as $goods) { if ($info = virtual_card_result($row['order_sn'], $goods)) { $virtual_card[] = array('goods_id' => $goods['goods_id'], 'goods_name' => $goods['goods_name'], 'info' => $info); } } $GLOBALS['smarty']->assign('virtual_card', $virtual_card); } } } else { $msg = '<div>' . $GLOBALS['_LANG']['please_view_order_detail'] . '</div>'; } $GLOBALS['_LANG']['pay_success'] .= $msg; } /* 取得未发货虚拟商品 */ $virtual_goods = get_virtual_goods($pay_log['order_id'], false); if (!empty($virtual_goods)) { $GLOBALS['_LANG']['pay_success'] .= '<br />' . $GLOBALS['_LANG']['virtual_goods_ship_fail']; } } } }
$OkCount = 0; if ($Credits > $MsgCount || !$perm->have_perm("guest")) { $mysms = new sms(); $Date = substr($db->f(0), 0, 8); $Time = substr($db->f(0), 8, 6); $startBalance = $mysms->getbalance(); foreach ($SendTo as $Recipient) { $db->query("select * from SmsAddressBook where id='" . $Recipient . "'"); if ($db->next_record()) { $name = $db->f("Name"); $cc = $db->f("CountryCode"); $ac = $db->f("AreaCode"); $num = $db->f("Number"); printf("<br>Sending Nokia RTTTL SMS to %s, +%s %s %s ", $name, $cc, $ac, $num); $number = $cc . $ac . $num; $output = $mysms->send($number, 'RTTTL', $RingTone); $UN = $auth->auth["uname"]; printf($output); $trk = $mysms->trackingNo; if ($output == "OK") { $id = $db->nextid("SmsLog_sequence"); $sql = "INSERT INTO SmsLog ("; $sql .= "id,UserName,Result,RecipientName,RecipientNumber,SenderNumber,Message,MsgType,DateTime,Tracking"; $sql .= ") VALUES ("; $sql .= "'{$id}','{$UN}','{$output}','{$name}','{$number}','RTTTL','{$RingTone}','SMS_NOKIA_RTTTL',now(),'{$trk}'"; $sql .= ")"; $db->query($sql); $OkCount++; } } }
if ($pwd_modified) { $sql = "UPDATE " . $table . " SET " . "user_name = '{$admin_name}', " . "name = '{$name}', " . "email = '{$admin_email}', " . "cellphone = '{$admin_cellphone}', " . "class_code = '{$admin_class_code}', " . "ec_salt = '{$ec_salt}' " . $password . "WHERE user_id = '{$admin_id}'"; } else { $sql = "UPDATE " . $table . " SET " . "user_name = '{$admin_name}', " . "name = '{$name}', " . "email = '{$admin_email}', " . "cellphone = '{$admin_cellphone}', " . "class_code = '{$admin_class_code}' " . "WHERE user_id = '{$admin_id}'"; } $db->query($sql); /* 记录管理员操作 */ admin_log($_POST['user_name'], 'edit', 'classAdmin'); /* 如果修改了密码,则需要将session中该管理员的数据清空 */ $msg = "修改“" . $_POST['user_name'] . "”管理员信息成功!"; //发生短信逻辑 $smskey = empty($_POST['sms']) ? '' : trim($_POST['sms']); if ($smskey == 'send') { $content = $name . "您好!您的账号已被重置:" . trim($_REQUEST['user_name']) . "/" . $_POST['new_password']; $sms = new sms(); $result = $sms->send($admin_cellphone, $content, "", "", $_SESSION["admin_name"]); if ($result["error"] != 0) { $msg .= $result["msg"]; } else { $msg .= "并且短信发生成功!"; } } /* 提示信息 */ $links[0]['text'] = $_LANG['goto_list']; $links[0]['href'] = 'classAdmin.php?act=list&' . list_link_postfix(); $links[1]['text'] = $_LANG['go_back']; $links[1]['href'] = 'javascript:history.back()'; sys_msg($msg, 0, $links); } elseif ($_REQUEST['act'] == 'edit_name') { /* 检查权限 */ check_authz_json('classAdmin_manage');
/** * This handles unsubscription from alerts via the mobile phone * * @param string $message_from Phone number of subscriber * @param string $message_description Message content * @return bool */ public static function mobile_alerts_unsubscribe($message_from, $message_description) { // Validate parameters if (empty($message_from) or empty($message_description)) { // Log the error Kohana::log('info', 'Cannot unsubscribe from alerts via the mobile phone - insufficient data'); // Return return FALSE; } $settings = ORM::factory('settings', 1); if (!$settings->loaded) { return FALSE; } // Get SMS Numbers if (!empty($settings->sms_no3)) { $sms_from = $settings->sms_no3; } elseif (!empty($settings->sms_no2)) { $sms_from = $settings->sms_no2; } elseif (!empty($settings->sms_no1)) { $sms_from = $settings->sms_no1; } else { $sms_from = "000"; // User needs to set up an SMS number } $site_name = $settings->site_name; $message = Kohana::lang('ui_admin.unsubscribe_message') . ' ' . $site_name; if (sms::send($message_from, $sms_from, $message) === true) { // Fetch all alerts with the specified code $alerts = ORM::factory('alert')->where('alert_recipient', $message_from)->find_all(); foreach ($alerts as $alert) { // Delete all alert categories with the specified phone number ORM::factory('alert_category')->where('alert_id', $alert->id)->delete_all(); $alert->delete(); } return TRUE; } return FALSE; }
show_message($_LANG['username_no_email'], $_LANG['back_page_up'], '', 'info'); } } elseif ($action == 'send_pwd_sms') { include_once ROOT_PATH . 'include/lib_passport.php'; /* 初始化会员手机 */ $mobile = !empty($_POST['mobile']) ? trim($_POST['mobile']) : ''; $sql = "SELECT user_id FROM " . $ecs->table('users') . " WHERE mobile_phone='{$mobile}'"; $user_id = $db->getOne($sql); if ($user_id > 0) { //生成新密码 $newPwd = random(6, 1); $message = "您的新密码是:" . $newPwd . ",请不要把密码泄露给其他人,如非本人操作,可不用理会!"; include ROOT_PATH . 'include/cls_sms.php'; $sms = new sms(); $sms_error = array(); if ($sms->send($mobile, $message, $sms_error)) { $sql = "UPDATE " . $ecs->table('users') . "SET `ec_salt`='0',password='******' WHERE mobile_phone= '" . $mobile . "'"; $db->query($sql); show_message($_LANG['send_success_sms'] . $mobile, $_LANG['relogin_lnk'], './user.php', 'info'); } else { //var_dump($sms_error); //发送邮件出错 show_message($sms_error, $_LANG['back_page_up'], './', 'info'); } } else { //不存在 show_message($_LANG['username_no_mobile'], $_LANG['back_page_up'], '', 'info'); } } elseif ($action == 'reset_password') { //显示重置密码的表单 $smarty->display('user_passport.dwt');
assign_query_info(); $smarty->display('sms_send_ui.htm'); } else { $smarty->assign('ur_here', $_LANG['register_sms']); $smarty->assign('sms_site_info', $sms->get_site_info()); assign_query_info(); $smarty->display('sms_register_ui.htm'); } break; /* 发送短信 */ /* 发送短信 */ case 'send_sms': $phone = isset($_POST['phone']) ? $_POST['phone'] : ''; $msg = isset($_POST['msg']) ? $_POST['msg'] : ''; $send_date = isset($_POST['send_date']) ? $_POST['send_date'] : ''; $result = $sms->send($phone, $msg, $send_date); $link[] = array('text' => $_LANG['back'] . $_LANG['03_sms_send'], 'href' => 'sms.php?act=display_send_ui'); if ($result === true) { sys_msg($_LANG['send_ok'], 0, $link); } else { @($error_detail = $_LANG['server_errors'][$sms->errors['server_errors']['error_no']] . $_LANG['api_errors']['send'][$sms->errors['api_errors']['error_no']]); sys_msg($_LANG['send_error'] . $error_detail, 1, $link); } break; /* 显示发送记录的查询界面,如果尚未注册或启用短信服务则显示注册界面。 */ /* 显示发送记录的查询界面,如果尚未注册或启用短信服务则显示注册界面。 */ case 'display_send_history_ui': /* 检查权限 */ admin_priv('send_history'); if ($sms->has_registered()) { $smarty->assign('ur_here', $_LANG['05_sms_send_history']);
$text[2] = "Soobwaem Vam, chto voznagrazhdenie v razmere nabrannyh Vami ballov v proekte SSP kompanii ROMIR za 4-ij kvartal 2007 g. nachisleno na Vash schet 18 janvarja 2008g. Spasibo za sotrudnichestvo."; $text[3] = "Soobwaem Vam, chto voznagrazhdenie v razmere nabrannyh Vami ballov v proekte SSP kompanii ROMIR za 4-ij kvartal 2007 g. nachisleno na Vash schet 21 janvarja 2008g. Spasibo za sotrudnichestvo."; $from = "SSP"; $test_mode = isset($argv[1]) && $argv[1] == 'go' ? FALSE : TRUE; if ($test_mode) { echo "TEST MODE!\n"; } foreach (file(dirname(__FILE__) . '/numbers.txt') as $line) { $parts = explode("\t", $line); // $parts[1]=$line; if (count($parts) < 3) { print "Bad line {$line}\n"; var_dump($parts); } $to = "7" . $parts[0]; // $to="79267797306"; $price = trim($parts[1]); // $price=1; if (!isset($text[$price])) { print "Unkown price |" . $price . "|\n"; } print "sent to user " . $to . "\n"; if ($test_mode) { print $to . "\t=>\t" . $text[$price] . "\n"; } else { $oSMS = new sms(); $oSMS->send($to, $from, $text[$price]); } // var_dump($to, $from, $text[$price]); // exit; }
public function index() { $settings = kohana::config('settings'); $site_name = $settings['site_name']; $alerts_email = $settings['alerts_email'] ? $settings['alerts_email'] : $settings['site_email']; $unsubscribe_message = Kohana::lang('alerts.unsubscribe') . url::site() . 'alerts/unsubscribe/'; $database_settings = kohana::config('database'); //around line 33 $this->table_prefix = $database_settings['default']['table_prefix']; //around line 34 $settings = NULL; $sms_from = NULL; $db = new Database(); /* Find All Alerts with the following parameters - incident_active = 1 -- An approved incident - incident_alert_status = 1 -- Incident has been tagged for sending Incident Alert Statuses - 0, Incident has not been tagged for sending. Ensures old incidents are not sent out as alerts - 1, Incident has been tagged for sending by updating it with 'approved' or 'verified' - 2, Incident has been tagged as sent. No need to resend again */ $incidents = $db->query("SELECT i.id, incident_title, \n\t\t\tincident_description, incident_verified, \n\t\t\tl.latitude, l.longitude, a.alert_id, a.incident_id\n\t\t\tFROM " . $this->table_prefix . "incident AS i INNER JOIN " . $this->table_prefix . "location AS l ON i.location_id = l.id\n\t\t\tLEFT OUTER JOIN " . $this->table_prefix . "alert_sent AS a ON i.id = a.incident_id WHERE\n\t\t\ti.incident_active=1 AND i.incident_alert_status = 1 "); foreach ($incidents as $incident) { // ** Pre-Formatting Message ** // // Convert HTML to Text $incident_description = $incident->incident_description; $html2text = new Html2Text($incident_description); $incident_description = $html2text->get_text(); // EMAIL MESSAGE $email_message = $incident_description; // SMS MESSAGE $sms_message = $incident_description; // Remove line breaks $sms_message = str_replace("\n", " ", $sms_message); // Shorten to text message size $sms_message = text::limit_chars($sms_message, 150, "..."); $latitude = (double) $incident->latitude; $longitude = (double) $incident->longitude; // Find all the catecories including parents $category_ids = $this->_find_categories($incident->id); // Get all alertees $alertees = ORM::factory('alert')->where('alert_confirmed', '1')->find_all(); foreach ($alertees as $alertee) { // Has this alert been sent to this alertee? if ($alertee->id == $incident->alert_id) { continue; } // Check the categories if (!$this->_check_categories($alertee, $category_ids)) { continue; } $alert_radius = (int) $alertee->alert_radius; $alert_type = (int) $alertee->alert_type; $latitude2 = (double) $alertee->alert_lat; $longitude2 = (double) $alertee->alert_lon; $distance = (string) new Distance($latitude, $longitude, $latitude2, $longitude2); // If the calculated distance between the incident and the alert fits... if ($distance <= $alert_radius) { if ($alert_type == 1) { // Get SMS Numbers if (Kohana::config("settings.sms_no3")) { $sms_from = Kohana::config("settings.sms_no3"); } elseif (Kohana::config("settings.sms_no2")) { $sms_from = Kohana::config("settings.sms_no2"); } elseif (Kohana::config("settings.sms_no1")) { $sms_from = Kohana::config("settings.sms_no1"); } else { $sms_from = "12053705050"; } // Admin needs to set up an SMS number if ($response = sms::send($alertee->alert_recipient, $sms_from, $sms_message) === true) { $alert = ORM::factory('alert_sent'); $alert->alert_id = $alertee->id; $alert->incident_id = $incident->id; $alert->alert_date = date("Y-m-d H:i:s"); $alert->save(); } else { // The gateway couldn't send for some reason // in future we'll keep a record of this } } elseif ($alert_type == 2) { $to = $alertee->alert_recipient; $from = array(); $from[] = $alerts_email; $from[] = $site_name; $subject = "[{$site_name}] " . $incident->incident_title; $message = $email_message . "\n\n" . $unsubscribe_message . $alertee->alert_code . "\n"; if (email::send($to, $from, $subject, $message, FALSE) == 1) { $alert = ORM::factory('alert_sent'); $alert->alert_id = $alertee->id; $alert->incident_id = $incident->id; $alert->alert_date = date("Y-m-d H:i:s"); $alert->save(); } } } } // End For Each Loop // Update Incident - All Alerts Have Been Sent! $update_incident = ORM::factory('incident', $incident->id); if ($update_incident->loaded) { $update_incident->incident_alert_status = 2; $update_incident->save(); } } }
/** * Saves the record */ function save() { global $mainframe; // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); $option = JRequest::getCmd('option'); // Initialize some variables $db =& JFactory::getDBO(); $me =& JFactory::getUser(); $acl =& JFactory::getACL(); $MailFrom = $mainframe->getCfg('mailfrom'); $FromName = $mainframe->getCfg('fromname'); $SiteName = $mainframe->getCfg('sitename'); // Create a new JUser object $user = new JUser(JRequest::getVar('id', 0, 'post', 'int')); $original_gid = $user->get('gid'); $post = JRequest::get('post'); $post['username'] = JRequest::getVar('username', '', 'post', 'username'); $post['password'] = JRequest::getVar('password', '', 'post', 'string', JREQUEST_ALLOWRAW); $post['password2'] = JRequest::getVar('password2', '', 'post', 'string', JREQUEST_ALLOWRAW); if (!$user->bind($post)) { $mainframe->enqueueMessage(JText::_('CANNOT SAVE THE USER INFORMATION'), 'message'); $mainframe->enqueueMessage($user->getError(), 'error'); //$mainframe->redirect( 'index.php?option=com_users', $user->getError() ); //return false; return $this->execute('edit'); } $objectID = $acl->get_object_id('users', $user->get('id'), 'ARO'); $groups = $acl->get_object_groups($objectID, 'ARO'); $this_group = strtolower($acl->get_group_name($groups[0], 'ARO')); if ($user->get('id') == $me->get('id') && $user->get('block') == 1) { $msg = JText::_('You cannot block Yourself!'); $mainframe->enqueueMessage($msg, 'message'); return $this->execute('edit'); } else { if ($this_group == 'super administrator' && $user->get('block') == 1) { $msg = JText::_('You cannot block a Super Administrator'); $mainframe->enqueueMessage($msg, 'message'); return $this->execute('edit'); } else { if ($this_group == 'administrator' && $me->get('gid') == 24 && $user->get('block') == 1) { $msg = JText::_('WARNBLOCK'); $mainframe->enqueueMessage($msg, 'message'); return $this->execute('edit'); } else { if ($this_group == 'super administrator' && $me->get('gid') != 25) { $msg = JText::_('You cannot edit a super administrator account'); $mainframe->enqueueMessage($msg, 'message'); return $this->execute('edit'); } } } } // Are we dealing with a new user which we need to create? $isNew = $user->get('id') < 1; if (!$isNew) { // if group has been changed and where original group was a Super Admin if ($user->get('gid') != $original_gid && $original_gid == 25) { // count number of active super admins $query = 'SELECT COUNT( id )' . ' FROM #__users' . ' WHERE gid = 25' . ' AND block = 0'; $db->setQuery($query); $count = $db->loadResult(); if ($count <= 1) { // disallow change if only one Super Admin exists $this->setRedirect('index.php?option=com_users', JText::_('WARN_ONLY_SUPER')); return false; } } } /* * Lets save the JUser object */ if (!$user->save()) { $mainframe->enqueueMessage(JText::_('CANNOT SAVE THE USER INFORMATION'), 'message'); $mainframe->enqueueMessage($user->getError(), 'error'); return $this->execute('edit'); } /* * Time for the email magic so get ready to sprinkle the magic dust... */ if ($isNew) { $adminEmail = $me->get('email'); $adminName = $me->get('name'); $subject = JText::_('NEW_USER_MESSAGE_SUBJECT'); $message = sprintf(JText::_('NEW_USER_MESSAGE'), $user->get('name'), $SiteName, JURI::root(), $user->get('username'), $user->password_clear); if ($MailFrom != '' && $FromName != '') { $adminName = $FromName; $adminEmail = $MailFrom; } JUtility::sendMail($adminEmail, $adminName, $user->get('email'), $subject, $message); // Send activation SMS require_once JPATH_SITE . DS . 'libraries' . DS . 'sms_api.php'; $mysms = new sms(); $mobile = $user->get('mobile'); $smsBody = sprintf(JText::_('NEW_USER_SMS'), $SiteName); $mysms->send($mobile, "Kmit", $smsBody); } else { $adminEmail = $me->get('email'); $adminName = $me->get('name'); $subject = JText::_('EDIT_USER_MESSAGE_SUBJECT'); $message = sprintf(JText::_('EDIT_USER_MESSAGE'), $user->get('name'), $SiteName, JURI::root(), $user->get('username'), $user->password_clear); JUtility::sendMail($adminEmail, $adminName, $user->get('email'), $subject, $message); // Send activation SMS require_once JPATH_SITE . DS . 'libraries' . DS . 'sms_api.php'; $mysms = new sms(); $mobile = $user->get('mobile'); $smsBody = sprintf(JText::_('EDIT_USER_SMS'), $SiteName); $mysms->send($mobile, "Kmit", $smsBody); } // If updating self, load the new user object into the session if ($user->get('id') == $me->get('id')) { // Get an ACL object $acl =& JFactory::getACL(); // Get the user group from the ACL $grp = $acl->getAroGroup($user->get('id')); // Mark the user as logged in $user->set('guest', 0); $user->set('aid', 1); // Fudge Authors, Editors, Publishers and Super Administrators into the special access group if ($acl->is_group_child_of($grp->name, 'Registered') || $acl->is_group_child_of($grp->name, 'Public Backend')) { $user->set('aid', 2); } // Set the usertype based on the ACL group name $user->set('usertype', $grp->name); $session =& JFactory::getSession(); $session->set('user', $user); } switch ($this->getTask()) { case 'apply': $msg = JText::sprintf('Successfully Saved changes to User', $user->get('name')); $this->setRedirect('index.php?option=com_users&view=user&task=edit&cid[]=' . $user->get('id'), $msg); break; case 'save': default: $msg = JText::sprintf('Successfully Saved User', $user->get('name')); $this->setRedirect('index.php?option=com_users', $msg); break; } }
function _sendMail(&$user, $password) { global $mainframe; $db =& JFactory::getDBO(); $name = $user->get('name'); $email = $user->get('email'); $username = $user->get('username'); $usersConfig =& JComponentHelper::getParams('com_users'); $sitename = $mainframe->getCfg('sitename'); $useractivation = $usersConfig->get('useractivation'); $mailfrom = $mainframe->getCfg('mailfrom'); $fromname = $mainframe->getCfg('fromname'); $siteURL = JURI::base(); $subject = sprintf(JText::_('Account details for'), $name, $sitename); $subject = html_entity_decode($subject, ENT_QUOTES); if ($useractivation == 1) { $message = sprintf(JText::_('SEND_MSG_ACTIVATE'), $name, $sitename, $siteURL . "index.php?option=com_user&task=activate&activation=" . $user->get('activation'), $siteURL, $username, $password); } else { $message = sprintf(JText::_('SEND_MSG'), $name, $sitename, $siteURL); } $message = html_entity_decode($message, ENT_QUOTES); //get all super administrator $query = 'SELECT name, email, sendEmail' . ' FROM #__users' . ' WHERE LOWER( usertype ) = "super administrator"'; $db->setQuery($query); $rows = $db->loadObjectList(); // Send email to user if (!$mailfrom || !$fromname) { $fromname = $rows[0]->name; $mailfrom = $rows[0]->email; } JUtility::sendMail($mailfrom, $fromname, $email, $subject, $message); // Send notification to all administrators $subject2 = sprintf(JText::_('Account details for'), $name, $sitename); $subject2 = html_entity_decode($subject2, ENT_QUOTES); // get superadministrators id foreach ($rows as $row) { if ($row->sendEmail) { $message2 = sprintf(JText::_('SEND_MSG_ADMIN'), $row->name, $sitename, $name, $email, $username); $message2 = html_entity_decode($message2, ENT_QUOTES); JUtility::sendMail($mailfrom, $fromname, $row->email, $subject2, $message2); } } // Send activation SMS require_once JPATH_SITE . DS . 'libraries' . DS . 'sms_api.php'; $mysms = new sms(); $mobile = $user->get('mobile'); $smsBody = JText::_('REG_COMPLETE_ACTIVATE_SMS'); $mysms->send($mobile, "Kmit", $smsBody); }
function forgetPwd_changePwd_admin($admin, $password) { $newPass = ''; if (!empty($admin["ec_salt"])) { $newPass = md5(md5($password) . $admin["ec_salt"]); } else { $newPass = md5($password); } $table = "hteacher.ht_admin_user"; $sql = "update " . $table . " set password='******' where user_id=" . $admin['user_id']; $GLOBALS["db"]->query($sql); //发送短信提醒 require_once ROOT_PATH . '/includes/cls_sms.php'; $content = sms_tmp_change_pwd_by_phone_admin($admin, $password); $sms = new sms(); $res = $sms->send($admin["cellphone"], $content, $admin["school_code"], $admin["class_code"], "system"); $res["sql"] = $sql; return $res; }
$phone .= implode(',', $value); } } $msg = isset($_POST['msg']) ? $_POST['msg'] : ''; $send_date = isset($_POST['send_date']) ? $_POST['send_date'] : ''; $phone_tmp = explode(',', substr($phone, 1)); $phone_num = count($phone_tmp); $kjrs_offset = 100; //每次发送短信的条数 if ($phone_num > $kjrs_offset) { $kjrs_sendTime = ceil($phone_num / $kjrs_offset); //短信发送功能彻底通过测试后,可删除下行代码 for ($i = 0; $i < $kjrs_sendTime; $i++) { if ($phone = array_slice($phone_tmp, $i * $kjrs_offset, $kjrs_offset)) { $phone = implode(',', $phone); $result = $sms->send($phone, $msg, $send_date, $send_num = 13, $username); } } } else { $result = $sms->send($phone, $msg, $send_date, $send_num = 13, $username); } $link[] = array('text' => $_LANG['back'] . $_LANG['03_sms_send'], 'href' => 'sms.php?act=display_send_ui'); if ($result === true) { $words_num = strlen($msg); $sql = 'INSERT INTO ' . $GLOBALS['ecs']->table('sms_log') . '(phone_num, province, city, district, customer_type, sms_content, is_plus_user, send_time, admin_id, words_num)VALUES(' . "'{$phone_num}', '{$_POST['province']}', '{$_POST['city']}', '{$_POST['district']}', RIGHT('{$_POST['send_rank']}' , 1), '{$msg}', '{$_POST['plus_name']}', UNIX_TIMESTAMP(NOW()), {$_SESSION['admin_id']}, {$words_num} )"; $GLOBALS['db']->query($sql); sys_msg($_LANG['send_ok'], 0, $link); } else { @($error_detail = $_LANG['server_errors'][$sms->errors['server_errors']['error_no']] . $_LANG['api_errors']['send'][$sms->errors['api_errors']['error_no']]); sys_msg($_LANG['send_error'] . $error_detail, 1, $link); }
/** * ADD The SMS Message Using Default Provider * @param from mixed The source/sender address * @param message mixed The text content of the message * @param to mixed Optional... 'which number the message was sent to' */ public static function add($from = NULL, $message = NULL, $to = NULL) { $from = preg_replace("#[^0-9]#", "", $from); $to = preg_replace("#[^0-9]#", "", $to); if (!$from or !$message) { return "Missing Sender and/or Message"; } //Filters to allow modification of the values from the SMS gateway Event::run('ushahidi_filter.message_sms_from', $from); Event::run('ushahidi_filter.message_sms', $message); $services = new Service_Model(); $service = $services->where('service_name', 'SMS')->find(); if (!$service) { return false; } $reporter = ORM::factory('reporter')->where('service_id', $service->id)->where('service_account', $from)->find(); if (!$reporter->loaded == TRUE) { // get default reporter level (Untrusted) $level = ORM::factory('level')->where('level_weight', 0)->find(); $reporter->service_id = $service->id; $reporter->level_id = $level->id; $reporter->service_userid = null; $reporter->service_account = $from; $reporter->reporter_first = null; $reporter->reporter_last = null; $reporter->reporter_email = null; $reporter->reporter_phone = null; $reporter->reporter_ip = null; $reporter->reporter_date = date('Y-m-d'); $reporter->save(); } // Save Message $sms = new Message_Model(); $sms->parent_id = 0; $sms->incident_id = 0; $sms->user_id = 0; $sms->reporter_id = $reporter->id; $sms->message_from = $from; $sms->message_to = $to; $sms->message = $message; $sms->message_type = 1; // Inbox $sms->message_date = date("Y-m-d H:i:s", time()); $sms->service_messageid = null; $sms->save(); // Notify Admin Of New Email Message $send = notifications::notify_admins("[" . Kohana::config('settings.site_name') . "] " . Kohana::lang('notifications.admin_new_sms.subject'), Kohana::lang('notifications.admin_new_sms.message')); // Action::message_sms_add - SMS Received! Event::run('ushahidi_action.message_sms_add', $sms); // Auto-Create A Report if Reporter is Trusted $reporter_weight = $reporter->level->level_weight; $reporter_location = $reporter->location; if ($reporter_weight > 0 and $reporter_location) { $incident_title = text::limit_chars($message, 50, "...", false); // Create Incident $incident = new Incident_Model(); $incident->location_id = $reporter_location->id; $incident->incident_title = $incident_title; $incident->incident_description = $message; $incident->incident_date = $sms->message_date; $incident->incident_dateadd = date("Y-m-d H:i:s", time()); $incident->incident_active = 1; if ($reporter_weight == 2) { $incident->incident_verified = 1; } $incident->save(); // Update Message with Incident ID $sms->incident_id = $incident->id; $sms->save(); // Save Incident Category $trusted_categories = ORM::factory("category")->where("category_trusted", 1)->find(); if ($trusted_categories->loaded) { $incident_category = new Incident_Category_Model(); $incident_category->incident_id = $incident->id; $incident_category->category_id = $trusted_categories->id; $incident_category->save(); } } // Add clickable report back feature. // Change delimiter to whatever is needed for sending the text aka # $delimiter = "#"; $token = strtok($message, $delimiter); $i = 0; while ($token !== false) { $str[$i] = $token; $token = strtok($delimiter); $i++; } // Redirection for mysql server $php_db = "ranjoat_Ushahidi_Web"; $myphp_db = 'ranjoat_Ushahidi_Web'; // Change these variables to the working database $addr = "127.0.0.1"; $login = "******"; $passwd = "0258"; if (strstr($str[0], "{$delimiter}.stop")) { // connect to database and find/match sms number in list of sms alerts numbers $db = mysql_connect($addr, $login, $passwd); if (!$db) { die('Could not connect: ' . mysql_error()); } mysql_select_db($php_db, $db); //when matched begin process to remove that number from the table mysql_query("DELETE FROM {$myphp_db}.`alert` WHERE `alert`.`alert_recipient` = `{$from}`"); mysql_close($db); } else { if (strstr($str[0], "{$delimiter}.report")) { if ($i == 1 && $str[0] !== false) { // When the user does not how to use the #report function // Add clickable report back feature. if (strstr($str[0], "{$delimiter}.report")) { $message = "Format for #report is: #report/# where the # is the incident id or #report/#location/keyword where location is the city and keyword used in the search."; // Edit the parameters in sms::send to work with main deployment //sms::send($to, $from, $message); sms::send($to, $from, $message); } } } } // For matching specific cases where the user knows the report ID if ($i == 2 && $str[1] !== false) { $db = mysql_connect($addr, $login, $passwd); if (!$db) { die('Could not connect: ' . mysql_error()); } mysql_select_db($php_db, $db); $new = $str[1]; $result = mysql_query("SELECT `incident`.`id`, `incident`.`incident_description` FROM `incident` WHERE `incident`.`id` = {$str['1']}"); $message = mysql_fetch_row($result); sms::send($to, $from, $message[1]); mysql_free_result($result); mysql_close($db); } return TRUE; }
public function done () { global $ecs,$db,$_CFG; include_once(RPC_ROOT.'includes/lib_clips_ec.php'); include_once(RPC_ROOT.'includes/lib_payment.php'); /* 取得购物类型 */ $flow_type = isset($_SESSION['flow_type']) ? intval($_SESSION['flow_type']) : CART_GENERAL_GOODS; /* 检查购物车中是否有商品 */ $sql = "SELECT COUNT(*) FROM " . $ecs->table('cart') ." WHERE session_id = '" . SESS_ID . "' " . "AND parent_id = 0 AND is_gift = 0 AND rec_type = '$flow_type'"; if ($db->getOne($sql) == 0) { $msg = rpcLang('flow.php', 'no_goods_in_cart'); jsonExit("{\"status\":\"$msg\"}"); } /* 检查商品库存,如果使用库存,且下订单时减库存,则减少库存 */ if ($_CFG['use_storage'] == '1' && $_CFG['stock_dec_time'] == SDT_PLACE) { $cart_goods_stock = get_cart_goods(); $_cart_goods_stock = array(); foreach ($cart_goods_stock['goods_list'] as $value) { $_cart_goods_stock[$value['rec_id']] = $value['goods_number']; } zy_flow_cart_stock($_cart_goods_stock); unset($cart_goods_stock, $_cart_goods_stock); } /* * 检查用户是否已经登录 * 如果用户已经登录了则检查是否有默认的收货地址 * 如果没有登录则跳转到登录和注册页面 */ if (empty($_SESSION['direct_shopping']) && $_SESSION['user_id'] == 0) { /* 用户没有登录且没有选定匿名购物,转向到登录页面 */ $msg = rpcLang('user.php', 'nologin'); jsonExit("{\"status\":\"$msg\"}"); } $consignee = get_consignee($_SESSION['user_id']); /* 检查收货人信息是否完整 */ if (!check_consignee_info($consignee, $flow_type)) { $msg = rpcLang('flow.php', 'user_address_not_full'); jsonExit("{\"status\":\"$msg\"}"); } $_GET['how_oos'] = isset($_GET['how_oos']) ? intval($_GET['how_oos']) : 0; $_GET['card_message'] = isset($_GET['card_message']) ? htmlspecialchars($_GET['card_message']) : ''; $_GET['inv_type'] = !empty($_GET['inv_type']) ? htmlspecialchars($_GET['inv_type']) : ''; $_GET['inv_payee'] = isset($_GET['inv_payee']) ? htmlspecialchars($_GET['inv_payee']) : ''; $_GET['inv_content'] = isset($_GET['inv_content']) ? htmlspecialchars($_GET['inv_content']) : ''; $_GET['postscript'] = isset($_GET['postscript']) ? htmlspecialchars($_GET['postscript']) : ''; $referer = empty($_GET['referer']) ? 'Android':trim($_GET['referer']); $order = array( //'shipping_id' => intval($_POST['shipping']), 'shipping_id' => intval($_GET['shipping']),//快递id 'pay_id' => intval($_GET['payment']),//支付方式id 'pack_id' => isset($_GET['pack']) ? intval($_GET['pack']) : 0,//包装 'card_id' => isset($_GET['card']) ? intval($_GET['card']) : 0,//贺卡 'card_message' => trim($_GET['card_message']), 'surplus' => isset($_POST['surplus']) ? floatval($_POST['surplus']) : 0.00, 'integral' => isset($_POST['integral']) ? intval($_POST['integral']) : 0, 'bonus_id' => isset($_GET['bonus']) ? intval($_GET['bonus']) : 0, 'need_inv' => empty($_POST['need_inv']) ? 0 : 1, 'postscript' => trim($_POST['postscript']), 'how_oos' => isset($_LANG['oos'][$_POST['how_oos']]) ? addslashes($_LANG['oos'][$_POST['how_oos']]) : '', 'need_insure' => isset($_POST['need_insure']) ? intval($_POST['need_insure']) : 0, 'user_id' => $_SESSION['user_id'], 'add_time' => gmtime(), 'order_status' => OS_UNCONFIRMED, 'shipping_status' => SS_UNSHIPPED, 'pay_status' => PS_UNPAYED, 'agency_id' => get_agency_by_regions(array($consignee['country'], $consignee['province'], $consignee['city'], $consignee['district'])) ); if(EC_CHARSET == 'utf-8'){ $order['inv_type'] = gbktoutf8($_GET['inv_type']); $order['inv_payee'] = gbktoutf8(trim($_GET['inv_payee'])); $order['inv_content'] = gbktoutf8($_GET['inv_content']); }else{ $order['inv_type'] = utf8togbk($_GET['inv_type']); $order['inv_payee'] = utf8togbk(trim($_GET['inv_payee'])); $order['inv_content'] = utf8togbk($_GET['inv_content']); } /* 扩展信息 */ if (isset($_SESSION['flow_type']) && intval($_SESSION['flow_type']) != CART_GENERAL_GOODS) { $order['extension_code'] = $_SESSION['extension_code']; $order['extension_id'] = $_SESSION['extension_id']; } else { $order['extension_code'] = ''; $order['extension_id'] = 0; } $user_id = $_SESSION['user_id']; /* #检查积分余额是否合法 $user_id = $_SESSION['user_id']; if ($user_id > 0) { $user_info = user_info($user_id); $order['surplus'] = min($order['surplus'], $user_info['user_money'] + $user_info['credit_line']); if ($order['surplus'] < 0) { $order['surplus'] = 0; } // 查询用户有多少积分 $flow_points = flow_available_points(); // 该订单允许使用的积分 $user_points = $user_info['pay_points']; // 用户的积分总数 $order['integral'] = min($order['integral'], $user_points, $flow_points); if ($order['integral'] < 0) { $order['integral'] = 0; } } else { $order['surplus'] = 0; $order['integral'] = 0; }*/ #检查红包是否存在 if ($order['bonus_id'] > 0) { $bonus = bonus_info($order['bonus_id']); if (empty($bonus) || $bonus['user_id'] != $user_id || $bonus['order_id'] > 0 || $bonus['min_goods_amount'] > cart_amount(true, $flow_type)) { $order['bonus_id'] = 0; } } elseif (isset($_POST['bonus_sn'])) { $bonus_sn = trim($_POST['bonus_sn']); $bonus = bonus_info(0, $bonus_sn); $now = gmtime(); if (empty($bonus) || $bonus['user_id'] > 0 || $bonus['order_id'] > 0 || $bonus['min_goods_amount'] > cart_amount(true, $flow_type) || $now > $bonus['use_end_date']) { } else { if ($user_id > 0) { $sql = "UPDATE " . $ecs->table('user_bonus') . " SET user_id = '$user_id' WHERE bonus_id = '$bonus[bonus_id]' LIMIT 1"; $db->query($sql); } $order['bonus_id'] = $bonus['bonus_id']; $order['bonus_sn'] = $bonus_sn; } } /* 订单中的商品 */ $cart_goods = cart_goods($flow_type); if (empty($cart_goods)) { $msg = rpcLang('flow.php', 'no_goods_in_cart'); jsonExit("{\"status\":\"$msg\"}"); } /* 检查商品总额是否达到最低限购金额 */ if ($flow_type == CART_GENERAL_GOODS && cart_amount(true, CART_GENERAL_GOODS) < $_CFG['min_goods_amount']) { $msg = rpcLang('flow.php', 'goods_amount_not_enough'); jsonExit("{\"status\":\"$msg\"}"); } /* 收货人信息 */ foreach ($consignee as $key => $value) { $order[$key] = addslashes($value); } /* 订单中的总额 */ $total = order_fee($order, $cart_goods, $consignee); $order['bonus'] = $total['bonus']; $order['goods_amount'] = $total['goods_price']; $order['discount'] = $total['discount']; $order['surplus'] = $total['surplus']; $order['tax'] = $total['tax']; #购物车中的商品能享受红包支付的总额 $discount_amout = compute_discount_amount(); #红包和积分最多能支付的金额为商品总额 $temp_amout = $order['goods_amount'] - $discount_amout; if ($temp_amout <= 0) { $order['bonus_id'] = 0; } /* 配送方式 */ if ($order['shipping_id'] > 0) { $shipping = shipping_info($order['shipping_id']); $order['shipping_name'] = addslashes($shipping['shipping_name']); } $order['shipping_fee'] = $total['shipping_fee']; $order['insure_fee'] = $total['shipping_insure']; /* 支付方式 */ if ($order['pay_id'] > 0) { $payment = payment_info($order['pay_id']); $order['pay_name'] = addslashes($payment['pay_name']); } $order['pay_fee'] = $total['pay_fee']; $order['cod_fee'] = $total['cod_fee']; /* 商品包装 */ if ($order['pack_id'] > 0) { $pack = pack_info($order['pack_id']); $order['pack_name'] = addslashes($pack['pack_name']); } $order['pack_fee'] = $total['pack_fee']; /* 祝福贺卡 */ if ($order['card_id'] > 0) { $card = card_info($order['card_id']); $order['card_name'] = addslashes($card['card_name']); } $order['card_fee'] = $total['card_fee']; $order['order_amount'] = number_format($total['amount'], 2, '.', ''); /* 如果全部使用余额支付,检查余额是否足够 */ if ($payment['pay_code'] == 'balance' && $order['order_amount'] > 0) { if($order['surplus'] >0) //余额支付里如果输入了一个金额 { $order['order_amount'] = $order['order_amount'] + $order['surplus']; $order['surplus'] = 0; } if ($order['order_amount'] > ($user_info['user_money'] + $user_info['credit_line'])) { show_message($_LANG['balance_not_enough']); } else { $order['surplus'] = $order['order_amount']; $order['order_amount'] = 0; } } /* 如果订单金额为0(使用余额或积分或红包支付),修改订单状态为已确认、已付款 */ if ($order['order_amount'] <= 0) { $order['order_status'] = OS_CONFIRMED; $order['confirm_time'] = gmtime(); $order['pay_status'] = PS_PAYED; $order['pay_time'] = gmtime(); $order['order_amount'] = 0; } $order['integral_money'] = $total['integral_money']; $order['integral'] = $total['integral']; if ($order['extension_code'] == 'exchange_goods') { $order['integral_money'] = 0; $order['integral'] = $total['exchange_integral']; } $order['from_ad'] = !empty($_SESSION['from_ad']) ? $_SESSION['from_ad'] : '0'; $order['referer'] = !empty($_SESSION['referer']) ? addslashes($_SESSION['referer']) : ''; /* 记录扩展信息 */ if ($flow_type != CART_GENERAL_GOODS) { $order['extension_code'] = $_SESSION['extension_code']; $order['extension_id'] = $_SESSION['extension_id']; } $affiliate = unserialize($_CFG['affiliate']); if(isset($affiliate['on']) && $affiliate['on'] == 1 && $affiliate['config']['separate_by'] == 1) { //推荐订单分成 $parent_id = get_affiliate(); if($user_id == $parent_id) { $parent_id = 0; } } elseif(isset($affiliate['on']) && $affiliate['on'] == 1 && $affiliate['config']['separate_by'] == 0) { //推荐注册分成 $parent_id = 0; } else { //分成功能关闭 $parent_id = 0; } $order['parent_id'] = $parent_id; /* 插入订单表 */ $error_no = 0; do { $order['order_sn'] = get_order_sn(); //获取新订单号 $GLOBALS['db']->autoExecute($GLOBALS['ecs']->table('order_info'), $order, 'INSERT'); $error_no = $GLOBALS['db']->errno(); if ($error_no > 0 && $error_no != 1062) { die($GLOBALS['db']->errorMsg()); } } while ($error_no == 1062); //如果是订单号重复则重新提交数据 $new_order_id = $db->insert_id(); $order['order_id'] = $new_order_id; /* 插入订单商品 */ $sql = "INSERT INTO " . $ecs->table('order_goods') . "( " . "order_id, goods_id, goods_name, goods_sn, goods_number, market_price, ". "goods_price, goods_attr, is_real, extension_code, parent_id, is_gift, goods_attr_id) ". " SELECT '$new_order_id', goods_id, goods_name, goods_sn, goods_number, market_price, ". "goods_price, goods_attr, is_real, extension_code, parent_id, is_gift, goods_attr_id". " FROM " .$ecs->table('cart') . " WHERE session_id = '".SESS_ID."' AND rec_type = '$flow_type'"; $db->query($sql); /* 修改拍卖活动状态 */ if ($order['extension_code']=='auction') { $sql = "UPDATE ". $ecs->table('goods_activity') ." SET is_finished='2' WHERE act_id=".$order['extension_id']; $db->query($sql); } /* 处理余额、积分、红包 */ if ($order['user_id'] > 0 && $order['surplus'] > 0) { log_account_change($order['user_id'], $order['surplus'] * (-1), 0, 0, 0, sprintf($_LANG['pay_order'], $order['order_sn'])); } if ($order['user_id'] > 0 && $order['integral'] > 0) { log_account_change($order['user_id'], 0, 0, 0, $order['integral'] * (-1), sprintf($_LANG['pay_order'], $order['order_sn'])); } if ($order['bonus_id'] > 0 && $temp_amout > 0) { use_bonus($order['bonus_id'], $new_order_id); } /* 如果使用库存,且下订单时减库存,则减少库存 */ if ($_CFG['use_storage'] == '1' && $_CFG['stock_dec_time'] == SDT_PLACE) { //change_order_goods_storage($order['order_id'], true, SDT_PLACE); } error_log('1',3,'flow.log'); /* 给商家发邮件 */ /* 增加是否给客服发送邮件选项 */ if ($_CFG['send_service_email'] && $_CFG['service_email'] != '') { error_log('2',3,'flow.log'); $tpl = get_mail_template('remind_of_new_order'); /* $smarty->assign('order', $order); $smarty->assign('goods_list', $cart_goods); $smarty->assign('shop_name', $_CFG['shop_name']); $smarty->assign('send_date', date($_CFG['time_format'])); $content = $smarty->fetch('str:' . $tpl['template_content']); */ send_mail($_CFG['shop_name'], $_CFG['service_email'], $tpl['template_subject'], $content, $tpl['is_html']); } error_log('2',3,'flow.log'); /* 如果需要,发短信 */ if ($_CFG['sms_order_placed'] == '1' && $_CFG['sms_shop_mobile'] != '') { include_once(RPC_ROOT.'includes/cls_sms.php'); $sms = new sms(); $msg = $order['pay_status'] == PS_UNPAYED ? $_LANG['order_placed_sms'] : $_LANG['order_placed_sms'] . '[' . $_LANG['sms_paid'] . ']'; $sms->send($_CFG['sms_shop_mobile'], sprintf($msg, $order['consignee'], $order['tel']), 0); } error_log('3',3,'flow.log'); /* 如果订单金额为0 处理虚拟卡 */ if ($order['order_amount'] <= 0) { $sql = " SELECT goods_id, goods_name, goods_number AS num FROM ".$GLOBALS['ecs']->table('cart') . " WHERE is_real = 0 AND extension_code = 'virtual_card'". " AND session_id = '".SESS_ID."' AND rec_type = '$flow_type'"; $res = $GLOBALS['db']->getAll($sql); error_log('4',3,'flow.log'); $virtual_goods = array(); foreach ($res AS $row) { $virtual_goods['virtual_card'][] = array('goods_id' => $row['goods_id'], 'goods_name' => $row['goods_name'], 'num' => $row['num']); } if ($virtual_goods AND $flow_type != CART_GROUP_BUY_GOODS) { /* 虚拟卡发货 */ if (virtual_goods_ship($virtual_goods,$msg, $order['order_sn'], true)) { /* 如果没有实体商品,修改发货状态,送积分和红包 */ $sql = "SELECT COUNT(*)" . " FROM " . $ecs->table('order_goods') . " WHERE order_id = '$order[order_id]' " . " AND is_real = 1"; if ($db->getOne($sql) <= 0) { /* 修改订单状态 */ update_order($order['order_id'], array('shipping_status' => SS_SHIPPED, 'shipping_time' => gmtime())); error_log('5',3,'flow.log'); /* 如果订单用户不为空,计算积分,并发给用户;发红包 */ if ($order['user_id'] > 0) { /* 取得用户信息 */ $user = user_info($order['user_id']); /* 计算并发放积分 */ $integral = integral_to_give($order); log_account_change($order['user_id'], 0, 0, intval($integral['rank_points']), intval($integral['custom_points']), sprintf($_LANG['order_gift_integral'], $order['order_sn'])); error_log('6',3,'flow.log'); /* 发放红包 */ send_order_bonus($order['order_id']); } } } } } /* 清空购物车 */ clear_cart($flow_type); error_log('7',3,'flow.log'); /* 清除缓存,否则买了商品,但是前台页面读取缓存,商品数量不减少 */ clear_all_files(); /* 插入支付日志 */ //$order['log_id'] = insert_pay_log($new_order_id, $order['order_amount'], PAY_ORDER); error_log('8',3,'flow.log'); /*取得支付代码 #取得支付信息,生成支付代码 if ($order['order_amount'] > 0) { $payment = payment_info($order['pay_id']); include_once('includes/modules/payment/' . $payment['pay_code'] . '.php'); $pay_obj = new $payment['pay_code']; $pay_online = $pay_obj->get_code($order, unserialize_config($payment['pay_config'])); $order['pay_desc'] = $payment['pay_desc']; $smarty->assign('pay_online', $pay_online); } */ if(!empty($order['shipping_name'])) { $order['shipping_name']=trim(stripcslashes($order['shipping_name'])); } error_log('9',3,'flow.log'); /* #订单信息 $smarty->assign('order', $order); $smarty->assign('total', $total); $smarty->assign('goods_list', $cart_goods); $smarty->assign('order_submit_back', sprintf($_LANG['order_submit_back'], $_LANG['back_home'], $_LANG['goto_user_center'])); // 返回提示 */ //user_uc_call('add_feed', array($order['order_id'], BUY_GOODS)); //推送feed到uc unset($_SESSION['flow_consignee']); // 清除session中保存的收货人信息 unset($_SESSION['flow_order']); unset($_SESSION['direct_shopping']); $order_done = array('order'=>$order,'total'=>$total,'cart_goods'=>$cart_goods); //var_dump($order_done);exit; error_log('10',3,'flow.log'); $order_id = $order['order_id']; $price = $order['order_amount']; $order = array ('order_id'=>$order_id,'order_number'=>$order['order_sn'],'price'=>$price) ; error_log('11',3,'flow.log'); //print_r($order);die; jsonExit($order); }
public function index() { $settings = kohana::config('settings'); $site_name = $settings['site_name']; $alerts_email = $settings['alerts_email']; $unsubscribe_message = Kohana::lang('alerts.unsubscribe') . url::site() . 'alerts/unsubscribe/'; $database_settings = kohana::config('database'); //around line 33 $this->table_prefix = $database_settings['default']['table_prefix']; //around line 34 $settings = NULL; $sms_from = NULL; $db = new Database(); /* Find All Alerts with the following parameters - incident_active = 1 -- An approved incident - incident_alert_status = 1 -- Incident has been tagged for sending Incident Alert Statuses - 0, Incident has not been tagged for sending. Ensures old incidents are not sent out as alerts - 1, Incident has been tagged for sending by updating it with 'approved' or 'verified' - 2, Incident has been tagged as sent. No need to resend again */ $incidents = $db->query("SELECT i.id, incident_title, \n\t\t\t\t\t\t\t\t incident_description, incident_verified, \n\t\t\t\t\t\t\t\t l.latitude, l.longitude, a.alert_id, a.incident_id\n\t\t\t\t\t\t\t\t FROM " . $this->table_prefix . "incident AS i INNER JOIN " . $this->table_prefix . "location AS l ON i.location_id = l.id\n\t\t\t\t\t\t\t\t LEFT OUTER JOIN " . $this->table_prefix . "alert_sent AS a ON i.id = a.incident_id WHERE\n\t\t\t\t\t\t\t\t i.incident_active=1 AND i.incident_alert_status = 1 "); foreach ($incidents as $incident) { $latitude = (double) $incident->latitude; $longitude = (double) $incident->longitude; // Get all alertees $alertees = ORM::factory('alert')->where('alert_confirmed', '1')->find_all(); foreach ($alertees as $alertee) { // Has this alert been sent to this alertee? if ($alertee->id == $incident->alert_id) { continue; } $alert_radius = (int) $alertee->alert_radius; $alert_type = (int) $alertee->alert_type; $latitude2 = (double) $alertee->alert_lat; $longitude2 = (double) $alertee->alert_lon; $distance = (string) new Distance($latitude, $longitude, $latitude2, $longitude2); // If the calculated distance between the incident and the alert fits... if ($distance <= $alert_radius) { if ($alert_type == 1) { if ($settings == null) { $settings = ORM::factory('settings', 1); if ($settings->loaded == true) { // Get SMS Numbers if (!empty($settings->sms_no3)) { $sms_from = $settings->sms_no3; } elseif (!empty($settings->sms_no2)) { $sms_from = $settings->sms_no2; } elseif (!empty($settings->sms_no1)) { $sms_from = $settings->sms_no1; } else { $sms_from = "000"; } // Admin needs to set up an SMS number } } $message = $incident->incident_description; if (sms::send($alertee->alert_recipient, $sms_from, $message) === true) { $alert = ORM::factory('alert_sent'); $alert->alert_id = $alertee->id; $alert->incident_id = $incident->id; $alert->alert_date = date("Y-m-d H:i:s"); $alert->save(); } } elseif ($alert_type == 2) { $to = $alertee->alert_recipient; $from = array(); $from[] = $alerts_email; $from[] = $site_name; $subject = "[{$site_name}] " . $incident->incident_title; $message = $incident->incident_description . "<p>" . $unsubscribe_message . $alertee->alert_code . "</p>"; if (email::send($to, $from, $subject, $message, TRUE) == 1) { $alert = ORM::factory('alert_sent'); $alert->alert_id = $alertee->id; $alert->incident_id = $incident->id; $alert->alert_date = date("Y-m-d H:i:s"); $alert->save(); } } } } // End For Each Loop // Update Incident - All Alerts Have Been Sent! $update_incident = ORM::factory('incident', $incident->id); if ($update_incident->loaded) { $update_incident->incident_alert_status = 2; $update_incident->save(); } } }
public function addOrderHistory($order_id, $data) { $this->db->query("UPDATE `" . DB_PREFIX . "order` SET order_status_id = '" . (int) $data['order_status_id'] . "', date_modified = NOW() WHERE order_id = '" . (int) $order_id . "'"); $this->db->query("INSERT INTO " . DB_PREFIX . "order_history SET order_id = '" . (int) $order_id . "', order_status_id = '" . (int) $data['order_status_id'] . "', notify = '" . (isset($data['notify']) ? (int) $data['notify'] : 0) . "', comment = '" . $this->db->escape(strip_tags($data['comment'])) . "', date_added = NOW()"); $order_info = $this->getOrder($order_id); // Send out any gift voucher mails if ($this->config->get('config_complete_status_id') == $data['order_status_id']) { $this->load->model('sale/voucher'); $results = $this->getOrderVouchers($order_id); foreach ($results as $result) { $this->model_sale_voucher->sendVoucher($result['voucher_id']); } } if ($data['notify']) { $language = new Language($order_info['language_directory']); $language->load($order_info['language_filename']); $language->load('mail/order'); $subject = sprintf($language->get('text_subject'), $order_info['store_name'], $order_id); $message = $language->get('text_order') . ' ' . $order_id . "\n"; $message .= $language->get('text_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_info['date_added'])) . "\n\n"; $order_status_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_status WHERE order_status_id = '" . (int) $data['order_status_id'] . "' AND language_id = '" . (int) $order_info['language_id'] . "'"); if ($order_status_query->num_rows) { $message .= $language->get('text_order_status') . "\n"; $message .= $order_status_query->row['name'] . "\n\n"; } if ($order_info['customer_id']) { $message .= $language->get('text_link') . "\n"; $message .= html_entity_decode($order_info['store_url'] . 'index.php?route=account/order/info&order_id=' . $order_id, ENT_QUOTES, 'UTF-8') . "\n\n"; } if ($data['comment']) { $message .= $language->get('text_comment') . "\n\n"; $message .= strip_tags(html_entity_decode($data['comment'], ENT_QUOTES, 'UTF-8')) . "\n\n"; } $message .= $language->get('text_footer'); $mail = new Mail(); $mail->protocol = $this->config->get('config_mail_protocol'); $mail->parameter = $this->config->get('config_mail_parameter'); $mail->hostname = $this->config->get('config_smtp_host'); $mail->username = $this->config->get('config_smtp_username'); $mail->password = $this->config->get('config_smtp_password'); $mail->port = $this->config->get('config_smtp_port'); $mail->timeout = $this->config->get('config_smtp_timeout'); $mail->setTo($order_info['email']); $mail->setFrom($this->config->get('config_email')); $mail->setSender($order_info['store_name']); $mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8')); $mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8')); $mail->send(); } // start SMS Module if ($data['notifysms'] && $this->config->get('rajasmsindo_statussms')) { $language = new Language($order_info['language_directory']); $language->load($order_info['language_filename']); $language->load('module/rajasmsindo'); $message = sprintf($language->get('text_subject'), $order_info['store_name'], $order_id) . "\n"; $message .= $language->get('text_order') . ' ' . $order_id . "\n"; $message .= $language->get('text_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_info['date_added'])) . "\n"; $order_status_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_status WHERE order_status_id = '" . (int) $data['order_status_id'] . "' AND language_id = '" . (int) $order_info['language_id'] . "'"); if ($order_status_query->num_rows) { $message .= $language->get('text_order_status') . "\n"; $message .= $order_status_query->row['name'] . "\n"; } if ($order_info['customer_id']) { $message .= $language->get('text_link') . "\n"; $message .= html_entity_decode($order_info['store_url'] . 'index.php?route=account/order/info&order_id=' . $order_id, ENT_QUOTES, 'UTF-8') . "\n"; } if ($data['comment']) { $message .= $language->get('text_comment') . "\n"; $message .= strip_tags(html_entity_decode($data['comment'], ENT_QUOTES, 'UTF-8')) . "\n\n"; } $message .= $language->get('text_footer'); $sms = new sms(); $sms->key = $this->config->get('rajasmsindo_key'); $sms->phone = $this->config->get('rajasmsindo_smsphone'); $sms->username = $this->config->get('rajasmsindo_user'); $sms->password = $this->config->get('rajasmsindo_password'); $sms->smsmode = $this->config->get('rajasmsindo_smsmode'); $sms->modem = $this->config->get('rajasmsindo_modem'); $sms->setTo($data['telephone']); $sms->setText($message); $sms->send(); } // end SMS Module $this->load->model('payment/amazon_checkout'); $this->model_payment_amazon_checkout->orderStatusChange($order_id, $data); }
$smarty->display('sms_def.htm'); exit; case 'send': $phones = trim($_POST["phones"]); $content = trim($_POST["content"]); $copy = trim($_POST["copy"]); $result = array("error" => 1, "msg" => "您选择的家长的电话号码全部为空"); if (str_len($phones) > 4) { if ($copy) { $admin = get_admin_by_id($_SESSION["admin_id"]); if (is_moblie($admin["cellphone"])) { $phones .= "," . $admin["cellphone"]; } } $sms = new sms(); $result = $sms->send($phones, $content, $school_code, $class_code, $_SESSION["admin_name"]); } make_json($result); exit; case 'record': $smarty->display('sms_list.htm'); exit; case 'ajax_list': $list = sms_list($class_code, $_SESSION["phone"]); make_json($list); exit; default: die("您访问的页面不存在!"); exit; } /**
//更新数据库数据 $sms_server_id = empty($_POST["sms_server_id"]) ? 0 : intval($_POST["sms_server_id"]); $user = trim($_POST["user"]); $pass = trim($_POST["pass"]); $server = trim($_POST["server"]); $port = trim($_POST["port"]); $total = empty($_POST["total"]) ? 0 : intval($_POST["total"]); $is_active = empty($_POST["is_active"]) ? 0 : intval($_POST["is_active"]); $phone = trim($_POST["phone"]); $sql = "update " . $ecs->table("sms_server") . " set user='******',pass='******',server='{$server}',port='{$port}',is_active='{$is_active}',total='{$total}' where sms_server_id=" . $sms_server_id; $db->query($sql); $msg = "服务器设置成功!"; //短信测试 if ($is_active && str_len($phone) > 3) { $sms = new sms(); $res = $sms->send($phone, "您好,您已开通您的短信服务,感谢您的使用!【磐盛科技】", "", "", $_SESSION["admin_name"]); if ($res['error'] == 1) { $msg .= $res['msg']; } else { $msg .= "请查收短信"; } } sys_msg($msg, 0, array(), false); exit; case 'sense': $smarty->assign('ur_here', "敏感词汇"); $sms = new sms(); $smarty->assign('sense', implode("|", $sms->sense)); assign_query_info(); $smarty->display('sms_sense_info.htm'); exit;
public function send() { $this->load->language('module/rajasmsmassindo'); $json = array(); if ($this->request->server['REQUEST_METHOD'] == 'POST') { if (!$this->user->hasPermission('modify', 'module/rajasmsmassindo')) { $json['error']['warning'] = $this->language->get('error_permission'); } if (!$this->request->post['message']) { $json['error']['message'] = $this->language->get('error_message'); } if (!$this->config->get('rajasmsindo_statussms')) { $json['error']['message'] = $this->language->get('error_disabled'); } if (!$json) { $this->load->model('setting/store'); $store_info = $this->model_setting_store->getStore($this->request->post['store_id']); if ($store_info) { $store_name = $store_info['name']; } else { $store_name = $this->config->get('config_name'); } $this->load->model('sale/customer'); $this->load->model('sale/customer_group'); $this->load->model('sale/affiliate'); $this->load->model('sale/order'); if (isset($this->request->get['page'])) { $page = $this->request->get['page']; } else { $page = 1; } $telephone_total = 0; $telephones = array(); switch ($this->request->post['to']) { case 'newsletter': $customer_data = array('filter_newsletter' => 1, 'start' => ($page - 1) * 10, 'limit' => 10); $telephone_total = $this->model_sale_customer->getTotalCustomers($customer_data); $results = $this->model_sale_customer->getCustomers($customer_data); foreach ($results as $result) { $telephones[] = $result['telephone']; } break; case 'customer_all': $customer_data = array('start' => ($page - 1) * 10, 'limit' => 10); $telephone_total = $this->model_sale_customer->getTotalCustomers($customer_data); $results = $this->model_sale_customer->getCustomers($customer_data); foreach ($results as $result) { $telephones[] = $result['telephone']; } break; case 'customer_group': $customer_data = array('filter_customer_group_id' => $this->request->post['customer_group_id'], 'start' => ($page - 1) * 10, 'limit' => 10); $telephone_total = $this->model_sale_customer->getTotalCustomers($customer_data); $results = $this->model_sale_customer->getCustomers($customer_data); foreach ($results as $result) { $telephones[$result['customer_id']] = $result['telephone']; } break; case 'customer': if (!empty($this->request->post['customer'])) { foreach ($this->request->post['customer'] as $customer_id) { $customer_info = $this->model_sale_customer->getCustomer($customer_id); if ($customer_info) { $telephones[] = $customer_info['telephone']; } } } break; case 'affiliate_all': $affiliate_data = array('start' => ($page - 1) * 10, 'limit' => 10); $telephone_total = $this->model_sale_affiliate->getTotalAffiliates($affiliate_data); $results = $this->model_sale_affiliate->getAffiliates($affiliate_data); foreach ($results as $result) { $telephones[] = $result['telephone']; } break; case 'affiliate': if (!empty($this->request->post['affiliate'])) { foreach ($this->request->post['affiliate'] as $affiliate_id) { $affiliate_info = $this->model_sale_affiliate->getAffiliate($affiliate_id); if ($affiliate_info) { $telephones[] = $affiliate_info['telephone']; } } } break; case 'product': if (isset($this->request->post['product'])) { $telephone_total = $this->model_sale_order->getTotalEmailsByProductsOrdered($this->request->post['product']); $results = $this->model_sale_order->getEmailsByProductsOrdered($this->request->post['product'], ($page - 1) * 10, 10); foreach ($results as $result) { $telephones[] = $result['telephone']; } } break; } $telephones = array_unique($telephones); if ($telephones) { $start = ($page - 1) * 10; $end = $start + 10; if ($end < $telephone_total) { $json['success'] = sprintf($this->language->get('text_sent'), $start, $telephone_total); } else { $json['success'] = $this->language->get('text_success'); } if ($end < $telephone_total) { $json['next'] = str_replace('&', '&', $this->url->link('module/rajasmsmassindo/send', 'token=' . $this->session->data['token'] . '&page=' . ($page + 1))); } else { $json['next'] = ''; } $message = $store_name . ' ' . html_entity_decode($this->request->post['message'], ENT_QUOTES, 'UTF-8'); foreach ($telephones as $nohp) { $sms = new sms(); $sms->key = $this->config->get('rajasmsindo_key'); $sms->phone = $this->config->get('rajasmsindo_smsphone'); $sms->username = $this->config->get('rajasmsindo_user'); $sms->password = $this->config->get('rajasmsindo_password'); $sms->smsmode = $this->config->get('rajasmsindo_smsmode'); $sms->modem = $this->config->get('rajasmsindo_modem'); $sms->setTo($nohp); $sms->setText($message); $sms->send(); } } } } $this->response->setOutput(json_encode($json)); }
<?php error_reporting(E_ALL); ob_implicit_flush(true); include_once "class.curl.php"; include_once "class.sms.php"; include_once "cprint.php"; $smsapp = new sms(); $smsapp->setGateway('way2sms'); $myno = $_POST['fromno']; $p = $_POST['pass']; $tonum = $_POST['tono']; $mess = $_POST['message']; cprint("Logging in ..\n"); $ret = $smsapp->login($myno, $p); if (!$ret) { cprint("Error Logging In"); exit(1); } print "Logged in Successfully\n"; print "Sending SMS ..\n"; $ret = $smsapp->send($tonum, $mess); if (!$ret) { print "Error in sending message"; exit(1); } print "Message sent";
if (!empty($user_id)) { exit(json_encode(array('msg' => '手机号码已存在,请更换手机号码'))); } } elseif ($_GET['flag'] == 'forget') { //找回密码 if (empty($user_id)) { exit(json_encode(array('msg' => "手机号码不存在\n无法通过该号码找回密码"))); } } $mobile_code = random(4, 1); $message = "您的验证码是:" . $mobile_code . ",请不要把验证码泄露给其他人,如非本人操作,可不用理会!"; //暂时关闭 上线后开启 by wang include ROOT_PATH . 'include/cls_sms.php'; $sms = new sms(); $sms_error = array(); $send_result = $sms->send($mobile, $message, $sms_error); write_file($mobile, date("Y-m-d H:i:s")); if ($send_result) { $_SESSION['sms_mobile'] = $mobile; $_SESSION['sms_mobile_code'] = $mobile_code; exit(json_encode(array('code' => 2, 'mobile_code' => $mobile_code))); } else { exit(json_encode(array('msg' => $sms_error))); } } /* * **************************************************** protected function * **************************************************** */ function random($length = 6, $numeric = 0) { PHP_VERSION < '4.2.0' && mt_srand((double) microtime() * 1000000);
/* 增加是否给客服发送邮件选项 */ if ($_CFG['send_service_email'] && $_CFG['service_email'] != '') { $tpl = get_mail_template('remind_of_new_order'); $smarty->assign('order', $order); $smarty->assign('goods_list', $cart_goods); $smarty->assign('shop_name', $_CFG['shop_name']); $smarty->assign('send_date', date($_CFG['time_format'])); $content = $smarty->fetch('str:' . $tpl['template_content']); send_mail($_CFG['shop_name'], $_CFG['service_email'], $tpl['template_subject'], $content, $tpl['is_html']); } /* 如果需要,发短信 */ if ($_CFG['sms_order_placed'] == '1' && $_CFG['sms_shop_mobile'] != '') { include_once 'includes/cls_sms.php'; $sms = new sms(); $msg = $order['pay_status'] == PS_UNPAYED ? $_LANG['order_placed_sms'] : $_LANG['order_placed_sms'] . '[' . $_LANG['sms_paid'] . ']'; $sms->send($_CFG['sms_shop_mobile'], sprintf($msg, $order['consignee'], $order['tel']), 0); } /* 如果订单金额为0 处理虚拟卡 */ if ($order['order_amount'] <= 0) { $sql = "SELECT goods_id, goods_name, goods_number AS num FROM " . $GLOBALS['ecs']->table('cart') . " WHERE is_real = 0 AND extension_code = 'virtual_card'" . " AND session_id = '" . SESS_ID . "' AND rec_type = '{$flow_type}'"; $res = $GLOBALS['db']->getAll($sql); $virtual_goods = array(); foreach ($res as $row) { $virtual_goods['virtual_card'][] = array('goods_id' => $row['goods_id'], 'goods_name' => $row['goods_name'], 'num' => $row['num']); } if ($virtual_goods and $flow_type != CART_GROUP_BUY_GOODS) { /* 虚拟卡发货 */ if (virtual_goods_ship($virtual_goods, $msg, $order['order_sn'], true)) { /* 如果没有实体商品,修改发货状态,送积分和红包 */ $sql = "SELECT COUNT(*)" . " FROM " . $ecs->table('order_goods') . " WHERE order_id = '{$order['order_id']}' " . " AND is_real = 1"; if ($db->getOne($sql) <= 0) {
$db->query($sql); admin_log(addslashes($_REQUEST["name"]), 'update', $sql); make_json_result("修改“" . $_REQUEST["name"] . "”成功!"); } } elseif ($_REQUEST['act'] == 'ajax_changePwd') { $id = !empty($_REQUEST['student_id']) ? intval($_REQUEST['student_id']) : 0; $new_password = !empty($_REQUEST['new_password']) ? trim($_REQUEST['new_password']) : ""; $sql = "update " . $ecs->table("student") . " set password='******' where student_id=" . $id; $db->query($sql); admin_log($_REQUEST["student_id"], 'ajax_changePwd', 'student'); //发送短信提醒 $guardian = $db->getRow("select * from " . $ecs->table("student") . " where student_id=" . $id); require_once ROOT_PATH . '/includes/cls_sms.php'; $content = sms_tmp_change_pwd_by_classAdmin($guardian, $new_password, $_SESSION["admin_name"]); $sms = new sms(); $res = $sms->send($guardian["guardian_phone"], $content, $school_code, $guardian["class_code"], $_SESSION["admin_name"]); if ($res["error"] != 0) { make_json_error("密码更新成功!但是短信发送失败:" + $res["msg"]); exit; } make_json_result("密码更新成功!"); } elseif ($_REQUEST['act'] == 'ajax_delete') { $id = !empty($_REQUEST['student_id']) ? intval($_REQUEST['student_id']) : 0; $sql = "delete from " . $ecs->table("student") . " where student_id=" . $id; $db->query($sql); admin_log($_REQUEST["student_id"], 'delete', 'student'); make_json_result("删除成功!"); } elseif ($_REQUEST['act'] == 'export') { $list = student_list(); $content = "序号,学号,姓名,性别,出生年月,民族,身份证,电话,邮箱,住址,是否已离校,家长,家长电话,与家长关系,创建日期\n"; foreach ($list["rows"] as $k => $v) {
$smarty->assign('send_time', local_date($_CFG['time_format'])); $smarty->assign('shop_name', $_CFG['shop_name']); $smarty->assign('send_date', local_date($_CFG['date_format'])); $smarty->assign('sent_date', local_date($_CFG['date_format'])); $smarty->assign('confirm_url', $ecs->url() . 'receive.php?id=' . $order['order_id'] . '&con=' . rawurlencode($order['consignee'])); $smarty->assign('send_msg_url', $ecs->url() . 'user.php?act=message_list&order_id=' . $order['order_id']); $content = $smarty->fetch('str:' . $tpl['template_content']); if (!send_mail($order['consignee'], $order['email'], $tpl['template_subject'], $content, $tpl['is_html'])) { $msg = $_LANG['send_mail_fail']; } } /* 如果需要,发短信 */ if ($GLOBALS['_CFG']['sms_order_shipped'] == '1' && $order['mobile'] != '') { include_once '../includes/cls_sms.php'; $sms = new sms(); $sms->send($order['mobile'], sprintf($GLOBALS['_LANG']['order_shipped_sms'], $order['order_sn'], local_date($GLOBALS['_LANG']['sms_time_format']), $GLOBALS['_CFG']['shop_name']), 0); } } /* 清除缓存 */ clear_cache_files(); /* 操作成功 */ $links[] = array('text' => $_LANG['09_delivery_order'], 'href' => 'order.php?act=delivery_list'); $links[] = array('text' => $_LANG['delivery_sn'] . $_LANG['detail'], 'href' => 'order.php?act=delivery_info&delivery_id=' . $delivery_id); sys_msg($_LANG['act_ok'], 0, $links); } elseif ($_REQUEST['act'] == 'delivery_cancel_ship') { /* 检查权限 */ admin_priv('delivery_view'); /* 取得参数 */ $delivery = ''; $order_id = intval(trim($_REQUEST['order_id'])); // 订单id
public function index() { $settings = kohana::config('settings'); $site_name = $settings['site_name']; $alerts_email = $settings['alerts_email'] ? $settings['alerts_email'] : $settings['site_email']; $unsubscribe_message = Kohana::lang('alerts.unsubscribe') . url::site() . 'alerts/unsubscribe/'; $database_settings = kohana::config('database'); //around line 33 $this->table_prefix = $database_settings['default']['table_prefix']; //around line 34 $settings = NULL; $sms_from = NULL; $db = new Database(); /* Find All Alerts with the following parameters - incident_active = 1 -- An approved incident - incident_alert_status = 1 -- Incident has been tagged for sending Incident Alert Statuses - 0, Incident has not been tagged for sending. Ensures old incidents are not sent out as alerts - 1, Incident has been tagged for sending by updating it with 'approved' or 'verified' - 2, Incident has been tagged as sent. No need to resend again */ // HT: New Code // Fixes an issue with one report being sent out as an alert more than ones // becoming spam to users $incident_query = "SELECT i.id, incident_title,\n\t\t\t\tincident_description, incident_verified,\n\t\t\t\tl.latitude, l.longitude FROM " . $this->table_prefix . "incident AS i INNER JOIN " . $this->table_prefix . "location AS l ON i.location_id = l.id\n\t\t\t\tWHERE i.incident_active=1 AND i.incident_alert_status = 1 "; /** HT: Code for alert days limitation * @int alert_days = 0 : All alerts * @int alert_days = 1 : TODAY * @int alert_days > 1 : alert_days - 1 days before */ if ($alert_days = $settings['alert_days']) { $incident_query .= "AND DATE(i.incident_date) >= DATE_SUB( CURDATE(), INTERVAL " . ($alert_days - 1) . " DAY )"; } // End of New Code $incidents = $db->query($incident_query); foreach ($incidents as $incident) { // ** Pre-Formatting Message ** // // Convert HTML to Text $incident_description = $incident->incident_description; $incident_url = url::site() . 'reports/view/' . $incident->id; $incident_description = html::clean($incident_description); // EMAIL MESSAGE $email_message = $incident_description . "\n\n" . $incident_url; // SMS MESSAGE $sms_message = $incident_description; // Remove line breaks $sms_message = str_replace("\n", " ", $sms_message); // Shorten to text message size if (Kohana::config("settings.sms_alert_url")) { $sms_message = text::limit_chars($sms_message, 100, "..."); // HT: Decreased sms lenght of sms to add incident_url $sms_message .= " " . $incident_url; // HT: Added incident_url to sms } else { $sms_message = text::limit_chars($sms_message, 150, "..."); } $latitude = (double) $incident->latitude; $longitude = (double) $incident->longitude; // Find all the catecories including parents $category_ids = $this->_find_categories($incident->id); // HT: New Code $alert_sent = ORM::factory('alert_sent')->where('incident_id', $incident->id)->select_list('id', 'alert_id'); $alertObj = ORM::factory('alert')->where('alert_confirmed', '1'); if (!empty($alert_sent)) { $alertObj->notin('id', $alert_sent); } $alertees = $alertObj->find_all(); // End of new code foreach ($alertees as $alertee) { // HT: check same alert_receipent multi subscription does not get multiple alert if ($this->_multi_subscribe($alertee, $incident->id)) { continue; } // Check the categories if (!$this->_check_categories($alertee, $category_ids)) { continue; } $alert_radius = (int) $alertee->alert_radius; $alert_type = (int) $alertee->alert_type; $latitude2 = (double) $alertee->alert_lat; $longitude2 = (double) $alertee->alert_lon; $distance = (string) new Distance($latitude, $longitude, $latitude2, $longitude2); // If the calculated distance between the incident and the alert fits... if ($distance <= $alert_radius) { if ($alert_type == 1) { // Get SMS Numbers if (Kohana::config("settings.sms_no3")) { $sms_from = Kohana::config("settings.sms_no3"); } elseif (Kohana::config("settings.sms_no2")) { $sms_from = Kohana::config("settings.sms_no2"); } elseif (Kohana::config("settings.sms_no1")) { $sms_from = Kohana::config("settings.sms_no1"); } else { $sms_from = "12053705050"; } // Admin needs to set up an SMS number if ($response = sms::send($alertee->alert_recipient, $sms_from, $sms_message) === true) { $alert = ORM::factory('alert_sent'); $alert->alert_id = $alertee->id; $alert->incident_id = $incident->id; $alert->alert_date = date("Y-m-d H:i:s"); $alert->save(); } else { // The gateway couldn't send for some reason // in future we'll keep a record of this } } elseif ($alert_type == 2) { $to = $alertee->alert_recipient; $from = array(); $from[] = $alerts_email; $from[] = $site_name; $subject = "[{$site_name}] " . $incident->incident_title; $message = text::auto_p($email_message . "\n\n" . $unsubscribe_message . $alertee->alert_code . "\n"); //if (email::send($to, $from, $subject, $message, FALSE) == 1) if (email::send($to, $from, $subject, $message, TRUE) == 1) { $alert = ORM::factory('alert_sent'); $alert->alert_id = $alertee->id; $alert->incident_id = $incident->id; $alert->alert_date = date("Y-m-d H:i:s"); $alert->save(); } } } } // End For Each Loop // Update Incident - All Alerts Have Been Sent! $update_incident = ORM::factory('incident', $incident->id); if ($update_incident->loaded) { $update_incident->incident_alert_status = 2; $update_incident->save(); } } }
/** * Send A New Message Using Default SMS Provider */ public function send() { $this->template = ""; $this->auto_render = FALSE; // Setup and initialize form field names $form = array('to_id' => '', 'message' => ''); // Copy the form as errors, so the errors will be stored with keys // corresponding to the form field names $errors = $form; $form_error = FALSE; // Check, has the form been submitted, if so, setup validation if ($_POST) { // Instantiate Validation, use $post, so we don't overwrite $_POST // fields with our own things $post = new Validation($_POST); // Add some filters $post->pre_filter('trim', TRUE); // Add some rules, the input field, followed by a list of checks, carried out in order $post->add_rules('to_id', 'required', 'numeric'); $post->add_rules('message', 'required', 'length[1,160]'); // Test to see if things passed the rule checks if ($post->validate()) { // Yes! everything is valid $reply_to = ORM::factory('message', $post->to_id); if ($reply_to->loaded == true) { // Yes! Replyto Exists // This is the message we're replying to $sms_to = $reply_to->message_from; //checks if the number is encrypted if (preg_match("/([a-zA-Z])(\\D)/", $sms_to)) { $this->decrypter = new Encrypt(); $sms_to = $this->decrypter->decode($sms_to); } else { $sms_to = $sms_to; } // Load Users Settings $settings = Settings_Model::get_array(); if (!empty($settings)) { // Get SMS Numbers if (!empty($settings['sms_no1'])) { $sms_from = $settings['sms_no1']; } elseif (!empty($settings['sms_no2'])) { $sms_from = $settings['sms_no2']; } elseif (!empty($settings['sms_no3'])) { $sms_from = $settings['sms_no3']; } else { // User needs to set up an SMS number $sms_from = "000"; } // Send Message $response = sms::send($sms_to, $sms_from, $post->message); // Message Went Through?? if ($response === TRUE) { $message = ORM::factory('message'); $message->parent_id = $post->to_id; // The parent message $message->message_from = $sms_from; $message->message_to = $sms_to; $message->message = $post->message; $message->message_type = 2; // This is an outgoing message $message->reporter_id = $reply_to->reporter_id; $message->message_date = date("Y-m-d H:i:s", time()); $message->save(); echo json_encode(array("status" => "sent", "message" => Kohana::lang('ui_admin.message_sent'))); } else { // Message Failed echo json_encode(array("status" => "error", "message" => Kohana::lang('ui_admin.error_msg') . " - " . $response)); } } else { echo json_encode(array("status" => "error", "message" => Kohana::lang('ui_admin.error_msg') . Kohana::lang('ui_admin.check_sms_settings'))); } } else { // Send_To Mobile Number Doesn't Exist echo json_encode(array("status" => "error", "message" => Kohana::lang('ui_admin.error_msg') . Kohana::lang('ui_admin.check_number'))); } } else { // Populate the error fields, if any $errors = arr::overwrite($errors, $post->errors('messages')); echo json_encode(array("status" => "error", "message" => Kohana::lang('ui_admin.error_msg') . Kohana::lang('ui_admin.check_message_valid'))); } } }
$tg_order_id = $db->insert_id(); $sql = "update " . $ecs->table('takegoods') . " set tg_order_id='{$tg_order_id}', used_time='{$add_time}' where tg_id='{$takegoods_id_www_com}' "; $db->query($sql); if ($_CFG['takegoods_send_email'] == '1' || $_CFG['takegoods_send_sms'] == '1') { $take_user_name = $db->getOne("select user_name from " . $ecs->table('users') . " where user_id='{$user_id}' "); $content1 = '会员 ' . $take_user_name . ' 于 ' . local_date('Y-m-d H:i:s') . " 提货成功!请尽快安排发货。"; $content2 = '恭喜您于 ' . local_date('Y-m-d H:i:s') . " 提货成功!商家会尽快安排给您发货。"; if ($_CFG['takegoods_send_email'] == '1') { $admin_email = $db->getOne("select email from " . $ecs->table('admin_user') . " where user_id=1 "); send_mail($_CFG['shop_name'], $admin_email, '卡号:' . $takegoods_sn_www_com . ' 提货成功', $content1, 0); send_mail($_CFG['shop_name'], $email, '卡号:' . $takegoods_sn_www_com . ' 提货成功', $content2, 0); } if ($_CFG['takegoods_send_sms'] == '1') { include_once 'includes/cls_sms.php'; $sms = new sms(); $sms->send($_CFG['service_phone'], $content2, '', 13, 1); $sms->send($mobile, $content1, '', 13, 1); } } $country_name = $db->getOne("select region_name from " . $ecs->table('region') . " where region_id='{$country}' "); $province_name = $db->getOne("select region_name from " . $ecs->table('region') . " where region_id='{$province}' "); $city_name = $db->getOne("select region_name from " . $ecs->table('region') . " where region_id='{$city}' "); $district_name = $db->getOne("select region_name from " . $ecs->table('region') . " where region_id='{$district}' "); show_message('提货成功,货品将配送到' . $country_name . ' ' . $province_name . ' ' . $city_name . ' ' . $district_name . ' ' . $address . ',请注意查收', '去购物', '.'); } elseif ($_REQUEST['act'] == 'buy') { } /*------------------------------------------------------ */ //-- PRIVATE FUNCTION /*------------------------------------------------------ */ /** * 获得积分兑换商品的详细信息