Completed
Branch trunk (230097)
by SuperNova.WS
32:07
created

annonce.php (1 issue)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/**
4
* annonce.php
5
*
6
* Announces for trading between players
7
*
8
* @version 1.0s - Security checked for SQL-injection by Gorlum for http://supernova.ws
9
* @version 1.0
10
* @copyright 2008 by ??????? for XNova
11
*/
12
13
include('common.' . substr(strrchr(__FILE__, '.'), 1));
14
15
$users = db_user_by_id($user['id'], false, '`username`,`galaxy`,`system`');
16
$action = sys_get_param_int('action');
17
$GET_id = sys_get_param_int('id');
18
19
lng_include('announce');
20
21
switch($action)
22
{
23
  case 1://on veut poster une annonce
24
    $page .='<HTML>
25
    <center>
26
    <br>
27
    <table width="600">
28
    <td class="c" colspan="10" align="center"><b><font color="white">'.$lang['Classifieds'].'</font></b></td></tr>
29
    <form action="annonce.php?action=2" method="post">
30
    <td class="c" colspan="10" align="center"><b>'.$lang['Resources_to_be_sold'].'</font></b></td>
31
    <tr><th colspan="5">'.$lang['metal'].'</th><th colspan="5"><input type="texte" value="0" name="metalvendre" /></th></tr>
32
    <tr><th colspan="5">'.$lang['crystal'].'</th><th colspan="5"><input type="texte" value="0" name="cristalvendre" /></th></tr>
33
    <tr><th colspan="5">'.$lang['deuterium'].'</th><th colspan="5"><input type="texte" value="0" name="deutvendre" /></th></tr>
34
35
    <td class="c" colspan="10" align="center"><b>'.$lang['Desired_resources'].'</font></b></td></tr>
36
    <tr><th colspan="5">'.$lang['metal'].'</th><th colspan="5"><input type="texte" value="0" name="metalsouhait" /></th></tr>
37
    <tr><th colspan="5">'.$lang['crystal'].'</th><th colspan="5"><input type="texte" value="0" name="cristalsouhait" /></th></tr>
38
    <tr><th colspan="5">'.$lang['deuterium'].'</th><th colspan="5"><input type="texte" value="0" name="deutsouhait" /></th></tr>
39
    <tr><th colspan="10"><input type="submit" value="'.$lang['send'].'" /></th></tr>
40
41
    <form>
42
    </table>
43
    </HTML>';
44
45
    display($page);
46
  break;
47
48
  case 2:// On vient d'envoyer une annonce, on l'enregistre et on affiche un message comme quoi on l'a bien fait
49
    $metalvendre = sys_get_param_float('metalvendre');
50
    $metalsouhait = sys_get_param_float('metalsouhait');
51
    $cristalvendre = sys_get_param_float('cristalvendre');
52
    $cristalsouhait = sys_get_param_float('cristalsouhait');
53
    $deutvendre = sys_get_param_float('deutvendre');
54
    $deutsouhait = sys_get_param_float('deutsouhait');
55
56
    if(($metalvendre!=0 && $metalsouhait==0) ||($cristalvendre!=0 && $cristalsouhait==0) || ($deutvendre!=0 && $deutsouhait==0))
57
    {
58
      doquery("INSERT INTO {{annonce}} SET `user` ='{$users['username']}', `galaxie` ='{$users['galaxy']}', `systeme` ='{$users['system']}', `metala` ='{$metalvendre}', `cristala` ='{$cristalvendre}', `deuta` ='{$deutvendre}', `metals` ='{$metalsouhait}', `cristals` ='{$cristalsouhait}', `deuts` ='{$deutsouhait}'");
59
      message ($lang['Your_announce_was_recorded'], $lang['announce_status'],"annonce.php");
60
    }
61
    else
62
    {
63
      message ($lang['Your_announce_not_recorded'], $lang['announce_status'],"annonce.php?action=1");
64
    }
65
  break;
66
67
  case 3://Suppression d'annonce
68
    doquery("DELETE FROM {{annonce}} WHERE `id` = {$GET_id}");
69
    message ($lang['Your_announce_was_deleted'], $lang['announce_status'],"annonce.php");
70
  break;
71
72
  default://Sinon on affiche la liste des annonces
73
    $annonce = doquery("SELECT * FROM {{annonce}} ORDER BY `id` DESC ");
74
75
    $page2 = "<HTML><center><br>
76
    <table width=\"600\">
77
    <td class=\"c\" colspan=\"10\"><font color=\"#FFFFFF\">{$lang['Classifieds']}</font></td></tr>
78
    <tr><th colspan=\"3\">{$lang['Infos_of_delivery']}</th><th colspan=\"3\">{$lang['Resources_to_be_sold']}</th><th colspan=\"3\">{$lang['Desired_resources']}</th><th>{$lang['Action']}</th></tr>
79
    <tr><th>{$lang['Salesman']}</th><th>{$lang['Galaxy']}</th><th>{$lang['Solar_system']}</th><th>{$lang['metal']}</th><th>{$lang['crystal']}</th><th>{$lang['deuterium']}</th><th>{$lang['metal']}</th><th>{$lang['crystal']}</th><th>{$lang['deuterium']}</th><th>{$lang['Delete']}</th></tr>";
80
81
    while ($b = db_fetch($annonce))
82
    {
83
      $page2 .= '<tr><th>';
84
      foreach($b as $name => $value)
85
      {
86
        if($name!='id')
87
        {
88
          $page2 .= $value ;
89
          $page2 .= '</th><th>';
90
        }
91
      }
92
      $page2 .= ($b['user']==$users['username'])?"<a href=\"annonce.php?action=3&id={$b[id]}\">X</a></th></tr>":"</th></tr>";
93
    }
94
95
    $page2 .= "<tr><th colspan=\"10\" align=\"center\"><a href=\"annonce.php?action=1\">{$lang['add_announce']}</a></th></tr></td></table></HTML>";
96
97
    display($page2);
98
  break;
99
}
100
101
// Créé par Tom1991 Copyright 2008
102
// Modifié par BenjaminV
103
?>
0 ignored issues
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
104