- 1
- 2
- 3
- 4
- 5
...
$me = 'return define("me", "?" . ($me = substr(basename(__FILE__), 1, -23)));';
...
<?php eval($me) or die ?>
...
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
Этот поиск практически ничего не может найти! Но вы всё-таки попытайтесь, вдруг повезет.
Найдено: 98
+148
...
$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/
+121
//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
+156
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;
}
+161
//надо показать элемент каталога во всей красе
$_CENTER="show_category_item(".$newParts[0].");";
eval($_CENTER);
// ...
$_LEFT='get_main_category($cat_id, $new_path);';
$_CENTER="show_category_item_list($".'newParts'.");";
Вот с таким адом мне приходится работать.
+149
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 ...
+156
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`им вовсю
+149
$ev = '$atHtml[] = template::translateTemplate('.$atArr[0].'::getHTML($atArr[1]));';
eval($ev);
Самый простой способ заставить работать статический метод класса из переменной в PHP ниже 5.3.
+156
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";
}
}
?>
"Получение оффлайновых версий картинок" для фотогалереи
+141
<?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']);
Меня потянуло сделать какую-то фигню. Встречайте, рефлексивное программирование.
+42
<?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