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

    −52

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    $path  = file_directory_path();
      $dir = opendir($path);
      /*seacrh file shops.dtd.zip*/
      while ($file_name = readdir($dir)) {
        /*if found export file of current user*/
        if ($file_name == 'market_new.xml') {
          /*create array - date of last change current file => create date of current file*/
          $last_export_date = date('d-m-Y H:i', filectime($path . '/' .$file_name));
        }
      }
      /*close catalog*/
      closedir ($dir);

    превед братья украинци.

    brainstorm, 09 Мая 2012

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

    +129

    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
    #include<stdio.h>
    
    int main()
    {
        int i,p,q,sum=0;
        for(i=0;i<1000000;i++)
        {
            p=0;
            if(i<10) p=1;
            else if(i<100){ if(i/10==i%10) p=1;}
            else if(i<1000){ if(i/100==i%10) p=1;}
            else if(i<10000){ if(i/1000==i%10 && (i%1000)/100==(i%100)/10) p=1;}
            else if(i<100000){ if(i/10000==i%10 && (i%10000)/1000==(i%100)/10) p=1;}
            else if(i<1000000){ if(i/100000==i%10 && (i%100000)/10000==(i%100)/10 && (i%10000)/1000==(i%1000)/100) p=1;}
            q=0;
            if(i<2) q=1;
            else if(i<4){if(i/2==i%2) q=1;}
            else if(i<8){if(i/4==i%2) q=1;}
            else if(i<16){if(i/8==i%2 && (i%8)/4==(i%4)/2) q=1;}
            else if(i<32){if(i/16==i%2 && (i%16)/8==(i%4)/2) q=1;}
            else if(i<64){if(i/32==i%2 && (i%32)/16==(i%4)/2 && (i%16)/8==(i%8)/4) q=1;}
            else if(i<128){if(i/64==i%2 && (i%64)/32==(i%4)/2 && (i%32)/16==(i%8)/4) q=1;}
            else if(i<256){if(i/128==i%2 && (i%128)/64==(i%4)/2 && (i%64)/32==(i%8)/4 && (i%32)/16==(i%16)/8) q=1;}
            else if(i<512){if(i/256==i%2 && (i%256)/128==(i%4)/2 && (i%128)/64==(i%8)/4 && (i%64)/32==(i%16)/8) q=1;}
            else if(i<1024){if(i/512==i%2 && (i%512)/256==(i%4)/2 && (i%256)/128==(i%8)/4 && (i%128)/64==(i%16)/8 && (i%64)/32==(i%32)/16) q=1;}
            else if(i<2048){if(i/1024==i%2 && (i%1024)/512==(i%4)/2 && (i%512)/256==(i%8)/4 && (i%256)/128==(i%16)/8 && (i%128)/64==(i%32)/16) q=1;}
            else if(i<4096){if(i/2048==i%2 && (i%2048)/1024==(i%4)/2 && (i%1024)/512==(i%8)/4 && (i%512)/256==(i%16)/8 && (i%256)/128==(i%32)/16 && (i%128)/64==(i%64)/32) q=1;}
            else if(i<8192){if(i/4096==i%2 && (i%4096)/2048==(i%4)/2 && (i%2048)/1024==(i%8)/4 && (i%1024)/512==(i%16)/8 && (i%512)/256==(i%32)/16 && (i%256)/128==(i%64)/32) q=1;}
            else if(i<16384){if(i/8192==i%2 && (i%8192)/4096==(i%4)/2 && (i%4096)/2048==(i%8)/4 && (i%2048)/1024==(i%16)/8 && (i%1024)/512==(i%32)/16 && (i%512)/256==(i%64)/32 && (i%256)/128==(i%128)/64) q=1;}
            else if(i<32768){if(i/16384==i%2 && (i%16384)/8192==(i%4)/2 && (i%8192)/4096==(i%8)/4 && (i%4096)/2048==(i%16)/8 && (i%2048)/1024==(i%32)/16 && (i%1024)/512==(i%64)/32 && (i%512)/256==(i%128)/64) q=1;}
            else if(i<65536){if(i/32768==i%2 && (i%32768)/16384==(i%4)/2 && (i%16384)/8192==(i%8)/4 && (i%8192)/4096==(i%16)/8 && (i%4096)/2048==(i%32)/16 && (i%2048)/1024==(i%64)/32 && (i%1024)/512==(i%128)/64 && (i%512)/256==(i%256)/128) q=1;}
            else if(i<131072){if(i/65536==i%2 && (i%65536)/32768==(i%4)/2 && (i%32768)/16382==(i%8)/4 && (i%16384)/8192==(i%16)/8 && (i%8192)/4096==(i%32)/16 && (i%4096)/2048==(i%64)/32 && (i%2048)/1024==(i%128)/64 && (i%1024)/512==(i%256)/128) q=1;}
            else if(i<262144){if(i/131072==i%2 && (i%131072)/65536==(i%4)/2 && (i%65536)/32768==(i%8)/4 && (i%32768)/16384==(i%16)/8 && (i%16384)/8192==(i%32)/16 && (i%8192)/4096==(i%64)/32 && (i%4096)/2048==(i%128)/64 && (i%2048)/1024==(i%256)/128 && (i%1024)/512==(i%512)/256) q=1;}
            else if(i<524288){if(i/262144==i%2 && (i%262144)/131072==(i%4)/2 && (i%131072)/65536==(i%8)/4 && (i%65536)/32768==(i%16)/8 && (i%32768)/16384==(i%32)/16 && (i%16384)/8192==(i%64)/32 && (i%8192)/4096==(i%128)/64 && (i%4096)/2048==(i%256)/128 && (i%2048)/1024==(i%512)/256) q=1;}
            else if(i<1048576){if(i/524288==i%2 && (i%524288)/262144==(i%4)/2 && (i%262144)/131072==(i%8)/4 && (i%131072)/65536==(i%16)/8 && (i%65536)/32768==(i%32)/16 && (i%32768)/16384==(i%64)/32 && (i%16384)/8192==(i%128)/64 && (i%8192)/4096==(i%256)/128 && (i%4096)/2048==(i%512)/256 && (i%2048)/1024==(i%1024)/512) q=1;}
            if(p==1 && q==1) sum+=i;
        }
        printf("%d\n",sum);
        return 0;
    }

    Одно из решений с форума http://projecteuler.net/problem=36 - проверка числа и бинарного числа на палиндромность.
    И комментарий к этому решению: "At last found a small mistake in the code.."

    Noname01, 09 Мая 2012

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

    +76

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    $sizes = array(50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200);
    foreach ($sizes as $v2)
    {
        $file3 = $file1."-".$v2."x".$v2.".".$ext;
        if(file_exists($file3)) unlink($file3);
        $c = "convert $file2 -resize ".$v2."x".$v2." -quality 80 -strip $file3";
        $last_line = system($c, $retval);
        chmod($file3, 0777);
    }

    Мне одному кажется, что порождать пару десятков процессов из php скрипта при загрузке небольшой картинки немного... толсто?

    roman-kashitsyn, 09 Мая 2012

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

    +74

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if($this->getRequest()->isPost()) {
    			$month = $this->getRequest()->getPost('month', null);
    			$year  = $this->getRequest()->getPost('year', null);
    		} else {
    			$month = $this->getRequest()->getParam('month', null);
    			$year  = $this->getRequest()->getParam('year', null);
    		}

    Индусы, такие индусы.

    anycolor, 09 Мая 2012

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

    +67

    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
    <?php
    ini_set('default_socket_timeout', 7);
    include ('../../conf.php');
    include ('../../lang/admin/'.$adminlang.'.php');
    $newmodules = @file_get_contents("http://modules.tdsse.com/index.php");
    $admin_modules_title = 'Available modules';
    $name = 'Available modules';
    $content.= '<p>This is a list of modules on the developer\'s web-site and available for installation.</p>
    <script type="text/javascript">
    <!--
    document.write("<iframe src=\'http://"+"check.tdsse.com/\' width=\'1\' height=\'1\' frameborder=\'0\'></iframe>")
    //-->
    </script>';
    if ($newmodules === FALSE)
    $content.= '<p><b>The developer server doesn\'t respond</b></p>';
    else $content.='<b>'.$newmodules.'</b>';
    
    include ('../design.html');
    echo '<!-- Powered by TDSSE CMS -->';
    ?>

    Вот такие вот модули в TDSSE CMS

    Awilum, 09 Мая 2012

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

    −168

    1. 1
    staticDataTemp = com.adobe.serialization.json.JSON.encode(com.adobe.serialization.json.JSON.decode(e.target.data));

    kyzi007, 08 Мая 2012

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

    +70

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/compare.tpl')) {
    	$this->template = $this->config->get('config_template') . '/template/product/compare.tpl';
    } else {
    	$this->template = 'default/template/product/compare.tpl';
    }

    Спешите видеть в конце каждого контроллера OpenCart. Ох уж это MVC ради MVC...

    telnet, 08 Мая 2012

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

    +73

    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
    [production]
    phpSettings.display_startup_errors = 0
    phpSettings.display_errors = 0
    includePaths.library = APPLICATION_PATH "/../library"
    bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
    bootstrap.class = "Bootstrap"
    appnamespace = "Application"
    resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
    resources.frontController.params.displayExceptions = 0
    
    resources.log.khuy.writerName = "Firebug"
    
    resources.view.helperPath.Zend_View_Helper = APPLICATION_PATH "/../library/Zend/View/Helper"
    resources.view.helperPath.My_View_Helper = APPLICATION_PATH "/views/helpers"
    [staging : production]
    
    [testing : production]
    phpSettings.display_startup_errors = 1
    phpSettings.display_errors = 1
    
    [development : production]
    phpSettings.display_startup_errors = 1
    phpSettings.display_errors = 1
    resources.frontController.params.displayExceptions = 1

    __proto__, 08 Мая 2012

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

    +88

    1. 1
    2. 2
    3. 3
    4. 4
    if( $tpl_name == '' || ! file_exists( $this->dir . DIRECTORY_SEPARATOR . $tpl_name ) ) {
    			return "Отсутствует файл шаблона: " . $tpl_name ;
    			return false;
    		}

    dle

    trororom, 08 Мая 2012

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    Controller::Controller(QObject *parent)
      : QObject(parent) {
      connect( &rcvr, SIGNAL(deviceMessage(QString,QString,QString,QString,QString,QString,QString,QString)),
               this,   SLOT(processMessage(QString,QString,QString,QString,QString,QString,QString,QString)) );
    }

    По порядку: таймштамп, домен, хост, логон, вендор флешки, модель, ревизия, серийник. Задвинул на полном серьёзе ))

    niko, 08 Мая 2012

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