本文整理汇总了PHP中WindFile类的典型用法代码示例。如果您正苦于以下问题:PHP WindFile类的具体用法?PHP WindFile怎么用?PHP WindFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WindFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postUpload
protected function postUpload($tmp_name, $filename)
{
if (strpos($filename, '..') !== false || strpos($filename, '.php.') !== false || preg_match('/\\.php$/', $filename)) {
exit('illegal file type!');
}
WindFolder::mkRecur(dirname($filename));
if (function_exists("move_uploaded_file") && @move_uploaded_file($tmp_name, $filename)) {
@unlink($tmp_name);
@chmod($filename, 0777);
return filesize($filename);
} elseif (@copy($tmp_name, $filename)) {
@unlink($tmp_name);
@chmod($filename, 0777);
return filesize($filename);
} elseif (is_readable($tmp_name)) {
Wind::import('WIND:utility.WindFile');
WindFile::write($filename, WindFile::read($tmp_name));
@unlink($tmp_name);
if (file_exists($filename)) {
@chmod($filename, 0777);
return filesize($filename);
}
}
return false;
}
示例2: parse_properties_file
/**
* 解析properties文件并返回一个多维数组
*
* 载入一个由 filename 指定的 properties 文件,
* 并将其中的设置作为一个联合数组返回。
*
* @param string $filename 文件名
* @return array
*/
private function parse_properties_file($filename)
{
if (!is_file($filename) || !in_array(substr($filename, strrpos($filename, '.') + 1), array('properties'))) {
return array();
}
$content = explode("\n", WindFile::read($filename));
$data = array();
$last_process = $current_process = '';
foreach ($content as $key => $value) {
$value = str_replace(array("\n", "\r"), '', trim($value));
if (0 === strpos(trim($value), self::COMMENT) || in_array(trim($value), array('', "\t", "\n"))) {
continue;
}
$tmp = explode('=', $value, 2);
if (0 === strpos(trim($value), self::LPROCESS) && strlen($value) - 1 === strrpos($value, self::RPROCESS)) {
$current_process = $this->trimChar(trim($value), array(self::LPROCESS, self::RPROCESS));
$data[$current_process] = array();
$last_process = $current_process;
continue;
}
$tmp[0] = trim($tmp[0]);
if (count($tmp) == 1) {
$last_process ? $data[$last_process][$tmp[0]] = '' : ($data[$tmp[0]] = '');
continue;
}
$tmp[1] = trim($tmp[1], '\'"');
$__tmpValue = strtolower($tmp[1]);
$tmp[1] = 'false' === $__tmpValue ? false : ('true' === $__tmpValue ? true : $tmp[1]);
$last_process ? $data[$last_process][$tmp[0]] = $tmp[1] : ($data[$tmp[0]] = $tmp[1]);
}
return $data;
}
示例3: getTemplateFileContent
/**
* 获得模板文件内容,目前只支持本地文件获取
*
* @param string $templateFile
* @return string
*/
private function getTemplateFileContent($templateFile)
{
if (false === ($content = WindFile::read($templateFile))) {
throw new WindViewException('[viewer.AbstractWindViewTemplate.getTemplateFileContent] Unable to open the template file \'' . $templateFile . '\'.');
}
return $content;
}
示例4: _getMP3Audio
private static function _getMP3Audio()
{
self::$_audioVerify = '';
$_len = Pw::strlen(self::$verifyCode);
for ($i = 0; $i < $_len; $i++) {
$_code = strtoupper(self::$verifyCode[$i]);
self::$_audioVerify .= WindFile::read(self::$_audioPath . '/' . $_code . '.mp3', WindFile::READ);
}
}
示例5: uploadRequest
public static function uploadRequest($url, $file, $timeout = 30)
{
if (!function_exists('fsockopen')) {
$urlArr = parse_url($url);
$port = isset($urlArr['port']) ? $urlArr['port'] : 80;
$boundary = "---------------------" . substr(md5(rand(0, 32000)), 0, 10);
$header = "POST " . $urlArr['path'] . '?' . $urlArr['query'] . " HTTP/1.0\r\n";
$header .= "Host: " . $urlArr['host'] . "\r\n";
$header .= "Content-type: multipart/form-data, boundary=" . $boundary . "\r\n";
if (!file_exists($file)) {
return false;
}
$imageInfo = @getimagesize($file);
$exts = array('1' => 'gif', '2' => 'jpg', '3' => 'png');
if (!isset($exts[$imageInfo[2]])) {
continue;
}
$ext = $exts[$imageInfo[2]];
$filename = rand(1000, 9999) . '.' . $ext;
$data = '';
$data .= "--{$boundary}\r\n";
$data .= "Content-Disposition: form-data; name=\"FileData\"; filename=\"" . $filename . "\"\r\n";
$data .= "Content-Type: " . $imageInfo['mime'] . "\r\n\r\n";
$data .= WindFile::read($file) . "\r\n";
$data .= "--{$boundary}--\r\n";
$header .= "Content-length: " . strlen($data) . "\r\n\r\n";
$fp = fsockopen($urlArr['host'], $port);
fputs($fp, $header . $data);
$response = '';
while (!feof($fp)) {
$response .= fgets($fp, 128);
}
fclose($fp);
preg_match("/Content-Length:.?(\\d+)/", $response, $matches);
if (isset($matches[1])) {
$response = substr($response, strlen($response) - intval($matches[1]));
}
return $response;
} elseif (function_exists('curl_init')) {
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $file);
curl_setopt($curl, CURLOPT_TIMEOUT, $timeout);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
curl_close($curl);
return $response;
} else {
return false;
}
}
示例6: save
/**
* 存储附件,如果是远程存储,记得删除本地文件
*
* @param string $source 本地源文件地址
* @param string $filePath 存储相对位置
* @return bool
*/
public function save($source, &$filePath)
{
$data = WindFile::read($source);
$stuff = WindFile::getSuffix($source);
$result = $this->_getCdn()->write($data, $stuff);
if ($result) {
Pw::deleteFile($source);
$filePath = $result;
return true;
} else {
return false;
}
}
示例7: packFromFileList
/**
* 将给出的文件列表进行打包
*
* @param mixed $fileList 文件列表
* @param string $dst 打包文件的存放位置
* @param method $packMethod 打包的方式,默认为stripWhiteSpaceByPhp
* @param boolean $compress 打包是否采用压缩的方式,默认为true
* @return boolean
*/
public function packFromFileList($fileList, $dst, $packMethod = WindPack::STRIP_PHP, $compress = true)
{
if (empty($dst) || empty($fileList)) {
return false;
}
$content = array();
$this->readContentFromFileList($fileList, $packMethod, $content);
$replace = $compress ? ' ' : "\n";
$content = implode($replace, $content);
$content = $this->callBack($content, $replace);
$content = $this->stripNR($content, $replace);
$content = $this->stripPhpIdentify($content, '');
return WindFile::write($dst, '<?php' . $replace . $content . '?>');
}
示例8: compile
/**
* 编译模板并返回编译后模板地址及内容
*
* <pre>
* <i>$output==true</i>返回编译文件绝对路径地址和内容,不生成编译文件;
* <i>$output==false</i>返回编译文件绝对路径地址和内容,生成编译文件
* </pre>
*
* @param string $template 模板名称 必填
* @param string $suffix 模板后缀 默认为空
* @param boolean $readOnly 是否直接输出模板内容,接受两个值true,false 默认值为false
* @param boolean $forceOutput 是否强制返回模板内容,默认为不强制
* @return array(compileFile,content) <pre>
* <i>compileFile</i>模板编译文件绝对地址,
* <i>content</i>编译后模板输出内容,当<i>$output</i>
* 为false时将content写入compileFile</pre>
*/
public function compile($template, $suffix = '', $readOnly = false, $forceOutput = false)
{
$templateFile = $this->windView->getViewTemplate($template, $suffix);
if (!is_file($templateFile)) {
throw new WindViewException('[component.viewer.WindViewerResolver.compile] ' . $templateFile, WindViewException::VIEW_NOT_EXIST);
}
$compileFile = $this->windView->getCompileFile($template);
if (!$this->checkReCompile($templateFile, $compileFile)) {
return array($compileFile, $forceOutput ? WindFile::read($compileFile) : '');
}
/* @var $_windTemplate WindViewTemplate */
$_windTemplate = Wind::getApp()->getComponent('template');
$_output = $_windTemplate->compile($templateFile, $this);
$readOnly === false && WindFile::write($compileFile, $_output);
return array($compileFile, $_output);
}
示例9: compile
/**
* 编译模板并返回编译后模板地址及内容
* <pre>
* <i>$output==true</i>返回编译文件绝对路径地址和内容,不生成编译文件;
* <i>$output==false</i>返回编译文件绝对路径地址和内容,生成编译文件
* </pre>
*
* @param string $template 模板名称 必填
* @param string $suffix 模板后缀 默认为空
* @param boolean $readOnly 是否直接输出模板内容,接受两个值true,false 默认值为false
* @param boolean $forceOutput 是否强制返回模板内容,默认为不强制
* @return array(compileFile,content) <pre>
* <i>compileFile</i>模板编译文件绝对地址,
* <i>content</i>编译后模板输出内容,当<i>$output</i>
* 为false时将content写入compileFile</pre>
*/
public function compile($template, $suffix = '', $readOnly = false, $forceOutput = false)
{
list($templateFile, $compileFile, $this->currentThemeKey) = $this->windView->getViewTemplate($template, $suffix);
if (!is_file($templateFile)) {
throw new WindViewException('[viewer.resolver.WindViewerResolver.compile] ' . $templateFile, WindViewException::VIEW_NOT_EXIST);
}
if (!$this->checkReCompile($templateFile, $compileFile)) {
return array($compileFile, $forceOutput || $readOnly ? WindFile::read($compileFile) : '');
}
/* @var $_windTemplate WindViewTemplate */
$_windTemplate = Wind::getComponent('template');
$_output = $_windTemplate->compile($templateFile, $this);
if (false === $readOnly) {
WindFolder::mkRecur(dirname($compileFile));
WindFile::write($compileFile, $_output);
}
return array($compileFile, $_output);
}
示例10: isMyBrother
/**
* 判断是否是子域名
*
* 此方法不够严谨,如果遇到主域名正好就是域名后缀的时候,类似www.info.com,www.net.cn时有bug。
*
* @param string $domain1
* @param string $domain2
*/
public static function isMyBrother($domain1, $domain2)
{
if ($domain1 == $domain2) {
return true;
}
if (WindFile::getSuffix($domain1) != WindFile::getSuffix($domain2)) {
return false;
}
$domain1 = str_replace(array('http://'), 'https://', $domain1);
$domain2 = str_replace(array('http://'), 'https://', $domain2);
$suffix = array('com', 'cn', 'name', 'org', 'net', 'edu', 'gov', 'info', 'pro', 'museum', 'coop', 'aero', 'xxx', 'idv', 'hk', 'tw', 'mo', 'me', 'biz');
$preg = implode('|', $suffix);
$domain1 = preg_replace("/(\\.({$preg}))*\\.({$preg})\$/iU", '', $domain1);
$domain2 = preg_replace("/(\\.({$preg}))*\\.({$preg})\$/iU", '', $domain2);
$r = explode('.', $domain1);
$main1 = end($r);
$r = explode('.', $domain2);
$main2 = end($r);
return $main1 == $main2;
}
示例11: _doCss
/**
* @param string $stylePackage
* @param booelan $isManifestChanged
* @return boolean
*/
private function _doCss($stylePackage)
{
$file = $stylePackage . '/' . $this->manifest;
$dir = $stylePackage . '/' . $this->cssDevDir;
$_dir = $stylePackage . '/' . $this->cssDir;
WindFolder::mkRecur($_dir);
$files = WindFolder::read($dir, WindFolder::READ_FILE);
foreach ($files as $v) {
if (WindFile::getSuffix($v) === 'css') {
$dev_css = $dir . '/' . $v;
//待编译文件
$css = $_dir . '/' . $v;
//编译后文件
$data = WindFile::read($dir . '/' . $v);
$_data = $this->_compress($data);
if (WindFile::write($css, $_data) === false) {
return new PwError('STYLE:style.css.write.fail');
}
}
}
return true;
}
示例12: doCompile
public function doCompile()
{
$JS_DEV_PATH = Wind::getRealDir('PUBLIC:res.js.dev');
$JS_BUILD_PATH = Wind::getRealDir('PUBLIC:res.js.build');
Wind::import('Wind:utility.WindFolder');
$files = $this->_getFiles($JS_DEV_PATH);
foreach ($files as $file) {
$newfile = $JS_BUILD_PATH . substr($file, strlen($JS_DEV_PATH));
WindFolder::mkRecur(dirname($newfile));
if (substr($file, -3) != '.js') {
if (!copy($file, $newfile)) {
return new PwError('copy failed');
}
continue;
}
$content = WindFile::read($file);
$compress = jscompress::pack($content);
if (!WindFile::write($newfile, $compress)) {
return new PwError('write failed');
}
}
}
示例13: getUnInstalledThemes
/**
* 查找未安装的风格
*
* @return array 未安装的风格名
*/
public function getUnInstalledThemes()
{
$config = Wekit::load('APPCENTER:service.srv.PwInstallApplication')->getConfig('style-type');
$themes = array();
foreach ($config as $k => $v) {
$dir = Wind::getRealDir('THEMES:' . $v[1]);
$files = WindFolder::read($dir, WindFolder::READ_DIR);
foreach ($files as $file) {
if (WindFile::isFile($dir . '/' . $file . '/' . $this->manifest)) {
$themes[$k][] = $file;
}
}
}
if (empty($themes)) {
return array();
}
$styles = array();
foreach ($themes as $k => $v) {
$r = $this->_styleDs()->fetchStyleByAliasAndType($v, $k, 'alias');
$r = array_diff($v, array_keys($r));
$r && ($styles[$k] = $r);
}
return $styles;
}
示例14: checkTxt
public function checkTxt($filename = '', $content = '')
{
if (!$filename && !$content) {
return new PwError("DESIGN:upload.file.error");
}
if ($filename) {
if (!($content = WindFile::read($filename))) {
return new PwError("DESIGN:upload.file.error");
}
}
$content = preg_replace("/\\/\\*(.+)\\*\\//", '', $content);
$content = unserialize(base64_decode($content));
$_array = array('page', 'segment', 'structure', 'module');
foreach ($_array as $v) {
if (!isset($content[$v])) {
return new PwError("DESIGN:file.check.fail");
}
}
$this->_content = $content;
if ($filename) {
WindFile::del($filename);
}
return true;
}
示例15: _getTemplate
private function _getTemplate($path)
{
list($tpl, $compile) = $this->windViewerResolver->getWindView()->getViewTemplate($path);
if (!$tpl) {
return '';
}
return WindFile::read($tpl);
}