Skip to content

Commit

Permalink
Merge pull request #17 from ROZARD/master
Browse files Browse the repository at this point in the history
Поддержка mysqli
  • Loading branch information
stdex committed Nov 22, 2016
2 parents 5e54d3c + 8b24eec commit a68a57f
Show file tree
Hide file tree
Showing 16 changed files with 587 additions and 242 deletions.
5 changes: 1 addition & 4 deletions .gitignore
@@ -1,9 +1,6 @@
/.idea
/engine/plugins
/engine/cache/_templates
/engine/cache/core
/engine/cache/twig
/engine/cache/last_backup.tmp
/engine/cache
/engine/backups/*.gz
/engine/conf/config.php
/engine/conf/plugdata.php
Expand Down
2 changes: 1 addition & 1 deletion engine/actions/configuration.php
Expand Up @@ -65,7 +65,7 @@ function systemConfigSave(){
}

// Check if DB connection params are correct
$sqlTest = new mysql();
$sqlTest = DBLoad();
if (!$sqlTest->connect($save_con['dbhost'],$save_con['dbuser'], $save_con['dbpasswd'], $save_con['dbname'], 1)) {
msgSticker($lang['dbcheck_error'], 'error');
return false;
Expand Down
2 changes: 1 addition & 1 deletion engine/actions/configuration.rpc.php
Expand Up @@ -36,7 +36,7 @@ function admConfigurationTestDB($params) {
}

// Check if DB connection params are correct
$sqlTest = new mysql();
$sqlTest = DBLoad();
if (!$sqlTest->connect($params['dbhost'], $params['dbuser'], $params['dbpasswd'], $params['dbname'], 1)) {
if ($sqlTest->error<2)
return array('status' => 0, 'errorCode' => 4, 'errorText' => iconv('Windows-1251','UTF-8', $lang['dbcheck_noconnect']));
Expand Down
2 changes: 1 addition & 1 deletion engine/actions/statistics.php
Expand Up @@ -130,7 +130,7 @@ function phpConfigGetBytes ($size_str) {
'php_self' => $PHP_SELF,
'php_os' => PHP_OS,
'php_version' => phpversion(),
'mysql_version' => mysql_get_server_info(),
'mysql_version' => $mysql->mysql_version(),
'gd_version' => (isset($gd_version) && is_array($gd_version))?$gd_version["GD Version"]:'<font color="red"><b>NOT INSTALLED</b></font>',
'currentVersion' => $displayEngineVersion,
'versionNotifyURL' => 'http://ngcms.ru/sync/versionInfo.php?ver='.urlencode(engineVersion).'&type='.urlencode(engineVersionType).'&build='.urlencode(engineVersionBuild).'&uuid='.$config['UUID'].'&pdo='.((extension_loaded('PDO') && extension_loaded('pdo_mysql') && class_exists('PDO'))?'yes':'no'),
Expand Down
2 changes: 1 addition & 1 deletion engine/actions/users.php
Expand Up @@ -396,7 +396,7 @@ function userList(){
}

$sortValue = (isset($_REQUEST['sort']) && isset($sortOrderMap[$_REQUEST['sort']]))?$sortOrderMap[$_REQUEST['sort']]:'id';
$name = ($_REQUEST['name'] != '')?("'%".mysql_real_escape_string($_REQUEST['name'])."%'"):'';
$name = ($_REQUEST['name'] != '')?("'%".$mysql->db_quote($_REQUEST['name'])."%'"):'';

// Records Per Page
// - Load
Expand Down
25 changes: 18 additions & 7 deletions engine/core.php
Expand Up @@ -86,10 +86,22 @@
// Check for support of mondatory modules
// ===========================================================
{
foreach (array('zlib' => 'ob_gzhandler', 'iconv' => 'iconv', 'GD' => 'imagecreatefromjpeg', 'mysql' => 'mysql_connect') as $pModule => $pFunction) {
if (!extension_loaded($pModule) || !function_exists($pFunction)) {
print "<html>\n<head><title>FATAL EXECUTION ERROR</title></head>\n<body>\n<div style='font: 24px verdana; background-color: #EEEEEE; border: #ABCDEF 1px solid; margin: 1px; padding: 3px;'><span style='color: red;'>FATAL ERROR</span><br/><span style=\"font: 16px arial;\"> Cannot load file CORE libraries of <a href=\"http://ngcms.ru/\">NGCMS</a> (<b>engine/core.php</b>), PHP extension [".$pModule."] with function [".$pFunction."] is not loaded!</span></div>\n</body>\n</html>\n";
print str_replace(array('{extension}', '{function}'), array($pModule, $pFunction), $lang['fatal.lostlib']);
foreach (array('sql' => array('mysql' => 'mysql_connect', 'mysqli' => 'mysqli_connect'), 'zlib' => 'ob_gzhandler', 'iconv' => 'iconv', 'GD' => 'imagecreatefromjpeg') as $pModule => $pFunction) {
$is_error = false;
if(is_array($pFunction)){
foreach($pFunction as $kModule => $vFunction){
if (extension_loaded($kModule) && function_exists($vFunction)) break;
if(!next($pFunction)) $is_error = true;
}
} else if (!extension_loaded($pModule) || !function_exists($pFunction)) {
$kModule = $pModule;
$vFunction = $pFunction;
$is_error = true;
}

if($is_error){
print "<html>\n<head><title>FATAL EXECUTION ERROR</title></head>\n<body>\n<div style='font: 24px verdana; background-color: #EEEEEE; border: #ABCDEF 1px solid; margin: 1px; padding: 3px;'><span style='color: red;'>FATAL ERROR</span><br/><span style=\"font: 16px arial;\"> Cannot load file CORE libraries of <a href=\"http://ngcms.ru/\">NGCMS</a> (<b>engine/core.php</b>), PHP extension [".$kModule."] with function [".$vFunction."] is not loaded!</span></div>\n</body>\n</html>\n";
//print str_replace(array('{extension}', '{function}'), array($kModule, $vFunction), $lang['fatal.lostlib']);
die();
}
}
Expand Down Expand Up @@ -279,10 +291,9 @@

// ** Load cache engine
@include_once root.'includes/classes/cache.class.php';
@include_once root.'includes/inc/DBLoad.php';

// ** Load MySQL DB engine library
@include_once root.'includes/classes/mysql.class.php';
$mysql = new mysql;
$mysql = DBLoad();
$mysql->connect($config['dbhost'], $config['dbuser'], $config['dbpasswd'], $config['dbname']);

// [[MARKER]] MySQL connection is established
Expand Down

0 comments on commit a68a57f

Please sign in to comment.