1. Список говнокодов пользователя brainstorm

    Всего: 35

  2. PHP / Говнокод #22680

    −125

    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
    public function write_log($level, $msg)
    	{
    		if ($this->_enabled === FALSE)
    		{
    			return FALSE;
    		}
    		$level = strtoupper($level);
    		if (( ! isset($this->_levels[$level]) OR ($this->_levels[$level] > $this->_threshold))
    			&& ! isset($this->_threshold_array[$this->_levels[$level]]))
    		{
    			return FALSE;
    		}
    		$filepath = $this->_log_path.'log-'.date('Y-m-d').'.'.$this->_file_ext;
    		$message = '';
    		if ( ! file_exists($filepath))
    		{
    			$newfile = TRUE;
    			// Only add protection to php files
    			if ($this->_file_ext === 'php')
    			{
    				$message .= "<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?>\n\n";
    			}
    		}
    		if ( ! $fp = @fopen($filepath, 'ab'))
    		{
    			return FALSE;
    		}
    		flock($fp, LOCK_EX);
    		// Instantiating DateTime with microseconds appended to initial date is needed for proper support of this format
    		if (strpos($this->_date_fmt, 'u') !== FALSE)
    		{
    			$microtime_full = microtime(TRUE);
    			$microtime_short = sprintf("%06d", ($microtime_full - floor($microtime_full)) * 1000000);
    			$date = new DateTime(date('Y-m-d H:i:s.'.$microtime_short, $microtime_full));
    			$date = $date->format($this->_date_fmt);
    		}
    		else
    		{
    			$date = date($this->_date_fmt);
    		}
    		$message .= $this->_format_line($level, $date, $msg);
    		for ($written = 0, $length = self::strlen($message); $written < $length; $written += $result)
    		{
    			if (($result = fwrite($fp, self::substr($message, $written))) === FALSE)
    			{
    				break;
    			}
    		}
    		flock($fp, LOCK_UN);
    		fclose($fp);
    		if (isset($newfile) && $newfile === TRUE)
    		{
    			chmod($filepath, $this->_file_permissions);
    		}
    		return is_int($result);
    	}

    https://github.com/bcit-ci/CodeIgniter/blob/develop/system/core/Log.php

    люблю с утра обмазаться несвежим пхп

    brainstorm, 27 Марта 2017

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

    −121

    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
    char *unserialize_php(UDF_INIT *initid, UDF_ARGS *args, char *result, unsigned long *length, char *is_null, char *error)
    {
    	const char* argv[] = {""};
    	std::string *value = (std::string*)initid->ptr;
    
    	PHP_EMBED_START_BLOCK(0, (char**)argv);
    	pfc_set_string(
    			UNSERIALIZE_PHP_TARGET_STRING,
    			args->args[0],
    			sizeof(UNSERIALIZE_PHP_TARGET_STRING),
    			args->lengths[0]);
    // ЧИТО?!!!!
    	if(!pfc_evalf(__func__, "$%s=unserialize($%s); if(!$%s) $%s=null; else { "
    				"if(isset(%s) && !is_resource(%s) && !is_object(%s) && !is_null(%s) && !is_array(%s)) {"
    				"$%s=%s; } else { $%s=null; }}",
    				UNSERIALIZE_PHP_TARGET_OBJECT,
    				UNSERIALIZE_PHP_TARGET_STRING,
    
    				// if
    				UNSERIALIZE_PHP_TARGET_OBJECT,
    				UNSERIALIZE_PHP_TARGET_OUTPUT_VARIABLE,
    
    				// else
    				args->args[1], // if(isset)
    				args->args[1], // if(is_resource)
    				args->args[1], // if(is_object)
    				args->args[1], // if(is_null)
    				args->args[1], // if(is_array)
    
    				UNSERIALIZE_PHP_TARGET_OUTPUT_VARIABLE,
    				args->args[1],
    
    				UNSERIALIZE_PHP_TARGET_OUTPUT_VARIABLE
    				))
    	{
    		strcpy(error,"eval return error.");
    		php_embed_shutdown(TSRMLS_C);
    		DEBUG_MSG("eval fail\n");
    		return 0;
    	}
    
    	if (!pfc_get_string(UNSERIALIZE_PHP_TARGET_OUTPUT_VARIABLE,
    				value,
    				sizeof(UNSERIALIZE_PHP_TARGET_OUTPUT_VARIABLE))) {
    		strcpy(error,"can't get output.");
    		php_embed_shutdown(TSRMLS_C);
    		DEBUG_MSG("get fail\n");
    		return 0;
    	}
    
    	*length = strlen(value->c_str());
    	if(*length==0)
    	{
    		*is_null = 1;
    		php_embed_shutdown(TSRMLS_C);
    		return 0;
    	}
    
    	PHP_EMBED_END_BLOCK();
    
    	return (char*)value->c_str();
    }

    отсюда
    https://github.com/junamai2000/mysql_unserialize_php

    brainstorm, 09 Июня 2014

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

    +31

    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
    if(!$_SESSION["subscribe_user"]){
    
    		   $arr_subscribes = unserialize('a:94:{i:212;s:3:"212";i:228;s:3:"228";i:302;s:3:"302";i:304;s:3:"304";i:322;s:3:"322";i:354;s:3:"354";i:366;s:3:"366";i:382;s:3:"382";i:402;s:3:"402";i:406;s:3:"406";i:458;s:3:"458";i:484;s:3:"484";i:492;s:3:"492";i:548;s:3:"548";i:564;s:3:"564";i:572;s:3:"572";i:622;s:3:"622";i:646;s:3:"646";i:700;s:3:"700";i:706;s:3:"706";i:714;s:3:"714";i:716;s:3:"716";i:718;s:3:"718";i:730;s:3:"730";i:740;s:3:"740";i:746;s:3:"746";i:766;s:3:"766";i:770;s:3:"770";i:816;s:3:"816";i:826;s:3:"826";i:832;s:3:"832";i:834;s:3:"834";i:852;s:3:"852";i:884;s:3:"884";i:894;s:3:"894";i:914;s:3:"914";i:920;s:3:"920";i:982;s:3:"982";i:988;s:3:"988";i:1010;s:4:"1010";i:1194;s:4:"1194";i:1456;s:4:"1456";i:1528;s:4:"1528";i:1598;s:4:"1598";i:1644;s:4:"1644";i:1828;s:4:"1828";i:1938;s:4:"1938";i:1942;s:4:"1942";i:1990;s:4:"1990";i:2130;s:4:"2130";i:2154;s:4:"2154";i:2250;s:4:"2250";i:2272;s:4:"2272";i:2338;s:4:"2338";i:2714;s:4:"2714";i:2798;s:4:"2798";i:2892;s:4:"2892";i:3018;s:4:"3018";i:3178;s:4:"3178";i:3181;s:4:"3181";i:3182;s:4:"3182";i:43;s:2:"43";i:23;s:2:"23";i:25;s:2:"25";i:26;s:2:"26";i:27;s:2:"27";i:28;s:2:"28";i:2;s:1:"2";i:67;s:2:"67";i:74;s:2:"74";i:70;s:2:"70";i:72;s:2:"72";i:13;s:2:"13";i:14;s:2:"14";i:15;s:2:"15";i:16;s:2:"16";i:17;s:2:"17";i:18;s:2:"18";i:19;s:2:"19";i:20;s:2:"20";i:21;s:2:"21";i:22;s:2:"22";i:52;s:2:"52";i:66;s:2:"66";i:68;s:2:"68";i:36;s:2:"36";i:37;s:2:"37";i:38;s:2:"38";i:39;s:2:"39";i:40;s:2:"40";i:41;s:2:"41";i:42;s:2:"42";i:76;s:2:"76";i:78;s:2:"78";}');
    
    			$subscr=new subscribe_new();
    			$subscr->GetUserSubscr();
    
    			if(!count($subscr->user_subscribes)){
    				$subscr->user2subscr_table = 'utos';
    				$sql="select subscribe.* from subscribe LEFT JOIN enterprises ON enterprises.id=subscribe.enterprise where subscribe.visible='Y' AND (subscribe.enterprise = 0 OR enterprises.visible = 'Y') order by priority desc, week_day,id";
    				$res=@mysql_db_query($DB,$sql);
    				$all_subscribe=array();
    				while ($row=@mysql_fetch_assoc($res)):
    					$subscr->all_subscribes[$row["id"]]=$row;
    
    				endwhile;
    				
    				$q = $subscr->UpdateSubscr($arr_subscribes);
    				#print_r($arr_subscribes);
    				
    				#exit;
    			}
    
    	   }

    ну хрясь чтоле

    brainstorm, 07 Апреля 2014

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

    +27

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    function makehash($str,$salt='',$strength='08'){
    	if (!$salt):
    		  $salt = "";
    		  for ($i = 0; $i < 22; $i++) {
    		    $salt .= substr("./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", mt_rand(0, 63), 1);
    		  }
    	endif;
        return crypt($str, "$2a$".$strength."$".$salt);
    }

    no comments

    brainstorm, 09 Октября 2013

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

    +26

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    $arr['body'][$row_num] = array(
                $datas,
                $tval,
                $club1_link,
                ($results['results_url'] != '' ? '<a href="' . $results['results_url'] . '"' . ($results['results_class'] != '' ? $results['results_class'] : '') . '>' : '<span>') . $results['results'] . ($results['results_url'] != '' ? '</a>' : '</span>'),
                $club2_link,
                spb_stats_show_media_icons($row),
            );

    было еще хуже. каждая строка была адовый тернарник...

    brainstorm, 16 Сентября 2013

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

    −65

    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
    public function validateLabelInput(&$label) {
        if ( 
          ! ( 
            (
              $this->labeling_main->is('1.1') && $this->labeling_main->is('7.1') && $this->labeling_main->is('2') && $this->labeling_main->is('3') 
                && $this->labeling_main->is('4') && $this->labeling_main->is('5') && $this->labeling_main->is('23') 
            )
            || (
              $this->labeling_main->is('1.1') 
                && ($this->labeling_main->is('7.2') || $this->labeling_main->is('7.3') || $this->labeling_main->is('7.4') ) 
                && $this->labeling_main->is('2') && $this->labeling_main->is('3') && $this->labeling_main->is('4') && $this->labeling_main->is('5')
                && $this->labeling_main->is('25') 
            )
            || (
              $this->labeling_main->is('1.1') && $this->labeling_main->is('7.5') && $this->labeling_main->is('2') && $this->labeling_main->is('3') 
                && $this->labeling_main->is('4') && $this->labeling_main->is('5')
            )
            || (
              $this->labeling_main->is('1.1') && $this->labeling_main->is('7.6') && $this->labeling_main->is('2') && $this->labeling_main->is('3')
            )
            || (
              $this->labeling_main->is('1.2') && $this->labeling_main->is('2') && $this->labeling_main->is('3') && $this->labeling_main->is('7') 
                && $this->labeling_main->is('4') && $this->labeling_main->is('5')
            )
            || (
              $this->labeling_main->is('1.3') && $this->labeling_main->is('2') && $this->labeling_main->is('3') && $this->labeling_main->is('7') 
                && $this->labeling_main->is('4') && $this->labeling_main->is('5')
            )
            || (
              $this->labeling_main->is('1.4') && ($this->labeling_main->is('8.1') || $this->labeling_main->is('8.2')) && $this->labeling_main->is('2')
                && $this->labeling_main->is('3') && $this->labeling_main->is('17') && $this->labeling_main->is('18')
            )
            || (
              $this->labeling_main->is('1.4') && $this->labeling_main->is('19') && $this->labeling_main->is('2') && $this->labeling_main->is('3') 
            )
            || (
              $this->labeling_main->is('1.4') && $this->labeling_main->is('20') && $this->labeling_main->is('2') && $this->labeling_main->is('3') 
            )
            || (
              $this->labeling_main->is('1.5') && $this->labeling_main->is('26.2') && $this->labeling_main->is('2') && $this->labeling_main->is('3') 
                && $this->labeling_main->is('17') && $this->labeling_main->is('18')
            )
            || (
              $this->labeling_main->is('1.5') && $this->labeling_main->is('26.1') && $this->labeling_main->is('2') && $this->labeling_main->is('3')
            )
            || (
              $this->labeling_main->is('1.6') && $this->labeling_main->is('22') && $this->labeling_main->is('2') && $this->labeling_main->is('3') 
                && $this->labeling_main->is('4') && $this->labeling_main->is('5')
            )
            || (
              $this->labeling_main->is('1.7') && $this->labeling_main->is('11')
            )
            || (
              $this->labeling_main->is('1.8') && $this->labeling_main->is('2') && $this->labeling_main->is('3')
            )
            || ($this->labeling_main->is('1.9'))
            || (
              $this->labeling_main->is('1.10') && $this->labeling_main->is('2') && $this->labeling_main->is('3') && $this->labeling_main->is('4') 
                && $this->labeling_main->is('5')
            )
            || (
              $this->labeling_main->is('1.11') && $this->labeling_main->is('2') && $this->labeling_main->is('3') && $this->labeling_main->is('17') 
                && $this->labeling_main->is('18')
            )
            || ($this->labeling_main->is('13'))
          )  
        ){
          $label['data']['status'] = 3;
        }
      }

    brainstorm, 24 Декабря 2012

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

    −52

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    require_once '/usr/share/php/smarty/Smarty.class.php';
    class SmartyMegaAPI extends Smarty{
        public function __construct()
        {
            $this->Smarty();
            $this->template_dir = './smarty/templates';
            $this->config_dir = './smarty/config';
            $this->compile_dir = './smarty/templates_c';
            $this->cache_dir = './smarty/cache';
        }
    }

    ООП такое ООП

    brainstorm, 18 Июля 2012

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

    −63

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    <?php
    
    global $KONKURS_ADMIN;
    $KONKURS_ADMIN=array('[email protected]',
                         '[email protected]',
                         '[email protected]');

    распределение привелегий в системе епта.

    brainstorm, 12 Июля 2012

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

    −80

    1. 1
    2. 2
    3. 3
    mysql_query(sprintf("insert into `spb_plusone_%ss`
                             values('%d','1') on duplicate key update `counter`=`counter`+1;", $_POST['type'], $_POST['id']), $conn);
        $result = mysql_fetch_assoc(mysql_query(sprintf("select `counter` from `spb_plusone_%ss` where `%s`='%d'", $_POST['type'], ($_POST['type'] == 'node' ? 'nid' : 'fid'), $_POST['id']), $conn));

    превед

    brainstorm, 09 Июля 2012

    Комментарии (13)
  11. PHP / Говнокод #10227

    −52

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    $path  = file_directory_path();
      $dir = opendir($path);
      /*seacrh file shops.dtd.zip*/
      while ($file_name = readdir($dir)) {
        /*if found export file of current user*/
        if ($file_name == 'market_new.xml') {
          /*create array - date of last change current file => create date of current file*/
          $last_export_date = date('d-m-Y H:i', filectime($path . '/' .$file_name));
        }
      }
      /*close catalog*/
      closedir ($dir);

    превед братья украинци.

    brainstorm, 09 Мая 2012

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