Permalink
Browse files

一覧時にMecab周りのエラーが発生することがあるバグ修正

Squashed commit of the following:

commit c21b308
Merge: af9b685 3d6f0b3
Author: Masashi Yoshikawa <logue@hotmail.co.jp>
Date:   Fri Apr 29 16:11:26 2016 +0900

    Merge pull request #38 from mikoim/feature/hash

    ハッシュ値をより厳密に比較するように修正

commit af9b685
Merge: 2bca456 1cad0e1
Author: Masashi Yoshikawa <logue@hotmail.co.jp>
Date:   Fri Apr 29 16:10:56 2016 +0900

    Merge pull request #39 from mikoim/feature/php7

    password_hash()を使用するスキームを追加

commit 2bca456
Merge: 4694319 2898c72
Author: Masashi Yoshikawa <logue@hotmail.co.jp>
Date:   Fri Apr 29 15:58:24 2016 +0900

    Merge pull request #40 from mikoim/feature/short

    複合演算子に置き換え

commit 2898c72
Author: Eshin Kunishima <ek@esh.ink>
Date:   Thu Apr 28 18:57:36 2016 +0900

    複合演算子に置き換え

commit 1cad0e1
Author: Eshin Kunishima <ek@esh.ink>
Date:   Thu Apr 28 23:52:44 2016 +0900

    password_hash()を使用するスキームを追加

commit 3d6f0b3
Author: Eshin Kunishima <ek@esh.ink>
Date:   Thu Apr 28 17:40:58 2016 +0900

    ハッシュ値をより厳密に比較するように修正
  • Loading branch information...
1 parent c97f370 commit 9ea42b7e7598a9a8416ad6f95930eb04d4a581ae @logue committed May 1, 2016
@@ -47,7 +47,7 @@ class Attach{
*/
const DELETE_ADMIN_ONLY = false;
/**
- * 管理者だけが添付ファイルを削除できるようにする
+ * 管理者だけが添付ファイルのバックアップを削除できるようにする
*/
const DELETE_ADMIN_NOBACKUP = false;
/**
@@ -87,7 +87,7 @@ class Attach{
*/
private $update = false;
/**
- * 管理情報格納ファイルオブジェクト
+ * 添付ファイルのログ(実際は管理情報格納ファイル)オブジェクト
*/
private $logfile;
/**
@@ -100,28 +100,33 @@ class Attach{
* @param string $file 添付ファイル名
*/
public function __construct($page, $filename, $age = 0){
- if (!isset($page)) Utility::dieMessage('Pagename is missing');
- if (!isset($filename)) Utility::dieMessage('Filename is missing');
+ if (empty($page)) Utility::dieMessage('Pagename is missing');
+ if (empty($filename)) Utility::dieMessage('Filename is missing');
+
+ // 初期設定
$this->page = $page;
$this->filename = $filename;
$this->age = (int)$age;
+ // サーバー上のファイル名
$this->basename = AttachFile::$dir . Utility::encode($page) . '_' . Utility::encode($filename) . ($this->age !== 0 ? '.'.$this->age : '');
+ // ファイルオブジェクト
$this->fileinfo = new File($this->basename);
-
+ // ページに添付されているファイル一覧
$this->files = $this->getAttaches();
- $this->update = false; // ステータスの更新フラグ
+ // ステータスの更新フラグ
+ $this->update = false;
// ログファイルが存在しない場合
if (!isset($this->files['log'])){
$this->files['log'] = Utility::encode($filename).'.log';
}
-
$this->logfile = new File(AttachFile::$dir . $this->files['log']);
+
// 管理情報を取得
if ($this->logfile->has()){;
$data = $this->logfile->get();
foreach ($this->status as $key=>$value) {
- $this->status[$key] = chop(array_shift($data));
+ $this->status[$key] = rtrim(array_shift($data));
}
$this->status['count'] = explode(',', $this->status['count']);
}
@@ -267,7 +272,7 @@ public function delete($pass){
*/
public function freeze($freeze, $pass){
if (Auth::check_role('role_contents_admin') && ! Auth::login($pass))
- return attach_info('err_adminpass');
+ return attach_info('err_adminpass'); // TODO
$this->status['freeze'] = $freeze;
$this->update = true;
@@ -344,7 +349,7 @@ public function render(){
header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode($this->filename));
}
- $buffer = 1024 * 8;
+ $buffer = self::PARTIAL_BUFFER_SIZE;
while(!feof($fp) && ($p = ftell($fp)) <= $end) {
if ($p + $buffer > $end) {
$buffer = $end - $p + 1;
@@ -374,10 +379,9 @@ public function info($err)
if (IS_AJAX) {
$retval = array('msg'=>sprintf($_attach_messages['btn_info'], Utility::htmlsc($this->filename)));
- $ret[] = '<div id="attach-info-tabs" class="tabs">';
- $ret[] = '<ul role="tablist">';
- $ret[] = '<li role="tab" id="tab1" aria-controls="attach_info"><a href="#attach_info">' . $_attach_messages['msg_info'] . '</a></li>';
- $ret[] = '<li role="tab" id="tab2" aria-controls="attach_form_edit"><a href="#attach_form_edit">' . $_LANG['skin']['edit'] . '</a></li>';
+ $ret[] = '<ul class="nav nav-tabs">';
+ $ret[] = '<li class="nav-item"><a class="nav-link active" href="#attach_info">' . $_attach_messages['msg_info'] . '</a></li>';
+ $ret[] = '<li class="nav-item"><a class="nav-link" href="#attach_form_edit">' . $_LANG['skin']['edit'] . '</a></li>';
$ret[] = '</ul>';
}else{
$retval = array('msg'=>sprintf($_attach_messages['msg_info'], htmlsc($this->filename)));
@@ -609,7 +613,8 @@ private function isCompress($mime_type = self::DEFAULT_MIME_TYPE){
'x-lzh-compressed' => false, // LZH
'x-rar-compressed' => false, // RAR
'x-java-archive' => false, // jar
- 'x-javascript' => true, // js
+ 'javascript' => true, // js
+ 'css' => true, // css
'ogg' => false, // ogg
'pdf' => false, // pdf
),
@@ -115,6 +115,9 @@ public static function get($type = 'wiki', $cmd = 'read', $with_filename = false
global $_string;
// 一覧の配列を取得
$heading = self::getHeadings($type);
+
+ if ($heading == null) return '<p class="alert alert-success">No match files</p>';
+
$contents = array();
if (IS_MOBILE) {
@@ -21,7 +21,7 @@ class MeCab{
public $usable = false;
public function __construct($mecab_path = ''){
if (!extension_loaded('mecab')) {
- if ( file_exists($mecab_path)){
+ if (!empty($mecab_path) && open_basedir($mecab_path) && file_exists($mecab_path)){
$this->mecab_path = $mecab_path;
$this->usable = true;
//throw new Exception('Mecab is not found or not executable. Please check mecab path: '.$mecab_path);

0 comments on commit 9ea42b7

Please sign in to comment.