Non puoi selezionare più di 25 argomenti
Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
31 righe
792 B
31 righe
792 B
<?php |
|
|
|
namespace MwgAuth\Models; |
|
|
|
use MwgAuth\Core\Model; |
|
|
|
class Storage extends Model |
|
{ |
|
public static function fileGetContents(string $fileName): ?string |
|
{ |
|
$fullName = self::getFullName($fileName); |
|
if (file_exists($fullName)) { |
|
return file_get_contents($fullName); |
|
} |
|
return null; |
|
} |
|
|
|
public static function filePutContents(string $fileName, string $data, int $flags = 0) |
|
{ |
|
$fullName = self::getFullName($fileName); |
|
$umask = umask(0); |
|
mkdir(dirname($fullName), 0777, true); |
|
file_put_contents($fullName, $data, $flags); |
|
umask($umask); |
|
} |
|
|
|
private static function getFullName(string $fileName): string |
|
{ |
|
return $_SERVER['DOCUMENT_ROOT'] . '/storage/' . $fileName; |
|
} |
|
}
|
|
|