DarkeSword Posted October 11, 2007 Share Posted October 11, 2007 So here's a fun little PHP script I whipped up. It redirects you to a random OCReMix by me. <?srand(time());$mixes = array('01095', '01178', '01463', '00758', '01154', '01069', '01235', '01374', '01316', '01286', '01507', '01343', '01044', '00982', '01129', '00943', '01010', '01591', '01079');$random = (rand()%count($mixes));$destination = 'http://www.ocremix.org/remix/OCR' . $mixes[$random] . '/';header( "Location:" . $destination ); ?> The remix ID numbers are stored in the $mixes array; if you want to specify your own mixes, just replace the numbers I have there with your own 5-digit ID numbers for your mixes. You can find the remix id number in the remix's URL. Ex: ocremix.org/remix/OCR01591 01591 is the remix id number for my Twilight Princess remix. Replace the numbers and save the code to a .php file and store it on a server that lets you use PHP. Then, whenever you point your browser to that file, it'll redirect you. I've got mine stored here: http://darkesword.com/randommix.php Quote Link to comment Share on other sites More sharing options...
Liontamer Posted October 11, 2007 Share Posted October 11, 2007 Nice work. Quote Link to comment Share on other sites More sharing options...
OceansAndrew Posted October 11, 2007 Share Posted October 11, 2007 Cool stuff, I would totally use this on my blog to randomly play my remix. Is this code similar to the Russian ReMix Roulette? Would things break if I added every ReMix into the array? Quote Link to comment Share on other sites More sharing options...
Dhsu Posted October 11, 2007 Share Posted October 11, 2007 I don't suppose there's a way to automatically seed the array using the results from a search? For example, you could create an interface that pretty much piggybacks onto the quicksearch, but instead of returning every result, it'll give you a random one. Quote Link to comment Share on other sites More sharing options...
Kanthos Posted October 11, 2007 Share Posted October 11, 2007 It wouldn't be hard to set that up, but you would, of course, need access to the site code. The remix numbers would just be records returned from a database; it'd be easy to put them in an array and then randomly play one. Quote Link to comment Share on other sites More sharing options...
Dhsu Posted October 11, 2007 Share Posted October 11, 2007 Either that, or just parse out the remix URLs from the HTML, and return a random one. Quote Link to comment Share on other sites More sharing options...
DarkeSword Posted October 11, 2007 Author Share Posted October 11, 2007 Either that, or just parse out the remix URLs from the HTML, and return a random one. Yeah, but really that kind of stuff is way easier to do if you have access to the site code. I don't (and I don't want it). As far as breaking the array, I'm not really sure, but it would be easier to make an array with all of the IDs for the removed remixes, set the randomization to the highest ID number on OCR, and then use an if-else statement to make sure you're always redirected to a valid remix. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.