public function cut() { static $isDel = false; $outFile = $this->getFileName(); $outDir = $this->getSaveDir($this->moduleid); $cut = new PwCutImage(); $image = $this->getRealPath($outFile); if (!$image) { return array('', '', $this->store->get($this->image, 0)); } //返回原图片 $cut->image = $image; $cut->outImage = Wind::getRealDir('PUBLIC:') . PUBLIC_ATTACH . '/' . $outDir . $outFile; $cut->cutWidth = $this->thumbW; $cut->cutHeight = $this->thumbH; $cut->quality = 90; $cut->forceThumb = true; $cut->forceScale = true; if ($cut->cut() !== false) { if (!$this->store instanceof PwStorageLocal) { $localFile = Wind::getRealDir('PUBLIC:') . PUBLIC_ATTACH . '/' . $outDir . $outFile; $this->store->save($localFile, $outDir . $outFile); $attachUrl = $this->store->get('', 0); WindFile::del(Wind::getRealDir('PUBLIC:') . PUBLIC_ATTACH . '/_tmp/' . $outFile); WindFile::del($localFile); } else { $attachUrl = Wekit::url()->attach . '/'; } return array($outDir, $outFile, $attachUrl); } return array('', '', $this->store->get($this->image, 0)); //返回原图片 }
/** * 获取web地址 * * @param string $path 相对存储地址 * @param int $ifthumb 是否获取缩略图 * @return string */ public function get($path, $ifthumb) { $dir = ''; if ($ifthumb & 2) { $dir = 'thumb/mini/'; } elseif ($ifthumb & 1) { $dir = 'thumb/'; } return Wekit::url()->attach . '/' . $dir . $path; }
public function preHandle() { $url = array(); $var = Wekit::url(); $url['base'] = $var->base; $url['res'] = $var->res; $url['css'] = $var->css; $url['images'] = $var->images; $url['js'] = $var->js; $url['attach'] = $var->attach; $url['themes'] = $var->themes; $url['extres'] = $var->extres; Wekit::setGlobal($url, 'url'); $request = array('m' => $this->router->getModule(), 'c' => $this->router->getController(), 'a' => $this->router->getAction()); $request['mc'] = $request['m'] . '/' . $request['c']; $request['mca'] = $request['mc'] . '/' . $request['a']; Wekit::setGlobal($request, 'request'); if (in_array($request['mca'], array('default/index/login', 'default/index/showVerify', 'appcenter/app/upload'))) { return; } /* @var $userService AdminUserService */ $userService = Wekit::load('ADMIN:service.srv.AdminUserService'); /* @var $safeService AdminSafeService */ $safeService = Wekit::load('ADMIN:service.srv.AdminSafeService'); /* @var $founderService AdminFounderService */ $founderService = Wekit::load('ADMIN:service.srv.AdminFounderService'); /* @var $loginUser AdminUserBo */ $loginUser = Wekit::getLoginUser(); if (!$loginUser->isExists() || !$founderService->isFounder($loginUser->username) && !$safeService->ipLegal(Wind::getComponent('request')->getClientIp())) { if (!$this->getRequest()->getIsAjaxRequest()) { $this->forward->forwardAction('default/index/login'); } else { $this->errorMessage->addError('logout', 'state'); $this->errorMessage->sendError('ADMIN:login.fail.not.login'); } } $_unVerifyTable = array('home', 'index', 'find'); if (!in_array(strtolower($request['c']), $_unVerifyTable)) { if ($request['c'] != 'adminlog') { $logService = Wekit::load('ADMIN:service.srv.AdminLogService'); $logService->log($this->getRequest(), $loginUser->username, $request['m'], $request['c'], $request['a']); } $_result = $userService->verifyUserMenuAuth($loginUser, $request['m'], $request['c'], $request['a']); if ($_result instanceof PwError) { $this->errorMessage->sendError($_result->getError()); } } }
/** * 获取应用中心门户模版 * */ public function getDesignAppStyle($page = 1, $perpage = 10) { $type = 'portal'; $ds = Wekit::load('APPCENTER:service.PwStyle'); $addons = Wekit::load('APPCENTER:service.srv.PwInstallApplication')->getConfig('style-type'); $page < 1 && ($page = 1); list($start, $limit) = Pw::page2limit($page, $perpage); $list = $ds->getStyleListByType($type, $limit, $start); foreach ($list as &$v) { if ($v['logo'] && strpos($v['logo'], 'http://') === false) { $args = array(Wekit::url()->themes, $addons[$type][1], $v['alias'], $v['logo']); $v['logo'] = implode('/', $args); } } return $list; }
public function preHandle() { /* 模板变量设置 */ $url = array(); $var = Wekit::url(); $url['base'] = $var->base; $url['res'] = $var->res; $url['css'] = $var->css; $url['images'] = $var->images; $url['js'] = $var->js; $url['attach'] = $var->attach; $url['themes'] = $var->themes; $url['extres'] = $var->extres; Wekit::setGlobal($url, 'url'); $request = array('m' => $this->router->getModule(), 'c' => $this->router->getController(), 'a' => $this->router->getAction()); $request['mc'] = $request['m'] . '/' . $request['c']; $request['mca'] = $request['mc'] . '/' . $request['a']; Wekit::setGlobal($request, 'request'); Wekit::setV('request', $request); $this->_setPreCache($request['m'], $request['mc'], $request['mca']); $loginUser = Wekit::getLoginUser(); $config = Wekit::C('site'); if ($config['visit.state'] > 0) { $service = Wekit::load('site.srv.PwSiteStatusService'); $resource = $service->siteStatus($loginUser, $config); if ($resource instanceof PwError) { if (!($config['visit.state'] == 1 && $request['mc'] == 'u/login')) { $this->showError($resource->getError()); } } } if (!in_array($request['mc'], array('u/login', 'u/register', 'u/findPwd')) && !$loginUser->getPermission('allow_visit')) { if ($loginUser->isExists()) { $this->showError(array('permission.visit.allow', array('{grouptitle}' => $loginUser->getGroupInfo('name')))); } else { $this->forwardRedirect(WindUrlHelper::createUrl('u/login/run')); } } if ($config['refreshtime'] > 0 && Wind::getApp()->getRequest()->isGet() && !Wind::getApp()->getRequest()->getIsAjaxRequest()) { if (Wekit::V('lastvist')->lastRequestUri == Wekit::V('lastvist')->requestUri && Wekit::V('lastvist')->lastvisit + $config['refreshtime'] > Pw::getTime()) { $this->showError('SITE:refresh.fast'); } } $this->_setPreHook($request['m'], $request['mc'], $request['mca']); $debug = $config['debug'] || !$config['css.compress']; Wekit::setGlobal(array('debug' => $debug ? '/dev' : '/build'), 'theme'); }
/** * 后台首页处理方法 */ public function run() { //TODO 后台默认首页内容扩展支持 list($groupType) = $this->getInput(array('type'), 'get'); $groupType or $groupType = 'member'; $groups = $this->_getGroupDs()->getGroupsByTypeInUpgradeOrder($groupType); if ('member' == $groupType) { $points = array(); $last = ''; foreach ($groups as $gid => $_item) { $points[] = $_item['points']; $last = $_item['points']; } $points[] = 999999999; $this->setOutput($points, 'points'); } //用户组类型 $groupTypes = $this->_getGroupDs()->getGroupTypes(); $typeClasses = array(); foreach ($groupTypes as $v) { $typeClasses[$v] = $groupType == $v ? ' class="current"' : ''; //TODO } //level images $imageDir = Wind::getRealDir('PUBLIC:res.images.level') . DIRECTORY_SEPARATOR; //$imageDir = sprintf('%s/www/res/images/level/',dirname(rtrim(WEKIT_PATH,DIRECTORY_SEPARATOR))); $imageUrl = sprintf('%s/level', Wekit::url()->images); $imageFiles = array(); if (is_dir($imageDir)) { if (false !== ($dh = opendir($imageDir))) { while (($file = readdir($dh)) !== false) { if (filetype($imageDir . $file) == 'dir') { continue; } $imageFiles[] = $file; } closedir($dh); } } natcasesort($imageFiles); $this->setOutput($imageUrl, 'imageUrl'); $this->setOutput($imageFiles, 'imageFiles'); $this->setOutput($groupType, 'groupType'); $this->setOutput($typeClasses, 'typeClasses'); $this->setOutput($groups, 'groups'); }
/** * 水印预览 */ public function viewAction() { $config = array('mark.limitwidth' => abs(intval($this->getInput('markLimitwidth', 'post'))), 'mark.limitheight' => abs(intval($this->getInput('markLimitheight', 'post'))), 'mark.position' => $this->getInput('markPosition', 'post'), 'mark.gif' => $this->getInput('markGif', 'post'), 'mark.type' => $this->getInput('markType', 'post'), 'mark.text' => $this->getInput('markText', 'post'), 'mark.fontfamily' => $this->getInput('markFontfamily', 'post'), 'mark.fontsize' => $this->getInput('markFontsize', 'post'), 'mark.fontcolor' => $this->getInput('markFontcolor', 'post'), 'mark.quality' => abs(intval($this->getInput('markQuality', 'post'))), 'mark.file' => $this->getInput('markFile', 'post'), 'mark.transparency' => abs(intval($this->getInput('markTransparency', 'post'))), 'mark.quality' => abs(intval($this->getInput('markQuality', 'post')))); Wind::import('LIB:image.PwImage'); Wind::import('LIB:image.PwImageWatermark'); $image = new PwImage(Wind::getRealDir('REP:demo', false) . '/demo.jpg'); $watermark = new PwImageWatermark($image); $watermark->setPosition($config['mark.position'])->setType($config['mark.type'])->setTransparency($config['mark.transparency'])->setQuality($config['mark.quality'])->setDstfile(Wind::getRealDir('PUBLIC:attachment', false) . '/demo.jpg'); if ($config['mark.type'] == 1) { $watermark->setFile($config['mark.file']); } else { $watermark->setText($config['mark.text'])->setFontfamily($config['mark.fontfamily'])->setFontsize($config['mark.fontsize'])->setFontcolor($config['mark.fontcolor']); } $watermark->execute(); $this->setOutput(Wekit::url()->attach . '/demo.jpg?' . time(), 'data'); $this->showMessage('ADMIN:success'); }
/** * 空间设置 * @see wekit/wind/web/WindController::run() */ public function run() { $perpage = 6; $page = 1; $this->spaceBo = new PwSpaceBo($this->loginUser->uid); $list = $this->_getStyleDs()->getAllStyle('space'); $addons = Wekit::load('APPCENTER:service.srv.PwInstallApplication')->getConfig('style-type'); //个性域名 $domain_isopen = Wekit::C('domain', 'space.isopen'); if ($domain_isopen) { $spaceroot = Wekit::C('domain', 'space.root'); $domain = $this->_spaceDomainDs()->getDomainByUid($this->loginUser->uid); $this->setOutput($spaceroot, 'spaceroot'); $this->setOutput($domain ? $domain : '', 'spacedomain'); } $this->setOutput($list, 'list'); $this->setOutput($perpage, 'perpage'); $this->setOutput(ceil(count($list) / $perpage), 'totalpage'); $this->setOutput(Wekit::url()->themes . '/' . $addons['space'][1], 'themeUrl'); $this->setOutput($this->spaceBo, 'space'); }
/** * 获取应用域名 * * @param string $_m * @return string */ private function _getModuleDomain($_m) { $appType = $this->_getAppType(); if (isset($appType[$_m])) { return $appType[$_m] . $this->base; } isset($appType['default']) || ($this->dynamicHost = Wekit::url()->base); return isset($appType['default']) ? $appType['default'] . $this->base : ($this->origialBase != $this->base ? Wekit::url()->base : ''); }
/** * windid更新 * * @return boolean */ private function _writeWindid() { $baseUrl = Wekit::url()->base; $key = md5(WindUtility::generateRandStr(10)); $charset = Wekit::V('charset'); $charset = str_replace('-', '', strtolower($charset)); if (!in_array($charset, array('gbk', 'utf8', 'big5'))) { $charset = 'utf8'; } $config = new PwConfigSet('windid'); $config->set('windid', 'local')->set('serverUrl', $baseUrl . '/windid')->set('clientId', 1)->set('clientKey', $key)->set('connect', 'db')->flush(); Wekit::C()->reload('windid'); Wind::import('WINDID:service.app.dm.WindidAppDm'); $dm = new WindidAppDm(); $dm->setApiFile('windid.php')->setIsNotify('1')->setIsSyn('1')->setAppName('phpwind9.0')->setSecretkey($key)->setAppUrl($baseUrl)->setCharset($charset)->setAppIp(''); $service = WindidApi::api('app'); $result = $service->addApp($dm); if ($result instanceof WindidError) { $this->showError('INSTALL:windid.init.fail'); } return true; }
/** * 生成表情html标签 * * @param int $key 表情序号 * @return string 表情html */ public static function createEmotion($length, $key) { is_null(self::$_emotion) && (self::$_emotion = Wekit::cache()->get('all_emotions')); isset(self::$_emotion['name'][$key]) && ($key = self::$_emotion['name'][$key]); $emotion = isset(self::$_emotion['emotion'][$key]) ? self::$_emotion['emotion'][$key] : current(self::$_emotion['emotion']); $html = "<img src=\"" . Wekit::url()->images . "/emotion/" . $emotion['emotion_folder'] . '/' . $emotion['emotion_icon'] . "\" />"; return array($html, 1); }
/** * 获取动他一下后台菜单 * * @param array $config * @return array */ public function spaceButton($space) { echo '<a rel="nofollow" href="' . WindUrlHelper::createUrl('app/dongta/index/act') . '" class="dongta J_qlogin_trigger J_dongta_act" data-uid="' . $space->spaceUser['uid'] . '"><em></em>打招呼</a>'; echo '<script>var URL_DONGTA = \'' . WindUrlHelper::createUrl('app/dongta/index/send') . '\';Wind.ready(function(){Wind.js(\'' . Wekit::url()->extres . '/dongta/js/dongta.js\');});</script>'; }
/** * 用户引导页面 * */ public function guideAction() { if (!$this->loginUser->isExists()) { $this->forwardRedirect(Wekit::url()->base); } $key = $this->getInput('key'); /* @var $guideService PwUserRegisterGuideService */ $guideService = Wekit::load('APPS:u.service.PwUserRegisterGuideService'); $next = $guideService->getNextGuide($key); if (!$next) { if (Wekit::C('register', 'active.check')) { $this->setOutput(1, 'check'); if (!Pw::getstatus($this->loginUser->info['status'], PwUser::STATUS_UNCHECK)) { $this->forwardRedirect(Wekit::url()->base); } } $synLogin = $this->_getWindid()->synLogin($this->loginUser->uid); $this->setOutput($this->loginUser->info['username'], 'username'); $this->setOutput('success', 'type'); $this->setOutput($synLogin, 'synLogin'); $this->setTemplate('register_about'); } else { $this->forwardRedirect(WindUrlHelper::createUrl($next['guide'])); } }
/** * 后台设置-附件缩略预览 */ public function viewAction() { list($thumb, $thumbsize_width, $thumbsize_height, $quality) = $this->getInput(array('thumb', 'thumbsize_width', 'thumbsize_height', 'quality'), 'post'); Wind::import('LIB:image.PwImage'); $image = new PwImage(Wind::getRealDir('REP:demo', false) . '/demo.jpg'); $thumburl = Wind::getRealDir('PUBLIC:attachment', false) . '/demo_thumb.jpg'; $image->makeThumb($thumburl, $thumbsize_width, $thumbsize_height, $quality, $thumb); $data = array('img' => Wekit::url()->attach . '/demo_thumb.jpg?' . time()); $this->setOutput($data, 'data'); $this->showMessage('ADMIN:success'); }
public function runJs() { echo '<script>var URL_DONGTA = \'' . WindUrlHelper::createUrl('app/dongta/index/send') . '\';</script>'; echo '<script src="' . Wekit::url()->extres . '/dongta/js/dongta.js"></script>'; }
/** * 执行数据库脚本升级 */ public function phpAction() { $phps = $this->_getPhps(); $step = Wekit::cache()->get('system_upgrade_php_step'); $step || ($step = 0); if ($phps && isset($phps[$step])) { $file = $phps[$step]; Wekit::cache()->set('system_upgrade_php_step', ++$step); $this->forwardRedirect(Wekit::url()->base . '/' . $file . '?from=' . urlencode(WindUrlHelper::createUrl('appcenter/upgrade/php?step=' . $step))); } else { Wekit::cache()->set('system_upgrade_step', 7); $this->forwardRedirect(WindUrlHelper::createUrl('appcenter/upgrade/end')); } }
/** * 过滤来源URL * * TODO * * @return string */ private function _filterUrl($returnDefault = true) { $url = $this->getInput('backurl'); if (!$url) { $url = $this->getRequest()->getServer('HTTP_REFERER'); } if ($url) { // 排除来自注册页面/自身welcome/show的跳转 $args = WindUrlHelper::urlToArgs($url); if ($args['m'] == 'u' && in_array($args['c'], array('register', 'login'))) { $url = ''; } } if (!$url && $returnDefault) { $url = Wekit::url()->base; } return $url; }
/** * 生成 图片 链接 * * @param string $path * @return string */ public static function createImgLink($path) { $html = "<img src=\"" . Wekit::url()->images . "/wind/file/img.gif\" align=\"absbottom\"> <a target=\"_blank\" href=\"{$path} \">{$path}</a>"; return self::_pushCode($html); }
public function __construct() { $this->attachUrl = Wekit::url()->attach; }
/** * 创建底部的js引入 */ public function createHtmlForFooter() { echo '<script>Wind.ready("global.js", function(){Wind.js("' . Wekit::url()->extres . '/majia/js/majia.js")})</script>'; }