Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- @Filename : permissionsConverter.php
- @Description : Tool to convert a permission file to a different type
- Will support P2, P3 and PermissionsBukkit
- @Dependencies : Spyc.php
- @Author : Pr4w
- @Special thanks to all the cool guys at bukkit.org
- @Usage : convertP2toP3("world.yml", "users.yml", "groups.yml");
- Have fun :)
- */
- require('spyc.php');
- function convertP2toP3($file, $userfile, $groupfile) {
- // Get the Yaml file
- $yaml = Spyc::YAMLLoad(@file_get_contents($file));
- // Fix users array
- $users = array ('users' => $yaml['users']);
- // Fix groups array
- $groups = array ('groups' => $yaml['groups']);
- // Dump the YAML of both users and groups
- $users = Spyc::YAMLDump($users, 4);
- $groups = Spyc::YAMLDump($groups, 4);
- // Perform transformation to Permission 3 format
- $users = str_replace("group:", "groups:
- -", $users);
- // Write users to a file
- $write = fopen($userfile, "w")
- or die ( "Could not open file !" );
- $write = fwrite($write, $users)
- or die ( "Could not write to file !" );
- // Write groups to a file
- $write = fopen($groupfile, "w")
- or die ( "Could not open file !");
- $write = fwrite($write, $groups)
- or die ( "Could not write to file !" );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement