<?php $tables_to_clear = array(User::table(), Customer::table(), Product::table(), Cart::table(), Address::table(), UserLog::table(), Account::table(), AccountHistory::table()); $db = Sdb::getDb(); foreach ($tables_to_clear as $table) { $db->exec("TRUNCATE TABLE {$table}"); } if (_get('exit')) { echo '<script src="static/hide.js"></script>'; echo '<div class="conclusion pass">All Clear!</div>'; exit; }
/** * Actualiza la clave de una cuenta en la BBDD. * * @param bool $isMassive para no actualizar el histórico ni enviar mensajes * @param bool $isRestore indica si es una restauración * @return bool */ public function updateAccountPass($isMassive = false, $isRestore = false) { $Log = new Log(__FUNCTION__); // No actualizar el histórico si es por cambio de clave maestra o restauración if (!$isMassive && !$isRestore) { // Guardamos una copia de la cuenta en el histórico if (!AccountHistory::addHistory($this->getAccountId(), false)) { $Log->addDescription(_('Error al actualizar el historial')); $Log->writeLog(); return false; } } $query = 'UPDATE accounts SET ' . 'account_pass = :accountPass,' . 'account_IV = :accountIV,' . 'account_userEditId = :accountUserEditId,' . 'account_dateEdit = NOW() ' . 'WHERE account_id = :accountId'; $data['accountPass'] = $this->getAccountPass(); $data['accountIV'] = $this->getAccountIV(); $data['accountUserEditId'] = $this->getAccountUserEditId(); $data['accountId'] = $this->getAccountId(); if (DB::getQuery($query, __FUNCTION__, $data) === false) { return false; } // No escribir en el log ni enviar correos si la actualización es // por cambio de clave maestra o restauración if (!$isMassive && !$isRestore) { $accountInfo = array('customer_name', 'account_name'); $this->getAccountInfoById($accountInfo); $Log->setAction(_('Modificar Clave')); $Log->addDescription(Html::strongText(_('Cliente') . ': ') . $this->_cacheParams['customer_name']); $Log->addDescription(Html::strongText(_('Cuenta') . ': ') . $this->_cacheParams['account_name'] . " (" . $this->getAccountId() . ")"); $Log->writeLog(); Email::sendEmail($Log); } return true; }
/** * Comprobar el hash de una clave. * * @param string $pwd con la clave a comprobar * @param string $checkedHash con el hash a comprobar * @param bool $isMPass si es la clave maestra * @return bool */ public static function checkHashPass($pwd, $checkedHash, $isMPass = false) { // Obtenemos el salt de la clave $salt = substr($checkedHash, 0, 72); // Obtenemos el hash SHA256 $validHash = substr($checkedHash, 72); // Re-hash de la clave a comprobar $testHash = crypt($pwd, $salt); // Comprobar si el hash está en formato anterior a 12002 if ($isMPass && strlen($checkedHash) === 128) { $check = hash("sha256", substr($checkedHash, 0, 64) . $pwd) == substr($checkedHash, 64, 64); if ($check) { $newHash = self::mkHashPassword($pwd); AccountHistory::updateAccountsMPassHash($newHash); ConfigDB::setValue('masterPwd', $newHash); Log::writeNewLog(_('Aviso'), _('Se ha regenerado el HASH de clave maestra. No es necesaria ninguna acción.')); } return $check; } // Si los hashes son idénticos, la clave es válida return $testHash == $validHash; }
public function historyAction() { $command = $this->_getParam('command'); if ($command != null && $command != '') { $userID = $this->_getParam('userID'); $userNo = $this->_getParam('userNo'); $fromStr = $this->_getParam('fromDate'); $toStr = $this->_getParam('toDate'); $part = 'dd/MM/YYYY'; $fromDate = $fromStr == null ? new Zend_Date() : new Zend_Date($fromStr, $part); $toDate = $toStr == null ? new Zend_Date() : new Zend_Date($toStr, $part); if ($fromDate->compare($toDate, $part, $fromDate->getLocale()) > 0) { $this->view->errMsg = "Invalid Period"; $this->render('history'); return; } require_once APPLICATION_PATH . '/models/AccountHistory.php'; //require_once ROOT_PATH.'/util/Period.php'; $hisObj = new AccountHistory(); $period = new Zing_Util_Period($fromDate, $toDate); $hisRows = $hisObj->getStatement($userID, $userNo, $period); $this->view->statements = $hisRows; } $this->render('history'); }