Parašė lekas11121· 2014 Sau. 29 19:01:16
#4
<?php
/*---------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2008 Nick Jones
| http://www.php-fusion.co.uk/
+----------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+----------------------------------------------------+
| CSS SERVER PANEL By Polk077 2009
| wwww.beststation.eu - lukas.siska@seznam.cz
+----------------------------------------------------*/
require_once "../../maincore.php";
require_once THEMES."templates/admin_header.php";
if (!iADMIN) { redirect(BASEDIR."index.php"); }
require_once ADMIN."navigation.php";
if (!defined("IN_FUSION")) { die("Access Denied"); }
if (file_exists(INFUSIONS."css_server_panel/locale/".$settings['locale'].".php")) { include INFUSIONS."css_server_panel/locale/".$settings['locale'].".php"; }
else { include INFUSIONS."css_server_panel/locale/Lithuanian.php"; }
$display = "";
$Error_Display = "";
if (isset($_GET['action']))
{
$action = $_GET['action'];
$id = $_GET['id'];
if (isset($_GET['neworder']))
{
$neworder = $_GET['neworder'];
}
}
else
{
$action = "";
}
switch ($action){
case "Remove":
$display = Remove_Server($id);
$display = "<tr><td colspan='7' class='tbl2'>".$display."</td></tr>";
break;
case "Edit":
break;
case "mvup":
move_order_up($id,$neworder);
@redirect ("css_server_admin.php");
break;
case "mvdown":
move_order_down($id,$neworder);
@redirect ("css_server_admin.php");
}
if (isset($_POST['submit']))
{
foreach($_POST as $key=>$value)
{
$$key = $value;
}
$Error_Display = "";
$Error_Display = validate_entry($server_type,$server_name,$ip1,$ip2,$ip3,$ip4,$server_port);
If ($Error_Display != "")
{
$Error_Display = "<tr><td colspan='7' class='tbl2'>".$Error_Display."</td></tr>";
}
}
// Serverių sąrašas
$server_list = admin_server_list();
opentable($locale['CSS_SERVER_001']);
echo "<table width='100%' valign='top' cellpadding='1' cellspacing='1' class='tbl-border'>
<tr>
<td align='center' valign='middle' width='10' class='tbl2'></td>
<td align='left' valign='middle' class='tbl2'>".$locale['CSS_SERVER_003']."</td>
<td align='center' valign='middle' class='tbl2' width='150'>".$locale['CSS_SERVER_004']."</td>
<td align='center' valign='middle' class='tbl2' width='100'>".$locale['CSS_SERVER_005']."</td>
<td align='center' valign='middle' class='tbl2' colspan='2'>".$locale['CSS_SERVER_012']."</td>
<td align='center' valign='middle' class='tbl2' width='200'>".$locale['CSS_SERVER_006']."</td>
</tr>
".$server_list."
".$display."
</table>";
closetable();
echo "<BR>";
opentable($locale['CSS_SERVER_002']);
echo "<form name='add_server' method='post' action='css_server_admin.php'>
<table width='100%' valign='top' cellpadding='1' cellspacing='1' class='tbl-border'>
".$Error_Display."
<tr>
<td class='tbl2' width='2%' align='right'>Pasirinkite žaidima:</td>
<td class='tbl2' colspan='3'>
<select size='1' class='tbl2' name='server_type'>
<option value='Counter Strike Source'>Counter Strike Source</option>
<option value='CounterStrike 1.6'>CounterStrike 1.6</option>
<option value='GTA:SAMP'>GTA:SAMP</option>
<option value='TeamSpeak'>TeamSpeak</option>
</select>
</td>
</tr>
<tr>
<td class='tbl2' width='2%' align='right'>Serverio pavadinimas:</td>
<td class='tbl2' colspan='3'>
<input type='text' size='130' class='tbl2' name='server_name'>
</td>
</tr>
<tr>
<td class='tbl2' width='2%' align='right'>IP Adresas:</td>
<td class='tbl2' width='5%'>
<input type='text' class='tbl2' size='2' maxlength='3' name='ip1'>.
<input type='text' class='tbl2' size='2' maxlength='3' name='ip2'>.
<input type='text' class='tbl2' size='2' maxlength='3' name='ip3'>.
<input type='text' class='tbl2' size='2' maxlength='3' name='ip4'>
</td>
<td class='tbl2' align='right' width='1%'>Portalas:</td>
<td class='tbl2' width='10%'>
<input type='text' class='tbl2' size='6' maxlength='8' name='server_port'>
</td>
</tr>
<tr>
<td class='tbl2' align='left' width='100%' colspan='4'>
<input type='submit' class='button' value='Prideti' name='submit'>
<input type='reset' class='button' value='Išvalyti'>
</td>
</tr>
</table>
</form>";
closetable();
echo "</td>\n";
//Funkcijos
Function validate_entry($type,$name,$ip1,$ip2,$ip3,$ip4,$port)
{
global $db_prefix;
$error_output = "";
if (strlen($name) <= -1) { $error_output .= "ProsĆm zadejte nĆzev serveru.<BR>"; }
if (strlen($ip1) <= -1 || !isDigits($ip1) || $ip1 <= -1 || $ip1 >= 255) { $error_output .= "ProsĆm zadejte ĨĆslo mezi 0 a 255 v prvnĆ koloce IP Adresy<BR>"; }
if (strlen($ip2) <= -1 || !isDigits($ip2) || $ip2 <= -1 || $ip2 >= 255){ $error_output .= "ProsĆm zadejte ĨĆslo mezi 0 a 255 v druhĆ© koloce IP Adresy<BR>"; }
if (strlen($ip3) <= -1 || !isDigits($ip3) || $ip3 <= -1 || $ip3 >= 255){ $error_output .= "ProsĆm zadejte ĨĆslo mezi 0 a 255 v tÅ™etĆ koloce IP Adresy<BR>"; }
if (strlen($ip4) <= -1 || !isDigits($ip4) || $ip4 <= -1 || $ip4 >= 255){ $error_output .= "ProsĆm zadejte ĨĆslo mezi 0 a 255 v ĨtvrtĆ© koloce IP Adresy<BR>"; }
if (strlen($port) <= -1) { $error_output .= "ProsĆm zadejte port serveru."; }
if ($error_output == "")
{
switch ($type) {
case "Counter Strike Source":
$image = "images/css.gif";
break;
case "TeamSpeak":
$image = "images/ts.gif";
break;
case "GTA:SAMP":
$image = "images/samp.gif";
break;
case "CounterStrike 1.6":
$image = "images/cs.png";
break;
}
$result = dbquery("SELECT * FROM ".$db_prefix."css_polk_servers ORDER BY css_polk_server_order DESC LIMIT 1");
if (dbrows($result) != 0) { $data = dbarray($result); $neworder = $data['css_polk_server_order'] + 1; } else { $neworder = 1; }
$SQL = "INSERT INTO ".$db_prefix."css_polk_servers";
$SQL .= "(css_polk_server_Name,css_polk_server_address,css_polk_server_port,css_polk_server_image,css_polk_server_type,css_polk_server_order) ";
$SQL .= "VALUES ('".$name."','".$ip1.".".$ip2.".".$ip3.".".$ip4."','".$port."','".$image."','".$type."','".$neworder."')";
$result = dbquery($SQL);
$error_output = "Added ".$name." Server Successfully.";
}
return $error_output;
}
Function Admin_Server_List()
{
global $locale;
global $db_prefix;
$result = dbquery("SELECT * FROM ".$db_prefix."css_polk_servers ORDER BY css_polk_server_order ASC");
$rows = dbrows($result);
If ($rows != 0)
{
$i=0;
while($data = dbarray($result))
{
$i++;
if ($rows != 1)
{
$up = $data['css_polk_server_order'] - 1;
$down = $data['css_polk_server_order'] + 1;
if ($i == 1)
{
$arrows = "<a href='css_server_admin.php?action=mvdown&id=".$data['css_polk_server_id']."&neworder=".$down."'><img src='".THEME."images/down.gif' border='0'></a>";
}
elseif ($i < $rows)
{
$arrows = "<a href='css_server_admin.php?action=mvup&id=".$data['css_polk_server_id']."&neworder=".$up."'><img src='".THEME."images/up.gif' border='0'><a href='css_server_admin.php?action=mvdown&id=".$data['css_polk_server_id']."&neworder=".$down."'><img src='".THEME."images/down.gif' border='0'></a>";
}
else
{
$arrows = "<a href='css_server_admin.php?action=mvup&id=".$data['css_polk_server_id']."&neworder=".$up."'><img src='".THEME."images/up.gif' border='0'>";
}
}
else
{
$arrows = "";
}
$list = "<tr><td align='center' valign='middle' class='tbl1' width='10'><img src='".$data['css_polk_server_image']."'></td>
<td align='left' valign='middle' class='tbl1'>".$data['css_polk_server_Name']."</td>
<td align='center' valign='middle' class='tbl1'>".$data['css_polk_server_address']."</td>
<td align='center' valign='middle' class='tbl1'>".$data['css_polk_server_port']."</td>
<td align='center' valign='middle' class='tbl1' width='40'>".$data['css_polk_server_order']."</td>";
$list .= "<td align='center' valign='middle' class='tbl1' width='30'>".$arrows."</td>";
$list .= "<td align='center' valign='middle' class='tbl1'><a href='css_server_admin.php?action=Remove&id=".$data['css_polk_server_id']."'>Ištrinti</a></td></tr>";
}
}
else
{
$list = "<tr><td align='center' valign='middle' colspan='7'>".$locale['CSS_SERVER_105']."</td></tr>";
}
return $list;
}
function remove_server($id)
{
global $db_prefix;
$result = dbquery("SELECT * FROM ".$db_prefix."css_polk_servers where css_polk_server_id =".$id);
$data = dbarray($result);
$remove_order = $data['css_polk_server_order'];
$SQL = "DELETE FROM ".$db_prefix."css_polk_servers";
$SQL .= " WHERE css_polk_server_id = ".$id;
$result = dbquery($SQL);
$result = dbquery("SELECT * FROM ".$db_prefix."css_polk_servers ORDER BY css_polk_server_order ASC");
$rows = dbrows($result);
if ($rows != 0)
{
while($data = dbarray($result))
{
if ($data['css_polk_server_order'] > $remove_order)
{
$new_order = $data['css_polk_server_order'] - 1;
$SQL = "UPDATE ".$db_prefix."css_polk_servers ";
$SQL .= "SET css_poplk_server_order =".$new_order;
$SQL .= " where css_polk_server_id =".$data['css_polk_server_id'];
$result_1 = dbquery($SQL);
}
}
}
return "";
}
function isDigits($element) {
return !preg_match ("/[^0-9]/", $element);
}
function move_order_up($id,$neworder)
{
global $db_prefix;
$data = dbarray(dbquery("SELECT * FROM ".$db_prefix."css_polk_servers WHERE css_polk_server_order=".$neworder));
$SQL = "UPDATE ".$db_prefix."css_polk_servers SET css_polk_server_order=$neworder+1";
$SQL .= " WHERE css_polk_server_order=".$data['css_polk_server_order'];
$result = dbquery($SQL);
$SQL = "UPDATE ".$db_prefix."css_polk_servers SET css_polk_server_order=$neworder";
$SQL .= " WHERE css_polk_server_id=".$id;
$result = dbquery($SQL);
}
function move_order_down($id,$neworder)
{
global $db_prefix;
$data = dbarray(dbquery("SELECT * FROM ".$db_prefix."css_polk_servers WHERE css_polk_server_order=".$neworder));
$SQL = "UPDATE ".$db_prefix."css_polk_servers SET css_polk_server_order=$neworder-1";
$SQL .= " WHERE css_polk_server_order=".$data['css_polk_server_order'];
$result = dbquery($SQL);
$SQL = "UPDATE ".$db_prefix."css_polk_servers SET css_polk_server_order=$neworder";
$SQL .= " WHERE css_polk_server_id=".$id;
$result = dbquery($SQL);
}
require_once THEMES."templates/footer.php";
?>