За последние 24 часа нас посетили 54982 программиста и 1682 робота. Сейчас ищут 1118 программистов ...

Грустная ошибка Parse error: syntax error, unexpected $end

Тема в разделе "Прочие вопросы по PHP", создана пользователем Mishcka, 2 сен 2010.

  1. Mishcka

    Mishcka Активный пользователь

    С нами с:
    1 июл 2009
    Сообщения:
    41
    Симпатии:
    0
    Превед, робяты! Возникла непредвиденная ошибка:
    Parse error: syntax error, unexpected $end in /home/vhosts/plotnikova.com/wp-admin/includes/update.php on line 48.
    Кто знает что за фигня?
    Вот код:
    PHP:
    1. <?php
    2. /**
    3.  * A simple set of functions to check our version 1.0 update service.
    4.  *
    5.  * @package WordPress
    6.  * @since 2.3.0
    7.  */
    8.  
    9. /**
    10.  * Check WordPress version against the newest version.
    11.  *
    12.  * The WordPress version, PHP version, and Locale is sent. Checks against the
    13.  * WordPress server at api.wordpress.org server. Will only check if WordPress
    14.  * isn't installing.
    15.  *
    16.  * @package WordPress
    17.  * @since 2.3.0
    18.  * @uses $wp_version Used to check against the newest WordPress version.
    19.  *
    20.  * @return mixed Returns null if update is unsupported. Returns false if check is too soon.
    21.  */
    22.  
    23.  
    24. function wp_version_check() {
    25.     if ( defined('WP_INSTALLING') )
    26.         return;
    27.  
    28.     global $wp_version, $wpdb, $wp_local_package;
    29.     $php_version = phpversion();
    30.  
    31.     $current = get_transient( 'update_core' );
    32.     if ( ! is_object($current) ) {
    33.         $current = new stdClass;
    34.         $current->updates = array();
    35.         $current->version_checked = $wp_version;
    36.     }
    37.  
    38.     $locale = apply_filters( 'core_version_check_locale', get_locale() );
    39.  
    40.     // Update last_checked for current to prevent multiple blocking requests if request hangs
    41.     $current->last_checked = time();
    42.     set_transient( 'update_core', $current );
    43.  
    44.     if ( method_exists( $wpdb, 'db_version' ) )
    45.         $mysql_version = preg_replace('/[^0-9.].*/', '', $wpdb->db_version());
    46.     else
    47.         $mysql_version = 'N/A';
    48.     $local_package = isset( $wp_local_package ) ? $wp_local_package : '';
    49.     $url = 'http://api.wordpress.org/core/version-check/1.3/?version=$wp_version&php=$php_version&locale=$locale&mysql=$mysql_version&local_package=$local_package';
    50.  
    51.  
    52. $options = array(
    53.         'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3),
    54.         'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
    55.     );
    56.  
    57.     $response = wp_remote_get($url, $options);
    58.  
    59.     if ( is_wp_error( $response ) )
    60.         return false;
    61.  
    62.     if ( 200 != $response['response']['code'] )
    63.         return false;
    64.  
    65.     $body = trim( $response['body'] );
    66.     $body = str_replace(array("\r\n", "\r"), "\n", $body);
    67.     $new_options = array();
    68.     foreach( explode( "\n\n", $body ) as $entry) {
    69.         $returns = explode("\n", $entry);
    70.         $new_option = new stdClass();
    71.         $new_option->response = esc_attr( $returns[0] );
    72.         if ( isset( $returns[1] ) )
    73.             $new_option->url = esc_url( $returns[1] );
    74.         if ( isset( $returns[2] ) )
    75.             $new_option->package = esc_url( $returns[2] );
    76.         if ( isset( $returns[3] ) )
    77.             $new_option->current = esc_attr( $returns[3] );
    78.         if ( isset( $returns[4] ) )
    79.             $new_option->locale = esc_attr( $returns[4] );
    80.         $new_options[] = $new_option;
    81.     }
    82.  
    83.     $updates = new stdClass();
    84.     $updates->updates = $new_options;
    85.     $updates->last_checked = time();
    86.     $updates->version_checked = $wp_version;
    87.     set_transient( 'update_core',  $updates);
    88. }
    89.  
    90. /**
    91.  * Check plugin versions against the latest versions hosted on WordPress.org.
    92.  *
    93.  * The WordPress version, PHP version, and Locale is sent along with a list of
    94.  * all plugins installed. Checks against the WordPress server at
    95.  * api.wordpress.org. Will only check if WordPress isn't installing.
    96.  *
    97.  * @package WordPress
    98.  * @since 2.3.0
    99.  * @uses $wp_version Used to notidy the WordPress version.
    100.  *
    101.  * @return mixed Returns null if update is unsupported. Returns false if check is too soon.
    102.  */
    103. function wp_update_plugins() {
    104.     global $wp_version;
    105.  
    106.     if ( defined('WP_INSTALLING') )
    107.         return false;
    108.  
    109.     // If running blog-side, bail unless we've not checked in the last 12 hours
    110.     if ( !function_exists( 'get_plugins' ) )
    111.         require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
    112.  
    113.     $plugins = get_plugins();
    114.     $active  = get_option( 'active_plugins' );
    115.     $current = get_transient( 'update_plugins' );
    116.     if ( ! is_object($current) )
    117.         $current = new stdClass;
    118.  
    119.     $new_option = new stdClass;
    120.     $new_option->last_checked = time();
    121.     $timeout = 'load-plugins.php' == current_filter() ? 3600 : 43200; //Check for updated every 60 minutes if hitting the themes page, Else, check every 12 hours
    122.     $time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked );
    123.  
    124.     $plugin_changed = false;
    125.     foreach ( $plugins as $file => $p ) {
    126.         $new_option->checked[ $file ] = $p['Version'];
    127.  
    128.         if ( !isset( $current->checked[ $file ] ) || strval($current->checked[ $file ]) !== strval($p['Version']) )
    129.             $plugin_changed = true;
    130.     }
    131.  
    132.     if ( isset ( $current->response ) && is_array( $current->response ) ) {
    133.         foreach ( $current->response as $plugin_file => $update_details ) {
    134.             if ( ! isset($plugins[ $plugin_file ]) ) {
    135.                 $plugin_changed = true;
    136.                 break;
    137.             }
    138.         }
    139.     }
    140.  
    141.     // Bail if we've checked in the last 12 hours and if nothing has changed
    142.     if ( $time_not_changed && !$plugin_changed )
    143.         return false;
    144.  
    145.     // Update last_checked for current to prevent multiple blocking requests if request hangs
    146.     $current->last_checked = time();
    147.     set_transient( 'update_plugins', $current );
    148.  
    149.     $to_send = (object)compact('plugins', 'active');
    150.  
    151.     $options = array(
    152.         'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3),
    153.         'body' => array( 'plugins' => serialize( $to_send ) ),
    154.         'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
    155.     );
    156.  
    157.     $raw_response = wp_remote_post('http://api.wordpress.org/plugins/update-check/1.0/', $options);
    158.  
    159.     if ( is_wp_error( $raw_response ) )
    160.         return false;
    161.  
    162.     if( 200 != $raw_response['response']['code'] )
    163.         return false;
    164.  
    165.     $response = unserialize( $raw_response['body'] );
    166.  
    167.     if ( false !== $response )
    168.         $new_option->response = $response;
    169.     else
    170.         $new_option->response = array();
    171.  
    172.     set_transient( 'update_plugins', $new_option );
    173. }
    174.  
    175. /**
    176.  * Check theme versions against the latest versions hosted on WordPress.org.
    177.  *
    178.  * A list of all themes installed in sent to WP. Checks against the
    179.  * WordPress server at api.wordpress.org. Will only check if WordPress isn't
    180.  * installing.
    181.  *
    182.  * @package WordPress
    183.  * @since 2.7.0
    184.  * @uses $wp_version Used to notidy the WordPress version.
    185.  *
    186.  * @return mixed Returns null if update is unsupported. Returns false if check is too soon.
    187.  */
    188. function wp_update_themes( ) {
    189.     global $wp_version;
    190.  
    191.     if( defined( 'WP_INSTALLING' ) )
    192.         return false;
    193.  
    194.     if( !function_exists( 'get_themes' ) )
    195.         require_once( ABSPATH . 'wp-includes/theme.php' );
    196.  
    197.     $installed_themes = get_themes( );
    198.     $current_theme = get_transient( 'update_themes' );
    199.     if ( ! is_object($current_theme) )
    200.         $current_theme = new stdClass;
    201.  
    202.     $new_option = new stdClass;
    203.     $new_option->last_checked = time( );
    204.     $timeout = 'load-themes.php' == current_filter() ? 3600 : 43200; //Check for updated every 60 minutes if hitting the themes page, Else, check every 12 hours
    205.     $time_not_changed = isset( $current_theme->last_checked ) && $timeout > ( time( ) - $current_theme->last_checked );
    206.  
    207.     $themes = array();
    208.     $checked = array();
    209.     $themes['current_theme'] = (array) $current_theme;
    210.     foreach( (array) $installed_themes as $theme_title => $theme ) {
    211.         $themes[$theme['Stylesheet']] = array();
    212.         $checked[$theme['Stylesheet']] = $theme['Version'];
    213.  
    214.         foreach( (array) $theme as $key => $value ) {
    215.             $themes[$theme['Stylesheet']][$key] = $value;
    216.         }
    217.     }
    218.  
    219.     $theme_changed = false;
    220.     foreach ( $checked as $slug => $v ) {
    221.         $new_option->checked[ $slug ] = $v;
    222.  
    223.         if ( !isset( $current_theme->checked[ $slug ] ) || strval($current_theme->checked[ $slug ]) !== strval($v) )
    224.             $theme_changed = true;
    225.     }
    226.  
    227.     if ( isset ( $current_theme->response ) && is_array( $current_theme->response ) ) {
    228.         foreach ( $current_theme->response as $slug => $update_details ) {
    229.             if ( ! isset($checked[ $slug ]) ) {
    230.                 $theme_changed = true;
    231.                 break;
    232.             }
    233.         }
    234.     }
    235.  
    236.     if( $time_not_changed && !$theme_changed )
    237.         return false;
    238.  
    239.     // Update last_checked for current to prevent multiple blocking requests if request hangs
    240.     $current_theme->last_checked = time();
    241.     set_transient( 'update_themes', $current_theme );
    242.  
    243.     $current_theme->template = get_option( 'template' );
    244.  
    245.     $options = array(
    246.         'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3),
    247.         'body'          => array( 'themes' => serialize( $themes ) ),
    248.         'user-agent'    => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
    249.     );
    250.  
    251.     $raw_response = wp_remote_post( 'http://api.wordpress.org/themes/update-check/1.0/', $options );
    252.  
    253.     if( is_wp_error( $raw_response ) )
    254.         return false;
    255.  
    256.     if( 200 != $raw_response['response']['code'] )
    257.         return false;
    258.  
    259.     $response = unserialize( $raw_response['body'] );
    260.     if( $response ) {
    261.         $new_option->checked = $checked;
    262.         $new_option->response = $response;
    263.     }
    264.  
    265.     set_transient( 'update_themes', $new_option );
    266. }
    267.  
    268. function _maybe_update_core() {
    269.     global $wp_version;
    270.  
    271.     $current = get_transient( 'update_core' );
    272.  
    273.     if ( isset( $current->last_checked ) &&
    274.         43200 > ( time() - $current->last_checked ) &&
    275.         isset( $current->version_checked ) &&
    276.         $current->version_checked == $wp_version )
    277.         return;
    278.  
    279.     wp_version_check();
    280. }
    281. /**
    282.  * Check the last time plugins were run before checking plugin versions.
    283.  *
    284.  * This might have been backported to WordPress 2.6.1 for performance reasons.
    285.  * This is used for the wp-admin to check only so often instead of every page
    286.  * load.
    287.  *
    288.  * @since 2.7.0
    289.  * @access private
    290.  */
    291. function _maybe_update_plugins() {
    292.     $current = get_transient( 'update_plugins' );
    293.     if ( isset( $current->last_checked ) && 43200 > ( time() - $current->last_checked ) )
    294.         return;
    295.     wp_update_plugins();
    296. }
    297.  
    298. /**
    299.  * Check themes versions only after a duration of time.
    300.  *
    301.  * This is for performance reasons to make sure that on the theme version
    302.  * checker is not run on every page load.
    303.  *
    304.  * @since 2.7.0
    305.  * @access private
    306.  */
    307. function _maybe_update_themes( ) {
    308.     $current = get_transient( 'update_themes' );
    309.     if( isset( $current->last_checked ) && 43200 > ( time( ) - $current->last_checked ) )
    310.         return;
    311.  
    312.     wp_update_themes();
    313. }
    314.  
    315. add_action( 'admin_init', '_maybe_update_core' );
    316. add_action( 'wp_version_check', 'wp_version_check' );
    317.  
    318. add_action( 'load-plugins.php', 'wp_update_plugins' );
    319. add_action( 'load-update.php', 'wp_update_plugins' );
    320. add_action( 'load-update-core.php', 'wp_update_plugins' );
    321. add_action( 'admin_init', '_maybe_update_plugins' );
    322. add_action( 'wp_update_plugins', 'wp_update_plugins' );
    323.  
    324. add_action( 'load-themes.php', 'wp_update_themes' );
    325. add_action( 'load-update.php', 'wp_update_themes' );
    326. add_action( 'admin_init', '_maybe_update_themes' );
    327. add_action( 'wp_update_themes', 'wp_update_themes' );
    328.  
    329. if ( !wp_next_scheduled('wp_version_check') && !defined('WP_INSTALLING') )
    330.     wp_schedule_event(time(), 'twicedaily', 'wp_version_check');
    331.  
    332. if ( !wp_next_scheduled('wp_update_plugins') && !defined('WP_INSTALLING') )
    333.     wp_schedule_event(time(), 'twicedaily', 'wp_update_plugins');
    334.  
    335. if ( !wp_next_scheduled('wp_update_themes') && !defined('WP_INSTALLING') )
    336.     wp_schedule_event(time(), 'twicedaily', 'wp_update_themes');
    337. ?>
    338.  
     
  2. Ещё один программер

    Ещё один программер Активный пользователь

    С нами с:
    2 сен 2010
    Сообщения:
    5
    Симпатии:
    0
    Адрес:
    Довольно-таки средняя Азия
    Думаю, PHP не понимает яваскриптовскую конструкцию условия:

    [js]$local_package = isset( $wp_local_package ) ? $wp_local_package : '';[/js]

    и считает, что точка с запятой должна быть после

    PHP:
    1. $local_package = isset( $wp_local_package )
    [/code]

    хотя могу ошибаться - не пробовал пользоваться этим в РНР
     
  3. iliavlad

    iliavlad Активный пользователь

    С нами с:
    24 янв 2009
    Сообщения:
    1.689
    Симпатии:
    4
    Mishcka
    это вообще тот файл, в котором ошибка?)
     
  4. Апельсин

    Апельсин Активный пользователь

    С нами с:
    20 мар 2010
    Сообщения:
    3.645
    Симпатии:
    2
  5. Mishcka

    Mishcka Активный пользователь

    С нами с:
    1 июл 2009
    Сообщения:
    41
    Симпатии:
    0
    Нет, это первый попавшийся файл, зачем мне файл в котором ошибка - я же хочу вам мозги попарить очень долго.
     
  6. Апельсин

    Апельсин Активный пользователь

    С нами с:
    20 мар 2010
    Сообщения:
    3.645
    Симпатии:
    2
    else
    $mysql_version = 'N/A';

    заключи с фигурные скобки или отдели пустой строкой от $local_package = isset( $wp_local_package ) ? $wp_local_package : '';
     
  7. Mishcka

    Mishcka Активный пользователь

    С нами с:
    1 июл 2009
    Сообщения:
    41
    Симпатии:
    0
    Ситуация не изменилась - надо бы еще придумать что-нибудь.
     
  8. Апельсин

    Апельсин Активный пользователь

    С нами с:
    20 мар 2010
    Сообщения:
    3.645
    Симпатии:
    2
    Mishcka
    начни вырезать по строке около 48й строчки, пока не найдешь проблемную. Вот в нее и смотри
     
  9. igordata

    igordata Суперстар
    Команда форума Модератор

    С нами с:
    18 мар 2010
    Сообщения:
    32.408
    Симпатии:
    1.768
    вынеси wp_version_check в отдельный файл. есть мысль, что косяк где-то раньше-позже этого места.
     
  10. neverlose

    neverlose Активный пользователь

    С нами с:
    27 авг 2008
    Сообщения:
    1.112
    Симпатии:
    20
    Видимо так оно и есть.
     
  11. iliavlad

    iliavlad Активный пользователь

    С нами с:
    24 янв 2009
    Сообщения:
    1.689
    Симпатии:
    4
    Mishcka
    вы не обижайтесь, пожалуйста, просто если поискать $end, который приводит к ошибке, то его нет в приведенном вами файле.
     
  12. Koc

    Koc Активный пользователь

    С нами с:
    3 мар 2008
    Сообщения:
    2.253
    Симпатии:
    0
    Адрес:
    \Ukraine\Dnepropetrovsk
    iliavlad
    $end в данном случае не переменная $end. Имеется в виду, что неожиданный конец файла.

    топикстартер, перекачай вордпресс и перезалей файло.
     
  13. iliavlad

    iliavlad Активный пользователь

    С нами с:
    24 янв 2009
    Сообщения:
    1.689
    Симпатии:
    4
    Koc
    не знал. теперь буду)