Ho creato questo codice in PHP per inviare un distintivo agli utenti del mio forum MYBB che hanno passato un tot. di tempo online solo che non riesco a capire perché non va, aiutino?
Codice PHP:
<?
session_start();
if(!session_is_registered(admpassword)){
include("main_login.php");
}
else{
$con = mysql_connect("localhost","habbocean","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_habbocean", $con);
?>
<div class="box_topleft_b"><div class="box_topright_b" id="top"></div></div>
<div class="box_middleleft"><div class="box_middleright">
<h3>Aggiornamento traguardi tempo</h3>
<table cellspacing="0" cellpadding="2" border="0" width="100%"><tbody align="center" style="font-size: 11px; font-family: verdana,sans-serif;">
<tr><td>
<form method="POST"><input type="submit" name="controlla" value="Aggiorna" /></form>
<?php
define("IN_MYBB", 1);
require_once "../../forum/global.php";
if($_POST['controlla']){
$nome = mysql_query("SELECT DISTINCT name FROM news1_comments");
while($line = mysql_fetch_array ($nome)){
$uid = mysql_query("SELECT uid FROM mybb_users WHERE username = '$line[name]'");
while($lin = mysql_fetch_array ($uid)){
$users_uid = mysql_query("SELECT * FROM mybb_awards_given WHERE to_uid = '$lin[uid]' LIMIT 1");
while($row = mysql_fetch_array ($users_uid)){
$query = "SELECT * FROM mybb_awards_given WHERE to_uid = '$lin[uid]' AND award_id = '390' LIMIT 1";
$query1 = mysql_query($query);
$getnum = mysql_query("SELECT timeonline FROM mybb_users WHERE uid='$lin[uid]'");
$num = mysql_num_rows($getnum);
if(($num>=1) && ($num<=3600)){
if(mysql_num_rows($query1) == "0"){
mysql_query("INSERT INTO mybb_awards_given (to_uid, award_id, date_given) VALUES('$row[to_uid]', '390', '".time()."')");
}}
elseif(($num>=3601) && ($num<=14400)){
$b = mysql_query("SELECT * FROM mybb_awards_given WHERE to_uid = '$row[to_uid]' AND award_id = '390' LIMIT 1");
while($rows1 = mysql_fetch_array ($b)){
mysql_query("UPDATE mybb_awards_given SET award_id = '391' WHERE gid = '$rows1[gid]'");
}}
elseif(($num>=14401) && ($num<=86400)){
$c = mysql_query("SELECT * FROM mybb_awards_given WHERE to_uid = '$row[to_uid]' AND award_id = '391' LIMIT 1");
while($rows2 = mysql_fetch_array ($c)){
mysql_query("UPDATE mybb_awards_given SET award_id = '392' WHERE gid = '$rows2[gid]'");
}}
elseif(($num>=86401) && ($num<=172800)){
$d = mysql_query("SELECT * FROM mybb_awards_given WHERE to_uid = '$row[to_uid]' AND award_id = '392' LIMIT 1");
while($rows3 = mysql_fetch_array ($d)){
mysql_query("UPDATE mybb_awards_given SET award_id = '393' WHERE gid = '$rows3[gid]'");
}}
elseif(($num>=172801) && ($num<=259200)){
$e = mysql_query("SELECT * FROM mybb_awards_given WHERE to_uid = '$row[to_uid]' AND award_id = '393' LIMIT 1");
while($rows4 = mysql_fetch_array ($e)){
mysql_query("UPDATE mybb_awards_given SET award_id = '394' WHERE gid = '$rows4[gid]'");
}}
elseif(($num>=259201) && ($num<=432000)){
$f = mysql_query("SELECT * FROM mybb_awards_given WHERE to_uid = '$row[to_uid]' AND award_id = '394' LIMIT 1");
while($rows5 = mysql_fetch_array ($f)){
mysql_query("UPDATE mybb_awards_given SET award_id = '395' WHERE gid = '$rows5[gid]'");
}}
elseif(($num>=432001) && ($num<=691200)){
$g = mysql_query("SELECT * FROM mybb_awards_given WHERE to_uid = '$row[to_uid]' AND award_id = '395' LIMIT 1");
while($rows6 = mysql_fetch_array ($g)){
mysql_query("UPDATE mybb_awards_given SET award_id = '396' WHERE gid = '$rows6[gid]'");
}}
elseif(($num>=691201) && ($num<=1296000)){
$h = mysql_query("SELECT * FROM mybb_awards_given WHERE to_uid = '$row[to_uid]' AND award_id = '396' LIMIT 1");
while($rows7 = mysql_fetch_array ($h)){
mysql_query("UPDATE mybb_awards_given SET award_id = '397' WHERE gid = '$rows7[gid]'");
}}
elseif(($num>=1296001) && ($num<=2160000)){
$i = mysql_query("SELECT * FROM mybb_awards_given WHERE to_uid = '$row[to_uid]' AND award_id = '397' LIMIT 1");
while($rows8 = mysql_fetch_array ($i)){
mysql_query("UPDATE mybb_awards_given SET award_id = '398' WHERE gid = '$rows8[gid]'");
}}
elseif(($num>=2160001) && ($num<=3456000)){
$l = mysql_query("SELECT * FROM mybb_awards_given WHERE to_uid = '$row[to_uid]' AND award_id = '398' LIMIT 1");
while($rows9 = mysql_fetch_array ($l)){
mysql_query("UPDATE mybb_awards_given SET award_id = '399' WHERE gid = '$rows9[gid]'");
}}
elseif(($num>=3456001) && ($num<=5184000)){
$m = mysql_query("SELECT * FROM mybb_awards_given WHERE to_uid = '$row[to_uid]' AND award_id = '399' LIMIT 1");
while($rows10 = mysql_fetch_array ($m)){
mysql_query("UPDATE mybb_awards_given SET award_id = '400' WHERE gid = '$rows10[gid]'");
}}}
}
}
}
?>
</td></tr></tbody></table></div></div><div class="box_bottomleft"><div class="box_bottomright"></div></div>
<?php
if($_POST['controlla']){
echo '<div class="box_topleft_b"><div class="box_topright_b"></div></div><div class="box_middleleft"><div class="box_middleright"><table cellspacing="0" cellpadding="2" border="0" width="100%"><tbody><tr><td colspan="2"><meta http-equiv="refresh" content="1;[url]http://habbocean.altervista.org/adm/file/badgeonline.php[/url]"><font style="font-size: 11px; font-family: verdana,sans-serif;"><center>[b]Aggiornamento in corso...[/b]
[img]http://habbocean.altervista.org/images/site/progress_bar_blue.gif[/img]</center></font></td></tr></tbody></table></div></div><div class="box_bottomleft"><div class="box_bottomright"></div></div>';
}
?>
<?php
mysql_close($con);
?>
<?php
}
?>