PHP - syntax error

 
Vista:

syntax error

Publicado por ivan (5 intervenciones) el 10/12/2019 15:24:18
¡hola , quetal !
soy un novato en esto de programación, recientemente he tenido problemas con una pagina web me sale que tengo un error de syntaxis en la linea 116 pero no se como encontrar ese error especifico para repararla, podrian ayudarme por favor

este es

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
/**
 * Copyright (C) 2014-2018 ServMask Inc.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * ███████╗███████╗██████╗ ██╗   ██╗███╗   ███╗ █████╗ ███████╗██╗  ██╗
 * ██╔════╝██╔════╝██╔══██╗██║   ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
 * ███████╗█████╗  ██████╔╝██║   ██║██╔████╔██║███████║███████╗█████╔╝
 * ╚════██║██╔══╝  ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
 * ███████║███████╗██║  ██║ ╚████╔╝ ██║ ╚═╝ ██║██║  ██║███████║██║  ██╗
 * ╚══════╝╚══════╝╚═╝  ╚═╝  ╚═══╝  ╚═╝     ╚═╝╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝
 */
 
class Ai1wm_Database_Utility {
 
	/**
	 * Replace all occurrences of the search string with the replacement string.
	 * This function is case-sensitive.
	 *
	 * @param  array  $from List of string we're looking to replace.
	 * @param  array  $to   What we want it to be replaced with.
	 * @param  string $data Data to replace.
	 * @return mixed        The original string with all elements replaced as needed.
	 */
	public static function replace_values( $from = array(), $to = array(), $data = '' ) {
		if ( ! empty( $from ) && ! empty( $to ) ) {
			return strtr( $data, array_combine( $from, $to ) );
		}
		return $data;
	}
	/**
	 * Take a serialized array and unserialize it replacing elements as needed and
	 * unserializing any subordinate arrays and performing the replace on those too.
	 * This function is case-sensitive.
	 *
	 * @param  array $from       List of string we're looking to replace.
	 * @param  array $to         What we want it to be replaced with.
	 * @param  mixed $data       Used to pass any subordinate arrays back to in.
	 * @param  bool  $serialized Does the array passed via $data need serializing.
	 * @return mixed             The original array with all elements replaced as needed.
	 */
	public static function replace_serialized_values( $from = array(), $to = array(), $data = '', $serialized = false ) {
		try {
 
			// Some unserialized data cannot be re-serialized eg. SimpleXMLElements
			if ( is_serialized( $data ) && ( $unserialized = @unserialize( $data ) ) !== false ) {
				$data = self::replace_serialized_values( $from, $to, $unserialized, true );
			} elseif ( is_array( $data ) ) {
				$tmp = array();
				foreach ( $data as $key => $value ) {
					$tmp[ $key ] = self::replace_serialized_values( $from, $to, $value, false );
				}
 
				$data = $tmp;
				unset( $tmp );
			} elseif ( is_object( $data ) ) {
				$tmp   = $data;
				$props = get_object_vars( $data );
				foreach ( $props as $key => $value ) {
					$tmp->$key = self::replace_serialized_values( $from, $to, $value, false );
				}
 
				$data = $tmp;
				unset( $tmp );
			} else {
				if ( is_string( $data ) ) {
					if ( ! empty( $from ) && ! empty( $to ) ) {
						$data = strtr( $data, array_combine( $from, $to ) );
					}
				}
			}
 
			if ( $serialized ) {
				return serialize( $data );
			}
		} catch ( Exception $e ) {
			// pass
		}
 
		return $data;
	}
 
	/**
	 * Escape MySQL special characters
	 *
	 * @param  string $data Data to replace.
	 * @return string
	 */
	public static function escape_mysql( $data ) {
		return strtr(
			$data,
			array_combine(
				array( "\x00", "\n", "\r", '\\', "'", '"', "\x1a" ),
				array( '\\0', '\\n', '\\r', '\\\\', "\\'", '\\"', '\\Z' )
			)
		);
	}
	/**
	 * Unescape MySQL spe]X
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de joel
Val: 3.828
Oro
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

syntax error

Publicado por joel (1269 intervenciones) el 10/12/2019 20:04:38
Ivan, solo hay 114 lineas!!! puede ser que te hayas dejado de copiar parte del código?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

syntax error

Publicado por ivan (5 intervenciones) el 10/12/2019 22:08:42
lo siento al parecer el resto del error no se puede enviar, pareciera ser símbolos chinos o algo así, un archivo corrupto.
<?php
/**
* Copyright (C) 2014-2018 ServMask Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
*/

class Ai1wm_Database_Utility {

/**
* Replace all occurrences of the search string with the replacement string.
* This function is case-sensitive.
*
* @param array $from List of string we're looking to replace.
* @param array $to What we want it to be replaced with.
* @param string $data Data to replace.
* @return mixed The original string with all elements replaced as needed.
*/
public static function replace_values( $from = array(), $to = array(), $data = '' ) {
if ( ! empty( $from ) && ! empty( $to ) ) {
return strtr( $data, array_combine( $from, $to ) );
}

return $data;
}

/**
* Take a serialized array and unserialize it replacing elements as needed and
* unserializing any subordinate arrays and performing the replace on those too.
* This function is case-sensitive.
*
* @param array $from List of string we're looking to replace.
* @param array $to What we want it to be replaced with.
* @param mixed $data Used to pass any subordinate arrays back to in.
* @param bool $serialized Does the array passed via $data need serializing.
* @return mixed The original array with all elements replaced as needed.
*/
public static function replace_serialized_values( $from = array(), $to = array(), $data = '', $serialized = false ) {
try {

// Some unserialized data cannot be re-serialized eg. SimpleXMLElements
if ( is_serialized( $data ) && ( $unserialized = @unserialize( $data ) ) !== false ) {
$data = self::replace_serialized_values( $from, $to, $unserialized, true );
} elseif ( is_array( $data ) ) {
$tmp = array();
foreach ( $data as $key => $value ) {
$tmp[ $key ] = self::replace_serialized_values( $from, $to, $value, false );
}

$data = $tmp;
unset( $tmp );
} elseif ( is_object( $data ) ) {
$tmp = $data;
$props = get_object_vars( $data );
foreach ( $props as $key => $value ) {
$tmp->$key = self::replace_serialized_values( $from, $to, $value, false );
}

$data = $tmp;
unset( $tmp );
} else {
if ( is_string( $data ) ) {
if ( ! empty( $from ) && ! empty( $to ) ) {
$data = strtr( $data, array_combine( $from, $to ) );
}
}
}

if ( $serialized ) {
return serialize( $data );
}
} catch ( Exception $e ) {
// pass
}

return $data;
}

/**
* Escape MySQL special characters
*
* @param string $data Data to replace.
* @return string
*/
public static function escape_mysql( $data ) {
return strtr(
$data,
array_combine(
array( "\x00", "\n", "\r", '\\', "'", '"', "\x1a" ),
array( '\\0', '\\n', '\\r', '\\\\', "\\'", '\\"', '\\Z' )
)
);
}

/**
* Unescape MySQL spe]X
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de joel
Val: 3.828
Oro
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

syntax error

Publicado por joel (1269 intervenciones) el 11/12/2019 08:48:28
Ivan, entonces, añádelo como archivo adjunto comprimido...

debajo de este formulario, hay un botón para "Adjuntar Archivos"
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de José Manuel
Val: 150
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

syntax error

Publicado por José Manuel (62 intervenciones) el 16/12/2019 12:08:51
Hola Iván:

Es simple, el archivo que indicas está corrupto. No puedes utilizarlo, tienes que obtenerlo de nuevo. La clase que indicas pertenece si no me equivoco, al plugin All In One WP Migration cuyo código está disponible aquí:

https://github.com/resource-watch/resource-watch-blog/tree/master/www/wp-content/plugins/all-in-one-wp-migration/lib/vendor/servmask/database

Bájate de nuevo el fichero o copia el código fuente, quizás esto solucione el problema que tienes. Dinos algo. Un saludo,
https://obelearningservices.com/blog/
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

syntax error

Publicado por ivan (5 intervenciones) el 16/12/2019 13:50:01
muchas gracias , voy a intentar resolverlo de esa manera, cualquier cosa les comento
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

syntax error

Publicado por ivan (5 intervenciones) el 16/12/2019 14:10:38
intente copiar el codigo fuente pero ahora me dice que tiene un error en la linea 56

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
/**
 * Copyright (C) 2014-2018 ServMask Inc.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * ███████╗███████╗██████╗ ██╗   ██╗███╗   ███╗ █████╗ ███████╗██╗  ██╗
 * ██╔════╝██╔════╝██╔══██╗██║   ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
 * ███████╗█████╗  ██████╔╝██║   ██║██╔████╔██║███████║███████╗█████╔╝
 * ╚════██║██╔══╝  ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
 * ███████║███████╗██║  ██║ ╚████╔╝ ██║ ╚═╝ ██║██║  ██║███████║██║  ██╗
 * ╚══════╝╚══════╝╚═╝  ╚═╝  ╚═══╝  ╚═╝     ╚═╝╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝
 */
class Ai1wm_Database_Utility {
	/**
	 * Replace all occurrences of the search string with the replacement string.
	 * This function is case-sensitive.
	 *
	 * @param  array  $from List of string we're looking to replace.
	 * @param  array  $to   What we want it to be replaced with.
	 * @param  string $data Data to replace.
	 * @return mixed        The original string with all elements replaced as needed.
	 */
	public static function replace_values( $from = array(), $to = array(), $data = '' ) {
		if ( ! empty( $from ) && ! empty( $to ) ) {
			return strtr( $data, array_combine( $from, $to ) );
		}
		return $data;
	}
	/**
	 * Take a serialized array and unserialize it replacing elements as needed and
	 * unserializing any subordinate arrays and performing the replace on those too.
	 * This function is case-sensitive.
	 *
	 * @param  array $from       List of string we're looking to replace.
	 * @param  array $to         What we want it to be replaced with.
	 * @param  mixed $data       Used to pass any subordinate arrays back to in.
	 * @param  bool  $serialized Does the array passed via $data need serializing.
	 * @return mixed             The original array with all elements replaced as needed.
	 */
	public static function replace_serialized_values( $from = array(), $to = array(), $data = '', $serialized = false ) {
		try {
			// Some unserialized data cannot be re-serialized eg. SimpleXMLElements
			if ( is_serialized( $data ) && ( $unserialized = @unserialize( $data ) ) !== false ) {
				$data = self::replace_serialized_values( $from, $to, $unserialized, true );
			} elseif ( is_array( $data ) ) {
				$tmp = array();
				foreach ( $data as $key => $value ) {
					$tmp[ $key ] = self::replace_serialized_values( $from, $to, $value, false );
				}
				$data = $tmp;
				unset( $tmp );
			} elseif ( is_object( $data ) ) {
				$tmp   = $data;
				$props = get_object_vars( $data );
				foreach ( $props as $key => $value ) {
					$tmp->$key = self::replace_serialized_values( $from, $to, $value, false );
				}
				$data = $tmp;
				unset( $tmp );
			} else {
				if ( is_string( $data ) ) {
					if ( ! empty( $from ) && ! empty( $to ) ) {
						$data = strtr( $data, array_combine( $from, $to ) );
					}
				}
			}
			if ( $serialized ) {
				return serialize( $data );
			}
		} catch ( Exception $e ) {
			// pass
		}
		return $data;
	}
	/**
	 * Escape MySQL special characters
	 *
	 * @param  string $data Data to replace.
	 * @return string
	 */
	public static function escape_mysql( $data ) {
		return strtr(
			$data,
			array_combine(
				array( "\x00", "\n", "\r", '\\', "'", '"', "\x1a" ),
				array( '\\0', '\\n', '\\r', '\\\\', "\\'", '\\"', '\\Z' )
			)
		);
	}
	/**
	 * Unescape MySQL special characters
	 *
	 * @param  string $data Data to replace.
	 * @return string
	 */
	public static function unescape_mysql( $data ) {
		return strtr(
			$data,
			array_combine(
				array( '\\0', '\\n', '\\r', '\\\\', "\\'", '\\"', '\\Z' ),
				array( "\x00", "\n", "\r", '\\', "'", '"', "\x1a" )
			)
		);
	}
}
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de José Manuel
Val: 150
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

syntax error

Publicado por José Manuel (62 intervenciones) el 16/12/2019 14:46:59
Hola de nuevo Iván:

Este es el fichero cuyo código debes copiar (en GitHub):
https://github.com/resource-watch/resource-watch-blog/blob/master/www/wp-content/plugins/all-in-one-wp-migration/lib/vendor/servmask/database/class-ai1wm-database-utility.php

Para evitar problemas, copialo usando el botón [Raw] que está en la parte superior izquierda. He probado el código y no me da error en ninguna parte. Lo que no sé es si lo estás usando conjuntamente con otro código y ahí empiezan a aparecer los problemas.

¿Quizás estás haciendo uso de la función replace_serialized_values (línea 56) y no la estás usando correctamente? Con los datos que nos das no puedo hacer nada más. Dinos algo.

Un saludo,
https://obelearningservices.com/blog/
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de joel
Val: 3.828
Oro
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

syntax error

Publicado por joel (1269 intervenciones) el 16/12/2019 15:39:47
Exactamente que error te da?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de joel
Val: 3.828
Oro
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

syntax error

Publicado por joel (1269 intervenciones) el 16/12/2019 13:24:52
Como dice José Miguel, este archivo esta corrupto... al final esta como compilado o algo extraño.

De donde has sacado ese archivo?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar