<?php
require_once "../config/config.php";
require_once "../includes/dbbackup_class.php";
require_once INCLUDE_DIR."/users_class.php";
$users = new users_class();
if($users->IsAdminhavePermission($_SESSION[SESSION_PREFIX.'Admin_UserID'],'Can restore backup')==true)
{
$lsrestorebackup=true;
}
else
{
$lsrestorebackup=false;
}
if($users->IsAdminhavePermission($_SESSION[SESSION_PREFIX.'Admin_UserID'],'Can download backup')==true)
{
$lsdownloadbackup=true;
}
else
{
$lsdownloadbackup=false;
}
$loDbRestore = new dbbackup_class();
/*
$lTypes=null;
$query = "SELECT * FROM ".TABLE_PREFIX."backup ORDER BY createdon";
$result = $loDbRestore->View($query);
$smarty->assign('data',$result);
$smarty->display('admin_db_restore.tpl');*/
echo($smarty->fetch('admin_header.php'));
?>
<!-- DHTML Goodies for database comments content -->
<style type="text/css">
/* YOU CAN REMOVE THIS PART */
h1{
line-height:130%;
}
a{
color: #D60808;
text-decoration:none;
font-weight:bold;
}
a:hover{
border-bottom:1px dotted #317082;
color: #307082;
}
/* END PART YOU CAN REMOVE */
#dhtmlgoodies_tooltip{
background-color:#EEE;
border:1px solid #000;
position:absolute;
display:none;
z-index:20000;
padding:2px;
font-size:1.2em;
-moz-border-radius:6px; /* Rounded edges in Firefox */
font-family: "Trebuchet MS", "Lucida Sans Unicode", Arial, sans-serif;
}
#dhtmlgoodies_tooltipShadow{
position:absolute;
background-color:#555;
display:none;
z-index:10000;
opacity:0.7;
filter:alpha(opacity=70);
-khtml-opacity: 0.7;
-moz-opacity: 0.7;
-moz-border-radius:6px; /* Rounded edges in Firefox */
}
</style>
<SCRIPT type="text/javascript">
var dhtmlgoodies_tooltip = false;
var dhtmlgoodies_tooltipShadow = false;
var dhtmlgoodies_shadowSize = 4;
var dhtmlgoodies_tooltipMaxWidth = 300;
var dhtmlgoodies_tooltipMinWidth = 100;
var dhtmlgoodies_iframe = false;
var tooltip_is_msie = (navigator.userAgent.indexOf('MSIE')>=0 && navigator.userAgent.indexOf('opera')==-1 && document.all)?true:false;
function showTooltip(e,tooltipTxt)
{
var bodyWidth = Math.max(document.body.clientWidth,document.documentElement.clientWidth) - 20;
if(!dhtmlgoodies_tooltip){
dhtmlgoodies_tooltip = document.createElement('DIV');
dhtmlgoodies_tooltip.id = 'dhtmlgoodies_tooltip';
dhtmlgoodies_tooltipShadow = document.createElement('DIV');
dhtmlgoodies_tooltipShadow.id = 'dhtmlgoodies_tooltipShadow';
document.body.appendChild(dhtmlgoodies_tooltip);
document.body.appendChild(dhtmlgoodies_tooltipShadow);
if(tooltip_is_msie){
dhtmlgoodies_iframe = document.createElement('IFRAME');
dhtmlgoodies_iframe.frameborder='5';
dhtmlgoodies_iframe.style.backgroundColor='#FFFFFF';
dhtmlgoodies_iframe.src = '#';
dhtmlgoodies_iframe.style.zIndex = 100;
dhtmlgoodies_iframe.style.position = 'absolute';
document.body.appendChild(dhtmlgoodies_iframe);
}
}
dhtmlgoodies_tooltip.style.display='block';
dhtmlgoodies_tooltipShadow.style.display='block';
if(tooltip_is_msie)dhtmlgoodies_iframe.style.display='block';
var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0;
var leftPos = e.clientX + 10;
dhtmlgoodies_tooltip.style.width = null; // Reset style width if it's set
dhtmlgoodies_tooltip.innerHTML = tooltipTxt;
dhtmlgoodies_tooltip.style.left = leftPos + 'px';
dhtmlgoodies_tooltip.style.top = e.clientY + 10 + st + 'px';
dhtmlgoodies_tooltipShadow.style.left = leftPos + dhtmlgoodies_shadowSize + 'px';
dhtmlgoodies_tooltipShadow.style.top = e.clientY + 10 + st + dhtmlgoodies_shadowSize + 'px';
if(dhtmlgoodies_tooltip.offsetWidth>dhtmlgoodies_tooltipMaxWidth){ /* Exceeding max width of tooltip ? */
dhtmlgoodies_tooltip.style.width = dhtmlgoodies_tooltipMaxWidth + 'px';
}
var tooltipWidth = dhtmlgoodies_tooltip.offsetWidth;
if(tooltipWidth<dhtmlgoodies_tooltipMinWidth)tooltipWidth = dhtmlgoodies_tooltipMinWidth;
dhtmlgoodies_tooltip.style.width = tooltipWidth + 'px';
dhtmlgoodies_tooltipShadow.style.width = dhtmlgoodies_tooltip.offsetWidth + 'px';
dhtmlgoodies_tooltipShadow.style.height = dhtmlgoodies_tooltip.offsetHeight + 'px';
if((leftPos + tooltipWidth)>bodyWidth){
dhtmlgoodies_tooltip.style.left = (dhtmlgoodies_tooltipShadow.style.left.replace('px','') - ((leftPos + tooltipWidth)-bodyWidth)) + 'px';
dhtmlgoodies_tooltipShadow.style.left = (dhtmlgoodies_tooltipShadow.style.left.replace('px','') - ((leftPos + tooltipWidth)-bodyWidth) + dhtmlgoodies_shadowSize) + 'px';
}
if(tooltip_is_msie){
dhtmlgoodies_iframe.style.left = dhtmlgoodies_tooltip.style.left;
dhtmlgoodies_iframe.style.top = dhtmlgoodies_tooltip.style.top;
dhtmlgoodies_iframe.style.width = dhtmlgoodies_tooltip.offsetWidth + 'px';
dhtmlgoodies_iframe.style.height = dhtmlgoodies_tooltip.offsetHeight + 'px';
}
}
function hideTooltip()
{
dhtmlgoodies_tooltip.style.display='none';
dhtmlgoodies_tooltipShadow.style.display='none';
if(tooltip_is_msie)dhtmlgoodies_iframe.style.display='none';
}
</SCRIPT>
<?php
echo "<div id=\"content\" class=\"setdiv\"> ";
echo "<div id=\"full-contentdiv\">";
echo "<center>
<table id='tblcustomloader' name='tblcustomloader' class='borderless' cellpadding='0' cellspacing='5' border='0' style='display:none;' >
<tr>
<td>
<img src='".ADMIN_IMAGE_DIR."/DBRestoreloader.gif' alt='' title='' >
</td>
<td valign='middle' >
<label>Please wait while database is being restored..........</label>
</td>
</tr>
</table>
</center>";
echo "<div class=\"righttop\">";
echo "<h2 align=\"center\">";
echo "Restore Database";
echo "</h2>";
echo "</div>";
echo "<div class=\"whole-page clear\">";
//echo $res;
$sql = "SELECT *,
case when lastrestoredon > 0 then concat('<span style=\"display:none;\">',from_unixtime(lastrestoredon),'</span>',date_format(from_unixtime(lastrestoredon),\"%d %b, %Y\")) else '-' end as `lastrestored`,
(case when LENGTH(note) >= 25 then CONCAT(SUBSTR(note,1,25),'... <a onmouseout=\"hideTooltip()\" href=\'#\' onmouseover=\"showTooltip(event,\'',note,'\');return false\">More</a>') else note end) as db_note,
concat('<span style=\"display:none;\">',from_unixtime(createdon),'</span>',date_format(from_unixtime(createdon),\"%d %b %Y\") ) as `createon`,
concat('<a href=\"db_restore.php?file=',filename,'&id=',id,'\" onclick=\"if(confirm(\'This action will replace all your exising data with this backup and cannot be undo. Do you really want to proceed?\')){document.getElementById(\'tblcustomloader\').style.display=\'\'; return true;}{return false;}\">
<img src=\"images/database.gif\" width=\"16\" height=\"16\" title=\"Restore Database\" alt=\"Restore\"></a>') as `Restore`,
concat('<img src=\"images/a_download.gif\" title=\"Download\" alt=\"Download\">') as `Download`
FROM ".TABLE_PREFIX."backup
ORDER BY createdon";
/*$sql = "SELECT *,
case when lastrestoredon > 0 then date_format(from_unixtime(lastrestoredon),\"%d %b, %Y\") else '-' end as `lastrestored`,
date_format(from_unixtime(createdon),\"%d %b, %Y\") as `createon`,'$lsrestorebackup' as `note`,
case when `note`=true then concat('<a href=\"db_restore1.php?file=',filename,'\" onclick=\"return(confirm(\'This action will replace all your exising data with this backup and cannot be undo. Do you really want to proceed?\'));\">
<img src=\"images/database.gif\" width=\"16\" height=\"16\" title=\"Restore Database\" alt=\"Restore\"></a>') else 'fgffgg' end as `Restore`,
concat('<img src=\"images/a_download.gif\" title=\"Download\" alt=\"Download\">') as `Download`
FROM ".TABLE_PREFIX."backup
ORDER BY createdon"; */
/* $sql = ""; */
# execute the sql query
$db->execute($sql);
$totalrowcount=$db->rowCount();
if($totalrowcount > 0)
{
echo "<div class=\"errormsg\" style=\"margin-bottom:5px;width:810px !important\">";
echo " <span>";
echo " WARNING! ALL YOUR CURRENT MEMBER SITES TABLES AND RECORDS WILL BE REPLACED WITH THE CONTENTS OF THE BACKUP! ";
echo " </span>";
echo "</div>";
}
# creates a new phpSortColumn object for ID´s
//$col_0 = new phpSortColumn("id", "ID");
#creates a new phpSortcolunm objects for name
$col_0 = new phpSortColumn("filename", "File Name");
$col_5 = new phpSortColumn("db_note", "Comments");
# creates a new phpSortColumn object for Tile
$col_1 = new phpSortColumn("lastrestored", "Last Restored On");
# creates a new phpSortColumn object for Field Type
$col_2 = new phpSortColumn("createon", "Created On");
if($lsrestorebackup==true && $lsdownloadbackup==true)
{
$col_3 = new phpSortColumn("Restore", "");
$col_4 = new phpSortColumn("Download", "","",'link','admin_db_download.php?','','','_self');
# add the columns to an array
$columns = array(0=>$col_0, 1=>$col_5, 2=>$col_1,3=>$col_2,4=>$col_3,5=>$col_4);
}
else if($lsrestorebackup==true && $lsdownloadbackup==false)
{
$col_3 = new phpSortColumn("Restore", "");
$columns = array(0=>$col_0, 1=>$col_5, 2=>$col_1,3=>$col_2,5=>$col_3);
}
else if($lsrestorebackup==false && $lsdownloadbackup==true)
{
$col_3 = new phpSortColumn("Download", "","",'link','admin_db_download.php?','','','_self');
$columns = array(0=>$col_0, 1=>$col_5, 2=>$col_1,3=>$col_2,5=>$col_3);
}
else
{
$columns = array(0=>$col_0, 1=>$col_5, 2=>$col_1,5=>$col_2);
}
# creates a new phpSortColumn object for Desplay Type
// $col_3 = new phpSortColumn("", "Action");
# create a new phpSortable object with the abstracted db object
# and the array of column object
$sortable = new phpSortable($db, $columns);
# define the table format: cellpadding, cellspacing, border
$sortable->setTableFormat ("2", "2", "0");
# define the table title
$sortable->tableTitle = "";
# define the link for edit of entries
//$sortable->editLink = "db_restore.php";
# open the edit page in a new window
//$sortable->editTarget = "_blank";
# window format for the edit page
// $sortable->editWindowFormat = "'width=300,height=400'";
# define the link for delete of entries
//$sortable->deleteLink = "download_dbbackup.php";
# define the link for add new entries
//$sortable->addLink = "admin_field_ae.php";
# define the hint to be displyed over the add button
//$sortable->addText = "Add New Field";
# Encrypt Edit and Delete Link
$sortable->encryptlink = true;
# define the key name to be attached to links
$sortable->urlKeyName = "file";
# define the column name of to be attached to links as key value
$sortable->tableKeyName = "filename";
# define the prompt message to be diplayed on clicking the edit button
$sortable->editPromptMsg = "This action will replace all your exising data with this backup and cannot be undo. Do you really want to proceed?";
# define the prompt message to be diplayed on clicking the delete button
//$sortable->deletePromptMsg = "Are you sure you want to delete this Field?";
# define the message to be diplayed if there are no results found
$sortable->emptyMsg = "No Backup found.";
#define the deafult row number to be displayed
$sortable->defaultRowsNum = "10";
#define the path for the css file
$sortable->cssFilePath = ADMIN_CSS_DIR."/phpSortable.css";
#define the path for of the images directory
$sortable->imgFilePath = ADMIN_IMAGE_DIR."/phpgrid/";
# print the table
$sortable->printTable();
echo "</div>";
echo "</div>";
echo "</div>";
//For display footer.php
echo($smarty->fetch('admin_footer.php'));
?>