PageRenderTime 51ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/admin/includes/db_restore.php

https://bitbucket.org/mpercy/deeemm-cms
PHP | 40 lines | 20 code | 12 blank | 8 comment | 6 complexity | 3822c3a5e51a7cdffd810c5860bf03b4 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause
  1. <?php
  2. defined( '_INDM' ) or die( 'POSSIBLE HACK ATTEMPT!' );
  3. /*===========================================================================
  4. Check user priviledges
  5. ===========================================================================*/
  6. require VALIDATE;
  7. if ($user != 'ADMIN') header("Location: " . $default_url . "index.php");
  8. $db_filename = $_REQUEST['db_filename'];
  9. if ($db_filename == 'select_file') {
  10. //selection not changed upload file if selected
  11. $db_filename = $_REQUEST['local_db_filename'];
  12. $new_filename = upload_file($abs_path . $db_backup_dir . $db_filename, 'local_db');
  13. $db_file = read_file($abs_path . $db_backup_dir . $new_filename);
  14. } else {
  15. $db_file = read_file($abs_path . $db_backup_dir . $db_filename);
  16. }
  17. //split file line by line
  18. $db_file_array = preg_split('/\n/', $db_file);
  19. //breakpoint($db_file_array);
  20. //check each line
  21. foreach($db_file_array as $value)
  22. {
  23. //if it's not a comment or blank line execute sql statement
  24. if (preg_match("/^[^#\s ]/", $value)) {
  25. mysql_query("$value") or die('effin thing');
  26. }
  27. }
  28. ?>