Skip to content

Commit

Permalink
Merge branch 'master' into pilot
Browse files Browse the repository at this point in the history
  • Loading branch information
nao-pon committed Feb 15, 2017
2 parents bfca27e + 0c56288 commit b6d4194
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
* @license https://github.com/xoopscube/legacy/blob/master/docs/GPL_V2.txt GNU GENERAL PUBLIC LICENSE Version 2
*
*/
$set_charset = (XOOPS_DB_TYPE === 'mysqli')? 'mysqli_set_charset' : 'mysql_set_charset';
if (function_exists($set_charset)) {
$set_charset($this->db->conn, 'utf8');
} else {
$this->db->queryF("/*!40101 SET NAMES utf8 */");
$this->db->queryF("/*!40101 SET SESSION character_set_database=utf8 */");
$this->db->queryF("/*!40101 SET SESSION character_set_server=utf8 */");
// $this->db->queryF("/*!40101 SET SESSION collation_connection=ujis_japanese_ci */");
// $this->db->queryF("/*!40101 SET SESSION collation_database=ujis_japanese_ci */");
// $this->db->queryF("/*!40101 SET SESSION collation_server=ujis_japanese_ci */");
;
$this->db->queryF("/*!40101 SET SESSION collation_connection=utf8_general_ci */");
}
70 changes: 42 additions & 28 deletions html/core/XCube_Utils.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public static function formatString()
*/
public static function encrypt($plain_text, $key = null, $algorithm = 'des', $mode = 'ecb')
{
if ($plain_text === '' || ! extension_loaded('mcrypt')) {
if ($plain_text === '') {
return $plain_text;
}

Expand All @@ -122,21 +122,28 @@ public static function encrypt($plain_text, $key = null, $algorithm = 'des', $mo
$key = XOOPS_SALT;
}
$key = md5($key);

$td = mcrypt_module_open($algorithm, '', $mode, '');
$key = substr($key, 0, mcrypt_enc_get_key_size($td));
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);

if (mcrypt_generic_init($td, $key, $iv) < 0) {
return $plain_text;

if (! function_exists('openssl_encrypt')) {
if (! extension_loaded('openssl')) {
return $plain_text;
}
$td = mcrypt_module_open($algorithm, '', $mode, '');
$key = substr($key, 0, mcrypt_enc_get_key_size($td));
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);

if (mcrypt_generic_init($td, $key, $iv) < 0) {
return $plain_text;
}

$crypt_text = base64_encode(mcrypt_generic($td, $plain_text));

mcrypt_generic_deinit($td);
mcrypt_module_close($td);
} else {
$crypt_text = openssl_encrypt($plain_text, strtoupper($algorithm.'-'.$mode), $key);
}

$crypt_text = base64_encode(mcrypt_generic($td, $plain_text));

mcrypt_generic_deinit($td);
mcrypt_module_close($td);

return $crypt_text;
return $crypt_text === false ? $plain_text : $crypt_text;
}

/**
Expand All @@ -150,7 +157,7 @@ public static function encrypt($plain_text, $key = null, $algorithm = 'des', $mo
*/
public static function decrypt($crypt_text, $key = null, $algorithm = 'des', $mode = 'ecb')
{
if ($crypt_text === '' || ! extension_loaded('mcrypt')) {
if ($crypt_text === '') {
return $crypt_text;
}

Expand All @@ -161,21 +168,28 @@ public static function decrypt($crypt_text, $key = null, $algorithm = 'des', $mo
$key = XOOPS_SALT;
}
$key = md5($key);

$td = mcrypt_module_open($algorithm, '', $mode, '');
$key = substr($key, 0, mcrypt_enc_get_key_size($td));
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);

if (mcrypt_generic_init($td, $key, $iv) < 0) {
return $crypt_text;

if (! function_exists('openssl_decrypt')) {
if (! extension_loaded('openssl')) {
return $crypt_text;
}
$td = mcrypt_module_open($algorithm, '', $mode, '');
$key = substr($key, 0, mcrypt_enc_get_key_size($td));
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);

if (mcrypt_generic_init($td, $key, $iv) < 0) {
return $crypt_text;
}

$plain_text = rtrim(mdecrypt_generic($td, base64_decode($crypt_text)), "\0");

mcrypt_generic_deinit($td);
mcrypt_module_close($td);
} else {
$plain_text = openssl_decrypt($crypt_text, strtoupper($algorithm.'-'.$mode), $key, OPENSSL_ZERO_PADDING);
}

$plain_text = rtrim(mdecrypt_generic($td, base64_decode($crypt_text)), "\0");

mcrypt_generic_deinit($td);
mcrypt_module_close($td);

return $plain_text;
return $plain_text === false ? $crypt_text : $plain_text;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion html/install/class/dbmanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function connectDB($selectdb = true)
if ($ret != false) {
$fname = dirname(dirname(__FILE__)).'/language/'.$GLOBALS['language'].'/charset_mysql.php';
if (file_exists($fname)) {
require_once($fname);
require($fname);
}
}
return $ret;
Expand Down
10 changes: 7 additions & 3 deletions html/modules/legacy/class/Legacy_Debugger.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,14 @@ class Legacy_PHPDebugger extends Legacy_AbstractDebugger
{
public function prepare()
{
if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
error_reporting(E_ALL ^ E_STRICT);
if (defined('XOOPS_ERROR_REPORTING_LEVEL')) {
error_reporting(XOOPS_ERROR_REPORTING_LEVEL);
} else {
error_reporting(E_ALL);
if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
error_reporting(E_ALL ^ E_STRICT ^ E_NOTICE);
} else {
error_reporting(E_ALL ^ E_NOTICE);
}
}
$GLOBALS['xoopsErrorHandler'] =& XoopsErrorHandler::getInstance();
$GLOBALS['xoopsErrorHandler']->activate(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class Legacy_SystemModuleInstall extends XCube_ActionFilter
public function preBlockFilter()
{
if (is_array(Legacy_Utils::checkSystemModules())) {
$this->mController->mSetupUser->add("Legacy_SystemModuleInstall::callbackSetupUser", XCUBE_DELEGATE_PRIORITY_FINAL-1);
$this->mRoot->mDelegateManager->add("Site.CheckLogin.Success", array(&$this, "callbackCheckLoginSuccess"));
$this->mController->mSetupUser->add(array($this, "callbackSetupUser"), XCUBE_DELEGATE_PRIORITY_FINAL-1);
$this->mRoot->mDelegateManager->add("Site.CheckLogin.Success", array($this, "callbackCheckLoginSuccess"));
}
}

Expand Down

0 comments on commit b6d4194

Please sign in to comment.