posted 14 Nov 2010 12:43 by Slippy Lane
#!/bin/bash
# x10receiver # A looping BASH script to receive and process x10 RF Remote commands
# *** REQUIREMENTS *** # CM12U (for UK users) or CM11x (where x is the appropriate letter code for your country's version of the CM11) # A built and installed copy of heyu (available at http://www.heyu.org) # A linux PC running BASH
# *** NOTES *** # This is a quick'n'dirty script, badly coded but it works for me. # You'll need to edit it for your system and heyu setup before it'll work properly
echo "$0 running..." heyu stop heyu start lfile=$HOME/lfile.dat housecode="X" unitcode="0" fn="None" while true; do heyu logtail 2 > $lfile counter=1 while read line do if [ $counter = 1 ]; then line1=$line counter=2 elif [ $counter = 2 ]; then line2=$line counter=0 fi done < "$lfile" # echo # echo "***BEGIN***" # echo $line1 # echo $line2 # echo "-${line1:16:14}-" if [ "${line2:16:9}" = "rcvi func" ]; then if [ "${line1:16:14}" = "rcvi addr unit" ]; then line1=${line1:15} # echo $line1 heyu logmsg "Checked1" lineidx=`expr index "$line1" ':'` lineidx2=$(($lineidx+4)) lineidx3=$(($lineidx+5)) lineidx1a=`expr index "$line1" '^('` lineidx1=$(($lineidx1a - 2)) # echo $lineidx $lineidx1 $lineidx1a $lineidx2 $lineidx3 lasthousecode=$housecode lastunitcode=$unitcode housecode=${line1:$lineidx2:1} unitcode=${line1:$lineidx3:$(($lineidx1 - $lineidx3))} # echo "/${line2:16:9}/" fi line2=${line2:15} heyu logmsg "Checked2" lineidx4=`expr index "$line2" ':'` lineidx5=20 lineidx6=$(($lineidx4-22)) fn=${line2:$lineidx5:$lineidx6} echo echo "[FN: $fn]" echo "[HC: $housecode (prev: $lasthousecode)]" echo "[UC: $unitcode (prev: $lastunitcode)]"
# read dummy
if [ "$fn" = " On" ]; then fn="on" elif [ "$fn" = "Off" ]; then fn="off" elif [ "$fn" = "ght" ]; then fn="bright" elif [ "$fn" = "Dim" ]; then fn="dim" fi
if [ "$housecode" = "A" ]; then if [ $unitcode = 9 ]; then if [ "$fn" = "on" ]; then heyu on A1 elif [ "$fn" = "off" ]; then heyu off A1 elif [ "$fn" = "bright" ]; then heyu off A1 sleep 5 heyu on A1 elif [ "$fn" = "dim" ]; then heyu off A1 sleep 60 heyu on A1 fi elif [ $unitcode = 12 ]; then if [ "$fn" = "on" ]; then zenity --info --text="9: router\n9 Bright: short reset router\n9 Dim: long reset router\n10: hall light\n11: living room light\n12 On: This help\n12 Off: gscripts\n13 On: transmission\n13 Off: terminal\n14 On: calculator\n14 Off: nautilus\n15 On: chrome\n15 Off: gedit\n16 On: A1,2,3 on\n16 Off: A1,2,3 off" & elif [ "$fn" = "off" ]; then gscripts & fi elif [ $unitcode = 13 ]; then if [ "$fn" = "on" ]; then transmission & elif [ "$fn" = "off" ]; then gnome-terminal & fi elif [ $unitcode = 14 ]; then if [ "$fn" = "on" ]; then gnome-calculator & elif [ "$fn" = "off" ]; then nautilus & fi elif [ $unitcode = 15 ]; then if [ "$fn" = "on" ]; then google-chrome & elif [ "$fn" = "off" ]; then gedit & fi elif [ $unitcode = 16 ]; then if [ "$fn" = "on" ]; then heyu $fn A1 heyu $fn A2 heyu $fn A3 elif [ "$fn" = "off" ]; then heyu $fn A1 heyu $fn A2 heyu $fn A3 elif [ "$fn" = "bright" ]; then heyu $fn A2 2 heyu $fn A3 2 elif [ "$fn" = "dim" ]; then heyu $fn A2 2 heyu $fn A3 2 fi else if [ "$fn" = "on" ]; then heyu $fn $housecode$(($unitcode-8)) elif [ "$fn" = "off" ]; then heyu $fn $housecode$(($unitcode-8)) elif [ "$fn" = "bright" ]; then heyu $fn $housecode$(($unitcode-8)) 2 elif [ "$fn" = "dim" ]; then heyu $fn $housecode$(($unitcode-8)) 2 fi fi fi fi done
|
posted 11 Oct 2009 16:30 by Slippy Lane
[
updated 13 Oct 2009 01:54
]
#!/bin/bash echo "Checking for Abe's presence on the network..."
result=`ping -c 1 192.168.2.2 | grep "1 received"` if [ -z "$result" ]; then echo "Switching Abe on..." switchon 0 # sends command to close output 0 on the K8055 interface board switchoff 0 # opens the output switch again. echo "Done. Waiting for network response from Abe..." while [ -z "$result" ]; do result=`ping -c 1 192.168.2.2 | grep "1 received"` done echo "Network response received." else echo "Abe is already powered up." fi
echo "Mounting remote drive..." if [ ! -d "/$HOME/abe" ]; then mkdir "/$HOME/abe" fi
if [ ! -e "/$HOME/abe/index.html" ]; then sshfs $USER@192.168.2.2:/ /$HOME/abe else echo "Home folder appears to already be mounted." fi
echo "Running x2vnc..." x2vnc 192.168.2.2:0 &
|
posted 11 Oct 2009 16:14 by Slippy Lane
[
updated 12 Oct 2009 15:53
]
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html expr:dir='data:blog.languageDirection' xmlns='http://www.w3.org/1999/xhtml' xmlns:b='http://www.google.com/2005/gml/b' xmlns:data='http://www.google.com/2005/gml/data' xmlns:expr='http://www.google.com/2005/gml/expr'> <head> <b:include data='blog' name='all-head-content'/> <title><data:blog.pageTitle/></title> <b:skin><![CDATA[/* ----------------------------------------------- Blogger Template Style Name: Minima Simple II Crossover Designer: Simon "Slippy Lane" URL: www.slippylane.com Date: 21st December 2008
Based on Name: Minima Lefty Stretch Designer: Douglas Bowman / Darren Delaye URL: www.stopdesign.com Date: 14 Jul 2006 ----------------------------------------------- */
/* Variable definitions ==================== <Variable name="bgcolor" description="Page Background Color" type="color" default="#fff" value="#ffffff"> <Variable name="textcolor" description="Text Color" type="color" default="#333" value="#000000"> <Variable name="footercolor" description="Date and Footer Color" type="color" default="#555" value="#000000"> <Variable name="linkcolor" description="Link Color" type="color" default="#58a" value="#5588aa"> <Variable name="pagetitlecolor" description="Blog Title Color" type="color" default="#666" value="#000000"> <Variable name="descriptioncolor" description="Blog Description Color" type="color" default="#999" value="#000000"> <Variable name="titlecolor" description="Post Title Color" type="color" default="#c60" value="#5588aa"> <Variable name="bordercolor" description="Border Color" type="color" default="#ccc" value="#ffffff"> <Variable name="sidebarcolor" description="Sidebar Title Color" type="color" default="#999" value="#000000"> <Variable name="sidebartextcolor" description="Sidebar Text Color" type="color" default="#666" value="#000000"> <Variable name="visitedlinkcolor" description="Visited Link Color" type="color" default="#999" value="#999999"> <Variable name="bodyfont" description="Text Font" type="font" default="normal normal 100% Georgia, Serif" value="normal normal 100% Georgia, Serif"> <Variable name="headerfont" description="Sidebar Title Font" type="font" default="normal normal 78% 'Trebuchet MS',Trebuchet,Arial,Verdana,Sans-serif" value="normal normal 78% Georgia, Times, serif"> <Variable name="pagetitlefont" description="Blog Title Font" type="font" default="normal normal 200% Georgia, Serif" value="normal bold 200% Georgia, Serif"> <Variable name="descriptionfont" description="Blog Description Font" type="font" default="normal normal 78% 'Trebuchet MS', Trebuchet, Arial, Verdana, Sans-serif" value="normal normal 78% Georgia, Times, serif"> <Variable name="postfooterfont" description="Post Footer Font" type="font" default="normal normal 78% 'Trebuchet MS', Trebuchet, Arial, Verdana, Sans-serif" value="normal normal 78% Georgia, Times, serif"> <Variable name="startSide" description="Start side in blog language" type="automatic" default="left" value="left"> <Variable name="endSide" description="End side in blog language" type="automatic" default="right" value="right"> */
/* Use this with templates/template-twocol.html */
body { background:$bgcolor; margin:0; color:$textcolor; font:$bodyfont; } a:link { color:$linkcolor; text-decoration:none; } a:visited { color:$visitedlinkcolor; text-decoration:none; } a:hover { color:$titlecolor; text-decoration:underline; } a img { border-width:0; }
/* Header ----------------------------------------------- */
#header-wrapper { margin:0 2% 10px; }
#header-inner { margin-$startSide: auto; margin-$endSide: auto; }
#header { margin: 0px; color:$pagetitlecolor; }
#header h1 { border-bottom:dotted 1px $bordercolor; margin-bottom:0px; color: $pagetitlecolor; font: $pagetitlefont; }
#header a { color:$pagetitlecolor; text-decoration:none; }
#header a:hover { color:$pagetitlecolor; }
#header .description { margin:0px; padding: 0px; }
#header img { margin-$startSide: auto; margin-$endSide: auto; }
/* Outer-Wrapper ----------------------------------------------- */ #outer-wrapper { margin:0; padding:10px; text-align:$startSide; font: $bodyfont; }
#main-wrapper { margin-$endSide: 2%; width: 67%; float: $endSide; display: inline; /* fix for doubling margin in IE */ word-wrap: break-word; /* fix for long text breaking sidebar float in IE */ overflow: hidden; /* fix for long non-text content breaking IE sidebar float */ }
#sidebar-wrapper { margin-$startSide: 2%; width: 25%; float: $startSide; display: inline; /* fix for doubling margin in IE */ word-wrap: break-word; /* fix for long text breaking sidebar float in IE */ overflow: hidden; /* fix for long non-text content breaking IE sidebar float */ }
/* Headings ----------------------------------------------- */
h2 { padding-top:15px; color:$footercolor; padding-bottom:0px; margin-bottom:0px; font-size: 90%; }
/* Posts ----------------------------------------------- */ h2.date-header { padding-top:15px; color:$footercolor; padding-bottom:0px; margin-bottom:0px; font-size: 90%; }
.post { padding-$startSide:5%; padding-$endSide:10%; } .post h3 { font-size: 140%; color: $titlecolor; }
.post h3 a, .post h3 a:visited, .post h3 strong { display:block; text-decoration:none; color:$titlecolor; font-weight:normal; }
.post h3 strong, .post h3 a:hover { color:$textcolor; }
.post-body { margin:0 0 .75em; line-height:1.6em; }
.post-body blockquote { line-height:1.3em; }
.post-footer { color:$footercolor; }
.comment-link { margin-$startSide:.6em; } .post img { padding:4px; border:1px solid $bordercolor; } .post blockquote { margin:1em 20px; } .post blockquote p { margin:.75em 0; }
/* Comments ----------------------------------------------- */ #comments h4 { margin:1em 0; font-weight: bold; line-height: 1.4em; text-transform:uppercase; letter-spacing:.2em; color: $sidebarcolor; }
#comments-block { margin:1em 0 1.5em; line-height:1.6em; } #comments-block .comment-author { margin:.5em 0; } #comments-block .comment-body { margin:.25em 0 0; } #comments-block .comment-footer { margin:-.25em 0 2em; line-height: 1.4em; text-transform:uppercase; letter-spacing:.1em; } #comments-block .comment-body p { margin:0 0 .75em; } .deleted-comment { font-style:italic; color:gray; }
.feed-links { clear: both; line-height: 2.5em; }
#blog-pager-newer-link { float: $startSide; } #blog-pager-older-link { float: $endSide; }
#blog-pager { text-align: center; }
/* Sidebar Content ----------------------------------------------- */ .sidebar { color: $sidebartextcolor; line-height: 1.5em; }
.sidebar ul { list-style:none; margin:0 0 0; padding:0 0 0; } .sidebar li { margin:0; padding-top:0; padding-$endSide:0; padding-bottom:.25em; padding-$startSide:15px; text-indent:-15px; line-height:1.5em; }
.sidebar .widget, .main .widget { border-bottom:1px dotted $bordercolor; margin:0 0 1.5em; padding:0 0 1.5em; }
.main .Blog { border-bottom-width: 0; }
/* Profile ----------------------------------------------- */ .profile-img { float: $startSide; margin-top: 0; margin-$endSide: 5px; margin-bottom: 5px; margin-$startSide: 0; padding: 4px; border: 1px solid $bordercolor; }
.profile-data { margin:0; text-transform:uppercase; letter-spacing:.1em; font: $postfooterfont; color: $sidebarcolor; font-weight: bold; line-height: 1.6em; }
.profile-datablock { margin:.5em 0 .5em; }
.profile-textblock { margin: 0.5em 0; line-height: 1.6em; }
.profile-link { font: $postfooterfont; text-transform: uppercase; letter-spacing: .1em; }
/* Footer ----------------------------------------------- */ #footer { width:660px; clear:both; margin:0 auto; padding-top:15px; line-height: 1.6em; text-transform:uppercase; letter-spacing:.1em; text-align: center; } ]]></b:skin> </head>
<body> <div id='outer-wrapper'><div id='wrap2'>
<!-- skip links for text browsers --> <span id='skiplinks' style='display:none;'> <a href='#main'>skip to main </a> | <a href='#sidebar'>skip to sidebar</a> </span>
<div id='header-wrapper'> <b:section class='header' id='header' maxwidgets='1' showaddelement='no'> <b:widget id='Header1' locked='true' title='slippylane.com sandbox (Header)' type='Header'> <b:includable id='main'>
<b:if cond='data:useImage'> <b:if cond='data:imagePlacement == "REPLACE"'> <!--Show just the image, no text--> <div id='header-inner'> <a expr:href='data:blog.homepageUrl' style='display: block'> <img expr:alt='data:title' expr:height='data:height' expr:id='data:widget.instanceId + "_headerimg"' expr:src='data:sourceUrl' expr:width='data:width' style='display: block'/> </a> </div> <b:else/> <!-- Show image as background to text. You can't really calculate the width reliably in JS because margins are not taken into account by any of clientWidth, offsetWidth or scrollWidth, so we don't force a minimum width if the user is using shrink to fit. This results in a margin-width's worth of pixels being cropped. If the user is not using shrink to fit then we expand the header. --> <div expr:style='"background-image: url(\"" + data:sourceUrl + "\"); " + "background-position: " + data:backgroundPositionStyleStr + "; " + data:widthStyleStr + "min-height: " + data:height + "px;" + "_height: " + data:height + "px;" + "background-repeat: no-repeat; "' id='header-inner'> <div class='titlewrapper' style='background: transparent'> <h1 class='title' style='background: transparent; border-width: 0px'> <b:include name='title'/> </h1> </div> <b:include name='description'/> </div> </b:if> <b:else/> <!--No header image --> <div id='header-inner'> <div class='titlewrapper'> <h1 class='title'> <b:include name='title'/> </h1> </div> <b:include name='description'/> </div> </b:if> </b:includable> <b:includable id='title'> <b:if cond='data:blog.url == data:blog.homepageUrl'> <data:title/> <b:else/> <a expr:href='data:blog.homepageUrl'><data:title/></a> </b:if> </b:includable> <b:includable id='description'> <div class='descriptionwrapper'> <p class='description'><span><data:description/></span></p> </div> </b:includable> </b:widget> </b:section> </div> <div id='content-wrapper'>
<div id='crosscol-wrapper' style='text-align:center'> <b:section class='crosscol' id='crosscol' showaddelement='no'/> </div>
<div id='main-wrapper'> <b:section class='main' id='main' showaddelement='no'> <b:widget id='HTML2' locked='false' title='' type='HTML'> <b:includable id='main'> <!-- only display title if it's non-empty --> <b:if cond='data:title != ""'> <h2 class='title'><data:title/></h2> </b:if> <div class='widget-content'> <data:content/> </div>
<b:include name='quickedit'/> </b:includable> </b:widget> <b:widget id='Blog1' locked='true' title='Blog Posts' type='Blog'> <b:includable id='main' var='top'> <!-- posts --> <div class='blog-posts hfeed'>
<b:include data='top' name='status-message'/>
<data:adStart/> <b:loop values='data:posts' var='post'> <b:if cond='data:post.dateHeader'> <h2 class='date-header'><data:post.dateHeader/></h2> </b:if> <b:include data='post' name='post'/> <b:if cond='data:blog.pageType == "item"'> <b:include data='post' name='comments'/> </b:if> <b:if cond='data:post.includeAd'> <data:adEnd/> <data:adCode/> <data:adStart/> </b:if> </b:loop> <data:adEnd/> </div>
<!-- navigation --> <b:include name='nextprev'/>
<!-- feed links --> <b:include name='feedLinks'/> <b:if cond='data:top.showStars'> <script src='http://www.google.com/jsapi' type='text/javascript'/> <script type='text/javascript'> google.load("annotations", "1", {"locale": "<data:top.languageCode/>"}); function initialize() { google.annotations.setApplicationId(<data:top.blogspotReviews/>); google.annotations.createAll(); google.annotations.fetch(); } google.setOnLoadCallback(initialize); </script> </b:if>
</b:includable> <b:includable id='nextprev'> <div class='blog-pager' id='blog-pager'> <b:if cond='data:newerPageUrl'> <span id='blog-pager-newer-link'> <a class='blog-pager-newer-link' expr:href='data:newerPageUrl' expr:id='data:widget.instanceId + "_blog-pager-newer-link"' expr:title='data:newerPageTitle'><data:newerPageTitle/></a> </span> </b:if>
<b:if cond='data:olderPageUrl'> <span id='blog-pager-older-link'> <a class='blog-pager-older-link' expr:href='data:olderPageUrl' expr:id='data:widget.instanceId + "_blog-pager-older-link"' expr:title='data:olderPageTitle'><data:olderPageTitle/></a> </span> </b:if>
<b:if cond='data:blog.homepageUrl != data:blog.url'> <a class='home-link' expr:href='data:blog.homepageUrl'><data:homeMsg/></a> <b:else/> <b:if cond='data:newerPageUrl'> <a class='home-link' expr:href='data:blog.homepageUrl'><data:homeMsg/></a> </b:if> </b:if>
</div> <div class='clear'/> </b:includable> <b:includable id='post' var='post'> <div class='post hentry uncustomized-post-template'> <a expr:name='data:post.id'/> <b:if cond='data:post.title'> <h3 class='post-title entry-title'> <b:if cond='data:post.link'> <a expr:href='data:post.link'><data:post.title/></a> <b:else/> <b:if cond='data:post.url'> <a expr:href='data:post.url'><data:post.title/></a> <b:else/> <data:post.title/> </b:if> </b:if> </h3> </b:if>
<div class='post-header-line-1'/>
<div class='post-body entry-content'> <data:post.body/> <div style='clear: both;'/> <!-- clear for photos floats --> </div>
<div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> <b:if cond='data:top.showAuthor'> <data:top.authorLabel/> <span class='fn'><data:post.author/></span> </b:if> </span>
<span class='post-timestamp'> <b:if cond='data:top.showTimestamp'> <data:top.timestampLabel/> <b:if cond='data:post.url'> <a class='timestamp-link' expr:href='data:post.url' rel='bookmark' title='permanent link'><abbr class='published' expr:title='data:post.timestampISO8601'><data:post.timestamp/></abbr></a> </b:if> </b:if> </span> <span class='reaction-buttons'> <b:if cond='data:top.showReactions'> <table border='0' cellpadding='0' cellspacing='0' width='100%'><tr> <td class='reactions-label-cell' nowrap='nowrap' valign='top' width='1%'> <span class='reactions-label'> <data:top.reactionsLabel/></span> </td> <td><iframe allowtransparency='true' class='reactions-iframe' expr:src='data:post.reactionsUrl' frameborder='0' name='reactions' scrolling='no'/></td> </tr></table> </b:if> </span>
<span class='star-ratings'> <b:if cond='data:top.showStars'> <div expr:g:background-color='data:backgroundColor' expr:g:text-color='data:textColor' expr:g:url='data:post.absoluteUrl' g:height='42' g:type='RatingPanel' g:width='280'/> </b:if> </span>
<span class='post-comment-link'> <b:if cond='data:blog.pageType != "item"'> <b:if cond='data:post.allowComments'> <a class='comment-link' expr:href='data:post.addCommentUrl' expr:onclick='data:post.addCommentOnclick'><b:if cond='data:post.numComments == 1'>1 <data:top.commentLabel/><b:else/><data:post.numComments/> <data:top.commentLabelPlural/></b:if></a> </b:if> </b:if> </span>
<!-- backlinks --> <span class='post-backlinks post-comment-link'> <b:if cond='data:blog.pageType != "item"'> <b:if cond='data:post.showBacklinks'> <a class='comment-link' expr:href='data:post.url + "#links"'><data:top.backlinkLabel/></a> </b:if> </b:if> </span>
<span class='post-icons'> <!-- email post links --> <b:if cond='data:post.emailPostUrl'> <span class='item-action'> <a expr:href='data:post.emailPostUrl' expr:title='data:top.emailPostMsg'> <img alt='' class='icon-action' height='13' src='http://www.blogger.com/img/icon18_email.gif' width='18'/> </a> </span> </b:if>
<!-- quickedit pencil --> <b:include data='post' name='postQuickEdit'/> </span> </div>
<div class='post-footer-line post-footer-line-2'> <span class='post-labels'> <b:if cond='data:post.labels'> <data:postLabelsLabel/> <b:loop values='data:post.labels' var='label'> <a expr:href='data:label.url' rel='tag'><data:label.name/></a><b:if cond='data:label.isLast != "true"'>,</b:if> </b:loop> </b:if> </span> </div>
<div class='post-footer-line post-footer-line-3'> <span class='post-location'> <b:if cond='data:top.showLocation'> <b:if cond='data:post.location'> <data:postLocationLabel/> <a expr:href='data:post.location.mapsUrl' target='_blank'><data:post.location.name/></a> </b:if> </b:if> </span> </div> </div> </div> </b:includable> <b:includable id='postQuickEdit' var='post'> <b:if cond='data:post.editUrl'> <span expr:class='"item-control " + data:post.adminClass'> <a expr:href='data:post.editUrl' expr:title='data:top.editPostMsg'> <img alt='' class='icon-action' height='18' src='http://www.blogger.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </b:if> </b:includable> <b:includable id='commentDeleteIcon' var='comment'> <span expr:class='"item-control " + data:comment.adminClass'> <a expr:href='data:comment.deleteUrl' expr:title='data:top.deleteCommentMsg'> <img src='http://www.blogger.com/img/icon_delete13.gif'/> </a> </span> </b:includable> <b:includable id='backlinkDeleteIcon' var='backlink'> <span expr:class='"item-control " + data:backlink.adminClass'> <a expr:href='data:backlink.deleteUrl' expr:title='data:top.deleteBacklinkMsg'> <img src='http://www.blogger.com/img/icon_delete13.gif'/> </a> </span> </b:includable> <b:includable id='comments' var='post'> <div class='comments' id='comments'> <a name='comments'/> <b:if cond='data:post.allowComments'> <h4> <b:if cond='data:post.numComments == 1'> 1 <data:commentLabel/>: <b:else/> <data:post.numComments/> <data:commentLabelPlural/>: </b:if> </h4>
<b:if cond='data:post.commentPagingRequired'> <span class='paging-control-container'> <a expr:class='data:post.oldLinkClass' expr:href='data:post.oldestLinkUrl'><data:post.oldestLinkText/></a>   <a expr:class='data:post.oldLinkClass' expr:href='data:post.olderLinkUrl'><data:post.olderLinkText/></a>   <data:post.commentRangeText/>   <a expr:class='data:post.newLinkClass' expr:href='data:post.newerLinkUrl'><data:post.newerLinkText/></a>   <a expr:class='data:post.newLinkClass' expr:href='data:post.newestLinkUrl'><data:post.newestLinkText/></a> </span> </b:if>
<dl id='comments-block'> <b:loop values='data:post.comments' var='comment'> <dt expr:class='"comment-author " + data:comment.authorClass' expr:id='data:comment.anchorName'> <a expr:name='data:comment.anchorName'/> <b:if cond='data:comment.authorUrl'> <a expr:href='data:comment.authorUrl' rel='nofollow'><data:comment.author/></a> <b:else/> <data:comment.author/> </b:if> <data:commentPostedByMsg/> </dt> <dd class='comment-body'> <b:if cond='data:comment.isDeleted'> <span class='deleted-comment'><data:comment.body/></span> <b:else/> <p><data:comment.body/></p> </b:if> </dd> <dd class='comment-footer'> <span class='comment-timestamp'> <a expr:href='data:comment.url' title='comment permalink'> <data:comment.timestamp/> </a> <b:include data='comment' name='commentDeleteIcon'/> </span> </dd> </b:loop> </dl>
<b:if cond='data:post.commentPagingRequired'> <span class='paging-control-container'> <a expr:class='data:post.oldLinkClass' expr:href='data:post.oldestLinkUrl'> <data:post.oldestLinkText/> </a> <a expr:class='data:post.oldLinkClass' expr:href='data:post.olderLinkUrl'> <data:post.olderLinkText/> </a>   <data:post.commentRangeText/>   <a expr:class='data:post.newLinkClass' expr:href='data:post.newerLinkUrl'> <data:post.newerLinkText/> </a> <a expr:class='data:post.newLinkClass' expr:href='data:post.newestLinkUrl'> <data:post.newestLinkText/> </a> </span> </b:if>
<p class='comment-footer'>
<b:if cond='data:post.embedCommentForm'> <b:include data='post' name='comment-form'/> <b:else/> <b:if cond='data:post.allowComments'> <a expr:href='data:post.addCommentUrl' expr:onclick='data:post.addCommentOnclick'><data:postCommentMsg/></a> </b:if> </b:if>
</p> </b:if>
<div id='backlinks-container'> <div expr:id='data:widget.instanceId + "_backlinks-container"'> <b:if cond='data:post.showBacklinks'> <b:include data='post' name='backlinks'/> </b:if> </div> </div> </div> </b:includable> <b:includable id='comment-form' var='post'> <div class='comment-form'> <a name='comment-form'/> <h4 id='comment-post-message'><data:postCommentMsg/></h4> <p><data:blogCommentMessage/></p> <data:blogTeamBlogMessage/> <a expr:href='data:post.commentFormIframeSrc' id='comment-editor-src'/> <iframe allowtransparency='true' class='blogger-iframe-colorize' frameborder='0' height='275' id='comment-editor' scrolling='no' src='' width='100%'/> <data:post.iframeColorizer/> </div> </b:includable> <b:includable id='backlinks' var='post'> <a name='links'/><h4><data:post.backlinksLabel/></h4> <b:if cond='data:post.numBacklinks != 0'> <dl class='comments-block' id='comments-block'> <b:loop values='data:post.backlinks' var='backlink'> <div class='collapsed-backlink backlink-control'> <dt class='comment-title'> <span class='backlink-toggle-zippy'> </span> <a expr:href='data:backlink.url' rel='nofollow'><data:backlink.title/></a> <b:include data='backlink' name='backlinkDeleteIcon'/> </dt> <dd class='comment-body collapseable'> <data:backlink.snippet/> </dd> <dd class='comment-footer collapseable'> <span class='comment-author'><data:post.authorLabel/> <data:backlink.author/></span> <span class='comment-timestamp'><data:post.timestampLabel/> <data:backlink.timestamp/></span> </dd> </div> </b:loop> </dl> </b:if> <p class='comment-footer'> <a class='comment-link' expr:href='data:post.createLinkUrl' expr:id='data:widget.instanceId + "_backlinks-create-link"' target='_blank'><data:post.createLinkLabel/></a> </p> </b:includable> <b:includable id='feedLinks'> <b:if cond='data:blog.pageType != "item"'> <!-- Blog feed links --> <b:if cond='data:feedLinks'> <div class='blog-feeds'> <b:include data='feedLinks' name='feedLinksBody'/> </div> </b:if>
<b:else/> <!--Post feed links --> <div class='post-feeds'> <b:loop values='data:posts' var='post'> <b:if cond='data:post.allowComments'> <b:if cond='data:post.feedLinks'> <b:include data='post.feedLinks' name='feedLinksBody'/> </b:if> </b:if> </b:loop> </div> </b:if> </b:includable> <b:includable id='feedLinksBody' var='links'> <div class='feed-links'> <data:feedLinksMsg/> <b:loop values='data:links' var='f'> <a class='feed-link' expr:href='data:f.url' expr:type='data:f.mimeType' target='_blank'><data:f.name/> (<data:f.feedType/>)</a> </b:loop> </div> </b:includable> <b:includable id='status-message'> <b:if cond='data:navMessage'> <div class='status-msg-wrap'> <div class='status-msg-body'> <data:navMessage/> </div> <div class='status-msg-border'> <div class='status-msg-bg'> <div class='status-msg-hidden'><data:navMessage/></div> </div> </div> </div> <div style='clear: both;'/> </b:if> </b:includable> </b:widget> <b:widget id='HTML1' locked='false' title='' type='HTML'> <b:includable id='main'> <!-- only display title if it's non-empty --> <b:if cond='data:title != ""'> <h2 class='title'><data:title/></h2> </b:if> <div class='widget-content'> <data:content/> </div>
<b:include name='quickedit'/> </b:includable> </b:widget> </b:section> </div>
<div id='sidebar-wrapper'> <b:section class='sidebar' id='sidebar' preferred='yes'> <b:widget id='Feed1' locked='false' title='Slippy on Friendfeed' type='Feed'> <b:includable id='main'> <h2><data:title/></h2> <div class='widget-content'> <ul expr:id='data:widget.instanceId + "_feedItemListDisplay"'> <b:loop values='data:feedData.items' var='i'> <li> <span class='item-title'> <a expr:href='data:i.alternate.href'> <data:i.title/> </a> </span> <b:if cond='data:showItemDate'> <b:if cond='data:i.str_published != ""'> <span class='item-date'>  - <data:i.str_published/> </span> </b:if> </b:if> <b:if cond='data:showItemAuthor'> <b:if cond='data:i.author != ""'> <span class='item-author'>  - <data:i.author/> </span> </b:if> </b:if> </li> </b:loop> </ul> <b:include name='quickedit'/> </div> </b:includable> </b:widget> <b:widget id='Followers2' locked='false' title='Followers' type='Followers'> <b:includable id='main'> <b:if cond='data:title != ""'> <b:if cond='data:codeSnippet != ""'> <h2 class='title'><data:title/></h2> <b:else/> <b:if cond='data:totalFollowerCount != ""'> <h2 class='title'><data:title/> (<data:totalFollowerCount/>)</h2> </b:if> </b:if> </b:if>
<div expr:id='data:widget.instanceId + "-wrapper"'> <b:if cond='data:codeSnippet != ""'> <div style='margin:2px;'> <data:codeSnippet/> </div> <b:else/> <b:if cond='data:totalFollowerCount == ""'> <span class='item-control following-not-admin'> <b><data:failureSnippet/></b> </span> <span class='item-control blog-admin'> <b><data:adminFailureSnippet/></b> </span> <b:else/> <b:if cond='data:followingLinkPresent'> <div class='follow-this profile-link item-control following-follow-this'> <a expr:href='"javascript:_FollowersView._openPopup(\"" + data:followUri + "\");"'> <data:followThisMessage/> </a> </div> <div class='follow-this profile-link item-control following-stop-following-this'> <a expr:href='"javascript:_FollowersView._openPopup(\"" + data:followUri + "\");"'> <data:stopFollowingMessage/> </a> </div> </b:if>
<div class='followers-grid'> <b:if cond='data:totalFollowerCount == 0'> <div class='profile-link item-control following-follow-this'> <data:emptyFollowersMessage/> </div> </b:if> <!-- Relies on the js written out in navbar.gxp --> <b:loop values='data:followers' var='follower'> <div class='follower'> <a expr:href='data:follower.profileUrl' expr:title='data:follower.displayName' rel='nofollow'> <img class='follower-img' expr:alt='data:follower.displayName' expr:height='data:follower.imageHeight' expr:onerror='"this.onerror=null;this.src=\"" + data:anonFollowerImageUrl + "\";"' expr:onload='"setAttributeOnload(this, \"src\", \"" + data:follower.imageUrl + "\")"' expr:width='data:follower.imageWidth' src='http://img1.blogblog.com/img/blank.gif'/> </a> </div> </b:loop> <div class='clear'/> </div>
<div class='followers-canvas profile-link'> <data:followersFooterMessage/> <span class='item-control following-not-admin'> <a expr:href='data:followersUri'> <data:viewAllMessage/> </a> </span> <span class='item-control blog-admin'> <a expr:href='data:manageFollowersUri'> <data:manageFollowersMessage/> </a> </span> </div> </b:if> </b:if> <b:include name='quickedit'/> </div> </b:includable> </b:widget> <b:widget id='BlogArchive2' locked='false' title='Blog Archive' type='BlogArchive'> <b:includable id='main'> <b:if cond='data:title'> <h2><data:title/></h2> </b:if> <div class='widget-content'> <div id='ArchiveList'> <div expr:id='data:widget.instanceId + "_ArchiveList"'> <b:if cond='data:style == "HIERARCHY"'> <b:include data='data' name='interval'/> </b:if> <b:if cond='data:style == "FLAT"'> <b:include data='data' name='flat'/> </b:if> <b:if cond='data:style == "MENU"'> <b:include data='data' name='menu'/> </b:if> </div> </div> <b:include name='quickedit'/> </div> </b:includable> <b:includable id='flat' var='data'> <ul> <b:loop values='data:data' var='i'> <li class='archivedate'> <a expr:href='data:i.url'><data:i.name/></a> (<data:i.post-count/>) </li> </b:loop> </ul> </b:includable> <b:includable id='menu' var='data'> <select expr:id='data:widget.instanceId + "_ArchiveMenu"'> <option value=''><data:title/></option> <b:loop values='data:data' var='i'> <option expr:value='data:i.url'><data:i.name/> (<data:i.post-count/>)</option> </b:loop> </select> </b:includable> <b:includable id='interval' var='intervalData'> <b:loop values='data:intervalData' var='i'> <ul> <li expr:class='"archivedate " + data:i.expclass'> <b:include data='i' name='toggle'/> <a class='post-count-link' expr:href='data:i.url'><data:i.name/></a> <span class='post-count' dir='ltr'>(<data:i.post-count/>)</span> <b:if cond='data:i.data'> <b:include data='i.data' name='interval'/> </b:if> <b:if cond='data:i.posts'> <b:include data='i.posts' name='posts'/> </b:if> </li> </ul> </b:loop> </b:includable> <b:includable id='toggle' var='interval'> <b:if cond='data:interval.toggleId'> <b:if cond='data:interval.expclass == "expanded"'> <a class='toggle' expr:href='data:widget.actionUrl + "&action=toggle" + "&dir=close&toggle=" + data:interval.toggleId + "&toggleopen=" + data:toggleopen'> <span class='zippy toggle-open'>▼ </span> </a> <b:else/> <a class='toggle' expr:href='data:widget.actionUrl + "&action=toggle" + "&dir=open&toggle=" + data:interval.toggleId + "&toggleopen=" + data:toggleopen'> <span class='zippy'> <b:if cond='data:blog.languageDirection == "rtl"'> ◄ <b:else/> ► </b:if> </span> </a> </b:if> </b:if> </b:includable> <b:includable id='posts' var='posts'> <ul class='posts'> <b:loop values='data:posts' var='i'> <li><a expr:href='data:i.url'><data:i.title/></a></li> </b:loop> </ul> </b:includable> </b:widget> </b:section> </div>
<!-- spacer for skins that want sidebar and main to be the same height--> <div class='clear'> </div>
</div> <!-- end content-wrapper -->
<div id='footer-wrapper'> <b:section class='footer' id='footer'/> </div>
</div></div> <!-- end outer-wrapper --> </body> </html> |
posted 11 Oct 2009 10:10 by Slippy Lane
[
updated 12 Oct 2009 15:43
]
watchip
#!/bin/bash
#watchip v0.1TEST by slippy
#quick script to periodically ping an IP and report when the IP fails to respond
#requires zenity for popup message
#this version is just a proof-of-concept.
#TODO
# modify to use hardware interface to power-cycle the router on network drop
#LICENSE
# Public Domain. Do with it what you will.
cWatch="watch --interval=60 $0 --check"
defIP="192.168.2.1"
if [ $# = 0 ]; then
echo "No parameters supplied. Running with default IP."
$cWatch $defIP
else
if [ "$1" = "--check" ]; then
echo "Checking $2..."
result=`ping -c 1 $2 | grep "1 received"`
if [ -z "$result" ]; then
echo "Host $2 is unreachable!"
if [ -n `which zenity` ]; then
zenity --warning --text="Host $2 is unreachable\!"
fi
else
echo "$result"
fi
echo "Done."
else
echo "Running with parameter \"$*\""
$cWatch $*
fi
fi
watchip2
#!/bin/bash
#watchip v2.0 by slippy #quick script to periodically ping an IP and power- #cycle the router when the IP fails to respond. #written for background-running and easy tweaking
#LICENSE: Public Domain. Do with it what you will.
numWatchInterval=60 strIP="192.168.2.1" numRelay=1 numSleepInterval=10 numPowerupInterval=30 cmdLog="null" cmdAlert="echo" cmdOff="/pub/scripts/switchoff" cmdOn="/pub/scripts/switchon"
while true; do $cmdLog "Checking $strIP" strResult=`ping -c 1 $strIP | grep '1 received'` if [ -z "$strResult" ]; then $cmdAlert "`date` : Host $strIP unreachable. Commencing power cycling." $cmdLog "Opening relay $numRelay" $cmdOff $numRelay $cmdLog "Sleeping for $numSleepInterval seconds." sleep $numSleepInterval $cmdLog "Closing relay $numRelay." $cmdOn $numRelay $cmdLog "Waiting for ping response." strResult=`ping -c 1 $strIP | grep '1 received'` while [ -z "$strResult" ]; do $cmdLog "None yet. Sleeping for $numPowerupInterval seconds." sleep $numPowerupInterval $cmdLog "Checking again..." strResult=`ping -c 1 $strIP | grep '1 received'` done $cmdAlert "`date` : Got ping response. Power-cycling complete." fi $cmdLog "Sleeping for $numWatchInterval seconds." sleep $numWatchInterval done
|
posted 10 Oct 2009 09:41 by Slippy Lane
[
updated 12 Oct 2009 15:29
]
First published in August, 2008
<?php
/* Slippy's Filtered Friendfeed SMS-via-Google-Calendar Notificator GData routines taken from the API Guide samples and modified where necessary. All other code is my own.
### PLEASE READ THE FOLLOWING NOTES ###
Note: Requires PHP5 and the Zend GData extensions Also requires user to have a Google account configured with Google Calendar. To receive SMS notifications, user must configure their Google Calendar settings with their mobile telephone details.
To run this script, you'll need a computer running a webserver, PHP5 and the Zend GData extensions It's beyond the scope of this project to explain how to install the above dependencies here, but whatever operating system you use (personally, I'm on Ubuntu Gutsy), there are guides all over the web on how to prepare your computer for running the GData extensions. If you aren't able to run your own PHP server, get in touch (slippy.lane@gmail.com) and maybe we can arrange a time for me to open up the local server for remote access so you can try the script out in your browser. This script is not intended for heavy use, only to prove a concept. My primary reason for sharing it like this is, well, because I, like a lot of people, think code should be free, and also so that others with a similar interest can learn these techniques from it - Using PHP to automatically process an XML/Atom feed, and using the Zend GData framework to create Google Calendar events and send SMS notifications. */ include "Zend/Loader.php"; Zend_Loader::loadClass('Zend_Gdata'); Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); Zend_Loader::loadClass('Zend_Gdata_Calendar');
#Retrieves an event from a Google Calendar data feed function getEvent($client, $eventId) { $gdataCal = new Zend_Gdata_Calendar($client); $query = $gdataCal->newEventQuery(); $query->setUser('default'); $query->setVisibility('private'); $query->setProjection('full'); $query->setEvent($eventId);
try { $eventEntry = $gdataCal->getCalendarEventEntry($query); return $eventEntry; } catch (Zend_Gdata_App_Exception $e) { var_dump($e); return null; } }
#Creates an event in the default Google Calendar referenced by $client function createEvent($client,$title,$desc,$where,$startDate,$startTime,$endDate,$endTime,$tzOffset) { $rem_method="sms"; $rem_minutes="5"; $gdataCal = new Zend_Gdata_Calendar($client); $newEvent = $gdataCal->newEventEntry();
$newEvent->title = $gdataCal->newTitle($title); $newEvent->where = array($gdataCal->newWhere($where)); $newEvent->content = $gdataCal->newContent("$desc");
$when = $gdataCal->newWhen(); $when->startTime = "{$startDate}T{$startTime}:00.000{$tzOffset}:00"; $when->endTime = "{$endDate}T{$endTime}:00.000{$tzOffset}:00"; $newEvent->when = array($when); // Upload the event to the calendar server // A copy of the event as it is recorded on the server is returned $createdEvent = $gdataCal->insertEvent($newEvent); return $createdEvent->id->text; }
#Adds a reminder to an event, referenced by $eventId function setReminder($client, $eventId, $minutes=15) { $gc = new Zend_Gdata_Calendar($client); $method = "sms"; if ($event = getEvent($client, $eventId)) { $times = $event->when; foreach ($times as $when) { $reminder = $gc->newReminder(); $reminder->setMinutes($minutes); $reminder->setMethod($method); $when->setReminders(array($reminder)); } $eventNew = $event->save(); return $eventNew; } else { return null; } }
#Simplifies creating an event and adding a reminder for the scope of this project. function notifyNow($client,$title,$desc,$location) { $reminderTime = getdate(time() + (6*60)); #Set the time of the event for 6 minutes in the future $rem_mins_before = 5; #And send an SMS reminder 5 minutes before the above time #Create the date and time strings to attach to the event $whendate = $reminderTime['year']."-".str_pad($reminderTime['mon'],2,'0',STR_PAD_LEFT)."-".str_pad($reminderTime['mday'],2,'0',STR_PAD_LEFT); $whentime = str_pad($reminderTime['hours'],2,'0',STR_PAD_LEFT).":".str_pad($reminderTime['minutes'],2,'0',STR_PAD_LEFT); #Create the event. $eventID contains the event's ID URI, and will be false if the create failed $eventID = createEvent($client, $title, $desc, $location, $whendate, $whentime, $whendate, $whentime, '+00'); if ($eventID!==false) #success! { #The next two lines extract the id code from the id URI $pos = (strrpos($eventID,"/")+1); $newEventID = substr($eventID,$pos); #And now we attach the 5 minute SMS reminder to the event. $newEvent = setReminder ($client, $newEventID, $rem_mins_before); } if ($newEvent!==false) {return $newEvent;} else {return false;} # return the event object for success, false for failure }
function recurse ($items) # Does what it says on the tin - recurses through an array of objects for the scope of this project { global $level; global $html; $level = $level + 1; foreach ($items as $item) { if ($item['href']) { $html .= str_repeat('.',($level*2)).'<a href="'.$item['href'].'">'.$item.' ['. $item['href'].']</a><br/>'; } else if ($item) { if (ltrim(rtrim($item))!="") { $html .= str_repeat('.',($level*2)).$item.'<br/>'; } } recurse($item); } $level = $level - 1; }
# # Configuration time... #
#These two lines load the atom feed from friendfeed.com into a simplexml object $xml $file = "http://friendfeed.com/public?format=atom"; $xml = @simplexml_load_file($file) or die ("no file loaded") ;
$level = 0; #Set the initial recurse level used in Recurse()
if (isset($_POST['user'])) #Do we have a username? {$user = ltrim(rtrim($_POST['user']));} #Good, put it in $user else {$user = '';} if (isset($_POST['pass'])) #Do we have a password? {$pass = ltrim(rtrim($_POST['pass']));} #Good, put it in $pass else {$pass = '';} if (!isset($_POST['alert'])) #SMS Alert Checkbox checked? {$alertchecked='';} else {$alertchecked='checked="on"';} #Make sure it's checked when it gets drawn. if (!isset($_POST['changed'])) #View only new/updated checkbox checked? {$checked='';} else {$checked='checked="on"';} #Same as SMS alert checkbox thingy
if (($user!=='')&&($pass!=='')) #So, we've got a username and password, yes? { #The next two lines log us in to the google calendar service. $service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME; $client = Zend_Gdata_ClientLogin::getHttpClient($user,$pass,$service); #And this one sets the $loggedin variable appropriately. if ($client!==false) {$loggedin = true;} else {$loggedin = false;} } else { #No user/pass. Not logged in. $loggedin = false; }
#This is all that messy html stuff. It always looks like this coz I do it late at night! Draws tha page header, login/filter/options form $html = "<html><head><title>Slippy's Filtered FriendFeed SMS-via-Google Calendar Notificator</title></head><body>". "<H2>Slippy's Filtered FriendFeed SMS-via-Google Calendar Notificator</H2>". '<H3>by Slippy Lane</H3>'. '<b>21st December 2007</b><br/><br/><center><table bgcolor="lightyellow" width="100%" border="0"><tr><td width="60%" valign="top">'. '<hr>Description: An experiment in using simplexml in PHP to filter an atom feed (from friendfeed.com) using various criteria, optionally display only new/updated matches and optionally create Google Calendar event which sends notification via SMS on new matches.<br/><br/>'. 'Note. This page contains a form and needs to submit POST data on every refresh, so it is not programmed to auto-refresh. I could go down the rout of using a Google Authorisation cookie and persistent session information, but the way I see it, automatic refresh varies from browser to browser. To make it auto-refresh, I load the page in Firefox, right-click then choose "reload every 30 seconds", then when it asks me if I want to resubmit POST data every time, I tell it yes, please.</td><td width="50"></td><td valign="top">'. '<hr/><center><form name="friendfeedfilter" method="post" action="'.$_SERVER['PHP_SELF'].'">';
#A little snippet to tell us if we're logged in or not. if ($loggedin) {$html .= '<font color="green">You are logged in.</font><br/>';} else {$html .= '<font color="red">You are not logged in.</font><br/>';}
#And the rest of the messy stuff $html .= '<table border="0"><tr><td>GCal User </td><td>'. '<input type="text" name="user" id="user" size="20" value="'.ltrim(rtrim($_POST['user'])).'"/></td></tr>'. '<tr><td>Pass </td><td><input type="password" name="pass" id="pass" size="20" value="'. ltrim(rtrim($_POST['pass'])).'"/></td></tr></table>'. '<input type="checkbox" name="alert" id="alert"'.$alertchecked.'/>'. ' Select this checkbox to have an SMS notification sent via GCal for each match.<br/>'. '<input type="checkbox" name="changed" id="changed"'.$checked.'/>'. ' Select this checkbox to display only new or updated items.<br/>'. '<table border="0"><tr><td>Filter by Friend</td><td>'. '<input name="friend" type="text" size="20" value="'. ltrim(rtrim($_POST['friend'])).'"'."/></td></tr>". '<tr><td>by Post Type</td><td><input name="location" type="text" size="20" value="'. ltrim(rtrim($_POST['location'])).'"/></td></tr></table>'. '<div align="center"><input name="send" type="submit" value="Enable the filter"></div>'. '</form></center></td></tr><tr><td><hr/></td><td></td><td><hr/></td></tr></table></center>'. '<b><a href="'.$xml->id.'">'.$xml->title."</a></b><br/>";
$items = array(); if ((isset($_POST['friend'])) or (isset($_POST['location']))) { #A little bit of output, telling the user what filters are active. $html .= "<hr/>"; if ($_POST['friend']) { $html .= "Filtering by friend: ".$_POST['friend']."<br/>"; if ($alertchecked!=='') $html .= "Sending SMS on new matches.<br/>"; } if ($_POST['location']) $html .= "Filtering by location: ".$_POST['location']."<br/>"; if ($checked !=='') $html .= "Only displaying new/updated matches.<br/>"; $html .= "<hr/>"; }
#So now let's iterate throught the <entry> tags in the atom document. foreach ($xml->entry as $entry) { #Set all the relevant variables and the item array $title = $entry->title; $item = array(); $id = explode(':',$entry->id); $item['id'] = $id[2]; $item['updated'] = $entry->updated; $item['friend'] = $title->div->a[0]; $item['action'] = (string) $title->div; # the "Add reminder" bit falls over $item['location'] = (string) $title->div->a[1]; # if these stay as simplexml objects, $item['links'] = (string) $entry->link; # so we convert them to strings here. $item['content'] = $entry->content->div->div;
#This section decides whether the current entry gets displayed or not. $match = false; #Default to "not displayed" if ($_POST['friend']) #Are we filtering by person? { if (stripos($item['friend'],$_POST['friend'])!==false) #Yes. Is this person a match? { $match = true; #Yes. Set $match appropriately } } else if ($_POST['location']) #Are we filtering by post location? { if (stripos($item['location'],$_POST['location'])!==false) #Yes. Is this item a match? { $match = true; #Yes. Set $match appropriately } } else $match = true; #We're not filtering so display all items.
if ($match) { #Format the feed content ready for output $outstr1 = '<a href="http://friendfeed.com'. $item['friend']['href']. '">'. $item['friend']. '</a> '. $item['action']." -- ". ' <a href="'. $item['location']['href']. '">'. $item['location']. "</a>"; $flag="none";
#Set some flags that tell us whether the item is new/updated/old and whether it is to be displayed or not. if (!isset($_SESSION[$item['id']])) { $flag="new"; $_SESSION[$item['id']] = htmlspecialchars($item['updated']); $outstr0 = "<b>[*]</b>"; } else { if ($_SESSION[$item['id']] != htmlspecialchars($item['updated'])) { $flag="upd"; $_SESSION[$item['id']] = htmlspecialchars($item['updated']); $outstr0 = "<b>[#]</b>"; } else { $flag="old"; $outstr0 = "<b>[ ]</b>"; } } #Is it new, updated or unfiltered? if ( (($flag=="new") || ($flag=="upd")) && (ltrim(rtrim($_POST['friend']))!='') ) { if ($alertchecked!==null) { if ($loggedin!==false) { $result = notifyNow($client,(string) $item['friend'],$item['action'],$item['location']); if ($result!==false) { $html .= "Notification of this item has been sent by SMS via GCal.<br/>"; } else { $html .= "Notification of this item failed.<br/>"; } } else { $html .= "Notification not sent - you are not logged in to the Google Calendar service. Please check your username and password above.<br/>"; } } } echo $checked; if (($flag=="new") || ($flag=="upd") || ($checked!=='checked="on"')) { $html .= $outstr0.$outstr1."<br/>"; recurse($item['content']); $html .= "<hr>"; } } } $html .= "</body></html>"; #All finished, so finally we output the html... echo $html; ?> |
posted 10 Oct 2009 09:34 by Slippy Lane
[
updated 12 Oct 2009 15:28
]
#!/bin/bash
script_title="Scripts - Script Manager" script_author="Slippy Lane" script_version="1.0" script_inception="26th April, 2008" script_license="Do what you like, just credit me for the original if you publish."
repo="/pub/scripts" # The folder where your script files are stored editor="gedit" # Your editor of choice viewer="less" # Your text viewer/output pager of choice
showTitle() { echo "title : $script_title" echo "description : $script_description" echo "author : $script_author" echo "version : $script_version" echo "inception : $script_inception" echo "license : $script_license" echo }
showUsage() { echo "Usage: $0 {command} [ {command options} ... ]" echo echo "Commands:" echo " (l)ist [script name] : shows list of scripts, or contents of a script" echo " (n)ew {script name} : creates a new script, and opens for editing" echo " (c)opy {existing script} {new script} : makes a copy of an existing script with a new name and opens it for editing" echo " kill {script name} : deletes script from repository" echo " (e)dit {script name} : Calls the defined editor with script as argument" echo " (a)lias {script name} {alias name} : creates a shortcut alias to a script" echo echo "Settings (static):" echo " repository : $repo" echo " editor : `which $editor`" echo " text viewer : `which $viewer`" echo exit }
toLower() { echo $1 | tr "[:upper:]" "[:lower:]" }
toUpper() { echo $1 | tr "[:lower:]" "[:upper:]" }
removeBackups() { c=0 for bf in $repo/*~; do if [ -e "$bf" ]; then if [ $c = 0 ]; then echo "Removing temp files..." c=1 fi rm "$bf" fi done }
listScripts() { removeBackups echo "Listing scripts..." pushd $repo ( for fn in *; do echo "[ $fn ]" done ) | $viewer popd echo "Done." }
showTitle
if [ -z "$1" ]; then showUsage fi
command=`toLower $1` shift
if [ $command = list ] | [ $command = l ]; then if [ -z "$1" ]; then listScripts else scrname=`toLower $1` if [ -e $repo/$scrname ]; then echo "Viewing script '$scrname'..." $viewer $repo/$scrname fi fi elif [ $command = copy ] | [ $command = c ]; then if [ -e "$repo/$1" ]; then if [ -e "$repo/$2" ]; then echo "Destination script already exists: $2" else echo "Copying script $1 to $2" cp $repo/$1 $repo/$2 echo "Done. Opening $2 for editing." $editor $repo/$2 & echo "Done." fi else echo "Script not found: $1" fi elif [ $command = new ] | [ $command = n ]; then if [ -z "$1" ]; then echo "Enter a name for the new script: (leave blank to abort)" read newscr if [ -z "$1" ]; then exit fi else newscr=$1 fi newscr=`toLower $newscr` if [ -e $repo/$newscr ]; then echo "Sorry, there's already a script with that name." exit fi echo "Creating script..." touch "$repo/$newscr" echo '#!/bin/bash' > "$repo/$newscr" chmod +x "$repo/$newscr" echo "Launching editor..." $editor "$repo/$newscr" & echo "Done." elif [ $command = kill ]; then if [ -z "$1" ]; then echo "You must supply a script name to delete." fi killscr=`toLower $1` if [ -e $repo/$killscr ]; then echo "Are you sure you want to remove the script '$killscr'?" echo "Type 'YES' (in uppercase, without quotes) and hit enter to confirm." read strcheck if [ -n "$strcheck" ]; then if [ $strcheck = YES ]; then echo "Removing file." rm $repo/$killscr if [ -e $repo/$killscr ]; then echo "Hmmm. That didn't work. Check your permissions?" else echo "$killscr script removed successfully." fi else echo "Aborted." fi else echo "Aborted." fi else echo "$killscr not found." exit fi elif [ $command = edit ] | [ $command = e ]; then if [ -z "$1" ]; then echo "You must supply a script name to edit." fi editscr=`toLower $1` $editor "$repo/$editscr" & elif [ $command = alias ] | [ $command = a ]; then if [ -z "$2" ]; then echo "You must supply two arguments" elif [ -e "$repo/$2" ]; then echo "A file with that alias name already exists." elif [ -e "$repo/$1" ]; then echo "Creating alias '$2' to '$1'..." ln -s $repo/$1 $repo/$2 ls -l $repo fi else showUsage fi exit |
|