SMS Server Tools 3
 Menu
Basic information:
Additional information:
Support:
Get SMS Server Tools 3:
Additional Options

 Sponsored links

 Search
Custom Search

 Visitor locations
 
 SMS Server Tools 3 Community
Welcome, Guest. The forum is currently read-only, but will open soon. Sun Jun 01, 2025 12:39
SMSTools3 Community » Search Bottom

Page:  1

Keywords:
Mode: All keywords (AND)
maulana23: Finally after some research, I got it all working,.. PHP script executed from eventhandler, then store the information extracted to DB. My problem to execute php script solved by changing #!/usr/bin/php to #!/usr/local/bin/php since I'm using FreeBSD. And those warning I got is because I uncommented some extension on the php.ini, while actual extension is stored on different file /usr/local/etc/php/extension.ini. So, what I did just to re-comment some of the extensions stated on the log before. Thank you again Keke. Sorry if I disturb you by asking some Newbie questions :D Have a good day mate.
maulana23: Update: ====== For the headers, I understand how it works. For PHP, I could make it run, but then, it shows some errors. Below is the log PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20 090626/php_gd2.dll' - Cannot open "/usr/local/lib/php/20090626/php_gd2.dll" in U nknown on line 0 Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/2009062 6/php_gd2.dll' - Cannot open "/usr/local/lib/php/20090626/php_gd2.dll" in Unknow n on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20 090626/php_gettext.dll' - Cannot open "/usr/local/lib/php/20090626/php_gettext.d ll" in Unknown on line 0 Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/2009062 6/php_gettext.dll' - Cannot open "/usr/local/lib/php/20090626/php_gettext.dll" i n Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20 090626/php_mysql.dll' - Cannot open "/usr/local/lib/php/20090626/php_mysql.dll" in Unknown on line 0 Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/2009062 6/php_mysql.dll' - Cannot open "/usr/local/lib/php/20090626/php_mysql.dll" in Un known on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20 090626/php_mysqli.dll' - Cannot open "/usr/local/lib/php/20090626/php_mysqli.dll " in Unknown on line 0 Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/2009062 6/php_mysqli.dll' - Cannot open "/usr/local/lib/php/20090626/php_mysqli.dll" in Unknown on line 0 PHP Deprecated: Function split() is deprecated in /usr/local/bin/sms.php on lin e 17 Deprecated: Function split() is deprecated in /usr/local/bin/sms.php on line 17 Now this is the problem I'm facing, hehe XD
maulana23: The first sample was a "web application". It requires a web server and is not meant to use as eventhandler. Do you mean this? $sms_headers = array(); So, should I remove this line? The second sample is for eventhandler, as you have noticed. It reads the whole SMS file, and creates an array which contains all headers which are presented in the file. Use cat /var/spool/sms/incoming/GSM1.CF3eUt to see what headers are existing. Headers -part ends on the first blank line. There is no 'SentTime', but there is 'Sent' which tells the same thing. See fileformat for more details. I see, means that I could use $sms_headers['Sent']; and other information as written on the /var/spool/sms/incoming/GSM1.CF3eUt file. Is it case sensitive? Bad to say without seeing the script, but as the PHP says that "not found", something is just not found. You could check the code, and also you could test the functionality without giving the script to the smsd before it's tested. Manual testing can be done by calling the script from the command line: # /usr/local/bin/sms.php RECEIVED /var/spool/sms/incoming/GSM1.CF3eUt The script can be tested without receiving (and sending) SMS, as the incoming file already exists. It's also faster to make fixes, and test it again until it works as expected. I have followed your instruction, but still get error 'Not Found' message. All those 3 files have been posted before this post. Thank you again in advance.
maulana23: Here is my smsd.conf # Example smsd.conf. Read the manual for a description devices = GSM1 logfile = /usr/logdata/smsdlog/smsd.log loglevel = 7 smart_logging = yes outgoing = /var/spool/sms/outgoing checked = /var/spool/sms/checked incoming = /var/spool/sms/incoming eventhandler = /usr/local/bin/sms.php #checkhandler = /usr/local/bin/multiplesms stats = /var/spool/sms/stats [queues] INDONESIA = /var/spool/sms/INDONESIA OTHER = /var/spool/sms/OTHER [provider] INDONESIA = 62 OTHER = 0,1,2,3,4,5,6,7,8,9 [GSM1] device = /dev/cuau2 pre_init = yes init = AT+CPMS="ME","ME","MT" incoming = yes outgoing = yes queues = INDONESIA, OTHER smsc = 6281100000 #pin = 1111 memory_start = 0 baudrate = 19200 mode = new rtscts = yes cs_convert = yes This is my koneksi.php <?php $server = "localhost"; $username = "root"; $passdb = ""; $dbname = "testing"; // Database connection $mysqli = mysqli_connect($server,$username,$passdb,$dbname) or die("Gagal"); //mysqli_select_db($dbname) or die("Database tidak ditemukan"); ?> And this is my sms.php #!/usr/bin/php <?php $sms_type = $argv[1]; $sms_file = $argv[2]; $sms_file_content = file_get_contents($sms_file); $i = strpos($sms_file_content, "\n\n"); $sms_headers_part = substr($sms_file_content, 0, $i); $sms_message_body = substr($sms_file_content, $i + 2); $sms_header_lines = split("\n", $sms_headers_part); $sms_headers = array(); include 'koneksi.php'; foreach ($sms_header_lines as $header) { $i = strpos($header, ":"); if ($i !== false) $sms_headers[substr($header, 0, $i)] = substr($header, $i + 2); } if ($sms_type == "RECEIVED") { $sql = "INSERT INTO sms (sender, pesan, tgl_terima) VALUES(".$sms_headers['From'].", $sms_message_body, now())"; $res = mysqli_query($mysqli,$sql); mysqli_close($mysqli); } ?> the smsd.conf is located in /usr/local/etc koneksi.php and sms.php are located in /usr/local/bin and both with chmod 755. I have tried to execute command you provided, but still not found.
maulana23: Hi again Keke, I have (ALSO) read :mrgreen: this. And this is actually what I'm looking for. From there, i'm confused with $sms_headers = array(); what items actually does it store? i believe $sms_headers['From'] is one of them, can I use $sms_headers['SentTime'] to get the time of sms sent? I have modified the smsd.conf and also chmod 755 the sms.php file eventhandler = /usr/local/bin/sms.php inside the sms.php file, I have included the koneksi.php (a file to connect to database). And I put the koneksi.php file under /usr/local/bin and chmod 755 the file as well. but after I run and test receiving the sms. 2011-03-02 17:27:10,6, GSM1: Wrote an incoming message file: /var/spool/sms/inco ming/GSM1.CF3eUt 2011-03-02 17:27:10,7, GSM1: Running eventhandler: /usr/local/bin/sms.php RECEIV ED /var/spool/sms/incoming/GSM1.CF3eUt 2011-03-02 17:27:10,3, GSM1: Done: eventhandler, execution time 0 sec., status: 32512 (127) 2011-03-02 17:27:10,3, GSM1: Exec: eventhandler encountered errors: 2011-03-02 17:27:10,3, GSM1: ! /usr/local/bin/sms.php: not found 2011-03-02 17:27:10,3, GSM1: ALERT: problem with eventhandler, result 127 What is wrong actually? What am I missing? Thank you again in advance. ps: I'm sorry if this getting out of topic, but I would like to continue discussing with you about this.
maulana23: Hi Keke, Thank you for your reply, and I apologies for the very late reply. For PHP, I'm still wondering how do you get the SENT, RECEIVED, SENDER, RECEIVER, MSG? Is it using the HTTP_GET and/or HTTP_POST? Something like this: $sender = $_GET['sender']; $receiver = $_GET['receiver']; . . $msg = $_GET['msg']; I have read this as well. From that post, does the php file define as eventhandler? Yes, I'm actually not used to C in Linux/Unix environment, just in Windows env. And to be honest, I dont know how to compile the C in Unix/Linux env. XD Thank you again in advance.
maulana23: Oh I see, so means all I need to do is just write down the location of the file on smsd.conf eventhandler=/my/eventhandler/location/file.c or eventhandler=/my/eventhandler/location/file.php with the extension of the file regarding to the language, is it correct? My second question, do I need to declare/include any file on the eventhandler? My third question, I see on the eventhandler written in bash, the following code $1 = 'RECEIVED' $2 = 'SENT' $3 = 'FAILED' I wonder, How do I distinguish the type of the sms? Thank you in advance.
maulana23: Operating system name and version: FreeBSD Version 8 Version of smsd: 3.1.11 Smsd installed from: sources Name and model of a modem / phone: Sierra Aircard 850 Interface: serial Hi there, I have a question, whether I can use C programming language for eventhandler or checkhandler? If yes, do you have a simple script to send and receive sms and store to DB? Thank you in advance.
maulana23: First of all, Happy New Year mate, and sorry for the late reply. Below is my checkhandler file and to be honest, I copied the whole thing from the post to my server without any changes to be made. #!/bin/bash # Sample script to allow multiple recipients in one message file. # Define this script as a checkhandler. outgoing="/var/spool/sms/outgoing" recipients=`formail -zx "To:" < "$1"` #count=`echo "$recipients" | wc -l` count=`echo "$recipients" | wc -w` if [ $count -gt 1 ]; then # Will need echo which accepts -n argument: ECHO=echo case `uname` in SunOS) ECHO=/usr/ucb/echo ;; esac messagebody=`sed -e '1,/^$/ d' < "$1"` headers=`formail -X "" -I "To:" -f < "$1"` for recipient in $recipients do file=`mktemp $outgoing/send_XXXXXX` $ECHO "To: $recipient" > $file if [ "x$headers" != "x" ]; then $ECHO "$headers" >> $file fi $ECHO "" >> $file $ECHO -n "$messagebody" >> $file done # Remove processed file: rm $1 # Tell to smsd that checkhandler has spooled this message: exit 2 fi exit 0 Here is my smsd.conf # Example smsd.conf. Read the manual for a description devices = GSM1 logfile = /usr/logdata/smsdlog/smsd.log loglevel = 7 smart_logging = yes outgoing = /var/spool/sms/outgoing checked = /var/spool/sms/checked incoming = /var/spool/sms/incoming eventhandler = /usr/local/bin/mysmsd checkhandler = /usr/local/bin/multiplesms stats = /var/spool/sms/stats [queues] INDONESIA = /var/spool/sms/INDONESIA OTHER = /var/spool/sms/OTHER [provider] INDONESIA = 62 OTHER = 0,1,2,3,4,5,6,7,8,9 [GSM1] device = /dev/cuau2 pre_init = yes init = AT+CPMS="ME","ME","MT" incoming = yes outgoing = yes queues = INDONESIA, OTHER smsc = 6281100000 #pin = 1111 memory_start = 0 baudrate = 19200 mode = new rtscts = yes cs_convert = yes I'm using version 3 of smstools and it is running on FreeBSD v8.0 OS
maulana23: Thank you for your quick response Keke. It sounds like you have not defined checkhandler in the smsd.conf. When checkhandler does not modify the message file, smsd will read all To: headers and only the latest value is used. Assuming that you have stored the script as /usr/local/bin/smsd_checkhandler.sh, in the global part of smsd.conf (top of a file) define: checkhandler = /usr/local/bin/smsd_checkhandler.sh is .sh extension required on the file name? Have you checked this topic: Sample eventhandler to store messages into SQL database? Yes, I have read it, and I have used it for a normal (single recipient) sms. When I use it for multiple recipients, all the recipients are stored into the same column and are counted as 1 value. What I was trying to ask is that, if I send to multiple recipients for example: To: recipient_1 To: recipient_2 To: etc. "Body messages". So, can it be stored to mysql into 2 values (different recipients but the same message)? The values that will be stored into mysql: To: recipient_1 "Body message" ---- To: recipient_2 "Body message"
maulana23: Hi Keke, I have read this post, based on that I have some questions to ask you about. 1. Does the checkhandler read the files from Outgoing folder? 2. I have saved a file (from html) that has many "To:" header and also the body of the message at the end, but why I only be able to send message for the last "To: recipient" ? 3. I have seen the mysql table (sms_log) that all the To: recipients are stored on the same column (receiver), is there any way to break those To: recipients and store the number on the column one by one? Thank you in advance.

Page:  1

SMSTools3 Community » Search Top

 
Time in this board is UTC.  

Privacy Policy   SMS Server Tools 3 Copyright © Keijo Kasvi.