"PHP" / Говнокод #5352 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 62
  63. 63
  64. 64
  65. 65
  66. 66
  67. 67
  68. 68
  69. 69
  70. 70
  71. 71
  72. 72
  73. 73
  74. 74
  75. 75
  76. 76
  77. 77
  78. 78
  79. 79
  80. 80
  81. 81
  82. 82
  83. 83
  84. 84
  85. 85
  86. 86
  87. 87
  88. 88
  89. 89
  90. 90
  91. 91
  92. 92
  93. 93
  94. 94
  95. 95
<?php
$month_cols = array("january" => 31,
	            "february" => 28,
                    "march" => 31,
                    "april" => 30,
                    "may" => 31,
                    "june" => 30,
                    "july" => 31,
                    "august" => 31,
                    "september" => 30,
                    "october" => 31,
                    "november" => 30,
                    "december" => 31);

if($_POST["month_to_change"])
{
$month_to = $_POST["month_to_change"];
 for($i = 1; $i <= $month_cols[$_POST["month_to_change"]]; $i++)
 {
  $description = mysql_real_escape_string($_POST["textar_".$i]);
  mysql_query("UPDATE `calender` SET `description` = '$description' WHERE `day` = '$i' AND `month` = '$month_to' LIMIT 1");
 }
}

  echo "<h3>Лунный календарь</h3>";

  if($_POST["month_change"])
  {
   if($_POST["month"] == "january") $jan_sel = "selected";
   if($_POST["month"] == "february") $feb_sel = "selected";
   if($_POST["month"] == "march") $mar_sel = "selected";
   if($_POST["month"] == "april") $apr_sel = "selected";
   if($_POST["month"] == "may") $may_sel = "selected";
   if($_POST["month"] == "june") $jun_sel = "selected";
   if($_POST["month"] == "july") $jul_sel = "selected";
   if($_POST["month"] == "august") $aug_sel = "selected";
   if($_POST["month"] == "september") $sep_sel = "selected";
   if($_POST["month"] == "october") $oct_sel = "selected";
   if($_POST["month"] == "november") $nov_sel = "selected";
   if($_POST["month"] == "december") $dec_sel = "selected";
  }
  else
  {
   $jan_sel = "selected";
  }

  $changing_month = $_POST["month"];
  if($changing_month == "") $changing_month = "january";

  echo "<table>\n";
  echo "<tr><td>\n";
  echo "<form name=\"form_name\" id=\"form_id\" action=\"\" method=\"post\">\n";
  echo "<select name=\"month\" onChange=\"this.form.submit()\">\n
  	<option value=\"january\" $jan_sel>Январь</option>\n
	<option value=\"february\" $feb_sel>Февраль</option>\n
        <option value=\"march\" $mar_sel>Март</option>\n
        <option value=\"april\" $apr_sel>Апрель</option>\n
        <option value=\"may\" $may_sel>Май</option>\n
        <option value=\"june\" $jun_sel>Июнь</option>\n
        <option value=\"july\" $jul_sel>Июль</option>\n
        <option value=\"august\" $aug_sel>Август</option>\n
        <option value=\"september\" $sep_sel>Сентябрь</option>\n
        <option value=\"october\" $oct_sel>Октябрь</option>\n
        <option value=\"november\" $nov_sel>Ноябрь</option>\n
        <option value=\"december\" $dec_sel>Декабрь</option>\n
        </select>\n";
  echo "<input type=\"hidden\" name=\"month_change\" value=\"change\">\n";
  echo "</td></tr>\n";

  for($i = 1; $i <= $month_cols[$changing_month]; $i++)
  {

  $q_q2 = mysql_query("SELECT `description` FROM `calender` WHERE `day` = '$i' AND `month` = '$changing_month' LIMIT 1");

  $descr = mysql_fetch_row($q_q2);

   echo "<tr valign=\"top\" cols=\"5\">
          <td><b>$i</b></td>
          <td>
          <textarea name=\"textar_$i\">".$descr[0]."</textarea>
          </td>
</tr>\n";
  }

  echo "<tr>
         <td colspan=\"2\" align=\"right\">
         <input type=\"submit\" value=\"Сохранить\">
         </td>
</tr>\n";

  echo "<input type=\"hidden\" name=\"month_to_change\" value=\"$changing_month\">\n";

  echo "</form>";
  echo "</table>";
?>

А это уже часть, которая апдейтит базу :-)

Запостил: varg242 varg242, (Updated )

Комментарии (12) RSS

  • ...
    if($_POST["month"] == "january") $jan_sel = "selected";
    ...
    - массивы? не, не слышал!

    echo "<select name=\"month\" onChange=\"this.form.submit()\">\n
    <option value=\"january\" $jan_sel>Январь</option>\n
    -циклы? не, не слышал!

    $month_to = $_POST["month_to_change"];
    -sql-injection? не, не слышал!!!
    Ответить

Добавить комментарий

Переведи на "PHP", guest!

    А не использовать ли нам bbcode?


    8