Rest of the Web scripts (bin and misc)

View: New views
1 Messages — Rating Filter:   Alert me  

Rest of the Web scripts (bin and misc)

by dmark :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Misc is pretty empty at this point.  Covers the jukebox, bar code reader and photo viewer.  Why they are not in web/bin is anybody's guess.

The files:

alarms - confusion between triggers and alarms (there is an extant page for the former, but not the latter.)  Delete.

barcode_scan and barcode_search - Horribly tangled up with widgets and a one-user-at-a-time form (!)  Skip for now.  I ended up deleting these and using a stand-alone form in web/bin.  Also, these are hard-coded to use the encrypted CueCats and nothing else. (?)

empty - Delete

failed_request - 404 error page

mp* - Unusable.  Re-did these from scratch.  Skip for now (tangled with common code updates.)

photo_search:  Here is the old one:

<html><body>
<table width=100% bgcolor='lightgrey'>
<td><center>

Search Photos
</center>
</td>
</table><br>

<a href="javascript:history.go(-1)"><img src="/ia5/images/back.gif" border=0></a></td>

<table>

<tr>
<form action='/bin/photo_search.pl'>
<td>Search String:</td>
<td><input align='left' size='25' name='search' onChange='form.submit()'></td>
</form>
</tr>

<tr>
<form action='/bin/photo_search.pl'>
<td>Jump to photo number:</td>
<td><input align='left' size='10' name='jump' onChange='form.submit()'></td>
</form>
</tr>

</table>

</body></html>

I changed it to:

<html>
<head>
<title>Search Photos</title>
<!--#include var="$config_parms{html_style}" -->
</head>
<body>
<h4 class="header">Search Photos</h4>
<form action='/bin/photo_search.pl'>
<label for="search"><u>N</u>ame Contains:</label>
<input size="25" name="search" id="search" accesskey="n">
<input type="submit" value="Search">
</form>
<form action='/bin/photo_search.pl'>
<label for="jump"><u>P</u>hoto Number:<label>
<input size="5" name="jump" id="jump" accesskey="p">
<input type="submit" value="Go to">
</form>
</tr>

</table>

</body></html>

Looks like I didn't do much work on this one (never really cared about the photo viewer functions.)  This should be "beheaded" like all of the rest.  Still an improvement, but not completely portable and not INCLUDE-friendly.

photos.pl - Just points to the new photos.shtml

photos.shtml - Frameset in both repositories, not used by my interface.

pictureframe - Also not used by my interface, has an exclamation point before the title (!Audrey Picture Frame.)

timers - Worth looking at as it does everything wrong:

1.  Delete the stupid table.  They use tables for layout, which has never been a good idea.
2.  Delete the <html> and <body> tags.
3.  Note that this script relies on an IFrame (AND a base target!)

<html><body>
<base target ="response">
<!--#include code="&html_header('Control Timers')" -->
<table width="100%" border="0">
<tr>
<td></td>
<td><a href="RUN;last_response?cancel_all_timers">  <img src="/graphics/cancel_timers.gif" border="0"></a></td>
</tr></table>

<table width="100%" border="0" >
<tr align=center>

<form name='timer' ACTION='SET;last_response'>
<td align=left>Timer amount:</td>
<td align='left'><INPUT SIZE=10 NAME='timer_time' value='<!--#include var="$timer_time->{state}"-->'></td></form>

<form name='timer' ACTION='SET;last_response'>
<td align=left>Timer Text:</td>
<td align='left'><INPUT SIZE=10 NAME='timer_text' value='<!--#include var="$timer_text->{state}"-->'></td></form>

</tr>
</table>

<iframe name="response" src="/empty.html" width=500 height=100></iframe>

</center>
</body>
</html>

My version ended up like this:

<a target="response" href="RUN;last_response?list_all_timers"><img src="../graphics/list_timers.gif" border="0"></a>
<a target="response" href="RUN;last_response?cancel_all_timers"><img src="../graphics/cancel_timers.gif" border="0"></a>
<form name="timer" ACTION="SET;last_response" target="response">
Timer Length:
<INPUT SIZE="10" NAME="timer_time" value="<!--#include var="$timer_time->{state}"-->">
<input type="submit" value="Add Timer" style="float:right">
</form>
<form name="timer" ACTION="SET;last_response" target="response">
Timer Text:
<INPUT SIZE="60" NAME="timer_text" value="<!--#include var="$timer_text->{state}"-->">
</form>
<iframe name="response" src="RUN;last_response?list_all_timers" width="100%" height="100"></iframe>

Here's the wrapper from the MHX folder (can also be used for frameset interfaces.)

<html>
<head>
<title>My House - Timers</title>
<!--#include file="/bin/head.pl"-->
</head>
<body>
<div style="float:right" class="toolbar"><!--#include file="/bin/top_toolbar.pl?Time"-->
<!--#include file="/bin/icon_auth.pl"--></div>
<!--#include file="/mhx/top2.shtml"-->
<img align="right" src="../graphics/icons/timer.png" /><h1 class="header">Timers</h1>
<!-- #include file="/misc/timers.shtml" -->
</div>
<p align="center"><!--#include file="/bin/toolbar.pl"--></p>
<!--#include file="/bin/footer2.pl?Time&Timer"-->
<!--#include file="/bin/my_status_line.pl"-->
</body>
</html>



Unauthorized - One liner (not used by my interface.)

That's the misc folder.  Not too hard to update that.  Now the bin folder.  There are 86 files between MH and a decent Web interface.  There are 146 files in my bin folder, but most are probably old scripts that were deleted prior to the last release.  There are several files added, but those won't be needed until these 86 are cleaned up.  Once that's done, I will post http_server.pl and the rest of the MHX pages.

alarms - companion to misc/alarms, adds a TIMER (not a trigger) and populates the IFrame.
browse - directory browsing interface, leave it be for now.  I have 300+ MIME icons from my email module that could be used with this.
button - turns text into graphics (like turning wine into water or gold into lead.)  Didn't mess with it.
button2 - French version of button.  Sure didn't mess with that.
button_action - Trash
button_toggle - Used for the various toggle buttons in IA5.  I did some work on it, but I don't think I used it in the end.  Here it is:

# Return an href linked image that can be used to toggle the given object
# Call like this:   <!--#include file="/bin/button_toggle.pl?vacation_mode"-->

# Authority: anyone

my ($object) = @ARGV;
my $object_friendly = $object;
$object_friendly =~ s/\$//;
$object_friendly =~ s/_/\x20/;

my $state = eval "state \$$object";
print "button_toggle.pl error: $@" if $@;

                                # Use a custom .gif or auto-generate one with button.pl (if GD is installed)
my $image = "/graphics/${object}_$state.gif";
$image = '' unless &http_get_local_file($image);
$image = "/bin/button.pl?\$$object&item&$state" if !$image and $Info{module_GD};

my $authority = 1;

#***Must check for specific authorization (guest, family or admin)

unless ($Authorized) {
                if ($object =~ /^\d+$/) { # Can't do html_pointer yet ... need to switch to Tk objects
                    $authority = 0;            
                }
                                # WAP pages don't allow for $ in url, so make it optional
                $object = "\$". $object unless substr($object, 0, 1) eq "\$";
                my $set_authority = eval qq[$object->get_authority if $object and ref($object) and UNIVERSAL::isa($object, 'Generic_Item');];
                print "button_toggle:SET authority eval error: $@\n" if $@;
                unless ($set_authority eq 'anyone' or $Password_Allow{$object} eq 'anyone') {
                    $authority = 0;                
                }

}

if ($image) {
    $image = "<img class=\"toggleState\" src=\"$image\" alt=\"Toggle $object_friendly\" border=\"0\" />";
}
else {
    $image = "$object -> $state";
}

print "button_toggle.pl:  o=$object s=$state i=$image\n" if $main::Debug{button};

if ($authority) {
        return "<a href=\"/SET;$ENV{HTTP_REQUEST}?$object=toggle\">$image</a>";
}
else {
        return $image;
}

callerid - Edits the telephone contacts, never got around to cleaning this one up (needs it badly.)

clock1 and clock2: Two lousy JS clocks.  Didn't use.

code_search: Minor tweaks here, needs beheading and wrapper (currently returns an entire page with headers.)

code_select and code_unselect: Nearly identical bookends (makes you wonder why there are two files.)  I did a ton of work on these (and I am sure I didn't end up using both), but some of the updates were MHX-specific.  Skip for now.  Both return entire pages (but they shouldn't.)

command_search: Searches for voice commands.  Doesn't look like a lot has changed on this one.

counter: Not used

dbi_table: Not used

dbm_edit: Not used.  Looks stolen.

display_map: APRS maps.  Not used.

DSC*: Not used.  A glance at the first one reveals a lot of bad JS.

flight_status:  Not used.  Does NOT return an entire page, so they actually got one right.

floorplan*:  Didn't use these, but you can't have mine (not for free anyway!)

get_state: Not used.

header_control: Not used.  A mess from the looks of it.  What is this supposed to be?  Documentation no help.

hvac: Despite the generic name, it is specific to the RCS TR40 thermostat.  Not used.

icon_auth: IMPORTANT.  Mine looks like this:


# Return a login/logout button depending on the current
# Authorization.

# Authority: anyone

my $icon = 'images/login.gif';
           # Return a user specific icon, or default logout icon if not found.
if ($Authorized) {
    $icon = "images/logout_$Authorized.gif";
#    $icon = 'images/logout.gif' unless &http_get_local_file('/ia5/' . $icon);
}


my $query_string = $ENV{HTTP_QUERY_STRING};


$query_string =~ s/&&/&/; #***Need to fix this in http_server!
$query_string = "?" . $query_string if $query_string;



my $action = ($Authorized) ? "/UNSET_PASSWORD?user=$Authorized" : "/SET_PASSWORD?user=$Authorized&referer=" . escape($ENV{HTTP_REQUEST} . $query_string);
#print "\ndbx a=$Authorized i=$icon a=$action\n";
return "<a href=\"$action\" title=\"" . (($Authorized)?"Logout (logged in as $Authorized)":'Login') . "\" onmouseover=\"if (this.title) window.status = this.title;return true\" onmouseout=\"window.status = '';return true\"><img src=\"$icon\" class=\"toolbarButton" . (($Authorized)?'Selected':'') . "\" alt=\"" . (($Authorized)?"Logout (logged in as $Authorized)":'Login') . "\" border=0></a>";

icon_mode: (Old) garbage.  I don't think IA5 uses it at this time.

iniedit: An INI editor.  Since there were no (working) dialogs when IA5 came out, this is what you get.  Really bad, but leave it in as IA5 uses it.

items: An MHT editor.  I did a ton of work to make this presentable.  Too large to paste inline.  Get the rest of these updates done and I will post it...

k8055: Who knows?  No documentation.  Not used.  Returns entire page (bad.)

list_*:  Not used.  All return whole pages (a recurring theme.)

ListManager.  Based on an idea by the biggest MH idiot of them all.  Avoid this bloated spectacle.

menu: Not used.  Looks ancient.  References the user agent header (bad.)

menu_keys: Not used.

mh_usage: Submits user info to online db.  Not used.

mhmedia_list: Looks old and unfinished.  Good candidate for deletion.

mp3*: Leave alone for the moment.  MP3 jukebox is tangled up in several files.  Will deal with that last...

mrwiki: Not used.  Looks like somebody had a lot of time on their hands.

phone_*: The worst set of Web scripts in history.  Was tinkering with these last fall, but never got them completely straightened out.  Certainly need beheading as there are wrappers for these in MHX.

photo_search: Didn't do anything with this.

photos: A (really lame) slide show script.  I updated it for my house, but likely broke Audrey's in the process.  Skip for now.

pictureframe: Not much there but comments (and they don't inspire confidence in this script!)  Not used.

rejectcall: Called from callerID list, leave alone for now.

rss_logs: Not too bad.  I expounded on these a bit for use with the MediaMVP, but no changes are necessary to make it work from MHX.

set_cookie and set_cookie2: Need to diff these with mine.  I know there were some tweaks.

set_parm*: Setup dialogs that never worked until I updated handy utilities a year or so back.  Probably some updates in these two, but skip for now.

set_func: Appears unchanged.

set_var: Appears unchanged.

shopping_list: Already covered in previous post.  Stupid implementation.  No excuse as I told him how to fix it a year ago.

soapcgi: Aborted attempt to add SOAP to MH.  Waste of time (as I warned last summer!)

status_line: for IA5.  Mine is called my_status_line and is very different.  Will post mine when the rest of this stuff is cleaned up.

tagline: Not used.

test_*: Not used.

triggers: The usual beheading is needed.  Other minor tweaks.  Too much to paste and format inline.

tv_search: Not used.  I always used the widget to search for TV shows.

uptime: Not used.

video_streamer: Not used by anything I have come across (certainly not in MHX.)  Nothing to it.

voicemail: Not used and not much there.

weather_conditions: Not used.  Mixes up XML and HTML.  I put this functionality in the RSS module and renamed it xml_server.

weather_graph*: Behead these two.  Both have wrappers in MHX.

That's it.  Like I said.  Fix this shit (post if you have questions) and I will post the MHX folder, the updated http_server.pl and the miscellaneous scripts that weren't pasted in here (jukebox, bar code reader, etc.)  Or maybe the user base is happy with the IA5 frameset (and no easy way to make a custom page, other than my_mh, buggy as hell, six years old, etc.)