function xcopy($source, $dest, $permissions = 0755) { if (is_link($source)) { return symlink(readlink($source), $dest); } if (is_file($source)) { return copy($source, $dest); } if (!is_hm($dest)) { mkhm($dest, $permissions); } $hm = hm($source); while (false !== ($entry = $hm->read())) { if ($entry == '.' || $entry == '..') { continue; } $this->xcopy("{$source}/{$entry}", "{$dest}/{$entry}", $permissions); } $hm->close(); return true; }
function hm_backtrace($limit = 0) { $new = array(); $backtrace = debug_backtrace(); array_shift($backtrace); foreach ($backtrace as $num => $val) { if ($val['function'] == 'do_action') { $new[$num] = reset($val['args']) . ' (via do_action)'; } else { $new[$num] = array('function' => $val['function']); } if (!empty($val['line'])) { $new[$num]['line'] = $val['line']; } if (!empty($val['file'])) { $new[$num]['file'] = $val['file']; } if (!empty($val['class'])) { $new[$num]['class'] = $val['class']; } } hm($new); }
hm("alive"); ?> :</td> <td> <select name="expire" style="width:150px"> <?php foreach ($expires as $long => $name) { ?> <option value="<?php h($long); ?> "><?php h($name); ?> </option> <?php } ?> </select> </td> </tr> </tbody> <tr> <td colspan="2" align="center"><input type="submit" value="<?php hm("loginandrock"); ?> "/></td> </tr> </table> </form> </div>
<td><?php h($value["local_value"]); ?> </td> </tr> <?php } ?> </table> <div class="gap"></div> <table bgcolor="#cccccc" cellpadding="2" cellspacing="1" width="600"> <tr> <th colspan="2"><a href="http://www.mongodb.org/downloads" target="_blank"><?php hm("build_info"); ?> </a> ({buildinfo:1})</th> </tr> <?php foreach ($buildInfos as $param => $value) { ?> <tr bgcolor="#fffeee"> <td width="120" valign="top"><?php h($param); ?> </td> <td><?php h($value); ?> </td>
h(url("server.processlist")); ?> " target="right"><?php hm("processlist"); ?> </a> <br/> <a href="<?php h(url("server.command")); ?> " target="right"><?php hm("command"); ?> </a> <br/> <a href="<?php h(url("server.execute")); ?> " target="right"><?php hm("execute"); ?> </a> <br/> <a href="<?php h(url("server.replication")); ?> " target="right"><?php hm("master_slave"); ?> </a> </div> </body> </html>
<p class="message"><?php h($db); ?> » <?php h($collection); ?> <?php hm("dropped_from_database"); ?> .</p> <script language="javascript"> window.parent.frames["left"].location.reload(); </script>
?> </a> | <?php } ?> <?php if ($row["can_refresh"]) { ?> <a href="#" onclick="refreshRecord('<?php h(rock_id_string($row["_id"])); ?> ',<?php h($index); ?> );return false;"><?php hm("refresh"); ?> </a> | <?php } ?> <!-- render operation menu --> <?php render_doc_menu($db, $collection, isset($row["_id"]) ? rock_id_string($row["_id"]) : 0, $index); ?> <!-- for gridfs --> <?php if (MCollection::isFile($row)) { ?> | GridFS: <a href="<?php
} ?> /><br/> <input type="submit" value="<?php hm("save"); ?> "/> </form> <?php if (isset($ret)) { ?> <div style="border:2px #ccc solid;margin-bottom:5px;background-color:#eeefff"> <?php hm("responseserver"); ?> <div style="margin-top:5px"> <?php h($ret_json); ?> </div> </div> <?php if ($ret["ok"]) { ?> <script language="javascript"> window.parent.frames["left"].location.reload(); </script> <?php
<h3><?php render_navigation($db); ?> » <?php hm("repair_database"); ?> </h3> <div style="border:2px #ccc solid;margin-bottom:5px;background-color:#eeefff"> <?php hm("response_from_server"); ?> : <div style="margin-top:5px"> <?php h($ret); ?> </div> </div>
if (isset($error2)) { ?> <p class="error"><?php h($error2); ?> </p><?php } if (isset($message2)) { ?> <p class="message"><?php h($message2); ?> </p> <script language="javascript"> window.parent.frames["left"].location.reload(); </script> <?php } ?> <p><strong>.json</strong> file exported with <a href="http://www.mongodb.org/display/DOCS/Import+Export+Tools" target="_blank">mongoexport</a>:</p> <form method="post" enctype="multipart/form-data"> <input type="hidden" name="format" value="json"/> Import to collection name:<input type="text" name="collection"/><br/> JSON File: <input type="file" style="width:400px" name="json"/><br/> <input type="submit" value="<?php hm("import"); ?> "/> </form>
h($code); ?> " <?php if (x("lang") == $code || x("lang") == "" && __LANG__ == $code) { ?> selected="selected"<?php } ?> ><?php h($lang); ?> </option> <?php } ?> </select></td> </tr> </tbody> <tr> <td colspan="2" align="center"><input type="submit" value="<?php hm("loginandrock"); ?> "/></td> </tr> </table> </form> <?php hm("rockmongocredits"); ?> </div>
<td align="center" valign="top"><?php if (isset($index["unique"]) && $index["unique"]) { ?> Y<?php } ?> </td> <td align="center" valign="top"><?php if (!isset($index["key"]["_id"]) || count($index["key"]) != 1) { ?> <a href="<?php h(url("collection.deleteIndex", array("db" => $db, "collection" => $collection, "index" => $index["name"]))); ?> " onclick="return window.confirm('<?php hm("warningindex"); ?> \'<?php h($index["name"]); ?> \'?');"><?php hm("drop"); ?> </a><?php } ?> </td> </tr> <?php } ?> </table>
<h3><?php render_navigation($db); ?> » <?php hm("authentication"); ?> </h3> <div class="operation"> <a href="<?php h(url("db.auth", array("db" => $db))); ?> " class="current">Users</a> | <a href="<?php h(url("db.addUser", array("db" => $db))); ?> ">Add User</a> </div> <table bgcolor="#cccccc" cellpadding="2" cellspacing="1" width="600"> <tr> <th>ID</th> <th>User</th> <th>Read Only</th> <th>Operation</th> </tr> <?php foreach ($users as $user) { ?> <tr bgcolor="#fffeee"> <td width="120" ><?php
?> "> <table width="100%"> <?php foreach ($logs as $log) { ?> <tr> <td valign="top"> <div style="background-color:#efefef;margin-bottom:10px"> <div style="border-bottom:1px #ccc solid"><?php echo $log["time"]; ?> [<a href="index.php?<?php echo $log["query"]; ?> "><?php hm("requery"); ?> </a>]</div> <div><?php echo $log["params"]["criteria"]; ?> </div> </div> </td> </tr> <?php } ?> </table> </div>
/** * Intelligently error_log the passed var. * * @access public * @param mixed $code * @return null */ function hm_log($code) { error_log(hm($code, false)); }
<?php function hm($v) { return htmlspecialchars($v); } $debut = microtime(); for ($i = 0; $i < 10000; $i++) { echo hm('Lorem ipsum') . '<br />'; } $fin = microtime(); file_put_contents('bench.txt', file_get_contents('bench.txt') . "\n" . ($fin - $debut)); $debut = microtime(); for ($i = 0; $i < 10000; $i++) { echo htmlspecialchars('Lorem ipsum') . '<br />'; } $fin = microtime(); var_dump($fin - $debut); file_put_contents('bench.txt', file_get_contents('bench.txt') . "\n" . 'NoAlias' . "\n" . ($fin - $debut)); $debut = microtime(); for ($i = 0; $i < 10000; $i++) { echo 'Lorem ipsum' . '<br />'; } $fin = microtime(); var_dump($fin - $debut); file_put_contents('bench.txt', file_get_contents('bench.txt') . "\n" . 'Nothing' . "\n" . ($fin - $debut));
hm("dropdatabase"); ?> </h3> <div style="border:2px #ccc solid;margin-bottom:5px;background-color:#eeefff"> <?php hm("responseserver"); ?> <div style="margin-top:5px"> <?php h($ret); ?> </div> </div> <p> <input type="button" value="<?php hm("gotodbs"); ?> " onclick="window.location='<?php h(url("server.databases")); ?> '"/> </p> <script language="javascript"> window.parent.frames["left"].location = "<?php h(url("admin.dbs")); ?> "; </script>
?> <form method="post"> <?php hm("username"); ?> :<br/> <input type="text" name="username" value="<?php h_escape(x("username")); ?> "/><br/> <?php hm("password"); ?> :<br/> <input type="password" name="password"/><br/> <?php hm("confirm_pass"); ?> :<br/> <input type="password" name="password2"/><br/> <?php hm("readonly"); ?> <br/> <input type="checkbox" name="readonly" value="1"/><br/> <input type="submit" value="<?php hm("addreplace"); ?> "/> </form> </div>
} ?> </table> <?php } ?> <?php if (!empty($masters)) { ?> <div class="gap"></div> <table bgcolor="#cccccc" cellpadding="2" cellspacing="1" width="600"> <tr> <th colspan="2"><?php hm("masters"); ?> (<a href="<?php h(url("collection.index", array("db" => "local", "collection" => "sources"))); ?> ">local.sources</a>)</th> </tr> <?php foreach ($masters as $master) { ?> <tr bgcolor="#cfffff"> <td colspan="2"><?php h($master["_id"]); ?> </td> </tr>
</table> <br/> </div> <div> <h3><?php hm("indexes"); ?> </h3> <?php hm("copyindexes"); ?> <input type="checkbox" name="copy_indexes" value="1" <?php if (x("copy_indexes")) { ?> checked="checked"<?php } ?> /> <br/><br/> </div> <div> <h3><?php hm("confirm"); ?> </h3> <input type="submit" value="<?php hm("transfer"); ?> "/> </div> </form>
<?php hm("about_content");
<input type="text" name="target" value="<?php h(x("target")); ?> "/><br/> <?php hm("removeifexists"); ?> <br/> <input type="checkbox" name="remove_target" value="1" <?php if (x("remove_target")) { ?> checked="checked"<?php } ?> /><br/> <?php hm("copyindexes"); ?> <br/> <input type="checkbox" name="copy_indexes" value="1" <?php if (x("copy_indexes")) { ?> checked="checked"<?php } ?> /><br/> <input type="submit" value="<?php hm("duplicate"); ?> "/> </form>
hm("dropdatabase"); ?> </h3> <p style="font-size:14px"> <?php hm("dropwarning"); ?> <?php h($db); ?> ? </p> <p style="font-size:14px"> <?php hm("dropwarning2"); ?> </p> <input type="button" value="<?php hm("yes"); ?> " onclick="window.location='<?php h(url("db.dropDatabase", array("db" => $db, "confirm" => 1))); ?> '"/> <input type="button" value="<?php hm("back"); ?> " onclick="window.location='<?php h(url("db.index", array("db" => $db))); ?> '"/>
<?php } ?> </ul> </li> <?php } ?> <?php if ($showDbSelector) { ?> <li> <img src="<?php render_theme_path(); ?> /images/database.png" align="absmiddle" width="14"/> <form id="selector" action="#" style="display:inline"> <input type="text" name="db" id="db" /> <input type="submit" value="<?php hm("selectdb"); ?> "> </form> </li> <?php } ?> </ul> <div style="height:40px"></div> </div>
:<br/> <select name="format" onchange="switchFormat(this)"> <option value="array" <?php if ($last_format == "array") { ?> selected="selected"<?php } ?> >Array</option> <option value="json" <?php if ($last_format == "json") { ?> selected="selected"<?php } ?> >JSON</option> </select> <br/> <?php hm("data"); ?> <br/> <textarea rows="35" cols="70" name="data" id="row_data"><?php echo x("data"); ?> </textarea><br/> <input type="submit" value="<?php hm("save"); ?> "/> </form>
?> </th> <th nowrap><?php hm("datasize"); ?> </th> <th nowrap><?php hm("indexsize"); ?> </th> <th><?php hm("collections"); ?> </th> <th><?php hm("objects"); ?> </th> </tr> <?php foreach ($dbs as $db) { ?> <tr bgcolor="#fffeee"> <td width="120" valign="top"><a href="<?php h(url("db.index", array("db" => $db["name"]))); ?> "><?php h($db["name"]); ?> </a></td> <td width="80"><?php
h($prog[$param]); } } ?> <?php } ?> </td> <?php } ?> </tr> <?php if (isset($prog["query"])) { ?> <tr bgcolor="#fffeee"> <td colspan="10"><strong><?php hm("query"); ?> </strong><br/>-----<br/><?php h($prog["query"]); ?> </td> </tr> <?php } ?> <?php } ?> </table>
<div class="operation"> <?php render_server_menu("status"); ?> </div> <table bgcolor="#cccccc" cellpadding="2" cellspacing="1" width="600"> <tr> <th colspan="2"><?php hm("server_status"); ?> ({serverStatus:1})</th> </tr> <?php foreach ($status as $param => $value) { ?> <tr bgcolor="#fffeee"> <td width="120" valign="top"><?php h($param); ?> </td> <td><?php h($value); ?> </td> </tr> <?php } ?> </table>
h($message); ?> </p> <?php } ?> <?php if (!empty($_POST)) { ?> <script language="javascript"> window.parent.frames["left"].location.reload(); </script> <?php } ?> <form method="post"> <?php hm("name"); ?> :<br/> <input type="text" name="name" value="<?php h(x("name")); ?> "/><br/> <input type="submit" value="<?php hm("create"); ?> " /> </form>
} } ?> </div> <div class="right"><?php h($admin); ?> | <a href="#" onclick="showManuals(this);return false;"><?php hm("manuals"); ?> <span style="font-size:11px">▼</span></a> | <a href="<?php h(url("plugins.index")); ?> " target="right">Plugins</a> | <a href="<?php h($logoutUrl); ?> " target="_top"><?php hm("logout"); ?> </a> | <?php render_select("language", rock_load_languages(), __LANG__, array("style" => "width:100px", "onchange" => "window.top.location='index.php?action=admin.changeLang&lang='+this.value")); ?> | <a href="<?php h(url("admin.about")); ?> " target="right">RockMongo v<?php h(ROCK_MONGO_VERSION); ?> </a></div> <div class="clear"></div> </div>