- 1
- 2
$res= (isset($r[0]) and count($r[0]) > 0) ? true : false;
return $res;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+71
$res= (isset($r[0]) and count($r[0]) > 0) ? true : false;
return $res;
Классика
+131
#------------обрабатываем окончания html-------------
RewriteEngine on
Options +FollowSymlinks
RewriteBase /
RewriteRule ^([A-Za-z0-9-]+)/(.*).html?$ /$1/$2 [NC,L]
RewriteRule ^(.*).html?$ /$1 [NC,L]
<IfModule mod_charset.c>
CharsetRecodeMultipartForms off
</IfModule>
#------------разбор URL для админки------------------
RewriteEngine on
RewriteRule ^([a-zA-Z0-9_-]+).html$ ([a-zA-Z0-9_-]+) [L]
RewriteRule ^([a-zA-Z0-9_-]+)/*([a-zA-Z0-9_-]*)/*([a-zA-Z0-9_-]*)/*([a-zA-Z0-9_-]*)/*([a-zA-Z0-9_-]*)/*([a-zA-Z0-9_-]*)/*([a-zA-Z0-9_-]*)/*([a-zA-Z0-9_-]*)/*([a-zA-Z0-9_-]*)$ /index.php?%{QUERY_STRING}¶m[0]=$1¶m[1]=$2¶m[2]=$3¶m[3]=$4¶m[4]=$5¶m[5]=$6¶m[6]=$7¶m[7]=$8¶m[8]=$9
Apache .htaccess
Смотрите сами :D
−52
$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);
превед братья украинци.
+129
#include<stdio.h>
int main()
{
int i,p,q,sum=0;
for(i=0;i<1000000;i++)
{
p=0;
if(i<10) p=1;
else if(i<100){ if(i/10==i%10) p=1;}
else if(i<1000){ if(i/100==i%10) p=1;}
else if(i<10000){ if(i/1000==i%10 && (i%1000)/100==(i%100)/10) p=1;}
else if(i<100000){ if(i/10000==i%10 && (i%10000)/1000==(i%100)/10) p=1;}
else if(i<1000000){ if(i/100000==i%10 && (i%100000)/10000==(i%100)/10 && (i%10000)/1000==(i%1000)/100) p=1;}
q=0;
if(i<2) q=1;
else if(i<4){if(i/2==i%2) q=1;}
else if(i<8){if(i/4==i%2) q=1;}
else if(i<16){if(i/8==i%2 && (i%8)/4==(i%4)/2) q=1;}
else if(i<32){if(i/16==i%2 && (i%16)/8==(i%4)/2) q=1;}
else if(i<64){if(i/32==i%2 && (i%32)/16==(i%4)/2 && (i%16)/8==(i%8)/4) q=1;}
else if(i<128){if(i/64==i%2 && (i%64)/32==(i%4)/2 && (i%32)/16==(i%8)/4) q=1;}
else if(i<256){if(i/128==i%2 && (i%128)/64==(i%4)/2 && (i%64)/32==(i%8)/4 && (i%32)/16==(i%16)/8) q=1;}
else if(i<512){if(i/256==i%2 && (i%256)/128==(i%4)/2 && (i%128)/64==(i%8)/4 && (i%64)/32==(i%16)/8) q=1;}
else if(i<1024){if(i/512==i%2 && (i%512)/256==(i%4)/2 && (i%256)/128==(i%8)/4 && (i%128)/64==(i%16)/8 && (i%64)/32==(i%32)/16) q=1;}
else if(i<2048){if(i/1024==i%2 && (i%1024)/512==(i%4)/2 && (i%512)/256==(i%8)/4 && (i%256)/128==(i%16)/8 && (i%128)/64==(i%32)/16) q=1;}
else if(i<4096){if(i/2048==i%2 && (i%2048)/1024==(i%4)/2 && (i%1024)/512==(i%8)/4 && (i%512)/256==(i%16)/8 && (i%256)/128==(i%32)/16 && (i%128)/64==(i%64)/32) q=1;}
else if(i<8192){if(i/4096==i%2 && (i%4096)/2048==(i%4)/2 && (i%2048)/1024==(i%8)/4 && (i%1024)/512==(i%16)/8 && (i%512)/256==(i%32)/16 && (i%256)/128==(i%64)/32) q=1;}
else if(i<16384){if(i/8192==i%2 && (i%8192)/4096==(i%4)/2 && (i%4096)/2048==(i%8)/4 && (i%2048)/1024==(i%16)/8 && (i%1024)/512==(i%32)/16 && (i%512)/256==(i%64)/32 && (i%256)/128==(i%128)/64) q=1;}
else if(i<32768){if(i/16384==i%2 && (i%16384)/8192==(i%4)/2 && (i%8192)/4096==(i%8)/4 && (i%4096)/2048==(i%16)/8 && (i%2048)/1024==(i%32)/16 && (i%1024)/512==(i%64)/32 && (i%512)/256==(i%128)/64) q=1;}
else if(i<65536){if(i/32768==i%2 && (i%32768)/16384==(i%4)/2 && (i%16384)/8192==(i%8)/4 && (i%8192)/4096==(i%16)/8 && (i%4096)/2048==(i%32)/16 && (i%2048)/1024==(i%64)/32 && (i%1024)/512==(i%128)/64 && (i%512)/256==(i%256)/128) q=1;}
else if(i<131072){if(i/65536==i%2 && (i%65536)/32768==(i%4)/2 && (i%32768)/16382==(i%8)/4 && (i%16384)/8192==(i%16)/8 && (i%8192)/4096==(i%32)/16 && (i%4096)/2048==(i%64)/32 && (i%2048)/1024==(i%128)/64 && (i%1024)/512==(i%256)/128) q=1;}
else if(i<262144){if(i/131072==i%2 && (i%131072)/65536==(i%4)/2 && (i%65536)/32768==(i%8)/4 && (i%32768)/16384==(i%16)/8 && (i%16384)/8192==(i%32)/16 && (i%8192)/4096==(i%64)/32 && (i%4096)/2048==(i%128)/64 && (i%2048)/1024==(i%256)/128 && (i%1024)/512==(i%512)/256) q=1;}
else if(i<524288){if(i/262144==i%2 && (i%262144)/131072==(i%4)/2 && (i%131072)/65536==(i%8)/4 && (i%65536)/32768==(i%16)/8 && (i%32768)/16384==(i%32)/16 && (i%16384)/8192==(i%64)/32 && (i%8192)/4096==(i%128)/64 && (i%4096)/2048==(i%256)/128 && (i%2048)/1024==(i%512)/256) q=1;}
else if(i<1048576){if(i/524288==i%2 && (i%524288)/262144==(i%4)/2 && (i%262144)/131072==(i%8)/4 && (i%131072)/65536==(i%16)/8 && (i%65536)/32768==(i%32)/16 && (i%32768)/16384==(i%64)/32 && (i%16384)/8192==(i%128)/64 && (i%8192)/4096==(i%256)/128 && (i%4096)/2048==(i%512)/256 && (i%2048)/1024==(i%1024)/512) q=1;}
if(p==1 && q==1) sum+=i;
}
printf("%d\n",sum);
return 0;
}
Одно из решений с форума http://projecteuler.net/problem=36 - проверка числа и бинарного числа на палиндромность.
И комментарий к этому решению: "At last found a small mistake in the code.."
+71
<?php
session_start();
$uploadName = 'test';
if (isset($_GET['ajax'])) {
if (isset($_SESSION["upload_progress_$uploadName"])) {
$progress = $_SESSION["upload_progress_$uploadName"];
$percent = round(100 * $progress['bytes_processed'] / $progress['content_length']);
$text1 = iconv("CP1251", "UTF-8", "Общий прогресс загрузки: ");
$text2 = iconv("CP1251", "UTF-8", "Загружается файл: ");
$text3 = iconv("CP1251", "UTF-8", "Общее время загрузки: ");
$text4 = iconv("CP1251", "UTF-8", "Скорость загрузки: ");
$text5 = iconv("CP1251", "UTF-8", " сек. ");
$text6 = iconv("CP1251", "UTF-8", " Мбайт. ");
echo '<HTML><HEAD><title>Upload</title><meta name="keywords"><meta name="description" ><meta http-equiv="content-type" content="text/html;charset=windows-1251"></HEAD><BODY>';
$pos1 = $percent * 4;
$pos2 = 400 - $pos1;
echo '<div style="background: #00ff00; width: '.$pos1.'; height: 10px; border: solid 1px black; "></div><div style="background: #ffe4e1; width: '.$pos2.'px; height: 10px; position: relative; left: '.$pos1.'px; top: -12px; border: solid 1px black;"></div>';
echo '<div align="center" style="width: 400;">';
echo '<b>'.$text1.$percent.'%<br>';
$t3 = time() - $progress[start_time];
echo $text3.$t3.$text5.'<br>';
if ($t3 < 1 ) { $t3 = 1; }
$speed = (($progress[bytes_processed] / $t3) / 1024) / 1024;
echo $text4.$formatted = sprintf ("%01.2f", $speed).$text6.'</b><br>';
for($i=0;$i<count($progress[files]);$i++){ echo $text2.$progress[files][$i][name].'<br>'; }
echo '</div>';
} else {
echo '<div align="center" style="width: 400;">no uploading</div>';
}
exit;
} elseif (isset($_GET['frame'])) { ?>
<div align="center"><form align="center" action="" method="POST" enctype="multipart/form-data">
<input type="hidden" name="<?=ini_get("session.upload_progress.name")?>"
value="<?=$uploadName?>" />
<input type="file" name="file[]" multiple="true"/><input value="Загрузить" type="submit" /></form></div>
<?php
if($_FILES){
for($i=0;$i<count($_FILES["file"]["name"]);$i++){
if(is_uploaded_file($_FILES["file"]["tmp_name"][$i])){
move_uploaded_file($_FILES["file"]["tmp_name"][$i], "upload/".$_FILES["file"]["name"][$i]);
}
}
echo '<div align="center">загружено</div>';
}
?>
<?php } else { ?>
<HTML><HEAD><title>Upload</title><meta name="keywords"><meta name="description" ><meta http-equiv="content-type" content="text/html;charset=windows-1251">
</HEAD><BODY><div align="center" style="width: 400;"><H3>Загрузчик файлоф на сайт</H3>требования: PHP 5.4, Firefox 3,6 и выше</div>
<iframe src="?frame" height="70" width="400" align="center" frameborder="0" vspace="0" hspace="0" marginwidth="0" marginheight="0" scrolling="no" style="overflow:visible"></iframe>
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script>
$(function() {
setInterval(function() {
$.get('?ajax', function(data) {
$('#ajax').html(data);
});
}, 500);
});
</script>
<div id="ajax"></div>
<?php }
...
+150
function (post, hash) {
if (!vk.id || cur.viewAsBox) return;
var icon = ge('like_icon' + post),
my = hasClass(icon, hasClass(icon, 'fw_like_icon') ? 'fw_my_like' : 'my_like'),
matches = post.match(/(-?\d+)(_?)(photo|video|note|topic|wall_reply|note_reply|photo_comment|video_comment|topic_post|)(\d+)/),
like_obj = (matches[3] || 'wall') + matches[1] + '_' + matches[4],
ref = cur.wallType ? (cur.wallType == 'feed' ? 'feed_' + cur.section : ('wall_' + (cur.onepost ? 'one' : (!(cur.wallType || '').indexOf('full_') ? 'full' : 'page')))) : cur.module;
ajax.post('like.php', {act: 'a_do_' + (my ? 'un' : '') + 'like', 'object': like_obj, hash: hash, wall: 1, from: ref}, {
onDone: wall.likeUpdate.pbind(post, !my)
});
var count = val(ge('like_real_count_wall' + post) || ge('like_count' + post));
wall.likeUpdate(post, !my, intval(count) + (my ? -1 : 1));
if (cur.onWallLike) {
cur.onWallLike();
}
}
Зачем посоны из контакта пишут такой говно-код? Куда смотрит Паша?
+164
/* выравниваем высотку блока контента, чтобы совпадал с клеточками бэкграунда */
$('#center>div').each(function(){
$(this).height(function(i,val){
if(val<200){return 200;}
if(val<401){return 401;}
if(val<602){return 602;}
if(val<803){return 803;}
if(val<1004){return 1004;}
if(val<1205){return 1205;}
if(val<1406){return 1406;}
if(val<1607){return 1607;}
if(val<1808){return 1808;}
if(val<2009){return 2009;}
if(val<2210){return 2210;}
if(val<2411){return 2411;}
if(val<2612){return 2612;}
if(val<2813){return 2813;}
if(val<3014){return 3014;}
});
});
Это была первая и вероятно последняя попытка разгрузить штатных программистов, отдав часть несложной работы фрилансерам :)
−94
#*тут определение факториала*
fac_missing_end = factorial(100)/1000000000000000000000000
#there are 134 digits when you take off the zeroes at the end
sum_of_digits = 0
recent_digit = fac_missing_end%10
new_fac = fac_missing_end/10
sum_of_digits = sum_of_digits + recent_digit
recent_digit = new_fac%10
new_fac = new_fac/10
sum_of_digits = sum_of_digits + recent_digit
recent_digit = new_fac%10
new_fac = new_fac/10
sum_of_digits = sum_of_digits + recent_digit
recent_digit = new_fac%10
new_fac = new_fac/10
sum_of_digits = sum_of_digits + recent_digit
# еще пару десятков строк такого говна
print sum_of_digits
http://projecteuler.net/problem=20
http://projecteuler.net/thread=20;page=8
>This is ridiculous, but it worked instantaneously
Первый шаг к решению проблемы — признать что у тебя есть проблема.
+130
for(int j =0;j<d[i]/2;++j){
char e[2] = {0,'\0'};
const char* g = &e[0];
e[0] = dict[i];
s0.append(g);
}
Нужен был const char*
+63
public class ExtendFSDirectoryProvider {
// skipped
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj == null || !(obj instanceof FSDirectoryProvider)) {
return false;
}
return indexName.equals(((ExtendFSDirectoryProvider) obj).indexName);
}
}
Даже неважно, что автор делает лишнюю проверку на null - в instanceof указан другой класс! Копипаста детектед.