- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
if ('$kaax' in window)
if ($kaax === undefined) $kaax = {defval : $kaax}; else
if ($kaax === null) $kaax = {defval : null}; else
$kaax.defval = $kaax;
else
var $kaax = {};
...
$kaax = $kaax.defval;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+161
if ('$kaax' in window)
if ($kaax === undefined) $kaax = {defval : $kaax}; else
if ($kaax === null) $kaax = {defval : null}; else
$kaax.defval = $kaax;
else
var $kaax = {};
...
$kaax = $kaax.defval;
Параноик объявляет переменную.
Тот факт, что window/undefined могут быть переопределены либо $kaax уже иметь свойство defval, упускается.
+163
function load_file( $name, $include_file = "tpl" ) {
global $db, $is_logged, $member_id, $cat_info, $config, $user_group, $category_id, $_TIME, $lang, $smartphone_detected, $dle_module;
$name = str_replace( '..', '', $name );
$url = @parse_url ($name);
$type = explode( ".", $url['path'] );
$type = strtolower( end( $type ) );
if ($type == "tpl") {
return $this->sub_load_template( $name );
}
if ($include_file == "php") {
if ( !$this->allow_php_include ) return;
if ($type != "php") return "Для подключения допускаются только файлы с расширением .tpl или .php";
if ($url['path']{0} == "/" )
$file_path = dirname (ROOT_DIR.$url['path']);
else
$file_path = dirname (ROOT_DIR."/".$url['path']);
$file_name = pathinfo($url['path']);
$file_name = $file_name['basename'];
if ( stristr ( php_uname( "s" ) , "windows" ) === false )
$chmod_value = @decoct(@fileperms($file_path)) % 1000;
if ( stristr ( dirname ($url['path']) , "uploads" ) !== false )
return "Файл находится в недопустимой папке /uploads/";
if ( stristr ( dirname ($url['path']) , "templates" ) !== false )
return "Файл находится в недопустимой папке /templates/";
if ($chmod_value == 777 ) return "Файл {$url['path']} находится в папке, которая доступна для записи (CHMOD 777). В целях безопасности подключение файлов из таких папок невозможно. Измените права на папку, чтобы на нее небыло прав на запись.";
if ( !file_exists($file_path."/".$file_name) ) return "Файл {$url['path']} не найден, его загрузка невозможна.";
if ( $url['query'] ) {
parse_str( $url['query'] );
}
ob_start();
$tpl = new dle_template( );
$tpl->dir = TEMPLATE_DIR;
include $file_path."/".$file_name;
return ob_get_clean();
}
return '{include file="'.$name.'"}';
}
DLE software, доставило
Шеф заказал сайт на этой цмс...
+158
// create singelton object, see below
function singelton(classDesc) {
return classDesc;
}
var LetterTypeAction = singelton(
{
selectLetterType : function(controlId, index) {
letterTypeManager.selectLetterType(controlId, index);
},
addLetterType : function() {
letterTypeManager.addLetterType();
},
saveLetterType : function() {
var tempLetterType = new LetterTypeDef();
tempLetterType.setId(currentLetterType.getId());
tempLetterType.setAbbreviation(TextUtils.trim(ControlUtils.getValueById(letterTypeAbbrId)));
tempLetterType.setDescription(TextUtils.trim(ControlUtils.getValueById(letterTypeDescrId)));
letterTypeManager.saveLetterType(tempLetterType);
},
changeLetterType : function() {
letterTypeManager.changeLetterType();
},
deleteLetterType : function() {
letterTypeManager.deleteLetterType(currentLetterType);
},
cancelLetterType : function() {
letterTypeManager.cancelLetterType();
},
sortLetterType : function(columnId) {
letterTypeManager.sortLetterType(columnId);
}
}
);
новый паттерн проектирования, добавляющий в код мусор
+158
<?php
class pvalidator extends validator {
public function fname($value) {
return (bool) preg_match("/^[А-Яа-яЁё]{3,16}$/iu", $value);
}
public function lname($value) {
return (bool) preg_match("/^[А-Яа-яЁё]{3,16}$/iu", $value);
}
public function tname($value) {
return (bool) preg_match("/^[А-Яа-яЁё]{3,16}$/iu", $value);
}
public function nickname($value) {
return (bool) preg_match("/^[А-Яа-яЁё \-]{3,32}$/iu", $value);
}
public function country($value) {
return (bool) preg_match("/^[А-Яа-яЁё \-]{2,32}$/iu", $value);
}
public function sity($value) {
return (bool) preg_match("/^[А-Яа-яЁё \-]{2,16}$/iu", $value);
}
public function school($value) {
return (bool) preg_match("/^[№А-Яа-яЁё 0-9\-]{2,16}$/iu", $value);
}
public function hresponse($value) {
return (bool) preg_match("/^.{0,32}$/iu", $value);
}
public function activity($value) {
return (bool) preg_match("/^.{0,32}$/iu", $value);
}
public function interest($value) {
return (bool) preg_match("/^.{0,32}$/iu", $value);
}
}
?>
Моё свежее, с утра высранное!
+164
function isUTF8 ($str) {
return $utf8 = (preg_match("/^([\x09\x0A\x0D\x20-\x7E]|[\xC2-\xDF][\x80-\xBF]|\xE0[\xA0-\xBF][\x80-\xBF]|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}|\xED[\x80-\x9F][\x80-\xBF]|\xF0[\x90-\xBF][\x80-\xBF]{2}|[\xF1-\xF3][\x80-\xBF]{3}|\xF4[\x80-\x8F][\x80-\xBF]{2})*$/", $str)) ? true : false;
}
говно или нет?
−100
N = 5
$mas = (1..N).to_a
$c = 0
def generate(l = 0)
if l == N-1
for i in 0..N-1 do
print("#{$mas[i]} ")
end
$c += 1; print("\n")
else
for i in l..N-1 do
t = $mas[l]; $mas[l] = $mas[i]; $mas[i] = t;
generate(l+1)
t = $mas[l]; $mas[l] = $mas[i]; $mas[i] = t;
end
end
return $c
end
p generate(0);
+162
<?
// blah blah blah ...
static public function parseCleanValue( $val, $postParse=true )
{
if ( $val == "" )
{
return "";
}
// blah blah blah ...
}
// blah blah blah ...
?>
IP.Board 3.0.4
/admin/sources/base/core.php:4139
IPB, такой IPB
+145
<?php
if (isset($_GET['offset'])) {
$minutes = $_GET['offset'];
echo "GMT offset (in minutes, from the browser): ". $minutes ."<br />\n";
echo "GMT: ". gmdate("Y-m-d H:i:s") ."<br />\n";
$local = gmmktime(gmdate("H"),gmdate("i")-$minutes); // adjust GMT by client's offset
echo "Calculated client's date/time: ". gmdate("Y-m-d h:i:s a",$local) ."<br />\n";
} else {
echo "<script language='javascript'>\n";
echo "var d = new Date();\n";
echo "location.href=\"${_SERVER['SCRIPT_NAME']}?offset=\" + d.getTimezoneOffset();\n";
echo "</script>\n";
exit();
}
?>
где здесь пхп, кажется, понятно )
+173
$dateEnd = date("Y-m-d",mktime(23, 59, 59, date("m"), date("d"), date("Y")));
У кого-то хватило ума почитать документацию, а вот понять её - нет.
+134
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <time.h>
#include <sys/types.h>
int main(int argc, char ** argv)
{
//...
time_t time0=time(NULL);
//...
if ((f=fopen(argv[1],"r"))==NULL)
{
//...
}
while ((fscanf(f,"%i %s",&tim[i],buffer[i]))!=EOF)
{
i++;
if (i>=n)
{
n=i+10;
tim=(int*)realloc(tim,n*sizeof(int));
buffer=(char**)realloc(buffer,n*sizeof(char*));
for (k=k; k<n; k++)
{
buffer[k]=(char*)realloc(buffer[k],256*sizeof(char));
}
}
}
if (fclose(f)==-1)
{
//...
}
//------------finished reading input file-------------------
//------------sorting (bubble =) )--------------------------
while (flag)
{
flag=0;
for (j=0; j<=i-2; j++)
{
if (tim[j]>tim[j+1])
{
tmpi=tim[j];
tim[j]=tim[j+1];
tim[j+1]=tmpi;
tmpc=buffer[j];
buffer[j]=buffer[j+1];
buffer[j+1]=tmpc;
flag=1;
}
}
}
//-----------executing------------------------------
k=0;
while(k<=i-1)
{
if (tim[k]==(int)(time(NULL)-time0))
{
if(!(pid=fork()))
{
execv(buffer[k],NULL);
}
else
{
k++;
}
}
}
//...
return 0;
}
Читает из файла таймер до запуска и имя программы. Я плакалъ...