Skip to content

Commit cb605b5

Browse files
committed
Fixed bugs. Added Generating... to Button
1 parent 12e2da8 commit cb605b5

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

handler.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
2+
error_reporting(0);
33
// header to return JSON to the jQuery Ajax request
44
header('Content-Type: application/json');
55

@@ -77,7 +77,7 @@ function random_glyphicon(){
7777

7878
// gather success info and display to user at the end
7979
$message = "The operations that were performed are: <ul>";
80-
80+
8181
// select the database
8282
$linkdb = mysqli_select_db($link, $database);
8383
if (!$linkdb) {
@@ -105,7 +105,7 @@ function random_glyphicon(){
105105
// the generation process starts here
106106
// collecting DB connection info to generate includes/connect.php file
107107
$connection = "<?php
108-
mysqli_connect(\"$host\", \"$username\", \"$password\");
108+
\$link = mysqli_connect(\"$host\", \"$username\", \"$password\");
109109
mysqli_select_db(\$link, \"$database\");
110110
mysqli_query(\$link, \"SET CHARACTER SET utf8\");
111111
?>
@@ -137,6 +137,7 @@ function random_glyphicon(){
137137

138138
// collecting data for the includes/header.php page which is the header of all pages
139139
$header = '<?php
140+
error_reporting(0);
140141
session_start();
141142
if ($_COOKIE["auth"] != "admin_in"){header("location:"."./");}
142143
include("includes/connect.php");
@@ -223,6 +224,7 @@ function random_glyphicon(){
223224
// collecting data for the edit page
224225
$edit = "<?php
225226
include \"includes/header.php\";
227+
\$data=[];
226228
227229
$"."act = $"."_GET['act'];
228230
if($"."act == \"edit\"){
@@ -256,7 +258,13 @@ function random_glyphicon(){
256258
$icon = random_glyphicon();
257259
$header .= "<li><a href=\"" . $small . ".php\"> <i class=\"glyphicon glyphicon-".$icon."\"></i>" . $capital . " <span class=\"pull-right\"><?=counting(\"" . $small . "\", \"id\")?></span></a></li>\n";
258260

261+
$head='';
262+
$body='';
263+
$mid='';
259264

265+
$insert='';
266+
$update='';
267+
$values='';
260268
// finding all the columns in a table
261269
$row = mysqli_query($link, "SHOW columns FROM " . $table[0])
262270
or die ('cannot select table fields');
@@ -287,7 +295,7 @@ function random_glyphicon(){
287295
// check if the column is not the ID to create the corresponding save and insert data
288296
if ($col[0] != 'id'){
289297

290-
$save .= "$" . $col[0] . " = mysqli_real_escape_string($"."_POST[\"" . $col[0] . "\"]);\n";
298+
$save .= "$" . $col[0] . " = mysqli_real_escape_string(\$link,$"."_POST[\"" . $col[0] . "\"]);\n";
291299

292300
$insert .= " `" . $col[0] . "` ,";
293301

@@ -296,6 +304,7 @@ function random_glyphicon(){
296304
$values .= " '\".md5($" . $col[0] . ").\"',";
297305

298306
}else{
307+
$attach_password = 0;
299308
$values .= " '\".$" . $col[0] . ".\"' ,";
300309
$update .= " `" . $col[0] . "` = '\".$" . $col[0] . ".\"' ,";
301310
}

index.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,11 @@
8282
<button class="btn btn-primary hidden-first hide" id="generate">Generate Admin Panel</button>
8383
</fieldset>
8484
</form>
85+
<br />
8586
</div>
8687
87-
<div class="col-lg-3 alert alert-dismissible alert-info">
88+
<div class="col-lg-3 alert alert-info">
89+
8890
<h3>Disclaimer</h3>
8991
<ul>
9092
<li>Mage doesn't provide a secure CRUD system. The goal of this tool is to make a fast admin panel to control a MySQL database, but securing that is your own responsibility.</li>
@@ -119,6 +121,7 @@
119121
$("#connect, #generate").on("click", function(e) {
120122
e.preventDefault();
121123
action = $(this).attr("id");
124+
if(action=="generate"){$("#generate").text('Please Wait...');$("#generate").attr('disabled','disabled');}
122125
$.ajax({
123126
type: "POST",
124127
url: "handler.php",
@@ -131,6 +134,7 @@
131134
database: $("#dbSelect").val()
132135
},
133136
success: function(response){
137+
if(action=="generate"){$("#generate").text('Generate');$("#generate").removeAttr('disabled');}
134138
if(response.status == "success") {
135139
$("#dbSelect").append(response.result);
136140
$(".hidden-first").toggleClass("hide");

library/data.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function mysqli_result($res,$row=0,$col=0){
1414
function qSELECT($query, $object = NULL){
1515
global $link;
1616
$result = mysqli_query($link, $query);
17-
$return = "";
17+
$return = [];
1818
if($result){
1919
$num = mysqli_num_rows($result);
2020
for ($i=0; $i<$num; $i++){

library/index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
error_reporting(0);
23
session_start();
34
if ($_COOKIE['auth'] == "admin_in"){header("location:"."home.php");}
45
?>

library/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ a, a:hover, a:focus {
131131
min-width: 80px;
132132
max-width: 80px;
133133
text-align: center;
134-
margin-left: -80px !important ;
134+
margin-left: -80px;
135135
}
136136
a[aria-expanded="false"]::before, a[aria-expanded="true"]::before {
137137
top: auto;

0 commit comments

Comments
 (0)