52 public $errors = array();
110 public $deliveryreceipt;
124 public function __construct($to, $from, $msg, $deliveryreceipt = 0, $deferred = 0, $priority = 3, $class = 1)
130 if (preg_match(
'/^win/i', PHP_OS)) {
133 if (preg_match(
'/^mac/i', PHP_OS)) {
139 $this->error =
'No SMS Engine defined';
140 throw new Exception(
'No SMS Engine defined');
143 dol_syslog(
"CSMSFile::CSMSFile: MAIN_SMS_SENDMODE=".
getDolGlobalString(
'MAIN_SMS_SENDMODE').
" charset=".
$conf->file->character_set_client.
" from=".$from.
", to=".$to.
", msg length=".strlen($msg), LOG_DEBUG);
144 dol_syslog(
"CSMSFile::CSMSFile: deferred=".$deferred.
" priority=".$priority.
" class=".$class, LOG_DEBUG);
147 $this->addr_from = $from;
148 $this->addr_to = $to;
149 $this->deferred = $deferred;
150 $this->priority = $priority;
151 $this->
class = $class;
152 $this->deliveryreceipt = $deliveryreceipt;
153 $this->message = $msg;
154 $this->nostop =
false;
165 $errorlevel = error_reporting();
166 error_reporting($errorlevel ^ E_WARNING);
170 dol_syslog(
"CSMSFile::sendfile addr_to=".$this->addr_to, LOG_DEBUG);
171 dol_syslog(
"CSMSFile::sendfile message=\n".$this->message);
173 $this->message = stripslashes($this->message);
183 $classmoduleofsender =
getDolGlobalString(
'MAIN_MODULE_'.strtoupper($sendmode).
'_SMS', $sendmode);
184 if ($classmoduleofsender ==
'ovh') {
185 $classmoduleofsender =
'ovhsms@ovh';
188 $tmp = explode(
'@', $classmoduleofsender);
189 $classfile = $tmp[0];
190 $module = (empty($tmp[1]) ? $tmp[0] : $tmp[1]);
191 dol_include_once(
'/'.$module.
'/class/'.strtolower($classfile).
'.class.php');
193 $classname = ucfirst($classfile);
195 dol_syslog(
"CSMSFile::sendfile: try to include class ".$classname);
197 if (class_exists($classname)) {
198 $sms =
new $classname($this->db);
199 '@phan-var-force OvhSms $sms';
201 $sms->expe = $this->addr_from;
202 $sms->dest = $this->addr_to;
203 $sms->deferred = $this->deferred;
204 $sms->priority = $this->priority;
205 $sms->class = $this->class;
206 $sms->message = $this->message;
207 $sms->nostop = $this->nostop;
208 $sms->deliveryreceipt = $this->deliveryreceipt;
210 $sms->socid = $this->socid;
211 $sms->contact_id = $this->contact_id;
212 $sms->member_id = $this->member_id;
213 $sms->fk_project = $this->fk_project;
215 $res = $sms->SmsSend();
217 $this->error = $sms->error;
218 $this->errors = $sms->errors;
220 dol_syslog(
"CSMSFile::sendfile: sms send error=".$this->error, LOG_ERR);
226 dol_syslog(
"CSMSFile::sendfile: sms send success with id=".$res, LOG_DEBUG);
233 $this->error =
'The SMS manager "'.$classfile.
'" defined into SMS setup MAIN_MODULE_'.strtoupper($sendmode).
'_SMS is not found';
236 dol_print_error(
null,
'Error to get list of senders: '.$e->getMessage());
241 $this->error =
'Bad value for MAIN_SMS_SENDMODE constant';
245 $this->error =
'No sms sent. Feature is disabled by option MAIN_DISABLE_ALL_SMS';
246 dol_syslog(
"CSMSFile::sendfile: ".$this->error, LOG_WARNING);
249 error_reporting($errorlevel);
265 global
$conf, $dolibarr_main_data_root;
267 if (@is_writable($dolibarr_main_data_root)) {
268 $outputfile = $dolibarr_main_data_root.
"/dolibarr_sms.log";
269 $fp = fopen($outputfile,
"w");
271 fwrite($fp,
"From: ".$this->addr_from.
"\n");
272 fwrite($fp,
"To: ".$this->addr_to.
"\n");
273 fwrite($fp,
"Priority: ".$this->priority.
"\n");
274 fwrite($fp,
"Class: ".$this->
class.
"\n");
275 fwrite($fp,
"Deferred: ".$this->deferred.
"\n");
276 fwrite($fp,
"DisableStop: ".((
string) (
int) $this->nostop).
"\n");
277 fwrite($fp,
"DeliveryReceipt: ".$this->deliveryreceipt.
"\n");
278 fwrite($fp,
"Message:\n".$this->message);
296 global $dolibarr_main_data_root;
298 if (@is_writable($dolibarr_main_data_root)) {
299 $outputfile = $dolibarr_main_data_root.
"/dolibarr_sms.log";
300 $fp = fopen($outputfile,
"a+");
302 fwrite($fp,
"\nResult of SmsSend = ".$result);
Class to send SMS Usage: $smsfile = new CSMSFile($subject,$sendto,$replyto,$message,...
dump_sms_result($result)
Write content of a SendSms result into a dump file (mode = all) Used for debugging.
sendfile()
Send SMS that was prepared by constructor.
dump_sms()
Write content of a SendSms request into a dump file (mode = all) Used for debugging.
__construct($to, $from, $msg, $deliveryreceipt=0, $deferred=0, $priority=3, $class=1)
CSMSFile.
dolChmod($filepath, $newmask='')
Change mod of a file.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...