Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // SO, this new version brings: repo info, "repo" and "packages" fields in the json, and is fully compatible with the bigger one
- // remember, the bigger one is exactly the same, but longer because there are more fiels to read/change
- // I wouldn't really care about the increased RAM usage of making another array at then if I were you, it's most probably negligeable.
- // change these as you like! they are what define your repo for installMii. Could even read them from a settings/config file
- $repoInfo = array();
- $repoInfo["name"] = "ChaosJester's Repo";
- $repoInfo["author"] = "ChaosJesterrrr";
- $repoInfo["website"] = "http://3dsrepo.chaosjester.net";
- // comment out/in the fields as you adapt your scraper!
- $fields = array(); // dont comment that one out, will break everything else
- $fields[] = "name";
- $fields[] = "short_description";
- $fields[] = "author";
- // those are commented out because your scraper doesnt put them in the master.list yet
- // $fields[] = "category";
- // $fields[] = "website";
- // $fields[] = "type";
- // $fields[] = "version";
- // $fields[] = "dl_path";
- // $fields[] = "info_path";
- $list = array();
- $lines = 0;
- $app = 0;
- $field = 0;
- $list[$app] = array();
- $fieldsNum = sizeof($fields);
- $file = fopen("master.list", "r");
- if($file) {
- while(!feof($file)){
- $line = substr(fgets($file),0,-2);
- $list[$app][$fields[$field]] = $line; // example: $list[0]["name"] = "3dscraft"
- $field++;
- $lines++;
- if($lines%$fieldsNum == 0 && !feof($file)) { // change app number once it goes back to "name"
- $app++;
- $field = 0;
- $list[$app] = array();
- }
- }
- }
- fclose($file);
- // create a new array before encoding to get the "repo" and "packages" part correctly
- $formattedjson = json_encode(array("repo"=>$repoInfo, "packages"=>$list));
- echo $formattedjson;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment