3 require_once "Socket.php";
4 require_once "LoomClient.php";
5 require_once "Cipher.php";
6 require_once "bcbitwise.php";
9 * iPhone interface to the Loom folder.
10 * Don't run this unencrypted.
11 * See http://www.whoopis.com/howtos/apache-rewrite.html
12 * for unstructions on setting up a .htaccess file to rewrite
13 * http://... to https://...
17 if (get_magic_quotes_gpc()) return stripslashes($x);
21 $passphrase = mq($_POST['passphrase']);
22 $session = mq($_POST['session']);
23 $qty = mq($_POST['zip']);
24 $type = mq($_POST['type']);
25 $location = mq($_POST['location']);
26 $folderkv = mq($_POST['folderkv']);
27 $valueskv = mq($_POST['valueskv']);
28 $take = mq($_POST['take']);
29 $give = mq($_POST['give']);
30 $page = mq($_POST['page']);
31 $greendot = mq($_POST['greendot']);
32 $contact = mq($_POST['contact']);
33 $showfolder = mq($_POST['showfolder']);
34 $newname = mq($_POST['newname']);
35 $oldname = mq($_POST['oldname']);
36 $newlocation = mq($_POST['newlocation']);
37 $savename = mq($_POST['savename']);
38 $delete = mq($_POST['delete']);
39 $add_location = mq($_POST['add_location']);
40 $commit = mq($_POST['commit']);
42 $client = new LoomClient();
44 // Redefine $encrypt_key if you want to use one.
45 // It should be a 32-character hex string, as generated
46 // by the grid-tutotial.php "Tools" page.
47 $client->disable_warnings();
49 include "ip-config.php";
50 $client->reenable_warnings();
55 if ($encrypt_key != '') {
57 if ($session_cipher != '') {
58 if ($folderkv != '') {
59 $folderkv = $session_cipher->decrypthex($folderkv);
61 if ($valueskv != '') {
62 $valueskv = $session_cipher->decrypthex($valueskv);
72 if ($page == 'refresh') {
77 if ($folderkv != '') $folder = $client->parsekv($folderkv, TRUE);
78 if ($valueskv != '') $values = $client->parsekv($valueskv, TRUE);
81 if (($session == '' && $passphrase == '') ||
!login()) {
82 $onload = 'passphrase';
86 $values = scanFolder($folder);
87 $valueskv = $client->array2kv($values);
91 $title = "Loom Wallet";
93 if ($page == 'main') doMain();
94 elseif ($page == 'locations') doLocations();
95 elseif ($page == 'add_location') doAddLocation();
96 elseif ($page == 'logout') doLogout();
100 if ($page == 'login') drawLogin();
101 elseif ($page == 'main') drawMain();
102 elseif ($page == 'locations') drawLocations();
103 elseif ($page == 'add_location') drawAddLocation();
108 global $qty, $type, $location, $take, $give;
109 global $client, $folder, $folder_loc, $folder_name;
110 global $values, $valueskv;
112 global $greendot, $contact;
116 if ($greendot != '') {
118 $location = $contact;
119 $qty = $values[$location][$type];
122 if ($type != '-- choose asset --') {
123 $t = $folder['types'][$type];
126 $min_precision = $t['min_precision'];
127 if ($min_precision == '') $min_precision = 0;
128 $scale = $t['scale'];
129 if ($scale == '') $scale = 0;
132 if ($location != '-- choose contact --') {
133 $loc = $folder['locs'][$location];
135 if ($id != '' && $loc != '') {
136 if ($scale != '') $count = bcmul($qty, bcpow(10, $scale), 0);
138 if ($count != '' && $id != '' && $loc != '') {
140 $client->buy($id, $folder_loc, $folder_loc, $url);
141 $res = $client->move($id, $count, $loc, $folder_loc, $url);
142 $loc_orig = $location;
143 $loc_dest = $folder_name;
144 } else if ($give != '') {
145 $client->buy($id, $loc, $folder_loc, $url);
146 $res = $client->move($id, $count, $folder_loc, $loc, $url);
147 $loc_dest = $location;
148 $loc_orig = $folder_name;
149 } else $transferred = FALSE;
151 $status = $res['status'];
152 if ($status == 'success') {
153 $value_orig = $client->applyScale($res['value_orig'], $min_precision, $scale);
154 $value_dest = $client->applyScale($res['value_dest'], $min_precision, $scale);
155 $values[$loc_orig][$type] = $value_orig;
156 ksort($values[$loc_orig]);
157 $values[$loc_dest][$type] = $value_dest;
158 ksort($values[$loc_dest]);
159 $valueskv = $client->array2kv($values);
160 } else $message = "Insufficient funds";
166 function doLocations() {
167 // Need to investigate how to delete.
168 // The "session" is an archive location containing the folder location
170 global $client, $folder, $values, $valueskv;
171 global $newname, $oldname;
172 global $savename, $delete, $add_location;
174 global $message, $title, $onload, $page;
175 global $greendot, $cancel;
178 $title = 'Loom Contacts';
180 if ($savename != '') {
181 if ($newname == $oldname) return;
182 if ($folder['locs'][$newname] != '') {
183 $message = "Duplicate Contact Name";
186 $res = $client->renameFolderLocation($session, $oldname, $newname);
191 else if ($add_location != '') {
192 $title = 'Loom Add Contact';
193 $page = 'add_location';
196 else if ($greendot == '' && $cancel == '') refreshFolder();
200 function makeCiphers() {
201 global $cipher, $encrypt_key, $session, $session_cipher;
202 if ($encrypt_key != '') {
204 $cipher = new Cipher($encrypt_key);
205 if ($session != '') $session = $cipher->decrypthex($session);
207 if ($session_cipher == '' && $session != '') {
208 $session_key = bcxorhex($session, $encrypt_key);
209 $session_cipher = new Cipher($session_key);
214 function doAddLocation() {
215 global $session, $commit, $page, $newname, $newlocation;
216 global $client, $message, $folder;
220 if ($commit != 'commit') $message = 'Cancelled';
221 else if ($newname == '') $message = 'Blank name';
222 else if ($folder['locs'][$newname] != '') $message = "Name already exists";
223 else if ($newlocation != '' && !$client->isValidID($newlocation)) {
224 $message = 'Invalid location ID';
226 if ($newlocation == '') $newlocation = $client->random
->random_id();
227 $client->newFolderLocation($session, $newname, $newlocation);
229 $message = "Contact created: $newname";
233 function doLogout() {
234 global $page, $folderkv, $valueskv;
235 global $client, $session;
240 $client->logout($session);
243 function drawHead() {
244 global $title, $onload;
248 <meta name
="viewport" content
="width=device-width" user
-scalable
="no" minimum
-scale
="1.0" maximum
-scale
="1.0"/>
249 <title
><?
echo $title; ?
></title
>
250 <link rel
="apple-touch-icon" href
="krugerand.png"/>
251 <link rel
="shortcut icon" href
="krugerand.png"/>
253 <script language
="JavaScript">
254 function submitPage(page
) {
255 document
.forms
["mainform"].page
.value
= page
;
256 document
.mainform
.submit();
259 function greenDot(greendot
, contact
) {
260 document
.forms
["mainform"].greendot
.value
= greendot
;
261 if (contact
!= "") document
.forms
["mainform"].contact
.value
= contact
;
262 document
.mainform
.submit();
265 function hideAddressbar() {
266 window
.scrollTo(0, 1);
269 function doOnLoad(selected
) {
271 setTimeout(hideAddressbar
, 250);
274 <?
additionalHTMLScripts(); ?
>
278 <style type
="text/css">
279 body
{ font
-family
: verdana
, arial
, sans
-serif
; font
-size
: 12pt
}
280 div
{ font
-size
:12pt
}
282 h1
{ font
-size
:14pt
}
283 h2
{ font
-size
:12pt
}
284 h3
{ font
-size
:10pt
}
285 td
{ font
-size
:12pt
}
286 ul
{ font
-size
:12pt
}
287 li
{ padding
-bottom
: 7px
}
288 pre
{ font
-family
: verdana
, arial
, sans
-serif
; }
289 A
:link
, A
:visited
{ color
:blue
; text
-decoration
:none
}
290 A
:hover
{ color
:blue
; text
-decoration
:underline
}
291 A
:active
{ color
:#FAD805; text-decoration:underline }
292 .tt
{ font
-family
: Courier
; font
-size
:10pt
}
293 .mono
{ font
-family
: monospace
; font
-size
: 11pt
}
294 .large_mono
{ font
-family
: monospace
; font
-size
: 10pt
}
295 .giant_mono
{ font
-family
: monospace
; font
-size
: 14pt
}
296 .tiny_mono
{ font
-family
: monospace
; font
-size
: 6pt
}
297 .normal
{ font
-size
:10pt
}
298 .smaller
{ font
-size
:6pt
}
299 .small
{ font
-size
:8pt
}
300 .large
{ font
-size
:12pt
}
301 .alarm
{ color
:red
; font
-weight
: bold
}
302 .focus_value
{ background
-color
:#DDDDDD }
303 .color_heading
{ margin
-top
:12px
; padding
:1px
; background
-color
:#DDDDDD; width:100% }
304 A
.label_link
{ font
-weight
:bold
; }
305 A
.highlight_link
{ font
-weight
:bold
; }
306 A
.cancel
{ background
-color
:#FFDDDD }
307 A
.plain
:link
, A
.plain
:visited
{ color
:black
; text
-decoration
:none
}
308 A
.plain
:hover
{ color
:blue
; text
-decoration
:underline
}
309 A
.plain
:active
{ color
:#FAD805; text-decoration:underline }
310 A
.name_dot
{ font
-size
:16pt
; font
-weight
:bold
; color
:green
; }
314 <body onload
="doOnLoad(document.forms[0].<? echo $onload; ?>)">
315 <table width
="320px">
320 function additionalHTMLScripts() {
323 if ($page == 'add_location') {
326 function Do0(form
) { form
.newlocation
.value
= form
.newlocation
.value +
"0" ;}
327 function Do1(form
) { form
.newlocation
.value
= form
.newlocation
.value +
"1" ;}
328 function Do2(form
) { form
.newlocation
.value
= form
.newlocation
.value +
"2" ;}
329 function Do3(form
) { form
.newlocation
.value
= form
.newlocation
.value +
"3" ;}
330 function Do4(form
) { form
.newlocation
.value
= form
.newlocation
.value +
"4" ;}
331 function Do5(form
) { form
.newlocation
.value
= form
.newlocation
.value +
"5" ;}
332 function Do6(form
) { form
.newlocation
.value
= form
.newlocation
.value +
"6" ;}
333 function Do7(form
) { form
.newlocation
.value
= form
.newlocation
.value +
"7" ;}
334 function Do8(form
) { form
.newlocation
.value
= form
.newlocation
.value +
"8" ;}
335 function Do9(form
) { form
.newlocation
.value
= form
.newlocation
.value +
"9" ;}
336 function DoA(form
) { form
.newlocation
.value
= form
.newlocation
.value +
"a" ;}
337 function DoB(form
) { form
.newlocation
.value
= form
.newlocation
.value +
"b" ;}
338 function DoC(form
) { form
.newlocation
.value
= form
.newlocation
.value +
"c" ;}
339 function DoD(form
) { form
.newlocation
.value
= form
.newlocation
.value +
"d" ;}
340 function DoE(form
) { form
.newlocation
.value
= form
.newlocation
.value +
"e" ;}
341 function DoF(form
) { form
.newlocation
.value
= form
.newlocation
.value +
"f" ;}
342 function DoBksp(form
)
343 { var T
= form
.newlocation
.value
;
345 var T2
= T
.substr(0,L
-1);
346 form
.newlocation
.value
= T2
;
348 function DoClr(form
) { form
.newlocation
.value
= ""; }
349 function DoEnter(form
) { form
.submit(); }
350 function DoCancel(form
) {
351 form
.commit
.value
= 'Cancel';
354 function submitOnRet(e
, form
) {
357 if (window
.event
) keynum
= e
.keyCode
; // IE
358 else if (e
.which
) keynum
= e
.which
; // Netscape/Firefox/Opera
359 keychar
= String.fromCharCode(keynum
);
360 if (keychar
!= "\n" && keychar
!= "\r") return true;
369 function drawTail() {
377 function drawLogin() {
379 $host = $_SERVER["HTTP_HOST"];
380 if (!$host ||
$host == '') $host = $_SERVER["SERVER_NAME"];
384 <a href
="https://loom.cc/">Loom
</a
> for iPhone
. Note that in order to
use this
385 confidently
, you must trust that the PHP scripts at
<?
echo $host; ?
> do
386 not steal your passphrase
. I promise that unless somebody hacks my
387 site
, the code running is what you can download from
388 <a href
="./">here
</a
>, but don
't trust that unless you know
390 <form method="post" action="" autocomplete="off">
391 <input type="hidden" name="page" value="main"/>
395 <td><input type="password" name="passphrase" size="35" /></td>
399 <td><input type="submit" name="login" text="Login" /></td>
402 <p>Because my SSL certificate is a $20/year cheapie from
403 <a href="http://www.godaddy.com/">GoDaddy.com</a>, you'll see a warning message on your iPhone when you come here
: "The certificate for this website is invalid..." Click the
"Continue" button to go ahead
. Your regular browser should allow you to easily add the CA certificate to eliminate warnings
, but the iPhone browser does not
. In any
case, your connection to my web site will be encrypted
.</p
>
405 <p
>One way to
use this
, without giving me the keys to your kingdom
, is to create a separate
"Mobile" folder in Loom
. Transfer assets that you think you might need on the road to a drop
-point shared between your main folder
and the
"Mobile" folder
, and only aim this page at the
"Mobile" folder
. You can always login to your main folder directly via
406 <a href
="https://loom.cc/">
407 loom
.cc
</a
>, if you need something there
. The regular
interface isn
't as convenient as this one, but it works on the mobile browser.</p>
412 function hsc($text) {
413 return htmlspecialchars($text);
416 function hiddenValue($name) {
417 eval('global $
' . $name . ';');
418 echo '<input type
="hidden" name
="' . $name .
419 '" value
="' . hsc(eval('return $' . $name . ';')) . '"/>' . "\n";
422 function drawValues($name, $typevalues) {
423 if (is_array($typevalues)) {
425 foreach ($typevalues as $type => $value) {
426 $link = '<a
class="plain" href
="javascript: greenDot(' . "'" .
427 hsc($type) . "', '" . hsc($name) . "')" . '" title
="Take">';
430 $str .= "<b>" . hsc($name) . "</b>\n";
431 $str .= '<table border
="0"><tr
><td width
="50px"> 
;</td
><td
>';
432 $str .= '<table border
="0">' . "\n";
434 $str .= '<tr
><td align
="right">' . $link . $value . "</a></td>\n" .
435 "<td>" . $link . $type. "</a></td></tr>\n";
440 echo "</table></td></tr></table>\n";
445 function writeSessionInfo() {
446 global $cipher, $session_cipher;
447 global $session, $folderkv, $valueskv;
449 $enc_session = $session;
450 $enc_folderkv = $folderkv;
451 $enc_valueskv = $valueskv;
453 if ($cipher) $enc_session = $cipher->encrypt2hex($enc_session);
454 if ($session_cipher) {
455 $enc_folderkv = $session_cipher->encrypt2hex($enc_folderkv);
456 $enc_valueskv = $session_cipher->encrypt2hex($enc_valueskv);
458 echo '<input type
="hidden" name
="session" value
="' . hsc($enc_session) . '"/>' . "\n";
459 echo '<input type
="hidden" name
="folderkv" value
="' . hsc($enc_folderkv) . '"/>' . "\n";
460 echo '<input type
="hidden" name
="valueskv" value
="' . hsc($enc_valueskv) . '"/>' . "\n";
463 function drawMain() {
464 global $session, $folder, $values, $folder_name;
465 global $qty, $type, $location;
471 <table border="0" width="99%" cellpadding="3">
473 <td colspan="2" style="background-color: #c0c0c0; text-align: center;"><span style="font-weight: normal; font-size: 110%;"><a href="javascript:submitPage('refresh
');">Refresh</a>
475 <a href="javascript:submitPage('locations
');">Contacts</a>
477 <a href="javascript:submitPage('logout
');">Logout</a>
482 drawValues($folder_name, $values[$folder_name]);
484 <table border="0" width="99%">
485 <form name="mainform" method="post" action="" autocomplete="off">
486 <input type="hidden" name="greendot" value=""/>
487 <input type="hidden" name="contact" value=""/>
493 <td align="right">Qty:</td>
494 <td><input style="font-size: 12pt;" type="text" size="25" name="zip" value="<? echo $qty; ?>" style="text-align:right;"></td>
498 <select name="type" style="font-size: 10pt;">
499 <option value="">-- choose asset --</option>
501 foreach ($folder['types
'] as $typename => $typearray) {
502 echo '<option value
="' . hsc($typename) . '"';
503 if ($type == $typename) echo ' selected
="selected"';
504 echo '>' . hsc($typename) . "</option>\n";
512 <select name="location" style="font-size: 10pt;">
513 <option value="">-- choose contact --</option>
515 foreach($values as $loc => $value) {
516 if ($loc != $folder_name) {
517 echo '<option value
="' . hsc($loc) . '"';
518 if ($loc == $location) echo ' selected
="selected"';
519 echo '>' . hsc($loc) . "</option>\n";
528 <input style="font-size: 10pt;" type="submit" name="take" value="Take"/>
529 <input style="font-size: 10pt;" type="submit" name="give" value="Give"/>
533 if ($message != '') {
534 echo '<tr
><td
></td
><td
class="alarm">' . hsc($message) . "</td></tr>\n";
538 foreach ($values as $name => $typevalues) {
539 if ($name != $folder_name) {
540 drawValues($name, $typevalues);
544 <p>Tap a value or asset name to take all the assets in that line.</p>
549 function drawLocations() {
550 global $session, $folder, $values, $folder_name;
551 global $qty, $type, $location, $greendot;
556 <table border="0" width="99%" cellpadding="3">
558 <td colspan="2" style="background-color: #c0c0c0; text-align: center;"><span style="font-weight: normal; font-size: 110%;"><a href="javascript:submitPage('main
');">Wallet</a>
560 <a href="javascript:submitPage('locations
');"><b>Contacts</b></a>
562 <a href="javascript:submitPage('logout
');">Logout</a>
566 <table border="0" width="99%">
567 <form name="mainform" method="post" action="" autocomplete="off">
570 echo '<input type
="hidden" name
="zip" value
="' . $qty . '"/>' . "\n";
572 hiddenValue('location
');
573 hiddenValue('newname
');
574 hiddenValue('newlocation
');
577 <input type="hidden" name="greendot" value=""/>
581 <a class="name_dot" href="javascript: greenDot('<?
echo $folder_name; ?
>', '')" title="Edit Name"> • </a>
585 if ($greendot != $folder_name) {
586 echo '<a
class="plain" href
="javascript: greenDot(' . "'" .
587 hsc($folder_name) . "', '')" . '" title
="Edit Name"><b
>' .
588 $folder_name . '</b
></a
>';
590 echo '<input style
="font-size: 12pt;" type
="text" size
="25" name
="newname" value
="' . hsc($folder_name) . '"/><br
/>' . "\n";
591 echo '<input type
="hidden" name
="oldname" value
="' . hsc($folder_name) . '"/>' . "\n";
592 echo '<input type
="submit" name
="savename" value
="Save"/>' . "\n";
593 echo '<input type
="submit" name
="cancel" value
="Cancel"/>' . "\n";
596 $locs = $folder['locs
'];
597 foreach ($locs as $name => $loc) {
598 if ($name != $folder_name) {
602 <a class=name_dot href="javascript: greenDot('<?
echo $name; ?
>', '')" title="Edit Name or Delete Folder"> • </a>
606 if ($greendot != $name) {
607 echo '<a
class="plain" href
="javascript: greenDot(' . "'" .
608 hsc($name) . "', '')" . '" title
="Edit Name or Delete Wallet">' .
611 echo '<input style
="font-size: 12pt;" type
="text" size
="25" name
="newname" value
="' . hsc($name) . '"/><br
/>' . "\n";
612 echo '<input type
="hidden" name
="oldname" value
="' . hsc($name) . '"/>' . "\n";
613 echo '<input type
="submit" name
="savename" value
="Save"/>' . "\n";
614 echo '<input type
="submit" name
="cancel" value
="Cancel"/>' . "\n";
616 echo '<input type
="submit" disabled name
="delete" value
="Delete..."/><br
/>' . "\n";
617 echo '</td
></tr
><tr
><td colspan
="2"><span
class="mono">' . "<b>$loc</b></span><br/>\n";
622 if ($message != '') {
623 echo '<tr
><td colspan
="2" class="alarm">' . hsc($message) . "</td></tr>\n";
626 <tr><td colspan="2"><input type="submit" name="add_location" value="Add Contact"/></td></tr>
629 <p>Tap a contact name to see its hex value, or to rename or delete it.</p>
633 function drawAddLocation() {
634 global $newname, $newlocation;
640 <form name="entryForm" method="post" action=""><b>
644 hiddenValue('commit
');
647 <input type="text" name="newname" style="font-size: 14pt;" size="25" value="<? echo $newname; ?>" onkeydown="submitOnRet(event, this.form)"/><br/>
648 Enter Contact, blank for random:<br/>
649 <input type="text" style="font-size: 11pt;" size="32" name="newlocation" value="<? echo $newlocation; ?>" onkeydown="submitOnRet(event, this.form)"/>
652 <td><input type="button" style="font-size: 18pt;" value="7" onClick="Do7(this.form)"></td>
653 <td><input type="button" style="font-size: 18pt;" value="8" onClick="Do8(this.form)"></td>
654 <td><input type="button" style="font-size: 18pt;" value="9" onClick="Do9(this.form)"></td>
655 <td><input type="button" style="font-size: 18pt;" value="F" onClick="DoF(this.form)"></td>
658 <td><input type="button" style="font-size: 18pt;" value="4" onClick="Do4(this.form)"></td>
659 <td><input type="button" style="font-size: 18pt;" value="5" onClick="Do5(this.form)"></td>
660 <td><input type="button" style="font-size: 18pt;" value="6" onClick="Do6(this.form)"></td>
661 <td><input type="button" style="font-size: 18pt;" value="E" onClick="DoE(this.form)"></td>
664 <td><input type="button" style="font-size: 18pt;" value="1" onClick="Do1(this.form)"></td>
665 <td><input type="button" style="font-size: 18pt;" value="2" onClick="Do2(this.form)"></td>
666 <td><input type="button" style="font-size: 18pt;" value="3" onClick="Do3(this.form)"></td>
667 <td><input type="button" style="font-size: 18pt;" value="D" onClick="DoD(this.form)"></td>
670 <td><input type="button" style="font-size: 18pt;" value="0" onClick="Do0(this.form)"></td>
671 <td><input type="button" style="font-size: 18pt;" value="A" onClick="DoA(this.form)"></td>
672 <td><input type="button" style="font-size: 18pt;" value="B" onClick="DoB(this.form)"></td>
673 <td><input type="button" style="font-size: 18pt;" value="C" onClick="DoC(this.form)"></td>
677 <input type="button" style="font-size: 18pt;" value="Del" onClick="DoBksp(this.form)">
678 <input type="button" style="font-size: 18pt;" value="Clr" onClick="DoClr(this.form)">
679 <input type="button" style="font-size: 18pt;" value="Enter" onClick="DoEnter(this.form)"><br/>
680 <input type="button" style="font-size: 18pt;" value="Cancel" onClick="DoCancel(this.form)"><br/>
686 global $folder, $folder_name, $folder_loc;
688 if ($folder == '') return refreshFolder();
689 $folder_name = $folder['name
'];
690 $folder_loc = $folder['loc
'];
694 function refreshFolder() {
695 global $client, $passphrase, $session;
696 global $folder, $folderkv, $folder_name, $folder_loc;
700 if ($session != '') {
701 $res = $client->touch_archive($session, $url);
702 if ($res['status
'] == 'success
') $loc = $res['content
'];
706 if ($passphrase != '') {
707 $loc = $client->hash2location($client->sha256($passphrase));
708 $session = $client->folderSession($loc);
713 $res = $client->touch_archive($loc, $url);
714 if ($res['status
'] != 'success
') return FALSE;
715 $folder = $client->parseFolder($loc, $res['content
']);
716 $folderkv = $client->array2kv($folder);
718 $folder_name = $folder['name
'];
719 $folder_loc = $folder['loc
'];
723 function fullRefresh() {
724 global $client, $folder, $values, $valueskv;
727 $values = scanFolder($folder);
728 $valueskv = $client->array2kv($values);
731 function blankToZero($x) {
732 if ($x == '') return 0;
736 // This is currently n-squared for pretty big n, since it has to do
737 // a web call for each location/type pair.
738 // Patrick has promised a scan() function in the web API that would
739 // allow it to be done with a single call.
740 /* Now uses Patrick's
scan() API call
741 function scanFolder($folder) {
744 $types = $folder['types'];
745 $locs = $folder['locs'];
747 foreach ($locs as $locname => $loc) {
748 $loc_values = array();
749 foreach ($types as $typename => $type) {
751 $min_precision = $type['min_precision'];
752 $scale = $type['scale'];
753 $res = $client->touch($id, $loc, $url);
754 if ($res['status'] == 'success') {
755 $value = $client->applyScale($res['value'], $min_precision, $scale);
756 $loc_values[$typename] = $value;
759 $values[$locname] = $loc_values;
765 function scanFolder($folder) {
768 return $client->namedScan($folder['locs'], $folder['types'], FALSE, $url);
772 // Copyright 2008 Bill St. Clair
774 // Licensed under the Apache License, Version 2.0 (the "License");
775 // you may not use this file except in compliance with the License.
776 // You may obtain a copy of the License at
778 // http://www.apache.org/licenses/LICENSE-2.0
780 // Unless required by applicable law or agreed to in writing, software
781 // distributed under the License is distributed on an "AS IS" BASIS,
782 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
783 // See the License for the specific language governing permissions
784 // and limitations under the License.