- 1
- 2
- 3
- 4
- 5
// Чистим мусор и дубликаты
foreach ($phones as $i => $p1){
foreach ($phones as $j => $p2){
if ($i = $j) continue;
...
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+157
// Чистим мусор и дубликаты
foreach ($phones as $i => $p1){
foreach ($phones as $j => $p2){
if ($i = $j) continue;
...
Все же и я наступил на эти грабли.
+154
<?php
for($tb=0;$tb<=10;$tb++){
switch($tb){
case 0: $number_table=3; $cros_table=20;
break;
case 1:$number_table+=19; $cros_table+=20;
break;
case 2:$number_table+=20; $cros_table+=20;
break;
case 3:$number_table+=20; $cros_table+=20;
break;
case 4:$number_table+=20; $cros_table+=20;
break;
case 5:$number_table+=20; $cros_table+=20;
break;
case 6:$number_table+=20; $cros_table+=20;
break;
case 7:$number_table+=20; $cros_table+=20;
break;
case 8:$number_table+=20; $cros_table+=20;
break;
case 9:$number_table+=20; $cros_table+=20;
break;
case 10:$number_table+=20; $cros_table+=20;
break;
}
for($i=$number_table; $i<=$cros_table; $i++){
$name_detail = $data->sheets[$global_page]['cells'][$i][1];
$option_detail = $data->sheets[$global_page]['cells'][$i][2];
$mark_detail = $data->sheets[$global_page]['cells'][$i][3];
$actions = $data->sheets[$global_page]['cells'][$i][4];
$work_cost = $data->sheets[$global_page]['cells'][$i][5];
$detail_cost = $data->sheets[$global_page]['cells'][$i][6];
if($name_detail==null){break;}
?>
Когда я это узрел я усомнился в адекватности человека...
+154
class Key{
private $chars = array('1'=>'a','2'=>'b','3'=>'c','4'=>'d','5'=>'e','6'=>'f','7'=>'g','8'=>'h','9'=>'i');
private $invChars = array('9'=>'a','8'=>'b','7'=>'c','6'=>'d','5'=>'e','4'=>'f','3'=>'g','2'=>'h','1'=>'i');
private $key = "";
private $numbers = array();
public function createKey(){
for($a=0;$a<4;$a++){
$this->numbers[0] = rand(1, 9);
$this->numbers[1] = rand(1, 9);
$this->key .= $this->numbers[0].$this->invChars[$this->numbers[1]].$this->numbers[1].$this->chars[$this->numbers[0]]."-";
}
return substr_replace($this->key, '', 19, 1);
}
public function checkKey($key){
if(preg_match("/^([1-9][a-iA-I][1-9][a-iA-I][\-][1-9][a-iA-I][1-9][a-iA-I][\-][1-9][a-iA-I][1-9][a-iA-I][\-][1-9][a-iA-I][1-9][a-iA-I])$/", $key)){
$key = str_replace('-', '', $key);
if($this->chars[$key[0]] == $key[3] && $this->invChars[$key[2]] == $key[1]){
if($this->chars[$key[4]] == $key[7] && $this->invChars[$key[6]] == $key[5]){
if($this->chars[$key[8]] == $key[11] && $this->invChars[$key[10]] == $key[9]){
if($this->chars[$key[12]] == $key[15] && $this->invChars[$key[14]] == $key[13]){
return true;
}
else{
return false;
}
}
else{
return false;
}
}
else{
return false;
}
}
else{
return false;
}
}
else{
return false;
}
}
}
Особенно регулярка...
+152
<?php
//Скрипт расчета времени.
foreach ($_POST as $k=>$v) $$k=$v;
if (!$to_month and !$to_day and !$to_year and !$to_hours and !$to_minutes and !$to_seconds) {
echo "<h1>Введите данные для расчета</h1>";
}
else {
$to_time = mktime(intval($to_hours),intval($to_minutes),intval($to_seconds),intval($to_month),intval($to_day),intval($to_year)) ;
$from_time = mktime(intval($from_hours),intval($from_minutes),intval($from_seconds),intval($from_month),intval($from_day),intval($from_year)) ;
$time = $to_time - $from_time;
echo
"От $from_month/$from_day/$from_year $from_hours:$from_minutes:$from_seconds
<br>До $to_month/$to_day/$to_year $to_hours:$to_minutes:$to_seconds
<br>Миллисекунд: ",$time*1000,"
<br>Секунд: ",$time,"
<br>Минут: ",$time/60,"
<br>Часов: ",$time/3600,"
<br>Дней: ",$time/86400,"
<br>Недель: ",$time/604800,"
<br>Месяцев: ",$time/2628000,"
<br>Лет: ",$time/31536000; //31557600 по Юлианскому.
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Сколько времени пройдет от и до</title>
<style>
body {
margin-left: 38%;
font-family: Verdana, Arial, Helvetica, sans-serif;
}
h1 {
font-size: 90%;
color: #333366;
}
input {
margin: 2px;
padding: 2px;
width: 200px;
}
h2 {
font-size: 70%;
color: #333366;
}
p {
font-size: 60%;
color: #f00;
}
</style>
</head>
<body>
<h2>Задайте время от:</h2>
<form method="post" target="_blank" action="date.php">
<input type="text" name="from_year" value="<?=date('Y')?>"> Год<br>
<input type="text" name="from_month" value="<?=date('m')?>"> Месяц<br>
<input type="text" name="from_day" value="<?=date('d')?>"> День<br>
<input type="text" name="from_hours" value="<?=date('G')?>"> Час<br>
<input type="text" name="from_minutes" value="<?=date('i')?>"> Минут<br>
<input type="text" name="from_seconds" value="<?=date('s')?>"> Секунд
<h2>Задайте время до:</h2>
<input type="text" name="to_year"> Год<br>
<input type="text" name="to_month"> Месяц<br>
<input type="text" name="to_day"> День<br>
<input type="text" name="to_hours"> Час<br>
<input type="text" name="to_minutes"> Минут<br>
<input type="text" name="to_seconds"> Секунд<br>
<input type="submit" value="Рассчитать">
</form>
<p>* Заполнять все поля не обязательно.<br>** Расчеты для лет верны если год - 365 дней.</p>
</body>
</html>
Лаксори эдишен
+163
require_once('bbcode.php');
$bbcode_ = $bbcode;
global $bbcode;
$bbcode = $bbcode_;
bbcode_format($text);
При этом:
function bbcode_format($str, $bbcode = false)
+88
#include <cstdlib>
#include <ctime>
main(){
srand((unsigned)time(NULL));
int x = 1^~0-(((1+&x?2||0:(~1))-(1 & 2)*.1-(1+-1?5:3)%1)==0?10:-rand()%5+1);
return 0;
}
perl'овцы развлекаются.
+155
http://govnokod.reformal.ru/proj/govnokod?ia=613048
надеюсь, меня поддержат
+130
catch (Exception e)
{
CommonAPI.SetErrorApp(0, MethodBase.GetCurrentMethod().DeclaringType.Name + "." + MethodBase.GetCurrentMethod().Name, e.Message);
#if DEBUG
throw e;
#else
return 0;
#endif
}
+151
var el = jQuery(this);
if(el.html().length<1){
el.prev().find('div').addClass('over');
var url = jQuery(jQuery(el.prev().children()[0]).children()[1]).attr('href');
url = url.replace('index.php', '')+'?ajax=1';
//url = url.replace(/&task=[^&]+/, '&task=subcatalogs');
el.html(jQuery.ajax({
url: url,
async: false
}).responseText);
var list = jQuery(el.children()[0]);
list.find('.parent').each(function(i,item){
jQuery(item).bind('click', catalogs_click);
jQuery(item).bind('mouseover', catalogs_mouseover);
jQuery(item).bind('mouseout', catalogs_mouseout);
jQuery(item).prev().bind('mouseover', catalogs_mouseover2);
jQuery(item).prev().find('div').bind('mouseover', catalogs_mouseover3);
jQuery(item).prev().find('div a').bind('mouseover', catalogs_mouseover4);
jQuery(item).prev().find('div img').bind('mouseover', catalogs_mouseover5);
});
list.find('.final').each(function(i,item){
jQuery(item).bind('mouseover', catalogs_mouseover6).bind('mouseout', catalogs_mouseout6);
jQuery(item).find('div').bind('mouseover', catalogs_mouseover7).bind('mouseout', catalogs_mouseout7);
jQuery(item).find('div a').bind('mouseover', catalogs_mouseover8).bind('mouseout', catalogs_mouseout8);
jQuery(item).find('div img').bind('mouseover', catalogs_mouseover9).bind('mouseout', catalogs_mouseout9);
});
list.show();
}else{
var list = jQuery(el.children()[0]);
if(!list.children().find('div').hasClass('over')){
el.prev().find('div').addClass('over');
}
list.show();
}
Взялся за проект на фрилансе...
+160
<a href="javascript:;" class="detail_back_link" ahref="/services_catalog/appl_list.php?SECTION=<?=$arResult["Block"]["ID"]?>"></a>
Добавить атрибут ahref к тегу <a> ??? Фантазер-разработчик. И написать href="javascript:;"........
Караул.