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.
48 @include
"ip-config.php";
53 if ($encrypt_key != '') {
55 if ($session_cipher != '') {
56 if ($folderkv != '') {
57 $folderkv = $session_cipher->decrypthex($folderkv);
59 if ($valueskv != '') {
60 $valueskv = $session_cipher->decrypthex($valueskv);
70 if ($page == 'refresh') {
75 if ($folderkv != '') $folder = $client->parsekv($folderkv, TRUE);
76 if ($valueskv != '') $values = $client->parsekv($valueskv, TRUE);
79 if (($session == '' && $passphrase == '') ||
!login()) {
80 $onload = 'passphrase';
84 $values = scanFolder($folder);
85 $valueskv = $client->array2kv($values);
89 $title = "Loom Wallet";
91 if ($page == 'main') doMain();
92 elseif ($page == 'locations') doLocations();
93 elseif ($page == 'add_location') doAddLocation();
94 elseif ($page == 'logout') doLogout();
98 if ($page == 'login') drawLogin();
99 elseif ($page == 'main') drawMain();
100 elseif ($page == 'locations') drawLocations();
101 elseif ($page == 'add_location') drawAddLocation();
106 global $qty, $type, $location, $take, $give;
107 global $client, $folder, $folder_loc, $folder_name;
108 global $values, $valueskv;
110 global $greendot, $contact;
114 if ($greendot != '') {
116 $qty = $values[$contact][$type];
117 if ($contact != $folder_name) {
118 $location = $contact;
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>
403 <p>One way to use this, without potentially 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
404 <a href="https://loom.cc/">
405 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
>
410 function hsc($text) {
411 return htmlspecialchars($text);
414 function hiddenValue($name) {
415 eval('global $' . $name . ';');
416 echo '<input type="hidden" name="' . $name .
417 '" value="' . hsc(eval('return $' . $name . ';')) . '"/>' . "\n";
420 function drawValues($name, $typevalues) {
422 if ($name == $folder_name) $title = 'Move to Qty & asset type';
423 else $title = 'Take';
424 if (is_array($typevalues)) {
426 foreach ($typevalues as $type => $value) {
427 $link = '<a class="plain" href="javascript: greenDot(' . "'" .
428 hsc($type) . "', '" . hsc($name) . "')" . '" title="' . $title . '">';
431 $str .= "<b>" . hsc($name) . "</b>\n";
432 $str .= '<table border="0"><tr><td width="50px"> </td><td>';
433 $str .= '<table border="0">' . "\n";
435 $str .= '<tr><td align="right">' . $link . $value . "</a></td>\n" .
436 "<td>" . $link . $type. "</a></td></tr>\n";
441 echo "</table></td></tr></table>\n";
446 function writeSessionInfo() {
447 global $cipher, $session_cipher;
448 global $session, $folderkv, $valueskv;
450 $enc_session = $session;
451 $enc_folderkv = $folderkv;
452 $enc_valueskv = $valueskv;
454 if ($cipher) $enc_session = $cipher->encrypt2hex($enc_session);
455 if ($session_cipher) {
456 $enc_folderkv = $session_cipher->encrypt2hex($enc_folderkv);
457 $enc_valueskv = $session_cipher->encrypt2hex($enc_valueskv);
459 echo '<input type="hidden" name="session" value="' . hsc($enc_session) . '"/>' . "\n";
460 echo '<input type="hidden" name="folderkv" value="' . hsc($enc_folderkv) . '"/>' . "\n";
461 echo '<input type="hidden" name="valueskv" value="' . hsc($enc_valueskv) . '"/>' . "\n";
464 function drawMain() {
465 global $session, $folder, $values, $folder_name;
466 global $qty, $type, $location;
472 <table border
="0" width
="99%" cellpadding
="3">
474 <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
>
476 <a href
="javascript:submitPage('locations');">Contacts
</a
>
478 <a href
="javascript:submitPage('logout');">Logout
</a
>
483 drawValues($folder_name, $values[$folder_name]);
485 <table border
="0" width
="99%">
486 <form name
="mainform" method
="post" action
="" autocomplete
="off">
487 <input type
="hidden" name
="greendot" value
=""/>
488 <input type
="hidden" name
="contact" value
=""/>
494 <td align
="right">Qty
:</td
>
495 <td
><input style
="font-size: 12pt;" type
="text" size
="25" name
="zip" value
="<? echo $qty; ?>" style
="text-align:right;"></td
>
499 <select name
="type" style
="font-size: 10pt;">
500 <option value
="">-- choose asset
--</option
>
502 foreach ($folder['types'] as $typename => $typearray) {
503 echo '<option value="' . hsc($typename) . '"';
504 if ($type == $typename) echo ' selected="selected"';
505 echo '>' . hsc($typename) . "</option>\n";
513 <select name
="location" style
="font-size: 10pt;">
514 <option value
="">-- choose contact
--</option
>
516 foreach($values as $loc => $value) {
517 if ($loc != $folder_name) {
518 echo '<option value="' . hsc($loc) . '"';
519 if ($loc == $location) echo ' selected="selected"';
520 echo '>' . hsc($loc) . "</option>\n";
529 <input style
="font-size: 10pt;" type
="submit" name
="give" value
="Give"/>
530 <input style
="font-size: 10pt;" type
="submit" name
="take" value
="Take"/>
534 if ($message != '') {
535 echo '<tr><td></td><td class="alarm">' . hsc($message) . "</td></tr>\n";
539 foreach ($values as $name => $typevalues) {
540 if ($name != $folder_name) {
541 drawValues($name, $typevalues);
545 <p
>Tap a value
or asset name to take all the assets in that line
.</p
>
550 function drawLocations() {
551 global $session, $folder, $values, $folder_name;
552 global $qty, $type, $location, $greendot;
557 <table border
="0" width
="99%" cellpadding
="3">
559 <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
>
561 <a href
="javascript:submitPage('locations');"><b
>Contacts
</b
></a
>
563 <a href
="javascript:submitPage('logout');">Logout
</a
>
567 <table border
="0" width
="99%">
568 <form name
="mainform" method
="post" action
="" autocomplete
="off">
571 echo '<input type="hidden" name="zip" value="' . $qty . '"/>' . "\n";
573 hiddenValue('location');
574 hiddenValue('newname');
575 hiddenValue('newlocation');
578 <input type
="hidden" name
="greendot" value
=""/>
582 <a
class="name_dot" href
="javascript: greenDot('<? echo $folder_name; ?>', '')" title
="Edit Name"> 
;&bull
; 
;</a
>
586 if ($greendot != $folder_name) {
587 echo '<a class="plain" href="javascript: greenDot(' . "'" .
588 hsc($folder_name) . "', '')" . '" title="Edit Name"><b>' .
589 $folder_name . '</b></a>';
591 echo '<input style="font-size: 12pt;" type="text" size="25" name="newname" value="' . hsc($folder_name) . '"/><br/>' . "\n";
592 echo '<input type="hidden" name="oldname" value="' . hsc($folder_name) . '"/>' . "\n";
593 echo '<input type="submit" name="savename" value="Save"/>' . "\n";
594 echo '<input type="submit" name="cancel" value="Cancel"/>' . "\n";
597 $locs = $folder['locs'];
598 foreach ($locs as $name => $loc) {
599 if ($name != $folder_name) {
603 <a
class=name_dot href
="javascript: greenDot('<? echo $name; ?>', '')" title
="Edit Name or Delete Folder"> 
;&bull
; 
;</a
>
607 if ($greendot != $name) {
608 echo '<a class="plain" href="javascript: greenDot(' . "'" .
609 hsc($name) . "', '')" . '" title="Edit Name or Delete Wallet">' .
612 echo '<input style="font-size: 12pt;" type="text" size="25" name="newname" value="' . hsc($name) . '"/><br/>' . "\n";
613 echo '<input type="hidden" name="oldname" value="' . hsc($name) . '"/>' . "\n";
614 echo '<input type="submit" name="savename" value="Save"/>' . "\n";
615 echo '<input type="submit" name="cancel" value="Cancel"/>' . "\n";
617 echo '<input type="submit" disabled name="delete" value="Delete..."/><br/>' . "\n";
618 echo '</td></tr><tr><td colspan="2"><span class="mono">' . "<b>$loc</b></span><br/>\n";
623 if ($message != '') {
624 echo '<tr><td colspan="2" class="alarm">' . hsc($message) . "</td></tr>\n";
627 <tr
><td colspan
="2"><input type
="submit" name
="add_location" value
="Add Contact"/></td
></tr
>
630 <p
>Tap a contact name to see its hex value
, or to rename
or delete it
.</p
>
634 function drawAddLocation() {
635 global $newname, $newlocation;
641 <form name
="entryForm" method
="post" action
=""><b
>
645 hiddenValue('commit');
648 <input type
="text" name
="newname" style
="font-size: 14pt;" size
="25" value
="<? echo $newname; ?>" onkeydown
="submitOnRet(event, this.form)"/><br
/>
649 Enter Contact
, blank
for random
:<br
/>
650 <input type
="text" style
="font-size: 11pt;" size
="32" name
="newlocation" value
="<? echo $newlocation; ?>" onkeydown
="submitOnRet(event, this.form)"/>
653 <td
><input type
="button" style
="font-size: 18pt;" value
="7" onClick
="Do7(this.form)"></td
>
654 <td
><input type
="button" style
="font-size: 18pt;" value
="8" onClick
="Do8(this.form)"></td
>
655 <td
><input type
="button" style
="font-size: 18pt;" value
="9" onClick
="Do9(this.form)"></td
>
656 <td
><input type
="button" style
="font-size: 18pt;" value
="F" onClick
="DoF(this.form)"></td
>
659 <td
><input type
="button" style
="font-size: 18pt;" value
="4" onClick
="Do4(this.form)"></td
>
660 <td
><input type
="button" style
="font-size: 18pt;" value
="5" onClick
="Do5(this.form)"></td
>
661 <td
><input type
="button" style
="font-size: 18pt;" value
="6" onClick
="Do6(this.form)"></td
>
662 <td
><input type
="button" style
="font-size: 18pt;" value
="E" onClick
="DoE(this.form)"></td
>
665 <td
><input type
="button" style
="font-size: 18pt;" value
="1" onClick
="Do1(this.form)"></td
>
666 <td
><input type
="button" style
="font-size: 18pt;" value
="2" onClick
="Do2(this.form)"></td
>
667 <td
><input type
="button" style
="font-size: 18pt;" value
="3" onClick
="Do3(this.form)"></td
>
668 <td
><input type
="button" style
="font-size: 18pt;" value
="D" onClick
="DoD(this.form)"></td
>
671 <td
><input type
="button" style
="font-size: 18pt;" value
="0" onClick
="Do0(this.form)"></td
>
672 <td
><input type
="button" style
="font-size: 18pt;" value
="A" onClick
="DoA(this.form)"></td
>
673 <td
><input type
="button" style
="font-size: 18pt;" value
="B" onClick
="DoB(this.form)"></td
>
674 <td
><input type
="button" style
="font-size: 18pt;" value
="C" onClick
="DoC(this.form)"></td
>
678 <input type
="button" style
="font-size: 18pt;" value
="Del" onClick
="DoBksp(this.form)">
679 <input type
="button" style
="font-size: 18pt;" value
="Clr" onClick
="DoClr(this.form)">
680 <input type
="button" style
="font-size: 18pt;" value
="Enter" onClick
="DoEnter(this.form)"><br
/>
681 <input type
="button" style
="font-size: 18pt;" value
="Cancel" onClick
="DoCancel(this.form)"><br
/>
687 global $folder, $folder_name, $folder_loc;
689 if ($folder == '') return refreshFolder();
690 $folder_name = $folder['name'];
691 $folder_loc = $folder['loc'];
695 function refreshFolder() {
696 global $client, $passphrase, $session;
697 global $folder, $folderkv, $folder_name, $folder_loc;
701 if ($session != '') {
702 $res = $client->touch_archive($session, $url);
703 if ($res['status'] == 'success') $loc = $res['content'];
707 if ($passphrase != '') {
708 $loc = $client->hash2location($client->sha256($passphrase));
709 $session = $client->folderSession($loc);
714 $res = $client->touch_archive($loc, $url);
715 if ($res['status'] != 'success') return FALSE;
716 $folder = $client->parseFolder($loc, $res['content']);
717 $folderkv = $client->array2kv($folder);
719 $folder_name = $folder['name'];
720 $folder_loc = $folder['loc'];
724 function fullRefresh() {
725 global $client, $folder, $values, $valueskv;
728 $values = scanFolder($folder);
729 $valueskv = $client->array2kv($values);
732 function blankToZero($x) {
733 if ($x == '') return 0;
737 // This is currently n-squared for pretty big n, since it has to do
738 // a web call for each location/type pair.
739 // Patrick has promised a scan() function in the web API that would
740 // allow it to be done with a single call.
741 /* Now uses Patrick's scan() API call
742 function scanFolder($folder) {
745 $types = $folder['types'];
746 $locs = $folder['locs'];
748 foreach ($locs as $locname => $loc) {
749 $loc_values = array();
750 foreach ($types as $typename => $type) {
752 $min_precision = $type['min_precision'];
753 $scale = $type['scale'];
754 $res = $client->touch($id, $loc, $url);
755 if ($res['status'] == 'success') {
756 $value = $client->applyScale($res['value'], $min_precision, $scale);
757 $loc_values[$typename] = $value;
760 $values[$locname] = $loc_values;
766 function scanFolder($folder) {
769 return $client->namedScan($folder['locs'], $folder['types'], FALSE, $url);
772 /* ***** BEGIN LICENSE BLOCK *****
773 * Version: MPL 1.1/GPL 2.0/LGPL 2.1/Apache 2.0
775 * The contents of this file are subject to the Mozilla Public License Version
776 * 1.1 (the "License"); you may not use this file except in compliance with
777 * the License. You may obtain a copy of the License at
778 * http://www.mozilla.org/MPL/
780 * Software distributed under the License is distributed on an "AS IS" basis,
781 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
782 * for the specific language governing rights and limitations under the
785 * The Original Code is LoomClient PHP library
787 * The Initial Developer of the Original Code is
789 * Portions created by the Initial Developer are Copyright (C) 2008
790 * the Initial Developer. All Rights Reserved.
793 * Bill St. Clair <bill@billstclair.com>
795 * Alternatively, the contents of this file may be used under the
796 * terms of the GNU General Public License Version 2 or later (the
797 * "GPL"), the GNU Lesser General Public License Version 2.1 or later
798 * (the "LGPL"), or The Apache License Version 2.0 (the "AL"), in
799 * which case the provisions of the GPL, LGPL, or AL are applicable
800 * instead of those above. If you wish to allow use of your version of
801 * this file only under the terms of the GPL, the LGPL, or the AL, and
802 * not to allow others to use your version of this file under the
803 * terms of the MPL, indicate your decision by deleting the provisions
804 * above and replace them with the notice and other provisions
805 * required by the GPL or the LGPL. If you do not delete the
806 * provisions above, a recipient may use your version of this file
807 * under the terms of any one of the MPL, the GPL the LGPL, or the AL.
808 ****** END LICENSE BLOCK ***** */