forked from xoopscube/legacy
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
xoops_trust_path/modules/xupdate/admin/actions/UserPassColumnLenFixAction.class.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters