From 4bc3e9d97bbf52f4b94e63aaaad1d6a39eb6f505 Mon Sep 17 00:00:00 2001
From: joyqi
Date: Wed, 18 Dec 2013 00:19:52 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=81=97=E6=BC=8F=E7=9A=84?=
=?UTF-8?q?=E8=AF=AD=E8=A8=80=E9=A1=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
修正GetText库无法读取mo文件的bug
---
admin/editor-js.php | 2 +-
admin/media.php | 2 +-
admin/menu.php | 2 +-
var/Typecho/I18n/GetText.php | 37 +++++++++++++++++++++++++-----------
4 files changed, 29 insertions(+), 14 deletions(-)
diff --git a/admin/editor-js.php b/admin/editor-js.php
index a41f29f8..b1aed329 100644
--- a/admin/editor-js.php
+++ b/admin/editor-js.php
@@ -214,7 +214,7 @@ $(document).ready(function () {
// 编辑预览切换
- var edittab = $('.editor').prepend(''),
+ var edittab = $('.editor').prepend(''),
editarea = $(textarea.parent()).attr("id", "wmd-editarea");
$(".wmd-edittab a").click(function() {
diff --git a/admin/media.php b/admin/media.php
index 399127df..6ef70c5b 100644
--- a/admin/media.php
+++ b/admin/media.php
@@ -27,7 +27,7 @@ Typecho_Widget::widget('Widget_Contents_Attachment_Edit')->to($attachment);
-
+
或者 %s选择文件上传%s', '
', ''); ?>
diff --git a/admin/menu.php b/admin/menu.php
index 92bba9e4..3f17e74d 100644
--- a/admin/menu.php
+++ b/admin/menu.php
@@ -9,7 +9,7 @@
if ($user->logged > 0) {
_e('最后登录: %s', Typecho_I18n::dateWord($user->logged + $options->timezone, $options->gmtTime + $options->timezone));
}
- ?>" href="adminUrl('profile.php'); ?>" class="author">screenName(); ?>网站
+ ?>" href="adminUrl('profile.php'); ?>" class="author">screenName(); ?>
diff --git a/var/Typecho/I18n/GetText.php b/var/Typecho/I18n/GetText.php
index 81b858d2..36aa5498 100644
--- a/var/Typecho/I18n/GetText.php
+++ b/var/Typecho/I18n/GetText.php
@@ -78,17 +78,14 @@ class Typecho_I18n_GetText
// Caching can be turned off
$this->enable_cache = $enable_cache;
-
- // $MAGIC1 = (int)0x950412de; //bug in PHP 5
- $MAGIC1 = (int) - 1794895138;
- // $MAGIC2 = (int)0xde120495; //bug
- $MAGIC2 = (int) - 569244523;
-
$this->STREAM = @fopen($file, 'rb');
- $magic = $this->readint();
- if ($magic == $MAGIC1) {
+
+ $unpacked = unpack('c', $this->read(4));
+ $magic = array_shift($unpacked);
+
+ if (-34 == $magic) {
$this->BYTEORDER = 0;
- } elseif ($magic == $MAGIC2) {
+ } elseif (-107 == $magic) {
$this->BYTEORDER = 1;
} else {
$this->error = 1; // not MO file
@@ -103,6 +100,24 @@ class Typecho_I18n_GetText
$this->translations = $this->readint();
}
+ /**
+ * read
+ *
+ * @param mixed $count
+ * @access private
+ * @return void
+ */
+ private function read($count)
+ {
+ $count = abs($count);
+
+ if ($count > 0) {
+ return fread($this->STREAM, $count);
+ }
+
+ return NULL;
+ }
+
/**
* Reads a 32bit Integer from the Stream
*
@@ -111,7 +126,7 @@ class Typecho_I18n_GetText
*/
private function readint()
{
- $end = unpack($this->BYTEORDER == 0 ? 'V' : 'N', fread($this->STREAM, 4));
+ $end = unpack($this->BYTEORDER == 0 ? 'V' : 'N', $this->read(4));
return array_shift($end);
}
@@ -123,7 +138,7 @@ class Typecho_I18n_GetText
*/
private function readintarray($count)
{
- return unpack(($this->BYTEORDER == 0 ? 'V' : 'N') . $count, fread($this->STREAM, 4 * $count));
+ return unpack(($this->BYTEORDER == 0 ? 'V' : 'N') . $count, $this->read(4 * $count));
}
/**