芝麻web文件管理V1.00
编辑当前文件:/home/r5772835/public_html/ycreate.jp/wp-content/themes/snow-monkey/Framework/Model/Filesystem.php
get_contents( $filepath ); } static::end(); return isset( $contents ) ? $contents : false; } /** * Write contents to the $filepath. * * @param string $filepath The file path. * @param string $contents Writing Content. * @return boolean * @throws \RuntimeException If the file fails to write. */ public static function put_contents( $filepath, $contents ) { $result = false; $filesystem = static::start(); if ( $filesystem ) { $result = $filesystem->put_contents( $filepath, $contents ); } static::end(); if ( ! $result ) { throw new \RuntimeException( sprintf( '[Snow Monkey] Failed to write to %1$s.', $filepath ) ); } return $result; } /** * Remove directory. * * @param string $filepath Path of the directory to be deleted. * @return boolean * @throws \RuntimeException If the file deletion fails. */ public static function rmdir( $filepath ) { if ( ! file_exists( $filepath ) ) { return true; } $result = false; $filesystem = static::start(); if ( $filesystem ) { $result = $filesystem->rmdir( $filepath, true ); } static::end(); if ( ! $result ) { throw new \RuntimeException( sprintf( '[Snow Monkey] Failed to remove to %1$s.', $filepath ) ); } return $result; } /** * Recursive directory creation based on full path. * * @param string $target Full path to attempt to create. * @return boolean Whether the path was created. True if path already exists. * @throws \RuntimeException If the creation of the directory fails. */ public static function mkdir( $target ) { if ( is_writable( $target ) ) { return true; } if ( file_exists( $target ) ) { return true; } try { if ( ! is_writable( dirname( $target ) ) ) { throw new \RuntimeException( sprintf( '[Snow Monkey] %1$s is not writable.', dirname( $target ) ) ); } } catch ( \Exception $e ) { echo $e->getMessage(); return false; } $result = false; try { $result = wp_mkdir_p( $target ); if ( ! $result ) { throw new \RuntimeException( sprintf( '[Snow Monkey] Failed to mkdir to %1$s.', $target ) ); } } catch ( \Exception $e ) { echo $e->getMessage(); } return $result; } }