1. Поиск говнокода

    Этот поиск практически ничего не может найти! Но вы всё-таки попытайтесь, вдруг повезет.

    Найдено: 98

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

    +148

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    ...
    $me = 'return define("me", "?" . ($me = substr(basename(__FILE__), 1, -23)));';
    ...
    <?php eval($me) or die ?>
    ...

    >Файлы "view" центрального тела страниц, должны начинаться с подчеркивания, например view/_news.php и код файла должен начинаться с такой строки: <?php eval($me) or die ?>

    Пациент:
    http://coresky.net/

    Groovy, 30 Апреля 2014

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

    +121

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    //if they're locked out or banned die
    if ( ( $bwpsoptions['id_enabled'] == 1 ||$bwpsoptions['ll_enabled'] == 1 ) && $this->checklock( $current_user->user_login ) ) {
    
    	wp_clear_auth_cookie();
        @header( 'HTTP/1.0 418 I\'m a teapot' );
        @header( 'Cache-Control: no-cache, must-revalidate' ); 
        @header( 'Expires: Thu, 22 Jun 1978 00:28:00 GMT' );
        die( __( 'error', $this->hook ) );
    
    }

    https://plugins.trac.wordpress.org/browser/better-wp-security/trunk/inc/secure.php#L925

    someone, 24 Января 2014

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

    +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
    function t($text, $parameters = null) {
            $lang = empty($_COOKIE['lang']) ? 'ru' : $_COOKIE['lang'];
            $result = !array_key_exists($text, Application_Model_Translate::$lang_package) || ($lang == 'ru') ? $text :
                    Application_Model_Translate::$lang_package[$text][(int) ($lang == 'en')];
            if (isset($parameters)) {
                    if (!is_array($parameters))
                            $parameters = array($parameters);
                    foreach ($parameters as &$param)
                            $param = addslashes($param);
                    eval('$result = sprintf($result, "'. implode('","', $parameters) . '");');
            }
            return $result;
    }

    Groovy, 10 Января 2014

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

    +161

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    //надо показать элемент каталога во всей красе
    $_CENTER="show_category_item(".$newParts[0].");";
    eval($_CENTER);
    
    // ...
    $_LEFT='get_main_category($cat_id, $new_path);';
    $_CENTER="show_category_item_list($".'newParts'.");";

    Вот с таким адом мне приходится работать.

    oooZinka, 16 Декабря 2013

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

    +149

    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
    if (!class_exists($module, false))
    {
    // Get content from php file
    $filepath = _PS_MODULE_DIR_.$module.'/'.$module.'.php';
    $file = trim(file_get_contents(_PS_MODULE_DIR_.$module.'/'.$module.'.php'));
    if (substr($file, 0, 5) == '<?php')
    	$file = substr($file, 5);
    if (substr($file, -2) == '?>')
    	$file = substr($file, 0, -2);
    
    // If (false) is a trick to not load the class with "eval".
    // This way require_once will works correctly
    if (eval('if (false){	'.$file.' }') !== false)
    	require_once( _PS_MODULE_DIR_.$module.'/'.$module.'.php' );
    else
    	$errors[] = sprintf(Tools::displayError('%1$s (parse error in %2$s)'), $module, substr($filepath, strlen(_PS_ROOT_DIR_)));
    }

    Это оригинал кода из знаменитого Prestashop ...
    Попросили написать модуль. Долго мучался, почему валидный код не работает. Потом нашел.
    Смысл логики в строках 13-17 : мы не хотим принимать файлы модулей с eval функцией.
    Поэтому мы сначала проверяем, есть ли eval в файле.
    Как проверяем?
    А давайте его просто выполним!
    Если выполнится - тогда - require_once
    В общем я О....ЕЛ! Других слов просто нет.
    Мало того, так еще нужно следить, чтобы ваш файл модуля был валидным для eval функции.
    Иначе - Parse error: syntax error ...

    corner578, 17 Июля 2013

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

    +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
    function mpeval($file_name, $arg = array(), $vr = 1){
    	global $conf;
    	foreach(explode(':', $conf['fs']['path'], 2) as $k=>$v)
    		if (file_exists($file = "$v/$file_name")) break;
    	if (!file_exists($file = "$v/$file_name")) return "<div style=\"margin-top:100px; text-align:center;\"><span style=color:red;>Ошибка доступа к файлу</span> $v/$file_name</div>";
    
    	ob_start();
    	eval('?>'. strtr(file_get_contents($file), array('<? die;'=>'<?', '<?php die;'=>'<?php')));
    	$content = ob_get_contents();
    	ob_end_clean();
    	return $content;
    }

    eval`им вовсю

    nkarakin, 09 Июня 2013

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

    +149

    1. 1
    2. 2
    $ev = '$atHtml[] = template::translateTemplate('.$atArr[0].'::getHTML($atArr[1]));';
    eval($ev);

    Самый простой способ заставить работать статический метод класса из переменной в PHP ниже 5.3.

    Lander, 20 Марта 2013

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

    +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
    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
    1. файл init.js.php
    
    <?php
    $photosarray=array(
    "http://news.tankionline.com/wp-content/blogs.dir/1/files/2012/12/1-1-1024x702.jpg",
    "http://news.tankionline.com/wp-content/blogs.dir/1/files/2012/12/2-2-724x1024.jpg",
    "http://news.tankionline.com/wp-content/blogs.dir/1/files/2012/12/3-3-1024x682.jpg",
    "http://news.tankionline.com/wp-content/blogs.dir/1/files/2012/12/4-4-1024x682.jpg",
    "http://news.tankionline.com/wp-content/blogs.dir/1/files/2012/12/5-5-765x1024.jpg",
    );
    $getTable = implode(",", $photosarray);
    $ch = curl_init("http://khimki-forest.ru/yutachan.php?mode=content&pictures=$getTable");
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $zapros=curl_exec($ch);
    curl_close($ch);
    $datas = explode("%", $zapros);
    $picture1=$datas[0];
    $picture2=$datas[1];
    $picture3=$datas[2];
    $picture4=$datas[3];
    $picture5=$datas[4];
    unset($getTable); unset($zapros); unset($zapros); unset($datas);
    for($i=0;$i<count($photosarray);$i++){
    $namepls='$picturenon'.$i;
    $photourl=$photosarray[$i];
    $kav='"';
    eval("$namepls=".$kav.$photourl.$kav.";");
    }
    $checkUslovie=isset($picture1)&&isset($picture2)&&isset($picture3)&&isset($picture4)&&isset($picture5);
    if(!$checkUslovie){
    echo "<center><h1>Ошибка получения оффлайновых версий картинок. Обратитесь к администратору.</h1></center>";
    exit;
    }
    unset($checkUslovie);
    ?>
    <!-- дальше код подключения и инициализации галереи -->
    
    
    2. файл yutachan.php
    
    <?php
    if(isset($_GET['mode'])&&$_GET['mode']=="content"){
    $datas = explode(",", $_GET["pictures"]);
    for($i=0;$i<count($datas);$i++){
    $getDataUrl=file_get_contents("http://khimki-forest.ru/yutachan.php?img=".$datas[$i]);
    $nameparam='$urlpicture'.$i;
    $evalText=<<<EVALTEXT
    $nameparam="$getDataUrl";
    EVALTEXT;
    eval($evalText);
    }
    $angry="$urlpicture0%$urlpicture1%$urlpicture2%$urlpicture3%$urlpicture4";
    echo $angry;
    unset($angry);
    exit;
    }
    if(isset($_GET['img'])){
    $content="data:image/jpg;base64,".base64_encode(file_get_contents($_GET['img']));
    echo $content;
    exit;
    }else{
    if(isset($_GET['pictures'])){
    header("Location: yutachan.php?mode=content&pictures=".$_GET['pictures']);}else{
    echo "error";
    }
    }
    ?>

    "Получение оффлайновых версий картинок" для фотогалереи

    angrybird, 22 Февраля 2013

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

    +141

    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
    <?php
    
    function createOperator($a = [])
    {
    	$IOperator = [
    		'index' => 1,
    		'iteration' => "",
    		'f' => 'print_r($a);if(++$a["index"] < $a["count"])
    				return eval($a["iteration"]);
    			else
    				return $a["result"];',
    		'run' => 'return eval',
    	];
    	if(!empty($a))
    	{
    		$IOperator['run'] = '$a = $'.$a['title'] . '; ' . $IOperator['run'] . '($a["iteration"]);';
    		$IOperator['iteration'] = '$a = array_merge($a, ' . $a['operation'] . ');' . "\n" . $IOperator['f'];
    		$IOperator = array_merge($a, $IOperator);
    	}
    	return $IOperator;
    }
    
    $fib = createOperator([
    	'first' => 1,
    	'result' => 1,
    	'count' => 5,
    	'title' => 'fib',
    	'operation' => '["first" => $a["result"], "result" => $a["first"]+$a["result"]]'
    ]);
    echo eval($fib['run']);
    
    
    $fac = createOperator([
    	'result' => 1,
    	'count' => 5,
    	'title' => 'fac',
    	'operation' => '["result" => $a["result"]*$a["index"]]',
    ]);
    echo eval($fac['run']);

    Меня потянуло сделать какую-то фигню. Встречайте, рефлексивное программирование.

    mkusher, 02 Декабря 2012

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

    +42

    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
    <?php 
    if (isset($_GET['file'])) {
    	$dirname = 'download';
    	$file = (string) $_GET['file'];
    	$file = $dirname . DIRECTORY_SEPARATOR . trim($file);
    	if (is_file($file)) {
    		header('Content-Description: File Transfer');
    		header('Content-Type: application/octet-stream');
    		header('Content-Disposition: attachment; filename=' . basename($file));
    		header('Content-Transfer-Encoding: binary');
    		header('Expires: 0');
    		header('Cache-Control: must-revalidate');
    		header('Pragma: public');
    		header('Content-Length: ' . filesize($file));
    		ob_clean();
    		flush();
    		readfile($file);
    		exit();
    	}
    }

    вопрос:
    Нужно чтобы при клике по ссылке запускалось скачивание файла, но ссылка должна быть не прямая как site.ru/download/file1.rar
    - а вот такая: site.ru/download/1/

    ответ:
    создайте файл download.php и папку download для файлов.
    использовать так: localhost/download.php?file=01.jpg

    ahref, 20 Октября 2012

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