Hey guys
I was just mucking around with the script for the database, and i think i got it. most of it is straight forward, what was lacking from the example was exactly that, an example instead of just xxxxxxxxxx
From what i could see, the database had 2 tables, one called files, and the other of your choice, i made a little example of one using just the 1 table called files, with the name and filepath as fields.
<?php
$db_server = "localhost"; /// insert server name
$db_user = "root"; /// insert username
$db_password = ""; /// insert password
$db_database = "maps"; /// insert database name
//
// Connect to the DB
//
if(!mysql_connect($db_server, $db_user, $db_password)) exit("error"); // Just return the word "error" so MMDL understands it
if(!mysql_select_db($db_database)) exit("error");
//
// Get the map link
//
$query = mysql_query("
SELECT `files`.`name` AS `file_id`,
`files`.`filepath` AS `file_path`
FROM `files`
WHERE `files`.`name` = '".mysql_real_escape_string($_GET['map'])."'
LIMIT 1
");
if(!$query) exit("error");
//
// Return the link
//
$record = mysql_fetch_assoc($query);
if (!$record) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
if(!$record) exit("404"); // MMDL understands "404" too
exit("http://www.eggplant.com.au/uploads/banana/".str_replace(" ", "%20", $record['file_path'])); /// replace with url of actual files.
?>
With the following little table and sample data
CREATE TABLE IF NOT EXISTS `files` (
`id` int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
`name` varchar(30) NOT NULL,
`filepath` varchar(30) NOT NULL
);
INSERT INTO files (name, filepath)
VALUES
('dm/mohdm1', 'dm/mohdm1.pk3'),
('dm/mohdm2', 'dm/mohdm2.pk3'),
('dm/mohdm3', 'dm/mohdm3.pk3'),
('dm/mohdm4', 'dm/mohdm4.pk3'),
('dm/mohdm5', 'dm/mohdm5.pk3'),
('dm/mohdm6', 'dm/mohdm6.pk3');
you can call the script whatever you want, but guide the MMDL url to the correct script
I was testing on localhost
http://localhost/download/index.php?map=dm/mohdm2
BOLD parts would be the base url , and then it adds the name it needs.
But i do not see why it really even needs the database, for small collections anyway. I can see why it would need them in bigger databases with thousands of maps, but if you are hosting your own, you really dont need it.
Just a basic script that will turn the map name into the filepath, ie if you call each map.pk3 the name of the map. dm/mohdm1 would be dm/mohdm1.pk3 .
Example
<?php
$map = $_GET['map'];
exit("http://www.eggplant.com.au/uploads/banana/".str_replace(" ", "%20", $map).'.pk3');
?>
Would suffice.