ThemeFilesAdminService
extends ThemeFilesService
in package
implements
ThemeFilesAdminServiceInterface
uses
BcContainerTrait
ThemeFilesAdminService
Table of Contents
Interfaces
- ThemeFilesAdminServiceInterface
- ThemeFilesAdminServiceInterface
Properties
- $ThemeFileForm : ThemeFileForm
- $ThemeFoldersService : ThemeFoldersServiceInterface
- Theme Folders Service
- $_tempalteTypes : array<string|int, mixed>
- テーマファイルタイプ
Methods
- __construct() : mixed
- Constructor
- copy() : ThemeFile|false
- コピー
- copyToTheme() : array<string|int, mixed>|false|string|array<string|int, string>
- 現在のテーマにファイルをコピー
- create() : ThemeFileForm
- テーマファイルを作成
- delete() : bool
- テーマファイルを削除
- get() : ThemeFile
- 単一データ取得
- getBaseDir() : string
- テーマ/プラグインの当該テンプレートタイプのベースディレクトリを取得する
- getForm() : ThemeFileForm
- フォームを取得
- getFullpath() : string
- fullpathを作成
- getImg() : array<string|int, mixed>
- テーマ内のイメージデータを取得する
- getImgThumb() : array<string|int, mixed>
- テーマ内の画像のサムネイルイメージのデータを取得する
- getNew() : ThemeFile
- テーマファイルの初期値を取得
- getService() : array<string|int, mixed>|mixed|object
- Get Service
- getViewVarsForAdd() : array<string|int, mixed>
- テーマファイル新規登録画面用の View 変数を取得する
- getViewVarsForEdit() : array<string|int, mixed>
- テーマファイル編集画面用の View 変数を取得する
- getViewVarsForIndex() : array<string|int, mixed>
- テーマファイル一覧用の View 変数を取得する
- getViewVarsForView() : array<string|int, mixed>
- テーマファイル表示画面用の View 変数を取得する
- hasService() : bool
- Has Service
- update() : ThemeFileForm
- テーマファイルを編集
- upload() : mixed
- ファイルをアップロードする
- assertWithinPluginsDir() : void
- 読み出し対象のパスがプラグイン配置ルート(App::path('plugins'))配下に収まっているか検証する
- assertWithinSourceDir() : void
- コピー元のパスが、コピー元テーマ/プラグインの当該タイプのディレクトリ配下に収まっているか検証する
- assertWithinThemeDir() : void
- 指定したパスがテーマディレクトリ配下に収まっているか検証する
Properties
$ThemeFileForm
public
ThemeFileForm
$ThemeFileForm
$ThemeFoldersService
Theme Folders Service
public
ThemeFoldersServiceInterface
$ThemeFoldersService
$_tempalteTypes
テーマファイルタイプ
protected
array<string|int, mixed>
$_tempalteTypes
= []
Tags
Methods
__construct()
Constructor
public
__construct() : mixed
Tags
copy()
コピー
public
copy(string $fullpath) : ThemeFile|false
Parameters
- $fullpath : string
Tags
Return values
ThemeFile|falsecopyToTheme()
現在のテーマにファイルをコピー
public
copyToTheme(array<string|int, mixed> $params) : array<string|int, mixed>|false|string|array<string|int, string>
Parameters
- $params : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>|false|string|array<string|int, string>create()
テーマファイルを作成
public
create(array<string|int, mixed> $postData) : ThemeFileForm
Parameters
- $postData : array<string|int, mixed>
Tags
Return values
ThemeFileFormdelete()
テーマファイルを削除
public
delete(string $fullpath) : bool
Parameters
- $fullpath : string
Tags
Return values
boolget()
単一データ取得
public
get(string $file) : ThemeFile
Parameters
- $file : string
Tags
Return values
ThemeFilegetBaseDir()
テーマ/プラグインの当該テンプレートタイプのベースディレクトリを取得する
public
getBaseDir(string $theme, string $plugin, string $type) : string
Admin web 経路(ThemeFilesController::parseArgs)が fullpath を組み立てる規則と同じ。 type が etc の場合はテンプレートディレクトリ直下(type ディレクトリを挟まない)。
Parameters
- $theme : string
-
テーマ名(コピー元の場合はプラグイン名のこともある)
- $plugin : string
-
プラグイン名(空の場合はテーマ自身)
- $type : string
-
テンプレートタイプ
Tags
Return values
string —末尾に DS を含むベースディレクトリ
getForm()
フォームを取得
public
getForm(array<string|int, mixed> $data) : ThemeFileForm
Parameters
- $data : array<string|int, mixed>
Tags
Return values
ThemeFileFormgetFullpath()
fullpathを作成
public
getFullpath(string $theme, string $plugin, string $type, string $path) : string
Parameters
- $theme : string
- $plugin : string
- $type : string
- $path : string
Tags
Return values
stringgetImg()
テーマ内のイメージデータを取得する
public
getImg(mixed $args) : array<string|int, mixed>
Parameters
- $args : mixed
Tags
Return values
array<string|int, mixed>getImgThumb()
テーマ内の画像のサムネイルイメージのデータを取得する
public
getImgThumb(array<string|int, mixed> $args, int $width, int $height) : array<string|int, mixed>
Parameters
- $args : array<string|int, mixed>
- $width : int
- $height : int
Tags
Return values
array<string|int, mixed>getNew()
テーマファイルの初期値を取得
public
getNew(string $file, string $type) : ThemeFile
Parameters
- $file : string
- $type : string
Tags
Return values
ThemeFilegetService()
Get Service
public
getService(mixed $service) : array<string|int, mixed>|mixed|object
Parameters
- $service : mixed
Tags
Return values
array<string|int, mixed>|mixed|objectgetViewVarsForAdd()
テーマファイル新規登録画面用の View 変数を取得する
public
getViewVarsForAdd(ThemeFile $entity, ThemeFileForm $form, array<string|int, mixed> $args) : array<string|int, mixed>
Parameters
- $entity : ThemeFile
- $form : ThemeFileForm
- $args : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>getViewVarsForEdit()
テーマファイル編集画面用の View 変数を取得する
public
getViewVarsForEdit(ThemeFile $themeFile, ThemeFileForm $themeFileForm, array<string|int, mixed> $args) : array<string|int, mixed>
Parameters
- $themeFile : ThemeFile
- $themeFileForm : ThemeFileForm
- $args : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>getViewVarsForIndex()
テーマファイル一覧用の View 変数を取得する
public
getViewVarsForIndex(array<string|int, mixed> $args) : array<string|int, mixed>
Parameters
- $args : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>getViewVarsForView()
テーマファイル表示画面用の View 変数を取得する
public
getViewVarsForView(ThemeFile $themeFile, ThemeFileForm $themeFileForm, array<string|int, mixed> $args) : array<string|int, mixed>
Parameters
- $themeFile : ThemeFile
- $themeFileForm : ThemeFileForm
- $args : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>hasService()
Has Service
public
hasService(mixed $service) : bool
Parameters
- $service : mixed
Tags
Return values
boolupdate()
テーマファイルを編集
public
update(array<string|int, mixed> $postData) : ThemeFileForm
Parameters
- $postData : array<string|int, mixed>
Tags
Return values
ThemeFileFormupload()
ファイルをアップロードする
public
upload(string $fullpath, array<string|int, mixed> $postData) : mixed
Parameters
- $fullpath : string
- $postData : array<string|int, mixed>
Tags
assertWithinPluginsDir()
読み出し対象のパスがプラグイン配置ルート(App::path('plugins'))配下に収まっているか検証する
protected
assertWithinPluginsDir(string $path) : void
パストラバーサル対策(GHSA-rqr8-gmx5-xvrr): 読み出し処理(ThemeFilesService::get() / ThemeFoldersService::get())でも境界を検証し、 config/ などテーマ・プラグイン外のファイルを読み出せないようにする。 管理画面ではテーマに加えてプラグイン自体のテンプレートも参照するため、 書き込み用の assertWithinThemeDir() より広いプラグイン配置ルートを境界とする。 配下でなければ BcException を投げる。
Parameters
- $path : string
-
検証対象のパス(ファイル or ディレクトリ)
Tags
assertWithinSourceDir()
コピー元のパスが、コピー元テーマ/プラグインの当該タイプのディレクトリ配下に収まっているか検証する
protected
assertWithinSourceDir(array<string|int, mixed> $params) : void
copyToTheme() のコピー元 $params['fullpath'] は Admin web 経路では parseArgs() が
URL から .. を除去せずに組み立てるため、任意のファイル/ディレクトリをカレントテーマの
webroot 配下へコピーして公開 URL から取得できてしまう。コピー元も境界を検証する。
Parameters
- $params : array<string|int, mixed>
-
theme / plugin / type / fullpath を含む配列
Tags
assertWithinThemeDir()
指定したパスがテーマディレクトリ配下に収まっているか検証する
protected
assertWithinThemeDir(string $path[, string|null $theme = null ]) : void
パストラバーサル対策(GHSA-2pj4-v76f-wjvx)の最終防衛線。 Admin web 経路の create()/update() はリクエストの fullpath を直接書き込み先に使い getFullpath() の境界チェックを通らないため、実際の書き込み sink でも テーマディレクトリ配下であることを必ず検証する。配下でなければ BcException を投げる。
許可する境界は次のとおり。
- $theme を指定した場合: そのテーマのディレクトリ配下のみ
- 未指定の場合: インストール済みの全テーマ(Theme / AdminTheme)のディレクトリ配下
以前は App::path('plugins') 配下(plugins/ と vendor/baserproject/ 全体)を許可していたため、
fullpath に .. を含めることで編集中のテーマ以外(コアプラグイン等)へ書き込めた。
テーマ以外のプラグインディレクトリは書き込み先として許可しない。
書き込み処理(ThemeFileForm::_execute / copy)は rawurldecode() を 1 回かけた値を使うため、 生の値に加えて 1 回デコードした値も検査する(GHSA-q7g3-qwrc-mp89)
Parameters
- $path : string
-
検証対象のパス(ファイル or ディレクトリ)
- $theme : string|null = null
-
書き込み先として許可するテーマ名(省略時は全テーマ)