Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

php 7.0 #131

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions INSTALL.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
Installation
--------------------------------------
1. Install PHP runtime environment if you don't have one yet, such like Apache Httpd, Nginx ...
2. Install MongoDB PHP driver (http://us.php.net/manual/en/mongo.installation.php)
3. Download the package from http://rockmongo.com/downloads
2. Install MongoDB PHP driver (http://php.net/manual/en/set.mongodb.php)
3. Download the package
4. Unzip the files into your disk, under root of your site
5. Open the config.php with your convenient editor, change host, port, admins and so on to yours
6. Visit the index.php in your browser, for example: http://localhost/rockmongo/index.php
7. Login with admin username and password, which is set "admin" and "admin" as default
8. Play with your MongoDBs!

Upgrade from old version
--------------------------------------
1.Copy all files excluding config.php to your old version directory
2.Done!


How to install
5. Run composer install
6. Open the config.php with your convenient editor, change host, port, admins and so on to yours
7. Visit the index.php in your browser, for example: http://localhost/rockmongo/index.php
8. Login with admin username and password, which is set "admin" and "admin" as default
9. Play with your MongoDBs!
20 changes: 13 additions & 7 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
Introduction
--------------------------------------
RockMongo is a MongoDB administration tool, written in PHP 5, very easy to install and use.
It has been modified to work with php7.0. Tested on debian 8.

Dependencies
--------------------------------------
alcaeus/mongo-php-adapter


Installation
--------------------------------------
1. Install PHP runtime environment if you don't have one yet, such like Apache Httpd, Nginx ...
2. Install MongoDB PHP driver (http://us.php.net/manual/en/mongo.installation.php)
3. Download the package from http://rockmongo.com/downloads
2. Install MongoDB PHP driver (http://php.net/manual/en/set.mongodb.php)
3. Download the package
4. Unzip the files into your disk, under root of your site
5. Open the config.php with your convenient editor, change host, port, admins and so on to yours
6. Visit the index.php in your browser, for example: http://localhost/rockmongo/index.php
7. Login with admin username and password, which is set "admin" and "admin" as default
8. Play with your MongoDBs!
5. Run composer install
6. Open the config.php with your convenient editor, change host, port, admins and so on to yours
7. Visit the index.php in your browser, for example: http://localhost/rockmongo/index.php
8. Login with admin username and password, which is set "admin" and "admin" as default
9. Play with your MongoDBs!


Upgrade from old version
Expand Down Expand Up @@ -52,7 +58,7 @@ Please feel free to report any bugs and issues to me, my email is: iwind.liu@gma

Source Code Repository
--------------------------------------
Repositories are located at
Original repositories are located at
https://github.com/iwind/rockmongo.git


Expand Down
54 changes: 27 additions & 27 deletions app/classes/VarEval.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,36 @@
class VarEval {
/**
* Source to run
*
*
* @var string
*/
private $_source;

/**
* Source Format
*
*
* @var string
*/
private $_format;

/**
* current MongoDB
*
* @var MongoDB
*/
private $_db;

function __construct($source, $format = "array", MongoDB $db = null) {
$this->_source = $source;

$this->_format = $format;
if (!$this->_format) {
$this->_format = "array";
}

$this->_db = $db;
}

/**
* execute the code
*
Expand All @@ -49,7 +49,7 @@ function execute() {
return $this->_runJson();
}
}

private function _runPHP() {
$this->_source = "return " . $this->_source . ";";
if (function_exists("token_get_all")) {//tokenizer extension may be disabled
Expand All @@ -59,30 +59,30 @@ private function _runPHP() {
$type = $token[0];
if (is_long($type)) {
if (in_array($type, array(
T_OPEN_TAG,
T_RETURN,
T_WHITESPACE,
T_ARRAY,
T_LNUMBER,
T_OPEN_TAG,
T_RETURN,
T_WHITESPACE,
T_ARRAY,
T_LNUMBER,
T_DNUMBER,
T_CONSTANT_ENCAPSED_STRING,
T_DOUBLE_ARROW,
T_CONSTANT_ENCAPSED_STRING,
T_DOUBLE_ARROW,
T_CLOSE_TAG,
T_NEW,
T_DOUBLE_COLON
))) {
continue;
}

if ($type == T_STRING) {
$func = strtolower($token[1]);
if (in_array($func, array(
//keywords allowed
"mongoid",
"mongocode",
"mongodate",
"mongoregex",
"mongobindata",
"mongoid",
"mongocode",
"mongodate",
"mongoregex",
"mongobindata",
"mongoint32",
"mongoint64",
"mongodbref",
Expand All @@ -104,7 +104,7 @@ private function _runPHP() {
}
return eval($this->_source);
}

private function _runJson() {
$timezone = @date_default_timezone_get();
date_default_timezone_set("UTC");
Expand Down Expand Up @@ -140,7 +140,7 @@ function ISODate (isoDateStr) {
return new Date(time);
};
};

function r_util_convert_empty_object_to_string(obj) {
if (r_util_is_empty(obj)) {
return "__EMPTYOBJECT__";
Expand All @@ -152,7 +152,7 @@ function r_util_convert_empty_object_to_string(obj) {
}
return obj;
};

function r_util_is_empty(obj) {
if (obj == null || typeof(obj) != "object" || (obj.constructor != Object)) {
return false;
Expand All @@ -162,7 +162,7 @@ function r_util_is_empty(obj) {
return false;
}
}

return true;
};
var o = ' . $this->_source . '; return r_util_convert_empty_object_to_string(o); }'
Expand All @@ -175,7 +175,7 @@ function r_util_is_empty(obj) {
}
return json_decode($this->_source, true);
}

private function _fixEmptyObject(&$object) {
if (is_array($object)) {
foreach ($object as &$v) {
Expand Down
3 changes: 0 additions & 3 deletions app/classes/VarExportor.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,6 @@ private function _formatVar($var) {
if (is_object($var)) {
$this->_paramIndex ++;
switch (get_class($var)) {
case "stdClass":
$this->_phpParams[$this->_paramIndex] = array();
return $this->_param($this->_paramIndex);
case "MongoId":
$this->_phpParams[$this->_paramIndex] = 'new MongoId("' . $var->__toString() . '")';
return $this->_param($this->_paramIndex);
Expand Down
2 changes: 2 additions & 0 deletions app/configs/rplugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

//$plugins["PLUGIN_NAME"]["enabled"] = 1;



?>
30 changes: 15 additions & 15 deletions app/controllers/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ public function doIndex() {
$this->topUrl = $this->path("admin.top");
$this->leftUrl = $this->path("admin.dbs");
$this->rightUrl = $this->path("server.index");

$this->display();
}

/** top frame **/
public function doTop() {
$this->logoutUrl = $this->path("logout.index");
$this->admin = $this->_admin->username();

$this->admin = $this->_admin->username();
$this->servers = $this->_admin->servers();
$this->serverIndex = $this->_admin->hostIndex();

$isMasterRet = null;
try {
$isMasterRet = $this->_mongo->selectDB($this->_admin->defaultDb())->command(array( "isMaster" => 1 ));
Expand All @@ -32,18 +32,18 @@ public function doTop() {
} catch (MongoCursorException $e) {
$this->isMaster = null;
}

$this->display();
}

}
/** show dbs in left frame **/
public function doDbs() {
$dbs = $this->_server->listDbs();
$this->dbs = array_values(rock_array_sort($dbs["databases"], "name"));
$this->baseUrl = $this->path("admin.dbs");
$this->tableUrl = $this->path("collection.index");
$this->showDbSelector = false;

//add collection count
foreach ($this->dbs as $index => $db) {
$collectionCount = count(MDb::listCollections($this->_mongo->selectDB($db["name"])));
Expand All @@ -54,9 +54,9 @@ public function doDbs() {
$this->dbs[$index] = $db;
}

//current db
//current db
$db = x("db");

$this->tables = array();
if ($db) {
$mongodb = $this->_mongo->selectDB($db);
Expand All @@ -67,27 +67,27 @@ public function doDbs() {
}
$this->display();
}

/** about project and us **/
public function doAbout() {
$this->display();
}

/** change current host **/
public function doChangeHost() {
$index = xi("index");
MUser::userInSession()->changeHost($index);
$this->redirect("admin.index", array( "host" => $index ));
}

/**
* change language of UI interface
*
*/
public function doChangeLang() {
setcookie("ROCK_LANG", x("lang"), time() + 365 * 86400);
header("location:index.php");
}
}
}


Expand Down
1 change: 0 additions & 1 deletion app/controllers/collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public function doSwitchFormat() {
else if ($format == "array") {//to array
$eval = new VarEval($data, "json", $this->_mongodb);
$array = $eval->execute();

$exportor = new VarExportor($this->_mongodb, $array);
$ret = $exportor->export(MONGO_EXPORT_PHP);
}
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/db.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function doIndex() {
$this->stats["Objects"] = $ret["objects"];
}
if (isset($ret["avgObjSize"])) {
$this->stats["Avg Object Size"] = r_human_bytes($ret["avgObjSize"]);
$this->stats["Avg Object Size"] = $ret["avgObjSize"];
}
if(isset($ret["dataSize"])) {
$this->stats["Data Size"] = $ret["dataSize"];
Expand All @@ -69,7 +69,7 @@ public function doIndex() {
$this->stats["Indexes"] = $ret["indexes"];
}
if(isset($ret["indexSize"])) {
$this->stats["Index Size"] = r_human_bytes($ret["indexSize"]);
$this->stats["Index Size"] = $ret["indexSize"];
}
if (isset($ret["fileSize"])) {
$this->stats["Total File Size"] = r_human_bytes($ret["fileSize"]);
Expand Down
18 changes: 0 additions & 18 deletions app/funcs/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ function json_format($json)
* @param integer $bytes Size in byte
* @param integer $precision Precision
* @return string size in k, m, g..
* @since 1.1.7
*/
function r_human_bytes($bytes, $precision = 2) {
if ($bytes == 0) {
Expand All @@ -263,21 +262,4 @@ function r_human_bytes($bytes, $precision = 2) {
return $bytes;
}

/**
* Get collection display icon
*
* @param string $collectionName Collection name
* @return string
* @since 1.1.8
*/
function r_get_collection_icon($collectionName) {
if (preg_match("/\\.(files|chunks)$/", $collectionName)){
return "grid";
}
if (preg_match("/^system\\.js$/", $collectionName)) {
return "table-systemjs";
}
return "table";
}

?>
Loading