OSDN Git Service

初回コミット(v2.6.17.1)
[magic3/magic3.git] / include / manager / fileManager.php
1 <?php
2 /**
3  * ファイル管理マネージャー
4  *
5  * PHP versions 5
6  *
7  * LICENSE: This source file is licensed under the terms of the GNU General Public License.
8  *
9  * @package    Magic3 Framework
10  * @author     平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
11  * @copyright  Copyright 2006-2013 Magic3 Project.
12  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
13  * @version    SVN: $Id: fileManager.php 6156 2013-07-02 00:03:50Z fishbone $
14  * @link       http://www.magic3.org
15  */
16 class FileManager extends Core
17 {
18         private $db;                                            // DBオブジェクト
19                 
20         /**
21          * コンストラクタ
22          */
23         function __construct()
24         {
25                 // 親クラスを呼び出す
26                 parent::__construct();
27                 
28                 // システムDBオブジェクト取得
29                 $this->db = $this->gInstance->getSytemDbObject();
30         }
31         
32         /**
33          * インストーラを退避
34          *
35          * @return bool                         true=成功、false=失敗
36          */
37         public function backupInstaller()
38         {
39                 global $gEnvManager;
40                 
41                 // システムルート取得
42                 $sytemRoot = $gEnvManager->getSystemRootPath();
43                 
44                 $filename = $sytemRoot . '/admin/install.php';
45                 $backupFilename = $filename . '_backup';
46                 return rename($filename, $backupFilename);
47         }
48         /**
49          * インストーラを回復
50          *
51          * @return bool                         true=成功、false=失敗
52          */
53         public function recoverInstaller()
54         {
55                 global $gEnvManager;
56                 
57                 // システムルート取得
58                 $sytemRoot = $gEnvManager->getSystemRootPath();
59                 
60                 $oldFilename = $sytemRoot . '/admin/install.php_backup';
61                 $newFilename = $sytemRoot . '/admin/install.php';
62                 
63                 // ファイルの存在チェック
64                 if (file_exists($newFilename)){
65                         return true;
66                 } else {
67                         return rename($oldFilename, $newFilename);
68                 }
69         }
70         /**
71          * インストーラファイルパスを取得
72          *
73          * @return string               ファイルパス
74          */
75         public function getInstallerPath()
76         {
77                 global $gEnvManager;
78                 
79                 // システムルート取得
80                 $sytemRoot = $gEnvManager->getSystemRootPath();
81                 
82                 $newFilename = $sytemRoot . '/admin/install.php';
83                 return $newFilename;
84         }
85         /**
86          * 添付ファイル情報を新規追加
87          *
88          * @param string $contentType   コンテンツタイプ
89          * @param string $fileId                ファイル識別ID(コンテンツタイプでユニーク)
90          * @param string $filePath              ファイルパス
91          * @param string $originalFilename      元のファイル名
92          * @param string $originalUrl           取得元のURL
93          * @return bool                                 true=成功、false=失敗
94          */
95         public function addAttachFileInfo($contentType, $fileId, $filePath, $originalFilename, $originalUrl = '')
96         {
97                 $ret = $this->db->addAttachFileInfo($contentType, $fileId, $filePath, $originalFilename, $originalUrl);
98                 return $ret;
99         }
100         /**
101          * 添付ファイル情報を更新
102          *
103          * @param string $contentType   コンテンツタイプ
104          * @param string $contentId             コンテンツID
105          * @param int $oldContentSerial 旧コンテンツシリアル番号
106          * @param int $contentSerial    コンテンツシリアル番号
107          * @param array $fileInfo               ファイル情報
108          * @param string $dir                   ファイル格納ディレクトリ
109          * @return bool                                 true=成功、false=失敗
110          */
111         public function updateAttachFileInfo($contentType, $contentId, $oldContentSerial, $contentSerial, $fileInfo, $dir)
112         {
113                 $ret = $this->db->updateAttachFileInfo($contentType, $contentId, $oldContentSerial, $contentSerial, $fileInfo, $dir);
114                 return $ret;
115         }
116         /**
117          * 添付ファイル情報を取得
118          *
119          * @param string $contentType   コンテンツタイプ
120          * @param int $contentSerial    コンテンツシリアル番号
121          * @param array  $rows                  レコード
122          * @return bool                                 1行以上取得 = true, 取得なし= false
123          */
124         public function getAttachFileInfo($contentType, $contentSerial, &$rows)
125         {
126                 $ret = $this->db->getAttachFileInfo($contentType, $contentSerial, $rows);
127                 return $ret;
128         }
129         /**
130          * ファイルIDから添付ファイル情報を取得
131          *
132          * @param string $contentType   コンテンツタイプ
133          * @param string $fileId                ファイルID
134          * @param array  $row                   レコード
135          * @param bool $assignedOnly    本登録済みファイルのみかどうか
136          * @return bool                                 取得あり = true, 取得なし= false
137          */
138         public function getAttachFileInfoByFileId($contentType, $fileId, &$row, $assignedOnly = true)
139         {
140                 $ret = $this->db->getAttachFileInfoByFileId($contentType, $fileId, $row, $assignedOnly);
141                 return $ret;
142         }
143         /**
144          * クライアントIDで仮登録の添付ファイル情報を取得
145          *
146          * @param string $contentType   コンテンツタイプ
147          * @param string $clientId              クライアントID
148          * @param array  $rows                  レコード
149          * @return bool                                 1行以上取得 = true, 取得なし= false
150          */
151         public function getAttachFileInfoByClientId($contentType, $clientId, &$rows)
152         {
153                 $ret = $this->db->getAttachFileInfoByClientId($contentType, $clientId, $rows);
154                 return $ret;
155         }
156         /**
157          * 添付ファイル情報を削除
158          *
159          * @param string $contentType   コンテンツタイプ
160          * @param int $contentSerial    コンテンツシリアル番号
161          * @param string $dir                   ファイル格納ディレクトリ
162          * @return bool                                 true=成功、false=失敗
163          */
164         public function delAttachFileInfo($contentType, $contentSerial, $dir)
165         {
166                 $ret = $this->db->delAttachFileInfo($contentType, $contentSerial, $dir);
167                 return $ret;
168         }
169         /**
170          * 添付ファイル情報をコンテンツIDで削除
171          *
172          * @param string $contentType   コンテンツタイプ
173          * @param string $contentId             コンテンツID
174          * @param string $dir                   ファイル格納ディレクトリ
175          * @return bool                                 true=成功、false=失敗
176          */
177         public function delAttachFileInfoByContentId($contentType, $contentId, $dir)
178         {
179                 $ret = $this->db->delAttachFileInfoByContentId($contentType, $contentId, $dir);
180                 return $ret;
181         }
182         /**
183          * 仮登録の添付ファイル情報を削除
184          *
185          * @param string $contentType   コンテンツタイプ
186          * @param string $dir                   ファイル格納ディレクトリ
187          * @return bool                                 true=成功、false=失敗
188          */
189         public function cleanAttachFileInfo($contentType, $dir)
190         {
191                 $ret = $this->db->cleanAttachFileInfo($contentType, $dir);
192                 return $ret;
193         }
194         /**
195          * ランダムなファイルIDを生成
196          *
197          * @return string               ファイルID
198          */
199         public function createRandFileId()
200         {
201                 global $gEnvManager;
202                 global $gAccessManager;
203                 
204                 return md5($gEnvManager->getRootUrl() . '-' . $gAccessManager->getAccessLogSerialNo() . '-' . rand());
205         }
206 }
207 ?>