本文整理汇总了PHP中util::rdel方法的典型用法代码示例。如果您正苦于以下问题:PHP util::rdel方法的具体用法?PHP util::rdel怎么用?PHP util::rdel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util
的用法示例。
在下文中一共展示了util::rdel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: importGame
public static function importGame($pack)
{
$pack->auth->permission = "read_write";
if (!users::authenticateUser($pack->auth)) {
return new return_package(6, NULL, "Failed Authentication");
}
$zipbasename = substr($pack->zip_name, 0, strrpos($pack->zip_name, ".zip"));
$tmp_import_folder = Config::v2_gamedata_folder . "/" . $zipbasename . "_import_" . date("mdY_Gis");
if (file_exists($tmp_import_folder)) {
return "no";
}
if (isset($pack->raw_upload_id)) {
$tmp_zip = Config::raw_uploads_folder . '/' . $pack->raw_upload_id;
} else {
if (isset($pack->zip_data)) {
$tmp_zip = $tmp_import_folder . ".zip";
//save data to zip
$zipfile = fopen($tmp_zip, "w");
fwrite($zipfile, base64_decode($pack->zip_data));
fclose($zipfile);
} else {
return new return_package(1, NULL, "No ZIP data given to import a game from");
}
}
//unzip to folder
$zip = new ZipArchive();
if ($zip->open($tmp_zip) === TRUE) {
$zip->extractTo($tmp_import_folder);
$zip->close();
}
unlink($tmp_zip);
//get rid of zip
unset($pack->zip_data);
//for readability in debug
//read text
$jsonfile = fopen($tmp_import_folder . "/export.json", "r");
$assoc_data = json_decode(fread($jsonfile, filesize($tmp_import_folder . "/export.json")), true);
fclose($jsonfile);
//convert to non-assoc for non-data tables
$import = new stdClass();
$import->game_id = $assoc_data["game_id"];
$import->table_data = array();
for ($i = 0; $i < count($assoc_data["table_data"]); $i++) {
$import->table_data[$i] = new stdClass();
$import->table_data[$i]->table = $assoc_data["table_data"][$i]["table"];
$import->table_data[$i]->columns = array();
for ($j = 0; $j < count($assoc_data["table_data"][$i]["columns"]); $j++) {
$import->table_data[$i]->columns[$j] = new stdClass();
$import->table_data[$i]->columns[$j]->name = $assoc_data["table_data"][$i]["columns"][$j]["name"];
$import->table_data[$i]->columns[$j]->meta = $assoc_data["table_data"][$i]["columns"][$j]["meta"];
}
$import->table_data[$i]->data = $assoc_data["table_data"][$i]["data"];
}
$pack->import = $import;
$ret = duplicate::importGameData($pack);
util::rdel($tmp_import_folder);
//get rid of zipto
return $ret;
}
示例2: exportNotes
public static function exportNotes($pack)
{
$pack->auth->game_id = $pack->game_id;
$pack->auth->permission = "read_write";
if (!editors::authenticateGameEditor($pack->auth)) {
return new return_package(6, NULL, "Failed Authentication");
}
$export = notes::getNotesForGame($pack);
$tmp_export_folder = $pack->game_id . "_notebook_export_" . date("mdY_Gis");
$fs_tmp_export_folder = Config::v2_gamedata_folder . "/" . $tmp_export_folder;
if (file_exists($fs_tmp_export_folder)) {
util::rdel($fs_tmp_export_folder);
}
mkdir($fs_tmp_export_folder, 0777);
$jsonfile = fopen($fs_tmp_export_folder . "/export.json", "w");
fwrite($jsonfile, json_encode($export));
fclose($jsonfile);
util::rcopy(Config::v2_gamedata_folder . "/" . $pack->game_id, $fs_tmp_export_folder . "/gamedata");
util::rzip($fs_tmp_export_folder, $fs_tmp_export_folder . ".zip");
util::rdel($fs_tmp_export_folder);
return new return_package(0, Config::v2_gamedata_www_path . "/" . $tmp_export_folder . ".zip");
}
示例3: rdel
public static function rdel($dirPath)
{
//hack to "fix" security issue of this becoming open API via our terrible framework
if (strpos($_SERVER['REQUEST_URI'], 'rdel') !== false) {
return new return_package(6, NULL, "Attempt to bypass authentication externally.");
}
if (!is_dir($dirPath)) {
throw new InvalidArgumentException("{$dirPath} must be a directory");
}
if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') {
$dirPath .= '/';
}
$files = glob($dirPath . '*', GLOB_MARK);
foreach ($files as $file) {
if (is_dir($file)) {
util::rdel($file);
} else {
unlink($file);
}
}
rmdir($dirPath);
}