PageRenderTime 45ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/ebpls010.php

http://ebpls.googlecode.com/
PHP | 164 lines | 136 code | 19 blank | 9 comment | 15 complexity | 651b5788bcfffe911c43f88e8dddf4cd MD5 | raw file
  1. <?php
  2. // eBPLS_PAGE_USER_DELETE: This module allows admins to delete user accounts.
  3. ob_start();
  4. $strFrmctr = (empty($frmctr)) ? "" : "_$frmctr";
  5. $qryVar1 = "frmDomain".$strFrmctr;
  6. $qryVar2 = "frmThreadId".$strFrmctr;
  7. require_once "includes/config.php";
  8. require_once "setup/" . $$qryVar1 . "/setting.php";
  9. require_once "lib/ebpls.lib.php";
  10. dbConnect();
  11. $intUserLevel = isUserLogged();
  12. syncUserCookieDbLogStat();
  13. require_once("lib/ebpls.utils.php");
  14. include("includes/variables.php");
  15. include("lib/multidbconnection.php");
  16. $dbLink =Open($dbtype,$connecttype,$dbhost,$dbuser,$dbpass,$dbname);
  17. //--- get connection from DB
  18. //$dbLink = get_db_connection();
  19. ?>
  20. <html>
  21. <head>
  22. <title>eBPLS</title>
  23. <link href="stylesheets/default.css" rel="stylesheet" type="text/css">
  24. <script language="JavaScript" src="includes/eBPLS.js"></script>
  25. </head>
  26. <body bgcolor="#FFFFFF" text="#000000" link="" vlink="" alink="" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
  27. <table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
  28. <tr>
  29. <td align="CENTER" valign="MIDDLE">
  30. <table width="650" border="0" cellspacing="1" cellpadding="1">
  31. <tr>
  32. <td bgcolor="<?php echo($thThemeColor4); ?>" align="RIGHT" class="thText">
  33. <a href="javascript: opener.location.reload(true); window.close();"><b>Close this Window [X]</b></a><br>
  34. </td>
  35. </tr>
  36. </table>
  37. <?php
  38. // update record if triggered
  39. if (!empty($frmBtnDelete)) {
  40. $checkif = @mysql_query("select username,login,logout from ebpls_user where id = '$frmId'");
  41. $checkiff = @mysql_fetch_assoc($checkif);
  42. $isonline = strtotime($checkiff[login])-strtotime($checkiff[logout]);
  43. if ($ThUserData[username] == $checkiff[username]) {
  44. ?>
  45. <body onload='javascript:alert ("Cannot delete own account!!"); return false;'></body>
  46. <?
  47. } else {
  48. if ($isonline > 0) {
  49. ?>
  50. <body onload='javascript:alert ("Cannot delete online user.\nAsk user to logout or\nkick user before deleting."); return false;'></body>
  51. <?
  52. } else {
  53. $strQuery = "DELETE FROM ebpls_user WHERE id = $frmId";
  54. }
  55. }
  56. //echo "$intUserLevel :: $strQuery<BR> :: " . eBPLS_USER_CTC;
  57. if ($intUserLevel >= eBPLS_USER_CTC ) {
  58. $result = th_query($strQuery);
  59. //--- delete from the listings
  60. delSubLevelListings($dbLink,$frmId);
  61. } else {
  62. $result = FALSE;
  63. }
  64. if ($result === FALSE) {
  65. "<div align=\"CENTER\" class=\"thFieldTitle\">Delete Failed! Please Contact Your Administrator.</div>";
  66. } else {
  67. echo "<div align=\"CENTER\" class=\"thFieldTitle\">Delete Successfull!</div>";
  68. }
  69. } else {
  70. // ********************** START HERE **********************
  71. if (!empty($$qryVar2) || !empty($frmId)) {
  72. require_once "lib/dbhtmltable.class.php";
  73. $objDbTable = new DbHtmlTable(
  74. $thThemeColor3, // <table> row alternating colour 1
  75. $thThemeColor4, // <table> row alternating colour 2
  76. "ARIAL,HELVETICA,SANS-SERIF", // results' font face
  77. "2", // results' font size
  78. "#000000", // <table> border colour
  79. 500, // <table> width
  80. 1, // <table> cellspacing
  81. 2 // <table> cellpadding
  82. );
  83. echo "<div align=\"CENTER\" class=\"thText\">\n";
  84. echo "<form method=\"POST\" action=\"" . $HTTP_SERVER_VARS['PHP_SELF'] . "\">\n";
  85. echo "<span class=\"thSectionTitle\">Delete This User?</span><br>\n";
  86. echo $objDbTable->getDbRecHtmlTable(
  87. "SELECT id, level, username, password, lastname, firstname, designation, email, gsmnum, dateadded, lastupdated FROM ebpls_user WHERE id = " . $$qryVar2,
  88. array('User Id', 'User Level', 'User Name', 'Password', 'Lastname', 'Firstname', 'Designation', 'Email Address', 'GSM Number', 'Date Added', 'Last Updated'),
  89. array('setInputHidden', 'decodeUserLevel', 'setInputText', 'setInputPassword', 'setInputText', 'setInputText', 'setInputText', 'setInputText', 'setInputText', null, null, null),
  90. $thDbLink,
  91. 200,
  92. 300
  93. ) . "<br>\n";
  94. echo "<input type=\"HIDDEN\" name=\"frmctr\" value=\"{$frmctr}\">\n";
  95. echo "<input type=\"HIDDEN\" name=\"$qryVar1\" value=\"" . $$qryVar1 . "\">\n";
  96. echo "<input type=\"HIDDEN\" name=\"$qryVar2\" value=\"" . $$qryVar2 . "\">\n";
  97. echo "<input type=\"SUBMIT\" name=\"frmBtnDelete\" value=\"Delete\"> &nbsp; &nbsp;\n";
  98. echo "<input type=\"BUTTON\" name=\"frmBtnCancel\" value=\"Close\" onClick=\"javascript: window.close();\"> &nbsp; &nbsp;\n";
  99. echo "</form>\n";
  100. echo "</div>\n";
  101. } else {
  102. echo "<br><br><span class=\"thFieldTitle\">Access Denied : Insufficient Parameters!</span>";
  103. }
  104. // ********************** END HERE **********************
  105. }
  106. // *** Module Dependent User-defined Functions ***
  107. function decodeUserLevel($intLevel)
  108. {
  109. return "<input type=\"TEXT\" name=\"$strFormName\" value=\"" . $GLOBALS['thUserLevel'][$intLevel][1] . "\" size=\"20\" style=\"width:270px\" readonly=\"readonly\">";
  110. }
  111. function setInputHidden($strInput, $strFieldName)
  112. {
  113. $strFormName = "frm" . ucfirst($strFieldName);
  114. return "<input type=\"HIDDEN\" name=\"$strFormName\" value=\"$strInput\">$strInput";
  115. }
  116. function setInputText($strInput, $strFieldName)
  117. {
  118. $strFormName = "frm" . ucfirst($strFieldName);
  119. return "<input type=\"HIDDEN\" name=\"{$strFormName}Old\" value=\"$strInput\"><input type=\"TEXT\" name=\"$strFormName\" value=\"$strInput\" size=\"20\" style=\"width:270px\" readonly=\"readonly\">";
  120. }
  121. function setInputPassword($strInput, $strFieldName)
  122. {
  123. $strFormName = "frm" . ucfirst($strFieldName);
  124. return "<input type=\"Password\" name=\"$strFormName\" value=\"$strInput\" size=\"20\" style=\"width:270px\" readonly=\"readonly\">";
  125. }
  126. function setHighLight($strInput)
  127. {
  128. return "<div align=\"CENTER\" class=\"thErrorMsg\" style=\"font-size:14pt;\">{$strInput}</div>";
  129. }
  130. function delSubLevelListings($dbLink,$uid)
  131. {
  132. $sql = "DELETE FROM ebpls_user_sublevel_listings WHERE user_id=$uid";
  133. @mysql_query($sql, $dbLink);
  134. }
  135. ?>
  136. </td>
  137. </tr>
  138. </table>
  139. </body>
  140. </html>
  141. <?php
  142. if ($intUserLevel > -1) setCurrentActivityLog($thStrLogAction);
  143. ob_end_flush();
  144. include "logger.php";
  145. ?>