Php file contains Chinese garbled characters. Do you know how to parse garbled text into Chinese?
Class Database
{
/*************************************** **************
** MySQL ????????????
**************************************** *************/
Var $ db;
Var $ seconds;
Var $ queries;
Var $ timer = 0;
Var $ querytimes = array ();
Var $ duration = '';
Public $ connectData = true;
/*************************************** **************
**??????,?????????
**************************************** *************/
Function Database ($ server = '', $ username ='', $ password = '', $ database = '')
{
Global $ site_engine_root;
// $ This-> seconds = $ this-> currentTime ();
If (''= $ server)
{
/*************************************** **************
**????????????????
**************************************** *************/
$ Server = $ GLOBALS ['DB _ host'];
$ Username = $ GLOBALS ['DB _ user'];
$ Password = $ GLOBALS ['DB _ pass'];
$ Database = $ GLOBALS ['DB _ name'];
}
/*************************************** **************
**?????????
**************************************** *************/
If (! $ This-> db = @ mysql_pconnect ($ server, $ username, $ password ))
{
If ($ username = 'root' & $ database = 'siteengine ')
{
@ Header ("Location:/install. php ");
}
Else
{
$ This-> connectData = false;
// $ This-> error ("database connect fail ");
}
}
If ($ database & $ this-> connectData = true)
{
If ($ this-> version ()> '4. 1 ')
{
Global $ config_charset;
$ Config_charset = 'utf-8 ';
If (! $ Dbcharset & in_array (strtolower ($ config_charset), array ('gbk', 'big5', 'utf-8 ')))
{
$ Dbcharset = str_replace ('-', '', $ config_charset );
}
If ($ dbcharset)
{
Mysql_query ("set names '$ dbcharset '");
}
}
If ($ this-> version ()> '5. 0.1 ')
{
Mysql_query ("SET SQL _mode = ''");
}
$ This-> selectDb ($ database );
}
Return true;
}
/*************************************** **************
**????????????
**************************************** *************/
Function disconnect ()
{
$ Result = mysql_close () or $ this-> error ();
Return $ result;
}
/*************************************** **************
**????????
**************************************** *************/
Function selectDb ($ database)
{
Global $ multidomain, $ site_engine_root, $ tablepre, $ db;
If (@ mysql_select_db ($ database, $ this-> db ))
{
Return true;
}
Else
{
If ($ multidomain = 1)
{
$ Query = $ this-> query ("create database". $ database );
@ Header ("Location:/install. php ");
// Require $ site_engine_root. 'Lib/query. php ';
// $ Fp = @ fopen ($ site_engine_root. 'data/SQL/siteengine. SQL ', "r ");
// $ Query = @ fread ($ fp, filesize ($ site_engine_root. 'data/SQL/siteengine. SQL '));
// @ Fclose ($ fp );
// If ($ tablepre! = 'Boka ') $ query = str_replace ("boka _", $ tablepre, $ query );
// $ SQL _query = new query ($ query );
// $ SQL _query-> doquery ();
// @ Header ("Location:/index. php ");
}
$ This-> error ("$ database connect error! ");
}
}
/*************************************** **************
**??????????? Web ????????? ???????????????? WHY ??? Web ????? ·??? True ??????????? ·??? False
**************************************** *************/
Function isWebEnv ()
{
If (isset ($ _ SERVER ['php _ SELF '])
{
Return true;
}
If (isset ($ GLOBALS ['_ server'] ['php _ SELF'])
{
Return true;
}
Return false;
}
/*************************************** **************
**???????????????????
**************************************** *************/
Function _ textConvert ($ text)
{
If ($ this-> isWebEnv () // Web ????
{
Return nl2br ($ text );
}
Return $ text;
}
/*************************************** **************
**?????????
**************************************** *************/
Function currentTime ()
{
List ($ usec, $ sec) = explode ('', microtime ());
$ Time = (double) $ sec + (double) $ usec;
Return $ time;
}
Function show ()
{
$ Message = "\ n". 'processed in'
. ($ This-> currentTime ()-$ this-> seconds). 'second (s ),'
. $ This-> queries. 'queries. '. "\ n ";
// Return $ this-> _ textConvert ($ message );
Return $ message;
}
/*************************************** **************
**?????????????????????
**************************************** *************/
Function error ($ var = false)
{
Global $ domain, $ language, $ site_engine_root;
// Header ('content-Type: text/html; charset = "UTF-8 "');
// @ $ Error ="
| An error was encountered |
"; // @ $ Error. = "SiteEngine \ n ". $ GLOBALS ['l _ site'] ['describerror ']. "error in file \"". $ _ SERVER ['php _ SELF ']. "\" \ n "; // @ $ Error. = $ GLOBALS ['l _ site'] ['errorinfo']. mysql_errno (). ':'. mysql_error (). "\ n "; If ($ var) { $ Error. = "\ n ". htmlspecialchars (@ $ GLOBALS ['l _ site'] ['errorsql']). "\ n ". $ var. "\ n "; } $ Error. =" |
";
If ($ GLOBALS ['Settings'] ['system'] ['errorreport'] = 1)
{
$ Errorinfo = mysql_errno (). ":". rawurlencode (mysql_error ());
$ Time = date ("Ymd H: I: s", time ());
// @ File ("http://error.siteengine.net /? Domain = $ domain & errorinfo = $ errorinfo & username = $ SESSION [username] & time = $ time & language = $ language ");
}
If (file_exists ($ site_engine_root. 'data/install. lock '))
{
Die ($ this-> _ textConvert ($ error ));
}
Else
{
Die ($ this-> _ textConvert ($ error ));
// @ Header ("Location:/install. php ");
}
//??????
Return $ error;
}
/*************************************** **************
**??????? SQL ????
**************************************** *************/
Function query ($ SQL)
{
Global $ opendebug, $ admincp;
$ This-> start_timer ();
If ($ opendebug = 1 & $ admincp = 0) | ($ opendebug = 2 & $ admincp = 1 ))
{
Echo ''. $ SQL .';
';
Echo gettotaltime ().'
';
// Echo $ SQL .';
';
}
$ Result = @ mysql_query ($ SQL, $ this-> db) or $ this-> error ($ SQL );
+ + $ This-> queries ;//??????????
$ This-> querytimes [] = $ this-> stop_timer ();
$ Lowersql = strtolower ($ SQL );
$ Lowersql = trim ($ lowersql );
If (substr ($ lowersql,) = "update" or substr ($ lowersql,) = "delete ")
{
// Echo"
Find update";
$ Affectrows = mysql_affected_rows ();
Return $ affectrows;
}
Return $ result;
}
/*************************************** **************
**??????? SQL ????
**************************************** *************/
Function unbufferedQuery ($ SQL)
{
$ Result = mysql_unbuffered_query ($ SQL, $ this-> db) or $ this-> error ($ SQL );
Return $ result;
}
/*************************************** **************
**????????????????????
**************************************** *************/
/*
* $ Result ?? Query ()????????
* $ Fetch_mode ???????? WHY ???
* DB_FETCHMODE_ORDERED (default )??????????????????
* DB_FETCHMODE_ASSOC ???????????????????
* DB_FETCHMODE_OBJECT ?????????????
*/
Function fetchRow ($ result, $ fetch_mode = false)
{
// Assert ('is _ resource ($ result )');
Switch ($ fetch_mode)
{
Case DB_FETCHMODE_OBJECT:
$ Row = @ mysql_fetch_object ($ result); // $ row-> username
Break;
Case DB_FETCHMODE_ASSOC:
$ Row = @ mysql_fetch_assoc ($ result); // $ row ['username']
Break;
Case DB_FETCHMODE_ORDERED:
Default ://?????
$ Row = @ mysql_fetch_row ($ result ); //,
Break;
}
Return $ row;
}
}
?>
Reply to discussion (solution)
Obviously, the encoding you open is inconsistent with the actual encoding of the file.
The copied data cannot be restored. You must read the original file and open it with the correct encoding.
If it is opened with an incorrect encoding and saved again, it is basically unable to be restored.
Create a new file encoding in the editor and set UTF-8 to copy your file.
Have you tried it on the third floor? What editor are you using. I created a new txt, and set it as a UTF-8, and then put the code in, still garbled.
Place your original file on the cloud disk
Have you tried it on the third floor? What editor are you using. I created a new txt, and set it as a UTF-8, and then put the code in, still garbled.
Notepad ++ try this editor
1. When someone else gives you this file, it will be garbled.
2. change the file storage to UTF8. you can use UE and EditPlus to save the file directly and select UTF8 for encoding.
It seems irreversible.