1. Лучший говнокод

    В номинации:
    За время:
  2. PHP / Говнокод #26025

    0

    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
    DBconfig.php
    <?
    function sql_connect($mysqlhost,$mysqluser,$mysqlpass,$mysqldb){
             $sql_conn=mysql_connect($mysqlhost,$mysqluser,$mysqlpass) or die("mysql_query error: " .mysql_error());
             mysql_select_db($mysqldb);
             }
    
    function sql_execute($query, $get_counter = false)
    	{
    	static $sqlquerycounter = 0;
    	if(isset($_GET['_dbg']) && isset($_GET['_sql'])){pr('['.$sqlquerycounter.'] '.$query);}
    
    	if(!$get_counter)
    		{
    		 if (!$query = mysql_query($query)) {
    			trigger_error('MySQL Error: '.mysql_error());
    		  }
    		$sqlquerycounter++;
    		return $query;
    		}
    	else {return $sqlquerycounter;}
    	}
    
    function sql_close(){
            mysql_close($sql_conn);
            }
    
    		
    ?>
    
    file.php
    
    sql_connect($_CONFIG["mysqlhost"], $_CONFIG["mysqluser"], $_CONFIG["mysqlpass"], $_CONFIG["mysqldb"]);
    $sql = sql_execute("SET NAMES UTF8");
    
    $sql = sql_execute("SELECT * FROM publications WHERE id='$_GET[id]' LIMIT 0,1");
    $res = mysql_fetch_array($sql);

    phpBidlokoder2, 11 Ноября 2019

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

    0

    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
    /**
    	* <p>Статический метод размещает все аргументы и ключи по парам.</p> <p>Нечетные аргументы - массивы, четные - ключи, по которым искать в массивах.</p> <p>Ключи могут быть массивами. В этом случае поиск происходит во вложенных массивах. Возвращает первый не пустой элемент пары аргумент/ключ.</p>
    	*
    	*
    	* @param array $arraya  массив для анализа
    	*
    	* @param array $string  Ключи поиска
    	*
    	* @param strin $integerk  Неограниченные последовательно проверяемые пары массив\ключ
    	*
    	* @param integer $mixeda  
    	*
    	* @return mixed 
    	*
    	* @static
    	* @link http://dev.1c-bitrix.ru/api_d7/bitrix/main/type/collection/firstnotempty.php
    	* @author Bitrix
    	*/
    	public static function firstNotEmpty()
    	{
    		$argCount = func_num_args();
    		for ($i = 0; $i < $argCount; $i += 2)
    		{
    			$anArray = func_get_arg($i);
    			$key = func_get_arg($i+1);
    			if (is_array($key))
    			{
    				$current = &$anArray;
    				$found = true;
    				foreach ($key as $k)
    				{
    					if (!is_array($current) || !array_key_exists($k, $current))
    					{
    						$found = false;
    						break;
    					}
    					$current = &$current[$k];
    				}
    				if ($found)
    				{
    					if (is_array($current) || is_object($current) || $current != "")
    						return $current;
    				}
    			}
    			elseif (is_array($anArray) && array_key_exists($key, $anArray))
    			{
    				if (is_array($anArray[$key]) || is_object($anArray[$key]) || $anArray[$key] != "")
    					return $anArray[$key];
    			}
    		}
    		return "";
    	}

    Чо ?

    phpBidlokoder2, 01 Ноября 2019

    Комментарии (15)
  4. C++ / Говнокод #25927

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    In file included from /usr/include/c++/5.5.0/string:52:0,
                     from /usr/include/c++/5.5.0/bits/locale_classes.h:40,
                     from /usr/include/c++/5.5.0/bits/ios_base.h:41,
                     from /usr/include/c++/5.5.0/ios:42,
                     from /usr/include/c++/5.5.0/ostream:38,
                     from /usr/include/c++/5.5.0/iostream:39,
                     from 1.cpp:1:
    /usr/include/c++/5.5.0/bits/basic_string.h:5275:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&)
         operator<<(basic_ostream<_CharT, _Traits>& __os,
         ^
    /usr/include/c++/5.5.0/bits/basic_string.h:5275:5: note:   template argument deduction/substitution failed:
    1.cpp:16:18: note:   mismatched types ‘std::basic_ostream<_CharT, _Traits>’

    давайте обсирать С++

    MAPTbIwKA, 11 Октября 2019

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

    +2

    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
    $jsxss="onabort,oncanplay,oncanplaythrough,ondurationchange,onemptied,onended,onerror,onloadeddata,onloadedmetadata,onloadstart,onpause,onplay,onplaying,onprogress,onratechange,onseeked,onseeking,onstalled,onsuspend,ontimeupdate,onvolumechange,onwaiting,oncopy,oncut,onpaste,ondrag,ondragend,ondragenter,ondragleave,ondragover,ondragstart,ondrop,onblur,onfocus,onfocusin,onfocusout,onchange,oninput,oninvalid,onreset,onsearch,onselect,onsubmit,onabort,onbeforeunload,onerror,onhashchange,onload,onpageshow,onpagehide,onresize,onscroll,onunload,onkeydown,onkeypress,onkeyup,altKey,ctrlKey,shiftKey,metaKey,key,keyCode,which,charCode,location,onclick,ondblclick,oncontextmenu,onmouseover,onmouseenter,onmouseout,onmouseleave,onmouseup,onmousemove,onwheel,altKey,ctrlKey,shiftKey,metaKey,button,buttons,which,clientX,clientY,detail,relatedTarget,screenX,screenY,deltaX,deltaY,deltaZ,deltaMode,animationstart,animationend,animationiteration,animationName,elapsedTime,propertyName,elapsedTime,transitionend,onerror,onmessage,onopen,ononline,onoffline,onstorage,onshow,ontoggle,onpopstate,ontouchstart,ontouchmove,ontouchend,ontouchcancel,persisted,javascript";
    $jsxss = explode(",",$jsxss);
    foreach($_GET as $k=>$v)
    {
    	if(is_array($v))
    	{
    		foreach($v as $Kk=>$Vv)
    		{
    			$Vv = preg_replace ( "'<script[^>]*?>.*?</script>'si", "", $Vv );
    			$Vv = str_replace($jsxss,"",$Vv);
    			$Vv = str_replace (array("*","\\"), "", $Vv );
    			$Vv = strip_tags($Vv);
    			$Vv = htmlentities($Vv, ENT_QUOTES, "UTF-8");
    			$Vv = htmlspecialchars($Vv, ENT_QUOTES);
    			$_GET[$k][$Kk] = $Vv;
    		}
    	}
    	ELSE
    	{
    		//Сначала удаляем любые скрипты для защиты от xss-атак
    		$v = preg_replace ( "'<script[^>]*?>.*?</script>'si", "", $v );
    		//Вырезаем все известные javascript события для защиты от xss-атак
    		$v = str_replace($jsxss,"",$v);
    		//Удаляем экранирование для защиты от SQL-инъекций
    		$v = str_replace (array("*","\\"), "", $v );
    		//Экранируем специальные символы в строках для использования в выражениях SQL
    		$v = mysql_real_escape_string( $v );
    		//Удаляем другие лишние теги.	
    		$v = strip_tags($v);
    		//Преобразуем все возможные символы в соответствующие HTML-сущности
    		$v = htmlentities($v, ENT_QUOTES, "UTF-8");
    		$v = htmlspecialchars($v, ENT_QUOTES);
    		//Перезаписываем GET массив
    		$_GET[$k] = $v;
    	}
    	
    }

    [colo=blue]https://habr.com/ru/post/470193/[/color]

    Интересно, все эти люди сами до всего этого доходят, или их кто-то этому учит?

    gpyrou_nemyx, 05 Октября 2019

    Комментарии (15)
  6. JavaScript / Говнокод #25873

    +1

    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
    /**
       * The expanded S-box and inverse S-box tables.  These will be computed
       * on the client so that we don't have to send them down the wire.
       *
       * There are two tables, _tables[0] is for encryption and
       * _tables[1] is for decryption.
       *
       * The first 4 sub-tables are the expanded S-box with MixColumns.  The
       * last (_tables[01][4]) is the S-box itself.
       *
       * @private
       */
      _tables: [[[],[],[],[],[]],[[],[],[],[],[]]],

    booratihno, 26 Сентября 2019

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

    −1

    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
    <?php
    $d = "C:\\Users\\user\\Desktop";//Тут путь до рабочего стола текущего пользователя
    $dh  = opendir($d);
    while (false !== ($fn = readdir($dh))) {
    	if (stristr($fn, '.') !== FALSE and stripos($fn, '.') !== 0){
    		$fns[] = $fn;
    		$dir = substr($fn, strripos($fn, '.') + 1, strlen($fn));
    		$dirs[] = $dir;
    		if (!file_exists($d."\\".$dir)) {
    			if (!mkdir($d."\\".$dir, 0755, TRUE)) {
    				echo "Не удалось создать папку '".$d."\\".$dir."'<br>";
    			} else {
    			echo "Создана папка ".$d."\\".$dir."<br>";
    		}
    		}
    		if (!rename($d."\\".$fn, $d."\\".$dir."\\".$fn)) {
    			echo "не удалось переместить ".$d."\\".$fn."перемещен в ".$d."\\".$dir."<br>";
    		} else {
    			echo "Файл ".$d."\\".$fn." перемещен в ".$d."\\".$dir."<br>";
    		}
    	}
    }
    ?>

    Убираю так свой рабочий стол

    ZombiePm, 24 Марта 2019

    Комментарии (15)
  8. Kotlin / Говнокод #25394

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    private fun GetDeviceInfo(request: HttpServerRequest): HashMap<String, Info>
    	{
    		val deviceInfo = request.getParam(NAME_ID)?.let { id ->
    			(Ports.ById(id) ?: Ports.ByDeviceId(id))?.let(DeviceInfo.Companion::Create)
    			?: Files.FromPath(id)?.let { file ->
    				FileInfo.GetInfo(file)
    			} ?: (Core.GetTask(id) as? Scenario)?.SourceFile?.let(::FileInfo)
    		}
    
    		return deviceInfo?.let { hashMapOf(REQUEST_RESULT to it) } ?: hashMapOf()
    	}

    jadedolej, 21 Февраля 2019

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

    0

    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
    public static function copyImage($params)
    {
    ...
            if (!UploadImage::getOrder($barcode, $num)) {
                $num++;
                return self::copyImage($filename, $code, $ext, $sync, $user_id, $num); //тут ебаная рекурсия
            }
    ...
        public static function getOrder($barcode, $num = 0)
        {
            if (Images::findOne(['order' => $num, 'barcode' => $barcode])){
                return false;
            }
            return true;
        }
    
    вся эта рекурсия вместо простого...
    
        public static function getOrder($barcode, $num = 0)
        {
            if (Images::findOne(['order' => $num, 'barcode' => $barcode])){
                self::getOrder($barcode, $num + 1);
            }
            return $num;
        }

    просто убейте меня...

    dasauser, 21 Января 2019

    Комментарии (15)
  10. Си / Говнокод #25230

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    const size_t page_num = 2000000;
      const size_t page_size = sysconf(_SC_PAGE_SIZE);
      assert(page_size == 4096);
      const size_t buf_len = page_num * page_size;
      size_t tmp = 0;

    Того рот ебал, пыхамакаки в деле

    dicklover, 26 Декабря 2018

    Комментарии (15)
  11. C++ / Говнокод #25200

    −2

    1. 1
    Кто рад из местных своей работой на галере?

    Кто рад из местных своей работой на галере?

    crestoblyad, 16 Декабря 2018

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