diff --git a/DBV.php b/DBV.php index d2a9e1d..6fdb54a 100644 --- a/DBV.php +++ b/DBV.php @@ -35,7 +35,6 @@ class DBV_Exception extends Exception class DBV { - protected $_action = "index"; protected $_adapter; protected $_log = array(); @@ -133,6 +132,28 @@ public function schemaAction() $this->_json($return); } } + + public function switchDatabaseAction() + { + $databaseID = isset($_GET['newdb']) ? $_GET['newdb'] : false; + if ($databaseID !== false) + { + $lines = @file(DBV_ROOT_PATH . DS . "config_list.php"); + if ($lines) + { + $needlesize = @strlen('$current_id'); + foreach ($lines as &$line) + if (!@strncmp($line, '$current_id', $needlesize)) + { + $line = '$current_id = ' . $databaseID . ";" . PHP_EOL; + break ; + } + @file_put_contents(DBV_ROOT_PATH . DS . "config_list.php", @implode("", $lines)); + header('Location: index.php'); + } + } + $this->indexAction(); + } public function revisionsAction() { @@ -176,6 +197,24 @@ public function revisionsAction() } } + public function addRevisionFolderAction() + { + $revision = $this->_getCurrentRevision(); + while (++$revision) + { + $dir = DBV_REVISIONS_PATH . DS . $revision; + if (!@file_exists($dir)) { + if (!@mkdir($dir)) + $this->_json(array('ok' => false, 'message' => __("Cannot create folder for revision #{revision}!", array('revision' => "$revision")))); + $dir .= '/comments.sql'; + if (!@file_put_contents($dir, ' ')) + $this->_json(array('ok' => false, 'message' => __("Cannot create sql file for revision #{revision}!", array('revision' => "$revision")))); + break ; + } + } + + $this->_json(array('ok' => true, 'rev' => $revision, 'message' => __("Revision #{revision} successfully added!", array('revision' => "$revision")))); + } public function saveRevisionFileAction() { @@ -274,6 +313,8 @@ protected function _getAction() protected function _view($view) { + global $conf_list; + global $current_id; $file = DBV_ROOT_PATH . DS . 'templates' . DS . "$view.php"; if (file_exists($file)) { include($file); diff --git a/config.php.sample b/config/config.php.sample similarity index 95% rename from config.php.sample rename to config/config.php.sample index 7a18293..c596c35 100644 --- a/config.php.sample +++ b/config/config.php.sample @@ -24,7 +24,7 @@ define('DBV_PASSWORD', 'dbv'); define('DB_ADAPTER', 'MySQL'); define('DS', DIRECTORY_SEPARATOR); -define('DBV_ROOT_PATH', dirname(__FILE__)); +define('DBV_ROOT_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR . ".."); /** * Only edit this lines if you want to place your schema files in custom locations diff --git a/config_list.php b/config_list.php new file mode 100644 index 0000000..faf144b --- /dev/null +++ b/config_list.php @@ -0,0 +1,16 @@ +this.$items.length-1||t<0)return;return this.sliding?this.$element.one("slid",function(){r.to(t)}):n==t?this.pause().cycle():this.slide(t>n?"next":"prev",e(this.$items[t]))},pause:function(t){return t||(this.paused=!0),this.$element.find(".next, .prev").length&&e.support.transition.end&&(this.$element.trigger(e.support.transition.end),this.cycle(!0)),clearInterval(this.interval),this.interval=null,this},next:function(){if(this.sliding)return;return this.slide("next")},prev:function(){if(this.sliding)return;return this.slide("prev")},slide:function(t,n){var r=this.$element.find(".item.active"),i=n||r[t](),s=this.interval,o=t=="next"?"left":"right",u=t=="next"?"first":"last",a=this,f;this.sliding=!0,s&&this.pause(),i=i.length?i:this.$element.find(".item")[u](),f=e.Event("slide",{relatedTarget:i[0],direction:o});if(i.hasClass("active"))return;this.$indicators.length&&(this.$indicators.find(".active").removeClass("active"),this.$element.one("slid",function(){var t=e(a.$indicators.children()[a.getActiveIndex()]);t&&t.addClass("active")}));if(e.support.transition&&this.$element.hasClass("slide")){this.$element.trigger(f);if(f.isDefaultPrevented())return;i.addClass(t),i[0].offsetWidth,r.addClass(o),i.addClass(o),this.$element.one(e.support.transition.end,function(){i.removeClass([t,o].join(" ")).addClass("active"),r.removeClass(["active",o].join(" ")),a.sliding=!1,setTimeout(function(){a.$element.trigger("slid")},0)})}else{this.$element.trigger(f);if(f.isDefaultPrevented())return;r.removeClass("active"),i.addClass("active"),this.sliding=!1,this.$element.trigger("slid")}return s&&this.cycle(),this}};var n=e.fn.carousel;e.fn.carousel=function(n){return this.each(function(){var r=e(this),i=r.data("carousel"),s=e.extend({},e.fn.carousel.defaults,typeof n=="object"&&n),o=typeof n=="string"?n:s.slide;i||r.data("carousel",i=new t(this,s)),typeof n=="number"?i.to(n):o?i[o]():s.interval&&i.pause().cycle()})},e.fn.carousel.defaults={interval:5e3,pause:"hover"},e.fn.carousel.Constructor=t,e.fn.carousel.noConflict=function(){return e.fn.carousel=n,this},e(document).on("click.carousel.data-api","[data-slide], [data-slide-to]",function(t){var n=e(this),r,i=e(n.attr("data-target")||(r=n.attr("href"))&&r.replace(/.*(?=#[^\s]+$j)/,"")),s=e.extend({},i.data(),n.data()),o;i.carousel(s),(o=n.attr("data-slide-to"))&&i.data("carousel").pause().to(o).cycle(),t.preventDefault()})}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.$element=e(t),this.options=e.extend({},e.fn.collapse.defaults,n),this.options.parent&&(this.$parent=e(this.options.parent)),this.options.toggle&&this.toggle()};t.prototype={constructor:t,dimension:function(){var e=this.$element.hasClass("width");return e?"width":"height"},show:function(){var t,n,r,i;if(this.transitioning||this.$element.hasClass("in"))return;t=this.dimension(),n=e.camelCase(["scroll",t].join("-")),r=this.$parent&&this.$parent.find("> .accordion-group > .in");if(r&&r.length){i=r.data("collapse");if(i&&i.transitioning)return;r.collapse("hide"),i||r.data("collapse",null)}this.$element[t](0),this.transition("addClass",e.Event("show"),"shown"),e.support.transition&&this.$element[t](this.$element[0][n])},hide:function(){var t;if(this.transitioning||!this.$element.hasClass("in"))return;t=this.dimension(),this.reset(this.$element[t]()),this.transition("removeClass",e.Event("hide"),"hidden"),this.$element[t](0)},reset:function(e){var t=this.dimension();return this.$element.removeClass("collapse")[t](e||"auto")[0].offsetWidth,this.$element[e!==null?"addClass":"removeClass"]("collapse"),this},transition:function(t,n,r){var i=this,s=function(){n.type=="show"&&i.reset(),i.transitioning=0,i.$element.trigger(r)};this.$element.trigger(n);if(n.isDefaultPrevented())return;this.transitioning=1,this.$element[t]("in"),e.support.transition&&this.$element.hasClass("collapse")?this.$element.one(e.support.transition.end,s):s()},toggle:function(){this[this.$element.hasClass("in")?"hide":"show"]()}};var n=e.fn.collapse;e.fn.collapse=function(n){return this.each(function(){var r=e(this),i=r.data("collapse"),s=e.extend({},e.fn.collapse.defaults,r.data(),typeof n=="object"&&n);i||r.data("collapse",i=new t(this,s)),typeof n=="string"&&i[n]()})},e.fn.collapse.defaults={toggle:!0},e.fn.collapse.Constructor=t,e.fn.collapse.noConflict=function(){return e.fn.collapse=n,this},e(document).on("click.collapse.data-api","[data-toggle=collapse]",function(t){var n=e(this),r,i=n.attr("data-target")||t.preventDefault()||(r=n.attr("href"))&&r.replace(/.*(?=#[^\s]+$j)/,""),s=e(i).data("collapse")?"toggle":n.data();n[e(i).hasClass("in")?"addClass":"removeClass"]("collapsed"),e(i).collapse(s)})}(window.jQuery),!function(e){"use strict";function r(){e(".dropdown-backdrop").remove(),e(t).each(function(){i(e(this)).removeClass("open")})}function i(t){var n=t.attr("data-target"),r;n||(n=t.attr("href"),n=n&&/#/.test(n)&&n.replace(/.*(?=#[^\s]*$j)/,"")),r=n&&e(n);if(!r||!r.length)r=t.parent();return r}var t="[data-toggle=dropdown]",n=function(t){var n=e(t).on("click.dropdown.data-api",this.toggle);e("html").on("click.dropdown.data-api",function(){n.parent().removeClass("open")})};n.prototype={constructor:n,toggle:function(t){var n=e(this),s,o;if(n.is(".disabled, :disabled"))return;return s=i(n),o=s.hasClass("open"),r(),o||("ontouchstart"in document.documentElement&&e('