- 1
<input type="submit" value="<?=lang('Send','Отправить')?>" />
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+163
<input type="submit" value="<?=lang('Send','Отправить')?>" />
Говнокод или нет?
+156
function __get($propertyName) {
....
if (!isset($propertyName[$this->propertyTable])) {
var_dump($this->propertyTable);
throw new Exception("Wrong property name \"$propertyName\"");
}
.....
}
Глубоко в дебрях...
+165
function is_bot() {
if (defined("IS_BOT")) {
return 1;
}
elseif (defined("IS_NOT_BOT")) {
return 0;
}
elseif (!defined("IS_BOT") and !defined("IS_NOT_BOT")) {
if (file_exists(INCLUDE_PATH."includes/core/is_bot.php")) {
require_once(INCLUDE_PATH."includes/core/is_bot.php");
if (function_exists('is_bot_real')) {
return is_bot_real();
}
else {
define("IS_NOT_BOT", true);
return 0;
}
}
else {
define("IS_NOT_BOT", true);
return 0;
}
}
else {
define("IS_NOT_BOT", true);
return 0;
}
}
PHPNuke, mainfile.php
+156
$div = false;
while (true) {
if ($div = !$div) {
// тут действие если четная итерация цикла
} else {
// тут если нечетная
}
}
ну, или так
for ($i=0, $div = true; $i<$max; $i++, $div = !$div){
if ($div) {
// тут действие если четная итерация цикла
} else {
// тут если нечетная
}
}
человек один говорит, что такая проверка на четность/нечетность - говно.
говно ли?
+109
if(!mysql_select_db($db_name,$data)){
print "<BR>";
echo mysql_error();
die();
}
Нашел в одном из движков онлайн игры
+152
$data = curl_init('http://'.$site.'/index/sub/');
curl_setopt($data, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($data, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($data, CURLOPT_POST, 1);
curl_setopt($data, CURLOPT_POSTFIELDS, $post);
curl_setopt($data, CURLOPT_HTTPHEADER, $headers);
curl_setopt($data, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($data, CURLOPT_CONNECTTIMEOUT,$timeout);
curl_setopt($data, CURLOPT_TIMEOUT,$timeout);
//curl_setopt($data, CURLOPT_COOKIEFILE, $cookie);
$data2 = curl_exec($data);
curl_close($data);
$return = iconv('utf-8','cp1251',$data2);
if (preg_match('/Неправильный логин или пароль/Ui',$return)) return FALSE; else return TRUE;
+157
<?php
set_time_limit(0);
Error_Reporting(E_ALL & ~E_NOTICE);
$mail = "@rambler.ru"; //e-mail или логин от контакта
$pass = ""; //пароль от контакта
$uids = "3,5,7,8,10,15,1955,54665,233254"; //кого проверяем
function get($link,$cookie){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$link);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
$otvet = curl_exec($ch);
curl_close($ch);
return $otvet;
}
$aut=file_get_contents('http://login.vk.com/?act=login&email='.urlencode($mail).'&pass='.urlencode($pass).'&expire=&vk=');
preg_match("/id=\'s\' value=\'(.*?)\'/",$aut,$sid);
$cookie="remixsid=$sid[1];";
$res=get("http://vkontakte.ru/feed2.php",$cookie);
$feed=json_decode($res);
$id=$feed->user->id;
$count = substr_count($uids,",");
$count = $count+1;
$sig=md5(''.$id.'api_id=35569fields=has_mobileformat=JSONmethod=getProfilesuids='.$uids.'v=2.0SRkM2ws8NQ');
$res=get("http://api.vkontakte.ru/api.php?api_id=35569&fields=has_mobile&format=JSON&method=getProfiles&uids=$uids&v=2.0&sig=$sig",$cookie);
preg_match_all("/uid\":(.*?),\"first_name\":\"(.*?)\",\"last_name\":\"(.*?)\",\"has_mobile\":(.*?)\}/",$res,$info);
for($i=0;$i<$count;$i) {
$qwe=$i++;
$uidx=$info[1][$qwe];
$first_name=$info[2][$qwe];
$last_name=$info[3][$qwe];
$has_mobile=$info[4][$qwe];
print iconv('utf-8', '866', "\n--------id$uidx: $first_name $last_name [$has_mobile]--------\n\n\n"); }
?>
http://volk.hx0.ru
+169
htaccess:
DirectoryIndex index.php
RewriteEngine on
RewriteBase /
RewriteRule ^0.html$ style/index.php
RewriteRule ^1.html$ style/index.php?id=register
RewriteRule ^2.html$ style/index.php?id=download
RewriteRule ^3.html$ style/index.php?id=top_chars
RewriteRule ^4.html$ style/index.php?id=who_online
RewriteRule ^5.html$ style/index.php?id=top_zeny
RewriteRule ^6.html$ style/index.php?id=top_mvp
RewriteRule ^7.html$ style/index.php?id=top_pvp
RewriteRule ^8.html$ style/index.php?id=top_guild
RewriteRule ^9.html$ style/index.php?id=who_sell_buy
RewriteRule ^10.html$ style/index.php?id=first_class
php:
<?php
$url = $REQUEST_URI;
$url2 = strlen($url);
if($url2 > 14) {
header("location: ./");
exit;
}
?>
Комментарий от автора:
"Да тут реврайт для того, чтобы превратить ссылки в одинаковую длину, а потом уже проверять длину ссылки, если больше нормы переадресиция на главную..."
+165
<script>
function build_view(){
$('div.content').append(""+ <?php $flag=false; foreach($work_meters as $work){?> "<div id=\"<?=$work->id?>\" style='margin-bottom:30px;' > <span class=\"name\"><?=$work->name?> </span> <div s\
tyle=\"display:inline;float:left\" align=\"left\" > <table class='data_table' style=\"margin-top:50px;\" id='table_<?=$work->id?>'> <tr> <td>дата</td><td>значение</td>"+ <?php if(in_array\
(5, $user->roles)) { ?> " <td></td> "+ <?php } ?> <?php while(list($key, $vals) = each($work->data)){ ?> " <tr><td><?=$vals[0]?></td> <td><?=$vals[1]?></td> "+ <?php if(in_array(5,\
$user->roles)) { ?> " <td><a onclick=\"delete_row(<?=$key?>, <?=$work->id?>)\" href='javascript:void(0);'>удалить</a></td> "+ <?php } ?> " </tr> "+ <?php } ?>" \
</tr> "+ <?php if(in_array(5, $user->roles)) { ?> " <tr><td><input type='text' name='date' size='7'/></td><td><input type='text' name='value' size='5'/></td><td><input type='button' value='\
добавить' onclick='add_data(<?=$work->id?>, $(this).parent().parent());'></td></tr> <tr><td colspan='3' style='text-align:right;'><input type='button' onclick='save(<?=$work->id?>);' value='\
сохранить'></td></tr> "+ <?php } ?> " </table> </div> <div style=\"width:600px;height:300px;margin-left:120px;\" class=\"image\"> </div> <div class=\"description\" style='margin-top\
=10px;'> <?=$work->description?> </div> </div>"+ <?php $flag = true;} ?>"" );
}
</script>
эта ересь генерирует html для javascript функции которая втсавляет это всё в страницу.
+157
/**********************************************************************
* Connect to DB - over-ridden by specific DB class
*/
function connect()
{
die(EZSQL_CORE_ERROR);
}
/**********************************************************************
* Select DB - over-ridden by specific DB class
*/
function select()
{
die(EZSQL_CORE_ERROR);
}
/**********************************************************************
* Basic Query - over-ridden by specific DB class
*/
function query()
{
die(EZSQL_CORE_ERROR);
}
/**********************************************************************
* Format a string correctly for safe insert - over-ridden by specific
* DB class
*/
function escape()
{
die(EZSQL_CORE_ERROR);
}
/**********************************************************************
* Return database specific system date syntax
* i.e. Oracle: SYSDATE Mysql: NOW()
*/
function sysdate()
{
die(EZSQL_CORE_ERROR);
}
Продвинутый способ создания абстрактных методов. Это кагбе абстрактный класс, от которого наследуются БД-специфичные классы. Затем какая вам БД нужна, под такую руками и создавайте экземпляр нужного класса, "фабрикой" даже и не пахнет.
Зовётся сие чудо ezSQL. Используется в NetCat. Ладно хоть не сами наложили (налажали?), но всё ж головой не подумали, когда брали.