Esempio n. 1
0
 /**
  * 存储附件,如果是远程存储,记得删除本地文件
  *
  * @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;
     }
 }
Esempio n. 2
0
 /**
  * 判断是否是子域名
  *
  * 此方法不够严谨,如果遇到主域名正好就是域名后缀的时候,类似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;
 }
Esempio n. 3
0
 /**
  * @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;
 }
Esempio n. 4
0
 /**
  * 根据文件获得文件访问的模式
  * 
  * @param string $filename 文件名
  * @param string $mode 模式,二进制还是ASCII上传,I为二进制模式,A为ASCII模式,默认为A模式,如果是auto将会根据文件后缀来设置模式
  * @return string 返回模式方式FTP_ASCII或是FTP_BINARY
  */
 private function getMode($filename, $mode)
 {
     if (strcasecmp($mode, 'auto') == 0) {
         $ext = WindFile::getSuffix($filename);
         $mode = in_array(strtolower($ext), array('txt', 'text', 'php', 'phps', 'php4', 'js', 'css', 'htm', 'html', 'phtml', 'shtml', 'log', 'xml')) ? 'A' : 'I';
     }
     return $mode == 'A' ? FTP_ASCII : FTP_BINARY;
 }