Skip to content

Commit

Permalink
Fixed some bugs
Browse files Browse the repository at this point in the history
Links are now working properly
Coded a different condition to show the Bakery or not in the "Show Soon"
building list
  • Loading branch information
iopietro committed Apr 8, 2018
1 parent 5bde1fe commit 4b1481f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Templates/Build/avaliable.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ if($workshop == 0 && $academy <= 9 && $academy >= 5 && $mainbuilding >= 2 && $ma
if($tournamentsquare == 0 && $rallypoint <= 14 && $rallypoint >= 7) {
include("soon/tsquare.tpl");
}
if($bakery == 0 && $grainmill >= 1 && $grainmill <= 5 || $cropland >= 5 && $cropland <= 10 || $mainbuilding >= 2 && $mainbuilding <= 5) {
if($bakery == 0 && ($grainmill >= 1 && $cropland >= 5 || $mainbuilding >= 2 && ($grainmill >= 1 || $cropland >= 5))) {
include("soon/bakery.tpl");
}
if($townhall == 0 && ($mainbuilding <= 9 && $mainbuilding >= 5) || ($academy >= 5 && $academy <= 9)) {
Expand Down
20 changes: 10 additions & 10 deletions Templates/Profile/preference.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ if($_POST) {
foreach($_POST as $key => $value) {
if(substr($key, 0, 2) == 'nr') {
$i = substr($key, 2);
$links[$i]['nr'] = mysqli_real_escape_string($GLOBALS['link'],$value);
$links[$i]['nr'] = mysqli_real_escape_string($database->dblink, $value);
}

if(substr($key, 0, 2) == 'id') {
$i = substr($key, 2);
$links[$i]['id'] = mysqli_real_escape_string($GLOBALS['link'],$value);
$links[$i]['id'] = mysqli_real_escape_string($database->dblink, $value);
}

if(substr($key, 0, 8) == 'linkname') {
$i = substr($key, 8);
$links[$i]['linkname'] = mysqli_real_escape_string($GLOBALS['link'],$value);
$links[$i]['linkname'] = mysqli_real_escape_string($database->dblink, $value);
}

if(substr($key, 0, 8) == 'linkziel') {
$i = substr($key, 8);
$links[$i]['linkziel'] = mysqli_real_escape_string($GLOBALS['link'],$value);
$links[$i]['linkziel'] = mysqli_real_escape_string($database->dblink, $value);
}
}

Expand All @@ -53,28 +53,28 @@ if($_POST) {
// Add new link
$userid = (int) $session->uid;
if($session->access!=BANNED){
$query = mysqli_query($GLOBALS['link'],'INSERT INTO `' . TB_PREFIX . 'links` (`userid`, `name`, `url`, `pos`) VALUES (' . $userid . ', \'' . $link['linkname'] . '\', \'' . $link['linkziel'] . '\', ' . $link['nr'] . ')');
$query = mysqli_query($database->dblink,'INSERT INTO `' . TB_PREFIX . 'links` (`userid`, `name`, `url`, `pos`) VALUES (' . $userid . ', \'' . $link['linkname'] . '\', \'' . $link['linkziel'] . '\', ' . $link['nr'] . ')');
}else{
header("Location: banned.php");
exit;
}
} elseif(trim($link['nr']) != '' AND trim($link['linkname']) != '' AND trim($link['linkziel']) != '' AND trim($link['id']) != '') {
// Update link
$query = mysqli_query($GLOBALS['link'],'SELECT userid FROM `' . TB_PREFIX . 'links` WHERE `id` = ' . $link['id']);
$query = mysqli_query($database->dblink,'SELECT userid FROM `' . TB_PREFIX . 'links` WHERE `id` = ' . $link['id']);
$data = mysqli_fetch_assoc($query);
// May the user update this entry?
if($data['userid'] == $session->uid) {
$query2 = mysqli_query($GLOBALS['link'],'UPDATE `' . TB_PREFIX . 'links` SET `name` = \'' . $link['linkname'] . '\', `url` = \'' . $link['linkziel'] . '\', `pos` = ' . $link['nr'] . ' WHERE `id` = ' . $link['id']);
$query2 = mysqli_query($database->dblink,'UPDATE `' . TB_PREFIX . 'links` SET `name` = \'' . $link['linkname'] . '\', `url` = \'' . $link['linkziel'] . '\', `pos` = ' . $link['nr'] . ' WHERE `id` = ' . $link['id']);
}
} elseif(trim($link['nr']) == '' AND trim($link['linkname']) == '' AND trim($link['linkziel']) == '' AND trim($link['id']) != '') {
// Delete entry
$query = mysqli_query($GLOBALS['link'],'SELECT userid FROM `' . TB_PREFIX . 'links` WHERE `id` = ' . $link['id']);
$query = mysqli_query($database->dblink,'SELECT userid FROM `' . TB_PREFIX . 'links` WHERE `id` = ' . $link['id']);
$data = mysqli_fetch_assoc($query);
// May the user delete this entry?
if($data['userid'] == $session->uid) {
$query2 = mysqli_query($GLOBALS['link'],'DELETE FROM `' . TB_PREFIX . 'links` WHERE `id` = ' . $link['id']);
$query2 = mysqli_query($database->dblink,'DELETE FROM `' . TB_PREFIX . 'links` WHERE `id` = ' . $link['id']);
}
}
}
Expand All @@ -84,7 +84,7 @@ if($_POST) {


// Fetch all links
$query = mysqli_query($GLOBALS['link'],'SELECT * FROM `' . TB_PREFIX . 'links` WHERE `userid` = ' . (int) $session->uid . ' ORDER BY `pos` ASC') or die(mysqli_error($database->dblink));
$query = mysqli_query($database->dblink,'SELECT * FROM `' . TB_PREFIX . 'links` WHERE `userid` = ' . (int) $session->uid . ' ORDER BY `pos` ASC') or die(mysqli_error($database->dblink));
$links = array();
while($data = mysqli_fetch_assoc($query)) {
$links[] = $data;
Expand Down

0 comments on commit 4b1481f

Please sign in to comment.