/** * 返回一张验证码的图 */ public function responseCaptchaCodeImg() { importMyLib('CaptchaCode'); $c = new CaptchaCode(); $c->show(); $this->session->set_userdata($this->sessionNamePrefix . 'captchacode', $c->getRandCode()); }
<?php importMyLib('MModelBase'); class SiteUsers extends MModelBase { function __construct() { parent::__construct(); $this->setMainTableName('site_users'); $this->setValidatorRules(array('user' => $this->formateValidatorRuleStr('用户名', false, 1, 10, true), 'pwd' => $this->formateValidatorRuleStr('密码', false, 32, 32, true), 'fullName' => $this->formateValidatorRuleStr('真实姓名', false, 4, 10, true), 'sex' => $this->formateValidatorRuleNum('性别', false, 2, false), 'phone' => $this->formateValidatorRuleStr('电话', false, 5, 16, true), 'mail' => $this->formateValidatorRuleStr('电话', false, 5, 60, true), 'onoff' => $this->formateValidatorRuleNum('是否开启', true))); } /** * getUserInfo方法用到的过滤和验证 * @param unknown $user * @param unknown $pwd */ public function getUserInfo_FV($user, $pwd) { $rechkData = $this->fiterAndValidator(array('user' => $user, 'pwd' => $pwd), $this->getValidatorRules(array('user', 'pwd'))); return $rechkData; } /* * 获得用户信息 */ public function getUserInfo($user, $pwd, $fv = null) { //$this->debugEcho('getUserInfo:'.$user.':'.$pwd); if ($fv == null) { $fv = $this->getUserInfo_FV($user, $pwd); } if ($fv['msg'] != '') {
/** * 页面设置 */ public function pageSetting() { $this->load->helper('url'); $msg = ''; importMyLib('MAdminUIComponent'); $rOneForm = new MAdminUIComponent(); $rOneForm->setFormTitle('页面设置'); $rOneForm->setFormBtnSubmit('', 'user', 'createSiteHtml', '静态生成官网', '生成'); //一些参数的设置 $rOneForm_system = new MAdminUIComponent(site_url('rm/user/editorUploadJson'), site_url('rm/user/editorFileManagerJson')); $siteName = ''; $siteKeyWord = ''; $siteDescription = ''; $rOneForm_system->setFormTxt('siteName', '网站名称', $siteName); $rOneForm_system->setFormTxt('siteKeyWord', '搜索关键字', $siteKeyWord); $rOneForm_system->setFormTxt('siteDescription', '搜索描述', $siteDescription); $rOneForm_system->setFormBtnSubmit('', 'user', 'pageSetting', '保存'); // $arrRender = array($rOneForm->getRenderData(), $rOneForm_system->getRenderData()); $this->responseAjaxSucess(array('render' => $arrRender)); }
<?php importMyLib('MAdminControllerBase'); /** * * @author fei 2015-6-29 * */ class RMBase extends MAdminControllerBase { protected $host; //当前网站的域外 function __construct($isStartSession = true) { parent::__construct($isStartSession); $this->host = $_SERVER['HTTP_HOST']; $temHost = str_replace('.', '', $this->host); $this->sessionNamePrefix = 'makeigameSite_usersite' . $temHost . '_admin_'; } /** * 格式化出符合jqxGrid用到的,编辑,删除,批量操作,操作返回的格式,实际上一个字符串,代表可以在前台自动转的页面: * 主要是调用adminHome里的MainJS.goSubPage * @param string $control * @param string $action * @param string $msg 提示信息 * @param string $parame */ public function _responseAjaxSucessForGrid($control, $action, $msg = '', $parame = null) { $url = $control . ':' . $action; if ($parame != null) {
/** * 默认调用的 * @param int $t 操作类型 */ protected function moduleShowList($t, $otherConfig) { //以下是测试格式 $msg = ''; //$msg='页面设置'; importMyLib('MAdminUIComponent'); $rOneForm = new MAdminUIComponent(site_url($this->AC->getConfig('k_editorUploadJson')), site_url($this->AC->getConfig('k_editorFileManagerJson'))); $rOneForm->setFormTitle('测试页面:基础UI设置'); $rOneForm->setFormTxt('title', '标题', '12312'); $rOneForm->setFormSelect('cate', '分类', array(array('分类1', 1), array('分类2', 2), array('分类3', 3))); $rOneForm->setFormRadio('color', '颜色', array(array('红', 1), array('蓝', 2), array('白', 3))); $rOneForm->setFormCheckbox('color', '多选参数', array(array('参数1', 1), array('参数2', 2), array('参数3', 3), array('参数4', 4), array('参数5', 5), array('参数6', 6), array('参数7', 7)), array(1, 4, 6)); $rOneForm->setFormUpOneImg('img', '缩略图', 'remarks', ''); $rOneForm->setFormEditor('remarks', '备注', ''); $rOneForm->setFormBtnSubmit('addSubmit', 'User', 'add'); // importMyLib('MAdminUIGrid'); $rGrid = new MAdminUIGrid(); $idname = 'myjqxgird'; $jqxgrid_parent_name = 'jqxWidget'; $datafields = $rGrid->getBatSetColumns(array(array('First Name', 'firstname', 1), array('Last Name', 'lastname', 1), array('Product', 'productname', 1), array('Quantity', 'quantity', 2), array('Price', 'price', 2))); $selectOptions = null; $jquGridUrl = '/makeigameSite/index.php/mangement/testModuleCate/0'; //编辑的地址有点特殊,因为它是直接调用js的加载页的方法:MainJS.goSubPage() 如有连接信息需要用冒号隔开 //注:如果需要传入控制方法的参数需要用/连接,例如:mangement:userList/1 $urlEdit = 'mangement:testModuleCate/1'; $urlDel = '/makeigameSite/index.php/mangement/testModuleCate/2'; $urlOpbat = '/makeigameSite/index.php/mangement/testModuleCate/3'; $gridTem = $rGrid->getRenderData($jquGridUrl, $urlEdit, $urlDel, $urlOpbat, $idname, $jqxgrid_parent_name, $datafields, $selectOptions, $this->AC->_getConfigAdminGridPageSize()); //注:最终js读取的是这种格式 $arrRender = array($rOneForm->getRenderData(), $gridTem); $this->AC->responseAjaxSucess(array('render' => $arrRender)); }
<?php defined('BASEPATH') or exit('No direct script access allowed'); importMyLib('Fitervalidator'); class MModelBase extends CI_Model { //Fitervalidator对象用到所有验证规则 private $validator_rules; private $validator; //表名 private $mainTableName = ''; // function __construct() { parent::__construct(); $this->validator = new Fitervalidator(); } /** * 调试,打印到前端 * @param unknown $msg * @param string $isPrintR */ protected function debugEcho($msg, $isPrintR = false) { echo '<hr>'; if (!$isPrintR) { echo $msg; } else { print_r($msg); } echo '<hr>';
<?php /** * 后台有户 * @author Administrator * */ importMyLib('MWebControllerBase'); class MainIndex extends MWebControllerBase { function __construct() { parent::__construct(''); $this->setThemeDirName('mainsite'); } public function index() { //这里通过域名,转换不同的目录和 $this->load_view(array('head', 'index', 'foot')); } /** * 登录 */ public function login() { $post = $this->input->post(); $fromUrl = $post['formUrl']; //$vcode=$this->input->post('vcode'); //if(!$vcode) return $this->responseAjaxEroor('验证码不能为空'); //if($vcode!=$this->_getCaptchaCurrentCode()) return $this->responseAjaxEroor('验证码错误:'.$this->_getCaptchaCurrentCode()); $this->load->model('SiteUsers', 'adminUser', true);
protected function moduleShowList($t, $otherConfig) { $c_id = 0; if (isset($otherConfig['c_id'])) { $c_id = intval($otherConfig['c_id']); } //默认显示列表 //以下是测试格式' ///* $rOneForm = $this->getModuleAddEditPublicPart('分类测试:添加分类'); if ($pid != 0) { $arrResult = $this->getOneSqlData($c_id); $ppid = $arrResult['c_id']; //上一级的c_id的值 //$rOneForm->setFormBtnSubmit('btnRegoParent',$this->currentControlName,$this->currentActionName); } //生成表格 importMyLib('MAdminUIGrid'); $rGrid = new MAdminUIGrid(); $idname = 'myjqxgird'; $jqxgrid_parent_name = 'jqxWidget'; //每条记录对应:$text,$datafield,$type,$columngroup='group2',$width=0,$editable=false $datafields = $rGrid->getBatSetColumns(array(array('标题', 'title', 1), array('排序', 'sortindex', 1, 40), array('上级', 'c_id', 2, 100))); $selectOptions = null; $strPathPrefix = $this->currentControlName . '/' . $this->currentActionName . '/'; $jquGridUrl = site_url($strPathPrefix . '0/' . $pid); //'/makeigameSite/index.php/mangement/testModuleCate/0'; $urlEdit = $this->currentControlName . ':' . $this->currentActionName . '/1'; //'mangement:testModuleCate/1'; //编辑的地址有点特殊,因为它是直接调用js的加载页的方法:MainJS.goSubPage() 如有连接信息需要用冒号隔开 $urlDel = site_url($strPathPrefix . '2'); //'/makeigameSite/index.php/mangement/testModuleCate/2'; $urlOpbat = site_url($strPathPrefix . '3'); //'/makeigameSite/index.php/mangement/testModuleCate/3'; $arrBtnLinks = array($rGrid->getItemColumnBtnLink('下级分类', site_url($strPathPrefix . '5'), 80)); //设置自定义的数组 //$arrBtnLinks[]=$rGrid->getItemColumnBtnLink('测试',$urlOpbat); $gridTem = $rGrid->getRenderData($jquGridUrl, $urlEdit, $urlDel, $urlOpbat, $idname, $jqxgrid_parent_name, $datafields, $arrBtnLinks, $selectOptions, $this->AC->_getConfigAdminGridPageSize()); //注:最终js读取的是这种格式 $arrRender = array($rOneForm->getRenderData(), $gridTem); $this->AC->responseAjaxSucess(array('render' => $arrRender)); }