选择显示字体大小

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

config.php文件

<?php  
// 你的用户名和密码,以及数据库名,和表名,在这里一次定义!!!
// 由于怕用户名和密码被别人通过浏览器看到,所以用了php的扩展名,这样通过浏览就看不到了!!!.

     &#36;username=&#39;your_name&#39;;          //用户名
     &#36;password=&#39;your_password&#39;;          //密码

     &#36;hostname=&#39;localhost&#39;;              //主机名,一般都为localhost     

     &#36;db_name=&#39;your_db_name&#39;;           //数据库
     &#36;table_name=&#39;your_liuyan_table&#39;;        //存放留言的表名  
        
     &#36;table_name_control=&#39;your_control_table&#39;;    //控制表名

     &#36;number_records_to_display=5;  //每页显示的留言条数!
      

     &#36;hang_zifu_number=50;  //换行的一行字符数!



// 连接数据库,在这里连好!!!

     &#36;id_link=@mysql_connect(&#36;hostname,&#36;username,&#36;password);
     if (! &#36;id_link) {
        affy_message("the connection to the local dtabase has failed.");}
   
// 处理参数,以后所有参数都可以通过 &#36;arr_request[&#39;name&#39;]得到,不管是post的还是get的!!!

  &#36;arr_request=array();
  if (count(&#36;http_get_vars)) {
     while (list(&#36;key,&#36;value)=each(&#36;http_get_vars)) {
         &#36;arr_request[strtolower(&#36;key)]=&#36;value;
     }
  }
   
  if (count(&#36;http_post_vars)) {
     while (list(&#36;key,&#36;value)=each(&#36;http_post_vars)) {
         &#36;arr_request[strtolower(&#36;key)]=&#36;value;
     }
  }

// 一些出错处理函数!

  function affy_footer() {
    echo &#39;</body></html>&#39;;
  }

  function affy_header(&#36;title) {
    echo &#39;<html><head><title>&#39;;
    echo "&#36;title";
    echo &#39;</title></head><body>&#39;;
  }

  function affy_message(&#36;msg) {
    echo &#39;<table>&#39;;
    echo &#39;<tr><td>&#39;;
    echo "&#36;msg";
    echo &#39;</td></tr>&#39;;
    echo &#39;</table>&#39;;
  }

  function affy_error_exit(&#36;msg) {
      &#36;errno = mysql_errno();
      &#36;error = mysql_error();
      echo &#39;<html><head><title>error</title></head><body>&#39;;
      echo &#36;msg;
      echo "<br>error: (&#36;errno) &#36;error<br>";
      echo &#39;</body></html>&#39;;
        exit();
  }

// 一些message处理函数!!!



//&#36;test="2123.1.45.189";

function ip_question(&#36;msg)
{
//echo &#36;msg;
//echo "<br>";
&#36;ip=preg_split("/./",&#36;msg);
&#36;num=count(&#36;ip);
//echo &#36;num;
&#36;result="";
for(&#36;i=0;&#36;i<&#36;num-1;&#36;i++)
{ &#36;result=&#36;result .&#36;ip[&#36;i].".";
  //echo &#36;ip[&#36;i];
  //echo "<br>";  
   
}
&#36;result=&#36;result ."xx";
return(&#36;result);  
}

//&#36;result=ip_question(&#36;test);
//echo &#36;result;



function add_blankto50(&#36;msg,&#36;hang_zifu_number)
{
&#36;num=strlen(&#36;msg);

&#36;num_need=&#36;hang_zifu_number-&#36;num;
&#36;str_suffix="";
for (&#36;i=0;&#36;i<&#36;num_need;&#36;i++)
{
  &#36;str_suffix=&#36;str_suffix." ";
  
}
//&#36;num6=strlen(&#36;str_suffix);
//echo &#36;num6;
//echo "<br>";

&#36;pattern=&#39;/^(.*)/&#39;;
&#36;replacement="\1&#36;str_suffix";

&#36;msg=preg_replace(&#36;pattern,&#36;replacement,&#36;msg);

return(&#36;msg);

}

function check_en_num(&#36;msg)
{
&#36;pattern=&#39;/[x00-x7f]/&#39;;

preg_match_all(&#36;pattern,&#36;msg,&#36;matches);

&#36;num2=count(&#36;matches[0]);

return(&#36;num2%2);

}

function short_one(&#36;msg)
{
&#36;pattern=&#39;/.&#36;/&#39;;
&#36;replacement=&#39;&#39;;
&#36;result=preg_replace(&#36;pattern,&#36;replacement,&#36;msg);

return(&#36;result);




}

function pian_question(&#36;msg)
{
&#36;pattern="/&#39;/";
&#36;replacement="&#39;";
&#36;temp=preg_replace(&#36;pattern,&#36;replacement,&#36;msg);
  
&#36;pattern="/\&#39;/";
&#36;replacement="&#39;";
&#36;result=preg_replace(&#36;pattern,&#36;replacement,&#36;temp);

return(&#36;result);    
  
}

function check_last(&#36;msg)
  {

&#36;pattern=&#39;/.&#36;/&#39;;

preg_match(&#36;pattern,&#36;msg,&#36;match);


if (&#36;match[0]>&#39;~&#39;)
  return(1);
else  
  return(0); // echo "英文";


}

//&#36;num5=short_one(&#36;test);
//echo &#36;num5;




function computer_message(&#36;msg,&#36;hang_zifu_number)
{
&#36;msg=pian_question(&#36;msg);

&#36;arr_phone=preg_split("/n/",&#36;msg);


&#36;num=count(&#36;arr_phone);
//echo &#36;num;
//echo "<br>";
//&#36;num2=strlen(&#36;arr_phone[0]);
//echo &#36;num2;
&#36;first_line=1;

for (&#36;i=0;&#36;i<&#36;num;&#36;i++)
{
   while(&#36;str_num=strlen(&#36;arr_phone[&#36;i])>&#36;hang_zifu_number)
      {
  
         &#36;first_line=0;
         &#36;workstr=&#36;arr_phone[&#36;i];
          
          

         &#36;pattern_pre50="/.{".&#36;hang_zifu_number ."}/";

         preg_match_all(&#36;pattern_pre50,&#36;workstr,&#36;matches);
         &#36;temp=&#36;matches[0][0];
         
         if ((check_last(&#36;temp)==1)and(check_en_num(&#36;temp)==1))  //  ji shu and chinese
            {       
                   &#36;hang_zifu_shortone=&#36;hang_zifu_number-1;
                      
                   &#36;pattern_replace="/^.{".&#36;hang_zifu_shortone ."}/";

                   &#36;replacement=&#39;&#39;;
                   &#36;arr_phone[&#36;i]=preg_replace(&#36;pattern_replace,&#36;replacement,&#36;workstr);
                       // 前面49个处理完!
      
                   &#36;temp=short_one(&#36;temp);  //从50个中减去一个.

             }  
               

                       
         
         else   
            {

              &#36;pattern_replace="/^.{".&#36;hang_zifu_number ."}/";

              &#36;replacement=&#39;&#39;;
              &#36;arr_phone[&#36;i]=preg_replace(&#36;pattern_replace,&#36;replacement,&#36;workstr);
         
            }  
                   
  
         &#36;message=&#36;message . &#36;temp."<br>";

      }
   
   if ((&#36;first_line==1)and(strlen(&#36;arr_phone[&#36;i])<&#36;hang_zifu_number))
     {
       
       &#36;first_line=0;
       &#36;temp_addblank=&#36;arr_phone[&#36;i];

       &#36;temp_addblank=add_blankto50(&#36;temp_addblank,&#36;hang_zifu_number);
     
       &#36;message=&#36;temp_addblank ."<br>";

     }

   else

       &#36;message=&#36;message .&#36;arr_phone[&#36;i]."<br>";


}
return(&#36;message);


}

//&#36;num1=strlen(&#36;test);
//echo &#36;num1;
//echo &#36;test;

//echo "<br>";
//&#36;mes=add_blankto50(&#36;test);
//&#36;num9=strlen(&#36;mes);
//echo &#36;num9;
//&#36;result=ip_question(&#36;test);
//computer_message(&#36;test);
//echo &#36;result;


function checkpass(&#36;passwd,&#36;action,&#36;db_name,&#36;table_name_control,&#36;id_link)
    {
      
      

     if (&#36;action="delete")
        &#36;str_sql="select value from &#36;table_name_control where leibie=&#39;delete&#39;;";
     else if (&#36;action="huifu")
        &#36;str_sql="select value from &#36;table_name_control where leibie=&#39;huifu&#39;;";
     else  
        echo "error";
       


     &#36;result=mysql_db_query(&#36;db_name,&#36;str_sql,&#36;id_link);
      
     if (! &#36;result) {
            affy_error_exit(&#39;sql execution has failed.&#39;);}


     &#36;record= mysql_fetch_object(&#36;result);
    // echo &#36;record->value;
    // echo "<br>";
    // echo &#36;passwd;
    // echo "<br>";
     if (&#36;record->value==&#36;passwd)
        return(1);
     else
        return(0);    



   }

//&#36;msg=computer_message(&#36;test,&#36;hang_zifu_number);

//echo &#36;msg;

?>


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons