/**
  * 此方法用于发布广告信息
  */
 public function actionRelease()
 {
     $this->layout = '//layouts/column1';
     $model = new Advertisement();
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model);
     if (isset($_POST['Advertisement'])) {
         $model->attributes = $_POST['Advertisement'];
         $model->start = strtotime($model->start);
         $model->end = strtotime($model->end);
         $model->hasimg = UtilMatch::hasImage($model->content);
         $model->imginfo = UtilMatch::getAllImageInfo($model->content);
         //			UtilHelper::dump(UtilMatch::hasImage($model->content));
         //			UtilHelper::dump(UtilMatch::getAllImageInfo($model->content));
         //
         UtilHelper::writeToFile($model->attributes);
         //
         //			die();
         $return = array();
         if ($model->save()) {
             $return = array('status' => 'ok', 'data' => CHtml::link('继续添加广告', array('/archiver/release', 'uid' => $model->uid)) . CHtml::link('/查看刚发布的广告', array('/info/view', 'uid' => $model->uid, 'id' => $model->id)));
         } else {
             $return = array('status' => 'false', 'data' => CHtml::errorSummary($model));
         }
         UtilHelper::writeToFile($return, 'a+');
         echo json_encode($return);
         die;
     }
     $this->render('release', array('model' => $model));
 }
Esempio n. 2
0
 public function actionCaiJi()
 {
     $todo = $this->getArticleList();
     foreach ($todo as $item) {
         $userSql = $this->randomSql('{{user}}', 1);
         $user = User::model()->findBySql($userSql);
         $cateSql = $this->randomSql('{{channel}}', 1);
         $category = Channel::model()->findBySql($cateSql);
         if ($user && $category) {
             $model = new Advertisement();
             $model->uid = $user->id;
             $model->cid = $category->id;
             $model->title = iconv('GB2312', 'UTF-8', $item['title']);
             $model->content = iconv('GB2312', 'UTF-8', $item['content']);
             $model->start = time();
             $model->end = time();
             $model->address = Profile::model()->getUserTrueName($user->id);
             $model->phone = $user->profiles->phone;
             $model->tag = implode(',', UtilSearch::phpAnalysis($model->content, 5));
             $model->hasimg = UtilMatch::hasImage($model->content);
             $model->imginfo = UtilMatch::getAllImageInfo($model->content);
             UtilHelper::dump($model->attributes);
         }
     }
     //		UtilHelper::writeToFile(serialize($todo), 'a+');
     //		UtilHelper::dump($todo);
     /**		foreach($arr[1] as $id=>$v){
     			echo CHtml::link($arr[2][$id], array('caijiwenzhang','url'=>$v))."</br>";
     		}
     */
 }