- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
foreach ( $all_fields as $k => $one_field )
{
if ( $one_field['id'] == $field_id )
{
}
else
{
break;
}
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+169
foreach ( $all_fields as $k => $one_field )
{
if ( $one_field['id'] == $field_id )
{
}
else
{
break;
}
}
дзен-foreach
+135
//глубоко в коде
char output[1024];
//еще глубже
struct sockaddr_in outputa;
//...
if(sendto(s, output, 512, 0, (struct sockaddr *) &output, rsize) == SOCKET_ERROR) {
printf("Socket error: %i.\n", WSAGetLastError());
}
Долго-же я думал, почему оно вываливается с ошибкой 10047.
+154
public function getCurrentDomain()
{
$host = 'http://' . $_SERVER['HTTP_HOST'];
$folder = strstr($_SERVER['SCRIPT_NAME'], 'index.php', true);
if ($folder)
{
if ($folder[1] != '/')
$folder = '/' . $folder;
$host.=$folder;
}
if ($host[strlen($host)] != '/')
$host.='/';
return $host
}
Решил определить домен+папку(если она есть) из откуда работает скрипт. Спать пора, да?
Как-то оно не так должно быть.
+160
<?php
class security extends engine{
var $temp=array();
function getUserId(){
$hash=explode('::',$_COOKIE['site_hash']);
$id=$hash[0];
return $id;
}
function getUserSecurityAccess($id){
if(is_numeric($id)){
$id=rawurlencode($id);
$conn_id=mysql_connect('host','user','passwd');
mysql_select_db('database');
$q=mysql_query("SELECT groupid FROM `users`
WHERE id='".$id."'",$conn_id);
if($q){
if(mysql_numrows($q)!=0){
$result=@mysql_fetch_assoc($q);
return $result['group_id'];
}else{
return -1;
}
}else{
return -1;
}
mysql_close($conn_id);
}else{
return -1;
}
}
function checkUserPermission($module,$act){
#return true;
$this->temp=array();
$this->temp['_result']=0;
$this->temp['_uid']=explode('::',$_COOKIE['site_hash']);
$this->temp['_uid']=$this->temp['_uid'][0];
$this->temp['_gid']=$this->getUserSecurityAccess($this->temp['_uid']);
$this->temp['_conn_id']=mysql_connect('host','user','passwd');
mysql_select_db('database');
$this->temp['_q1']=mysql_query('SELECT perms'
.'FROM `secure_groups`'
.'WHERE id='.$this->temp['_gid']);
$this->temp['_access_stamp']=mysql_fetch_assoc($this->temp['_q1']);
$this->temp['_access_stamp']=$this->temp['_access_stamp']['perms'];
$this->temp['_access_stamp']=explode(';',$this->temp['_access_stamp']);
$this->temp['_access_stamp']=array_slice($this->temp['_access_stamp'],0,-1);
foreach($this->temp['_access_stamp'] as $this->temp['v']){
$this->temp['_mod_access']=explode(':',$this->temp['v']);
$this->temp['_mod_indefier']=$this->temp['_mod_access'][0];
if($this->temp['_mod_indefier']==$module){
$this->temp['_perms']=explode(',',$this->temp['_mod_access'][1]);
switch($act){
case 'r':
$this->temp['_result']=($this->temp['_perms'][0]==1)? 1:0;
break;
case 'w':
$this->temp['_result']=($this->temp['_perms'][1]==1)? 1:0;
break;
}
break;
}
}
mysql_close($conn_id);
return $this->temp['_result'];
}
}
?>
Понравилось окончание статьи
"Надеюсь, что мы скоро встретимся...
Кто хочет почитать остальные мои статьи - прошу на http://e-code.tnt43.com.
С уважением Карпенко Кирилл, глава IT-отдела ИНПП. "
+159
<?php
session_start();
DEFINE('trusteko', true);
@$l=$_GET['l'];
//echo md5('12345');
include_once "../admin/meta.php";
include_once ("../inc/setup.php");
include_once ("../inc/config.php");
$dbc=db_connect();
if(isset($_POST['reg']))
{
$query="SELECT * FROM `access` WHERE login='".$_POST['login']."' LIMIT 1";
$result = mysql_query($query,$dbc);
$row=mysql_fetch_array($result);
if (md5($_POST['passwd'])==$row['parol'] and $_POST['login']==$row['login'])
{
$_SESSION['passwd']=$_POST['passwd'];
$_SESSION['login']=$_POST['login'];
//////////////////
include "menu_text.php";
//////////////////
}
else
{
echo "<center><form action=\"\" method=\"post\" name=\"reg\">
<table style=\"width:400px; height:50px;border:1px;\" align=\"center\">
<tr><td colspan=\"2\" style=\"text-align:center\">Авторизация</td></tr>
<tr><td>Login:</td><td><input type=\"text\" name=\"login\"></td></tr>
<tr><td>Password:</td><td><input type=\"password\" name=\"passwd\"></td></tr>
<tr><Td colspan=\"2\"><input type=\"submit\" name=\"reg\" value=\"Вход\"></td></tr>
</table>
</form></center>";
}
}
if (isset($_SESSION['login']) and !isset($_POST['reg']))
{
$query="SELECT * FROM `access` WHERE login='".$_SESSION['login']."' LIMIT 1";
$result = mysql_query($query,$dbc);
$row=mysql_fetch_array($result);
if (md5($_SESSION['passwd'])==$row['parol'] and $_SESSION['login']==$row['login'])
{
//////////////////
include "menu_text.php";
//////////////////
}
}
if (!isset($_SESSION['login']) and !isset($_POST['reg']))
{
echo "<center><form action=\"\" method=\"post\" name=\"reg\">
<table style=\"width:400px; height:50px;border:1px;\" align=\"center\">
<tr><td colspan=\"2\" style=\"text-align:center\">Авторизация</td></tr>
<tr><td>Login:</td><td><input type=\"text\" name=\"login\"></td></tr>
<tr><td>Password:</td><td><input type=\"password\" name=\"passwd\"></td></tr>
<tr><Td colspan=\"2\"><input type=\"submit\" name=\"reg\" value=\"Вход\"></td></tr>
</table>
</form></center>";
}
?>
Мое, этому коду 2 года )
Веселая система авторизации.
Разумеется я так уже не пишу ;)
+134
$i=10000;
while(true)
{
$i--;
if ($i==0) break;
// Какойто код с $i
}
Выкопал в одном серьезном проекте. Так там что не цикл так while(true) c точками выхода по телу цикла..
+166
<?php
if (!isset($_REQUEST['page'])&&!isset($_REQUEST['story']))
{
header('Location: index.php');
exit;
}
$page = $_REQUEST['page'];
$story = intval($_REQUEST['story']);
include_once('db_fns.php');
include_once('header.php');
$handle = db_connect();
if($story)
{
$query = "select * from stories
where id = '$story' and
published is not null";
}
else
{
$query = "select * from stories
where page = '$page' and
published is not null
order by published desc";
}
$result = $handle->query($query);
while ($story = $result->fetch_assoc())
{
// headline
echo "<h2>{$story['headline']}</h2>";
//picture
if ($story['picture'])
{
echo '<div style="float:right; margin:0px 0px 6px 6px;">';
echo '<img src="resize_image.php?image=';
echo urlencode($story[picture]);
echo '&max_width=200&max_height=120" align = right/></div>';
}
// byline
$w = get_writer_record($story['writer']);
echo '<br /><p class="byline">';
echo $w[full_name].', ';
echo date('M d, H:i', $story['modified']);
echo '</p>';
// main text
echo $story['story_text'];
}
include_once('footer.php');
?>
Там еще много такого говнеца
http://www.ibm.com/developerworks/ru/library/l-php_mysql_10/index.html?S_TACT=105AGX99&S_CMP=GR01
На ЛОРе обсуждают http://www.linux.org.ru/news/doc/6002642
−94
mCharInfoContent.x += ( hexTile.x + hexTile.parent.x + hexTile.parent.parent.x + hexTile.parent.parent.parent.x );
mCharInfoContent.y += ( hexTile.y + hexTile.parent.y + hexTile.parent.parent.y + hexTile.parent.parent.parent.y );
Красота неописуемая, метод научного тыка в действии
+161
<?
$result = mysql_query("SELECT date, article, post_text FROM posts");
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
echo "<div class=\"block\">\n\t<span class=\"da_ar\" id=\"left\">\n\t\t".$row[0]."\n\t</span>\n\t<span class=\"da_ar\" id=\"right\">\n\t\t".$row[1]."\n\t</span>\n\t<div class=\"block_text\"><pre>\n".$row[2]."</pre>\n\t</div>\n</div>";
}
mysql_free_result($result);
?>
Да - да - да, все это в одну строчку...
Не совсем, конечно, говно, но все же:)
+175
// "Dedicated to the near-memory of Nev. Let's start remembering people while they're still alive."
// Nev's great contribution to dc++
while(1) break;
Вот такое можно увидеть в исходниках ядра DC++
https://github.com/negativ/eiskaltdcpp/blob/master/dcpp/DCPlusPlus.cpp#L60