DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (87e68dba52ef)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
<?php

include 'HTTP/WebDAV/Client.php';

//error_reporting(E_NONE);

if (isset($_POST['log'])) {
  $user = urlencode($_POST['usr']);
  $pass = $_POST['pwd'];
  $serv = $_POST['srv'];
  
  $uri = "webdavs://$user:$pass@$serv/user/$user/";
  $ver = file_get_contents($uri."meta/version");
  
  if (!$ver) {
    /* Try again without https */
    $uri = "webdav://$user:$pass@$serv/user/$user/";
    $ver = file_get_contents($uri."meta/version");
  }
  
  if ($ver) {
    /* Setup the JSON to pass to client */
    $pkey = file_get_contents($uri."private/privkey");
    $bms = getJSON($uri, "bookmarks");
    $ses = getJSON($uri, "tabs");
    printHome($pkey, $bms, $ses, $_POST['usr'], $serv);
  } else {
    header("Location: index.php?error=1");
  }
} else {
  header("Location: index.php");
}

function getJSON($uri, $which) {
  $keys = file_get_contents($uri."user-data/$which/keys.json");
  if ($keys) {
    $stat = file_get_contents($uri."user-data/$which/status.json");
    $snap = file_get_contents($uri."user-data/$which/snapshot.json");

    $check = json_decode($stat, true);
    if ($check['snapEncryption'] != "none") 
      $snap = json_encode(file_get_contents($uri."user-data/$which/snapshot.json"));
      
    return array($keys, $stat, $snap);
  } else {
    return array(false, false, false);
  }
}

function printHome($pkey, $bmarks, $tabs, $user, $server)
{
  $time = date(DATE_RFC822);
  if (empty($pkey)) {
    $pkey = "false";
  }
  if (!$bmarks[0]) {
    $bmarks = array("false", "false", "false");
  }
  if (!$tabs[0]) {
    $tabs = array("false", "false", "false");    
  }
  
  $page = <<<EOT
<html>
<head>
  <title>Weave / Home</title>
  
  <!-- Weave Import -->
  <script type="text/javascript" src="weave/util.js"></script>
  <script type="text/javascript" src="weave/pkcs5v2.js"></script>
  <script type="text/javascript" src="weave/aes.js"></script>
  <script type="text/javascript" src="weave/asn1.js"></script>

  <!-- RSA Import -->
  <script type="text/javascript" src="weave/rsa/jsbn.js"></script>
  <script type="text/javascript" src="weave/rsa/jsbn2.js"></script>
  <script type="text/javascript" src="weave/rsa/prng4.js"></script>
  <script type="text/javascript" src="weave/rsa/rng.js"></script>
  <script type="text/javascript" src="weave/rsa/rsa.js"></script>
  <script type="text/javascript" src="weave/rsa/rsa2.js"></script>
  
  <!-- ProtoFlow -->
  <script type="text/javascript" src="proto/prototype.js"></script>
  <script type="text/javascript" src="proto/scriptaculous.js"></script>
  <script type="text/javascript" src="proto/reflection.js"></script>
  <script type="text/javascript" src="proto/protoFlow.js"></script>
  <link rel="stylesheet" type="text/css" href="proto/protoFlow.css" />
  
  <!-- YUI Import -->
  <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.5.2/build/assets/skins/sam/skin.css" />
  <script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/yahoo-dom-event/yahoo-dom-event.js"></script>
  <script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/element/element-beta-min.js"></script> 
  <script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/button/button-min.js"></script> 
  <script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/container/container-min.js"></script> 
  <script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/json/json-min.js"></script> 
  <script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/tabview/tabview-min.js"></script> 
  <script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/treeview/treeview-min.js"></script>
  
  <link rel="stylesheet" type="text/css" href="css/main.css" />
  <!-- Load up the JSON -->
  <script type="text/javascript">
    Weave.Xfer = {
      user: '$user',
      key: $pkey,
      bmk: {
        keys: $bmarks[0],
        stat: $bmarks[1],
        snap: $bmarks[2]
      },
      tab: {
        keys: $tabs[0],
        stat: $tabs[1],
        snap: $tabs[2]
      }
    };
  </script>
</head>
<body class="yui-skin-sam">
  <div class="user-msg">
    You are logged in as <b>$user@$server</b>
  </div>
  <div id="container"></div>
  <div id="message">
    <table class="msg">
      <tr>
        <td>
          <a href="javascript:securityPop()">
          <img border="none" src="images/clear-lock.png" />
          </a>
        </td>
        <td>&nbsp;</td>
        <td>
          Your data has been safely decrypted by your web browser. To learn more about how Weave 
          keeps your data safe, click the lock icon.<br />
          <b>To <a href="javascript:logoutPop()">logout</a>, simply close this page!</b><br />
          Last updated: $time
        </td>
      </tr>
    </table>
  </div>
  <div class="img-footer">
    Powered By <br />
    <a href="http://labs.mozilla.com/"><img border="none" src="images/weave-footer.png" /></a>
  </div>
</body>
  <!-- Let's get cracking! -->
  <script src="weave.js" language="javascript"></script>
</html>
EOT;

  echo $page;
}

?>