public function addAction() { $status = $this->getInput('startup_status'); // $config = new PwConfigSet('native'); if (count($_FILES)) { Wind::import('SRV:upload.action.PwStartUpUpload'); Wind::import('LIB:upload.PwUpload'); $bhv = new PwStartUpUpload(); $bhv->filename = 'startup'; // $upload = new PwUpload($bhv); if ($upload->check() === true) { $result = $upload->execute(); } if ($result !== true) { $this->showError($result->getError()); } if (!($data = $bhv->getAttachInfo())) { $this->showError('upload.fail'); } // $filepath = $upload->getStore()->getAbsolutePath($data['filename'], $data['path']); $filecontent = file_get_contents($filepath); // $config->set('startup.imgmd5', md5($filecontent)); $config->set('startup.img', $data['path'] . $data['filename']); } $config->set('startup.status', $status)->flush(); $this->showMessage('ADMIN:success'); }
/** * 淘宝推广图片 * * @access public * @return void */ public function dotaoAction() { if (!($user = $this->_getUser())) { $this->showError('login.not'); } $fid = $this->getInput('fid', 'post'); // $this->_accpetUploadForH5(); // Wind::import('SRV:upload.action.PwTaoUpload'); Wind::import('LIB:upload.PwUpload'); $bhv = new PwTaoUpload(); $bhv->filename = date('YmdHis'); // $upload = new PwUpload($bhv); if (($result = $upload->check()) === true) { $result = $upload->execute(); } if ($result !== true) { $this->showError($result->getError()); } if (!($data = $bhv->getAttachInfo())) { $this->showError('upload.fail'); } $data['path'] = Pw::getPath($data['path'] . $data['filename']); // $this->setOutput($data, 'data'); $this->showMessage('upload.success'); }
/** * 发存修改一个发现数据 * * @access public * @return void */ public function doAddAction() { list($fid, $title, $href, $des, $vieworder) = $this->getInput(array('fid', 'title', 'href', 'des', 'vieworder')); $title = trim($title); $href = trim($href); $des = trim($des); $vieworder = (int) $vieworder; if (empty($title)) { $this->showError("NATIVE:fresh.title.empty"); } if (empty($href)) { $this->showError("NATIVE:fresh.link.empty"); } if (Pw::strlen($title) > 5) { $this->showError("名称不能超过5个字符"); } if (Pw::strlen($des) > 9) { $this->showError("备注不能超过9个字符"); } if ($fid) { $fname = $fid; } else { $maxId = $this->_getDao()->getMaxId(); $fname = count($maxId) ? $maxId['fresh_id'] + 1 : 1; } if (!$fid && !$_FILES) { $this->showError('NATIVE:upload.empty'); } if ($_FILES) { Wind::import('SRV:upload.action.PwFreshUpload'); Wind::import('LIB:upload.PwUpload'); $bhv = new PwFreshUpload(); $bhv->filename = $fname; $upload = new PwUpload($bhv); if ($upload->check() === true) { $result = $upload->execute(); } if ($result !== true) { $this->showError($result->getError()); } if (!($data = $bhv->getAttachInfo())) { $this->showError('upload.fail'); } $img = $data['path'] . $data['filename']; } $data = array('title' => $title, 'href' => $href, 'des' => $des, 'vieworder' => $order); if ($img && $_FILES) { $data['img'] = $img; } if ($fid) { $this->_getDao()->updateFresh($fid, $data); } else { $this->_getDao()->addFresh($data); } $this->showMessage('success'); }
/** * * @access public * @return * @example * */ public function dosetAction() { /* $vd = function() { foreach(func_get_args() as $arg) { error_log(var_export($arg, true)); } }; */ $config = new PwConfigSet('notifier'); /* * 如果form的class是J_ajaxForm,可以只按照count($_FILES)来判断; * 如果不是,需要判断具体的tmp_name是否为空来判断是否选择了文件。 * */ if (count($_FILES) && !empty($_FILES['avatar']['tmp_name'])) { Wind::import('SRV:upload.action.PwStartUpUpload'); Wind::import('LIB:upload.PwUpload'); $bhv = new PwStartUpUpload(); $bhv->filename = 'avatar'; $upload = new PwUpload($bhv); if ($upload->check() === true) { $result = $upload->execute(); } if ($result !== true) { $this->showError($result->getError()); } if (!($data = $bhv->getAttachInfo())) { $this->showError('upload.fail'); } // 添加进设置项 $config->set('avatar', $data['path'] . $data['filename']); } $nickname = $this->getInput('nickname'); if (empty($nickname)) { $nickname = PwLaiWangSerivce::$defaultNotifier['nickname']; } $usertype = intval($this->getInput('usertype')); if ($usertype != PwLaiWangSerivce::USERTYPE_NAME && $usertype != PwLaiWangSerivce::USERTYPE_ID) { $usertype = PwLaiWangSerivce::USERTYPE_NAME; } $user = $this->getInput('user'); if ($usertype == PwLaiWangSerivce::USERTYPE_NAME) { $userinfo = Wekit::load('user.PwUser')->getUserByName($user, PwUser::FETCH_MAIN); } else { $userinfo = Wekit::load('user.PwUser')->getUserByUid($user, PwUser::FETCH_MAIN); } if (empty($userinfo)) { $this->showError('NATIVE:user.notfound'); } $config->set('nickname', $nickname)->set('usertype', $usertype)->set('username', $userinfo['username'])->set('userid', $userinfo['uid'])->flush(); $this->showMessage('ADMIN:success', 'native/notifier/run/', true); }
public function doAddAction() { list($bid, $title, $clickType, $href, $vieworder, $img) = $this->getInput(array('bid', 'title', 'clickType', 'href', 'vieworder', 'img')); $title = trim($title); $href = trim($href); $vieworder = (int) $vieworder; if (count($this->_getDao()->getBanner(PwBanner::BANNER_TYPE_NATIVE_INDEX)) >= 4 && !$bid) { $this->showError("NATIVE:banner.num.out"); } if (empty($title)) { $this->showError("NATIVE:banner.title.empty"); } if (empty($clickType)) { $this->showError("NATIVE:banner.clickType.empty"); } if (empty($href)) { $this->showError("NATIVE:banner.link.empty"); } if ($bid) { $fname = $bid; } else { $maxId = $this->_getDao()->getMaxId(); $fname = count($maxId) ? $maxId['banner_id'] + 1 : 1; } if (count($_FILES)) { Wind::import('SRV:upload.action.PwBannerUpload'); Wind::import('LIB:upload.PwUpload'); $bhv = new PwBannerUpload(); $bhv->filename = $fname; $upload = new PwUpload($bhv); if ($upload->check() === true) { $result = $upload->execute(); } if ($result !== true) { $this->showError($result->getError()); } if (!($data = $bhv->getAttachInfo())) { $this->showError('upload.fail'); } $img = $data['path'] . $data['filename']; } elseif (empty($bid)) { $this->showError('upload.empty'); } $data = array('banner_type' => PwBanner::BANNER_TYPE_NATIVE_INDEX, 'type' => $clickType, 'title' => $title, 'href' => $href, 'img' => $img, 'vieworder' => $order); if ($bid) { $this->_getDao()->updateBanner($bid, $data); } else { $this->_getDao()->addBanner($data); } $this->showMessage('success'); }
/** * 暂时不用 */ public function replaceAction() { $aid = $this->getInput('aid'); Wind::import('SRV:upload.action.PwAttReplaceUpload'); Wind::import('LIB:upload.PwUpload'); $bhv = new PwAttReplaceUpload($this->loginUser, $aid); $upload = new PwUpload($bhv); if (($result = $upload->check()) === true) { $result = $upload->execute(); } if ($result !== true) { $this->showError($result->getError()); } $this->setOutput($bhv->getAttachInfo(), 'data'); $this->showMessage('upload.success'); }
private function _uploadFile() { Wind::import('SRV:upload.action.PwDesignImageUpload'); Wind::import('SRV:upload.PwUpload'); $bhv = new PwDesignImageUpload(); $upload = new PwUpload($bhv); if (($result = $upload->check()) === true) { $result = $upload->execute(); } if ($result !== true) { return $result; } $image = $bhv->getAttachInfo(); if (!$image['filename']) { return ''; } return Pw::getPath($image['path'] . $image['filename']); }
public function updateIcon($uid) { $userBo = Wekit::getLoginUser(); if ($userBo->uid != $uid) { return $this->buildResponse(USER_NOT_LOGIN, "用户未登录"); } Wind::import('SRV:upload.action.PwAvatarUpload'); Wind::import('LIB:upload.PwUpload'); $bhv = new PwAvatarUpload($userBo); $upload = new PwUpload($bhv); if (($result = $upload->check()) === true) { $result = $upload->execute(); } if ($result !== true) { return $this->buildResponse(USER_UPDATE_ERROR, "更新头像"); } else { return $this->buildResponse(0, '更新成功'); } }
public function doimportAction() { Wind::import('SRV:upload.action.PwWordUpload'); Wind::import('LIB:upload.PwUpload'); $bhv = new PwWordUpload(); $upload = new PwUpload($bhv); if (($result = $upload->check()) === true) { $result = $upload->execute(); } if ($result !== true) { $error = $result->getError(); if (is_array($error)) { list($error, ) = $error; if ($error == 'upload.ext.error') { $this->showError('WORD:ext.error'); } } $this->showError($result->getError()); } $source = $bhv->getAbsoluteFile(); if (!WindFile::isFile($source)) { $this->showError('operate.fail'); } $content = WindFile::read($source); pw::deleteAttach($bhv->dir . $bhv->filename, 0, $bhv->isLocal); $content = explode("\n", $content); if (!$content) { $this->showError('WORD:import.data.empty'); } $wordService = $this->_getWordService(); $typeMap = $this->_getWordDS()->getTypeMap(); Wind::import('SRV:word.dm.PwWordDm'); foreach ($content as $value) { list($word, $type, $replace) = $this->_parseTextUseInImport($value, $typeMap); if (!$word || !$type || $wordService->isExistWord($word)) { continue; } $dm = new PwWordDm(); /* @var $dm PwWordDm */ $dm->setWord($word)->setWordType($type); $replace = $this->_getWordDS()->isReplaceWord($type) ? $replace ? $replace : '****' : ''; $dm->setWordReplace($replace); $this->_getWordDS()->add($dm); } $this->_getWordFilter()->updateCache(); $this->showMessage('success'); }
private function _uploadImage($key = 'image') { Wind::import('SRV:upload.action.PwMedalUpload'); Wind::import('LIB:upload.PwUpload'); if ($key == 'image') { $bhv = new PwMedalUpload('image', 80, 80); } else { $bhv = new PwMedalUpload('icon', 30, 30); } $upload = new PwUpload($bhv); if (($result = $upload->check()) === true) { $result = $upload->execute(); } if ($result !== true) { $this->showError($result->getError()); } return $bhv->getAttachInfo(); }
/** * 上次投票项图片 * */ public function uploadOptionImage() { Wind::import('SRV:upload.action.PwPollUpload'); Wind::import('SRV:upload.PwUpload'); $bhv = new PwPollUpload($this->user); $upload = new PwUpload($bhv); if (($result = $upload->check()) === true) { $result = $upload->execute(); } if ($result !== true) { return $result == false ? new PwError('operate.fail') : $result; } return $bhv->getAttachInfo(); }
private function _upload($portalId = 0) { Wind::import('SRV:upload.action.PwPortalUpload'); Wind::import('LIB:upload.PwUpload'); $bhv = new PwPortalUpload($portalId); $upload = new PwUpload($bhv); if (($result = $upload->check()) === true) { $result = $upload->execute(); } if ($result !== true) { $this->showError($result->getError()); } return $bhv->getAttachInfo(); }
private function _uploadFile($key, $moduleid = 0) { Wind::import('SRV:upload.action.PwDesignDataUpload'); Wind::import('SRV:upload.PwUpload'); $bhv = new PwDesignDataUpload($key, $moduleid); $upload = new PwUpload($bhv); if (($result = $upload->check()) === true) { $result = $upload->execute(); } if ($result !== true) { $this->showError($result->getError()); } $image = $bhv->getAttachInfo(); return $image['filename'] ? Pw::getPath($image['path'] . $image['filename']) : ""; }
/** * 上传 * * @param string $key * @return string */ private function _upload($key) { Wind::import('SRV:upload.action.PwIconUpload'); Wind::import('LIB:upload.PwUpload'); $bhv = new PwIconUpload($key, 'background/'); $upload = new PwUpload($bhv); $r = $upload->execute(); if ($r instanceof PwError) { $this->showError($r->getError()); } return $bhv->getAttachInfo(); }
/** * 上传图标 * * @return string */ private function saveIcon() { Wind::import("SRV:upload.action.PwTaskIconUpload"); Wind::import('LIB:upload.PwUpload'); $taskUpload = new PwTaskIconUpload(80, 80); $upload = new PwUpload($taskUpload); if (($result = $upload->check()) === true) { $result = $upload->execute(); } if ($result !== true) { $this->showError($result->getError()); } $path = $taskUpload->getPath(); return $path ? $path : $this->getInput('oldicon'); }
private function _uploadImage() { Wind::import('SRV:upload.action.PwSpaceUpload'); Wind::import('SRV:upload.PwUpload'); $bhv = new PwSpaceUpload($this->loginUser->uid); $upload = new PwUpload($bhv); if (($result = $upload->check()) === true) { $result = $upload->execute(); } if ($result !== true) { $this->showError($result->getError()); } return $bhv->getAttachInfo(); }
/** * 上传话题图标 * * @return string */ private function uploadLogo() { Wind::import("SRV:upload.action.PwTagUpload"); Wind::import('LIB:upload.PwUpload'); $tagUpload = new PwTagUpload(156, 156); $upload = new PwUpload($tagUpload); if (($result = $upload->check()) === true) { $result = $upload->execute(); } if ($result !== true) { $this->showError($result->getError()); } return $tagUpload->getPath(); }
/** * 上传头像 */ public function doavatarAction() { $uid = (int) $this->getInput('uid', 'get'); Wind::import('WSRV:upload.action.WindidAvatarUpload'); Wind::import('LIB:upload.PwUpload'); $bhv = new WindidAvatarUpload($uid); $upload = new PwUpload($bhv); if (($result = $upload->check()) === true) { $result = $upload->execute(); } else { $this->output($this->errorCode('upload.content.error')); } if ($result instanceof PwError) { $this->output($this->errorCode($result->getError())); } else { $this->_getNotifyService()->send('uploadAvatar', array('uid' => $uid), 0); //服务端发送通知 $this->output(1); } }
private function _uploadImage($type, $fid) { Wind::import('SRV:upload.action.PwForumUpload'); Wind::import('LIB:upload.PwUpload'); $bhv = new PwForumUpload($type, $fid); $upload = new PwUpload($bhv); if (($result = $upload->check()) === true) { $result = $upload->execute(); } if ($result !== true) { $this->showError($result->getError()); } $attachInfo = $bhv->getAttachInfo(); return $attachInfo; }