7 * LICENSE: This source file is licensed under the terms of the GNU General Public License.
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
16 class FileManager extends Core
18 private $db; // DBオブジェクト
23 function __construct()
26 parent::__construct();
29 $this->db = $this->gInstance->getSytemDbObject();
35 * @return bool true=成功、false=失敗
37 public function backupInstaller()
42 $sytemRoot = $gEnvManager->getSystemRootPath();
44 $filename = $sytemRoot . '/admin/install.php';
45 $backupFilename = $filename . '_backup';
46 return rename($filename, $backupFilename);
51 * @return bool true=成功、false=失敗
53 public function recoverInstaller()
58 $sytemRoot = $gEnvManager->getSystemRootPath();
60 $oldFilename = $sytemRoot . '/admin/install.php_backup';
61 $newFilename = $sytemRoot . '/admin/install.php';
64 if (file_exists($newFilename)){
67 return rename($oldFilename, $newFilename);
73 * @return string ファイルパス
75 public function getInstallerPath()
80 $sytemRoot = $gEnvManager->getSystemRootPath();
82 $newFilename = $sytemRoot . '/admin/install.php';
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=失敗
95 public function addAttachFileInfo($contentType, $fileId, $filePath, $originalFilename, $originalUrl = '')
97 $ret = $this->db->addAttachFileInfo($contentType, $fileId, $filePath, $originalFilename, $originalUrl);
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=失敗
111 public function updateAttachFileInfo($contentType, $contentId, $oldContentSerial, $contentSerial, $fileInfo, $dir)
113 $ret = $this->db->updateAttachFileInfo($contentType, $contentId, $oldContentSerial, $contentSerial, $fileInfo, $dir);
119 * @param string $contentType コンテンツタイプ
120 * @param int $contentSerial コンテンツシリアル番号
121 * @param array $rows レコード
122 * @return bool 1行以上取得 = true, 取得なし= false
124 public function getAttachFileInfo($contentType, $contentSerial, &$rows)
126 $ret = $this->db->getAttachFileInfo($contentType, $contentSerial, $rows);
130 * ファイルIDから添付ファイル情報を取得
132 * @param string $contentType コンテンツタイプ
133 * @param string $fileId ファイルID
134 * @param array $row レコード
135 * @param bool $assignedOnly 本登録済みファイルのみかどうか
136 * @return bool 取得あり = true, 取得なし= false
138 public function getAttachFileInfoByFileId($contentType, $fileId, &$row, $assignedOnly = true)
140 $ret = $this->db->getAttachFileInfoByFileId($contentType, $fileId, $row, $assignedOnly);
144 * クライアントIDで仮登録の添付ファイル情報を取得
146 * @param string $contentType コンテンツタイプ
147 * @param string $clientId クライアントID
148 * @param array $rows レコード
149 * @return bool 1行以上取得 = true, 取得なし= false
151 public function getAttachFileInfoByClientId($contentType, $clientId, &$rows)
153 $ret = $this->db->getAttachFileInfoByClientId($contentType, $clientId, $rows);
159 * @param string $contentType コンテンツタイプ
160 * @param int $contentSerial コンテンツシリアル番号
161 * @param string $dir ファイル格納ディレクトリ
162 * @return bool true=成功、false=失敗
164 public function delAttachFileInfo($contentType, $contentSerial, $dir)
166 $ret = $this->db->delAttachFileInfo($contentType, $contentSerial, $dir);
170 * 添付ファイル情報をコンテンツIDで削除
172 * @param string $contentType コンテンツタイプ
173 * @param string $contentId コンテンツID
174 * @param string $dir ファイル格納ディレクトリ
175 * @return bool true=成功、false=失敗
177 public function delAttachFileInfoByContentId($contentType, $contentId, $dir)
179 $ret = $this->db->delAttachFileInfoByContentId($contentType, $contentId, $dir);
185 * @param string $contentType コンテンツタイプ
186 * @param string $dir ファイル格納ディレクトリ
187 * @return bool true=成功、false=失敗
189 public function cleanAttachFileInfo($contentType, $dir)
191 $ret = $this->db->cleanAttachFileInfo($contentType, $dir);
197 * @return string ファイルID
199 public function createRandFileId()
202 global $gAccessManager;
204 return md5($gEnvManager->getRootUrl() . '-' . $gAccessManager->getAccessLogSerialNo() . '-' . rand());