<?
	#Разработано вебстудией rostixsoft 
    include_once 'сюда абсолютный путь к корню сайта/engine/config.php'; /// подключение к бд
    $tasksKronUP = mysql_query( "SELECT id, iduser FROM tasks WHERE dateup > '0' and date + dateup < '".time()."' and iduser in (SELECT id FROM user WHERE adv_money >= '" . $config['tasksup'] . "' ) " );
	if ( mysql_num_rows( $tasksKronUP ) > 0 ) {
		while ( $tasksKronUP_row = mysql_fetch_array( $tasksKronUP ) ) {
				
			$up_user_balance = mysql_fetch_array( mysql_query( "SELECT adv_money FROM user WHERE id = '".$tasksKronUP_row['iduser']."'" ) );
			if($up_user_balance["adv_money"] >= $config['tasksup']) {
				#Поднимаем задание 
				mysql_query( "UPDATE tasks SET date = '".time()."' WHERE id = '".$tasksKronUP_row['id']."' " );
				mysql_query( "UPDATE user SET adv_money = adv_money - '" . $config['tasksup'] . "' WHERE id = '".$tasksKronUP_row['iduser']."' " );
				mysql_query( "INSERT INTO history_reklama_pay SET iduser = '" . $tasksKronUP_row['iduser'] . "', price = '" . $config['tasksup'] . "', type = 4, date = '" . time() . "', h_text = 'Авто подъем задания <b>№" . $tasksKronUP_row['id'] . "</b> в списке выдачи', payopt = 0 " );
			}
		
		}
	}
?>