updatedb.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. $data = false;
  3. ini_set("display_errors", 1);
  4. ini_set("error_reporting", E_ALL | E_STRICT);
  5. require_once("user.php");
  6. $USER = new User("registration_callback");
  7. function checkDatabase($type, $table, $check) {
  8. if ($type == "PRAGMA") :
  9. $query = 'PRAGMA table_info(' . $table . ')';
  10. elseif ($type == "SELECT") :
  11. $query = 'SELECT name FROM sqlite_master WHERE type="table" AND name="' . $table . '"';
  12. endif;
  13. $dbfile = DATABASE_LOCATION.'users.db';
  14. $file_db = new PDO("sqlite:" . $dbfile);
  15. $file_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  16. $runQuery = $file_db->query($query);
  17. $buildArray = array();
  18. foreach($runQuery as $row) :
  19. array_push($buildArray, $row['name']);
  20. endforeach;
  21. $file_db = null;
  22. if (in_array($check, $buildArray)) :
  23. $found = '<div class="panel panel-success"><div class="panel-heading"><h3 class="panel-title">'. $check . '</h3></div><div style="color: gray" class="panel-body">' . $check . ' was found in ' . $table . ' and is Good 2 Go!</div></div>';
  24. elseif (!in_array($check, $buildArray)) :
  25. $found = '<div class="panel panel-danger"><div class="panel-heading"><h3 class="panel-title">'. $check . '</h3></div><div style="color: gray" class="panel-body">' . $check . ' was not found in ' . $table . ' and is being added now!</div></div>';
  26. if ($type == "PRAGMA") :
  27. $file_db = new PDO("sqlite:" . $dbfile);
  28. $file_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  29. $count = $file_db->exec("ALTER TABLE `$table` ADD COLUMN `$check` TEXT");
  30. $file_db = null;
  31. endif;
  32. endif;
  33. echo $found;
  34. }
  35. ?>
  36. <html lang="en" class="no-js">
  37. <head>
  38. <meta charset="UTF-8">
  39. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  40. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  41. <meta name="msapplication-tap-highlight" content="no" />
  42. <title>Organizr Upgrade</title>
  43. <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
  44. <link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css">
  45. <link rel="stylesheet" href="bower_components/mdi/css/materialdesignicons.min.css">
  46. <link rel="stylesheet" href="bower_components/metisMenu/dist/metisMenu.min.css">
  47. <link rel="stylesheet" href="bower_components/Waves/dist/waves.min.css">
  48. <link rel="stylesheet" href="bower_components/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.css">
  49. <link rel="stylesheet" href="js/selects/cs-select.css">
  50. <link rel="stylesheet" href="js/selects/cs-skin-elastic.css">
  51. <link rel="stylesheet" href="css/style.css">
  52. </head>
  53. <body class="gray-bg" style="padding: 0;">
  54. <div id="main-wrapper" class="main-wrapper">
  55. <!--Content-->
  56. <div id="content" style="margin:0 20px; overflow:hidden">
  57. <h1><center>Database Upgrade</center></h1>
  58. <h5 id="countdown"></h5>
  59. <?php
  60. //checkDatabase('SELECT', 'options', 'options');
  61. //checkDatabase('SELECT', 'tabs', 'tabs');
  62. //checkDatabase('PRAGMA', 'options', 'loading');
  63. //checkDatabase('PRAGMA', 'options', 'hovertext');
  64. ?>
  65. </div>
  66. </div>
  67. <script>
  68. (function countdown(remaining) {
  69. if(remaining === 0)
  70. window.top.location = window.top.location.href.split('#')[0];
  71. document.getElementById('countdown').innerHTML = "<center>Page will refresh in <strong>" + remaining + "</strong> seconds [You may close this at anytime]</center>";
  72. setTimeout(function(){ countdown(remaining - 1); }, 1000);
  73. })(10);
  74. </script>
  75. </body>
  76. </html>