- 1
break; break; break; // PLEASE, BREAK!!!!!!
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+153
break; break; break; // PLEASE, BREAK!!!!!!
+153
function splitString($inS)
{
$k = strlen($inS);
$res = array();
for($i=0;$i<$k;$i++)
{
$res[$i] = $inS{$i};
};
return($res);
};
function toTranslit($text)
{
$outS = '';
$data = splitString(trim($text,' -_')); //str_split($text);
foreach($data as $ch)
{
switch($ch)
{
case 'А' : $rc = 'a'; break;
case 'Б' : $rc = 'b'; break;
case 'В' : $rc = 'v'; break;
//тут очень, очень много букафф... все какие есть...
case '8' : $rc = '8'; break;
case '9' : $rc = '9'; break;
case '0' : $rc = '0'; break;
case '-' : $rc = '-'; break;
case '_' : $rc = '_'; break;
case ' ' : $rc = '-'; break;
default : $rc = '';
};
$outS .= $rc;
};
$outS = str_replace('_','-',$outS);
while(strpos('--',$outS)) { $outS = str_replace('--','-',$outS); };
return($outS);
};
ещё из просеивания, пара функций преобразующая введённую пользователем строчку в транслит
уходит корнями в 2002й год -- продержалась в ядре CMS-ки аж 7 лет, исправно при этом работая.
...и ведь опять я сам писал, заразу...
+144.1
<?php
//много кода
if(($ln > 0) && ($ln <= $limit))
//обработка строчки $ln
} elseif($ln < 1) {
echo("Нельзя вводить пустую строку!<BR>\n");
} elseif($ln > $limit) {
echo("Вы ввели слишком много<BR>\n");
} else {
echo("Невыясненный облом<BR>\n");
};
//дальше много кода
?>
при апе major версии нашей CMS контролирую тщательное просеивание старого кода.
иногда находятся такие хохмочки...
...эту я сам писал, лет уже не помню сколько назад, она уже 3 версии зараза пережила... только сейчас заметил.
+134
фак
Бугагга
+148
if ($quantity >=2) {
$bid = print_money($row["bid"]*$quantity);
} else {
$bid = print_money($row["bid"]);
}
Из одного индусского проэкта.
Они боятся умножать на 1.
+146
<?php
class db {
function db_conn ($host,$user,$pass,$db) {
if(!($this->link = @mysqli_connect($host,$user,$pass)))
{
echo "<font color=\"red\">Error:</font> connect to host: $host";
//exit();
}
if(!mysqli_select_db($this->link,$db))
{
echo "<font color=\"red\">Error:</font> select database $db";
exit();
}
return $this->link;
}
function sql_query ($query) {
$result = mysqli_query($this->link, $query);
if (!$result)
{
$this->error_msg = mysqli_error ($result);
return $this->error_msg;
}
return $result;
}
function sql_fetch_assoc ($query) {
$res=$this->sql_query($query);
//$array = array();
$row = mysqli_fetch_array($res);
mysqli_free_result($res);
return $row;
}
}
?>
+148
<?php
class db {
function db_conn ($host,$user,$pass,$db) {
if((!$this->link = @mysqli_connect($host,$user,$pass)))
{
echo "<font color=\"red\">Error:</font> connect to host: $host";
exit();
}
if(!mysqli_select_db($this->link,$db))
{
echo "<font color=\"red\">Error:</font> select database $db";
exit();
}
}
function sql_query ($query) {
$this->link = mysqli_query($this->link, $query);
if (!$this->link)
{
$this->error_msg = mysqli_error ($this->link);
return $this->error_msg;
}
return $this->link;
}
function sql_fetch_assoc ($query) {
$res=$this->sql_query($query);
$array = array();
$row = mysqli_fetch_array($res);
/*{
$array[]=$cur;
}*/
mysqli_free_result($res);
return $row;
}
}
?>
+151
<?
$sess_del ="NEWCONTENT";
$sd_flag =base64_encode($sess_del);
?>
<td width="127"><a href="createeflyer.php?s_flag=<?=$sd_flag?>" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image12','','images/navig-ovr_12.jpg',1)"><img src="<?=$imagesrc2?>" alt="createflyer" name="Image12" width="127" height="39" border="0" id="Image12" /></a></td>
Продолжение индийского эпоса (#1244-#1245, #1248-#1251)
-Назовем это "Операция Ы"!
-Почему "Ы"?
-Чтобы никто не догадался
+61.5
global $scan, $scan1, $scan2, $pri1, $pri2, $host, $i1, $hits;
global $server1, $server2;
global $item;
global $use_1, $term_1, $trun1, $bop_1;
global $use_2, $term_2, $trun2, $bop_2;
global $use_3, $term_3, $trun3, $bop_3;
global $use_4, $term_4, $trun4, $bop_4;
global $use_5, $term_5, $trun5, $bop_5;
$ver1=ord(substr(phpversion(),0,1))-48;
$ver2=ord(substr(phpversion(),2,1))-48;
$ver=$ver1*10+$ver2;
#echo $ver;
if ($ver>42)extract($_REQUEST);
if ($format == "1.2.840.10003.5.109.10") {
$pri2=1;
$pri1=1;
$pxml=0;
}
if (($scan==tounicode("список"))||($scan1==tounicode("список"))||($scan2==tounicode("список")))
{
if (strlen($term_2)>0)
{
$term_1=$term_2;
$use_1=$use_2;
}
if (strlen($term_3)>0)
{
$term_1=$term_3;
$use_1=$use_3;
}
include("func.php");
$target=$host[0];
$field1="@attr 1=" . $use_1;
$term1=$term_1;
if (strlen($term1)==0)
/* {
echo "<title>z39.50</title><BODY bgcolor=FFFFE6 TEXT=000000 LINK=brown VLINK=brown topmargin=0 leftmargin=0 marginwidth=0 marginheight=0><center><table width=70% border=1 cellpadding=25 cellspacing=0><td valign=top><font face='arial,helvetica' size=6 color=#333333>Шлюз Z39.50</font><hr><font color=brown><p><b>Для просмотра списка введите, пожалуйста, первую букву поискового терма<p><br><a href='javascript:history.back()'><img src=back.gif border=0></A></td></table>";
exit;
} */
{
$term_1='0';
$term1=$term_1;
}
$syntax="RUSMarc";
$element="F";
$number=15;
?>
+139.8
unction int2hex($intega){
$Ziffer = "0123456789ABCDEF";
return $Ziffer[($intega%256)/16].$Ziffer[$intega%16];
}
function url_encode($text){
$text = urlencode($text);
if(!strpos($text,"%C3"))
for($i=129;$i<255;$i++){
$in = "%".int2hex($i);
$out = "%C3%".int2hex($i-64);
$text = str_replace($in,$out,$text);
}
return $text;
}
function tounicode ($string){
$unistring="";
for($i=0;$i<strlen($string);$i++){
$current=$string[$i];
$codcurrent=ord($current);
if($codcurrent>255):
$unicurrent=utf8_encode($current);
$unistring=$unistring.$unicurrent;
elseif($codcurrent<192):
if($codcurrent==184):
$unicurrent=chr(209).chr($codcurrent-39);
$unistring=$unistring.$unicurrent;
elseif($codcurrent==168):
$unicurrent=chr(208).chr($codcurrent-39);
$unistring=$unistring.$unicurrent;
elseif($codcurrent==147):
$unicurrent=utf8_encode("\"");
$unistring=$unistring.$unicurrent;
elseif($codcurrent==148):
$unicurrent=utf8_encode("\"");
$unistring=$unistring.$unicurrent;
elseif($codcurrent==151):
$unicurrent=utf8_encode("-");
$unistring=$unistring.$unicurrent;
else:
$unicurrent=utf8_encode($current);
$unistring=$unistring.$unicurrent;
endif;
else:
if ($codcurrent<240):
$unicurrent=chr(208).chr($codcurrent-48);
$unistring=$unistring.$unicurrent;
else:
$unicurrent=chr(209).chr($codcurrent-112);
$unistring=$unistring.$unicurrent;
endif;
endif;
}
return $unistring;
}