public function run() { $iAccountID = $this->get('id'); $oAccount = new m\Account(); $aDetail = $oAccount->getAccountDetail($iAccountID); if (empty($aDetail)) { c\Router::redirect(c\Router::genURL('Home')); } $aFields = $oAccount->getAccountFields($iAccountID); $oUser = new m\User(); $aDefaultPassword = $oUser->getDefaultPassword(); $aEmails = $oUser->getEmails(); foreach ($aFields as $k => $v) { $aFields[$k]['display'] = u\Str::partCover($v['value'], 2, 1); } sort($aFields); $aFieldNames = array_map(function ($v) { foreach ($v as $key => $value) { if ($key !== 'name') { unset($v[$key]); } } return $v; }, $aFields); $aAccountAll = $oAccount->getAllAccount(); $aSiteList = []; foreach ($aAccountAll as $aAccountDetail) { $aSiteList[] = ['name' => 'link:' . $aAccountDetail['name']]; } $aData = ['page_title' => 'Open Sesame - ' . $aDetail['name'], 'app' => $aDetail, 'fields' => $aFields, 'form_action_add' => c\Router::genURL('AddField'), 'form_action_del' => c\Router::genURL('DeleteField'), 'form_action_updatefield' => c\Router::genURL('UpdateField'), 'form_action_updateaccount' => c\Router::genURL('UpdateAccount'), 'site_list' => json_encode($aSiteList), 'field_names' => json_encode($aFieldNames), 'default_password' => $aDefaultPassword['data'], 'emails' => $aEmails['data']]; return $aData; }
public function run() { $iID = $this->post('id'); $iAccountID = $this->post('account_id'); (new m\Account())->del($iID); c\Router::redirect(c\Router::genURL('Detail', ['id' => $iAccountID])); }
public function run() { $sFieldName = $this->post('field_name'); $sFieldValue = $this->post('field_value'); $iAccountID = $this->post('account_id'); (new m\Account())->addField($sFieldName, $sFieldValue, $iAccountID); c\Router::redirect(c\Router::genURL('Detail', ['id' => $iAccountID])); }
public function run() { $sAccountName = $this->post('account_name'); $sAccountURL = 'http://' . parse_url($this->post('account_url'))['host']; $iAccountID = $this->post('account_id'); (new m\Account())->updateAccount($sAccountName, parse_url($sAccountURL)['host'], $iAccountID, false); c\Router::redirect(c\Router::genURL('Detail', ['id' => $iAccountID])); }
public function run() { $sName = $this->post('name'); $sURL = $this->post('url'); $aURLDetail = parse_url($sURL); $iAccountID = (new m\Account())->addAccount($sName, $aURLDetail['host']); c\Router::redirect(c\Router::genURL('Detail', ['id' => $iAccountID])); }
public function run() { $oAccount = new m\Account(); $iTotal = $oAccount->getTotal(); if ($iTotal === false) { $oAccount->createTable(); } $aData = ['page_title' => 'Open Sesame', 'form_action_add' => c\Router::genURL('AddAccount'), 'site_total' => $iTotal, 'recomm' => (new m\Recommand())->get(4)]; return $aData; }
public function run() { $sKeyword = $this->get('q'); $aList = (new m\Search())->handle($sKeyword); $aOutput = []; foreach ($aList as $aAccount) { $aOutput[] = ['name' => $aAccount['name'], 'rowid' => $aAccount['rowid'], 'info_url' => c\Router::genURL('Detail', ['id' => $aAccount['rowid']]), 'goto_url' => $aAccount['value']]; } $aData = ['page_title' => '搜索结果', 'keyword' => $sKeyword, 'total' => count($aList), 'form_action_del' => c\Router::genURL('DeleteAccount'), 'site_list' => $aOutput]; return $aData; }
/** * 推荐帐号。 * @param int $iSize 推荐个数。 * @return array */ public function get($iSize) { $sSQL = 'SELECT rowid, name, value FROM ' . Account::TABLE_NAME . ' WHERE valid=1 AND parent=0 ORDER BY RANDOM() LIMIT ' . $iSize; $ret = u\DB::getList($sSQL); foreach ($ret as $k => $v) { $ret[$k]['url'] = c\Router::genURL('Detail', ['id' => $v['rowid']]); } return $ret; }
/** * 获得一个帐号的所有记录。 * @param int $iAccountID 帐号ID。 * @return array */ public function getAccountFields($iAccountID) { $sSQL = 'SELECT *, rowid FROM ' . self::TABLE_NAME . ' WHERE parent=? AND valid=' . self::STATUS_VALID; $aResult = u\DB::getList($sSQL, [$iAccountID]); foreach ($aResult as $k => $v) { $aResult[$k]['value'] = $sRealValue = $this->decrypt(gzinflate($v['value'])); $aResult[$k]['name'] = base64_decode(gzinflate($v['name'])); if (substr($sRealValue, 0, 5) === 'link:') { $sSQLAccount = 'SELECT rowid FROM ' . self::TABLE_NAME; $sSQLAccount .= ' WHERE valid=' . self::STATUS_VALID . ' AND name=? LIMIT 1'; $sLinkAccount = substr($sRealValue, 5); $aAccountID = u\DB::getOne($sSQLAccount, [$sLinkAccount]); $aResult[$k]['link'] = c\Router::genURL('Detail', ['id' => $aAccountID['rowid']]); $aResult[$k]['linkname'] = $sLinkAccount; } } return $aResult; }
public function run() { $iID = $this->post('id'); (new m\Account())->del($iID); c\Router::redirect(c\Router::genURL('Home')); }