选择显示字体大小

一个sql管理员的web接口

<?   
    /*************************************************************************************  
     *        sqladmin  v2.0  -  an  sql  administration  user  interface  for  the  web *   
     *            copyright  (c)  1997-98    alessandro  ve.net  <ave.net@scdi.org>      *   
     *************************************************************************************   
     *      this  library  is  free  software;  you  can  redistribute  it  and/or       *   
     *      modify  it  under  the  terms  of  the  gnu  library  general  public        *   
     *      license  as  published  by  the  free  software  foundation;  either         *   
     *      version  2  of  the  license,  or  (at  your  option)  any  later  version.  *   
     *                                                                                   *   
     *      this  library  is  distributed  in  the  hope  that  it  will  be  useful,   *   
     *      but  without  any  warranty;  without  even  the  implied  warranty  of      *   
     *      merchantability  or  fitness  for  a  particular  purpose.    see  the  gnu  *   
     *      library  general  public  license  for  more  details.                       *   
     *                                                                                   *   
     *      you  should  have  received  a  copy  of  the  gnu  library  general  public *   
     *      license  along  with  this  library;  if  not,  write  to  the               *   
     *      free  software  foundation,  inc.,  59  temple  place  -  suite  330,        *   
     *      boston,  ma    02111-1307,  usa.                                             *   
     *************************************************************************************/   


    /*  todo:   
      *  -  add  sort  order.   
      *  -  add  simple  view.   
      *  -  add  some  documentation.   
      */   

    /*  limitations:   
      *  -  works  only  with  msql.   
      */   

    /*  history:   
      *  -  97-11-05  (ave.net)  corrected  a  bug  with  quote.   
      *  -  98-01-01  (ave.net)  added  a  sortcolumn  parameter  to   
      *      administrationtable  function.   
      *  -  98-03-14  (ave.net)  added  function  addtable  to  enable  users  to   
      *      add  (but  not  modify)  en  entry  to  the  database.   
      *  -  98-05-19  (ave.net)  submitted  to  px.   
      *  -  98-10-11  (ave.net)  now  sqladmin  works  with  php3.  the  php2  version   
      *      will  not  be  mainteained  anymore.   
      *  -  98-10-11  (ave.net)  sqladmin  is  now  distributed  under  the  lgpl   
      *      instead  of  mpl.   
      */   

    function  escapeforhtml  (&#36;string)   
    {   
        &#36;result  =  &#36;string;   
        //&#36;result  =  ereg_replace  ("\"",  """,  &#36;result);   
        &#36;result  =  ereg_replace  ("<",  "<",  &#36;result);   
        &#36;result  =  ereg_replace  (">",  ">",  &#36;result);   
        return  &#36;result;   
    }   

    function  displaytuple  (&#36;fieldsnumber,  &#36;fieldnames,   
                                                  &#36;fieldlengths,  &#36;values,  &#36;mode)   
    {   
        &#36;result  =  "";   
        &#36;result  .=  "<form  method=\"post\"><table  border><tr>"  .   
            "<td  bgcolor=\"#ccccff\">";   
        &#36;result  .=  "<table  cellspacing=\"0\"  cellpadding=\"0\">";   
        &#36;fieldindex  =  0;   
        while  (&#36;fieldindex  <  &#36;fieldsnumber)   
        {   
            &#36;result  .=  "<tr><td>"  .  &#36;fieldnames  [&#36;fieldindex]  .  "</td><td>";   
            if  (&#36;fieldlengths  [&#36;fieldindex]  <=  128)   
            {   
                &#36;result  .=  "<input  type=\"text\"  name=\""  .   
                    &#36;fieldnames  [&#36;fieldindex]  .  "\"  value=\""  .   
                    &#36;values  [&#36;fieldindex]  .  "\"  size=\"64\">";   
            }   
            else   
            {   
                &#36;result  .=  "<textarea  name=\""  .   
                    &#36;fieldnames  [&#36;fieldindex]  .  "\""  .   
                    "  cols=\"64\"  rows=\"10\"  wrap=\"virtual\">"  .   
                    escapeforhtml  (&#36;values  [&#36;fieldindex])  .  "</textarea>";   
            }   
            &#36;result  .=    "<input  type=\"hidden\"  name=\"old-"  .   
                &#36;fieldnames  [&#36;fieldindex]  .   
                "\"  value=\""  .  escapeforhtml  (&#36;values  [&#36;fieldindex])  .  "\">"  .   
                "</td></tr>";   
            &#36;fieldindex++;   
        }   
        &#36;result  .=  "<tr><td  align=\"center\"  colspan=\"2\">";   
        if  (&#36;mode  ==  "modify")   
        {   
            &#36;result  .=  "<input  type=\"submit\"  name=\"remove\"  value=\"remove\">";   
            &#36;result  .=  "<input  type=\"submit\"  name=\"update\"  value=\"update\">";   
        }   
        else   
            {  &#36;result  .=  "<input  type=\"submit\"  name=\"add\"  value=\"add\">";  }   
        &#36;result  .=  "</table></td></tr></table></form>";   
        return  &#36;result;   
    }   

    function  fieldfromtype  (&#36;text,  &#36;type)   
    {   
        if  (&#36;type  ==  "int"    &#36;type  ==  "uint"    &#36;type  == "real")   
            {  &#36;result  =  &#36;text;  }   
        else   
            {  &#36;result  =  "&#39;"  .  addslashes  (&#36;text)  .  "&#39;";  }   
        return  &#36;result;   
    }   

    function  executemsql  (&#36;database,  &#36;command)   
    {   
        /*echo  "<tt>"  .  &#36;command  .  "</tt><hr>";*/   
        msql  (&#36;database,  &#36;command);   
    }   

    function  handleremove  (&#36;database,  &#36;table,  &#36;fieldsnumber,   
                                                  &#36;fieldnames,  &#36;fieldlengths,  &#36;fieldtypes)   
    {   
        global  &#36;remove;   
        if  (&#36;remove  !=  "")   
        {   
            &#36;command  =  "delete  from  "  .  &#36;table  .  "  where  ";   
            &#36;fieldindex  =  0;   
            while  (&#36;fieldindex  <  &#36;fieldsnumber)   
            {   
                &#36;fieldname  =  "old-"  .  &#36;fieldnames  [&#36;fieldindex];   
                global  &#36;&#36;fieldname;   
                &#36;command  .=  &#36;fieldnames  [&#36;fieldindex]  .  "="  .   
                    fieldfromtype  (&#36;&#36;fieldname,  &#36;fieldtypes  [&#36;fieldindex]);   
                if  (&#36;fieldindex  !=  &#36;fieldsnumber  -  1)   
                    {  &#36;command  .=  "  and  ";  }   
                &#36;fieldindex++;   
            }                  
            executemsql  (&#36;database,  &#36;command);   
        }   
    }   

    function  handleupdate  (&#36;database,  &#36;table,  &#36;fieldsnumber,   
                                                  &#36;fieldnames,  &#36;fieldlengths,  &#36;fieldtypes)   
    {   
        global  &#36;update;   
        if  (&#36;update  !=  "")   
        {   
            &#36;command  =  "update  "  .  &#36;table  .  "  set  ";   
            &#36;fieldindex  =  0;   
            while  (&#36;fieldindex  <  &#36;fieldsnumber)   
            {   
                &#36;fieldname  =  &#36;fieldnames  [&#36;fieldindex];   
                global  &#36;&#36;fieldname;   
                &#36;command  .=  &#36;fieldname  .  "="  .   
                    fieldfromtype  (&#36;&#36;fieldname,  &#36;fieldtypes  [&#36;fieldindex]);   
                if  (&#36;fieldindex  !=  &#36;fieldsnumber  -  1)   
                    {  &#36;command  .=  ",  ";  }   
                &#36;fieldindex++;   
            }   
            &#36;command  .=  "  where  ";   
            &#36;fieldindex  =  0;   
            while  (&#36;fieldindex  <  &#36;fieldsnumber)   
            {   
                &#36;fieldname  =  "old-"  .  &#36;fieldnames  [&#36;fieldindex];   
                global  &#36;&#36;fieldname;   
                &#36;command  .=  &#36;fieldnames  [&#36;fieldindex]  .  "="  .   
                    fieldfromtype  (&#36;&#36;fieldname,  &#36;fieldtypes  [&#36;fieldindex]);   
                if  (&#36;fieldindex  !=  &#36;fieldsnumber  -  1)   
                    {  &#36;command  .=  "  and  ";  }   
                &#36;fieldindex++;   
            }   
            executemsql  (&#36;database,  &#36;command);   
        }   
    }   

    function  handleadd  (&#36;database,  &#36;table,  &#36;fieldsnumber,   
                                            &#36;fieldnames,  &#36;fieldlengths,  &#36;fieldtypes)   
    {   
        global  &#36;add;   
        if  (&#36;add  !=  "")   
        {   
            &#36;command  =  "insert  into  "  .  &#36;table  .  "  (";   
            &#36;fieldindex  =  0;   
            while  (&#36;fieldindex  <  &#36;fieldsnumber)   
            {   
                &#36;command  .=  &#36;fieldnames  [&#36;fieldindex];   
                if  (&#36;fieldindex  !=  &#36;fieldsnumber  -  1)   
                    {  &#36;command  .=  ",  ";  }   
                &#36;fieldindex++;   
            }   
            &#36;command  .=  ")  values  (";   
            &#36;fieldindex  =  0;   
            while  (&#36;fieldindex  <  &#36;fieldsnumber)   
            {   
                &#36;fieldname  =  &#36;fieldnames  [&#36;fieldindex];   
                global  &#36;&#36;fieldname;   
                &#36;command  .=  fieldfromtype  (&#36;&#36;fieldname,  &#36;fieldtypes  [&#36;fieldindex]);   
                if  (&#36;fieldindex  !=  &#36;fieldsnumber  -  1)   
                    {  &#36;command  .=  ",  ";  }   
                &#36;fieldindex++;   
            }   
            &#36;command  .=  ")";   
            executemsql  (&#36;database,  &#36;command);   
        }   
    }   

    function  displayremoveupdate  (&#36;database,  &#36;table,  &#36;sortcolumn,   
                                                                &#36;fieldsnumber,  &#36;fieldnames,  &#36;fieldlengths)   
    {   
        &#36;result  =  "";   
        if  (&#36;sortcolumn  !=  "")   
            {  &#36;sortcolumn  =  "  order  by  "  .  &#36;sortcolumn;  }   
        &#36;msqlresult  =  msql  (&#36;database,  "select  *  from  "  .  &#36;table  .  &#36;sortcolumn);   
        &#36;tuplesnumber  =  msql_numrows  (&#36;msqlresult);   
        &#36;tupleindex  =  0;   
        while  (&#36;tupleindex  <  &#36;tuplesnumber)   
        {   
            &#36;fieldindex  =  0;   
            while  (&#36;fieldindex  <  &#36;fieldsnumber)   
            {   
                &#36;values  [&#36;fieldindex]  =  msql_result  (&#36;msqlresult,  &#36;tupleindex,   
                    &#36;fieldnames  [&#36;fieldindex]);   
                &#36;fieldindex++;   
            }   
            &#36;result  .=  displaytuple  (&#36;fieldsnumber,  &#36;fieldnames,   
                &#36;fieldlengths,  &#36;values,  "modify");   
            &#36;tupleindex++;   
        }   
        return  &#36;result;   
    }   

    function  displayadd  (&#36;fieldsnumber,  &#36;fieldnames,  &#36;fieldlengths)   
    {   
        &#36;result  =  "";   
        &#36;fieldindex  =  0;   
        while  (&#36;fieldindex  <  &#36;fieldsnumber)   
        {   
            &#36;values  [&#36;fieldindex]  =  "";   
            &#36;fieldindex++;   
        }   
        &#36;result  .=  displaytuple  (&#36;fieldsnumber,  &#36;fieldnames,   
            &#36;fieldlengths,  &#36;values,  "add");   
        msql_close  ();   
        return  &#36;result;   
    }   

    function  administrationtable  (&#36;database,  &#36;table,  &#36;sortcolumn)   
    {   
        &#36;result  =  "";   
        msql_connect  ( "localhost");   
        &#36;msqlresult  =  msql  (&#36;database,  "select  *  from  "  .  &#36;table);   
        &#36;fieldsnumber  =  msql_numfields  (&#36;msqlresult);    
        &#36;msqlresult  =  msql_listfields  (&#36;database,  &#36;table);   
        &#36;fieldindex  =  0;   
        while  (&#36;fieldindex  <  &#36;fieldsnumber)   
        {   
            &#36;fieldnames  [&#36;fieldindex]  =  msql_fieldname  (&#36;msqlresult,  &#36;fieldindex);   
            &#36;fieldlengths  [&#36;fieldindex]  =  msql_fieldlen  (&#36;msqlresult,  &#36;fieldindex);   
            &#36;fieldtypes  [&#36;fieldindex]  =  msql_fieldtype  (&#36;msqlresult,  &#36;fieldindex);   
            &#36;fieldindex++;   
        }   
        handleremove  (&#36;database,  &#36;table,  &#36;fieldsnumber,  &#36;fieldnames,  &#36;fieldlengths,  &#36;fieldtypes);   
        handleupdate  (&#36;database,  &#36;table,  &#36;fieldsnumber,  &#36;fieldnames,  &#36;fieldlengths,  &#36;fieldtypes);   
        handleadd  (&#36;database,  &#36;table,  &#36;fieldsnumber,  &#36;fieldnames,  &#36;fieldlengths,  &#36;fieldtypes);   
        &#36;result  .=  displayremoveupdate  (&#36;database,  &#36;table,  &#36;sortcolumn,  &#36;fieldsnumber,  &#36;fieldnames,    
&#36;fieldlengths);   
        &#36;result  .=  displayadd  (&#36;fieldsnumber,  &#36;fieldnames,  &#36;fieldlengths);   
        return  &#36;result;   
    }   

    function  addtable  (&#36;database,  &#36;table)   
    {   
        &#36;result  =  "";   
        msql_connect  ( "localhost");   
        &#36;msqlresult  =  msql  (&#36;database,  "select  *  from  "  .  &#36;table);   
        &#36;fieldsnumber  =  msql_numfields  (&#36;msqlresult);    
        &#36;msqlresult  =  msql_listfields  (&#36;database,  &#36;table);   
        &#36;fieldindex  =  0;   
        while  (&#36;fieldindex  <  &#36;fieldsnumber)   
        {   
            &#36;fieldnames  [&#36;fieldindex]  =  msql_fieldname  (&#36;msqlresult,  &#36;fieldindex);   
            &#36;fieldlengths  [&#36;fieldindex]  =  msql_fieldlen  (&#36;msqlresult,  &#36;fieldindex);   
            &#36;fieldtypes  [&#36;fieldindex]  =  msql_fieldtype  (&#36;msqlresult,  &#36;fieldindex);   
            &#36;fieldindex++;   
        }   
        handleadd  (&#36;database,  &#36;table,  &#36;fieldsnumber,  &#36;fieldnames,  &#36;fieldlengths,  &#36;fieldtypes);   
        &#36;result  .=  displayadd  (&#36;fieldsnumber,  &#36;fieldnames,  &#36;fieldlengths);   
        return  &#36;result;   
    }   
?>   


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

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