From a64d56c0f6f525b26fd665d7ce5cb211123f70bc Mon Sep 17 00:00:00 2001 From: akrherz Date: Mon, 19 Sep 2022 12:08:09 -0500 Subject: [PATCH] sundry review --- README.md | 7 ++- html/facebook.php | 114 ---------------------------------------------- html/index.php | 1 - html/p.php | 15 +++--- 4 files changed, 12 insertions(+), 125 deletions(-) delete mode 100644 html/facebook.php diff --git a/README.md b/README.md index 97aa4f0..fc997d6 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ -This is a collection of stuff driving the http://weather.im website +Weather.IM +========== + +This is a collection of stuff driving the [weather.im website](https://weather.im). This website is playground of Iowa Environmental Mesonet related weather + -instant messaging apps \ No newline at end of file +instant messaging apps. diff --git a/html/facebook.php b/html/facebook.php deleted file mode 100644 index 433aa5b..0000000 --- a/html/facebook.php +++ /dev/null @@ -1,114 +0,0 @@ -require_login(); } - -$has_permission = $facebook->api_client->users_hasAppPermission("publish_stream"); - - - -include("$rootpath/include/wfo_locs.php"); -$postgis = pg_connect("dbname=postgis"); -$rs = pg_prepare($postgis, "QUERYFOR", "SELECT * from - iemface_user_subscriptions WHERE userid = $1"); -$rs = pg_prepare($postgis, "DELETEALL", "DELETE from - iemface_user_subscriptions WHERE userid = $1"); -$rs = pg_prepare($postgis, "INSERT", "INSERT into - iemface_user_subscriptions(userid, channel) VALUES ($1,$2)"); -$rs = pg_prepare($postgis, "SELECTUSER", "SELECT * from - iemface_user_details WHERe userid = $1"); -$rs = pg_prepare($postgis, "INSERTUSER", "INSERT into - iemface_user_details(userid) VALUES($1)"); - -/* Look for our user*/ -$rs = pg_execute($postgis, "SELECTUSER", Array($user_id)); -if (pg_num_rows($rs) == 0){ - pg_execute($postgis, "INSERTUSER", Array($user_id)); -} - -$attachment = Array( - 'name' => 'Weather.IM', - 'href' => "http://weather.im/facebook.php", - 'caption' => 'caption', - 'description' => 'Feature Image', - 'media' => array(array('type' => 'image', - 'src' => "http://weather.im/img/bender.jpg", - 'href' => "http://weather.im/facebook.php")), -); -$action_links = array( - array('text' => 'Permalink', - 'href' => "http://weather.im/facebook.php")); - - -if (isset($_REQUEST["do"])){ - pg_execute($postgis, "DELETEALL", Array($user_id)); - - if (isset($_REQUEST["channels"])){ - $msg = "I subscribed to Forecast Discussion's from offices: "; - while( list($idx,$channel) = each($_REQUEST["channels"])){ - pg_execute($postgis, "INSERT", Array($user_id, $channel)); - $msg .= " [$channel], "; - } - if(!$has_permission){ - //echo "
Allow Posts on your wall!!"; - header("Location: http://www.facebook.com/authorize.php?api_key=${facebook_appapikey}&v=1.0&ext_perm=publish_stream"); - } else { - $facebook->api_client->stream_publish($msg,$attachment, - $action_links,$user_id,$user_id); - } - } -} - -$subscriptions = Array(); -$rs = pg_execute($postgis, "QUERYFOR", Array($user_id)); -for($i=0;$row=@pg_fetch_array($rs,$i);$i++){ - $subscriptions[ $row["channel"] ] = True; -} - -include("$rootpath/include/header.php"); -?> -

Weather.IM Facebook Gateway

- -
This application is a demonstration prototype of the -automated and configurable relay of a NWS Text Product to Facebook.
- -

Hello Facebook User! You can configure this form to allow me to post -notifications to your faceback immediately when your favorite National -Weather Service forecast issues an Area Forecast Discussion.

- -
-
- -%s - %s
\n", - $key, (array_key_exists("AFD$key",$subscriptions) ? "CHECKED": ""), - $key, $val["city"]); - $cntr += 1; - if ($cntr % 50 == 0){ echo "
\n";} -} -?> -
- -

-

- diff --git a/html/index.php b/html/index.php index 270f430..e077b82 100644 --- a/html/index.php +++ b/html/index.php @@ -29,4 +29,3 @@ EOF; $t->render('single.phtml'); -?> \ No newline at end of file diff --git a/html/p.php b/html/p.php index 77c4551..8335f80 100644 --- a/html/p.php +++ b/html/p.php @@ -18,21 +18,20 @@ WHERE pil = $1 and entered between $2 and $3 ORDER by entered ASC LIMIT 100"); $ts = gmmktime( substr($e,8,2), substr($e,10,2), 0, - substr($e,4,2), substr($e,6,2), substr($e,0,4) ); + substr($e,4,2), substr($e,6,2), substr($e,0,4) ); $offset0 = 0; $offset1 = 60; $rs = pg_execute($pgconn, "_LSELECT", Array($pil, - date("Y-m-d H:i", $ts+$offset0), - date("Y-m-d H:i", $ts+$offset1))); + date("Y-m-d H:i", $ts+$offset0), + date("Y-m-d H:i", $ts+$offset1))); if (pg_numrows($rs) < 1){ - echo "
Sorry, could not find product.
"; + echo "
Sorry, could not find product.
"; } else{ - $row = pg_fetch_assoc($rs, 0); - $d = preg_replace("/\r\r\n/", "\n", $row["data"]); - echo "
". htmlentities($d) ."
\n"; + $row = pg_fetch_assoc($rs, 0); + $d = preg_replace("/\r\r\n/", "\n", $row["data"]); + echo "
". htmlentities($d) ."
\n"; } } -?>