1. <?php
  2. /*
  3. UserSpice 4
  4. An Open Source PHP User Management System
  5. by the UserSpice Team at http://UserSpice.com
  6. This program is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. ?>
  18. <?php require_once 'init.php'; ?>
  19. <?php require_once $abs_us_root.$us_url_root.'users/includes/header.php'; ?>
  20. <?php require_once $abs_us_root.$us_url_root.'users/includes/navigation.php'; ?>
  21. <?php if (!securePage($_SERVER['PHP_SELF'])){die();} ?>
  22. <?php
  23. $lang = array_merge($lang,array(
  24. "ADMIN_VERIFY_NOREF" => "There is no referrer, you cannot verify yourself. Please return to the Dashboard.",
  25. "INCORRECT_ADMINPW" => "Incorrect password. Administrator Verification Failed!"
  26. ));
  27. //PHP Goes Here!
  28. $errors = $successes = [];
  29. $form_valid=TRUE;
  30. $current=date("Y-m-d H:i:s");
  31. $actual_link = Input::get('actual_link');
  32. $page = Input::get('page');
  33. if (empty($actual_link) || empty($page)) {
  34. $actual_link = '';
  35. $page = '';
  36. $errors[] = lang("ADMIN_VERIFY_NOREF");
  37. }
  38. //Verify Admin Redirect
  39. $findUserQ = $db->query("SELECT last_confirm FROM users WHERE id = ?",array($user->data()->id));
  40. $findUser = $findUserQ->first();
  41. //get the current time
  42. $current=date("Y-m-d H:i:s");
  43. //convert the string time to a time format php can use
  44. $ctFormatted = date("Y-m-d H:i:s", strtotime($current));
  45. //convert the db time to a time format php can use
  46. $dbTime = strtotime($findUser->last_confirm);
  47. //take the db time and add 2 hours to it.
  48. $dbPlus = date("Y-m-d H:i:s", strtotime('+2 hours', $dbTime));
  49. //See what you've got, uncomment this
  50. // echo $ctFormatted;
  51. // echo '<br>';
  52. // echo $dbPlus;
  53. // echo '<br>';
  54. if (strtotime($ctFormatted) < strtotime($dbPlus)){
  55. Redirect::to($actual_link);
  56. }
  57. //Forms posted
  58. if (!empty($_POST)) {
  59. //Manually Add User
  60. if(!empty($_POST['verifyAdmin'])) {
  61. $password=Input::get('password');
  62. if (password_verify($password,$user->data()->password)) {
  63. $fields = array(
  64. 'last_confirm' => $current,
  65. );
  66. $db->update('users',$user->data()->id,$fields);
  67. if(!empty($actual_link)){
  68. Redirect::to($actual_link);
  69. }
  70. } else {
  71. $errors[] = lang("INCORRECT_ADMINPW");
  72. }
  73. }
  74. }
  75. ?>
  76. <div id="page-wrapper">
  77. <div class="container">
  78. <!-- Page Heading -->
  79. <div class="row">
  80. <?=resultBlock($errors,$successes);?>
  81. <? if ($actual_link !='') { ?>
  82. <div class="col-xs-12 col-md-6">
  83. <h1>Password Verification</h1>
  84. </div>
  85. </div>
  86. <div class="row">
  87. <form class="verify-admin" action="adminverify.php?actual_link=<?=$actual_link?>&page=<?=$page?>" method="POST" id="payment-form">
  88. <div class="col-md-5">
  89. <div class="input-group"><input class="form-control" type="password" name="password" id="password" placeholder="Please enter your password..." required autofocus>
  90. <span class="input-group-btn">
  91. <input class='btn btn-primary' type='submit' name='verifyAdmin' value='Verify' />
  92. </span></div>
  93. <input type="hidden" value="<?=Token::generate();?>" name="csrf">
  94. <? } ?>
  95. </div>
  96. </div>
  97. </form><br />
  98. </div>
  99. </div>
  100. </div>
  101. </div>
  102. <!-- End of main content section -->
  103. <?php require_once $abs_us_root.$us_url_root.'users/includes/page_footer.php'; // the final html footer copyright row + the external js calls ?>
  104. <!-- Place any per-page javascript here -->
  105. <?php require_once $abs_us_root.$us_url_root.'users/includes/html_footer.php'; // currently just the closing /body and /html ?>