コード例 #1
0
ファイル: WindFile.php プロジェクト: jellycheng/windframework
 /**
  * 保存文件
  * 
  * @param string $fileName          保存的文件名
  * @param mixed $data               保存的数据
  * @param boolean $isBuildReturn    是否组装保存的数据是return $params的格式,如果没有则以变量声明的方式保存,默认为true则以return的方式保存
  * @param string $method            打开文件方式,默认为rb+的形式
  * @param boolean $ifLock           是否对文件加锁,默认为true即加锁
  */
 public static function savePhpData($fileName, $data, $isBuildReturn = true, $method = self::READWRITE, $ifLock = true)
 {
     $temp = "<?php\r\n ";
     if (!$isBuildReturn && is_array($data)) {
         foreach ($data as $key => $value) {
             if (!preg_match('/^\\w+$/', $key)) {
                 continue;
             }
             $temp .= "\$" . $key . " = " . WindString::varToString($value) . ";\r\n";
         }
         $temp .= "\r\n?>";
     } else {
         $isBuildReturn && ($temp .= " return ");
         $temp .= WindString::varToString($data) . ";\r\n?>";
     }
     return self::write($fileName, $temp, $method, $ifLock);
 }
コード例 #2
0
 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;
 }
コード例 #3
0
 /**
  * 从下一行记录中获得下标是$index的值,如果获取失败则返回false
  * 
  * @param int $index 列下标
  * @return string|bool
  */
 public function fetchColumn($index = 0)
 {
     $result = $this->_statement->fetchColumn($index);
     if (WIND_DEBUG & 2) {
         Wind::getApp()->getComponent('windLogger')->info("[component.db.WindResultSet.fetchColumn] \r\n\tResult:" . WindString::varToString($result));
     }
     return $result;
 }
コード例 #4
0
 /**
  * 检查消息内容
  *
  * @return bool
  */
 private function checkContent()
 {
     $len = WindString::strlen($this->_data['content']);
     if (!$this->_data['content'] || $len > 500) {
         return new WindidError(WindidError::MESSAGE_CONTENT_LENGTH_ERROR);
     }
     return true;
 }
コード例 #5
0
ファイル: Windid.php プロジェクト: fanqimeng/4tweb
 public static function substrs($string, $length, $start = 0, $dot = false)
 {
     return WindString::substr($string, $start, $length, self::client()->clientCharser);
 }
コード例 #6
0
ファイル: Pw.php プロジェクト: healthguo/PHP
	/**
	 * 字符串截取
	 *
	 * @param string $string
	 * @param int $length
	 * @param int $start
	 * @param bool $dot
	 */
	public static function substrs($string, $length, $start = 0, $dot = true) {
		if (self::strlen($string) <= $length) return $string;
		return WindString::substr($string, $start, $length, Wekit::V('charset'), $dot);
	}
コード例 #7
0
 /**
  * 根据现有目录结构调整升级包目录
  *
  * @param array $fileList        	
  */
 public function sortDirectory($fileList)
 {
     $this->_log('start to sort the directory');
     $sourceDir = $this->tmpPath . DIRECTORY_SEPARATOR . $this->target;
     $directoryFile = $sourceDir . DIRECTORY_SEPARATOR . 'conf/directory.php';
     $directory = @(include $directoryFile);
     if (!is_array($directory)) {
         return new PwError('APPCENTER:upgrade.directory.fail');
     }
     $this->_log('the remote directory is:' . var_export($directory, true));
     $root = Wind::getRealDir('ROOT:');
     $sort = array('TPL', 'THEMES', 'ACLOUD', 'WINDID', 'REP', 'SRV', 'LIB', 'HOOK', 'EXT', 'APPS', 'CONF', 'DATA', 'SRC', 'PUBLIC');
     $strtr = array();
     $localDirectory = @(include Wind::getRealPath('CONF:directory.php', true));
     foreach ($sort as $v) {
         if ($directory[$v] == $localDirectory[$v]) {
             continue;
         }
         $search = PwSystemHelper::relative(WEKIT_PATH . str_replace('/', DIRECTORY_SEPARATOR, $directory[$v]));
         $strtr[rtrim($search, '/\\')] = rtrim(Wind::getRootPath($v), '/\\');
     }
     $this->_log('way of moving directory' . var_export($strtr, true));
     if (!($sourceMd5 = WindFile::read($sourceDir . DIRECTORY_SEPARATOR . 'conf/md5sum'))) {
         return new PwError('APPCENTER:upgrade.target.hash.fail');
     }
     $sourceMd5 = PwSystemHelper::resolveMd5($sourceMd5);
     // md5sum
     $data = '';
     foreach ($sourceMd5 as $v => $md5) {
         $v = trim($v, '/');
         $v = str_replace('/', DIRECTORY_SEPARATOR, $v);
         $_v = ROOT_PATH . $v;
         $file = $v;
         foreach ($strtr as $search => $replace) {
             if (0 === strpos($_v, $search)) {
                 $file = str_replace(ROOT_PATH, '', $replace . substr($_v, strlen($search)));
                 $file = str_replace('//', '/', $file);
                 break;
             }
         }
         $data .= PwSystemHelper::md5content($md5, $file);
     }
     WindFile::write($sourceDir . DIRECTORY_SEPARATOR . 'conf/md5sum', $data);
     $moveList = $newFileList = array();
     $url = PwApplicationHelper::acloudUrl(array('a' => 'forward', 'do' => 'getVersionHash', 'pwversion' => $this->local));
     /* 从线上获取当前版本的所有文件md5 */
     /* $result = PwApplicationHelper::requestAcloudData($url);
     		if ($result['code'] !== '0' || !$result['info']) return new PwError(array('APPCENTER:upgrade.version.hash.fail', array($result['msg']))); */
     if (!($tmp = WindFile::read(CONF_PATH . 'md5sum'))) {
         return new PwError('APPCENTER:upgrade.hash.fail');
     }
     $md5List = PwSystemHelper::resolveMd5($tmp);
     $this->_log('obtain the md5 list of current version');
     foreach ($fileList as $v) {
         $v = trim($v, '/');
         $v = str_replace('/', DIRECTORY_SEPARATOR, $v);
         $_v = $root . $v;
         $file = $v;
         foreach ($strtr as $search => $replace) {
             if (0 === strpos($_v, $search)) {
                 $file = str_replace($root, '', $replace . substr($_v, strlen($search)));
                 $file = str_replace('//', '/', $file);
                 $moveList[$v] = $file;
                 break;
             }
         }
         $newFileList[$file] = $md5List[str_replace(DIRECTORY_SEPARATOR, '/', $file)];
     }
     $this->_log('files need to move ' . var_export($moveList, true));
     $relativePath_1 = PwSystemHelper::resolveRelativePath(PUBLIC_PATH, Wind::getRealPath('SRC:wekit'));
     $relativePath_2 = PwSystemHelper::resolveRelativePath(PUBLIC_PATH . 'aCloud', Wind::getRealPath('SRC:wekit'));
     foreach ($moveList as $old => $new) {
         WindFolder::mkRecur(dirname($sourceDir . DIRECTORY_SEPARATOR . $new));
         copy($sourceDir . DIRECTORY_SEPARATOR . $old, $sourceDir . DIRECTORY_SEPARATOR . $new);
         WindFile::del($sourceDir . DIRECTORY_SEPARATOR . $old);
         if ('.php' === substr($old, -4) && !strncasecmp($old, 'www' . DIRECTORY_SEPARATOR, 4)) {
             $content = WindFile::read($sourceDir . DIRECTORY_SEPARATOR . $new);
             if (strpos($content, '../../src/wekit.php')) {
                 $content = str_replace('../../src/wekit.php', $relativePath_2, $content);
             } else {
                 $content = str_replace('../src/wekit.php', $relativePath_1, $content);
             }
             // $content = str_replace('../src/wekit.php',
             // Wind::getRealPath('SRC:wekit'), $content);
             WindFile::write($sourceDir . DIRECTORY_SEPARATOR . $new, $content);
         }
     }
     // 目录文件
     if ($directory != $localDirectory) {
         $directory = array_merge($directory, $localDirectory);
         $temp = "<?php\r\n defined('WEKIT_VERSION') or exit(403);\r\n return ";
         $temp .= WindString::varToString($directory) . ";\r\n?>";
         WindFile::write($directoryFile, $temp);
     }
     Wekit::cache()->set('system_upgrade_replace', 1);
     return $newFileList;
 }
コード例 #8
0
ファイル: WindidUserValidator.php プロジェクト: ccq18/EduSoho
 /**
  * 用户名长度是否有效
  *
  * @param string $username 判断的长度
  * @param string $charset
  * @return boolean
  */
 private static function isNameLenValid($username, $charset = 'utf8')
 {
     Wind::import('WIND:utility.WindString');
     $len = WindString::strlen($username, $charset);
     return $len > self::getConfig('security.username.max') || $len < self::getConfig('security.username.min');
 }
コード例 #9
0
 /**
  * 验证字符串的长度
  * 
  * @param string $string 要验证的字符串
  * @param string $length 指定的合法的长度
  * @param string $charset 字符编码默认为utf-8编码
  * @return boolean 如果长度大于给定的长度则返回true,否则返回false
  */
 public static function isLegalLength($string, $length, $charset = 'utf8')
 {
     Wind::import('WIND:utility.WindString');
     return WindString::strlen($string, $charset) > (int) $length;
 }
コード例 #10
0
ファイル: compile.php プロジェクト: jellycheng/windframework
function addImports()
{
    $_content = WindString::varToString($GLOBALS['imports']);
    $_content = str_replace(array("\r\n", "\t", " "), '', $_content);
    return 'Wind::setImports(' . $_content . ');';
}
コード例 #11
0
 /**
  * 向打包好的文件头部注入 import 信息
  */
 public function injectionImports()
 {
     $_content = WindString::varToString($this->imports);
     $_content = str_replace(array("\r\n", "\t", " "), '', $_content);
     return 'Wind::$_imports += ' . $_content . ';';
 }
コード例 #12
0
ファイル: WindError.php プロジェクト: ccq18/EduSoho
 /**
  *
  * @param array $call
  * @return string
  */
 private function _getCallLine($call)
 {
     $call_signature = "";
     if (isset($call['file'])) {
         $call_signature .= $call['file'] . " ";
     }
     if (isset($call['line'])) {
         $call_signature .= "(" . $call['line'] . ") ";
     }
     if (isset($call['function'])) {
         $call_signature .= $call['function'] . "(";
         if (isset($call['args'])) {
             foreach ($call['args'] as $arg) {
                 if (is_string($arg)) {
                     $arg = '"' . (strlen($arg) <= 64 ? $arg : substr($arg, 0, 64) . "…") . '"';
                 } else {
                     if (is_object($arg)) {
                         $arg = "" . get_class($arg) . "";
                     } else {
                         if ($arg === true) {
                             $arg = "true";
                         } else {
                             if ($arg === false) {
                                 $arg = "false";
                             } else {
                                 if ($arg === null) {
                                     $arg = "null";
                                 } else {
                                     if (is_array($arg)) {
                                         $arg = WindString::varToString($arg);
                                     } else {
                                         $arg = strval($arg);
                                     }
                                 }
                             }
                         }
                     }
                 }
                 $call_signature .= $arg . ',';
             }
         }
         $call_signature = trim($call_signature, ',') . ")";
     }
     return $call_signature;
 }
コード例 #13
0
 /**
  * 执行一条sql语句 同时返回影响行数
  * 
  * @param string $sql sql语句
  * @return int
  */
 public function execute($sql)
 {
     try {
         $result = $this->getDbHandle()->exec($this->parseQueryString($sql));
         if (WIND_DEBUG & 2) {
             Wind::getApp()->getComponent('windLogger')->info("[db.WindConnection.execute] \r\n\tSQL: " . $sql . " \r\n\tResult:" . WindString::varToString($result));
         }
         return $result;
     } catch (PDOException $e) {
         $this->close();
         throw new WindDbException($e->getMessage());
     }
 }
コード例 #14
0
ファイル: PwGDCode.php プロジェクト: latticet/EduSoho_jb51
 private static function _writeImage()
 {
     for ($i = 0; $i < self::$_codeLen; $i++) {
         //$_text = Pw::substrs(self::$verifyCode, 1, $i, false);
         $_text = WindString::substr(self::$verifyCode, $i, 1, 'utf-8', false);
         self::_setRandSize();
         self::_setRandAngle();
         self::_setRandX();
         self::_setRandY();
         self::_setRandColor();
         ImageTTFText(self::$_image, self::$_size, self::$_angle, self::$_codeX * $i + 10, self::$_codeY, self::$_color, self::$_font, $_text);
     }
 }
コード例 #15
0
ファイル: Pw.php プロジェクト: fanqimeng/4tweb
 /**
  * 字符串截取
  *
  * @param string $string
  * @param int $length
  * @param int $start
  * @param bool $dot
  */
 public static function substrs($string, $length, $start = 0, $dot = true)
 {
     return WindString::substr($string, $start, $length, Wekit::app()->charset, $dot);
 }