function bm_env_check() { $env_ok = file_exists(NMBOOKPATH) || bm_create_dir(BMBOOKPATH); if ($env_ok && !file_exists(BMBACKUPPATH)) { $env_ok = bm_create_dir(BMBACKUPPATH); } if ($env_ok && !file_exists(BMDATAPATH)) { if ($env_ok = bm_create_dir(BMDATAPATH)) { bm_update_cache(); } } if (!$env_ok) { //echo '<h3>Books Manager</h3><p>' . i18n_r('news_manager/ERROR_ENV') . '</p>'; echo '<h3>Books Manager</h3><p>' . 'books_manager' . '</p>'; } return $env_ok; }
function bm_restore_book($backup) { if (strpos($backup, ':')) { # revert to the previous version of a book list($current, $backup) = explode(':', $backup); $current .= '.xml'; $backup .= '.xml'; if (file_exists(BMBOOKPATH . $current) && file_exists(BMBACKUPPATH . $backup)) { $status = unlink(BMBOOKPATH . $current) && rename(BMBACKUPPATH . $backup, BMBOOKPATH . $backup) && bm_update_cache(); } } else { # restore the deleted book $backup .= '.xml'; if (file_exists(BMBACKUPPATH . $backup)) { $status = rename(BMBACKUPPATH . $backup, BMBOOKPATH . $backup) && bm_update_cache(); } } if (@$status) { bm_display_message(i18n_r('books_manager/SUCCESS_RESTORE')); } else { bm_display_message(i18n_r('books_manager/ERROR_RESTORE'), true); } }