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 addAction() { if ($this->isPost()) { $iAdID = (int) $this->getParam('id'); $aAd = null; if ($iAdID > 0) { $aAd = Model_Ad::getDetail($iAdID); if ($aAd['iUserID'] != $this->aCurrUser['iUserID']) { return $this->showMsg('不要乱改别人的数据', false); } } $aData = array(); $aData['iUserID'] = $this->aCurrUser['iUserID']; $aData['iMediaType'] = (int) $this->getParam('iMediaType'); $aData['iAdType'] = (int) $this->getParam('iAdType'); $aData['sAdName'] = $this->getParam('sAdName'); $aData['iPlanMinMoney'] = (int) $this->getParam('iPlanMinMoney'); $aData['iPlanMaxMoney'] = (int) $this->getParam('iPlanMaxMoney'); $aData['sCatID'] = (int) $this->getParam('sCatID'); $aAdType = $this->getParam('aAdType'); $aCityID = $this->getParam('aCityID'); $aErr = array(); if (!Util_Validate::isLength($aData['sAdName'], 2, 50)) { $aErr['sAdName'] = '请输入推广名称'; } if ($aData['iPlanMinMoney'] > $aData['iPlanMaxMoney']) { $aErr['iPlanMoney'] = '后者数字必须大于前者数字'; } /* * if (empty($aAdType)) { $aErr['aAdType'] = '请选择广告类型'; } if (empty($aCatID)) { $aErr['aCatID'] = '请选择媒体类别'; } */ /* * if (empty($aCityID)) { $aErr['aCityID'] = '请选择城市/地区'; } */ if (!empty($aCityID) && count($aCityID) > 3) { $aErr['aCityID'] = '最多选择3个城市/地区'; } // 判断该自媒是否已经存在 if (!empty($aData['sAdName'])) { $aOtherAd = Model_Ad::getAdByName($aData['iUserID'], $aData['sAdName'], $iAdID); if (!empty($aOtherAd) && $aOtherAd['iStatus'] != Model_Ad::STATUS_DELETE) { $aErr['sAdName'] = '该推广计划已经存在!'; } } if (!empty($aErr)) { return $this->showMsg($aErr, false); } /* * if (count($aAdType) == 2) { $aData['iAdType'] = 3; } else { $aData['iAdType'] = array_pop($aAdType); } */ $aData['sCityID'] = empty($aCityID) ? '' : join(',', $aCityID); $aData['iStatus'] = Model_Ad::STATUS_WRITING; if (empty($aAd)) { $iAdID = Model_Ad::addData($aData); } else { $aData['iAdID'] = $aAd['iAdID']; Model_Ad::updData($aData); } Model_User::updData(array('iUserID' => $this->aCurrUser['iUserID'], 'iFirst' => 'iFirst + 1')); if ($iAdID > 0) { return $this->showMsg($iAdID, true); } else { $aErr['sAdName'] = '添加失败,请稍后再试'; return $this->showMsg($aErr, false); } } else { $iAdID = intval($this->getParam('id')); $aAd = null; if ($iAdID > 0) { $aAd = Model_Ad::getDetail($iAdID); } if (empty($aAd)) { $iType = intval($this->getParam('type', Model_Media::TYPE_WEIXIN)); } else { $iType = $aAd['iMediaType']; $aAd['aCityID'] = explode(',', $aAd['sCityID']); $aAd['aCatID'] = explode(',', $aAd['sCatID']); } $aData = array(); switch ($iType) { case Model_Media::TYPE_WEIXIN: $aData['aCategory'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_WEIXIN_CATEGORY); // $aData['aTag'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_WEIXIN_TAG); break; case Model_Media::TYPE_FRIEND: $aData['aCategory'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_FRIEND_CATEGORY); // $aData['aTag'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_FRIEND_TAG); break; case Model_Media::TYPE_WEIBO: $aData['aCategory'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_WEIBO_CATEGORY); // $aData['aTag'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_WEIBO_TAG); break; case Model_Media::TYPE_NEWS: $aData['aCategory'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_NEWS_CATEGORY); // $aData['aTag'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_NEWS_TAG); break; } $aData['aAdType'] = array(1 => '软广', 2 => '硬广'); $aData['aCity'] = Model_City::getPairCitys(Model_City::TYPE_FRONT); $aType = Model_Media::$aType; unset($aType[Model_Media::TYPE_NEWS]); $this->assign('iType', $iType); $this->assign('aType', $aType); $this->assign('aData', $aData); $this->assign('aAd', $aAd); $this->assign('aUser', Model_User::getDetail($this->aCurrUser['iUserID'])); $this->assign('sTopMenu', 'aadd'); $this->setMeta('ad_add', array('sTitle' => '添加推广计划')); } }
/** * 请求数据检测 * * @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; }
/** * 修改密码 */ 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' => '自媒体中心 - 修改登录密码')); } }
/** * 请求数据检测 * * @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 addAction() { if ($this->isPost()) { $aUser = $this->getCurrUser(Model_User::TYPE_MEDIA); if (empty($aUser)) { return $this->showMsg('请先登录!', false); } $iMediaID = (int) $this->getParam('iMediaID'); $aMedia = null; if ($iMediaID > 0) { $aMedia = Model_Media::getDetail($iMediaID); if ($aMedia['iUserID'] != $aUser['iUserID']) { return $this->showMsg('不要乱改别人的数据', false); } } $aData = array(); $aData['iUserID'] = $aUser['iUserID']; $aData['iMediaType'] = (int) $this->getParam('iMediaType'); $aData['sMediaName'] = $this->getParam('sMediaName'); $aData['sOpenName'] = $this->getParam('sOpenName'); $aData['iFollowerNum'] = (int) $this->getParam('iFollowerNum'); $aData['sFollowerImg'] = $this->getParam('sFollowerImg'); $aData['sAvatar'] = $this->getParam('sAvatar'); $aData['sQRCode'] = $this->getParam('sQRCode'); $aErr = array(); switch ($aData['iMediaType']) { case Model_Media::TYPE_WEIXIN: if ($aData['iFollowerNum'] == 0) { $aErr['iFollowerNum'] = '请输入丝粉数量'; } if (!Util_Validate::isLength($aData['sMediaName'], 2, 50)) { $aErr['sMediaName'] = '请输入微信名称'; } if (!preg_match('/[a-z][0-9a-z_\\-]{5,19}/i', $aData['sOpenName'])) { $aErr['sOpenName'] = '请输入正确的微信帐号'; } if (empty($aData['sFollowerImg'])) { $aErr['sFollowerImg'] = '请上传粉丝数截图'; } if (empty($aData['sAvatar'])) { $aErr['sAvatar'] = '请上传微信头像'; } if (empty($aData['sQRCode'])) { $aErr['sQRCode'] = '请上传二维码'; } $aOtherMedia = Model_Media::getMediaByOpenName($aData['iMediaType'], $aData['sOpenName'], $iMediaID); if (!empty($aOtherMedia)) { $aErr['sOpenName'] = '该自媒体已经存在!'; } break; case Model_Media::TYPE_FRIEND: if (empty($aData['sMediaName'])) { $aErr['sMediaName'] = '请输入账号名称'; } if ($aData['iFollowerNum'] == 0) { $aErr['iFollowerNum'] = '请输入好友数量'; } if (empty($aData['sFollowerImg'])) { $aErr['sFollowerImg'] = '请上传好友数截图'; } if (empty($aData['sAvatar'])) { $aErr['sAvatar'] = '请上传你微信头像'; } // 判断该自媒是否已经存在 $aOtherMedia = Model_Media::getMediaByName($aData['iMediaType'], $aData['sMediaName'], $iMediaID); if (!empty($aOtherMedia)) { $aErr['sMediaName'] = '该微信帐号已经存在!'; } break; case Model_Media::TYPE_WEIBO: if (empty($aData['sMediaName'])) { $aErr['sMediaName'] = '请输入账号名称'; } if ($aData['iFollowerNum'] == 0) { $aErr['iFollowerNum'] = '请输入好友数量'; } if (empty($aData['sFollowerImg'])) { $aErr['sFollowerImg'] = '请上传好友数截图'; } if (empty($aData['sAvatar'])) { $aErr['sAvatar'] = '请上传你微博头像'; } $aData['sUrl'] = $this->getParam('sUrl'); if (!Util_Validate::isAbsoluteUrl($aData['sUrl'])) { $aErr['sUrl'] = '请输入正确的微博地址'; } // 判断该自媒是否已经存在 $aOtherMedia = Model_Media::getMediaByName($aData['iMediaType'], $aData['sMediaName'], $iMediaID); if (!empty($aOtherMedia)) { $aErr['sMediaName'] = '该微博帐号已经存在!'; } break; } $aCatID = $this->getParam('aCatID'); $aCityID = $this->getParam('aCityID'); $aTagID = $this->getParam('aTagID'); // if (empty($aCatID)) { // $aErr['aCatID'] = '请选择媒体类别'; // } // if (! empty($aCatID) && count($aCatID) > 3) { // $aErr['aCatID'] = '最多选择3个媒体类别'; // } if (empty($aTagID)) { $aErr['aTagID'] = '请选择媒体标签'; } if (!empty($aTagID) && count($aTagID) > 6) { $aErr['aTagID'] = '最多选择6个媒体标签'; } if (empty($aCityID)) { $aErr['aCityID'] = '请选择城市/地区'; } if (!empty($aCityID) && count($aCityID) > 3) { $aErr['aCityID'] = '最多选择3个城市/地区'; } if (!empty($aErr)) { return $this->showMsg($aErr, false); } if (empty($aMedia)) { $aData['iStatus'] = 3; $aData['sVerifyCode'] = strtoupper(Util_Tools::passwdGen(32)); $iMediaID = Model_Media::addData($aData); } else { $aData['iStatus'] = 2; $aData['iMediaID'] = $aMedia['iMediaID']; Model_Media::updData($aData); } Model_User::updData(array('iUserID' => $this->aCurrUser['iUserID'], 'iFirst' => 'iFirst + 1')); if ($iMediaID > 0) { //Model_Media::updCategory($iMediaID, $aCatID); Model_Media::updCity($iMediaID, $aCityID); Model_Media::updTag($iMediaID, $aTagID); return $this->showMsg($iMediaID, true); } else { $aErr['sMediaName'] = '添加失败,请稍后再试'; return $this->showMsg($aErr, false); } } else { $aUser = $this->getCurrUser(Model_User::TYPE_MEDIA); if (empty($aUser)) { return $this->redirect('/user/login/type/' . Model_User::TYPE_MEDIA . '.html?ret=' . Util_Uri::getCurrUrl()); } $iMediaID = intval($this->getParam('id')); $aMedia = null; if ($iMediaID > 0) { $aMedia = Model_Media::getFullDetail($iMediaID); } if (empty($aMedia)) { $iType = intval($this->getParam('type', Model_Media::TYPE_WEIXIN)); } else { $iType = $aMedia['iMediaType']; } $aData = array(); switch ($iType) { case Model_Media::TYPE_WEIXIN: $aData['aCategory'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_WEIXIN_CATEGORY); $aData['aTag'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_WEIXIN_TAG); break; case Model_Media::TYPE_FRIEND: $aData['aCategory'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_FRIEND_CATEGORY); $aData['aTag'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_FRIEND_TAG); break; case Model_Media::TYPE_WEIBO: $aData['aCategory'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_WEIBO_CATEGORY); $aData['aTag'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_WEIBO_TAG); break; case Model_Media::TYPE_NEWS: $aData['aCategory'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_NEWS_CATEGORY); $aData['aTag'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_NEWS_TAG); break; } $aData['aCity'] = Model_City::getPairCitys(Model_City::TYPE_FRONT); // array_unshift($aData['aCategory'], '不限'); // array_unshift($aData['aCity'], '不限'); // array_unshift($aData['aTag'], '不限'); $aType = Model_Media::$aType; unset($aType[Model_Media::TYPE_NEWS]); $this->assign('iType', $iType); $this->assign('aType', $aType); $this->assign('aData', $aData); $this->assign('aMedia', $aMedia); $this->assign('aUser', Model_User::getDetail($this->aCurrUser['iUserID'])); $this->assign('sTopMenu', 'madd'); $sRandCode = Util_Tools::passwdGen(8, Util_Tools::FLAG_ALPHANUMERIC); Util_Cookie::set('media_verify_code', $sRandCode); $this->assign('sRandCode', $sRandCode); $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' => '用户忘记密码')); } }