- 1
var x = _.without.bind(_, someArray).apply(_, anotherArray);
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+142
var x = _.without.bind(_, someArray).apply(_, anotherArray);
Человек не был знаком с методом difference в underscore
+142
<?php
class ModelCheckoutOrder extends Model {
public function addOrder($data) {
$this->event->trigger('pre.order.add', $data);
$this->db->query("INSERT INTO `" . DB_PREFIX . "order` SET invoice_prefix = '" . $this->db->escape($data['invoice_prefix']) . "', store_id = '" . (int)$data['store_id'] . "', store_name = '" . $this->db->escape($data['store_name']) . "', store_url = '" . $this->db->escape($data['store_url']) . "', customer_id = '" . (int)$data['customer_id'] . "', customer_group_id = '" . (int)$data['customer_group_id'] . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', fax = '" . $this->db->escape($data['fax']) . "', custom_field = '" . $this->db->escape(isset($data['custom_field']) ? serialize($data['custom_field']) : '') . "', payment_firstname = '" . $this->db->escape($data['payment_firstname']) . "', payment_lastname = '" . $this->db->escape($data['payment_lastname']) . "', payment_company = '" . $this->db->escape($data['payment_company']) . "', payment_address_1 = '" . $this->db->escape($data['payment_address_1']) . "', payment_address_2 = '" . $this->db->escape($data['payment_address_2']) . "', payment_city = '" . $this->db->escape($data['payment_city']) . "', payment_postcode = '" . $this->db->escape($data['payment_postcode']) . "', payment_country = '" . $this->db->escape($data['payment_country']) . "', payment_country_id = '" . (int)$data['payment_country_id'] . "', payment_zone = '" . $this->db->escape($data['payment_zone']) . "', payment_zone_id = '" . (int)$data['payment_zone_id'] . "', payment_address_format = '" . $this->db->escape($data['payment_address_format']) . "', payment_custom_field = '" . $this->db->escape(isset($data['payment_custom_field']) ? serialize($data['payment_custom_field']) : '') . "', payment_method = '" . $this->db->escape($data['payment_method']) . "', payment_code = '" . $this->db->escape($data['payment_code']) . "', shipping_firstname = '" . $this->db->escape($data['shipping_firstname']) . "', shipping_lastname = '" . $this->db->escape($data['shipping_lastname']) . "', shipping_company = '" . $this->db->escape($data['shipping_company']) . "', shipping_address_1 = '" . $this->db->escape($data['shipping_address_1']) . "', shipping_address_2 = '" . $this->db->escape($data['shipping_address_2']) . "', shipping_city = '" . $this->db->escape($data['shipping_city']) . "', shipping_postcode = '" . $this->db->escape($data['shipping_postcode']) . "', shipping_country = '" . $this->db->escape($data['shipping_country']) . "', shipping_country_id = '" . (int)$data['shipping_country_id'] . "', shipping_zone = '" . $this->db->escape($data['shipping_zone']) . "', shipping_zone_id = '" . (int)$data['shipping_zone_id'] . "', shipping_address_format = '" . $this->db->escape($data['shipping_address_format']) . "', shipping_custom_field = '" . $this->db->escape(isset($data['shipping_custom_field']) ? serialize($data['shipping_custom_field']) : '') . "', shipping_method = '" . $this->db->escape($data['shipping_method']) . "', shipping_code = '" . $this->db->escape($data['shipping_code']) . "', comment = '" . $this->db->escape($data['comment']) . "', total = '" . (float)$data['total'] . "', affiliate_id = '" . (int)$data['affiliate_id'] . "', commission = '" . (float)$data['commission'] . "', marketing_id = '" . (int)$data['marketing_id'] . "', tracking = '" . $this->db->escape($data['tracking']) . "', language_id = '" . (int)$data['language_id'] . "', currency_id = '" . (int)$data['currency_id'] . "', currency_code = '" . $this->db->escape($data['currency_code']) . "', currency_value = '" . (float)$data['currency_value'] . "', ip = '" . $this->db->escape($data['ip']) . "', forwarded_ip = '" . $this->db->escape($data['forwarded_ip']) . "', user_agent = '" . $this->db->escape($data['user_agent']) . "', accept_language = '" . $this->db->escape($data['accept_language']) . "', date_added = NOW(), date_modified = NOW()");
Я вас еще немного помучаю, хорошо?
3978 символов, считая отступы
https://github.com/opencart/opencart/blob/d5f66b0d75a5adf35815e333e45598bbc38750d0/upload/catalog/model/checkout/order.php#L6
+141
char chByte15[3] = { pchCodeKey[0x15 * 2], pchCodeKey[0x15 * 2 + 1], 0 };
char chByte16[3] = { pchCodeKey[0x16 * 2], pchCodeKey[0x16 * 2 + 1], 0 };
char chByte18[3] = { pchCodeKey[0x18 * 2], pchCodeKey[0x18 * 2 + 1], 0 };
unsigned char uchByte15h;
unsigned char uchByte16h;
unsigned char uchByte18h;
uchByte15h = strtoul(chByte15, NULL, 16);
uchByte16h = strtoul(chByte16, NULL, 16);
uchByte18h = strtoul(chByte18, NULL, 16);
все забыли про scanf()...
+146
if(isset($_GET['go']))
$go = htmlspecialchars(strip_tags(stripslashes(trim(urldecode(mysql_escape_string($_GET['go']))))));
else
$go = "main";
// ....
switch($go){
"Тыыыыыыы не пройдеееешь!". Зафильтровали (да ещё и криво) бедную переменную только для того, чтобы потом использовать её в switch-case блоке. Индусы-паникеры.
+142
(function($){
function pickMenuByHash(hash) {
if(hash == undefined || hash == '' || hash == '#')
hash = '#home'; // хеш по умолчанию
// Выбираем ссылки с нужным хешем, чтро бы потом присвоить им класс "active"
var A_tags = $('a[href="' + hash + '"]');
// Ищем все ссылки в родительском теге UL относительно ссылок и удаляем у них классы "active"
A_tags.parents('UL').find('a').removeClass('active');
// Добавляем к ссылкам с нужным нам хешем класс "active"
$('a[href="' + hash + '"]').addClass('active');
}
// Обновить состояние менюшек (сверху и справа) при загрузке страницы
$(function(){
pickMenuByHash(document.location.hash);
});
// При изменении хеша обновить состояния менюшек (сверху и справа)
$(window).on('hashchange', function(){
pickMenuByHash(document.location.hash);
});
})(jQuery);
Вот тебе при изменении хеша на сайте верхнее и правое меню будет в актуальном для хеша состоянии.
+141
const char *pS;
char *pD;
// clear out new string
szNew[0] = '\0';
pS = pszValue;
pD = szNew;
// step through the string, only copying back in characters that are printable
while( *pS )
{
if( ((byte)*pS) < 32 || ((byte)*pS) > 255 )
{
pS++;
continue;
}
*pD++ = *pS++;
}
// terminate the new string
*pD = '\0';
Мало того, char в проекте подразумевается signed
+143
if(!$user['email']) {
$err = $this->system_message->getLang('empty_email');
} elseif(strlen($user['email']) < self::MIN_USER_NAME) {
$err = $this->system_message->getLang('small_email');
} elseif(strlen($user['email']) > self::MAX_USER_NAME) {
$err = $this->system_message->getLang('long_email');
} elseif(!filter_var($user['email'], FILTER_VALIDATE_EMAIL)) {
$err = $this->system_message->getLang('incorrect_name');
}
if(!$user['passw']) {
$err = $this->system_message->getLang('empty_passw');
} elseif(strlen($user['passw']) < self::MIN_PASSWORD_NAME) {
$err = $this->system_message->getLang('small_passw');
} elseif(strlen($user['passw']) > self::MAX_PASSWORD_NAME) {
$err = $this->system_message->getLang('long_passw');
}
if($err) {
//!TODO add a exeption
} else {
$find_email = $this->db_users->prepare("SELECT * FROM `users` WHERE `email` = :email");
$find_email->execute(array(':email' => $user['email']));
Мдэээ...
+140
<?php
/**
* @desc Локализация сайта
*
**/
class System_Message{
private function openLangFail($lang){
$path = '/../message/'.$lang.'.php';
if (file_exists($path)) {
return 'File with languages not found';
} else {
return include $path;
}
}
public function getLang($value, $lang='ru'){
$lang = self::openLangFail($lang);
if($lang[$value] != '') {
return $lang[$value];
} else {
return false;
}
}
}
Ну как?
+143
public enum WebViewImageType {
Back = 0,
Close = 1,
Menu = 2
}
WebViewImageType GetImageType(int jsType){
switch (jsType) {
case 0:
return WebViewImageType.Back;
case 1:
return WebViewImageType.Close;
case 2:
return WebViewImageType.Menu;
default:
return WebViewImageType.Back;
}
}
+48
auto filename = std::string{};