- 1
- 2
- 3
...
$ORDER_ID = urldecode(urldecode($_REQUEST["ORDER_ID"]));
...
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+159
...
$ORDER_ID = urldecode(urldecode($_REQUEST["ORDER_ID"]));
...
битрикс :)
+159
var existingDates=new Array();
existingDates[11]=new Array();
existingDates[11][3]=[10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28];
existingDates[11][4]=[3,4,5,6,7,8,10,11,12,13,14,15,16,17,18,19,21,22,23,24,25,26,28,29,30,31];
existingDates[11][5]=[1,2,4,5,6,7,8,9,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30];
existingDates[11][6]=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31];
existingDates[11][7]=[1,2,3,4,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31];
existingDates[11][8]=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30];
existingDates[11][9]=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31];
existingDates[11][10]=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30];
existingDates[11][11]=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31];
/*... */
existingDates[24][1]=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28];
existingDates[24][2]=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31];
existingDates[24][3]=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30];
existingDates[24][4]=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31];
existingDates[24][5]=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30];
existingDates[24][6]=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31];
existingDates[24][7]=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31];
existingDates[24][8]=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30];
existingDates[24][9]=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31];
existingDates[24][10]=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30];
existingDates[24][11]=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31];
existingDates[25]=new Array();
existingDates[25][0]=[5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31];
existingDates[25][1]=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28];
existingDates[25][2]=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31];
existingDates[25][3]=[1];
/* ... */
Src: http://www.kommersant.ru/archive/news/77/2015-04-01
+159
public function getProductAttributes($product_id) {
$product_attribute_data = array();
$product_attribute_query = $this->db->query("SELECT attribute_id FROM " . DB_PREFIX . "product_attribute WHERE product_id = '" . (int)$product_id . "' GROUP BY attribute_id");
foreach ($product_attribute_query->rows as $product_attribute) {
$product_attribute_description_data = array();
$product_attribute_description_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_attribute WHERE product_id = '" . (int)$product_id . "' AND attribute_id = '" . (int)$product_attribute['attribute_id'] . "'");
foreach ($product_attribute_description_query->rows as $product_attribute_description) {
$product_attribute_description_data[$product_attribute_description['language_id']] = array('text' => $product_attribute_description['text']);
}
$product_attribute_data[] = array(
'attribute_id' => $product_attribute['attribute_id'],
'product_attribute_description' => $product_attribute_description_data
);
}
return $product_attribute_data;
}
Opencart -> ModelCatalogProduct -> getProductAttributes
Первым запросом в БД они берут IDы атрибутов, перебирают их циклом, в котором другим запросом берут всё, в том числе и те же IDы, из той же таблицы и снова перебирают строки циклом.
+159
$home = $jsClass = $benchmark = $showAtom = $mainJS = $author = $update = $nameError = $mailError = $msgError = $slugError = $spamError = $codeError = $codeTitleError = $titleError = $error = $author = $authorEmail = $authorURL = $ga = $embed = $noIndex = false;
Зачем?
Отсюда:
https://github.com/mathiasbynens/jsperf.com/blob/master/index.php#L25
+159
string http_build_url ([ mixed $url [, mixed $parts [, int $flags = HTTP_URL_REPLACE [, array &$new_url ]]]] )
Parameters
url
(part(s) of) an URL in form of a string or associative array like parse_url() returns
parts
same as the first argument
волшебно
+159
$this->vars['cookie_domain'] = $this->vars['cookie_domain'] == "" ? "" : $this->vars['cookie_domain'];
Из IPB от 2007 года, по следам индусского неизвестного классика.
Если cookie_domain = "", то пусть будет "", а если нет, то и хуй с ним, пусть остается как есть.
+159
if (1) {
define("IMGBASE","");
define("IMGNUM","");
} else {
define("IMGBASE","imgs");
define("IMGFN","_rm");
}
Может я плохой программист, а это не говнокод??? Но таких условий в проекте миллионы блядь!
+159
function getProductIds(text, containerId) {
var products = new Array();
var valueFound = false;
var start = 0;
var end = 0;
var itemCount = 0;
var curChar = 0;
var readStart = text.indexOf(containerId);
var triggerChar = ">";
while (valueFound == false) {
if (text.substring(readStart + curChar, readStart + curChar + triggerChar.length) == triggerChar)
valueFound = true;
else
curChar++;
}
start = readStart + curChar + 1;
valueFound = false;
triggerChar = "</div>";
while (valueFound == false) {
if (text.substring(readStart + curChar, readStart + curChar + triggerChar.length) == triggerChar)
valueFound = true;
else
curChar++;
}
end = readStart + curChar;
var itemsHtml = text.substring(start, end).replace(" ", "").replace("\n", "");
curChar = 0;
triggerChar = "ProductId";
while (curChar < itemsHtml.length) {
if (itemsHtml.substring(curChar, curChar + triggerChar.length) == triggerChar)
itemCount++;
curChar++;
}
for (var curItem = 1; curItem <= itemCount; curItem++) {
var product = new Array();
product[0] = getValue(itemsHtml, "LineItem_" + curItem + "_ProductId", "value=\"", "\"", 1);
product[1] = getValue(itemsHtml, "LineItem_" + curItem + "_ProductName", "value=\"", "\"", 1);
product[2] = getValue(itemsHtml, "LineItem_" + curItem + "_Quantity", "value=\"", "\"", 1);
product[3] = getValue(itemsHtml, "LineItem_" + curItem + "_UnitPrice", "value=\"", "\"", 1);
products[curItem - 1] = product;
}
return products;
}
Шедевральный код. Работают с HTML даже не на нативном js, а как с обычной строкой. Правильно, зачем париться - строки знают все :)
PS Код не мой. Однако стоит отметить, что он успешно используется на реальных сайтах :)
+159
/**
* @package mod_jlcurrency
* @author Zhukov Artem ([email protected])
* @version 1.1
* @copyright (C) 2012 by JoomLine (http://www.joomline.net)
* @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
*
*/
// No direct access
defined('_JEXEC') or die('Restricted access');
$vl = array();
$vl[$params->get('JPY')]=$params->get('JPY');$vl[$params->get('ZAR')]=$params->get('ZAR');
$vl[$params->get('KRW')]=$params->get('KRW');$vl[$params->get('CHF')]=$params->get('CHF');
$vl[$params->get('SEK')]=$params->get('SEK');$vl[$params->get('CZK')]=$params->get('CZK');
$vl[$params->get('UAH')]=$params->get('UAH');$vl[$params->get('UZS')]=$params->get('UZS');
$vl[$params->get('TRY')]=$params->get('TRY');$vl[$params->get('TMT')]=$params->get('TMT');
$vl[$params->get('TJS')]=$params->get('TJS');$vl[$params->get('SGD')]=$params->get('SGD');
$vl[$params->get('XDR')]=$params->get('XDR');$vl[$params->get('RON')]=$params->get('RON');
$vl[$params->get('PLN')]=$params->get('PLN');$vl[$params->get('NOK')]=$params->get('NOK');
$vl[$params->get('MDL')]=$params->get('MDL');$vl[$params->get('LTL')]=$params->get('LTL');
$vl[$params->get('LVL')]=$params->get('LVL');$vl[$params->get('CNY')]=$params->get('CNY');
$vl[$params->get('KGS')]=$params->get('KGS');$vl[$params->get('CAD')]=$params->get('CAD');
$vl[$params->get('KZT')]=$params->get('KZT');$vl[$params->get('INR')]=$params->get('INR');
$vl[$params->get('EUR')]=$params->get('EUR');$vl[$params->get('USD')]=$params->get('USD');
$vl[$params->get('DKK')]=$params->get('DKK');$vl[$params->get('HUF')]=$params->get('HUF');
$vl[$params->get('BRL')]=$params->get('BRL');$vl[$params->get('BGN')]=$params->get('BGN');
$vl[$params->get('BYR')]=$params->get('BYR');$vl[$params->get('AMD')]=$params->get('AMD');
$vl[$params->get('GBP')]=$params->get('GBP');$vl[$params->get('AZN')]=$params->get('AZN');
$vl[$params->get('AUD')]=$params->get('AUD');
Эмм. Это так и должно быть?
+159
/**
* Дублирование пароля в поле CONFIRM_PASSWORD.
*/
function removeConfirmPasswordField()
{
$arFields = filter_input(INPUT_POST, 'REGISTER', FILTER_DEFAULT , FILTER_REQUIRE_ARRAY);
if($arFields)
{
$arKeys = array_keys($arFields);
$arNeedKeys = array('PASSWORD', 'CONFIRM_PASSWORD');
if(count(array_intersect($arKeys, $arNeedKeys)) === count($arNeedKeys))
{
$_POST['REGISTER']['CONFIRM_PASSWORD'] = $_POST['REGISTER']['PASSWORD'];
$_REQUEST['REGISTER']['CONFIRM_PASSWORD'] = $_REQUEST['REGISTER']['PASSWORD'];
}
}
}
AddEventHandler('main', 'OnBeforeProlog', 'removeConfirmPasswordField');
Вот таким способом я дублирую значение поля ввода пароля в поле для его подтверждения...