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

Multibyte fix #104

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
2 changes: 1 addition & 1 deletion app/controllers/collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function doIndex() {
$params = xn();
if ($this->_logQuery && count($params) > 3) {//not only "action", "db" and "collection"
$logDir = dirname(__ROOT__) . DS . "logs";
if (!empty($params["criteria"]) && strlen(trim($params["criteria"], "{} \t\n\r")) > 0) {
if (!empty($params["criteria"]) && mb_strlen(trim($params["criteria"], "{} \t\n\r")) > 0) {
if (is_writable($logDir)) {
$logFile = $this->_logFile($this->db, $this->collection);
$fp = null;
Expand Down
9 changes: 5 additions & 4 deletions app/funcs/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ function json_format_html($json)
$indent_level = 0;
$in_string = false;

$len = strlen($json);
$len = mb_strlen($json);
$chars = preg_split('//u',$json, -1, PREG_SPLIT_NO_EMPTY);

for($c = 0; $c < $len; $c++)
{
$char = $json[$c];
$char = $chars[$c];
switch($char)
{
case '{':
Expand Down Expand Up @@ -89,7 +90,7 @@ function json_format_html($json)
}
break;
case '"':
if($c > 0 && $json[$c-1] != '\\') {
if($c > 0 && $chars[$c-1] != '\\') {
$in_string = !$in_string;
if ($in_string) {
$new_json .= "<font color=\"#DD0000\" class=\"string_var\">" . $char;
Expand Down Expand Up @@ -171,7 +172,7 @@ function json_format($json)

$json = json_encode($json_obj);
*/
$len = strlen($json);
$len = mb_strlen($json);

for($c = 0; $c < $len; $c++)
{
Expand Down
2 changes: 1 addition & 1 deletion app/lib/mongo/RQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function attr($nameOrAttrs, $value = null) {
$nameOrAttrs = array( $nameOrAttrs => $value );
}
foreach ($nameOrAttrs as $attr => $value) {
if ($attr == "_id" && (!is_object($value) || !($value instanceof MongoId)) && strlen($attr) == 24) {
if ($attr == "_id" && (!is_object($value) || !($value instanceof MongoId)) && mb_strlen($attr) == 24) {
$value = new MongoId($value);
}
if (!isset($this->_attrs[$attr])) {
Expand Down
2 changes: 1 addition & 1 deletion app/lib/page/RPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ function setAutoQuery($bool = true, $except = "", $only = "") {
if (!is_array($except)) {
$except = preg_split("/\\s+,\\s+/", $except);
}
if (!is_array($only) && strlen($only) > 0) {
if (!is_array($only) && mb_strlen($only) > 0) {
$only = preg_split("/\\s+,\\s+/", $only);
}
if ($bool) {
Expand Down
25 changes: 25 additions & 0 deletions themes/default/views/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,31 @@
$(document).click(window.parent.hideMenus);
if ($("textarea").length > 0) {
$("textarea").tabby();


// Search with ID field
var elTextField = $("<input />").attr({type: 'text', size: 30}).keypress(function(e) {
if (e.keyCode == '13') {
e.preventDefault();
$(this).parent().find('input:last').click();
}
});
var elButton = $("<input />").attr({type: 'button', value: 'Select by ID'})
.bind('click', function (e) {
var v = $(this).parent().find('input:first').val();
// заветная строка!
$('#query_form textarea').val('{\n\"_id\": ObjectId(\"'+v+'\")\n}');
$('#query_form').submit();
});
$("<div />")
.html('_id: ')
.css({paddingLeft: 5, paddingTop: 4})
.append(elTextField)
.append(' ')
.append(elButton)
.prependTo('#query_form');


}
});
</script>
Expand Down