Ticket #966: deep_manifest.php

File deep_manifest.php, 2.0 KB (added by secorp, at 2010-09-12T15:30:03Z)
Line 
1<?php
2  $page_title = "Allmydata - Deep Manifest";
3
4  require(".inc/includes.php");
5  require(".inc/ui/dbconnection.php");
6
7//  echo "<table>";
8//  echo "<tr><td><b>Your browser is:</b></td><td>{$_SERVER['HTTP_USER_AGENT']}</td></tr>";
9//  echo "<tr><td><b>Your referrer is:</b></td><td>{$_SERVER['HTTP_REFERER']}</td></tr>";
10//  echo "</table>";
11//  echo "<table>";
12//  echo "<tr><td>Num</td><td>Email</td><td>Account ID</td><td>Base URI</td><td>Size</td></tr>";
13
14  // get list of accounts and then figure out amount of space used
15  $query = "select * from user where active = 1 and base_uri <> '' order by account_id desc limit 0";
16  echo "account_id,CHK,DIR<br>";
17  $q_results = mysql_query($query);
18  $i = 1;
19  while($results = mysql_fetch_array($q_results)) {
20    $base_uri = $results['base_uri'];
21    $account_id = $results['account_id'];
22    $email = $results['email'];
23    $ch = curl_init();
24    $uri_url = "http://webapi.allmydata.com:8123/uri/";
25    $full_url = $uri_url . urlencode($base_uri) . "?t=manifest";
26//    echo $full_url;
27    curl_setopt($ch, CURLOPT_URL, $full_url);
28    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
29    $body = curl_exec($ch);
30    $manifest_array = explode("URI:", $body);
31    $j = 0;
32    $CHK_count = 0;
33    $DIR_count = 0;
34    while($manifest_line = $manifest_array[$j]) {
35      //echo '"' . $manifest_line . '"';
36      if(strstr($manifest_line, "CHK")) {
37        $CHK_count = $CHK_count + 1;
38      } else if(strstr($manifest_line, "DIR")) {
39        $DIR_count = $DIR_count + 1;
40      }
41      $j = $j+1;
42    }
43    echo $account_id . ",";
44    echo $CHK_count . ",";
45    echo $DIR_count;
46    echo "<br>";
47//    $inner_query = "update user set used_quota=" . $size . " where account_id = ". $account_id;
48//    $results = mysql_query($inner_query);
49//    echo "<tr><td>" . $i . "</td><td>" . $email . "</td><td>" . $account_id . "</td><td>" . $base_uri . "</td><td>" . $size . "</td></tr>";
50    $i = $i + 1;
51    usleep(500000);
52  }
53//  echo "</table>";
54//  mysql_close($connect);
55?>