如题所述
/**
* @desc ä¿åæ°å¢å¹¿å
*/
public function saveAdd(){
$userInfo = $this->getUserInfo();
if(!$userInfo['id'] || $userInfo['id'] == 0){
$this->error('请éæ°ç»éæ·»å 广å');
exit;
}
$_POST['user_id'] = $userInfo['id'];
if($_POST['areaType'] == 'all') unset($_POST['area']);
if( $_POST['areaType'] == 'custom' && (count($_POST['area']) == 34 || $_POST['area'] == '') ) unset($_POST['area']);
$id = null;
if($_POST['uploadType'] == 'single'){
/*$picInfo = getimagesize($_POST['pic']);
$sizeInfo = D('AdSizeConfig')->getDataById($_POST['size_id']);
if(($sizeInfo['width'] != $picInfo[0]) || $sizeInfo['height'] != $picInfo[1]){
$this->error('æ¨ä¸ä¼ çå¾çé¿æ宽ä¸æ£ç¡®ï¼');
}*/
$id = D($this->className)->addData($_POST);
}
if($_POST['uploadType'] == 'multi'){
foreach($_POST['picArr'] as $key => $val){
$data[$key] = $_POST;
$data[$key]['pic'] = $val;
$picInfo = getimagesize("./" . $val);
$map['width'] = $picInfo[0];
$map['height'] = $picInfo[1];
$data[$key]['size_id'] = D('AdSizeConfig')->where($map)->getField('id');
$id = D($this->className)->addData($data[$key]);
}
}
if($id){
//æ·»å 广å积å,è·åå±ç¤ºæ¶é´ï¼è·åå±ç¤ºåºå
$diff_time_start = strtotime($_POST['start_date']);
$diff_time_end = strtotime($_POST['end_date']);
$diff_days = floor(($diff_time_end -$diff_time_start)/86400) +1;
$area_ratio = ($_POST['areaType'] == 'all') ? 5 : 1;
$uid = $userInfo['id'];
//$method = 'ad_saveadd';
//$points = -intval($diff_days) * $area_ratio;
//$desc = 'è¿ä¹å¤'.$points.'åæ°';
//D('ScoreHistory')->setScoreByRule($method,'',$uid,'');
$this->userAddScore();
$this->success('æ·»å æåï¼','/Home/Ad/index');
}else{
$this->error( D($this->className)->getLastError() );
}
}
* @desc ä¿åæ°å¢å¹¿å
*/
public function saveAdd(){
$userInfo = $this->getUserInfo();
if(!$userInfo['id'] || $userInfo['id'] == 0){
$this->error('请éæ°ç»éæ·»å 广å');
exit;
}
$_POST['user_id'] = $userInfo['id'];
if($_POST['areaType'] == 'all') unset($_POST['area']);
if( $_POST['areaType'] == 'custom' && (count($_POST['area']) == 34 || $_POST['area'] == '') ) unset($_POST['area']);
$id = null;
if($_POST['uploadType'] == 'single'){
/*$picInfo = getimagesize($_POST['pic']);
$sizeInfo = D('AdSizeConfig')->getDataById($_POST['size_id']);
if(($sizeInfo['width'] != $picInfo[0]) || $sizeInfo['height'] != $picInfo[1]){
$this->error('æ¨ä¸ä¼ çå¾çé¿æ宽ä¸æ£ç¡®ï¼');
}*/
$id = D($this->className)->addData($_POST);
}
if($_POST['uploadType'] == 'multi'){
foreach($_POST['picArr'] as $key => $val){
$data[$key] = $_POST;
$data[$key]['pic'] = $val;
$picInfo = getimagesize("./" . $val);
$map['width'] = $picInfo[0];
$map['height'] = $picInfo[1];
$data[$key]['size_id'] = D('AdSizeConfig')->where($map)->getField('id');
$id = D($this->className)->addData($data[$key]);
}
}
if($id){
//æ·»å 广å积å,è·åå±ç¤ºæ¶é´ï¼è·åå±ç¤ºåºå
$diff_time_start = strtotime($_POST['start_date']);
$diff_time_end = strtotime($_POST['end_date']);
$diff_days = floor(($diff_time_end -$diff_time_start)/86400) +1;
$area_ratio = ($_POST['areaType'] == 'all') ? 5 : 1;
$uid = $userInfo['id'];
//$method = 'ad_saveadd';
//$points = -intval($diff_days) * $area_ratio;
//$desc = 'è¿ä¹å¤'.$points.'åæ°';
//D('ScoreHistory')->setScoreByRule($method,'',$uid,'');
$this->userAddScore();
$this->success('æ·»å æåï¼','/Home/Ad/index');
}else{
$this->error( D($this->className)->getLastError() );
}
}
温馨提示:答案为网友推荐,仅供参考