laconicatools-svn Mailing List for Laconi.ca Tools
Status: Alpha
Brought to you by:
jontheniceguy
You can subscribe to this list here.
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(41) |
Oct
(3) |
Nov
(27) |
Dec
(2) |
|---|
|
From: <jon...@us...> - 2008-12-02 19:40:55
|
Revision: 86
http://laconicatools.svn.sourceforge.net/laconicatools/?rev=86&view=rev
Author: jontheniceguy
Date: 2008-12-02 19:40:54 +0000 (Tue, 02 Dec 2008)
Log Message:
-----------
For debugging purposes, it may be convenient to turn on output_to_screen, which does not work for many of the web calls used in OpenID
Modified Paths:
--------------
smsToLaconica/trunk/web_index.php
Modified: smsToLaconica/trunk/web_index.php
===================================================================
--- smsToLaconica/trunk/web_index.php 2008-12-02 19:35:37 UTC (rev 85)
+++ smsToLaconica/trunk/web_index.php 2008-12-02 19:40:54 UTC (rev 86)
@@ -5,6 +5,12 @@
// SVN Version: $Rev$ on $Date$ last updated by $Author$
require_once('config.php');
+
+if($debug['output_to_screen']==TRUE) {
+ $debug['output_to_file']=TRUE;
+ $debug['output_to_screen']=FALSE;
+}
+
require_once('lib_openid.php');
require_once('lib_' . $phone['data_type'] . '.php');
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2008-12-02 19:35:44
|
Revision: 85
http://laconicatools.svn.sourceforge.net/laconicatools/?rev=85&view=rev
Author: jontheniceguy
Date: 2008-12-02 19:35:37 +0000 (Tue, 02 Dec 2008)
Log Message:
-----------
Fixing issue https://sourceforge.net/tracker2/?func=detail&aid=2379103&group_id=238273&atid=1105946
Modified Paths:
--------------
smsToLaconica/trunk/lib_text.php
Modified: smsToLaconica/trunk/lib_text.php
===================================================================
--- smsToLaconica/trunk/lib_text.php 2008-11-21 23:21:18 UTC (rev 84)
+++ smsToLaconica/trunk/lib_text.php 2008-12-02 19:35:37 UTC (rev 85)
@@ -88,6 +88,7 @@
if(is_array($messages)) {
foreach($messages as $message) {
SendCmd('AT+CMGD=' . $message['index'], $socket);
+ sleep($sleep/4);
}
}
}
@@ -95,4 +96,4 @@
return $messages;
}
-?>
\ No newline at end of file
+?>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2008-11-21 23:21:21
|
Revision: 84
http://laconicatools.svn.sourceforge.net/laconicatools/?rev=84&view=rev
Author: jontheniceguy
Date: 2008-11-21 23:21:18 +0000 (Fri, 21 Nov 2008)
Log Message:
-----------
A round up of the latest bug fixes, the addition of license details at the top of lib_debug and a fix for direct message and author-error-handling errors in daemon_feed (which cause a crash!).
Modified Paths:
--------------
smsToLaconica/trunk/daemon_feed.php
smsToLaconica/trunk/default_config.php
smsToLaconica/trunk/lib_debug.php
Modified: smsToLaconica/trunk/daemon_feed.php
===================================================================
--- smsToLaconica/trunk/daemon_feed.php 2008-11-16 16:46:54 UTC (rev 83)
+++ smsToLaconica/trunk/daemon_feed.php 2008-11-21 23:21:18 UTC (rev 84)
@@ -2,7 +2,7 @@
// This code is released under the AGPL (V.3 or later)
// Author: Jon Spriggs (jo...@sp...)
-// Version: 0.6
+// Version: 0.6.1
// SVN Version: $Rev$ on $Date$ last updated by $Author$
// SimplePie is a library released under a BSD style license. As a result, I have
@@ -84,6 +84,9 @@
if(d_mysql_num_rows($qry)>0) {
while(list($feed_id, $feed_url, $feed_type, $last_date, $user_id)=d_mysql_fetch_array($qry)) {
debug("Checking $feed_url for $user_id", TRUE);
+ $breakdown=explode("/", $feed_url);
+ $feed_path=strtolower(substr($breakdown[count($breakdown)-1], 0, strpos($breakdown[count($breakdown)-1], ".")));
+ if(($feed_type=='T' AND $feed_path=='direct_messages') OR ($feed_type=='L' AND $feed_path=='direct_messages')) {$dm=TRUE;} else {$dm=FALSE;}
$feed=new SimplePie();
$feed->set_feed_url($feed_url);
$feed->set_cache_duration(30);
@@ -96,20 +99,31 @@
}
$message_number++;
$message[$message_number]['user_id']=$user_id;
- $author=$feed_item->get_author()->get_name();
- $title=$feed_item->get_title();
- if($feed_type=="T") {
- $feed_author=explode(" ", $author);
- $author=$feed_type . ":" . substr($feed_author[0], 0, 17) . ":";
+ if($dm==FALSE) {
+ if($feed_item->get_author()) {
+ $author=$feed_item->get_author()->get_name();
+ } else {
+ $author="No Author";
+ d_mysql_query("INSERT INTO errors (time_in, user_id, error_text, acknowledged) VALUES (NOW(), '$user_id', 'Could not determine author name from feed ($feed_id). Object with error is " . $feed_item->get_permalink() . "', 0)");
+ }
+ $title=$feed_item->get_title();
+ if($feed_type=="T") {
+ $feed_author=explode(" ", $author);
+ $author=$feed_type . ":" . substr($feed_author[0], 0, 17) . ":";
+ } else {
+ $author=substr($title, 0, strpos($title, ":"));
+ $author=$feed_type . ":" . substr($author, 0, 17) . ":";
+ }
+ if($feed_type=="I" OR $feed_type=="L") {
+ $title=substr($title, strpos($title, ":")+2);
+ }
+ $message[$message_number]['title']=$author . substr($title, 0, 140);
+ $message[$message_number]['link']=$feed_item->get_permalink();
} else {
- $author=substr($title, 0, strpos($title, ":"));
- $author=$feed_type . ":" . substr($author, 0, 17) . ":";
+ $temp_author=explode(" ", $feed_item->get_title());
+ $message[$message_number]['title']=$feed_type . ":" . substr($temp_author[2], 0 , 15) . " D:" . substr($feed_item->get_description(), 0, 140);
+ $message[$message_number]['link']=$feed_item->get_permalink();
}
- if($feed_type=="I" OR $feed_type=="L") {
- $title=substr($title, strpos($title, ":")+2);
- }
- $message[$message_number]['title']=$author . substr($title, 0, 140);
- $message[$message_number]['link']=$feed_item->get_permalink();
}
}
$feed->__destruct();
Modified: smsToLaconica/trunk/default_config.php
===================================================================
--- smsToLaconica/trunk/default_config.php 2008-11-16 16:46:54 UTC (rev 83)
+++ smsToLaconica/trunk/default_config.php 2008-11-21 23:21:18 UTC (rev 84)
@@ -42,7 +42,7 @@
'owner_url'=>'http://my.own.website',
'owner_mail'=>'ow...@my...',
'system_mail'=>'sms...@my...',
- 'version'=>'0.6',
+ 'version'=>'0.6.1',
'source'=>'LaconicaTools',
'source_url'=>'http://sf.net/projects/laconicatools',
'number'=>'+441234567890', // and the number to which your users will send their SMS.
@@ -60,4 +60,4 @@
'from_name'=>'smsToLaconica Service',
'from_address'=>'sms...@YO...');
-$services=array("T"=>'Twitter API', "L"=>'Twitter API');
\ No newline at end of file
+$services=array("T"=>'Twitter API', "L"=>'Twitter API');
Modified: smsToLaconica/trunk/lib_debug.php
===================================================================
--- smsToLaconica/trunk/lib_debug.php 2008-11-16 16:46:54 UTC (rev 83)
+++ smsToLaconica/trunk/lib_debug.php 2008-11-21 23:21:18 UTC (rev 84)
@@ -1,5 +1,10 @@
<?php
+// This code is released under the AGPL (V.3 or later)
+// Author: Jon Spriggs (jo...@sp...)
+// Version: 0.6.1
+// SVN Version: $Rev$ on $Date$ last updated by $Author$
+
function call_rest_api($url, $fields="", $auth="", $type="post", $get_data=FALSE) {
// This code originally taken from http://morethanseven.net/posts/posting-to-twitter-using-php/
$curl_handle = curl_init();
@@ -95,7 +100,7 @@
$stat_line="";
foreach($status as $stat_name=>$state) {
$stat_head.="<th>$stat_name</th>";
- if($states['state']==0) {$stat="Down since {$state['time']}";} else {$stat="Up at {$state['time']}";}
+ if($state['state']==0) {$stat="Down since {$state['time']}";} else {$stat="Up at {$state['time']}";}
$stat_line.="<td>$stat</td>";
}
return "<table><tr>$stat_head</tr><tr>$stat_line</tr></table>";
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2008-11-16 16:46:59
|
Revision: 83
http://laconicatools.svn.sourceforge.net/laconicatools/?rev=83&view=rev
Author: jontheniceguy
Date: 2008-11-16 16:46:54 +0000 (Sun, 16 Nov 2008)
Log Message:
-----------
Ready for release!
Added Paths:
-----------
smsToLaconica/releases/0.6/
smsToLaconica/releases/0.6/install.sh
Removed Paths:
-------------
smsToLaconica/releases/0.6/install.sh
Property changes on: smsToLaconica/releases/0.6
___________________________________________________________________
Added: svn:mergeinfo
+
Deleted: smsToLaconica/releases/0.6/install.sh
===================================================================
--- smsToLaconica/trunk/install.sh 2008-11-16 16:32:53 UTC (rev 80)
+++ smsToLaconica/releases/0.6/install.sh 2008-11-16 16:46:54 UTC (rev 83)
@@ -1,45 +0,0 @@
-#! /bin/bash
-# This code is released under the AGPL (V.3 or later)
-# Author: Jon Spriggs (jo...@sp...)
-# Version: 0.6
-# SVN Version: $Rev$ on $Date$ last updated by $Author$
-#
-# This code creates a *DEFAULT* install of smsToLaconica - you will need to make some changes to it, but it's an ok out-of-the-box install.
-
-echo Installing required files for smsToLaconica
-if [ -f default_config.php ]; then
- PWD=`pwd`
- if [ -f config.php ]; then
- echo "Found the config file."
- else
- cp default_config.php config.php
- echo "Copied the default configuration file to config.php"
- fi
-else
- echo "This is not the right path. Exiting!"
- exit
-fi
-
-wget http://simplepie.org/mint/pepper/orderedlist/downloads/download.php?file=http%3A//simplepie.org/downloads/simplepie_1.1.1.zip
-unzip -j simplepie_1.1.1.zip *simplepie.inc
-rm simplepie_1.1.1.zip
-
-sudo mkdir /var/www/smsToLaconica
-sudo chown $USER.$USER /var/www/smsToLaconica
-sudo chmod 755 /var/www/smsToLaconica
-
-ln -s `pwd`/web_index.php /var/www/smsToLaconica/index.php
-ln -s `pwd`/config.php `pwd`/lib_debug.php `pwd`/lib_text.php `pwd`/lib_pdu.php `pwd`/lib_openid.php /var/www/smsToLaconica
-
-cd /var/www/smsToLaconica
-wget http://stevelove.org/scripts/class.openid.phps
-mv class.openid.phps class.openid.php
-
-wget http://openidenabled.com/files/php-openid/files/PHP-yadis-1.0.2.tar.gz
-tar -xf PHP-yadis-1.0.2.tar.gz PHP-yadis-1.0.2/Services/
-mv PHP-yadis-1.0.2/Services Services/
-rm -Rf PHP-yadis-1.0.2 PHP-yadis-1.0.2.tar.gz
-
-sudo touch /var/log/sms_to_laconica.log
-sudo chown $USER.www-data /var/log/sms_to_laconica.log
-sudo chmod 770 /var/log/sms_to_laconica.log
Copied: smsToLaconica/releases/0.6/install.sh (from rev 82, smsToLaconica/trunk/install.sh)
===================================================================
--- smsToLaconica/releases/0.6/install.sh (rev 0)
+++ smsToLaconica/releases/0.6/install.sh 2008-11-16 16:46:54 UTC (rev 83)
@@ -0,0 +1,48 @@
+#! /bin/bash
+# This code is released under the AGPL (V.3 or later)
+# Author: Jon Spriggs (jo...@sp...)
+# Version: 0.6
+# SVN Version: $Rev$ on $Date$ last updated by $Author$
+#
+# This code creates a *DEFAULT* install of smsToLaconica - you will need to make some changes to it, but it's an ok out-of-the-box install.
+
+echo Installing required files for smsToLaconica
+if [ -f default_config.php ]; then
+ PWD=`pwd`
+ if [ -f config.php ]; then
+ echo "Found the config file."
+ else
+ cp default_config.php config.php
+ echo "Copied the default configuration file to config.php"
+ fi
+else
+ echo "This is not the right path. Exiting!"
+ exit
+fi
+
+wget http://simplepie.org/mint/pepper/orderedlist/downloads/download.php?file=http%3A//simplepie.org/downloads/simplepie_1.1.1.zip
+unzip -j simplepie_1.1.1.zip *simplepie.inc
+rm simplepie_1.1.1.zip
+
+mkdir cache
+chmod 777 cache
+
+sudo mkdir /var/www/smsToLaconica
+sudo chown $USER.$USER /var/www/smsToLaconica
+sudo chmod 755 /var/www/smsToLaconica
+
+ln -s `pwd`/web_index.php /var/www/smsToLaconica/index.php
+ln -s `pwd`/config.php `pwd`/lib_debug.php `pwd`/lib_text.php `pwd`/lib_pdu.php `pwd`/lib_openid.php /var/www/smsToLaconica
+
+cd /var/www/smsToLaconica
+wget http://stevelove.org/scripts/class.openid.phps
+mv class.openid.phps class.openid.php
+
+wget http://openidenabled.com/files/php-openid/files/PHP-yadis-1.0.2.tar.gz
+tar -xf PHP-yadis-1.0.2.tar.gz PHP-yadis-1.0.2/Services/
+mv PHP-yadis-1.0.2/Services Services/
+rm -Rf PHP-yadis-1.0.2 PHP-yadis-1.0.2.tar.gz
+
+sudo touch /var/log/sms_to_laconica.log
+sudo chown $USER.www-data /var/log/sms_to_laconica.log
+sudo chmod 770 /var/log/sms_to_laconica.log
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2008-11-16 16:45:36
|
Revision: 82
http://laconicatools.svn.sourceforge.net/laconicatools/?rev=82&view=rev
Author: jontheniceguy
Date: 2008-11-16 16:45:31 +0000 (Sun, 16 Nov 2008)
Log Message:
-----------
Small flaw in the install script.
Modified Paths:
--------------
smsToLaconica/trunk/install.sh
Modified: smsToLaconica/trunk/install.sh
===================================================================
--- smsToLaconica/trunk/install.sh 2008-11-16 16:41:09 UTC (rev 81)
+++ smsToLaconica/trunk/install.sh 2008-11-16 16:45:31 UTC (rev 82)
@@ -24,6 +24,9 @@
unzip -j simplepie_1.1.1.zip *simplepie.inc
rm simplepie_1.1.1.zip
+mkdir cache
+chmod 777 cache
+
sudo mkdir /var/www/smsToLaconica
sudo chown $USER.$USER /var/www/smsToLaconica
sudo chmod 755 /var/www/smsToLaconica
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2008-11-16 16:41:11
|
Revision: 81
http://laconicatools.svn.sourceforge.net/laconicatools/?rev=81&view=rev
Author: jontheniceguy
Date: 2008-11-16 16:41:09 +0000 (Sun, 16 Nov 2008)
Log Message:
-----------
Removed old branch. No longer required.
Removed Paths:
-------------
smsToLaconica/branches/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2008-11-16 16:32:59
|
Revision: 80
http://laconicatools.svn.sourceforge.net/laconicatools/?rev=80&view=rev
Author: jontheniceguy
Date: 2008-11-16 16:32:53 +0000 (Sun, 16 Nov 2008)
Log Message:
-----------
Tweak in run_script.sh for clarity of admin. Adjustment to feed script, now handles timezones properly. Added additional debugging.
Modified Paths:
--------------
smsToLaconica/trunk/daemon_feed.php
smsToLaconica/trunk/run_scripts.sh
Modified: smsToLaconica/trunk/daemon_feed.php
===================================================================
--- smsToLaconica/trunk/daemon_feed.php 2008-11-16 12:34:14 UTC (rev 79)
+++ smsToLaconica/trunk/daemon_feed.php 2008-11-16 16:32:53 UTC (rev 80)
@@ -17,6 +17,7 @@
d_mysql_connect();
function send_update_sms($user_id, $title, $url="") {
+ debug("Preparing to send SMS to $user_id with message '$title'", TRUE);
if(check_service_ok($user_id)) {
$qry=d_mysql_query("SELECT user_number FROM users WHERE user_id='$user_id'");
if(d_mysql_num_rows($qry)>0) {
@@ -43,17 +44,11 @@
$credit_and_tz_qry=d_mysql_query("SELECT user_timezone FROM users WHERE user_id='$user_id' AND phone_credit>0");
if(d_mysql_num_rows($credit_and_tz_qry)>0) {
list($timezone)=d_mysql_fetch_array($credit_and_tz_qry);
- $now="now";
- if($timezone!='')
- {
- $ltz=new DateTimeZone($timezone);
- $lt=new DateTime('now', $tz);
- $localtime=$ltz->getOffset($lt);
- if($localtime>0) {$now="+$localtime seconds";}
- if($localtime<0) {$now="$localtime seconds";}
- }
- $service_qry=d_mysql_query("SELECT user_id FROM users_sms_service WHERE user_id='$user_id' AND service_day='" . date("N", strtotime($now)) . "' AND service_hour='" . gmdate("H", strtotime($now)) . "'");
+ if($timezone=='') {$timezone='UTC';}
+ $dateTime = new DateTime("now", new DateTimeZone($timezone));
+ $service_qry=d_mysql_query("SELECT user_id FROM users_sms_service WHERE user_id='$user_id' AND service_day='" . $dateTime->format("N") . "' AND service_hour='" . $dateTime->format("H") . "'");
if(d_mysql_num_rows($service_qry)>0) {
+ debug("Service check succeeded for user $user_id", TRUE);
$return=TRUE;
} else {
event_log($user_id, "A service check failed as you were outside your approved service times.");
@@ -96,7 +91,6 @@
debug("There are " . count($feed->get_items()) . " in $feed_url to process", TRUE);
foreach($feed->get_items() as $feed_item) {
if(strtotime($feed_item->get_date("Y-m-d H:i:s"))>strtotime($last_date)) {
- debug("This is a new message for processing in $feed_url for $user_id", TRUE);
if($feed_item->get_date("U")>strtotime($update_feed[$feed_id])) {
$update_feed[$feed_id]=$feed_item->get_date("Y-m-d H:i:s");
}
@@ -116,8 +110,6 @@
}
$message[$message_number]['title']=$author . substr($title, 0, 140);
$message[$message_number]['link']=$feed_item->get_permalink();
- } else {
- debug("There are no new messages for processing in $feed_url for $user_id", TRUE);
}
}
$feed->__destruct();
Modified: smsToLaconica/trunk/run_scripts.sh
===================================================================
--- smsToLaconica/trunk/run_scripts.sh 2008-11-16 12:34:14 UTC (rev 79)
+++ smsToLaconica/trunk/run_scripts.sh 2008-11-16 16:32:53 UTC (rev 80)
@@ -7,10 +7,12 @@
# This script only starts smsToLaconica, it does not stop it. If you need proper init.d scripts, please either author them yourself or get someone to author them and contribute them back into the project.
echo -n Starting smsToLaconica:
-echo -n daemon_modem:
-nohup php -q daemon_modem.php >/dev/null &
-echo -n Done. daemon_database:
-nohup php -q daemon_database.php >/dev/null &
-echo -n Done. daemon_feed:
-nohup php -q daemon_feed.php >/dev/null &
-echo -n Done. [Finished]
+echo daemon_modem:
+nohup php -q daemon_modem.php >/dev/null 2>/dev/null &
+echo -n Done.
+echo daemon_database:
+nohup php -q daemon_database.php >/dev/null 2>/dev/null &
+echo -n Done.
+echo daemon_feed:
+nohup php -q daemon_feed.php >/dev/null 2>/dev/null &
+echo Done. [Finished]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2008-11-16 12:34:21
|
Revision: 79
http://laconicatools.svn.sourceforge.net/laconicatools/?rev=79&view=rev
Author: jontheniceguy
Date: 2008-11-16 12:34:14 +0000 (Sun, 16 Nov 2008)
Log Message:
-----------
Memory leaks (already identified in simplepie as a result of a PHP bug) results in less caching (ironically), and more unsetting of variables in daemon_feed.php. Typo in daemon_database meant users registering a phone number didnt actually register it after all. Fixed
Modified Paths:
--------------
smsToLaconica/trunk/daemon_database.php
smsToLaconica/trunk/daemon_feed.php
Modified: smsToLaconica/trunk/daemon_database.php
===================================================================
--- smsToLaconica/trunk/daemon_database.php 2008-11-16 01:53:26 UTC (rev 78)
+++ smsToLaconica/trunk/daemon_database.php 2008-11-16 12:34:14 UTC (rev 79)
@@ -79,7 +79,7 @@
$get_user_qry=d_mysql_query("SELECT user_id FROM users WHERE phone_code LIKE '" . mysql_real_escape_string(trim($message)) . "'");
if(d_mysql_num_rows($get_user_qry)>0) {
list($user_id)=d_mysql_fetch_array($get_user_qry);
- d_mysql_query("UPDATE users SET phone_number='$phone_number' WHERE user_id='$user_id'");
+ d_mysql_query("UPDATE users SET user_number='$phone_number', phone_code='' WHERE user_id='$user_id'");
d_mysql_query("DELETE FROM queue_in WHERE in_id='$in_id'");
} else {
d_mysql_query("INSERT INTO errors (time_in, user_number, message, error_text) VALUES (NOW(), '" . mysql_real_escape_string($phone_number) . "', '" . mysql_real_escape_string($message) . "', 'No such user')");
@@ -108,4 +108,4 @@
mail($user_mail, $title, $message, $headers);
}
}
-}
\ No newline at end of file
+}
Modified: smsToLaconica/trunk/daemon_feed.php
===================================================================
--- smsToLaconica/trunk/daemon_feed.php 2008-11-16 01:53:26 UTC (rev 78)
+++ smsToLaconica/trunk/daemon_feed.php 2008-11-16 12:34:14 UTC (rev 79)
@@ -88,9 +88,15 @@
$qry=d_mysql_query($sql);
if(d_mysql_num_rows($qry)>0) {
while(list($feed_id, $feed_url, $feed_type, $last_date, $user_id)=d_mysql_fetch_array($qry)) {
- $feed=new SimplePie($feed_url);
+ debug("Checking $feed_url for $user_id", TRUE);
+ $feed=new SimplePie();
+ $feed->set_feed_url($feed_url);
+ $feed->set_cache_duration(30);
+ $feed->init();
+ debug("There are " . count($feed->get_items()) . " in $feed_url to process", TRUE);
foreach($feed->get_items() as $feed_item) {
if(strtotime($feed_item->get_date("Y-m-d H:i:s"))>strtotime($last_date)) {
+ debug("This is a new message for processing in $feed_url for $user_id", TRUE);
if($feed_item->get_date("U")>strtotime($update_feed[$feed_id])) {
$update_feed[$feed_id]=$feed_item->get_date("Y-m-d H:i:s");
}
@@ -110,8 +116,12 @@
}
$message[$message_number]['title']=$author . substr($title, 0, 140);
$message[$message_number]['link']=$feed_item->get_permalink();
+ } else {
+ debug("There are no new messages for processing in $feed_url for $user_id", TRUE);
}
}
+ $feed->__destruct();
+ unset($feed);
}
if(count($update_feed)>0) {
foreach($update_feed as $feed_id=>$new_date) {
@@ -131,6 +141,7 @@
send_update_sms($message['user_id'], $message['title'], $message['link']);
}
}
+ unset($messages);
d_mysql_query("UPDATE service_status SET last_run=CURRENT_TIMESTAMP WHERE service_name='daemon_feed.php'", TRUE, TRUE);
}
-?>
\ No newline at end of file
+?>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2008-11-16 01:53:28
|
Revision: 78
http://laconicatools.svn.sourceforge.net/laconicatools/?rev=78&view=rev
Author: jontheniceguy
Date: 2008-11-16 01:53:26 +0000 (Sun, 16 Nov 2008)
Log Message:
-----------
Some debug testing proved that SQL errors werent being picked up right, and there was an SQL error in the new user page.
Modified Paths:
--------------
smsToLaconica/trunk/lib_debug.php
smsToLaconica/trunk/web_index.php
Modified: smsToLaconica/trunk/lib_debug.php
===================================================================
--- smsToLaconica/trunk/lib_debug.php 2008-11-16 01:18:26 UTC (rev 77)
+++ smsToLaconica/trunk/lib_debug.php 2008-11-16 01:53:26 UTC (rev 78)
@@ -54,7 +54,7 @@
function d_mysql_query($sql) {
$return=mysql_query($sql);
if(mysql_error()!="") {
- debug("SQL: $sql\r\nERR: " . mysql_error(), TRUE, TRUE);
+ debug("SQL: $sql\r\nERR: " . mysql_error());
} else {
debug("SQL: $sql", TRUE, TRUE);
}
@@ -108,4 +108,4 @@
function event_log($user_id, $message) {
d_mysql_query("INSERT INTO event_log (user_id, event) VALUES ('" . mysql_real_escape_string($user_id) . "', '" . mysql_real_escape_string($message) . "')");
}
-?>
\ No newline at end of file
+?>
Modified: smsToLaconica/trunk/web_index.php
===================================================================
--- smsToLaconica/trunk/web_index.php 2008-11-16 01:18:26 UTC (rev 77)
+++ smsToLaconica/trunk/web_index.php 2008-11-16 01:53:26 UTC (rev 78)
@@ -85,7 +85,7 @@
$_SESSION['created']=FALSE;
}
} else {
- d_mysql_query("INSERT INTO users (last_logged_in, openid_identity, user_name, user_mail, usser_language, user_country, user_timezone) VALUES (NOW(), '" . mysql_real_escape_string($_SESSION['openid_identity']) . "', '" . mysql_real_escape_string($_SESSION['fullname']) . "', '" . mysql_real_escape_string($_SESSION['email']) . "', '" . mysql_real_escape_string($_SESSION['language']) . "', '" . mysql_real_escape_string($_SESSION['country']) . "', '" . mysql_real_escape_string($_SESSION['timezone']) . "')");
+ d_mysql_query("INSERT INTO users (last_logged_in, openid_identity, user_name, user_mail, user_language, user_country, user_timezone) VALUES (NOW(), '" . mysql_real_escape_string($_SESSION['openid_identity']) . "', '" . mysql_real_escape_string($_SESSION['fullname']) . "', '" . mysql_real_escape_string($_SESSION['email']) . "', '" . mysql_real_escape_string($_SESSION['language']) . "', '" . mysql_real_escape_string($_SESSION['country']) . "', '" . mysql_real_escape_string($_SESSION['timezone']) . "')");
$user_exist=d_mysql_query("SELECT * FROM users WHERE openid_identity='{$_SESSION['openid_identity']}'");
$user=d_mysql_fetch_array($user_exist);
$user_id=$user['user_id'];
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2008-11-16 01:18:31
|
Revision: 77
http://laconicatools.svn.sourceforge.net/laconicatools/?rev=77&view=rev
Author: jontheniceguy
Date: 2008-11-16 01:18:26 +0000 (Sun, 16 Nov 2008)
Log Message:
-----------
Huge numbers of changes to the webUI, including; retrieve more data from OpenID. Use "quick setup mode" for adding update service and feeds in one click. A little embedded CSS on the main page. A few typos in the service calls and data show. More event log data (after all, we are logging the bloody stuff!). More disclosure about OpenID data retrieval. Corrected a little Logging data. This marks the proper Alpha release (including being installed on my proper gateway after this check-in).
Modified Paths:
--------------
smsToLaconica/trunk/web_index.php
Modified: smsToLaconica/trunk/web_index.php
===================================================================
--- smsToLaconica/trunk/web_index.php 2008-11-16 01:11:24 UTC (rev 76)
+++ smsToLaconica/trunk/web_index.php 2008-11-16 01:18:26 UTC (rev 77)
@@ -35,20 +35,63 @@
session_destroy();
header("Location: $site_url");
} else {
+ $detail_updated=FALSE;
require_once("lib_debug.php");
d_mysql_connect();
$user_exist=d_mysql_query("SELECT * FROM users WHERE openid_identity='{$_SESSION['openid_identity']}'");
if(d_mysql_num_rows($user_exist)>0) {
$user=d_mysql_fetch_array($user_exist);
$user_id=$user['user_id'];
- d_mysql_query("UPDATE users SET last_logged_in=NOW() WHERE user_id='$user_id'");
- event_log($user_id, "Logged in.");
+ if($_SESSION['established']!=TRUE) {
+ $sql='';
+ if(isset($_SESSION['fullname'])) {
+ if(strtolower($_SESSION['fullname'])!=strtolower($user['user_name']) AND $user['user_name_manual']!=1) {
+ $sql=", user_name='" . mysql_real_escape_string($_SESSION['fullname']) . "'";
+ $detail_updated=TRUE;
+ }
+ }
+ if(isset($_SESSION['email'])) {
+ if(strtolower($_SESSION['email'])!=strtolower($user['user_mail']) AND $user['user_mail_manual']!=1) {
+ $sql=", user_mail='" . mysql_real_escape_string($_SESSION['email']) . "'";
+ $detail_updated=TRUE;
+ }
+ }
+ if(isset($_SESSION['language'])) {
+ if(strtolower($_SESSION['language'])!=strtolower($user['user_language']) AND $user['user_language_manual']!=1) {
+ $sql=", user_language='" . mysql_real_escape_string($_SESSION['language']) . "'";
+ $detail_updated=TRUE;
+ }
+ } else {
+ if(strtolower($_SESSION['language'])!=strtolower($user['user_language']) AND $user['user_language_manual']!=1) {
+ $sql=", user_language='" . mysql_real_escape_string($_SESSION['language']) . "'";
+ $detail_updated=TRUE;
+ }
+ }
+ if(isset($_SESSION['country'])) {
+ if(strtolower($_SESSION['country'])!=strtolower($user['user_country']) AND $user['user_country_manual']!=1) {
+ $sql=", user_country='" . mysql_real_escape_string($_SESSION['country']) . "'";
+ $detail_updated=TRUE;
+ }
+ }
+ if(isset($_SESSION['timezone'])) {
+ if(strtolower($_SESSION['timezone'])!=strtolower($user['user_timezone']) AND $user['user_timezone_manual']!=1) {
+ $sql=", user_timezone='" . mysql_real_escape_string($_SESSION['timezone']) . "'";
+ $detail_updated=TRUE;
+ }
+ }
+ d_mysql_query("UPDATE users SET last_logged_in=NOW() $sql WHERE user_id='$user_id'");
+ event_log($user_id, "Logged in.");
+ $_SESSION['established']=TRUE;
+ $_SESSION['created']=FALSE;
+ }
} else {
- d_mysql_query("INSERT INTO users (openid_identity, user_name, user_mail) VALUES ('{$_SESSION['openid_identity']}', '{$_SESSION['fullname']}', '{$_SESSION['email']}')");
+ d_mysql_query("INSERT INTO users (last_logged_in, openid_identity, user_name, user_mail, usser_language, user_country, user_timezone) VALUES (NOW(), '" . mysql_real_escape_string($_SESSION['openid_identity']) . "', '" . mysql_real_escape_string($_SESSION['fullname']) . "', '" . mysql_real_escape_string($_SESSION['email']) . "', '" . mysql_real_escape_string($_SESSION['language']) . "', '" . mysql_real_escape_string($_SESSION['country']) . "', '" . mysql_real_escape_string($_SESSION['timezone']) . "')");
$user_exist=d_mysql_query("SELECT * FROM users WHERE openid_identity='{$_SESSION['openid_identity']}'");
$user=d_mysql_fetch_array($user_exist);
$user_id=$user['user_id'];
event_log($user_id, "Created user account.");
+ $_SESSION['created']=TRUE;
+ $_SESSION['established']=TRUE;
$sql="INSERT INTO users_sms_service (user_id, service_day, service_hour) VALUE ";
$insert=0;
for($d=1; $d<=7; $d++) {
@@ -60,17 +103,17 @@
}
}
d_mysql_query($sql);
- event_log($user_id, "Set up service hours.");
+ event_log($user_id, "Set up default service hours.");
}
if($_GET['ds']!="") {
if(d_mysql_num_rows(d_mysql_query("SELECT user_service_id FROM users_update_service WHERE user_id='$user_id' AND user_service_id='" . mysql_real_escape_string($_GET['ds']) . "'"))>0) {
d_mysql_query("DELETE FROM users_update_service WHERE user_service_id='" . mysql_real_escape_string($_GET['ds']) . "'");
- event_log($user_id, "Deleted Service {$_GET['ds']} number.");
+ event_log($user_id, "Deleted Service number {$_GET['ds']}.");
}
} elseif($_GET['df']!="") {
if(d_mysql_num_rows(d_mysql_query("SELECT feed_id FROM users_feeds WHERE user_id='$user_id' AND feed_id='" . mysql_real_escape_string($_GET['df']) . "'"))>0) {
d_mysql_query("DELETE FROM users_feeds WHERE feed_id='" . mysql_real_escape_string($_GET['df']) . "'");
- event_log($user_id, "Deleted Watch Feed {$_GET['df']} number.");
+ event_log($user_id, "Deleted Feed number {$_GET['df']}.");
}
} elseif($_POST['cs']!="") {
if($_POST['service_type']!='' AND $_POST['base_url']!='' AND $_POST['username']!='' AND $_POST['password']!='' AND $services[strtoupper($_POST['service_type'])]!='') {
@@ -88,17 +131,59 @@
}
} elseif($_POST['cf']!="") {
if($_POST['feed_type']!='' AND $_POST['feed_url']!='' AND $services[strtoupper($_POST['feed_type'])]!='') {
- d_mysql_query("INSERT INTO users_feeds (user_id, feed_type, feed_url, last_time) VALUES ('$user_id', '" . mysql_real_escape_string(strtoupper($_POST['feed_type'])) . "', '" . mysql_real_escape_string($_POST['feed_url']) . "', '0000-00-00 00:00:00')");
+ d_mysql_query("INSERT INTO users_feeds (user_id, feed_type, feed_url, last_time) VALUES ('$user_id', '" . mysql_real_escape_string(strtoupper($_POST['feed_type'])) . "', '" . mysql_real_escape_string($_POST['feed_url']) . "', '" . gmdate('Y-m-d H:i:s') . "')");
$parse_url=parse_url($_POST['feed_url']);
if(isset($parse_url['scheme'])) {$url=$parse_url['scheme']. "://";} else {$url="http://";}
if(isset($parse_url['user'])) {$url.=$parse_url['user'];}
if(isset($parse_url['pass'])) {$url.=":*****";}
if(isset($parse_url['user'])) {$url.="@";}
+ if(isset($parse_url['host'])) {$url.=$parse_url['host'];}
if(isset($parse_url['path'])) {$url.=$parse_url['path'];}
if(isset($parse_url['query'])) {$url.='?' . $parse_url['query'];}
if(isset($parse_url['fragment'])) {$url.='#' . $parse_url['fragment'];}
event_log($user_id, "Added feed at " . mysql_real_escape_string($url));
}
+ } elseif($_POST['ta']!="") {
+ if($_POST['service_type']!='' AND $_POST['base_url']!='' AND $_POST['username']!='' AND $_POST['password']!='' AND $services[strtoupper($_POST['service_type'])]!='') {
+ $buffer=call_rest_api($_POST['base_url'] . "/account/verify_credentials.xml", "", $_POST['username'] . ":" . $_POST['password'], "GET");
+ if($buffer==TRUE) {
+ d_mysql_query("INSERT INTO users_update_service (user_id, service_type, base_url, username, password) VALUES ('$user_id', '" . mysql_real_escape_string(strtoupper($_POST['service_type'])) . "', '" . mysql_real_escape_string($_POST['base_url']) . "', '" . mysql_real_escape_string($_POST['username']) . "', '" . mysql_real_escape_string($_POST['password']) . "')");
+ event_log($user_id, "Added update service at " . mysql_real_escape_string($_POST['base_url'] . "/statuses/replies.rss") . " for username " . mysql_real_escape_string($_POST['username']));
+
+ $parse_url=parse_url($_POST['base_url']);
+ if(isset($parse_url['scheme'])) {$url=$parse_url['scheme']. "://";} else {$url="http://";}
+ if(isset($_POST['username'])) {$url.=$_POST['username'];}
+ if(isset($_POST['password'])) {$url.=":" . $_POST['password'];}
+ if(isset($_POST['username'])) {$url.="@";}
+ if(isset($parse_url['host'])) {$url.=$parse_url['host'];}
+ if(isset($parse_url['path'])) {$url.=$parse_url['path'];}
+
+ if(isset($parse_url['scheme'])) {$no_auth_url=$parse_url['scheme']. "://";} else {$no_auth_url="http://";}
+ if(isset($parse_url['host'])) {$no_auth_url.=$parse_url['host'];}
+ if(isset($parse_url['path'])) {$no_auth_url.=$parse_url['path'];}
+
+ if($_POST['ar']=='on') {
+ d_mysql_query("INSERT INTO users_feeds (user_id, feed_type, feed_url, last_time) VALUES ('$user_id', '" . mysql_real_escape_string(strtoupper($_POST['service_type'])) . "', '" . mysql_real_escape_string($url . "/statuses/replies.rss") . "', '" . gmdate('Y-m-d H:i:s') . "')");
+ event_log($user_id, "Added service at " . mysql_real_escape_string($no_auth_url . "/statuses/replies.rss") . " for username " . mysql_real_escape_string($_POST['username']));
+ }
+ if($_POST['ad']=='on') {
+ d_mysql_query("INSERT INTO users_feeds (user_id, feed_type, feed_url, last_time) VALUES ('$user_id', '" . mysql_real_escape_string(strtoupper($_POST['service_type'])) . "', '" . mysql_real_escape_string($url . "/direct_messages.rss") . "', '" . gmdate('Y-m-d H:i:s') . "')");
+ event_log($user_id, "Added service at " . mysql_real_escape_string($no_auth_url . "/direct_messages.rss") . " for username " . mysql_real_escape_string($_POST['username']));
+ }
+ if($_POST['as']=='on') {
+ $base_url_no_api=preg_replace("/\/api/", '/search/notice/rss?q=', $no_auth_url);
+ $search_url=preg_replace("/\/\/twitter.com/", '//search.twitter.com/search.atom?q=', $base_url_no_api);
+ d_mysql_query("INSERT INTO users_feeds (user_id, feed_type, feed_url, last_time) VALUES ('$user_id', '" . mysql_real_escape_string(strtoupper($_POST['service_type'])) . "', '" . mysql_real_escape_string($search_url . "%40" . $_POST['username']) . "', '" . gmdate("Y-m-d H:i:s") . "')");
+ event_log($user_id, "Added service at " . mysql_real_escape_string($search_url) . " for username " . mysql_real_escape_string($_POST['username']));
+ }
+ } elseif($buffer==FALSE) {
+ $error="It was not possible to contact the feed service. Please check the base URL.";
+ event_log($user_id, "When trying to add service at ". mysql_real_escape_string($_POST['base_url']) . " for username " . mysql_real_escape_string($_POST['username']). ", the API service was not available.");
+ } else {
+ $error="There was an error with the authentication to this service. Please check that the API is currently available on the remote service and that your authentication details are correct.";
+ event_log($user_id, "When trying to add service at ". mysql_real_escape_string($_POST['base_url']) . " for username " . mysql_real_escape_string($_POST['username']). ", there was an error trying to authenticate.");
+ }
+ }
} elseif($_POST['sh']!="") {
$service_times_qry=d_mysql_query("SELECT service_day, service_hour FROM users_sms_service WHERE user_id='$user_id'");
if(d_mysql_num_rows($service_times_qry)>0) {
@@ -106,9 +191,7 @@
}
for($d=1; $d<=7; $d++) {
for($h=0; $h<=23; $h++) {
- if(($_POST["{$d}-{$h}"]=='on' AND $svc_hours["{$d}-{$h}"]==TRUE) OR ($_POST["{$d}-{$h}"]!='on' AND $svc_hours["{$d}-{$h}"]==FALSE)) {
- // Value is the same! Yey!
- } else {
+ if(($_POST["{$d}-{$h}"]=='on' AND $svc_hours["{$d}-{$h}"]==TRUE) OR ($_POST["{$d}-{$h}"]!='on' AND $svc_hours["{$d}-{$h}"]==FALSE)) {} else {
if($_POST["{$d}-{$h}"]=='on') {
d_mysql_query("INSERT INTO users_sms_service (user_id, service_day, service_hour) VALUES ('$user_id', '$d', '$h')");
} else {
@@ -135,15 +218,35 @@
if(d_mysql_num_rows($service_times_qry)>0) {
while(list($day, $hour)=d_mysql_fetch_array($service_times_qry)) {$svc_hours["{$day}-{$hour}"]=TRUE;}
}
-
- $event_log_qry=d_mysql_query("SELECT timestamp, event FROM event_log WHERE user_id = '$user_id' ORDER BY timestamp DESC LIMIT 0,5");
+ $event_log_qry=d_mysql_query("SELECT timestamp, event FROM event_log WHERE user_id = '$user_id' ORDER BY timestamp DESC LIMIT 0,50");
if(d_mysql_num_rows($event_log_qry)>0) {
while($event_log[]=d_mysql_fetch_array($event_log_qry)) {}
}
-
- echo "<html><head><title>smsToLaconica User Portal</title></head><body><p align=center>smsToLaconica User Portal</p>";
- echo service_status();
- echo "<p>Hello {$user['user_name']}.</p>";
+ echo "<html><head><title>smsToLaconica User Portal</title><style type=\"text/css\">
+.heading{
+ text-align: center;
+ font-size: 150%;
+}
+.heading_2{
+ text-align: center;
+ font-size: 130%;
+}
+table{
+ width: 100%;
+}
+</style></head><body><p class='heading'>smsToLaconica User Portal</p>";
+ echo "<p>Hello {$user['user_name']}.";
+ if($_SESSION['created']==FALSE) {echo " Welcome back! You last logged in on {$user['last_logged_in']}.";}
+ if($details_updated==TRUE) {echo "Your details were updated this session. Please check your details below to confirm they are accurate! If not, please contact <a href='mailto:{$ui['system_mail']}'>the service administrator</a> to have them set to manual adjustment.";}
+ echo "</p>";
+ echo "<p class='heading_2'>User Details</p>";
+ foreach(array('Name'=>'user_name', 'E-Mail'=>'user_mail', 'Phone Number'=>'user_number', 'Country'=>'user_country', 'Language'=>'user_language', 'Timezone'=>'user_timezone') as $head=>$body) {
+ $heading.="<th>$head</th>";
+ $content.="<td>";
+ if($user[$body]!='') {$content.=$user[$body];} else {$content.=' ';}
+ $content.="</td>";
+ }
+ echo "<table><tr>$heading</tr><tr>$content</tr></table>";
if($update_svc==FALSE) {
if($user['phone_code']=='') {
$getcode=str_split(md5($_SESSION['openid_identity'] . date("U") . $_SESSION['fullname'] . date("U") . $_SESSION['email']), 1);
@@ -162,10 +265,17 @@
} else {
$phone_service="<p>You don't have a phone number set up with this service yet. To add a number, please send a message to {$ui['number']} with activation code: {$user['phone_code']}.</p>";
}
- echo "<p>Update Services</p>";
- echo "<table><tr><th>Service Type</th><th>Base URL</th><th>Username</th><th>Password</th><th>Function</th></tr>";
- echo "<tr><td>Example Laconi.ca</td><td>http://identi.ca/api</td><td>username</td><td>password</td><td>EXAMPLE ONLY</td></tr>";
- echo "<tr><td>Example Twitter</td><td>http://twitter.com</td><td>username</td><td>password</td><td>EXAMPLE ONLY</td></tr>";
+ echo "<p class='heading_2'>Service Status</p>";
+ echo service_status();
+
+ echo "<p class='heading_2'>Quick Service Setup</p>";
+ echo "<p>Data entered here will auto-populate the 'Update Services' and 'RSS Feeds' sections below.</p>";
+ echo "<table><tr><th>Service Type</th><th>Base URL</th><th>Username</th><th>Password</th><th>Services</th></tr>";
+
+ echo "<form action='$site_url' method='post'><input type='hidden' name='ta' value='create'><tr><td valign=centet><select name='service_type'><option value='T'>Twitter</option><option value='L' selected>Laconi.ca System</option></select></td><td valign=center><input type='text' name='base_url' size='15' value='http://identi.ca/api'></td><td valign=center><input type='text' name='username' size='10'></td><td valign=center><input type='password' name='password' size='10'></td><td>Submit Updates: <input type='checkbox' checked='checked' disabled='disabled'><br>Send Replies: <input type='checkbox' name='ar' checked><br>Send Direct Messages: <input type='checkbox' name='ad' checked><br>Search for @username: <input type='checkbox' name='as'><br><input type='submit' value='Save'></td></tr></form></table>";
+
+ echo "<p class='heading_2'>Remove Services</p>";
+ echo "<table><tr><th>Service Type</th><th>Base URL</th><th>Username</th><th>Password</th><th>Delete</th></tr>";
if(count($update_svc)>0 AND $update_svc!=FALSE) {
foreach($update_svc as $svc) {
if($svc['base_url']!='' AND $svc['username']!='' AND $svc['password']!='') {
@@ -182,16 +292,11 @@
}
}
}
- echo "<form action='$site_url' method='post'><input type='hidden' name='cs' value='create'><tr><td><select name='service_type'><option value='T'>Twitter</option><option value='L' selected>Laconi.ca System</option></select></td><td><input type='text' name='base_url' size='15' value='http://identi.ca/api'></td><td><input type='text' name='username' size='10'></td><td><input type='password' name='password' size='10'></td><td><input type='submit' value='Save'></td></tr></form></table>";
-
+ echo "</table>";
echo $phone_service;
- echo "<p>RSS Feeds</p>";
+ echo "<p class='heading_2'>RSS Feeds</p>";
echo "<table><tr><th>Feed Type</th><th>Feed URL</th><th>Function</th></tr>";
- echo "<tr><td>Example Laconi.ca Replies</td><td>http://username:pas...@id.../api/statuses/replies.rss</td><td>EXAMPLE ONLY</td></tr>";
- echo "<tr><td>Example Twitter Replies</td><td>http://username:pas...@tw.../statuses/replies.rss</td><td>EXAMPLE ONLY</td></tr>";
- echo "<tr><td>Example Laconi.ca Search</td><td>http://identi.ca/search/notice/rss?q=%40username</td><td>EXAMPLE ONLY</td></tr>";
- echo "<tr><td>Example Twitter Search</td><td>http://search.twitter.com/search.atom?q=%40username</td><td>EXAMPLE ONLY</td></tr>";
if(count($feeds)>0 AND $feeds!=FALSE) {
foreach($feeds as $feed) {
if($feed['feed_url']!='') {
@@ -209,16 +314,17 @@
if(isset($parse_url['user'])) {$url.=$parse_url['user'];}
if(isset($parse_url['pass'])) {$url.=":*****";}
if(isset($parse_url['user'])) {$url.="@";}
+ if(isset($parse_url['host'])) {$url.=$parse_url['host'];}
if(isset($parse_url['path'])) {$url.=$parse_url['path'];}
if(isset($parse_url['query'])) {$url.='?' . $parse_url['query'];}
if(isset($parse_url['fragment'])) {$url.='#' . $parse_url['fragment'];}
- echo "</td><td>" . htmlentities($url) . "</td><td><a href='$site_url?ds={$feed['feed_id']}'>Delete</a></td></tr>";
+ echo "</td><td>" . htmlentities($url) . "</td><td><a href='$site_url?df={$feed['feed_id']}'>Delete</a></td></tr>";
}
}
}
echo "<form action='$site_url' method='post'><input type='hidden' name='cf' value='create'><tr><td><select name='feed_type'><option value='T'>Twitter</option><option value='L' selected>Laconi.ca System</option></select></td><td><input type='text' name='feed_url' size='40' value='http://username:pas...@id.../api/statuses/replies.rss'></td><td><input type='submit' value='Save'></td></tr></form></table>";
if($functions['send']==TRUE) {
- echo "<form action='$site_url' method='post'><p>SMS Service Periods<input type='hidden' name='sh' value='true'> <input type=submit value='Update'></p>";
+ echo "<form action='$site_url' method='post'><p align=center><span class='heading_2'>SMS Service Periods</span><input type='hidden' name='sh' value='true'> <input type=submit value='Update'></p>";
echo "<table><tr><th>Day</th>";
for($h=0; $h<24; $h++) {echo "<th>$h</th>";}
echo "</tr>";
@@ -232,7 +338,8 @@
}
echo "</table></form>";
}
- echo "<table><tr><th>Time</th><th>Event Log Message</th></tr>";
+ echo "<p class='heading_2'>Event Log</p>";
+ echo "<table><tr><th>Time</th><th>Message</th></tr>";
if(count($event_log)>0 AND $event_log!=FALSE) {
foreach($event_log as $event) {
echo "<tr><td>{$event['timestamp']}</td><td>{$event['event']}</td></tr>";
@@ -241,14 +348,14 @@
echo "</table>";
}
} else {
- $err_data=OpenID_Auth(); // This script may return error data or it may send a header line. Either way, if we get past here, we need to render the page :)
+ $err_data=OpenID_Auth(array('email','fullname','country','language','timezone')); // This script may return error data or it may send a header line. Either way, if we get past here, we need to render the page :)
echo "<html><head><title>smsToLaconica</title></head>";
- echo "<body>" . login_form() . $err_data;
+ echo "<body><table><tr><td width=50%>";
echo "<p>What is smsToLaconica?</p>";
echo "<p>smsToLaconica is a set of scripts which allow you to send text messages to update any twitter-like API, for example, Twitter, Identi.ca, etc. Log in to start sending!<br><br>";
if($functions['send']==TRUE) {
echo" This system may also be configured to send you SMS messages when you receive a reply or a directed message. These settings will be displayed on a further screen once you have logged in.";
}
- echo "</p>";
- echo "</body></html>";
+ echo "</p></td><td width=50%>" . login_form() . $err_data;
+ echo "<p>Please note, this system will attempt to retrieve the following information; Your name, your e-mail address, your language and country (for selecting translation languages where available), and your timezone. The name and e-mail fields are required, and all the others are optional. If the OpenID system does not return a timezone, country or language, the assumption will be that you are based in the UK (which is where this system was created), and proceed as such. If you wish to change these settings, please inform your administrator. Details will be on the following screen.</td></tr></table></body></html>";
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2008-11-16 01:11:27
|
Revision: 76
http://laconicatools.svn.sourceforge.net/laconicatools/?rev=76&view=rev
Author: jontheniceguy
Date: 2008-11-16 01:11:24 +0000 (Sun, 16 Nov 2008)
Log Message:
-----------
Documentation updates in README.txt and UPGRADE.txt. DB Updates for message_logs (enhanced logging for later perhaps?), manual record modifications in users table, event_log table now has scope for alphanumeric characters (e.g service messages) and export is a direct result from phpMyAdmin, hence more exported settings on the tables.
Modified Paths:
--------------
smsToLaconica/trunk/README.txt
smsToLaconica/trunk/UPGRADE.txt
smsToLaconica/trunk/smsToLaconica.sql
Property Changed:
----------------
smsToLaconica/trunk/UPGRADE.txt
Modified: smsToLaconica/trunk/README.txt
===================================================================
--- smsToLaconica/trunk/README.txt 2008-11-16 00:55:58 UTC (rev 75)
+++ smsToLaconica/trunk/README.txt 2008-11-16 01:11:24 UTC (rev 76)
@@ -58,3 +58,7 @@
Your best bet is to communicate with me by e-mail.
All the best, Jon Spriggs
+
+-------------------------------------------------------------------------------------------------------
+Author: Jon Spriggs (jo...@sp...)
+SVN Version: $Rev$ on $Date$ last updated by $Author$
\ No newline at end of file
Modified: smsToLaconica/trunk/UPGRADE.txt
===================================================================
--- smsToLaconica/trunk/UPGRADE.txt 2008-11-16 00:55:58 UTC (rev 75)
+++ smsToLaconica/trunk/UPGRADE.txt 2008-11-16 01:11:24 UTC (rev 76)
@@ -2,10 +2,15 @@
<=0.5.1 >=0.6
-Practically all the filenames have changed, and there are major database changes need to
-be made. Lastly, the phone number is no longer MD5'd, as this prevents sending SMS
-messages (should that be desired).
+Practically all the filenames have changed, and there are major database changes need to be made. Lastly, the phone number is no longer MD5'd, as this prevents
+sending SMS messages (should that be desired). Best bet would be to rename the database, rename the <0.6 release directories to something else, then bring in
+the new versions of all the files (there is a script "install.sh" which will also download dependencies), update the config, import the database and tell your
+users to re-register.
+You may be able to do this manually, but I really wouldn't recommend it. I certainly haven't done it!
+
+Aside from anything else, this version uses OpenID as the authentication method, rather than Laconi.ca/Twitter authentication.
+
<=0.5 to >=0.5.1
This script will process any messages stored in your phone UNLESS you change the script to not handle the read messages. These settings are in daemon_modem.php.
@@ -13,3 +18,7 @@
Please use the following sql statement;
ALTER TABLE `users` ADD `posts` INT NOT NULL DEFAULT '0';
+
+-------------------------------------------------------------------------------------------------------
+Author: Jon Spriggs (jo...@sp...)
+SVN Version: $Rev$ on $Date$ last updated by $Author$
\ No newline at end of file
Property changes on: smsToLaconica/trunk/UPGRADE.txt
___________________________________________________________________
Added: svn:keywords
+ Date Rev Author Id
Modified: smsToLaconica/trunk/smsToLaconica.sql
===================================================================
--- smsToLaconica/trunk/smsToLaconica.sql 2008-11-16 00:55:58 UTC (rev 75)
+++ smsToLaconica/trunk/smsToLaconica.sql 2008-11-16 01:11:24 UTC (rev 76)
@@ -3,12 +3,19 @@
-- Version 0.6
-- SVN Version: $Rev$ on $Date$ last updated by $Author$
+SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
+
--
+-- Database: `smsToLaconica`
+--
+
+-- --------------------------------------------------------
+
+--
-- Table structure for table `errors`
--
-DROP TABLE IF EXISTS `errors`;
-CREATE TABLE `errors` (
+CREATE TABLE IF NOT EXISTS `errors` (
`error_id` int(11) NOT NULL auto_increment,
`time_in` datetime NOT NULL,
`user_number` varchar(50) NOT NULL,
@@ -17,79 +24,129 @@
`error_text` text NOT NULL,
`acknowledged` tinyint(1) NOT NULL,
PRIMARY KEY (`error_id`)
-) ENGINE=MyISAM;
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+-- --------------------------------------------------------
+
--
-- Table structure for table `event_log`
--
-DROP TABLE IF EXISTS `event_log`;
-CREATE TABLE `event_log` (
+CREATE TABLE IF NOT EXISTS `event_log` (
`event_id` int(11) NOT NULL auto_increment,
`timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
- `user_id` int(11) NOT NULL,
+ `user_id` varchar(50) NOT NULL,
`event` text NOT NULL,
PRIMARY KEY (`event_id`),
UNIQUE KEY `event_id` (`event_id`)
-) ENGINE=MyISAM;
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+-- --------------------------------------------------------
+
--
+-- Table structure for table `message_in_log`
+--
+
+CREATE TABLE IF NOT EXISTS `message_in_log` (
+ `log_id` int(11) NOT NULL auto_increment,
+ `user_id` int(11) NOT NULL,
+ `counter` int(11) NOT NULL,
+ `c_year` int(11) NOT NULL,
+ `c_month` int(11) NOT NULL,
+ `c_day` int(11) NOT NULL,
+ `c_hour` int(11) NOT NULL,
+ `c_minute` int(11) NOT NULL,
+ PRIMARY KEY (`log_id`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `message_out_log`
+--
+
+CREATE TABLE IF NOT EXISTS `message_out_log` (
+ `log_id` int(11) NOT NULL auto_increment,
+ `user_id` int(11) NOT NULL,
+ `counter` int(11) NOT NULL,
+ `c_year` int(11) NOT NULL,
+ `c_month` int(11) NOT NULL,
+ `c_day` int(11) NOT NULL,
+ `c_hour` int(11) NOT NULL,
+ `c_minute` int(11) NOT NULL,
+ PRIMARY KEY (`log_id`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+
+-- --------------------------------------------------------
+
+--
-- Table structure for table `queue_in`
--
-DROP TABLE IF EXISTS `queue_in`;
-CREATE TABLE `queue_in` (
+CREATE TABLE IF NOT EXISTS `queue_in` (
`in_id` int(11) NOT NULL auto_increment,
`phone_number` varchar(25) NOT NULL,
`message` varchar(255) NOT NULL,
`time_in` datetime NOT NULL,
`time_last` datetime NOT NULL,
PRIMARY KEY (`in_id`)
-) ENGINE=MyISAM;
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+-- --------------------------------------------------------
+
--
-- Table structure for table `queue_out`
--
-DROP TABLE IF EXISTS `queue_out`;
-CREATE TABLE `queue_out` (
+CREATE TABLE IF NOT EXISTS `queue_out` (
`out_id` int(11) NOT NULL auto_increment,
`phone_number` varchar(25) NOT NULL,
`message` varchar(255) NOT NULL,
`time_in` datetime NOT NULL,
`time_last` datetime NOT NULL,
PRIMARY KEY (`out_id`)
-) ENGINE=MyISAM;
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+-- --------------------------------------------------------
+
--
-- Table structure for table `service_status`
--
-DROP TABLE IF EXISTS `service_status`;
-CREATE TABLE `service_status` (
+CREATE TABLE IF NOT EXISTS `service_status` (
`service_name` varchar(50) NOT NULL,
`last_run` timestamp NOT NULL default CURRENT_TIMESTAMP,
PRIMARY KEY (`service_name`)
-) ENGINE=MyISAM;
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
--- Data for table `service_status`
+-- Dumping data for table `service_status`
--
-INSERT INTO `service_status` VALUES ('daemon_feed.php', '0000-00-00 00:00:00');
-INSERT INTO `service_status` VALUES ('daemon_modem.php', '0000-00-00 00:00:00');
-INSERT INTO `service_status` VALUES ('daemon_database.php', '0000-00-00 00:00:00');
+INSERT INTO `service_status` (`service_name`, `last_run`) VALUES
+('daemon_feed.php', '0000-00-00 00:00:00'),
+('daemon_modem.php', '0000-00-00 00:00:00'),
+('daemon_database.php', '0000-00-00 00:00:00');
+-- --------------------------------------------------------
+
--
-- Table structure for table `users`
--
-DROP TABLE IF EXISTS `users`;
-CREATE TABLE `users` (
+CREATE TABLE IF NOT EXISTS `users` (
`user_id` int(11) NOT NULL auto_increment,
`openid_identity` varchar(255) NOT NULL,
`user_name` varchar(255) NOT NULL,
+ `user_name_manual` tinyint(1) NOT NULL,
`user_mail` varchar(255) NOT NULL,
+ `user_mail_manual` tinyint(1) NOT NULL,
+ `user_language` varchar(50) NOT NULL,
+ `user_language_manual` tinyint(1) NOT NULL,
+ `user_country` varchar(50) NOT NULL,
+ `user_county_manual` tinyint(1) NOT NULL,
+ `user_timezone` varchar(50) NOT NULL,
+ `user_timezone_manual` tinyint(1) NOT NULL,
`user_number` varchar(20) NOT NULL,
`phone_credit` int(11) NOT NULL default '0',
`phone_code` varchar(255) NOT NULL,
@@ -99,41 +156,44 @@
PRIMARY KEY (`user_id`),
UNIQUE KEY `openid_identity` (`openid_identity`),
UNIQUE KEY `user_mail` (`user_mail`)
-) ENGINE=MyISAM;
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+-- --------------------------------------------------------
+
--
-- Table structure for table `users_feeds`
--
-DROP TABLE IF EXISTS `users_feeds`;
-CREATE TABLE `users_feeds` (
+CREATE TABLE IF NOT EXISTS `users_feeds` (
`feed_id` int(11) NOT NULL auto_increment,
`feed_url` text NOT NULL,
`feed_type` varchar(50) NOT NULL,
`last_time` datetime NOT NULL,
`user_id` int(11) NOT NULL,
PRIMARY KEY (`feed_id`)
-) ENGINE=MyISAM;
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+-- --------------------------------------------------------
+
--
-- Table structure for table `users_sms_service`
--
-DROP TABLE IF EXISTS `users_sms_service`;
-CREATE TABLE `users_sms_service` (
+CREATE TABLE IF NOT EXISTS `users_sms_service` (
`user_service_id` int(11) NOT NULL auto_increment,
`user_id` int(11) NOT NULL,
`service_day` tinyint(1) NOT NULL,
`service_hour` tinyint(2) NOT NULL,
PRIMARY KEY (`user_service_id`)
-) ENGINE=MyISAM;
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+-- --------------------------------------------------------
+
--
-- Table structure for table `users_update_service`
--
-DROP TABLE IF EXISTS `users_update_service`;
-CREATE TABLE `users_update_service` (
+CREATE TABLE IF NOT EXISTS `users_update_service` (
`user_service_id` int(11) NOT NULL auto_increment,
`user_id` int(11) NOT NULL,
`service_type` varchar(2) NOT NULL,
@@ -141,4 +201,4 @@
`username` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
PRIMARY KEY (`user_service_id`)
-) ENGINE=MyISAM;
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2008-11-16 00:56:03
|
Revision: 75
http://laconicatools.svn.sourceforge.net/laconicatools/?rev=75&view=rev
Author: jontheniceguy
Date: 2008-11-16 00:55:58 +0000 (Sun, 16 Nov 2008)
Log Message:
-----------
Install script pulls in a version of SimplePie from their website. lib_openid.php pulls in more data and coding standards are applied. Added standard header to lib_openid.php, and set properties accordingly.
Modified Paths:
--------------
smsToLaconica/trunk/install.sh
smsToLaconica/trunk/lib_openid.php
Property Changed:
----------------
smsToLaconica/trunk/lib_openid.php
Modified: smsToLaconica/trunk/install.sh
===================================================================
--- smsToLaconica/trunk/install.sh 2008-11-16 00:46:08 UTC (rev 74)
+++ smsToLaconica/trunk/install.sh 2008-11-16 00:55:58 UTC (rev 75)
@@ -20,6 +20,10 @@
exit
fi
+wget http://simplepie.org/mint/pepper/orderedlist/downloads/download.php?file=http%3A//simplepie.org/downloads/simplepie_1.1.1.zip
+unzip -j simplepie_1.1.1.zip *simplepie.inc
+rm simplepie_1.1.1.zip
+
sudo mkdir /var/www/smsToLaconica
sudo chown $USER.$USER /var/www/smsToLaconica
sudo chmod 755 /var/www/smsToLaconica
Modified: smsToLaconica/trunk/lib_openid.php
===================================================================
--- smsToLaconica/trunk/lib_openid.php 2008-11-16 00:46:08 UTC (rev 74)
+++ smsToLaconica/trunk/lib_openid.php 2008-11-16 00:55:58 UTC (rev 75)
@@ -1,5 +1,10 @@
<?php
+// This code is released under the AGPL (V.3 or later)
+// Author: Jon Spriggs (jo...@sp...)
+// Version: 0.6
+// SVN Version: $Rev$ on $Date$ last updated by $Author$
+
// This function is tested with the code obtained from
// http://www.stevelove.org/2008/08/how-to-wordpresscom-and-the-simple-openid-php-class/
// Using the Yadis library, as referenced from
@@ -10,7 +15,7 @@
require_once('class.openid.php');
require_once('lib_debug.php');
-function OpenID_Auth($site_url='', $req_flds=array('email', 'fullname')) {
+function OpenID_Auth($req_flds=array('email','fullname','dob','gender','postcode','country','language','timezone'), $site_url='') {
if($site_url=='') {
if($_SERVER['HTTPS']!='') {
$site_url="https://";
@@ -28,12 +33,12 @@
}
$site_url.=$request_url;
}
- if ($_POST['openid_action'] == "login"){ // Get identity from user and redirect browser to OpenID Server
+ if($_POST['openid_action']=="login") { // Get identity from user and redirect browser to OpenID Server
$openid = new SimpleOpenID;
$openid->SetIdentity($_POST['openid_url']);
$openid->SetTrustRoot($site_url);
$openid->SetRequiredFields($req_flds);
- if ($openid->GetOpenIDServer()){
+ if($openid->GetOpenIDServer()) {
$openid->SetApprovedURL($site_url);
$openid->Redirect();
} else {
@@ -41,11 +46,11 @@
$err_data="ERROR CODE: " . $error['code'] . "<br>";
$err_data.="ERROR DESCRIPTION: " . $error['description'] . "<br>";
}
- } else if($_GET['openid_mode'] == 'id_res') {
+ } elseif($_GET['openid_mode'] == 'id_res') {
$openid = new SimpleOpenID;
$openid->SetIdentity($_GET['openid_identity']);
$openid_validation_result = $openid->ValidateWithServer();
- if ($openid_validation_result == true){
+ if($openid_validation_result == true) {
if(session_id()=="") {session_start();}
$_SESSION['valid']=TRUE;
$_SESSION['openid_identity']=$openid->OpenID_Standarize($_GET['openid_identity']);
@@ -55,14 +60,14 @@
}
}
header("Location: $site_url");
- } else if($openid->IsError() == true){
+ } else if($openid->IsError() == true) {
$error = $openid->GetError();
$err_data="ERROR CODE: " . $error['code'] . "<br>";
$err_data.="ERROR DESCRIPTION: " . $error['description'] . "<br>";
- }else{
+ } else {
$err_data="INVALID AUTHORIZATION";
}
- }else if ($_GET['openid_mode'] == 'cancel'){
+ } elseif ($_GET['openid_mode'] == 'cancel') {
$err_data="USER CANCELED REQUEST";
}
return($err_data);
Property changes on: smsToLaconica/trunk/lib_openid.php
___________________________________________________________________
Added: svn:keywords
+ Date Rev Author Id
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2008-11-16 00:46:11
|
Revision: 74
http://laconicatools.svn.sourceforge.net/laconicatools/?rev=74&view=rev
Author: jontheniceguy
Date: 2008-11-16 00:46:08 +0000 (Sun, 16 Nov 2008)
Log Message:
-----------
The function d_mysql_fetch_array erroniously returned results when even when verbose and SQL logging were turned off.
Modified Paths:
--------------
smsToLaconica/trunk/lib_debug.php
Modified: smsToLaconica/trunk/lib_debug.php
===================================================================
--- smsToLaconica/trunk/lib_debug.php 2008-11-16 00:44:26 UTC (rev 73)
+++ smsToLaconica/trunk/lib_debug.php 2008-11-16 00:46:08 UTC (rev 74)
@@ -69,7 +69,7 @@
function d_mysql_fetch_array($qry) {
$return=mysql_fetch_array($qry);
- if($return) {debug("ARY: " . print_r($return, TRUE), FALSE, TRUE);}
+ if($return) {debug("ARY: " . print_r($return, TRUE), TRUE, TRUE);}
return $return;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2008-11-16 00:44:31
|
Revision: 73
http://laconicatools.svn.sourceforge.net/laconicatools/?rev=73&view=rev
Author: jontheniceguy
Date: 2008-11-16 00:44:26 +0000 (Sun, 16 Nov 2008)
Log Message:
-----------
Cleaned up SQL queries and wrote in Timezone functions to SMS Out functions.
Modified Paths:
--------------
smsToLaconica/trunk/daemon_database.php
smsToLaconica/trunk/daemon_feed.php
Modified: smsToLaconica/trunk/daemon_database.php
===================================================================
--- smsToLaconica/trunk/daemon_database.php 2008-11-11 21:19:15 UTC (rev 72)
+++ smsToLaconica/trunk/daemon_database.php 2008-11-16 00:44:26 UTC (rev 73)
@@ -14,14 +14,12 @@
dump_config();
d_mysql_connect();
-$queue_in_sql="SELECT in_id, phone_number, message FROM queue_in WHERE time_last<=NOW()";
while(TRUE) {
sleep($sleep);
- $queue_in_res=d_mysql_query($queue_in_sql);
+ $queue_in_res=d_mysql_query("SELECT in_id, phone_number, message FROM queue_in WHERE time_last<=NOW()");
if(d_mysql_num_rows($queue_in_res)>0) {
while(list($in_id, $phone_number, $message)=mysql_fetch_array($queue_in_res)) {
- $user_sql="SELECT user_id FROM users WHERE user_number='" . mysql_real_escape_string($phone_number) . "'";
- $user_res=d_mysql_query($user_sql);
+ $user_res=d_mysql_query("SELECT user_id FROM users WHERE user_number='" . mysql_real_escape_string($phone_number) . "'");
if(d_mysql_num_rows($user_res)>0) {
list($user_id)=d_mysql_fetch_array($user_res);
$service='';
@@ -53,41 +51,39 @@
$buffer=call_rest_api($base_url . "/statuses/update.xml", "source={$ui['message_source']}&status=$message", "$username:$password");
switch($buffer) {
case TRUE:
- $sql="DELETE FROM queue_in WHERE in_id='$in_id';";
- d_mysql_query($sql);
- $sql="UPDATE users SET messages_received=messages_received+1 WHERE user_id='$user_id'";
- d_mysql_query($sql);
+ d_mysql_query("DELETE FROM queue_in WHERE in_id='$in_id'");
+ d_mysql_query("UPDATE users SET messages_received=messages_received+1 WHERE user_id='$user_id'");
+ $msg_qry=d_mysql_query("SELECT counter FROM message_in_log WHERE user_id='$user_id' AND c_year='" . gmdate('Y') . "' AND c_month='" . gmdate('m') . "' AND c_day='" . gmdate('d') . "' AND c_hour='" . gmdate('H') . "' AND c_minute='" . gmdate('i') . "'");
+ if(d_mysql_num_rows($msg_qry)>0) {
+ d_mysql_query("UPDATE message_in_log SET counter=counter+1 WHERE user_id='$user_id' AND c_year='" . gmdate('Y') . "' AND c_month='" . gmdate('m') . "' AND c_day='" . gmdate('d') . "' AND c_hour='" . gmdate('H') . "' AND c_minute='" . gmdate('i') . "'");
+ } else {
+ d_mysql_query("INSERT INTO message_in_log (user_id, counter, c_year, c_month, c_day, c_hour, c_minute) VALUES ('$user_id', 1, '" . gmdate('Y') . "', c_month='" . gmdate('m') . "', c_day='" . gmdate('d') . "', c_hour='" . gmdate('H') . "', c_minute='" . gmdate('i') . "')");
+ }
+ event_log($user_id, "Status was updated at " , mysql_real_escape_string($base_url) . " with the message \"" . mysql_real_escape_string($message) . "\"");
break;
case FALSE:
- $sql="INSERT INTO errors (time_in, user_id, message, error_text) VALUES (NOW(), '$user_id', '" . mysql_real_escape_string($message) . "', 'No response from the server " . mysql_real_escape_string($base_url) . "')";
- d_mysql_query($sql);
- $sql="UPDATE queue_in SET time_last='" . date("Y-m-d H:i:s", strtotime("+5 minutes")) . "' where in_id='$in_id'";
- d_mysql_query($sql);
+ d_mysql_query("INSERT INTO errors (time_in, user_id, message, error_text) VALUES (NOW(), '$user_id', '" . mysql_real_escape_string($message) . "', 'No response from the server " . mysql_real_escape_string($base_url) . "')");
+ d_mysql_query("UPDATE queue_in SET time_last='" . date("Y-m-d H:i:s", strtotime("+5 minutes")) . "' where in_id='$in_id'");
+ event_log($user_id, "A status update for " , mysql_real_escape_string($base_url) . " with the message \"" . mysql_real_escape_string($message) . "\" was postponed until " . date("Y-m-d H:i:s", strtotime("+5 minutes")) . " due to an error contacting the remote server.");
break;
default:
- $sql="DELETE FROM queue_in WHERE in_id='$in_id';";
- d_mysql_query($sql);
- $sql="INSERT INTO errors (time_in, user_id, message, error_text) VALUES (NOW(), '$user_id, '" . mysql_real_escape_string($message) . "', 'Server: " . mysql_real_escape_string($base_url) . " Responds: " . mysql_real_escape_string($buffer) . "')";
- d_mysql_query($sql);
+ d_mysql_query("DELETE FROM queue_in WHERE in_id='$in_id'");
+ d_mysql_query("INSERT INTO errors (time_in, user_id, message, error_text) VALUES (NOW(), '$user_id, '" . mysql_real_escape_string($message) . "', 'Server: " . mysql_real_escape_string($base_url) . " Responds: " . mysql_real_escape_string($buffer) . "')");
send_alert_mail($user_id, "Status could not be updated", "Unfortunately, your message ($message) could not be sent to $base_url as we received an error message. Please can you review your settings at the below URL to resolve this issue.");
+ event_log($user_id, "A status update for " , mysql_real_escape_string($base_url) . " with the message \"" . mysql_real_escape_string($message) . "\" was cancelled due to an error message received from the server.");
}
}
}
}
} else {
- $get_user_sql="SELECT user_id FROM users WHERE phone_code LIKE '" . mysql_real_escape_string(trim($message)) . "'";
- $get_user_qry=d_mysql_query($get_user_sql);
+ $get_user_qry=d_mysql_query("SELECT user_id FROM users WHERE phone_code LIKE '" . mysql_real_escape_string(trim($message)) . "'");
if(d_mysql_num_rows($get_user_qry)>0) {
list($user_id)=d_mysql_fetch_array($get_user_qry);
- $update_user_sql="UPDATE users SET phone_number='$phone_number' WHERE user_id='$user_id'";
- d_mysql_query($update_user_sql);
- $sql="DELETE FROM queue_in WHERE in_id='$in_id';";
- d_mysql_query($sql);
+ d_mysql_query("UPDATE users SET phone_number='$phone_number' WHERE user_id='$user_id'");
+ d_mysql_query("DELETE FROM queue_in WHERE in_id='$in_id'");
} else {
- $sql="INSERT INTO errors (time_in, user_number, message, error_text) VALUES (NOW(), '" . mysql_real_escape_string($phone_number) . "', '" . mysql_real_escape_string($message) . "', 'No such user')";
- d_mysql_query($sql);
- $sql="DELETE FROM queue_in WHERE in_id='$in_id';";
- d_mysql_query($sql);
+ d_mysql_query("INSERT INTO errors (time_in, user_number, message, error_text) VALUES (NOW(), '" . mysql_real_escape_string($phone_number) . "', '" . mysql_real_escape_string($message) . "', 'No such user')");
+ d_mysql_query("DELETE FROM queue_in WHERE in_id='$in_id'");
}
}
}
@@ -112,5 +108,4 @@
mail($user_mail, $title, $message, $headers);
}
}
- d_mysql_query("UPDATE service_status SET last_run=CURRENT_TIMESTAMP WHERE service_name='daemon_database.php'", TRUE, TRUE);
}
\ No newline at end of file
Modified: smsToLaconica/trunk/daemon_feed.php
===================================================================
--- smsToLaconica/trunk/daemon_feed.php 2008-11-11 21:19:15 UTC (rev 72)
+++ smsToLaconica/trunk/daemon_feed.php 2008-11-16 00:44:26 UTC (rev 73)
@@ -7,7 +7,7 @@
// SimplePie is a library released under a BSD style license. As a result, I have
// not included it in this release. Please obtain this code from
-// http://simplepie.org
+// http://simplepie.org - this code was tested with version 1.1.1
require_once("simplepie.inc");
require_once("config.php");
@@ -18,39 +18,55 @@
function send_update_sms($user_id, $title, $url="") {
if(check_service_ok($user_id)) {
- $sql="SELECT user_number FROM users WHERE user_id='$user_id'";
- $qry=d_mysql_query($sql);
+ $qry=d_mysql_query("SELECT user_number FROM users WHERE user_id='$user_id'");
if(d_mysql_num_rows($qry)>0) {
while(list($user_number)=d_mysql_fetch_array($qry)) {
- $sql="INSERT INTO queue_out (phone_number, message, time_in, time_last) VALUES ('{$user_number}', '" . mysql_real_escape_string($title) . "', NOW(), NOW())";
- d_mysql_query($sql);
- $sql="UPDATE users SET phone_credit=phone_credit-1, messages_sent=messages_sent+1 WHERE user_id='$user_id'";
- d_mysql_query($sql);
+ d_mysql_query("INSERT INTO queue_out (phone_number, message, time_in, time_last) VALUES ('{$user_number}', '" . mysql_real_escape_string($title) . "', NOW(), NOW())");
+ d_mysql_query("UPDATE users SET phone_credit=phone_credit-1, messages_sent=messages_sent+1 WHERE user_id='$user_id'");
+ $msg_qry=d_mysql_query("SELECT counter FROM message_out_log WHERE user_id='$user_id' AND c_year='" . gmdate('Y') . "' AND c_month='" . gmdate('m') . "' AND c_day='" . gmdate('d') . "' AND c_hour='" . gmdate('H') . "' AND c_minute='" . gmdate('i') . "'");
+ if(d_mysql_num_rows($msg_qry)>0) {
+ d_mysql_query("UPDATE message_out_log SET counter=counter+1 WHERE user_id='$user_id' AND c_year='" . gmdate('Y') . "' AND c_month='" . gmdate('m') . "' AND c_day='" . gmdate('d') . "' AND c_hour='" . gmdate('H') . "' AND c_minute='" . gmdate('i') . "'");
+ } else {
+ d_mysql_query("INSERT INTO message_out_log (user_id, counter, c_year, c_month, c_day, c_hour, c_minute) VALUES ('$user_id', 1, '" . gmdate('Y') . "', c_month='" . gmdate('m') . "', c_day='" . gmdate('d') . "', c_hour='" . gmdate('H') . "', c_minute='" . gmdate('i') . "')");
+ }
+ event_log($user_id, "Message \"" . mysql_real_escape_string($title). "\" was queued to be sent to " . mysql_real_escape_string($user_number));
}
}
} else {
send_update_mail($user_id, $title, $url);
+ event_log($user_id, "Message \"" . mysql_real_escape_string($title). "\" was sent by e-mail. Please see the previous event log to review why this was sent by e-mail rather than by SMS.");
}
}
function check_service_ok($user_id) {
$return=FALSE;
- $service_sql="SELECT user_id FROM users_sms_service WHERE user_id='$user_id' AND service_day='" . gmdate("N") . "' AND service_hour='" . gmdate("H") . "'";
- $service_qry=d_mysql_query($service_sql);
- if(d_mysql_num_rows($service_qry)>0) {
- $credit_sql="SELECT phone_credit FROM users WHERE user_id='$user_id'";
- $credit_qry=d_mysql_query($credit_sql);
- if(d_mysql_num_rows($credit_qry)>0) {
+ $credit_and_tz_qry=d_mysql_query("SELECT user_timezone FROM users WHERE user_id='$user_id' AND phone_credit>0");
+ if(d_mysql_num_rows($credit_and_tz_qry)>0) {
+ list($timezone)=d_mysql_fetch_array($credit_and_tz_qry);
+ $now="now";
+ if($timezone!='')
+ {
+ $ltz=new DateTimeZone($timezone);
+ $lt=new DateTime('now', $tz);
+ $localtime=$ltz->getOffset($lt);
+ if($localtime>0) {$now="+$localtime seconds";}
+ if($localtime<0) {$now="$localtime seconds";}
+ }
+ $service_qry=d_mysql_query("SELECT user_id FROM users_sms_service WHERE user_id='$user_id' AND service_day='" . date("N", strtotime($now)) . "' AND service_hour='" . gmdate("H", strtotime($now)) . "'");
+ if(d_mysql_num_rows($service_qry)>0) {
$return=TRUE;
+ } else {
+ event_log($user_id, "A service check failed as you were outside your approved service times.");
}
+ } else {
+ event_log($user_id, "A service check failed as you had no available phone credit.");
}
return $return;
}
function send_update_mail($user_id, $title, $url="") {
global $ui;
- $sql="SELECT user_name, user_mail FROM users WHERE user_id='$user_id'";
- $qry=d_mysql_query($sql);
+ $qry=d_mysql_query("SELECT user_name, user_mail FROM users WHERE user_id='$user_id'");
if(d_mysql_num_rows($qry)>0) {
while(list($user_name, $user_mail)=d_mysql_fetch_array($qry)) {
$headers = 'MIME-Version: 1.0' . "\r\n" .
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2008-11-11 21:19:26
|
Revision: 72
http://laconicatools.svn.sourceforge.net/laconicatools/?rev=72&view=rev
Author: jontheniceguy
Date: 2008-11-11 21:19:15 +0000 (Tue, 11 Nov 2008)
Log Message:
-----------
Copied branch 0.6 to trunk for general purpose testing!
Modified Paths:
--------------
smsToLaconica/trunk/README.txt
smsToLaconica/trunk/UPGRADE.txt
smsToLaconica/trunk/default_config.php
smsToLaconica/trunk/lib_pdu.php
smsToLaconica/trunk/run_scripts.sh
smsToLaconica/trunk/smsToLaconica.sql
Added Paths:
-----------
smsToLaconica/trunk/daemon_database.php
smsToLaconica/trunk/daemon_feed.php
smsToLaconica/trunk/daemon_modem.php
smsToLaconica/trunk/install.sh
smsToLaconica/trunk/lib_debug.php
smsToLaconica/trunk/lib_modem.php
smsToLaconica/trunk/lib_openid.php
smsToLaconica/trunk/lib_text.php
smsToLaconica/trunk/mail_admin.php
smsToLaconica/trunk/web_index.php
Removed Paths:
-------------
smsToLaconica/trunk/admin.php
smsToLaconica/trunk/process_db.php
smsToLaconica/trunk/read_sms.php
smsToLaconica/trunk/ui.php
Modified: smsToLaconica/trunk/README.txt
===================================================================
--- smsToLaconica/trunk/README.txt 2008-11-11 21:05:36 UTC (rev 71)
+++ smsToLaconica/trunk/README.txt 2008-11-11 21:19:15 UTC (rev 72)
@@ -6,8 +6,9 @@
Version 0.1 was written by Jon Spriggs (XMPP and SMTP: jo...@sp...)
Version 0.5 was written by Jon Spriggs, with some fixes identified by Ciaran G (http://blog.ciarang.com)
-Version 0.5.1 was written by Jon Spriggs, adding support for differing SMS interpretation systems (PDU and Text), and
-monitoring text messages received from a user.
+Version 0.5.1 was written by Jon Spriggs, adding support for differing SMS interpretation systems (PDU and Text), and monitoring text messages received from a user.
+Version 0.6 was written by Jon Spriggs introducing Text Mode and providing functions to send messages as well as receive them.
+
This document has been taken from SVN at version $Rev$ on $Date$ last updated by $Author$
Requirements
@@ -18,32 +19,42 @@
3. (Optional) Some form of Bluetooth transport for Ser2Net to communicate with, unless you have a data cable which exposes
itself as a serial interface.
4. An old mobile phone which uses SMS-PDU.
+5. simplepie (tested with version 1.1.1) from http://simplepie.org placed in the script
+root (/path/to/script/root/simplepie.inc).
+6. simple_openid (tested with Steve Love's modified version) from
+http://www.stevelove.org/2008/08/how-to-wordpresscom-and-the-simple-openid-php-class/,
+placed in the script root (/path/to/script/root/class.openid.php)
+7. The services folder from the Yadis library, referenced from
+http://www.stevelove.org/2008/08/how-to-yahoo-and-the-simple-openid-php-class/ placed in
+the script root (/path/to/script/root/services)
Install Guide
-------------
-1. Unpack these files to a directory outside of your Web Root - there is only one page which is web based, and that isn't
-written yet!
+1. Unpack these files to a directory outside of your Web Root.
2. Import smsToLaconica.sql to your MySQL instance.
-3. Configure your Ser2Net to talk to your mobile phone. Confirm it works by telnetting to the port you've designated for
-your mobile phone and send the command "AT" (no quotes) and wait for a response OK. If you get nothing, then contact me
-for some (VERY) limited support. Check your phone talks SMS-PDU by sending the AT+CMGL=4. If this returns ERROR, then your
-phone doesn't talk PDU. If it returns OK, then it does. Your phone may talk SMS-TEXT, which you can find out by sending
-AT+CGMS="ALL". I don't have a phone which talks SMS-TEXT, so these scripts are based on SMS-PDU.
-4. Edit config.php with at least enough information for the scripts to talk to your MySQL server and Ser2Net instance.
-5. Using nohup or screen, start php -q read_sms.php and php -q process_db.php
-6. Add an entry to the database table users, with the base url of your laconi.ca instance (e.g. http://identi.ca), your
-username and password on that laconi.ca instance (e.g. jontheniceguy and p@$$w0rd) and your mobile number in the format
-441234567890, where 44 is your country code and the number is your mobile number. You can, alternatively, copy or link
-the ui.php and config.php to somewhere on your web service and visit the ui.php file. Add your details there.
-7. Send an SMS from your current phone to your old phone and watch the scripts running text up the screen. Check your
-laconi.ca environment to see if the message was posted.
-8. If required, create a CRON task to activate the admin.php script on a regular basis. This will send you an e-mail
-containing the latest user list and the number of messages that person has sent (and processing errors with that number).
+3. Configure your Ser2Net to talk to your mobile phone. Confirm it works by telnetting to
+the port you've designated for your mobile phone and send the command "AT" (no quotes)
+and wait for a response OK. If you get nothing, then contact me for some (VERY) limited
+support.
+4. Test whether your phone talks SMS-TEXT or SMS-PDU with the AT command "AT+CMGF=1". If
+it replies OK, then it talks SMS-TEXT, if it replies ERROR, then it only talks SMS-PDU.
+You'll need to know this for the next step.
+5. Edit config.php with at least enough information for the scripts to talk to your MySQL
+server and Ser2Net instance.
+6. Run run_scripts.sh
+7. Copy or link the ui.php and config.php to somewhere on your web service and visit the
+ui.php file.
+8. Send an SMS from your current phone to your old phone and watch the scripts running
+text up the screen. Check your laconi.ca environment to see if the message was posted.
+9. If required, create a CRON task to activate the admin.php script on a regular basis.
+This will send you an e-mail containing the latest user list and the number of messages
+that person has sent (and processing errors with that number).
-Any comments or questions, please contact me by e-mail, find me on irc as JonTheNiceGuy on the FreeNode network (not
-often really!), or send me a dent at http://identi.ca/jontheniceguy.
+Any comments or questions, please contact me by e-mail, find me on irc as JonTheNiceGuy
+on the FreeNode network (not often really!), or send me a dent at
+http://identi.ca/jontheniceguy.
Your best bet is to communicate with me by e-mail.
-All the best, Jon Spriggs
\ No newline at end of file
+All the best, Jon Spriggs
Modified: smsToLaconica/trunk/UPGRADE.txt
===================================================================
--- smsToLaconica/trunk/UPGRADE.txt 2008-11-11 21:05:36 UTC (rev 71)
+++ smsToLaconica/trunk/UPGRADE.txt 2008-11-11 21:19:15 UTC (rev 72)
@@ -1,9 +1,15 @@
Upgrade Notes
+<=0.5.1 >=0.6
+
+Practically all the filenames have changed, and there are major database changes need to
+be made. Lastly, the phone number is no longer MD5'd, as this prevents sending SMS
+messages (should that be desired).
+
<=0.5 to >=0.5.1
-YOU MUST CLEAR YOUR PHONE'S SMS MEMORY BEFORE YOU UPDATE TO THIS VERSION!
+This script will process any messages stored in your phone UNLESS you change the script to not handle the read messages. These settings are in daemon_modem.php.
Please use the following sql statement;
-ALTER TABLE `users` ADD `posts` INT NOT NULL DEFAULT '0';
\ No newline at end of file
+ALTER TABLE `users` ADD `posts` INT NOT NULL DEFAULT '0';
Deleted: smsToLaconica/trunk/admin.php
===================================================================
--- smsToLaconica/trunk/admin.php 2008-11-11 21:05:36 UTC (rev 71)
+++ smsToLaconica/trunk/admin.php 2008-11-11 21:19:15 UTC (rev 72)
@@ -1,68 +0,0 @@
-<?php
-$mail="<html><body><h1>SMS -> Laconi.ca Bridge - Admin Information</h1>";
-
-// This code is released under the AGPL (V.3 or later)
-// Author: Jon Spriggs (jo...@sp...)
-// Version: 0.5.1
-// SVN Version: $Rev$ on $Date$ last updated by $Author$
-
-include_once("config.php");
-
-if(!isset($db)) {$db=array('host'=>'localhost', 'user'=>'smsToLaconica', 'pass'=>'smsToLaconica', 'base'=>'smsToLaconica');}
-if(!isset($debug)) {$debug=array('enabled'=>FALSE, 'output_to_screen'=>FALSE, 'output_to_file'=>FALSE, 'output_file'=>'/var/log/sms_to_laconica.log', 'verbose'=>FALSE);}
-if(!isset($code_book)) {$code_book=array(0=>0,1=>1,2=>2,3=>3,4=>4,5=>5,6=>6,7=>7,8=>8,9=>9,'a'=>'a','b'=>'b','c'=>'c','d'=>'d','e'=>'e','f'=>'f');}
-if(!isset($ui)) {$ui=array('owner'=>'YOUR NAME HERE', 'owner_url'=>'http://YOUR.OWN.WEBSITE', 'version'=>'0.5', 'source'=>'LaconicaTools', 'source_url'=>'http://laconicatools.sf.net', 'number'=>'Not yet set! Please contact the administrator of this service before use!');}
-if(!isset($email)) {$email=array('send_admin_mail'=>FALSE, 'to_address'=>'sms...@te...', 'from_name'=>'smsToLaconica Service', 'from_address'=>'sms...@YO...');}
-
-mysql_connect($db['host'], $db['user'], $db['pass']) or die("Can't connect to the Database Server");
-mysql_select_db($db['base']) or die("Can't select the Database");
-
-$base_url_qry=mysql_query("SELECT base_url FROM users GROUP BY base_url");
-if(mysql_num_rows($base_url_qry)>0) {
- $mail.="<h1>User list</h1>";
- $mail.="<table width=100%><tr><th>Laconi.ca Instance<br>(Authenticated/Code Allocated)</th><th>Users - Authenticated<br>(Posted/Errors)</th><th>Users - Code Allocated</th></tr>";
- while(list($base_url)=mysql_fetch_array($base_url_qry)) {
- $auth_users_qry=mysql_query("SELECT username, number, posts FROM users WHERE base_url like '$base_url' AND number!=''");
- $code_users_qry=mysql_query("SELECT username FROM users WHERE base_url like '$base_url' AND code!=''");
- $mail.="<tr><td valign=center>$base_url (" . mysql_num_rows($auth_users_qry) . "/" . mysql_num_rows($code_users_qry) . ")</td><td valign=center>";
- $counter=0;
- while(list($username, $number, $posts)=mysql_fetch_array($auth_users_qry)) {
- $counter++;
- list($errs)=mysql_fetch_array(mysql_query("SELECT count(id) FROM mq WHERE `from`='$number' AND `date`<`queue_action`"));
- if($counter>1) {$mail.="<br>";}
- if($errs<1) {$errs=0;}
- if($posts<1) {$posts=0;}
- $mail.=htmlentities($username) . " ($posts/$errs)";
- }
- $mail.="</td><td valign=center>";
- $counter=0;
- while(list($username)=mysql_fetch_array($code_users_qry)) {
- $counter++;
- if($counter>1) {$mail.="<br>";}
- $mail.=htmlentities($username, ENT_QUOTES);
- }
- $mail.="</td></tr>";
- }
- $mail.="</table>";
-}
-
-$mq_no_rx_qry=mysql_query("SELECT mq.id, mq.`date`, mq.`from`, mq.`msg` FROM mq LEFT JOIN users ON mq.`from` = users.`number` WHERE users.`username` IS NULL");
-if(mysql_num_rows($mq_no_rx_qry)>0) {
- $mail.="<h1>Messages with no user</h1>";
- $mail.="<table width=100%><tr><th>Date</th><th>From</th><th>Message</th></tr>";
- while(list($id, $date, $from, $msg)=mysql_fetch_array($mq_no_rx_qry)) {
- $mail.="<tr><td>" . htmlentities($date) . "</td><td>" . htmlentities($from) . "</td><td>" . htmlentities($msg) . "</td></tr>";
- }
- $mail.="</table>";
-}
-
-$mail.='<p>This gateway is brought to you by <a href="' . $ui['owner_url'] . '">' . $ui['owner'] . '</a> and runs the smsToLaconica gateway software, version '. $ui['version'] .', which is available under the GNU Affero General Public License from <a href="' . $ui['source_url'] . '">' . $ui['source'] . '</a></p></body></html>';
-
-if(!$email['send_admin_mail']==FALSE) {
- // HTML Posting Information derived from http://www.sitepoint.com/article/advanced-email-php/
- mail($email['to_address'], 'smsToLaconica Report for ' . date('Y-m-d'), $mail, 'From: ' . $email['from_name'] . '<' . $email['from_address'] . ">\nMIME-Version: 1.0\nContent-type: text/html; charset=iso-8859-1");
-} else {
- echo "From: " . $email['from_name'] . '<' . $email['from_address'] . ">\r\nTo: " . $email['to_address']. "\r\nSubject: smsToLaconica Report for " . date('Y-m-d') . "\r\n" . $mail;
-
-}
-?>
\ No newline at end of file
Copied: smsToLaconica/trunk/daemon_database.php (from rev 66, smsToLaconica/trunk/process_db.php)
===================================================================
--- smsToLaconica/trunk/daemon_database.php (rev 0)
+++ smsToLaconica/trunk/daemon_database.php 2008-11-11 21:19:15 UTC (rev 72)
@@ -0,0 +1,116 @@
+<?php
+
+// This code is released under the AGPL (V.3 or later)
+// Author: Jon Spriggs (jo...@sp...)
+// Version: 0.6
+// SVN Version: $Rev$ on $Date$ last updated by $Author$
+
+ini_set("max_execution_time", 0);
+set_time_limit(0);
+
+require_once("config.php");
+require_once("lib_debug.php");
+
+dump_config();
+d_mysql_connect();
+
+$queue_in_sql="SELECT in_id, phone_number, message FROM queue_in WHERE time_last<=NOW()";
+while(TRUE) {
+ sleep($sleep);
+ $queue_in_res=d_mysql_query($queue_in_sql);
+ if(d_mysql_num_rows($queue_in_res)>0) {
+ while(list($in_id, $phone_number, $message)=mysql_fetch_array($queue_in_res)) {
+ $user_sql="SELECT user_id FROM users WHERE user_number='" . mysql_real_escape_string($phone_number) . "'";
+ $user_res=d_mysql_query($user_sql);
+ if(d_mysql_num_rows($user_res)>0) {
+ list($user_id)=d_mysql_fetch_array($user_res);
+ $service='';
+ switch(substr($message, 0, 2)) {
+ case "T ":
+ // Twitter
+ case "L ":
+ // Laconi.ca
+ case "P ":
+ // Location Updates on both - not yet implemented!
+ $service=substr($message, 0, 1);
+ $message=substr($message, 2);
+ break;
+ }
+ if($service=='T' OR $service=='L') {
+ $where="AND service_type='$service'";
+ } elseif($service=='P') {
+ $where="AND (service_type='T' OR service_type='L')";
+ }
+ $update_service_sql="SELECT base_url, username, password FROM users_update_service WHERE user_id='$user_id' $where";
+ $update_service_res=d_mysql_query($update_service_sql);
+ if(d_mysql_num_rows($update_service_res)>0) {
+ while(list($base_url, $username, $password)=d_mysql_fetch_array($update_service_res)) {
+ switch($service) {
+ case 'P':
+ // Update location - To be completed
+ break;
+ default:
+ $buffer=call_rest_api($base_url . "/statuses/update.xml", "source={$ui['message_source']}&status=$message", "$username:$password");
+ switch($buffer) {
+ case TRUE:
+ $sql="DELETE FROM queue_in WHERE in_id='$in_id';";
+ d_mysql_query($sql);
+ $sql="UPDATE users SET messages_received=messages_received+1 WHERE user_id='$user_id'";
+ d_mysql_query($sql);
+ break;
+ case FALSE:
+ $sql="INSERT INTO errors (time_in, user_id, message, error_text) VALUES (NOW(), '$user_id', '" . mysql_real_escape_string($message) . "', 'No response from the server " . mysql_real_escape_string($base_url) . "')";
+ d_mysql_query($sql);
+ $sql="UPDATE queue_in SET time_last='" . date("Y-m-d H:i:s", strtotime("+5 minutes")) . "' where in_id='$in_id'";
+ d_mysql_query($sql);
+ break;
+ default:
+ $sql="DELETE FROM queue_in WHERE in_id='$in_id';";
+ d_mysql_query($sql);
+ $sql="INSERT INTO errors (time_in, user_id, message, error_text) VALUES (NOW(), '$user_id, '" . mysql_real_escape_string($message) . "', 'Server: " . mysql_real_escape_string($base_url) . " Responds: " . mysql_real_escape_string($buffer) . "')";
+ d_mysql_query($sql);
+ send_alert_mail($user_id, "Status could not be updated", "Unfortunately, your message ($message) could not be sent to $base_url as we received an error message. Please can you review your settings at the below URL to resolve this issue.");
+ }
+ }
+ }
+ }
+ } else {
+ $get_user_sql="SELECT user_id FROM users WHERE phone_code LIKE '" . mysql_real_escape_string(trim($message)) . "'";
+ $get_user_qry=d_mysql_query($get_user_sql);
+ if(d_mysql_num_rows($get_user_qry)>0) {
+ list($user_id)=d_mysql_fetch_array($get_user_qry);
+ $update_user_sql="UPDATE users SET phone_number='$phone_number' WHERE user_id='$user_id'";
+ d_mysql_query($update_user_sql);
+ $sql="DELETE FROM queue_in WHERE in_id='$in_id';";
+ d_mysql_query($sql);
+ } else {
+ $sql="INSERT INTO errors (time_in, user_number, message, error_text) VALUES (NOW(), '" . mysql_real_escape_string($phone_number) . "', '" . mysql_real_escape_string($message) . "', 'No such user')";
+ d_mysql_query($sql);
+ $sql="DELETE FROM queue_in WHERE in_id='$in_id';";
+ d_mysql_query($sql);
+ }
+ }
+ }
+ }
+ d_mysql_query("UPDATE service_status SET last_run=CURRENT_TIMESTAMP WHERE service_name='daemon_database.php'", TRUE, TRUE);
+}
+
+function send_alert_mail($user_id, $title, $message) {
+ global $ui;
+ $sql="SELECT user_name, user_mail FROM users WHERE user_id='$user_id'";
+ $qry=d_mysql_query($sql);
+ if(d_mysql_num_rows($qry)>0) {
+ while(list($user_name, $user_mail)=d_mysql_fetch_array($qry)) {
+ $headers = "MIME-Version: 1.0\r\n" .
+ "Content-type: text/html; charset=iso-8859-1\r\n" .
+ "From: smsToLaconica Service <{$email['from_address']}>\r\n" .
+ "To: $user_name <$user_mail>\r\n" .
+ "Reply-To: {$ui['system_mail']}\r\n" .
+ 'X-Mailer: PHP/' . phpversion();
+ $message = "<html><head>$title</head><body><p>$message</p>{$ui['standard_footer']}</body></html>";
+ debug("Mail sent to $user_mail: $headers\r\n$message", "Verbose");
+ mail($user_mail, $title, $message, $headers);
+ }
+ }
+ d_mysql_query("UPDATE service_status SET last_run=CURRENT_TIMESTAMP WHERE service_name='daemon_database.php'", TRUE, TRUE);
+}
\ No newline at end of file
Property changes on: smsToLaconica/trunk/daemon_database.php
___________________________________________________________________
Added: svn:keywords
+ Date Rev Author Id
Added: svn:mergeinfo
+
Copied: smsToLaconica/trunk/daemon_feed.php (from rev 66, smsToLaconica/branches/0.6/daemon_feed.php)
===================================================================
--- smsToLaconica/trunk/daemon_feed.php (rev 0)
+++ smsToLaconica/trunk/daemon_feed.php 2008-11-11 21:19:15 UTC (rev 72)
@@ -0,0 +1,120 @@
+<?php
+
+// This code is released under the AGPL (V.3 or later)
+// Author: Jon Spriggs (jo...@sp...)
+// Version: 0.6
+// SVN Version: $Rev$ on $Date$ last updated by $Author$
+
+// SimplePie is a library released under a BSD style license. As a result, I have
+// not included it in this release. Please obtain this code from
+// http://simplepie.org
+
+require_once("simplepie.inc");
+require_once("config.php");
+require_once("lib_debug.php");
+
+dump_config();
+d_mysql_connect();
+
+function send_update_sms($user_id, $title, $url="") {
+ if(check_service_ok($user_id)) {
+ $sql="SELECT user_number FROM users WHERE user_id='$user_id'";
+ $qry=d_mysql_query($sql);
+ if(d_mysql_num_rows($qry)>0) {
+ while(list($user_number)=d_mysql_fetch_array($qry)) {
+ $sql="INSERT INTO queue_out (phone_number, message, time_in, time_last) VALUES ('{$user_number}', '" . mysql_real_escape_string($title) . "', NOW(), NOW())";
+ d_mysql_query($sql);
+ $sql="UPDATE users SET phone_credit=phone_credit-1, messages_sent=messages_sent+1 WHERE user_id='$user_id'";
+ d_mysql_query($sql);
+ }
+ }
+ } else {
+ send_update_mail($user_id, $title, $url);
+ }
+}
+
+function check_service_ok($user_id) {
+ $return=FALSE;
+ $service_sql="SELECT user_id FROM users_sms_service WHERE user_id='$user_id' AND service_day='" . gmdate("N") . "' AND service_hour='" . gmdate("H") . "'";
+ $service_qry=d_mysql_query($service_sql);
+ if(d_mysql_num_rows($service_qry)>0) {
+ $credit_sql="SELECT phone_credit FROM users WHERE user_id='$user_id'";
+ $credit_qry=d_mysql_query($credit_sql);
+ if(d_mysql_num_rows($credit_qry)>0) {
+ $return=TRUE;
+ }
+ }
+ return $return;
+}
+
+function send_update_mail($user_id, $title, $url="") {
+ global $ui;
+ $sql="SELECT user_name, user_mail FROM users WHERE user_id='$user_id'";
+ $qry=d_mysql_query($sql);
+ if(d_mysql_num_rows($qry)>0) {
+ while(list($user_name, $user_mail)=d_mysql_fetch_array($qry)) {
+ $headers = 'MIME-Version: 1.0' . "\r\n" .
+ 'Content-type: text/html; charset=iso-8859-1' . "\r\n" .
+ 'From: ' . $ui['system_mail'] . "\r\n" .
+ "To: $user_name <$user_mail>\r\n" .
+ 'Reply-To: ' . $ui['system_mail'] . "\r\n" .
+ 'X-Mailer: PHP/' . phpversion();
+ if($url=="") {$title_url=$title;} else {$title_url="<a href=\"$url\">$title</a>";}
+ $message = "<html><head>$title</head><body><h2>$title_url</h2><p>This gateway is brought to you by <a href=\"{$ui['owner_url']}\">{$ui['owner']}</a> and runs the smsToLaconica gateway software, version {$ui['version']}, which is available under the GNU Affero General Public License from <a href=\"{$ui['source_url']}\">{$ui['source']}</a></p></body></html>";
+ debug("Mail sent to $user_mail: $headers\r\n$message", "Verbose");
+ mail($user_mail, $title, $message, $headers);
+ }
+ }
+}
+
+function get_rss_feed() {
+ $sql="SELECT feed_id, feed_url, feed_type, last_time, user_id FROM users_feeds ORDER BY last_time desc";
+ $qry=d_mysql_query($sql);
+ if(d_mysql_num_rows($qry)>0) {
+ while(list($feed_id, $feed_url, $feed_type, $last_date, $user_id)=d_mysql_fetch_array($qry)) {
+ $feed=new SimplePie($feed_url);
+ foreach($feed->get_items() as $feed_item) {
+ if(strtotime($feed_item->get_date("Y-m-d H:i:s"))>strtotime($last_date)) {
+ if($feed_item->get_date("U")>strtotime($update_feed[$feed_id])) {
+ $update_feed[$feed_id]=$feed_item->get_date("Y-m-d H:i:s");
+ }
+ $message_number++;
+ $message[$message_number]['user_id']=$user_id;
+ $author=$feed_item->get_author()->get_name();
+ $title=$feed_item->get_title();
+ if($feed_type=="T") {
+ $feed_author=explode(" ", $author);
+ $author=$feed_type . ":" . substr($feed_author[0], 0, 17) . ":";
+ } else {
+ $author=substr($title, 0, strpos($title, ":"));
+ $author=$feed_type . ":" . substr($author, 0, 17) . ":";
+ }
+ if($feed_type=="I" OR $feed_type=="L") {
+ $title=substr($title, strpos($title, ":")+2);
+ }
+ $message[$message_number]['title']=$author . substr($title, 0, 140);
+ $message[$message_number]['link']=$feed_item->get_permalink();
+ }
+ }
+ }
+ if(count($update_feed)>0) {
+ foreach($update_feed as $feed_id=>$new_date) {
+ $sql="UPDATE users_feeds SET last_time='$new_date' WHERE feed_id='$feed_id'";
+ d_mysql_query($sql);
+ }
+ }
+ return $message;
+ }
+}
+
+while(TRUE) {
+ sleep($sleep);
+ $messages=get_rss_feed();
+ if(count($messages)>0) {
+ foreach($messages as $message) {
+ send_update_sms($message['user_id'], $message['title'], $message['link']);
+ }
+ }
+ d_mysql_query("UPDATE service_status SET last_run=CURRENT_TIMESTAMP WHERE service_name='daemon_feed.php'", TRUE, TRUE);
+}
+?>
\ No newline at end of file
Property changes on: smsToLaconica/trunk/daemon_feed.php
___________________________________________________________________
Added: svn:keywords
+ Date Rev Author Id
Added: svn:mergeinfo
+
Copied: smsToLaconica/trunk/daemon_modem.php (from rev 66, smsToLaconica/trunk/read_sms.php)
===================================================================
--- smsToLaconica/trunk/daemon_modem.php (rev 0)
+++ smsToLaconica/trunk/daemon_modem.php 2008-11-11 21:19:15 UTC (rev 72)
@@ -0,0 +1,46 @@
+<?php
+
+// This code is released under the AGPL (V.3 or later)
+// Author: Jon Spriggs (jo...@sp...)
+// Version: 0.6
+// SVN Version: $Rev$ on $Date$ last updated by $Author$
+
+ini_set("max_execution_time", 0);
+set_time_limit(0);
+
+require_once("config.php");
+require_once("lib_debug.php");
+
+require_once('lib_modem.php');
+require_once('lib_' . $phone['data_type'] . '.php');
+
+dump_config();
+d_mysql_connect();
+
+while(TRUE) {
+ sleep($sleep);
+ if($functions['send']==TRUE) {
+ $qry=d_mysql_query("SELECT out_id, phone_number, message FROM queue_out");
+ if(d_mysql_num_rows($qry)>0) {
+ while(list($out_id, $phone_number, $message)=mysql_fetch_array($qry)) {
+ $success=Send_SMS($phone_number, $message);
+ if($success==TRUE) {
+ d_mysql_query("DELETE FROM queue_out WHERE out_id='$out_id'");
+ event_log(mysql_real_escape_string($phone_number), "Message sent '" . mysql_real_escape_string($message) . "'.");
+ }
+ }
+ }
+ }
+ $message=Read_SMS();
+ if(count($message)>0) {
+ foreach($message as $msg) {
+ debug("Message received from " . $msg['number'] . " at " . $msg['timestamp'] . ": " . $msg['message']);
+ debug(print_r($msg, true), 'verbose', 'sql');
+ $sql="INSERT INTO queue_in VALUES (NULL , '{$msg['number']}', '" . mysql_real_escape_string($msg['message']) . "', NOW(), NOW());";
+ d_mysql_query($sql);
+ event_log($msg['number'], "Message received '{$msg['message']}'.");
+ }
+ }
+ d_mysql_query("UPDATE service_status SET last_run=CURRENT_TIMESTAMP WHERE service_name='daemon_modem.php'", TRUE, TRUE);
+}
+?>
\ No newline at end of file
Property changes on: smsToLaconica/trunk/daemon_modem.php
___________________________________________________________________
Added: svn:keywords
+ Date Rev Author Id
Added: svn:mergeinfo
+
Modified: smsToLaconica/trunk/default_config.php
===================================================================
--- smsToLaconica/trunk/default_config.php 2008-11-11 21:05:36 UTC (rev 71)
+++ smsToLaconica/trunk/default_config.php 2008-11-11 21:19:15 UTC (rev 72)
@@ -2,7 +2,7 @@
// This code is released under the AGPL (V.3 or later)
// Author: Jon Spriggs (jo...@sp...)
-// Version: 0.5.1
+// Version: 0.6
// SVN Version: $Rev$ on $Date$ last updated by $Author$
$db=array('host'=>'localhost',
@@ -15,11 +15,7 @@
'output_to_file'=>TRUE, // If you want to log to a file, set this to true
'output_file'=>'/var/log/sms_to_laconica.log', // Here is the logfile
'verbose'=>FALSE, // This logs all messages and SQL messages
- 'sql'=>FALSE, // This logs SQL entries
- 'unsecure_number'=>FALSE); // This is a one way switch. If you change it from unsecure to secure
- // then you'll have to MD5 the numbers. If you change it from secure to
- // unsecure then you'll have to clear down all the user accounts and
- // recreate them all! CHANGE AT YOUR OWN RISK!
+ 'sql'=>FALSE); // This logs SQL entries
$sleep=10; // This value sets the load of this script on your server.
// As it's still in pre-pre-pre-alpha(!), I don't know how much load
@@ -43,16 +39,25 @@
'f'=>'ppp');
$ui=array('owner'=>'YourNameHere', // This block allows you to customize the footer of your gateway...
- 'owner_url'=>'http://my.own.website',
- 'version'=>'0.5.1',
+ 'owner_url'=>'http://my.own.website',
+ 'owner_mail'=>'ow...@my...',
+ 'system_mail'=>'sms...@my...',
+ 'version'=>'0.6',
'source'=>'LaconicaTools',
'source_url'=>'http://sf.net/projects/laconicatools',
- 'number'=>'+441234567890'); // and the number to which your users will send their SMS.
+ 'number'=>'+441234567890', // and the number to which your users will send their SMS.
+ 'message_source'=>'smsToLaconica'); // This is used when posting messages to twitter-like APIs.
+$ui['standard_footer']="<p>This gateway is brought to you by <a href=\"{$ui['owner_url']}\">{$ui['owner']}</a> and runs the smsToLaconica gateway software, version {$ui['version']}, which is available under the GNU Affero General Public License from <a href=\"{$ui['source_url']}\">{$ui['source']}</a></p>";
+
$phone=array('init'=>array("AT"), // These commands are sent to the phone when initialized
- 'data_type'=>'pdu'); // Options are currently limited to PDU, but text mode will eventually be allowed
+ 'data_type'=>'text',
+ 'host'=>'127.0.0.1',
+ 'port'=>'2000'); // Options are currently limited to PDU, but text mode will eventually be allowed
$email=array('send_admin_mail'=>FALSE,
'to_address'=>'sms...@te...',
'from_name'=>'smsToLaconica Service',
- 'from_address'=>'sms...@YO...');
\ No newline at end of file
+ 'from_address'=>'sms...@YO...');
+
+$services=array("T"=>'Twitter API', "L"=>'Twitter API');
\ No newline at end of file
Copied: smsToLaconica/trunk/install.sh (from rev 67, smsToLaconica/branches/0.6/install.sh)
===================================================================
--- smsToLaconica/trunk/install.sh (rev 0)
+++ smsToLaconica/trunk/install.sh 2008-11-11 21:19:15 UTC (rev 72)
@@ -0,0 +1,41 @@
+#! /bin/bash
+# This code is released under the AGPL (V.3 or later)
+# Author: Jon Spriggs (jo...@sp...)
+# Version: 0.6
+# SVN Version: $Rev$ on $Date$ last updated by $Author$
+#
+# This code creates a *DEFAULT* install of smsToLaconica - you will need to make some changes to it, but it's an ok out-of-the-box install.
+
+echo Installing required files for smsToLaconica
+if [ -f default_config.php ]; then
+ PWD=`pwd`
+ if [ -f config.php ]; then
+ echo "Found the config file."
+ else
+ cp default_config.php config.php
+ echo "Copied the default configuration file to config.php"
+ fi
+else
+ echo "This is not the right path. Exiting!"
+ exit
+fi
+
+sudo mkdir /var/www/smsToLaconica
+sudo chown $USER.$USER /var/www/smsToLaconica
+sudo chmod 755 /var/www/smsToLaconica
+
+ln -s `pwd`/web_index.php /var/www/smsToLaconica/index.php
+ln -s `pwd`/config.php `pwd`/lib_debug.php `pwd`/lib_text.php `pwd`/lib_pdu.php `pwd`/lib_openid.php /var/www/smsToLaconica
+
+cd /var/www/smsToLaconica
+wget http://stevelove.org/scripts/class.openid.phps
+mv class.openid.phps class.openid.php
+
+wget http://openidenabled.com/files/php-openid/files/PHP-yadis-1.0.2.tar.gz
+tar -xf PHP-yadis-1.0.2.tar.gz PHP-yadis-1.0.2/Services/
+mv PHP-yadis-1.0.2/Services Services/
+rm -Rf PHP-yadis-1.0.2 PHP-yadis-1.0.2.tar.gz
+
+sudo touch /var/log/sms_to_laconica.log
+sudo chown $USER.www-data /var/log/sms_to_laconica.log
+sudo chmod 770 /var/log/sms_to_laconica.log
Property changes on: smsToLaconica/trunk/install.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:keywords
+ Date Rev Author Id
Added: svn:mergeinfo
+
Copied: smsToLaconica/trunk/lib_debug.php (from rev 70, smsToLaconica/branches/0.6/lib_debug.php)
===================================================================
--- smsToLaconica/trunk/lib_debug.php (rev 0)
+++ smsToLaconica/trunk/lib_debug.php 2008-11-11 21:19:15 UTC (rev 72)
@@ -0,0 +1,111 @@
+<?php
+
+function call_rest_api($url, $fields="", $auth="", $type="post", $get_data=FALSE) {
+ // This code originally taken from http://morethanseven.net/posts/posting-to-twitter-using-php/
+ $curl_handle = curl_init();
+ curl_setopt($curl_handle, CURLOPT_URL, $url);
+ curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 10);
+ curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, TRUE);
+ curl_setopt($curl_handle, CURLOPT_HEADER, TRUE);
+ if(strtolower($type)=="post") {
+ curl_setopt($curl_handle, CURLOPT_POST, 1);
+ curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $fields);
+ }
+ if($auth!="") {
+ curl_setopt($curl_handle, CURLOPT_USERPWD, $auth);
+ }
+ $buffer = curl_exec($curl_handle);
+ curl_close($curl_handle);
+ if (empty($buffer)) {
+ return FALSE;
+ } elseif (stristr($buffer,' 200 OK') AND $get_data==FALSE) {
+ return TRUE;
+ } else {
+ return $buffer;
+ }
+}
+
+function debug($message, $verbose=FALSE, $sql=FALSE) {
+ global $debug;
+ if($debug['enabled']==TRUE) {
+ if($verbose!=FALSE) {if($debug['verbose']==TRUE) {$verbose=FALSE;}}
+ if($sql!=FALSE) {if($debug['sql']==TRUE) {$verbose=FALSE;}}
+ if($verbose==FALSE) {
+ $timestamp=date("Y-m-d H:i:s") . " - ";
+ if($debug['output_to_screen']==TRUE) {echo $timestamp . $message . "\r\n";}
+ if($debug['output_to_file']==TRUE AND
+!empty($debug['output_file'])) {
+ $handle=fopen($debug['output_file'],"a");
+ fwrite($handle, $timestamp . $message . "\r\n");
+ fclose($handle);
+ }
+ }
+ }
+}
+
+function d_mysql_connect() {
+ global $db;
+ mysql_connect($db['host'], $db['user'], $db['pass']) or die("Can't connect to the Database Server");
+ debug("DB Server Connected at {$db['host']} with username {$db['user']}", TRUE, TRUE);
+ mysql_select_db($db['base']) or die("Can't select the Database");
+ debug("DB Selected {$db['base']}", TRUE, TRUE);
+}
+
+function d_mysql_query($sql) {
+ $return=mysql_query($sql);
+ if(mysql_error()!="") {
+ debug("SQL: $sql\r\nERR: " . mysql_error(), TRUE, TRUE);
+ } else {
+ debug("SQL: $sql", TRUE, TRUE);
+ }
+ return $return;
+}
+
+function d_mysql_num_rows($qry) {
+ $return=mysql_num_rows($qry);
+ debug("NUM: $return", TRUE, TRUE);
+ return $return;
+}
+
+function d_mysql_fetch_array($qry) {
+ $return=mysql_fetch_array($qry);
+ if($return) {debug("ARY: " . print_r($return, TRUE), FALSE, TRUE);}
+ return $return;
+}
+
+function dump_config() {
+ global $db, $debug, $sleep, $code_book, $ui, $phone, $email;
+ debug("Config Values are:\r\n\$db => " . print_r($db, TRUE) . "\r\n\$debug => " . print_r($debug, TRUE) . "\r\n\$sleep => " . print_r($sleep, TRUE) . "\r\n\$code_book => " . print_r($code_book, TRUE) . "\r\n\$ui => " . print_r($ui, TRUE) . "\r\n\$phone => " . print_r($phone, TRUE) . "\r\n\$email => " . print_r($email, TRUE));
+}
+
+function service_status($html=TRUE) {
+ $back5=strtotime("-5 minutes");
+ $status_qry=d_mysql_query("SELECT * FROM service_status");
+ while($status_ary=d_mysql_fetch_array($status_qry)) {
+ $status[$status_ary['service_name']]['time']=$status_ary['last_run'];
+ if(strtotime($status_ary['last_run'])<$back5) {
+ $status[$status_ary['service_name']]['state']="0";
+ } else {
+ $status[$status_ary['service_name']]['state']="1";
+ }
+ }
+ if(count($status)>0) {
+ if($html==TRUE) {
+ $stat_head="";
+ $stat_line="";
+ foreach($status as $stat_name=>$state) {
+ $stat_head.="<th>$stat_name</th>";
+ if($states['state']==0) {$stat="Down since {$state['time']}";} else {$stat="Up at {$state['time']}";}
+ $stat_line.="<td>$stat</td>";
+ }
+ return "<table><tr>$stat_head</tr><tr>$stat_line</tr></table>";
+ } else {
+ return $status;
+ }
+ }
+}
+
+function event_log($user_id, $message) {
+ d_mysql_query("INSERT INTO event_log (user_id, event) VALUES ('" . mysql_real_escape_string($user_id) . "', '" . mysql_real_escape_string($message) . "')");
+}
+?>
\ No newline at end of file
Property changes on: smsToLaconica/trunk/lib_debug.php
___________________________________________________________________
Added: svn:keywords
+ Date Rev Author Id
Added: svn:mergeinfo
+
Copied: smsToLaconica/trunk/lib_modem.php (from rev 66, smsToLaconica/branches/0.6/lib_modem.php)
===================================================================
--- smsToLaconica/trunk/lib_modem.php (rev 0)
+++ smsToLaconica/trunk/lib_modem.php 2008-11-11 21:19:15 UTC (rev 72)
@@ -0,0 +1,44 @@
+<?php
+
+// This code is released under the AGPL (V.3 or later)
+// Author: Jon Spriggs (jo...@sp...)
+// Version: 0.6
+// SVN Version: $Rev$ on $Date$ last updated by $Author$
+
+require_once("lib_debug.php");
+
+function SendCmd($send, $socket) {
+ $session_active=Send($send, $socket);
+ $rx="";
+ while(!stristr($rx, "OK") AND !stristr($rx, "ERROR") AND !stristr($rx, ">") AND $session_active=TRUE) {
+ $data=Receive($socket) or $data=FALSE;
+ if($data==FALSE) {$session_active=FALSE;} else {$rx.=$data;}
+ }
+ if($session_active=FALSE and $rx="") {
+ return FALSE;
+ } else {
+ return $rx;
+ }
+}
+
+function Send($send,$socket) {
+ $return=TRUE;
+ fputs($socket,"$send\r") or $return=FALSE;
+ debug("TX: " . $send, "verbose");
+ return $return;
+}
+
+function Receive($socket) {
+ $session_active=FALSE;
+ do {
+ $read_block=fread($socket,1000) or $session_active=TRUE;
+ $status=socket_get_status($socket);
+ $receive.=$read_block;
+ } while ($status['unread_bytes'] AND $session_active=FALSE);
+ if(strlen($receive)>0) {
+ debug("RX: " . $receive, "verbose");
+ }
+ return($receive);
+}
+
+?>
\ No newline at end of file
Property changes on: smsToLaconica/trunk/lib_modem.php
___________________________________________________________________
Added: svn:keywords
+ Date Rev Author Id
Added: svn:mergeinfo
+
Copied: smsToLaconica/trunk/lib_openid.php (from rev 70, smsToLaconica/branches/0.6/lib_openid.php)
===================================================================
--- smsToLaconica/trunk/lib_openid.php (rev 0)
+++ smsToLaconica/trunk/lib_openid.php 2008-11-11 21:19:15 UTC (rev 72)
@@ -0,0 +1,83 @@
+<?php
+
+// This function is tested with the code obtained from
+// http://www.stevelove.org/2008/08/how-to-wordpresscom-and-the-simple-openid-php-class/
+// Using the Yadis library, as referenced from
+// http://www.stevelove.org/2008/08/how-to-yahoo-and-the-simple-openid-php-class/
+// The code here is taken from the original example file at
+// http://www.phpclasses.org/browse/package/3290.html
+// with a load of tweaks.
+require_once('class.openid.php');
+require_once('lib_debug.php');
+
+function OpenID_Auth($site_url='', $req_flds=array('email', 'fullname')) {
+ if($site_url=='') {
+ if($_SERVER['HTTPS']!='') {
+ $site_url="https://";
+ if($_SERVER['SERVER_PORT']!=443) {$off_port=TRUE;}
+ } else {
+ $site_url="http://";
+ if($_SERVER['SERVER_PORT']!=80) {$off_port=TRUE;}
+ }
+ $site_url.=$_SERVER['SERVER_NAME'];
+ if($off_port==TRUE) {$site_url.=':' . $_SERVER['SERVER_PORT'];}
+ if(strstr($_SERVER['REQUEST_URI'], '?')) {
+ $request_url=substr($_SERVER['REQUEST_URI'],0,strpos($_SERVER['REQUEST_URI'], '?'));
+ } else {
+ $request_url=$_SERVER['REQUEST_URI'];
+ }
+ $site_url.=$request_url;
+ }
+ if ($_POST['openid_action'] == "login"){ // Get identity from user and redirect browser to OpenID Server
+ $openid = new SimpleOpenID;
+ $openid->SetIdentity($_POST['openid_url']);
+ $openid->SetTrustRoot($site_url);
+ $openid->SetRequiredFields($req_flds);
+ if ($openid->GetOpenIDServer()){
+ $openid->SetApprovedURL($site_url);
+ $openid->Redirect();
+ } else {
+ $error = $openid->GetError();
+ $err_data="ERROR CODE: " . $error['code'] . "<br>";
+ $err_data.="ERROR DESCRIPTION: " . $error['description'] . "<br>";
+ }
+ } else if($_GET['openid_mode'] == 'id_res') {
+ $openid = new SimpleOpenID;
+ $openid->SetIdentity($_GET['openid_identity']);
+ $openid_validation_result = $openid->ValidateWithServer();
+ if ($openid_validation_result == true){
+ if(session_id()=="") {session_start();}
+ $_SESSION['valid']=TRUE;
+ $_SESSION['openid_identity']=$openid->OpenID_Standarize($_GET['openid_identity']);
+ foreach(array('email','fullname','dob','gender','postcode','country','language','timezone') as $var) {
+ if(isset($_GET['openid_sreg_' . $var])) {
+ $_SESSION[$var]=$_GET['openid_sreg_' . $var];
+ }
+ }
+ header("Location: $site_url");
+ } else if($openid->IsError() == true){
+ $error = $openid->GetError();
+ $err_data="ERROR CODE: " . $error['code'] . "<br>";
+ $err_data.="ERROR DESCRIPTION: " . $error['description'] . "<br>";
+ }else{
+ $err_data="INVALID AUTHORIZATION";
+ }
+ }else if ($_GET['openid_mode'] == 'cancel'){
+ $err_data="USER CANCELED REQUEST";
+ }
+ return($err_data);
+}
+
+function login_form() {
+return '<div>
+<fieldset id="openid">
+<legend>OpenID Login</legend>
+<form method="post" onsubmit="this.login.disabled=true;">
+<input type="hidden" name="openid_action" value="login">
+<div><input type="text" name="openid_url" class="openid_login"><input type="submit" name="login" value="login >>"></div>
+<div><a href="http://www.myopenid.com/" class="link" >Get an OpenID</a></div>
+</form>
+</fieldset>
+</div>';
+}
+?>
\ No newline at end of file
Property changes on: smsToLaconica/trunk/lib_openid.php
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: smsToLaconica/trunk/lib_pdu.php
===================================================================
--- smsToLaconica/trunk/lib_pdu.php 2008-11-11 21:05:36 UTC (rev 71)
+++ smsToLaconica/trunk/lib_pdu.php 2008-11-11 21:19:15 UTC (rev 72)
@@ -2,17 +2,20 @@
// This code is released under the AGPL (V.3 or later)
// Author: Jon Spriggs (jo...@sp...)
-// Version: 0.5.1
-// SVN Version: $Rev: 7 $ on $Date: 2008-09-09 13:48:36 +0100 (Tue, 09 Sep 2008) $ last updated by $Author: jontheniceguy $
-// -----------------------------------------------------------------------
-// I've not normally put any comments in my code at this point, however,
-// I wanted to stress that this code will fully decrypt PDU content from
-// a mobile phone, and a later version is intended to encrypt to PDU.
+// Version: 0.6
+// SVN Version: $Rev: 57 $ on $Date: 2008-10-31 09:18:55 +0000 (Fri, 31 Oct 2008) $ last updated by $Author: jontheniceguy $
+$functions=array('send'=>FALSE, 'receive'=TRUE);
+
$commands=array('select_mode'=>'AT+CMGF=0',
- 'get_msgs'=>'AT+CMGL=4');
+ 'get_msgs'=>'AT+CMGL=4',
+ 'send_msg'=>'AT+CMGS=');
-function handle_SMS($capture) {
+// Following data taken from http://dreamfabric.com/sms/default_alphabet.html
+$arrChar=array('0'=>'@', '1'=>'£', '2'=>'$', '3'=>'¥', '4'=>'è', '5'=>'é', '6'=>'ù', '7'=>'ì', '8'=>'ò', '9'=>'Ç', '10'=>'', '11'=>'Ø', '12'=>'ø', '13'=>'', '14'=>'Å', '15'=>'å', '16'=>'Δ', '17'=>'_', '18'=>'Φ', '19'=>'Γ', '20'=>'Λ', '21'=>'Ω', '22'=>'Π', '23'=>'Ψ', '24'=>'Σ', '25'=>'Θ', '26'=>'Ξ', '27'=>'', '27 10'=>"\n", '27 20'=>'^', '27 40'=>'{', '27 41'=>'}', '27 47'=>"\\", '27 60'=>'[', '27 61'=>'~', '27 62'=>']', '27 64'=>'|', '27 101'=>'€', '28'=>'Æ', '29'=>'æ', '30'=>'ß', '31'=>'É', '32'=>' ', '33'=>'!', '34'=>'"', '35'=>'#', '36'=>'¤', '37'=>'%', '38'=>'&', '39'=>"'", '40'=>'(', '41'=>')', '42'=>'*', '43'=>'+', '44'=>',', '45'=>'-', '46'=>'.', '47'=>'/', '48'=>'0', '49'=>'1', '50'=>'2', '51'=>'3', '52'=>'4', '53'=>'5', '54'=>'6', '55'=>'7', '56'=>'8', '57'=>'9', '58'=>':', '59'=>';', '60'=>'<', '61'=>'=', '62'=>'>', '63'=>'?', '64'=>'¡', '65'=>'A', '66'=>'B', '67'=>'C', '68'=>'D', '69'=>'E', '70'=>'F', '71'=>'G', '72'=>'H', '73'=>'I', '74'=>'J', '75'=>'K', '76'=>'L', '77'=>'M', '78'=>'N', '79'=>'O', '80'=>'P', '81'=>'Q', '82'=>'R', '83'=>'S', '84'=>'T', '85'=>'U', '86'=>'V', '87'=>'W', '88'=>'X', '89'=>'Y', '90'=>'Z', '91'=>'Ä', '92'=>'Ö', '93'=>'Ñ', '94'=>'Ü', '95'=>'§', '96'=>'¿', '97'=>'a', '98'=>'b', '99'=>'c', '100'=>'d', '101'=>'e', '102'=>'f', '103'=>'g', '104'=>'h', '105'=>'i', '106'=>'j', '107'=>'k', '108'=>'l', '109'=>'m', '110'=>'n', '111'=>'o', '112'=>'p', '113'=>'q', '114'=>'r', '115'=>'s', '116'=>'t', '117'=>'u', '118'=>'v', '119'=>'w', '120'=>'x', '121'=>'y', '122'=>'z', '123'=>'ä', '124'=>'ö', '125'=>'ñ', '126'=>'ü', '127'=>'à');
+
+
+function handle_SMS($capture, $verbose=FALSE) {
$capture_p=str_replace("\n", "\r", $capture);
$capture=str_replace("\r\r", "\r", $capture_p);
@@ -65,6 +68,7 @@
$data_as_dec=hexdec($data_as_hex);
$message[$msg]['data_8bit']=chr($data_as_dec); // THIS IS NOT TESTED!
$data_as_bin=str_pad(decbin($data_as_dec), 8, "0", STR_PAD_LEFT);
+ $message[$msg]['prechunk'][]=$data_as_bin;
$old_chunk=$chunk;
$chunk=$data_as_bin . $old_chunk;
$chunked_bin[]=substr($chunk, -7);
@@ -94,14 +98,136 @@
}
}
}
+ switch($message[$msg]['bit_length']) {
+ case '7':
+ $message[$msg]['message']=$message[$msg]['data_7bit'];
+ break;
+ case '8':
+ $message[$msg]['message']=$message[$msg]['data_8bit'];
+ break;
+ }
}
}
- debug(print_r($message,TRUE), "verbose");
- return($message);
+ if($verbose==TRUE or count($message)<1) {
+ return $message;
+ } else {
+ foreach($message as $msg) {
+ $return[]['index']=$msg['index'];
+ $return[]['number']=$msg['addr'];
+ $return[]['message']=$msg['message'];
+ $return[]['timestamp']=$msg['timestamp'];
+ }
+ return $return;
+ }
}
+function Read_SMS($unread_only=FALSE, $delete_on_read=TRUE) {
+ $socket=Connect();
+ if($unread_only==TRUE) {
+ $data=SendCmd('AT+CMGL=0', $socket);
+ } else {
+ $data=SendCmd('AT+CMGL=4', $socket);
+ }
+ $messages=handle_SMS($data);
+ if($delete_on_read==TRUE) {
+ foreach($messages as $message) {
+ SendCmd('AT+CMGD=' . $message['index'], $socket);
+ }
+ }
+ fclose($socket);
+ return $messages;
+}
+
+function Send_SMS($number, $message) {
+ debug("Script erroniously tried to send $message to $number while in PDU mode. Oops!");
+}
+
+function Connect() {
+ global $serial, $phone, $sleep;
+ $socket=fsockopen($serial['host'],$serial['port']);
+ while($socket==FALSE) {
+ debug("Failed to connect to device. Sleeping $sleep microseconds before trying again.");
+ sleep($sleep);
+ $socket=fsockopen($serial['host'],$serial['port']);
+ }
+ SendCmd("AT+CMGF=0", $socket);
+ foreach($phone['init'] as $cmd) {
+ SendCmd($cmd, $socket);
+ }
+ return $socket;
+}
+
function dec_to_pdu($dec) {
- // Following data taken from http://dreamfabric.com/sms/default_alphabet.html
- $arrChar=array('0'=>'@', '1'=>'£', '2'=>'$', '3'=>'¥', '4'=>'è', '5'=>'é', '6'=>'ù', '7'=>'ì', '8'=>'ò', '9'=>'Ç', '10'=>'', '11'=>'Ø', '12'=>'ø', '13'=>'', '14'=>'Å', '15'=>'å', '16'=>'Δ', '17'=>'_', '18'=>'Φ', '19'=>'Γ', '20'=>'Λ', '21'=>'Ω', '22'=>'Π', '23'=>'Ψ', '24'=>'Σ', '25'=>'Θ', '26'=>'Ξ', '27'=>'', '27 10'=>"\n", '27 20'=>'^', '27 40'=>'{', '27 41'=>'}', '27 47'=>"\\", '27 60'=>'[', '27 61'=>'~', '27 62'=>']', '27 64'=>'|', '27 101'=>'€', '28'=>'Æ', '29'=>'æ', '30'=>'ß', '31'=>'É', '32'=>' ', '33'=>'!', '34'=>'"', '35'=>'#', '36'=>'¤', '37'=>'%', '38'=>'&', '39'=>"'", '40'=>'(', '41'=>')', '42'=>'*', '43'=>'+', '44'=>',', '45'=>'-', '46'=>'.', '47'=>'/', '48'=>'0', '49'=>'1', '50'=>'2', '51'=>'3', '52'=>'4', '53'=>'5', '54'=>'6', '55'=>'7', '56'=>'8', '57'=>'9', '58'=>':', '59'=>';', '60'=>'<', '61'=>'=', '62'=>'>', '63'=>'?', '64'=>'¡', '65'=>'A', '66'=>'B', '67'=>'C', '68'=>'D', '69'=>'E', '70'=>'F', '71'=>'G', '72'=>'H', '73'=>'I', '74'=>'J', '75'=>'K', '76'=>'L', '77'=>'M', '78'=>'N', '79'=>'O', '80'=>'P', '81'=>'Q', '82'=>'R', '83'=>'S', '84'=>'T', '85'=>'U', '86'=>'V', '87'=>'W', '88'=>'X', '89'=>'Y', '90'=>'Z', '91'=>'Ä', '92'=>'Ö', '93'=>'Ñ', '94'=>'Ü', '95'=>'§', '96'=>'¿', '97'=>'a', '98'=>'b', '99'=>'c', '100'=>'d', '101'=>'e', '102'=>'f', '103'=>'g', '104'=>'h', '105'=>'i', '106'=>'j', '107'=>'k', '108'=>'l', '109'=>'m', '110'=>'n', '111'=>'o', '112'=>'p', '113'=>'q', '114'=>'r', '115'=>'s', '116'=>'t', '117'=>'u', '118'=>'v', '119'=>'w', '120'=>'x', '121'=>'y', '122'=>'z', '123'=>'ä', '124'=>'ö', '125'=>'ñ', '126'=>'ü', '127'=>'à');
+ global $arrChar;
return $arrChar[$dec];
}
+
+function pdu_to_dec($msg_chr) {
+ global $arrChar;
+ foreach($arrChar as $index=>$value) {
+ if($value==$msg_chr) {return $index; break;}
+ }
+}
+
+/*
+function write_pdu($number, $message) {
+ $return['SMSC_Length']="00";
+ $return['First_Octet']="11";
+ $return['SMSC_Number']="00";
+ str_pad(strtoupper(dechex(count($pdu_as_bin))),2,"0", STR_PAD_LEFT);
+ $return['Dest_Length']=str_pad(strtoupper(dechex(strlen($number))),2,"0", STR_PAD_LEFT);
+ $return['Number_Type']="91";
+ $return['Dest_Number']='';
+ $dest_number=str_split($number, 2);
+ foreach($dest_number as $pair) {
+ if(strlen($pair)==1) {$pair.='F';}
+ $return['Dest_Number'].=strrev($pair);
+ }
+ $return['TP-PID']="00";
+ $return['TP-PDS']="00";
+ $return['TP-VLD']="AA";
+ $temp_message=str_split($message);
+ for($i=count($temp_message)-1; $i>=0; $i--) {
+ $temp=explode(" ", pdu_to_dec($temp_message[$i]));
+ if(count($temp)>1) {
+ $pdu_as_bin[]=str_pad(decbin($temp[0]), 7, "0", STR_PAD_LEFT);
+ $pdu_as_bin[]=str_pad(decbin($temp[1]), 7, "0", STR_PAD_LEFT);
+ } else {
+ $pdu_as_bin[]=str_pad(decbin($temp[0]), 7, "0", STR_PAD_LEFT);
+ }
+ }
+ $return['msgsize']=str_pad(strtoupper(dechex(count($pdu_as_bin))),2,"0", STR_PAD_LEFT);
+ $pdu_binary='';
+ foreach($pdu_as_bin as $binary) {$pdu_binary.=$binary;}
+ $pdu='';
+ for($l=strlen($pdu_binary)-8; $l>=0; $l=$l-8) {
+ if($l<0) {
+ $return['msg'].=dechex(bindec(str_pad(substr($pdu_binary, 0, $l), 8, "0", STR_PAD_LEFT)));
+ } else {
+ $return['msg'].=strtoupper(dechex(bindec(substr($pdu_binary, $l, 8))));
+ }
+ }
+ $return['outgoing_code']=$return['SMSC_Length'].
+ $return['First_Octet'].
+ $return['SMSC_Number'].
+ $return['Dest_Length'].
+ $return['Number_Type'].
+ $return['Dest_Number'].
+ $return['TP-PID'].
+ $return['TP-PDS'].
+ $return['TP-VLD'].
+ $return['msgsize'].
+ $return['msg'];
+ $return['total_size']=strlen($return['outgoing_code'])-2;
+ return($return);
+}
+
+function send_message_as_cmd($number, $message) {
+ global $commands;
+ $data=write_pdu($number, $message);
+ $cmd=$commands['send_msg'] . $data['total_size'] . "\r\n" . $data['outgoing_code'] . "\r\n" . chr(26) . "\r\n";
+ return($cmd);
+}
+*/
+
+?>
\ No newline at end of file
Copied: smsToLaconica/trunk/lib_text.php (from rev 66, smsToLaconica/branches/0.6/lib_text.php)
===================================================================
--- smsToLaconica/trunk/lib_text.php (rev 0)
+++ smsToLaconica/trunk/lib_text.php 2008-11-11 21:19:15 UTC (rev 72)
@@ -0,0 +1,98 @@
+<?php
+
+// This code is released under the AGPL (V.3 or later)
+// Author: Jon Spriggs (jo...@sp...)
+// Version: 0.6
+// SVN Version: $Rev$ on $Date$ last updated by $Author$
+
+$functions=array('send'=>TRUE, 'receive'=>TRUE);
+
+function handle_SMS($capture) {
+ $capture_p=str_replace("\n", "\r", $capture);
+ $capture=str_replace("\r\r", "\r", $capture_p);
+
+ $lines=explode("\r", $capture);
+
+ $msg=0;
+ foreach($lines as $line) {
+ if(substr($line,0,8)=="AT+CMGL=") {
+ // Local Echo
+ } elseif(substr($line, 0, 1)=="+") {
+ $msg++;
+ $temp_split=substr($line, 6);
+ $temp_data=explode(",", trim($temp_split));
+ $message[$msg]['index']=$temp_data[0];
+ $message[$msg]['number']=substr($temp_data[2], 1, -1);
+ $y=substr($temp_data[4], 1, 2);
+ $m=substr($temp_data[4], 4, 2);
+ $d=substr($temp_data[4], 7, 2);
+ $h=substr($temp_data[5], 0, 2);
+ $i=substr($temp_data[5], 3, 2);
+ $s=substr($temp_data[5], 6, 2);
+ $u=substr($temp_data[5], 8, 3);
+ $message[$msg]['timestamp']="20" . $y . "-" . $m . "-" . $d . " " . $h . ":" . $i . ":" . $s;
+ } else {
+ if($msg>0) {
+ if($message[$msg]['message']!='') {$message[$msg]['message'].="\r\n";}
+ $message[$msg]['message'].=$line;
+ }
+ }
+ if($msg>0) {
+ if(substr($message[$msg]['message'], -4)=="\r\nOK") {
+ $message[$msg]['message']=trim(substr($message[$msg]['message'], 0, -4));
+ }
+ }
+ }
+ return($message);
+}
+
+function Connect() {
+ global $phone, $sleep;
+ $socket=fsockopen($phone['host'],$phone['port']);
+ while($socket==FALSE) {
+ debug("Failed to connect to device. Sleeping $sleep microseconds before trying again.");
+ sleep($sleep);
+ $socket=fsockopen($phone['host'],$phone['port']);
+ }
+ SendCmd("AT+CMGF=1", $socket);
+ foreach($phone['init'] as $cmd) {
+ SendCmd($cmd, $socket);
+ }
+ return $socket;
+}
+
+function Send_SMS($number, $message) {
+ global $sleep;
+ $socket=Connect();
+ // SendCMD will return False if the socket closed while trying to send.
+ $data=SendCmd("AT+CMGS=\"$number\"", $socket);
+ if($data==FALSE) {return FALSE;}
+ $data=SendCmd($message, $socket);
+ if($data==FALSE) {return FALSE;}
+ $data=Send(chr(26), $socket);
+ sleep($sleep/4); // These two sleep statements are because for some reason the modem might hang on reconnection.
+ fclose($socket);
+ sleep($sleep/4);
+ if($data==TRUE) {return TRUE;}
+}
+
+function Read_SMS($unread_only=FALSE, $delete_on_read=TRUE) {
+ $socket=Connect();
+ if($unread_only==TRUE) {
+ $data=SendCmd('AT+CMGL="REC UNREAD"', $socket);
+ } else {
+ $data=SendCmd('AT+CMGL="ALL"', $socket);
+ }
+ $messages=handle_SMS($data);
+ if($delete_on_read==TRUE) {
+ if(is_array($messages)) {
+ foreach($messages as $message) {
+ SendCmd('AT+CMGD=' . $message['index'], $socket);
+ }
+ }
+ }
+ fclose($socket);
+ return $messages;
+}
+
+?>
\ No newline at end of file
Property changes on: smsToLaconica/trunk/lib_text.php
___________________________________________________________________
Added: svn:keywords
+ Date Rev Author Id
Added: svn:mergeinfo
+
Copied: smsToLaconica/trunk/mail_admin.php (from rev 66, smsToLaconica/trunk/admin.php)
===================================================================
--- smsToLaconica/trunk/mail_admin.php (rev 0)
+++ smsToLaconica/trunk/mail_admin.php 2008-11-11 21:19:15 UTC (rev 72)
@@ -0,0 +1,98 @@
+<?php
+
+// This code is released under the AGPL (V.3 or later)
+// Author: Jon Spriggs (jo...@sp...)
+// Version: 0.6
+// SVN Version: $Rev$ on $Date$ last updated by $Author$
+
+require_once("config.php");
+require_once("lib_debug.php");
+
+dump_config();
+d_mysql_connect();
+
+$users_qry=d_mysql_query("SELECT * FROM users");
+while($user_ary=d_mysql_fetch_array($users_qry)) {
+ $users[$user_ary['user_id']]=$user_ary;
+}
+
+$update_service_qry=d_mysql_query("SELECT * FROM users_update_service GROUP BY base_url");
+while($update_service=d_mysql_fetch_array($update_service_qry)) {
+ $users[$update_service['user_id']]['feed'][]=$update_service;
+}
+
+$errors_qry=d_mysql_query("SELECT * FROM errors WHERE (acknowledged=0 AND user_id='') OR user_id<>''");
+while($errors_ary=d_mysql_fetch_array($errors_qry)) {
+ if($errors_ary['user_id']!='') {
+ $users[$errors_ary['user_id']]['errors'][]=$errors_ary;
+ } else {
+ $errors[]=$errors_ary;
+ }
+}
+
+
+
+$mail="<html><body>";
+// This below code snippet is adapted from http://www.randomsnippets.com/2008/02/12/how-to-hide-and-show-your-div/
+$mail.="<script language=\"javascript\">
+function toggle(showHideDiv, switchTextDiv) {
+ var ele = document.getElementById(showHideDiv);
+ var text = document.getElementById(switchTextDiv);
+ if(ele.style.display == \"block\") {
+ ele.style.display = \"none\";
+ text.innerHTML = \"Show Details\";
+ }
+ else {
+ ele.style.display = \"block\";
+ text.innerHTML = \"Hide Details\";
+ }
+}
+</script>";
+$mail.="<p align=center>smsToLaconica - Admin Information</p>";
+
+$mail.="<p>Service Status</p>" . service_status();
+
+$mail.="<p>There are " . count($users) . " users on the service.</p>";
+if(count($users)>0) {
+ $mail.="<table><tr><th>Username</th><th>Posts Out</th><th>Posts In (Errors)</th><th>Feeds</th></tr>";
+ foreach($users as $user_id=>$user) {
+ $mail.="<tr><td>" . htmlentities($user['user_name'], ENT_QUOTES);
+ if($user['user_number']=='') {
+ $mail.="(unconfirmed)</td><td>N/A</td><td>N/A (N/A)</td><td> </td></tr>";
+ } else {
+ $mail.="</td><td>{$user['messages_sent']}</td><td>{$user['messages_received']} ('" . count($user['errors']) . " ";
+ if(count($user['errors'])>0) {
+ $mail.="- <a id='error_{$user_id}' href=\"javascript:toggle('error_detail_{$user_id}','error_{$user_id}');\">Show Details</a><div id='error_detail_{$user_id}'>";
+ foreach($user['errors'] as $error) {
+ $mail.="<i>" . htmlentities($error['message'], ENT_QUOTES) . "</i><b>" . htmlentities($error['error_text'], ENT_QUOTES) . "</b><br>";
+ }
+ $mail.="</div>";
+ }
+ $mail.=")</td><td>" . count($user['feed']) . " ";
+ if(count($user['feed'])>0) {
+ $mail.="- <a id='feed_{$user_id}' href=\"javascript:toggle('feed_detail_{$user_id}','feed_{$user_id}');\" >Show Details</a><div id='feed_detail_{$user_id}'>";
+ foreach($user['feed'] as $feed) {
+ $mail.=htmlentities($feed['base_url'] . "/" . htmlentities($feed['username']), ENT_QUOTES) . "<br>";
+ }
+ $mail.="</div>";
+ }
+ $mail.="</td></tr>";
+ }
+ }
+ $mail.="</table>";
+}
+
+$mail.=$ui['standard_footer'] . '</body></html>';
+if(!$email['send_admin_mail']==FALSE) {
+ // HTML Posting Information derived from http://www.sitepoint.com/article/advanced-email-php/
+ $headers = 'MIME-Version: 1.0' . "\r\n" .
+ 'Content-type: text/html; charset=iso-8859-1' . "\r\n" .
+ "From: smsToLaconica Service <{$email['from_address']}>\r\n" .
+ "To: smsToLaconica Admin <{$email['to_address']}>\r\n" .
+ "Reply-To: {$email['to_address']}\r\n" .
+ 'X-Mailer: PHP/' . phpversion();
+ mail($email['to_address'], 'smsToLaconica Report for ' . date('Y-m-d'), $mail, $headers);
+} else {
+ echo "From: " . $email['from_name'] . '<' . $email['from_address'] . ">\r\nTo: " . $email['to_address']. "\r\nSubject: smsToLaconica Report for " . date('Y-m-d') . "\r\n" . $mail;
+}
+?>
Property changes on: smsToLaconica/trunk/mail_admin.php
___________________________________________________________________
Added: svn:keywords
+ Date Rev Author Id
Added: svn:mergeinfo
+
Deleted: smsToLaconica/trunk/process_db.php
===================================================================
--- smsToLaconica/trunk/process_db.php 2008-11-11 21:05:36 UTC (rev 71)
+++ smsToLaconica/trunk/process_db.php 2008-11-11 21:19:15 UTC (rev 72)
@@ -1,109 +0,0 @@
-<?php
-
-// This code is released under the AGPL (V.3 or later)
-// Author: Jon Spriggs (jo...@sp...)
-// Version: 0.5.1
-// SVN Version: $Rev$ on $Date$ last updated by $Author$
-
-ini_set("max_execution_time", 0);
-set_time_limit(0);
-
-include_once("config.php");
-
-if(!isset($db)) {$db=array('host'=>'localhost', 'user'=>'smsToLaconica', 'pass'=>'smsToLaconica', 'base'=>'smsToLaconica');}
-if(!isset($debug)) {$debug=array('enabled'=>FALSE, 'output_to_screen'=>FALSE, 'output_to_file'=>FALSE, 'output_file'=>'/var/log/sms_to_laconica.log', 'verbose'=>FALSE);}
-if(!isset($sleep)) {$sleep=10;}
-
-if($debug['verbose']==TRUE) {debug("Configuration Values for DB: " . print_r($db, TRUE) . "\r\nAnd for Debug: " . print_r($debug, TRUE) . "\r\nThe sleep value is: $sleep");}
-
-mysql_connect($db['host'], $db['user'], $db['pass']) or die("Can't connect to the Database Server");
-mysql_select_db($db['base']) or die("Can't select the Database");
-
-$mq_sql="SELECT `mq`.`id`, `mq`.`...
[truncated message content] |
|
From: <jon...@us...> - 2008-11-11 21:05:39
|
Revision: 71
http://laconicatools.svn.sourceforge.net/laconicatools/?rev=71&view=rev
Author: jontheniceguy
Date: 2008-11-11 21:05:36 +0000 (Tue, 11 Nov 2008)
Log Message:
-----------
All the web UI now works! Removed the web_ui.php
Modified Paths:
--------------
smsToLaconica/branches/0.6/web_index.php
Removed Paths:
-------------
smsToLaconica/branches/0.6/web_ui.php
Modified: smsToLaconica/branches/0.6/web_index.php
===================================================================
--- smsToLaconica/branches/0.6/web_index.php 2008-11-11 17:29:20 UTC (rev 70)
+++ smsToLaconica/branches/0.6/web_index.php 2008-11-11 21:05:36 UTC (rev 71)
@@ -36,7 +36,7 @@
if(d_mysql_num_rows($user_exist)>0) {
$user=d_mysql_fetch_array($user_exist);
$user_id=$user['user_id'];
- d_mysql_query("UPDATE users SET last_logged_in=NOW WHERE user_id='$user_id'");
+ d_mysql_query("UPDATE users SET last_logged_in=NOW() WHERE user_id='$user_id'");
event_log($user_id, "Logged in.");
} else {
d_mysql_query("INSERT INTO users (openid_identity, user_name, user_mail) VALUES ('{$_SESSION['openid_identity']}', '{$_SESSION['fullname']}', '{$_SESSION['email']}')");
@@ -84,7 +84,15 @@
} elseif($_POST['cf']!="") {
if($_POST['feed_type']!='' AND $_POST['feed_url']!='' AND $services[strtoupper($_POST['feed_type'])]!='') {
d_mysql_query("INSERT INTO users_feeds (user_id, feed_type, feed_url, last_time) VALUES ('$user_id', '" . mysql_real_escape_string(strtoupper($_POST['feed_type'])) . "', '" . mysql_real_escape_string($_POST['feed_url']) . "', '0000-00-00 00:00:00')");
- event_log($user_id, "Added feed at " . mysql_real_escape_string($_POST['feed_url']));
+ $parse_url=parse_url($_POST['feed_url']);
+ if(isset($parse_url['scheme'])) {$url=$parse_url['scheme']. "://";} else {$url="http://";}
+ if(isset($parse_url['user'])) {$url.=$parse_url['user'];}
+ if(isset($parse_url['pass'])) {$url.=":*****";}
+ if(isset($parse_url['user'])) {$url.="@";}
+ if(isset($parse_url['path'])) {$url.=$parse_url['path'];}
+ if(isset($parse_url['query'])) {$url.='?' . $parse_url['query'];}
+ if(isset($parse_url['fragment'])) {$url.='#' . $parse_url['fragment'];}
+ event_log($user_id, "Added feed at " . mysql_real_escape_string($url));
}
} elseif($_POST['sh']!="") {
$service_times_qry=d_mysql_query("SELECT service_day, service_hour FROM users_sms_service WHERE user_id='$user_id'");
@@ -123,6 +131,11 @@
while(list($day, $hour)=d_mysql_fetch_array($service_times_qry)) {$svc_hours["{$day}-{$hour}"]=TRUE;}
}
+ $event_log_qry=d_mysql_query("SELECT timestamp, event FROM event_log WHERE user_id = '$user_id' ORDER BY timestamp DESC LIMIT 0,5");
+ if(d_mysql_num_rows($event_log_qry)>0) {
+ while($event_log[]=d_mysql_fetch_array($event_log_qry)) {}
+ }
+
echo "<html><head><title>smsToLaconica User Portal</title></head><body><p align=center>smsToLaconica User Portal</p>";
echo service_status();
echo "<p>Hello {$user['user_name']}.</p>";
@@ -150,19 +163,21 @@
echo "<tr><td>Example Twitter</td><td>http://twitter.com</td><td>username</td><td>password</td><td>EXAMPLE ONLY</td></tr>";
if(count($update_svc)>0 AND $update_svc!=FALSE) {
foreach($update_svc as $svc) {
- echo "<tr><td>";
- switch($svc['service_type']) {
- case "T":
- echo "Twitter";
- break;
- case "L":
- echo "Laconi.ca";
- break;
+ if($svc['base_url']!='' AND $svc['username']!='' AND $svc['password']!='') {
+ echo "<tr><td>";
+ switch($svc['service_type']) {
+ case "T":
+ echo "Twitter";
+ break;
+ case "L":
+ echo "Laconi.ca";
+ break;
+ }
+ echo "</td><td>" . htmlentities($svc['base_url']) . "</td><td>" . htmlentities($svc['username']) . "</td><td>*****</td><td><a href='$site_url?ds={$svc['user_service_id']}'>Delete</a></td></tr>";
}
- echo "</td><td>" . htmlentities($svc['base_url']) . "</td><td>" . htmlentities($svc['username']) . "</td><td>*****</td><td><a href='$site_url?ds={$svc['user_service_id']}'>Delete</a></td></tr>";
}
}
- echo "<form action='$site_url' method='post'><input type='hidden' name='cs' value='create'><tr><td><select name='service_type'><option value='T'>Twitter</option><option value='L' selected>Laconi.ca System</option></select></td><td><input type='text' size='15' value='http://identi.ca/api'></td><td><input type='text' size='10'></td><td><input type='password' size='10'></td><td><input type='submit' value='Save'></td></tr></form></table>";
+ echo "<form action='$site_url' method='post'><input type='hidden' name='cs' value='create'><tr><td><select name='service_type'><option value='T'>Twitter</option><option value='L' selected>Laconi.ca System</option></select></td><td><input type='text' name='base_url' size='15' value='http://identi.ca/api'></td><td><input type='text' name='username' size='10'></td><td><input type='password' name='password' size='10'></td><td><input type='submit' value='Save'></td></tr></form></table>";
echo $phone_service;
@@ -174,21 +189,31 @@
echo "<tr><td>Example Twitter Search</td><td>http://search.twitter.com/search.atom?q=%40username</td><td>EXAMPLE ONLY</td></tr>";
if(count($feeds)>0 AND $feeds!=FALSE) {
foreach($feeds as $feed) {
- echo "<tr><td>";
- switch($feed['feed_type']) {
- case "T":
- echo "Twitter";
- break;
- case "L":
- echo "Laconi.ca";
- break;
+ if($feed['feed_url']!='') {
+ echo "<tr><td>";
+ switch($feed['feed_type']) {
+ case "T":
+ echo "Twitter";
+ break;
+ case "L":
+ echo "Laconi.ca";
+ break;
+ }
+ $parse_url=parse_url($feed['feed_url']);
+ if(isset($parse_url['scheme'])) {$url=$parse_url['scheme']. "://";} else {$url="http://";}
+ if(isset($parse_url['user'])) {$url.=$parse_url['user'];}
+ if(isset($parse_url['pass'])) {$url.=":*****";}
+ if(isset($parse_url['user'])) {$url.="@";}
+ if(isset($parse_url['path'])) {$url.=$parse_url['path'];}
+ if(isset($parse_url['query'])) {$url.='?' . $parse_url['query'];}
+ if(isset($parse_url['fragment'])) {$url.='#' . $parse_url['fragment'];}
+ echo "</td><td>" . htmlentities($url) . "</td><td><a href='$site_url?ds={$feed['feed_id']}'>Delete</a></td></tr>";
}
- echo "</td><td>" . htmlentities($feed['feed_url']) . "</td><td><a href='$site_url?ds={$feed['feed_id']}'>Delete</a></td></tr>";
}
}
- echo "<form action='$site_url' method='post'><input type='hidden' name='cf' value='create'><tr><td><select name='feed_type'><option value='T'>Twitter</option><option value='L' selected>Laconi.ca System</option></select></td><td><input type='text' size='40' value='http://username:pas...@id.../api/statuses/replies.rss'></td><td><input type='submit' value='Save'></td></tr></form></table>";
+ echo "<form action='$site_url' method='post'><input type='hidden' name='cf' value='create'><tr><td><select name='feed_type'><option value='T'>Twitter</option><option value='L' selected>Laconi.ca System</option></select></td><td><input type='text' name='feed_url' size='40' value='http://username:pas...@id.../api/statuses/replies.rss'></td><td><input type='submit' value='Save'></td></tr></form></table>";
if($functions['send']==TRUE) {
- echo "<form action='$site_url' method='post'><p>SMS Service Periods</p><input type='hidden' name='sh' value='true'><p><input type=submit value='Update'></p>";
+ echo "<form action='$site_url' method='post'><p>SMS Service Periods<input type='hidden' name='sh' value='true'> <input type=submit value='Update'></p>";
echo "<table><tr><th>Day</th>";
for($h=0; $h<24; $h++) {echo "<th>$h</th>";}
echo "</tr>";
@@ -202,6 +227,13 @@
}
echo "</table></form>";
}
+ echo "<table><tr><th>Time</th><th>Event Log Message</th></tr>";
+ if(count($event_log)>0 AND $event_log!=FALSE) {
+ foreach($event_log as $event) {
+ echo "<tr><td>{$event['timestamp']}</td><td>{$event['event']}</td></tr>";
+ }
+ }
+ echo "</table>";
}
} else {
$err_data=OpenID_Auth(); // This script may return error data or it may send a header line. Either way, if we get past here, we need to render the page :)
Deleted: smsToLaconica/branches/0.6/web_ui.php
===================================================================
--- smsToLaconica/branches/0.6/web_ui.php 2008-11-11 17:29:20 UTC (rev 70)
+++ smsToLaconica/branches/0.6/web_ui.php 2008-11-11 21:05:36 UTC (rev 71)
@@ -1,68 +0,0 @@
-<html>
-<head>
-<title>SMS->Laconi.ca Bridge</title>
-</head>
-<body>
-
-<h1>SMS -> Laconi.ca Bridge</h1>
-
-<p>Please bear three things in mind.</p>
-
-<ul>
-<li>This is a cost neutral service - I make no money from this - no adverts, and it's linked to my home network connection, therefore, please don't go crazy sending loads of traffic through here.</li>
-<li>Because of the fact that this is linked through my home system, at some point there may be outages and your post may not arrive when you expect it to.</li>
-<li>Again, because this is connected to my home system, I will have to keep the number of subscriptions quite low to start with. I'll see what the network consumption is like and then adjust the number of users based on that.</li>
-</ul>
-
-<p>To enable and to disable the service, complete the form below.</p>
-
-<?php
-
-// This code is released under the AGPL (V.3 or later)
-// Author: Jon Spriggs (jo...@sp...)
-// Version: 0.5.1
-// SVN Version: $Rev$ on $Date$ last updated by $Author$
-
-if(!empty($_POST['base_url']) AND !empty($_POST['username']) AND !empty($_POST['password'])) {
- include_once("config.php");
-
- if(!isset($db)) {$db=array('host'=>'localhost', 'user'=>'smsToLaconica', 'pass'=>'smsToLaconica', 'base'=>'smsToLaconica');}
- if(!isset($debug)) {$debug=array('enabled'=>FALSE, 'output_to_screen'=>FALSE, 'output_to_file'=>FALSE, 'output_file'=>'/var/log/sms_to_laconica.log', 'verbose'=>FALSE);}
- if(!isset($code_book)) {$code_book=array(0=>0,1=>1,2=>2,3=>3,4=>4,5=>5,6=>6,7=>7,8=>8,9=>9,'a'=>'a','b'=>'b','c'=>'c','d'=>'d','e'=>'e','f'=>'f');}
- if(!isset($ui)) {$ui=array('owner'=>'YOUR OWN NAME', 'owner_url'=>'http://YOUR.OWN.WEBSITE', 'version'=>'0.5.1', 'source'=>'LaconicaTools', 'source_url'=>'http://laconicatools.sf.net', 'number'=>'Not yet set! Please contact the administrator of this service before use!');}
-
- mysql_connect($db['host'], $db['user'], $db['pass']) or die("Can't connect to the Database Server");
- mysql_select_db($db['base']) or die("Can't select the Database");
-
- $check_user="SELECT id FROM users WHERE base_url LIKE 'http://" . mysql_real_escape_string($_POST['base_url']) . "' AND username LIKE '" . mysql_real_escape_string($_POST['username']) . "' AND password LIKE '" . mysql_real_escape_string($_POST['password']) . "' LIMIT 1";
- $check_user_qry=mysql_query($check_user);
- if(mysql_num_rows($check_user_qry)>0) {
- list($id)=mysql_fetch_array($check_user_qry);
- list($number)=mysql_fetch_array(mysql_query("SELECT number FROM users WHERE id='$id'"));
- mysql_query("DELETE FROM mq WHERE `from`='$number'");
- mysql_query("DELETE FROM users WHERE id='$id'");
- echo "This access has been removed.";
- } else {
- // TODO: Verify authentication against remote site using Twitter API. See process_db.php for a CURL example.
- $getcode=str_split(md5($_POST['base_url'] . $_POST['username']), 1);
- $code=$code_book[$getcode[0]] .'-'. $code_book[$getcode[1]] .'-'. $code_book[$getcode[2]] .'-'. $code_book[$getcode[3]];
- $sql="INSERT INTO users (`base_url`, `username`, `password`, `code`) VALUES ('http://" . mysql_real_escape_string($_POST['base_url']) . "', '" . mysql_real_escape_string($_POST['username']). "', '" . mysql_real_escape_string($_POST['password']) . "', '$code')";
- if(mysql_query($sql)) {echo "Please send an SMS to {$ui['number']} with this code: $code";} else {echo "Warning, your registration has been denied!";}
- }
-}
-?>
-
-<table width=100%>
-<tr><td align=center>
-<form method="post" action="#">
-Laconi.ca Environment: http://<input type="text" width="30" name="base_url" value="identi.ca/api"><br>
-Username: <input type="text" width="30" name="username"><br>
-Password: <input type="password" width="30" name="password"><br>
-<input type=hidden name=submit value=true><input type=submit value="Add/Remove from Gateway">
-</form>
-</td></tr>
-</table>
-
-<p>This gateway is brought to you by <?php echo '<a href="' . $ui['owner_url'] . '">' . $ui['owner'] . '</a>'; ?> and runs the smsToLaconica gateway software, version <?php echo $ui['version']; ?>, which is available under the GNU Affero General Public License from <?php echo '<a href="' . $ui['source_url'] . '">' . $ui['source'] . '</a>'; ?></p>
-</body>
-</html>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2008-11-11 17:29:27
|
Revision: 70
http://laconicatools.svn.sourceforge.net/laconicatools/?rev=70&view=rev
Author: jontheniceguy
Date: 2008-11-11 17:29:20 +0000 (Tue, 11 Nov 2008)
Log Message:
-----------
Various bug fixes. Nearly ready for release?!
Modified Paths:
--------------
smsToLaconica/branches/0.6/lib_debug.php
smsToLaconica/branches/0.6/lib_openid.php
smsToLaconica/branches/0.6/smsToLaconica.sql
smsToLaconica/branches/0.6/web_index.php
Modified: smsToLaconica/branches/0.6/lib_debug.php
===================================================================
--- smsToLaconica/branches/0.6/lib_debug.php 2008-11-11 08:11:00 UTC (rev 69)
+++ smsToLaconica/branches/0.6/lib_debug.php 2008-11-11 17:29:20 UTC (rev 70)
@@ -1,10 +1,5 @@
<?php
-$debug['enabled']=TRUE;
-$debug['output_to_screen']=TRUE;
-$debug['verbose']=TRUE;
-$debug['sql']=TRUE;
-
function call_rest_api($url, $fields="", $auth="", $type="post", $get_data=FALSE) {
// This code originally taken from http://morethanseven.net/posts/posting-to-twitter-using-php/
$curl_handle = curl_init();
Modified: smsToLaconica/branches/0.6/lib_openid.php
===================================================================
--- smsToLaconica/branches/0.6/lib_openid.php 2008-11-11 08:11:00 UTC (rev 69)
+++ smsToLaconica/branches/0.6/lib_openid.php 2008-11-11 17:29:20 UTC (rev 70)
@@ -8,6 +8,7 @@
// http://www.phpclasses.org/browse/package/3290.html
// with a load of tweaks.
require_once('class.openid.php');
+require_once('lib_debug.php');
function OpenID_Auth($site_url='', $req_flds=array('email', 'fullname')) {
if($site_url=='') {
@@ -22,6 +23,8 @@
if($off_port==TRUE) {$site_url.=':' . $_SERVER['SERVER_PORT'];}
if(strstr($_SERVER['REQUEST_URI'], '?')) {
$request_url=substr($_SERVER['REQUEST_URI'],0,strpos($_SERVER['REQUEST_URI'], '?'));
+ } else {
+ $request_url=$_SERVER['REQUEST_URI'];
}
$site_url.=$request_url;
}
@@ -33,7 +36,7 @@
if ($openid->GetOpenIDServer()){
$openid->SetApprovedURL($site_url);
$openid->Redirect();
- }else{
+ } else {
$error = $openid->GetError();
$err_data="ERROR CODE: " . $error['code'] . "<br>";
$err_data.="ERROR DESCRIPTION: " . $error['description'] . "<br>";
@@ -45,10 +48,10 @@
if ($openid_validation_result == true){
if(session_id()=="") {session_start();}
$_SESSION['valid']=TRUE;
- $_SESSION['openid_identity']=$openid_db_safe = $openid->OpenID_Standarize($_GET['openid_identity']);
+ $_SESSION['openid_identity']=$openid->OpenID_Standarize($_GET['openid_identity']);
foreach(array('email','fullname','dob','gender','postcode','country','language','timezone') as $var) {
if(isset($_GET['openid_sreg_' . $var])) {
- $_SESSION['openid_sreg_' . $var]=$_GET['openid_sreg_' . $var];
+ $_SESSION[$var]=$_GET['openid_sreg_' . $var];
}
}
header("Location: $site_url");
Modified: smsToLaconica/branches/0.6/smsToLaconica.sql
===================================================================
--- smsToLaconica/branches/0.6/smsToLaconica.sql 2008-11-11 08:11:00 UTC (rev 69)
+++ smsToLaconica/branches/0.6/smsToLaconica.sql 2008-11-11 17:29:20 UTC (rev 70)
@@ -25,11 +25,12 @@
DROP TABLE IF EXISTS `event_log`;
CREATE TABLE `event_log` (
- `event_id` int(11) NOT NULL,
+ `event_id` int(11) NOT NULL auto_increment,
`timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`user_id` int(11) NOT NULL,
`event` text NOT NULL,
- PRIMARY KEY (`event_id`)
+ PRIMARY KEY (`event_id`),
+ UNIQUE KEY `event_id` (`event_id`)
) ENGINE=MyISAM;
--
Modified: smsToLaconica/branches/0.6/web_index.php
===================================================================
--- smsToLaconica/branches/0.6/web_index.php 2008-11-11 08:11:00 UTC (rev 69)
+++ smsToLaconica/branches/0.6/web_index.php 2008-11-11 17:29:20 UTC (rev 70)
@@ -15,6 +15,8 @@
if($off_port==TRUE) {$site_url.=':' . $_SERVER['SERVER_PORT'];}
if(strstr($_SERVER['REQUEST_URI'], '?')) {
$request_url=substr($_SERVER['REQUEST_URI'],0,strpos($_SERVER['REQUEST_URI'], '?'));
+ } else {
+ $request_url=$_SERVER['REQUEST_URI'];
}
$site_url.=$request_url;
}
@@ -37,11 +39,12 @@
d_mysql_query("UPDATE users SET last_logged_in=NOW WHERE user_id='$user_id'");
event_log($user_id, "Logged in.");
} else {
- d_mysql_query("INSERT INTO users (openid_identity, user_name, user_mail) VALUES ('{$_SESSION['openid_identity']}, {$_SESSION['fullname']}, {$_SESSION['email']}')");
+ d_mysql_query("INSERT INTO users (openid_identity, user_name, user_mail) VALUES ('{$_SESSION['openid_identity']}', '{$_SESSION['fullname']}', '{$_SESSION['email']}')");
$user_exist=d_mysql_query("SELECT * FROM users WHERE openid_identity='{$_SESSION['openid_identity']}'");
$user=d_mysql_fetch_array($user_exist);
+ $user_id=$user['user_id'];
event_log($user_id, "Created user account.");
- $sql="INSERT INTO users_sms_status (user_id, service_day, service_hour) VALUE ";
+ $sql="INSERT INTO users_sms_service (user_id, service_day, service_hour) VALUE ";
$insert=0;
for($d=1; $d<=7; $d++) {
for($h=0; $h<=23; $h++) {
@@ -51,7 +54,7 @@
}
}
}
- d_mysql_session($sql);
+ d_mysql_query($sql);
event_log($user_id, "Set up service hours.");
}
if($_GET['ds']!="") {
@@ -65,7 +68,7 @@
event_log($user_id, "Deleted Watch Feed {$_GET['df']} number.");
}
} elseif($_POST['cs']!="") {
- if($_POST['service_type']!='' AND $_POST['base_url']!='' AND $_POST['username']!='' AND $_POST['password']!='' AND $services[strtoupper($_POST['service_type']))!='') {
+ if($_POST['service_type']!='' AND $_POST['base_url']!='' AND $_POST['username']!='' AND $_POST['password']!='' AND $services[strtoupper($_POST['service_type'])]!='') {
$buffer=call_rest_api($_POST['base_url'] . "/account/verify_credentials.xml", "", $_POST['username'] . ":" . $_POST['password'], "GET");
if($buffer==TRUE) {
d_mysql_query("INSERT INTO users_update_service (user_id, service_type, base_url, username, password) VALUES ('$user_id', '" . mysql_real_escape_string(strtoupper($_POST['service_type'])) . "', '" . mysql_real_escape_string($_POST['base_url']) . "', '" . mysql_real_escape_string($_POST['username']) . "', '" . mysql_real_escape_string($_POST['password']) . "')");
@@ -79,7 +82,7 @@
}
}
} elseif($_POST['cf']!="") {
- if($_POST['feed_type']!='' AND $_POST['feed_url']!='' AND $services[strtoupper($_POST['feed_type']))!='') {
+ if($_POST['feed_type']!='' AND $_POST['feed_url']!='' AND $services[strtoupper($_POST['feed_type'])]!='') {
d_mysql_query("INSERT INTO users_feeds (user_id, feed_type, feed_url, last_time) VALUES ('$user_id', '" . mysql_real_escape_string(strtoupper($_POST['feed_type'])) . "', '" . mysql_real_escape_string($_POST['feed_url']) . "', '0000-00-00 00:00:00')");
event_log($user_id, "Added feed at " . mysql_real_escape_string($_POST['feed_url']));
}
@@ -149,10 +152,10 @@
foreach($update_svc as $svc) {
echo "<tr><td>";
switch($svc['service_type']) {
- "T":
+ case "T":
echo "Twitter";
break;
- "L":
+ case "L":
echo "Laconi.ca";
break;
}
@@ -173,20 +176,19 @@
foreach($feeds as $feed) {
echo "<tr><td>";
switch($feed['feed_type']) {
- "T":
+ case "T":
echo "Twitter";
break;
- "L":
+ case "L":
echo "Laconi.ca";
break;
}
echo "</td><td>" . htmlentities($feed['feed_url']) . "</td><td><a href='$site_url?ds={$feed['feed_id']}'>Delete</a></td></tr>";
}
}
- echo "<form action='$site_url' method='post'><input type='hidden' name='cf' value='create'><tr><td><select name='feed_type'><option value='T'>Twitter</option><option value='L' selected>Laconi.ca System</option></select></td><td><input type='text' size='15' value='http://identi.ca/api'></td><td><input type='text' size='10'></td><td><input type='password' size='10'></td><td><input type='submit' value='Save'></td></tr></form></table>";
+ echo "<form action='$site_url' method='post'><input type='hidden' name='cf' value='create'><tr><td><select name='feed_type'><option value='T'>Twitter</option><option value='L' selected>Laconi.ca System</option></select></td><td><input type='text' size='40' value='http://username:pas...@id.../api/statuses/replies.rss'></td><td><input type='submit' value='Save'></td></tr></form></table>";
if($functions['send']==TRUE) {
- echo "<p>SMS Service Periods</p>"
- echo "<form action='$site_url' method='post'><input type='hidden' name='sh' value='true'><p><input type=submit value='Update'></p>";
+ echo "<form action='$site_url' method='post'><p>SMS Service Periods</p><input type='hidden' name='sh' value='true'><p><input type=submit value='Update'></p>";
echo "<table><tr><th>Day</th>";
for($h=0; $h<24; $h++) {echo "<th>$h</th>";}
echo "</tr>";
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2008-11-11 08:11:06
|
Revision: 69
http://laconicatools.svn.sourceforge.net/laconicatools/?rev=69&view=rev
Author: jontheniceguy
Date: 2008-11-11 08:11:00 +0000 (Tue, 11 Nov 2008)
Log Message:
-----------
Untested Web UI page finished. Typo and Bug testing to follow - perhaps this evening?
Modified Paths:
--------------
smsToLaconica/branches/0.6/web_index.php
Modified: smsToLaconica/branches/0.6/web_index.php
===================================================================
--- smsToLaconica/branches/0.6/web_index.php 2008-11-09 21:36:37 UTC (rev 68)
+++ smsToLaconica/branches/0.6/web_index.php 2008-11-11 08:11:00 UTC (rev 69)
@@ -41,8 +41,19 @@
$user_exist=d_mysql_query("SELECT * FROM users WHERE openid_identity='{$_SESSION['openid_identity']}'");
$user=d_mysql_fetch_array($user_exist);
event_log($user_id, "Created user account.");
+ $sql="INSERT INTO users_sms_status (user_id, service_day, service_hour) VALUE ";
+ $insert=0;
+ for($d=1; $d<=7; $d++) {
+ for($h=0; $h<=23; $h++) {
+ if($h>=9 AND $h<=20) {
+ if($insert==0) {$insert=1;} else {$sql.=", ";}
+ $sql.="('$user_id', '$d', '$h')";
+ }
+ }
+ }
+ d_mysql_session($sql);
+ event_log($user_id, "Set up service hours.");
}
- // Form Actions Take Place Here
if($_GET['ds']!="") {
if(d_mysql_num_rows(d_mysql_query("SELECT user_service_id FROM users_update_service WHERE user_id='$user_id' AND user_service_id='" . mysql_real_escape_string($_GET['ds']) . "'"))>0) {
d_mysql_query("DELETE FROM users_update_service WHERE user_service_id='" . mysql_real_escape_string($_GET['ds']) . "'");
@@ -58,15 +69,42 @@
$buffer=call_rest_api($_POST['base_url'] . "/account/verify_credentials.xml", "", $_POST['username'] . ":" . $_POST['password'], "GET");
if($buffer==TRUE) {
d_mysql_query("INSERT INTO users_update_service (user_id, service_type, base_url, username, password) VALUES ('$user_id', '" . mysql_real_escape_string(strtoupper($_POST['service_type'])) . "', '" . mysql_real_escape_string($_POST['base_url']) . "', '" . mysql_real_escape_string($_POST['username']) . "', '" . mysql_real_escape_string($_POST['password']) . "')");
- event_log($user_id, "Added service at " . mysql_real_escape_string($_POST['base_url']) . "for username" . mysql_real_escape_string($_POST['password']));
+ event_log($user_id, "Added service at " . mysql_real_escape_string($_POST['base_url']) . " for username " . mysql_real_escape_string($_POST['username']));
} elseif($buffer==FALSE) {
$error="It was not possible to contact the feed service. Please check the base URL.";
- event_log($user_id, "When trying to add service at ". mysql_real_escape_string($_POST['base_url']) . "for username" . mysql_real_escape_string($_POST['password']). ", the API service was not available.");
+ event_log($user_id, "When trying to add service at ". mysql_real_escape_string($_POST['base_url']) . " for username " . mysql_real_escape_string($_POST['username']). ", the API service was not available.");
} else {
$error="There was an error with the authentication to this service. Please check that the API is currently available on the remote service and that your authentication details are correct.";
- event_log($user_id, "When trying to add service at ". mysql_real_escape_string($_POST['base_url']) . "for username" . mysql_real_escape_string($_POST['password']). ", there was an error trying to authenticate.");
+ event_log($user_id, "When trying to add service at ". mysql_real_escape_string($_POST['base_url']) . " for username " . mysql_real_escape_string($_POST['username']). ", there was an error trying to authenticate.");
}
}
+ } elseif($_POST['cf']!="") {
+ if($_POST['feed_type']!='' AND $_POST['feed_url']!='' AND $services[strtoupper($_POST['feed_type']))!='') {
+ d_mysql_query("INSERT INTO users_feeds (user_id, feed_type, feed_url, last_time) VALUES ('$user_id', '" . mysql_real_escape_string(strtoupper($_POST['feed_type'])) . "', '" . mysql_real_escape_string($_POST['feed_url']) . "', '0000-00-00 00:00:00')");
+ event_log($user_id, "Added feed at " . mysql_real_escape_string($_POST['feed_url']));
+ }
+ } elseif($_POST['sh']!="") {
+ $service_times_qry=d_mysql_query("SELECT service_day, service_hour FROM users_sms_service WHERE user_id='$user_id'");
+ if(d_mysql_num_rows($service_times_qry)>0) {
+ while(list($day, $hour)=d_mysql_fetch_array($service_times_qry)) {$svc_hours["{$day}-{$hour}"]=TRUE;}
+ }
+ for($d=1; $d<=7; $d++) {
+ for($h=0; $h<=23; $h++) {
+ if(($_POST["{$d}-{$h}"]=='on' AND $svc_hours["{$d}-{$h}"]==TRUE) OR ($_POST["{$d}-{$h}"]!='on' AND $svc_hours["{$d}-{$h}"]==FALSE)) {
+ // Value is the same! Yey!
+ } else {
+ if($_POST["{$d}-{$h}"]=='on') {
+ d_mysql_query("INSERT INTO users_sms_service (user_id, service_day, service_hour) VALUES ('$user_id', '$d', '$h')");
+ } else {
+ d_mysql_query("DELETE FROM users_sms_service WHERE user_id='$user_id' AND service_day='$d' AND service_hour='$h'");
+ }
+ }
+ }
+ }
+ event_log($user_id, "Updated SMS service hours.");
+ }
+ $update_svc_qry=d_mysql_query("SELECT * FROM users_update_service WHERE user_id='$user_id'");
+ if(d_mysql_num_rows($update_svc_qry)>0) {
while($update_svc[]=d_mysql_fetch_array($update_svc_qry)) {}
} else {
$update_svc=FALSE;
@@ -77,6 +115,11 @@
} else {
$feeds=FALSE;
}
+ $service_times_qry=d_mysql_query("SELECT service_day, service_hour FROM users_sms_service WHERE user_id='$user_id'");
+ if(d_mysql_num_rows($service_times_qry)>0) {
+ while(list($day, $hour)=d_mysql_fetch_array($service_times_qry)) {$svc_hours["{$day}-{$hour}"]=TRUE;}
+ }
+
echo "<html><head><title>smsToLaconica User Portal</title></head><body><p align=center>smsToLaconica User Portal</p>";
echo service_status();
echo "<p>Hello {$user['user_name']}.</p>";
@@ -87,6 +130,7 @@
d_mysql_query("UPDATE users SET phone_code='$code' WHERE user_id='$user_id'");
$user['phone_code']=$code;
}
+ $phone_service='';
} elseif($user['user_number']!='') {
$phone_service="<p>This service has established a connection with your phone that is numbered " . htmlentities($user['user_number']) . ", from which it has received {$user['messages_sent']} messages";
if($functions['send']==TRUE) {
@@ -95,11 +139,13 @@
}
$phone_service.=". $credit</p>";
} else {
- $phone_service="<p>You don't have a phone number set up with this service yet. If you would like to add a number, please send a message to {$ui['number']} with activation code: {$user['phone_code']}.</p>";
+ $phone_service="<p>You don't have a phone number set up with this service yet. To add a number, please send a message to {$ui['number']} with activation code: {$user['phone_code']}.</p>";
}
echo "<p>Update Services</p>";
echo "<table><tr><th>Service Type</th><th>Base URL</th><th>Username</th><th>Password</th><th>Function</th></tr>";
- if(count($update_svc)>0) {
+ echo "<tr><td>Example Laconi.ca</td><td>http://identi.ca/api</td><td>username</td><td>password</td><td>EXAMPLE ONLY</td></tr>";
+ echo "<tr><td>Example Twitter</td><td>http://twitter.com</td><td>username</td><td>password</td><td>EXAMPLE ONLY</td></tr>";
+ if(count($update_svc)>0 AND $update_svc!=FALSE) {
foreach($update_svc as $svc) {
echo "<tr><td>";
switch($svc['service_type']) {
@@ -110,12 +156,50 @@
echo "Laconi.ca";
break;
}
- echo "</td><td>" . htmlentities($svc['base_url']) . "</td><td>" . htmlentities($svc['username']) . "</td><td>*****</td><td><a href='$site_url?df={$svc['user_service_id']}'>Delete</a></td></tr>";
+ echo "</td><td>" . htmlentities($svc['base_url']) . "</td><td>" . htmlentities($svc['username']) . "</td><td>*****</td><td><a href='$site_url?ds={$svc['user_service_id']}'>Delete</a></td></tr>";
}
}
- echo "<form action='$site_url' method='post><input type='hidden' name='cs' value='create'><tr><td><select name='service_type'><option value='T'>Twitter</option><option value='L' selected>Laconi.ca System</option></select></td><td><input type='text' size='15' value='http://identi.ca/api'></td><td><input type='text' size='10'></td><td><input type='password' size='10'></td><td><input type='submit' value='Save'></td></tr></form></table>";
- // List searches and RSS feeds
- // Add a search or RSS feed
+ echo "<form action='$site_url' method='post'><input type='hidden' name='cs' value='create'><tr><td><select name='service_type'><option value='T'>Twitter</option><option value='L' selected>Laconi.ca System</option></select></td><td><input type='text' size='15' value='http://identi.ca/api'></td><td><input type='text' size='10'></td><td><input type='password' size='10'></td><td><input type='submit' value='Save'></td></tr></form></table>";
+
+ echo $phone_service;
+
+ echo "<p>RSS Feeds</p>";
+ echo "<table><tr><th>Feed Type</th><th>Feed URL</th><th>Function</th></tr>";
+ echo "<tr><td>Example Laconi.ca Replies</td><td>http://username:pas...@id.../api/statuses/replies.rss</td><td>EXAMPLE ONLY</td></tr>";
+ echo "<tr><td>Example Twitter Replies</td><td>http://username:pas...@tw.../statuses/replies.rss</td><td>EXAMPLE ONLY</td></tr>";
+ echo "<tr><td>Example Laconi.ca Search</td><td>http://identi.ca/search/notice/rss?q=%40username</td><td>EXAMPLE ONLY</td></tr>";
+ echo "<tr><td>Example Twitter Search</td><td>http://search.twitter.com/search.atom?q=%40username</td><td>EXAMPLE ONLY</td></tr>";
+ if(count($feeds)>0 AND $feeds!=FALSE) {
+ foreach($feeds as $feed) {
+ echo "<tr><td>";
+ switch($feed['feed_type']) {
+ "T":
+ echo "Twitter";
+ break;
+ "L":
+ echo "Laconi.ca";
+ break;
+ }
+ echo "</td><td>" . htmlentities($feed['feed_url']) . "</td><td><a href='$site_url?ds={$feed['feed_id']}'>Delete</a></td></tr>";
+ }
+ }
+ echo "<form action='$site_url' method='post'><input type='hidden' name='cf' value='create'><tr><td><select name='feed_type'><option value='T'>Twitter</option><option value='L' selected>Laconi.ca System</option></select></td><td><input type='text' size='15' value='http://identi.ca/api'></td><td><input type='text' size='10'></td><td><input type='password' size='10'></td><td><input type='submit' value='Save'></td></tr></form></table>";
+ if($functions['send']==TRUE) {
+ echo "<p>SMS Service Periods</p>"
+ echo "<form action='$site_url' method='post'><input type='hidden' name='sh' value='true'><p><input type=submit value='Update'></p>";
+ echo "<table><tr><th>Day</th>";
+ for($h=0; $h<24; $h++) {echo "<th>$h</th>";}
+ echo "</tr>";
+ foreach(array(1=>'Monday', 2=>'Tuesday', 3=>'Wednesday', 4=>'Thursday', 5=>'Friday', 6=>'Saturday', 7=>'Sunday') as $d=>$day) {
+ echo "<tr><th>$day</th>";
+ for($h=0; $h<24; $h++) {
+ if($svc_hours["{$d}-{$h}"]==TRUE) {$checked="checked";} else {$checked="";}
+ echo "<td><input type='checkbox' name='{$d}-{$h}' $checked></td>";
+ }
+ echo "</tr>";
+ }
+ echo "</table></form>";
+ }
}
} else {
$err_data=OpenID_Auth(); // This script may return error data or it may send a header line. Either way, if we get past here, we need to render the page :)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2008-11-09 21:57:46
|
Revision: 68
http://laconicatools.svn.sourceforge.net/laconicatools/?rev=68&view=rev
Author: jontheniceguy
Date: 2008-11-09 21:36:37 +0000 (Sun, 09 Nov 2008)
Log Message:
-----------
Added more detail to the web UI form (now can create update services).
Modified Paths:
--------------
smsToLaconica/branches/0.6/web_index.php
Modified: smsToLaconica/branches/0.6/web_index.php
===================================================================
--- smsToLaconica/branches/0.6/web_index.php 2008-11-09 21:19:43 UTC (rev 67)
+++ smsToLaconica/branches/0.6/web_index.php 2008-11-09 21:36:37 UTC (rev 68)
@@ -54,10 +54,10 @@
event_log($user_id, "Deleted Watch Feed {$_GET['df']} number.");
}
} elseif($_POST['cs']!="") {
- if($_POST['service_type']!='' AND $_POST['base_url']!='' AND $_POST['username']!='' AND $_POST['password']!='' AND $services[$_POST['service_type'])!='') {
+ if($_POST['service_type']!='' AND $_POST['base_url']!='' AND $_POST['username']!='' AND $_POST['password']!='' AND $services[strtoupper($_POST['service_type']))!='') {
$buffer=call_rest_api($_POST['base_url'] . "/account/verify_credentials.xml", "", $_POST['username'] . ":" . $_POST['password'], "GET");
if($buffer==TRUE) {
- d_mysql_query("INSERT INTO users_update_service (user_id, service_type, base_url, username, password) VALUES ('$user_id', '" . mysql_real_escape_string($_POST['service_type']) . "', '" . mysql_real_escape_string($_POST['base_url']) . "', '" . mysql_real_escape_string($_POST['username']) . "', '" . mysql_real_escape_string($_POST['password']) . "')");
+ d_mysql_query("INSERT INTO users_update_service (user_id, service_type, base_url, username, password) VALUES ('$user_id', '" . mysql_real_escape_string(strtoupper($_POST['service_type'])) . "', '" . mysql_real_escape_string($_POST['base_url']) . "', '" . mysql_real_escape_string($_POST['username']) . "', '" . mysql_real_escape_string($_POST['password']) . "')");
event_log($user_id, "Added service at " . mysql_real_escape_string($_POST['base_url']) . "for username" . mysql_real_escape_string($_POST['password']));
} elseif($buffer==FALSE) {
$error="It was not possible to contact the feed service. Please check the base URL.";
@@ -97,14 +97,12 @@
} else {
$phone_service="<p>You don't have a phone number set up with this service yet. If you would like to add a number, please send a message to {$ui['number']} with activation code: {$user['phone_code']}.</p>";
}
- // List Update Service
echo "<p>Update Services</p>";
echo "<table><tr><th>Service Type</th><th>Base URL</th><th>Username</th><th>Password</th><th>Function</th></tr>";
if(count($update_svc)>0) {
foreach($update_svc as $svc) {
echo "<tr><td>";
switch($svc['service_type']) {
- "t":
"T":
echo "Twitter";
break;
@@ -112,10 +110,10 @@
echo "Laconi.ca";
break;
}
- echo "</td><td>" . htmlentities($svc['base_url']) . "</td><td>" . htmlentities($svn['username']) . "</td><td>*****</td><td><a href='$site_url?df={$svc['user_service_id']}'>Delete</a>"
+ echo "</td><td>" . htmlentities($svc['base_url']) . "</td><td>" . htmlentities($svc['username']) . "</td><td>*****</td><td><a href='$site_url?df={$svc['user_service_id']}'>Delete</a></td></tr>";
}
}
- // Add an Update Service
+ echo "<form action='$site_url' method='post><input type='hidden' name='cs' value='create'><tr><td><select name='service_type'><option value='T'>Twitter</option><option value='L' selected>Laconi.ca System</option></select></td><td><input type='text' size='15' value='http://identi.ca/api'></td><td><input type='text' size='10'></td><td><input type='password' size='10'></td><td><input type='submit' value='Save'></td></tr></form></table>";
// List searches and RSS feeds
// Add a search or RSS feed
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2008-11-09 21:19:48
|
Revision: 67
http://laconicatools.svn.sourceforge.net/laconicatools/?rev=67&view=rev
Author: jontheniceguy
Date: 2008-11-09 21:19:43 +0000 (Sun, 09 Nov 2008)
Log Message:
-----------
Added a basic installer for 0.6
Added Paths:
-----------
smsToLaconica/branches/0.6/install.sh
Added: smsToLaconica/branches/0.6/install.sh
===================================================================
--- smsToLaconica/branches/0.6/install.sh (rev 0)
+++ smsToLaconica/branches/0.6/install.sh 2008-11-09 21:19:43 UTC (rev 67)
@@ -0,0 +1,41 @@
+#! /bin/bash
+# This code is released under the AGPL (V.3 or later)
+# Author: Jon Spriggs (jo...@sp...)
+# Version: 0.6
+# SVN Version: $Rev$ on $Date$ last updated by $Author$
+#
+# This code creates a *DEFAULT* install of smsToLaconica - you will need to make some changes to it, but it's an ok out-of-the-box install.
+
+echo Installing required files for smsToLaconica
+if [ -f default_config.php ]; then
+ PWD=`pwd`
+ if [ -f config.php ]; then
+ echo "Found the config file."
+ else
+ cp default_config.php config.php
+ echo "Copied the default configuration file to config.php"
+ fi
+else
+ echo "This is not the right path. Exiting!"
+ exit
+fi
+
+sudo mkdir /var/www/smsToLaconica
+sudo chown $USER.$USER /var/www/smsToLaconica
+sudo chmod 755 /var/www/smsToLaconica
+
+ln -s `pwd`/web_index.php /var/www/smsToLaconica/index.php
+ln -s `pwd`/config.php `pwd`/lib_debug.php `pwd`/lib_text.php `pwd`/lib_pdu.php `pwd`/lib_openid.php /var/www/smsToLaconica
+
+cd /var/www/smsToLaconica
+wget http://stevelove.org/scripts/class.openid.phps
+mv class.openid.phps class.openid.php
+
+wget http://openidenabled.com/files/php-openid/files/PHP-yadis-1.0.2.tar.gz
+tar -xf PHP-yadis-1.0.2.tar.gz PHP-yadis-1.0.2/Services/
+mv PHP-yadis-1.0.2/Services Services/
+rm -Rf PHP-yadis-1.0.2 PHP-yadis-1.0.2.tar.gz
+
+sudo touch /var/log/sms_to_laconica.log
+sudo chown $USER.www-data /var/log/sms_to_laconica.log
+sudo chmod 770 /var/log/sms_to_laconica.log
Property changes on: smsToLaconica/branches/0.6/install.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:keywords
+ Date Rev Author Id
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2008-11-09 13:32:57
|
Revision: 66
http://laconicatools.svn.sourceforge.net/laconicatools/?rev=66&view=rev
Author: jontheniceguy
Date: 2008-11-09 13:32:55 +0000 (Sun, 09 Nov 2008)
Log Message:
-----------
Current version of the DB.
Modified Paths:
--------------
smsToLaconica/branches/0.6/smsToLaconica.sql
Modified: smsToLaconica/branches/0.6/smsToLaconica.sql
===================================================================
--- smsToLaconica/branches/0.6/smsToLaconica.sql 2008-11-08 16:40:15 UTC (rev 65)
+++ smsToLaconica/branches/0.6/smsToLaconica.sql 2008-11-09 13:32:55 UTC (rev 66)
@@ -1,42 +1,143 @@
-- This database definition is released under the AGPL (V.3 or later)
-- Author: Jon Spriggs (jo...@sp...)
--- Version 0.5.1
+-- Version 0.6
-- SVN Version: $Rev$ on $Date$ last updated by $Author$
-CREATE TABLE IF NOT EXISTS `iq` (
- `id` int(11) NOT NULL auto_increment,
- `date` datetime NOT NULL,
- `from` varchar(50) NOT NULL,
- `msg` varchar(200) NOT NULL,
- `queue_action` datetime NOT NULL,
- PRIMARY KEY (`id`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
+--
+-- Table structure for table `errors`
+--
-CREATE TABLE IF NOT EXISTS `oq` (
- `id` int(11) NOT NULL auto_increment,
- `date_start` datetime NOT NULL,
- `number` varchar(50) NOT NULL,
- `message` varchar(200) NOT NULL,
- PRIMARY KEY (`id`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
+DROP TABLE IF EXISTS `errors`;
+CREATE TABLE `errors` (
+ `error_id` int(11) NOT NULL auto_increment,
+ `time_in` datetime NOT NULL,
+ `user_number` varchar(50) NOT NULL,
+ `user_id` int(11) NOT NULL,
+ `message` text NOT NULL,
+ `error_text` text NOT NULL,
+ `acknowledged` tinyint(1) NOT NULL,
+ PRIMARY KEY (`error_id`)
+) ENGINE=MyISAM;
-CREATE TABLE IF NOT EXISTS `errors` (
- `id` int(11) NOT NULL auto_increment,
- `mid` int(11) NOT NULL,
- `timestamp` datetime NOT NULL,
- `response` text NOT NULL,
- PRIMARY KEY (`id`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
+--
+-- Table structure for table `event_log`
+--
-CREATE TABLE IF NOT EXISTS `users` (
- `id` int(11) NOT NULL auto_increment,
+DROP TABLE IF EXISTS `event_log`;
+CREATE TABLE `event_log` (
+ `event_id` int(11) NOT NULL,
+ `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
+ `user_id` int(11) NOT NULL,
+ `event` text NOT NULL,
+ PRIMARY KEY (`event_id`)
+) ENGINE=MyISAM;
+
+--
+-- Table structure for table `queue_in`
+--
+
+DROP TABLE IF EXISTS `queue_in`;
+CREATE TABLE `queue_in` (
+ `in_id` int(11) NOT NULL auto_increment,
+ `phone_number` varchar(25) NOT NULL,
+ `message` varchar(255) NOT NULL,
+ `time_in` datetime NOT NULL,
+ `time_last` datetime NOT NULL,
+ PRIMARY KEY (`in_id`)
+) ENGINE=MyISAM;
+
+--
+-- Table structure for table `queue_out`
+--
+
+DROP TABLE IF EXISTS `queue_out`;
+CREATE TABLE `queue_out` (
+ `out_id` int(11) NOT NULL auto_increment,
+ `phone_number` varchar(25) NOT NULL,
+ `message` varchar(255) NOT NULL,
+ `time_in` datetime NOT NULL,
+ `time_last` datetime NOT NULL,
+ PRIMARY KEY (`out_id`)
+) ENGINE=MyISAM;
+
+--
+-- Table structure for table `service_status`
+--
+
+DROP TABLE IF EXISTS `service_status`;
+CREATE TABLE `service_status` (
+ `service_name` varchar(50) NOT NULL,
+ `last_run` timestamp NOT NULL default CURRENT_TIMESTAMP,
+ PRIMARY KEY (`service_name`)
+) ENGINE=MyISAM;
+
+--
+-- Data for table `service_status`
+--
+
+INSERT INTO `service_status` VALUES ('daemon_feed.php', '0000-00-00 00:00:00');
+INSERT INTO `service_status` VALUES ('daemon_modem.php', '0000-00-00 00:00:00');
+INSERT INTO `service_status` VALUES ('daemon_database.php', '0000-00-00 00:00:00');
+
+--
+-- Table structure for table `users`
+--
+
+DROP TABLE IF EXISTS `users`;
+CREATE TABLE `users` (
+ `user_id` int(11) NOT NULL auto_increment,
+ `openid_identity` varchar(255) NOT NULL,
+ `user_name` varchar(255) NOT NULL,
+ `user_mail` varchar(255) NOT NULL,
+ `user_number` varchar(20) NOT NULL,
+ `phone_credit` int(11) NOT NULL default '0',
+ `phone_code` varchar(255) NOT NULL,
+ `messages_sent` int(11) NOT NULL default '0',
+ `messages_received` int(11) NOT NULL default '0',
+ `last_logged_in` datetime NOT NULL,
+ PRIMARY KEY (`user_id`),
+ UNIQUE KEY `openid_identity` (`openid_identity`),
+ UNIQUE KEY `user_mail` (`user_mail`)
+) ENGINE=MyISAM;
+
+--
+-- Table structure for table `users_feeds`
+--
+
+DROP TABLE IF EXISTS `users_feeds`;
+CREATE TABLE `users_feeds` (
+ `feed_id` int(11) NOT NULL auto_increment,
+ `feed_url` text NOT NULL,
+ `feed_type` varchar(50) NOT NULL,
+ `last_time` datetime NOT NULL,
+ `user_id` int(11) NOT NULL,
+ PRIMARY KEY (`feed_id`)
+) ENGINE=MyISAM;
+
+--
+-- Table structure for table `users_sms_service`
+--
+
+DROP TABLE IF EXISTS `users_sms_service`;
+CREATE TABLE `users_sms_service` (
+ `user_service_id` int(11) NOT NULL auto_increment,
+ `user_id` int(11) NOT NULL,
+ `service_day` tinyint(1) NOT NULL,
+ `service_hour` tinyint(2) NOT NULL,
+ PRIMARY KEY (`user_service_id`)
+) ENGINE=MyISAM;
+
+--
+-- Table structure for table `users_update_service`
+--
+
+DROP TABLE IF EXISTS `users_update_service`;
+CREATE TABLE `users_update_service` (
+ `user_service_id` int(11) NOT NULL auto_increment,
+ `user_id` int(11) NOT NULL,
+ `service_type` varchar(2) NOT NULL,
`base_url` varchar(255) NOT NULL,
`username` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
- `number` varchar(50) NOT NULL,
- `code` varchar(50) NOT NULL,
- `message_in` INT NOT NULL DEFAULT '0',
- `message_out` INT NOT NULL DEFAULT '0',
- PRIMARY KEY (`id`),
- UNIQUE KEY `uid` (`number`, `code`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
+ PRIMARY KEY (`user_service_id`)
+) ENGINE=MyISAM;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2008-11-08 16:40:18
|
Revision: 65
http://laconicatools.svn.sourceforge.net/laconicatools/?rev=65&view=rev
Author: jontheniceguy
Date: 2008-11-08 16:40:15 +0000 (Sat, 08 Nov 2008)
Log Message:
-----------
Some changes to the web UI which have broken the script (committed for rebuilding laptop), added event logging and service list.
Modified Paths:
--------------
smsToLaconica/branches/0.6/daemon_modem.php
smsToLaconica/branches/0.6/default_config.php
smsToLaconica/branches/0.6/lib_debug.php
smsToLaconica/branches/0.6/web_index.php
Modified: smsToLaconica/branches/0.6/daemon_modem.php
===================================================================
--- smsToLaconica/branches/0.6/daemon_modem.php 2008-11-06 15:57:50 UTC (rev 64)
+++ smsToLaconica/branches/0.6/daemon_modem.php 2008-11-08 16:40:15 UTC (rev 65)
@@ -26,6 +26,7 @@
$success=Send_SMS($phone_number, $message);
if($success==TRUE) {
d_mysql_query("DELETE FROM queue_out WHERE out_id='$out_id'");
+ event_log(mysql_real_escape_string($phone_number), "Message sent '" . mysql_real_escape_string($message) . "'.");
}
}
}
@@ -37,6 +38,7 @@
debug(print_r($msg, true), 'verbose', 'sql');
$sql="INSERT INTO queue_in VALUES (NULL , '{$msg['number']}', '" . mysql_real_escape_string($msg['message']) . "', NOW(), NOW());";
d_mysql_query($sql);
+ event_log($msg['number'], "Message received '{$msg['message']}'.");
}
}
d_mysql_query("UPDATE service_status SET last_run=CURRENT_TIMESTAMP WHERE service_name='daemon_modem.php'", TRUE, TRUE);
Modified: smsToLaconica/branches/0.6/default_config.php
===================================================================
--- smsToLaconica/branches/0.6/default_config.php 2008-11-06 15:57:50 UTC (rev 64)
+++ smsToLaconica/branches/0.6/default_config.php 2008-11-08 16:40:15 UTC (rev 65)
@@ -58,4 +58,6 @@
$email=array('send_admin_mail'=>FALSE,
'to_address'=>'sms...@te...',
'from_name'=>'smsToLaconica Service',
- 'from_address'=>'sms...@YO...');
\ No newline at end of file
+ 'from_address'=>'sms...@YO...');
+
+$services=array("T"=>'Twitter API', "L"=>'Twitter API');
\ No newline at end of file
Modified: smsToLaconica/branches/0.6/lib_debug.php
===================================================================
--- smsToLaconica/branches/0.6/lib_debug.php 2008-11-06 15:57:50 UTC (rev 64)
+++ smsToLaconica/branches/0.6/lib_debug.php 2008-11-08 16:40:15 UTC (rev 65)
@@ -109,4 +109,8 @@
}
}
}
+
+function event_log($user_id, $message) {
+ d_mysql_query("INSERT INTO event_log (user_id, event) VALUES ('" . mysql_real_escape_string($user_id) . "', '" . mysql_real_escape_string($message) . "')");
+}
?>
\ No newline at end of file
Modified: smsToLaconica/branches/0.6/web_index.php
===================================================================
--- smsToLaconica/branches/0.6/web_index.php 2008-11-06 15:57:50 UTC (rev 64)
+++ smsToLaconica/branches/0.6/web_index.php 2008-11-08 16:40:15 UTC (rev 65)
@@ -3,6 +3,22 @@
require_once('lib_openid.php');
require_once('lib_' . $phone['data_type'] . '.php');
+if($site_url=='') {
+ if($_SERVER['HTTPS']!='') {
+ $site_url="https://";
+ if($_SERVER['SERVER_PORT']!=443) {$off_port=TRUE;}
+ } else {
+ $site_url="http://";
+ if($_SERVER['SERVER_PORT']!=80) {$off_port=TRUE;}
+ }
+ $site_url.=$_SERVER['SERVER_NAME'];
+ if($off_port==TRUE) {$site_url.=':' . $_SERVER['SERVER_PORT'];}
+ if(strstr($_SERVER['REQUEST_URI'], '?')) {
+ $request_url=substr($_SERVER['REQUEST_URI'],0,strpos($_SERVER['REQUEST_URI'], '?'));
+ }
+ $site_url.=$request_url;
+}
+
session_start();
if($_SESSION['valid']==TRUE) {
if($_GET['logout']==TRUE) {
@@ -10,22 +26,7 @@
$_SESSION = array();
if (isset($_COOKIE[session_name()])) {setcookie(session_name(), '', time()-42000, '/');}
session_destroy();
- if($site_url=='') {
- if($_SERVER['HTTPS']!='') {
- $site_url="https://";
- if($_SERVER['SERVER_PORT']!=443) {$off_port=TRUE;}
- } else {
- $site_url="http://";
- if($_SERVER['SERVER_PORT']!=80) {$off_port=TRUE;}
- }
- $site_url.=$_SERVER['SERVER_NAME'];
- if($off_port==TRUE) {$site_url.=':' . $_SERVER['SERVER_PORT'];}
- if(strstr($_SERVER['REQUEST_URI'], '?')) {
- $request_url=substr($_SERVER['REQUEST_URI'],0,strpos($_SERVER['REQUEST_URI'], '?'));
- }
- $site_url.=$request_url;
- header("Location: $site_url");
- }
+ header("Location: $site_url");
} else {
require_once("lib_debug.php");
d_mysql_connect();
@@ -34,21 +35,52 @@
$user=d_mysql_fetch_array($user_exist);
$user_id=$user['user_id'];
d_mysql_query("UPDATE users SET last_logged_in=NOW WHERE user_id='$user_id'");
+ event_log($user_id, "Logged in.");
} else {
d_mysql_query("INSERT INTO users (openid_identity, user_name, user_mail) VALUES ('{$_SESSION['openid_identity']}, {$_SESSION['fullname']}, {$_SESSION['email']}')");
$user_exist=d_mysql_query("SELECT * FROM users WHERE openid_identity='{$_SESSION['openid_identity']}'");
$user=d_mysql_fetch_array($user_exist);
+ event_log($user_id, "Created user account.");
}
- $feeds_qry=d_mysql_query("SELECT * FROM users_update_service WHERE user_id='$user_id'");
+ // Form Actions Take Place Here
+ if($_GET['ds']!="") {
+ if(d_mysql_num_rows(d_mysql_query("SELECT user_service_id FROM users_update_service WHERE user_id='$user_id' AND user_service_id='" . mysql_real_escape_string($_GET['ds']) . "'"))>0) {
+ d_mysql_query("DELETE FROM users_update_service WHERE user_service_id='" . mysql_real_escape_string($_GET['ds']) . "'");
+ event_log($user_id, "Deleted Service {$_GET['ds']} number.");
+ }
+ } elseif($_GET['df']!="") {
+ if(d_mysql_num_rows(d_mysql_query("SELECT feed_id FROM users_feeds WHERE user_id='$user_id' AND feed_id='" . mysql_real_escape_string($_GET['df']) . "'"))>0) {
+ d_mysql_query("DELETE FROM users_feeds WHERE feed_id='" . mysql_real_escape_string($_GET['df']) . "'");
+ event_log($user_id, "Deleted Watch Feed {$_GET['df']} number.");
+ }
+ } elseif($_POST['cs']!="") {
+ if($_POST['service_type']!='' AND $_POST['base_url']!='' AND $_POST['username']!='' AND $_POST['password']!='' AND $services[$_POST['service_type'])!='') {
+ $buffer=call_rest_api($_POST['base_url'] . "/account/verify_credentials.xml", "", $_POST['username'] . ":" . $_POST['password'], "GET");
+ if($buffer==TRUE) {
+ d_mysql_query("INSERT INTO users_update_service (user_id, service_type, base_url, username, password) VALUES ('$user_id', '" . mysql_real_escape_string($_POST['service_type']) . "', '" . mysql_real_escape_string($_POST['base_url']) . "', '" . mysql_real_escape_string($_POST['username']) . "', '" . mysql_real_escape_string($_POST['password']) . "')");
+ event_log($user_id, "Added service at " . mysql_real_escape_string($_POST['base_url']) . "for username" . mysql_real_escape_string($_POST['password']));
+ } elseif($buffer==FALSE) {
+ $error="It was not possible to contact the feed service. Please check the base URL.";
+ event_log($user_id, "When trying to add service at ". mysql_real_escape_string($_POST['base_url']) . "for username" . mysql_real_escape_string($_POST['password']). ", the API service was not available.");
+ } else {
+ $error="There was an error with the authentication to this service. Please check that the API is currently available on the remote service and that your authentication details are correct.";
+ event_log($user_id, "When trying to add service at ". mysql_real_escape_string($_POST['base_url']) . "for username" . mysql_real_escape_string($_POST['password']). ", there was an error trying to authenticate.");
+ }
+ }
+ while($update_svc[]=d_mysql_fetch_array($update_svc_qry)) {}
+ } else {
+ $update_svc=FALSE;
+ }
+ $feeds_qry=d_mysql_query("SELECT * FROM users_feeds WHERE user_id='$user_id'");
if(d_mysql_num_rows($feeds_qry)>0) {
- while($feeds[]=d_mysql_fetch_array) {}
+ while($feeds[]=d_mysql_fetch_array($feeds_qry)) {}
} else {
$feeds=FALSE;
}
echo "<html><head><title>smsToLaconica User Portal</title></head><body><p align=center>smsToLaconica User Portal</p>";
echo service_status();
- echo "<p>Hello {$user['user_name']}.";
- if($feeds==FALSE) {
+ echo "<p>Hello {$user['user_name']}.</p>";
+ if($update_svc==FALSE) {
if($user['phone_code']=='') {
$getcode=str_split(md5($_SESSION['openid_identity'] . date("U") . $_SESSION['fullname'] . date("U") . $_SESSION['email']), 1);
$code=$code_book[$getcode[0]] .'-'. $code_book[$getcode[1]] .'-'. $code_book[$getcode[2]] .'-'. $code_book[$getcode[3]];
@@ -56,16 +88,33 @@
$user['phone_code']=$code;
}
} elseif($user['user_number']!='') {
- echo " This service has established a connection with your phone that is numbered " . htmlentities($user['user_number']) . ", from which it has received {$user['messages_sent']} messages";
+ $phone_service="<p>This service has established a connection with your phone that is numbered " . htmlentities($user['user_number']) . ", from which it has received {$user['messages_sent']} messages";
if($functions['send']==TRUE) {
- echo " and sent it {$user['messages_received']} messages";
- $credit="You have {$user['phone_credit']} message credits remaining. One credit is equal to one message sent to you from the system. You should contact <a href='mailto:{$ui['system_mail']}'>the service administrator</a> to obtain more credits.";
+ $phone_service.=" and sent it {$user['messages_received']} messages";
+ $credit="You have {$user['phone_credit']} message credits remaining. One credit is equal to one message sent to you from the system. You should contact <a href='mailto:{$ui['system_mail']}'>the service administrator</a> to obtain more credits";
}
- echo ". $credit</p>";
+ $phone_service.=". $credit</p>";
} else {
- echo " You don't have a phone number set up with this service yet. If you would like to add a number, please send a message to {$ui['number']} with activation code: {$user['phone_code']}";
+ $phone_service="<p>You don't have a phone number set up with this service yet. If you would like to add a number, please send a message to {$ui['number']} with activation code: {$user['phone_code']}.</p>";
}
// List Update Service
+ echo "<p>Update Services</p>";
+ echo "<table><tr><th>Service Type</th><th>Base URL</th><th>Username</th><th>Password</th><th>Function</th></tr>";
+ if(count($update_svc)>0) {
+ foreach($update_svc as $svc) {
+ echo "<tr><td>";
+ switch($svc['service_type']) {
+ "t":
+ "T":
+ echo "Twitter";
+ break;
+ "L":
+ echo "Laconi.ca";
+ break;
+ }
+ echo "</td><td>" . htmlentities($svc['base_url']) . "</td><td>" . htmlentities($svn['username']) . "</td><td>*****</td><td><a href='$site_url?df={$svc['user_service_id']}'>Delete</a>"
+ }
+ }
// Add an Update Service
// List searches and RSS feeds
// Add a search or RSS feed
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2008-11-06 15:58:04
|
Revision: 64
http://laconicatools.svn.sourceforge.net/laconicatools/?rev=64&view=rev
Author: jontheniceguy
Date: 2008-11-06 15:57:50 +0000 (Thu, 06 Nov 2008)
Log Message:
-----------
Moved the status update into a separate function, updated the e-mail tool. Made a series of changes to the web_index around phone numbers and codes. More to follow!
Modified Paths:
--------------
smsToLaconica/branches/0.6/lib_debug.php
smsToLaconica/branches/0.6/mail_admin.php
smsToLaconica/branches/0.6/web_index.php
Modified: smsToLaconica/branches/0.6/lib_debug.php
===================================================================
--- smsToLaconica/branches/0.6/lib_debug.php 2008-11-05 00:44:39 UTC (rev 63)
+++ smsToLaconica/branches/0.6/lib_debug.php 2008-11-06 15:57:50 UTC (rev 64)
@@ -82,4 +82,31 @@
global $db, $debug, $sleep, $code_book, $ui, $phone, $email;
debug("Config Values are:\r\n\$db => " . print_r($db, TRUE) . "\r\n\$debug => " . print_r($debug, TRUE) . "\r\n\$sleep => " . print_r($sleep, TRUE) . "\r\n\$code_book => " . print_r($code_book, TRUE) . "\r\n\$ui => " . print_r($ui, TRUE) . "\r\n\$phone => " . print_r($phone, TRUE) . "\r\n\$email => " . print_r($email, TRUE));
}
+
+function service_status($html=TRUE) {
+ $back5=strtotime("-5 minutes");
+ $status_qry=d_mysql_query("SELECT * FROM service_status");
+ while($status_ary=d_mysql_fetch_array($status_qry)) {
+ $status[$status_ary['service_name']]['time']=$status_ary['last_run'];
+ if(strtotime($status_ary['last_run'])<$back5) {
+ $status[$status_ary['service_name']]['state']="0";
+ } else {
+ $status[$status_ary['service_name']]['state']="1";
+ }
+ }
+ if(count($status)>0) {
+ if($html==TRUE) {
+ $stat_head="";
+ $stat_line="";
+ foreach($status as $stat_name=>$state) {
+ $stat_head.="<th>$stat_name</th>";
+ if($states['state']==0) {$stat="Down since {$state['time']}";} else {$stat="Up at {$state['time']}";}
+ $stat_line.="<td>$stat</td>";
+ }
+ return "<table><tr>$stat_head</tr><tr>$stat_line</tr></table>";
+ } else {
+ return $status;
+ }
+ }
+}
?>
\ No newline at end of file
Modified: smsToLaconica/branches/0.6/mail_admin.php
===================================================================
--- smsToLaconica/branches/0.6/mail_admin.php 2008-11-05 00:44:39 UTC (rev 63)
+++ smsToLaconica/branches/0.6/mail_admin.php 2008-11-06 15:57:50 UTC (rev 64)
@@ -30,11 +30,8 @@
}
}
-$status_qry=d_mysql_query("SELECT * FROM service_status");
-while($status_ary=d_mysql_fetch_array($status_qry)) {
- $status[$status_ary['service_name']]=$status_ary['last_run'];
-}
+
$mail="<html><body>";
// This below code snippet is adapted from http://www.randomsnippets.com/2008/02/12/how-to-hide-and-show-your-div/
$mail.="<script language=\"javascript\">
@@ -53,18 +50,7 @@
</script>";
$mail.="<p align=center>smsToLaconica - Admin Information</p>";
-$mail.="<p>Service Status:</p>";
-$back5=strtotime("-5 minutes");
-if(count($status)>0) {
- $stat_head="";
- $stat_line="";
- foreach($status as $stat_name=>$stat) {
- $stat_head.="<th>$stat_name</th>";
- if(strtotime($stat)<$back5) {$state="Down since $stat";} else {$state="Up at $stat";}
- $stat_line.="<td>$state</td>";
- }
- $mail.="<table><tr>$stat_head</tr><tr>$stat_line</tr></table>";
-}
+$mail.="<p>Service Status</p>" . service_status();
$mail.="<p>There are " . count($users) . " users on the service.</p>";
if(count($users)>0) {
Modified: smsToLaconica/branches/0.6/web_index.php
===================================================================
--- smsToLaconica/branches/0.6/web_index.php 2008-11-05 00:44:39 UTC (rev 63)
+++ smsToLaconica/branches/0.6/web_index.php 2008-11-06 15:57:50 UTC (rev 64)
@@ -10,34 +10,66 @@
$_SESSION = array();
if (isset($_COOKIE[session_name()])) {setcookie(session_name(), '', time()-42000, '/');}
session_destroy();
- if($site_url=='') {
- if($_SERVER['HTTPS']!='') {
- $site_url="https://";
- if($_SERVER['SERVER_PORT']!=443) {$off_port=TRUE;}
+ if($site_url=='') {
+ if($_SERVER['HTTPS']!='') {
+ $site_url="https://";
+ if($_SERVER['SERVER_PORT']!=443) {$off_port=TRUE;}
+ } else {
+ $site_url="http://";
+ if($_SERVER['SERVER_PORT']!=80) {$off_port=TRUE;}
+ }
+ $site_url.=$_SERVER['SERVER_NAME'];
+ if($off_port==TRUE) {$site_url.=':' . $_SERVER['SERVER_PORT'];}
+ if(strstr($_SERVER['REQUEST_URI'], '?')) {
+ $request_url=substr($_SERVER['REQUEST_URI'],0,strpos($_SERVER['REQUEST_URI'], '?'));
+ }
+ $site_url.=$request_url;
+ header("Location: $site_url");
+ }
+ } else {
+ require_once("lib_debug.php");
+ d_mysql_connect();
+ $user_exist=d_mysql_query("SELECT * FROM users WHERE openid_identity='{$_SESSION['openid_identity']}'");
+ if(d_mysql_num_rows($user_exist)>0) {
+ $user=d_mysql_fetch_array($user_exist);
+ $user_id=$user['user_id'];
+ d_mysql_query("UPDATE users SET last_logged_in=NOW WHERE user_id='$user_id'");
} else {
- $site_url="http://";
- if($_SERVER['SERVER_PORT']!=80) {$off_port=TRUE;}
+ d_mysql_query("INSERT INTO users (openid_identity, user_name, user_mail) VALUES ('{$_SESSION['openid_identity']}, {$_SESSION['fullname']}, {$_SESSION['email']}')");
+ $user_exist=d_mysql_query("SELECT * FROM users WHERE openid_identity='{$_SESSION['openid_identity']}'");
+ $user=d_mysql_fetch_array($user_exist);
}
- $site_url.=$_SERVER['SERVER_NAME'];
- if($off_port==TRUE) {$site_url.=':' . $_SERVER['SERVER_PORT'];}
- if(strstr($_SERVER['REQUEST_URI'], '?')) {
- $request_url=substr($_SERVER['REQUEST_URI'],0,strpos($_SERVER['REQUEST_URI'], '?'));
+ $feeds_qry=d_mysql_query("SELECT * FROM users_update_service WHERE user_id='$user_id'");
+ if(d_mysql_num_rows($feeds_qry)>0) {
+ while($feeds[]=d_mysql_fetch_array) {}
+ } else {
+ $feeds=FALSE;
}
- $site_url.=$request_url;
- header("Location: $site_url");
+ echo "<html><head><title>smsToLaconica User Portal</title></head><body><p align=center>smsToLaconica User Portal</p>";
+ echo service_status();
+ echo "<p>Hello {$user['user_name']}.";
+ if($feeds==FALSE) {
+ if($user['phone_code']=='') {
+ $getcode=str_split(md5($_SESSION['openid_identity'] . date("U") . $_SESSION['fullname'] . date("U") . $_SESSION['email']), 1);
+ $code=$code_book[$getcode[0]] .'-'. $code_book[$getcode[1]] .'-'. $code_book[$getcode[2]] .'-'. $code_book[$getcode[3]];
+ d_mysql_query("UPDATE users SET phone_code='$code' WHERE user_id='$user_id'");
+ $user['phone_code']=$code;
+ }
+ } elseif($user['user_number']!='') {
+ echo " This service has established a connection with your phone that is numbered " . htmlentities($user['user_number']) . ", from which it has received {$user['messages_sent']} messages";
+ if($functions['send']==TRUE) {
+ echo " and sent it {$user['messages_received']} messages";
+ $credit="You have {$user['phone_credit']} message credits remaining. One credit is equal to one message sent to you from the system. You should contact <a href='mailto:{$ui['system_mail']}'>the service administrator</a> to obtain more credits.";
+ }
+ echo ". $credit</p>";
+ } else {
+ echo " You don't have a phone number set up with this service yet. If you would like to add a number, please send a message to {$ui['number']} with activation code: {$user['phone_code']}";
+ }
+ // List Update Service
+ // Add an Update Service
+ // List searches and RSS feeds
+ // Add a search or RSS feed
}
- require_once("lib_debug.php");
- d_mysql_connect();
- $user_exist=d_mysql_query("SELECT user_id FROM users WHERE openid_identity='{$_SESSION['openid_identity']}'");
- if(d_mysql_num_rows($user_exist)>0) {
- list($user_id)=d_mysql_fetch_array($user_exist);
- d_mysql_query("UPDATE users SET last_logged_in=NOW WHERE user_id='$user_id'");
- } else {
- d_mysql_query("INSERT INTO users (openid_identity, user_name, user_mail) VALUES ('{$_SESSION['openid_identity']}, {$_SESSION['fullname']}, {$_SESSION['email']}')");
- $user_exist=d_mysql_query("SELECT user_id FROM users WHERE openid_identity='{$_SESSION['openid_identity']}'");
- list($user_id)=d_mysql_fetch_array($user_exist);
- }
- // We can now start doing stuff with the account :)
} else {
$err_data=OpenID_Auth(); // This script may return error data or it may send a header line. Either way, if we get past here, we need to render the page :)
echo "<html><head><title>smsToLaconica</title></head>";
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2008-11-05 00:44:44
|
Revision: 63
http://laconicatools.svn.sourceforge.net/laconicatools/?rev=63&view=rev
Author: jontheniceguy
Date: 2008-11-05 00:44:39 +0000 (Wed, 05 Nov 2008)
Log Message:
-----------
This update includes support files for the simple_openid class from phpclasses. There are some documentation changes and the creation of web_index.php - which is a new version of web_ui.php, albeit with a different name to extract details for the system. web_index.php creates new user accounts and shows a splash screen. Hopefully soon, this will also manage adding a phone number to a users account (taken from web_ui.php) and credit (which I do not know how to handle right now, although the DB mechanism is there, the *financial aspect* is the problem - it will probably end up being paypal!) and the user feeds... nearly there!
Modified Paths:
--------------
smsToLaconica/branches/0.6/README.txt
smsToLaconica/branches/0.6/UPGRADE.txt
Added Paths:
-----------
smsToLaconica/branches/0.6/lib_openid.php
smsToLaconica/branches/0.6/web_index.php
Modified: smsToLaconica/branches/0.6/README.txt
===================================================================
--- smsToLaconica/branches/0.6/README.txt 2008-11-04 19:24:15 UTC (rev 62)
+++ smsToLaconica/branches/0.6/README.txt 2008-11-05 00:44:39 UTC (rev 63)
@@ -8,6 +8,7 @@
Version 0.5 was written by Jon Spriggs, with some fixes identified by Ciaran G (http://blog.ciarang.com)
Version 0.5.1 was written by Jon Spriggs, adding support for differing SMS interpretation systems (PDU and Text), and monitoring text messages received from a user.
Version 0.6 was written by Jon Spriggs introducing Text Mode and providing functions to send messages as well as receive them.
+
This document has been taken from SVN at version $Rev$ on $Date$ last updated by $Author$
Requirements
@@ -18,32 +19,41 @@
3. (Optional) Some form of Bluetooth transport for Ser2Net to communicate with, unless you have a data cable which exposes
itself as a serial interface.
4. An old mobile phone which uses SMS-PDU.
-5. simplepie.inc from simplepie.org
+5. simplepie (tested with version 1.1.1) from http://simplepie.org placed in the script
+root (/path/to/script/root/simplepie.inc).
+6. simple_openid (tested with Steve Love's modified version) from
+http://www.stevelove.org/2008/08/how-to-wordpresscom-and-the-simple-openid-php-class/,
+placed in the script root (/path/to/script/root/class.openid.php)
+7. The services folder from the Yadis library, referenced from
+http://www.stevelove.org/2008/08/how-to-yahoo-and-the-simple-openid-php-class/ placed in
+the script root (/path/to/script/root/services)
Install Guide
-------------
1. Unpack these files to a directory outside of your Web Root.
-2. If your version of php and apache can cope with symbolically linked files, you should link config.php and web_ui.php into the web directory. If you can't use symlinks, copy config.php and web_ui.php into the web directory.
2. Import smsToLaconica.sql to your MySQL instance.
-3. Configure your Ser2Net to talk to your mobile phone. Confirm it works by telnetting to the port you've designated for
-your mobile phone and send the command "AT" (no quotes) and wait for a response OK. If you get nothing, then contact me
-for some (VERY) limited support. Check your phone talks SMS-PDU by sending the AT+CMGL=4. If this returns ERROR, then your
-phone doesn't talk PDU. If it returns OK, then it does. Your phone may talk SMS-TEXT, which you can find out by sending
-AT+CGMS="ALL". I don't have a phone which talks SMS-TEXT, so these scripts are based on SMS-PDU.
-4. Edit config.php with at least enough information for the scripts to talk to your MySQL server and Ser2Net instance.
-5. Using nohup or screen, start php -q read_sms.php and php -q process_db.php
-6. Add an entry to the database table users, with the base url of your laconi.ca instance (e.g. http://identi.ca), your
-username and password on that laconi.ca instance (e.g. jontheniceguy and p@$$w0rd) and your mobile number in the format
-441234567890, where 44 is your country code and the number is your mobile number. You can, alternatively, copy or link
-the ui.php and config.php to somewhere on your web service and visit the ui.php file. Add your details there.
-7. Send an SMS from your current phone to your old phone and watch the scripts running text up the screen. Check your
-laconi.ca environment to see if the message was posted.
-8. If required, create a CRON task to activate the admin.php script on a regular basis. This will send you an e-mail
-containing the latest user list and the number of messages that person has sent (and processing errors with that number).
+3. Configure your Ser2Net to talk to your mobile phone. Confirm it works by telnetting to
+the port you've designated for your mobile phone and send the command "AT" (no quotes)
+and wait for a response OK. If you get nothing, then contact me for some (VERY) limited
+support.
+4. Test whether your phone talks SMS-TEXT or SMS-PDU with the AT command "AT+CMGF=1". If
+it replies OK, then it talks SMS-TEXT, if it replies ERROR, then it only talks SMS-PDU.
+You'll need to know this for the next step.
+5. Edit config.php with at least enough information for the scripts to talk to your MySQL
+server and Ser2Net instance.
+6. Run run_scripts.sh
+7. Copy or link the ui.php and config.php to somewhere on your web service and visit the
+ui.php file.
+8. Send an SMS from your current phone to your old phone and watch the scripts running
+text up the screen. Check your laconi.ca environment to see if the message was posted.
+9. If required, create a CRON task to activate the admin.php script on a regular basis.
+This will send you an e-mail containing the latest user list and the number of messages
+that person has sent (and processing errors with that number).
-Any comments or questions, please contact me by e-mail, find me on irc as JonTheNiceGuy on the FreeNode network (not
-often really!), or send me a dent at http://identi.ca/jontheniceguy.
+Any comments or questions, please contact me by e-mail, find me on irc as JonTheNiceGuy
+on the FreeNode network (not often really!), or send me a dent at
+http://identi.ca/jontheniceguy.
Your best bet is to communicate with me by e-mail.
Modified: smsToLaconica/branches/0.6/UPGRADE.txt
===================================================================
--- smsToLaconica/branches/0.6/UPGRADE.txt 2008-11-04 19:24:15 UTC (rev 62)
+++ smsToLaconica/branches/0.6/UPGRADE.txt 2008-11-05 00:44:39 UTC (rev 63)
@@ -2,7 +2,9 @@
<=0.5.1 >=0.6
-Practically all the filenames have changed, and there are database changes need to be made. Lastly, the phone number is no longer MD5'd, as this prevents sending SMS messages (should that be desired).
+Practically all the filenames have changed, and there are major database changes need to
+be made. Lastly, the phone number is no longer MD5'd, as this prevents sending SMS
+messages (should that be desired).
<=0.5 to >=0.5.1
@@ -10,4 +12,4 @@
Please use the following sql statement;
-ALTER TABLE `users` ADD `posts` INT NOT NULL DEFAULT '0';
\ No newline at end of file
+ALTER TABLE `users` ADD `posts` INT NOT NULL DEFAULT '0';
Added: smsToLaconica/branches/0.6/lib_openid.php
===================================================================
--- smsToLaconica/branches/0.6/lib_openid.php (rev 0)
+++ smsToLaconica/branches/0.6/lib_openid.php 2008-11-05 00:44:39 UTC (rev 63)
@@ -0,0 +1,80 @@
+<?php
+
+// This function is tested with the code obtained from
+// http://www.stevelove.org/2008/08/how-to-wordpresscom-and-the-simple-openid-php-class/
+// Using the Yadis library, as referenced from
+// http://www.stevelove.org/2008/08/how-to-yahoo-and-the-simple-openid-php-class/
+// The code here is taken from the original example file at
+// http://www.phpclasses.org/browse/package/3290.html
+// with a load of tweaks.
+require_once('class.openid.php');
+
+function OpenID_Auth($site_url='', $req_flds=array('email', 'fullname')) {
+ if($site_url=='') {
+ if($_SERVER['HTTPS']!='') {
+ $site_url="https://";
+ if($_SERVER['SERVER_PORT']!=443) {$off_port=TRUE;}
+ } else {
+ $site_url="http://";
+ if($_SERVER['SERVER_PORT']!=80) {$off_port=TRUE;}
+ }
+ $site_url.=$_SERVER['SERVER_NAME'];
+ if($off_port==TRUE) {$site_url.=':' . $_SERVER['SERVER_PORT'];}
+ if(strstr($_SERVER['REQUEST_URI'], '?')) {
+ $request_url=substr($_SERVER['REQUEST_URI'],0,strpos($_SERVER['REQUEST_URI'], '?'));
+ }
+ $site_url.=$request_url;
+ }
+ if ($_POST['openid_action'] == "login"){ // Get identity from user and redirect browser to OpenID Server
+ $openid = new SimpleOpenID;
+ $openid->SetIdentity($_POST['openid_url']);
+ $openid->SetTrustRoot($site_url);
+ $openid->SetRequiredFields($req_flds);
+ if ($openid->GetOpenIDServer()){
+ $openid->SetApprovedURL($site_url);
+ $openid->Redirect();
+ }else{
+ $error = $openid->GetError();
+ $err_data="ERROR CODE: " . $error['code'] . "<br>";
+ $err_data.="ERROR DESCRIPTION: " . $error['description'] . "<br>";
+ }
+ } else if($_GET['openid_mode'] == 'id_res') {
+ $openid = new SimpleOpenID;
+ $openid->SetIdentity($_GET['openid_identity']);
+ $openid_validation_result = $openid->ValidateWithServer();
+ if ($openid_validation_result == true){
+ if(session_id()=="") {session_start();}
+ $_SESSION['valid']=TRUE;
+ $_SESSION['openid_identity']=$openid_db_safe = $openid->OpenID_Standarize($_GET['openid_identity']);
+ foreach(array('email','fullname','dob','gender','postcode','country','language','timezone') as $var) {
+ if(isset($_GET['openid_sreg_' . $var])) {
+ $_SESSION['openid_sreg_' . $var]=$_GET['openid_sreg_' . $var];
+ }
+ }
+ header("Location: $site_url");
+ } else if($openid->IsError() == true){
+ $error = $openid->GetError();
+ $err_data="ERROR CODE: " . $error['code'] . "<br>";
+ $err_data.="ERROR DESCRIPTION: " . $error['description'] . "<br>";
+ }else{
+ $err_data="INVALID AUTHORIZATION";
+ }
+ }else if ($_GET['openid_mode'] == 'cancel'){
+ $err_data="USER CANCELED REQUEST";
+ }
+ return($err_data);
+}
+
+function login_form() {
+return '<div>
+<fieldset id="openid">
+<legend>OpenID Login</legend>
+<form method="post" onsubmit="this.login.disabled=true;">
+<input type="hidden" name="openid_action" value="login">
+<div><input type="text" name="openid_url" class="openid_login"><input type="submit" name="login" value="login >>"></div>
+<div><a href="http://www.myopenid.com/" class="link" >Get an OpenID</a></div>
+</form>
+</fieldset>
+</div>';
+}
+?>
\ No newline at end of file
Added: smsToLaconica/branches/0.6/web_index.php
===================================================================
--- smsToLaconica/branches/0.6/web_index.php (rev 0)
+++ smsToLaconica/branches/0.6/web_index.php 2008-11-05 00:44:39 UTC (rev 63)
@@ -0,0 +1,52 @@
+<?
+require_once('config.php');
+require_once('lib_openid.php');
+require_once('lib_' . $phone['data_type'] . '.php');
+
+session_start();
+if($_SESSION['valid']==TRUE) {
+ if($_GET['logout']==TRUE) {
+ // This code from http://uk.php.net/manual/en/function.session-destroy.php
+ $_SESSION = array();
+ if (isset($_COOKIE[session_name()])) {setcookie(session_name(), '', time()-42000, '/');}
+ session_destroy();
+ if($site_url=='') {
+ if($_SERVER['HTTPS']!='') {
+ $site_url="https://";
+ if($_SERVER['SERVER_PORT']!=443) {$off_port=TRUE;}
+ } else {
+ $site_url="http://";
+ if($_SERVER['SERVER_PORT']!=80) {$off_port=TRUE;}
+ }
+ $site_url.=$_SERVER['SERVER_NAME'];
+ if($off_port==TRUE) {$site_url.=':' . $_SERVER['SERVER_PORT'];}
+ if(strstr($_SERVER['REQUEST_URI'], '?')) {
+ $request_url=substr($_SERVER['REQUEST_URI'],0,strpos($_SERVER['REQUEST_URI'], '?'));
+ }
+ $site_url.=$request_url;
+ header("Location: $site_url");
+ }
+ require_once("lib_debug.php");
+ d_mysql_connect();
+ $user_exist=d_mysql_query("SELECT user_id FROM users WHERE openid_identity='{$_SESSION['openid_identity']}'");
+ if(d_mysql_num_rows($user_exist)>0) {
+ list($user_id)=d_mysql_fetch_array($user_exist);
+ d_mysql_query("UPDATE users SET last_logged_in=NOW WHERE user_id='$user_id'");
+ } else {
+ d_mysql_query("INSERT INTO users (openid_identity, user_name, user_mail) VALUES ('{$_SESSION['openid_identity']}, {$_SESSION['fullname']}, {$_SESSION['email']}')");
+ $user_exist=d_mysql_query("SELECT user_id FROM users WHERE openid_identity='{$_SESSION['openid_identity']}'");
+ list($user_id)=d_mysql_fetch_array($user_exist);
+ }
+ // We can now start doing stuff with the account :)
+} else {
+ $err_data=OpenID_Auth(); // This script may return error data or it may send a header line. Either way, if we get past here, we need to render the page :)
+ echo "<html><head><title>smsToLaconica</title></head>";
+ echo "<body>" . login_form() . $err_data;
+ echo "<p>What is smsToLaconica?</p>";
+ echo "<p>smsToLaconica is a set of scripts which allow you to send text messages to update any twitter-like API, for example, Twitter, Identi.ca, etc. Log in to start sending!<br><br>";
+ if($functions['send']==TRUE) {
+ echo" This system may also be configured to send you SMS messages when you receive a reply or a directed message. These settings will be displayed on a further screen once you have logged in.";
+ }
+ echo "</p>";
+ echo "</body></html>";
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jon...@us...> - 2008-11-04 19:24:21
|
Revision: 62
http://laconicatools.svn.sourceforge.net/laconicatools/?rev=62&view=rev
Author: jontheniceguy
Date: 2008-11-04 19:24:15 +0000 (Tue, 04 Nov 2008)
Log Message:
-----------
Moved standard footer into config, completed admin e-mail tool (although not tested), adjusted runscript and copied some changes into daemon_database.php
Modified Paths:
--------------
smsToLaconica/branches/0.6/daemon_database.php
smsToLaconica/branches/0.6/default_config.php
smsToLaconica/branches/0.6/mail_admin.php
smsToLaconica/branches/0.6/run_scripts.sh
Modified: smsToLaconica/branches/0.6/daemon_database.php
===================================================================
--- smsToLaconica/branches/0.6/daemon_database.php 2008-11-04 08:45:40 UTC (rev 61)
+++ smsToLaconica/branches/0.6/daemon_database.php 2008-11-04 19:24:15 UTC (rev 62)
@@ -59,7 +59,7 @@
d_mysql_query($sql);
break;
case FALSE:
- $sql="INSERT INTO errors (time_in, message, error_text) VALUES (NOW(), 'From user_id: $user_id message: " . mysql_real_escape_string($message) . "', 'No response from the server " . mysql_real_escape_string($base_url) . "')";
+ $sql="INSERT INTO errors (time_in, user_id, message, error_text) VALUES (NOW(), '$user_id', '" . mysql_real_escape_string($message) . "', 'No response from the server " . mysql_real_escape_string($base_url) . "')";
d_mysql_query($sql);
$sql="UPDATE queue_in SET time_last='" . date("Y-m-d H:i:s", strtotime("+5 minutes")) . "' where in_id='$in_id'";
d_mysql_query($sql);
@@ -67,7 +67,7 @@
default:
$sql="DELETE FROM queue_in WHERE in_id='$in_id';";
d_mysql_query($sql);
- $sql="INSERT INTO errors (time_in, message, error_text) VALUES (NOW(), 'From user_id: $user_id message: " . mysql_real_escape_string($message) . "', 'Server: " . mysql_real_escape_string($base_url) . " Responds: " . mysql_real_escape_string($buffer) . "')";
+ $sql="INSERT INTO errors (time_in, user_id, message, error_text) VALUES (NOW(), '$user_id, '" . mysql_real_escape_string($message) . "', 'Server: " . mysql_real_escape_string($base_url) . " Responds: " . mysql_real_escape_string($buffer) . "')";
d_mysql_query($sql);
send_alert_mail($user_id, "Status could not be updated", "Unfortunately, your message ($message) could not be sent to $base_url as we received an error message. Please can you review your settings at the below URL to resolve this issue.");
}
@@ -84,7 +84,7 @@
$sql="DELETE FROM queue_in WHERE in_id='$in_id';";
d_mysql_query($sql);
} else {
- $sql="INSERT INTO errors (time_in, message, error_text) VALUES (NOW(), 'From number: $phone_number message: " . mysql_real_escape_string($message) . "', 'No such user')";
+ $sql="INSERT INTO errors (time_in, user_number, message, error_text) VALUES (NOW(), '" . mysql_real_escape_string($phone_number) . "', '" . mysql_real_escape_string($message) . "', 'No such user')";
d_mysql_query($sql);
$sql="DELETE FROM queue_in WHERE in_id='$in_id';";
d_mysql_query($sql);
@@ -101,13 +101,13 @@
$qry=d_mysql_query($sql);
if(d_mysql_num_rows($qry)>0) {
while(list($user_name, $user_mail)=d_mysql_fetch_array($qry)) {
- $headers = 'MIME-Version: 1.0' . "\r\n" .
- 'Content-type: text/html; charset=iso-8859-1' . "\r\n" .
- 'From: ' . $ui['system_mail'] . "\r\n" .
+ $headers = "MIME-Version: 1.0\r\n" .
+ "Content-type: text/html; charset=iso-8859-1\r\n" .
+ "From: smsToLaconica Service <{$email['from_address']}>\r\n" .
"To: $user_name <$user_mail>\r\n" .
- 'Reply-To: ' . $ui['system_mail'] . "\r\n" .
+ "Reply-To: {$ui['system_mail']}\r\n" .
'X-Mailer: PHP/' . phpversion();
- $message = "<html><head>$title</head><body><p>$message</p><p>This gateway is brought to you by <a href=\"{$ui['owner_url']}\">{$ui['owner']}</a> and runs the smsToLaconica gateway software, version {$ui['version']}, which is available under the GNU Affero General Public License from <a href=\"{$ui['source_url']}\">{$ui['source']}</a></p></body></html>";
+ $message = "<html><head>$title</head><body><p>$message</p>{$ui['standard_footer']}</body></html>";
debug("Mail sent to $user_mail: $headers\r\n$message", "Verbose");
mail($user_mail, $title, $message, $headers);
}
Modified: smsToLaconica/branches/0.6/default_config.php
===================================================================
--- smsToLaconica/branches/0.6/default_config.php 2008-11-04 08:45:40 UTC (rev 61)
+++ smsToLaconica/branches/0.6/default_config.php 2008-11-04 19:24:15 UTC (rev 62)
@@ -48,6 +48,8 @@
'number'=>'+441234567890', // and the number to which your users will send their SMS.
'message_source'=>'smsToLaconica'); // This is used when posting messages to twitter-like APIs.
+$ui['standard_footer']="<p>This gateway is brought to you by <a href=\"{$ui['owner_url']}\">{$ui['owner']}</a> and runs the smsToLaconica gateway software, version {$ui['version']}, which is available under the GNU Affero General Public License from <a href=\"{$ui['source_url']}\">{$ui['source']}</a></p>";
+
$phone=array('init'=>array("AT"), // These commands are sent to the phone when initialized
'data_type'=>'text',
'host'=>'127.0.0.1',
Modified: smsToLaconica/branches/0.6/mail_admin.php
===================================================================
--- smsToLaconica/branches/0.6/mail_admin.php 2008-11-04 08:45:40 UTC (rev 61)
+++ smsToLaconica/branches/0.6/mail_admin.php 2008-11-04 19:24:15 UTC (rev 62)
@@ -1,67 +1,112 @@
<?php
-$mail="<html><body><h1>SMS -> Laconi.ca Bridge - Admin Information</h1>";
// This code is released under the AGPL (V.3 or later)
// Author: Jon Spriggs (jo...@sp...)
// Version: 0.5.1
// SVN Version: $Rev$ on $Date$ last updated by $Author$
-include_once("config.php");
+require_once("config.php");
+require_once("lib_debug.php");
-if(!isset($db)) {$db=array('host'=>'localhost', 'user'=>'smsToLaconica', 'pass'=>'smsToLaconica', 'base'=>'smsToLaconica');}
-if(!isset($debug)) {$debug=array('enabled'=>FALSE, 'output_to_screen'=>FALSE, 'output_to_file'=>FALSE, 'output_file'=>'/var/log/sms_to_laconica.log', 'verbose'=>FALSE);}
-if(!isset($ui)) {$ui=array('owner'=>'YOUR NAME HERE', 'owner_url'=>'http://YOUR.OWN.WEBSITE', 'version'=>'0.6', 'source'=>'LaconicaTools', 'source_url'=>'http://laconicatools.sf.net', 'number'=>'Not yet set! Please contact the administrator of this service before use!');}
-if(!isset($email)) {$email=array('send_admin_mail'=>FALSE, 'to_address'=>'sms...@te...', 'from_name'=>'smsToLaconica Service', 'from_address'=>'sms...@YO...');}
+dump_config();
+d_mysql_connect();
-mysql_connect($db['host'], $db['user'], $db['pass']) or die("Can't connect to the Database Server");
-mysql_select_db($db['base']) or die("Can't select the Database");
+$users_qry=d_mysql_query("SELECT * FROM users");
+while($user_ary=d_mysql_fetch_array($users_qry)) {
+ $users[$user_ary['user_id']]=$user_ary;
+}
-$base_url_qry=mysql_query("SELECT base_url FROM users GROUP BY base_url");
-if(mysql_num_rows($base_url_qry)>0) {
- $mail.="<h1>User list</h1>";
- $mail.="<table width=100%><tr><th>Laconi.ca Instance<br>(Authenticated/Code Allocated)</th><th>Users - Authenticated<br>(In/Out)</th><th>Users - Code Allocated</th></tr>";
- while(list($base_url)=mysql_fetch_array($base_url_qry)) {
- $auth_users_qry=mysql_query("SELECT username, number, posts_out, posts_in FROM users WHERE base_url like '$base_url' AND number!=''");
- $code_users_qry=mysql_query("SELECT username FROM users WHERE base_url like '$base_url' AND code!=''");
- $mail.="<tr><td valign=center>$base_url (" . mysql_num_rows($auth_users_qry) . "/" . mysql_num_rows($code_users_qry) . ")</td><td valign=center>";
- $counter=0;
- while(list($username, $number, $posts)=mysql_fetch_array($auth_users_qry)) {
- $counter++;
- list($errs)=mysql_fetch_array(mysql_query("SELECT count(id) FROM mq WHERE `from`='$number' AND `date`<`queue_action`"));
- if($counter>1) {$mail.="<br>";}
- if($errs<1) {$errs=0;}
- if($posts<1) {$posts=0;}
- $mail.=htmlentities($username) . " ($posts/$errs)";
- }
- $mail.="</td><td valign=center>";
- $counter=0;
- while(list($username)=mysql_fetch_array($code_users_qry)) {
- $counter++;
- if($counter>1) {$mail.="<br>";}
- $mail.=htmlentities($username, ENT_QUOTES);
- }
- $mail.="</td></tr>";
+$update_service_qry=d_mysql_query("SELECT * FROM users_update_service GROUP BY base_url");
+while($update_service=d_mysql_fetch_array($update_service_qry)) {
+ $users[$update_service['user_id']]['feed'][]=$update_service;
+}
+
+$errors_qry=d_mysql_query("SELECT * FROM errors WHERE (acknowledged=0 AND user_id='') OR user_id<>''");
+while($errors_ary=d_mysql_fetch_array($errors_qry)) {
+ if($errors_ary['user_id']!='') {
+ $users[$errors_ary['user_id']]['errors'][]=$errors_ary;
+ } else {
+ $errors[]=$errors_ary;
}
- $mail.="</table>";
}
-$mq_no_rx_qry=mysql_query("SELECT mq.id, mq.`date`, mq.`from`, mq.`msg` FROM mq LEFT JOIN users ON mq.`from` = users.`number` WHERE users.`username` IS NULL");
-if(mysql_num_rows($mq_no_rx_qry)>0) {
- $mail.="<h1>Messages with no user</h1>";
- $mail.="<table width=100%><tr><th>Date</th><th>From</th><th>Message</th></tr>";
- while(list($id, $date, $from, $msg)=mysql_fetch_array($mq_no_rx_qry)) {
- $mail.="<tr><td>" . htmlentities($date) . "</td><td>" . htmlentities($from) . "</td><td>" . htmlentities($msg) . "</td></tr>";
+$status_qry=d_mysql_query("SELECT * FROM service_status");
+while($status_ary=d_mysql_fetch_array($status_qry)) {
+ $status[$status_ary['service_name']]=$status_ary['last_run'];
+}
+
+$mail="<html><body>";
+// This below code snippet is adapted from http://www.randomsnippets.com/2008/02/12/how-to-hide-and-show-your-div/
+$mail.="<script language=\"javascript\">
+function toggle(showHideDiv, switchTextDiv) {
+ var ele = document.getElementById(showHideDiv);
+ var text = document.getElementById(switchTextDiv);
+ if(ele.style.display == \"block\") {
+ ele.style.display = \"none\";
+ text.innerHTML = \"Show Details\";
}
+ else {
+ ele.style.display = \"block\";
+ text.innerHTML = \"Hide Details\";
+ }
+}
+</script>";
+$mail.="<p align=center>smsToLaconica - Admin Information</p>";
+
+$mail.="<p>Service Status:</p>";
+$back5=strtotime("-5 minutes");
+if(count($status)>0) {
+ $stat_head="";
+ $stat_line="";
+ foreach($status as $stat_name=>$stat) {
+ $stat_head.="<th>$stat_name</th>";
+ if(strtotime($stat)<$back5) {$state="Down since $stat";} else {$state="Up at $stat";}
+ $stat_line.="<td>$state</td>";
+ }
+ $mail.="<table><tr>$stat_head</tr><tr>$stat_line</tr></table>";
+}
+
+$mail.="<p>There are " . count($users) . " users on the service.</p>";
+if(count($users)>0) {
+ $mail.="<table><tr><th>Username</th><th>Posts Out</th><th>Posts In (Errors)</th><th>Feeds</th></tr>";
+ foreach($users as $user_id=>$user) {
+ $mail.="<tr><td>" . htmlentities($user['user_name'], ENT_QUOTES);
+ if($user['user_number']=='') {
+ $mail.="(unconfirmed)</td><td>N/A</td><td>N/A (N/A)</td><td> </td></tr>";
+ } else {
+ $mail.="</td><td>{$user['messages_sent']}</td><td>{$user['messages_received']} ('" . count($user['errors']) . " ";
+ if(count($user['errors'])>0) {
+ $mail.="- <a id='error_{$user_id}' href=\"javascript:toggle('error_detail_{$user_id}','error_{$user_id}');\">Show Details</a><div id='error_detail_{$user_id}'>";
+ foreach($user['errors'] as $error) {
+ $mail.="<i>" . htmlentities($error['message'], ENT_QUOTES) . "</i><b>" . htmlentities($error['error_text'], ENT_QUOTES) . "</b><br>";
+ }
+ $mail.="</div>";
+ }
+ $mail.=")</td><td>" . count($user['feed']) . " ";
+ if(count($user['feed'])>0) {
+ $mail.="- <a id='feed_{$user_id}' href=\"javascript:toggle('feed_detail_{$user_id}','feed_{$user_id}');\" >Show Details</a><div id='feed_detail_{$user_id}'>";
+ foreach($user['feed'] as $feed) {
+ $mail.=htmlentities($feed['base_url'] . "/" . htmlentities($feed['username']), ENT_QUOTES) . "<br>";
+ }
+ $mail.="</div>";
+ }
+ $mail.="</td></tr>";
+ }
+ }
$mail.="</table>";
}
-$mail.='<p>This gateway is brought to you by <a href="' . $ui['owner_url'] . '">' . $ui['owner'] . '</a> and runs the smsToLaconica gateway software, version '. $ui['version'] .', which is available under the GNU Affero General Public License from <a href="' . $ui['source_url'] . '">' . $ui['source'] . '</a></p></body></html>';
-
+$mail.=$ui['standard_footer'] . '</body></html>';
if(!$email['send_admin_mail']==FALSE) {
// HTML Posting Information derived from http://www.sitepoint.com/article/advanced-email-php/
- mail($email['to_address'], 'smsToLaconica Report for ' . date('Y-m-d'), $mail, 'From: ' . $email['from_name'] . '<' . $email['from_address'] . ">\nMIME-Version: 1.0\nContent-type: text/html; charset=iso-8859-1");
+ $headers = 'MIME-Version: 1.0' . "\r\n" .
+ 'Content-type: text/html; charset=iso-8859-1' . "\r\n" .
+ "From: smsToLaconica Service <{$email['from_address']}>\r\n" .
+ "To: smsToLaconica Admin <{$email['to_address']}>\r\n" .
+ "Reply-To: {$email['to_address']}\r\n" .
+ 'X-Mailer: PHP/' . phpversion();
+ mail($email['to_address'], 'smsToLaconica Report for ' . date('Y-m-d'), $mail, $headers);
} else {
echo "From: " . $email['from_name'] . '<' . $email['from_address'] . ">\r\nTo: " . $email['to_address']. "\r\nSubject: smsToLaconica Report for " . date('Y-m-d') . "\r\n" . $mail;
-
}
?>
\ No newline at end of file
Modified: smsToLaconica/branches/0.6/run_scripts.sh
===================================================================
--- smsToLaconica/branches/0.6/run_scripts.sh 2008-11-04 08:45:40 UTC (rev 61)
+++ smsToLaconica/branches/0.6/run_scripts.sh 2008-11-04 19:24:15 UTC (rev 62)
@@ -1,6 +1,16 @@
#!/bin/sh
-#This very rough! file is from version 0.5.1 of the smsToLaconica scripts.
-#SVN Version: $Rev$ on $Date$ last updated by $Author$
+# This code is released under the AGPL (V.3 or later)
+# Author: Jon Spriggs (jo...@sp...)
+# Version: 0.6
+# SVN Version: $Rev$ on $Date$ last updated by $Author$
+#
+# This script only starts smsToLaconica, it does not stop it. If you need proper init.d scripts, please either author them yourself or get someone to author them and contribute them back into the project.
+echo -n Starting smsToLaconica:
+echo -n daemon_modem:
nohup php -q daemon_modem.php >/dev/null &
+echo -n Done. daemon_database:
nohup php -q daemon_database.php >/dev/null &
+echo -n Done. daemon_feed:
+nohup php -q daemon_feed.php >/dev/null &
+echo -n Done. [Finished]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|