protected function _checkData($param = array()) { $aRow = empty($param) ? $this->_getParams() : $param; if (!Util_Validate::isLength($aRow['sName'], 2, 20)) { return $this->showMsg('名称长度范围为2到20个字!', false); } return $aRow; }
/** * 请求数据检测 * * @return mixed */ public function _checkData($sType = 'add') { $iType = $this->getParam('iType'); $sEmail = $this->getParam('sEmail'); $sMobile = $this->getParam('sMobile'); $sRealName = $this->getParam('sRealName'); $sPassword = $this->getParam('sPassword'); $sCoName = $this->getParam('sCoName'); $iCoIndustry = $this->getParam('iCoIndustry'); $sCoAddress = $this->getParam('sCoAddress'); $sCoWebSite = $this->getParam('sCoWebSite'); $sCoDesc = $this->getParam('sCoDesc'); $sWeixin = $this->getParam('sWeixin'); $sQQ = $this->getParam('sQQ'); $iIncome = $this->getParam('iIncome'); $iMoney = $this->getParam('iMoney'); $iStatus = $this->getParam('iStatus'); $iRate = $this->getParam('iRate'); $iUpdateTime = time(); if (!Util_Validate::isEmail($sEmail)) { return $this->showMsg('输入的邮箱地址不合法!', false); } if (($sType == 'add' || !empty($sPassword)) && !Util_Validate::isLength($sPassword, 6, 20)) { return $this->showMsg('登录密码长度范围为6到20字符!', false); } if (!Util_Validate::isMobile($sMobile)) { return $this->showMsg('输入的手机号码不合法!', false); } if (!Util_Validate::isLength($sRealName, 2, 20)) { return $this->showMsg('真实姓名长度范围为2到20字符!', false); } $aDomain = Model_Domain::getPairDomain(Model_Domain::TYPE_CO_INDUSTRY); if (!isset($aDomain[$iCoIndustry])) { return $this->showMsg('选择的行业不存在!', false); } $aRow = array('iType' => $iType, 'sEmail' => $sEmail, 'sMobile' => $sMobile, 'sRealName' => $sRealName, 'sCoName' => $sCoName, 'iCoIndustry' => $iCoIndustry, 'sCoAddress' => $sCoAddress, 'sCoWebSite' => $sCoWebSite, 'sCoDesc' => $sCoDesc, 'sWeixin' => $sWeixin, 'sQQ' => $sQQ, 'iIncome' => $iIncome, 'iMoney' => $iMoney, 'iStatus' => $iStatus, 'iUpdateTime' => $iUpdateTime, 'iRate' => $iRate); if (!empty($sPassword)) { $aRow['sPassword'] = md5(Yaf_G::getConf('cryptkey', 'cookie') . $sPassword); } return $aRow; }
/** * 请求数据检测 * * @return mixed */ public function _checkData($sType = 'add') { $sPermissionName = $this->getParam('sPermissionName'); $sPath = $this->getParam('sPath'); $iMenuID = $this->getParam('iMenuID'); if (!Util_Validate::isLength($sPermissionName, 2, 30)) { return $this->showMsg('权限名长度范围为2到30个字!', false); } if (!Util_Validate::isLength($sPath, 2, 50)) { return $this->showMsg('权限点长度范围为2到30个字符!', false); } if (empty($iMenuID)) { return $this->showMsg('请选择权限点的归属模块!', false); } $iCnt = Model_Menu::getCnt(array('where' => array('iParentID' => $iMenuID))); if ($iCnt > 0) { return $this->showMsg('归属模块只能选择最底层的模块!', false); } $aRow = array('sPermissionName' => $sPermissionName, 'sPath' => $sPath, 'iMenuID' => $iMenuID); return $aRow; }
/** * 设置广告 */ public function add3Action() { if ($this->isPost()) { $iAdID = (int) $this->getParam('iAdID', 0); $aAd = Model_Ad::getDetail($iAdID); if (empty($aAd) || $aAd['iUserID'] != $this->aCurrUser['iUserID']) { return $this->show404(); } $aErr = array(); $aData = array(); $aData['iAdID'] = $iAdID; $aData['iAdPos'] = (int) $this->getParam('iAdPos'); $aData['iPlanTime'] = strtotime($this->getParam('iPlanTime')); if ($aData['iPlanTime'] < strtotime('+2hour')) { $aErr['iPlanTime'] = '投放时间必须晚于当前时间2小时'; } if ($aData['iPlanTime'] > strtotime('+7day')) { $aErr['iPlanTime'] = '投放时间必须小于7天'; } switch ($aAd['iMediaType']) { case Model_Media::TYPE_WEIXIN: $aData['sImportUrl'] = $this->getParam('sImportUrl', ''); $aData['sWordFile'] = $this->getParam('sWordFile', ''); $aData['sTitle'] = $this->getParam('sTitle'); $aData['sCoverImg'] = $this->getParam('sCoverImg'); $aData['iIsCover'] = (int) $this->getParam('iIsCover'); $aData['sAbstract'] = $this->getParam('sAbstract'); $aData['sContent'] = $this->getParam('sContent'); $aData['sOriginalUrl'] = $this->getParam('sOriginalUrl'); if (!Util_Validate::isCLength($aData['sTitle'], 2, 50)) { $aErr['sTitle'] = '请输入标题'; } if ($aData['iIsCover'] && empty($aData['sCoverImg'])) { $aErr['sCoverImg'] = '请上传封面图'; } // if (empty($aData['sAbstract'])) { // $aErr['sAbstract'] = '请输入摘要'; // } if (!Util_Validate::isCLength($aData['sContent'], 20, 999999)) { $aErr['sContent'] = '请输入内容至少20个字'; } break; case Model_Media::TYPE_FRIEND: case Model_Media::TYPE_WEIBO: $aData['sForwardUrl'] = $this->getParam('sForwardUrl', ''); $aData['sForwardText'] = $this->getParam('sForwardText', ''); $aForwardImg = $this->getParam('aForwardImg'); if ($aData['iAdPos'] == 1) { if (!Util_Validate::isAbsoluteUrl($aData['sForwardUrl'])) { $aErr['sForwardUrl'] = '请输入正确的投放地址'; } } else { if (!empty($aData['sForwardUrl']) && !Util_Validate::isAbsoluteUrl($aData['sForwardUrl'])) { $aErr['sForwardUrl'] = '请输入正确的投放地址'; } } if (!Util_Validate::isCLength($aData['sForwardText'], 5, 200)) { $aErr['sForwardText'] = '投放文字长度为5~200字之间'; } $aData['sForwardImg'] = array(); foreach ($aForwardImg as $sForwardImg) { if (!empty($sForwardImg)) { $aData['sForwardImg'][] = $sForwardImg; } } if (empty($aData['sForwardImg'])) { $aErr['sForwardImg'] = '请至少选择一张投放配图'; $aForwardImg = array(); } $aData['sForwardImg'] = join(',', $aData['sForwardImg']); break; } if (!empty($aErr)) { return $this->showMsg($aErr, false); } Model_Ad::setSetting($aAd, $aData); return $this->showMsg($aAd['iAdID'], true); } else { $iAdID = (int) $this->getParam('id', 0); $aAd = Model_Ad::getDetail($iAdID); if (empty($aAd) || $aAd['iUserID'] != $this->aCurrUser['iUserID']) { return $this->show404(); } $sCookieKey = 'media_choose_' . $aAd['iMediaType']; $aChooseID = isset($_COOKIE[$sCookieKey]) ? explode(',', $_COOKIE[$sCookieKey]) : array(); if (!empty($aChooseID)) { Model_Ad::updMedia($iAdID, $aChooseID, $this->aCurrUser['iUserID']); } setcookie($sCookieKey, null, 0, '/'); $aSetting = Model_Ad::getSetting($aAd); if (!empty($aSetting) && isset($aSetting['sForwardImg'])) { $aSetting['aForwardImg'] = explode(',', $aSetting['sForwardImg']); } $this->assign('aTitle', Model_Media::$aPos[$aAd['iMediaType']]); $this->assign('aSetting', $aSetting); $this->assign('aAd', $aAd); $this->assign('sTopMenu', 'aadd'); $this->setMeta('ad_add', array('sTitle' => '添加推广计划 - 推广计划')); } }
/** * 请求数据检测 * @param $sType 操作类型 add:添加,edit:修改: * @param $iOptype 操作类型 0:保存,1:发布 * @return mixed * */ public function _checkData($sType = 'add', $param = array()) { $aRow = empty($param) ? $this->_getParams() : $param; //保存和发布都需要做的判断 if (!Util_Validate::isCLength($aRow['sTitle'], 5, 22)) { return $this->showMsg('资讯标题长度范围为5到22个字!', false); } if (!empty($param) || $aRow['iOptype'] > 0) { if (!Util_Validate::isCLength($aRow['sShortTitle'], 5, 15)) { return $this->showMsg('短标题长度范围为5到15个字!', false); } if (!Util_Validate::isCLength($aRow['sAuthor'], 2, 20)) { return $this->showMsg('资讯作者长度范围为2到20个字!', false); } if (!Util_Validate::isCLength($aRow['sMedia'], 1, 20)) { return $this->showMsg('媒体来源长度范围为1到20个字!', false); } if (!Util_Validate::isCLength($aRow['sKeyword'], 2, 50)) { return $this->showMsg('关键字长度范围为2到20个字!', false); } if (empty($aRow['sImage'])) { return $this->showMsg('请选择一张默认图片!', false); } if (!Util_Validate::isCLength($aRow['sAbstract'], 60, 90)) { return $this->showMsg('资讯摘要长度范围为60到90个字!', false); } if (!Util_Validate::isCLength($aRow['sContent'], 100, 16777215)) { return $this->showMsg('资讯内容长度范围为100到65535个字!', false); } if ($aRow['iCategoryID'] < 0) { return $this->showMsg('请选择一个资讯分类!', false); } if ($aRow['iPublishTime'] == 0) { $iPublishTime = time(); } if (!Model_Author::getAuthorByName($aRow['sAuthor'])) { return $this->showMsg('作者不存在', false); } /** if (Model_News::EVALUATION_NEWS == $this->_getTypeID()) { if (empty($aRow['sLoupanID'])) { return $this->showMsg('请添加推送楼盘', false); } }*/ if ($aRow['sLoupanID']) { $aLoupanID = explode(',', $aRow['sLoupanID']); foreach ($aLoupanID as $key => $value) { if (!Model_CricUnit::getLoupanByID($value)) { unset($aLoupanID[$key]); $iLouChange = 1; //楼盘ID过滤标记 //return $this->showMsg('推送楼盘不存在', false); } } if (isset($iLouChange)) { $aRow['sLoupanID'] = implode(',', $aLoupanID); } } if ($aRow['sTag']) { $sTag = explode(',', $aRow['sTag']); foreach ($sTag as $key => $value) { $aTag = Model_Tag::getDetail($value); if (empty($aTag) || $aTag['iStatus'] != 1 || $aTag['iTypeID'] != $this->_getTypeTag()) { return $this->showMsg('资讯标签不存在,无效标签名称为(' . $value . ')', false); } } } } //去掉非字段的元素 unset($aRow['iOptype']); return $aRow; }
/** * 修改密码 */ public function chgpwdAction() { if ($this->isPost()) { $aParam = $this->getParams(); $aErr = array(); if (empty($aParam['sNewPassword']) || !Util_Validate::isLength($aParam['sNewPassword'], 6, 12)) { $aErr['sNewPassword'] = '******'; } if ($aParam['sNewPassword'] != $aParam['sRePassword']) { $aErr['sRePassword'] = '******'; } $aUser = Model_User::getDetail($this->aCurrUser['iUserID']); if (Model_User::makePassword($aParam['sOldPassword']) != $aUser['sPassword']) { $aErr['sOldPassword'] = '******'; } if (!empty($aErr)) { return $this->showMsg($aErr, false); } $sNewPassword = Model_User::makePassword($aParam['sNewPassword']); Model_User::updData(array('sPassword' => $sNewPassword, 'iUserID' => $aUser['iUserID'])); return $this->showMsg('登录密码修改成功!', true); } else { $this->assign('iTabID', 3); $this->setMeta('mcenter_page', array('sTitle' => '自媒体中心 - 修改登录密码')); } }
/** * 请求数据检测 * @param int $iType * @param array $param * @return array|bool */ public function _checkData($iType, $param = array()) { $aRow = empty($param) ? $this->_getParams($iType) : $param; if (!Util_Validate::isCLength($aRow['sName'], 2, 20)) { return $this->showMsg('商品标题长度范围为2到20个字!', false); } if (!Util_Validate::isCLength($aRow['sDesc'], 2, 20)) { return $this->showMsg('商品描述长度范围为2到200个字!', false); } if (!Util_Validate::isFloat($aRow['iCosts'])) { return $this->showMsg('商品成本必须是数字!', false); } if (!Util_Validate::isFloat($aRow['iPrice'])) { return $this->showMsg('商品价格必须是数字!', false); } if (!Util_Validate::isInt($aRow['iCatID'])) { return $this->showMsg('商品类别必须是数字!', false); } if (!Util_Validate::isInt($aRow['iAgentRate'])) { return $this->showMsg('代理商比例必须是数字!', false); } if ($aRow['iUnlockType'] == -1) { return $this->showMsg('请选择商品解锁类型!', false); } if ($aRow['iUnlockType'] == 0 && $aRow['iUnlockLevel'] <= 0) { return $this->showMsg('请选择商品解锁级别!', false); } if ($aRow['iUnlockType'] == 0 && $aRow['iUnlockPoint'] == 0) { return $this->showMsg('请选择商品解锁点!', false); } if ($aRow['sThumbImg'] == '') { return $this->showMsg('商品缩略图不能为空', false); } if ($aRow['iPrice'] < $aRow['iCosts'] * 2) { return $this->showMsg('价格必须为成本的2倍以上', false); } if ($iType == 1) { $aGoods = Model_Goods::getGoodsByName($aRow['sName']); if ($aGoods['sName'] == $aRow['sName']) { return $this->showMsg('商品名称不能重复', false); } } return $aRow; }
/** * 请求数据检测 * * @return mixed */ public function _checkData($sType = 'add') { $sAdminName = $this->getParam('sAdminName'); $sPassword = $this->getParam('sPassword'); $sMobile = $this->getParam('sMobile'); $sEmail = $this->getParam('sEmail'); $sRealName = $this->getParam('sRealName'); $iCityID = $this->getParam('iCityID'); $aCityID = $this->getParam('aCityID'); $sAllCityID = $this->getParam('sAllCityID'); $aRoleID = $this->getParam('aRoleID'); $sAdminID = $this->getParam('sAdminID'); if (!Util_Validate::isLength($sAdminName, 3, 50)) { return $this->showMsg('用户名长度范围为3到30个字!', false); } if (($sType == 'add' || !empty($sPassword)) && !Util_Validate::isLength($sPassword, 6, 20)) { return $this->showMsg('登录密码长度范围为6到20字符!', false); } if (!Util_Validate::isMobile($sMobile)) { return $this->showMsg('输入的手机号码不合法!', false); } if (!Util_Validate::isEmail($sEmail)) { return $this->showMsg('输入的邮箱地址不合法!', false); } if (!Util_Validate::isLength($sRealName, 2, 20)) { return $this->showMsg('真实姓名长度范围为2到20字符!', false); } $aCity = Model_City::getPairCitys(); if (!isset($aCity[$iCityID])) { return $this->showMsg('选择的城市不存在!', false); } // 将默认城市加入到城市权限中 if ($sAllCityID == '1') { $aCityID = array(-1); } elseif (empty($aCityID) || !in_array($iCityID, $aCityID)) { $aCityID[] = $iCityID; } // 将默认城市加入到城市权限中 if ($sAdminID == '1') { $aRoleID = array(-1); } elseif (empty($aRoleID)) { return $this->showMsg('请至少选择一个角色!', false); } $aRow = array('sAdminName' => $sAdminName, 'sMobile' => $sMobile, 'sEmail' => $sEmail, 'sRealName' => $sRealName, 'iCityID' => $iCityID, 'sCityID' => join(',', $aCityID), 'sRoleID' => join(',', $aRoleID)); if (!empty($sPassword)) { $aRow['sPassword'] = md5(Yaf_G::getConf('cryptkey', 'cookie') . $sPassword); } return $aRow; }
/** * 请求数据检测 * * @return mixed */ public function _checkData($sType = 'add') { $sCityName = $this->getParam('sCityName'); $sCityCode = $this->getParam('sCityCode'); $iFrontShow = $this->getParam('iFrontShow'); $iBackendShow = $this->getParam('iBackendShow'); if (!Util_Validate::isLength($sCityName, 2, 20)) { return $this->showMsg('城市名称长度范围为2到20个字!', false); } if (!Util_Validate::isLength($sCityCode, 2, 50)) { return $this->showMsg('城市代码长度范围为2到50个字母!', false); } if (!Util_Validate::isRange($iFrontShow, 0, 1)) { return $this->showMsg('城市前台是否启用输入不合法!', false); } if (!Util_Validate::isRange($iBackendShow, 0, 1)) { return $this->showMsg('城市后台是否启用输入不合法!', false); } $aRow = array('sCityName' => $sCityName, 'sCityCode' => $sCityCode, 'iFrontShow' => $iFrontShow, 'iBackendShow' => $iBackendShow); return $aRow; }
/** * 填写报价 */ public function add2Action() { if ($this->isPost()) { $aUser = $this->getCurrUser(Model_User::TYPE_MEDIA); if (empty($aUser)) { return $this->showMsg('请先登录!', false); } $iMediaID = (int) $this->getParam('iMediaID'); $aMedia = Model_Media::getDetail($iMediaID); if (empty($aMedia)) { return $this->showMsg('数据导常', false); } if ($aMedia['iUserID'] != $aUser['iUserID']) { return $this->showMsg('不要乱改别人的数据', false); } $aData = array('iMediaID' => $iMediaID, 'iPrice1' => intval($this->getParam('iPrice1', 0)), 'iPrice2' => intval($this->getParam('iPrice2', 0)), 'iPrice3' => intval($this->getParam('iPrice3', 0)), 'iPrice4' => intval($this->getParam('iPrice4', 0)), 'iPrice5' => intval($this->getParam('iPrice1', 0)), 'iPrice6' => intval($this->getParam('iPrice2', 0)), 'iPrice7' => intval($this->getParam('iPrice3', 0)), 'iPrice8' => intval($this->getParam('iPrice4', 0))); $aErr = array(); if (!Util_Validate::isUnsignedInt($aData['iPrice1'])) { $aErr['iPrice1'] = '请输入正确的报价'; } if (!Util_Validate::isUnsignedInt($aData['iPrice2'])) { $aErr['iPrice2'] = '请输入正确的报价'; } if (!Util_Validate::isUnsignedInt($aData['iPrice3'])) { $aErr['iPrice3'] = '请输入正确的报价'; } if (!Util_Validate::isUnsignedInt($aData['iPrice4'])) { $aErr['iPrice4'] = '请输入正确的报价'; } if ($aData['iPrice1'] + $aData['iPrice2'] + $aData['iPrice3'] + $aData['iPrice4'] == 0) { $aErr['iPrice1'] = '请至少输入一个报价'; } if (!empty($aErr)) { return $this->showMsg($aErr, false); } $aData['iStatus'] = 2; Model_Media::updData($aData); return $this->showMsg($iMediaID, true); } else { $aUser = $this->getCurrUser(Model_User::TYPE_MEDIA); if (empty($aUser)) { return $this->redirect('/user/login/type/' . Model_User::TYPE_MEDIA . '?ret=' . Util_Uri::getCurrUrl()); } $iMediaID = (int) $this->getParam('id'); if (empty($iMediaID)) { return $this->show404(); } $aMedia = Model_Media::getDetail($iMediaID); if (empty($aMedia) || $aMedia['iUserID'] != $aUser['iUserID']) { return $this->show404(); } $aTitle = array(Model_Media::TYPE_WEIXIN => array('iPrice1' => '单图文报价', 'iPrice2' => '多图文第一条报价', 'iPrice3' => '多图文第二条报价', 'iPrice4' => '多图文第三条报价'), Model_Media::TYPE_FRIEND => array('iPrice1' => '转发报价', 'iPrice2' => '直发报价'), Model_Media::TYPE_WEIBO => array('iPrice1' => '转发报价', 'iPrice2' => '直发报价')); $this->assign('aTitle', $aTitle); $this->assign('aMedia', $aMedia); $this->assign('sTopMenu', 'madd'); $this->setMeta('media_add', array('sTitle' => '添加媒体 - 填写报价')); } }
/** * 请求数据检测 * @return mixed */ public function _checkData($sType = 'add') { $sRoleName = $this->getParam('sRoleName'); $sDesc = $this->getParam('sDesc'); $aPermission = $this->getParam('aPermission'); $aModule = $this->getParam('aModule'); if (!Util_Validate::isLength($sRoleName, 2, 20)) { return $this->showMsg('角色名长度范围为2到20个字!', false); } if (empty($aPermission)) { return $this->showMsg('至少给这个角色选择一个权限吧!', false); } if (empty($aModule)) { $aModule = array(); } $aRow = array('sRoleName' => $sRoleName, 'sDesc' => $sDesc, 'sPermission' => join(',', $aPermission), 'sModule' => join(',', $aModule)); return $aRow; }
/** * 请求数据检测 * @return mixed */ public function _checkData($sType = 'add') { $sMenuName = $this->getParam('sMenuName'); $sUrl = $this->getParam('sUrl'); $iParentID = $this->getParam('iParentID'); $sIcon = $this->getParam('sIcon'); if (!Util_Validate::isLength($sMenuName, 2, 20)) { return $this->showMsg('菜单名长度范围为2到20个字!', false); } if (!Util_Validate::isUrl($sUrl)) { return $this->showMsg('输入的URL不合法!', false); } $aRow = array('sMenuName' => $sMenuName, 'sUrl' => $sUrl, 'iParentID' => $iParentID, 'sIcon' => $sIcon); return $aRow; }
/** * 忘记密码后的修改密码 * * @return boolean */ public function forgetdAction() { if ($this->isPost()) { $iUserID = (int) $this->getParam('u'); $sCode = $this->getParam('c'); $aCode = Model_VerifyCode::getCode($iUserID, Model_VerifyCode::TYPE_USER_FORGET, $sCode); if (empty($aCode)) { return $this->show404(); } $aParam = $this->getParams(); if (empty($aParam['sPassword']) || empty($aParam['sRePassword']) || !Util_Validate::isLength($aParam['sPassword'], 6, 20)) { return $this->showMsg('登录密码长度为6-20个字符!', false); } if ($aParam['sPassword'] != $aParam['sRePassword']) { return $this->showMsg('登录密码两次输入不一致!', false); } $sNewPassword = Model_User::makePassword($aParam['sPassword']); Model_User::updData(array('sPassword' => $sNewPassword, 'iUserID' => $aCode['iUserID'])); return $this->showMsg('密码修改成功!', true); } else { $iUserID = (int) $this->getParam('u'); $sCode = $this->getParam('c'); $aUser = Model_User::getDetail($iUserID); if (empty($aUser)) { return $this->show404(); } $aCode = Model_VerifyCode::getCode($iUserID, Model_VerifyCode::TYPE_USER_FORGET, $sCode); if (empty($aCode)) { return $this->show404(); } $this->assign('aCode', $aCode); $this->setMeta('common_page', array('sTitle' => '用户忘记密码')); } }