public function afterAction($handlerAdapter)
 {
     parent::afterAction($handlerAdapter);
     $debug = Wekit::C('site', 'debug') || !Wekit::C('site', 'css.compress');
     Wekit::setGlobal(array('debug' => $debug ? '/dev' : '/build'), 'theme');
     $this->setTheme('site', null);
     /* @var $resource WindLangResource */
     $resource = Wind::getComponent('i18n');
     $_error = $this->getForward()->getVars('message');
     if ($resource !== null) {
         foreach ($_error as $key => $value) {
             if (is_array($value)) {
                 list($value, $var) = $value;
             } else {
                 $var = array();
             }
             $message = $resource->getMessage($value, $var);
             $message && ($_error[$key] = $message);
         }
     }
     $this->getForward()->setVars(array('message' => $_error, '__error' => ''));
     $type = $this->getRequest()->getAcceptTypes();
     // 如果是含有上传的递交,不能采用ajax的方式递交,需要以html的方式递交,并且返回的结果需要是json格式,将以json=1传递过来标志
     $json = $this->getInput('_json');
     $requestJson = $this->getRequest()->getIsAjaxRequest() && strpos(strtolower($type), "application/json") !== false;
     if ($requestJson || $json == 1) {
         $this->getResponse()->setHeader('Content-type', 'application/json; charset=' . Wekit::V('charset'));
         echo Pw::jsonEncode($this->getForward()->getVars());
         exit;
     }
 }
 /**
  * 根据当前版本+release获取升级信息(patch包地址) ,hash值
  * 获取升级文件列表
  */
 public function checkUpgrade()
 {
     $url = PwApplicationHelper::acloudUrl(array('a' => 'forward', 'do' => 'getUpdateInfo', 'pwversion' => $this->local));
     $r = PwApplicationHelper::requestAcloudData($url);
     $r = WindConvert::convert($r, Wekit::V('charset'), 'utf8');
     return is_array($r) ? $r['code'] === '0' ? $r['info'] : $r['msg'] : '无法连接云平台!';
 }
Esempio n. 3
0
 public function run()
 {
     header("Content-type: text/html; charset=" . Wekit::V('charset'));
     //$pwServer['HTTP_USER_AGENT'] = 'Shockwave Flash';
     $swfhash = 1;
     Pw::echoJson(array('uid' => $this->loginUser->uid, 'a' => 'dorun', 'verify' => $swfhash));
     $this->setTemplate('');
 }
Esempio n. 4
0
 public function getCache()
 {
     $cache = new PwCache();
     $cache->mergeKeys(Wekit::V('cacheKeys'));
     if (Wekit::V('dbcache') && $cache->isDbCache()) {
         PwLoader::importCache(Wekit::S('cacheService'));
     }
     return $cache;
 }
Esempio n. 5
0
 /**
  * 重写下afterAction,不去i18n解析
  * 
  */
 public function afterAction($handlerAdapter)
 {
     $_error = $this->getForward()->getVars('message');
     $this->getForward()->setVars(array('message' => $_error, '__error' => ''));
     $type = $this->getRequest()->getAcceptTypes();
     if ($this->getRequest()->getIsAjaxRequest() && strpos(strtolower($type), "application/json") !== false) {
         $this->getResponse()->setHeader('Content-type', 'application/json; charset=' . Wekit::V('charset'));
         exit(Pw::jsonEncode($this->getForward()->getVars()));
     }
 }
 protected function output($message = '')
 {
     if (is_numeric($message)) {
         echo $message;
         exit;
     } else {
         header('Content-type: application/json; charset=' . Wekit::V('charset'));
         echo Pw::jsonEncode($message);
         exit;
     }
 }
Esempio n. 7
0
 /**
  * manifest path
  *
  * @param string $manifest        	
  */
 public function __construct($manifest, $extends = array())
 {
     is_string($manifest) && ($manifest = Wind::getComponent('configParser')->parse($manifest));
     if ($extends) {
         $manifest = WindUtility::mergeArray($manifest, $extends);
         $charset = isset($manifest['application']['charset']) ? $manifest['application']['charset'] : 'utf-8';
     } else {
         $charset = Wekit::V('charset');
     }
     strncasecmp($charset, 'utf', 3) && ($manifest = WindConvert::convert($manifest, $charset, 'utf-8'));
     $this->manifest = $manifest;
 }
Esempio n. 8
0
 public function __construct()
 {
     $config = Wekit::C('email');
     $this->_config = array('mailOpen' => $config['mailOpen'], 'mailMethod' => $config['mailMethod'], 'host' => $config['mail.host'], 'port' => $config['mail.port'], 'from' => $config['mail.from'], 'auth' => $config['mail.auth'], 'user' => $config['mail.user'], 'password' => $config['mail.password'], 'timeout' => 20);
     //尝试链接超时时间
     $this->_mail = new WindMail();
     $this->_mail->setCharset(Wekit::V('charset'));
     $this->_mail->setDate(date('r', Pw::getTime()));
     $this->_mail->setContentEncode(WindMail::ENCODE_BASE64);
     $this->_mail->setContentType(WindMail::MIME_HTML);
     $this->_mail->setFrom($this->_config['from'], Wekit::C('site', 'info.name'));
 }
Esempio n. 9
0
 protected function _setPreHook($m, $mc, $mca)
 {
     $prehook = Wekit::V('prehook');
     PwHook::preset($prehook['ALL']);
     PwHook::preset($prehook[$this->loginUser->isExists() ? 'LOGIN' : 'UNLOGIN']);
     if (isset($prehook[$m])) {
         PwHook::preset($prehook[$m]);
     }
     if (isset($prehook[$mc])) {
         PwHook::preset($prehook[$mc]);
     }
     if (isset($prehook[$mca])) {
         PwHook::preset($prehook[$mca]);
     }
 }
Esempio n. 10
0
 public function afterAction($handlerAdapter)
 {
     parent::afterAction($handlerAdapter);
     $debug = Wekit::C('site', 'debug') || !Wekit::C('site', 'css.compress');
     Wekit::setGlobal(array('debug' => $debug ? '/dev' : '/build'), 'theme');
     $this->setTheme('site', null);
     /* @var $resource WindLangResource */
     $resource = Wind::getComponent('i18n');
     $_error = $this->getForward()->getVars('message');
     if ($resource !== null) {
         foreach ($_error as $key => $value) {
             if (is_array($value)) {
                 list($value, $var) = $value;
             } else {
                 $var = array();
             }
             $message = $resource->getMessage($value, $var);
             $message && ($_error[$key] = $message);
         }
     }
     $this->getForward()->setVars(array('message' => $_error, '__error' => ''));
     $type = $this->getRequest()->getAcceptTypes();
     // 如果是含有上传的递交,不能采用ajax的方式递交,需要以html的方式递交,并且返回的结果需要是json格式,将以json=1传递过来标志
     $json = $this->getInput('_json');
     $requestJson = $this->getRequest()->getIsAjaxRequest() && strpos(strtolower($type), "application/json") !== false;
     if ($requestJson || $json == 1) {
         $this->getResponse()->setHeader('Content-type', 'application/json; charset=' . Wekit::V('charset'));
         $vars = $this->getForward()->getVars();
         isset($vars['referer']) && ($vars['referer'] = rawurlencode($vars['referer']));
         foreach ($vars as $key => $value) {
             if ($key == 'html') {
                 continue;
             }
             //$vars[$key] = WindSecurity::escapeArrayHTML($value);
         }
         //jsonp
         $callback = $this->getInput('callback', 'get');
         if ($callback && preg_match('/[\\w_]/i', $callback)) {
             echo $callback . "(" . Pw::jsonEncode($vars) . ")";
             exit;
         }
         //            print_r($vars);
         echo Pw::jsonEncode($vars);
         exit;
     }
 }
Esempio n. 11
0
 public function dorunAction()
 {
     $this->getRequest()->isPost() || $this->showError('operate.fail');
     list($windid, $serverUrl, $clientId, $clientKey, $connect) = $this->getInput(array('windid', 'serverUrl', 'clientId', 'clientKey', 'connect'), 'post');
     if ($windid == 'local') {
         $serverUrl = Wekit::C('site', 'info.url') . '/windid';
         $clientId = 1;
         !$clientKey && ($clientKey = md5(WindUtility::generateRandStr(10)));
         $connect = 'db';
     }
     $config = new PwConfigSet('windid');
     $config->set('windid', $windid)->set('serverUrl', $serverUrl)->set('clientId', $clientId)->set('clientKey', $clientKey)->set('connect', $connect);
     if ($windid == 'client') {
         list($dbhost, $dbport, $dbuser, $dbpwd, $dbname, $dbprefix, $dbcharset) = $this->getInput(array('dbhost', 'dbport', 'dbuser', 'dbpwd', 'dbname', 'dbprefix', 'dbcharset'), 'post');
         $config->set('db.host', $dbhost)->set('db.port', $dbport)->set('db.user', $dbuser)->set('db.pwd', $dbpwd)->set('db.name', $dbname)->set('db.prefix', $dbprefix)->set('db.charset', $dbcharset);
     }
     $config->flush();
     if ($clientId) {
         Wekit::C()->reload('windid');
         $service = WindidApi::api('app');
         WindidApi::getDm('app');
         if (!$service->getApp($clientId)) {
             $charset = Wekit::V('charset');
             $charset = str_replace('-', '', strtolower($charset));
             if (!in_array($charset, array('gbk', 'utf8', 'big5'))) {
                 $charset = 'utf8';
             }
             $dm = new WindidAppDm();
             $dm->setId($clientId)->setApiFile('windid.php')->setIsNotify(1)->setIsSyn(1)->setAppName(Wekit::C('site', 'info.name'))->setSecretkey($clientKey)->setAppUrl(Wekit::C('site', 'info.url'))->setAppIp(Wind::getComponent('request')->getClientIp())->setCharset($charset);
             $service->addApp($dm);
         } elseif ($clientKey) {
             $dm = new WindidAppDm($clientId);
             $dm->setSecretkey($clientKey)->setAppUrl(Wekit::C('site', 'info.url'))->setCharset($charset);
             $service->editApp($dm);
         }
     }
     $_avatarUrl = WindidApi::api('avatar')->getAvatarUrl();
     if ($_avatarUrl != WindidError::SERVER_ERROR) {
         Wekit::C()->setConfig('site', 'avatarUrl', $_avatarUrl);
     }
     $this->showMessage('ADMIN:success');
 }
Esempio n. 12
0
 /**
  * 获取线上补丁列表
  *
  * @return Ambigous <multitype:, boolean, string>
  */
 public function getOnlinePatchList()
 {
     $url = PwApplicationHelper::acloudUrl(array('a' => 'forward', 'do' => 'getSecurityPatch', 'pwversion' => NEXT_VERSION));
     $r = PwApplicationHelper::requestAcloudData($url);
     if (!is_array($r)) {
         return '无法连接云平台!';
     }
     if ($r['code'] !== '0') {
         return $r['msg'];
     }
     /* $r['info'] = array(
     			array('id' => '9000001', 'name' => '更新', 'desc' => 'blabla', 'time' => '1323333', 'rule' => array(
     				array('filename' => 'src/wekit.php', 'search' => base64_encode('Jianmin Chen'), 'replace' => base64_encode('Shi Long'), 'count' => '1', 'nums' => array('1'))))
     		); */
     $temp = array();
     foreach ($r['info'] as $v) {
         $v['id'] = $v['name'];
         $temp[$v['id']] = WindConvert::convert($v, Wekit::V('charset'), 'utf8');
     }
     return $temp;
 }
Esempio n. 13
0
 public function run()
 {
     header("Content-type:text/html;charset=" . Wekit::V('charset'));
     echo '这里是windid系统服务中心';
     exit;
 }
Esempio n. 14
0
if (!defined('WEKIT_VERSION')) {
    error_reporting(E_ERROR | E_PARSE);
    require_once WINDID_BOOT . '../wekit.php';
    Wekit::init('windidclient');
    Wind::application('windidclient', Wekit::S());
    $database = (include WINDID_BOOT . 'conf/database.php');
    $windidConfig = (include Wind::getRealPath('WINDID:conf.config.php', true));
    Wind::register(WINDID_PATH . 'service', 'SRV');
} else {
    $windidConfig = Wekit::C('windid');
    if ($windidConfig['windid'] == 'local') {
        $database = Wind::getComponent('db')->getConfig();
        $database['tableprefix'] .= 'windid_';
        $windidConfig['connect'] = 'db';
    } else {
        $database = array('dsn' => 'mysql:host=' . $windidConfig['db.host'] . ';dbname=' . $windidConfig['db.name'] . ';port=' . $windidConfig['db.port'], 'user' => $windidConfig['db.user'], 'pwd' => $windidConfig['db.pwd'], 'charset' => $windidConfig['db.charset'], 'tableprefix' => $windidConfig['db.prefix']);
    }
    $windidConfig['charset'] = Wekit::V('charset');
}
Wind::register(WINDID_PATH . 'service', 'WSRV');
Wind::import('WSRV:base.WindidBaseDao');
Wind::import('WSRV:base.WindidUtility');
Wind::import('WSRV:base.WindidError');
Wind::registeComponent(array('path' => 'WIND:db.WindConnection', 'config' => $database), 'windiddb', 'singleton');
define('WINDID_CONNECT', $windidConfig['connect']);
define('WINDID_SERVER_URL', $windidConfig['serverUrl']);
define('WINDID_CLIENT_ID', $windidConfig['clientId']);
define('WINDID_CLIENT_KEY', $windidConfig['clientKey']);
define('WINDID_CLIENT_CHARSET', $windidConfig['charset']);
Wekit::createapp('windidclient', 'windid');
Esempio n. 15
0
 private function _saveVerifyCode()
 {
     Wind::import('LIB:utility.verifycode.PwBaseCode');
     $code = WindConvert::convert(PwBaseCode::getCode(), Wekit::V('charset'), 'UTF-8');
     $code = Pw::encrypt(strtolower($code));
     //Wind::import('WIND:http.session.WindSession');
     Pw::setCookie('Pw_verify_code', $code, 3600);
     /*$session = new WindSession();
     		$session->set('verifycode', $code);*/
 }
Esempio n. 16
0
 protected function _getCacheServer($use, $config)
 {
     switch ($use) {
         case self::USE_FILE:
             Wind::import('LIB:engine.extension.cache.PwFileCache');
             $server = new PwFileCache();
             break;
         case self::USE_DB:
             Wind::import('WIND:cache.strategy.WindDbCache');
             $server = new WindDbCache(Wind::getComponent('db'));
             break;
         case self::USE_MEN:
             $class = Wind::import('WIND:cache.strategy.Wind' . Wekit::V('mem.server'));
             $server = new $class();
             break;
         case self::USE_REDIS:
             Wind::import('WIND:cache.strategy.WindRedisCache');
             $server = new WindRedisCache();
             break;
     }
     $config && $server->setConfig($config);
     return $server;
 }
Esempio n. 17
0
 /**
  * 在线服务  	
  */
 protected function updateOnline()
 {
     $loginUser = Wekit::getLoginUser();
     $request = Wekit::V('request');
     if ($loginUser->uid > 0 && $request['mca'] == 'bbs/read/run') {
         return false;
     }
     //帖子阅读页在ReadController里处理
     if ($loginUser->uid > 0 && $request['m'] == 'space') {
         return false;
     }
     //空间在spaceBaseController里处理
     $online = Wekit::load('online.srv.PwOnlineService');
     // $service->clearNotOnline(); // 由计划任务清理
     if ($loginUser->uid > 0 && $request['mca'] == 'bbs/thread/run') {
         $createdTime = $online->forumOnline($this->getInput('fid'));
     } else {
         $clientIp = $loginUser->ip;
         $createdTime = $online->visitOnline($clientIp);
     }
     if (!$createdTime) {
         return false;
     }
     $dm = Wekit::load('online.dm.PwOnlineDm');
     $time = Pw::getTime();
     if ($loginUser->uid > 0) {
         $dm->setUid($loginUser->uid)->setUsername($loginUser->username)->setModifytime($time)->setCreatedtime($createdTime)->setGid($loginUser->gid)->setFid($this->getInput('fid', 'get'))->setRequest($request['mca']);
         Wekit::load('online.PwUserOnline')->replaceInfo($dm);
     } else {
         $dm->setIp($clientIp)->setCreatedtime($createdTime)->setModifytime($time)->setFid($this->getInput('fid', 'get'))->setTid($this->getInput('tid', 'get'))->setRequest($request['mca']);
         Wekit::load('online.PwGuestOnline')->replaceInfo($dm);
     }
 }
Esempio n. 18
0
 /**
  * 获取动他一下后台菜单
  *
  * @param array $config
  * @return array 
  */
 public function spaceButton($space)
 {
     echo '<a rel="nofollow" href="' . WindUrlHelper::createUrl('app/dongta/index/act') . '" class="message 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::V('url')->extres . '/dongta/js/dongta.js\');});</script>';
 }
Esempio n. 19
0
 public function doText($source, $water, $offsetX, $offsetY)
 {
     $R = hexdec(substr($this->fontcolor, 1, 2));
     $G = hexdec(substr($this->fontcolor, 3, 2));
     $B = hexdec(substr($this->fontcolor, 5));
     //imagestring($sourcedb['source'],$w_font,$wX,$wY,$w_text,imagecolorallocate($sourcedb['source'],$R,$G,$B));
     if (strpos($this->fontfamily, 'ch') === 0 && strtoupper(Wekit::V('charset')) != 'UTF-8') {
         $this->text = WindConvert::WindConvert($this->text, 'UTF-8', Wekit::V('charset'));
     }
     imagettftext($source, $this->fontsize, 0, $offsetX, $offsetY + $water->height, imagecolorallocate($source, $R, $G, $B), $this->fontfile, $this->text);
     unset($water);
     return $source;
 }
Esempio n. 20
0
 private function _saveVerifyCode()
 {
     Wind::import('LIB:utility.verifycode.PwBaseCode');
     $code = WindConvert::convert(PwBaseCode::getCode(), Wekit::V('charset'), 'UTF-8');
     $code = Pw::encrypt(strtolower($code), $this->_config['key']);
     //
     $verify_session_id = Pw::getCookie('Pw_verify_code');
     if (!$verify_session_id) {
         $verify_session_id = md5($code);
         Pw::setCookie('Pw_verify_code', md5($code), 3600);
     }
     //session 保存验证码
     Wind::import('WIND:http.session.WindSession');
     $session = new WindSession();
     $session->set('verifycode', $code);
 }
Esempio n. 21
0
 public function __construct()
 {
     $this->charset = Wekit::V('charset');
 }
Esempio n. 22
0
 /**
  * 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;
 }
Esempio n. 23
0
 /**
  * 替换敏感词
  * 
  * @param string $s  需要查找的文本
  * @return string $s 替换后的文本
  */
 public function replace($s)
 {
     $charset = Wekit::V('charset');
     $charset = str_replace('-', '', strtolower($charset));
     $isUTF8 = $charset == 'utf8' ? true : false;
     $ret = array();
     $cur = 0;
     //当前节点,初始为根节点
     $i = 0;
     //字符串当前偏移
     $p = 0;
     //字符串回溯位置
     $len = strlen($s);
     while ($i < $len) {
         $c = ord($s[$i]);
         if (isset($this->nodes[$cur][1][$c])) {
             //如果存在
             $cur = $this->nodes[$cur][1][$c];
             //下移当前节点
             if ($this->nodes[$cur][0]) {
                 //是叶子节点,单词匹配!
                 $s = substr_replace($s, $this->nodes[$cur][3], $p, $i - $p + 1);
                 //取出匹配位置和匹配的词以及词的权重
                 $p = $i + 1;
                 //设置下一个回溯位置
                 $cur = 0;
                 //重置当前节点为根节点
             }
             $i++;
             //下一个字符
         } else {
             //不匹配
             $cur = 0;
             //重置当前节点为根节点
             if (!$isUTF8 && ord($s[$p]) > 127 && ord($s[$p + 1]) > 127) {
                 $p += 2;
                 //设置下一个回溯位置
             } else {
                 $p += 1;
                 //设置下一个回溯位置
             }
             $i = $p;
             //把当前偏移设为回溯位置
         }
     }
     return $s;
 }
Esempio n. 24
0
File: Pw.php Progetto: healthguo/PHP
	/**
	 * 编码转换
	 *
	 * @param string $string 内容字符串
	 * @param string $fromEncoding 原编码
	 * @return string
	 */
	public static function convert($string, $toEncoding, $fromEncoding = '') {
		!$fromEncoding && $fromEncoding = Wekit::V('charset');
		return WindConvert::convert($string, $toEncoding, $fromEncoding);
	}
Esempio n. 25
0
 public function downloadAction()
 {
     $aid = (int) $this->getInput('aid', 'get');
     $submit = (int) $this->getInput('submit', 'post');
     $attach = Wekit::load('attach.PwThreadAttach')->getAttach($aid);
     if (!$attach) {
         $this->showError('BBS:thread.buy.attach.error');
     }
     Wind::import('SRV:forum.bo.PwForumBo');
     $forum = new PwForumBo($attach['fid']);
     if (!$forum->isForum()) {
         $this->showError('data.error');
     }
     if ($attach['cost'] && !$this->loginUser->isExists()) {
         $this->showError('download.fail.login.not', 'bbs/attach/download');
     }
     if (!$forum->allowDownload($this->loginUser)) {
         if (!$this->loginUser->isExists()) {
             $this->showError('download.fail.login.not', 'bbs/attach/download');
         }
         $this->showError(array('BBS:forum.permissions.download.allow', array('{grouptitle}' => $this->loginUser->getGroupInfo('name'))));
     }
     if (!$forum->foruminfo['allow_download'] && !$this->loginUser->getPermission('allow_download')) {
         if (!$this->loginUser->isExists()) {
             $this->showError('download.fail.login.not', 'bbs/attach/download');
         }
         $this->showError(array('permission.download.allow', array('{grouptitle}' => $this->loginUser->getGroupInfo('name'))));
     }
     Wind::import('SRV:credit.bo.PwCreditBo');
     $creditBo = PwCreditBo::getInstance();
     // 购买积分检查
     if (($attach = $this->_checkAttachCost($attach)) instanceof PwError) {
         $this->showError($attach->getError());
     }
     // 下载积分检查
     if (($reduceDownload = $this->_checkAttachDownload('download_att', $attach, $forum)) instanceof PwError) {
         $this->showError($reduceDownload->getError());
     }
     //下载积分提示
     $lang = Wind::getComponent('i18n');
     if (1 == $this->loginUser->getPermission('allow_download') && $reduceDownload && $attach['cost']) {
         $dataShow = $lang->getMessage('BBS:thread.attachbuy.message.all', array('{buyCount}' => -$attach['cost'] . $creditBo->cType[$attach['ctype']], '{downCount}' => rtrim($reduceDownload, ',')));
     } elseif (1 == $this->loginUser->getPermission('allow_download') && $reduceDownload && !$attach['cost']) {
         $dataShow = $lang->getMessage('BBS:thread.attachbuy.message.download', array('{downCount}' => rtrim($reduceDownload, ',')));
     } elseif ($attach['cost']) {
         $dataShow = $lang->getMessage('BBS:thread.attachbuy.message.buy', array('{count}' => $this->loginUser->getCredit($attach['ctype']) . $creditBo->cType[$attach['ctype']], '{buyCount}' => -$attach['cost'] . $creditBo->cType[$attach['ctype']]));
     } else {
         $dataShow = $lang->getMessage('BBS:thread.attachbuy.message.success');
     }
     !$submit && $this->showMessage($dataShow);
     //购买积分操作
     $this->_operateBuyCredit($attach);
     // 下载积分
     if ($reduceDownload) {
         Wind::import('SRV:attach.dm.PwThreadAttachBuyDm');
         $dm = new PwThreadAttachBuyDm();
         $dm->setAid($aid)->setCreatedUserid($this->loginUser->uid)->setCreatedTime(Pw::getTime())->setCtype($attach['ctype'])->setCost($attach['cost']);
         Wekit::load('attach.PwThreadAttachDownload')->add($dm);
         $this->_operateCredit('download_att', $forum);
     }
     //更新附件点击数
     Wind::import('SRV:attach.dm.PwThreadAttachDm');
     $dm = new PwThreadAttachDm($aid);
     $dm->addHits(1);
     Wekit::load('attach.PwThreadAttach')->updateAttach($dm);
     $filename = basename($attach['path']);
     $fileext = substr(strrchr($attach['path'], '.'), 1);
     $filesize = 0;
     if (strpos(Wind::getApp()->getRequest()->getServer('HTTP_USER_AGENT'), 'MSIE') !== false && $fileext == 'torrent') {
         $attachment = 'inline';
     } else {
         $attachment = 'attachment';
     }
     $attach['name'] = trim(str_replace('&nbsp;', ' ', $attach['name']));
     if (strtoupper(Wekit::V('charset')) == 'UTF-8') {
         $attach['name'] = Pw::convert($attach['name'], "gbk", 'utf-8');
     }
     $filesize = 0;
     $fgeturl = Wind::getComponent('storage')->getDownloadUrl($attach['path']);
     if (strpos($fgeturl, 'http') !== 0) {
         if (!is_readable($fgeturl)) {
             $this->showError('BBS:thread.buy.attach.error');
         }
         $filesize = filesize($fgeturl);
     }
     $timestamp = Pw::getTime();
     $ctype = '';
     switch ($fileext) {
         case "pdf":
             $ctype = "application/pdf";
             break;
         case "rar":
         case "zip":
             $ctype = "application/zip";
             break;
         case "doc":
             $ctype = "application/msword";
             break;
         case "xls":
             $ctype = "application/vnd.ms-excel";
             break;
         case "ppt":
             $ctype = "application/vnd.ms-powerpoint";
             break;
         case "gif":
             $ctype = "image/gif";
             break;
         case "png":
             $ctype = "image/png";
             break;
         case "jpeg":
         case "jpg":
             $ctype = "image/jpeg";
             break;
         case "wav":
             $ctype = "audio/x-wav";
             break;
         case "mpeg":
         case "mpg":
         case "mpe":
             $ctype = "video/x-mpeg";
             break;
         case "mov":
             $ctype = "video/quicktime";
             break;
         case "avi":
             $ctype = "video/x-msvideo";
             break;
         case "txt":
             $ctype = "text/plain";
             break;
         default:
             $ctype = "application/octet-stream";
     }
     ob_end_clean();
     header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $timestamp + 86400) . ' GMT');
     header('Expires: ' . gmdate('D, d M Y H:i:s', $timestamp + 86400) . ' GMT');
     header('Cache-control: max-age=86400');
     header('Content-Encoding: none');
     header("Content-Disposition: {$attachment}; filename=\"{$attach['name']}\"");
     header("Content-type: {$ctype}");
     header("Content-Transfer-Encoding: binary");
     $filesize && header("Content-Length: {$filesize}");
     $i = 1;
     while (!@readfile($fgeturl)) {
         if (++$i > 3) {
             break;
         }
     }
     exit;
 }
Esempio n. 26
0
 /**
  * 获得当前编码
  *
  * @return string
  */
 protected function _buildSecurity($content)
 {
     static $charset = '';
     if ($charset) {
         $charset = Wekit::V('charset') == 'GBK' ? 'ISO-8859-1' : Wekit::V('charset');
     }
     return WindSecurity::escapeHTML($content, $charset);
 }
Esempio n. 27
0
 public function runJs()
 {
     echo '<script>var URL_DONGTA = \'' . WindUrlHelper::createUrl('app/dongta/index/send') . '\';</script>';
     echo '<script src="' . Wekit::V('url')->extres . '/dongta/js/dongta.js"></script>';
 }