大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 技术开发 -> PHP专区 -> 挑战最棒的留言本的源码(四)

挑战最棒的留言本的源码(四)

时间: 2021-07-31 作者:daque

config.php文献 <?php  // 你的用户名和暗号,以及数据库名,和表名,在这边一次设置!!! // 因为怕用户名和暗号被旁人经过欣赏器看到,以是用了php的扩充名,如许经过欣赏就看得见了!!!.      $username='your_name';          //用户名      $password='your_password';          //暗号      $hostname='localhost';              //长机名,普遍都为localhost          $db_name='your_db_name';           //数据库名      $table_name='your_liuyan_table';        //寄存留言的表名               $table_name_control='your_control_table';    //遏制表名      $number_records_to_display=5;  //每页表露的留言条数!            $hang_zifu_number=50;  //换行的一条龙字符数! // 贯穿数据库,在这边连好!!!      $id_link=@mysql_connect($hostname,$username,$password);      if (! $id_link) {         affy_message("the connection to the local dtabase has failed.");}    // 处置参数,此后一切参数都不妨经过 $arr_request['name']获得,尽管是post的仍旧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;      }   } // 少许堕落处置因变量!   function affy_footer() {     echo '</body></html>';   }   function affy_header($title) {     echo '<html><head><title>';     echo "$title";     echo '</title></head><body>';   }   function affy_message($msg) {     echo '<table>';     echo '<tr><td>';     echo "$msg";     echo '</td></tr>';     echo '</table>';   }   function affy_error_exit($msg) {       $errno = mysql_errno();       $error = mysql_error();       echo '<html><head><title>error</title></head><body>';       echo $msg;       echo "<br>error: ($errno) $error<br>";       echo '</body></html>';         exit();   } // 少许message处置因变量!!! //$test="2123.1.45.189"; function ip_question($msg) { //echo $msg; //echo "<br>"; $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 "<br>";     } $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 "<br>"; $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 "英文"; } //$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 "<br>"; //$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_shortone=$hang_zifu_number-1;                                          $pattern_replace="/^.{".$hang_zifu_shortone ."}/";                    $replacement='';                    $arr_phone[$i]=preg_replace($pattern_replace,$replacement,$workstr);                        // 前方49个处置完!                          $temp=short_one($temp);  //从50其中减去一个.              }                                                          else               {               $pattern_replace="/^.{".$hang_zifu_number ."}/";               $replacement='';               $arr_phone[$i]=preg_replace($pattern_replace,$replacement,$workstr);                      }                                $message=$message . $temp."<br>";       }       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 ."<br>";      }    else        $message=$message .$arr_phone[$i]."<br>"; } return($message); } //$num1=strlen($test); //echo $num1; //echo $test; //echo "<br>"; //$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 "<br>";     // echo $passwd;     // echo "<br>";      if ($record->value==$passwd)         return(1);      else         return(0);       } //$msg=computer_message($test,$hang_zifu_number); //echo $msg; ?> 【正文版权归作家与奥索网共通具有,如需连载,请证明作家及根源】    

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.