supernova-ws /
SuperNova
| 1 | <?php |
||||
| 2 | /** @noinspection PhpDeprecationInspection */ |
||||
| 3 | /** @noinspection SqlResolve */ |
||||
| 4 | /** @noinspection PhpUnnecessaryCurlyVarSyntaxInspection */ |
||||
| 5 | |||||
| 6 | /** |
||||
| 7 | * Created by Gorlum 05.03.2018 20:42 |
||||
| 8 | */ |
||||
| 9 | |||||
| 10 | namespace Player; |
||||
| 11 | |||||
| 12 | use DBAL\db_mysql; |
||||
| 13 | use Fleet\DbFleetStatic; |
||||
| 14 | use mysqli_result; |
||||
| 15 | use SN; |
||||
| 16 | use Planet\DBStaticPlanet; |
||||
| 17 | |||||
| 18 | /** |
||||
| 19 | * Class PlayerStatic |
||||
| 20 | * @package Player |
||||
| 21 | * |
||||
| 22 | * @deprecated |
||||
| 23 | */ |
||||
| 24 | class PlayerStatic { |
||||
| 25 | |||||
| 26 | public static function getPlayerProduction($userId) { |
||||
| 27 | /** @noinspection SqlResolve */ |
||||
| 28 | return doquery(" |
||||
|
0 ignored issues
–
show
Deprecated Code
introduced
by
Loading history...
|
|||||
| 29 | SELECT |
||||
| 30 | sum(metal_perhour) + sum(crystal_perhour) * 2 + sum(deuterium_perhour) * 4 AS `total`, |
||||
| 31 | sum(metal_perhour) AS `metal`, |
||||
| 32 | sum(crystal_perhour) AS `crystal`, |
||||
| 33 | sum(deuterium_perhour) AS `deuterium`, |
||||
| 34 | avg(metal_mine_porcent) AS `avg_metal_percent`, |
||||
| 35 | avg(crystal_mine_porcent) AS `avg_crystal_percent`, |
||||
| 36 | avg(deuterium_sintetizer_porcent) AS `avg_deuterium_percent` |
||||
| 37 | FROM |
||||
| 38 | `{{planets}}` AS p |
||||
| 39 | WHERE |
||||
| 40 | p.`id_owner` = {$userId} |
||||
| 41 | GROUP BY |
||||
| 42 | id_owner", true); |
||||
|
0 ignored issues
–
show
true of type true is incompatible with the type string expected by parameter $table of doquery().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 43 | } |
||||
| 44 | |||||
| 45 | /** |
||||
| 46 | * @param $UserID |
||||
| 47 | * |
||||
| 48 | * @deprecated |
||||
| 49 | * |
||||
| 50 | * TODO: Full rewrite |
||||
| 51 | */ |
||||
| 52 | public static function DeleteSelectedUser($UserID) { |
||||
| 53 | $internalTransaction = false; |
||||
| 54 | if (!db_mysql::db_transaction_check(false)) { |
||||
| 55 | db_mysql::db_transaction_start(); |
||||
| 56 | |||||
| 57 | $internalTransaction = true; |
||||
| 58 | } |
||||
| 59 | |||||
| 60 | $TheUser = db_user_by_id($UserID); |
||||
|
0 ignored issues
–
show
The function
db_user_by_id() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 61 | |||||
| 62 | if (!empty($TheUser['ally_id'])) { |
||||
| 63 | /** @noinspection SqlResolve */ |
||||
| 64 | $TheAlly = doquery("SELECT * FROM `{{alliance}}` WHERE `id` = '" . $TheUser['ally_id'] . "';", '', true); |
||||
|
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 65 | $TheAlly['ally_members'] -= 1; |
||||
| 66 | /** @noinspection SqlResolve */ |
||||
| 67 | doquery("UPDATE `{{alliance}}` SET `ally_members` = '" . $TheAlly['ally_members'] . "' WHERE `id` = '" . $TheAlly['id'] . "';"); |
||||
|
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 68 | |||||
| 69 | // if ( $TheAlly['ally_members'] > 0 ) { |
||||
| 70 | // doquery ( "UPDATE `{{alliance}}` SET `ally_members` = '" . $TheAlly['ally_members'] . "' WHERE `id` = '" . $TheAlly['id'] . "';"); |
||||
| 71 | // } else { |
||||
| 72 | // doquery ( "DELETE FROM `{{alliance}}` WHERE `id` = '" . $TheAlly['id'] . "';"); |
||||
| 73 | // doquery ( "DELETE FROM `{{statpoints}}` WHERE `stat_type` = '2' AND `id_owner` = '" . $TheAlly['id'] . "';"); |
||||
| 74 | // } |
||||
| 75 | } |
||||
| 76 | |||||
| 77 | // Deleting all fleets |
||||
| 78 | DbFleetStatic::db_fleet_list_delete_by_owner($UserID); |
||||
| 79 | |||||
| 80 | // Deleting all planets |
||||
| 81 | DBStaticPlanet::db_planet_list_delete_by_owner($UserID); |
||||
| 82 | |||||
| 83 | // TEMPORARY player messages not deleted |
||||
| 84 | // doquery("DELETE FROM `{{messages}}` WHERE `message_sender` = '" . $UserID . "';"); |
||||
| 85 | // doquery("DELETE FROM `{{messages}}` WHERE `message_owner` = '" . $UserID . "';"); |
||||
| 86 | |||||
| 87 | doquery("DELETE FROM `{{notes}}` WHERE `owner` = '" . $UserID . "';"); |
||||
|
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 88 | |||||
| 89 | doquery("DELETE FROM `{{buddy}}` WHERE `BUDDY_SENDER_ID` = '" . $UserID . "';"); |
||||
|
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 90 | doquery("DELETE FROM `{{buddy}}` WHERE `BUDDY_OWNER_ID` = '" . $UserID . "';"); |
||||
|
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 91 | |||||
| 92 | doquery("DELETE FROM `{{referrals}}` WHERE (`id` = '{$UserID}') OR (`id_partner` = '{$UserID}');"); |
||||
|
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 93 | |||||
| 94 | doquery("DELETE FROM `{{statpoints}}` WHERE `stat_type` = '1' AND `id_owner` = '" . $UserID . "';"); |
||||
|
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 95 | |||||
| 96 | // Deleting all units |
||||
| 97 | SN::db_del_record_list(LOC_UNIT, "`unit_location_type` = " . LOC_PLAYER . " AND `unit_player_id` = " . $UserID); |
||||
| 98 | |||||
| 99 | // Deleting player's record |
||||
| 100 | SN::db_del_record_by_id(LOC_USER, $UserID); |
||||
| 101 | dbUpdateUsersCount(SN::$config->pass()->users_amount - 1); |
||||
| 102 | |||||
| 103 | if ($internalTransaction) { |
||||
| 104 | db_mysql::db_transaction_commit(); |
||||
| 105 | } |
||||
| 106 | } |
||||
| 107 | |||||
| 108 | public static function dbUpdateBotStatus($botType, $onlineTime = SN_TIME_NOW) { |
||||
| 109 | SN::$db->doquery("UPDATE `{{users}}` SET `onlinetime` = " . $onlineTime . " WHERE `user_bot` = " . $botType); |
||||
| 110 | } |
||||
| 111 | |||||
| 112 | /** |
||||
| 113 | * @param string $query |
||||
| 114 | * |
||||
| 115 | * @return array|bool|mysqli_result|null |
||||
| 116 | * @deprecated |
||||
| 117 | */ |
||||
| 118 | public static function dbSelectOne($query) { |
||||
| 119 | $query .= ' LIMIT 1'; |
||||
| 120 | $query .= db_mysql::db_transaction_check(db_mysql::DB_TRANSACTION_WHATEVER) ? ' FOR UPDATE' : ''; |
||||
| 121 | |||||
| 122 | return SN::$db->doquery($query, true); |
||||
| 123 | } |
||||
| 124 | |||||
| 125 | } |
||||
| 126 |