Uqmi-sms


#!/bin/sh
echo "Content-type: text/html"
###########################
#oprek by @norman-biston
#device yang digunakan adalah /dev/cdc-wdm0 
#sesuaikan jika berbeda
#path /www/cgi-bin/smsku
#chmod 755
#tampilan [iprouter]/cgi-bin/smsku
###########################
echo
echo '

<style>
table {
  font-family: arial, sans-serif;
  border-collapse: collapse;
  width: 100%;
}

td, th {
  border: 1px solid #dddddd;
  text-align: left;
  padding: 8px;
  font-size: 13px;
}

tr:nth-child(even) {
  background-color: #dddddd;
}

body {
  font-size: 12px;
  font-family: arial, sans-serif;
}
input[type=submit] {
  background-color: #919797 ;
  border: none;
  color: white;
  padding: 6px 20px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 12px;
  margin: 4px 2px;
  cursor: pointer;
}
</style>
'
echo '<html><head><title>smsku by norman-biston</title></head><body><pre>'

DEVX="/dev/cdc-wdm0"
QUERY="$QUERY_STRING"

if [ -z "$QUERY" ]; then
echo "<h2>Sms Inbox</h2>"
lines=$(uqmi -d $DEVX --list-message|grep -o -E '[0-9]+')
echo "<table>"
for co in $lines; do
        se=$(uqmi -d /dev/cdc-wdm0 --get-message $co | grep 'sender' | cut -c2- | sed 's/^[^:]*://g' | xargs | head -c -2)
        ti=$(uqmi -d /dev/cdc-wdm0 --get-message $co | grep 'timestamp' | cut -c2- | sed 's/^[^:]*://g' | xargs | head -c -2)
        tx=$(uqmi -d /dev/cdc-wdm0 --get-message $co | grep 'text' | cut -c2- | sed 's/^[^:]*://g' | xargs | head -c -1)
    echo "<tr><td><a href=smsku?id=$co>$se</a></td><td>$ti</td><td>$tx</td></tr>"
done
exit
fi

QUERY=$(echo $QUERY|sed 's/%2B/=/g')
IFS="&"
set -- $QUERY

IFS="+"
set -- $QUERY
tmp=$1=$2=$3=$4
IFS="="
set -- $tmp


if [ ! -z "$2" ]; then
    uqmi -d $DEVX --delete-message $2
    echo "<h2>delete sms index "$2"</h2>"
    echo '<meta http-equiv="refresh" content="2; URL=smsku" />'
fi