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. 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)
  3. 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)
  4. 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)
  5. 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)
  6. 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)
  7. 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)
  8. PHP / Говнокод #10213

    +75

    1. 1
    2. 2
    3. 3
    4. 4
    require( "./configuration.php" );
    include( "./include.php" );
    $returned = @( );
    if ( ( $returned ) != @( "harper" ) )

    cthulhu25, 07 Мая 2012

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

    +80

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    $F = 0;
    if ($F == "0") {
    include ("index-bd.php");
    }
    else {
    include ("../index-bd.php");
    };

    И так подключатся все файлы в проекте.

    Evil_Wolf, 07 Мая 2012

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

    +79

    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
    //первый сайт - интернет магазин
    //отрывок из функции редактирования, функции добавления, функции удаления товаров, в таблицу "export_catalogue" каждая строка - это "поле товара" и "новое значение поля"
    //что-то на подобие лога изменений. Конечно копипаст всех полей товаров.
    $this->insert($table = "`export_catalogue`", $fields = "`action`, `table`, `element`, `fields`, `value`", $values="'update', 'catalogue_files', '$catalogue_id', 'name_rus', '$name_rus'");
    $this->insert($table = "`export_catalogue`", $fields = "`action`, `table`, `element`, `fields`, `value`", $values="'update', 'catalogue_files', '$catalogue_id', 'name_ger', '$name_ger'");
    
    //файл xml_create_catalogue.php, который запускается по крону каждые 5 минут, создаёт xml файлы. Каждый файл содержит в себе изменение одного поля товара
    $result_export_array = $global->select_all($fields = "*", $table = "`export_catalogue`", $where = "`create` = '0' ORDER BY `id` ASC");
    for ($i=0; $i<count($result_export_array); $i++){
      $doc = new DOMDocument('1.0', 'utf-8');
      $doc->formatOutput = true;
      ...
      // название fields - не мой коммент
      $fields = $doc->createElement('fields');
      $fields = $root->appendChild($fields);
      // данные element - не мой коммент
      $data_fields = $doc->createTextNode($result_export_array[$i]['fields']);
      $data_fields = $fields->appendChild($data_fields);
      ...
      //если картинка или файл товара, то файл кодируется в бэйс64 и записывается в ячейку xml
      $value_default = $result_export_array[$i]['value'].'photo_data'.base64_encode($contents);
      $value_convert = mb_convert_encoding($value_default, "UTF-8", "Windows-1251");
      $data_value = $doc->createTextNode($value_convert);
      ...
      //почетка, что файл экспорта создан
      $global->update($table = "`export_catalogue`", $fields = "`create` = '1'", $where = "`id` = '".$result_export_array[$i]['id']."'");
    }
    
    //файл xml_upload_catalogue.php, крон - 5 минут, копирует созданные xml файлы на фтп второго сайта
    $result_export_array = $global->select_all($fields = "*", $table = "`export_catalogue`", $where = "`upload` = '0' ORDER BY `id` ASC");
     for ($i=0; $i<count($result_export_array); $i++){
      ... //тут идёт копирование файлов по фтп
      //пометка, что файл загружен на второй сайт
      $global->update($table = "`export_catalogue`", $fields = "`upload` = '1'", $where = "`id` = '$file_id'"); 
    }
    
    //второй сайт - интернет магазин
    //xml_import_catalogue.php по крону, проверяется наличие xml файлов и поля импортируются в каталог
    //цикл по списку файлов
    foreach ($file_list as $key => $file_name) {
      //в таблицу import_catalogue записывается, какие файлы были импортированны 
      $next_file_array = $global->select_only($fields = "*", $table = "`import_catalogue`", $where = "`id` != '0' ORDER BY `id` DESC LIMIT 1");
      //причем имя файла(числовое) должно быть обязательно на 1 больше последнего записанного в таблице 
      $next_file = intval($next_file_array['id'] + 1).'.xml';
      ...
      //апдейт поля товара
      $value_convert = mb_convert_encoding($value_xml, "Windows-1251", "UTF-8");
      $global->update($table = "`$table_xml`", $fields = "`$fields_xml` = '".$global->sql_prepare($value_convert)."'", $where = "`id` = '$element_xml'");
      ...
      //помечаем, что файл импортирован и удаляем
      $global->insert($table = "`import_catalogue`", $fields = "`joined`", $values="'$joined'");
    }

    Самый идеальный экспорт товаров из одного сайта в другой. Приведены отрывки кода из двух сайтов на каждом этапе экспорта

    Cool-Di, 05 Мая 2012

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