コード例 #1
0
 /**
  * Page のプロセス.
  *
  * @return void
  */
 function process()
 {
     // FIXME パスのチェック関数が必要
     if (preg_match('|\\./|', $_GET['file'])) {
         SC_Utils_Ex::sfDispError('');
     }
     // ユーザー認証
     SC_Utils_Ex::sfIsSuccess(new SC_Session());
     // ソースとして表示するファイルを定義(直接実行しないファイル)
     $arrViewFile = array('html', 'htm', 'tpl', 'php', 'css', 'js');
     // 拡張子取得
     $arrResult = split('\\.', $_GET['file']);
     $ext = $arrResult[count($arrResult) - 1];
     // ファイル内容表示
     if (in_array($ext, $arrViewFile)) {
         $objFileManager = new SC_Helper_FileManager_Ex();
         // ファイルを読み込んで表示
         header("Content-type: text/plain\n\n");
         print $objFileManager->sfReadFile(USER_PATH . $_GET['file']);
     } else {
         $this->sendRedirect(USER_URL . $_GET['file']);
         exit;
     }
 }
コード例 #2
0
 /**
  * ファイル内容を表示する
  *
  * @return void
  */
 public function execFileView($objFormParam)
 {
     $file = $objFormParam->getValue('file');
     // ソースとして表示するファイルを定義(直接実行しないファイル)
     $arrViewFile = array('html', 'htm', 'tpl', 'php', 'css', 'js');
     $extension = pathinfo($file, PATHINFO_EXTENSION);
     if (in_array($extension, $arrViewFile)) {
         $objFileManager = new SC_Helper_FileManager_Ex();
         // ファイルを読み込んで表示
         header("Content-type: text/plain\n\n");
         echo $objFileManager->sfReadFile(USER_REALDIR . $file);
     } else {
         SC_Response_Ex::sendRedirect(USER_URL . $file);
     }
 }
コード例 #3
0
 /**
  * SQL文からクエリ実行し CSVファイルを送信する
  *
  * @param integer $sql SQL文
  * @param array $arrVal プリペアドステートメントの実行時に使用される配列。配列の要素数は、クエリ内のプレースホルダの数と同じでなければなりません。
  * @param string $file_head ファイル名の頭に付ける文字列
  * @param array $arrHeader ヘッダ出力列配列
  * @param boolean $is_download true:ダウンロード用出力までさせる false:CSVの内容を返す(旧方式、メモリを食います。)
  * @return mixed $is_download = true時 成功失敗フラグ(boolean) 、$is_downalod = false時 string
  */
 function sfDownloadCsvFromSql($sql, $arrVal = array(), $file_head = 'csv', $arrHeader = array(), $is_download = false)
 {
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     // ヘッダ構築
     if (is_array($arrHeader)) {
         $header = $this->sfArrayToCSV($arrHeader);
         $header = mb_convert_encoding($header, 'SJIS-Win');
         $header .= "\r\n";
     }
     //テンポラリファイル作成
     // TODO: パフォーマンス向上には、ストリームを使うようにすると良い
     //  環境要件がPHPバージョン5.1以上になったら使うように変えても良いかと
     //  fopen('php://temp/maxmemory:'. (5*1024*1024), 'r+');
     $tmp_filename = tempnam(CSV_TEMP_REALDIR, $file_head . '_csv');
     $this->fpOutput = fopen($tmp_filename, 'w+');
     fwrite($this->fpOutput, $header);
     $objQuery->doCallbackAll(array(&$this, 'cbOutputCSV'), $sql, $arrVal);
     fclose($this->fpOutput);
     if ($is_download) {
         // CSVを送信する。
         $this->lfDownloadCSVFile($tmp_filename, $file_head . '_');
         $res = true;
     } else {
         $res = SC_Helper_FileManager_Ex::sfReadFile($tmp_filename);
     }
     //テンポラリファイル削除
     unlink($tmp_filename);
     return $res;
 }