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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    private function check($data) {
    	$result = $this->checkData($data);
    	if ($result === true) return true;
    	$sm = new SystemMessage();
    	return $sm->message($result);
    }
    protected function checkData($data) {
    	return false;
    }

    С видеокурса Михаила Русакова

    REMOX, 27 Сентября 2015

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

    −4

    1. 1
    2. 2
    3. 3
    4. 4
    // Привет коллеги, у меня возникла делема, куда пихать код отправки
    // на e-mail сообщения? В модель формы или в контроллере оставить?
    // фреймворк Yii, в самой Yii доке, написано, что в контроллерах надо
    // оставлять, а вы как делаете?

    Привет коллеги, у меня возникла делема, куда пихать код отправки на e-mail сообщения? В модель формы или в контроллере оставить? Фреймворк Yii, в самой Yii доке, написано, что в контроллерах надо оставлять, а вы как делаете?

    proweber1, 27 Сентября 2015

    Комментарии (8)
  3. C++ / Говнокод #18765

    +1

    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
    import std.io;
    import std.string;
    import calendar.month;
    
    module calendar.date;
    
    namespace Chrono
    {
        export
        struct Date {
            Date(int, Month, int);
            int day() const
            {
                return d;
            }
            Month month() const
            {
                return m;
            }
            Int year() const
            {
                return y;
            }
        private:
            int d;
            Month m;
            int y;
        };
        export
        std::ostream &operator<<(std::ostream &, const Date &);
        export
        std::string to_string(const Date &);
    }

    По мотивам: http://habrahabr.ru/company/infopulse/blog/267781/
    зы. https://github.com/isocpp/CppCoreGuidelines/blob/master/talks/Large-Scale-C%2B%2B-With-Modules.pdf

    CriDos, 27 Сентября 2015

    Комментарии (14)
  4. Си / Говнокод #18760

    +14

    1. 1
    2. 2
    3. 3
    /*
    удалено по просьбе правообладателя
    */

    Думал я, что меня уже так просто не удивишь, пока не увидел ЭТО!

    gorthauer87, 24 Сентября 2015

    Комментарии (32)
  5. C# / Говнокод #18758

    −1

    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
    public interface IApplicationUserManager { }
    
        public class ApplicationUserManager : UserManager<ApplicationUser, long>, IApplicationUserManager
        {
            private static ApplicationUserManager applicationUserManager;
            public static bool IsUserInRole(long userId, string roleName)
            {
                return applicationUserManager.UserInRole(userId, roleName);
            }
    
            public ApplicationUserManager(IAccountService accountService)
                : base(new ApplicationUserStore())
            {
                this.accountService = accountService;
                applicationUserManager = this;
            }
         }

    Проверяй, проверяй мои роли полностью...

    FreedomHex, 24 Сентября 2015

    Комментарии (0)
  6. JavaScript / Говнокод #18757

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    var date_match=time.split('.');
    date_match=new Date(
    	date_match[1]+'-'+date_match[0]+'-'+/[\w\W]+(\d{4,4})\/(\d{4,4})[\w\W]+/.exec(document.title)[(date_match[1]>6)?1:2]//Gangsta
    );

    Darth, 23 Сентября 2015

    Комментарии (0)
  7. Pascal / Говнокод #18756

    +5

    1. 1
    Commission:= Commission/100*StrToInt(Label8.Caption); //Вычисление комиссии

    Терминальщики :|

    Dego1n, 23 Сентября 2015

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

    +3

    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
    $apiUrl = 'https://www.etxt.ru/api/json/';
    	$apiPass = '12300f89';
    	$sign = md5('method=folders.listFolderstoken=d0jjghg196942a9aefghhhh'.md5($apiPass.'api-pass'));
    	$params = array(
    		'method' => 'folders.listFolders',
    		'sign' => $sign,
    		'token' => 'd083b49cghhjjka9ae9fddghuyhhg'
    	);
    	$result = file_get_contents($apiUrl, false, stream_context_create(array(
    		'http' => array(
    			'method'  => 'POST',
    			'header'  => 'Content-type: application/x-www-form-urlencoded',
    			'content' => http_build_query($params)
    		)
    	)));
    
    	echo $result;
    	echo '<br />';
    	var_dump($params);
    	echo '<br />';
    	echo '<br />';
    	echo 'Trying using CURL';
    	echo '<br />';
    	echo '<br />';
    
    	$myCurl = curl_init();
    	curl_setopt_array($myCurl, array(
    		CURLOPT_URL => $apiUrl,
    		CURLOPT_RETURNTRANSFER => true,
    		CURLOPT_POST => true,
    		CURLOPT_POSTFIELDS => http_build_query($params)
    	));
    	$response = curl_exec($myCurl);
    	curl_close($myCurl);
    
    	echo "Ответ на Ваш запрос: ".$response;

    Не работал, потому что API написаны не понятно, нужно в $apiUrl вписывать sign и token. Поддержка выслала мне более универсальный код с функцией ksort! Потому этот код просто под удаление...

    increazon, 23 Сентября 2015

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

    +8

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    // большой кусок кода 
    $where = '';
    if (strlen($data["name"])) {
        $where = $where . " AND name = '" . $data["name"] . "'";
    }
    if (strlen($data["company"])) {
        $where = $where . " AND company = '" . $data["company"] . "'";
    }
    if (strlen($data["status"])) {
        $where = $where . " AND status = '" . $data["status"] . "'";
    }
    // большой кусок кода

    Проверка переменных на пустоту...

    koftikes, 23 Сентября 2015

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

    +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
    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
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    if(file_exists('./daemon.php') & isset($_GET['stop'])){
        rename('./daemon.php', './daemon.php~');
        sleep(3);
        header('Location: http://'.$_SERVER[HTTP_HOST]);
    }elseif(isset($_GET['restart'])){
        include('./lib.inc');
        @rename('./daemon.php', './daemon.php~');
        sleep(3);
        rename('./daemon.php~', './daemon.php');
        ping('daemon.php');
        sleep(3);
        header('Location: http://'.$_SERVER[HTTP_HOST]);
    }
        echo '<a href="/?restart" class="button">Start/Restart</a> ';
    if(file_exists('./daemon.php'))
        echo '<a href="/?stop" class="button">Stop</a>';
    ?><br>
    
    <div class="display">-</div>
    <script type="text/javascript"><!--
    var xd;
    setInterval(function(){
    xd&&xd.abort();
    xd = new XMLHttpRequest();
    xd.onreadystatechange = function(){
    if(xd.readyState == 4){
    document.querySelector(".display").textContent = xd.responseText;
    }
    }
    xd.open('GET', '/display.txt', true);
    xd.send();
    
    }, 3000);
    //--></script>
    
    
    daemon.php:
    
    if(date('his')-file_get_contents('./date')<2)
        exit;
        file_put_contents('./date', date('his'));
        include('./lib.inc');
        $f=fopen('./lock', 'w+');
        flock($f, LOCK_EX);
        ping('core.php');
        sleep(3);
        ping('daemon.php');
        usleep(200);
        ping('daemon.php');
        usleep(200);
        flock($f, LOCK_UN);
    
    
    core.php:
    
        ini_set('display_errors', 'on');
        error_reporting(E_ALL);
        ini_set('html_errors', 'off');
        $xreservedbasedir=__DIR__;
        $xreservedtmpbuf=str_repeat('x', 1024 * 3);
    function ob_write($buffer){
        unset($GLOBALS['xreservedtmpbuf']);
        file_put_contents($GLOBALS['xreservedbasedir'].'/display.txt', $buffer, LOCK_EX);
    }
        ob_start('ob_write');
        include('./script.php');
    
    script.php:
    
        echo date("Y.m.d h:i:s"); //любой код, который исполняет демон
    
    lib.inc:
    
    function ping($action){
        $h=$_SERVER[HTTP_HOST];
        $http=fsockopen($h, 80, $e1, $e2, 1);
    if($http){
        fwrite($http,
        'GET /'.$action.' HTTP/1.1'."\r\n".
        'Accept: */*'."\r\n".
        'Host: '.$h."\r\n\r\n"
        );
        fclose($http);
    }
    }

    демон на php? Легко!

    loki90, 23 Сентября 2015

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