1. PHP / Говнокод #3992

    +165

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    //SECURITY
    $mid = mysql_escape_string($mid);
    $ip = mysql_escape_string($ip);
    ..
    ..
    $time = intval(time());

    на всякий случай ;-)

    ZALMAN, 16 Августа 2010

    Комментарии (2)
  2. PHP / Говнокод #3991

    +126

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    if (isset($_REQUEST['input1'])) {
       echo "Данные введены";
    }
    elseif (!isset($_REQUEST['input1'])) {
       echo "
          <form action='#' name='form1'>
          <input type='text' name='input1' value='' >
          <input type='submit' value='Отправить' />
          </form>
       ";
    }

    Логика ващще

    Vasiliy, 16 Августа 2010

    Комментарии (2)
  3. PHP / Говнокод #3990

    +144

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-s
    RewriteCond %{REQUEST_FILENAME} !-l
    
    RewriteRule \.(jpeg|gif|bmp|png|jpg|css|js)$ - [L]
    
    RewriteRule ^([a-z]+)$ index.php?param1=$1 [L,QSA]

    abcee, 15 Августа 2010

    Комментарии (9)
  4. PHP / Говнокод #3986

    +156

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    //delete internal note
    
    if(is_numeric($post['nID']) && is_numeric($post['cID'])) {
    //echo $post['nID'];
    	$q = mysql_query("DELETE FROM notes WHERE notes_id='{$post['nID']}' LIMIT 1");
    	if($q) {echo "<span style='font-weight:bold;color:red'>Note deleted</span>";}
    	show_notes_2($post['cID']);
    }
    
    if(is_numeric($post['nIDD']) && is_numeric($post['cIDD'])) {
    //echo $post['nID'];
    	$q = mysql_query("DELETE FROM notes WHERE notes_id='{$post['nIDD']}' LIMIT 1");
    	if($q) {echo "<span style='font-weight:bold;color:red'>Note deleted</span>";}
    	show_notes($post['cIDD'],2);
    }

    что нам стоит срач устроить

    n0ne, 15 Августа 2010

    Комментарии (2)
  5. PHP / Говнокод #3985

    +157

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    $q = mysql_query("... /* тут мог быть ваш код */") or die(mysql_error());
          $nr = mysql_num_rows($q);
          $contor=0;
          if($nr<1) {
            echo "No notes found";
            $contor=0;
          } else {
            $contor=1;
            $cc = 0;
            while($d = mysql_fetch_assoc($q)) {
              ... /* тут мог быть ваш код */
              $cc++;
              $contor++;
            }
            if (!$contor) $contor = 0;
          }
          if (!$contor) $contor = 0;

    для уверенности.

    n0ne, 15 Августа 2010

    Комментарии (7)
  6. PHP / Говнокод #3980

    +148

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    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
    96. 96
    97. 97
    98. 98
    <?php
    if (!$action){
    	echoheader('addnews', $echo['header']);
    ?>
    
    <form method="post" name="addnews" action="<?=$PHP_SELF; ?>" onsubmit="return process_form(this)">
    
    
    
    <!-- короткая -->
    <fieldset id="short"><legend><?=$echo['short']; ?></legend>
    
    <?
    	echo run_filters('new-advanced-options', 'short');
    ?>
    
    
    <textarea name="short_story" tabindex="4"></textarea>
    </fieldset>
    
    
    
    <!-- кнопки -->
    <fieldset id="actions"><legend><?=$echo['actions']; ?></legend>
    <input type="submit" value="<?=$echo['add']; ?>" accesskey="s">
    </fieldset>
    
    
    
    
    
    <?
    	}
    ?>
    
    <fieldset id="date"><legend><?=$echo['date']; ?></legend>
    <input type="text" name="day" size="10" maxlength="2" value="<?=date('d'); ?>" title="<?=$echo['calendar']['day']; ?>" readonly>
    
    <input type="text" name="month" size="10" maxlength="10" value="<?=date('M'); ?>" readonly>
    
    
    
    <input type="text" name="year" maxlength="4" value="<?=date('y'); ?>" title="<?=$echo['calendar']['year']; ?>" readonly> <input type="text" name="hour" maxlength="2" value="<?=date('H', (time() + $config_date_adjust * 60)); ?>" title="<?=$echo['calendar']['hour']; ?>" readonly>:<input type="text" name="minute" maxlength="2" value="<?=date('i', (time() + $config_date_adjust * 60)); ?>" title="<?=$echo['calendar']['minute']; ?>" readonly>:<input type="text" name="second" maxlength="2" value="<?=date('s', (time() + $config_date_adjust * 60)); ?>" title="<?=$echo['calendar']['second']; ?>" readonly>
    </fieldset>
    
    
    
    </div></fieldset>
    
    <input type="hidden" name="mod" value="addnews">
    <input type="hidden" name="action" value="doaddnews">
    </form>
    
    <?
    	echofooter();
    
    
    // ********************************************************************************
    // Do add News to DB
    // ********************************************************************************
    if ($action == 'doaddnews'){
    	if (($added_time = strtotime($day.' '.$month.' '.$year.' '.$hour.':'.$minute.':'.$second)) == -1){
    		$added_time = (time() + $config_date_adjust * 60);
    	}
    
    	if (!$title){
    		$title = substr($short_story, 0, 10).'...';
    	}
    
    	$id = $sql->last_insert_id('news', '', 'id') + 1;
    
    	run_actions('new-save-entry');
    
    	$sql->insert(array(
    	'table'	 => 'news',
    	'values' => array(
    				'date'	   => $added_time,
    				'author'   => $member['username'],
    				'title'	   => replace_news('add', $title),
    				'short'	   => strlen(replace_news('add', $short_story)),
    				'full'	   => strlen(replace_news('add', $full_story)),
    				'avatar'   => $avatar,
    				'category' => $category,
    				'url'	   => ($url ? my_namespace($url) : my_namespace(totranslit($title))),
    				'hidden'   => (($config_approve_news == 'yes' and $member['level'] > 2) ? true : false)
    				)
    	));
    
    	$sql->insert(array(
    	'table'	 => 'story',
    	'values' => array(
    				'post_id' => $id,
    				'short'	  => replace_news('add', $short_story),
    				'full'	  => replace_news('add', $full_story)
    				)
    	));
    
    	run_actions('new-save-entry');

    dimiork, 14 Августа 2010

    Комментарии (19)
  7. PHP / Говнокод #3977

    +151

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    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
    <?php  
    
    // фиксация времени начала генерации страницы  
    $begin = microtime();  
    // матрица начального времени с секундами и миллисекундами  
    $arrbegin = explode(" ",$begin);  
    // Полное начальное время 
    $allbegin = $arrbegin[1] + $arrbegin[0];  
    
    ?>  
    
    <?php  
    
    // фиксация времени останова   
    $stop = microtime();  
    // матрица времени останова с секундами и миллисекундами  
    $arrend = explode(" ",$stop);  
    // Полное время останова 
    $allend = $arrend[1] + $arrend[0];  
    // вычитание из конечного времени начального  
    $alltime = $allend - $allbegin;  
    
    // вывод в браузер времени генерации страницы  
    $format = "Страница сгенерирована за %f секунд"; 
    printf($format,$alltime);  
    
    ?>

    http://acvarif.info/wbsphp/additphp/gener.html
    извращенный подсчет времени генерации

    Morgan, 13 Августа 2010

    Комментарии (6)
  8. PHP / Говнокод #3971

    +151

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    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
    <?php 
    $result2 = mysql_query("SELECT id,title FROM menu",$db);
    if (!$result2)
    {
    echo "<p>Запрос на выборку из базы не прошел.<br>Код ошибки:</p>";
    exit(mysql_error());
       }
    if (mysql_num_rows($result2) > 0)
    {
    $myrow2 = mysql_fetch_array($result2);
    do 
    {
    printf ("<p class='menu1'><a class=menu href='podelkin.php?cat=%s'>%s</a></p>",$myrow2["id"], $myrow2["title"]);
       }
    
    $cat=$myrow2 ["id"]
    
    $result3 = mysql_query("SELECT id,title FROM data WHERE cat=$cat",$db);
    if (!$result3)
    {
    echo "<p>Запрос на выборку из базы не прошел.<br>Код ошибки:</p>";
    exit(mysql_error());
       }
    if (mysql_num_rows($result3) > 0)
    {
    $myrow3 = mysql_fetch_array($result3);
    do 
    {
    printf ("<p class='menu1'><a class=menu href='podelkin_post.php?cat=%s'>%s</a></p>",$myrow3["id"], $myrow3["title"]);
       }
    while ($myrow3 = mysql_fetch_array($result3));
       }
    while ($myrow2 = mysql_fetch_array($result2));
       }
    else
    {
    echo "<p>Информация по запросу неможет быть извлечена в таблице нет записей</p>";
    exit ();
       }
    ?>

    http://ruseller-board.com/viewtopic.php?f=41&t=4777
    доска Гк xD

    Morgan, 13 Августа 2010

    Комментарии (3)
  9. PHP / Говнокод #3969

    +150

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    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
    <?php
    ob_start();
    $dblocation="localhost";
    
            $dbuser="root";
    
            $dbpasswd="qjgndfqe";
    	$dbname="lab3";
    
            $dbcnx=mysql_connect($dblocation, $dbuser, $dbpasswd);
    
            if(!$dbcnx)
            {
               echo("Не удалось подключиться к базе данных");
    
                exit();
            }
    
            $dbq=mysql_query("select version();");
    
            //echo(mysql_result($dbq,0));
    	
    	$db_select=mysql_select_db($dbname);
    	if(!$db_select)
    	{
    		echo("cant select table");
    		exit();
    	}
    	
    	$str=strtolower(trim($_SERVER['HTTP_USER_AGENT']));
    	//echo("\n");
    	if (strstr($str, 'firefox'))
    		{
    			mysql_query("UPDATE counter SET cnt1=cnt1+1");
    		}
    
    	if (strstr($str, 'opera'))
    		{
    			mysql_query("UPDATE counter SET cnt2=cnt2+1");
    		}
    
    	if (strstr($str, 'chrome'))
    		{
    			mysql_query("UPDATE counter SET cnt3=cnt3+1");
    		}
    
    	$sqltable = mysql_query("SELECT cnt1, cnt2, cnt3 FROM counter");
    	$row = mysql_fetch_array($sqltable);
    	$cnt1 = " | "."Firefox ".$row['cnt1']." | ";
    	$cnt2 = "Opera ".$row['cnt2']." | ";
    	$cnt3 = "Chrome ".$row['cnt3']." | ";
    
    	header("Content-type: image/png");
    	$im = @imagecreatetruecolor(350, 30)
          		or die('Cannot Initialize new GD image stream');
    	$color1=imagecolorallocate($im,0,0,255);
    	$color2=imagecolorallocate($im,233,14,91);
    	$color3=imagecolorallocate($im,0,10,0);
    	$bgcolor=imagecolorallocate($im,192,155,120);
    
    	imagefilledrectangle($im, 0,0,349,29, $bgcolor);
    	imagestring($im,50,0,5,"$cnt1",$color1);
    	imagestring($im,50,150,5,"$cnt2",$color2);
    	imagestring($im,50,250,5,"$cnt3",$color3);
    	
    	imagepng($im);
    	imagedestroy($im);
    ?>

    deezzel, 13 Августа 2010

    Комментарии (3)
  10. PHP / Говнокод #3968

    +163

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    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
    <?php
    
    if (isset($_POST['author']))
    {
    $author = $_POST['author'];
    }
    
    if (isset($_POST['text']))
    {
    $text = $_POST['text'];
    }
    
    if (isset($_POST['pr']))
    {
    $pr = $_POST['pr'];
    }
    
    if (isset($_POST['sub_com']))
    {
    $sub_com = $_POST['sub_com'];
    }
    if (isset($_POST['surname']))
    {
    $surname = $_POST['surname'];
    }
    if (isset($_POST['tel']))
    {
    $tel = $_POST['tel'];
    }
    
    if (isset($sab_com))/*если нажата кнопка*/
    {
    if (isset($author)) {trim($author);}/*убираем лишние пробелы*/
    else {$author="";}
    if (isset($text)) {trim($text);}/*убираем лишние пробелы*/
    else {$textr="";}
    if (isset($surname)) {trim($surname);}/*убираем лишние пробелы*/
    else {$surname="";}
    if (isset($tel)) {trim($tel);}/*убираем лишние пробелы*/
    else {$tel="";}
    if (empty($author) or empty($text) or empty($surname) or empty($tel))/*если пустая переменная автор или текст*/
    {
    exit ("<p align ='center'><strong><h1>Вы ввели не всю информацию, вернитесь назад и заполните все поля. </h1></strong> <br><br> <input name='back' type='button' value='Вернуться назад' onclick='javascript:self.back();'>");
    }/*останавливаем программу ,всталяем кнопку,даем команду при нажатии вернутся назад на 1 шаг*/
    
    $author = stripslashes($author);/*охрана от слешов*/
    $text = stripslashes($text);/*охрана от слешов*/
    $surname = stripslashes($surname);/*охрана от слешов*/
    $tel = stripslashes($tel);/*охрана от слешов*/
    $author = htmlspecialchars($author);/*охрана от различных тегов*/
    $text = htmlspecialchars($text);/*охрана от различных тегов*/
    $surname = htmlspecialchars($surname);/*охрана от различных тегов*/
    $tel = htmlspecialchars($tel);/*охрана от различных тегов*/
    if ($pr == 777)
    {
    $address = '[email protected]';
    $sub = "Появился новый заказчик";/**/
    $mes = "Имя заказчика: $author \n Фамилия заказчика: $surname \n телефон заказчика: $tel\nСодержание письма: $text";
    
    $verify = mail ($address,$sub,$mes,"Content-type:text/plain; charset = windows-1251\r\n");
    if ($verify == 'true')
    {
    echo ("<p align ='center'><strong><h1>Ваша заявка успешно отправлена.</h1></strong> <br><br> <input name='back' type='button' value='Вернуться назад' onclick='javascript:self.back();'>");
    }
    }
    else
    {
    exit ("<p>Вы ввели неверные числа с картинки на предыдущей странице. <br> <input name='back' type='button' value='Вернуться назад' onclick='javascript:self.back();'>");
    }
    }
    
    ?>

    Такой вот обработчик.

    http://ruseller-board.com/viewtopic.php?f=41&t=3363

    mrbig66, 13 Августа 2010

    Комментарии (26)