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

    +153

    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
    public static function translite($string) {
            $rus=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",
                "ё","й","ю","ь","ч","щ","ц","у","к",
                "е","н","г","ш","з","х","ъ","ф","ы","в",
                "а","п","р","о","л","д","ж","э","я","с",
                "м","и","т","б","Ё","Й","Ю","Ч","Ь",
                "Щ","Ц","У","К","Е","Н","Г","Ш","З",
                "Х","Ъ","Ф","Ы","В","А","П","Р","О",
                "Л","Д","Ж","Э","Я","С","М","И","Т","Б",
                "-"," ","–","?",'"',",",".","«","»","'","!",
                "/","\\",":",";","<",">","(",")","[","]",
                "{","}","@","#","№","$","%","^","&","*",
                "~");
            $eng = 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",
                "yo","iy","yu","","ch","sh","c","u","k",
                "e","n","g","sh","z","h","","f","y","v",
                "a","p","r","o","l","d","j","е","ya","s",
                "m","i","t","b","yo","iy","yu","ch","",
                "sh","c","u","k","e","n","g","sh","z",
                "h","","f","y","v","a","p","r","o",
                "l","d","j","e","ya","s","m","i","t","b",
                "_","_","_","","","","","","","","",
                "","","","","","","","","","",
                "","","","","","","","","","",
                "");
            $string = str_replace($rus, $eng,  $string);
            if(!empty($string)) {
                return $string;
            }
            else return("");
        }

    Как соответсвует название функции той неведомой херне, которую она делает я так и не понял.
    Столько травы у меня нет.

    Homess, 26 Декабря 2013

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

    +160

    1. 1
    2. 2
    3. 3
    {if $smarty.foreach.categories.iteration == 2 || $smarty.foreach.categories.iteration == 4 || $smarty.foreach.categories.iteration == 6 || $smarty.foreach.categories.iteration == 8 || $smarty.foreach.categories.iteration == 10 || $smarty.foreach.categories.iteration == 12  || $smarty.foreach.categories.iteration == 14  || $smarty.foreach.categories.iteration == 16}
          <div class="clear"></div>
    {/if}

    Smarty

    uadeveloper, 26 Декабря 2013

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

    +154

    1. 1
    2. 2
    3. 3
    4. 4
    if((int)$this->tmpl['detailwindow'] == 4 || (int)$this->tmpl['detailwindow'] == 5 || (int)$this->tmpl['detailwindow'] == 7) {
      } else { 
       echo '<td align="center">' . str_replace("%onclickclose%", $this->tmpl['detailwindowclose'], $this->item->closebutton). '</td>';
      }

    Какая глубина мысли!
    Интересно, а чтобы ОНО написало в С++?

    virtual_cia, 26 Декабря 2013

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

    +151

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    $proposal['categories'] = explode(',',db_get_field('
                SELECT GROUP_CONCAT(pc.category_id)
                FROM `?:proposal_categories` pc
                INNER JOIN `?:proposal` p ON pc.`proposal_id` = p.`id`
                INNER JOIN `?:proposal_category` pca ON pc.`category_id` = pca.`id`
                WHERE pca.`status` = ?s AND pc.`proposal_id` = ?i
                ORDER BY pca.position', 'A', $proposal['proposal_id']));

    Нашел в собственном коде... вроде безобидно, но забавно.

    Segalp, 25 Декабря 2013

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

    +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
    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
    class StaticArray { // TO DO: add float, char, double
    private $min = 0;
    private $lengch = 0;
    private $max = 0;
    private $array = array();
    function __construct($lengch,$type) {
    if (!is_numeric($lengch) || $type != 'int'&& $type != 'long'&& $type != 'byte'&& $type != 'short'){  
    echo "BAD ARRRAY TYPE OR LENGCH!\n";
    return false;
    }
    $this->lengch = $lengch;
    switch ($type){
    case 'int':
    $this->min = -2147483647;
    $this->max = 2147483648;
    break;
    case 'byte':
    $this->min = -127;
    $this->max = 128;
    break;
    case 'short':
    $this->min = -32768;
    $this->max = 32767;
    break;
    case 'long':
    $this->min = -9223372036854775808;
    $this->max = 9223372036854775807;
    break;
    }
    for ($i=0;$i < $lengch;$i++){
    $this->array[$i] = 0;
    }
    }
     function add ($vaule,$num){
     if ($vaule >= $this->max || $vaule <= $this->min || !is_numeric($num) || $num < 0 || $num >= $this->lengch){
     echo "Not valid vaule!\n";
     return false;
     }
     $this->array[$num] = $vaule;
    }
     
     function ToNormalArray (){
     return $this->array;
     }
     function get ($num){
     if ($num >= $this->lengch || $num < 0){
     echo "BAD ARRAY INDEX\n";
     return false;
     }
     return $this->array[$num];
     }
     function GetLengch(){
     return $this->lengch; 
    }
    }

    Обнаружил в исходниках одного из сайтов который разрабатывал. Предыдущий кодер действительно этим ползовался! Особенно умиляет метод ToNormalArray().

    zadrot, 25 Декабря 2013

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

    +155

    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
    //users.php
    
    public function search_()
        {
    // --- Поиск по пользователям
          $sql_search = mysql_query($this->sql);
          $folder = $this->folder;
          if (mysql_num_rows($sql_search)>0)
          {
            $row_search = mysql_fetch_assoc($sql_search);
            do
            {
              $user_id = $row_search["id"];
              $sql = mysql_query("SELECT SOCIAL_fotos.picture_mini FROM SOCIAL_fotos WHERE fotoalbum_id = '0' and user_id = '$user_id' LIMIT 1");
              if (mysql_num_rows($sql)>0)
              {
                $row_sql = mysql_fetch_assoc($sql);
                $picture_mini = $row_sql["picture_mini"];
              }
              else
                $picture_mini = "picture/empty_mini.jpg";
              printf("<p><a href=\"%s\" target=\"_blank\"><img src=\"$folder/%s\">%s</a><br>%s", $row_search["alias"], $picture_mini, $row_search["lfm"], $row_search["city"]);
            }
            while($row_search = mysql_fetch_assoc($sql_search));
          }
        }
    //funct_prover.php
    
    
    function prover($con)
      {
        $element = array("'");
        $con = str_replace($element, ";appost;", $con);
        return htmlspecialchars(trim($con));
      }
    
    
    //conf_connect.php
    
    $server_con = 'localhost'; // Адрес сервера mysql
      $username_con = ''; // Имя пользователя
      $password_con = ''; // Пароль
      $dbname_con = 'socialdb';
    
      $url = $_SERVER["HTTP_HOST"];
      $site1 = 'panzins.ru';
      $site2 = 'www.panzins.ru';
      if ($url != $site1 and $url != 'localhost' and $url != $site2)
      exit();
      $url_path = $_SERVER["REQUEST_URI"];
      if ($url == $site2)
      {
        header("Location: http://panzins.ru$url_path");
        exit();
      }
    
      mysql_connect($server_con, $username_con, $password_con) or die("No connection");
      mysql_query('SET NAMES utf8') or die("Set names error");
      mysql_select_db($dbname_con) or die("No database");
      header('Content-Type:text/html; charset=utf-8');
      $table_log = "SOCIAL_log";
      $table_alias = "SOCIAL_alias";
      $table_user = "SOCIAL_user";
    
    // И еще много няшек

    MVC, PDO, Framework, для лохов ибо там избыточный код. Написать свою соц сеть за 30 дней легко. Знакомьтесь, Сергей Панзин, скромный адепт Жопова. http://rutracker.org/forum/viewtopic.php?t=4619804

    Сам шидевр. http://panzins.ru/

    Keeper, 23 Декабря 2013

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

    +155

    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
    $s='';
    		$kfg=new Konfig('');
    		$kfg('self');
    		{
    			$kfg->k1='v1';
    			$s.=$kfg->k1."\n";
    		}
    		{
    			$kfg->k2->k='v2';
    			$s.=$kfg->k2->k."\n";
    		}
    		{
    			$kfg->{'k3.k'}='v3';
    			$s.=$kfg->k3->k."\n";
    		}
    		{
    			$kfg->k4='v4';
    			$kfg->k4->k='v4';
    			$s.=$kfg->k4."\n";
    			$s.=$kfg->k4->k."\n";
    		}
    		{
    			$s.=$kfg->strstr('ab','b');
    		}
    		$this->response->body('<pre>'.$s."\n".Debug::dump((string)$kfg)."\n".Debug::dump($kfg).'</pre>');

    TDD in Action, Вот так я проверяю работоспособность волшебной во всех местах конфиги.
    из личного сайта http://lure0xaos.url.ph/

    Lure Of Chaos, 22 Декабря 2013

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

    +153

    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
    /*где-то в начале: error_reporting(0);*/
    
    class PhocaGalleryFile{
    	function getCSSFile($id = 0, $fullPath = 0) {
    		if ((int)$id > 0) {
    			$db = &Factory::getDBO();
    			$query = 'SELECT a.filename as filename, a.type as type'
    				.' FROM #__styles AS a'
    			    .' WHERE a.id = '.(int) $id;
    			$db->setQuery($query, 0, 1);
    			$filename = $db->loadObject();
    			if (isset($filename->filename) && $filename->filename != '') {
    				if ($fullPath == 1 && isset($filename->type)) {
    					return self::getCSSPath($filename->type). $filename->filename;
    				} else {
    					return $filename->filename;
    				}
    			}
    		}
    
    		return false;
    	}
    
     . . .
    }

    Поубивал пустые строки (по 2 штуки между каждой строкой кода) и комменты вида:
    /* ===============
    == This function is geting a CSSFile fron database .....
    ===============
    */
    Гы! Код для заказчика должен выглядеть наукообразно и непонятно.
    И обязательно выдавать Notices и Warnings.

    virtual_cia, 19 Декабря 2013

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

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    /* @component Phoca Component
     * @copyright Copyright (C) Jan Pavelka www.phoca.cz
    */
    	protected function getLabel() {
    		echo '<div class="clearfix"></div>';
    		return parent::getLabel();
    		echo '<div class="clearfix"></div>';
    	}

    Это диагноз...

    virtual_cia, 18 Декабря 2013

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

    +119

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    Well, there were other factors in play there. htmlspecialchars was a
    very early function. Back when PHP had less than 100 functions and the
    function hashing mechanism was strlen(). In order to get a nice hash
    distribution of function names across the various function name lengths
    names were picked specifically to make them fit into a specific length
    bucket. This was circa late 1994 when PHP was a tool just for my own
    personal use and I wasn't too worried about not being able to remember
    the few function names.
    
    -Rasmus

    http://news.php.net/php.internals/70691

    someone, 17 Декабря 2013

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