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

    +159

    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
    unset($stats_array);
    		if(!empty($finish_array))
    		{
    			$finish_array1=array();
    			foreach($finish_array as $key=>$value)
    			{
    				//print_r($value);
    				foreach($value as $key1=>$value1)
    				{
    					$finish_array1[]=array("product"=>$key,"mirror"=>$key1,"views"=>$value1);
    				}
    				$i++;
    				
    			}
    			unset($finish_array);
    		function cmp_c($a, $b)
    		{
    			if((int)$b["views"]<$a["views"]) return -1;
    			else return 1;
    			//return strcmp($b["views"],$a["views"]);
    		}
    
    		usort($finish_array1, "cmp_c");
    		$RESULT_TABLE="
    		<table border='1'>
    			<tr>
        			<td>Референс</td>
        			<td>КЭШ</td>
        			<td>Просмотров</td>
      			</tr>";

    тот же новый программист.
    сочно, сладко

    warider, 31 Марта 2011

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

    +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
    switch ($_REQUEST['period'])
    {
    	case 7: $period_checked_1='checked="checked"';break;
    	case 14: $period_checked_2='checked="checked"';break;
    	case 30: $period_checked_3='checked="checked"';break;
    	case 90: $period_checked_4='checked="checked"';break;
    	case 180: $period_checked_5='checked="checked"';break;
    	case 360: $period_checked_6='checked="checked"';break;
    	case 720: $period_checked_7='checked="checked"';break;
    	case 'all_period': $period_checked_8='checked="checked"';break;
    }
    
    
    // следующий код повторяется через каждые 20 строк 5 раз
    		/**НАСТРОЙКИ**/
    $num=25; //количество записей на странице
    $page = $_GET['page'];
    $posts=stats::count_prod($brand);
    $total = intval(($posts - 1) / $num) + 1;
    $page = intval($page); 
    if(empty($page) or $page < 0) $page = 1;  
    if($page > $total) $page = $total;
    $start = $page * $num - $num; 
    $end=$page * $num;
    /*************/

    выдержки из "спагетти-кода" нашего нового программиста, которого вчера уволили.
    теперь приходится копаться в этом говне

    warider, 31 Марта 2011

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

    +159

    1. 1
    echo file_get_contents("split('?')[1]");

    Смесь PHP & JavaScript. Честно, я не понимаю, какого результата хотел добиться автор.

    stuffort, 31 Марта 2011

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

    +161

    1. 1
    2. 2
    $this->Object = Application::getObject();
    $this->OBJECT = $this->Object->object;

    А Баден-Баден где-то в Европе...

    skubent, 31 Марта 2011

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

    +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
    37. 37
    38. 38
    39. 39
    $замены = array(
    	'{' => 'начало',
    	'}' => 'конец',
    	'for' => 'циклдля',
    	'echo' => 'вывод',
    	'print' => 'печать',
    	'while' => 'пока',
    	'foreach' => 'циклмассив',
    	'$' => 'пер ',
    	'=' => ':=',
    	//'==' => '=',
    	'!=' => '<>',
    	'function' => 'функ',
    	'true' => 'правда',
    	'false' => 'ложь',
    	'if' => 'если',
    	'else' => 'иначе',
    	'as' => 'как',
    	'array' => 'массив',
    	'_GET' => 'ГЕТ',
    	'_POST' => 'ПОСТ',
    	'return' => 'вернуть',
    );
    
    isset($_GET['debug']) ? print(ВПоХаПэ(file_get_contents($_GET['f']))) : Компилить(file_get_contents($_GET['f']));
    
    function Компилить($сорсец) {
    	eval(ВПоХаПэ($сорсец));
    }
    
    function ВПоХаПэ($сорсец) {
    	global $замены;
    	return str_replace(array_values($замены), array_keys($замены), $сорсец);
    }
    
    function ИзПоХаПэ($сорсец) {
    	global $замены;
    	return str_replace(array_keys($замены), array_values($замены), $сорсец);
    }

    Транслятор псевдоязыка в PHP

    Мартин, 30 Марта 2011

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

    +159

    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
    if (is_dir($read_dir)) {
    	if ($open_dir = @opendir($read_dir)) {
    		while (false !== ($dir_temp = readdir($open_dir))){
    			if ($dir_temp != "." && $dir_temp != ".." && is_dir($read_dir.'/'.$dir_temp) && $filtre == '') {
    				if(!(file_exists("../templates/".$dir_temp."/parameter/info.php"))) {
    					echo messStop(LG_DIR.' ' . $dir_temp . ' '.LG_MOD_ERROR_IS_FILE_);
    				} else {
    					require("../templates/".$dir_temp."/parameter/info.php");
    					echo "<tr><td>";
    					if(!(file_exists("../templates/".$dir_temp."/parameter/previews.jpg"))) {
    						echo "<a href=\"?am=mod[template]&template=[edit]&name=$dir_temp\" OnMouseOver=\"Tip('<img width=&quot;175&quot; src=&quot;../images/all/no_prewies.png&quot; >')\" />$temp_name</a>";
    					} else {
    						echo "<a href=\"?am=mod[template]&template=[edit]&name=$dir_temp\" OnMouseOver=\"Tip('<img width=&quot;175&quot; src=&quot;../templates/$dir_temp/parameter/previews.jpg&quot; >')\" />$temp_name</a>";
    					}
    					echo "</td><td>$temp_version</td><td>$temp_date</td><td>$temp_autor</td></tr>";
    				}
    			} elseif ($dir_temp != "." && $dir_temp != ".." && is_dir($read_dir.'/'.$dir_temp) && $dir_temp == $filtre) {
    				if(!(file_exists("../templates/".$dir_temp."/parameter/info.php"))) {
    					echo messStop(LG_DIR.' ' . $dir_temp . ' '.LG_MOD_ERROR_IS_FILE_);
    				} else {
    					require("../templates/".$dir_temp."/parameter/info.php");
    					echo "<tr><td>";
    					if(!(file_exists("../templates/".$dir_temp."/parameter/previews.jpg"))) {
    						echo "<a href=\"?am=mod[template]&template=[edit]&name=$dir_temp\" OnMouseOver=\"Tip('<img width=&quot;175&quot; src=&quot;../images/all/no_prewies.png&quot; >')\" />$temp_name</a>";
    					} else {
    						echo "<a href=\"?am=mod[template]&template=[edit]&name=$dir_temp\" OnMouseOver=\"Tip('<img width=&quot;175&quot; src=&quot;../templates/$dir_temp/parameter/previews.jpg&quot; >')\" />$temp_name</a>";
    					}
    					echo "</td><td>$temp_version</td><td>$temp_date</td><td>$temp_autor</td></tr>";
    				}
    			} elseif(!is_dir($read_dir.'/'.$filtre) && $filtre != '' && $filtre != $dir_temp) {
    				$returnMessWarn = messSearch(LG_ERR_FILTRE_NULL);
    			}
    		}
    	closedir($open_dir);
    	}
    }

    Данный код выводит списком шаблоны от системы.... Самое страшное, когда спустя некоторое время, со свежими мозгами потребовалось усовершенствовать всё это, в итоге проблема решилась просто, всё переписатьс нуля по человечески.

    nethak, 30 Марта 2011

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

    +155

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if($upload) { $ftpsucc=1; } else { $ftpsucc=0; } 
    // check upload status: 
    print (!$upload) ? 'Cannot upload' : 'Upload complete'; 
    print "\n"; 
    // close the FTP stream 
    ftp_close($conn_id); 
    ?>

    Из комментариев php.net. Переменная $ftpsucc далее не используется.

    Sinless, 30 Марта 2011

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

    +167

    1. 1
    Перейти на страницу <span onmouseover="this.className='menu_over'" onmouseout="this.className='menu'" class="menu" onClick="window.location='<?echo $arItem["DETAIL_PAGE_URL"]?>'">--></span>

    тег "a" видимо был незнаком.

    Fisher, 30 Марта 2011

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

    +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
    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
    function get_section(){
    		if(ifGet('section')){
    			if($this->get_file('./applications/app.'.$this->section.'.php')){
    				switch (Get('section')){
    					case ''.$this->section.'':
    						$m = new $this->section();
    					break;
    				}
    			} else {
    				
    				switch (Get('section'))
    				{
    					default:
    						include_once('./applications/sys.pages.php');
    						$m = new pages();
    					break;
    				}
    			}
    		}else{
    			switch (Get('section'))
    			{
    				default:
    					include_once('./applications/sys.home.php');
    					$m = new home();
    				break;
    			}
    		}
    		
    		if(isset($m) && is_object($m)) {
    			$this->output = $m->output;
    			$this->title = $m->title;
    			$this->crumbs = $m->crumbs;
    		}
    	}

    я сам в шоке как такое мог написать...

    Impossible, 30 Марта 2011

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

    +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
    66. 66
    67. 67
    insert_image.php:
    <?php
    
    require_once('../config.inc.php');
    if ((!isset($_SESSION['user_type'])) || ($_SESSION['user_type'] != 0)) {
        header('Location: /');
        die;
    }
    require('admin_image.inc.php');
    
    
    settitle.php:
    <?php
    
    require_once('../config.inc.php');
    if ((!isset($_SESSION['user_type'])) || ($_SESSION['user_type'] != 0)) {
        header('Location: /');
        die;
    }
    $id = intval($_POST['image']);
    $title = $_POST['imgtitle'];
    mysql_query("UPDATE images SET title='$title' WHERE id=$id");
    require('admin_image.inc.php');
    
    upload_image.php:
    <?php
    
    require_once('../config.inc.php');
    if ((!isset($_SESSION['user_type'])) || ($_SESSION['user_type'] != 0)) {
        header('Location: /');
        die;
    }
    
    if ((isset($_POST['upload'])) && (isset($_FILES['newimage']))) {
        $title = (isset($_POST['title'])) ? $_POST['title'] : '';
        $file = $_FILES['newimage'];
        if ($file['error'] != 0) {
            $msg = 'An error occured during uploading file. (Error code:' . $file['error'] . ')';
        } else {
            $type = $file['type'];
            $tmp_name = $file['tmp_name'];
            //check if we are uploading image or not
            if (!(((preg_match('/\.gif/i', $file['name'])) || (preg_match('/\.jpg/i', $file['name'])) ||
                    (preg_match('/\.jpeg/i', $file['name'])) || (preg_match('/\.bmp/i', $file['name'])) ||
                    (preg_match('/\.png/i', $file['name'])))
                    && ((preg_match('/gif/i', $file['type'])) || (preg_match('/jpg/i', $file['type'])) ||
                    (preg_match('/jpeg/i', $file['type'])) || (preg_match('/bmp/i', $file['type'])) ||
                    (preg_match('/png/i', $file['type']))))) {
                $msg = 'You are trying to upload a non-image file.';
            } elseif (filesize($tmp_name) <= 0) {
                $msg = 'You are trying to upload file which size is 0 bytes.';
            } else {
                $img_data = fread(fopen($tmp_name, 'r'), filesize($tmp_name));
                if (mysql_query("INSERT INTO images (id, image, type, title)"
                                . " VALUES ('',"
                                . " '" . mysql_escape_string($img_data) . "',"
                                . " '" . mysql_escape_string($type) . "',"
                                . " '" . mysql_escape_string($title) . "')"))
                    $msg = 'Image uploaded.';
                else
                    $msg = 'An error occured during inserting image in DB.';
            }
        }
    }
    if (isset($msg))
        $MyPage->assign('msg', $msg);
    require('admin_image.inc.php');

    Какая экспрессия, какое необычное именование файлов... lower_case_with_underscores + просто текст
    А главное какое необычное представление о модульности: 2 файла по 10 строк, и один на 40, в каждом из которых прописана авторизация и которые инклюдят главный файл

    govno, 29 Марта 2011

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