- 1
- 2
- 3
- 4
- 5
public static function compress($data, $options = null)
{
return (new static)
->html_compress($data, $options);
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
Всего: 99
+142
public static function compress($data, $options = null)
{
return (new static)
->html_compress($data, $options);
}
Расширяшка для Yii2, экономия байтов
https://github.com/rmrevin/yii2-minify-view
+143
/**
* Returns the first line of docblock.
*
* @param \Reflector $reflection
* @return string
*/
protected function parseDocCommentSummary($reflection)
{
$docLines = preg_split('~\R~u', $reflection->getDocComment());
if (isset($docLines[1])) {
return trim($docLines[1], "\t *");
}
return '';
}
/**
* Returns full description from the docblock.
*
* @param \Reflector $reflection
* @return string
*/
protected function parseDocCommentDetail($reflection)
{
$comment = strtr(trim(preg_replace('/^\s*\**( |\t)?/m', '', trim($reflection->getDocComment(), '/'))), "\r", '');
if (preg_match('/^\s*@\w+/m', $comment, $matches, PREG_OFFSET_CAPTURE)) {
$comment = trim(substr($comment, 0, $matches[0][1]));
}
if ($comment !== '') {
return rtrim(Console::renderColoredString(Console::markdownToAnsi($comment)));
}
return '';
}
Yii2, SOLID, очередной класс консольного приложения, который делает все подряд и хуево
https://github.com/yiisoft/yii2/blob/47bcd020fff582395db8fe9e00598acad0257922/framework/console/Controller.php#L481-L512
+140
http://phpocean.com/tutorials/back-end/create-your-first-desktop-application-with-php-and-php-desktop/4
верстка самого сайта, phpdesktop, zooboole - у меня жестко бортануло
+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
+165
// Whoever introduced xml to shipping companies should be flogged
$xml = '<?xml version="1.0"?>';
$xml .= '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://fedex.com/ws/rate/v10">';
$xml .= ' <SOAP-ENV:Body>';
$xml .= ' <ns1:RateRequest>';
$xml .= ' <ns1:WebAuthenticationDetail>';
// почти сотня строк
$xml .= '</SOAP-ENV:Envelope>';
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $xml);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
Смотри-ка, оно еще и ругается
https://github.com/opencart/opencart/blob/58eeb544e2eddbe18b00224e10d2761259e8ce7b/upload/catalog/model/shipping/fedex.php#L48
+142
public function api() {
...
if ($this->validate()) {
if ($store_info) {
$url = $store_info['ssl'];
} else {
$url = HTTPS_CATALOG;
}
if (isset($this->session->data['cookie']) && isset($this->request->get['api'])) {
...
$curl = curl_init();
// Set SSL if required
if (substr($url, 0, 5) == 'https') {
curl_setopt($curl, CURLOPT_PORT, 443);
}
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLINFO_HEADER_OUT, true);
curl_setopt($curl, CURLOPT_USERAGENT, $this->request->server['HTTP_USER_AGENT']);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_FORBID_REUSE, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_URL, $url . 'index.php?route=' . $this->request->get['api'] . ($url_data ? '&' . http_build_query($url_data) : ''));
if ($this->request->post) {
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($this->request->post));
}
curl_setopt($curl, CURLOPT_COOKIE, session_name() . '=' . $this->session->data['cookie'] . ';');
$json = curl_exec($curl);
curl_close($curl);
API в опенкарте. Ну, короч, приходит пользователь, дергает АПИ, а я сам в контроллере дергаю свое АПИ. Такая практика.
https://github.com/opencart/opencart/blob/4a151334efc702729071bd8d45a7e4af4e07b3ef/upload/admin/controller/sale/order.php#L2152
+144
function initAnnounce(srcUrl)
{
announceIdAr [1-1] = 1;
announceFNameAr[1-1] = "image1_1.gif";
announceUrlAr [1-1] = "2-2&am=1&qn=35";
announceTextAr [1-1] = "Бывает ли Президенту скучно?";
announceIdAr [2-1] = 2;
announceFNameAr[2-1] = "image1_2.gif";
announceUrlAr [2-1] = "2-2&am=1&qn=16";
announceTextAr [2-1] = "В чем Президент не виноват?";
// еще говно
announceIdAr [13-1] = 13;
announceFNameAr[13-1] = "image1_13.gif";
announceUrlAr [13-1] = "5-6";
announceTextAr [13-1] = "День Победы";
var announcesNumber = announceIdAr.length;
//alert(announcesNumber);
var index = Math.round(Math.random() * (announcesNumber - 1));
//alert(index);
// еще дохуя алертов
//выясняем, активна ли CD-версия
var url2 = stringReplace(srcUrl, ".htm", "");
if (url2 != srcUrl)
{
//активна CD-версия
announceUrl = stringReplace(announceUrl, "&", "_");
announceUrl = stringReplace(announceUrl, "=", "_");
};
// /выясняем, активна ли CD-версия
var url = stringReplace(srcUrl, "!!!", announceUrl);
kids.kremlin.ru
там вообще все жорошо
+155
/**
* @param string $singular
* @param string $context
*/
function translate($singular, $context=null) {
return $singular;
}
Любимый вордпресс, wp-includes/pomo/translations.php. Кажется, это такой интерфейс.
+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
волшебно
+161
there is a reason why opencart is the no.1 most used ecommerce solution in places like china and india, its the easiest code base to understand!
--
many apps servers! what does that mean? you mean different applications running from the same framework?
you build each application starting from the index.php file and include what ever library classes you require.
--
"I agree with you that it's harder to write simple code, because REPEATING CODE IS HARD TO DEBUG HARD TO READ AND TO CORRECT. so it makes you waste a lot of time."
this is what search and replace is for!
Создатель опенкарта (Daniel Kerr) исходит на говно, много мякотки
http://www.techchattr.com/never-use-opencart#comment-1151857248