1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-04 10:19:24 +02:00
Oinktube/locale/save.php
2021-10-05 11:42:35 -03:00

34 lines
1 KiB
PHP

<?php
header('Content-Type: application/json');
if (empty($global['systemRootPath'])) {
$global['systemRootPath'] = "../";
}
require_once $global['systemRootPath'] . 'objects/user.php';
$obj = new stdClass();
$obj->status = "1";
$obj->error = "";
if (!User::isAdmin() || !empty($global['disableAdvancedConfigurations'])) {
$obj->status = 0;
$obj->error = __("Permission denied");
die(json_encode($obj));
}
$dir = "{$global['systemRootPath']}locale/";
if (!is_writable($dir)) {
$obj->status = 0;
$obj->error = sprintf(__("Your %slocale dir is not writable"), $global['systemRootPath']);
die(json_encode($obj));
}
$file = $dir.strtolower($_POST['flag']).".php";
$myfile = fopen($file, "w") or die("Unable to open file!");
if (!$myfile) {
$obj->status = 0;
$obj->error = __("Unable to open file!");
die(json_encode($obj));
}
$txt = "<?php\nglobal \$t;\n";
fwrite($myfile, $txt);
fwrite($myfile, $_POST['code']);
fclose($myfile);
echo json_encode($obj);