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

    +166

    1. 1
    if (substr(json_encode($row['list']), 0, 1) == '[') {

    Такой вот аналог is_array()

    Lowezar, 17 Декабря 2013

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

    +149

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    if ($result->fetch()) {
        return $result->get('num_flags');
    }
    else {
        return 666;
    }

    Верующий программист :)

    xakip, 17 Декабря 2013

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

    +161

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    //надо показать элемент каталога во всей красе
    $_CENTER="show_category_item(".$newParts[0].");";
    eval($_CENTER);
    
    // ...
    $_LEFT='get_main_category($cat_id, $new_path);';
    $_CENTER="show_category_item_list($".'newParts'.");";

    Вот с таким адом мне приходится работать.

    oooZinka, 16 Декабря 2013

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

    +164

    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
    if($_POST['Selling_property_1']!=NULL):update_field('field_51db015800526',  $_POST['Selling_property_1'], $_POST['pid']); endif;
    if($_POST['Relocation_budget_1']!=NULL):update_field('field_51db018100527',  $_POST['Relocation_budget_1'], $_POST['pid']); endif;
    if($_POST['Selling_property_2']!=NULL):update_field('field_51db01ac00528',  $_POST['Selling_property_2'], $_POST['pid']); endif;
    if($_POST['School_1']!=NULL):update_field('field_51db01b900529',  $_POST['School_1'], $_POST['pid']);endif;
    if($_POST['homestyling_1']!=NULL):update_field('field_51db01c60052a',  $_POST['homestyling_1'], $_POST['pid']);endif;
    if($_POST['Telephony_1']!=NULL):update_field('field_51db02090052b',  $_POST['Telephony_1'], $_POST['pid']);endif;
    if($_POST['Broadband_1']!=NULL):update_field('field_51db02130052c',  $_POST['Broadband_1'], $_POST['pid']);endif;
    if($_POST['TV_1']!=NULL):update_field('field_51db021c0052d',  $_POST['TV_1'], $_POST['pid']);endif;
    if($_POST['Home_alarm_1']!=NULL):update_field('field_51db02280052e',  $_POST['Home_alarm_1'], $_POST['pid']);endif;
    if($_POST['Craftsmen_1']!=NULL):update_field('field_51db023a0052f',  $_POST['Craftsmen_1'], $_POST['pid']);endif;
    if($_POST['Home_decor_1']!=NULL):update_field('field_51db023e00530',  $_POST['Home_decor_1'], $_POST['pid']);endif;
    if($_POST['Bank_1']!=NULL):update_field('field_51db024900531',  $_POST['Bank_1'], $_POST['pid']);endif;
    if($_POST['Moving_cmp_1']!=NULL):update_field('field_51db025400532',  $_POST['Moving_cmp_1'], $_POST['pid']);endif;
    if($_POST['homestyling_2']!=NULL):update_field('field_51db025f00533',  $_POST['homestyling_2'], $_POST['pid']);endif;
    if($_POST['change_1']!=NULL):update_field('field_51db026900534',  $_POST['change_1'], $_POST['pid']);endif;
    if($_POST['moving_cmp_2']!=NULL):update_field('field_51db027200535',  $_POST['moving_cmp_2'], $_POST['pid']);endif;
    if($_POST['moving_truck_1']!=NULL):update_field('field_51db027e00536',  $_POST['moving_truck_1'], $_POST['pid']);endif;
    if($_POST['household_cleaning_1']!=NULL):update_field('field_51db028800537',  $_POST['household_cleaning_1'], $_POST['pid']);endif;
    if($_POST['insurance_1']!=NULL):update_field('field_51db029200538',  $_POST['insurance_1'], $_POST['pid']);endif;
    if($_POST['cleaning_1']!=NULL):update_field('field_51db029c00539',  $_POST['cleaning_1'], $_POST['pid']);endif;
    if($_POST['Home_alarm_1']!=NULL):update_field('field_51db02a70053a',  $_POST['home_alarm_2'], $_POST['pid']);endif;
    if($_POST['select_2']!=NULL):update_field('field_51db02b10053b',  $_POST['select_2'], $_POST['pid']);endif;
    if($_POST['insurance_2']!=NULL):update_field('field_51db02ca0053c',  $_POST['insurance_2'], $_POST['pid']);endif;
    if($_POST['school_2']!=NULL):update_field('field_51db02d40053d',  $_POST['school_2'], $_POST['pid']);endif;
    if($_POST['Telephony_2']!=NULL):update_field('field_51db02e10053e',  $_POST['Telephony_2'], $_POST['pid']);endif;
    if($_POST['Broadband_2']!=NULL):update_field('field_51db02e50053f',  $_POST['Broadband_2'], $_POST['pid']);endif;
    if($_POST['TV_2']!=NULL):update_field('field_51db02f100540',  $_POST['TV_2'], $_POST['pid']);endif;
    if($_POST['gasket_1']!=NULL):update_field('field_51db02fc00541',  $_POST['gasket_1'], $_POST['pid']);endif;
    if($_POST['electricity_2']!=NULL):update_field('field_51db030400542',  $_POST['electricity_2'], $_POST['pid']);endif;
    if($_POST['storage_1']!=NULL):update_field('field_51db031600543',  $_POST['storage_1'], $_POST['pid']);endif;
    if($_POST['electricity_1']!=NULL):update_field('field_51db031c00544',  $_POST['electricity_1'], $_POST['pid']);endif;
    if($_POST['change_2']!=NULL):update_field('field_51db032700545',  $_POST['change_2'], $_POST['pid']);endif;
    if($_POST['garbage_1']!=NULL):update_field('field_51db033100546',  $_POST['garbage_1'], $_POST['pid']);endif;
    if($_POST['garbage_2']!=NULL):update_field('field_51db033c00547',  $_POST['garbage_2'], $_POST['pid']);endif;
    if($_POST['gasket_2']!=NULL):update_field('field_51db034400548',  $_POST['gasket_2'], $_POST['pid']);endif;
    if($_POST['storage_2']!=NULL):update_field('field_51db034e00549',  $_POST['storage_2'], $_POST['pid']);endif;
    if($_POST['cleaning_2']!=NULL):update_field('field_51db03570054a',  $_POST['cleaning_2'], $_POST['pid']);endif;
    if($_POST['moving_truck_2']!=NULL):update_field('field_51db035f0054b',  $_POST['moving_truck_2'], $_POST['pid']);endif;
    if($_POST['inspection_1']!=NULL):update_field('field_51db03690054c',  $_POST['inspection_1'], $_POST['pid']);endif;
    if($_POST['craftsmen_2']!=NULL):update_field('field_51db03750054d',  $_POST['craftsmen_2'], $_POST['pid']);endif;
    if($_POST['household_cleaning_2']!=NULL):update_field('field_51db037e0054e',  $_POST['household_cleaning_2'], $_POST['pid']);endif;

    Обработка формы румынскими колегами.

    jenezis, 13 Декабря 2013

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

    +148

    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
    
    /* Почему статические методы — говно */
    
    abstract class BaseNewsPeer {
    …
    	/**
    	 * Method to select one object from the DB.
    	 *
    	 * @param      Criteria $criteria object used to create the SELECT statement.
    	 * @param      PropelPDO $con
    	 * @return     News
    	 * @throws     PropelException Any exceptions caught during processing will be
    	 *		 rethrown wrapped into a PropelException.
    	 */
    	public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
    	{
    		$critcopy = clone $criteria;
    		$critcopy->setLimit(1);
    		$objects = NewsPeer::doSelect($critcopy, $con);
    		if ($objects) {
    			return $objects[0];
    		}
    		return null;
    	}
    …
    
    class NewsPeer extends BaseNewsPeer
    {
    	…
    }

    kix, 13 Декабря 2013

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

    +153

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    <?php
    sfConfig::set('show_counters', true);
    /**
     * Lite
     *
     * @category Symfony
     * @package Plugins
     * @subpackage liteSearchsite
     * @author 
     * @since 12.11.2008
     * @version $Id: actions.class.php 28664 2011-03-15 13:14:49Z ringtail $
     */
    
    /**
     * class liteSearchsiteActions. Функции для работы с поиском
     *
     * @category Symfony
     * @package Plugins
     * @subpackage liteSearchsite
     * @author Tretyakov Ilya <[email protected]>
     * @version $Id: actions.class.php 28664 2011-03-15 13:14:49Z ringtail $
     */
    class liteSearchsiteActions extends sfActions
    {
      protected $searchsite;
      protected $search_server = 'http://217.148.52.134:17000/';
    
      /**
       * конструктор
       *
       * @see sfComponent
       */
      public function __construct($context, $moduleName, $actionName)
      {
        $this->searchsite = new liteSearchsite();
        parent::__construct($context, $moduleName, $actionName);
      }
    
      /**
       * Поиск. главная
       *
       * @param unknown_type $request
       */
      public function executeIndex($request)
      {
        if ($request) {
          $page = $request->getParameter('id');
          $this->text = htmlspecialchars($request->getParameter('search_text'));
          $reqid = $request->getParameter('reqid');
          $page = $request->getParameter('p');
          $numdoc = $request->getParameter('numdoc');
    
        }
        if (!$page) $page = 0;
    
        if (!$this->searchsite->checkServer($this->search_server)) { throw new sfException('Ахтунг!'); }
        if (!1) {
          $this->search_work = 0;
        } else
        if ($this->searchsite->uploadXml($this->search_server, $this->text, $reqid, $page, $numdoc)) {
    
          $this->pages_found = $this->searchsite->getCountItem();
          $this->start_page = $this->searchsite->getStartPage();
    
          $this->pages_found_word = $this->searchsite->getWordLinks();
          $this->reqid = $this->searchsite->getRegId();
          $this->pages = $this->searchsite->getPages();
          $this->count_results = $this->searchsite->getDifPages();
    
          if ($this->pages) {
            $this->nextpagelink = $this->searchsite->getLinkNextPage();
            $this->prepagelink = $this->searchsite->getLinkPrePage();
          }
    
          $this->search_work = 1;
    
          if (!$this->pages_found) {
            $this->no_result = 1;
            $this->pages_found = 0;
          } else {
            $this->no_result = 0;
    
            $this->list = $this->searchsite->getList($page);
    
            //пересчитаем
            //$this->pages_found = $this->searchsite->getCountItem();
            //$this->searchsite->setCountPages();
            //$this->pages_found_word = $this->searchsite->getWordLinks();
            //$this->pages = $this->searchsite->getPages();
            //$this->count_results = $this->searchsite->getDifPages();
    
            if ($this->pages) {
              $this->nextpagelink = $this->searchsite->getLinkNextPage();
              $this->prepagelink = $this->searchsite->getLinkPrePage();
            }
          }
        } else {
          $this->search_work = 0;
        }
      }

    kix, 11 Декабря 2013

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

    +154

    1. 1
    2. 2
    if (!empty($_GET[ret])) $_SESSION[ret] = $_GET[ret];
    else if (!empty($_SESSION[ret])) $_GET[ret] = $_SESSION[ret];

    Из разряда черной магии

    psycho-coder, 10 Декабря 2013

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

    +153

    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
    php_sapi_name() === 'cli' or exit('Only CLI mode allowed');
    
    getenv('API_HOST') or exit(<<<EOT
    
      To run tests you should setup "API_HOST" environment variable.
      Try follow in bash command line:
    
      $ export API_HOST=<api_host>
      cd path/to/tests
      php direct_report_problem.php
    
    
    EOT
    );
    
    defined('API_ENDPOINT') || define('API_ENDPOINT', getenv('API_HOST') . '/webservice/index.php');
    
    $method = API_ENDPOINT . '?op=...';
    
    $describe = function ($msg, $test) {
        printf("\n\n[%s]\n\n%s\n\n", $msg, shell_exec($test()));
        sleep(2);
    };
    
    $describe('Cannot upload empty report', function() use ($method) {
        return 'curl'
        . ' -F user_id=61'
        . ' ' . $method;
    });
    
    $describe('Can upload only direct report note', function() use ($method) {
        return 'curl'
        . ' -F user_id=61'
        . ' -F problem_note=NOTE'
        . ' ' . $method;
    });
    
    $describe('Can upload only direct report sound', function() use ($method) {
        return 'curl'
        . ' -F user_id=61'
        . ' -F [email protected]'
        . ' ' . $method;
    });
    
    $describe('Can upload only direct report image', function() use ($method) {
        return 'curl'
        . ' -F user_id=61'
        . ' -F [email protected]'
        . ' ' . $method;
    });
    
    $describe('Can upload all data direct report note, image, sound', function() use ($method) {
        return 'curl'
        . ' -F user_id=61'
        . ' -F problem_note=NOTE'
        . ' -F [email protected]'
        . ' -F [email protected]'
        . ' ' . $method;
    });

    __proto__, 10 Декабря 2013

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

    +155

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    function lastDay($month, $year) {
        if ($month != 12) {
            $m = $month + 1;
            $y = $year;
        } else {
            $m = 1;
            $y = $year + 1;
        }
        return strftime("%d", mktime(0, 0, 0, $m, 0, $y));
    }

    Оригинальный и дофига понятный способ получить последний день текущего месяца.

    anton0xf, 09 Декабря 2013

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

    +154

    1. 1
    2. 2
    $date = date("Y-m-01", strtotime("-1 month"));
    $like = substr($date, 0, 8) . "%";

    а потом $like вставляется в sql-код

    anton0xf, 09 Декабря 2013

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