- 1
$table_name = "$pub_code"."_"."$lg_code";
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+151.9
$table_name = "$pub_code"."_"."$lg_code";
+157
$f=file(substr($_SERVER["SCRIPT_NAME"],1));
if(substr($f[9],1,4)=="url=") {$f[9]='$url=\''.$_POST['def_dir']."';\r\n";}
if(substr($f[10],1,16)=="root_user_login=") {$f[10]='$root_user_login=\''.$_POST['adm_login']."';\r\n";}
if(substr($f[11],1,15)=="root_user_pass=") {$f[11]='$root_user_pass=\''.$_POST['adm_pass']."';\r\n";}
if(substr($f[12],1,12)=="maxfilesize=") {$f[12]='$maxfilesize=\''.$_POST['maxfilesize']."';\r\n";}
if(substr($f[13],1,20)=="delete_confirmation=") {$f[13]='$delete_confirmation='.$_POST['delete_confirmation'].";\r\n";}
fwrite(fopen(substr($_SERVER["SCRIPT_NAME"],1), "w"), join('', $f)); /// the script must be in root folder =( I'm too lazy to fix it
соус ФМа знакомого...strpos для лохов! юзаем substr!=)
+156
$htmlhead='<html><head><meta>..............</head><body>';
$htmlend='</body></html>';
$table['start']='<table style=...><tr><td>'
$table['center']='</td><td>';
$table['end']='</td></tr></table>';
$menu='<a href=.......>main</a>aaa'
[..........]
function serror($error) {
global $htmlhead;
global $table;
global $menu;
global $htmlend;
global $lang;
echo $htmlhead.$table['start'].$menu ......
}
Так грамотно вначале, и тут вдруг...
+154
$max_b = 0;
for($i=1;$i<=40;$i++){
$max_b +=(41-$i);
}
Нашел у товарища в коде, данный кусочек вызывался в цикле порядка десятка тысяч раз
+168.2
if ($obj->id == 17718 || $obj->id == 16579 || $obj->id == 16849 || $obj->id == 16527 || $obj->id == 16866 || $obj->id == 16864 || $obj->id == 16863 || $obj->id == 16549 || $obj->id == 16809 || $obj->id == 16155 || $obj->id == 16852 || $obj->id == 16808 || $obj->id == 17750 || $obj->id == 17754 || $obj->id == 16993 || $obj->id == 16720 || $obj->id == 16594 || $obj->id == 16595 || $obj->id == 16703 || $obj->id == 16704 || $obj->id == 16806 || $obj->id == 16807 || $obj->id == 16712 || $obj->id == 16716 || $obj->id == 16722 || $obj->id == 16830 || $obj->id == 16831 || $obj->id == 16867 || $obj->id == 17412 || $obj->id == 16690 || $obj->id == 16039 || $obj->id == 16797 || $obj->id == 16749 || $obj->id == 16829 || $obj->id == 16571 || $obj->id == 16592 || $obj->id == 16136 || $obj->id == 17307 || $obj->id == 16846 || $obj->id == 17308 || $obj->id == 16577 || $obj->id == 16630 || $obj->id == 17405 || $obj->id == 17403 || $obj->id == 16042 || $obj->id == 16131 || $obj->id == 16631 || $obj->id == 16139 || $obj->id == 16575 || $obj->id == 16576 || $obj->id == 16574 || $obj->id == 16573 || $obj->id == 16535 || $obj->id == 16536 || $obj->id == 16570 || $obj->id == 16528 || $obj->id == 16526 || $obj->id == 17409 || $obj->id == 16622 || $obj->id == 16623 || $obj->id == 16619 || $obj->id == 16620 || $obj->id == 16805 || $obj->id == 16151 || $obj->id == 16804 || $obj->id == 16026 || $obj->id == 16613 || $obj->id == 16681 || $obj->id == 16682 || $obj->id == 17414 || $obj->id == 16618 || $obj->id == 16626 || $obj->id == 16627 || $obj->id == 17413 || $obj->id == 16628 || $obj->id == 16629 || $obj->id == 16593 || $obj->id == 16165 || $obj->id == 16166 || $obj->id == 17404 || $obj->id == 16168 || $obj->id == 16174 || $obj->id == 17402 || $obj->id == 16140 || $obj->id == 16624 || $obj->id == 16625 || $obj->id == 16621 || $obj->id == 16832 || $obj->id == 16584 || $obj->id == 16718 || $obj->id == 16719 || $obj->id == 16530 || $obj->id == 16847 || $obj->id == 16585 || $obj->id == 16756 || $obj->id == 16825 || $obj->id == 16823 || $obj->id == 16824 || $obj->id == 17783 || $obj->id == 17787 || $obj->id == 17788 || $obj->id == 17782 || $obj->id == 17789 || $obj->id == 17790 || $obj->id == 17784 || $obj->id == 17791 || $obj->id == 17792 || $obj->id == 17785 || $obj->id == 17793 || $obj->id == 17794) continue;
Кусок скрипта генерации каталога на CD. Пропуск позиций, которые надо исключить из каталога.
+151
//клас для отправления писем через smtp
//способ приминения
//функция хеадерс(ящик куда отправлять,ящик откуда отправляется,почтовик(пример @yandex.ru), тема письма)
//$headers = $post->headers($users[$i]."@yandex.ru",$users[$i]."@yandex.ru","@yandex.ru",$result['title']);
//функция отправка (текст письма, заголовок, ящик получателя, адрес отправителя,имя пользователя, пароль, домен почтовика(пример yandex.ru))
//$post->send($result_text,$headers,$users[$i]."@yandex.ru",$users[$i]."@yandex.ru",$users[$i],$pass[$i],"yandex.ru");
class mailer
{
function get_data($smtp_conn)
{
$data="";
while($str = fgets($smtp_conn,515))
{
$data .= $str;
if(substr($str,3,1) == " ") { break; }
}
return $data;
}
function headers($to,$from,$prefix,$zag)
{
$header="Date: ".date("D, j M Y G:i:s")." +0700\r\n";
$header.="From: <".$from.">\r\n";
$header.="X-Mailer: The Bat! (v3.99.3) Professional\r\n";
$header.="X-Priority: 3 (Normal)\r\n";
$header.="Message-ID: <172562218.".date("YmjHis").$prefix.">\r\n";
$header.="To: <".$to.">\r\n";
$header.="Subject: ".$zag."\r\n";
$header.="MIME-Version: 1.0\r\n";
$header.="Content-Type: text/html; charset=utf-8\r\n";
$header.="Content-Transfer-Encoding: 8bit\r\n";
return $header;
}
function send($text, $header, $to, $from, $login , $pass, $mailer)
{
$fin = new mailer;
$smtp_conn = fsockopen("smtp.".$mailer, 25,$errno, $errstr, 10);
$data = $fin->get_data($smtp_conn);
fputs($smtp_conn,"EHLO ".$mailer."\r\n");
$data = $fin->get_data($smtp_conn);
fputs($smtp_conn,"AUTH LOGIN\r\n");
$data = $fin->get_data($smtp_conn);
fputs($smtp_conn,base64_encode($login)."\r\n");
$data = $fin->get_data($smtp_conn);
fputs($smtp_conn,base64_encode($pass)."\r\n");
$data = $fin->get_data($smtp_conn);
fputs($smtp_conn,"MAIL FROM:".$from."\r\n");
$data = $fin->get_data($smtp_conn);
fputs($smtp_conn,"RCPT TO:".$to."\r\n");
$data = $fin->get_data($smtp_conn);
fputs($smtp_conn,"DATA\r\n");
$data = $fin->get_data($smtp_conn);
fputs($smtp_conn,$header."\r\n".$text."\r\n.\r\n");
$data = $fin->get_data($smtp_conn);
fputs($smtp_conn,"QUIT\r\n");
$data = $fin->get_data($smtp_conn);
}
}
клас для отправления писем через smtp
+163.3
$true = true;
for ($i=0; $i<count($list); $i++)
if (!isset($list[$i]))
$true = false;
if ($true != true)
die ("Error");
Немного о правде и лжи
+158
<?php
...
$date1['year'] = ($_POST['year1']>=2006 && $_POST['year1']<=2037) ? $_POST['year1'] : (($_GET['year1']>=2006 && $_GET['year1']<=2037) ? $_GET['year1'] : date('Y'));
$date1['month'] = ($_POST['month1']>=1 && $_POST['month1']<=12) ? $_POST['month1'] : (($_GET['month1']>=1 && $_GET['month1']<=12) ? $_GET['month1'] : date('n'));
$date1['day'] = $type>2 ? 1 : (($_POST['day1']>=1 && $_POST['day1']<=31) ? $_POST['day1'] : (($_GET['day1']>=1 && $_GET['day1']<=31) ? $_GET['day1'] : date('j')));
$date1['hour'] = $type>1 ? 0 : ((isset($_POST['hour1']) && $_POST['hour1']>=0 && $_POST['hour1']<=23) ? $_POST['hour1'] : ((isset($_GET['hour1']) && $_GET['hour1']>=0 && $_GET['hour1']<=23) ? $_GET['hour1'] : 0));
$date1['min'] = $type ? 0 : ((isset($_POST['min1']) && $_POST['min1']>=0 && $_POST['min1']<=59) ? $_POST['min1'] : ((isset($_GET['min1']) && $_GET['min1']>=0 && $_GET['min1']<=59) ? $_GET['min1'] : 0));
$date2['year'] = ($_POST['year2']>=2006 && $_POST['year2']<=2037) ? $_POST['year2'] : (($_GET['year2']>=2006 && $_GET['year2']<=2037) ? $_GET['year2'] : date('Y'));
$date2['month'] = ($_POST['month2']>=1 && $_POST['month2']<=12) ? $_POST['month2'] : (($_GET['month2']>=1 && $_GET['month2']<=12) ? $_GET['month2'] : date('n'));
$date2['day'] = $type>2 ? cal_days_in_month(CAL_GREGORIAN, $date2['month'], $date2['year']) : (($_POST['day2']>=1 && $_POST['day2']<=31) ? $_POST['day2'] : (($_GET['day2']>=1 && $_GET['day2']<=31) ? $_GET['day2'] : date('j')));
$date2['hour'] = $type>1 ? 23 : ((isset($_POST['hour2']) && $_POST['hour2']>=0 && $_POST['hour2']<=23) ? $_POST['hour2'] : ((isset($_GET['hour2']) && $_GET['hour2']>=0 && $_GET['hour2']<=23) ? $_GET['hour2'] : 23));
$date2['min'] = $type ? 59 : ((isset($_POST['min2']) && $_POST['min2']>=0 && $_POST['min2']<=59) ? $_POST['min2'] : ((isset($_GET['min2']) && $_GET['min2']>=0 && $_GET['min2']<=59) ? $_GET['min2'] : 59));
$date1['day'] = cal_days_in_month(CAL_GREGORIAN, $date1['month'], $date1['year'])<$date1['day'] ? cal_days_in_month(CAL_GREGORIAN, $date1['month'], $date1['year']) : $date1['day'];
$date2['day'] = cal_days_in_month(CAL_GREGORIAN, $date2['month'], $date2['year'])<$date2['day'] ? cal_days_in_month(CAL_GREGORIAN, $date2['month'], $date2['year']) : $date2['day'];
$time_from = mktime($date1['hour'], $date1['min'], 1, $date1['month'], $date1['day'], $date1['year']);
$time_to = mktime($date2['hour'], $date2['min'], 59, $date2['month'], $date2['day'], $date2['year']);
$types = array(0,1,2,3);
switch ($type) {
case 0:
$sql_cols = "minute(from_unixtime(data.log_time)) as \"i\", hour(from_unixtime(data.log_time)) as \"G\", day(from_unixtime(data.log_time)) as \"j\", month(from_unixtime(data.log_time)) as \"n\", year(from_unixtime(data.log_time)) as \"Y\"";
$sql_group_by = 'group by "i", "G", "j", "n", "Y"';
break;
case 1:
$sql_cols = "'0' as \"i\", hour(from_unixtime(data.log_time)) as \"G\", day(from_unixtime(data.log_time)) as \"j\", month(from_unixtime(data.log_time)) as \"n\", year(from_unixtime(data.log_time)) as \"Y\"";
$sql_group_by = 'group by "G", "j", "n", "Y"';
break;
case 2:
$sql_cols = "'0' as \"i\", '0' as \"G\", day(from_unixtime(data.log_time)) as \"j\", month(from_unixtime(data.log_time)) as \"n\", year(from_unixtime(data.log_time)) as \"Y\"";
$sql_group_by = 'group by "j", "n", "Y"';
break;
case 3:
$sql_cols = "'0' as \"i\", '0' as \"G\", '0' as \"j\", month(from_unixtime(data.log_time)) as \"n\", year(from_unixtime(data.log_time)) as \"Y\"";
$sql_group_by = 'group by "n", "Y"';
break;
default:
$sql_cols = "'0' as \"i\", '0' as \"G\", '0' as \"j\", '0' as \"n\", year(from_unixtime(data.log_time)) as \"Y\"";
$sql_group_by = 'group by "Y"';
$type = 2;
}
...
Писал "биллинг" попутно изучая пхп) скрипт вывода статистики
+163.2
$isLoginned = true;
if (strlen(strval($isLoginned)) == 4) {
} else {
}
В одном из опенсурсных форумов в исходниках видел
+161
if ($_GET['prot'] && !ereg("^[_a-zA-Z0-9]+$",$_GET['prot'])) $_GET['prot'] = "";
if ($_GET['id'] && !ereg("^[_a-zA-Z0-9]+$",$_GET['id'])) $_GET['id'] = "";
разбирал один скрипт и нашел там такую проверку
это особенно весело смотрится, если учесть, что в этих переменных должно быть число