Witaj
Gość

Wątek: [Dzielę Pliki]Skrypty PHP  (Przeczytany 4788 razy)

  • *******
  • Wiadomości: 1092

  • Pochwał: 22

[Dzielę Pliki]Skrypty PHP
« dnia: Sierpień 10, 2009, 02:32:15 pm »
Przydatne skrypty php na stronę Twojego serwera. Oto one:

- Top Pk:

<?
require ("config.php");
$col = 0;
echo "<table align = 'center' width = '500'><tr>";
$query = "Select char_name,pkkills from characters where pkkills>0 order by pkkills desc";
$mk = mysql_query($query);
while ($a = mysql_fetch_array($mk))
{
$name = $a['char_name'];
$kills = $a['pkkills'];
if ($col<5) {echo "<td>".$kills." ".$name."</td>"; $col ++;} else {if ($col==5) {echo "</tr><tr><td>".$kills." ".$name."</td>"; $col=1; } }
}
?>

- Top PvP:

<?
require ("config.php");
$col = 0;
echo "<table align = 'center' width = '500'><tr>";
$query = "Select char_name,pvpkills from characters where pvpkills>0 order by pvpkills desc";
$mk = mysql_query($query);
while ($a = mysql_fetch_array($mk))
{
$name = $a['char_name'];
$kills = $a['pvpkills'];
if ($col<5) {echo "<td>".$kills." ".$name."</td>"; $col ++;} else { if ($col==5) {echo "</tr><tr><td>".$kills." ".$name."</td>"; $col=1; } }
}
?>

- Hero:

<?
require ("config.php");
$col = 0;
echo "<table align = 'center' width = '500'><tr>";
$query = "Select char_name from heroes";
$mk = mysql_query($query);
while ($a = mysql_fetch_array($mk))
{
$name = $a['char_name'];
if ($col<5) {echo "<td>".$name."</td>"; $col ++;} else { if ($col==5) {echo "</tr><tr><td>".$name."</td>"; $col=1; } }
}
?>

- Serwer Status i statystyki:

<?php

#Login Server
$serverLip="87.229.24.144";
$serverLport="9014";

#GameServer
$serverGip="127.0.0.1";
$serverGPort="7777";

#Database Host
$databaseHost="127.0.0.1";
$databaseLogin="root";
$databasePassword="root";
$databaseName="l2jdb";

#MySQL Server Host
$mySQLserver="127.0.0.1";
$mySQLuser="root";
$mySQLpassword="root";
$mySQLdefaultdb="l2jdb";

#Ventrilo
$ventriloip="warnet.hu";
$ventriloport="3784";

#TeamSpeak 2
$teamspeakip="warnet.hu";
$teamspeakport="8767";

?>


<?php

$flogin 
= @fsockopen ($serverLip,$serverLport$errno$errstr1);
if ( 
$flogin 
    
$lstat "<font color=#00FF00><b>Online</b></font>"
else 
    
$lstat "<font color=red><b>Offline</b></font>";

$fgame = @fsockopen ($serverGip,$serverGPort$errno$errstr1);
if ( 
$fgame 
    
$gstat "<font color=#00FF00><b>Online</b></font>"
else 
    
$gstat "<font color=red><b>Offline</b></font>"

$ventrilo = @fsockopen ($ventriloip,$ventriloport$errno$errstr1);
if ( 
$ventrilo 
    
$ventrilo "<font color=#00FF00><b>Online</b></font>"
else 
    
$ventrilo "<font color=red><b>Offline</b></font>"

$teamspeak = @fsockopen ($teamspeakip,$teamspeakport$errno$errstr1);
if ( 
$teamspeak 
    
$teamspeak "<font color=#00FF00><b>Online</b></font>"
else 
    
$teamspeak "<font color=red><b>Offline</b></font>"


mysql_connect($databaseHost,$databaseLogin,$databasePassword) or die (mysql_error());

mysql_select_db($databaseName) or die(mysql_error());  

//online kari
$query = ("SELECT * FROM characters WHERE online=1");

$result mysql_query($query) or die(mysql_error());

$num=mysql_numrows($result);

//all accounts


$query = ("SELECT * FROM accounts WHERE access_level>=0");

$result mysql_query($query) or die(mysql_error());

$acc=mysql_numrows($result);

//Alliance
$query = ("SELECT * FROM clan_data WHERE ally_name!=\"\"");

$result mysql_query($query) or die(mysql_error());

$alliance=mysql_numrows($result);

//all characters


$query = ("SELECT * FROM characters WHERE accesslevel>=0");

$result mysql_query($query) or die(mysql_error());

$char=mysql_numrows($result);

//Acc-Char bans

$query = ("SELECT * FROM accounts WHERE access_level<0");

$result mysql_query($query) or die(mysql_error());

$accban=mysql_numrows($result);

$query = ("SELECT * FROM characters WHERE accesslevel<0");

$result mysql_query($query) or die(mysql_error());

$charban=mysql_numrows($result);

//Clan

   
$get_config_data="SELECT clan_id FROM clan_data";

$query = ("SELECT clan_id FROM clan_data WHERE clan_id>0");

$result mysql_query($query) or die(mysql_error());

$clan=mysql_numrows($result);

//GM
$query = ("SELECT * FROM characters WHERE accesslevel=200 AND online=1");

$result mysql_query($query) or die(mysql_error());

$gm=mysql_numrows($result);



//Titan


$query = ("SELECT * FROM characters WHERE accesslevel=75 AND online=1");

$result mysql_query($query) or die(mysql_error());

$titan=mysql_numrows($result);


mysql_close();
mysql_connect($mySQLserver,$mySQLuser,$mySQLpassword) or die(mysql_error());

mysql_select_db($mySQLdefaultdb) or die(mysql_error());
?>

<html>
<head>
<title>Server Status - By Mentor</title>
<link rel="stylesheet" type="text/css" href="img/style.css" />
</head>
<body>
<div id="sidebar">
<h2><center><span>Server</span>Status</center></h2>
<ul>
<li><b><span>LoginServer:</span></b> <font color=#00FF00><?php print ("$lstat"); ?></li>
<li><b><span>GameServer:</span></b> <font color=#00FF00><?php print ("$gstat"); ?></li>
<li><b><span>Ventrilo:</span></b> <font color=#00FF00><?php print ("$ventrilo"); ?></li>
<li><b><span>TeamSpeak 2:</span></b> <font color=#00FF00><?php print ("$teamspeak"); ?></li>
<li><span>Online Players:</span> <font color=#00FF00><?php print ("$num"); ?></li>
<li><span>GM online:</span> <font color=#00FF00><?php print ("$gm"); ?></li>
<li><span>Titan online:</span> <font color=#00FF00><?php print ("$titan"); ?></li>
<li><span>Characters:</span> <font color=#00FF00><?php print ("$char"); ?></li>
<li><span>Account.:</span> <font color=#00FF00><?php print ("$acc"); ?></li>
<li><span>Banned Characters:</span> <font color=#00FF00><?php print ("$charban"); ?></li>
<li><span>Banned Account:</span> <font color=#00FF00><?php print ("$accban"); ?></li>
<li><span>Clans:</span> <font color=#00FF00><?php print ("$clan"); ?></li>
<li><span>Alliances:</span> <font color=#00FF00><?php print ("$alliance"); ?></li>
</ul>
</div>
</body>
</html>

- Zamki:

<?
   $host = "91.205.74.22";
   $user = "root";
   $password = "66778811";
   $dbase = "l2jdb";

   $connect = mysql_connect ($host,$root,$password) or die ("Could not connect to Server");
   $db_connect = mysql_select_db ($dbase,$connect) or die ("Could not connect to Data Base");
?>


<body>
<table width="332" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="322"><div align="center">
      <p>ADEN</p>
      <p><img src="graficos/castillo_aden.jpg" width="322" height="233" /></p>
      <p>
  <?
  require ("config.php");
  $query = "Select clan_name from clan_data where hasCastle = 5";
$mk = mysql_query($query);
$res = mysql_fetch_array($mk);
if ($res['clan_name']=="") { $res = "nadie."; } else {$res = $res['clan_name']; }
echo "<center>En posesion de ".$res."</center>";
  ?>
  </p>
    </div></td>
  </tr>
  <tr>
    <td><div align="center">
      <p>DION</p>
      <p><img src="graficos/castillo_dion.jpg" width="322" height="233" /></p>
      <p>
  <?
  require ("config.php");
  $query = "Select clan_name from clan_data where hasCastle = 2";
$mk = mysql_query($query);
$res = mysql_fetch_array($mk);
if ($res['clan_name']=="") { $res = "nadie."; } else {$res = $res['clan_name']; }
echo "<center>En posesion de ".$res."</center>";
  ?>
  </p>
    </div></td>
  </tr>
  <tr>
    <td><div align="center">
      <p>GIRAN</p>
      <p><img src="graficos/castillo_giran.jpg" width="322" height="233" /></p>
      <p>
        <?
  require ("config.php");
  $query = "Select clan_name from clan_data where hasCastle = 3";
$mk = mysql_query($query);
$res = mysql_fetch_array($mk);
if ($res['clan_name']=="") { $res = "nadie."; } else {$res = $res['clan_name']; }
echo "<center>En posesion de ".$res."</center>";
  ?>
      </p>
    </div></td>
  </tr>
  <tr>
    <td><div align="center">
      <p>GLUDIO</p>
      <p><img src="graficos/castillo_gludio.jpg" width="322" height="233" /></p>
      <p>
        <?
  require ("config.php");
  $query = "Select clan_name from clan_data where hasCastle = 1";
$mk = mysql_query($query);
$res = mysql_fetch_array($mk);
if ($res['clan_name']=="") { $res = "nadie."; } else {$res = $res['clan_name']; }
echo "<center>En posesion de ".$res."</center>";   ?>
      </p>
    </div></td>
  </tr>
  <tr>
    <td><div align="center">
      <p>GODDARD</p>
      <p><img src="graficos/castillo_goddard.jpg" width="322" height="233" /></p>
      <p>
        <?
  require ("config.php");
  $query = "Select clan_name from clan_data where hasCastle = 7";
$mk = mysql_query($query);
$res = mysql_fetch_array($mk);
if ($res['clan_name']=="") { $res = "nadie."; } else {$res = $res['clan_name']; }
echo "<center>En posesion de ".$res."</center>";
  ?>
      </p>
    </div></td>
  </tr>
  <tr>
    <td><div align="center">
      <p>INNADRIL</p>
      <p><img src="graficos/castillo_innadril.jpg" width="322" height="233" /></p>
      <p>
        <?
  require ("config.php");
  $query = "Select clan_name from clan_data where hasCastle = 6";
$mk = mysql_query($query);
$res = mysql_fetch_array($mk);
if ($res['clan_name']=="") { $res = "nadie."; } else {$res = $res['clan_name']; }
echo "<center>En posesion de ".$res."</center>";
  ?>
      </p>
    </div></td>
  </tr>
  <tr>
    <td><div align="center">
      <p>OREN</p>
      <p><img src="graficos/castillo_oren.jpg" width="322" height="233" /></p>
      <p>
        <?
  require ("config.php");
  $query = "Select clan_name from clan_data where hasCastle = 4";
$mk = mysql_query($query);
$res = mysql_fetch_array($mk);
if ($res['clan_name']=="") { $res = "nadie."; } else {$res = $res['clan_name']; }
echo "<center>En posesion de ".$res."</center>";
  ?>
      </p>
    </div></td>
  </tr>
  <tr>
    <td><div align="center">
      <p>RUNE</p>
      <p><img src="graficos/castillo_rune.jpg" width="322" height="233" /></p>
      <p>
        <?
  require ("config.php");
  $query = "Select clan_name from clan_data where hasCastle = 8";
$mk = mysql_query($query);
$res = mysql_fetch_array($mk);
if ($res['clan_name']=="") { $res = "nadie."; } else {$res = $res['clan_name']; }
echo "<center>En posesion de ".$res."</center>";
  ?>
      </p>
    </div></td>
  </tr>
  <tr>
    <td><div align="center">
      <p>STUTGART</p>
      <p><img src="graficos/castillo_stutgart.jpg" width="322" height="233" /></p>
      <p>
        <?
  require ("config.php");
  $query = "Select clan_name from clan_data where hasCastle = 9";
$mk = mysql_query($query);
$res = mysql_fetch_array($mk);
if ($res['clan_name']=="") { $res = "nadie."; } else {$res = $res['clan_name']; }
echo "<center>En posesion de ".$res."</center>";
  ?>
      </p>
    </div></td>
  </tr>
</table>
</body>

- Olimpiada:

<?
require ("config.php");
$clases = array (
"0" => "Human Fighter",
"1" => "Warrior",
"2" => "Gladiator",
"3" => "Warlord",
"4" => "Human Knight",
"5" => "Paladin",
"6" => "Dark Avenger",
"7" => "Rogue",
"8" => "Treasure Hunter",
"9" => "Hawkeye",
"10" => "Human Mage",
"11" => "Human Wizard",
"12" => "Sorcerer",
"13" => "Necromancer",
"14" => "Warlock",
"15" => "Cleric",
"16" => "Bishop",
"17" => "Human Prophet",
"18" => "Elf Fighter",
"19" => "Elf Knight",
"20" => "Temple Knight",
"21" => "Swordsinger",
"22" => "Scout",
"23" => "Plains Walker",
"24" => "Silver Ranger",
"25" => "Elf Mage",
"26" => "Elf Wizard",
"27" => "Spellsinger",
"28" => "Oracle",
"30" => "Elder",
"31" => "DE Fighter",
"32" => "Palus Knight",
"33" => "Shilien Knight",
"34" => "Bladedancer",
"35" => "Assassin",
"36" => "Abyss Walker",
"37" => "Phantom Ranger",
"38" => "DE Mage",
"39" => "DE Wizard",
"40" => "Spell Howler",
"41" => "Phatom Summoner",
"42" => "Shillien Oracle",
"43" => "Shillien Elder",
"44" => "Orc Fighter",
"45" => "Raider",
"46" => "Destroyer",
"47" => "Monk",
"48" => "Tyrant",
"49" => "Orc Mage",
"50" => "Shaman",
"51" => "Overlord",
"52" => "Warcryer",
"53" => "Dwarf Fighter",
"54" => "Scavenger",
"55" => "Bounty Hunter",
"56" => "Artisan",
"57" => "Warsmith",
"88" => "Duelist",
"89" => "DreadNought",
"90" => "Phoenix Knight",
"91" => "Hell Knight",
"92" => "Saggitarius",
"93" => "Adventurer",
"94" => "Archmage",
"95" => "Soultaker",
"96" => "Arcana Lord",
"97" => "Cardinal",
"98" => "Hierophant",
"99" => "Eva Templar",
"100" => "Sword Muse",
"101" => "Wind Rider",
"102" => "Moonlight Sentinel",
"103" => "Mystic Muse",
"104" => "Elemental Master",
"105" => "Eva Saint",
"106" => "Shilien Templar",
"107" => "Spectral Dancer",
"108" => "Ghost Hunter",
"109" => "Ghost Sentinel",
"110" => "Storm Screamer",
"111" => "Spectral Master",
"112" => "Shillen Saint",
"113" => "Titan",
"114" => "Grand Khauatari",
"115" => "Dominator",
"116" => "Doomcryer",
"117" => "Fortune Seeker",
"118" => "Maestro",
"123" => "Male Soldier",
"124" => "Female Soldier",
"125" => "Trooper",
"126" => "Warder",
"127" => "Berserker",
"128" => "Male Soulbreaker",
"129" => "Female Soulbreaker",
"130" => "Arbalester",
"131" => "Doombringer",
"132" => "Male Soulhound",
"133" => "Female Soulhound",
"134" => "Trickster",
"135" => "Inspector",
"136" => "Judicator"
);
$ultima = "";
echo "<table width='500' align='center'>";
$query = "Select class_id,char_name,olympiad_points from olympiad_nobles order by class_id desc,olympiad_points desc";
$mk = mysql_query($query);
while ($a = mysql_fetch_array($mk))
{
$raza = $a['class_id'];
if ($raza != $ultima) { $ultima = $raza; $color = "<tr><td colspan='3'><hr></td></tr>"; } else { $color =""; }
$nombre = $a['char_name'];
$puntos = $a['olympiad_points'];
$clase = $clases[$raza];
echo $color."<tr><td>".$clase."</td><td>".$nombre."</td><td>".$puntos."</td></tr>";
}

?>

- Do kilku z nich wymagany jest osobny config:

<?
   $host = "91.205.74.22";
   $user = "root";
   $password = "66778811";
   $dbase = "l2jdb";

   $connect = mysql_connect ($host,$root,$password) or die ("Could not connect to Server");
   $db_connect = mysql_select_db ($dbase,$connect) or die ("Could not connect to Data Base");
?>






  • Wiadomości: 2

  • Pochwał: 0

Odp: [Dzielę Pliki]Skrypty PHP
« Odpowiedź #1 dnia: Marzec 06, 2012, 03:29:53 pm »
Widać ze sie napociles, dobra robota, ale moglbys jeszcze dla zielonych napisac jak ma sie nazywac ten skrypt np: "skrypt.php" i gdzie powinien byc umieszczony po to aby strona to wczytala :P

Pozdrawiam


  • Wiadomości: 181

  • Pochwał: 7

Odp: [Dzielę Pliki]Skrypty PHP
« Odpowiedź #2 dnia: Marzec 06, 2012, 04:16:09 pm »
Skrypty te możesz umieścić w tabeli lub nie, umieszczasz je w kodzie strony lecz jeśli pierwotnie masz ją zapisaną w .html zmieniasz jej rozszerzenie do .php i skrypty zaczynają działać.