PageRenderTime 106ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/osj-register.php

http://osjobber.googlecode.com/
PHP | 598 lines | 464 code | 64 blank | 70 comment | 92 complexity | 7a19fd2f7d4d9c927f27a5cf0860f91e MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0
  1. <?php
  2. define("EW_PAGE_ID", "register", TRUE); // Page ID
  3. ?>
  4. <?php
  5. session_start(); // Initialize session data
  6. ob_start(); // Turn on output buffering
  7. ?>
  8. <?php include "osj-ewcfg50.php" ?>
  9. <?php include "osj-ewmysql50.php" ?>
  10. <?php include "osj-phpfn50.php" ?>
  11. <?php include "osj-osj2dusersinfo.php" ?>
  12. <?php include "osj-userfn50.php" ?>
  13. <?php
  14. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
  15. header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
  16. header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1
  17. header("Cache-Control: post-check=0, pre-check=0", false);
  18. header("Pragma: no-cache"); // HTTP/1.0
  19. ?>
  20. <?php
  21. // Open connection to the database
  22. $conn = ew_Connect();
  23. ?>
  24. <?php
  25. $Security = new cAdvancedSecurity();
  26. ?>
  27. <?php
  28. // Common page loading event (in userfn*.php)
  29. Page_Loading();
  30. ?>
  31. <?php
  32. // Page load event, used in current page
  33. Page_Load();
  34. ?>
  35. <?php
  36. $bUserExists = FALSE;
  37. // Create form object
  38. $objForm = new cFormObj();
  39. if (@$_POST["a_register"] <> "") {
  40. // Get action
  41. $osj2Dusers->CurrentAction = $_POST["a_register"];
  42. LoadFormValues(); // Get form values
  43. } else {
  44. $osj2Dusers->CurrentAction = "I"; // Display blank record
  45. LoadDefaultValues(); // Load default values
  46. }
  47. // Handle email activation
  48. if (@$_GET["action"] <> "") {
  49. $sAction = $_GET["action"];
  50. $sEmail = $_GET["email"];
  51. $qs = new cQueryString();
  52. $sApprovalCode = $qs->getValue("code");
  53. if ($sEmail == TEAdecrypt($sApprovalCode, EW_RANDOM_KEY)) {
  54. if (strtolower($sAction) == "confirm") { // Email activation
  55. if (ActivateEmail($sEmail)) { // activate this email
  56. $_SESSION[EW_SESSION_MESSAGE] = "Your account is activated"; // Set message acount activated
  57. Page_Terminate("osj-login.php"); // Go to login page
  58. }
  59. }
  60. }
  61. if (@$_SESSION[EW_SESSION_MESSAGE] == "") {
  62. $_SESSION[EW_SESSION_MESSAGE] = "Activation failed"; // Set activate failed message
  63. }
  64. Page_Terminate("osj-login.php"); // Go to login page
  65. }
  66. switch ($osj2Dusers->CurrentAction) {
  67. case "I": // Blank record, no action required
  68. break;
  69. case "A": // Add
  70. // Check for Duplicate User ID
  71. $sFilter = "(`user_email` = '" . ew_AdjustSql($osj2Dusers->user_email->CurrentValue) . "')";
  72. // Set up filter (Sql Where Clause) and get Return Sql
  73. // Sql constructor in osj2Dusers class, osj2Dusersinfo.php
  74. $osj2Dusers->CurrentFilter = $sFilter;
  75. $sUserSql = $osj2Dusers->SQL();
  76. if ($rs = $conn->Execute($sUserSql)) {
  77. if (!$rs->EOF) {
  78. $bUserExists = TRUE;
  79. RestoreFormValues(); // Restore form values
  80. $_SESSION[EW_SESSION_MESSAGE] = "User Already Exists!"; // Set user exist message
  81. }
  82. $rs->Close();
  83. }
  84. if (!$bUserExists) {
  85. $osj2Dusers->SendEmail = TRUE; // Send email on add success
  86. if (AddRow()) { // Add record
  87. // Load user email
  88. $sReceiverEmail = $osj2Dusers->user_email->CurrentValue;
  89. if ($sReceiverEmail == "") { // Send to recipient directly
  90. $sReceiverEmail = EW_RECIPIENT_EMAIL;
  91. $sBccEmail = "";
  92. } else { // Bcc recipient
  93. $sBccEmail = EW_RECIPIENT_EMAIL;
  94. }
  95. // Set up email content
  96. if ($sReceiverEmail <> "") {
  97. $Email = new cEmail;
  98. $Email->Load("txt/osj-register.txt");
  99. $Email->ReplaceSender(EW_SENDER_EMAIL); // Replace Sender
  100. $Email->ReplaceRecipient($sReceiverEmail); // Replace Recipient
  101. if ($sBccEmail <> "") $Email->AddBcc($sBccEmail); // Add Bcc
  102. $Email->ReplaceContent('<!--user_email-->', strval($osj2Dusers->user_email->CurrentValue));
  103. $Email->ReplaceContent('<!--user_password-->', strval($osj2Dusers->user_password->CurrentValue));
  104. $Email->ReplaceContent('<!--user_level-->', strval($osj2Dusers->user_level->CurrentValue));
  105. $sActivateLink = ew_FullUrl() . "?action=confirm";
  106. $sActivateLink .= "&email=" . $osj2Dusers->user_email->CurrentValue;
  107. $sActivateLink .= "&code=" . TEAencrypt($osj2Dusers->user_email->CurrentValue, EW_RANDOM_KEY);
  108. $Email->ReplaceContent("<!--ActivateLink-->", $sActivateLink);
  109. $Email->Send();
  110. }
  111. $_SESSION[EW_SESSION_MESSAGE] = "Registration Successful. An email has been sent to your email address, please click the link in the email to activate your account."; // Activate success
  112. Page_Terminate("osj-login.php"); // Go to login page
  113. } else {
  114. RestoreFormValues(); // Restore form values
  115. }
  116. }
  117. }
  118. // Render row
  119. $osj2Dusers->RowType = EW_ROWTYPE_ADD; // Render add
  120. RenderRow();
  121. ?>
  122. <?php include "osj-header.php" ?>
  123. <script type="text/javascript">
  124. <!--
  125. var EW_PAGE_ID = "register"; // Page id
  126. var EW_SHOW_HIGHLIGHT = "Show highlight";
  127. var EW_HIDE_HIGHLIGHT = "Hide highlight";
  128. //-->
  129. </script>
  130. <script type="text/javascript">
  131. <!--
  132. function ew_ValidateForm(fobj) {
  133. if (fobj.a_confirm && fobj.a_confirm.value == "F")
  134. return true;
  135. var i, elm, aelm, infix;
  136. var rowcnt = (fobj.key_count) ? Number(fobj.key_count.value) : 1;
  137. for (i=0; i<rowcnt; i++) {
  138. infix = (fobj.key_count) ? String(i+1) : "";
  139. elm = fobj.elements["x" + infix + "_user_email"];
  140. if (elm && !ew_HasValue(elm)) {
  141. if (!ew_OnError(elm, "Please enter required field - Email"))
  142. return false;
  143. }
  144. elm = fobj.elements["x" + infix + "_user_email"];
  145. if (elm && !ew_CheckEmail(elm.value)) {
  146. if (!ew_OnError(elm, "Users must provide a valid email address."))
  147. return false;
  148. }
  149. elm = fobj.elements["x" + infix + "_user_password"];
  150. if (elm && !ew_HasValue(elm)) {
  151. if (!ew_OnError(elm, "Please enter required field - Password"))
  152. return false;
  153. }
  154. if (fobj.x_user_password && !ew_HasValue(fobj.x_user_password)) {
  155. if (!ew_OnError(fobj.x_user_password, "Please enter password"))
  156. return false;
  157. }
  158. if (fobj.c_user_password.value != fobj.x_user_password.value) {
  159. if (!ew_OnError(fobj.c_user_password, "Mismatch Password"))
  160. return false;
  161. }
  162. elm = fobj.elements["x" + infix + "_user_level"];
  163. if (elm && !ew_HasValue(elm)) {
  164. if (!ew_OnError(elm, "Please enter required field - User Level"))
  165. return false;
  166. }
  167. }
  168. return true;
  169. }
  170. //-->
  171. </script>
  172. <script type="text/javascript">
  173. <!--
  174. var ew_DHTMLEditors = [];
  175. //-->
  176. </script>
  177. <script type="text/javascript">
  178. <!--
  179. // js for Popup Calendar
  180. //-->
  181. </script>
  182. <script type="text/javascript">
  183. <!--
  184. var ew_MultiPagePage = "Page"; // multi-page Page Text
  185. var ew_MultiPageOf = "of"; // multi-page Of Text
  186. var ew_MultiPagePrev = "Prev"; // multi-page Prev Text
  187. var ew_MultiPageNext = "Next"; // multi-page Next Text
  188. //-->
  189. </script>
  190. <script language="JavaScript" type="text/javascript">
  191. <!--
  192. // Write your client script here, no need to add script tags.
  193. // To include another .js script, use:
  194. // ew_ClientScriptInclude("my_javascript.js");
  195. //-->
  196. </script>
  197. <p><span class="phpmaker">
  198. Registration Page<br><br>
  199. <a href="osj-login.php">Back to Login Page</a>
  200. </span></p>
  201. <?php
  202. if (@$_SESSION[EW_SESSION_MESSAGE] <> "") {
  203. ?>
  204. <p><span class="ewmsg"><?php echo $_SESSION[EW_SESSION_MESSAGE] ?></span></p>
  205. <?php
  206. $_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message
  207. }
  208. ?>
  209. <form name="fosj2Dusersregister" id="fosj2Dusersregister" action="osj-register.php" method="post" onSubmit="return ew_ValidateForm(this);">
  210. <p>
  211. <input type="hidden" name="a_register" id="a_register" value="A">
  212. <table class="ewTable">
  213. <tr class="ewTableRow">
  214. <td class="ewTableHeader">Email<span class='ewmsg'>&nbsp;*</span></td>
  215. <td<?php echo $osj2Dusers->user_email->CellAttributes() ?>><span id="cb_x_user_email">
  216. <input type="text" name="x_user_email" id="x_user_email" title="Email" size="30" maxlength="255" value="<?php echo $osj2Dusers->user_email->EditValue ?>"<?php echo $osj2Dusers->user_email->EditAttributes() ?>>
  217. </span></td>
  218. </tr>
  219. <tr class="ewTableAltRow">
  220. <td class="ewTableHeader">Password<span class='ewmsg'>&nbsp;*</span></td>
  221. <td<?php echo $osj2Dusers->user_password->CellAttributes() ?>><span id="cb_x_user_password">
  222. <input type="password" name="x_user_password" id="x_user_password" title="Password" value="<?php echo $osj2Dusers->user_password->EditValue ?>" size="30" maxlength="255"<?php echo $osj2Dusers->user_password->EditAttributes() ?>>
  223. </span></td>
  224. </tr>
  225. <!--tr id=""-->
  226. <tr class="ewTableRow">
  227. <td class="ewTableHeader">Confirm Password</td>
  228. <td<?php echo $osj2Dusers->user_password->CellAttributes() ?>>
  229. <input type="password" name="c_user_password" id="c_user_password" title="Password" value="<?php echo $osj2Dusers->user_password->EditValue ?>" size="30" maxlength="255"<?php echo $osj2Dusers->user_password->EditAttributes() ?>>
  230. </td>
  231. </tr>
  232. <?php if (!$Security->IsAdmin() && $Security->IsLoggedIn()) { // Non system admin ?>
  233. <div<?php echo $osj2Dusers->user_level->ViewAttributes() ?>><?php echo $osj2Dusers->user_level->EditValue ?></div>
  234. <?php } else { ?>
  235. <select id="x_user_level" name="x_user_level"<?php echo $osj2Dusers->user_level->EditAttributes() ?>>
  236. <!--option value="">Please Select</option-->
  237. <?php
  238. if (is_array($osj2Dusers->user_level->EditValue)) {
  239. $arwrk = $osj2Dusers->user_level->EditValue;
  240. $rowswrk = count($arwrk);
  241. for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
  242. $selwrk = (strval($osj2Dusers->user_level->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected" : "";
  243. ?>
  244. <option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
  245. <?php echo $arwrk[$rowcntwrk][1] ?>
  246. </option>
  247. <?php
  248. }
  249. }
  250. ?>
  251. </select>
  252. <?php
  253. $sSqlWrk = "SELECT `user_level_id`, `user_level_name` FROM `osj-user_level`";
  254. $sSqlWrk .= " WHERE (" . "`user_level_name` != 'Default' AND `user_level_name`!= 'Administrator'" . ")";
  255. $sSqlWrk = TEAencrypt($sSqlWrk, EW_RANDOM_KEY);
  256. ?>
  257. <input type="hidden" name="s_x_user_level" id="s_x_user_level" value="<?php echo $sSqlWrk ?>"><input type="hidden" name="lc_x_user_level" id="lc_x_user_level" value="2"><input type="hidden" name="ld1_x_user_level" id="ld1_x_user_level" value="1"><input type="hidden" name="ld2_x_user_level" id="ld2_x_user_level" value="-1"><input type="hidden" name="lft_x_user_level" id="lft_x_user_level" value="1">
  258. <?php } ?>
  259. </table>
  260. <p>
  261. <input type="submit" name="btnAction" id="btnAction" value=" Register ">
  262. </form>
  263. <script language="JavaScript">
  264. <!--
  265. var f = document.fosj2Dusersregister;
  266. ew_AjaxUpdateOpt(f.x_user_level, f.x_user_level, false);
  267. //-->
  268. </script>
  269. <script language="JavaScript" type="text/javascript">
  270. <!--
  271. // Write your startup script here
  272. // document.write("page loaded");
  273. //-->
  274. </script>
  275. <?php include "osj-footer.php" ?>
  276. <?php
  277. // If control is passed here, simply terminate the page without redirect
  278. Page_Terminate();
  279. // -----------------------------------------------------------------
  280. // Subroutine Page_Terminate
  281. // - called when exit page
  282. // - clean up connection and objects
  283. // - if url specified, redirect to url, otherwise end response
  284. function Page_Terminate($url = "") {
  285. global $conn;
  286. // Page unload event, used in current page
  287. Page_Unload();
  288. // Global page unloaded event (in userfn*.php)
  289. Page_Unloaded();
  290. // Close Connection
  291. $conn->Close();
  292. // Go to url if specified
  293. if ($url <> "") {
  294. ob_end_clean();
  295. header("Location: $url");
  296. }
  297. exit();
  298. }
  299. ?>
  300. <?php
  301. // Activate account based on email
  302. function ActivateEmail($email) {
  303. global $conn, $osj2Dusers;
  304. $sFilter = "(`user_email` = '" . ew_AdjustSql($email) . "')";
  305. $osj2Dusers->CurrentFilter = $sFilter;
  306. $sSql = $osj2Dusers->SQL();
  307. $conn->raiseErrorFn = 'ew_ErrorFn';
  308. $rs = $conn->Execute($sSql);
  309. $conn->raiseErrorFn = '';
  310. if ($rs === FALSE)
  311. return FALSE;
  312. if (!$rs->EOF) {
  313. $rs->Close();
  314. $rsnew = array('user_status' => 1); // Auto register
  315. return $conn->Execute($osj2Dusers->UpdateSQL($rsnew));
  316. } else {
  317. $_SESSION[EW_SESSION_MESSAGE] = "No records found";
  318. $rs->Close();
  319. return FALSE;
  320. }
  321. }
  322. ?>
  323. <?php
  324. // Load default values
  325. function LoadDefaultValues() {
  326. global $osj2Dusers;
  327. $osj2Dusers->user_level->CurrentValue = 2;
  328. }
  329. ?>
  330. <?php
  331. // Load form values
  332. function LoadFormValues() {
  333. // Load from form
  334. global $objForm, $osj2Dusers;
  335. $osj2Dusers->user_email->setFormValue($objForm->GetValue("x_user_email"));
  336. $osj2Dusers->user_password->setFormValue($objForm->GetValue("x_user_password"));
  337. $osj2Dusers->user_level->setFormValue($objForm->GetValue("x_user_level"));
  338. }
  339. // Restore form values
  340. function RestoreFormValues() {
  341. global $osj2Dusers;
  342. $osj2Dusers->user_email->CurrentValue = $osj2Dusers->user_email->FormValue;
  343. $osj2Dusers->user_password->CurrentValue = $osj2Dusers->user_password->FormValue;
  344. $osj2Dusers->user_level->CurrentValue = $osj2Dusers->user_level->FormValue;
  345. }
  346. ?>
  347. <?php
  348. // Render row values based on field settings
  349. function RenderRow() {
  350. global $conn, $Security, $osj2Dusers;
  351. // Call Row Rendering event
  352. $osj2Dusers->Row_Rendering();
  353. // Common render codes for all row types
  354. // user_email
  355. $osj2Dusers->user_email->CellCssStyle = "";
  356. $osj2Dusers->user_email->CellCssClass = "";
  357. // user_password
  358. $osj2Dusers->user_password->CellCssStyle = "";
  359. $osj2Dusers->user_password->CellCssClass = "";
  360. // user_level
  361. $osj2Dusers->user_level->CellCssStyle = "";
  362. $osj2Dusers->user_level->CellCssClass = "";
  363. if ($osj2Dusers->RowType == EW_ROWTYPE_VIEW) { // View row
  364. } elseif ($osj2Dusers->RowType == EW_ROWTYPE_ADD) { // Add row
  365. // user_email
  366. $osj2Dusers->user_email->EditCustomAttributes = "";
  367. $osj2Dusers->user_email->EditValue = ew_HtmlEncode($osj2Dusers->user_email->CurrentValue);
  368. // user_password
  369. $osj2Dusers->user_password->EditCustomAttributes = "";
  370. $osj2Dusers->user_password->EditValue = ew_HtmlEncode($osj2Dusers->user_password->CurrentValue);
  371. // user_level
  372. $osj2Dusers->user_level->EditCustomAttributes = "";
  373. if (!$Security->CanAdmin()) { // System admin
  374. $osj2Dusers->user_level->EditValue = "********";
  375. } else {
  376. $sSqlWrk = "SELECT `user_level_id`, `user_level_name` FROM `osj-user_level`";
  377. if (trim(strval($osj2Dusers->user_level->CurrentValue)) == "") {
  378. $sSqlWrk .= " WHERE 0=1";
  379. } else {
  380. $sSqlWrk .= " WHERE `user_level_id` = " . ew_AdjustSql($osj2Dusers->user_level->CurrentValue) . "";
  381. }
  382. $sSqlWrk .= " AND (" . "`user_level_name` != 'Default' AND `user_level_name`!= 'Administrator'" . ")";
  383. $rswrk = $conn->Execute($sSqlWrk);
  384. $arwrk = ($rswrk) ? $rswrk->GetRows() : array();
  385. if ($rswrk) $rswrk->Close();
  386. array_unshift($arwrk, array("", "Please Select"));
  387. $osj2Dusers->user_level->EditValue = $arwrk;
  388. }
  389. } elseif ($osj2Dusers->RowType == EW_ROWTYPE_EDIT) { // Edit row
  390. } elseif ($osj2Dusers->RowType == EW_ROWTYPE_SEARCH) { // Search row
  391. }
  392. // Call Row Rendered event
  393. $osj2Dusers->Row_Rendered();
  394. }
  395. ?>
  396. <?php
  397. // Add record
  398. function AddRow() {
  399. global $conn, $Security, $osj2Dusers;
  400. // Check if valid User ID
  401. $bValidUser = FALSE;
  402. if ($Security->CurrentUserID() <> "" && !$Security->IsAdmin()) { // Non system admin
  403. $bValidUser = $Security->IsValidUserID($osj2Dusers->user_id->CurrentValue);
  404. if (!$bValidUser) {
  405. $_SESSION[EW_SESSION_MESSAGE] = "Unauthorized";
  406. return FALSE;
  407. }
  408. }
  409. // Check for duplicate key
  410. $bCheckKey = TRUE;
  411. $sFilter = $osj2Dusers->SqlKeyFilter();
  412. if (trim(strval($osj2Dusers->user_id->CurrentValue)) == "") {
  413. $bCheckKey = FALSE;
  414. } else {
  415. $sFilter = str_replace("@user_id@", ew_AdjustSql($osj2Dusers->user_id->CurrentValue), $sFilter); // Replace key value
  416. }
  417. if (!is_numeric($osj2Dusers->user_id->CurrentValue)) {
  418. $bCheckKey = FALSE;
  419. }
  420. if ($bCheckKey) {
  421. $rsChk = $osj2Dusers->LoadRs($sFilter);
  422. if ($rsChk && !$rsChk->EOF) {
  423. $_SESSION[EW_SESSION_MESSAGE] = "Duplicate value for primary key";
  424. $rsChk->Close();
  425. return FALSE;
  426. }
  427. }
  428. if ($osj2Dusers->user_email->CurrentValue <> "") { // Check field with unique index
  429. $sFilter = "(`user_email` = '" . ew_AdjustSql($osj2Dusers->user_email->CurrentValue) . "')";
  430. $rsChk = $osj2Dusers->LoadRs($sFilter);
  431. if ($rsChk && !$rsChk->EOF) {
  432. $_SESSION[EW_SESSION_MESSAGE] = "Duplicate value for index or primary key -- `user_email`, value = " . $osj2Dusers->user_email->CurrentValue;
  433. $rsChk->Close();
  434. return FALSE;
  435. }
  436. }
  437. $rsnew = array();
  438. // Field user_email
  439. $osj2Dusers->user_email->SetDbValueDef($osj2Dusers->user_email->CurrentValue, "");
  440. $rsnew['user_email'] =& $osj2Dusers->user_email->DbValue;
  441. // Field user_password
  442. $osj2Dusers->user_password->SetDbValueDef($osj2Dusers->user_password->CurrentValue, "");
  443. $rsnew['user_password'] =& $osj2Dusers->user_password->DbValue;
  444. // Field user_level
  445. $rsnew['user_level'] = 2; // Set default User Level
  446. // Call Row Inserting event
  447. $bInsertRow = $osj2Dusers->Row_Inserting($rsnew);
  448. if ($bInsertRow) {
  449. $conn->raiseErrorFn = 'ew_ErrorFn';
  450. $AddRow = $conn->Execute($osj2Dusers->InsertSQL($rsnew));
  451. $conn->raiseErrorFn = '';
  452. } else {
  453. if ($osj2Dusers->CancelMessage <> "") {
  454. $_SESSION[EW_SESSION_MESSAGE] = $osj2Dusers->CancelMessage;
  455. $osj2Dusers->CancelMessage = "";
  456. } else {
  457. $_SESSION[EW_SESSION_MESSAGE] = "Insert cancelled";
  458. }
  459. $AddRow = FALSE;
  460. }
  461. if ($AddRow) {
  462. $osj2Dusers->user_id->setDbValue($conn->Insert_ID());
  463. $rsnew['user_id'] =& $osj2Dusers->user_id->DbValue;
  464. // Call Row Inserted event
  465. $osj2Dusers->Row_Inserted($rsnew);
  466. WriteAuditTrailOnAdd($rsnew);
  467. if ($osj2Dusers->SendEmail) SendEmailOnAdd($rsnew);
  468. }
  469. return $AddRow;
  470. }
  471. ?>
  472. <?php
  473. // Write Audit Trail start/end for grid update
  474. function WriteAuditTrailDummy($typ) {
  475. $table = 'osj-users';
  476. // Write Audit Trail
  477. $filePfx = "log";
  478. $curDate = date("Y/m/d");
  479. $curTime = date("H:i:s");
  480. $id = ew_ScriptName();
  481. $user = CurrentUserID();
  482. $action = $typ;
  483. ew_WriteAuditTrail($filePfx, $curDate, $curTime, $id, $user, $action, $table, "", "", "", "");
  484. }
  485. ?>
  486. <?php
  487. // Write Audit Trail (add page)
  488. function WriteAuditTrailOnAdd(&$rs) {
  489. global $osj2Dusers;
  490. $table = 'osj-users';
  491. // Get key value
  492. $key = "";
  493. if ($key <> "") $key .= EW_COMPOSITE_KEY_SEPARATOR;
  494. $key .= $rs['user_id'];
  495. // Write Audit Trail
  496. $filePfx = "log";
  497. $curDate = date("Y/m/d");
  498. $curTime = date("H:i:s");
  499. $id = ew_ScriptName();
  500. $user = CurrentUserID();
  501. $action = "A";
  502. $oldvalue = "";
  503. foreach (array_keys($rs) as $fldname) {
  504. if ($osj2Dusers->fields[$fldname]->FldDataType <> EW_DATATYPE_BLOB) { // Ignore Blob Field
  505. $newvalue = ($osj2Dusers->fields[$fldname]->FldDataType == EW_DATATYPE_MEMO) ? "<MEMO>" : $rs[$fldname]; // Memo Field
  506. ew_WriteAuditTrail($filePfx, $curDate, $curTime, $id, $user, $action, $table, $fldname, $key, $oldvalue, $newvalue);
  507. }
  508. }
  509. }
  510. ?>
  511. <?php
  512. // Send email after add success
  513. function SendEmailOnAdd(&$rs) {
  514. $sFn = "txt/notify.txt";
  515. $sTable = 'osj-users';
  516. $sSubject = $sTable . " record inserted";
  517. $sAction = "Inserted";
  518. // Get key value
  519. $sKey = "";
  520. if ($sKey <> "") $sKey .= EW_COMPOSITE_KEY_SEPARATOR;
  521. $sKey .= $rs['user_id'];
  522. ew_SendNotifyEmail($sFn, $sSubject, $sTable, $sKey, $sAction);
  523. }
  524. ?>
  525. <?php
  526. // Page Load event
  527. function Page_Load() {
  528. //echo "Page Load";
  529. }
  530. // Page Unload event
  531. function Page_Unload() {
  532. //echo "Page Unload";
  533. }
  534. ?>