- 1
- 2
- 3
- 4
- 5
- 6
if($response == null){
echo "<pre>";
var_dump($response);
echo "</pre>";
die();
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
Всего: 13
+2
if($response == null){
echo "<pre>";
var_dump($response);
echo "</pre>";
die();
}
Таким способом выводится на экран надпись NULL
−18
switch (is_array ($_waz_table_ok['table_list']) && in_array($this->__table, $_waz_table_ok['table_list']))
{
case false:
$s = "CREATE TABLE ".$this->__table." (\n";
foreach ($filds as $f_name=>$fild) {
if (is_array ($fild)) {
$o = $fild;
} else {
$o = $types[$fild];
}
$s .= $f_name.' '.$o['Type'].' '.($o['Null'] == 'NO' ? 'NOT' : '').' NULL'.(!is_null($o['Default']) ? ' default \''.$o['Default'].'\'' : '').' '.$o['Extra'].",\n";
$s .= strlen($o['Key']) > 0 ? ($o['Key'] == 'PRI' ? 'PRIMARY KEY ('.$f_name.')' : ($o['Key'] == 'UNI' ? 'UNIQUE ' : '').' KEY '.$f_name.'('.$f_name.')' ).",\n" : '';
}
$s .= $this->prefix."timestamp timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP\n";
$result = mysql_query('SELECT VERSION()') or die(mysql_error());
$v = mysql_fetch_row($result);
if ($v[0][0] == '5') {
$s .= ") ENGINE=MyISAM DEFAULT CHARSET=cp1251;\n";
} else {
$s .= ") TYPE=MyISAM;\n";
}
$sql[] = $s;
$setting = get_class($this).'Setting';
if (class_exists($setting)) {
$cl = &new $setting;
if (strlen ($_s = $cl->getDefaultRows($this->__table)) > 0) {
$sql[] = $_s;
}
}
break;
case true:
$result = mysql_query ('SHOW COLUMNS FROM '.$this->__table) or die(mysql_error());
$rows_del = array ();
$rows_edit = array ();
$rows_add = array ();
while ($row = mysql_fetch_assoc($result)) {
if (!isset ($filds[$row['Field']])) {
if ($row['Field'] != $this->prefix.'timestamp') {
$rows_del[] = $row;
}
} else {
if (is_array ($filds[$row['Field']])) {
$o = $filds[$row['Field']];
} else {
$o = $types[$filds[$row['Field']]];
}
$filds[$row['Field']] = $o;
if ($row['Type'] != $o['Type'] || $row['Null'] != $o['Null'] || $row['Key'] != $o['Key'] || $row['Default'] != $o['Default'] || $row['Extra'] != $o['Extra']) {
$filds[$row['Field']]['db_options_old'] = $row;
$rows_edit[$row['Field']] = $filds[$row['Field']];
unset($filds[$row['Field']]);
} else {
unset($filds[$row['Field']]);
}
}
}
$rows_add = $filds;
foreach ($rows_del as $row) {
$sql[] = 'ALTER TABLE '.$this->__table.' DROP '.$row['Field'].";\n";
}
foreach ($rows_add as $f_name=>$row) {
if (is_array ($row)) {
$o = $row;
} else
{
$o = $types[$row];
}
$sql[] = 'ALTER TABLE '.$this->__table.' ADD '.$f_name.' '.$o['Type'].' '.($o['Null'] == 'NO' ? 'NOT' : '').' NULL'.(!is_null($o['Default']) ? ' default \''.$o['Default'].'\'' : '').' '.$o['Extra'].";\n";
if (strlen($o['Key']) > 0)
{
$sql[] = 'ALTER TABLE '.$this->__table.' ADD '.($o['Key'] == 'PRI' ? 'PRIMARY KEY ('.$f_name.')' : ($o['Key'] == 'UNI' ? 'UNIQUE ' : 'INDEX ').'('.$f_name.')' ).";\n";
}
}
foreach ($rows_edit as $f_name=>$row)
{
if (is_array ($row)) {
$o = $row;
} else {
$o = $types[$row];
}
$l = $row['db_options_old'];
if ($o['Type'] != $l['Type'] || $o['Null'] != $l['Null'] || $o['Default'] != $l['Default'] || $o['Extra'] != $l['Extra']) {
$sql[] = 'ALTER TABLE '.$this->__table.' CHANGE '.$f_name.' '.$f_name.' '.$o['Type'].' '.($o['Null'] == 'NO' ? 'NOT' : '').' NULL'.(!is_null($o['Default']) ? ' default \''.$o['Default'].'\'' : '').' '.$o['Extra'].";\n";
}
if ($o['Key'] != $l['Key']) {
if ($l['Key'] != '') {
$sql[] = 'ALTER TABLE '.$this->__table.' DROP '.($l['Key'] == 'PRI' ? 'PRIMARY KEY' : 'INDEX '.$f_name).";\n";
}
if ($o['Key'] != '') {
$sql[] = 'ALTER TABLE '.$this->__table.' ADD '.(strlen($o['Key']) > 0 ? ($o['Key'] == 'PRI' ? 'PRIMARY KEY ('.$f_name.')' : ($o['Key'] == 'UNI' ? ($l['Key'] != '' ? 'INDEX ' : 'UNIQUE ') : 'INDEX ').$f_name.'('.$f_name.')').";\n" : '');
}
}
}
break;
}
столкнулся с такой "хорошо" читаемой херовиной, вот для чего здесь SWITCH true false ? почему не IF?
−50
/* beg govno_2 */
$auk_connect = new mysqli($hostname, $username, $password, $auk_database);
if ($auk_connect->connect_error) {
trigger_error("Connection failed: " . $auk_connect->connect_error);
exit;
}
function getAukcionUserInfo($auk_user_id = null) {
global $auk_connect;
if (!is_numeric($auk_user_id)) {
return false;
}
$query_result = $auk_connect->query('SELECT * FROM `aukcion_users` au INNER JOIN wa_contact wc ON au.`contact_id` = wc.id
WHERE
wc.`id` = '.$auk_user_id.'');
if ($query_result) {
$auk_contact_info = $query_result->fetch_array(MYSQLI_ASSOC);
return $auk_contact_info;
} else {
return false;
}
}
// var_dump($_SESSION);
if (isset($_SESSION['auth_user'])) {
if (isset($_SESSION['auth_user']['id']) && ($_SESSION['auth_user']['id'] > 0)) {
$govno_2 = getAukcionUserInfo($_SESSION['auth_user']['id']);
if (empty($govno_2)) {
// разлогиниваемся с govno
//unset($_SESSION['ID_P']);
} elseif (isset($govno_2['akk_id']) && is_numeric($govno_2['akk_id'])) {
// var_dump('AKK_ID=', $govno_2['akk_id']);
$govno_3_result = mysql_query('SELECT akk, id_akk, contakt FROM akk WHERE id_akk = '.$govno_2['akk_id'].'');
if ($govno_3_result) {
$govno_contact_info = mysql_fetch_assoc($govno_3_result);
if (!empty($govno_contact_info)) {
$_SESSION['ID_P']=array(
1=>$govno_contact_info['id_akk'],
2=>md5($_SERVER['REMOTE_ADDR']),
3=>$govno_contact_info['contakt']
);
//var_dump('123123123123123123123');
}
}
}
} else {
// разлогиниваемся с govno
unset($_SESSION['ID_P']);
}
} else {
// разлогиниваемся с govno
unset($_SESSION['ID_P']);
}
//var_dump($_SESSION);
//}
/* end govno_2 */
очередной высер
+156
<?php
// Код курильщика
for ($i=1;$i<8;$i+=2){
if($i==$row->ShipingTime) $result .="<option selected value='".$i."'>".$i."</option>";
else $result .="<option value='".$i."'>".$i."</option>";
if($i==7) {$i+=3;
if($i==$row->ShipingTime) $result .="<option selected value='".$i."'>".$i."</option>";
else $result .="<option value='".$i."'>".$i."</option>";
}
else {
if($i==10) {
$i+=4;
if($i==$row->ShipingTime) $result .="<option selected value='".$i."'>".$i."</option>";
else $result .="<option value='".$i."'>".$i."</option>";
}
else {
for ($i=20;$i<45;$i+=10){
if($i==$row->ShipingTime) $result .="<option selected value='".$i."'>".$i."</option>";
else $result .="<option value='".$i."'>".$i."</option>";
if($i==40){$i+=20;
if($i==$row->ShipingTime) $result .="<option selected value='".$i."'>".$i."</option>";
else $result .="<option value='".$i."'>".$i."</option>";
$i+=30;
if($i==$row->ShipingTime) $result .="<option selected value='".$i."'>".$i."</option>";
else $result .="<option value='".$i."'>".$i."</option>";
}
}
}
}
// Код здорового человека (провели рефакторинг)
$ST_variants = array('1', '3', '5', '7', '10', '14', '20', '30' , '40', '60', '90');
foreach ($ST_variants as $value) {
print "<option ". ($value==$row->ShipingTime) ? 'selected' : '' ; ." value='".$value."'>".$value."</option>";
}
Заказчик хотел получить <select> со списком значений: '1', '3', '5', '7', '10', '14', '20', '30' , '40', '60', '90'...
+166
define("DB_YESTERDAY",date('d/m/Y', time()-172800-86400-86400-86400
-86400-86400-86400-86400-86400-86400-86400-86400-86400-86400-86400
-86400-86400-86400-86400-86400-86400-86400-86400-86400-86400)); //если более 2 дней подряд были выходные, валюты не показывались. Дописано "-86400"
Дописано -86400? Забыли упомянуть, что 24 раза(
+156
function(loaded) {
var sale=$("#markupz").val();
var markup=$("#salez").val();
...
});
утонул в таком коде
+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
+155
/* $res = array ('res_count' => 15, кол-во результатов
'...' => прочее,
)*/
{if ($res) && (($res['res_count']%10) == 1)&& ((($res['res_count']/10)%10) != 1)}
нашёлся <b>{$res['res_count']}</b> результат
{else}
нашлось <b>{$res['res_count']}</b>
{if ($res) && ((($res['res_count']/10)%10) != 1) && (($res['res_count']%10)>1) && (($res['res_count']%10)<5)}
результата
{else}
результатов
{/if}
{/if}
нашёл функцию под SMARTY для склонения слов, которая используется при выводе результатов поиска... она была записана в 1-у строчку для "лучшего понимания" (напишу в комменте )
+157
function add() {
global $MovRow, $Array_html, $Array_desc, $Array_mov, $Opera;
if ($MovRow==4) return;
if ($Opera) {
for ($i=0; $i<5; $i++) {
$Array_html[$i]=str_replace("padding-bottom: 3px;", "", $Array_html[$i]);
}
}
for ($i=0; $i<5; $i++) {
if ($Array_mov[$i]<=5) {
if ($MovRow==5&&$Array_mov[$i]==4)
$Array_html[$i]=str_replace($Array_desc[$i], $Array_desc[$i]."<br><br>", $Array_html[$i]);
else if ($MovRow==5&&$Array_mov[$i]==3)
$Array_html[$i]=str_replace($Array_desc[$i], $Array_desc[$i]."<br><br><br>", $Array_html[$i]);
else if ($MovRow==6&&$Array_mov[$i]==4) {
$Array_html[$i]=str_replace($Array_desc[$i], $Array_desc[$i]."<br><br><br>", $Array_html[$i]);
}
else if($MovRow==6&&$Array_mov[$i]==5) {
if ($Array_desc[$i][strlen($Array_desc[$i])-1]=='>'&&$Array_desc[$i][strlen($Array_desc[$i])-2]=='r')
$Array_html[$i]=str_replace($Array_desc[$i], $Array_desc[$i]."<br>", $Array_html[$i]);
else $Array_html[$i]=str_replace($Array_desc[$i], $Array_desc[$i]."<br><br>", $Array_html[$i]);
}
else if($MovRow==7&&$Array_mov[$i]==4)
$Array_html[$i]=str_replace($Array_desc[$i], $Array_desc[$i]."<br><br><br><br>", $Array_html[$i]);
else if($MovRow==7&&$Array_mov[$i]==5)
$Array_html[$i]=str_replace($Array_desc[$i], $Array_desc[$i]."<br><br><br>", $Array_html[$i]);
else if($MovRow==7&&$Array_mov[$i]==6)
$Array_html[$i]=str_replace($Array_desc[$i], $Array_desc[$i]."<br><br>", $Array_html[$i]);
}
}
}
наткнулся на этот код, и что-то нехватает мозгов, чтобы понять, что это, для чего это, и где это чудо применяется =((
+157
echo '
<font class="phonetop">
+7 (495)
<font style="font-size:28px">
99-888-77
</font>
</font>
';
ну как так можно?
использовать в теге font class, и в то же время, умудриться непонятно для чего изменять размер шрифта в теге font через style?
даже если нравится тег font, так у него есть атрибут size=""
...