Skip to content

Commit 0827143

Browse files
author
Josh
authored
Merge pull request #44 from paintballrefjosh/bug-fixes
Bug fixes
2 parents d853105 + 18d3ab9 commit 0827143

13 files changed

+96
-48
lines changed

core/SDL/class.account.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function check()
8383
}
8484

8585
// Make sure the activation code is NULL in the DB
86-
if($res['activation_code'] != NULL)
86+
if($res['locked'] == 1)
8787
{
8888
$this->setgroup();
8989
return false;
@@ -169,8 +169,8 @@ function login($params)
169169
return 4;
170170
}
171171

172-
// If the activation code is not NULL, the account is not activated, return 5
173-
if($res2['activation_code'] != NULL)
172+
// If the account is locked or "inactive" then return 5, do not allow login
173+
if($res['locked'] == 1)
174174
{
175175
$success = 0;
176176
return 5;

core/SDL/class.rasocket.php

+16-18
Original file line numberDiff line numberDiff line change
@@ -209,16 +209,16 @@ private function writeDebugLog()
209209
Returns 2 if it's not authenticated
210210
@param $command the command to enter on console
211211
*/
212-
public function executeCommand($type, $shost, $remote, $command)
212+
public function executeCommand($type, $host, $port, $user, $pass, $command)
213213
{
214214
if($type == 0)
215215
{
216-
if(!$this->connect($shost, $remote[1]))
216+
if(!$this->connect($host, $port))
217217
{
218218
return 0;
219219
}
220220

221-
if(!$this->auth($remote[2], $remote[3]))
221+
if(!$this->auth($user, $pass))
222222
{
223223
return 2;
224224
}
@@ -272,7 +272,7 @@ public function executeCommand($type, $shost, $remote, $command)
272272
}
273273
else # type is SOAP
274274
{
275-
$client = $this->soapHandle($shost, $remote);
275+
$client = $this->soapHandle($host, $port, $user, $pass);
276276
// If multiple commands
277277
if(is_array($command))
278278
{
@@ -338,29 +338,29 @@ public function executeCommand($type, $shost, $remote, $command)
338338

339339
// ************************************************************
340340
// Setups the Soap Handle
341-
private function soapHandle($shost, $remote)
341+
private function soapHandle($host, $port, $user, $pass)
342342
{
343343
global $mwe_config;
344344
if($mwe_config['emulator'] == 'mangos')
345345
{
346346
$client = new SoapClient(NULL,
347347
array(
348-
"location" => "http://".$shost.":".$remote[1]."/",
348+
"location" => "http://".$host.":".$port."/",
349349
"uri" => "urn:MaNGOS",
350350
"style" => SOAP_RPC,
351-
"login" => $remote[2],
352-
"password" => $remote[3]
351+
"login" => $user,
352+
"password" => $pass
353353
));
354354
}
355355
else
356356
{
357357
$client = new SoapClient(NULL,
358358
array(
359-
"location" => "http://".$shost.":".$remote[1]."/",
359+
"location" => "http://".$host.":".$port."/",
360360
"uri" => "urn:TC",
361361
"style" => SOAP_RPC,
362-
"login" => $remote[2],
363-
"password" => $remote[3]
362+
"login" => $user,
363+
"password" => $pass
364364
));
365365
}
366366
return $client;
@@ -378,17 +378,15 @@ private function soapHandle($shost, $remote)
378378
*/
379379
function send($command, $realm)
380380
{
381-
global $RDB;
381+
global $RDB, $DB;
382382

383383
// Get the remote access information from the realm database
384-
$get_remote = $RDB->selectRow("SELECT * FROM `realmlist` WHERE id='".$realm."'");
385-
$remote = explode(';', $get_remote['ra_info']);
386-
$shost = $get_remote['address'];
387-
384+
$remote = $DB->selectRow("SELECT ra_type, ra_port, ra_user, ra_pass FROM `mw_realm` WHERE `realm_id`='".$realm."'");
385+
$host = $RDB->selectCell("SELECT `address` FROM `realmlist` WHERE `id` = '$realm'");
388386
// Make sure the remote access type is either 1 or 0
389-
if($remote[0] == 0 || $remote[0] == 1)
387+
if((int)$remote['ra_type'] == 0 || (int)$remote['ra_type'] == 1)
390388
{
391-
$result = $this->executeCommand($remote[0], $shost, $remote, $command);
389+
$result = $this->executeCommand($remote['ra_type'], $host, $remote['ra_port'], $remote['ra_user'], $remote['ra_pass'], $command);
392390
if($result != 1)
393391
{
394392
if($result == 0)

core/class.database.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function count($query)
140140
{
141141
$sql = mysqli_query($this->mysql, $query) or die("Couldnt Run Query: ".$query."<br />Error: ".mysqli_error($this->mysql)."");
142142
$this->_statistics['count']++;
143-
return (int)mysqli_fetch_assoc($sql);
143+
return mysqli_num_rows($sql);
144144
}
145145

146146
// ************************************************************

core/core.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
class Core
1212
{
13-
public $version = '4.1.1';
14-
public $version_date = '2017-03-29, 13:17';
13+
public $version = '4.1.2';
14+
public $version_date = '2017-04-02, 15:41';
1515
public $db_version = '4.1.0';
1616
private $conf;
1717

inc/admin/script_files/admin.news.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function addNews($subj,$message,$un)
2626
else
2727
{
2828
$post_time = time();
29-
$sql = "INSERT INTO mw_news(title, message, posted_by, post_time) VALUES('".$subj."','".$message."','".$un."','".$post_time."')";
29+
$sql = "INSERT INTO mw_news(title, message, posted_by, post_time) VALUES('".$DB->real_escape_string($subj)."','".$DB->real_escape_string($message)."','".$un."','".$post_time."')";
3030
$tabs = $DB->query($sql);
3131

3232
output_message('success', $lang['news_add_success']);
@@ -41,7 +41,7 @@ function editNews($idz,$mess)
4141
}
4242
else
4343
{
44-
$DB->query("UPDATE `mw_news` SET `message`='$mess' WHERE `id`='$idz'");
44+
$DB->query("UPDATE `mw_news` SET `message`='".$DB->real_escape_string($mess)."' WHERE `id`='$idz'");
4545

4646
output_message('success', $lang['news_edit_success']);
4747
}

inc/admin/script_files/admin.realms.php

+11
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ function updateRealm()
4040
if(empty($_POST['db_char_port']))
4141
$_POST['db_char_port'] = 0;
4242

43+
if(empty($_POST['ra_port']))
44+
$_POST['ra_port'] = 0;
45+
4346
if($realm > 0)
4447
{
4548
$DB->query("UPDATE `mw_realm` SET
@@ -53,6 +56,10 @@ function updateRealm()
5356
`db_char_port` = '".$_POST['db_char_port']."',
5457
`db_char_user` = '".$_POST['db_char_user']."',
5558
`db_char_pass` = '".$_POST['db_char_pass']."',
59+
`ra_type` = '".$_POST['ra_type']."',
60+
`ra_port` = '".$_POST['ra_port']."',
61+
`ra_user` = '".$_POST['ra_user']."',
62+
`ra_pass` = '".$_POST['ra_pass']."',
5663
`site_enabled` = '".$_POST['site_enabled']."'
5764
WHERE `realm_id` = ".$_GET['id']."
5865
");
@@ -70,6 +77,10 @@ function updateRealm()
7077
`db_char_port` = '".$_POST['db_char_port']."',
7178
`db_char_user` = '".$_POST['db_char_user']."',
7279
`db_char_pass` = '".$_POST['db_char_pass']."',
80+
`ra_type` = '".$_POST['ra_type']."',
81+
`ra_port` = '".$_POST['ra_port']."',
82+
`ra_user` = '".$_POST['ra_user']."',
83+
`ra_pass` = '".$_POST['ra_pass']."',
7384
`site_enabled` = '".$_POST['site_enabled']."',
7485
`realm_id` = ".$_GET['id'].";
7586
");

inc/admin/template_files/admin.realms.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,14 @@
1717
if(isset($_GET['id']))
1818
{
1919
$rlm = $RDB->selectRow("SELECT * FROM `realmlist` WHERE `id`='".$_GET['id']."'");
20-
$rlm_ext = $DB->selectRow("SELECT * FROM mw_realm WHERE realm_id = '".$_GET['id']."'");
20+
$rlm_ext = $DB->selectRow("SELECT * FROM `mw_realm` WHERE `realm_id` = '".$_GET['id']."'");
2121

22-
$db_info = explode( ';', $rlm['dbinfo'] ) ;
23-
$ra_info = explode( ';', $rlm['ra_info'] ) ;
2422
?>
2523

2624
<!-- EDITING A REALM -->
2725
<div class="content">
2826
<div class="content-header">
29-
<h4><a href="?p=admin">Main Menu</a> / <a href="?p=admin&sub=realms">Manage Realms</a> / Edit</h4>
27+
<h4><a href="?p=admin">Main Menu</a> / <a href="?p=admin&amp;sub=realms">Manage Realms</a> / Edit</h4>
3028
</div> <!-- .content-header -->
3129
<div class="main-content">
3230

@@ -253,7 +251,7 @@
253251
<!-- Ra Password -->
254252
<div class="field">
255253
<label for="dbh"><?php echo $lang['remote_access_pass']; ?>: </label>
256-
<input id="dbh" name="ra_pass" size="20" type="text" class="medium" value="<?php echo $rlm_ext['ra_pass']; ?>" />
254+
<input id="dbh" name="ra_pass" size="20" type="password" class="medium" value="<?php echo $rlm_ext['ra_pass']; ?>" />
257255
<p class="field_help"><?php echo $lang['remote_access_pass_desc']; ?>.</p>
258256
</div>
259257

inc/frontpage/frontpage.index.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,12 @@
8989
}
9090
unset($CHDB_EXTRA, $data); // Free up memory.
9191

92-
$server['moreinfo'] = $mwe_config['fp_server_more_info'];
92+
if($mwe_config['fp_server_more_info'])
93+
{
94+
$server['moreinfo'] = $mwe_config['fp_server_more_info'];
95+
$server['moreinfourl'] = mw_url('server', 'statistic', $changerealmtoparam);
96+
}
97+
9398
$servers[] = $server;
9499
}
95100
}

inc/server/server.commands.php

+14-7
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,19 @@
3535
{
3636
$userlevel = 0;
3737
}
38-
39-
$permissions = $RDB->select("SELECT `rbac_linked_permissions`.`linkedId` FROM `rbac_linked_permissions`
40-
LEFT JOIN `rbac_default_permissions` ON (`rbac_linked_permissions`.`id` = `rbac_default_permissions`.`permissionId`)
41-
WHERE `rbac_default_permissions`.`secId` = <= $userlevel"
42-
);
43-
$permissions = join(",", $permissions);
44-
$alltopics = $WDB->select("SELECT * FROM `command` WHERE `permission` IN ($permissions) ORDER BY `name` ASC");
38+
$sql = "SELECT `rbac_linked_permissions`.`linkedId` FROM `rbac_linked_permissions`
39+
LEFT JOIN `rbac_default_permissions` ON (`rbac_linked_permissions`.`id` BETWEEN `rbac_default_permissions`.`permissionId` + 4 AND 199)
40+
WHERE `rbac_default_permissions`.`secId` <= $userlevel";
41+
$permissions = $RDB->select($sql);
42+
43+
$permission_id = "";
44+
foreach($permissions as $row)
45+
{
46+
$permission_id .= $row['linkedId'].",";
47+
}
48+
$permission_id = substr($permission_id, 0, -1);
49+
50+
$sql = "SELECT * FROM `command` WHERE `permission` IN ($permission_id) ORDER BY `name` ASC";
51+
$alltopics = $WDB->select($sql);
4552
}
4653
?>

inc/server/server.statistic.php

+8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212
echo "Not Included!"; exit;
1313
}
1414

15+
// Check to see if the changerealm_to variable is set in the URI. If so we need to set the selected
16+
// realm cookie and reload the page in order to pull the players online from the correct realm
17+
if(isset($_GET['changerealm_to']))
18+
{
19+
setcookie("cur_selected_realm", $_GET['changerealm_to'], time() + (3600 * 24 * 365));
20+
redirect("?p=server&sub=statistic",1);
21+
}
22+
1523
// build top of page navigation breadcrumbs
1624
$realm = $RDB->selectRow("SELECT * FROM realmlist WHERE `id`='".$user['cur_selected_realm']."' LIMIT 1");
1725
$pathway_info[] = array('title' => 'Server Statistics', 'link' => '?p=server&sub=statistic');

templates/blizzlike/body_right.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@
269269
?>
270270
<li>
271271
<div>
272-
<a href="<?php echo mw_url('server', 'info'); ?>"><?php echo $lang['more_info']; ?></a>
272+
<a href="<?php echo $server['moreinfourl']; ?>"><?php echo $lang['more_info']; ?></a>
273273
</div>
274274
</li>
275275

templates/blizzlike/server/server.commands.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
{
1515
$postnum++;
1616
if($hl=='alt')$hl=''; else $hl='alt';
17+
$topic_permission = $RDB->selectCell("SELECT `name` FROM `rbac_permissions` WHERE id IN (SELECT `id` FROM `rbac_linked_permissions` WHERE linkedId = ".$topic['permission'].")");
1718
?>
1819
<script type="text/javascript">
1920
var postId<?php echo $postnum;?>="<?php echo $postnum;?>";
@@ -50,7 +51,7 @@
5051
<li>
5152
<div class="letter-box0"></div>
5253
<div class="blog-post">
53-
<playerlevel><?php echo "Level : ".$topic['security']."<br/>";?></playerlevel>
54+
<playerlevel><?= $topic_permission; ?><br/></playerlevel>
5455
<description><?php echo str_replace("\r",'<br/>',$topic['help']);?></description>
5556
</div>
5657
</li>

update/index.php

+27-7
Original file line numberDiff line numberDiff line change
@@ -35,32 +35,52 @@
3535
}
3636

3737
$Update->check_for_updates();
38+
39+
$sql_file = "https://raw.githubusercontent.com/paintballrefjosh/MaNGOSWebV4/master/update/scripts/update_" . $Update->next_db_version . ".sql";
40+
$php_file = "https://raw.githubusercontent.com/paintballrefjosh/MaNGOSWebV4/master/update/scripts/update_" . $Update->next_db_version . ".php";
41+
$sql_headers = @get_headers($sql_file);
42+
$php_headers = @get_headers($php_file);
43+
3844
//die($db_act_ver . "---".$Core->db_version."---".$Update->next_db_version);
3945
if(file_exists("scripts/update_" . $Update->next_db_version . ".php"))
4046
{
4147
// check to see if there is a local PHP script to handle the SQL update
4248
include("scripts/update_" . $Update->next_db_version . ".php");
4349
}
44-
elseif(file_exists("https://raw.githubusercontent.com/paintballrefjosh/MaNGOSWebV4/master/update/scripts/update_" . $Update->next_db_version . ".php"))
50+
/*elseif(stripos($php_headers[0], "200 OK") >= 0) // disabling this feature due to default php settings not allowing remote files to be included
4551
{
4652
// check for online copy if no local copy exists of the PHP script
47-
include("https://raw.githubusercontent.com/paintballrefjosh/MaNGOSWebV4/master/update/scripts/update_" . $Update->next_db_version . ".php");
48-
}
53+
include($php_file);
54+
}*/
4955
else
5056
{
5157
// no script required for this DB update, proceed
5258
if(file_exists("scripts/update_" . $Update->next_db_version . ".sql"))
5359
{
5460
// check to see if there is a local SQL script and run
5561
$DB->runSQL("scripts/update_" . $Update->next_db_version . ".sql");
62+
?>
63+
64+
Database successfully updated using file: "scripts/update_<?= $Update->next_db_version; ?>.sql !!<br /><br />
65+
<a href="index.php">Go back</a> to check for additional updates.<br />
66+
67+
<?php
68+
5669
}
57-
elseif(file_exists("https://raw.githubusercontent.com/paintballrefjosh/MaNGOSWebV4/master/update/scripts/update_" . $Update->next_db_version . ".sql"))
70+
/* elseif(stripos($sql_headers[0], "200 OK") >= 0)
5871
{
5972
// check for online copy if no local copy exists of the SQL script
60-
$DB->runSQL("https://raw.githubusercontent.com/paintballrefjosh/MaNGOSWebV4/master/update/scripts/update_" . $Update->next_db_version . ".sql");
61-
}
73+
$DB->runSQL($sql_file);
74+
?>
75+
76+
Database successfully updated using file: <?= $sql_file; ?> !!<br /><br />
77+
<a href="index.php">Go back</a> to check for additional updates.<br />
78+
79+
<?php
80+
81+
}*/
6282
else
6383
{
64-
die("SQL update file not found!");
84+
die("SQL update file not found!<br /><br />Current DB Version: $db_act_ver <br />Expected DB Version: $Core->db_version <br />Next DB Version: $Update->next_db_version");
6585
}
6686
}

0 commit comments

Comments
 (0)