Exemple #1
0
 /**
  * リネームする
  * @param string $to
  */
 public function rename($to)
 {
     if ($this->status['freeze']) {
         return attach_info('msg_isfreeze');
     }
     if (Auth::check_role('role_contents_admin') && !Auth::login($pass)) {
         return attach_info('err_adminpass');
     }
     // 基点名(エンコードされたページ名+_)
     $basename = AttachFile::$dir . Utility::encode($this->page) . '_';
     // 新しいファイル名
     $newname = Utility::encode($to);
     if (file_exists($basename . $newname)) {
         // ファイルが存在する場合
         return false;
     }
     $rename_targets = array();
     foreach (AttachFile::exists() as $file) {
         if (!preg_match('/^(' . preg_quote(Utility::encode($this->filename)) . ')(\\.((\\d+)|(log)))$/', $file, $matches)) {
             continue;
         }
         // 0 …ファイル名全体 1…ファイル名 2…拡張子
         rename($basename . $matches[0], $basename . $newname . $matches[2]);
     }
     AttachFile::clearCache();
     return true;
 }
Exemple #2
0
 /**
  * 添付ファイル一覧
  * @return string
  */
 private function getAttaches()
 {
     // TODO: UPLOAD_DIRの参照方法の変更
     global $_LANG;
     $ret = array();
     $exists = false;
     $attaches = $this->wiki->attach(false);
     if (!empty($attaches)) {
         $ret[] = '<dl class="list-inline">';
         $ret[] = '<dt>' . $_LANG['skin']['attach_title'] . '</dt>';
         foreach ($attaches as $filename => $files) {
             if (!isset($files[0])) {
                 continue;
             }
             $fileinfo = new AttachFile($this->page, $filename);
             $exists = true;
             if (!$fileinfo->has()) {
                 continue;
             }
             $logfileinfo = new AttachFile($this->page, $filename, 'log');
             $count = $logfileinfo->has() ? $logfileinfo->head(1) : '0';
             $ret[] = '<dd><a href="' . Router::get_cmd_uri('attach', null, null, array('pcmd' => 'open', 'refer' => $this->page, 'age' => 0, 'openfile' => $filename)) . '" title="' . Time::getZoneTimeDate('Y/m/d H:i:s', $fileinfo->time()) . ' ' . sprintf('%01.1f', round($fileinfo->getSize() / 1024, 1)) . 'KB' . '"><span class="fa fa-download"></span>' . Utility::htmlsc($filename) . '</a> ' . '<a href="' . Router::get_cmd_uri('attach', null, null, array('pcmd' => 'info', 'refer' => $this->page, 'file' => $filename)) . '" class="btn btn-default btn-xs" title="' . $_LANG['skin']['attach_info'] . '">' . '<span class="fa fa-info"></span></a>' . '</dd>';
         }
         $ret[] = '</dl>';
     }
     return $exists ? join("\n", $ret) : null;
 }