/** * 编辑 */ public function store_class_editOp() { $lang = Language::getLangContent(); $model_class = Model('store_class'); if (chksubmit()) { //验证 $obj_validate = new Validate(); $obj_validate->validateparam = array(array("input" => $_POST["sc_name"], "require" => "true", "message" => $lang['store_class_name_no_null'])); $error = $obj_validate->validate(); if ($error != '') { showMessage($error); } else { $update_array = array(); $update_array['sc_name'] = $_POST['sc_name']; $update_array['sc_bail'] = intval($_POST['sc_bail']); $update_array['sc_sort'] = intval($_POST['sc_sort']); $result = $model_class->editStoreClass($update_array, array('sc_id' => intval($_POST['sc_id']))); if ($result) { $this->log(L('nc_edit,store_class') . '[' . $_POST['sc_name'] . ']', 1); showMessage($lang['nc_common_save_succ'], 'index.php?act=store_class&op=store_class'); } else { showMessage($lang['nc_common_save_fail']); } } } $class_array = $model_class->getStoreClassInfo(array('sc_id' => intval($_GET['sc_id']))); if (empty($class_array)) { showMessage($lang['illegal_parameter']); } Tpl::output('class_array', $class_array); Tpl::showpage('store_class.edit'); }
public function testOutOfExistsFieldNotFound() { $testdata = ["name" => "Foo Bar", "mobile" => "0912345678", "address" => "Hong Kong", "phone" => "12345678"]; $chk = new Validate($testdata); $chk->outOf(["address", "phone", "mobile", "business"], 4); $this->assertFalse($chk->validate()); }
public function unbindOp() { //修改密码 $model_member = Model('member'); $update_arr = array(); if ($_POST['is_editpw'] == 'yes') { /** * 填写密码信息验证 */ $obj_validate = new Validate(); $obj_validate->validateparam = array(array("input" => $_POST["new_password"], "require" => "true", "validator" => "Length", "min" => 6, "max" => 20, "message" => Language::get('member_qqconnect_password_null')), array("input" => $_POST["confirm_password"], "require" => "true", "validator" => "Compare", "operator" => "==", "to" => $_POST["new_password"], "message" => Language::get('member_qqconnect_input_two_password_again'))); $error = $obj_validate->validate(); if ($error != '') { showMessage($error, '', 'html', 'error'); } $update_arr['member_passwd'] = md5(trim($_POST['new_password'])); } $update_arr['member_qqopenid'] = ''; $update_arr['member_qqinfo'] = ''; $edit_state = $model_member->updateMember($update_arr, $_SESSION['member_id']); if (!$edit_state) { showMessage(Language::get('member_qqconnect_password_modify_fail'), 'html', 'error'); } session_unset(); session_destroy(); showMessage(Language::get('member_qqconnect_unbind_success'), 'index.php?act=login&ref_url=' . urlencode('index.php?act=member_qqconnect&op=qqbind')); }
/** * 上传参数设置 * */ public function paramOp() { if (chksubmit()) { $obj_validate = new Validate(); $obj_validate->validateparam = array(array("input" => $_POST["image_max_filesize"], "require" => "true", "validator" => "Number", "message" => L('upload_image_filesize_is_number')), array("input" => trim($_POST["image_allow_ext"]), "require" => "true", "message" => L('image_allow_ext_not_null'))); $error = $obj_validate->validate(); if ($error != '') { showMessage($error); } else { $model_setting = Model('setting'); $result = $model_setting->updateSetting(array('image_dir_type' => intval($_POST['image_dir_type']), 'image_max_filesize' => intval($_POST['image_max_filesize']), 'image_allow_ext' => $_POST['image_allow_ext'])); if ($result) { $this->log(L('nc_edit,upload_param'), 1); showMessage(L('nc_common_save_succ')); } else { $this->log(L('nc_edit,upload_param'), 0); showMessage(L('nc_common_save_fail')); } } } //获取默认图片设置属性 $model_setting = Model('setting'); $list_setting = $model_setting->getListSetting(); Tpl::output('list_setting', $list_setting); //输出子菜单 Tpl::output('top_link', $this->sublink($this->links, 'param')); Tpl::showpage('upload.param'); }
/** * 管理员编辑 */ public function admin_editOp() { /** * 保存 */ if (isset($_POST) && !empty($_POST)) { //表单验证 $obj_validate = new Validate(); $obj_validate->validateparam = array(array("input" => trim($_POST['admin_password']), "require" => "true", "message" => Language::get('nc_admin_admin_password_is_not_null')), array("input" => trim($_POST['admin_confirm_password']), "require" => "true", "message" => Language::get('nc_admin_password_confirm_is_not_null'))); $error = $obj_validate->validate(); if ($error != '') { $this->showTip(Language::get('error') . $error, '', 'error'); } $condition = array(); $condition['admin_id'] = intval($_POST['admin_id']); $params = array(); $params['admin_password'] = md5(trim($_POST['admin_password'])); $model = Model(); $result = $model->table('admin')->where($condition)->update($params); if ($result) { $this->showTip(Language::get('nc_admin_edit_account_succ')); } else { $this->showTip(Language::get('nc_admin_edit_account_fail')); } } $admin_id = intval($_GET['admin_id']); $model = Model(); $admininfo = $model->table('admin')->where(array('admin_id' => $admin_id))->find(); if (empty($admininfo)) { $this->showTip(Language::get('nc_admin_add_account_succ')); } Tpl::output('admininfo', $admininfo); Tpl::showpage('admin.edit'); }
/** * 保存平台咨询 */ public function save_mallconsultOp() { if (!chksubmit()) { showDialog(L('wrong_argument'), 'reload'); } //验证表单信息 $obj_validate = new Validate(); $obj_validate->validateparam = array( array("input"=>$_POST["type_id"],"require"=>"true","validator"=>"Number","message"=>"请选择咨询类型"), array("input"=>$_POST["consult_content"],"require"=>"true","message"=>"请填写咨询内容") ); $error = $obj_validate->validate(); if ($error != ''){ showDialog($error); } $insert = array(); $insert['mct_id'] = $_POST['type_id']; $insert['member_id'] = $_SESSION['member_id']; $insert['member_name'] = $_SESSION['member_name']; $insert['mc_content'] = $_POST['consult_content']; $result = Model('mall_consult')->addMallConsult($insert); if ($result) { showDialog(L('nc_common_op_succ'), 'reload', 'succ'); } else { showDialog(L('nc_common_op_fail'), 'reload'); } }
/** * 编辑邮件模板 */ public function email_tpl_editOp() { $model_templates = Model('mail_templates'); if (chksubmit()) { $obj_validate = new Validate(); $obj_validate->validateparam = array(array("input" => $_POST["code"], "require" => "true", "message" => L('mailtemplates_edit_no_null')), array("input" => $_POST["title"], "require" => "true", "message" => L('mailtemplates_edit_title_null')), array("input" => $_POST["content"], "require" => "true", "message" => L('mailtemplates_edit_content_null'))); $error = $obj_validate->validate(); if ($error != '') { showMessage($error); } else { $update_array = array(); $update_array['code'] = $_POST["code"]; $update_array['title'] = $_POST["title"]; $update_array['content'] = $_POST["content"]; $result = $model_templates->editTpl($update_array, array('code' => $_POST['code'])); if ($result === true) { $this->log(L('nc_edit,email_tpl'), 1); showMessage(L('mailtemplates_edit_succ'), 'index.php?act=message&op=email_tpl'); } else { $this->log(L('nc_edit,email_tpl'), 0); showMessage(L('mailtemplates_edit_fail')); } } } if (empty($_GET['code'])) { showMessage(L('mailtemplates_edit_code_null')); } $templates_array = $model_templates->getTplInfo(array('code' => $_GET['code'])); Tpl::output('templates_array', $templates_array); Tpl::output('top_link', $this->sublink($this->links, 'email_tpl')); Tpl::showpage('message.email_tpl.edit'); }
/** * 金币设置 */ public function settingOp() { /** * 读取语言包 */ $lang = Language::getLangContent(); /** * 实例化模型 */ $model_setting = Model('setting'); /** * 保存信息 */ if (chksubmit()) { /** * 验证 */ $obj_validate = new Validate(); $obj_validate->validateparam = array(array("input" => $_POST["gold_isuse"], "require" => "true", "message" => $lang['gold_isuse_check']), array("input" => $_POST["gold_rmbratio"], "require" => "true", "validator" => "Number", "message" => $lang['gold_rmbratio_isnum'])); $error = $obj_validate->validate(); if ($error != '') { showMessage($error); } else { /* * 构造更新数据数组 */ $update_array = array(); $update_array['promotion_allow'] = trim($_POST['promotion_allow']); $update_array['points_isuse'] = trim($_POST['points_isuse']); $update_array['gold_isuse'] = trim($_POST['gold_isuse']); $update_array['gold_rmbratio'] = trim($_POST['gold_rmbratio']); $update_array['predeposit_isuse'] = trim($_POST['predeposit_isuse']); $update_array['groupbuy_allow'] = trim($_POST['groupbuy_allow']); //积分中心 $update_array['pointshop_isuse'] = trim($_POST['pointshop_isuse']); if (C('payment') != 1) { $update_array['predeposit_isuse'] = 1; } //支付到平台时强制开启预存款功能 $result = $model_setting->updateSetting($update_array); if ($result === true) { showMessage($lang['nc_common_save_succ']); } else { showMessage($lang['nc_common_save_fail']); } } } /** * 读取设置内容 $list_setting */ $list_setting = $model_setting->getListSetting(); /** * 模板输出 */ Tpl::output('list_setting', $list_setting); Tpl::showpage('operation.setting'); }
/** * 检查修改密码数据 * @author Yusure http://yusure.cn * @date 2016-02-15 * @param [param] * @return [type] [description] */ private function _check_passwd_data() { import('Org.Util.Validate'); $obj_validate = new \Validate(); $obj_validate->validateparam = array(array('input' => $_POST['old_pwd'], 'require' => 'true', 'message' => '旧不能为空'), array('input' => $_POST['new_pwd'], 'require' => 'true', 'message' => '新密码不能为空'), array('input' => $_POST['new_pwd'], 'require' => 'true', 'validator' => 'length', 'min' => '6', 'max' => '16', 'message' => '密码范围在6~16位之间!'), array('input' => $_POST['confirm_pwd'], 'require' => 'true', 'message' => '确认密码不能为空'), array('input' => $_POST['new_pwd'], 'validator' => 'compare', 'operator' => '==', 'to' => $_POST['confirm_pwd'], 'message' => '您两次输入的密码不一致!')); $error = $obj_validate->validate(); if ($error != '') { $this->error($error); } }
/** * 检查登陆提交 * @author Yusure http://yusure.cn * @date 2016-02-03 * @param [param] * @return [type] [description] */ private function _checkLoginPost() { import('Org.Util.Validate'); $obj_validate = new \Validate(); $obj_validate->validateparam = array(array('input' => $_POST['user_name'], 'require' => 'true', 'message' => '用户名不能为空'), array('input' => $_POST['user_passwd'], 'require' => 'true', 'message' => '密码不能为空'), array('input' => $_POST['user_name'], 'require' => 'true', 'validator' => 'length', 'min' => '1', 'max' => '32', 'message' => '用户名太长'), array('input' => $_POST['user_passwd'], 'require' => 'true', 'validator' => 'length', 'min' => '1', 'max' => '32', 'message' => '密码太长')); $error = $obj_validate->validate(); if ($error != '') { $this->error($error); } }
/** * 编辑 */ public function mb_home_editOp() { $model = Model('mb_home'); if ($_POST['form_submit'] == 'ok') { //验证 $obj_validate = new Validate(); $obj_validate->validateparam = array(array("input" => $_POST["h_title"], "require" => "true", "message" => L('home_add_null')), array("input" => $_POST["h_desc"], "require" => "true", "message" => L('home_add_null')), array("input" => $_POST["h_keyword"], "require" => "true", "message" => L('home_add_null')), array("input" => $_POST["h_sort"], "require" => "true", 'validator' => 'Number', "message" => L('home_add_sort_int'))); $error = $obj_validate->validate(); if ($error != '') { showMessage($error); } else { $home_array = $model->getMbHomeInfoByID(intval($_POST['h_id'])); //上传图片 if ($_FILES['h_img']['name'] != '') { $upload = new UploadFile(); $upload->set('default_dir', ATTACH_MOBILE . '/home'); $result = $upload->upfile('h_img'); if ($result) { $_POST['h_img'] = $upload->file_name; } else { showMessage($upload->error); } } $update_array = array(); $update_array['h_title'] = trim($_POST['h_title']); $update_array['h_desc'] = trim($_POST['h_desc']); $update_array['h_keyword'] = trim($_POST['h_keyword']); if (!empty($_POST['h_multi_keyword'])) { $update_array['h_multi_keyword'] = $_POST['h_multi_keyword']; } if ($_POST['h_img']) { $update_array['h_img'] = $_POST['h_img']; } $update_array['h_sort'] = trim($_POST['h_sort']); $condition = array(); $condition['h_id'] = intval($_POST['h_id']); $result = $model->editMbHome($update_array, $condition); if ($result) { //除图片 if (!empty($_POST['h_img']) && !empty($home_array['h_img'])) { @unlink(BASE_ROOT_PATH . DS . DIR_UPLOAD . DS . ATTACH_MOBILE . '/home' . DS . $home_array['h_img']); } showMessage(L('home_edit_succ'), 'index.php?act=mb_home&op=mb_home_list'); } else { showMessage(L('home_edit_fail')); } } } $home_array = $model->getMbHomeInfoByID(intval($_GET['h_id'])); if (empty($home_array)) { showMessage(L('wrong_argument')); } Tpl::output('home_array', $home_array); Tpl::showpage('mb_home.edit'); }
/** * update/insert row * * @param array array The array of key => value pairs to be inserted into the database * * @return object */ public function save($array = null) { //get our class $class = get_called_class(); //get our table column / field names $fields = array_keys($class::$columns); //get our table name $table = $class::$table; //if we're passed an array of key => value pairs, use those //and override the other values that were passed in if (!is_null($array) and is_array($array)) { foreach ($array as $key => $value) { $this->{$key} = $value; } } //loop through out fields... foreach ($fields as $key) { //for ease or access, store this $value = $this->{$key}; //auto-validate $validated = Validate::validate($class, $key, $value); //check the validate didnt return false (failing) if ($validated === false) { //if it did, throw an exception throw new MeagrException('The value "' . $value . '" was given for "' . $key . '" breaking one or more validate rules "' . implode('", "', $class::$columns[$key]['validate']) . '". '); continue; } //if we passed validate if (isset($value) and !empty($value) and $validated !== false) { $data[$key] = $validated; //if the value was empty or not set, use the default value } elseif (!empty($class::$columns[$key]['database']['default'])) { $data[$key] = $class::$columns[$key]['database']['default']; //we shouldnt really get here, but if we do, use empty string } else { $data[$key] = ''; } } //get the db instance $db = new Database(); //update if (isset($data['id']) and !empty($data['id'])) { //set the updated time $data['updated_at'] = date('Y-m-d H:i:s'); return $db->update($table, $data); //insert } else { //set our time stamps $data['created_at'] = date('Y-m-d H:i:s'); $data['updated_at'] = date('Y-m-d H:i:s'); return $db->insert($table, $data); } }
/** * cms标签标题修改 */ public function update_tag_nameOp() { $new_value = trim($_GET['value']); $obj_validate = new Validate(); $obj_validate->validateparam = array(array('input' => $new_value, 'require' => 'true', "validator" => "Length", "min" => "1", "max" => "10", 'message' => Language::get('tag_name_error'))); $error = $obj_validate->validate(); if ($error != '') { echo json_encode(array('result' => FALSE, 'message' => Language::get('tag_name_error'))); die; } else { $this->update_tag('tag_name', $new_value); } }
/** * 登录操作 * */ public function loginOp() { //检测登陆 $this->checklogin(); if (isset($_POST) && !empty($_POST)) { $obj_validate = new Validate(); $obj_validate->validateparam = array(array("input" => $_POST["member_name"], "require" => "true", "message" => $lang['nc_login_username_is_not_null']), array("input" => $_POST["password"], "require" => "true", "message" => $lang['nc_login_password_is_not_null'])); $error = $obj_validate->validate(); if ($error != '') { $this->showTip(Language::get('error') . $error, '', 'error'); } $params = array(); $params['member_name'] = trim($_POST['member_name']); $params['password'] = md5($_POST['password']); $model = Model(); $memberinfo = $model->table('member')->where($params)->find(); if (empty($memberinfo)) { $this->showTip(Language::get('login_index_login_again'), '', 'error'); } $_SESSION['is_login'] = '******'; $_SESSION['member_id'] = $memberinfo['member_id']; $_SESSION['member_name'] = $memberinfo['member_name']; $_SESSION['avatar'] = $memberinfo['avatar']; $_SESSION['store_id'] = $memberinfo['store_id']; $model->table('member')->where(array('member_id' => $memberinfo['member_id']))->setInc('login_num', 1); //选择城市 $area_id = $memberinfo['usercity']; $model_area = Model('area'); $area_info = $model_area->getOne(array('area_id' => $area_id)); if (get_magic_quotes_gpc()) { $area_str = serialize($area_info); } else { $area_str = serialize(@addslashes($area_info)); } setCookie('city', $area_str); $_POST['ref_url'] = strstr($_POST['ref_url'], 'logout') === false && !empty($_POST['ref_url']) ? $_POST['ref_url'] : 'index.php?act=index'; if ($_GET['inajax'] == 1) { showDialog(Language::get('login_index_login_success'), 'reload', succ); } if (!empty($_POST['ref_url'])) { $this->showTip(Language::get('login_index_login_success'), $_POST['ref_url'], 'succ'); } else { $this->showTip(Language::get('login_index_login_again'), 'index.php?act=login', 'error'); } } if (empty($_GET['ref_url'])) { $_GET['ref_url'] = getReferer(); } Tpl::output('banner', 1); Tpl::showpage('login'); }
/** * 积分添加 */ public function addpointsOp() { if ($_POST['form_submit'] == 'ok') { /** * 验证 */ $obj_validate = new Validate(); $obj_validate->validateparam = array(array("input" => $_POST["member_id"], "require" => "true", "message" => Language::get('admin_points_member_error_again')), array("input" => $_POST["pointsnum"], "require" => "true", 'validator' => 'Compare', 'operator' => ' >= ', 'to' => 1, "message" => Language::get('admin_points_points_min_error'))); $error = $obj_validate->validate(); if ($error != '') { showMessage($error, '', '', 'error'); } //查询会员信息 $obj_member = Model('member'); $member_id = intval($_POST['member_id']); $member_info = $obj_member->infoMember(array('member_id' => "{$member_id}")); if (!is_array($member_info) || count($member_info) <= 0) { showMessage(Language::get('admin_points_userrecord_error'), 'index.php?act=points&op=addpoints', '', 'error'); } $pointsnum = intval($_POST['pointsnum']); if ($_POST['operatetype'] == 2 && $pointsnum > intval($member_info['member_points'])) { showMessage(Language::get('admin_points_points_short_error') . $member_info['member_points'], 'index.php?act=points&op=addpoints', '', 'error'); } $obj_points = Model('points'); $insert_arr['pl_memberid'] = $member_info['member_id']; $insert_arr['pl_membername'] = $member_info['member_name']; $admininfo = $this->getAdminInfo(); $insert_arr['pl_adminid'] = $admininfo['id']; $insert_arr['pl_adminname'] = $admininfo['name']; if ($_POST['operatetype'] == 2) { $insert_arr['pl_points'] = -$_POST['pointsnum']; } else { $insert_arr['pl_points'] = $_POST['pointsnum']; } if ($_POST['pointsdesc']) { $insert_arr['pl_desc'] = trim($_POST['pointsdesc']); } else { $insert_arr['pl_desc'] = Language::get('admin_points_system_desc'); } $result = $obj_points->savePointsLog('system', $insert_arr, true); if ($result) { showMessage(Language::get('admin_points_add_success'), 'index.php?act=points&op=addpoints'); } else { showMessage(Language::get('admin_points_add_fail'), 'index.php?act=points&op=addpoints', '', 'error'); } } else { Tpl::showpage('points.add'); } }
/** * 添加停车位 */ public function party_addOp() { require_once BASE_RESOURCE_PATH . DS . 'phpqrcode' . DS . 'index.php'; $PhpQRCode = new PhpQRCode(); $PhpQRCode->set('pngTempDir', BASE_UPLOAD_PATH . DS . ATTACH_STORE . DS . 'party' . DS); //$lang = Language::getLangContent(); $model_party_barcode = Model('party_barcode'); if (chksubmit()) { $obj_validate = new Validate(); $obj_validate->validateparam = array(array("input" => $_POST["code"], "require" => "true", "message" => "请输入编码"), array("input" => $_POST["address"], "require" => "true", "message" => "请输入地址")); $error = $obj_validate->validate(); if ($error != '') { showMessage($error); } else { $PB = array(); $PB['code'] = $_POST['code']; $PB['address'] = $_POST['address']; $PB['lastuptime'] = time(); $return = $model_party_barcode->addPB($PB); // 生成商品二维码 if (!empty($return)) { //QueueClient::push('createGoodsQRCode', array('store_id' => $_SESSION['store_id'], 'goodsid_array' => $goodsid_array)); // 生成停车位二维码 $PhpQRCode->set('date', $return); $PhpQRCode->set('pngTempName', $return . '.png'); $PhpQRCode->init(); // $model_party_barcode->editPB( // array('barcodeurl'=>trim($_GET['value'])), // 'spec' // ); } if ($return) { $url = array(array('url' => 'index.php?act=party_barcode&op=party_add', 'msg' => "继续添加"), array('url' => 'index.php?act=party_barcode&op=index', 'msg' => "查看所有")); $this->log('新建停车位[' . $_POST['s_name'] . ']', 1); showMessage("添加成功", $url); } else { $this->log('[新建停车位' . $_POST['s_name'] . ']', 0); showMessage("添加失败"); } } } // 一级商品分类 //$gc_list = H('party_codes') ? H('party_codes') : H('party_codes', true); //Tpl::output('gc_list', $gc_list); Tpl::showpage('party_barcode.add'); }
public function editOp() { $payement_model = Model('payment'); //编辑 if (isset($_POST) && !empty($_POST)) { $payment_id = intval($_POST['payment_id']); /* * 验证 */ $obj_validate = new Validate(); $obj_validate->validateparam = array(array("input" => $payment_id, "require" => "true", "message" => Language::get('wrong_argument'))); $error = $obj_validate->validate(); if ($error != '') { showMessage($error); } $params = array('payment_state' => $_POST['payment_state'], 'payment_info' => trim($_POST["payment_info"])); $payment_config = ''; $config_array = explode(',', $_POST["config_name"]); //配置参数 if (is_array($config_array) && !empty($config_array)) { $config_info = array(); foreach ($config_array as $k) { $config_info[$k] = trim($_POST[$k]); } $payment_config = serialize($config_info); } $params['payment_config'] = $payment_config; //支付接口配置信息 $condition = array('payment_id' => $payment_id); $result = $payement_model->modify($params, $condition); if ($result) { $this->showTip('编辑成功', '', 'succ'); } else { $this->showTip('编辑失败', '', 'fail'); } } //支付方式 $payment_id = intval($_GET['payment_id']); $payment = $payement_model->getOne(array('payment_id' => $payment_id)); Tpl::output('payment', $payment); //配置信息 $payment_config = $payment['payment_config']; $config_array = unserialize($payment_config); Tpl::output('config_array', $config_array); Tpl::showpage('payment.edit'); }
public function chargeOp() { if (isset($_POST) && !empty($_POST)) { $obj_validate = new Validate(); $validate_array = array(array('input' => $_POST['payment'], 'require' => 'true', 'message' => '支付方式不能为空'), array('input' => $_POST['charge_price'], 'require' => 'true', 'message' => '充值金额不能为空')); $obj_validate->validateparam = $validate_array; $error = $obj_validate->validate(); if ($error != '') { showMessage(Language::get('error') . $error, '', '', 'error'); } //获得支付信息 $payment_id = intval($_POST['payment']); $payment_model = Model('payment'); $payment = $payment_model->getOne(array('payment_id' => $payment_id)); if (empty($payment)) { $this->showTip(L('nc_admin_payment_is_not_exists'), '', 'html', 'error'); } $params = array('pdr_sn' => $this->recharge_snOrder(), 'member_id' => $_SESSION['member_id'], 'member_name' => $_SESSION['member_name'], 'payment' => $payment['payment_id'], 'payment_name' => $payment['payment_name'], 'charge_price' => $_POST['charge_price'], 'charge_des' => $_POST['charge_des'], 'charge_time' => time(), 'state' => 1); $model = Model(); $result = $model->table('predeposit_charge')->insert($params); if ($result) { //使用在线支付时跳转到对应的网站 $payment_orderinfo = array(); $payment_orderinfo['order_sn'] = $params['pdr_sn']; $payment_orderinfo['order_desc'] = '预存款充值'; $payment_orderinfo['order_amount'] = $params['charge_price']; $payment_orderinfo['modeltype'] = '3'; //表示是预存款功能调用支付接口 //支付信息 $payment_info = array(); $payment_info['payment_config'] = unserialize($payment['payment_config']); $inc_file = BASE_ROOT_PATH . DS . ATTACH_PATH . DS . 'api' . DS . 'gold_payment' . DS . $payment['payment_code'] . DS . $payment['payment_code'] . '.php'; //加载配置文件 require_once $inc_file; $payment_api = new $payment['payment_code']($payment_info, $payment_orderinfo); @header("Location: " . $payment_api->get_payurl()); exit; } else { $this->showTip(L('nc_recharge_fail'), '', 'html', 'error'); } } $payment_model = Model('payment'); $paymentlist = $payment_model->getList(array('payment_state' => 1)); Tpl::output('list', $paymentlist); Tpl::showpage('predeposit.charge'); }
/** * 注册 */ public function register($register_info) { // 注册验证 $obj_validate = new Validate(); $obj_validate->validateparam = array(array("input" => $register_info["username"], "require" => "true", "message" => '用户名不能为空'), array("input" => $register_info["password"], "require" => "true", "message" => '密码不能为空'), array("input" => $register_info["password_confirm"], "require" => "true", "validator" => "Compare", "operator" => "==", "to" => $register_info["password"], "message" => '密码与确认密码不相同'), array("input" => $register_info["email"], "require" => "true", "validator" => "email", "message" => '电子邮件格式不正确')); $error = $obj_validate->validate(); if ($error != '') { return array('error' => $error); } // 验证用户名是否重复 $check_member_name = $this->infoMember(array('member_name' => trim($register_info['username']))); if (is_array($check_member_name) and count($check_member_name) > 0) { return array('error' => '用户名已存在'); } // 验证邮箱是否重复 $check_member_email = $this->infoMember(array('member_email' => trim($register_info['email']))); if (is_array($check_member_email) and count($check_member_email) > 0) { return array('error' => '邮箱已存在'); } // 会员添加 $member_info = array(); $member_info['member_name'] = $register_info['username']; $member_info['member_passwd'] = $register_info['password']; $member_info['member_email'] = $register_info['email']; $insert_id = $this->addMember($member_info); if ($insert_id) { //添加会员积分 if ($GLOBALS['setting_config']['points_isuse'] == 1) { $points_model = Model('points'); $points_model->savePointsLog('regist', array('pl_memberid' => $insert_id, 'pl_membername' => $register_info['username']), false); } // 添加默认相册 $insert['ac_name'] = '买家秀'; $insert['member_id'] = $insert_id; $insert['ac_des'] = '买家秀默认相册'; $insert['ac_sort'] = 1; $insert['is_default'] = 1; $insert['upload_time'] = TIMESTAMP; Model()->table('sns_albumclass')->insert($insert); $member_info['member_id'] = $insert_id; $member_info['is_buy'] = 1; return $member_info; } else { return array('error' => '注册失败'); } }
public function edit_classOp() { if (chksubmit()) { //数据验证 $obj_validate = new Validate(); $validate_array = array(array('input' => $_POST['live_class_name'], 'require' => 'true', "validator" => "Length", "min" => "1", "max" => "10", 'message' => Language::get('live_groupbuy_class_name_is_not_null')), array('input' => $_POST['live_class_sort'], 'require' => 'true', 'validator' => 'Range', 'min' => 0, 'max' => 255, 'message' => Language::get('live_groupbuy_class_sort_is_not_null'))); $obj_validate->validateparam = $validate_array; $error = $obj_validate->validate(); if ($error != '') { showMessage(Language::get('error') . $error, '', '', 'error'); } $params = array(); $params['live_class_name'] = trim($_POST['live_class_name']); $params['live_class_sort'] = intval($_POST['live_class_sort']); if (isset($_POST['parent_class_id']) && intval($_POST['parent_class_id']) > 0) { $params['parent_class_id'] = $_POST['parent_class_id']; } else { $params['parent_class_id'] = 0; } $condition = array(); //条件 $condition['live_class_id'] = intval($_POST['live_class_id']); $model_live_class = Model('live_class'); $res = $model_live_class->editLive_class($condition, $params); if ($res) { H('live_class', null); //清除缓存 delCacheFile('live_class'); $this->log('编辑抢购分类[ID:' . intval($_POST['live_class_id']) . ']', 1); showMessage('编辑成功', 'index.php?act=live_class', '', 'succ'); } else { showMessage('编辑失败', 'index.php?act=live_class', '', 'error'); } } $model_live_class = Model('live_class'); //分类信息 $live_class = $model_live_class->live_classInfo(array('live_class_id' => intval($_GET['live_class_id']))); if (empty($live_class)) { showMessage('该分类不存在', '', '', 'error'); } Tpl::output('live_class', $live_class); $list = $model_live_class->getList(array('parent_class_id' => 0)); Tpl::output('list', $list); Tpl::showpage('live.groupbuyclass.edit'); }
public function unbindOp() { //修改密码 $model_member = Model('member'); $update_arr = array(); if ($_POST['is_editpw'] == 'yes') { /** * 填写密码信息验证 */ $obj_validate = new Validate(); $obj_validate->validateparam = array(array("input" => $_POST["new_password"], "require" => "true", "validator" => "Length", "min" => 6, "max" => 20, "message" => Language::get('member_sconnect_password_null')), array("input" => $_POST["confirm_password"], "require" => "true", "validator" => "Compare", "operator" => "==", "to" => $_POST["new_password"], "message" => Language::get('member_sconnect_input_two_password_again'))); $error = $obj_validate->validate(); if ($error != '') { showMessage($error, '', 'html', 'error'); } $update_arr['member_passwd'] = md5(trim($_POST['new_password'])); } $update_arr['member_sinaopenid'] = ''; $update_arr['member_sinainfo'] = ''; $edit_state = $model_member->updateMember($update_arr, $_SESSION['member_id']); if ($edit_state) { if ($GLOBALS['setting_config']['ucenter_status'] == '1' && $_POST['is_editpw'] == 'yes') { /** * Ucenter处理 */ $model_ucenter = Model('ucenter'); $model_ucenter->userEdit(array('login_name' => $_SESSION['member_name'], 'old_password' => trim($_POST['orig_password']), 'password' => trim($_POST['new_password']))); } } else { showMessage(Language::get('member_sconnect_password_modify_fail'), '', 'html', 'error'); } session_unset(); session_destroy(); /** * 同步登录通知 */ if ($GLOBALS['setting_config']['ucenter_status'] == '1') { /** * Ucenter处理 */ $model_ucenter = Model('ucenter'); $out_str = $model_ucenter->userLogout(); } showMessage(Language::get('member_sconnect_unbind_success'), 'index.php?act=login&ref_url=' . urlencode('index.php?act=member_sconnect&op=sinabind')); }
public function updateAddressOp() { $address_model = Model('address'); // 验证提交数据 $obj_validate = new Validate(); $obj_validate->validateparam = array(array("input" => $_POST["true_name"], "require" => "true", "message" => "真实姓名必填"), array("input" => $_POST["area_id"], "require" => "true", "validator" => "Number", "message" => "地址信息错误"), array("input" => $_POST["city_id"], "require" => "true", "validator" => "Number", "message" => "地址信息错误"), array("input" => $_POST["area_info"], "require" => "true", "message" => "地址信息错误"), array("input" => $_POST["address"], "require" => "true", "message" => "地址信息错误"), array("input" => $_POST['mob_phone'], 'require' => 'true', "validator" => "mobile", 'message' => "手机号码有误")); $error = $obj_validate->validate(); if ($error != '') { $error = strtoupper(CHARSET) == 'GBK' ? Language::getUTF8($error) : $error; output_error($error); } $data = array(); $data['member_id'] = $this->member_info['member_id']; $data['true_name'] = $_POST['true_name']; $data['area_id'] = intval($_POST['area_id']); $data['city_id'] = intval($_POST['city_id']); $data['area_info'] = $_POST['area_info']; $data['address'] = $_POST['address']; $data['mob_phone'] = $_POST['mob_phone']; $data['is_default'] = $_POST['is_default'] ? 1 : 0; // 判断用户地址数量,如果为0,设置当前添加地址为默认地址 $address_num = $address_model->getAddressCount(array('member_id' => $this->member_info['member_id'], 'is_default' => 1)); if ($address_num == 0) { $data['is_default'] = 1; } if ($data['is_default'] == 1) { $address_model->editAddress(array('is_default' => 0), array('member_id' => $this->member_info['member_id'], 'is_default' => 1)); } if (intval($_POST['id']) > 0) { $rs = $address_model->editAddress($data, array('address_id' => intval($_POST['id']), 'member_id' => $this->member_info['member_id'])); if (!$rs) { output_error("地址信息修改失败"); } } else { $count = $address_model->getAddressCount(array('member_id' => $this->member_info['member_id'])); if ($count >= 20) { output_error("最多允许添加20个有效地址"); } $rs = $address_model->addAddress($data); if (!$rs) { output_error("地址添加失败"); } } output_data("设置成功"); }
public static function dispatch($class) { if (!class_exists($class)) { include_once 'controllers/' . str_replace('_', '/', $class) . '.php'; } $instance = new $class(); $params = array_slice(func_get_args(), 1); $return = true; if (method_exists($instance, 'init')) { $return = call_user_func_array(array($instance, 'init'), $params); } if (!(true === $return)) { if (is_string($return) || $return instanceof Url) { Url::redirect($return); } return false; } $errors = array(); if (Request::isPost()) { $validation = new Validate(); if ($rules = $instance->validation()) { $validation->add($rules); $validation->validate(); } if ($validation->valid()) { $return = $instance->post(); if (!(false === $return)) { if (is_string($return) || $return instanceof Url) { Url::redirect($return); } return true; } } $errors = $validation->errors(); } $return = $instance->get(); if (!(false === $return)) { $return['errors'] = $errors; $view = new View($class, $return); $viewContent = $view->dispatch(); return $viewContent; } return false; }
/** * 店铺打印设置 */ public function indexOp(){ $model = Model(); $store_info = $model->table('store')->where(array('store_id'=>$_SESSION['store_id']))->find(); if(empty($store_info)){ showDialog(Language::get('store_storeinfo_error'),'index.php?act=store_printsetup','error'); } if(chksubmit()){ $obj_validate = new Validate(); $obj_validate->validateparam = array( array("input"=>$_POST['store_printdesc'], "require"=>"true","validator"=>"Length","min"=>1,"max"=>200,"message"=>Language::get('store_printsetup_desc_error')) ); $error = $obj_validate->validate(); if ($error != ''){ showDialog($error); } $update_arr = array(); //上传认证文件 if($_FILES['store_stamp']['name'] != '') { $upload = new UploadFile(); $upload->set('default_dir',ATTACH_STORE); if($_FILES['store_stamp']['name'] != '') { $result = $upload->upfile('store_stamp'); if ($result){ $update_arr['store_stamp'] = $upload->file_name; //删除旧认证图片 if (!empty($store_info['store_stamp'])){ @unlink(BASE_UPLOAD_PATH.DS.ATTACH_STORE.DS.$store_info['store_stamp']); } } } } $update_arr['store_printdesc'] = $_POST['store_printdesc']; $rs = $model->table('store')->where(array('store_id'=>$_SESSION['store_id']))->update($update_arr); if ($rs){ showDialog(Language::get('nc_common_save_succ'),'index.php?act=store_printsetup','succ'); }else { showDialog(Language::get('nc_common_save_fail'),'index.php?act=store_printsetup','error'); } }else{ Tpl::output('store_info',$store_info); self::profile_menu('store_printsetup'); Tpl::showpage('store_printsetup'); } }
/** * 不进行父类的登录验证,所以增加构造方法重写了父类的构造方法 */ public function __construct() { Language::read('common,layout,login'); $result = chksubmit(true, true, 'num'); if ($result) { if ($result === -11) { showMessage('非法请求'); } // if ($result === -12){ // showMessage(L('login_index_checkcode_wrong')); // } //var_dump($_POST['captcha']); if (process::islock('admin')) { showMessage('您的操作过于频繁,请稍后再试'); } $obj_validate = new Validate(); $obj_validate->validateparam = array(array("input" => $_POST["user_name"], "require" => "true", "message" => L('login_index_username_null')), array("input" => $_POST["password"], "require" => "true", "message" => L('login_index_password_null')), array("input" => $_POST["captcha"], "require" => "true", "message" => L('login_index_checkcode_null'))); $error = $obj_validate->validate(); if ($error != '') { showMessage(L('error') . $error); } else { $model_admin = Model('admin'); $array = array(); $array['admin_name'] = $_POST['user_name']; $array['admin_password'] = md5(trim($_POST['password'])); $admin_info = $model_admin->infoAdmin($array); if (is_array($admin_info) and !empty($admin_info)) { $this->systemSetKey(array('name' => $admin_info['admin_name'], 'id' => $admin_info['admin_id'], 'gid' => $admin_info['admin_gid'], 'sp' => $admin_info['admin_is_super'])); $update_info = array('admin_id' => $admin_info['admin_id'], 'admin_login_num' => $admin_info['admin_login_num'] + 1, 'admin_login_time' => TIMESTAMP); $model_admin->updateAdmin($update_info); $this->log(L('nc_login'), 1); process::clear('admin'); @header('Location: index.php'); exit; } else { process::addprocess('admin'); showMessage(L('login_index_username_password_wrong'), 'index.php?act=login&op=login'); } } } Tpl::output('html_title', L('login_index_need_login')); Tpl::showpage('login', 'login_layout'); }
/** * 新增/编辑发货地址 */ public function daddress_addOp() { Language::read('member_member_index'); $lang = Language::getLangContent(); $model_daddress = Model('daddress'); if (chksubmit()) { //保存 新增/编辑 表单 $obj_validate = new Validate(); $obj_validate->validateparam = array(array("input" => $_POST["seller_name"], "require" => "true", "message" => $lang['store_daddress_receiver_null']), array("input" => $_POST["area_id"], "require" => "true", "validator" => "Number", "message" => $lang['store_daddress_wrong_area']), array("input" => $_POST["city_id"], "require" => "true", "validator" => "Number", "message" => $lang['store_daddress_wrong_area']), array("input" => $_POST["area_info"], "require" => "true", "message" => $lang['store_daddress_area_null']), array("input" => $_POST["address"], "require" => "true", "message" => $lang['store_daddress_address_null']), array("input" => $_POST['telphone'], 'require' => 'true', 'message' => $lang['store_daddress_phone_and_mobile'])); $error = $obj_validate->validate(); if ($error != '') { showValidateError($error); } $data = array('store_id' => $_SESSION['store_id'], 'seller_name' => $_POST['seller_name'], 'area_id' => $_POST['area_id'], 'city_id' => $_POST['city_id'], 'area_info' => $_POST['area_info'], 'address' => $_POST['address'], 'telphone' => $_POST['telphone'], 'company' => $_POST['company']); $address_id = intval($_POST['address_id']); if ($address_id > 0) { $condition = array(); $condition['address_id'] = $address_id; $condition['store_id'] = $_SESSION['store_id']; $update = $model_daddress->editAddress($data, $condition); if (!$update) { showDialog($lang['store_daddress_modify_fail'], '', 'error'); } } else { $insert = $model_daddress->addAddress($data); if (!$insert) { showDialog($lang['store_daddress_add_fail'], '', 'error'); } } showDialog($lang['nc_common_op_succ'], 'reload', 'succ', 'CUR_DIALOG.close()'); } elseif (is_numeric($_GET['address_id']) > 0) { //编辑 $condition = array(); $condition['address_id'] = intval($_GET['address_id']); $condition['store_id'] = $_SESSION['store_id']; $address_info = $model_daddress->getAddressInfo($condition); if (empty($address_info) && !is_array($address_info)) { showMessage($lang['store_daddress_wrong_argument'], 'index.php?act=store_deliver_set&op=daddress_list', 'html', 'error'); } Tpl::output('address_info', $address_info); } Tpl::showpage('store_deliver_set.daddress_add', 'null_layout'); }
public function sloginOp() { if (isset($_POST) && !empty($_POST)) { $obj_validate = new Validate(); $obj_validate->validateparam = array(array("input" => $_POST["account"], "require" => "true", "message" => $lang['nc_store_login_account_is_not_null']), array("input" => $_POST["password"], "require" => "true", "message" => $lang['nc_store_login_password_is_not_null'])); $error = $obj_validate->validate(); if ($error != '') { $this->showTip(Language::get('error') . $error, '', 'html', 'error'); } $params = array(); $params['account'] = trim($_POST['account']); $params['password'] = md5($_POST['password']); $model = Model(); $store = $model->table('store')->where($params)->find(); if (!empty($store)) { //待审核 //if($store['is_audit'] == 1){ // $this->showTip(L('nc_store_login_store_audit_wait'),'','html','error'); // exit; //} //审核未通过 if ($store['is_audit'] == 3) { $this->showTip(L('nc_store_login_store_audit_no'), '', 'html', 'error'); exit; } if ($store['store_state'] == 3) { $this->showTip(L('nc_store_login_store_is_close'), '', 'html', 'error'); } $_SESSION['store_id'] = $store['store_id']; $_SESSION['account'] = $store['account']; $_SESSION['store_avatar'] = $store['avatar']; $_SESSION['seller_login'] = 1; header("Location:index.php?act=storesetting&op=dashboard"); exit; //$this->showTip(L('nc_store_login_login_succ'),'index.php?act=storesetting','succ'); } else { $this->showTip(L('nc_store_login_login_fail'), '', 'html', 'error', '', '2000'); } } Tpl::showpage('slogin', 'null_layout'); }
/** * 基本设置 */ public function settingOp() { $model_setting = Model('setting'); if (chksubmit()) { $obj_validate = new Validate(); $obj_validate->validateparam = array(); $error = $obj_validate->validate(); if ($error != '') { showMessage($error); } else { $update_array = array(); $update_array['flea_isuse'] = $_POST['flea_isuse']; $update_array['promotion_allow'] = $_POST['promotion_allow']; $update_array['groupbuy_allow'] = $_POST['groupbuy_allow']; $update_array['points_isuse'] = $_POST['points_isuse']; $update_array['pointshop_isuse'] = $_POST['pointshop_isuse']; $update_array['voucher_allow'] = $_POST['voucher_allow']; $update_array['pointprod_isuse'] = $_POST['pointprod_isuse']; $update_array['points_reg'] = intval($_POST['points_reg']) ? $_POST['points_reg'] : 0; $update_array['points_login'] = intval($_POST['points_login']) ? $_POST['points_login'] : 0; $update_array['points_comments'] = intval($_POST['points_comments']) ? $_POST['points_comments'] : 0; $update_array['points_orderrate'] = intval($_POST['points_orderrate']) ? $_POST['points_orderrate'] : 0; $update_array['points_ordermax'] = intval($_POST['points_ordermax']) ? $_POST['points_ordermax'] : 0; $update_array['points_invite'] = intval($_POST['points_invite']) ? $_POST['points_invite'] : 0; $update_array['points_rebate'] = intval($_POST['points_rebate']) ? $_POST['points_rebate'] : 0; $result = $model_setting->updateSetting($update_array); if ($result === true) { $this->log(L('nc_edit,nc_operation,nc_operation_set'), 1); showMessage(L('nc_common_save_succ')); } else { showMessage(L('nc_common_save_fail')); } } } $list_setting = $model_setting->getListSetting(); Tpl::output('list_setting', $list_setting); Tpl::output('top_link', $this->sublink($this->links, 'setting')); Tpl::showpage('operation.setting'); }
/** * 绑定身份证号码 * @return [type] [description] */ public function bind_idcardOp() { $model_member = Model('member'); $obj_validate = new Validate(); $obj_validate->validateparam = array(array("input" => $_POST["truename"], "require" => "true", "message" => '真实姓名不能为空'), array("input" => $_POST["idcard"], "require" => "true", "message" => '身份证号不能为空')); $error = $obj_validate->validate(); if ($error != '') { output_error($error); } if (!$this->checkIdCard($_POST['idcard'])) { output_error("身份证号码不正确"); } $data = array(); $data['member_truename'] = $_POST['truename']; $data['member_idnum'] = strtoupper($_POST['idcardencryptShowencryptShow']); $update = $model_member->editMember(array('member_id' => $this->member_info['member_id']), $data); if ($update) { output_data("认证成功"); } else { output_error("系统错误,认证失败"); } }
/** * sina微博设置 */ public function sinaOp() { $model_setting = Model('setting'); if (chksubmit()) { $obj_validate = new Validate(); if (trim($_POST['sina_isuse']) == '1') { $obj_validate->validateparam = array(array("input" => $_POST["sina_wb_akey"], "require" => "true", "message" => Language::get('sina_wb_akey_error')), array("input" => $_POST["sina_wb_skey"], "require" => "true", "message" => Language::get('sina_wb_skey_error'))); } $error = $obj_validate->validate(); if ($error != '') { showMessage($error); } else { $update_array = array(); $update_array['sina_isuse'] = $_POST['sina_isuse']; $update_array['sina_wb_akey'] = $_POST['sina_wb_akey']; $update_array['sina_wb_skey'] = $_POST['sina_wb_skey']; $update_array['sina_appcode'] = $_POST['sina_appcode']; $result = $model_setting->updateSetting($update_array); if ($result === true) { $this->log(L('nc_edit,sinaSettings'), 1); showMessage(Language::get('nc_common_save_succ')); } else { $this->log(L('nc_edit,sinaSettings'), 0); showMessage(Language::get('nc_common_save_fail')); } } } $is_exist = function_exists('curl_init'); if ($is_exist) { $list_setting = $model_setting->getListSetting(); Tpl::output('list_setting', $list_setting); } Tpl::output('is_exist', $is_exist); //输出子菜单 Tpl::output('top_link', $this->sublink($this->links, 'sina')); Tpl::showpage('setting.sina_setting'); }