【发布时间】:2013-01-14 18:26:32
【问题描述】:
从昨天早上开始,我在使用 WP 3.2.1 通过 godaddy.com 托管的网站上出现以下错误。我现在知道该网站被黑了。我无权访问 WP admin CP,因为它也带有相同的错误:
解析错误:语法错误,第 192 行 /home/content/xx/xxxxx/html/websites/xxxxxxxx/wp-includes/functions.php 中的意外 T_VARIABLE
这是 php 文件中的代码行:
$mm = substr( $mysqlstring, 8, 2 ); // Mysql string Month
有人可以帮忙吗?
这是整个区块:
function size_format( $bytes, $decimals = 0 ) {
$quant = array(
// ========================= Origin ====
'TB' => 1099511627776, // pow( 1024, 4)
'GB' => 1073741824, // pow( 1024, 3)
'MB' => 1048576, // pow( 1024, 2)
'kB' => 1024, // pow( 1024, 1)
'B ' => 1, // pow( 1024, 0)
);
foreach ( $quant as $unit => $mag )
if ( doubl// Mysql string Year
$mm = substr( $mysqlstring, 8, 2 ); // Mysql string Month
$md = substr( $mysqlstring, 5, 2 ); // Mysql string day
$day = mktime( 0, 0, 0, $md, $mm, $my ); // The timestamp for mysqlstring day.
$weekday = date( 'w', $day ); // The day of the week from the timestamp
if ( !is_numeric($start_of_week) )
$start_of_week = get_option( 'start_of_week' );
if ( $weekday < $start_of_week )
$weekday += 7;
$start = $day - 86400 * ( $weekday - $start_of_week ); // The most recent week start day on or before $day
$end = $start + 604799; // $start + 7 days - 1 second
return compact( 'start', 'end' );
}
/**
* Unserialize value only if it was serialized.
*
* @since 2.0.0
*
* @param string $original Maybe unserialized original, if is needed.
* @return mixed Unserialized data can be any type.
*/
function maybe_unserialize( $original ) {
if ( is_serialized( $original ) ) // don't attempt to unserialize data that wasn't serialized going in
return @unserialize( $original );
return $original;
}
【问题讨论】:
-
你能贴出周围的代码——在这之前和之后几行吗?为什么您认为您的网站被黑客入侵了?
-
根据我的经验,错误通常与缺少分号
;的行有关。 -
答案很简单:从备份中恢复整个 WP 安装。
-
感谢您发布完整的函数体。语法错误非常明显。检查标记为错误的那一行之前的两行。这是一个不完整的陈述。如 cmets 中所述,最好的办法是从备份中恢复文件。也就是说,如果站点已被黑客入侵,您希望从备份中恢复整个站点,首先删除所有内容。
-
我在几个月未接触过的网站上安装 GoDaddy WP 时遇到了同样的问题。希望mods没有关闭这个话题。非常困惑是什么导致了这种情况。我将它与之前安装的旧版本 functions.php 进行了比较,并修复了 size_format 函数以解决我的问题。感谢发帖。