Challenge the source code of the best message book (4 ). Config. php file? Php: your username and password, as well as the database name, and table name are defined here !!! The php config. php file is used for fear that the user name and password will be viewed in the browser.
// Your username and password, as well as the database name, and table name are defined here !!!
// For fear that the user name and password will be viewed by others through the browser, the php extension will be used, so you will not be able to see it through browsing !!!.
$ Username = 'Your _ name'; // User name
$ Password = 'Your _ password'; // password
$ Hostname = 'localhost'; // host name, generally localhost
$ Db_name = 'Your _ db_name '; // database name
$ Table_name = 'Your _ liuyan_table '; // The table name that stores the message.
$ Table_name_control = 'Your _ control_table '; // control table name
$ Number_records_to_display = 5; // number of messages displayed on each page!
$ Hang_zifu_number = 50; // The number of characters in a line break!
// Connect to the database !!!
$ Id_link = @ mysql_connect ($ hostname, $ username, $ password );
If (! $ Id_link ){
Affy_message ("The connection to the local dtabase has failed .");}
// Processing parameters. all subsequent parameters can be obtained through $ arr_request ['name'], whether post or get !!!
$ Arr_request = array ();
If (count ($ HTTP_GET_VARS )){
While (list ($ key, $ value) = each ($ HTTP_GET_VARS )){
$ Arr_request [strtolower ($ key)] = $ value;
}
}
If (count ($ HTTP_POST_VARS )){
While (list ($ key, $ value) = each ($ HTTP_POST_VARS )){
$ Arr_request [strtolower ($ key)] = $ value;
}
}
// Some error handling functions!
Function affy_footer (){
Echo'';
}
Function affy_header ($ title ){
Echo' '; <Br> echo "$ title"; <br> echo'';
}
Function affy_message ($ msg ){
Echo'
';Echo'
'; Echo "$ msg "; Echo' |
';Echo'
';
}
Function affy_error_exit ($ msg ){
$ Errno = mysql_errno ();
$ Error = mysql_error ();
Echo' Error';
Echo $ msg;
Echo"
Error: ($ errno) $ error
";
Echo'';
Exit ();
}
// Some message processing functions !!!
// $ Test = "2123.1.45.189 ";
Function ip_question ($ msg)
{
// Echo $ msg;
// Echo"
";
$ Ip = preg_split ("/./", $ msg );
$ Num = count ($ ip );
// Echo $ num;
$ Result = "";
For ($ I = 0; $ I <$ num-1; $ I ++)
{$ Result = $ result. $ ip [$ I]. ".";
// Echo $ ip [$ I];
// Echo"
";
}
$ Result = $ result. "XX ";
Return ($ result );
}
// $ Result = ip_question ($ test );
// Echo $ result;
Function add_blankto50 ($ msg, $ hang_zifu_number)
{
$ Num = strlen ($ msg );
$ Num_need = $ hang_zifu_number-$ num;
$ Str_suffix = "";
For ($ I = 0; $ I <$ num_need; $ I ++)
{
$ Str_suffix = $ str_suffix ."";
}
// $ Num6 = strlen ($ str_suffix );
// Echo $ num6;
// Echo"
";
$ Pattern = '/^ (.*)/';
$ Replacement = "\ 1 $ str_suffix ";
$ Msg = preg_replace ($ pattern, $ replacement, $ msg );
Return ($ msg );
}
Function check_en_num ($ msg)
{
$ Pattern = '/[x00-x7f]/';
Preg_match_all ($ pattern, $ msg, $ matches );
$ Num2 = count ($ matches [0]);
Return ($ num2 % 2 );
}
Function short_one ($ msg)
{
$ Pattern = '/. $ /';
$ Replacement = '';
$ Result = preg_replace ($ pattern, $ replacement, $ msg );
Return ($ result );
}
Function pian_question ($ msg)
{
$ Pattern = "/'/";
$ Replacement = "'";
$ Temp = preg_replace ($ pattern, $ replacement, $ msg );
$ Pattern = "/\'/";
$ Replacement = "'";
$ Result = preg_replace ($ pattern, $ replacement, $ temp );
Return ($ result );
}
Function check_last ($ msg)
{
$ Pattern = '/. $ /';
Preg_match ($ pattern, $ msg, $ match );
If ($ match [0]> '~ ')
Return (1 );
Else
Return (0); // echo "English ";
}
// $ Num5 = short_one ($ test );
// Echo $ num5;
Function computer_message ($ msg, $ hang_zifu_number)
{
$ Msg = pian_question ($ msg );
$ Arr_phone = preg_split ("/n/", $ msg );
$ Num = count ($ arr_phone );
// Echo $ num;
// Echo"
";
// $ Num2 = strlen ($ arr_phone [0]);
// Echo $ num2;
$ First_line = 1;
For ($ I = 0; $ I <$ num; $ I ++)
{
While ($ str_num = strlen ($ arr_phone [$ I])> $ hang_zifu_number)
{
$ First_line = 0;
$ Workstr = $ arr_phone [$ I];
$ Pattern_pre50 = "/. {". $ hang_zifu_number ."}/";
Preg_match_all ($ pattern_pre50, $ workstr, $ matches );
$ Temp = $ matches [0] [0];
If (check_last ($ temp) = 1) and (check_en_num ($ temp) = 1) // ji shu and chinese
{
$ Hang_zifu_1_one = $ hang_zifu_number-1;
$ Pattern_replace = "/^. {". $ hang_zifu_1_one ."}/";
$ Replacement = '';
$ Arr_phone [$ I] = preg_replace ($ pattern_replace, $ replacement, $ workstr );
// The first 49 processed!
$ Temp = short_one ($ temp); // subtract one from 50.
}
Else
{
$ Pattern_replace = "/^. {". $ hang_zifu_number ."}/";
$ Replacement = '';
$ Arr_phone [$ I] = preg_replace ($ pattern_replace, $ replacement, $ workstr );
}
$ Message = $ message. $ temp ."
";
}
If ($ first_line = 1) and (strlen ($ arr_phone [$ I]) <$ hang_zifu_number ))
{
$ First_line = 0;
$ Temp_addblank = $ arr_phone [$ I];
$ Temp_addblank = add_blankto50 ($ temp_addblank, $ hang_zifu_number );
$ Message = $ temp_addblank ."
";
}
Else
$ Message = $ message. $ arr_phone [$ I]."
";
}
Return ($ message );
}
// $ Num1 = strlen ($ test );
// Echo $ num1;
// Echo $ test;
// Echo"
";
// $ Mes = add_blankto50 ($ test );
// $ Num9 = strlen ($ mes );
// Echo $ num9;
// $ Result = ip_question ($ test );
// Computer_message ($ test );
// Echo $ result;
Function checkpass ($ passwd, $ action, $ db_name, $ table_name_control, $ id_link)
{
If ($ action = "delete ")
$ Str_ SQL = "select value from $ table_name_control where leibie = 'delete ';";
Else if ($ action = "huifu ")
$ Str_ SQL = "select value from $ table_name_control where leibie = 'huifu ';";
Else
Echo "error ";
$ Result = mysql_db_query ($ db_name, $ str_ SQL, $ id_link );
If (! $ Result ){
Affy_error_exit ('SQL Execution has failed .');}
$ Record = mysql_fetch_object ($ result );
// Echo $ record-> value;
// Echo"
";
// Echo $ passwd;
// Echo"
";
If ($ record-> value = $ passwd)
Return (1 );
Else
Return (0 );
}
// $ Msg = computer_message ($ test, $ hang_zifu_number );
// Echo $ msg;
?>
[This article is copyrighted by the author and osuo. if you need to reprint it, please indicate the author and its source]
Why? Php // your username and password, as well as the database name, and table name are defined here !!! // For fear that the user name and password will be viewed by others in the browser, php's...