Jump to content

Problema MYSQL , trebuie modificat in MYSQLi


Recommended Posts

Posted (edited)

Error Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead

 

Am si eu un fisier mai vechi pe care vreau sa il folosesc si am incercat sa il testez si imi da o eroare cum ca trebuie schimbata conectarea la baza de date si tot din MYSQL in MYSQLi 

 

 

Am atasat fisierul mai jos 

 

 

 

 

activity.php

Edited by ~ FREAK ~

  • Moderators
Posted

http://php.net/manual/ro/mysqli.query.php

Spoiler


<!--
	`Activity.PHP' — Reads MySQL Database Showing The Admins That Had Activity
																				-->

<?php Require_Once('activity.config.php'); ?>

<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8;" />

		<title>
			<?php Echo x_TITLE; ?>
		</title>

		<link type="text/css" rel="stylesheet" href="Hattrick_Data/Theme.CSS" />
		<link type="text/css" rel="stylesheet" href="Hattrick_Data/Global.CSS" />
		<link type="text/css" rel="stylesheet" href="Hattrick_Data/Custom.CSS" />

		<style>
			html, div, body, a, td, tr, th, table
			{
				font-family: "Calibri";
				font-size: 13.15px;
			}

			html, div, body, table
			{
				width: auto !important;
				height: auto !important;
			}
		</style>
	</head>

	<body>
		<a class="block_ad303x1000_left" style="background-image:url(Hattrick_Data/1Left.jpg);"></a>
		<a class="block_ad303x1000_right" style="background-image:url(Hattrick_Data/1Right.jpg);"></a>
		<center>
		<b>
		<a href=/go/top.php>Top Players</a>&nbsp;|&nbsp;
		<a href=/go/sb>SourceBans</a>&nbsp;|&nbsp;
		<a href=/go/activity.php>Activity</a>&nbsp;|&nbsp;
		<a href=/go/bans.php>Bans</a></b>
		<br /><br />
		<div class="page_content">

		<?php
			// Error_Reporting(E_ERROR);
			
			Date_Default_TimeZone_Set('Europe/Bucharest');
			Header('Content-Type: text/html; charset=utf-8;');
			Require_Once('Hattrick_Data/PHP_Functions.PHP');

			$connection = mysqli_connect(x_HOST, x_USR, x_PASS, x_DB);
			mysqli_query($connection, "SET NAMES 'utf8';");
			mysqli_query($connection, SPrintF("delete from adminsactivity where timeStamp < %d;", Time() - (86400 * 7 * 4)));
			mysqli_query($connection, SPrintF("delete from adminsonline where lastSeen < %d;", Time() - (86400 * 7 * 4)));
			mysqli_query($connection, SPrintF("delete from maps where Stamp < %d;", Time() - (86400 * 7 * 4)));
			mysqli_query($connection, SPrintF("delete from nf_players where lastSeen < %d;", Time() - (86400 * 7 * 4)));
			mysqli_query($connection, SPrintF("delete from nf_players where char_length(Steam) < 1;"));
			mysqli_query($connection, SPrintF("delete from ss_players where seen < %d;", Time() - (86400 * 7 * 4)));
			mysqli_query($connection, SPrintF("delete from ss_players where char_length(steam) < 1;"));
			mysqli_query($connection, SPrintF("delete from ore where char_length(steam) < 1;"));
			mysqli_query($connection, SPrintF("delete from AdminsActivity where timeStamp < %d;", Time() - (86400 * 7 * 4)));
			mysqli_query($connection, SPrintF("delete from AdminsOnline where lastSeen < %d;", Time() - (86400 * 7 * 4)));
			$QId = mysqli_query($connection, "SHOW TABLE STATUS WHERE Name LIKE '%Admins%';");
			$Size = 0;
			
			While ($Data = mysqli_fetch_array($QId))
			{
				If (StrIStr($Data['Name'], "Admins"))
					$Size += $Data['Data_length'] + $Data['Index_length'];
			}
			
			$MB = Number_Format($Size / (1024 * 1024), 4);
			$QId = mysqli_query($connection, "SELECT * FROM AdminsOnline;");
			$Total = mysqli_num_rows($QId);
			
			If ($Total == 1)
				Echo SPrintF("<a target=_blank href=%s>%s</a>&nbsp;&nbsp;&nbsp;—&nbsp;&nbsp;&nbsp;<b>%s</b> TOTAL ADMINISTRATORS&nbsp;&nbsp;&nbsp;—&nbsp;&nbsp;&nbsp;<b>%s MB</b> DATABASE SIZE&nbsp;&nbsp;&nbsp;—&nbsp;&nbsp;&nbsp;<a target=_blank href=%s>%s</a><br /><br />", x_URL_OWNER_1, x_NAME_OWNER_1, Number_Format($Total), $MB, x_URL_OWNER_2, x_NAME_OWNER_2);
		
			Else
				Echo SPrintF("<a target=_blank href=%s>%s</a>&nbsp;&nbsp;&nbsp;—&nbsp;&nbsp;&nbsp;<b>%s</b> TOTAL ADMINISTRATORS&nbsp;&nbsp;&nbsp;—&nbsp;&nbsp;&nbsp;<b>%s MB</b> DATABASE SIZE&nbsp;&nbsp;&nbsp;—&nbsp;&nbsp;&nbsp;<a target=_blank href=%s>%s</a><br /><br />", x_URL_OWNER_1, x_NAME_OWNER_1, Number_Format($Total), $MB, x_URL_OWNER_2, x_NAME_OWNER_2);
			
			$QId = mysqli_query($connection, "SELECT * FROM AdminsOnline ORDER BY minutesOnline DESC;");

			Echo "<table class=\"table_lst\">";
				Echo "<tr>";
					Echo "<td class=\"col_h\">";
						Echo "&nbsp;#&nbsp;";
					Echo "</td>";
					Echo "<td class=\"col_h\">";
						Echo "&nbsp;Administrator&nbsp;";
					Echo "</td>";
					Echo "<td class=\"col_h\">";
						Echo "&nbsp;Playing&nbsp;";
					Echo "</td>";
					Echo "<td class=\"col_h\">";
						Echo "&nbsp;Spectating&nbsp;";
					Echo "</td>";
					Echo "<td class=\"col_h\">";
						Echo "&nbsp;SPEC %&nbsp;";
					Echo "</td>";
					Echo "<td class=\"col_h\">";
						Echo "&nbsp;Total Time&nbsp;";
					Echo "</td>";
					Echo "<td class=\"col_h\">";
						Echo "&nbsp;Last Seen&nbsp;";
					Echo "</td>";
				Echo "</tr>";

				$Id = 0;
				
				While ($Data = mysqli_fetch_array($QId))
				{
					$Id++;
					
					Echo "<tr>";
						Echo "<td>";
							If ($Id <= 3)
								Echo SPrintF("&nbsp;<b><font color=darkgreen>%s</font></b>&nbsp;", Number_Format($Id));
							Else
								Echo SPrintF("&nbsp;%s&nbsp;", Number_Format($Id));
						Echo "</td>";
						Echo "<td>";
							$Addr = $Data['adminIp'];

							If ($Id <= 3)
								Echo SPrintF("&nbsp;<img src=Hattrick_Data/Flags/%s.gif height=15 width=20 title=\"%s\"></img>&nbsp;<a target=_blank href=http://steamrep.com/?%s><img src=Hattrick_Data/Steam.GIF height=15 width=15 title=\"%s\"></img></a>&nbsp;<a href=/go/activitylog.php?steam=%s title=\"%s\"><b><font color=darkgreen>%s</font></b></a>&nbsp;", StrToLower($Data['countryCode']), $Data['Country'], $Data['adminSteam'], $Data['adminSteam'], $Data['adminSteam'], $Data['adminName'], $Data['adminName']);
							Else
								Echo SPrintF("&nbsp;<img src=Hattrick_Data/Flags/%s.gif height=15 width=20 title=\"%s\"></img>&nbsp;<a target=_blank href=http://steamrep.com/?%s><img src=Hattrick_Data/Steam.GIF height=15 width=15 title=\"%s\"></img></a>&nbsp;<a href=/go/activitylog.php?steam=%s title=\"%s\"><b>%s</b></a>&nbsp;", StrToLower($Data['countryCode']), $Data['Country'], $Data['adminSteam'], $Data['adminSteam'], $Data['adminSteam'], $Data['adminName'], $Data['adminName']);
						Echo "</td>";
						Echo "<td>";
							Echo SPrintF("&nbsp;%s&nbsp;", Format_Time_String($Data['minutesOnline']));
						Echo "</td>";
						Echo "<td>";
							If ($Data['minutesSpecOnline'] >= ($Data['minutesOnline'] / 2))
								Echo SPrintF("&nbsp;<b><font color=darkgreen>%s</font></b>&nbsp;", Format_Time_String($Data['minutesSpecOnline']));
							Else If ($Data['minutesSpecOnline'] > 0)
								Echo SPrintF("&nbsp;<b><font color=darkorange>%s</font></b>&nbsp;", Format_Time_String($Data['minutesSpecOnline']));
							Else
								Echo SPrintF("&nbsp;<b><font color=darkred>%s</font></b>&nbsp;", Format_Time_String($Data['minutesSpecOnline']));
						Echo "</td>";
						Echo "<td>";
							If ($Data['minutesSpecOnline'] >= ($Data['minutesOnline'] / 2))
								Echo SPrintF("&nbsp;<b><font color=darkgreen>%.2f %%</font></b>&nbsp;", (float) (((float) $Data['minutesSpecOnline']) * 100.0) / ((float) $Data['minutesOnline']));
							Else If ($Data['minutesSpecOnline'] > 0)
								Echo SPrintF("&nbsp;<b><font color=darkorange>%.2f %%</font></b>&nbsp;", (float) (((float) $Data['minutesSpecOnline']) * 100.0) / ((float) $Data['minutesOnline']));
							Else
								Echo SPrintF("&nbsp;<b><font color=darkred>%.2f %%</font></b>&nbsp;", (float) (((float) $Data['minutesSpecOnline']) * 100.0) / ((float) $Data['minutesOnline']));
						Echo "</td>";
						Echo "<td>";
							If ($Data['minutesOnline'] + $Data['minutesSpecOnline'] >= $Data['minutesOnline'] * 1.5)
								Echo SPrintF("&nbsp;<b><font color=darkgreen>%s</font></b>&nbsp;", Format_Time_String($Data['minutesOnline'] + $Data['minutesSpecOnline']));
							Else
								Echo SPrintF("&nbsp;<b><font color=darkorange>%s</font></b>&nbsp;", Format_Time_String($Data['minutesOnline'] + $Data['minutesSpecOnline']));
						Echo "</td>";
						Echo "<td>";
							If ($Data['lastSeen'] >= Time() - 86400)
								Echo SPrintF("&nbsp;<b><font color=darkgreen>%s</font></b>&nbsp;", Date("M j, 'y @ g:i a", $Data['lastSeen']));
							Else If ($Data['lastSeen'] >= Time() - (86400 * 3))
								Echo SPrintF("&nbsp;<b><font color=darkorange>%s</font></b>&nbsp;", Date("M j, 'y @ g:i a", $Data['lastSeen']));
							Else
								Echo SPrintF("&nbsp;<b><font color=darkred>%s</font></b>&nbsp;", Date("M j, 'y @ g:i a", $Data['lastSeen']));
						Echo "</td>";
					Echo "</tr>";
				}

			Echo "</table>";
			Echo SPrintF("<br />%s<br />%s<br />", x_COPYRIGHT_1, x_COPYRIGHT_2);

			mysqli_close($connection);
		?>

		</div>
		<br />
		</center>
	</body>
</html>


 

Sper ca e ok ... nu l-am testat

Posted

PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/freakhosting/public_html/ore/activity.php:7) in /home/freakhosting/public_html/ore/activity.php on line 52
 

Posted

Nu mai imi da erori acum , dar am pus baza de date si tot , am importat niste tabele in baza de date 

 

Cand dau refresh la pagina web dispar tabelele din baza de date 

 

Ai idee de ce ? 

  • Moderators
Posted
mysqli_query($connection, SPrintF("delete from adminsactivity where timeStamp < %d;", Time() - (86400 * 7 * 4)));
mysqli_query($connection, SPrintF("delete from adminsonline where lastSeen < %d;", Time() - (86400 * 7 * 4)));
mysqli_query($connection, SPrintF("delete from maps where Stamp < %d;", Time() - (86400 * 7 * 4)));
mysqli_query($connection, SPrintF("delete from nf_players where lastSeen < %d;", Time() - (86400 * 7 * 4)));
mysqli_query($connection, SPrintF("delete from nf_players where char_length(Steam) < 1;"));
mysqli_query($connection, SPrintF("delete from ss_players where seen < %d;", Time() - (86400 * 7 * 4)));
mysqli_query($connection, SPrintF("delete from ss_players where char_length(steam) < 1;"));
mysqli_query($connection, SPrintF("delete from ore where char_length(steam) < 1;"));
mysqli_query($connection, SPrintF("delete from AdminsActivity where timeStamp < %d;", Time() - (86400 * 7 * 4)));
mysqli_query($connection, SPrintF("delete from AdminsOnline where lastSeen < %d;", Time() - (86400 * 7 * 4)));

Asta sterge inregistrarile mai vechi de 86400*7*4 secunde, adica 4 saptamani.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.