Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

migrations.inc.php 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /* Poweradmin, a friendly web-based admin tool for PowerDNS.
  3. * See <http://www.poweradmin.org> for more details.
  4. *
  5. * Copyright 2007-2009 Rejo Zenger <rejo@zenger.nl>
  6. * Copyright 2010-2014 Poweradmin Development Team
  7. * <http://www.poweradmin.org/credits.html>
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. */
  22. /**
  23. * Migration functions
  24. *
  25. * @package Poweradmin
  26. * @copyright 2007-2010 Rejo Zenger <rejo@zenger.nl>
  27. * @copyright 2010-2014 Poweradmin Development Team
  28. * @license http://opensource.org/licenses/GPL-3.0 GPL
  29. */
  30. /** Check if given migration exists
  31. *
  32. * @param resource $db DB link
  33. * @param string $file_name Migration file name
  34. *
  35. * @return boolean true on success, false on failure
  36. */
  37. function migration_exists($db, $file_name) {
  38. $query = "SELECT COUNT(version) FROM migrations WHERE version = " . $db->quote($file_name, 'text');
  39. $count = $db->queryOne($query);
  40. if ($count == 0) {
  41. return false;
  42. }
  43. return true;
  44. }
  45. /** Save migration status to database
  46. *
  47. * @param resource $db DB link
  48. * @param string $file_name Migration file name
  49. *
  50. * @return boolean true on success, false on failure
  51. */
  52. function migration_save($db, $file_name) {
  53. $query = "INSERT INTO migrations (version, apply_time) VALUES(" . $db->quote($file_name, 'text') . "," . $db->quote(time(), 'text') . ")";
  54. return $db->query($query);
  55. }
  56. /** Get newline symbol depending on environment
  57. *
  58. * @return string newline for run environment
  59. */
  60. function migration_get_environment_newline() {
  61. $new_line = '<br/>';
  62. if (php_sapi_name() == 'cli') {
  63. $new_line = PHP_EOF;
  64. }
  65. return $new_line;
  66. }
  67. /** Display given message
  68. *
  69. * @param string $msg Message that needs to be dispalyed
  70. */
  71. function migration_message($msg) {
  72. $new_line = migration_get_environment_newline();
  73. echo $msg.$new_line;
  74. }