Example #1
0
 /**
  * 更新
  *
  * @param  $id
  */
 public function actionUpdate($id)
 {
     parent::_acl();
     $model = parent::_dataLoad(new Place(), $id);
     $imageList = $this->_gets->getParam('imageList');
     $imageListSerialize = XUtils::imageListSerialize($imageList);
     if (isset($_POST['Place'])) {
         $model->attributes = $_POST['Place'];
         $model->pic_other = $imageListSerialize['dataSerialize'];
         $data = $_POST['Place'];
         $model->rank = $data['rank'];
         $file = XUpload::upload($_FILES['attach']);
         $adr = XUpload::upload($_FILES['pic_adr']);
         if (is_array($file)) {
             $model->pic = $file['pathname'];
             @unlink($_POST['oAttach']);
             @unlink($_POST['oThumb']);
         }
         if (is_array($adr)) {
             $model->pic_adr = $adr['pathname'];
             @unlink($_POST['oAttach']);
             @unlink($_POST['oThumb']);
         }
         if ($model->validate() && $model->save()) {
             AdminLogger::_create(array('catalog' => 'update', 'intro' => '编辑内容,ID:' . $id));
             $this->redirect(array('index'));
         }
     }
     if ($imageList) {
         $imageList = $imageListSerialize['data'];
     }
     $this->render('place_update', array('model' => $model));
 }
Example #2
0
 /**
  * 更新
  *
  * @param  $id
  */
 public function actionUpdate($id)
 {
     parent::_acl();
     $time = 1;
     $model = parent::_dataLoad(new Lesson(), $id);
     if (isset($_POST['Lesson'])) {
         $acl = $this->_gets->getPost('acl');
         $model->attributes = $_POST['Lesson'];
         $model->check_status = $_POST['Lesson']['check_status'];
         $starttime = $model->start_date_time;
         $endtime = $model->end_date_time;
         if ($starttime >= $endtime) {
             $time = 0;
         }
         $file = XUpload::upload($_FILES['attach']);
         if (is_array($file)) {
             $model->pic = $file['pathname'];
             @unlink($_POST['oAttach']);
             @unlink($_POST['oThumb']);
         }
         //echo CActiveForm::validate($model);exit;
         if ($model->validate() && $model->save() && ($time = 1)) {
             AdminLogger::_create(array('catalog' => 'update', 'intro' => '编辑内容,ID:' . $id));
             $this->redirect(array('index'));
         }
     }
     $this->render('lesson_update', array('model' => $model));
 }
Example #3
0
 public function actionSinfo()
 {
     $this->_seoTitle = '学员 - 个人信息';
     $student_id = $this->_user['studentId'];
     $studentInfo = StudentUpdate::model()->findByPk($student_id);
     //F::dump($sinfo);
     if (isset($_POST['StudentUpdate'])) {
         $studentInfo->attributes = $_POST['StudentUpdate'];
         $file = XUpload::upload($_FILES['attach']);
         if (is_array($file)) {
             $studentInfo->pic = $file['pathname'];
             @unlink($_POST['oAttach']);
             @unlink($_POST['oThumb']);
         }
         if ($studentInfo->pic == null) {
             Yii::app()->user->setFlash('picMessage', '头像不能为空');
         }
         if ($studentInfo->validate()) {
             if ($studentInfo->save() && $studentInfo->pic != null) {
                 $cookie = new CHttpCookie('userName', $studentInfo->name);
                 Yii::app()->request->cookies['userName'] = $cookie;
                 Yii::app()->user->setFlash('success', '保存成功!');
             }
         }
     }
     $this->render('student_info', array('studentInfo' => $studentInfo));
 }
Example #4
0
 /**
  * 更新
  *
  * @param  $id
  */
 public function actionUpdate($id)
 {
     parent::_acl();
     $model = parent::_dataLoad(new Place(), $id);
     if (isset($_POST['Place'])) {
         $model->attributes = $_POST['Place'];
         $file = XUpload::upload($_FILES['attach']);
         $adr = XUpload::upload($_FILES['pic_adr']);
         if (is_array($file)) {
             $model->pic = $file['pathname'];
             @unlink($_POST['oAttach']);
             @unlink($_POST['oThumb']);
         }
         if (is_array($adr)) {
             $model->pic_adr = $adr['pathname'];
             @unlink($_POST['oAttach']);
             @unlink($_POST['oThumb']);
         }
         if ($model->validate() && $model->save()) {
             AdminLogger::_create(array('catalog' => 'update', 'intro' => '编辑内容,ID:' . $id));
             $this->redirect(array('index'));
         }
     }
     $this->render('place_update', array('model' => $model));
 }
 /**
  * 更新
  *
  * @param  $id
  */
 public function actionUpdate($id)
 {
     parent::_acl();
     $model = parent::_dataLoad(new Lesson(), $id);
     if (isset($_POST['Lesson'])) {
         $acl = $this->_gets->getPost('acl');
         $model->attributes = $_POST['Lesson'];
         $model->teacher_id = 23;
         $model->check_status = 1;
         $model->actual_students = 0;
         $model->arrivals = 0;
         if ($model->validate()) {
             $file = XUpload::upload($_FILES['attach']);
             if (is_array($file)) {
                 $model->pic = $file['pathname'];
                 @unlink($_POST['oAttach']);
                 @unlink($_POST['oThumb']);
             }
             if ($model->save()) {
                 AdminLogger::_create(array('catalog' => 'update', 'intro' => '编辑内容,ID:' . $id));
                 $this->redirect(array('index'));
             }
         }
     }
     $this->render('lesson_update', array('model' => $model));
 }
Example #6
0
 /**
  * 上传
  */
 public function actionBasicExecute()
 {
     if (XUtils::method() == 'POST') {
         $adminiUserId = self::_sessionGet('adminiUserId');
         $file = XUpload::upload($_FILES['imgFile']);
         if (is_array($file)) {
             $model = new Upload();
             $model->user_id = intval($accountUserId);
             $model->file_name = $file['pathname'];
             $model->thumb_name = $file['paththumbname'];
             $model->real_name = $file['name'];
             $model->file_ext = $file['extension'];
             $model->file_mime = $file['type'];
             $model->file_size = $file['size'];
             $model->save_path = $file['savepath'];
             $model->hash = $file['hash'];
             $model->save_name = $file['savename'];
             $model->create_time = time();
             if ($model->save()) {
                 exit(CJSON::encode(array('state' => 'success', 'fileId' => $model->id, 'realFile' => $model->real_name, 'message' => '上传成功', 'file' => $file['pathname'])));
             } else {
                 @unlink($file['pathname']);
                 exit(CJSON::encode(array('state' => 'error', 'message' => '数据写入失败,上传错误')));
             }
         } else {
             exit(CJSON::encode(array('error' => 1, 'message' => '上传错误')));
         }
     }
 }
Example #7
0
 public function actionUpdate($id)
 {
     parent::_acl();
     $model = parent::_dataLoad(new Teacher(), $id);
     if (isset($_POST['Teacher'])) {
         $acl = $this->_gets->getPost('acl');
         $model->attributes = $_POST['Teacher'];
         $file = XUpload::upload($_FILES['attach']);
         $degree = XUpload::upload($_FILES['degree']);
         if (is_array($file)) {
             $model->pic = $file['pathname'];
             @unlink($_POST['oAttach']);
             @unlink($_POST['oThumb']);
         }
         if (is_array($degree)) {
             $model->degree = $degree['pathname'];
             @unlink($_POST['oAttach']);
             @unlink($_POST['oThumb']);
         }
         if ($model->validate()) {
             if ($model->save()) {
                 AdminLogger::_create(array('catalog' => 'update', 'intro' => '编辑内容,ID:' . $id));
                 $this->redirect(array('index'));
             }
         }
     }
     $this->render('teacher_update', array('model' => $model));
 }
Example #8
0
 /**
  * 编辑器文件上传
  */
 public function actionUpload()
 {
     if (XUtils::method() == 'POST') {
         $file = XUpload::upload($_FILES['imgFile']);
         if (is_array($file)) {
             $model = new Upload();
             $model->user_id = intval($admini['userId']);
             $model->file_name = CHtml::encode($file['pathname']);
             $model->thumb_name = CHtml::encode($file['paththumbname']);
             $model->real_name = CHtml::encode($file['name']);
             $model->file_ext = $file['extension'];
             $model->file_mime = $file['type'];
             $model->file_size = $file['size'];
             $model->save_path = $file['savepath'];
             $model->hash = $file['hash'];
             $model->save_name = $file['savename'];
             $model->create_time = time();
             if ($model->save()) {
                 exit(CJSON::encode(array('error' => 0, 'url' => Yii::app()->baseUrl . '/' . $file['pathname'])));
             } else {
                 @unlink($file['pathname']);
                 @unlink($file['paththumbname']);
                 exit(CJSON::encode(array('error' => 1, 'message' => '上传错误')));
             }
         } else {
             exit(CJSON::encode(array('error' => 1, 'message' => '上传错误:' . $file)));
         }
     }
 }
Example #9
0
 private function _getLogo($imageField, $path, $logoname)
 {
     $temp_arr = explode('.', $logoname);
     $hz = end($temp_arr);
     if (!in_array($hz, array('png', 'gif', 'jpg', 'jpeg'))) {
         $logoname = 'logo.png';
     }
     $file = $image_link = null;
     if (!empty($_FILES[$imageField]) && !empty($_FILES[$imageField]['name'])) {
         $file = XUpload::upload($_FILES[$imageField], array('thumb' => false, 'allowExts' => $this->_conf['upload_allow_ext'], 'maxSize' => $this->_conf['upload_max_size'] * 1024, 'saveRule' => array('rule' => 'custom', 'string' => 'images', 'path' => $path)));
     }
     $image_link = str_replace($file['savename'], $logoname, $file['pathname']);
     // 删掉同名图片
     is_file($image_link) && unlink($image_link);
     //改名为原名
     rename($file['pathname'], $image_link);
     return $image_link;
 }
Example #10
0
 /**
  * 更新
  *
  * @param  $id
  */
 public function actionUpdate($id)
 {
     parent::_acl('banner_update');
     $model = parent::_dataLoad(new Banner(), $id);
     if (isset($_POST['Banner'])) {
         $model->attributes = $_POST['Banner'];
         $file = XUpload::upload($_FILES['attach']);
         if (is_array($file)) {
             $model->image = $file['pathname'];
             @unlink($_POST['oAttach']);
         }
         if ($model->save()) {
             AdminLogger::_create(array('catalog' => 'update', 'intro' => '编辑banner,ID:' . $id));
             $this->redirect(array('index'));
         }
     }
     $this->render('update', array('model' => $model));
 }
Example #11
0
 /**
  * 单页更新
  *
  * @param $id        	
  */
 public function actionUpdate($id)
 {
     parent::_acl();
     $model = parent::_dataLoad(new Page(), $id);
     if (isset($_POST['Page'])) {
         $model->attributes = $_POST['Page'];
         $file = XUpload::upload($_FILES['attach'], array('thumb' => true, 'thumbSize' => array(200, 180)));
         if (is_array($file)) {
             $model->attach_file = $file['pathname'];
             $model->attach_thumb = $file['paththumbname'];
             @unlink($_POST['oAttach']);
             @unlink($_POST['oThumb']);
         }
         if ($model->save()) {
             XXcache::refresh('_link');
             AdminLogger::_create(array('catalog' => 'update', 'intro' => '编辑单页,ID:' . $id));
             $this->redirect(array('index'));
         }
     }
     $this->render('update', array('model' => $model));
 }
Example #12
0
 /**
  * 录入
  *
  */
 public function actionCreate()
 {
     parent::_acl();
     $model = new File();
     if (isset($_FILES['attach'])) {
         $file = XUpload::upload($_FILES['attach']);
         $image = XUpload::upload($_FILES['image']);
         if (is_array($file)) {
             $name = explode('.', $file['name']);
             $model->name = $name[0];
             $model->path = $file['pathname'];
         }
         if (is_array($image)) {
             $model->image = $image['pathname'];
         }
         if ($model->save()) {
             AdminLogger::_create(array('catalog' => 'create', 'intro' => '上传文件,ID:' . $model->id));
             $this->redirect(array('index'));
         }
     }
     $this->render('create', array('model' => $model));
 }
Example #13
0
 /**
  * 编辑
  *
  * @param  $id
  */
 public function actionUpdate($id)
 {
     parent::_acl('catalog_update');
     $model = new Catalog();
     $parentId = intval($_POST['Catalog']['parent_id']);
     $model = parent::_dataLoad(new Catalog(), $id);
     if (isset($_POST['Catalog'])) {
         self::parentTrue($id, $parentId);
         $model->attributes = $_POST['Catalog'];
         $file = XUpload::upload($_FILES['attach']);
         if (is_array($file)) {
             $model->image = $file['pathname'];
             @unlink($_POST['oAttach']);
         }
         if ($model->save()) {
             XXcache::refresh('_catalog');
             AdminLogger::_create(array('catalog' => 'update', 'intro' => '编辑类别,ID:' . $id . ',名称:' . $model->catalog_name));
             $this->redirect(array('index'));
         }
     }
     $this->render('update', array('model' => $model));
 }
Example #14
0
 /**
  * 更新
  *
  * @param  $id
  */
 public function actionUpdate($id)
 {
     parent::_acl('post_update');
     $original = Yii::app()->request->getQuery('original');
     $model = parent::_dataLoad(new Post(), $id);
     if (isset($_POST['Post'])) {
         $model->attributes = $_POST['Post'];
         $file = XUpload::upload($_FILES['attach']);
         if (is_array($file)) {
             $model->image = $file['pathname'];
             @unlink($_POST['oAttach']);
         }
         if ($model->save()) {
             AdminLogger::_create(array('catalog' => 'update', 'intro' => '编辑内容,ID:' . $id));
             if (!empty($original)) {
                 $this->redirect($original);
             } else {
                 $this->redirect(array('index'));
             }
         }
     }
     $this->render('update', array('model' => $model, 'original' => $original));
 }
Example #15
0
 /**
  * 更新
  *
  * @param  $id
  */
 public function actionUpdate($id)
 {
     parent::_acl('subject_update');
     $model = parent::_dataLoad(new Subject(), $id);
     $imageList = $this->_gets->getParam('imageList');
     $layoutList = $this->_gets->getParam('layoutList');
     $imageListSerialize = XUtils::imageListSerialize($imageList);
     $layoutListSerialize = XUtils::imageListSerialize($layoutList);
     if (isset($_POST['Subject'])) {
         $model->attributes = $_POST['Subject'];
         $model->date = strtotime($_POST['Subject']['date']);
         $file = XUpload::upload($_FILES['attach']);
         if (is_array($file)) {
             $model->room_type_image = $file['pathname'];
             @unlink($_POST['oAttach']);
         }
         $model->image_list = $imageListSerialize['dataSerialize'];
         $model->layout_list = $layoutListSerialize['dataSerialize'];
         if ($model->save()) {
             AdminLogger::_create(array('catalog' => 'update', 'intro' => '编辑项目,ID:' . $id));
             $this->redirect(array('index'));
         }
     }
     if ($imageList) {
         $imageList = $imageListSerialize['data'];
     } elseif ($model->image_list) {
         $imageList = unserialize($model->image_list);
     }
     if ($layoutList) {
         $layoutList = $layoutListSerialize['data'];
     } elseif ($model->layout_list) {
         $layoutList = unserialize($model->layout_list);
     }
     $this->city_list = parent::_groupList('city');
     $this->render('update', array('model' => $model, 'imageList' => $imageList, 'layoutList' => $layoutList));
 }
Example #16
0
 /**
  * 处理图片上传
  * @param type $imageField 图片字段
  * @return null
  */
 protected function _doLocalImage($imageField = 'image_link')
 {
     $file = $image_link = null;
     if (!empty($_FILES[$imageField]) && !empty($_FILES[$imageField]['name'])) {
         $file = XUpload::upload($_FILES[$imageField], array('thumb' => false, 'allowExts' => $this->_conf['upload_allow_ext'], 'maxSize' => $this->_conf['upload_max_size'] * 1024, 'saveRule' => array('rule' => 'default', 'format' => 'Ymd', 'path' => DIR_UPLOADS)));
     }
     if (!empty($file) && is_array($file) && isset($file['name'])) {
         if (!empty($_POST['oldpicname'])) {
             $oldname = str_replace($file['savename'], $file['name'], $file['pathname']);
             // 删掉同名图片
             is_file($oldname) && unlink($oldname);
             //改名为原名
             rename($file['pathname'], $oldname);
             $image_link = str_replace(DIR_UPLOADS, '', $file['savepath'] . $file['name']);
         } else {
             $image_link = str_replace(DIR_UPLOADS, '', $file['pathname']);
         }
     }
     //                ppr($image_link,1);
     return $image_link;
 }
Example #17
0
 public function actionAddBooks()
 {
     $this->_seoTitle = '名师 - 编辑著作';
     $id = Yii::app()->request->getParam('id');
     if ($id === null) {
         $model = new Book();
     } else {
         $model = Book::model()->findByPk($_GET['id']);
     }
     if (isset($_POST['Book'])) {
         $model->attributes = $_POST['Book'];
         $model->teacher_id = $this->_user['masterId'];
         if ($model->validate()) {
             $file = XUpload::upload($_FILES['attach']);
             if (is_array($file)) {
                 $model->pic = $file['pathname'];
                 @unlink($_POST['oAttach']);
                 @unlink($_POST['oThumb']);
             }
         }
         if ($model->save()) {
             $this->redirect(array('mybooks'));
         }
     }
     $this->render('addbooks', array('model' => $model));
 }
Example #18
0
 /**
  * 专题更新
  *
  * @param $id
  */
 public function actionSpecialUpdate($id)
 {
     parent::_acl('post_special_update');
     $model = parent::_dataLoad(new Special(), $id);
     if (isset($_POST['Special'])) {
         $model->attributes = $_POST['Special'];
         $file = XUpload::upload($_FILES['attach'], array('thumb' => true, 'thumbSize' => array(500, 400)));
         if (is_array($file)) {
             $model->attach_file = $file['pathname'];
             $model->attach_thumb = $file['paththumbname'];
             @unlink($_POST['oAttach']);
             @unlink($_POST['oThumb']);
         }
         if ($model->save()) {
             self::_adminiLogger(array('catalog' => 'update', 'intro' => '专题更新,ID:' . $model->id));
             $this->redirect(array('special'));
         }
     }
     $this->render('special_update', array('model' => $model));
 }
Example #19
0
 public function actionInfo()
 {
     $model = HostUpdate::model()->findByPk($this->_user['hostId']);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['HostUpdate'])) {
         $model->attributes = $_POST['HostUpdate'];
         $file = XUpload::upload($_FILES['attach']);
         if (is_array($file)) {
             $model->pic = $file['pathname'];
             @unlink($_POST['oAttach']);
             @unlink($_POST['oThumb']);
         }
         $head = XUpload::upload($_FILES['head_portrait']);
         if (is_array($head)) {
             $model->head_portrait = $head['pathname'];
             @unlink($_POST['oAttach']);
             @unlink($_POST['oThumb']);
         }
         if ($model->validate() and $model->save()) {
             $cookie = new CHttpCookie('userName', $model->name);
             Yii::app()->request->cookies['userName'] = $cookie;
             Yii::app()->user->setFlash('success', '保存成功!');
             $this->redirect(array('/host/default/Info'));
         }
     }
     $this->render('info', array('model' => $model));
 }
Example #20
0
 /**
  * 更新广告
  */
 public function actionAdUpdate($id)
 {
     parent::_acl('ad_update');
     $model = parent::_dataLoad(new Ad(), $id);
     if (isset($_POST['Ad'])) {
         $file = XUpload::upload($_FILES['attach']);
         if (is_array($file)) {
             $model->attach_file = $file['pathname'];
             @unlink($_POST['oAttach']);
         }
         $model->attributes = $_POST['Ad'];
         $model->expired_time = intval(strtotime($model->expired_time));
         $model->start_time = intval(strtotime($model->start_time));
         if ($model->save()) {
             XXcache::refresh('_ad');
             AdminLogger::_create(array('catalog' => 'update', 'intro' => '编辑广告,ID:' . $id));
             $this->redirect(array('ad'));
         }
     }
     $model->expired_time = date('Y-m-d', $model->expired_time);
     $model->start_time = date('Y-m-d', $model->start_time);
     $this->render('ad_update', array('model' => $model));
 }
Example #21
0
 /**
  * 更新
  *
  * @param  $id
  */
 public function actionUpdate($id)
 {
     parent::_acl('house_update');
     $original = Yii::app()->request->getQuery('original');
     $model = parent::_dataLoad(new House(), $id);
     $imageList = $this->_gets->getParam('imageList');
     $imageListSerialize = XUtils::imageListSerialize($imageList);
     if (isset($_POST['House'])) {
         $model->attributes = $_POST['House'];
         $model->accessDate = strtotime($_POST['House']['accessDate']);
         $model->match = implode(',', $_POST['House']['match']);
         $file = XUpload::upload($_FILES['house_image']);
         if (is_array($file)) {
             $model->house_image = $file['pathname'];
             @unlink($_POST['oAttach']);
         }
         $model->image_list = $imageListSerialize['dataSerialize'];
         if ($model->save()) {
             AdminLogger::_create(array('catalog' => 'update', 'intro' => '编辑房源信息,ID:' . $id));
             if (!empty($original)) {
                 $this->redirect($original);
             } else {
                 $this->redirect(array('index'));
             }
         }
     }
     if ($imageList) {
         $imageList = $imageListSerialize['data'];
     } elseif ($model->image_list) {
         $imageList = unserialize($model->image_list);
     }
     $this->subject_list = parent::_groupList('subject');
     $this->city_list = parent::_groupList('city');
     $this->district_list = parent::_groupList('district');
     $this->investType_list = parent::_groupList('investType');
     $this->propertyType_list = parent::_groupList('propertyType');
     $this->match_list = parent::_groupList('match');
     $this->render('update', array('model' => $model, 'imageList' => $imageList, 'original' => $original));
 }