찾다
백엔드 개발PHP 튜토리얼一个SQL管理员的web接口_php基础

   
    /*************************************************************************************  
     *        SQLAdmin  v2.0  -  An  SQL  Administration  User  Interface  for  the  Web *   
     *            Copyright  (C)  1997-98    Alessandro  Vernet        *   
     *************************************************************************************   
     *      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  (avernet)  Corrected  a  bug  with  quote.   
      *  -  98-01-01  (avernet)  Added  a  sortColumn  parameter  to   
      *      administrationTable  function.   
      *  -  98-03-14  (avernet)  Added  function  addTable  to  enable  users  to   
      *      add  (but  not  modify)  en  entry  to  the  database.   
      *  -  98-05-19  (avernet)  Submitted  to  PX.   
      *  -  98-10-11  (avernet)  Now  SQLAdmin  works  with  PHP3.  The  PHP2  version   
      *      will  not  be  mainteained  anymore.   
      *  -  98-10-11  (avernet)  SQLAdmin  is  now  distributed  under  the  LGPL   
      *      instead  of  MPL.   
      */   

    function  escapeforhtml  ($string)   
    {   
        $result  =  $string;   
        //$result  =  ereg_replace  ("\"",  """,  $result);   
        $result  =  ereg_replace  ("        $result  =  ereg_replace  (">",  ">",  $result);   
        return  $result;   
    }   

    function  displayTuple  ($fieldsNumber,  $fieldNames,   
                                                  $fieldLengths,  $values,  $mode)   
    {   
        $result  =  "";   
        $result  .=  "

"  .   
            "
";   
        $result  .=  "";   
        $fieldIndex  =  0;   
        while  ($fieldIndex          {   
            $result  .=  "";   
            $fieldIndex++;   
        }   
        $result  .=  "
"  .  $fieldNames  [$fieldIndex]  .  " ";   
            if  ($fieldLengths  [$fieldIndex]              {   
                $result  .=  "                    $fieldNames  [$fieldIndex]  .  "\"  VALUE=\""  .   
                    $values  [$fieldIndex]  .  "\"  SIZE=\"64\">";   
            }   
            else   
            {   
                $result  .=  "";   
            }   
            $result  .=    "                $fieldNames  [$fieldIndex]  .   
                "\"  VALUE=\""  .  escapeforhtml  ($values  [$fieldIndex])  .  "\">"  .   
                "
";   
        if  ($mode  ==  "modify")   
        {   
            $result  .=  "";   
            $result  .=  "";   
        }   
        else   
            {  $result  .=  "";  }   
        $result  .=  "
";   
        return  $result;   
    }   

    function  fieldFromType  ($text,  $type)   
    {   
        if  ($type  ==  "int"  ||  $type  ==  "uint"  ||  $type  == "real")   
            {  $result  =  $text;  }   
        else   
            {  $result  =  "'"  .  AddSlashes  ($text)  .  "'";  }   
        return  $result;   
    }   

    function  executeMsql  ($database,  $command)   
    {   
        /*echo  ""  .  $command  .  "
";*/   
        msql  ($database,  $command);   
    }   

    function  handleRemove  ($database,  $table,  $fieldsNumber,   
                                                  $fieldNames,  $fieldLengths,  $fieldTypes)   
    {   
        global  $remove;   
        if  ($remove  !=  "")   
        {   
            $command  =  "DELETE  FROM  "  .  $table  .  "  WHERE  ";   
            $fieldIndex  =  0;   
            while  ($fieldIndex              {   
                $fieldName  =  "old-"  .  $fieldNames  [$fieldIndex];   
                global  $$fieldName;   
                $command  .=  $fieldNames  [$fieldIndex]  .  "="  .   
                    fieldFromType  ($$fieldName,  $fieldTypes  [$fieldIndex]);   
                if  ($fieldIndex  !=  $fieldsNumber  -  1)   
                    {  $command  .=  "  AND  ";  }   
                $fieldIndex++;   
            }                  
            executeMsql  ($database,  $command);   
        }   
    }   

    function  handleUpdate  ($database,  $table,  $fieldsNumber,   
                                                  $fieldNames,  $fieldLengths,  $fieldTypes)   
    {   
        global  $update;   
        if  ($update  !=  "")   
        {   
            $command  =  "UPDATE  "  .  $table  .  "  SET  ";   
            $fieldIndex  =  0;   
            while  ($fieldIndex              {   
                $fieldName  =  $fieldNames  [$fieldIndex];   
                global  $$fieldName;   
                $command  .=  $fieldName  .  "="  .   
                    fieldFromType  ($$fieldName,  $fieldTypes  [$fieldIndex]);   
                if  ($fieldIndex  !=  $fieldsNumber  -  1)   
                    {  $command  .=  ",  ";  }   
                $fieldIndex++;   
            }   
            $command  .=  "  WHERE  ";   
            $fieldIndex  =  0;   
            while  ($fieldIndex              {   
                $fieldName  =  "old-"  .  $fieldNames  [$fieldIndex];   
                global  $$fieldName;   
                $command  .=  $fieldNames  [$fieldIndex]  .  "="  .   
                    fieldFromType  ($$fieldName,  $fieldTypes  [$fieldIndex]);   
                if  ($fieldIndex  !=  $fieldsNumber  -  1)   
                    {  $command  .=  "  AND  ";  }   
                $fieldIndex++;   
            }   
            executeMsql  ($database,  $command);   
        }   
    }   

    function  handleAdd  ($database,  $table,  $fieldsNumber,   
                                            $fieldNames,  $fieldLengths,  $fieldTypes)   
    {   
        global  $add;   
        if  ($add  !=  "")   
        {   
            $command  =  "INSERT  INTO  "  .  $table  .  "  (";   
            $fieldIndex  =  0;   
            while  ($fieldIndex              {   
                $command  .=  $fieldNames  [$fieldIndex];   
                if  ($fieldIndex  !=  $fieldsNumber  -  1)   
                    {  $command  .=  ",  ";  }   
                $fieldIndex++;   
            }   
            $command  .=  ")  VALUES  (";   
            $fieldIndex  =  0;   
            while  ($fieldIndex              {   
                $fieldName  =  $fieldNames  [$fieldIndex];   
                global  $$fieldName;   
                $command  .=  fieldFromType  ($$fieldName,  $fieldTypes  [$fieldIndex]);   
                if  ($fieldIndex  !=  $fieldsNumber  -  1)   
                    {  $command  .=  ",  ";  }   
                $fieldIndex++;   
            }   
            $command  .=  ")";   
            executeMsql  ($database,  $command);   
        }   
    }   

    function  displayRemoveUpdate  ($database,  $table,  $sortColumn,   
                                                                $fieldsNumber,  $fieldNames,  $fieldLengths)   
    {   
        $result  =  "";   
        if  ($sortColumn  !=  "")   
            {  $sortColumn  =  "  ORDER  BY  "  .  $sortColumn;  }   
        $msqlresult  =  msql  ($database,  "SELECT  *  FROM  "  .  $table  .  $sortColumn);   
        $tuplesNumber  =  msql_numrows  ($msqlresult);   
        $tupleIndex  =  0;   
        while  ($tupleIndex          {   
            $fieldIndex  =  0;   
            while  ($fieldIndex              {   
                $values  [$fieldIndex]  =  msql_result  ($msqlresult,  $tupleIndex,   
                    $fieldNames  [$fieldIndex]);   
                $fieldIndex++;   
            }   
            $result  .=  displayTuple  ($fieldsNumber,  $fieldNames,   
                $fieldLengths,  $values,  "modify");   
            $tupleIndex++;   
        }   
        return  $result;   
    }   

    function  displayAdd  ($fieldsNumber,  $fieldNames,  $fieldLengths)   
    {   
        $result  =  "";   
        $fieldIndex  =  0;   
        while  ($fieldIndex          {   
            $values  [$fieldIndex]  =  "";   
            $fieldIndex++;   
        }   
        $result  .=  displayTuple  ($fieldsNumber,  $fieldNames,   
            $fieldLengths,  $values,  "add");   
        msql_close  ();   
        return  $result;   
    }   

    function  administrationTable  ($database,  $table,  $sortColumn)   
    {   
        $result  =  "";   
        msql_connect  ( "localhost");   
        $msqlresult  =  msql  ($database,  "SELECT  *  FROM  "  .  $table);   
        $fieldsNumber  =  msql_numfields  ($msqlresult);    
        $msqlresult  =  msql_listfields  ($database,  $table);   
        $fieldIndex  =  0;   
        while  ($fieldIndex          {   
            $fieldNames  [$fieldIndex]  =  msql_fieldname  ($msqlresult,  $fieldIndex);   
            $fieldLengths  [$fieldIndex]  =  msql_fieldlen  ($msqlresult,  $fieldIndex);   
            $fieldTypes  [$fieldIndex]  =  msql_fieldtype  ($msqlresult,  $fieldIndex);   
            $fieldIndex++;   
        }   
        handleRemove  ($database,  $table,  $fieldsNumber,  $fieldNames,  $fieldLengths,  $fieldTypes);   
        handleUpdate  ($database,  $table,  $fieldsNumber,  $fieldNames,  $fieldLengths,  $fieldTypes);   
        handleAdd  ($database,  $table,  $fieldsNumber,  $fieldNames,  $fieldLengths,  $fieldTypes);   
        $result  .=  displayRemoveUpdate  ($database,  $table,  $sortColumn,  $fieldsNumber,  $fieldNames,    
$fieldLengths);   
        $result  .=  displayAdd  ($fieldsNumber,  $fieldNames,  $fieldLengths);   
        return  $result;   
    }   

    function  addTable  ($database,  $table)   
    {   
        $result  =  "";   
        msql_connect  ( "localhost");   
        $msqlresult  =  msql  ($database,  "SELECT  *  FROM  "  .  $table);   
        $fieldsNumber  =  msql_numfields  ($msqlresult);    
        $msqlresult  =  msql_listfields  ($database,  $table);   
        $fieldIndex  =  0;   
        while  ($fieldIndex          {   
            $fieldNames  [$fieldIndex]  =  msql_fieldname  ($msqlresult,  $fieldIndex);   
            $fieldLengths  [$fieldIndex]  =  msql_fieldlen  ($msqlresult,  $fieldIndex);   
            $fieldTypes  [$fieldIndex]  =  msql_fieldtype  ($msqlresult,  $fieldIndex);   
            $fieldIndex++;   
        }   
        handleAdd  ($database,  $table,  $fieldsNumber,  $fieldNames,  $fieldLengths,  $fieldTypes);   
        $result  .=  displayAdd  ($fieldsNumber,  $fieldNames,  $fieldLengths);   
        return  $result;   
    }   
?>   

성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
PHP 로깅 : PHP 로그 분석을위한 모범 사례PHP 로깅 : PHP 로그 분석을위한 모범 사례Mar 10, 2025 pm 02:32 PM

PHP 로깅은 웹 애플리케이션을 모니터링하고 디버깅하고 중요한 이벤트, 오류 및 런타임 동작을 캡처하는 데 필수적입니다. 시스템 성능에 대한 귀중한 통찰력을 제공하고 문제를 식별하며 더 빠른 문제 해결을 지원합니다.

Laravel의 플래시 세션 데이터로 작업합니다Laravel의 플래시 세션 데이터로 작업합니다Mar 12, 2025 pm 05:08 PM

Laravel은 직관적 인 플래시 방법을 사용하여 임시 세션 데이터 처리를 단순화합니다. 응용 프로그램에 간단한 메시지, 경고 또는 알림을 표시하는 데 적합합니다. 데이터는 기본적으로 후속 요청에만 지속됩니다. $ 요청-

PHP의 컬 : REST API에서 PHP Curl Extension 사용 방법PHP의 컬 : REST API에서 PHP Curl Extension 사용 방법Mar 14, 2025 am 11:42 AM

PHP 클라이언트 URL (CURL) 확장자는 개발자를위한 강력한 도구이며 원격 서버 및 REST API와의 원활한 상호 작용을 가능하게합니다. PHP CURL은 존경받는 다중 프로모토콜 파일 전송 라이브러리 인 Libcurl을 활용하여 효율적인 execu를 용이하게합니다.

Laravel 테스트에서 단순화 된 HTTP 응답 조롱Laravel 테스트에서 단순화 된 HTTP 응답 조롱Mar 12, 2025 pm 05:09 PM

Laravel은 간결한 HTTP 응답 시뮬레이션 구문을 제공하여 HTTP 상호 작용 테스트를 단순화합니다. 이 접근법은 테스트 시뮬레이션을보다 직관적으로 만들면서 코드 중복성을 크게 줄입니다. 기본 구현은 다양한 응답 유형 단축키를 제공합니다. Illuminate \ support \ Facades \ http를 사용하십시오. http :: 가짜 ([ 'google.com'=> ​​'Hello World', 'github.com'=> ​​[ 'foo'=> 'bar'], 'forge.laravel.com'=>

Codecanyon에서 12 개의 최고의 PHP 채팅 스크립트Codecanyon에서 12 개의 최고의 PHP 채팅 스크립트Mar 13, 2025 pm 12:08 PM

고객의 가장 긴급한 문제에 실시간 인스턴트 솔루션을 제공하고 싶습니까? 라이브 채팅을 통해 고객과 실시간 대화를 나누고 문제를 즉시 해결할 수 있습니다. 그것은 당신이 당신의 관습에 더 빠른 서비스를 제공 할 수 있도록합니다.

PHP에서 늦은 정적 결합의 개념을 설명하십시오.PHP에서 늦은 정적 결합의 개념을 설명하십시오.Mar 21, 2025 pm 01:33 PM

기사는 PHP 5.3에 도입 된 PHP의 LSB (Late STATIC BING)에 대해 논의하여 정적 방법의 런타임 해상도가보다 유연한 상속을 요구할 수있게한다. LSB의 실제 응용 프로그램 및 잠재적 성능

프레임 워크 사용자 정의/확장 : 사용자 정의 기능을 추가하는 방법.프레임 워크 사용자 정의/확장 : 사용자 정의 기능을 추가하는 방법.Mar 28, 2025 pm 05:12 PM

이 기사에서는 프레임 워크에 사용자 정의 기능 추가, 아키텍처 이해, 확장 지점 식별 및 통합 및 디버깅을위한 모범 사례에 중점을 둡니다.

See all articles

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

뜨거운 도구

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

맨티스BT

맨티스BT

Mantis는 제품 결함 추적을 돕기 위해 설계된 배포하기 쉬운 웹 기반 결함 추적 도구입니다. PHP, MySQL 및 웹 서버가 필요합니다. 데모 및 호스팅 서비스를 확인해 보세요.

ZendStudio 13.5.1 맥

ZendStudio 13.5.1 맥

강력한 PHP 통합 개발 환경

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

DVWA

DVWA

DVWA(Damn Vulnerable Web App)는 매우 취약한 PHP/MySQL 웹 애플리케이션입니다. 주요 목표는 보안 전문가가 법적 환경에서 자신의 기술과 도구를 테스트하고, 웹 개발자가 웹 응용 프로그램 보안 프로세스를 더 잘 이해할 수 있도록 돕고, 교사/학생이 교실 환경 웹 응용 프로그램에서 가르치고 배울 수 있도록 돕는 것입니다. 보안. DVWA의 목표는 다양한 난이도의 간단하고 간단한 인터페이스를 통해 가장 일반적인 웹 취약점 중 일부를 연습하는 것입니다. 이 소프트웨어는