Challenge the best message book source (iv) _php tutorial

Source: Internet
Author: User
config.php file

Your user name and password, as well as the database name, and the table name, are defined here once!!!
Because of the fear that the user name and password are seen by others through the browser, so the PHP extension, so that browsing will not see the!!!.

$username = ' your_name '; User name
$password = ' Your_password '; Password

$hostname = ' localhost '; Host name, usually localhost

$db _name= ' Your_db_name '; Database name
$table _name= ' your_liuyan_table '; Name of the table holding the message

$table _name_control= ' your_control_table '; Control Table Name

$number _records_to_display=5; The number of message bars displayed per page!


$hang _zifu_number=50; The number of characters in line wrapping!



Connect to the database and stay connected!!!

$id _link= @mysql_connect ($hostname, $username, $password);
if (! $id _link) {
Affy_message ("The connection to the local dtabase have failed.");

Processing parameters, all subsequent parameters can be obtained by $arr _request[' name '), either 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 ' <title>'; <br> echo "$title"; <br> Echo '</title>';
}

function Affy_message ($msg) {
Echo '

'; Echo ' '; Echo '
';
echo "$msg";
Echo '
';
}

function Affy_error_exit ($msg) {
$errno = Mysql_errno ();
$error = Mysql_error ();
Echo ' <title>Error</title>';
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. " ";

}
$num 6=strlen ($str _suffix);
echo $num 6;
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);

$num 2=count ($matches [0]);

Return ($num 2%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";


}

$num 5=short_one ($test);
echo $num 5;




function Computer_message ($msg, $hang _zifu_number)
{
$msg =pian_question ($msg);

$arr _phone=preg_split ("/n/", $msg);


$num =count ($arr _phone);
Echo $num;
echo "
";
$num 2=strlen ($arr _phone[0]);
echo $num 2;
$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_shortone= $hang _zifu_number-1;

$pattern _replace= "/^. {". $hang _zifu_shortone."} /";

$replacement = ";
$arr _phone[$i]=preg_replace ($pattern _replace, $replacement, $WORKSTR);
The first 49 finishes!

$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);


}

$num 1=strlen ($test);
echo $num 1;
Echo $test;

echo "
";
$mes =add_blankto50 ($test);
$num 9=strlen ($mes);
echo $num 9;
$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;

?>


"The copyright of this article is owned by the author and house Orso near net, if need to reprint, please specify the author and source"


http://www.bkjia.com/PHPjc/316169.html www.bkjia.com true http://www.bkjia.com/PHPjc/316169.html techarticle config.php file? PHP//Your user name and password, as well as the database name, and the table name, once defined here!!!//Due to fear that the user name and password are seen by others through the browser, so the use of PHP ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.