PluginProbe
WP-DBManager / 2.04
WP-DBManager v2.04
4.0.0 trunk 1.00 2.00 2.01 2.02 2.03 2.04 2.05 2.10 2.11 2.20 2.30 2.31 2.40 2.50 2.65 2.70 2.71 2.72 2.73 2.74 2.75 2.76 2.78 All 40 releases
wp-dbmanager / dbmanager / database-run.php

database-run.php in WP-DBManager 2.04, at dbmanager/database-run.php

79 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 +----------------------------------------------------------------+
4 | |
5 | WordPress 2.0 Plugin: WP-DBManager 2.04 |
6 | Copyright (c) 2005 Lester "GaMerZ" Chan |
7 | |
8 | File Written By: |
9 | - Lester "GaMerZ" Chan |
10 | - http://www.lesterchan.net |
11 | |
12 | File Information: |
13 | - Database Run Query |
14 | - wp-content/plugins/dbmanager/database-run.php |
15 | |
16 +----------------------------------------------------------------+
17 */
18
19
20 ### Require Database Config
21 require('database-config.php');
22
23
24 ### Form Processing
25 if($_POST['do']) {
26 // Decide What To Do
27 switch($_POST['do']) {
28 case 'Run':
29 $sql_queries2 = trim($_POST['sql_query']);
30 $totalquerycount = 0;
31 $successquery = 0;
32 if($sql_queries2) {
33 $sql_queries = array();
34 $sql_queries2 = explode("\n", $sql_queries2);
35 foreach($sql_queries2 as $sql_query2) {
36 $sql_query2 = trim(stripslashes($sql_query2));
37 $sql_query2 = preg_replace("/[\r\n]+/", '', $sql_query2);
38 if(!empty($sql_query2)) {
39 $sql_queries[] = $sql_query2;
40 }
41 }
42 if($sql_queries) {
43 foreach($sql_queries as $sql_query) {
44 if (preg_match("/^\\s*(insert|update|replace|delete|create|alter) /i",$sql_query)) {
45 $run_query = $wpdb->query($sql_query);
46 if(!$run_query) {
47 $text .= "<font color=\"red\">$sql_query</font><br />";
48 } else {
49 $successquery++;
50 $text .= "<font color=\"green\">$sql_query</font><br />";
51 }
52 $totalquerycount++;
53 } elseif (preg_match("/^\\s*(select|drop|show|grant) /i",$sql_query)) {
54 $text .= "<font color=\"red\">$sql_query</font><br />";
55 $totalquerycount++;
56 }
57 }
58 $text .= "<font color=\"blue\">$successquery/$totalquerycount Query(s) Executed Successfully</font>";
59 } else {
60 $text = "<font color=\"red\">Empty Query</font>";
61 }
62 } else {
63 $text = "<font color=\"red\">Empty Query</font>";
64 }
65 break;
66 }
67 }
68 ?>
69 <?php if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>'.$text.'</p></div>'; } ?>
70 <!-- Run SQL Query -->
71 <div class="wrap">
72 <h2>Run SQL Query</h2>
73 <form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post">
74 <p><b>Seperate Multiple Queries With A New Line</b><br /><font color="green">Use Only INSERT, UPDATE, REPLACE, DELETE, CREATE and ALTER statements.</font></p>
75 <p align="center"><textarea cols="120" rows="30" name="sql_query"></textarea></p>
76 <p align="center"><input type="submit" name="do" Value="Run" class="button" />&nbsp;&nbsp;<input type="button" name="cancel" Value="<?php _e('Cancel'); ?>" class="button" onclick="javascript:history.go(-1)" /></p>
77 <p>1. CREATE statement will return an error, which is perfectly normal due to the database class. To confirm that your table has been created check the Manage Database page.<br />2. UPDATE statement may return an error sometimes due to the newly updated value being the same as the previous value.<br />3. ALTER statement will return an error because there is no value returned.</p>
78 </form>
79 </div>