Last active
January 3, 2016 23:37
-
-
Save andreblue/d2e1107e8a448506b97a to your computer and use it in GitHub Desktop.
Super simple workshop addon lister. Provided either a collection ID, or the collection URL and it will get you the ID's. If you need it in resource.AddWorkshop option, checkmark the gmod one.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $doingRequest = (empty($_POST['request'])) ? false : true; | |
| if($doingRequest){ | |
| $wsid = (empty($_POST['wsid']) ? 0 : (int)urldecode($_POST['wsid'])); | |
| if($wsid <= 0){ | |
| $url = urldecode($_POST['wsid']); | |
| $url = str_replace("http://steamcommunity.com/sharedfiles/filedetails/?id=", "", $url); | |
| $url = (int)str_replace("https://steamcommunity.com/sharedfiles/filedetails/?id=", "", $url); | |
| if($url<=0){ | |
| echo "Error: Workshop ID Is not valid."; | |
| die(); | |
| } | |
| $wsid = $url; | |
| } | |
| //var_dump($wsid); | |
| $data = file_get_contents("http://steamcommunity.com/sharedfiles/filedetails/?id={$wsid}"); | |
| $errored = strpos($data, '<div class="error_ctn">'); | |
| if($errored !== false){ | |
| echo "Error: Workshop ID Is not valid."; | |
| die(); | |
| } | |
| $muster = '<a href="http:\/\/steamcommunity.com\/sharedfiles\/filedetails\/\?id=([0-9]+)">'; | |
| preg_match_all($muster, $data, $matched); | |
| $matches = array_unique(array_values($matched[1])); | |
| sort($matches); | |
| //The collection gets added to the list, thus remember to remove it! | |
| $checkOurCollectionID = array_search($wsid, $matches); | |
| if($checkOurCollectionID !== false){ | |
| unset($matches[$checkOurCollectionID]); | |
| } | |
| if(isset($_POST['gmod']) && !empty($_POST['gmod']) && $_POST['gmod'] == "1"){ | |
| foreach($matches as $id) { | |
| if($id != $wsid){ | |
| print "resource.AddWorkshop('" . $id . "') -- Workshop Link: http://steamcommunity.com/sharedfiles/filedetails/?id={$id}" . PHP_EOL; | |
| } | |
| } | |
| }else{ | |
| foreach($matches as $id) { | |
| if($id != $wsid){ | |
| print $id . PHP_EOL; | |
| } | |
| } | |
| } | |
| die(); | |
| } | |
| ?> | |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <!-- Google Hosted JQUERY --> | |
| <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> | |
| <!-- Latest compiled and minified CSS --> | |
| <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous"> | |
| <!-- Optional theme --> | |
| <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous"> | |
| <!-- Latest compiled and minified JavaScript --> | |
| <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script> | |
| </head> | |
| <body> | |
| <div id="container" > | |
| <div id="content"> | |
| <form method="post" id="requestList"> | |
| <label for="wsidin">Workshop Collection("Can be the id or url"): </label> | |
| <input type="text" id="wsidin" name="wsid"><br> | |
| <label for="doGmodin">Gmod Styling("Will add the resource.AddWorkshop bit"): </label> | |
| <input type="checkbox" id="doGmodin" name="gmod" value="1"><br> | |
| <input type="submit" name="request" value="Get the ID List"> | |
| </form> | |
| <textarea id="results" readonly="readonly"> | |
| IDs will show up here | |
| </textarea> | |
| </div> | |
| </div> | |
| <script> | |
| $( "#requestList" ).submit(function( event ) { | |
| // Stop form from submitting normally | |
| event.preventDefault(); | |
| // Get some values from elements on the page: | |
| var $form = $( this ), | |
| iwsid = $form.find( "input[name='wsid']" ).val(), | |
| irequest = $form.find( "input[name='request']" ).val(), | |
| doGmod = $form.find( "input[name='gmod']:checked" ).val(), | |
| url = $form.attr( "action" ); | |
| // Send the data using post | |
| var posting = $.post( url, { wsid: iwsid, request: irequest, gmod: doGmod } ); | |
| // Put the results in a div | |
| posting.done(function( data ) { | |
| $( "#results" ).empty().append( data ); | |
| }); | |
| }); | |
| </script> | |
| </body> | |
| </html> | |
| <?php | |
| /* | |
| The MIT License (MIT) | |
| Copyright (c) 2015 Andre | |
| Permission is hereby granted, free of charge, to any person obtaining a copy | |
| of this software and associated documentation files (the "Software"), to deal | |
| in the Software without restriction, including without limitation the rights | |
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| copies of the Software, and to permit persons to whom the Software is | |
| furnished to do so, subject to the following conditions: | |
| The above copyright notice and this permission notice shall be included in all | |
| copies or substantial portions of the Software. | |
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
| SOFTWARE. | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment