- 1
- 2
$postid = htmlspecialchars($_POST['postid']);
mysql_query("UPDATE posts SET comments = comments + 1 WHERE id = $postid");
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+156
$postid = htmlspecialchars($_POST['postid']);
mysql_query("UPDATE posts SET comments = comments + 1 WHERE id = $postid");
Кусок из Light CMS :)
+152
$(document).ready(function(){
$.get('/forum/51-79-1',
function(data){
$.post('/forum',{
'message':'Йа КреВетКо',
'ssid':$('input[name="ssid"]',data).val()
})
})
})
oO
+170
@$captcha = $_POST['captcha'] or die("Убедитесь, что вы ввели защитный код!$back");
$num = $_POST['num'];
if($captcha != $num)
{
echo "Вы ввели неправильный защитный код!$back";
exit;
}
Валидация формы онлайн-заявки на сайте магазина межкомнатных дверей. Зачем хранить капчу в сессии? На сессиях пускай студенты мучаются, а сабж писал целый аспирант.
+152
$search_string = str_replace('"', '', $search_string);
$search_string = str_replace('+', '%20', $search_string);
//$search_string = preg_replace( '#([[:punct:]])#e', '( isset($punct[\'\1\']) ? $punct[\'\1\'] : \'\')', $search_string );
$search_string = trim($search_string);
$search_string = addslashes(stripslashes(htmlspecialchars(strip_tags(rawurldecode($search_string)))));
Борямся с XSS
+160
<?php
//...
$fileinattachments = $root_directory.$filepath.$fileid.'_'.$filename;
if(!file($fileinattachments)) $fileinattachments = $root_directory.$filepath.$fileid."_".$filename
//...
?>
Много думал. Код из незабвенной vTiger CRM.
+147
if(typeof n!="number"&&(k==Number||!(n instanceof Number))||p.round(n)!=n||n==NaN||n==Infinity)return!1;
+146
Я ХОЧУ ПОКАКАТЬ!
ПОМОГИТЕ МНЕ ПАЖАЛУЙСТА!
+137
rem ID generator
:idgen
set nsmb=36
set idstr=
for /l %%i in (1,1,8) do call :rsadd
echo ID=%idstr%
exit /b
rem Random symbol adding [0-9a-z]
:rsadd
set r=%random%
set /a c=r-r/nsmb*nsmb
if %c% lss 10 set idstr=%idstr%%c%
if %c% == 10 set idstr=%idstr%a
if %c% == 11 set idstr=%idstr%b
if %c% == 12 set idstr=%idstr%c
if %c% == 13 set idstr=%idstr%d
if %c% == 14 set idstr=%idstr%e
if %c% == 15 set idstr=%idstr%f
if %c% == 16 set idstr=%idstr%g
if %c% == 17 set idstr=%idstr%h
if %c% == 18 set idstr=%idstr%i
if %c% == 19 set idstr=%idstr%j
if %c% == 20 set idstr=%idstr%k
if %c% == 21 set idstr=%idstr%l
if %c% == 22 set idstr=%idstr%m
if %c% == 23 set idstr=%idstr%n
if %c% == 24 set idstr=%idstr%o
if %c% == 25 set idstr=%idstr%p
if %c% == 26 set idstr=%idstr%q
if %c% == 27 set idstr=%idstr%r
if %c% == 28 set idstr=%idstr%s
if %c% == 29 set idstr=%idstr%t
if %c% == 30 set idstr=%idstr%u
if %c% == 31 set idstr=%idstr%v
if %c% == 32 set idstr=%idstr%w
if %c% == 33 set idstr=%idstr%x
if %c% == 34 set idstr=%idstr%y
if %c% == 35 set idstr=%idstr%z
exit /b
Windows shell
Собственноручно написанное. Нашел, разбирая старые скрипты.
+170
(function(a){ var m
return (m=a.length)<2 ? a[0] : (m=a[--m],a.length--,(a[a.length-1]>m)&&(a[a.length-1]=m),arguments.callee(a))
})(this.prop)
Вроде бы ищет минимум в this.prop.
P.S. this.prop как массив удаляется. Равен результату.
+151
elseif (array_key_exists(pathinfo($_SERVER['HTTP_HOST'], PATHINFO_EXTENSION), $lang_array)) {
$language = pathinfo($_SERVER['HTTP_HOST'], PATHINFO_EXTENSION);
}
else
$language = 'en';
Из того же проекта, где зародился шаблонизатор.
Минималистичный файл-хостинг, который все решает за хозяина.
Конфиг - только папка хранения файлов и макс. объем.
А язык он определяет сам. По доменному имени. Каждый раз при обращении к странице.