static function db()
 {
     if (is_null(self::$_db)) {
         $conn = new Mongo();
         self::$_db = $conn->selectDB(self::get_config('db_name'));
     }
     return self::$_db;
 }
 public function testAddUser()
 {
     /* check auth methods */
     $this->object->addUser("fred", "ted");
     MongoAuth::getHash("fred", "ted");
     $a2 = new MongoAdmin();
     $this->assertTrue($a2->connected);
     $a2->login("fred", "ted");
     $this->assertTrue($a2->loggedIn, json_encode($a2));
     $x = $this->object->changePassword("fred", "ted", "foobar");
     $this->assertEquals(1, $x['ok'], json_encode($x));
     $a2 = new MongoAdmin();
     $a2->login("fred", "ted");
     $this->assertFalse($a2->loggedIn);
     $a2 = new MongoAdmin();
     $a2->login("fred", "foobar");
     $this->assertTrue($a2->loggedIn);
     $this->object->deleteUser("fred");
     $a2 = new MongoAdmin();
     $a2->login("fred", "foobar");
     $this->assertFalse($a2->loggedIn);
 }
Exemple #3
0
 function index_method()
 {
     $vars = array();
     if (!empty($_GET['coll'])) {
         $coll = MongoAdmin::db()->selectCollection($_GET['coll']);
         $cur = $coll->find()->sort(array('_id' => 1));
         if (!empty($_GET['skip'])) {
             $skip = intval($_GET['skip']);
         } else {
             $skip = 0;
         }
         if ($skip < 0) {
             $skip = 0;
         }
         $limit = 20;
         $cur->skip($skip)->limit($limit);
         $vars['current_coll'] = $coll;
         $vars['cur'] = $cur;
         $vars['skip'] = $skip;
         $vars['limit'] = $limit;
     }
     MongoAdmin::tpl('index', $vars);
 }
Exemple #4
0
<![endif]-->
</head>
<body class="twoColElsLtHdr">
<div id="container">
  <div id="header">
    <h1>phpMongoAdmin - <?php 
echo h(MongoAdmin::db());
?>
</h1>
    <!-- end #header -->
  </div>
  <div id="sidebar1">
    <h3>listCollections</h3>
    <ul>
    <?php 
$coll_list = MongoAdmin::db()->listCollections();
foreach ($coll_list as $coll) {
    ?>
      <li><a href="<?php 
    echo url('default.index', array('coll' => $coll->getName()));
    ?>
"><?php 
    echo h($coll->getName());
    ?>
</a></li>
    <?php 
}
?>
    </ul>
    <!-- end #sidebar1 -->
  </div>
Exemple #5
0
<?php

require dirname(__FILE__) . '/lib/mongoadmin.php';
MongoAdmin::loadConfig(dirname(__FILE__) . '/config.php');
MongoAdmin::dispatching();
Exemple #6
0
 function drop_method()
 {
     $coll = MongoAdmin::db()->selectCollection($_REQUEST['coll']);
     $coll->remove(array('_id' => $_REQUEST['doc']));
     redirect(url('default.index', array('coll' => $coll->getName())));
 }