/** * 设置广告 */ 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' => '添加推广计划 - 推广计划')); } }
/** * 个人信息 */ public function userinfoAction() { if ($this->isPost()) { $aParam = $this->getParams(); $aParam['iUserID'] = $this->aCurrUser['iUserID']; $aUser = Model_User::getDetail($aParam['iUserID']); $aErr = array(); // if (empty($aParam['sEmail']) || ! Util_Validate::isEmail($aParam['sEmail'])) { // $aErr['sEmail'] = '邮箱格式不正确'; // } if (empty($aParam['sMobile']) || !Util_Validate::isMobile($aParam['sMobile'])) { $aErr['sMobile'] = '手机号码格式不正确'; } if ($aUser['sEmail'] != $aParam['sEmail'] && Model_User::getUserByEmail($aParam['sEmail'], $aParam['iType'], $aParam['iUserID'])) { $aErr['sEmail'] = '该邮箱已经被注册了'; } if ($aUser['sMobile'] != $aParam['sMobile'] && Model_User::getUserByMobile($aParam['sMobile'], $aParam['iType'], $aParam['iUserID'])) { $aErr['sMobile'] = '该手机号码已经被注册了'; } if (!Util_Validate::isCLength($aParam['sRealName'], 2, 5)) { $aErr['sRealName'] = '姓名长度为2-5个汉字!'; } if (!Util_Validate::isLength($aParam['sWeixin'], 4, 50)) { $aErr['sWeixin'] = '请输入正确的微信号'; } if (!Util_Validate::isQQ($aParam['sQQ'])) { $aErr['sQQ'] = 'QQ号码输入不正确'; } if (!empty($aErr)) { return $this->showMsg($aErr, false); } Model_User::updData($aParam); return $this->showMsg('个人信息修改成功!', true); } else { $aUser = Model_user::getDetail($this->aCurrUser['iUserID']); $this->assign('aUser', $aUser); $this->assign('iTabID', 2); $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; }
/** * 请求数据检测 * @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 chginfoAction() { if ($this->isPost()) { $aParam = $this->getParams(); $aUser = Model_User::getDetail($aParam['iUserID']); $aErr = array(); if (empty($aParam['sEmail']) || !Util_Validate::isEmail($aParam['sEmail'])) { $aErr['sEmail'] = '登录邮箱格式不正确!'; } if (empty($aParam['sMobile']) || !Util_Validate::isMobile($aParam['sMobile'])) { $aErr['sMobile'] = '手机号码格式不正确!'; } if ($aUser['sEmail'] != $aParam['sEmail'] && Model_User::getUserByEmail($aParam['sEmail'], $aParam['iType'], $aParam['iUserID'])) { $aErr['sEmail'] = '该邮箱已经被注册了!'; } if ($aUser['sMobile'] != $aParam['sMobile'] && Model_User::getUserByMobile($aParam['sMobile'], $aParam['iType'], $aParam['iUserID'])) { $aErr['sMobile'] = '该手机号码已经被注册了!'; } if (!Util_Validate::isCLength($aParam['sCoName'], 1, 50)) { $aErr['sCoName'] = '企业名称长度为1-50个汉字!'; } if (!Util_Validate::isCLength($aParam['sRealName'], 2, 5)) { $aErr['sRealName'] = '联系人名称长度为2-5个汉字!'; } if (!Util_Validate::isAbsoluteUrl($aParam['sCoWebsite'])) { $aErr['sCoWebsite'] = '网址格式不正确!'; } if (!Util_Validate::isCLength($aParam['sCoDesc'], 2, 200)) { $aErr['sCoDesc'] = '公司介绍长度为2-500个汉字!'; } if (empty($aParam['sWeixin'])) { $aErr['sWeixin'] = '请输入你的微信号!'; } if (!Util_Validate::isQQ($aParam['sQQ'])) { $aErr['sQQ'] = 'QQ号码输入不正确!'; } if (!empty($aErr)) { return $this->showMsg($aErr, false); } Model_User::updData($aParam); return $this->showMsg('个人信息修改成功!', true); } else { $iType = $this->getParam('type'); $aUser = $this->getCurrUser($iType); if (empty($aUser)) { return $this->show404(); } $aUser = Model_user::getDetail($aUser['iUserID']); $aIndustry = Model_Domain::getOption(Model_Domain::TYPE_CO_INDUSTRY); $this->assign('aUser', $aUser); $this->assign('aIndustry', $aIndustry); } }