Guest User

Untitled

a guest
Feb 6th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.32 KB | None | 0 0
  1. root@OpenWrt:/usr/share/3ginfo/cgi-bin# cat sms1.sh
  2. #!/bin/sh
  3.  
  4. echo "Content-type: text/html"
  5. echo ""
  6. echo "
  7. <html>
  8. <style type=\"text/css\">
  9. body {
  10. font-family: Verdana, Arial, Helvetica, sans-serif;
  11. }
  12. #centered {
  13. width: 800px;
  14. margin: auto;
  15. text-align: center;
  16. }
  17. .label {
  18. text-align: left;
  19. }
  20. .text {
  21. width: 100%;
  22. }
  23. pre {
  24. text-align: left;
  25. }
  26. </style>
  27. <head>
  28. <title>SMS</title>
  29. <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />
  30. </head>
  31. <body>
  32. "
  33. if [ "$REQUEST_METHOD" = POST ]; then
  34. read -t 3 QUERY_STRING
  35. eval $(echo "$QUERY_STRING"|awk -F'&' '{for(i=1;i<=NF;i++){print $i}}')
  36. action=`uhttpd -d $action 2>/dev/null`
  37. tel=`uhttpd -d $msisdn 2>/dev/null`
  38. msg=`uhttpd -d $msg 2>/dev/null`
  39. id=`uhttpd -d $id 2>/dev/null`
  40. else
  41. action="x"
  42. fi
  43.  
  44. case "$action" in
  45. send)
  46. echo "[global]" > /tmp/gnokiirc
  47. echo "model = AT" >> /tmp/gnokiirc
  48. echo "port = "$(uci get 3ginfo.@3ginfo[0].device1) >> /tmp/gnokiirc
  49. echo "connection = serial" >> /tmp/gnokiirc
  50.  
  51. echo "$msg" | tr '+' ' ' | gnokii --config /tmp/gnokiirc --sendsms $tel 2>/dev/null
  52. R=$?
  53. if [ $R -eq 0 ]; then
  54. echo "Wysłano wiadomość do $tel!<br />"
  55. else
  56. echo "<font color=red><strong>Wystąpił problem z wysłaniem wiadomości!</strong></font><br />"
  57. fi
  58. echo $tel": "$msg >> /tmp/sms.txt
  59. rm /tmp/gnokiirc
  60. ;;
  61. delete)
  62. echo "[global]" > /tmp/gnokiirc
  63. echo "model = AT" >> /tmp/gnokiirc
  64. echo "port = "$(uci get 3ginfo.@3ginfo[0].device1) >> /tmp/gnokiirc
  65. echo "connection = serial" >> /tmp/gnokiirc
  66. gnokii --config /tmp/gnokiirc --deletesms SM $id 2>/dev/null
  67. rm /tmp/gnokiirc
  68. ;;
  69. esac
  70.  
  71. echo "
  72. <form method=\"post\">
  73. <input type=\"hidden\" name=\"action\" id=\"action\" value=\"send\">
  74. <div class=label>Numer telefonu:</div><input name=\"msisdn\" class=text><br />
  75. <div class=label>Wiadomość:</div><textarea name=\"msg\" class=text></textarea><br /><br />
  76. <input type=\"submit\" name=\"submit\" value=\"Wyślij\" text-align=center>
  77. </form>
  78. "
  79.  
  80. echo "[global]" > /tmp/gnokiirc
  81. echo "model = AT" >> /tmp/gnokiirc
  82. echo "port = "$(uci get 3ginfo.@3ginfo[0].device1) >> /tmp/gnokiirc
  83. echo "connection = serial" >> /tmp/gnokiirc
  84. echo "<pre>"
  85. gnokii --config /tmp/gnokiirc --getsms SM 0 end 2>/dev/null | \
  86. sed -e ' \
  87. s/ (unread)/<\/pre><font color=green><strong>Nowa wiadomość<\/strong><\/font><pre>/g; \
  88. s/Msg Center.*//g; \
  89. s/(read)//g; \
  90. s/^Sender/Nadawca/g;s/Date\/time/Data\/czas/g; \
  91. s/^Text:/Treść wiadomości:<\/pre><pre style="white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;white-space:pre-wrap;word-wrap:break-word;">/g; \
  92. s/\(^[0-9]*\)..Inbox Message/<\/pre><hr \/><form style="text-align: left;" method="post"><input type="hidden" name="action" id="action" value="delete"><input type="hidden" name="id" id="id" value="\1"><input type="submit" name="submit" value="Usuń"><\/form><pre>/g'
  93. rm /tmp/gnokiirc
  94.  
  95. echo "</pre>
  96. </div>
  97. </body></html>"
Add Comment
Please, Sign In to add comment