Jump to content

carstorm

Members
  • Posts

    18
  • Joined

  • Last visited

carstorm's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. As already stated there are none. Ya mod names can have spaces hence why I use each line as an element. The php script is on the same page hence why there is no action attribute.
  2. Sorry about the confusion. In the original post I have the form using get yet the PHP looking for post. It is using get. Now my code is: if(isset($_GET[ 'modsToBeChecked' ])) { $modsToBeChecked = str_replace( "\r", "\n", str_replace( "\r\n", "\n", $_GET[ 'modsToBeChecked' ] ) ); $modsToBeChecked = explode( "\n", $modsToBeChecked ); var_dump( $modsToBeChecked ); } I'm not getting any errors generated by php yet still getting a internal server error!
  3. Ah it says "Notice: Undefined index: modsToBeChecked" line 66 which is this line str_replace( "\r\n", "\n", $_GET[ 'modsToBeChecked' ] ) Is that the wrong way to get the form data?
  4. Whenever I hit submit I get an internal server error. Here is the code: <?php $modsToBeChecked = str_replace( "\r", "\n", str_replace( "\r\n", "\n", $_POST[ 'modsToBeChecked' ] ) ); $modsToBeChecked = explode( "\n", $modsToBeChecked ); var_dump( $modsToBeChecked );?> $modsToBeChecked is passed in from a textarea form. It is suppose to treat each line in the textbox as one element of the array. Here is the form code in case you need it: <form action=""><textarea name="modsToBeChecked" rows="25" cols="50"></textarea> <input type="submit"> </form>
  5. To suit my purpose in the end I need it to only need the mod name. How would I go about this? Would I use array_search? I know the function would have to be reworked.
  6. Ya I had plans on turning it into a function eventually. What if I only wanted to get info on one mod though. I tried passing in "Railcraft" but nothing showed up. <?php function getMod($mod) { $page = file_get_contents($mod[1]); $posStart = strpos($page, "Newest File: ") + $mod[2]; $posStop = strpos($page, "<",$posStart) + $mod[3]; $version = substr($page, $posStart, $posStop-$posStart); $output = "<br>{$mod[0]}<br>version $version<br>"; return $output; } $mods = array ( array("RailCraft","http://www.curse.com/mc-mods/minecraft/railcraft",23,0), array("Tinker's Construct","http://www.curse.com/mc-mods/minecraft/tinkers-construct",31,-4), ); echo getMod("RailCraft") ?>
  7. I think this is achieves what I'm trying to do unless anyone else has a diff/better idea $mods = array ( array("RailCraft","http://www.curse.com/mc-mods/minecraft/railcraft",23,0), array("Tinker's Construct","http://www.curse.com/mc-mods/minecraft/tinkers-construct",31,-4), );
  8. Ok I got working code with a final value "version" that I can use with this code <?php echo nl2br("\nRailcraft",false); $page = file_get_contents("http://www.curse.com/mc-mods/minecraft/railcraft"); $posStart = strpos($page, "Newest File: ")+23; echo nl2br("\nStart " . $posStart,false); $posStop = strpos($page, "<",$posStart); echo nl2br("\nStop " . $posStop,false); $version = substr($page, $posStart, $posStop-$posStart); echo nl2br("\nversion " . $version,false); echo nl2br("\nTinker's Construct",false); $page = file_get_contents("http://www.curse.com/mc-mods/minecraft/tinkers-construct"); $posStart = strpos($page, "Newest File: ")+31; echo nl2br("\nStart " . $posStart,false); $posStop = strpos($page, "<",$posStart)-4; echo nl2br("\nStop " . $posStop,false); $version = substr($page, $posStart, $posStop-$posStart); echo nl2br("\nversion " . $version,false); ?> However for every entry there will be 3 things I will have to know that will be different: page, posStart, and posStop. I was wondering what would be the best way to organise these. I was thinking some kind of array but have no idea if that's possible or if it's even the best solution. I would need something such as (using the two above examples): Railcraft page = http://www.curse.com/mc-mods/minecraft/railcraft posStartModifier = 23posStopModifer = -0 Tinker's Construct page = http://www.curse.com/mc-mods/minecraft/tinkers-construct posStartModifier =31; posStopModifer = -4; If you think I should start a new thread let me know since my original question is solved.
  9. I read that but misunderstood it the first time. Thanks for clearing that up.
  10. So does this mean I should use strpos since this will be running on 100s if not 1000s of pages at once in the end when it's done for the best performance.
  11. I just looked at http://php.net/manual/en/function.preg-match.php but didn't really understand it. In the end I need a string (it can be one of the array elements) that has a value of exactly "9.4 .0.0". How would I go about this and if you can either explain the code and/or link me to a good source of info on preg_match? Thank You!
  12. Sorry I was making my last post and didn't see it till after I posted mine. Just wondering though what makes your way different than mine (other than obviously the code )
  13. Sorry for the triple post but I can't edit posts I had errors in concatenation and one variable was wrong. Now it shows everything but the version. The output is "Start 22228Stop 22258version" This is the current code: <?php$page = file_get_contents("http://www.curse.com/mc-mods/minecraft/railcraft"); $posStart = strpos($page, "Newest File: "); echo "Start " . $posStart; $posStop = strpos($page, "<",$posStart); echo "Stop " . $posStop; $version = substr($posStart,$posStop); echo "version " . $version; ?>
  14. Ok this is what I got so far. It's not erroring but also not displaying anything. For now I'm just echoing to make sure it's working with be only being interested in the last line being "9.4.0.0" as of right now! <?php $page = file_get_contents("http://www.curse.com/mc-mods/minecraft/railcraft"); $posStart = strpos($page, "Newest File: "); echo "Start " $posStart; $posStop = strpos($page, "<",$startPos); echo "Stop " $posStop; $version = substr($posStart,$posStop); echo $version; ?>
  15. Though this looked good at first glance, the project seems to no longer be downloadable on sourceforge. This is what I'm probably going to use. As of right now it just simply returns the entire page as if I was looking at it on its regular site. Using RegExp I'm guessing there is a way to search for specific content on the page. How would I do this. I think finding the line " <li class="newest-file">Newest File: Railcraft 9.4.0.0</li>" would be the best way?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.