Advertisement
Guest User

Untitled

a guest
Oct 28th, 2011
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.15 KB | None | 0 0
  1. <?php
  2. require_once('lib/https.php');
  3. require_once('lib/common.php');
  4. Secure();
  5. error_reporting(E_ALL);
  6. ini_set('display_errors', true);
  7.  
  8. ////////////////////////////////////////
  9. // Server Side
  10.  
  11. $rs = new RecordSet();
  12. $rs->Connect();
  13.  
  14. $subuser_id = '';
  15. $subuser_name = '';
  16. $subuser_username = '';
  17. $subuser_notes = '';
  18. $subuser_email = '';
  19. $subuser_reseller_id = '';
  20.  
  21. $form_subuser_info = new Form('subuser information');
  22.  
  23. //$form_subuser_info->AddElement('', 'user_id', 'hidden', (int)$_REQUEST['user_id']);
  24. $form_subuser_info->AddElement('Name', 'subuser_name', 'text', $subuser_name);
  25. $form_subuser_info->AddElement('Email', 'subuser_email', 'text', $subuser_email);
  26. $form_subuser_info->AddElement('Login Extension', 'subuser_loginid', 'text', $subuser_username);
  27. $form_subuser_info->AddElement('Password', 'subuser_password', 'password');
  28. $form_subuser_info->AddElement('Password', 'subuser_password2', 'password');
  29. $form_subuser_info->AddElement('Notes', 'subuser_notes', 'text', $subuser_notes);
  30. $form_subuser_info->AddElement('Update', 'submit', 'submit', null, null);
  31. //$form_subuser_info->AddElement('Update', 'submit', 'okcancel', '', 'window.close();');
  32.  
  33. $form_subuser_info->AddRule('subuser_name', 'required');
  34. $form_subuser_info->AddRule('subuser_email', 'required');
  35. $form_subuser_info->AddRule('subuser_loginid', 'required');
  36.  
  37. $form_subuser_info->SetProcessor('UpdateSettingsForuser');
  38.  
  39. function UpdateSettingsForuser($form, $o)
  40. {
  41. /*$rs2 = new RecordSet();
  42. $rs2->Connect();
  43.  
  44. $rs2->Open("SELECT * FROM subusers WHERE id='" . (int)$_REQUEST['user_id'] . "'");
  45. if(!$rs->IsEOF())
  46. {
  47.  
  48. $rs2->edit('subusers');
  49. $rs2->SetValue('name', $form->GetValue('subuser_name'));
  50. $rs2->SetValue('email', $form->GetValue('subuser_email'));
  51. $rs2->SetValue('username', $form->GetValue('subuser_loginid'));
  52.  
  53. if(strlen($form->GetValue('subuser_password')) <= 0
  54. && $form->GetValue('subuser_password') === $form->GetValue('subuser_password')
  55. && strlen($form->GetValue('subuser_password')) <= 12
  56. && strlen($form->GetValue('subuser_password')) >= 6)
  57. {
  58. //password entered into the form, change password to new password.
  59. $rs2->SetValue('password', sha1($form->GetValue('subuser_loginid')));
  60. }
  61.  
  62. $rs2->SetValue('notes', $form->GetValue('subuser_notes'));
  63. //$rs->SetValue('hide_support', $form->GetValue('hide_support') ? true : false);
  64.  
  65. $rs2->Update();
  66. }
  67.  
  68. $rs2->Close();*/
  69. $o->alert("My Settings has been updated.");
  70. //$o->redirect('subuser_view.php?user_id=' . $form->GetValue('user_id'));
  71. }
  72.  
  73. // Validate that reseller controls this customer
  74. function ValidateSubuser($user_id)
  75. {
  76. $rs4 = new RecordSet();
  77. $rs4->Connect();
  78. $rs4->Open("SELECT * FROM subusers WHERE id = '" . (int)$user_id . "' AND reseller_id = '" . (int)$_SESSION['security']['user_id'] . "'");
  79.  
  80. if($rs4->IsEof())
  81. {
  82. $rs4->Close();
  83. $rs4->Disconnect();
  84. return false;
  85. }
  86.  
  87. $rs4->Close();
  88. $rs4->Disconnect();
  89.  
  90. return true;
  91. }
  92.  
  93. ////////////////////////////////////////
  94. // Client Side
  95.  
  96. $onload .= '';
  97. $onfocus .= '';
  98.  
  99. if(ValidateSubuser((int)$_REQUEST['user_id']))
  100. {
  101.  
  102. $rs->Open("SELECT * FROM subusers WHERE id='" . (int)$_REQUEST['user_id'] . "' AND reseller_id = '" . (int)$_SESSION['security']['user_id'] . "'");
  103.  
  104. if(!$rs->IsEOF())
  105. {
  106.  
  107. //Pull data from database.
  108. $subuser_id = $rs->GetValue('id');
  109. $subuser_name = $rs->GetValue('name');
  110. $subuser_username = $rs->GetValue('username');
  111. $subuser_notes = $rs->GetValue('notes');
  112. $subuser_email = $rs->GetValue('email');
  113. $subuser_reseller_id = $rs->GetValue('reseller_id');
  114.  
  115. //set the form data
  116. $form_subuser_info->SetValue('user_id', (int)$_REQUEST['user_id']);
  117. $form_subuser_info->SetValue('subuser_name', $subuser_name);
  118. $form_subuser_info->SetValue('subuser_email', $subuser_email);
  119. $form_subuser_info->SetValue('subuser_loginid', $subuser_username);
  120. $form_subuser_info->SetValue('subuser_notes', $subuser_notes);
  121.  
  122. }
  123. }
  124.  
  125. require_once('include/header.php');
  126. ?>
  127.  
  128. <?=$form_subuser_info->GetScript()?>
  129. <?php echo($form_subuser_info->GetHTML(null, true)); ?>
  130.  
  131. <?php require_once('include/footer.php');?>
  132.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement