1. 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)
  2. 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)
  3. PHP / Говнокод #4499

    +145

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

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

    ReallyBugMeNot, 01 Ноября 2010

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

    +166

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

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

    ReallyBugMeNot, 01 Ноября 2010

    Комментарии (1)
  5. 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)
  6. 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)
  7. 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)
  8. 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)
  9. PHP / Говнокод #4490

    +165

    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
    print "<form method=post name=\"main\" action=\"xz.php\" enctype=\"multipart/form-data\">\n";
    $box=$_POST['box'];
    while (list ($key,$val) = @each ($box)) {
    
     $size=filesize($server[$_GET['server']].":"."/".$val);
           if ($size < 0) $size=sprintf("%u", $size);
          $size=format_size($size, 0, 1);
    echo "<input type=\"text\" size=55 name=\"file_name\"  value=\"".$val."\">
    <input type=\"text\" size=25 name=\"film_name\"  value=\"\">
    <input type=\"text\" size=10 name=\"file_razmer\"  value=\"".$size."\">
    <input type=\"text\" size=1 name=\"file_server\"  value=\"".$_GET['server']."\">
    <select name=\"file_kachestvo\" size=1 >
    <option value=0></option>
    <option value=CamRip>CamRip</option>
    <option value=Telesync>Telesync</option>
    <option value=Promo DVD>Promo DVD</option>
    <option value=Telecine (TC)>Telecine (TC)</option>
    <option value=VHSrip>VHSrip</option>
    <option value=TVrip>TVrip</option>
    <option value=SATrip>SATrip</option>
    <option value=HDrip>HDrip</option>
    <option value=WEBrip>WEBrip</option>
    <option value=DVDRip>DVDRip</option></select>";
    print "<select name=\"file_serial\" size=1 >\n";
    for ($i=0; $i<count($serials); $i++) {
        print "\t\t<option value=".$serials[$i]['id'];
        if (@$_GET['mode']=="edit") if ($category[$i]['id']==$base_files[$index]['file_category']) print " selected";
        print ">".$serials[$i]['name_serials']."</option>\n";
    }
    print "</select></td>\n";
    print "</tr>\n";
    echo "";
    
    }
    print "<td colspan=2 align=center><input type=\"submit\" value=\"Добавить\"></td>\n";
    echo "</form>";
    
    //---------- и тут кагбэ обработчик формы--------------
    <?
    include ('config2.php');
    
    
        if ($_POST['file_serial']==0) {
            print "<p>Ошибка! Не заполныны обязательные поля:<br><br>\n";
            if ($_POST['file_serial']==0) print "<li>Сериал</br>\n";
            print "<br><a href=\"#\" onClick=\"history.back()\">Вернуться на сайт</a></p>";
            die();
        }
    //    $_POST['file_description'] = addslashes($_POST['file_description']);
        if ($_POST['file_serial'])
        $query="INSERT INTO files VALUES (";
        $query.="'',";
        $query.="'".$_POST['file_name']."',";
        $query.="'".$_POST['film_name']."',";
        $query.="'',";
        $query.="'',";
        $query.="'',";
        $query.="'',";
        $query.="'',";
        $query.="'',";
        $query.="'".$_POST['file_razmer']."',";
        $query.="'".$_POST['file_server']."',";
        $query.="'".$_POST['file_kachestvo']."',";
        $query.="'',";
        $query.="'',";
        $query.="'',";
        $query.="'',";
        $query.="'',";
        $query.="'".$_POST['file_serial']."',";
        $query.="'',";
        $query.="'0',";
        $query.="'',";
        $query.="'',";
        $query.="'0'";
        $query.=");";
        if (mysql_query ($query)) print "<p align=center>Сериал успешно добавлен в базу</p>";
        else print "<p align=center>Query failed</p>";
        print "<p align=center><a href=\"#\" onClick=\"history.back(-2)\">Вернуться на сайт</a></p>";
        die();
    ?>

    это гениально. вы не находите? http://forum.searchengines.ru/showpost.php?p=7879190&postcount=5

    GoodTalkBot, 31 Октября 2010

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

    +170

    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
    <?php 
    // Генерируем картинку для капчи, цифры и латынские литеры
    // PHP код:
    function rnd_str($str_size=1){ 
            $str='';  
            $chars= array(  
                'a', 'b', 'c', 'd', 'e',  
                'f', 'g', 'h', 'i', 'j',  
                'k', 'l', 'm', 'n', 'o',  
                'p', 'q', 'r', 's', 't',  
                'u', 'v', 'w', 'x', 'y',  
                'z',  
                  
                'A', 'B', 'C', 'D', 'E',  
                'F', 'G', 'H', 'I', 'J',  
                'K', 'L', 'M', 'N', 'O',  
                'P', 'Q', 'R', 'S', 'T',  
                'U', 'V', 'W', 'X', 'Y',  
                'Z'  
            );  
              
            for( $i=0; $i<$str_size; $i++ ){  
                $num= true;  
                if( rand(0,1) == 1 ) $num= false;  
                if($num) $str.= rand(0,9);  
                else $str.= $chars[rand(0,sizeof($chars)-1)];  
            }  
            return $str;  
        } 
    ?>
    <?php 
    // пример 
    // PHP код:
    
    echo rnd_str(); 
    ?>

    ...Внезапно наткнулось...

    > Важная информация
    > 27.03.2010 - Ура! Форуму OnlyWM - 1 месяц

    istem, 29 Октября 2010

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