- 1
- 2
- 3
- 4
if ($i++%2==0)
$bgc='#eeeeee';
else
$bgc='#cccccc';
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+147.8
if ($i++%2==0)
$bgc='#eeeeee';
else
$bgc='#cccccc';
Самое интересное, что инкремент производится после прохождения проверки
+153
function strum($text, $simb)
{
if(mb_strlen($text, 'UTF-8') > $simb){
}
if(mb_strlen($text, 'UTF-8') > $simb)
{
$start = 0;
for($i = 0; $i <= (ceil(mb_strlen($text, 'UTF-8') / $simb)); $i++)
{
$tmp = mb_strpos($text, '. ', $start + $simb, 'UTF-8');
if(is_numeric($tmp))
{
$num[] = $tmp;
}
$tmp = mb_strpos($text, '! ', $start + $simb, 'UTF-8');
if(is_numeric($tmp))
{
$num[] = $tmp;
}
$tmp = mb_strpos($text, '? ', $start + $simb, 'UTF-8');
if(is_numeric($tmp))
{
$num[] = $tmp;
}
if($num != '')
{
$end = min($num) + 1;
}
if($end <= $start)
{
$end = mb_strlen($text, 'UTF-8');
}
$str = mb_substr($text, $start, $end, 'UTF-8');
$string[] = mb_substr($str, 0, ($end - $start), 'UTF-8');
$start = $end;
unset($num);
unset($str);
unset($tmp);
if($end == mb_strlen($text, 'UTF-8'))
{
break;
}
}
}
else
{
$string[] = $text;
}
return $string;
}
Функция для умной разбивки
+153
<?php
$thelist = array();
$dir = './upload/ftp/';
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && $file !="index.php" && $file !=".ftpquota") {
$file = $file;
$thelist[] = array('file' => $file, 'filemtime' => filemtime($file), 'filesize' => filesize($file));
}
}
closedir($handle);
}
?>
<?php
for($i = 0; $i < count($thelist); $i++) {
?><a href="sitename/<?=$thelist[$i]['file']?>"><?=$thelist[$i]['file']?></a><?php
}
?>
+156
<?
$i=$var = null;
function NullPointerShare(&$vv)
{
for (;;)
{
$i=$vv;
$i++;
if ($i==20)
{
$i=null;
die (NullPointerShare($i));
}else if ($i<20){
$ix=19;
die (NullPointerShare($ix));
}
}
return $vv;
}
die ("--> ".NullPointerShare($var));
?>
Без коментов:)
+157
<?php
// AI для jabber-бота http://coolbot.vndv.com
// Автор AI: Black.ZerO
$db = mysql_connect($dbhost, $dbuser, $dbpasswd) or die("MySQL error");
mysql_select_db($dbname, $db);
$result = mysql_query("select * from mozg", $db);
$myrow = mysql_fetch_array($result);
$messages['body'] = "Hello";
do
{
if ($messages['body'] == $myrow[question])
{
echo "OK";
break;
}
else {
echo "false";
}
}
while ($myrow = mysql_fetch_array($result));
AI для jabber-бота http://coolbot.vndv.com
+155
$cnt_ = count($array_objects['rate']);
for($i=0; $i<$cnt_; $i++) {
//...
}
$DB->query('REPAIR TABLE `' . $rates_table . '` QUICK;');
Кусок скрипта для импорта данных из XML...
+152
// phpBB 3.0.x auto-generated configuration file
// Do not change anything in this file!
include_once dirname(dirname (dirname (__FILE__)))."/conf/config.php";
Мегакод
+153.1
function filterVar($value)
{
if (get_magic_quotes_gpc())
{
$value = stripslashes($value);
}
$value = strip_tags($value); //режем теги.
$value = preg_replace('%(<[^>]*(>|$)|>)%e', '', $value);
return str_replace(array("\n", "\r"), array(' ', ''), $value);
}
foreach ($_GET as $reqValue)
{
$reqValue = is_array($reqValue) ? array_filter($reqValue, 'filterVar') : filterVar($reqValue);
}
$_REQUEST = array_merge ($_GET,$_POST);
это меня вывело из себя
+158.2
$step = ($item / 10);
$step = explode(".", $step);
$j = ($step[0] * 10 + 1);
Округляем хуле %)
+156
test
test