public function create()
 {
     if ($this->checkFormSubmit()) {
         $shopnew = $_GET['shopnew'];
         if ($shopnew['shopname'] && $shopnew['province'] && $shopnew['city'] && $shopnew['address'] && $shopnew['description']) {
             $upload = new UploadImage();
             if ($filedata = $upload->saveImage()) {
                 $shopnew['pic'] = $filedata['attachment'];
             }
             $shopnew['uid'] = $this->uid;
             $shopnew['username'] = $this->username;
             $shopnew['dateline'] = time();
             $shopid = $this->t('shop')->insert($shopnew, true);
             $links = array(array('text' => 'go_back', 'url' => '/?m=home&c=shop'), array('text' => 'reedit', 'url' => '/?m=home&c=shop&a=edit&shopid=' . $shopid));
             $this->showSuccess('save_succeed', '', $links, '', true);
         } else {
             $this->showError('undefined_action');
         }
     } else {
         global $G, $lang;
         $shop = $this->t('shop')->where(array('uid' => $this->uid))->selectOne();
         if ($shopcount) {
             $this->redirect('/?m=home&c=shop&a=edit&shopid=' . $shop['shopid']);
         } else {
             include template('shop_form');
         }
     }
 }
 public function uploadimage()
 {
     if ($_GET['from'] == 'swfupload') {
         $uid = intval($_GET['uid']);
         $username = trim($_GET['username']);
         $token = sha1($uid . $username . formhash());
         if (!$uid || !$username || $token != $_GET['token']) {
             $this->showAjaxError(-1, 'nologin');
         }
     } else {
         $uid = $GLOBALS['G']['uid'];
         if (!$uid) {
             $this->showAjaxError(-1, 'nologin');
         }
     }
     $upload = new UploadImage();
     if ($photo = $upload->saveImage()) {
         $photo['uid'] = $GLOBALS['G']['uid'];
         $photo['uptime'] = time();
         $photo['photoid'] = M('photo')->insert($photo, true);
         if ($_GET['from'] == 'umeditor') {
             $returns = array("state" => 'SUCCESS', "name" => $photo['name'], "url" => $photo['attachment'], "size" => $photo['filesize'], "type" => $photo['type']);
         } elseif ($_GET['from'] == 'redactor') {
             $img = image($photo['attachment']);
             exit('<img src="' . $img . '">');
         } else {
             $returns = $photo;
             $returns['url'] = C('ATTACHURL') . $photo['thumb'];
         }
         $this->showAjaxReturn($returns);
     }
 }
예제 #3
0
 public function setimage()
 {
     $id = intval($_GET['id']);
     $upload = new UploadImage();
     if ($image = $upload->saveImage()) {
         $this->t('ad')->where(array('id' => $id))->update(array('pic' => $image['attachment']));
         $this->showAjaxReturn(array('pic' => image($image['attachment'])));
     } else {
         $this->showAjaxError(-1, 'upload failed(' . $upload->error . ')');
     }
 }