Warning: Cannot use a scalar value as an array in /home/admin/public_html/forum/include/fm.class.php on line 757

Warning: Invalid argument supplied for foreach() in /home/admin/public_html/forum/include/fm.class.php on line 770
Форумы портала PHP.SU :: Версия для печати :: Ужаснейшая и очень грустная ошибка Parse error: syntax error, unexpected $end
Форумы портала PHP.SU » PHP » Программирование на PHP » Ужаснейшая и очень грустная ошибка Parse error: syntax error, unexpected $end

Страниц (1): [1]
 

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

1) Я гуглил - не помогло - я не нашел причину ошибки.
2) Тему отредактировал - теперь только строчка с ошибкой.
4. Darth_Ixis - 02 Сентября, 2010 - 08:26:35 - перейти к сообщению
У вас обычная синтаксическая ошибка. Просмотрите свой код хорошенько, вероятно пропущены, либо обычные, либо фигурные скобки.

Если не помогло, вот что гугл нашептал.

Цитата:
Проблема: на страницах вылазит Parse error: syntax error, unexpected $end

Решение: разрешить PHP использование коротких тегов,
для этого добавляем или исправляем в php.ini опцию:
5. altermann - 02 Сентября, 2010 - 08:35:46 - перейти к сообщению
Когда я сталкивался с такими ошибками, я заметил что ошибка не всегда там куда указывает сообщение. У вас или где-то не хватает скобки, кавычки, или где-то лишняя
6. biperch - 02 Сентября, 2010 - 08:56:13 - перейти к сообщению
внимательней читай свой код
7. Uchkuma - 02 Сентября, 2010 - 09:05:25 - перейти к сообщению
altermann пишет:
Когда я сталкивался с такими ошибками, я заметил что ошибка не всегда там куда указывает сообщение.
Интерпретатор не телепат, он не знает где вы допустили ошибку. Он всего лишь указывает вам на место, где обнаружил неожиданный результат.
8. garvey - 02 Сентября, 2010 - 09:25:00 - перейти к сообщению
Это весь ваш код?
9. SAD - 02 Сентября, 2010 - 09:43:33 - перейти к сообщению
там кода больше 300 строк. возможные причины объяснили, но смотрите - необязательно ошибка именно в той строке
Uchkuma пишет:
Интерпретатор не телепат, он не знает где вы допустили ошибку. Он всего лишь указывает вам на место, где обнаружил неожиданный результат.
10. Mishcka - 02 Сентября, 2010 - 15:18:14 - перейти к сообщению
Darth_Ixis пишет:
У вас обычная синтаксическая ошибка. Просмотрите свой код хорошенько, вероятно пропущены, либо обычные, либо фигурные скобки.
Если не помогло, вот что гугл нашептал.

Он много чего нашептать может Улыбка Где я на хостинге найду этот файл?

altermann пишет:
Когда я сталкивался с такими ошибками, я заметил что ошибка не всегда там куда указывает сообщение. У вас или где-то не хватает скобки, кавычки, или где-то лишняя

Я подсчитал количество открывающих и закрывающих фигурных и обычных скобок -- количества совпадают. Я уже удалил все строки из этого файла, он занимает 0 байт, НО ошибка осталась и по-прежнему на 48-й строке.

biperch пишет:
внимательней читай свой код

Очень умно. В этом случае желаю вам тщательней думать прежде чем что-то писать Улыбка

garvey пишет:
Это весь ваш код?

Теперь весь - обновил.

SAD пишет:
там кода больше 300 строк. возможные причины объяснили, но смотрите - необязательно ошибка именно в той строке

Ни одна не оказалась той самой.
11. Мелкий - 02 Сентября, 2010 - 15:52:22 - перейти к сообщению
Mishcka пишет:
Теперь весь - обновил.

Проверяйте, что у вас реально на сервере расположено, представленный скрипт синтаксически корректен.
Особенно если учесть:
Mishcka пишет:
Я уже удалил все строки из этого файла, он занимает 0 байт, НО ошибка осталась и по-прежнему на 48-й строке.

Значит, тут не скрипт косячит, а кто-то что-то не оттуда читает.
12. altermann - 02 Сентября, 2010 - 16:01:28 - перейти к сообщению
PHP:
скопировать код в буфер обмена
  1. if ( method_exists( $wpdb, 'db_version' ) )
  2.    $mysql_version = preg_replace('/[^0-9.].*/', '', $wpdb->db_version());
  3. else
  4.    $mysql_version = 'N/A';


Мне кажеться тут скобок фигурных нехватает (строки 45-48)
13. Мелкий - 02 Сентября, 2010 - 16:27:24 - перейти к сообщению
altermann пишет:
Мне кажеться тут скобок фигурных нехватает (строки 45-48)

Они необязательны.

 

Powered by ExBB FM 1.0 RC1