Skip to content

Commit

Permalink
Merge branch 'xupdate' into pilot
Browse files Browse the repository at this point in the history
  • Loading branch information
nao-pon committed Oct 29, 2018
2 parents 9f0c6b4 + 7a6f762 commit 0a7fc89
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 1 deletion.
@@ -0,0 +1,62 @@
<?php
/**
* @file
* @package xupdate
* @version $Id$
**/

if (!defined('XOOPS_ROOT_PATH')) {
exit;
}

require_once XUPDATE_TRUST_PATH . '/class/AbstractAction.class.php';

/**
* Xupdate_Admin_IndexAction
**/
class Xupdate_Admin_UserPassColumnLenFixAction extends Xupdate_AbstractAction
{
/**
* getDefaultView
*
* @param void
*
* @return Enum
**/
public function getDefaultView()
{
$redirect = xoops_getrequest('xoops_redirect');
if ($redirect[0] !== '/') {
$redirect = XOOPS_URL . '/index.php';
}
if (!defined('XCUBE_CORE_USER_PASS_LEN_FIXED') && $this->mod_config['_FtpLoginCheck'] && is_callable('User_Utils::checkUsersPassColumnLength')) {
$this->_userPassColumnLenFix();
}
header('Location: ' . $redirect);
exit();
}

private function _userPassColumnLenFix()
{
if (User_Utils::checkUsersPassColumnLength()) {
// update mainfile.php that adds `define('XCUBE_CORE_USER_PASS_LEN_FIXED', true);`
if ($this->Ftp->app_login()) {
$mainfile = XOOPS_ROOT_PATH . '/mainfile.php';
$src = file_get_contents($mainfile);
$sens = '/define\s*\(\s*(["\'])XOOPS_MAINFILE_INCLUDED\\1\s*,\s*1\s*\)\s*;\s*(?:\r\n|\n|\r)/';
if (preg_match($sens, $src) && !preg_match('/define\s*\(\s*(["\'])XCUBE_CORE_USER_PASS_LEN_FIXED\\1/', $src)) {
$add = ' // Alrady fixed length of users table pass column of this DB (Auto inserts by X-update)'."\n";
$add .= ' define(\'XCUBE_CORE_USER_PASS_LEN_FIXED\', true);'."\n\n";
$src = preg_replace($sens, '$0' . $add, $src);
$local = XOOPS_TRUST_PATH.'/'.$this->mod_config['temp_path'].'/mainfile.custom.php';
file_put_contents($local, $src);
$mod = @ fileperms($mainfile);
$this->Ftp->localChmod($mainfile, 0606);
$this->Ftp->localPut($local, $mainfile);
$this->Ftp->localChmod($mainfile, $mod? $mod : 0404);
@unlink($local);
}
}
}
}
}
7 changes: 7 additions & 0 deletions xoops_trust_path/modules/xupdate/admin/index.php
Expand Up @@ -6,6 +6,13 @@
* @version $Id$
**/

// to call User_Utils::checkUsersPassColumnLength()
// and insert `define('XCUBE_CORE_USER_PASS_LEN_FIXED', true);` to mainfile.php
if (!defined('XCUBE_CORE_USER_PASS_LEN_FIXED') && is_callable('User_Utils::checkUsersPassColumnLength') && xoops_getrequest('action') !== 'UserPassColumnLenFix') {
header('Location: ' . XOOPS_URL . '/modules/xupdate/admin/index.php?action=UserPassColumnLenFix&xoops_redirect='.rawurlencode($_SERVER['REQUEST_URI']));
exit();
}

$root =& XCube_Root::getSingleton();
$root->mContext->mModule->setAdminMode(true);

Expand Down
2 changes: 1 addition & 1 deletion xoops_trust_path/modules/xupdate/xoops_version.php
Expand Up @@ -22,7 +22,7 @@
//
$modversion['name'] = _MI_XUPDATE_LANG_XUPDATE;
$modversion['version'] = '0.74';
$modversion['detailed_version'] = '0.74.0';
$modversion['detailed_version'] = '0.74.2';
$modversion['description'] = _MI_XUPDATE_DESC_XUPDATE;
$modversion['author'] = _MI_XUPDATE_LANG_AUTHOR;
$modversion['credits'] = _MI_XUPDATE_LANG_CREDITS;
Expand Down

0 comments on commit 0a7fc89

Please sign in to comment.