- 1
- 2
if(strlen($refnumber)==1) $refnumber="00".$refnumber;
if(strlen($refnumber)==2) $refnumber="0".$refnumber;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+157
if(strlen($refnumber)==1) $refnumber="00".$refnumber;
if(strlen($refnumber)==2) $refnumber="0".$refnumber;
+157
class ModelCheckoutOrder extends Model {
public function addOrder($data) {
$data['login']=md5(rand(0,100).rand(0,100).rand(0,100).rand(0,100).rand(0,100).rand(0,100).rand(0,100).rand(0,100).rand(0,100));
$this->db->query("INSERT INTO `" . DB_PREFIX . "order` SET login='".$data['login']."',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']) . "', 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_company_id = '" . $this->db->escape($data['payment_company_id']) . "', payment_tax_id = '" . $this->db->escape($data['payment_tax_id']) . "', 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_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_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'] . "', 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()");
$order_id = $this->db->getLastId();
foreach ($data['products'] as $product) {
$this->db->query("INSERT INTO " . DB_PREFIX . "order_product SET order_id = '" . (int)$order_id . "', product_id = '" . (int)$product['product_id'] . "', name = '" . $this->db->escape($product['name']) . "', model = '" . $this->db->escape($product['model']) . "', quantity = '" . (int)$product['quantity'] . "', price = '" . (float)$product['price'] . "', total = '" . (float)$product['total'] . "', tax = '" . (float)$product['tax'] . "', reward = '" . (int)$product['reward'] . "'");
$order_product_id = $this->db->getLastId();
foreach ($product['option'] as $option) {
$this->db->query("INSERT INTO " . DB_PREFIX . "order_option SET order_id = '" . (int)$order_id . "', order_product_id = '" . (int)$order_product_id . "', product_option_id = '" . (int)$option['product_option_id'] . "', product_option_value_id = '" . (int)$option['product_option_value_id'] . "', name = '" . $this->db->escape($option['name']) . "', `value` = '" . $this->db->escape($option['value']) . "', `type` = '" . $this->db->escape($option['type']) . "'");
}
foreach ($product['download'] as $download) {
$this->db->query("INSERT INTO " . DB_PREFIX . "order_download SET order_id = '" . (int)$order_id . "', order_product_id = '" . (int)$order_product_id . "', name = '" . $this->db->escape($download['name']) . "', filename = '" . $this->db->escape($download['filename']) . "', mask = '" . $this->db->escape($download['mask']) . "', remaining = '" . (int)($download['remaining'] * $product['quantity']) . "'");
}
}
И это известный движок интернет-магазина OpenCart???
\catalog\model\checkout\order.php
+157
/* Код невлазит, т.к. весит около 1MB и происходит 413 Request Entity Too Large .
Читайте по ссылке - http://m.uploadedit.com/b041/1413367407745.txt
Код универсален, включает в себя PHP, HTML, CSS, JS, SQL и, возможно, силу земли.
Полностью работоспособен.
Наслаждайтесь.
*/
см. внутри
+157
'errorHandler' =>
class yii\console\ErrorHandler#6 (6) {
public $discardExistingOutput =>
bool(true)
public $memoryReserveSize =>
int(262144)
public $exception =>
NULL
private $_memoryReserve =>
string(262144) "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"...
Где-то в недрах Yii2. Я, кажется, понимаю, что это и зачем (хотя не уверен, что это работает, когда памяти уже не хватило), но выглядит просто адово.
+157
if ( !empty($vendor) and strtolower(substr($record_title, 0, strlen($vendor)+1)) == strtolower("$vendor ")
) {
$record_title = substr($record_title, strlen($vendor)+1);
}
Вырзаем из названия товара, компанию производителя.
+157
// экшен произвольного контроллера, они там все такие
$data['heading_title'] = $this->language->get('heading_title');
$data['text_my_account'] = $this->language->get('text_my_account');
$data['text_my_orders'] = $this->language->get('text_my_orders');
$data['text_my_newsletter'] = $this->language->get('text_my_newsletter');
$data['text_edit'] = $this->language->get('text_edit');
$data['text_password'] = $this->language->get('text_password');
// еще 20-30 аналогичных строчек
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/account/account.tpl')) {
$this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/account/account.tpl', $data));
} else {
$this->response->setOutput($this->load->view('default/template/account/account.tpl', $data));
}
теги: Опенкарт, вчера релизнули, модный паттерн MVC-L, тонкие контроллеры, классика, табы для того и сделаны, чтобы ими отбивать
https://github.com/opencart/opencart/tree/master/upload/catalog/controller/account
+157
$('#id_accept_eula').click(function () {
// код аффтара
try {
var v = 1 - this.getAttribute('value');
this.setAttribute('value', v);
if (v == 1) {
$('#submit_button').removeAttr('disabled');
} else {
$('#submit_button').attr('disabled', 'disabled');
}
} catch (e) {
alert('exc: ' + e);
}
// заменил на
$("#submit_button").prop('disabled', !this.checked);
});
Когда платят за строки кода...
+157
public function toArray()
{
$that = $this;
$profile = $this->getProfile();
return [
'sex' => $profile->getSex(),
'distance' => (int) $profile->get($profile::FIELD_DISTANCE),
'balance' => new Object_Response_Model_User_Balance($profile->get($profile::FIELD_BALANCE)),
'payments' => call_user_func(function() use ($that) {
$return = [];
$checkoutTypes = $that->getRelationCheckoutTypes()->find_all()->as_array();
foreach($checkoutTypes as $checkoutType) {
if (json_decode($checkoutType->data)[0]->value) {
$return[] = $checkoutType;
}
}
return $return;
}),
'vk' => $this->getRelationSocial()->getProfileUrl(),
'validate' => $this->getValidate()
];
};
Автор: просто php нам дало анонимные функции, почему бы ими не пользоваться?
+157
for ($j=1; $j<8; $j++) {
$up = "";
$down = "";
for ($i=1; $i<7; $i++) {
if (($i==4)&&($j==4)) {
$up = $up.'<td class="simp" colspan="2" rowspan="4">Военная<br>Подготовка</td>';
continue;
}
if (($i==4)&&($j>3)&&($j<6)) {
continue;
}
$x = $i*2-1;
$y = $j*2-1;
if (($table[$x][$y]==$table[$x][$y+1])&&($table[$x+1][$y+1]==$table[$x+1][$y])&&($table[$x+1][$y+1]==$table[$x][$y])) {
$up = $up.str_replace("<br><br>","","<td title='".$table[$x][$y]['description']."' class='simp' colspan='2' rowspan='2'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>");
}
else {
$cnt = 0;
if ($table[$x][$y]==$s) $cnt++;
if ($table[$x][$y+1]==$s) $cnt++;
if ($table[$x+1][$y]==$s) $cnt++;
if ($table[$x+1][$y+1]==$s) $cnt++;
if ($cnt==3) {
$up = $up."<td title='".$table[$x][$y]['description']."' class='insm'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>";
$up = $up."<td title='".$table[$x+1][$y]['description']."' class='insm'>".$table[$x+1][$y]['subject']."<br>".$table[$x+1][$y]['auditory']."<br>".$table[$x+1][$y]['lecturer']."</td>";
$down = $down."<td title='".$table[$x][$y+1]['description']."' class='insm'>".$table[$x][$y+1]['subject']."<br>".$table[$x][$y+1]['auditory']."<br>".$table[$x][$y+1]['lecturer']."</td>";
$down = $down."<td title='".$table[$x+1][$y+1]['description']."' class='insm'>".$table[$x+1][$y+1]['subject']."<br>".$table[$x+1][$y+1]['auditory']."<br>".$table[$x+1][$y+1]['lecturer']."</td>";
}
else {
if ($table[$x][$y]==$table[$x][$y+1]) { // Левые совпадают
$up = $up."<td title='".$table[$x][$y]['description']."' class='insm' rowspan='2'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>";
if ($table[$x+1][$y]==$table[$x+1][$y+1]) {
$up = $up."<td title='".$table[$x+1][$y]['description']."' class='insm' rowspan='2'>".$table[$x+1][$y]['subject']."<br>".$table[$x+1][$y]['auditory']."<br>".$table[$x+1][$y]['lecturer']."</td>";
}
else {
$up = $up."<td title='".$table[$x+1][$y]['description']."' class='insm'>".$table[$x+1][$y]['subject']."<br>".$table[$x+1][$y]['auditory']."<br>".$table[$x+1][$y]['lecturer']."</td>";
$down = $down."<td title='".$table[$x+1][$y+1]['description']."' class='insm'>".$table[$x+1][$y+1]['subject']."<br>".$table[$x+1][$y+1]['auditory']."<br>".$table[$x+1][$y+1]['lecturer']."</td>";
}
} else {
if ($table[$x+1][$y]==$table[$x+1][$y+1]) { // Правые совпадают
$up = $up."<td title='".$table[$x][$y]['description']."' class='insm'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>";
$down = $down."<td title='".$table[$x][$y+1]['description']."' class='insm'>".$table[$x][$y+1]['subject']."<br>".$table[$x][$y+1]['auditory']."<br>".$table[$x][$y+1]['lecturer']."</td>";
$up = $up."<td title='".$table[$x+1][$y]['description']."' class='insm' rowspan='2'>".$table[$x+1][$y]['subject']."<br>".$table[$x+1][$y]['auditory']."<br>".$table[$x+1][$y]['lecturer']."</td>";
}
else {
if ($table[$x][$y]==$table[$x+1][$y]) { // Верхние совпадают
$up = $up."<td title='".$table[$x][$y]['description']."' class='insm' colspan='2'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>";
if ($table[$x][$y+1]==$table[$x+1][$y+1]) {
$down = $down."<td title='".$table[$x][$y+1]['description']."' class='insm' colspan='2'>".$table[$x][$y+1]['subject']."<br>".$table[$x][$y+1]['auditory']."<br>".$table[$x][$y+1]['lecturer']."</td>";
}
else {
$down = $down."<td title='".$table[$x][$y+1]['description']."' class='insm'>".$table[$x][$y+1]['subject']."<br>".$table[$x][$y+1]['auditory']."<br>".$table[$x][$y+1]['lecturer']."</td>";
$down = $down."<td title='".$table[$x+1][$y+1]['description']."' class='insm'>".$table[$x+1][$y+1]['subject']."<br>".$table[$x+1][$y+1]['auditory']."<br>".$table[$x+1][$y+1]['lecturer']."</td>";
}
}
else {
if ($table[$x][$y+1]==$table[$x+1][$y+1]) { // Нижние совпадают
$up = $up."<td title='".$table[$x][$y]['description']."' class='insm'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>";
$up = $up."<td title='".$table[$x+1][$y]['description']."' class='insm'>".$table[$x+1][$y]['subject']."<br>".$table[$x+1][$y]['auditory']."<br>".$table[$x+1][$y]['lecturer']."</td>";
$down = $down."<td title='".$table[$x][$y+1]['description']."' class='insm' colspan='2'>".$table[$x][$y+1]['subject']."<br>".$table[$x][$y+1]['auditory']."<br>".$table[$x][$y+1]['lecturer']."</td>";
}
else {
$up = $up."<td title='".$table[$x][$y]['description']."' class='insm'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>";
...
Рендер расписания занятий из базы данных в табличку на HTML
+157
function tedit_object()
{
if($this->authlib->logged_in()) {
$manager = $this->authlib->logged_manager_data();
$object_id = $this->input->post('object_id');
$type = $this->input->post('type');
$doprice = $this->input->post('doprice');
$price = $this->input->post('price');
$valute = $this->input->post('valute');
$dop = $this->input->post('dop');
$dozag = $this->input->post('dozag');
$zag = $this->input->post('zag');
$poslezag = $this->input->post('poslezag');
$rajon = $this->input->post('rajon');
$naselenp = $this->input->post('naselenp');
$opisanie = $this->input->post('opisanie');
$coordinatesgmap = $this->input->post('coordinatesgmap');
$dorprice = $this->input->post('dorprice');
$porprice = $this->input->post('porprice');
$domorepered = $this->input->post('domorepered');
$domore = $this->input->post('domore');
$domoreposle = $this->input->post('domoreposle');
$sdanpered = $this->input->post('sdanpered');
$sdan = $this->input->post('sdan');
$stars = $this->input->post('stars');
$kakchestvo = $this->input->post('kakchestvo');
$jivetpered = $this->input->post('jivetpered');
$jivet = $this->input->post('jivet');
$jivetposle = $this->input->post('jivetposle');
$jivetposle2 = $this->input->post('jivetposle2');
$rprice = $this->input->post('rprice');
$vip = $this->input->post('vip');
$data_to_object = array(
'manager_id' => $manager['id'],
'type_id' => $type,
'dorprice' => $dorprice,
'doprice' => $doprice,
'porprice' => $porprice,
'price' => $price,
'valute_id' => $valute,
'dop' => $dop,
'dozag' => $dozag,
'zag' => $zag,
'poslezag' => $poslezag,
'domorepered' => $domorepered,
'domore' => $domore,
'domoreposle' => $domoreposle,
'sdanpered' => $sdanpered,
'sdan' => $sdan,
'stars' => $stars,
'kakchestvo' => $kakchestvo,
'jivetpered' => $jivetpered,
'jivet' => $jivet,
'jivetposle' => $jivetposle,
'jivetposle2' => $jivetposle2,
'rprice' => $rprice,
'vip' => $vip,
'map' => $coordinatesgmap,
'naselenp' => $naselenp,
'rajon' => $rajon,
'desc' => $opisanie,
'modified' => date('Y-m-d H:i:s')
);
$this->db->where('id', $object_id);
$this->db->update('object_only', $data_to_object);
///echo $object_id;
redirect('/edit_object/'.$object_id, 'refresh');
} else { redirect('/authorization/', 'refresh'); }
}
Любимый проект <3