- 1
А может, стоит добавить категорию для лаб/уроков? А то искать искры истинных какашек среди php-datetime'ов и студенческих поделок становится действительно трудно.
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+148
А может, стоит добавить категорию для лаб/уроков? А то искать искры истинных какашек среди php-datetime'ов и студенческих поделок становится действительно трудно.
+170
int GetRndWithRnd(int iRnd, int iRndPlusMinus)
{
if(!iRndPlusMinus) return iRnd;
switch((Rand())%2)
{
case 1:
// plus
return (int)(iRnd+(Rand()%iRndPlusMinus));
break;
default:
// minus
return (int)(iRnd-(Rand()%iRndPlusMinus));
break;
}
return 0;
}
Чтоб враги не догадались
−82
function repair_clock_Contact(objGame, mVal, sVal) -- master, slave
-- vsyakie daNNue
local mType = string.sub (tostring (mVal), -1, -1);
local mi, mj = repair_clock_GetElemPos(objGame, mVal);
local sType = string.sub (tostring (sVal), -1, -1);
local si, sj = repair_clock_GetElemPos(objGame, sVal);
--?????NEKYUiNYAvKVADRATE???????
-- if (tonumber (mType) == 2) then -- FOR MEHA TEST
-- local a = 0;
-- end
if (tonumber (mType) == 9) then
mType = 2;
end
--??????????????????????????????
--!!!!!NEKYUiNYA!!!!!
mType = 6 - mType;
sType = 6 - sType;
--!!!!!!!!!!!!!!!!!!
--------------------
..........................
Коменты жгут)))
язык Lua
+146
<?php
/**
* @class Sanitize
* @author Nirmit Bothra
* @copyright 2007
* @description This class sanitizes all user input which are accessed by PHP using POST, GET or REQUEST variables. Data sanitation helps in making
* safe transactions with a database.
*/
class sanitize {
function sanitize() {
// class constructor and
$this->sanitizeCookie();
$this->sanitizeGet();
$this->sanitizeRequest();
$this->sanitizePost();
}
function sanitizePost() {
foreach($_POST as $key=>$value) {
$_POST[$key] = addslashes($value);
}
}
function sanitizeGet() {
foreach($_GET as $key=>$value) {
$_GET[$key] = addslashes($value);
}
}
function sanitizeRequest() {
foreach($_REQUEST as $key=>$value) {
$_REQUEST[$key] = addslashes($value);
}
}
function sanitizeCookie() {
foreach($_COOKIE as $key=>$value) {
$_COOKIE[$key] = addslashes($value);
}
}
}
$sanitizedData =& new sanitize();
?>
http://www.phpclasses.org/browse/file/21488.html
универсальная индусская обработка входных данных.
юзер в безопасности!
+149
// get info from db
$results = $this->datadb->dataForIndex();
$data_['mainResult'] = $results['mainResult'];
$data_['pics'] = $results['pics'];
$data_['com'] = $results['com'];
$data_['huuInvert'] = $results['huuInvert'];
$data_['dateInvert'] = $results['dateInvert'];
$data_['type'] = $results['type'];
Кусок со своего CMS. Да я знаю что можно объединить массивы, но иногда не все требуется из функции.
+140
try
{
client.SendData(xml);
}
catch(Exception e)
{
string s = e.ToString();
if(s.Substring(0,80)=="System.InvalidOperationException: Operation not allowed on non-connected sockets")
{
client.tcpclient.Close();
clients.Remove(client.SessionId);
}
else if (s.Substring(0,71)=="System.IO.IOException: Unable to write data to the transport connection")
{
client.tcpclient.Close();
clients.Remove(client.SessionId);
}
else
{
client.tcpclient.Close();
clients.Remove(client.SessionId);
}
}
нестандартное определение типа исключения
найдено в примерах кода кандидата на работу
+154
if (request->status().is_success() &&
(request->GetResponseCode() / 100) == 2) {
/* блаблабла */
}
Было случайно откопано в исходниках хромиума (http://src.chromium.org/svn/trunk/src/webkit/appcache/appcache_update_job.cc). И первый вопрос который возникает это "Ну вот нахера???".
+146
var a = 4.83 + 2.54 + 4.85 + 4.83;
alert(a);
// выводит 17.049999999999997
Что за глюк???
+32
if (!empty($forum_actions))
{
?>
<div class="linksb">
<div class="inbox crumbsplus">
<p class="subscribelink clearb"><?php echo implode(' - ', $forum_actions); ?></p>
</div>
</div>
<?php
}
?>
<div id="brdstats" class="block">
<h2><span><?php echo $lang_index['Board info'] ?></span></h2>
<div class="box">
<div class="inbox">
<dl class="conr">
<dt><strong><?php echo $lang_index['Board stats'] ?></strong></dt>
<dd><span><?php printf($lang_index['No of users'], '<strong>'.forum_number_format($stats['total_users']).'</strong>') ?></span></dd>
<dd><span><?php printf($lang_index['No of topics'], '<strong>'.forum_number_format($stats['total_topics']).'</strong>') ?></span></dd>
<dd><span><?php printf($lang_index['No of posts'], '<strong>'.forum_number_format($stats['total_posts']).'</strong>') ?></span></dd>
</dl>
<dl class="conl">
<dt><strong><?php echo $lang_index['User info'] ?></strong></dt>
<dd><span><?php printf($lang_index['Newest user'], $stats['newest_user']) ?></span></dd>
<?php
if ($pun_config['o_users_online'] == '1')
{
// Fetch users online info and generate strings for output
$num_guests = 0;
$users = array();
$result = $db->query('SELECT user_id, ident FROM '.$db->prefix.'online WHERE idle=0 ORDER BY ident', true) or error('Unable to fetch online list', __FILE__, __LINE__, $db->error());
while ($pun_user_online = $db->fetch_assoc($result))
{
if ($pun_user_online['user_id'] > 1)
{
if ($pun_user['g_view_users'] == '1')
$users[] = "\n\t\t\t\t".'<dd><a href="profile.php?id='.$pun_user_online['user_id'].'">'.pun_htmlspecialchars($pun_user_online['ident']).'</a>';
else
$users[] = "\n\t\t\t\t".'<dd>'.pun_htmlspecialchars($pun_user_online['ident']);
}
else
++$num_guests;
}
главная страница форумного движка fluxbb
moar тут по сцылке https://github.com/fluxbb/fluxbb/blob/fluxbb-1.4/index.php
Блядь... зато скока у них там этого самого прекрасно пафоса про секурность и прочие ништяки.
Имхо пора на написание опенсорсного говнокода давать лицензию сродни водительским правам
+109
while(1) {
:cycle
goto cycleCode;
}
// ...
:cycleCode
//код
goto cycle;