public function loginAction() { session_start(); if (IS_POST) { $username = I('post.username'); $password = I('post.password'); if (empty($username) || empty($password)) { $this->error('请输入用户名及密码'); } $acl = new Acl(); $user = $acl->getUser($username, true); if (!empty($user)) { $pwd = Utility::encodePassword($password, $user['salt']); if ($pwd != $user['password']) { $this->error('您输入的密码错误'); } if ($user['status'] == Acl::STATUS_DISABLED) { $this->error('您的账号已经被禁用, 请联系系统管理员'); } $user = coll_elements(array('uid', 'username', 'role'), $user); session('user', $user); $forward = I('get.forward'); if (empty($forward)) { $forward = U('bench/welcome/index'); } else { $forward = base64_decode($forward); } $this->success('成功登陆', $forward); } else { $this->error('您输入的用户名或密码错误'); } exit; } $this->display('Wander/login'); }
public function alipayModify() { $id = intval(I('get.id')); if (empty($id)) { $this->error('访问错误'); } $a = new Account(); $account = $a->getAccount($id, Account::ACCOUNT_ALIPAY); if (empty($account)) { $this->error('访问错误'); } if (IS_POST) { if (I('post.method') == 'generate') { $ret = Utility::sslGenKey(); if (!is_error($ret)) { $rec = array(); $rec['public_key'] = $ret['public']; $rec['private_key'] = $ret['private']; $a->table('__PLATFORM_ALIPAY__')->data($rec)->where("`id`='{$id}'")->save(); } exit(json_encode($ret)); } $ret = $a->modify(Account::ACCOUNT_ALIPAY, $id); if (is_error($ret)) { $this->error($ret['message']); } $this->success('保存成功'); exit; } $isGen = function_exists('openssl_pkey_new'); $this->assign('isGen', $isGen); $this->assign('entity', $account); $this->display('alipay-form'); }
public function modifyUser($uid, $user) { $uid = intval($uid); $input = coll_elements(array('password', 'role', 'status'), $user); $user = $this->getUser($uid); $input['password'] = Utility::encodePassword($input['password'], $user['salt']); $ret = $this->table('__USR_USERS__')->data($input)->where("`uid`={$uid}")->save(); if ($ret !== false) { return true; } return error(-2, '保存用户数据失败, 请稍后重试'); }
public function touchCheck() { $pub = Utility::sslTrimKey($this->account['public_key']); $ret = "<biz_content>{$pub}</biz_content><success>true</success>"; $dat = $this->client->encryptAndSign($ret, false, true); parent::touchCheck(); $message = $this->parse($this->params['biz_content']); $rec = array(); $rec['appid'] = $message['to']; $m = new Model(); $m->table('__PLATFORM_ALIPAY__')->data($rec)->where("`id`='{$this->account['id']}'")->save(); exit($dat); }
private function fileImageUpload($option) { if (empty($option['width'])) { $option['width'] = 600; } if (!empty($_FILES['file']['name'])) { $ret = Utility::upload($_FILES['file']); if (is_error($ret)) { $this->frameCallback($ret); } File::imageThumb($ret['abs'], $ret['abs'], $option['width']); $result = array(); $result['filename'] = $ret['filename']; $result['url'] = $ret['url']; $result['error'] = 0; $this->frameCallback($result); } else { $this->frameCallback(error(-1, '请选择要上传的图片!')); } }
public function modifyAction($uid) { $uid = intval($uid); $user = $this->acl->getUser($uid, true); if (empty($user)) { $this->error('访问错误'); } if (IS_POST) { $input = $this->validateForm(true); $input = coll_elements(array('password', 'role', 'status'), $input); $input['password'] = Utility::encodePassword($input['password'], $user['salt']); $ret = $this->acl->table('__USR_USERS__')->data($input)->where("`uid`={$uid}")->save(); if (empty($ret)) { $this->error('保存用户信息失败, 请稍后重试'); } else { $this->success('保存成功'); exit; } } $this->assign('user', $user); $this->display('form'); }
public static function saveSettings($settings) { $keys = self::getOptions(); $settings = coll_elements($keys, $settings); return Utility::saveSettings('PAY', $settings); }
public function execAction() { if (IS_POST) { $u = new Utility(); $schemas = array(); foreach ($this->coreTables as $table) { $schemas[] = $u->dbTableSchema($table); } $install = file_get_contents(ADDON_CURRENT_PATH . 'Data/install.php'); $install = str_replace('//{init-db-schemas}', serialize($schemas), $install); $install = str_replace('//{$init-db-datas}', trim($this->coreDatas), $install); $zip = new \ZipArchive(); $tmpFile = ADDON_CURRENT_PATH . 'Data/package.zip'; @unlink($tmpFile); $zip->open($tmpFile, \ZipArchive::CREATE); $release = I('post.release'); $ver = <<<DOC <?php define('MB_VERSION', '1.0.0'); define('MB_RELEASE', '{$release}'); DOC; file_put_contents(MB_ROOT . 'source/Conf/version.inc.php', $ver); $files = File::tree(MB_ROOT); foreach ($files as $file) { $local = substr($file, strlen(MB_ROOT)); $isIgnore = false; foreach ($this->ignores as $ig) { if (preg_match($ig, $local)) { $isIgnore = true; break; } } if (!$isIgnore) { if (substr($local, -4) == '.php' && !preg_match('/^\\/source\\/ThinkPHP\\/.*$/i', $local)) { $content = $this->trimComments($file); if (preg_match('/^\\/source\\/const\\.inc\\.php$/i', $local)) { $content = preg_replace('/^.*define\\(\'APP_DEBUG\'.*$\\n/m', '', $content); } $zip->addFromString("upload{$local}", $content); } else { $zip->addFile($file, "upload{$local}"); } } } $zip->addEmptyDir('upload/addons'); $zip->addEmptyDir('upload/attachment/qr'); $zip->addEmptyDir('upload/attachment/media/alipay'); $zip->addEmptyDir('upload/source/Data/Logs/Api'); $zip->addEmptyDir('upload/source/Data/Logs/Wander'); $zip->addEmptyDir('upload/source/Data/Logs/Bench'); $zip->addEmptyDir('upload/source/Data/Logs/App'); $zip->addEmptyDir('upload/source/Data/Runtime/Web'); $zip->addEmptyDir('upload/source/Data/Runtime/App'); $zip->addFromString('upload/install.php', $install); $zip->close(); $version = MB_VERSION; $filename = "MicroBuilder-V{$version}-Release({$release})"; header('content-type: application/zip'); header('content-disposition: attachment; filename="' . $filename . '.zip"'); readfile($tmpFile); @unlink($tmpFile); } $release = date('YmdHi', TIMESTAMP - TIMESTAMP % 1800 + 1800); $this->assign('release', $release); $this->display('Publish/exec'); }
public function create($member, $fan = null) { if (!preg_match('/^1\\d{10}$/', $member['mobile'])) { return error(-1, '你输入的手机号格式不正确'); } $condition = '`mobile`=:mobile'; $pars = array(); $pars[':mobile'] = $member['mobile']; $exist = $this->table('__MMB_MEMBERS__')->where($condition)->bind($pars)->find(); if (!empty($exist)) { return error(-2, '你输入的手机号已经注册过, 请直接登陆或者更换后重试'); } $rec = coll_elements(array('mobile', 'password'), $member, ''); $rec['salt'] = util_random(8); $rec['password'] = Utility::encodePassword($rec['password'], $rec['salt']); $condition = '`isdefault`=1'; $pars = array(); $group = $this->table('__MMB_GROUPS__')->where($condition)->bind($pars)->find(); $rec['groupid'] = $group['id']; $rec['createtime'] = TIMESTAMP; $rec['joinfrom'] = $member['from']; if (empty($rec['joinfrom'])) { $rec['joinfrom'] = ''; } $ret = $this->table('__MMB_MEMBERS__')->data($rec)->add(); if (empty($ret)) { return error(-2, '系统错误, 创建会员失败, 请稍后重试'); } $uid = $this->getLastInsID(); $this->table('__MMB_PROFILES__')->data(array('uid' => $uid))->add(); if (!empty($fan) && empty($fan['uid'])) { if ($rec['joinfrom'] == 'weixin') { $record = array(); $record['uid'] = $uid; $this->table('__MMB_MAPPING_FANS__')->data($record)->where("`fanid`='{$fan['fanid']}' OR `unionid`='{$fan['unionid']}'")->save(); } } return $uid; }
public function uninstall() { $u = new Utility(); $u->dbRunQuery(trim($this->uninstallSql)); }