1. PHP / Говнокод #20852

    +317

    1. 1
    $this->db->query("UPDATE `" . DB_PREFIX . "order` SET 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($payment_country) . "', payment_country_id = '" . (int)$data['payment_country_id'] . "', payment_zone = '" . $this->db->escape($payment_zone) . "', payment_zone_id = '" . (int)$data['payment_zone_id'] . "', payment_address_format = '" . $this->db->escape($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($shipping_country) . "', shipping_country_id = '" . (int)$data['shipping_country_id'] . "', shipping_zone = '" . $this->db->escape($shipping_zone) . "', shipping_zone_id = '" . (int)$data['shipping_zone_id'] . "', shipping_address_format = '" . $this->db->escape($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']) . "', order_status_id = '" . (int)$data['order_status_id'] . "', affiliate_id  = '" . (int)$data['affiliate_id'] . "', date_modified = NOW() WHERE order_id = '" . (int)$order_id . "'");

    Строчечка

    govnozmey, 18 Августа 2016

    Комментарии (2)
  2. PHP / Говнокод #20822

    +119

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    <?php header('Content-Type: application/rss+xml'); ?>
    <?='<?xml version="1.0" encoding="utf-8"?>'?>
    <rss xmlns:content="http://purl.org/rss/1.0/modules/content/" version="2.0">
      <channel>
        <title><![CDATA[Neon Genesis Kode]]></title>
        <link>http://govnokod.ru</link>
        <description><![CDATA[Свежие комментарии]]></description>
        <pubDate><?=date(DATE_RSS)?></pubDate>
        <language>ru-ru</language>
        <docs>http://blogs.law.harvard.edu/tech/rss</docs>
        <ttl>3600</ttl>
    <?php
    
    $curl_context = curl_init(); 
    curl_setopt($curl_context, CURLOPT_URL, 'http://146.185.130.46/ngk/api/v1/latest'); 
    curl_setopt($curl_context, CURLOPT_RETURNTRANSFER, 1); 
    $raw_data = curl_exec($curl_context); 
    curl_close($curl_context);     
    $data = JSON_decode($raw_data);
    
    foreach($data as $item) { ?>
      <item>
          <title><![CDATA[Комментарий к говнокоду #<?=$item->thread_id?>]]></title>
          <link>http://govnokod.ru/<?=$item->thread_id?>#comment<?=$item->comment_id?></link>
          <guid>http://govnokod.ru/<?=$item->thread_id?>#comment<?=$item->comment_id?></guid>
          <description><![CDATA[<?=$item->text?>]]></description>
          <pubDate><?=date(DATE_RSS, strtotime($item->posted))?></pubDate>
      </item>
    <?php } ?>
    </channel>
    </rss>

    Обычный пыхокод. Листайте дальше.

    inkanus-gray, 17 Августа 2016

    Комментарии (191)
  3. PHP / Говнокод #20680

    +341

    1. 1
    2. 2
    $dom = new DOMDocument;
    $dom->loadHTML('<?xml encoding="UTF-8">' . $document);

    Выжал самое интересное.

    Кто угадает, зачем к документу прилепляется строка '<?xml encoding="UTF-8">', тому ничего. Но без неё не работает. Точнее, работает, но неправильно.

    inkanus-gray, 13 Августа 2016

    Комментарии (9)
  4. PHP / Говнокод #20525

    +4

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    // Change the color of the displayed status
    		if ($status == "active") {
    			$status_display = '<font color="white">' . $status . '</font>';
    		} elseif ($status == "sold") {
    			$status_display = '<font color="green">' . $status . '</font>';
    		} elseif ($status == "emis") {
    			$status_display = '<font color="orange">' . $status . '</font>';
    		} elseif ($status == "alert") {
    			//
    		} elseif ($status == "deleted") {
    			$status_display = '<font color="white">' . $status . '</font>';
    			//$style="text-decoration: line-through;";
    		} elseif ($status == "closed") {
    			$status_display = '<font color="closed">' . $status . '</font>';
    		} elseif ($status == "options_sent") {
    			$status_display = '<font color="yellow">' . $status . '</font>';
    		}
    		if ($trip_type == "one_way") {
    			$one_way = "SELECTED";
    			$round_trip = "";
    			$trip_type = '<font color="DarkBlue">One Way</font>';
    		} else {
    			$one_way = "";
    			$round_trip = "SELECTED";
    			$trip_type = '<font color="#348017">Round Trip</font>';
    		}
    		if ($cabin_class == "economy_class") {
    			$eco_class = "SELECTED";
    			$bus_class = "";
    			$ooo_class = "";
    		} elseif ($cabin_class == "business_class") {
    			$eco_class = "";
    			$bus_class = "SELECTED";
    			$ooo_class = "";
    		} elseif ($cabin_class == "o_class") {
    			$eco_class = "";
    			$bus_class = "";
    			$ooo_class = "SELECTED";
    		}
    		if ($num_pass == "1") {
    			$n1 = "SELECTED";
    			$n2 = "";
    			$n3 = "";
    			$n4 = "";
    			$n5 = "";
    			$n6 = "";
    			$n7 = "";
    			$n8 = "";
    			$n9 = "";
    			$n10 = "";
    		} elseif ($num_pass == "2") {
    			$n1 = "";
    			$n2 = "SELECTED";
    			$n3 = "";
    			$n4 = "";
    			$n5 = "";
    			$n6 = "";
    			$n7 = "";
    			$n8 = "";
    			$n9 = "";
    			$n10 = "";
    		} elseif ($num_pass == "3") {
    			$n1 = "";
    			$n2 = "";
    			$n3 = "SELECTED";
    			$n4 = "";
    			$n5 = "";
    			$n6 = "";
    			$n7 = "";
    			$n8 = "";
    			$n9 = "";

    Вот почему не надо мелочиться. И нанимать нормальных программистов.

    OMD, 11 Августа 2016

    Комментарии (13)
  5. PHP / Говнокод #20521

    +4

    1. 1
    var options = [<?php echo implode(',', range(App\Service\Service::CONSTANT_MIN, App\Service\Service::CONSTANT_MAX)); ?>];

    Diwms, 11 Августа 2016

    Комментарии (1)
  6. PHP / Говнокод #20491

    +5

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    $db=Yii::$app->db;
    
    if($db->driverName == 'pgsql') {
    $sql ="select a.* from report a inner join code_report b on a.id=b.report_id ";
    $sql.=" inner join code c on b.code_id=c.id  where cast (c.val as integer ) {$znaki[$sign]} $value group by a.id";//pgsql
    }
    if($db->driverName == 'mysql') {
    $sql ="select a.* from report a inner join code_report b on a.id=b.report_id ";
    $sql.=" inner join code c on b.code_id=c.id  where convert(c.val, signed) {$znaki[$sign]} $value group by a.id";//mysql
    }

    Кандидат прислал тестовое задание

    heleg, 08 Августа 2016

    Комментарии (26)
  7. PHP / Говнокод #20489

    +5

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    function make_json($array){
    
        $json = '{';
        $pairs = array();
    
        foreach($array as $key=>$val){
            if (!is_numeric($val)) { $val = "'{$val}'"; }
            $pairs[] = "{$key}: $val";
        }
    
        $json .= implode(', ', $pairs);
        $json .= '}';
    
        return $json;
    
    }

    dm_fomenok, 08 Августа 2016

    Комментарии (58)
  8. PHP / Говнокод #20457

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    // Validation
    		$err = $fc->validationInput($fieldsArray, wire('input')->post);
    		if( $err === false ) {
    			// Saving
    			$fc->saveInput($fieldsArray, wire('input')->post);
    			// Send emails to the submitter and to the owner
    
    			$toSubmitter = wire('user')->email;
    			$toOwner = wire('pages')->get(wire('page')->created_users_id)->email;
    			
    		
    
    			$subject = "reservation #{$destPage->id}";
    
    			
    			ob_start(); ?>
    			
    			<p>Dear <?php echo $owner->o_firstname; ?>,</p>
    
    			<p>We have enquiry for your <?php echo $destPage->id->title; ?> in your account on site. Please log in to see details and replay to the guests directly.</p>
    			
    			<p>Here is the link: <a href="<?php echo 'http://'.$loginLink; ?>">http://<?php echo $loginLink; ?></a><p>
    
    			<p>Thank you in advance for contacting guests shortly. If you require any assistance please do not hesitate to get in touch.</p>
    
    			<p>The Team<br />
    			Lionl<br />
    			237 Perrier<br />
    			74700 <br />
    			<br />
    			Fr</p>
    			
    			<?php $textBody = ob_get_clean(); 
    			
    			$sent1 = wireMail($toSubmitter, '', $subject, '', array( 'bodyHTML' => $textBody ));
    			wireMail($toSubmitter, '', $subject, array( 'bodyHTML' => $textBody ));
    			
    			$agentMail = $fc->getInput('reservation_contact_email')->value;
    			$agentName = $fc->getInput('leader')->value;
    			$agentPhone = $fc->getInput('reservation_contact_phone')->value;
    
    			$regUser = wire('users')->find("email=$agentMail");
    			
    			
    			$destPage->of(false);

    Отправка письма

    gorbatka42, 02 Августа 2016

    Комментарии (0)
  9. PHP / Говнокод #20456

    0

    1. 1
    2. 2
    $result = call_user_func_array([ $brief, $value ? 'setOption' : 'deleteOption' ],
                                           [ $option ] + ($value ? [ 1 => $value ] : []));

    heleg, 02 Августа 2016

    Комментарии (1)
  10. PHP / Говнокод #20448

    +2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    <?php
    /*
    * System class
    * @package: PerfCMS
    */
    
    class System extends PerfSystem
    {
    	public static function textarea($rows = 5, $cols = 25, $name = 'text', $value = '', $class = '', $id = 'area', $style = '')
    	{
    		if(parent::browserType() == 'web')
    		{
    			Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/assets/js/bbtags.js');
    			return '
    			<div id="tagspanel" class="textarea">
    			<a href="#" title="'. Lang::get('bold_text').'" id="bold" onclick="return bbtags(\'[b]\', \'[/b]\', \'bold\', \''.$id.'\')">'.System::image('bbpanel/bold.png').'<span class="tooltip"></span></a>
    			<a href="#" title="'. Lang::get('italic_text').'" id="italic" onclick="return bbtags(\'[i]\', \'[/i]\', \'italic\', \''.$id.'\')">'.System::image('bbpanel/italic.png').'</a>
    			<a href="#" title="'. Lang::get('underline_text').'" id="underline" onclick="return bbtags(\'[u]\', \'[/u]\', \'underline\', \''.$id.'\')">'.System::image('bbpanel/underline.png').'</a>
    			<a href="#" title="'. Lang::get('strike_text').'" id="strikethrough" onclick="return bbtags(\'[s]\', \'[/s]\', \'strikethrough\', \''.$id.'\')">'.System::image('bbpanel/strikethrough.png').'</a>
    			<a href="#" title="'. Lang::get('quote_text').'" id="blockquote" onclick="return bbtags(\'[quote]\', \'[/quote]\', \'blockquote\', \''.$id.'\')">'.System::image('bbpanel/blockquote.png').'</a>
    			<a href="#" title="'. Lang::get('spoiler_text').'" id="spoiler" onclick="return bbtags(\'[spoiler]\', \'[/spoiler]\', \'spoiler\', \''.$id.'\')">'.System::image('bbpanel/spoiler.png').'</a>
    			<a href="#" title="'. Lang::get('color_text').'" id="color" onclick="return bbtags(\'[color=]\', \'[/color]\', \'color\', \''.$id.'\')">'.System::image('bbpanel/text_color.png').'</a>
    			<a href="#" title="'. Lang::get('url_text').'" id="link" onclick="return bbtags(\'[url=http://]\', \'[/url]\', \'link\', \''.$id.'\')">'.System::image('bbpanel/insert_link.png').'</a>
    			<a href="#" id="image" onclick="return bbtags(\'[img=http://]\', \'[/img]\', \'image\', \''.$id.'\')">'.System::image('bbpanel/image.png').'</a>
    			<a href="#" title="'. Lang::get('video_text').'" id="video" onclick="return bbtags(\'[video]\', \'[/video]\', \'video\', \''.$id.'\')">'.System::image('bbpanel/video.png').'</a>
    			<a href="#" title="'.Lang::get('source_text').'" id="source" onclick="return bbtags(\'[source lang=]\', \'[/source]\', \'source\', \''.$id.'\')">'.System::image('bbpanel/script_code.png').'</a>
    			</div>
    			<textarea name="'.$name.'" rows="'.$rows.'" cols="'.$cols.'"'.(!empty($class) ? ' class="'.$class.'"' : null).(!empty($style) ? ' style="'.$style.'"' : null).' id="'.$id.'">'.(!empty($value) ? $value : null).'</textarea>';
    		}
    		else
    		{
    			return '[<a href="/help/codes">'.Lang::get('bb_codes').'</a> | <a href="/help/smiles">'.Lang::get('smiles').'</a> | <a href="/help/rules">'.Lang::get('rules').'</a> | <a href="/help/">'.Lang::get('help').'</a>]<br/>
    			<textarea name="'.$name.'" rows="'.$rows.'" cols="'.$cols.'"'.(!empty($class) ? ' class="'.$class.'"' : null).(!empty($style) ? ' style="'.$style.'"' : null).' id="'.$id.'">'.(!empty($value) ? $value : null).'</textarea>';
    		}
    	}
    
    
    }

    Весь класс https://gist.github.com/eskrano/bb8fe1bc1e6b22456d68cf3e56bf752b

    eskrano, 30 Июля 2016

    Комментарии (3)