<?
$sot_db_host = 'localhost'; // хост
$sot_db_user_name = 'valfe201_ferma'; // имя пользователя
$sot_db_password = 'paifeM9dohbid1o'; // пароль
$sot_db_name = 'valfe201_ferma'; // имя базы данных

if(!($db=@mysql_connect($sot_db_host, $sot_db_user_name, $sot_db_password))){
header("Location:/404.php");
exit;
}

if (!@mysql_select_db($sot_db_name,$db)){
echo "Wrong MySQL db name";
exit;
}

mysql_query('set charset utf8',$db); 
mysql_query('SET names utf8',$db); 
mysql_query('set character_set_client="utf8"',$db); 
mysql_query('set character_set_connection="utf8"',$db); 
mysql_query('set character_set_result="utf8"',$db);

//===============================================================//

mysql_query('UPDATE `kolhoz_collective` SET `rating`="0", `level`="1"');


/*
$sql = mysql_query('SRLECT * FROM `kolhoz_collective_user`');
while($rez = mysql_fetch_assoc($sql)){
$rez
}


//===============================================================//

$sql_ww = mysql_query("SELECT * FROM `kolhoz_level` ORDER BY `id`");
$ee_ww = 1;
while($sql_array = mysql_fetch_array($sql_ww)){
$ee_ww += $sql_array['rating'];
if($sql_array['level']>70){$ee_ww += 5000;}
if($sql_array['level'] == 33){echo $ee_ww.'<br>'; break;}
}


$sql = mysql_query("SELECT * FROM `kolhoz_level`");
$t = 1;
while($sql_array = mysql_fetch_array($sql)){


$vv_2 = mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_level` WHERE `id`='".$sql_array['id']."'"));

if($sql_array['level'] == 2){
$vv_1['rating_all'] = 0;
} else {
$r=1;
$gg=1;
while($r==1){
$vv_1 = mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_level` WHERE `id`='".($sql_array['id']-$gg)."'"));
if($vv_1['id']==''){$r=0;$gg++;}
}
}

//if($vv_1['rating_all']==''){$vv_1['rating_all'] = 0;}

mysql_query("UPDATE `kolhoz_level` SET `rating_all`='".($vv_2['rating']+$vv_1['rating_all'])."' WHERE `id`='".$sql_array['id']."'");

$vv_1 = '';
$vv_2 = '';
$t++;
}


if(mysql_query('UPDATE `kolhoz_user` SET `status`="0" WHERE id="18633"')){echo 1;} else {echo 2;}
*/
?>
