<form id="hz9zz"></form>
  • <form id="hz9zz"></form>

      <nobr id="hz9zz"></nobr>

      <form id="hz9zz"></form>

    1. 明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

      在phpMyAdmin使用用戶口令登陸

      [摘要]使用過phpMyAdmin的人知道,在phpMyAdmin中,使用文件config.inc.php保存用戶名和密碼,當需要更換用戶或用戶口令更改時,必須修改config.inc.php文件,然后再上...
      使用過phpMyAdmin的人知道,在phpMyAdmin中,使用文件config.inc.php保存用戶名和密碼,當需要更換用戶或用戶口令更改時,必須修改config.inc.php文件,然后再上傳,特別的不方便。更有時,為了修改MYSQL庫或表而使用root賬號,如果這時其它網站的自動搜擎系統搜索到index.php并繼續執行其中的每一步的話,是相當危險的。為此需要用戶登陸機制,在每次使用時,輸入用戶名和口令,這樣會安全得多。
      以下是我在管理過程中,根據實際需要,對phpMyAdmin做的一些更改,為了盡量不影響原來phpMyAdmin的結構,我在phpMyAdmin的基礎上增加了一個文件index0.php,僅僅修改了一個文件config.inc.php,對phpMyAdmin沒有一點影響,既可以使用原來的phpMyAdmin,也可以使用新的用戶口令登陸機制。
      以下為兩個文件列表,將這兩個文件拷貝到phpMyAdmin目錄,執行index0.php即可,該程序在Apache + PHP + MYSQL 和 IIS5 + PHP + MYSQl 和 PWS + PHP + MYSQL下正常執行。
      phpMyAdmin 下載:
      A set of PHP3-scripts to adminstrate MySQL over the WWW.
      Version 2.1.0 - 08/06/2000
      http://www.phpwizard.net/projects/phpMyAdmin/

      index0.php文件:

      <html><head><title>MySQL 維護</title></head><body>
      <!--

      <?php
      //編碼,防止在地址欄上顯示
      function b2h($string) {
      return(bin2hex(strrev($string)));
      }

      //反編碼,防止在地址欄上顯示
      function h2b($string) {
      $stringtmp="";
      for($i=0;$i<strlen($string);$i+=2) {
      $stringtmp .= pack("C",hexdec(substr($string,$i,2)));
      }
      return(strrev($stringtmp));
      }
      global $PHP_SELF;

      if (1==0) {
      echo "-->PHP運行不正常,請檢查<!--";
      } else {
      echo "--".">";
      }
      ?>

      <?php
      if ($step=="") {
      ?>

      <p>歡迎使用</p>本工具用于維護MySQL數據庫</p>
      <p><a href="<? echo basename($PHP_SELF); ?>?step=2">下一步 -></a></p>

      <?php
      }
      if ($step==2) {

      $userfiletmp="/tmp/~userfile/~tmp.inc";
      if (file_exists($userfiletmp)) {
      include $userfiletmp;
      //$dbservertype,$servername,$dbusername,$dbpassword,$dbname;
      $dbservertype=h2b($dbservertype);
      $servername=h2b($servername);
      $dbusername=h2b($dbusername);
      $dbname=h2b($dbname);
      $curtime=h2b($curtime);
      if (time()-$curtime<120){
      $dbpassword=h2b($dbpassword);
      }else{
      $dbpassword="";
      }
      }else{
      $dbservertype="mysql";
      $servername="localhost";
      $dbusername="";
      $dbpassword="";
      $dbname="";
      }

      $dbservertype=($dbservertype==""?"mysql":$dbservertype);
      $servername=($servername==""?"localhost":$servername);

      ?>

      <p>填入連接信息</p></p>
      <div align="center">
      <center>
      <table border="1" width="53%" height="111">
      <tr>
      <td width="100%" height="105">

      <form method="POST" action="<? echo basename($PHP_SELF); ?>?step=3">

      <div align="center">
      <center>
      <table border="1" width="83%" height="60">
      <tr>
      <td width="34%" height="10">主機類型:</td>
      <td width="66%" height="10"><input type="text" name="dbservertype" size="20" value="<? echo $dbservertype; ?>"></td>
      </tr>
      <tr>
      <td width="34%" height="10">主機地址:</td>
      <td width="66%" height="10"><input type="text" name="servername" size="20" value="<? echo $servername; ?>"></td>
      </tr>
      <tr>
      <td width="34%" height="10">用戶名稱:</td>
      <td width="66%" height="10"><input type="text" name="dbusername" size="20" value="<? echo $dbusername; ?>"></td>
      </tr>
      <tr>
      <td width="34%" height="16">密碼:</td>
      <td width="66%" height="16"><input type="password" name="dbpassword" size="20" value="<? echo $dbpassword; ?>"></td>
      </tr>
      <tr>
      <td width="34%" height="16">數據庫名:</td>
      <td width="66%" height="16"><input type="text" name="dbname" size="20" value="<? echo $dbname; ?>"></td>
      </tr>
      </table>
      </center>
      </div>
      <p align="center"><input type="submit" value="下一步" name="next"><input type="reset" value="清 除" name="reset"></p>
      </form>
      </td>
      </tr>
      </table>
      </center>
      </div>

      <?php
      }
      if ($step==3) {
      $dbservertype=trim($dbservertype);
      $servername=trim($servername);
      $dbusername=trim($dbusername);
      $dbpassword=trim($dbpassword);
      $dbname=trim($dbname);

      echo "<p>確認是否正確:</p>n";
      echo "<p><b>Database server type:</b> $dbservertype</p>n";
      echo "<p><b>Database server hostname / IP address:</b> $servername</p>n";
      echo "<p><b>Database username:</b> $dbusername</p>n";
      echo "<p><b>Database password:</b> ******</p>n";
      echo "<p><b>Database name:</b> $dbname</p>n";
      echo "<p>以上參數正確才能繼續</p>";

      $dbservertype=b2h($dbservertype);
      $servername=b2h($servername);
      $dbusername=b2h($dbusername);
      $dbpassword=b2h($dbpassword);
      $dbname=b2h($dbname);

      $userfiletmp="/tmp/~userfile/~tmp.inc";
      if (!file_exists(dirname($userfiletmp))) {
      mkdir(dirname($userfiletmp), 0700);
      }
      $handertmp=fopen($userfiletmp,"w");
      fputs($handertmp,"<?phpn");
      fputs($handertmp,"$"."dbservertype="$dbservertype";n");
      fputs($handertmp,"$"."servername="$servername";n");
      fputs($handertmp,"$"."dbusername="$dbusername";n");
      fputs($handertmp,"$"."dbpassword="$dbpassword";n");
      fputs($handertmp,"$"."dbname="$dbname";n");
      $curtime=time();
      $curtime=b2h($curtime);
      fputs($handertmp,"$"."curtime="$curtime";n");
      fputs($handertmp,"?>n");
      fclose($handertmp);


      //echo "<p><a href="".basename($PHP_SELF)."?step=4&servername=$servername&dbusername=$dbusername&dbpassword=$dbpassword&dbname=$dbname">下一步 -></a></p>";
      echo "<p><a href="index.php">下一步 -></a></p>";
      }

      if ($step==4) {
      }

      if ($step==44) {
      $step=0;
      $userfiletmp="/tmp/~userfile/~tmp.inc";
      if (file_exists($userfiletmp)) {
      include $userfiletmp;
      //重新保存文件,去掉密碼
      $dbpassword="";
      $handertmp=fopen($userfiletmp,"w");
      fputs($handertmp,"<?phpn");
      fputs($handertmp,"$"."dbservertype="$dbservertype";n");
      fputs($handertmp,"$"."servername="$servername";n");
      fputs($handertmp,"$"."dbusername="$dbusername";n");
      fputs($handertmp,"$"."dbpassword="$dbpassword";n");
      fputs($handertmp,"$"."dbname="$dbname";n");
      $curtime=time();
      $curtime=b2h($curtime);
      fputs($handertmp,"$"."curtime="$curtime";n");
      fputs($handertmp,"?>n");
      fclose($handertmp);
      echo "</p></p><center><a href="".basename($PHP_SELF)."">成功注銷,請重新登陸</a></center>";
      }
      }
      ?>

      <?php
      if ($step>1) {
      echo "</p><a href=javascript:location.reload()>刷新</a>";
      echo " <a href=javascript:history.back()>上一步</a>";
      }
      ?>

      <?php
      echo "</"."body>";
      echo "<"."!--";
      ?>

      -->
      </html>

      config.inc.php 文件

      <?php
      /* $Id: config.inc.php,v 1.28 2000/07/13 13:52:48 tobias Exp $ */

      //編碼,防止在地址欄上顯示
      function b2h($string) {
      return(bin2hex(strrev($string)));
      }

      //反編碼,防止在地址欄上顯示
      function h2b($string) {
      $stringtmp="";
      for($i=0;$i<strlen($string);$i+=2) {
      $stringtmp .= pack("C",hexdec(substr($string,$i,2)));
      }
      return(strrev($stringtmp));
      }

      /*
      * phpMyAdmin Configuration File
      * All directives are explained in Documentation.html
      */

      // The $cfgServers array starts with $cfgServers[1]. Do not use $cfgServers[0].
      // You can disable a server config entry by setting host to ''.
      $cfgServers[1]['host'] = 'localhost'; // MySQL hostname
      $cfgServers[1]['port'] = ''; // MySQL port - leave blank for default port
      $cfgServers[1]['adv_auth'] = false; // Use advanced authentication?
      $cfgServers[1]['stduser'] = 'root'; // MySQL standard user (only needed with advanced auth)
      $cfgServers[1]['stdpass'] = ''; // MySQL standard password (only needed with advanced auth)
      $cfgServers[1]['user'] = 'root'; // MySQL user (only needed with basic auth)
      $cfgServers[1]['password'] = ''; // MySQL password (only needed with basic auth)
      $cfgServers[1]['only_db'] = ''; // If set to a db-name, only this db is accessible
      $cfgServers[1]['verbose'] = ''; // Verbose name for this host - leave blank to show the hostname

      $userfiletmp="/tmp/~userfile/~tmp.inc";
      if (file_exists($userfiletmp)) {
      include $userfiletmp;
      //$servername,$dbusername,$dbpassword,$dbname;
      $dbservertype=h2b($dbservertype);
      if ($dbservertype=="mysql"){
      $servername=h2b($servername);
      $dbusername=h2b($dbusername);
      $dbpassword=h2b($dbpassword);
      $dbname=h2b($dbname);
      $curtime=h2b($curtime);
      if (time()-$curtime<600){
      $cfgServers[1]['host'] = $servername; // MySQL hostname
      $cfgServers[1]['user'] = $dbusername; // MySQL user (only needed with basic auth)
      $cfgServers[1]['password'] = $dbpassword; // MySQL password (only needed with basic auth)
      $cfgServers[1]['only_db'] = $dbname; // If set to a db-name, only this db is accessible

      //重新保存文件,以便更新時間
      $dbservertype=b2h($dbservertype);
      $servername=b2h($servername);
      $dbusername=b2h($dbusername);
      $dbpassword=b2h($dbpassword);
      $dbname=b2h($dbname);

      $handertmp=fopen($userfiletmp,"w");
      fputs($handertmp,"<?phpn");
      fputs($handertmp,"$"."dbservertype="$dbservertype";n");
      fputs($handertmp,"$"."servername="$servername";n");
      fputs($handertmp,"$"."dbusername="$dbusername";n");
      fputs($handertmp,"$"."dbpassword="$dbpassword";n");
      fputs($handertmp,"$"."dbname="$dbname";n");
      $curtime=time();
      $curtime=b2h($curtime);
      fputs($handertmp,"$"."curtime="$curtime";n");
      fputs($handertmp,"?>n");
      fclose($handertmp);

      }else{
      echo "</p>賬號參數已經過期,請重新輸入!</p>";
      echo "<a href="index0.php" target="_top">登陸</a>";
      die("</p><b>程序終止</b>");
      }
      }
      }

      $cfgServers[2]['host'] = '';
      $cfgServers[2]['port'] = '';
      $cfgServers[2]['adv_auth'] = false;
      $cfgServers[2]['stduser'] = '';
      $cfgServers[2]['stdpass'] = '';
      $cfgServers[2]['user'] = '';
      $cfgServers[2]['password'] = '';
      $cfgServers[2]['only_db'] = '';
      $cfgServers[2]['verbose'] = '';

      $cfgServers[3]['host'] = '';
      $cfgServers[3]['port'] = '';
      $cfgServers[3]['adv_auth'] = false;
      $cfgServers[3]['stduser'] = '';
      $cfgServers[3]['stdpass'] = '';
      $cfgServers[3]['user'] = 'root';
      $cfgServers[3]['password'] = '';
      $cfgServers[3]['only_db'] = '';
      $cfgServers[3]['verbose'] = '';

      // If you have more than one server configured, you can set $cfgServerDefault
      // to any one of them to autoconnect to that server when phpMyAdmin is started,
      // or set it to 0 to be given a list of servers without logging in
      // If you have only one server configured, $cfgServerDefault *MUST* be
      // set to that server.
      $cfgServerDefault = 1; // Default server (0 = no default server)
      $cfgServer = '';
      unset($cfgServers[0]);

      $cfgManualBase = "http://www.mysql.com/documentation/mysql/bychapter/";

      $cfgConfirm = true;
      $cfgPersistentConnections = false;

      $cfgBorder = "0";
      $cfgThBgcolor = "#D3DCE3";
      $cfgBgcolorOne = "#CCCCCC";
      $cfgBgcolorTwo = "#DDDDDD";
      $cfgMaxRows = 30;
      $cfgMaxInputsize = "300px";
      $cfgOrder = "ASC";
      $cfgShowBlob = true;
      $cfgShowSQL = true;

      require("chinese_gb.inc.php");

      $strWelcome="<a href="index0.php?step=44" target="_top">注銷賬戶</a> <a href="index0.php" target="_top">重新登陸</a></p>$strWelcome";

      $cfgColumnTypes = array(
      "TINYINT",
      "SMALLINT",
      "MEDIUMINT",
      "INT",
      "BIGINT",
      "FLOAT",
      "DOUBLE",
      "DECIMAL",
      "DATE",
      "DATETIME",
      "TIMESTAMP",
      "TIME",
      "YEAR",
      "CHAR",
      "VARCHAR",
      "TINYBLOB",
      "TINYTEXT",
      "TEXT",
      "BLOB",
      "MEDIUMBLOB",
      "MEDIUMTEXT",
      "LONGBLOB",
      "LONGTEXT",
      "ENUM",
      "SET");

      $cfgFunctions = array(
      "ASCII",
      "CHAR",
      "SOUNDEX",
      "CURDATE",
      "CURTIME",
      "FROM_DAYS",
      "FROM_UNIXTIME",
      "NOW",
      "PASSWORD",
      "PERIOD_ADD",
      "PERIOD_DIFF",
      "TO_DAYS",
      "USER",
      "WEEKDAY",
      "RAND");

      $cfgAttributeTypes = array(
      "",
      "BINARY",
      "UNSIGNED",
      "UNSIGNED ZEROFILL");

      // Setting magic_quotes_runtime - do not change!
      set_magic_quotes_runtime(0);
      ?>

      如有引用,請注明高山雪和alpsnow@china.com







      日韩精品一区二区三区高清