Fix for php7
This commit is contained in:
@@ -131,7 +131,7 @@ if(!$isDataFolderExists){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(request["BASE_URL"].indexOf("http://") == 0 || request["BASE_URL"].indexOf("https://")){
|
if(request["BASE_URL"].indexOf("http://") == 0 || request["BASE_URL"].indexOf("https://") == 0){
|
||||||
}else{
|
}else{
|
||||||
alert("Invalid Base URL");
|
alert("Invalid Base URL");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -13,52 +13,51 @@ $ret = array();
|
|||||||
if(!$isConfigFileExists || $configData != ""){
|
if(!$isConfigFileExists || $configData != ""){
|
||||||
$ret["status"] = "ERROR";
|
$ret["status"] = "ERROR";
|
||||||
$ret["msg"] = "You are trying to install icehrm on an existing installation.";
|
$ret["msg"] = "You are trying to install icehrm on an existing installation.";
|
||||||
echo json_encode($ret);
|
echo json_encode($ret);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$action = $_REQUEST['action'];
|
$action = $_REQUEST['action'];
|
||||||
|
|
||||||
if($action == "TEST_DB"){
|
if($action == "TEST_DB"){
|
||||||
|
|
||||||
$db = NewADOConnection('mysqli');
|
$db = NewADOConnection('mysqli');
|
||||||
$res = $db->Connect($_REQUEST["APP_HOST"], $_REQUEST["APP_USERNAME"], $_REQUEST["APP_PASSWORD"], $_REQUEST["APP_DB"]);
|
$res = $db->Connect($_REQUEST["APP_HOST"], $_REQUEST["APP_USERNAME"], $_REQUEST["APP_PASSWORD"], $_REQUEST["APP_DB"]);
|
||||||
|
|
||||||
if (!$res){
|
if (!$res){
|
||||||
error_log('Could not connect: ' . mysql_error());
|
error_log('Could not connect: ' . $db->ErrorMsg());
|
||||||
$ret["status"] = "ERROR";
|
$ret["status"] = "ERROR";
|
||||||
$ret["msg"] = "Incorrect credentials or incorrect DB host";
|
$ret["msg"] = "Incorrect credentials or incorrect DB host :".$db->ErrorMsg();
|
||||||
echo json_encode($ret);
|
echo json_encode($ret);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $db->Execute("Show tables");
|
$result = $db->Execute("Show tables");
|
||||||
error_log(print_r("Number of tables:".$result->RecordCount(),true));
|
error_log(print_r("Number of tables:".$result->RecordCount(),true));
|
||||||
$num_rows = $result->RecordCount();
|
$num_rows = $result->RecordCount();
|
||||||
if($num_rows != 0){
|
if($num_rows != 0){
|
||||||
error_log('Database is not empty: ' . mysql_error());
|
|
||||||
$ret["status"] = "ERROR";
|
$ret["status"] = "ERROR";
|
||||||
$ret["msg"] = "Database is not empty";
|
$ret["msg"] = "Database is not empty";
|
||||||
echo json_encode($ret);
|
echo json_encode($ret);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret["status"] = "SUCCESS";
|
$ret["status"] = "SUCCESS";
|
||||||
$ret["msg"] = "Successfully connected to the database";
|
$ret["msg"] = "Successfully connected to the database";
|
||||||
echo json_encode($ret);
|
echo json_encode($ret);
|
||||||
|
|
||||||
}else if($action == "INS"){
|
}else if($action == "INS"){
|
||||||
|
|
||||||
$config = file_get_contents(CLIENT_APP_PATH."config.sample.php");
|
$config = file_get_contents(CLIENT_APP_PATH."config.sample.php");
|
||||||
|
|
||||||
if(empty($config)){
|
if(empty($config)){
|
||||||
error_log('Sample config file is empty');
|
error_log('Sample config file is empty');
|
||||||
$ret["status"] = "ERROR";
|
$ret["status"] = "ERROR";
|
||||||
$ret["msg"] = "Sample config file not found";
|
$ret["msg"] = "Sample config file not found";
|
||||||
echo json_encode($ret);
|
echo json_encode($ret);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$config = str_replace("_LOG_", $_REQUEST['LOG'], $config);
|
$config = str_replace("_LOG_", $_REQUEST['LOG'], $config);
|
||||||
$config = str_replace("_APP_BASE_PATH_", APP_PATH, $config);
|
$config = str_replace("_APP_BASE_PATH_", APP_PATH, $config);
|
||||||
$config = str_replace("_CLIENT_BASE_PATH_", CLIENT_APP_PATH, $config);
|
$config = str_replace("_CLIENT_BASE_PATH_", CLIENT_APP_PATH, $config);
|
||||||
@@ -69,69 +68,67 @@ if($action == "TEST_DB"){
|
|||||||
$config = str_replace("_APP_PASSWORD_", $_REQUEST['APP_PASSWORD'], $config);
|
$config = str_replace("_APP_PASSWORD_", $_REQUEST['APP_PASSWORD'], $config);
|
||||||
$config = str_replace("_APP_HOST_", $_REQUEST['APP_HOST'], $config);
|
$config = str_replace("_APP_HOST_", $_REQUEST['APP_HOST'], $config);
|
||||||
$config = str_replace("_CLIENT_", 'app', $config);
|
$config = str_replace("_CLIENT_", 'app', $config);
|
||||||
|
|
||||||
$con = mysql_connect($_REQUEST["APP_HOST"],$_REQUEST["APP_USERNAME"],$_REQUEST["APP_PASSWORD"]);
|
|
||||||
|
|
||||||
$db = NewADOConnection('mysqli');
|
$db = NewADOConnection('mysqli');
|
||||||
$res = $db->Connect($_REQUEST["APP_HOST"], $_REQUEST["APP_USERNAME"], $_REQUEST["APP_PASSWORD"], $_REQUEST["APP_DB"]);
|
$res = $db->Connect($_REQUEST["APP_HOST"], $_REQUEST["APP_USERNAME"], $_REQUEST["APP_PASSWORD"], $_REQUEST["APP_DB"]);
|
||||||
|
|
||||||
|
|
||||||
if (!$res){
|
if (!$res){
|
||||||
error_log('Could not connect: ' . mysql_error());
|
error_log('Could not connect: ' . $db->ErrorMsg());
|
||||||
$ret["status"] = "ERROR";
|
$ret["status"] = "ERROR";
|
||||||
$ret["msg"] = "Incorrect credentials or incorrect DB host";
|
$ret["msg"] = "Incorrect credentials or incorrect DB host. ".'Could not connect: ' . $db->ErrorMsg();
|
||||||
echo json_encode($ret);
|
echo json_encode($ret);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $db->Execute("Show tables");
|
$result = $db->Execute("Show tables");
|
||||||
error_log(print_r("Number of tables:".$result->RecordCount(),true));
|
error_log(print_r("Number of tables:".$result->RecordCount(),true));
|
||||||
$num_rows = $result->RecordCount();
|
$num_rows = $result->RecordCount();
|
||||||
if($num_rows != 0){
|
if($num_rows != 0){
|
||||||
error_log('Database is not empty: ' . mysql_error());
|
|
||||||
$ret["status"] = "ERROR";
|
$ret["status"] = "ERROR";
|
||||||
$ret["msg"] = "Database is not empty";
|
$ret["msg"] = "Database is not empty";
|
||||||
echo json_encode($ret);
|
echo json_encode($ret);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Run create table script
|
//Run create table script
|
||||||
$insql = file_get_contents(CLIENT_APP_PATH."../scripts/".APP_ID."db.sql");
|
$insql = file_get_contents(CLIENT_APP_PATH."../scripts/".APP_ID."db.sql");
|
||||||
$sql_list = preg_split('/;/',$insql);
|
$sql_list = preg_split('/;/',$insql);
|
||||||
foreach($sql_list as $sql){
|
foreach($sql_list as $sql){
|
||||||
if (preg_match('/^\s+$/', $sql) || $sql == '') { # skip empty lines
|
if (preg_match('/^\s+$/', $sql) || $sql == '') { # skip empty lines
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$db->Execute($sql);
|
$db->Execute($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Run create table script
|
//Run create table script
|
||||||
$insql = file_get_contents(CLIENT_APP_PATH."../scripts/".APP_ID."_master_data.sql");
|
$insql = file_get_contents(CLIENT_APP_PATH."../scripts/".APP_ID."_master_data.sql");
|
||||||
$sql_list = preg_split('/;/',$insql);
|
$sql_list = preg_split('/;/',$insql);
|
||||||
foreach($sql_list as $sql){
|
foreach($sql_list as $sql){
|
||||||
if (preg_match('/^\s+$/', $sql) || $sql == '') { # skip empty lines
|
if (preg_match('/^\s+$/', $sql) || $sql == '') { # skip empty lines
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$db->Execute($sql);
|
$db->Execute($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Write config file
|
//Write config file
|
||||||
|
|
||||||
$file = fopen(CLIENT_APP_PATH."config.php","w");
|
$file = fopen(CLIENT_APP_PATH."config.php","w");
|
||||||
if($file){
|
if($file){
|
||||||
fwrite($file,$config);
|
fwrite($file,$config);
|
||||||
fclose($file);
|
fclose($file);
|
||||||
}else{
|
}else{
|
||||||
error_log('Unable to write configurations to file');
|
error_log('Unable to write configurations to file');
|
||||||
$ret["status"] = "ERROR";
|
$ret["status"] = "ERROR";
|
||||||
$ret["msg"] = "Unable to write configurations to file";
|
$ret["msg"] = "Unable to write configurations to file";
|
||||||
echo json_encode($ret);
|
echo json_encode($ret);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret["status"] = "SUCCESS";
|
$ret["status"] = "SUCCESS";
|
||||||
$ret["msg"] = "Successfully installed. Please rename or delete install folder";
|
$ret["msg"] = "Successfully installed. Please rename or delete install folder";
|
||||||
echo json_encode($ret);
|
echo json_encode($ret);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user