function sendsms($sms_sender, $sms_footer, $sms_to, $sms_msg, $uid, $gpid = 0, $sms_type = 'text', $unicode = 0) { global $datetime_now, $core_config, $gateway_module; // make sure sms_datetime is in supported format and in GMT+0 // timezone used for outgoing message is not module timezone, but gateway timezone // module gateway may have set already to +0000 (such kannel and clickatell) $sms_datetime = core_adjust_datetime($core_config['datetime']['now'], $core_config['main']['cfg_datetime_timezone']); // sent sms will be handled by plugin/tools/* first $ret_intercept = interceptsendsms($sms_sender, $sms_footer, $sms_to, $sms_msg, $uid, $gpid, $sms_type, $unicode); if ($ret_intercept['modified']) { $sms_sender = $ret_intercept['param']['mobile_sender'] ? $ret_intercept['param']['mobile_sender'] : $sms_sender; $sms_footer = $ret_intercept['param']['sms_footer'] ? $ret_intercept['param']['sms_footer'] : $sms_footer; $sms_to = $ret_intercept['param']['sms_to'] ? $ret_intercept['param']['sms_to'] : $sms_to; $sms_msg = $ret_intercept['param']['sms_msg'] ? $ret_intercept['param']['sms_msg'] : $sms_msg; $uid = $ret_intercept['param']['uid'] ? $ret_intercept['param']['uid'] : $uid; $gpid = $ret_intercept['param']['gpid'] ? $ret_intercept['param']['gpid'] : $gpid; $sms_type = $ret_intercept['param']['sms_type'] ? $ret_intercept['param']['sms_type'] : $sms_type; $unicode = $ret_intercept['param']['unicode'] ? $ret_intercept['param']['unicode'] : $unicode; } // fixme anton - mobile number can be anything, screened by gateway // $sms_sender = sendsms_getvalidnumber($sms_sender); $ok = false; $username = uid2username($uid); $sms_to = sendsms_getvalidnumber($sms_to); logger_print("start", 3, "sendsms"); if (rate_cansend($username, $sms_to)) { // fixme anton - its a total mess ! need another DBA $sms_footer = addslashes($sms_footer); $sms_msg = addslashes($sms_msg); // we save all info first and then process with gateway module // the thing about this is that message saved may not be the same since gateway may not be able to process // message with that length or certain characters in the message are not supported by the gateway $db_query = "\n \t INSERT INTO " . _DB_PREF_ . "_tblSMSOutgoing \n \t (uid,p_gpid,p_gateway,p_src,p_dst,p_footer,p_msg,p_datetime,p_sms_type,unicode) \n \t VALUES ('{$uid}','{$gpid}','{$gateway_module}','{$sms_sender}','{$sms_to}','{$sms_footer}','{$sms_msg}','{$sms_datetime}','{$sms_type}','{$unicode}')\n\t"; logger_print("saving:{$uid},{$gpid},{$gateway_module},{$sms_sender},{$sms_to},{$sms_type},{$unicode}", 3, "sendsms"); // continue to gateway only when save to db is true if ($smslog_id = @dba_insert_id($db_query)) { logger_print("smslog_id:" . $smslog_id . " saved", 3, "sendsms"); // fixme anton - another mess ! $sms_footer = stripslashes($sms_footer); $sms_msg = stripslashes($sms_msg); if (x_hook($gateway_module, 'sendsms', array($sms_sender, $sms_footer, $sms_to, $sms_msg, $uid, $gpid, $smslog_id, $sms_type, $unicode))) { // fixme anton - deduct user's credit as soon as gateway returns true rate_deduct($smslog_id); $ok = true; } } } $ret['status'] = $ok; $ret['smslog_id'] = $smslog_id; return $ret; }
function recvsms_inbox_add($sms_datetime, $sms_sender, $target_user, $message, $sms_receiver = "", $reference_id = '') { global $core_config; // sms to inbox will be handled by plugins first $ret_intercept = recvsms_inbox_add_intercept($sms_datetime, $sms_sender, $target_user, $message, $sms_receiver, $reference_id); if ($ret_intercept['param_modified']) { $sms_datetime = $ret_intercept['param']['sms_datetime'] ? $ret_intercept['param']['sms_datetime'] : $sms_datetime; $sms_sender = $ret_intercept['param']['sms_sender'] ? $ret_intercept['param']['sms_sender'] : $sms_sender; $target_user = $ret_intercept['param']['target_user'] ? $ret_intercept['param']['target_user'] : $target_user; $message = $ret_intercept['param']['message'] ? $ret_intercept['param']['message'] : $message; $sms_receiver = $ret_intercept['param']['sms_receiver'] ? $ret_intercept['param']['sms_receiver'] : $sms_receiver; $reference_id = $ret_intercept['param']['reference_id'] ? $ret_intercept['param']['reference_id'] : $reference_id; } $ok = FALSE; if ($sms_sender && $target_user && $message) { $user = user_getdatabyusername($target_user); if ($uid = $user['uid']) { // discard if banned if (user_banned_get($uid)) { logger_print("user banned, message ignored uid:" . $uid, 2, "recvsms_inbox_add"); return FALSE; } // get name from target_user's phonebook $c_name = ''; if (substr($sms_sender, 0, 1) == '@') { $c_username = str_replace('@', '', $sms_sender); $c_name = user_getfieldbyusername($c_username, 'name'); } else { $c_name = phonebook_number2name($uid, $sms_sender); } $sender = $c_name ? $c_name . ' (' . $sms_sender . ')' : $sms_sender; // forward to Inbox if ($fwd_to_inbox = $user['fwd_to_inbox']) { $db_query = "\n\t\t\t\t\tINSERT INTO " . _DB_PREF_ . "_tblSMSInbox\n\t\t\t\t\t(in_sender,in_receiver,in_uid,in_msg,in_datetime,reference_id)\n\t\t\t\t\tVALUES ('{$sms_sender}','{$sms_receiver}','{$uid}','{$message}','" . core_adjust_datetime($sms_datetime) . "','{$reference_id}')\n\t\t\t\t"; logger_print("saving sender:" . $sms_sender . " receiver:" . $sms_receiver . " target:" . $target_user . " reference_id:" . $reference_id, 2, "recvsms_inbox_add"); if ($inbox_id = @dba_insert_id($db_query)) { logger_print("saved id:" . $inbox_id . " sender:" . $sms_sender . " receiver:" . $sms_receiver . " target:" . $target_user, 2, "recvsms_inbox_add"); $ok = TRUE; } } // forward to email, consider site config too if ($parent_uid = user_getparentbyuid($uid)) { $site_config = site_config_get($parent_uid); } $web_title = $site_config['web_title'] ? $site_config['web_title'] : $core_config['main']['web_title']; $email_service = $site_config['email_service'] ? $site_config['email_service'] : $core_config['main']['email_service']; $email_footer = $site_config['email_footer'] ? $site_config['email_footer'] : $core_config['main']['email_footer']; $sms_receiver = $sms_receiver ? $sms_receiver : '-'; if ($fwd_to_email = $user['fwd_to_email']) { if ($email = $user['email']) { $subject = _('Message from') . " " . $sender; $body = $web_title . "\n\n"; $body .= _('Message received at') . " " . $sms_receiver . " " . _('on') . " " . $sms_datetime . "\n\n"; $body .= _('From') . " " . $sender . "\n\n"; $body .= $message . "\n\n--\n"; $body .= $email_footer . "\n\n"; $body = stripslashes($body); logger_print("send email from:" . $email_service . " to:" . $email . " message:[" . $message . "]", 3, "recvsms_inbox_add"); $data = array('mail_from_name' => $web_title, 'mail_from' => $email_service, 'mail_to' => $email, 'mail_subject' => $subject, 'mail_body' => $body); sendmail($data); logger_print("sent email from:" . $email_service . " to:" . $email, 3, "recvsms_inbox_add"); } } // forward to mobile if ($fwd_to_mobile = $user['fwd_to_mobile']) { if ($mobile = $user['mobile']) { // fixme anton $c_message = $message . ' ' . $sender; if ($sender_uid = user_mobile2uid($sms_sender)) { if ($sender_username = user_uid2username($sender_uid)) { $c_message = $message . ' ' . '@' . $sender_username; } } $message = $c_message; $unicode = core_detect_unicode($message); $nofooter = TRUE; logger_print("send to mobile:" . $mobile . " from:" . $sms_sender . " user:"******" message:" . $message, 3, "recvsms_inbox_add"); list($ok, $to, $smslog_id, $queue) = sendsms($target_user, $mobile, $message, 'text', $unicode, '', $nofooter); if ($ok[0] == 1) { logger_print("sent to mobile:" . $mobile . " from:" . $sms_sender . " user:"******"recvsms_inbox_add"); } } } } } return $ok; }
/** * Create SMS queue * * @global array $core_config * @param string $sms_sender * @param string $sms_footer * @param string $sms_msg * @param integer $uid * @param integer $gpid * @param string $sms_type * @param integer $unicode * @param string $sms_schedule * @param string $smsc * @return string Queue code */ function sendsms_queue_create($sms_sender, $sms_footer, $sms_msg, $uid, $gpid = 0, $sms_type = 'text', $unicode = 0, $sms_schedule = '', $smsc = '') { global $core_config; $ret = FALSE; $dt = core_get_datetime(); $sms_schedule = trim($sms_schedule) ? core_adjust_datetime($sms_schedule) : $dt; $queue_code = md5(uniqid($uid . $gpid, true)); logger_print("saving queue_code:" . $queue_code . " src:" . $sms_sender, 2, "sendsms_queue_create"); // message entering this proc already stripslashed, we need to addslashes it before saving to db $sms_sender = addslashes($sms_sender); $sms_msg = addslashes($sms_msg); $sms_footer = addslashes($sms_footer); $db_query = "INSERT INTO " . _DB_PREF_ . "_tblSMSOutgoing_queue "; $db_query .= "(queue_code,datetime_entry,datetime_scheduled,uid,gpid,sender_id,footer,message,sms_type,unicode,smsc,flag) "; $db_query .= "VALUES ('{$queue_code}','" . $dt . "','" . $sms_schedule . "','{$uid}','{$gpid}','{$sms_sender}','{$sms_footer}','{$sms_msg}','{$sms_type}','{$unicode}','{$smsc}','2')"; if ($id = dba_insert_id($db_query)) { logger_print("saved queue_code:" . $queue_code . " id:" . $id, 2, "sendsms_queue_create"); $ret = $queue_code; } return $ret; }
/** * Get current server date and time in GMT+0 * * @return current date and time */ function core_get_datetime() { global $core_config; $tz = core_get_timezone(); $dt = date($core_config['datetime']['format'], time()); $ret = core_adjust_datetime($dt, $tz); return $ret; }
function schedule_hook_playsmsd() { global $core_config; // fetch every minutes if (!core_playsmsd_timer(60)) { return; } // mark a start //_log('start scheduler', 2, 'schedule_hook_playsmsd'); // get current server time $current_datetime = core_display_datetime(core_get_datetime()); $current_timestamp = strtotime($current_datetime); // collect active schedules $conditions = array('flag_active' => 1, 'flag_deleted' => 0); $schedules = dba_search(_DB_PREF_ . '_featureSchedule', '*', $conditions); foreach ($schedules as $sch) { $schedule_id = $sch['id']; $uid = $sch['uid']; $schedule_name = $sch['name']; $schedule_rule = (int) $sch['schedule_rule']; // collect destinations $conditions = array('schedule_id' => $schedule_id); $destinations = dba_search(_DB_PREF_ . '_featureSchedule_dst', '*', $conditions, '', $extras); foreach ($destinations as $dst) { $id = $dst['id']; $name = $dst['name']; $schedule_message = str_ireplace('#NAME#', $name, $sch['message']); $destination = $dst['destination']; $schedule = $dst['schedule'] ? core_display_datetime($dst['schedule']) : '0000-00-00 00:00:00'; $scheduled = $dst['scheduled'] ? core_display_datetime($dst['scheduled']) : '0000-00-00 00:00:00'; if (!$scheduled || $scheduled == '0000-00-00 00:00:00') { $scheduled = $schedule; } $scheduled_timestamp = strtotime($scheduled); //_log('uid:' . $uid . ' schedule_id:' . $schedule_id . ' id:' . $id . ' rule:' . $schedule_rule . ' current:[' . $current_datetime . '] schedule:[' . $schedule . '] scheduled:[' . $scheduled . ']', 2, 'schedule_hook_playsmsd'); $continue = FALSE; if ($current_timestamp >= $scheduled_timestamp) { switch ($schedule_rule) { // once case '0': //$scheduled = '2038-01-19 10:14:07'; $scheduled = '2030-01-19 10:14:07'; $scheduled = core_adjust_datetime($scheduled); $scheduled_timestamp = strtotime($current_datetime); $scheduled_display = $current_datetime; $continue = TRUE; break; // Annually // Annually case '1': $current_schedule = date('Y', $current_timestamp) . '-' . date('m-d H:i:s', strtotime($schedule)); $next = ''; if ($current_timestamp > strtotime($current_schedule)) { $next = '+1 year'; } $scheduled = date($core_config['datetime']['format'], strtotime($next . ' ' . $current_schedule)); $scheduled = core_adjust_datetime($scheduled); $scheduled_timestamp = strtotime($scheduled); $scheduled_display = core_display_datetime($scheduled); $continue = TRUE; break; // Monthly // Monthly case '2': $current_schedule = date('Y-m', $current_timestamp) . '-' . date('d H:i:s', strtotime($schedule)); $next = ''; if ($current_timestamp > strtotime($current_schedule)) { $next = '+1 month'; } $scheduled = date($core_config['datetime']['format'], strtotime($next . ' ' . $current_schedule)); $scheduled = core_adjust_datetime($scheduled); $scheduled_timestamp = strtotime($scheduled); $scheduled_display = core_display_datetime($scheduled); $continue = TRUE; break; // Weekly // Weekly case '3': $current_schedule = date('Y-m-d', $current_timestamp) . ' ' . date('H:i:s', strtotime($schedule)); $current_day = date('l', strtotime($current_schedule)); $next = ''; if ($current_timestamp > strtotime($current_schedule)) { $next = 'next ' . $current_day; } $scheduled = date($core_config['datetime']['format'], strtotime($next . ' ' . $current_schedule)); $scheduled = core_adjust_datetime($scheduled); $scheduled_timestamp = strtotime($scheduled); $scheduled_display = core_display_datetime($scheduled); $continue = TRUE; break; // Daily // Daily case '4': $current_schedule = date('Y-m-d', $current_timestamp) . ' ' . date('H:i:s', strtotime($schedule)); $next = ''; if ($current_timestamp > strtotime($current_schedule)) { $next = '+1 day'; } $scheduled = date($core_config['datetime']['format'], strtotime($next . ' ' . $current_schedule)); $scheduled = core_adjust_datetime($scheduled); $scheduled_timestamp = strtotime($scheduled); $scheduled_display = core_display_datetime($scheduled); $continue = TRUE; break; } } if ($continue) { // set scheduled to next time $items = array('c_timestamp' => mktime(), 'scheduled' => $scheduled); $conditions = array('schedule_id' => $schedule_id, 'id' => $id); if (dba_update(_DB_PREF_ . '_featureSchedule_dst', $items, $conditions, 'AND')) { // if the interval is under an hour then go ahead, otherwise expired $interval = $current_timestamp - $scheduled_timestamp; if ($interval <= 3600) { _log('sendsms uid:' . $uid . ' schedule_id:' . $schedule_id . ' id:' . $id . ' rule:' . $schedule_rule . ' schedule:[' . $schedule . '] scheduled:[' . $scheduled_display . ']', 2, 'schedule_hook_playsmsd'); $username = user_uid2username($uid); sendsms_helper($username, $destination, $schedule_message, 'text', $unicode); } else { _log('expired uid:' . $uid . ' schedule_id:' . $schedule_id . ' id:' . $id . ' rule:' . $schedule_rule . ' schedule:[' . $schedule . '] scheduled:[' . $scheduled_display . '] interval:' . $interval, 2, 'schedule_hook_playsmsd'); } } else { _log('fail update uid:' . $uid . ' schedule_id:' . $schedule_id . ' id:' . $id . ' rule:' . $schedule_rule . ' schedule:[' . $schedule . '] scheduled:[' . $scheduled_display . ']', 2, 'schedule_hook_playsmsd'); } } } } // mark an end //_log('end scheduler', 2, 'schedule_hook_playsmsd'); }
case "dst_edit_yes": $id = $_REQUEST['id']; // destination ID $schedule_id = $_REQUEST['schedule_id']; // schedule ID $db_query = "SELECT * FROM " . _DB_PREF_ . "_featureSchedule WHERE uid='" . $user_config['uid'] . "' AND id='{$schedule_id}' AND flag_deleted='0'"; $db_result = dba_query($db_query); $db_row = dba_fetch_array($db_result); $schedule_name = $db_row['name']; $schedule_message = $db_row['message']; if ($id && $schedule_id && $schedule_name && $schedule_message) { $name = $_POST['name']; $destination = $_POST['destination']; $schedule = trim($_POST['schedule']); if ($name && $destination && $schedule) { $schedule = $schedule ? core_adjust_datetime($schedule) : '0000-00-00 00:00:00'; $db_query = "\n\t\t\t\t\tUPDATE " . _DB_PREF_ . "_featureSchedule_dst\n\t\t\t\t\tSET c_timestamp='" . mktime() . "',name='{$name}',destination='{$destination}',schedule='{$schedule}',scheduled='0000-00-00 00:00:00'\n\t\t\t\t\tWHERE schedule_id='{$schedule_id}' AND id='{$id}'"; if (@dba_affected_rows($db_query)) { $_SESSION['dialog']['info'][] = _('Destination has been edited'); } else { $_SESSION['dialog']['info'][] = _('Fail to edit destination'); } } else { $_SESSION['dialog']['info'][] = _('Mandatory fields must not be empty'); } header("Location: " . _u('index.php?app=main&inc=feature_schedule&route=manage&op=dst_edit&schedule_id=' . $schedule_id . '&id=' . $id)); exit; } else { auth_block(); } break;
$_SESSION['dialog']['info'][] = _('Fail to upload CSV file'); header("Location: " . _u('index.php?app=main&inc=feature_schedule&route=import&op=list&schedule_id=' . $schedule_id)); exit; } break; case "import_yes": @set_time_limit(0); $num = $_POST['number_of_row']; $session_import = $_POST['session_import']; $data = $_SESSION['tmp'][$session_import]; foreach ($data as $d) { $name = trim($d[0]); $destination = trim($d[1]); $schedule = trim($d[2]); if ($name && $destination && $schedule) { $schedule = core_adjust_datetime($schedule); // add destiantions, replace existing entry with the same name if (dba_isexists(_DB_PREF_ . '_featureSchedule_dst', array('schedule_id' => $schedule_id, 'name' => $name), 'AND')) { // update $items = array('c_timestamp' => mktime(), 'schedule' => $schedule, 'scheduled' => '0000-00-00 00:00:00'); $conditions = array('schedule_id' => $schedule_id, 'name' => $name, 'destination' => $destination); dba_update(_DB_PREF_ . '_featureSchedule_dst', $items, $conditions); } else { // insert $items = array('schedule_id' => $schedule_id, 'schedule' => $schedule, 'scheduled' => '0000-00-00 00:00:00', 'name' => $name, 'destination' => $destination); dba_add(_DB_PREF_ . '_featureSchedule_dst', $items); } } } $_SESSION['dialog']['info'][] = _('Entries in CSV file have been imported'); header("Location: " . _u('index.php?app=main&inc=feature_schedule&route=import&op=list&schedule_id=' . $schedule_id));
function setsmsincomingaction($sms_datetime, $sms_sender, $message, $sms_receiver = "") { global $gateway_module, $core_config; // make sure sms_datetime is in supported format and in GMT+0 $sms_datetime = core_adjust_datetime($sms_datetime); // incoming sms will be handled by plugin/tools/* first $ret_intercept = interceptincomingsms($sms_datetime, $sms_sender, $message, $sms_receiver); if ($ret_intercept['modified']) { $sms_datetime = $ret_intercept['param']['sms_datetime'] ? $ret_intercept['param']['sms_datetime'] : $sms_datetime; $sms_sender = $ret_intercept['param']['sms_sender'] ? $ret_intercept['param']['sms_sender'] : $sms_sender; $message = $ret_intercept['param']['message'] ? $ret_intercept['param']['message'] : $message; $sms_receiver = $ret_intercept['param']['sms_receiver'] ? $ret_intercept['param']['sms_receiver'] : $sms_receiver; } // if hooked function returns cancel=true then stop the processing incoming sms, return false if ($ret_intercept['cancel']) { logger_print("cancelled datetime:" . $sms_datetime . " sender:" . $sms_sender . " receiver:" . $sms_receiver . " message:" . $message, 3, "setsmsincomingaction"); return false; } $c_uid = 0; $c_feature = ""; $ok = false; $array_target_keyword = explode(" ", $message); $target_keyword = strtoupper(trim($array_target_keyword[0])); $message_full = $message; $message = $array_target_keyword[1]; for ($i = 2; $i < count($array_target_keyword); $i++) { $message .= " " . $array_target_keyword[$i]; } switch ($target_keyword) { case "BC": $c_uid = mobile2uid($sms_sender); $c_username = uid2username($c_uid); $c_feature = 'core'; $array_target_group = explode(" ", $message); $target_group = strtoupper(trim($array_target_group[0])); $c_gpid = phonebook_groupcode2id($c_uid, $target_group); $message = $array_target_group[1]; for ($i = 2; $i < count($array_target_group); $i++) { $message .= " " . $array_target_group[$i]; } logger_print("username:"******" gpid:" . $c_gpid . " sender:" . $sms_sender . " receiver:" . $sms_receiver . " message:" . $message, 3, "setsmsincomingaction bc"); list($ok, $to, $queue) = sendsms_bc($c_username, $c_gpid, $message); $ok = true; break; case "PV": $c_feature = 'core'; $array_target_user = explode(" ", $message); $target_user = strtoupper(trim($array_target_user[0])); $c_uid = username2uid($target_user); $message = $array_target_user[1]; for ($i = 2; $i < count($array_target_user); $i++) { $message .= " " . $array_target_user[$i]; } logger_print("datetime:" . $sms_datetime . " sender:" . $sms_sender . " receiver:" . $sms_receiver . " target:" . $target_user . " message:" . $message, 3, "setsmsincomingaction pv"); if (insertsmstoinbox($sms_datetime, $sms_sender, $target_user, $message, $sms_receiver)) { $ok = true; } break; default: for ($c = 0; $c < count($core_config['featurelist']); $c++) { $c_feature = $core_config['featurelist'][$c]; $ret = x_hook($c_feature, 'setsmsincomingaction', array($sms_datetime, $sms_sender, $target_keyword, $message, $sms_receiver)); if ($ok = $ret['status']) { $c_uid = $ret['uid']; logger_print("feature:" . $c_feature . " datetime:" . $sms_datetime . " sender:" . $sms_sender . " receiver:" . $sms_receiver . " keyword:" . $target_keyword . " message:" . $message, 3, "setsmsincomingaction"); break; } } } $c_status = $ok ? 1 : 0; if ($c_status == 0) { $c_feature = ''; $target_keyword = ''; $message = $message_full; // from interceptincomingsms(), force status as 'handled' if ($ret_intercept['hooked']) { $c_status = 1; logger_print("intercepted datetime:" . $sms_datetime . " sender:" . $sms_sender . " receiver:" . $sms_receiver . " message:" . $message, 3, "setsmsincomingaction"); } else { logger_print("unhandled datetime:" . $sms_datetime . " sender:" . $sms_sender . " receiver:" . $sms_receiver . " message:" . $message, 3, "setsmsincomingaction"); } } $db_query = "\n INSERT INTO " . _DB_PREF_ . "_tblSMSIncoming \n (in_uid,in_feature,in_gateway,in_sender,in_receiver,in_keyword,in_message,in_datetime,in_status)\n VALUES\n ('{$c_uid}','{$c_feature}','{$gateway_module}','{$sms_sender}','{$sms_receiver}','{$target_keyword}','{$message}','{$sms_datetime}','{$c_status}')\n "; $db_result = dba_query($db_query); return $ok; }
function user_edit_conf($uid, $data = array()) { global $user_config; $ret['status'] = FALSE; $ret['error_string'] = _('No changes made'); $fields = array('footer', 'datetime_timezone', 'language_module', 'fwd_to_inbox', 'fwd_to_email', 'fwd_to_mobile', 'local_length', 'replace_zero', 'new_token', 'enable_webservices', 'webservices_ip', 'sender', 'acl_id'); $up = array(); foreach ($fields as $field) { $up[$field] = trim($data[$field]); } $up['lastupdate_datetime'] = core_adjust_datetime(core_get_datetime()); if ($uid) { if ($up['new_token']) { $up['token'] = md5(mktime() . $uid . _PID_); } unset($up['new_token']); // if sender ID is sent then validate it if ($c_sender = core_sanitize_sender($up['sender'])) { $check_sender = sender_id_check($uid, $c_sender) ? TRUE : FALSE; } else { $check_sender = TRUE; } if ($check_sender) { $up['sender'] = $c_sender; $c_footer = core_sanitize_footer($up['footer']); $up['footer'] = strlen($c_footer) > 30 ? substr($c_footer, 0, 30) : $c_footer; // acl exception for admins $c_status = (int) user_getfieldbyuid($uid, 'status'); if ($c_status == 2) { $up['acl_id'] = 0; } // self edit can't save acl if ($uid == $user_config['uid']) { unset($up['acl_id']); } if (dba_update(_DB_PREF_ . '_tblUser', $up, array('flag_deleted' => 0, 'uid' => $uid))) { if ($up['token']) { $ret['error_string'] = _('User configuration has been saved and webservices token updated'); } else { $ret['error_string'] = _('User configuration has been saved'); } $ret['status'] = TRUE; } else { $ret['error_string'] = _('Fail to save configuration'); } } else { $ret['error_string'] = _('Invalid sender ID'); } } else { $ret['error_string'] = _('Unknown error'); } return $ret; }