diff --git a/.htaccess b/.htaccess index 972e6ca..30e94f5 100644 --- a/.htaccess +++ b/.htaccess @@ -76,10 +76,9 @@ DirectoryIndex index.php index.html index.htm # RewriteBase / # Pass all requests not referring directly to files in the filesystem to index.php. -RewriteCond %{REQUEST_FILENAME} !-f -RewriteCond %{REQUEST_FILENAME} !-d -RewriteCond $1 !^(index\.php) -RewriteRule ^(.*)$ index.php/$1 [L] + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule ^ index.php [L] diff --git a/config/config.ini.example b/config/config.ini.example index 5312b43..41edb78 100644 --- a/config/config.ini.example +++ b/config/config.ini.example @@ -13,7 +13,9 @@ social.facebook = "https://www.facebook.com" social.google = "https://plus.google.com" social.tumblr = "http://www.tumblr.com" -; Custom menu link +; Custom menu link. +; See example below: +; "Google->http://www.google.com|Wikipedia->http://www.wikipedia.org". blog.menu = "" ; Breadcrumb home text. Useful when installed on subfolder. diff --git a/system/admin/admin.php b/system/admin/admin.php index ce00efd..112a994 100644 --- a/system/admin/admin.php +++ b/system/admin/admin.php @@ -1,5 +1,6 @@ '; } } +} + +// Get all available zip files +function get_backup_files () { + if (isset($_SESSION['user'])) { + $files = get_zip_files(); + if(!empty($files)) { + krsort($files); + echo ''; + echo ''; + $i = 0; $len = count($files); + foreach($files as $file) { + + if ($i == 0) { + $class = 'item first'; + } + elseif ($i == $len - 1) { + $class = 'item last'; + } + else { + $class = 'item'; + } + $i++; + + // Extract the date + $arr = explode('_', $file); + + // Replaced string + $replaced = substr($arr[0], 0,strrpos($arr[0], '/')) . '/'; + + $name = str_replace($replaced,'',$file); + + $date = str_replace('.zip','',$arr[1]); + $t = str_replace('-', '', $date); + $time = new DateTime($t); + $timestamp= $time->format("D, d F Y, H:i:s"); + + $url = site_url() . $file; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo '
FilenameDateOperations
' . $name . '' . $timestamp . 'Download
'; + } + else { + echo 'No available backup!'; + } + } } \ No newline at end of file diff --git a/system/admin/views/backup-start.html.php b/system/admin/views/backup-start.html.php new file mode 100644 index 0000000..84454fd --- /dev/null +++ b/system/admin/views/backup-start.html.php @@ -0,0 +1,17 @@ + \ No newline at end of file diff --git a/system/admin/views/backup.html.php b/system/admin/views/backup.html.php new file mode 100644 index 0000000..eb30b4a --- /dev/null +++ b/system/admin/views/backup.html.php @@ -0,0 +1,15 @@ + +Create backup +

Your backups

+ \ No newline at end of file diff --git a/system/htmly.php b/system/htmly.php index a37f48a..67373e5 100644 --- a/system/htmly.php +++ b/system/htmly.php @@ -862,6 +862,41 @@ post('/admin/import', function() { }); +// Backup page +get('/admin/backup',function(){ + if(login()) { + config('views.root', 'system/admin/views'); + render('backup', array( + 'head_contents' => head_contents('Backup content - ' . blog_title(), blog_description(), site_url()), + 'bodyclass' => 'backup', + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Backup' + )); + } + else { + $login = site_url() . 'login'; + header("location: $login"); + } + die; +}); + +// Create Zip file +get('/admin/backup-start',function(){ + if(login()) { + config('views.root', 'system/admin/views'); + render('backup-start', array( + 'head_contents' => head_contents('Backup content started - ' . blog_title(), blog_description(), site_url()), + 'bodyclass' => 'startbackup', + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Backup started' + )); + } + else { + $login = site_url() . 'login'; + header("location: $login"); + } + die; +}); + + // The tag page get('/tag/:tag',function($tag){ diff --git a/system/includes/functions.php b/system/includes/functions.php index 28bd13f..a0e4b5d 100644 --- a/system/includes/functions.php +++ b/system/includes/functions.php @@ -81,6 +81,22 @@ function get_author_names(){ return $_cache; } +// Get backup file. +function get_zip_files(){ + + static $_cache = array(); + + if(empty($_cache)){ + + // Get the names of all the + // zip files. + + $_cache = glob('backup/*.zip'); + } + + return $_cache; +} + // usort function. Sort by filename. function sortfile($a, $b) { return $a['filename'] == $b['filename'] ? 0 : ( $a['filename'] < $b['filename'] ) ? 1 : -1; @@ -967,8 +983,60 @@ EOF; // Menu function menu(){ $menu = config('blog.menu'); + $req = $_SERVER['REQUEST_URI']; + if (!empty($menu)) { - return $menu; + + $links = explode('|', $menu); + + echo ''; } else { get_menu(); @@ -1035,6 +1103,17 @@ function get_menu() { echo ''; } + else { + + echo '';