2moons /includes/functions/CreateOneMoonRecord.php

Language PHP Lines 82
MD5 Hash 782b668dd4a1ba626eb13908af27d9fa Estimated Cost $1,090 (why?)
Repository https://bitbucket.org/VolCh/2moons.git View Raw File View Project SPDX
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php

/**
 *  2Moons
 *  Copyright (C) 2012 Jan Kröpke
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @package 2Moons
 * @author Jan Kröpke <info@2moons.cc>
 * @copyright 2012 Jan Kröpke <info@2moons.cc>
 * @license http://www.gnu.org/licenses/gpl.html GNU GPLv3 License
 * @version 1.7.1 (2013-01-18)
 * @info $Id$
 * @link http://2moons.cc/
 */

function CreateOneMoonRecord($Galaxy, $System, $Planet, $Universe, $Owner, $MoonName, $Chance, $time = 0, $Size = 0)
{
	global $USER;

	$SQL  = "SELECT id_luna,planet_type,id,name,temp_max,temp_min FROM ".PLANETS." ";
	$SQL .= "WHERE ";
	$SQL .= "universe = '".$Universe."' AND ";
	$SQL .= "galaxy = '".$Galaxy."' AND ";
	$SQL .= "system = '".$System."' AND ";
	$SQL .= "planet = '".$Planet."' AND ";
	$SQL .= "planet_type = '1';";
	$MoonPlanet = $GLOBALS['DATABASE']->getFirstRow($SQL);

	if ($MoonPlanet['id_luna'] != 0)
		return false;

	if($Size == 0) {
		$size	= floor(pow(mt_rand(10, 20) + 3 * $Chance, 0.5) * 1000); # New Calculation - 23.04.2011
	} else {
		$size	= $Size;
	}
	
	$maxtemp	= $MoonPlanet['temp_max'] - mt_rand(10, 45);
	$mintemp	= $MoonPlanet['temp_min'] - mt_rand(10, 45);

	$GLOBALS['DATABASE']->multi_query("INSERT INTO ".PLANETS." SET
					  name = '".$MoonName."',
					  id_owner = ".$Owner.",
					  universe = ".$Universe.",
					  galaxy = ".$Galaxy.",
					  system = ".$System.",
					  planet = ".$Planet.",
					  last_update = ".TIMESTAMP.",
					  planet_type = '3',
					  image = 'mond',
					  diameter = ".$size.",
					  field_max = '1',
					  temp_min = ".$mintemp.",
					  temp_max = ".$maxtemp.",
					  metal = 0,
					  metal_perhour = 0,
					  crystal = 0,
					  crystal_perhour = 0,
					  deuterium = 0,
					  deuterium_perhour = 0;
					  SET @moonID = LAST_INSERT_ID();
					  UPDATE ".PLANETS." SET
					  id_luna = @moonID
					  WHERE
					  id = ".$MoonPlanet['id'].";");

	return true;
}
Back to Top