<?php
/* Reminder: always indent with 4 spaces (no tabs). */
// +---------------------------------------------------------------------------+
// | Copyright (c) 2008, Demian Turner |
// | All rights reserved. |
// | |
// | Redistribution and use in source and binary forms, with or without |
// | modification, are permitted provided that the following conditions |
// | are met: |
// | |
// | o Redistributions of source code must retain the above copyright |
// | notice, this list of conditions and the following disclaimer. |
// | o Redistributions in binary form must reproduce the above copyright |
// | notice, this list of conditions and the following disclaimer in the |
// | documentation and/or other materials provided with the distribution. |
// | o The names of the authors may not be used to endorse or promote |
// | products derived from this software without specific prior written |
// | permission. |
// | |
// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
// | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
// | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
// | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
// | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
// | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
// | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
// | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
// | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
// | |
// +---------------------------------------------------------------------------+
// | Seagull 0.6 |
// +---------------------------------------------------------------------------+
// | AccountMgr.php |
// +---------------------------------------------------------------------------+
// | Author: Demian Turner <demian@phpkitchen.com> |
// +---------------------------------------------------------------------------+
// $Id: AccountMgr.php,v 1.25 2005/05/17 23:54:52 demian Exp $
require_once SGL_MOD_DIR . '/user/classes/UserDAO.php';
require_once 'DB/DataObject.php';
require_once SGL_MOD_DIR . '/main/classes/Main.php';
/**
* Manages User's account.
*
* @package User
* @author Demian Turner <demian@phpkitchen.com>
*/
class TerminateAccountMgr extends SGL_Manager
{
public function TerminateAccountMgr()
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
parent::SGL_Manager();
$this->pageTitle = 'Terminate account';
$this->da = UserDAO::singleton();
$this->_aActionsMapping = array(
'terminate' => array('terminate'),
);
}
public function validate(&$req, &$input)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
$this->validated = true;
$input->error = array();
$input->pageTitle = $this->pageTitle;
$input->action = ($req->get('action')) ? $req->get('action') : 'terminate';
}
public function display(&$output)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
}
function includeSitebuilderDao()
{
require_once(SGL_MOD_DIR . '/../lib/RVSGL/DaoFactory.php');
require_once(SGL_MOD_DIR . '/../lib/RVSGL/SitebuilderDao/DbWrapper.php');
$p = SGL_LIB_DIR . '/RVSGL/SitebuilderDao';
$p = realpath($p);
$aList = rvsLibs_System::ls(array($p), $aDirIgnore = array('SitebuilderInf.php', 'DbWrapper.php'));
$aMethods2 = array();
foreach ($aList['files'] as $path) {
$fileName = end(RvsLibs_String::dbeExplode('/', $path));
if(is_file(SGL_MOD_DIR . '/../lib/RVSGL/SitebuilderDao/'. $fileName)) {
require_once(SGL_MOD_DIR . '/../lib/RVSGL/SitebuilderDao/'. $fileName);
}
}
}
public function _cmd_terminate()
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
/* $moduleConfigFile = SGL_MOD_DIR . '/user/conf.ini';
$c = new SGL_Config();
$config = $c->load($moduleConfigFile);*/
$config = $this->conf;
$oMain = new Main;
$timesCurrent = time();
$unExpire = '0000-00-00 00:00:00';
$query = "
SELECT `usr_id`
,`user_expire`
,`username`
FROM
{$this->conf['table']['user']}
";
//Fix PHP5.3 (use MDB2)
$aUserExpire = $this->dbh->getAll($query, SGL_DB_FETCHMODE_ASSOC);
SGL::logMessage('***query***' . $query, PEAR_LOG_DEBUG);
if ($config['LoginMgr']['enable_terminate_account']) {
SGL::logMessage('_cmd_terminate---if--$config==' . $config['LoginMgr']['enable_terminate_account'], PEAR_LOG_DEBUG);
foreach ($aUserExpire as $key => $value) {
if ($aUserExpire[$key]['usr_id'] != 1 && $aUserExpire[$key]['usr_id'] != '999999999') {
if ($aUserExpire[$key]['user_expire'] != '' && $aUserExpire[$key]['user_expire'] != $unExpire) {
$timeExpire = strtotime($aUserExpire[$key]['user_expire']);
//86400 แปลง เป็น วัน
$aUserExpire[$key]['timeTeminate'] = $timeExpire + ($config['LoginMgr']['terminate_after_expire'] * 86400);
//วัน ปัจจุบัน >= วันที่ terminate
if ($timesCurrent >= $aUserExpire[$key]['timeTeminate']) {
$this->da->deletePrefsByUserId($aUserExpire[$key]['usr_id']);
$this->da->deletePermsByUserId($aUserExpire[$key]['usr_id']);
$this->da->deleteUserTmp($aUserExpire[$key]['usr_id']);
$this->da->deleteChangePassword($aUserExpire[$key]['usr_id']);
if (!empty($config['cookie']['rememberMeEnabled'])) {
$this->da->deleteUserLoginCookiesByUserId($aUserExpire[$key]['usr_id']);
}
$this->da->deleteUserByUserId($aUserExpire[$key]['usr_id']);
if ($oMain->verifyModules('tryout') === true) {
require_once(SGL_MOD_DIR . '/tryout/classes/Api.php');
$this->includeSitebuilderDao();
$oTryoutApi = new TryoutApi();
//deleteFileAndFolder
if ($config['LoginMgr']['terminate_delete_file']) {
$oTryoutApi->deleteFileAndFolder($aUserExpire[$key]['username']);
}
$oTryoutApi->deleteRvsUser($aUserExpire[$key]['username']);
}
}
}
}
}
}
}
}
?>
Copyright 2K16 - 2K18 Indonesian Hacker Rulez