- 1
- 2
- 3
- 4
- 5
- 6
- 7
function xchg(s,o,n)
{ var r=s.split(o).join(n);
return r;
}
function toHTML(s)
{return xchg(xchg(xchg(xchg(xchg(xchg(s,'<BR>',''),'<br>',''),'<','<'),'>','>'),'&','&'),'\'\'','\'');}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+165
function xchg(s,o,n)
{ var r=s.split(o).join(n);
return r;
}
function toHTML(s)
{return xchg(xchg(xchg(xchg(xchg(xchg(s,'<BR>',''),'<br>',''),'<','<'),'>','>'),'&','&'),'\'\'','\'');}
Кусок кода из моего скрипта Гостевой книги для Народа, добавляющей туда bb-теги, смайлы и прочие радости (сейчас там, вроде, скрипты уже вырезаются). Писалось лет 6 назад.
В целом код в скрипте оказался на удивление еще не таким говнокодестым, как я ожидал. Есть еще пара кусочков говнокогда...
+153
<script type="text/javascript">
// <![CDATA[
var tid=1429594;
var arr;
arr = new Array();var k=0;
var test;
function requestThread(pin) {
if (document.getElementById('p'+pin)) {
$('#t'+pin).html('<font color="#2255EE"><b>'+$('#t'+pin).html()+'</b></font>');
$.post('./lbitcomment.php', {u: 'http://site.livejournal.com/1429594.html?format=light&thread='+pin, i: $('#p'+pin).val()}, function (data)
{
$('#t'+pin).html(data);
p=p+1
while ((!document.getElementById('t'+arr[p])) && (p<=k))
p++;
if (p<=k) {
requestThread(arr[p]);
}
return;
});
} else {
p=p+1;
if (p<=k)
requestThread(arr[p]);
}
return;
}
p=1;
$(document).ready(function(){
requestThread(arr[1]);
});
// ]]>
</script>
Скрипт для разворачивания комментов ЖЖ ( http://www.hex.su/tools/open-thread/ ) добавляет в страницу такой вот код.
+144
// Devide vector
Tuple<Complex[], Complex[]> DevideVector(Complex[] vector){
Complex[] firstPart = new Complex[vector.Length / 2],
secondPart = new Complex[vector.Length / 2];
for (int index = 0; index < firstPart.Length; index++) { firstPart[index] = vector[index]; }
for (int index = 0, offset = firstPart.Length; index < secondPart.Length; index++) { secondPart[index] = vector[index + offset]; }
return new Tuple<Complex[], Complex[]>(firstPart, secondPart);}
// FFT
public Complex[] Transform(Complex[] vector){
inverse = false;
Complex[] result = Operation(vector);
result = InverceIndexBits(result);
for (int index = 0; index < vector.Length; index++) { result[index] /= result.Length; }
return result;}
// IFFT
public Complex[] InverseTransform(Complex[] vector){
inverse = true;
Complex[] result = Operation(vector);
result = InverceIndexBits(result);
return result;}
}}
Код из лабы моего одногруппника. Яркий пример того, как НЕ НАДО оформлять код
+157
// (c) Template Optimizer
// (c) Template Compiler
// skin/news.tpl
/*<?php
die ('<br /><br />Template Parser: <b>Access locked</b>');
?>*/
$value0 = '
';
if ( $this->get_tpl_tag ('USER.ACCESS') == '1' )
{
$value0 .= '
';
$this->set_tpl_tag ('ACTION', 'new_add');
$value0 .= '
';
$this->set_tpl_tag ('SUBMIT', 'Добавить');
$value0 .= '
';
$this->set_tpl_tag ('CAPTION', 'Добавить новость');
$value0 .= '
' . $this->file_include ('content.tpl') . '
';
}
$value0 .= '
';
$this->open_local (array ('NEW'));
if ( is_array ($this->get_tpl_tag ('NEWS')) )
foreach ( $this->get_tpl_tag ('NEWS') as $this->tags['NEW'] )
{
$value0 .= '
<table class="news" width="100%">
<tr>
<th>
<h2>' . $this->get_tpl_tag ('NEW.TITLE') . '</h2>
</th>
<th align="right">
<span class="gensmall">' . $this->get_tpl_tag ('NEW.TIME') . ' </span>
';
if ( $this->get_tpl_tag ('USER.ACCESS') == '1' )
{
$value0 .= '
<a href="admin.php?action=new_edit&new=' . $this->get_tpl_tag ('NEW.ID') . '"><img src="' . $this->root_dir . '/images/rename.gif" alt="Редактировать" title="Редактировать" style="vertical-align: middle; border: none;" /></a>
<a href="admin.php?action=new_delete&new=' . $this->get_tpl_tag ('NEW.ID') . '" onclick="return confirm (\'Удалить новость за ' . $this->get_tpl_tag ('NEW.TIME') . '?\');"><img src="' . $this->root_dir . '/images/delete.gif" alt="Удалить" title="Удалить" style="vertical-align: middle; border: none;" />
';
}
$value0 .= '
</th>
</tr>
<tr>
<td colspan="2">
' . $this->get_tpl_tag ('NEW.BODY') . '
</td>
</tr>
</table>
';
}
$this->close_local();
$value0 .= '
';
$this->set_tpl_tag ('_ALIGN_', 'LEFT');
$value0 .= '
' . $this->file_include ('pagebar.tpl');
Вот такой "говнокод" выдает мой шаблонизатор после компилирования шаблона.
В данном примере это блок новостей.
+168
function m($s, $re)
{
return preg_match($re, $s);
}
Из какого-то движка такая вот функа в файле function.php
+144
void addSlash( const char* command, char* sdo )
{
int command_length;
char *command_line = command;
command_length = strlen(command);
while(command_length>0){
switch(*command_line){
case '"':
strcpy(sdo+strlen(sdo),"\\");
default:
strcpy(sdo+strlen(sdo), command_line);
}
command_line++;
command_length--;
}
}
Должно быть добавление слешей перед двойными кавычками.
+154
String boo = value[i]/*.ConvertTo<String>()*/;
std::string boovalue(boo.Value());
st.bind(1+i, boovalue.c_str());
+169
/* создать задачу */
function add_problem($value) {
...
}
+1001
string GetStringHash(string S)
{
MD5 md = MD5.Create();
byte[] B = md.ComputeHash(Encoding.UTF8.GetBytes(S));
return string.Format("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}",
B[0x00], B[0x01], B[0x02], B[0x03], B[0x04], B[0x05], B[0x06], B[0x07],
B[0x08], B[0x09], B[0x0A], B[0x0B], B[0x0C], B[0x0D], B[0x0E], B[0x0F]);
}
Запостил: 4eburashka, прямо перед выпилом ресурса.
+151
$g_source= SF(qGet("source")); // $_GET['source'] со всякой фильтрацией
if ($g_source=="") { $g_source=''; }