<?php

/******************************************************************************
 *
 *	PROJECT: Flynax Classifieds Software
 *	VERSION: 4.8.0
 *	LICENSE: FL4HLD2A8696 - http://www.flynax.com/license-agreement.html
 *	PRODUCT: Real Estate Script
 *	DOMAIN: immofil.com
 *	FILE: ACCOUNT_REMOVE.INC.PHP
 *
 *	The software is a commercial product delivered under single, non-exclusive,
 *	non-transferable license for one domain or IP address. Therefore distribution,
 *	sale or transfer of the file in whole or in part without permission of Flynax
 *	respective owners is considered to be illegal and breach of Flynax License End
 *	User Agreement.
 *
 *	You are not allowed to remove this information from the file without permission
 *	of Flynax respective owners.
 *
 *	Flynax Classifieds Software 2020 |  All copyrights reserved.
 *
 *	http://www.flynax.com/
 *
 ******************************************************************************/

$id = (int)$_GET['id'];
$hash = $rlValid->xSql($_GET['hash']);
$md5hash = md5(base64_decode($hash));

if (!isset($_GET['complete'])) {
    if (!$id || !$hash) {
        $sError = true;
    } else {
        $sql = "SELECT `T1`.`ID`, `T1`.`Last_step` ";
        $sql .= "FROM `". RL_DBPREFIX ."accounts` AS `T1` ";
        $sql .= "WHERE `T1`.`ID` = '{$id}' AND `T1`.`Loc_address` = '{$md5hash}' AND `T1`.`Status` = 'incomplete' LIMIT 1";
        $account = $rlDb -> getRow($sql);
        
        if ($account) {
            if (isset($_GET['confirm'])) {
                $reefless->loadClass('Admin', 'admin');
                $rlAdmin->deleteAccountDetails($id);
                $rlDb->query("DELETE FROM `". RL_DBPREFIX ."accounts` WHERE `ID` = '{$id}' LIMIT 1");
                
                $reefless->loadClass('Notice');
                $rlNotice->saveNotice($lang['remote_delete_account_removed']);

                $url = SEO_BASE;
                $url = $config['mod_rewrite'] ? $pages['account_remove'] .'.html?complete' : '?page='. $pages['account_remove']. '&complete';
                $reefless->redirect(null, $url);
            } else {
                $rlSmarty->assign_by_ref('account', $account);
                $rlSmarty->assign('show_form', true);
            }
        } else {
            $rlSmarty->assign('pAlert', $lang['remote_delete_account_alert']);
        }
    }
}