Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsteampassnet committed Jun 7, 2016
2 parents 0c90554 + 96e8116 commit 0cd49c1
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 33 deletions.
30 changes: 17 additions & 13 deletions includes/libraries/Database/Meekrodb/db.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public function nonSQLError($message) {
}

$error_handler = is_callable($this->nonsql_error_handler) ? $this->nonsql_error_handler : 'meekrodb_error_handler';

call_user_func($error_handler, array(
'type' => 'nonsql',
'error' => $message
Expand Down Expand Up @@ -611,27 +611,27 @@ protected function queryHelper() {
if ($this->error_handler) {
$db_error = $db->error;
$db_errno = $db->errno;
$db->query(
"INSERT INTO ".$GLOBALS['pre']."log_system SET
date=".time().",
qui=".$_SESSION['user_id'].",
label='Query: ".addslashes($sql)."<br />Error: ".addslashes($db_error)."<br />@ ".$_SERVER['REQUEST_URI']."',
type='error'",
MYSQLI_USE_RESULT
);
$db->query(
"INSERT INTO ".$GLOBALS['pre']."log_system SET
date=".time().",
qui=".$_SESSION['user_id'].",
label='Query: ".addslashes($sql)."<br />Error: ".addslashes($db_error)."<br />@ ".$_SERVER['REQUEST_URI']."',
type='error'",
MYSQLI_USE_RESULT
);

$error_handler = is_callable($this->error_handler) ? $this->error_handler : 'meekrodb_error_handler';
call_user_func($error_handler, array(
'type' => 'sql',
'query' => $sql,
'error' => $db_error,
'code' => $db_errno
));
}
if ($this->throw_exception_on_error) {
$e = new MeekroDBException($db->error, $sql, $db->errno);
$e = new MeekroDBException($db_error, $sql, $db_errno);
throw $e;
}
} else if ($this->success_handler) {
Expand Down Expand Up @@ -910,15 +910,19 @@ public static function reIndex() {
}

function meekrodb_error_handler($params) {
if (isset($params['query'])) $out[] = "QUERY: " . $params['query'];
/*if (isset($params['query'])) $out[] = "QUERY: " . $params['query'];
if (isset($params['error'])) $out[] = "ERROR: " . $params['error'];
$out[] = "";
if (php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) {
echo implode("\n", $out);
} else {
echo implode("<br>\n", $out);
}
*/

echo prepareExchangedData('[{"error" : "'.$params['error'].'"}]', "encode");

die;
}
Expand Down
28 changes: 15 additions & 13 deletions install/install.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/**
* @file install.js
* @author Nils Laumaillé
* @version 2.1.22
* @copyright (c) 2009-2011 Nils Laumaillé
* @licensing GNU AFFERO GPL 3.0
* @link http://www.teampass.net
* @file install.js
* @author Nils Laumaillé
* @version 2.1.22
* @copyright (c) 2009-2011 Nils Laumaillé
* @licensing GNU AFFERO GPL 3.0
* @link http://www.teampass.net
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
Expand Down Expand Up @@ -119,6 +119,7 @@ function CheckPage()
$("#step_result").html("Please wait <img src=\"images/ajax-loader.gif\">");
var globalResult = true;
$("#step_res").val("true");
$('#pop_db').html("");
var ajaxReqs = [];
for (index = 0; index < tasks.length; ++index) {
var tsk = tasks[index].split("*");//console.log(tsk[1]);
Expand Down Expand Up @@ -152,11 +153,12 @@ function CheckPage()
$("#step_result").html(data[0].result);
}
} else {
// ignore setting error if regarding setting permissions (step 6, index 2)
if (step+data[0].index != "62") {
$("#step_res").val("false");
}
// ignore setting error if regarding setting permissions (step 6, index 2)
if (step+data[0].index != "62") {
$("#step_res").val("false");
}
$("#res"+step+"_check"+data[0].index).html("<img src=\"images/exclamation-red.png\">&nbsp;<i>"+data[0].error+"</i>");
$('#pop_db').append('<li><img src=\"images/exclamation-red.png\">&nbsp;Error on task `<b>'+data[0].table+'`</b>. <i>'+data[0].error+'</i></li>');
if (data[0].result != undefined && data[0].result != "" ) {
$("#step_result").html(data[0].result);
}
Expand All @@ -169,7 +171,7 @@ function CheckPage()
setTimeout(function(){
// all requests are complete
if ($("#step_res").val() == "false") {
data = $.parseJSON(data.responseText);
data = $.parseJSON(data.responseText);
$("#step_error").show().html("At least one task has failed! Please correct and relaunch. ");
$("#res_"+step).html("<img src=\"images/exclamation-red.png\">");
} else {
Expand All @@ -179,8 +181,8 @@ function CheckPage()
$("#but_next").show();
// Hide restart button at end of step 6 if successful
if (step == "7") {
$("#but_restart").prop("disabled", true);
$("#but_restart").hide();
$("#but_restart").prop("disabled", true);
$("#but_restart").hide();
}
}
$("#step_result").html("");
Expand Down
12 changes: 6 additions & 6 deletions install/install.queries.php
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ function chmod_r($dir, $dirPermissions, $filePermissions) {
`folder` varchar(300) NOT NULL,
`author` varchar(50) NOT NULL,
`renewal_period` tinyint(4) NOT NULL DEFAULT '0',
`timestamp` varchar(50) NOT NULL
`timestamp` varchar(50) DEFAULT NULL
) CHARSET=utf8;"
);
} else if ($task == "roles_title") {
Expand Down Expand Up @@ -723,26 +723,26 @@ function chmod_r($dir, $dirPermissions, $filePermissions) {
$tmp = mysqli_fetch_row(mysqli_query($dbTmp, "SELECT COUNT(*) FROM `".$var['tbl_prefix']."users` WHERE login = 'admin'"));
if ($tmp[0] == 0 || empty($tmp[0])) {
$mysqli_result = mysqli_query($dbTmp,
"INSERT INTO `".$var['tbl_prefix']."users` (`id`, `login`, `pw`, `groupes_visibles`, `derniers`, `key_tempo`, `last_pw_change`, `last_pw`, `admin`, `fonction_id`, `groupes_interdits`, `last_connexion`, `gestionnaire`, `email`, `favourites`, `latest_items`, `personal_folder`) VALUES (NULL, 'admin', '".bCrypt($var['admin_pwd'],'13' )."', '', '', '', '', '', '1', '', '', '', '0', '', '', '', '0')"
"INSERT INTO `".$var['tbl_prefix']."users` (`id`, `login`, `pw`, `groupes_visibles`, `derniers`, `key_tempo`, `last_pw_change`, `last_pw`, `admin`, `fonction_id`, `groupes_interdits`, `last_connexion`, `gestionnaire`, `email`, `favourites`, `latest_items`, `personal_folder`) VALUES ('1', 'admin', '".bCrypt($var['admin_pwd'],'13' )."', '', '', '', '', '', '1', '', '', '', '0', '', '', '', '0')"
);
} else {
$mysqli_result = mysqli_query($dbTmp, "UPDATE `".$var['tbl_prefix']."users` SET `pw` = '".bCrypt($var['admin_pwd'],'13' )."' WHERE login = 'admin' AND id = '1'");
}
// check that API doesn't exist

// check that API doesn't exist
$tmp = mysqli_fetch_row(mysqli_query($dbTmp, "SELECT COUNT(*) FROM `".$var['tbl_prefix']."users` WHERE id = '9999999'"));
if ($tmp[0] == 0 || empty($tmp[0])) {
$mysqli_result = mysqli_query($dbTmp,
"INSERT INTO `".$var['tbl_prefix']."users` (`id`, `login`, `read_only`) VALUES ('9999999', 'API', '1')"
);
}
}
}
}
// answer back
if ($mysqli_result) {
echo '[{"error" : "", "index" : "'.$_POST['index'].'", "multiple" : "'.$_POST['multiple'].'", "table" : "'.$task.'"}]';
} else {
echo '[{"error" : "true", "index" : "'.$_POST['index'].'", "multiple" : "'.$_POST['multiple'].'", "table" : "'.$task.'"}]';
echo '[{"error" : "'.$mysqli_result.'", "index" : "'.$_POST['index'].'", "multiple" : "'.$_POST['multiple'].'", "table" : "'.$task.'"}]';
}
} else {
echo '[{"error" : "'.addslashes(str_replace(array("'", "\n", "\r"), array('"', '', ''), mysqli_connect_error())).'", "result" : "Failed", "multiple" : ""}]';
Expand Down
1 change: 1 addition & 0 deletions install/upgrade_run_2.1.26.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ function tableExists($tablename, $database = false)
mysqli_query($dbTmp, "ALTER TABLE `".$_SESSION['tbl_prefix']."cache` MODIFY label VARCHAR(100)");
mysqli_query($dbTmp, "ALTER TABLE `".$_SESSION['tbl_prefix']."cache` MODIFY restricted_to DEFAULT NULL");
mysqli_query($dbTmp, "ALTER TABLE `".$_SESSION['tbl_prefix']."cache` MODIFY tags DEFAULT NULL");
mysqli_query($dbTmp, "ALTER TABLE `".$_SESSION['tbl_prefix']."cache` MODIFY timestamp DEFAULT NULL");

// add Estonia
mysqli_query($dbTmp, "INSERT INTO `".$_SESSION['tbl_prefix']."languages` VALUES (null, 'estonia', 'Estonia', 'ee', 'ee.png')");
Expand Down
5 changes: 5 additions & 0 deletions items.load.php
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,11 @@ function(data) {
$("#div_dialog_message").show();
return;
}

if (data.error != "") {
$("#div_dialog_message_text").html("An error appears. Answer from Server cannot be parsed!<br /><br />Returned data:<br />"+data.error);
$("#div_dialog_message").show();
}

// reset password shown info
$("#pw_shown").val("0");
Expand Down
3 changes: 2 additions & 1 deletion sources/import.queries.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,8 @@ function sanitiseString($str, $crLFReplacement) {
'perso' => $personalFolder == 0 ? 0 : 1,
'login' => $item[1],
'folder' => $data_fld['title'],
'author' => $_SESSION['user_id']
'author' => $_SESSION['user_id'],
'timestamp' => time()
)
);
}
Expand Down

0 comments on commit 0cd49c1

Please sign in to comment.