- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
if (isset($_GET['worker_submit'])){
$_POST['worker_submit']='true';
}
// ..... (строк 300 кода)
if (isset($_POST['worker_submit'])){
// ..... пошли-поехали
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+159
if (isset($_GET['worker_submit'])){
$_POST['worker_submit']='true';
}
// ..... (строк 300 кода)
if (isset($_POST['worker_submit'])){
// ..... пошли-поехали
}
автор не знал ни про глобальный массив $_REQUEST ни про логический тип данных. Зато работает.
+162
class recordset {
/*используется для оптимизации работы с MySQL*/
var $res;
function recordset($sql,$link="") {
if ($link!="")
{
$this->res=mysql_query($sql,$link);
if (!$this->res)
{
echo $sql;
echo mysql_error($link);
}
}
else
{
$this->res=mysql_query($sql);
if (!$this->res)
{
echo $sql;
echo mysql_error();
}
}
}
function gr() {
$row=mysql_fetch_row($this->res);
if ($row) {for ($i=0;$i<count($row);$i++) $row[$i]=convert_cyr_string($row[$i],"k","w");}
return $row; }
function ga() {
$row=mysql_fetch_array($this->res);
if ($row) {foreach($row as $key=>$val) $row[$key]=convert_cyr_string($val,"k","w");}
return $row; }
function nr() {
$num=mysql_num_rows($this->res);
return $num; }}
еще один перл того же автора, что и в 2х предыдущих опубликованных мной говнокодах.
На этот раз старорежимный ООП - великолепный класс.
+146
$this->load->model('Bimail');
$this->Bimail->beautymail(
$this->adminmail,
$this->input->post('mail'),
$$this->adminsubject,
$this->input->post('name'),
$this->input->post('text'));
$this->redirect('conn/ok');
Как видите я написал два знака доллара на 5 строке. При таком вызове фукции у мея виснет httpd.exe (это Apach). Кто может объяснить почему?
И еще: почему РНР не выдает ошибки?
*Провернуть такую ошибку в простом коде не получилось.
+151
public function GetCurrentCultureID(){
return 1;
}
ой как лень дописывать поддержку мультиязычность в устаревшие модули....
+146
$module=(!empty($_GET['mod']))?$_GET['mod']:"static";
if(is_file("modules/".$module.".class.php"))
{
include_once("modules/".$module.".class.php");
}
else
{
include_once("modules/error.class.php");
}
от такая хитрожопая система, позволяющая подгружать "модули"
+158
$s = "insert content (name,description,type,ltype,contract_id) values ('".addslashes($title[$key])."','".addslashes($description)."','".addslashes($type[$key])."','".addslashes($ltype[$key])."','".addslashes($contracts[$key])."')";
$result = mysql_query($s);
$s2 = "select id from content where ((name='".addslashes($title[$key])."')and(description='".addslashes($description)."')) order by id desc limit 1";
//echo $s2;
$result2 = mysql_query($s2);
$id = mysql_result($result2, 0, "id"); // вот id вставленного контента
(facepalm) получение last_insert_id =)
особо порадовало "order by id desc limit 1", учитывая что в таблице `content` поле `name` UNIQUE
+144
if ($_FILES['file1']['tmp_name'])
{
if($_FILES['file1']['type'] == 'image/gif' or $_FILES['file1']['type'] == 'image/jpeg' or $_FILES['file1']['type'] == 'image/pjpeg' or $_FILES['file1']['type'] == 'image/png')
{
if(move_uploaded_file($_FILES['file1']['tmp_name'], $upload_foto_new))
{
print 1;//good
}
else
{
print 2;//bad
}
}
else
print 3;//wrong format
}
загрузка картинки
+144
<?
//тут был говнокод)
?>
+166
function toup($str) {
#перевод в верхний регистр (просто strtoupper не всегда корректно работает с русскими буквами)
$str=strtoupper($str);
$str=str_replace("а","А",$str);$str=str_replace("б","Б",$str);$str=str_replace("в","В",$str);
$str=str_replace("г","Г",$str);$str=str_replace("д","Д",$str);$str=str_replace("е","Е",$str);
$str=str_replace("ж","Ж",$str);$str=str_replace("з","З",$str);$str=str_replace("и","И",$str);$str=str_replace("й","Й",$str);
$str=str_replace("к","К",$str);$str=str_replace("л","Л",$str);$str=str_replace("м","М",$str);
$str=str_replace("н","Н",$str);$str=str_replace("о","О",$str);$str=str_replace("п","П",$str);
$str=str_replace("р","Р",$str);$str=str_replace("с","С",$str);$str=str_replace("т","Т",$str);
$str=str_replace("у","У",$str);$str=str_replace("ф","Ф",$str);$str=str_replace("х","Х",$str);
$str=str_replace("ц","Ц",$str);$str=str_replace("ч","Ч",$str);$str=str_replace("ш","Ш",$str);
$str=str_replace("щ","Щ",$str);$str=str_replace("ъ","Ъ",$str);$str=str_replace("ы","Ы",$str);
$str=str_replace("ь","Ь",$str);$str=str_replace("э","Э",$str);$str=str_replace("ю","Ю",$str);
$str=str_replace("я","Я",$str);
return $str;}
function tolower($str) {
#перевод в нижний регистр (просто strtolower не всегда корректно работает с русскими буквами)
$str=strtolower($str);
$str=str_replace("А","а",$str);$str=str_replace("Б","б",$str);$str=str_replace("В","в",$str);
$str=str_replace("Г","г",$str);$str=str_replace("Д","д",$str);$str=str_replace("Е","е",$str);
$str=str_replace("Ж","ж",$str);$str=str_replace("З","з",$str);$str=str_replace("И","и",$str);$str=str_replace("Й","й",$str);
$str=str_replace("К","к",$str);$str=str_replace("Л","л",$str);$str=str_replace("М","м",$str);
$str=str_replace("Н","н",$str);$str=str_replace("О","о",$str);$str=str_replace("П","п",$str);
$str=str_replace("Р","р",$str);$str=str_replace("С","с",$str);$str=str_replace("Т","т",$str);
$str=str_replace("У","у",$str);$str=str_replace("Ф","ф",$str);$str=str_replace("Х","х",$str);
$str=str_replace("Ц","ц",$str);$str=str_replace("Ч","ч",$str);$str=str_replace("Ш","ш",$str);
$str=str_replace("Щ","щ",$str);$str=str_replace("Ъ","ъ",$str);$str=str_replace("Ы","ы",$str);
$str=str_replace("Ь","ь",$str);$str=str_replace("Э","э",$str);$str=str_replace("Ю","ю",$str);
$str=str_replace("Я","я",$str);
return $str;}
Еще 2 шикарные функции, того же автора, что и в предыдущем моем посте.
про setlocale никто и не слыхивал.
+164
if (strlen($str)>1 && substr($str,strlen($str)-2,1)=="1") {
switch(substr($str,strlen($str)-1,1)) {
case "0": $newstr="десять рублей";break;
case "1": $newstr="одиннадцать рублей";break;
case "2": $newstr="двенадцать рублей";break;
case "3": $newstr="тринадцать рублей";break;
case "4": $newstr="четырнадцать рублей";break;
case "5": $newstr="пятнадцать рублей";break;
case "6": $newstr="шестнадцать рублей";break;
case "7": $newstr="семьнадцать рублей";break;
case "8": $newstr="восемьнадцать рублей";break;
case "9": $newstr="девятьнадцать рублей";break;}}
else {
switch(substr($str,strlen($str)-1,1)) {
case "0": $newstr="рублей";break;
case "1": $newstr="один рубль";break;
case "2": $newstr="два рубля";break;
case "3": $newstr="три рубля";break;
case "4": $newstr="четыре рубля";break;
case "5": $newstr="пять рублей";break;
.......................................
case "7": $newstr="семь миллионов ".$newstr;break;
case "8": $newstr="восемь миллионов ".$newstr;break;
case "9": $newstr="девять миллионов ".$newstr;break;}
if (strlen($str)>7) {
switch(substr($str,strlen($str)-8,1)) {
case "2": $newstr="двадцать ".$newstr;break;
case "3": $newstr="тридцать ".$newstr;break;
case "4": $newstr="сорок ".$newstr;break;
case "5": $newstr="пятьдесят ".$newstr;break;
case "6": $newstr="шестьдесят ".$newstr;break;
case "7": $newstr="семьдесят ".$newstr;break;
case "8": $newstr="восемьдесят ".$newstr;break;
case "9": $newstr="девяносто ".$newstr;break;}}}}
if (strlen($str)>8) {
switch(substr($str,strlen($str)-9,1)) {
case "0": $newstr="сто ".$newstr;break;
case "1": $newstr="сто ".$newstr;break;
case "2": $newstr="двести ".$newstr;break;
case "3": $newstr="триста ".$newstr;break;
case "4": $newstr="четыреста ".$newstr;break;
case "5": $newstr="пятьсот ".$newstr;break;
case "6": $newstr="шестьсот ".$newstr;break;
case "7": $newstr="семьсот ".$newstr;break;
case "8": $newstr="восемьсот ".$newstr;break;
case "9": $newstr="девятьсот ".$newstr;break;}}
Вот так делают "сумму прописью".
Радует и форматирование, и порядок порядков чисел в if .. elseif .. else