function GetcolumnValue($table, $Forgien_Key_Display_Field) { $coulmtype = GetCoulmsInfo($table); $primryname = $coulmtype['FieldsName'][0]; $page = (int) (!isset($_GET["page"]) ? 1 : $_GET["page"]); if ($page <= 0) { $page = 1; } $per_page = 10; // Set how many records do you want to display per page. $startpoint = $page * $per_page - $per_page; $statement = "`{$table}` ORDER BY `{$primryname}` DESC"; // Change `records` according to your table name. $columvalue = QueryResult("SELECT * FROM {$statement} LIMIT {$startpoint} , {$per_page}"); $counter = 0; $itreation_FK = 0; $limtbuttonrepeat = 0; //get config info $confObj = CheckconfigInfo(); while ($rowvalue = mysql_fetch_row($columvalue)) { echo "<form method='POST' action='authentication/deletequery.php' data-form='true' id='myform_{$counter}'><tr>"; //we check the length to make it fit with the table responsive //append the radio button echo "<td ><span id='hash'>#</span><input type='radio' name='showrelatedinfo' value='" . $rowvalue[0] . "' style='display:none;margin-top: -2px;opacity: 1;margin-left: 0px;position: inherit;'></td>"; if (count($rowvalue) < 8) { for ($i = 0; $i < count($rowvalue); $i++) { //get primry key for the fields less than 8 $prima = mysql_get_foregin_key($table, $coulmtype['FieldsName'][$i]); if ($prima != '') { //get FK tablename and primary key for the forgien key and the display name if exsist and its value $FK = GetForeginKey_TableName($table, $prima); $Tablename_FK = substr($FK[$prima], 0, strpos($FK[$prima], '.')); // add the button to get all info for this primary key from the related table @($fktables = GetForgienTablename_ForSpecific_Tablename($table)); @($fktablesname = substr($fktables[$limtbuttonrepeat], 0, strpos($fktables[$limtbuttonrepeat], '.'))); @($fkidname = end(explode(".", $fktables[$limtbuttonrepeat]))); if ($limtbuttonrepeat < count($fktables) && $fktablesname != '') { echo "<a id='displayrelatedrecords' onclick=\"window.open('authentication/displayrelatedinfo.php?tablename={$table}&relatedinfo={$fktablesname}&fkfieldname={$fkidname}&relatedid={$rowvalue['0']}&true','Display Related Info','scrollbars=1,resizable=1,width=1200,height=640')\" style=\"cursor: pointer;margin-bottom:10px;margin-right:10px;display:none\" class='btn btn-info'>Display " . " " . ucfirst($fktablesname) . "</a> "; } $limtbuttonrepeat++; $PK_Name_For_FK = end(explode(".", $FK[$prima])); $FKNAME = $coulmtype['FieldsName'][$i]; $PK_Value_For_FK = $rowvalue[$i]; if (!empty($Forgien_Key_Display_Field)) { if (array_key_exists($Tablename_FK, $Forgien_Key_Display_Field)) { $FK_Field_Display = $Forgien_Key_Display_Field[$Tablename_FK]; @($FK_Query = QueryResult("SELECT * FROM {$Tablename_FK} WHERE `{$PK_Name_For_FK}` = '{$PK_Value_For_FK}' ")); while (@($FKRow = mysql_fetch_array(@$FK_Query))) { echo "<td>" . $FKRow[$FK_Field_Display] . "</td>"; } echo "<input type=\"hidden\" name=\"Tablename_FK\" prim_key=\"{$PK_Value_For_FK}\" display_name=\"{$FK_Field_Display}\" value=\"{$Tablename_FK}\">"; } else { $FK_Query = QueryResult("SELECT * FROM {$Tablename_FK} WHERE `{$PK_Name_For_FK}` = '{$PK_Value_For_FK}' "); while ($FKRow = mysql_fetch_array($FK_Query)) { echo "<td>" . substr($FKRow[0], 0, 60) . "</td>"; } echo "<input type=\"hidden\" name=\"Tablename_FK\" prim_key=\"{$PK_Value_For_FK}\" value=\"{$Tablename_FK}\">"; } //end of array has no value for this tablename } else { $FK_Query = QueryResult("SELECT * FROM {$Tablename_FK} WHERE `{$PK_Name_For_FK}` = '{$PK_Value_For_FK}' "); while ($FKRow = mysql_fetch_array($FK_Query)) { echo "<td>" . substr($FKRow[0], 0, 60) . "</td>"; } echo "<input type=\"hidden\" name=\"Tablename_FK\" prim_key=\"{$PK_Value_For_FK}\" value=\"{$Tablename_FK}\">"; } } else { //prepare the variables for youtube and viedo and images if (count($confObj) > 0) { if ($confObj['fieldname_image'] != '') { $images = $confObj['fieldname_image']; } else { $images = 'Image'; } if ($confObj['youtubefieldname'] != '') { $youtube = $confObj['youtubefieldname']; } else { $youtube = 'YouTube'; } if ($confObj['viedofieldname'] != '') { $viedo = $confObj['viedofieldname']; } else { $viedo = 'Video'; } } else { $youtube = 'YouTube'; $viedo = 'Video'; $images = 'Image'; } //check for youtube if (preg_match('/' . $youtube . '/', $coulmtype['FieldsName'][$i])) { if (@$rowvalue[$i] != '') { echo "<td><iframe src='{$rowvalue[$i]}' width='130' height='100' frameborder='0' scrolling='no' allowfullscreen></iframe></td>"; } else { echo "<td><img src='images/youtube.png' style='width:130px;height:80px;border-radius: 10px;'/></td>"; } } else { if (preg_match('/' . $viedo . '/', $coulmtype['FieldsName'][$i])) { if (@$rowvalue[$i] != '') { echo "<td><video width='320' height='240' controls><source src='{$rowvalue[$i]}' type='video/mp4'></video> </td>"; } else { echo "<td><img src='images/video.png' style='width:130px;height:80px;border-radius: 10px;'/></td>"; } } else { if (preg_match('/' . $images . '/', $coulmtype['FieldsName'][$i]) && $coulmtype['OrginalFieldType'][$i] != "blob" && $coulmtype['FieldType'][$i] != "text") { //same code for the blob type but we check for the name incase the type is not blob if ($rowvalue[$i] == '') { echo "<td><img src='images/default.png' style='width:80px;height:80px;border-radius: 10px;'/></td>"; } else { echo "<td><img src='authentication/uploads/{$rowvalue[$i]}' style='width:80px;height:80px;border-radius: 10px;'/></td>"; } } else { if ($coulmtype['OrginalFieldType'][$i] == "blob" && $coulmtype['FieldType'][$i] != "text") { if ($rowvalue[$i] == '') { echo "<td><img src='images/default.png' style='width:80px;height:80px;border-radius: 10px;'/></td>"; } else { echo "<td><img src='data:image/jpeg;base64," . base64_encode($rowvalue[$i]) . "' style='width:80px;height:80px;border-radius: 10px;'/></td>"; } } else { echo "<td>" . substr($rowvalue[$i], 0, 40) . "</td>"; } } } } } //end of primary key // add the edit and delete at the end of columns if ($i == count($rowvalue) - 1) { echo "<input type='hidden' name='tablename' value='{$table}' />\n <input type='hidden' name='mainid' value='{$rowvalue['0']}' />"; echo "<td><a onclick=\"window.open('authentication/ineredit.php?tablename={$table}&edit={$rowvalue['0']}','Update Recors','scrollbars=1,resizable=1,width=600,height=640')\" style=\"cursor: pointer;\">Edit</a></td><td><input form='myform_{$counter}' type='submit' name='delete' value='Delete' class=\"btn btn-danger\" style=\"cursor: pointer;\" /></td>"; } } } else { for ($i = 0; $i < 8; $i++) { //get primry key for the fields less than 8 $prima = mysql_get_foregin_key($table, $coulmtype['FieldsName'][$i]); if ($prima != '') { //get FK tablename and primary key for the forgien key and the display name if exsist and its value $FK = GetForeginKey_TableName($table, $prima); $Tablename_FK = substr($FK[$prima], 0, strpos($FK[$prima], '.')); // add the button to get all info for this primary key from the related table @($fktables = GetForgienTablename_ForSpecific_Tablename($table)); @($fktablesname = substr($fktables[$limtbuttonrepeat], 0, strpos($fktables[$limtbuttonrepeat], '.'))); @($fkidname = end(explode(".", $fktables[$limtbuttonrepeat]))); if ($limtbuttonrepeat < count($fktables) && $fktablesname != '') { echo "<a id='displayrelatedrecords' onclick=\"window.open('authentication/displayrelatedinfo.php?tablename={$table}&relatedinfo={$fktablesname}&fkfieldname={$fkidname}&relatedid={$rowvalue['0']}&true','Display Related Info','scrollbars=1,resizable=1,width=1200,height=640')\" style=\"cursor: pointer;margin-bottom:10px;margin-right:10px;display:none\" class='btn btn-info'>Display " . " " . ucfirst($fktablesname) . "</a> "; } $limtbuttonrepeat++; $PK_Name_For_FK = end(explode(".", $FK[$prima])); $FKNAME = $coulmtype['FieldsName'][$i]; $PK_Value_For_FK = $rowvalue[$i]; if (!empty($Forgien_Key_Display_Field)) { if (array_key_exists($Tablename_FK, $Forgien_Key_Display_Field)) { $FK_Field_Display = $Forgien_Key_Display_Field[$Tablename_FK]; @($FK_Query = QueryResult("SELECT * FROM {$Tablename_FK} WHERE `{$PK_Name_For_FK}` = '{$PK_Value_For_FK}' ")); while (@($FKRow = mysql_fetch_array(@$FK_Query))) { echo "<td>" . $FKRow[$FK_Field_Display] . "</td>"; } echo "<input type=\"hidden\" name=\"Tablename_FK\" prim_key=\"{$PK_Value_For_FK}\" display_name=\"{$FK_Field_Display}\" value=\"{$Tablename_FK}\">"; } else { @($FK_Query = QueryResult("SELECT * FROM {$Tablename_FK} WHERE `{$PK_Name_For_FK}` = '{$PK_Value_For_FK}' ")); while (@($FKRow = mysql_fetch_array(@$FK_Query))) { echo "<td>" . substr($FKRow[0], 0, 60) . "</td>"; } echo "<input type=\"hidden\" name=\"Tablename_FK\" prim_key=\"{$PK_Value_For_FK}\" value=\"{$Tablename_FK}\">"; } //end of array has no value for this tablename } else { $FK_Query = QueryResult("SELECT * FROM {$Tablename_FK} WHERE `{$PK_Name_For_FK}` = '{$PK_Value_For_FK}' "); while ($FKRow = mysql_fetch_array($FK_Query)) { echo "<td>" . substr($FKRow[0], 0, 60) . "</td>"; } echo "<input type=\"hidden\" name=\"Tablename_FK\" prim_key=\"{$PK_Value_For_FK}\" value=\"{$Tablename_FK}\">"; } } else { //prepare the variables for youtube and viedo and images if (count($confObj) > 0) { if ($confObj['fieldname_image'] != '') { $images = $confObj['fieldname_image']; } else { $images = 'Image'; } if ($confObj['youtubefieldname'] != '') { $youtube = $confObj['youtubefieldname']; } else { $youtube = 'YouTube'; } if ($confObj['viedofieldname'] != '') { $viedo = $confObj['viedofieldname']; } else { $viedo = 'Video'; } } else { $youtube = 'YouTube'; $viedo = 'Video'; $images = 'Image'; } //check for youtube if (preg_match('/' . $youtube . '/', $coulmtype['FieldsName'][$i])) { if (@$rowvalue[$i] != '') { echo "<td><iframe src='{$rowvalue[$i]}' width='130' height='100' frameborder='0' scrolling='no' allowfullscreen></iframe></td>"; } else { echo "<td><img src='images/youtube.png' style='width:130px;height:80px;border-radius: 10px;'/></td>"; } } else { if (preg_match('/' . $viedo . '/', $coulmtype['FieldsName'][$i])) { if (@$rowvalue[$i] != '') { echo "<td><video width='320' height='240' controls><source src='{$rowvalue[$i]}' type='video/mp4'></video> </td>"; } else { echo "<td><img src='images/video.png' style='width:130px;height:80px;border-radius: 10px;'/></td>"; } } else { if (preg_match('/' . $images . '/', $coulmtype['FieldsName'][$i]) && $coulmtype['OrginalFieldType'][$i] != "blob" && $coulmtype['FieldType'][$i] != "text") { //same code for the blob type but we check for the name incase the type is not blob if ($rowvalue[$i] == '') { echo "<td><img src='images/default.png' style='width:80px;height:80px;border-radius: 10px;'/></td>"; } else { echo "<td><img src='authentication/uploads/{$rowvalue[$i]}' style='width:80px;height:80px;border-radius: 10px;'/></td>"; } } else { if ($coulmtype['OrginalFieldType'][$i] == "blob" && $coulmtype['FieldType'][$i] != "text") { if ($rowvalue[$i] == '') { echo "<td><img src='images/default.png' style='width:80px;height:80px;border-radius: 10px;'/></td>"; } else { echo "<td><img src='data:image/jpeg;base64," . base64_encode($rowvalue[$i]) . "' style='width:80px;height:80px;border-radius: 10px;'/></td>"; } } else { echo "<td>" . substr($rowvalue[$i], 0, 40) . "</td>"; } } } } } //end of primary key // add the edit and delete at the end of columns if ($i == 8 - 1) { echo "<input type='hidden' name='tablename' value='{$table}' />\n <input type='hidden' name='mainid' value='{$rowvalue['0']}' />\n <td><a onclick=\"window.open('authentication/ineredit.php?tablename={$table}&edit={$rowvalue['0']}','Update Records','scrollbars=1,resizable=1,width=600,height=640')\" style=\"cursor: pointer;\">Edit</a></td><td><input form='myform_{$counter}' type='submit' name='delete' value='Delete' class=\"btn btn-danger\" style=\"cursor: pointer;\" /></td>"; } } } //end of if number of col more less than 8 echo "</tr></form>"; $counter++; } //end of while loop // displaying paginaiton. echo pagination($statement, $per_page, $page, $url = '?', $table); }
} //draw the submit form for ($i = 0; $i <= @$colum_submit_number - 1; $i++) { //check if the name is primary key and not display it if ($colum_submit_name_no_replace[$i] != @$PrimryKey_DisplayName) { //get the forgien key if exsist $FK = mysql_get_foregin_key($tablename, $table_submit_info['FieldsName'][$i]); //check if the field now is one of the forgien keys if ($FK != '' && $colum_submit_name_no_replace[$i] == $FK) { //get table name for the fk and select * from table by field name if exsist //databas name to get all FK $FK_Fields_Name = $colum_submit_name_no_replace[$i]; $All_FK_TableName = GetForeginKey_TableName($tablename, $FK); $Tablename_FK = substr($All_FK_TableName[$FK_Fields_Name], 0, strpos($All_FK_TableName[$FK_Fields_Name], '.')); $PK_Name_For_FK = end(explode(".", $All_FK_TableName[$FK_Fields_Name])); $FK_PK = GetCoulmsInfo($Tablename_FK); $PK_Name_For_FK = $FK_PK['primrykeyname']; //get * from this table if display name if empty //the FK Field Should be Displayed by user if (!empty($Forgien_Key_Display_Field)) { //get the displayed forgien key name if (array_key_exists($Tablename_FK, $Forgien_Key_Display_Field)) { $FK_Field_Display = $Forgien_Key_Display_Field[$Tablename_FK]; //get the value that already selected in the main table $FK_Value_Query = mysql_query("SELECT * FROM {$Tablename_FK} "); //append the dropdown list echo "<div class='form-group' >\n\t\t\t\t\t\t\t\t\t<label for='input-rounded' class='col-sm-2 control-label'>" . $colum_submit_name[$i] . "</label>\n\t\t\t\t\t\t\t\t\t<div class='col-sm-10'>\n\t\t\t\t\t\t\t\t\t <select name='{$colum_submit_name_no_replace[$i]}' id='{$colum_submit_name_no_replace[$i]}' >"; //now get the rest of value from the same table while ($RestOfValue = mysql_fetch_array($FK_Value_Query)) { $Selected_Value = $RestOfValue[$FK_Field_Display]; $FK_ID = $RestOfValue[$PK_Name_For_FK];
<?php require 'function.php'; //handel query excute //check the table if (!empty($_POST['tablename'])) { $main_table = mysql_real_escape_string($_POST['tablename']); //check the query type if (!empty($_POST['delete'])) { $main_id = mysql_real_escape_string($_POST['mainid']); $get_prim_key_name = GetCoulmsInfo($main_table); $get_prim_key_name = $get_prim_key_name['primrykeyname']; $delet_query = "DELETE FROM `{$main_table}` WHERE `{$get_prim_key_name}` ='{$main_id}'"; if (!mysql_query($delet_query)) { $error = mysql_error(); echo "<script>window.location ='../index.php?tablename={$main_table}&error={$error}';</script>"; } else { echo "<script>window.location ='../index.php?tablename={$main_table}&Done';</script>"; } } //end of delete query unset($_POST); unset($SESSION); }
</head> <body style="color:white;"> <main class="page-content content-wrap"> <div class="navbar"> <div class="navbar-inner"> <form method="POST" action="" enctype='multipart/form-data'> <?php //include main library include 'function.php'; include 'FK_Config.php'; if (isset($_GET['tablename']) && isset($_GET['edit'])) { # code... $tablename = mysql_real_escape_string($_GET['tablename']); $PrimID = mysql_real_escape_string($_GET['edit']); echo "<div id='table_title' >\n\t<h1 style='margin-left: 14px;color:#4E5E6A;'>" . strtoupper($tablename) . "</h1>\n\t</div><table>"; $table_update_info = GetCoulmsInfo($tablename); @($PrimryKey_DisplayName = $table_update_info['FieldsName'][0]); @($colum_update_name_no_replace = $table_update_info['FieldsName']); @($colum_update_name = str_replace('_', ' ', $table_update_info['FieldsName'])); @($colum_update_type = $table_update_info['FieldType']); @($colum_update_orginaltype = $table_update_info['OrginalFieldType']); @($colum_update_number = $table_update_info['columnnumber']); $fkfieldname = mysql_real_escape_string($_GET['fkfieldname']); $relatedid = mysql_real_escape_string($_GET['relatedid']); //get all config info if exsist @($confObj = CheckconfigInfo()); //prepare the variables for youtube and viedo and images if (count($confObj) > 0) { if ($confObj['fieldname_image'] != '') { $images = str_replace('_', '', $confObj['fieldname_image']); } else {
echo "<style>.tableMSG{display:block!important}.toast-info { background-color: #E26B7D!important;}</style>"; } else { if ($userloginfield == '') { echo "<style>.userfieldMSG{display:block!important}.toast-info { background-color: #E26B7D!important;}</style>"; } else { if ($userloginpassword == '') { echo "<style>.passwordfieldMSG{display:block!important}.toast-info { background-color: #E26B7D!important;}</style>"; } else { if (isset($_POST['userlogin'])) { if (!empty(isset($_POST['username'])) && !empty(isset($_POST['userpassword']))) { # code... $username = mysql_real_escape_string($_POST['username']); $userpassword = mysql_real_escape_string($_POST['userpassword']); $ASHPassword = sha1($userpassword); //get primary key $coulmtype = GetCoulmsInfo($usertable); $primryname = $coulmtype['FieldsName'][0]; $getuserid = mysql_query("SELECT `{$primryname}` FROM `{$usertable}` WHERE `{$userloginfield}`='{$username}' AND `{$userloginpassword}`='{$ASHPassword}' "); if (!$getuserid) { echo "<style>.wronguserMSG{display:block!important}.toast-info { background-color: #E26B7D!important;}</style>"; } else { $checkuserexsist = mysql_num_rows($getuserid); if ($checkuserexsist == 0) { echo "<style>.wronguserMSG{display:block!important}.toast-info { background-color: #E26B7D!important;}</style>"; } elseif ($checkuserexsist == 1) { // Fetch the user id from the query $user_id = mysql_result($getuserid, 0, $primryname); // Store the user id in the Session // Note : The Session is Started in the page Core.inc.php which is included to the index page and has session.start(); $_SESSION['userid'] = $user_id; $id = $_SESSION['userid'];
echo "<div class='page-title'>\n\n <h3>Dashboard</h3>\n <div class='page-breadcrumb'>\n <ol class='breadcrumb'>\n <li><a href='index.html'>Home</a></li>\n <li class='active'>Dashboard</li>\n </ol>\n </div>"; } ?> </div> <div id="toast-container" class="toast-top-full-width DeleteMSG" aria-live="polite" role="alert" style="display:none"><div class="toast toast-info"><div class="toast-message">Sucssesfully Record Deleted!</div></div></div> <div id="toast-container" class="toast-top-full-width UpdateMSG" aria-live="polite" role="alert" style="display:none"><div class="toast toast-info"><div class="toast-message">Sucssesfully Records Updated!</div></div></div> <div id="toast-container" class="toast-top-full-width SubmitMSG" aria-live="polite" role="alert" style="display:none"><div class="toast toast-info"><div class="toast-message">Sucssesfully Records Submited!</div></div></div> <div id="main-wrapper"> <?php if (isset($_GET['tablename'])) { //get the table name $table = $_GET['tablename']; $tableinfo = GetCoulmsInfo($table); //var_dump($tableinfo['columnnumber']); echo "<div class='col-md-12'>\n <div class='panel panel-white'>\n <div class='panel-heading clearfix'>\n <h4 class='panel-title'><a onclick=\"window.open('authentication/addnewrecord.php?tablename={$table}&newrecord','Update Records','scrollbars=1,resizable=1,width=600,height=640')\" style=\"cursor: pointer;\">Add New Record</a></h4>\n </div>\n <div class='panel-body'>\n <div class='table-responsive'>\n <table class='table table-bordered'>\n <thead>\n <tr>\n <th> Display </th>"; GetCloumName($table); echo "<th>Edit</th>\n <th>Delete</th></tr>\n </thead>\n <tbody>"; GetcolumnValue($table, @$Forgien_Key_Display_Field); echo "\n \n </tbody>\n </table>\n </div>\n </div>\n </div>\n </div>"; } else { //check statistics table @($statistics = mysql_query("SELECT * FROM statistics_settings_genericadmin")); @($statisticstable = mysql_num_rows(mysql_query("SELECT * FROM statistics_settings_genericadmin"))); if (@$statisticstable != 0) { echo "<div class='row'>"; while ($statrow = mysql_fetch_array($statistics)) { $statmethod = $statrow['methodname']; $tablename = $statrow['tablename'];