public function update($assetID) { $skipFields = ''; $skipFields .= $this->loadModel('custom')->dealWithCustomArrayField(); $oldAsset = $this->getAssetById($assetID); $now = helper::now(); $address = fixer::input('post')->get('address'); $extendaddress = fixer::input('post')->get('extendaddress'); $devicenumber = fixer::input('post')->get('devicenumber'); $code = fixer::input('post')->get('code'); $module = $this->loadModel('info')->getAllChildId(fixer::input('post')->cleanInt('module')->setDefault('module', 0)->get('module'), 'asset'); $result1 = $this->dao->select('*')->from(TABLE_INFOASSET)->where('address')->eq($extendaddress)->andWhere('address')->ne('IP Format Error')->andWhere('address')->ne('Conflict!')->andWhere('address')->ne('')->beginIF($module)->andWhere('module')->in($module)->fi()->fetchAll(); $result2 = $this->dao->select('*')->from(TABLE_INFOASSET)->where('extendaddress')->eq($address)->andWhere('extendaddress')->ne('IP Format Error')->andWhere('extendaddress')->ne('Conflict!')->andWhere('extendaddress')->ne('')->beginIF($module)->andWhere('module')->in($module)->fi()->fetchAll(); $asset = fixer::input('post')->cleanInt('module')->setDefault('module', 0)->add('lastEditedBy', $this->app->user->account)->add('lastEditedDate', $now)->setDefault('lenddate', '0000-00-00')->setDefault('returndate', '0000-00-00')->setDefault('product', '0')->setDefault('project', '0')->setIF(!(strlen(trim($extendaddress)) == 0) && !validater::checkIP($extendaddress), 'extendaddress', 'IP Format Error')->setIF(!(strlen(trim($address)) == 0) && !validater::checkIP($address), 'address', 'IP Format Error')->removeIF(trim($address) == trim($extendaddress), 'extendaddress')->setIF($result1, 'extendaddress', 'Conflict!')->setIF($result2, 'address', 'Conflict!')->get(); $condition = "`lib` = '{$asset->lib}' AND module = '{$asset->module}' and id != '{$assetID}'"; $conditionaddress = $condition . " and address != 'IP Format Error' and address != 'Conflict!'"; $conditionextaddress = $condition . " and extendaddress != 'IP Format Error' and extendaddress != 'Conflict!'"; $this->dao->update(TABLE_INFOASSET)->data($asset)->autoCheck($skipFields)->batchCheck($this->config->asset->edit->requiredFields, 'notempty')->check('hostname', 'unique', $condition)->checkIF(!(strlen(trim($address)) == 0), 'address', 'unique', $conditionaddress)->checkIF(!(strlen(trim($extendaddress)) == 0), 'extendaddress', 'unique', $conditionextaddress)->checkIF(!(strlen(trim($devicenumber)) == 0), 'devicenumber', 'unique', $condition)->checkIF(!(strlen(trim($code)) == 0), 'code', 'unique', $condition)->where('id')->eq((int) $assetID)->exec(); $asset->editedCount = $asset->editedCount - 1; if (!dao::isError()) { return common::createChanges($oldAsset, $asset); } }
/** * Add a blacklist item. * * @access public * @return void */ public function addBlacklist() { $typeList = $this->lang->guarder->blacklistModes; if ($_POST) { $item = $this->post->identity; $type = 'keywords'; if (validater::checkIP($item)) { $type = 'ip'; } if (validater::checkEmail($item)) { $type = 'email'; } if (validater::checkAccount($item)) { $user = $this->loadModel('user')->getByAccount($item); if (!empty($user)) { $type = 'account'; } } $result = $this->guarder->punish($type, $item, $this->post->reason, $this->post->expired); if ($result) { $this->send(array('result' => 'success', 'message' => $this->lang->setSuccess, 'locate' => inlink('blacklist', "mode={$type}"))); } $this->send(array('result' => 'fail', 'message' => dao::geterror())); } $this->view->title = $this->lang->guarder->addBlacklist; $this->display(); }