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

    +168

    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
    // преобразование из 12345 в 12 345
    function ValueF($value) {
      $temp=explode(".",$value);
    
      for ($i_f=strlen($temp[0])-1, $i_f2=1; $i_f>=0; $i_f--, $i_f2++) {
        $str.=$temp[0][$i_f];
        if ($i_f2==3) {
          $str.=" ";
          $i_f2=0;
          }
        }
      $str=strrev($str);
    
    return $str;
    }

    2006 год

    dendy_barn, 03 Ноября 2010

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

    +167

    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
    if (!empty($_POST['mail'])) {
    $res=mysql_query("SELECT * FROM `users` WHERE email='".$_POST['mail']."' LIMIT 1");
    if (mysql_num_rows($res) > 0) {
    $row=mysql_fetch_array($res);
    
    $to  = $_POST['mail'] ; 
    $subject = "Восстановление пароля";
    $message = '<html><head><title>Восстановление пароля</title></head><body>
    <p>Процедура восстановления пароля прошла успешно</ p>
    <p>Ваш пароль: <b style="color:#006633"> '.$row['pass'].'</b></p></body></html> '; 
    
    $headers  = "Content-type: text/html; charset=utf8 \r\n"; 
    $headers .= "From: Восстановление пароля <[email protected]>\r\n"; 
    $headers .= "Bcc: [email protected]\r\n"; 
    $send=mail($to, $subject, $message, $headers); 
    if ($send==true) { echo 'Пароль был отправлен на ваш email.';} else { echo 'Попробуйте позже.';}
    }
    else { echo 'Такого пользователя нет в базе.'; }

    Мегасекьюрное восстановление пароля!

    Wivern, 02 Ноября 2010

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

    +164

    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
    function get_afisha()
    {
    	global $database;
    	$i=2;			
    	while(count($row)<4)
    	{
    		$query='
    		(
    			SELECT DISTINCT ae.id, ae.title
    				FROM afisha.#__afisha_events ae
    				WHERE  	ae.published = 1 AND
    						ae.deleted = 0 AND
    						ae.type_event = 1 AND
    						ae.id IN (SELECT aed.id_event FROM afisha.#__afisha_event_dates aed WHERE aed.date >= CURDATE()) AND
    						ae.city=1
    				ORDER BY RAND()	
    				LIMIT 1
    		)
    		union
    		(		
    			SELECT c.id,c.title		
    				FROM night.#__content c 
    				LEFT JOIN night.#__content_afisha_date ca 
    					ON c.id = ca.id_content		
    				WHERE 	c.state=1 AND 
    						c.access=0 AND 
    						ca.date >= CURDATE() AND 
    						c.catid=5 AND
    						ae.city=1
    				GROUP BY c.id, ca.id_content		
    				ORDER BY RAND()		
    				LIMIT 1
    		)
    		union
    		(		
    			SELECT DISTINCT ae.id, ae.title
    				FROM afisha.#__afisha_events ae
    				WHERE  	ae.published = 1 AND
    						ae.deleted = 0 AND
    						ae.type_event = 4 AND
    						ae.id IN (SELECT aed.id_event FROM afisha.#__afisha_event_dates aed WHERE aed.date >= CURDATE()) AND
    						ae.city=1
    				ORDER BY RAND()	
    				LIMIT 1
    		)
    		union
    		(
    			SELECT DISTINCT ae.id, ae.title
    				FROM afisha.#__afisha_events ae
    				WHERE  	ae.published = 1 AND
    						ae.deleted = 0 AND
    						ae.type_event = 2 AND
    						ae.id IN (SELECT aed.id_event FROM afisha.#__afisha_event_dates aed WHERE aed.date >= CURDATE()) AND
    						ae.city=1
    				ORDER BY RAND()	
    				LIMIT 1
    		)';		
    		$database->setQuery($query);
    		$row=$database->loadObjectlist();
    		$i++;
    	}
    	return $row;
    }
    $row=get_afisha();

    Очень нужная переменная i.

    vidok, 02 Ноября 2010

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

    +173

    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
    $z="select team,r1,ochko from gametable order by pos ";$q=mysql_query($z); //присваиваю переменной данные из таблтцы
    $i=0;
    while($inf=mysql_fetch_array($q,MYSQL_ASSOC)){
    $i++;
    if($inf['team']=="ManchesterUnited"){$inf['team']="<b>ManchesterUnited</b>";
    }
    
    $row=array("class=\"row-2\"","class=\"row-3\"","class=\"row-4\"","class=\"row-5\"","class=\"row-6\"","class=\"row-1\"");//массив из стилей
    if ($i==1) {echo "$row[0]";};
    elseif($i==2) {echo "$row[1]";}
    elseif($i==3) {echo "$row[2]";}
    elseif($i==4) {echo "$row[3]";}
    elseif($i==5) {echo "$row[3]";}
    elseif($i==6) {echo "$row[4]";}
    elseif($i==7,12){echo "$row[5]";}
    else {$row="class=\"row-2\"";}
    
    echo"
     <tr $row>// вставка стиля
    <td class=\"column-1\">$i </td>
       <td class=\"column-2\">$inf[team]</td>
       <td class=\"column-3\">$inf[r1]</td>
       <td class=\"column-3\">$inf[ochko]</td>
                <td class=\"column-3\"></td>        
           <td class=\"column-3\"></td>
           <td class=\"column-4\"></td>
           <td class=\"column-3\"></td>
    </tr>";
    }

    Свежачок!
    Я насчитал 9 какашек, а вы?

    Uchkuma, 01 Ноября 2010

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

    +145

    1. 1
    2. 2
    class Partner extends SqlQuery {
    ...

    Партнер - это тот, кто привел юзера. Т.е. по факту, другой юзер.

    ReallyBugMeNot, 01 Ноября 2010

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

    +166

    1. 1
    echo $tpl->ParseTemplate2('client_pardon', $client_pardon,  $CFG['root']['template_basket']);

    Самописный интернет-магазин, кусок кода "если обломилось создание заказа".

    ReallyBugMeNot, 01 Ноября 2010

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

    +161

    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
    // Функция отметки входящих сообщений как прочитанных
    	function CheckReadPM() {	
    		global $user, $site, $db;
    		$pm_ids = SafeDB($_POST['mod'], 11, int);
    		$where = '(`id` = '.$pm_ids[0];
    		$i = 1;
    		while($i < count($pm_ids)) {
    			$where .= ' or `id` = '.$pm_ids[$i];	
    			$i++;	
    		}
    		$where .= ") and `to` = ".$user->Get('u_id')." and `black` = 0";
    		$db->Update('private', "`read` = 1", $where);	
    	}

    Мартин, 31 Октября 2010

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

    +168

    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
    <?php
    Class Draw
    {
    // вырисовка графика баланса
    	function Graph($y1,$y2,$y3,$y4,$y5,$y6,$y7,$firstday) {
    		header ("Content-type: image/png");
    		$im = imagecreatefrompng("graph.png");
    		$text_color = imagecolorallocate($im, 233, 14, 91);
    		$color = imagecolorallocate($im, 0, 0, 0);
    		$bg = imagecolorallocate($im, 180, 180, 200);
    		#--------------------------------------------------------
    		imagefill ($im, 0, 0, $bg);
    		#---------------------------------------------------------
    		imageline($im, 50, 0, 1000, 0, $color);
    // в это же духе еще ~10 строк
    		imageline($im, 50, 900, 1000, 900, $color);
    		#---------------------------------------------------------
    		imageline($im, 100, 950, 100, 0, $color);
    // аналогично
    		imageline($im, 700, 950, 700, 0, $color);
    		#---------------------------------------------------------
    		imageline($im, 100, 1000-$y1, 200, 1000-$y2, $text_color);
    		imagefilledellipse ($im, 100, 1000-$y1, 10, 10, $color);
    		imagestring($im, 3, 115, 1000-$y1, $y1 . " RUB", $text_color);
    		imagestring($im, 5, 90, 960, $firstday, $text_color);
    		#-----------------------------------------------------------
    		imageline($im, 200, 1000-$y2, 300, 1000-$y3, $text_color);
    		imagefilledellipse ($im, 200, 1000-$y2, 10, 10, $color);
    		imagestring($im, 3, 215, 1000-$y2, $y2 . " RUB", $text_color);
    		imagestring($im, 5, 190, 960, $firstday+1, $text_color);
    		#-------------------------------------------------------------
    		imageline($im, 300, 1000-$y3, 400, 1000-$y4, $text_color);
    		imagefilledellipse ($im, 300, 1000-$y3, 10, 10, $color);
    		imagestring($im, 3, 315, 1000-$y3, $y3 . " RUB", $text_color);
    		imagestring($im, 5, 290, 960, $firstday+2, $text_color);
    		#------------------------------------------------------------
    		imageline($im, 400, 1000-$y4, 500, 1000-$y5, $text_color);
    		imagefilledellipse ($im, 400, 1000-$y4, 10, 10, $color);
    		imagestring($im, 3, 415, 1000-$y4, $y4 . " RUB", $text_color);
    		imagestring($im, 5, 390, 960, $firstday+3, $text_color);
    		#-----------------------------------------------------------
    		imageline($im, 500, 1000-$y5, 600, 1000-$y6, $text_color);
    		imagefilledellipse ($im, 500, 1000-$y5, 10, 10, $color);
    		imagestring($im, 3, 515, 1000-$y5, $y5 . " RUB", $text_color);
    		imagestring($im, 5, 490, 960, $firstday+4, $text_color);
    		#------------------------------------------------------------
    		imageline($im, 600, 1000-$y6, 700, 1000-$y7, $text_color);
    		imagefilledellipse ($im, 600, 1000-$y6, 10, 10, $color);
    		imagestring($im, 3, 615, 1000-$y6, $y6 . " RUB", $text_color);
    		imagestring($im, 5, 590, 960, $firstday+5, $text_color);
    		#------------------------------------------------------------
    		imagefilledellipse ($im, 700, 1000-$y7, 10, 10, $color);
    		imagestring($im, 3, 715, 1000-$y7, $y7 . " RUB", $text_color);
    		imagestring($im, 5, 690, 960, $firstday+6, $text_color);
    		#---------------------------------------------------------
    		imagestring($im, 5, 0, 900, 100, $text_color);
    		imagestring($im, 5, 0, 800, 200, $text_color);
    		imagestring($im, 5, 0, 700, 300, $text_color);
    		imagestring($im, 5, 0, 600, 400, $text_color);
    		imagestring($im, 5, 0, 500, 500, $text_color);
    		imagestring($im, 5, 0, 400, 600, $text_color);
    		imagestring($im, 5, 0, 300, 700, $text_color);
    		imagestring($im, 5, 0, 200, 800, $text_color);
    		imagestring($im, 5, 0, 100, 900, $text_color);
    		imagestring($im, 5, 0, 0, 1000, $text_color);
    		#---------------------------------------------------------
    		imagepng($im);
    		imagedestroy($im);
    	}
    }
    ?>

    той же 3х летней давности.....комментарии излишни

    Steel2010, 31 Октября 2010

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

    +164

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    function CheckDBInsert($str)
    {
    $arr = array("INSERT","SELECT","UPDATE","DELETE","FLUSH","UNION","CONCAT","SET","GRANT","--",";","..","'","-","%","(",")");
    foreach ($arr as $v) {
    $pos = strpos($str, $v);
    if ($pos === false) {
    	} else {
    return "ОШИБКО";
    die();
    }
    }

    код мой 3-летней давности....я плакалЬ(но он работал!)

    Steel2010, 31 Октября 2010

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

    +158

    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
    // Итак, определим класс Namer.
    class Namer {
       var $name;
       var $surname;
       function getName() { return $this->name; }
       function getSurname() { return $this->surname; }
    }
    
    
    
    // Как видим, интерфейсная часть полностью определена. Осталось реализовать два механизма обработки входной строки. Сделаем это мы в двух классах-наследниках SpaceNamer и CommaNamer.
    
    
    //// класс для обработки строки в формате "имя фамилия"
    class SpaceNamer extends Namer {
       function SpaceNamer($full_name) {
          $splitter_pos = strpos($full_name, ' '); // находим пробел
          $this->name = substr($full_name, 0, $splitter_pos); // все, что до пробела - это имя
          $this->surname = substr($full_name, $splitter_pos+1); // после пробела - фамилия
       }
    }
    
    //// класс для обработки строки в формате "фамилия,имя"
    class CommaNamer extends Namer {
       function CommaNamer($full_name) {
          $splitter_pos = strpos($full_name, ','); // находим запятую
          $this->name = substr($full_name, $splitter_pos+1); // все, что до запятой - это фамилия
          $this->surname = substr($full_name, 0, $splitter_pos); // после запятой - имя
       }
    }

    и интерфейсы не нужны!

    Morgan, 31 Октября 2010

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