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

    +154

    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
    switch($step) {
            case 0:
                    setup_config_display_header();
    ?>
    <p><?php _e( 'Welcome to WordPress. Before getting started, we need some information on the database. You will need to know the following items before proceeding.' ) ?></p>
    <ol>
            <li><?php _e( 'Database name' ); ?></li>
            <li><?php _e( 'Database username' ); ?></li>
            <li><?php _e( 'Database password' ); ?></li>
            <li><?php _e( 'Database host' ); ?></li>
            <li><?php _e( 'Table prefix (if you want to run more than one WordPress in a single database)' ); ?></li>
    </ol>
    <p><strong><?php _e( "If for any reason this automatic file creation doesn’t work, don’t worry. All this does is fill in the database information to a configuration file. You may also simply open <code>wp-config-sample.php</code> in a text editor, fill in your information, and save it as <code>wp-config.php</code>." ); ?></strong></p>
    <p><?php _e( "In all likelihood, these items were supplied to you by your Web Host. If you do not have this information, then you will need to contact them before you can continue. If you’re all ready…" ); ?></p>
    <p class="step"><a href="setup-config.php?step=1<?php if ( isset( $_GET['noapi'] ) ) echo '&noapi'; ?>" class="button button-large"><?php _e( 'Let’s go!' ); ?></a></p>
    <?php
            break;
            case 1:
                    setup_config_display_header();
    //...
            case 2:
            foreach ( array( 'dbname', 'uname', 'pwd', 'dbhost', 'prefix' ) as $key )
                    $$key = trim( wp_unslash( $_POST[ $key ] ) );
            $tryagain_link = '</p><p class="step"><a href="setup-config.php?step=1" onclick="javascript:history.go(-1);return false;" class="button button-large">' . __( 'Try again' ) . '</a>';
            if ( empty( $prefix ) )
                    wp_die( __( '<strong>ERROR</strong>: "Table Prefix" must not be empty.' . $tryagain_link ) );
            // Validate $prefix: it can only contain letters, numbers and underscores.
            if ( preg_match( '|[^a-z0-9_]|i', $prefix ) )
                    wp_die( __( '<strong>ERROR</strong>: "Table Prefix" can only contain numbers, letters, and underscores.' . $tryagain_link ) );
            // Test the db connection.
            /**#@+
             * @ignore
             */
            define('DB_NAME', $dbname);
            define('DB_USER', $uname);
            define('DB_PASSWORD', $pwd);
            define('DB_HOST', $dbhost);
            /**#@-*/
            // We'll fail here if the values are no good.
            require_wp_db();
    
    // еще двести строк свитча с html, обработкой данных прямо на лету и даже небольшим количеством инлайн-js

    Захотел я подцепиться к внутреннему api установки вордпресса, чтобы эту самую установку делать через конфиг-файлы и композер. В результате проще оказалось имитировать окружение веб-сервера, заполнять всякие $_GET-$_POST и просто подключать нужный файл. А как они сами с этим адом работают - для меня остается загадкой

    Целиком https://core.trac.wordpress.org/browser/tags/3.9.2/src/wp-admin/setup-config.php и https://core.trac.wordpress.org/browser/tags/3.9.2/src/wp-admin/install.php

    Запостил: Fike, 30 Августа 2014

    Комментарии (1) RSS

    • 225	        // Not a PHP5-style by-reference foreach, as this file must be parseable by PHP4.

      Заботливые какие.
      Ответить

    Добавить комментарий