/** * 根据当前版本+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'] : '无法连接云平台!'; }
/** * 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::app()->charset; } strncasecmp($charset, 'utf', 3) && ($manifest = WindConvert::convert($manifest, $charset, 'utf-8')); $this->manifest = $manifest; }
private function _conv($array, $fromCharset, $toCharset) { if (!is_array($array)) { return WindConvert::convert($array, $toCharset, $fromCharset); } foreach ($array as $k => $v) { if (is_array($v)) { $array[$k] = $this->_conv($v, $fromCharset, $toCharset); } $array[$k] = WindConvert::convert($v, $toCharset, $fromCharset); } return $array; }
/** * ajax递交编码转换 */ private function _convertCharsetForAjax() { if (!Wind::getApp()->getRequest()->getIsAjaxRequest()) { return; } $toCharset = Wind::getApp()->getResponse()->getCharset(); if (strtoupper(substr($toCharset, 0, 2)) != 'UT') { $_tmp = array(); foreach ($_POST as $key => $value) { $key = WindConvert::convert($key, $toCharset, 'UTF-8'); $_tmp[$key] = WindConvert::convert($value, $toCharset, 'UTF-8'); } $_POST = $_tmp; } }
protected function forceDownload($string, $filename, $ext = 'txt', $charset = 'utf-8') { $router = Wind::getComponent('router'); $filename = WindConvert::convert($filename, 'gbk', Wekit::app()->charset); //ie fixed $filename .= '.' . $ext; //ob_end_clean(); header('Content-Encoding: none'); header("Content-type: application/octet-stream"); header('Content-type: text/html; charset=' . $charset . ''); header("Accept-Ranges: bytes"); header("Accept-Length: " . WindString::strlen($string, $charset)); header("Content-Disposition: attachment; filename=" . $filename); echo $string; //@flush(); //@ob_flush(); exit; }
public function zip($charset = 'utf-8') { Wind::import('LIB:utility.PwZip'); $zip = new PwZip(); $files = $this->read($this->dir); $fromCharset = Wekit::app()->charset; foreach ($files as &$v) { $v['filename'] = str_replace($this->dir, '', $v['filename']); $ext = strrchr($v['filename'], "."); if ($ext != $this->_tplExt) { continue; } //$v['data'] = $this->decompilePw($v['data']); $v['data'] = $this->decompileTitle($v['data']); //$v['data'] = $this->decompileList($v['data']); $v['data'] = $this->decompileTpl($v['data']); $v['data'] = $this->decompileStyle($v['data']); } foreach ($files as $file) { if ($file['filename'] == 'module/data.txt') { continue; } if (strtolower($file['filename']) == 'manifest.xml') { Wind::import("WIND:parser.WindXmlParser"); $xml = new WindXmlParser('1.0', $fromCharset); $config = $xml->parseXmlStream($file['data'], 0); unset($config['module']); $file['data'] = $this->xmlFormat($config, $charset); } else { $ext = strtolower(substr(strrchr($file['filename'], '.'), 1)); if (in_array($ext, array('css', 'js', 'htm'))) { $file['data'] = WindConvert::convert($file['data'], $charset, $fromCharset); } } $file['filename'] = $this->folder . '/' . $file['filename']; if (!$zip->addFile($file['data'], $file['filename'])) { return new PwError("DESIGN:zlib.error"); } } $txt = $this->doTxt($charset); $txtfile = $this->folder . '/module/data.txt'; $zip->addFile($txt['content'], $txtfile); return $zip->getCompressedFile(); }
public function doavatarAction() { $uid = (int) $this->getInput('uid', 'get'); Wind::import('WINDID:service.upload.action.WindidAvatarUpload'); Wind::import('WINDID:service.upload.WindidUpload'); $bhv = new WindidAvatarUpload($uid); $upload = new WindidUpload($bhv); if (($result = $upload->check()) === true) { $result = $upload->execute(); } if ($result !== true) { $array = array("isSuccess" => false, "msg" => WindConvert::convert('上传失败', 'utf8', Wekit::app()->charset), "erCode" => "000"); //$this->showMessage($result->getMessage()); } else { //用户上传头像之后的钩子 PwSimpleHook::getInstance('update_avatar')->runDo($uid); $array = array("isSuccess" => true, "msg" => WindConvert::convert('上传成功', 'utf8', Wekit::app()->charset), "erCode" => "000"); } echo WindJson::encode($array, Windid::client()->clientCharser); exit; }
/** * 获取线上补丁列表 * * @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; }
public function beforeAction($handlerAdapter) { if ('finish' != $handlerAdapter->getAction()) { Wekit::createapp('install'); } //ajax递交编码转换 if ($this->getRequest()->getIsAjaxRequest()) { $toCharset = $this->getResponse()->getCharset(); if (strtoupper(substr($toCharset, 0, 2)) != 'UT') { $_tmp = array(); foreach ($_POST as $key => $value) { $key = WindConvert::convert($key, $toCharset, 'UTF-8'); $_tmp[$key] = WindConvert::convert($value, $toCharset, 'UTF-8'); } $_POST = $_tmp; } } $_consts = (include Wind::getRealPath('CONF:publish.php', true)); foreach ($_consts as $const => $value) { if (defined($const)) { continue; } if ($const === 'PUBLIC_URL' && !$value) { $value = Wind::getApp()->getRequest()->getBaseUrl(true); } define($const, $value); } $url = array(); $url['base'] = PUBLIC_URL; $url['res'] = WindUrlHelper::checkUrl(PUBLIC_RES, PUBLIC_URL); $url['css'] = WindUrlHelper::checkUrl(PUBLIC_RES . '/css/', PUBLIC_URL); $url['images'] = WindUrlHelper::checkUrl(PUBLIC_RES . '/images/', PUBLIC_URL); $url['js'] = WindUrlHelper::checkUrl(PUBLIC_RES . '/js/dev/', PUBLIC_URL); $url['attach'] = WindUrlHelper::checkUrl(PUBLIC_ATTACH, PUBLIC_URL); Wekit::setGlobal($url, 'url'); $this->setOutput(NEXT_VERSION, 'wind_version'); WindFile::isFile($this->_getInstallLockFile()) && $this->showError('INSTALL:have_install_lock'); }
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; }
/** * 将一个数组转换为xml * * @param array $arr 待转换的数组 * @param string $charset 编码 * @param DOMDocument $dom 根节点 * @return DOMDocument */ protected function arrayToXml($arr, $charset, $dom = null) { foreach ($arr as $key => $val) { if (is_numeric($key)) { $itemx = $this->dom->createElement("item"); $id = $this->dom->createAttribute("id"); $id->appendChild($this->dom->createTextNode($key)); $itemx->appendChild($id); } else { $itemx = $this->dom->createElement($key); } $dom->appendChild($itemx); if (is_string($val)) { $val = WindConvert::convert($val, 'utf8', $charset); $itemx->appendChild($this->dom->createTextNode($val)); } elseif (is_object($val)) { $this->arrayToXml(get_object_vars($val), $charset, $itemx); } else { $this->arrayToXml($val, $charset, $itemx); } } }
/** * 将字符串转化成json格式对象 * * @param string $string * @return string */ protected static function stringToJson($string) { $ascii = ''; $strlen = strlen($string); for ($c = 0; $c < $strlen; ++$c) { $b = $string[$c]; $ordVar = ord($string[$c]); if (0x8 == $ordVar) { $ascii .= '\\b'; } elseif (0x9 == $ordVar) { $ascii .= '\\t'; } elseif (0xa == $ordVar) { $ascii .= '\\n'; } elseif (0xc == $ordVar) { $ascii .= '\\f'; } elseif (0xd == $ordVar) { $ascii .= '\\r'; } elseif (in_array($ordVar, array(0x22, 0x2f, 0x5c))) { $ascii .= '\\' . $string[$c]; } elseif (0x20 <= $ordVar && 0x7f >= $ordVar) { $ascii .= $string[$c]; //ASCII } elseif (0xc0 == ($ordVar & 0xe0)) { $char = pack('C*', $ordVar, ord($string[++$c])); $ascii .= sprintf('\\u%04s', bin2hex(WindConvert::utf8ToUTF16BE($char))); } elseif (0xe0 == ($ordVar & 0xf0)) { $char = pack('C*', $ordVar, ord($string[++$c]), ord($string[++$c])); $ascii .= sprintf('\\u%04s', bin2hex(WindConvert::utf8ToUTF16BE($char))); } elseif (0xf0 == ($ordVar & 0xf8)) { $char = pack('C*', $ordVar, ord($string[++$c]), ord($string[++$c]), ord($string[++$c])); $ascii .= sprintf('\\u%04s', bin2hex(WindConvert::utf8ToUTF16BE($char))); } elseif (0xf8 == ($ordVar & 0xfc)) { $char = pack('C*', $ordVar, ord($string[++$c]), ord($string[++$c]), ord($string[++$c]), ord($string[++$c])); $ascii .= sprintf('\\u%04s', bin2hex(WindConvert::utf8ToUTF16BE($char))); } elseif (0xfc == ($ordVar & 0xfe)) { $char = pack('C*', $ordVar, ord($string[++$c]), ord($string[++$c]), ord($string[++$c]), ord($string[++$c]), ord($string[++$c])); $ascii .= sprintf('\\u%04s', bin2hex(WindConvert::utf8ToUTF16BE($char))); } } return '"' . $ascii . '"'; }
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);*/ }
/** * 编码转换 * * @param string $string 内容字符串 * @param string $fromEncoding 原编码 * @return string */ public static function convert($string, $toEncoding, $fromEncoding = '') { !$fromEncoding && ($fromEncoding = Wekit::app()->charset); return WindConvert::convert($string, $toEncoding, $fromEncoding); }
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); }
/** * @see PwUploadAction.update */ public function update($uploaddb) { $srv = Wekit::load('attach.PwThreadAttach'); foreach ($uploaddb as $key => $value) { $value['name'] = WindConvert::convert($value['name'], Wind::getApp()->getResponse()->getCharset(), 'utf-8'); $att = new PwThreadAttachDm(); $att->setName($value['name']); $att->setType($value['type']); $att->setSize($value['size']); $att->setPath($value['fileuploadurl']); $att->setIfthumb($value['ifthumb']); $att->setCreatedUser($this->user->uid); $att->setCreatedTime(Pw::getTime()); if ($value['thumb'] && $value['thumb'][0]) { $att->setWidth($value['thumb'][0][2]); $att->setHeight($value['thumb'][0][3]); } $att->setApp('thread'); $aid = $srv->addAttach($att); $this->attachs[$aid] = array('aid' => $aid, 'name' => $value['name'], 'type' => $value['type'], 'path' => $value['fileuploadurl'], 'size' => $value['size'], 'descrip' => $value['descrip'], 'ifthumb' => $value['ifthumb']); } return true; }
/** * 编码转换 * * @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); }
private function _creatDom($root, $dom, $array) { $charset = strtolower(Wind::getApp()->getResponse()->getCharset()); $charset = $charset == 'gbk' ? 'gb2312' : 'utf-8'; foreach ($array as $k => $v) { if (is_numeric($k)) { $child = $dom->createElement('item'); } else { $child = $dom->createElement($k); } $root->appendChild($child); if (!is_array($v)) { $v = WindConvert::convert($v, 'utf8', $charset); $child->appendChild($dom->createTextNode($v)); } else { $this->_creatDom($child, $dom, $v); } } }