- 1
- 2
- 3
- 4
- 5
<? session_start();
if (isset($_session['username'])) $s=$_session['username'];
else $s="Beda!!!!"
echo $s;
?>
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+165
<? session_start();
if (isset($_session['username'])) $s=$_session['username'];
else $s="Beda!!!!"
echo $s;
?>
+165
/*
CONNECT
*/
function connect( $server, $user, $pass )
{
return mysql_connect( $server, $user, $pass );
mysql_query("SET NAMES 'utf8'");
}
/*
PCONNECT
*/
function pconnect( $server, $user, $pass )
{
return mysql_pconnect( $server, $user, $pass );
mysql_query("SET NAMES 'utf8'");
}
/*
SELECT DB
*/
function select_db($database,$link_id)
{
return mysql_select_db($database,$link_id);
mysql_query("SET NAMES 'utf8'");
}
+171
bool BMPTextureLoader::Load (GraphicContent **content, string file_name)
{
int width, height;
int bpp;
unsigned char *pixels;
ifstream file (file_name.c_str());
char temp[4];
long unsigned int data_shift;
//Read BMP identifier (bfType)
file.read(temp,2);
temp[2] = '\0';
if ((temp[0] != 'B') || (temp[1] != 'M'))
{
return false;
}
//Ignore file size and two reserved zero (bfSize, bfReserved1, bfReserved2)
file.ignore(8);
//Read pixel-data shift (bfOffBits)
file.read(temp,4);
data_shift = 0;
for (int i=0; i<4; i++)
{
data_shift += (int)(temp[i]) * pow(256.0,i);
}
if (data_shift < 54)
{
return false;
}
//Ignore information data size (biSize)
file.ignore(4);
//Read image width (biWidth)
file.read(temp,4);
width = 0;
for (int i=0; i<4; i++)
{
width += (int)(temp[i]) * pow(256.0,i);
}
if (width < 0)
{
return false;
}
//Read image height (biHeight)
file.read(temp,4);
height = 0;
for (int i=0; i<4; i++)
height += (int)(temp[i]) * pow(256.0,i);
if (height < 0)
{
return false;
}
//Read mandatory 1 (biPlanes)
file.ignore(2);
//Read bite per pixel (biBitCount)
file.read(temp,2);
int bipp = 0;
bipp += (int)(temp[0]) + (int)(temp[1])*256;
if ((bipp <= 0) || (bipp / 8. != 3))
{
return false;
}
bpp = 3;
//Read compression type (biCompression)
file.read(temp,4);
int c_type = 0;
for (int i=0; i<4; i++)
{
c_type += (int)(temp[i]) * pow(256.0,i);
}
if (c_type != 0)
{
return false;
}
file.close();
file.open(file_name);
file.ignore (data_shift);
//Read pixel data
pixels = new unsigned char[width*height*bpp];
for (int i=height-1; i>=0; i--)
{
for (int j=0; j<width; j++)
{
file.read(reinterpret_cast<char*>(&pixels[i*width*bpp + j*bpp + 2]), 1);
file.read(reinterpret_cast<char*>(&pixels[i*width*bpp + j*bpp + 1]), 1);
file.read(reinterpret_cast<char*>(&pixels[i*width*bpp + j*bpp]), 1);
}
}
//Create texture
Terminal terminal;
Считываю BMP файл. Размеры, количество бит на пиксель и тип сжатия считываются нормально. Бит на пиксель 24, сжатия нет(0). Дальше я переоткрываю файл и отступаю нужное кол-во пикселей (смещение данных). После этого считываю данные о цветах пикселей. С рисунками нарисованными непосредственно мной всё проходит нормально. Но с картинками взятыми из интернета происходит сбой. После определённого пикселя считывание прекращается. По дебагу получается что при достижение этого пикселя наступает конец файла. Пробовал вырезать куски изображения из нета и переносить в свой файл. Одни куски переносятся и всё нормально, другие обрывают считывание. Наблюдал эту проблему у нескольких рисунков. Возможно кто-то сталкивался с такой проблемой?
Источник: http://www.gamedev.ru/code/forum/?id=144831
+159
<div id='vote' name='vote'></div>
<script src="http://siteheart.com/apps/api.js"></script>
<script type="text/javascript">
var query = window.location.search.substring('?url=');//находим часть url, что нужно затереть
query = query.replace('?url=','');
var url_split = query.split("&"); //разбиваем url на части
var url = url_split[0]; //нас интересует только первая часть
var params = {
text : 'Оцените эту страницу',
appendTo : 'vote',
id : 3055,
description : 'Приватбанк',
template : 'full',
vid : encodeURIComponent( url ) //document.location.href
};
Siteheart.widget('Vote', params); //описание https://siteheart.com/apps/vote/full.html
</script>
Вот такой код в privat24.privatbank.ua.
Комменты убили.
+101
TLine = record
X1, Y1, X2, Y2: smallint;
Attr: array [0 .. 7] of byte;
end;
{rail:
Attr[0]: Quality
Attr[1]: ********
||Weight of Station
||10 = Station; 11 = Big Station
Attr[2]: Count of passengers
Real count = Attr[2] * (Attr[1] and $3F) / 63;
Attr[3]: ****0100
||||
|||for Selected
||for "crossrail"
for MoveEndSel
===========================================
bridge:
Attr[0]: Quality
Attr[1]: ********
||
Z of ends
Attr[2]:
Attr[3]: ****1100
===========================================
3d-object:
Attr[0]: Number
Attr[1-2]: RandSeed
Attr[3]: ****1111
===========================================
Attr[4..7] reserved, but not used
}
Это я был вынужден написать себе такую памятку после попыток понять свой код, начатый на 3 курсе.
В будущем я учёл свои ошибки при написании http://govnokod.ru/5261
+158
function buildKust( $queryId )
{
$commentQuery = getElementsBy('queryncomment', 'query', $queryId);
IF($commentQuery)
foreach($commentQuery as $key=>$CQ)
{
$query = mysql_query("SELECT * FROM comments WHERE lev = 0 AND id = '".$CQ['comment']."' ");
while($comment = mysql_fetch_array($query))
$nullLevel[] = $comment;
}
IF($nullLevel)
foreach($nullLevel as $key=>$nullComment)
{
$nullComment['level'] = 0;
$brunch[0] = $nullComment;
$kust[] = getChildren($nullComment,$brunch, 1);
}
return $kust;
}
Коменты
+177
enum
{
QUEST_5727 = 5727,
QUEST_6566 = 6566,
};
+158
function make_category_select($name,$selected='',$not='',$additional='')
{
global $udb,$admin,$evoLANG,$cat_cache;
$this->parent_name = $this->parent_name != "" ? $this->parent_name : $evoLANG['noparent'];
if ($this->onlyoptions != 1)
{
$a .= "<select name=\"".$name."\" ".$additional.">\n";
}
$a .= '<option value=""> '.$this->parent_name." </option>\n";
$a .= $this->make_cat_options('0',$selected,1,$not);
if ($this->onlyoptions != 1)
{
$a .= '</select>';
}
return $a;
}
+159
function make_cat_options($pid='0',$selected='',$depth=1,$not='')
{
global $cat_cache,$udb,$database,$admin;
if ( !is_array($cat_cache) )
{
$sql = $udb->query('SELECT * FROM '.$database['cat'].' ORDER BY orders ASC, cid ASC');
while ($row = $udb->fetch_array($sql))
{
$cat_cache[$row['pid']][$row['cid']] = $row;
}
}
$cache = $cat_cache;
$xaccess = explode(",",$not);
if(!isset($cache[$pid])) return;
while (list($parent,$category) = each($cache[$pid]))
{
if ( $this->cattpl != '' )
{
$a .= str_replace(
array('{url}','{description}','{name}'),
array(
$this->link_cat( $category[$this->sestype_cat()]),
$admin->superhtmlentities($category['description']),
str_repeat(' ',$depth-1)." ".$category['name']
),
$this->cattpl );
}
else
{
$category['name'] = $this->hsc == 1 ? $admin->superhtmlentities($category['name']) : $category['name'];
unset($sel);
if ($category['cid'] == $selected)
{
$sel = 'selected="selected"';
}
if ( !in_array($category['cid'],$xaccess) )
{
if ( $category['disabled'] != 1 )
{
$a .= '<option value="'.($this->cat_name == 1 ? $this->link_cat($category[$this->sestype_cat()]) : $category['cid']).'" '.$sel.'>';
if ($depth > 1)
{
$a .= str_repeat("-",$depth-1)." ".$category['name']."</option>"."\n";
}
else
{
$a .= $category['name']."</option>";
}
}
else
{
$a .= '<optgroup label="'. str_repeat("-",$depth-1)." ".$category['name'].'">';
$closegroup = 1;
}
}
}
$a .= $this->make_cat_options($category['cid'],$selected,$depth+1,$not);
if ( $closegroup == 1 )
{
$a .= "</optgroup>\n";
}
}
$udb->free_result($sql);
return $a;
}
+159
function get_list_templ()
{
$list = array();
$odir = opendir("../templetes");
while (($rdir = readdir($odir)) != false)
{
if ($rdir !== '.' and $rdir !== '..' and !strpos($rdir, '.'))
{
echo $rdir.': ';
$odir2 = opendir("../templetes/$rdir");
while($rdir2 = readdir($odir2))
if ($rdir2 !== '.' and $rdir2 != '..' and strpos($rdir2, '.'))
{
if ($rdir2 === 'index.php')
{
echo $rdir2."<br />";
} else
{
echo 'No exits index.php<br />';
}
}
}
}