SQL 管理者の Web インターフェイスの概要

WBOY
リリース: 2016-08-08 09:33:50
オリジナル
1074 人が閲覧しました

   
    /************************************************ ************************************
     * SQLAdmin v2.0 - Web 用 SQL 管理 ユーザー インターフェイス *
     * 著作権 (C) 1997-98 Alessandro Vernet       *
     ************************************************* ***********************************
     * この ライブラリ は 無料 ソフトウェアです。  再配布、および/または *
     * GNU ライブラリ 一般 公開 *
の 条件に基づいて 変更します。      * フリー ソフトウェア財団によって発行されたライセンス。  いずれか *
     * ライセンスのバージョン 2、または(オプションで)それ以降のバージョン。  *
     * *
     * この ライブラリ は、役立つことを願って 配布されています。 *
     * ただし、いかなる保証もありません。  黙示の保証もなしに、 *
     * 商品性 または 特定の 目的への適合性。    GNU *
を参照してください。      * ライブラリ 一般 パブリック ライセンス の詳細については、こちらをご覧ください。                       *
     * *
     * あなたは、 GNU Library General Public *
の コピー を受け取っているはずです     * この ライブラリとともに ライセンス。  そうでない場合は、 *
にメールしてください      * 無料 ソフトウェア Foundation, Inc., 59 Temple Place - Suite 330、 *
     * ボストン、マサチューセッツ州 02111-1307、米国。                                             *
     ************************************************* ***********************************/


    /* TODO:
      * - 並べ替え順序を追加します。   
      * - シンプルな ビューを追加します。   
      * - いくつかのドキュメントを追加します。   
      */

    /* 制限事項:
      * - mSQL でのみ動作します。   
      */

    /* 履歴:
      * - 97-11-05 (avernet) バグを 引用とともに修正しました。   
      * - 98-01-01 (avernet) sortColumn パラメータ を
に追加しました       * administrationTable 関数。   
      * - 98-03-14 (avernet) ユーザーが
できるようにする 関数 addTable を追加しました       * データベースにエントリを追加します(ただし、変更はしません)。   
      * - 98-05-19 (avernet) PX に送信されました。   
      * - 98-10-11 (avernet) SQLAdmin は php3 で動作するようになりました。  PHP2 バージョン
      * 今後はメンテナンスされなくなります。   
      * - 98-10-11 (avernet) SQLAdmin は 現在 LGPL に基づいて 配布されています
      *MPL の代わりに。   
      */

    関数 escapeforhtml ($string)
    {
        $result = $string;   
        //$result = ereg_replace (""", """, $result);   
        $result = ereg_replace ("<", "<", $result);   
        $result = ereg_replace (">", ">", $result);   
        $result を返します。   
    }

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

"  。   
            "
";   
        $result .= "";   
        $fieldIndex = 0;   
        while ($fieldIndex < $fieldsNumber)
        {
            $result .= "";   
            $fieldIndex++;   
        }
        $result .= "
"  。  $fieldNames [$fieldIndex] 。  "";   
            if ($fieldLengths [$fieldIndex] <= 128)
            {
                $result .= "                     $fieldNames [$fieldIndex] 。  "" VALUE="" 。   
                    $values [$fieldIndex] 。  "" SIZE="64">";
            }
            その他
            {
                $result .= "";   
            }
            $result .= "                 $fieldNames [$fieldIndex] 。   
                "" VALUE="" 。  escapeforhtml ($values [$fieldIndex]) 。  "">" .
                "
";   
        if ($mode == "変更")
        {
            $result .= "";   
            $result .= "";   
        }
        その他
            { $result .= "";  }
        $result .= "gt;";   
        $result を返します。   
    }

    関数 fieldFromType ($text, $type)
    {
        if ($type == "int" || $type == "uint" || $type == "real")
            { $結果 = $テキスト;  }
        その他
            { $result = 「」」 。  AddSlashes ($text) 。  "";  }
        $result を返します。   
    }

    関数 executeMsql ($database, $command)
    {
        /*エコー 「」  。  $コマンド 。  "";*/
        msql ($database, $command);   
    }

    関数 handleRemove ($database, $table, $fieldsNumber,
                                                  $fieldNames、 $fieldLengths、 $fieldTypes)
    {
        グローバル $remove;   
        if ($remove != "")
        {
            $command = 「DELETE FROM 」 。  $テーブル 。  " どこ ";   
            $fieldIndex = 0;   
            while ($fieldIndex < $fieldsNumber)
            {
                $fieldName = 「old-」 。  $fieldNames [$fieldIndex];   
                グローバル $$フィールド名;   
                $command .= $fieldNames [$fieldIndex] 。  「= 。   
                    fieldFromType ($$fieldName, $fieldTypes [$fieldIndex]);   
                if ($fieldIndex != $fieldsNumber - 1)
                    { $command .= 「 AND 」;  }
                $fieldIndex++;   
            }
            executeMsql ($database, $command);   
        }
    }

    関数 handleUpdate ($database, $table, $fieldsNumber,
                                                  $fieldNames、 $fieldLengths、 $fieldTypes)
    {
        グローバル $アップデート;   
        if ($update != "")
        {
            $command = 「更新 」 。  $テーブル 。  " セット ";   
            $fieldIndex = 0;   
            while ($fieldIndex < $fieldsNumber)
            {
                $fieldName = $fieldNames [$fieldIndex];   
                グローバル $$フィールド名;   
                $command .= $fieldName .  「= 。   
                    fieldFromType ($$fieldName, $fieldTypes [$fieldIndex]);   
                if ($fieldIndex != $fieldsNumber - 1)
                    { $command .= ", ";  }
                $fieldIndex++;   
            }
            $command .= " WHERE ";   
            $fieldIndex = 0;   
            while ($fieldIndex < $fieldsNumber)
            {
                $fieldName = 「old-」 。  $fieldNames [$fieldIndex];   
                グローバル $$フィールド名;   
                $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)
    {
        グローバル $add;   
        if ($add != "")
        {
            $command = 「INSERT INTO 」 。  $テーブル 。  " (";
            $fieldIndex = 0;   
            while ($fieldIndex < $fieldsNumber)
            {
                $command .= $fieldNames [$fieldIndex];   
                if ($fieldIndex != $fieldsNumber - 1)
                    { $command .= ", ";  }
                $fieldIndex++;   
            }
            $command .= ") VALUES (";
            $fieldIndex = 0;   
            while ($fieldIndex < $fieldsNumber)
            {
                $fieldName = $fieldNames [$fieldIndex];   
                グローバル $$フィールド名;   
                $command .= fieldFromType ($$fieldName, $fieldTypes [$fieldIndex]);   
                if ($fieldIndex != $fieldsNumber - 1)
                    { $command .= ", ";  }
                $fieldIndex++;   
            }
            $command .= ")";   
            executeMsql ($database, $command);   
        }
    }

    関数 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 < $tupleNumber)
        {
            $fieldIndex = 0;   
            while ($fieldIndex < $fieldsNumber)
            {
                $values [$fieldIndex] = msql_result ($msqlresult, $tupleIndex,
                    $fieldNames [$fieldIndex]);   
                $fieldIndex++;   
            }
            $result .= displayTuple ($fieldsNumber, $fieldNames,
                $fieldLengths, $values, "変更");   
            $tupleIndex++;   
        }
        $result を返します。   
    }

    function displayAdd ($fieldsNumber, $fieldNames, $fieldLengths)
    {
        $result = "";   
        $fieldIndex = 0;   
        while ($fieldIndex < $fieldsNumber)
        {
            $values [$fieldIndex] = "";   
            $fieldIndex++;   
        }
        $result .= displayTuple ($fieldsNumber, $fieldNames,
            $fieldLengths, $values, "add");   
        msql_close ();   
        $result を返します。   
    }

    関数 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 < $fieldsNumber)
        {
            $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);   
        $result を返します。   
    }

    関数 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 < $fieldsNumber)
        {
            $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);   
        $result を返します。   
    }
?>   

上記は SQL 管理者を介した Web インターフェイスであり、さまざまな内容が含まれているため、PHP 教則に関心のある友人が役立つことを望んでいます。

関連ラベル:
ソース:php.cn
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!