function start()
{
    global $_CONFIG, $pathinfo;
    $pdir = str_replace($_CONFIG['script_name'], "", $_SERVER["SCRIPT_FILENAME"]);
    $purl = $_SERVER['HTTP_HOST'] . str_replace("/" . $_CONFIG['script_name'], "", $_SERVER['SCRIPT_NAME']);
    ?>


<script>
$(function() {
	$( "#DBcreated" ).button();
	$( "#phpinfo").button();
	$( "#manual_sql" ).button();
	$( "#transfer_mode-ftp" ).button();
	$( "#transfer_mode-direct" ).button();
	$( "input:submit", ".form" ).button();
});
$(function() {
	$( "#tabs" ).tabs();
	$( "#tabs2" ).tabs();
});
</script>


<!-- section 1-->
<div id="tabs2">
	<ul>
		<li><a href="#tabs2-1">New Path & Url Configuration</a></li>
	</ul>
	<div id="tabs2-1">
		<table class="adminForm">

			<tr><td nowrap>
				1. Install directory: (server path where you want to restore your backup)<br />
				<input type=text size=80 name='output_path' value='<?php 
    echo str_replace("\\", "/", $pdir);
    ?>
'><br >

		    </td></tr>
		    <tr><td>
				<br />2.Install Url: (the url correspondent of your Install directory:)<br />
				<div style="display:inline">
					<div style="float:left">
						<select name='output_url_pref'>
							<option selected value='http'>http://</option>
							<option value='https'>https://</option>
						</select>
					</div>
					<div style="float:left">
						<input type=text size=65 name='output_url' value='<?php 
    echo $purl;
    ?>
'>
					</div>
				</div>

			</td></tr>
			<tr><td>
				<br />3. Choose backup archive to restore:
				<?php 
    echo version_list('ver');
    ?>
		    </td></tr>
		</table>
	</div>
</div>
<!-- end section 1-->

<div id="tabs">
	<ul>
		<li><a href="#tabs-1">New Mysql Configuration</a></li>
		<li><a href="#tabs-2">File Restore Options</a></li>
	</ul>

	<div id="tabs-1">
	<!--start tabs 1 -->
		<table width="100%">
			    <tr><td>
					<!--<h3><a href="#">Mysql configuration: </a></h3>-->
					<input type=checkbox checked name='DBcreated' id="DBcreated"> <label  for="DBcreated">Import mysql database</label>
					<input type='checkbox' value='1' name='manual_sql' checked id="manual_sql"> <label for="manual_sql">Incremental sql import</label>
			    </td></tr>
			    <tr><td>
					<!-- mysql details -->
					<table width='100%'>
				    <tr>
						<td nowrap>Mysql server:</td>
						<td><input type=text size=40 name='mysql_server' value='localhost'></td>
				    <tr>
						<td>Mysql username:</td>
						<td><input type=text size=40 name='mysql_username' value=''></td>
				    </tr>
				    <tr>
						<td>Mysql password:</td>
						<td><input type=text size=40 name='mysql_pass' value=''></td>
				    </tr>
				    <tr>
						<td>Mysql database:</td>
						<td><input type=text size=40 name='mysql_db' value=''></td>
				   </tr>
				   <tr>
						<td>Data encoding:</td>
						<td>
						<select name="charset_of_file">

						    <option value="" selected="selected">Default</option>
						    <option value="big5" title="Big5 Traditional Chinese">big5</option>
						    <option value="binary" title="Binary pseudo charset">binary</option>
						    <option value="cp1250" title="Windows Central European">cp1250</option>
						    <option value="cp932" title="SJIS for Windows Japanese">cp932</option>
						    <option value="euckr" title="EUC-KR Korean">euckr</option>

						    <option value="gb2312" title="GB2312 Simplified Chinese">gb2312</option>
						    <option value="gbk" title="GBK Simplified Chinese">gbk</option>
						    <option value="latin1" title="cp1252 West European">latin1</option>
						    <option value="latin2" title="ISO 8859-2 Central European">latin2</option>
						    <option value="sjis" title="Shift-JIS Japanese">sjis</option>
						    <option value="tis620" title="TIS620 Thai">tis620</option>

						    <option value="ucs2" title="UCS-2 Unicode">ucs2</option>
						    <option value="ujis" title="EUC-JP Japanese">ujis</option>
						    <option value="utf8" title="UTF-8 Unicode" >utf8</option>
						</select>
						</td>
				   </tr>

				    <?php 
    $dir = "administrator/backups/";
    $sql_files = array();
    if (@is_dir($dir)) {
        if ($handle = @opendir($dir)) {
            /* This is the correct way to loop over the directory. */
            while (false !== ($file = @readdir($handle))) {
                if (strstr($file, ".sql")) {
                    $sql_files[] = $file;
                }
            }
            @closedir($handle);
        }
        if (sizeof($sql_files) > 0) {
            $list = "";
            for ($i = 0; $i < sizeof($sql_files); $i++) {
                $list .= "<option value='{$sql_files[$i]}'>{$sql_files[$i]}</option>";
            }
            echo "<tr><td>Import Mysql file:</td>\r\n\t\t\t\t     <td><select name='sql_setfile'><option value='database-sql.sql'>Default</option>{$list}</select></td>    </tr>";
        }
    }
    ?>
					</table>
					</tr></td>
					<!-- end mysql details -->
		</table>
	<!--end tabs 1 -->
    </div>

	<div id="tabs-2">
	<!-- start tabs 2 -->
		<table width="100%">
		  <tr bgcolor='#dddddd'><td>
			<!--<h3><a href="#">Files transfer and configuration:</a></h3>-->
			  <input type=checkbox name='files_skip' value='1' > <font color='red'>Skip files restore</font><br />
			  <input type=checkbox name='preserve_perm' value='1'> Restore files permissions<br />
			  <input type=checkbox name='file_utilities' value='1' > Restore by using the server utilities(tar) <br />
			  <input type='checkbox' value='1' name='manual_ftp' checked> Incremental transfer
		  </td></tr>

		  <tr><td colspan=2>

			<table width='100%'>
				  <tr><td colspan='2'>
					<label for="transfer_mode-ftp">Install files throught ftp:</label>
					<input type=radio name=transfer_mode value=2 id="transfer_mode-ftp">
					<!--<small>this will attempt to transfer all files through ftp, so the owner keep it's permissions, can be used to send files to other hosts also, <font color=red>*recommended</font></small>-->
					<label for="transfer_mode-direct">Install files directly</label>
					<input type=radio name=transfer_mode value=1 checked id="transfer_mode-direct"><br />
					<!--<small>transfering the files directly will cause some permissions problems in some cases, but it's faster than the other option </small>-->
				 </td></tr>
				 <tr>
				   <td  valign="top" nowrap>Ftp server:</td>
				   <td><input type=text size=30 name='ftp_server' value='localhost'> : <input type=text size=3 name='ftp_port' value='21'></td>
				  </tr>
				  <tr>
				   <td valign="top">Ftp username:</td>
				   <td><input type=text size=30 name='ftp_user'></td>
				  </tr>
				  <tr>
				   <td valign="top">Ftp password:</td>
				   <td><input type=text size=30 name='ftp_pass'></td>
				  </tr>
				  <tr>
				   <td valign="top">Ftp upload path:</td>
				   <td><input type=text size=30 name='ftp_path'>
				    <br><small>ftp root path of where the backup will be restored</small>
				   </td>
				  </tr>
			  </table>

		</td></tr>
		</table>
		<!--end tabs 2-->
	</div>
</div>

<br />
<div class="form">
	<input type=hidden name='task' value='step1'>
	<input type=submit name=submit value='Start install' >
	<button onclick="window.open('XCloner.php?task=getinfo', 'getInfo', 'toolbar,width=750,height=400'); return false;" id="phpinfo">phpinfo()</button>
</div>
<small>*after hitting submit please wait for the package to get unarchived and transfered through ftp if it is the case!</small>

<br />
<span class="ui-state-highlight">
	<span style='color:red'>Security Note:</span> After restore <b>delete the XCloner.php</b> script from your server</span>
</span>

<?php 
}
Example #2
0
function start()
{
    global $_CONFIG, $pathinfo;
    $pdir = str_replace($_CONFIG['script_name'], "", $_SERVER["SCRIPT_FILENAME"]);
    $purl = $_SERVER['HTTP_HOST'] . str_replace($_CONFIG['script_name'], "", $_SERVER['SCRIPT_NAME']);
    ?>





  <input type=hidden name='task' value='step1'>

  <table width='100%'>

 

  <tr bgcolor='#dddddd'><td>

  <b>Path configuration: <a href='XCloner.php?task=getinfo' onclick="window.open('XCloner.php?task=getinfo', 'getInfo', 'toolbar,width=550,height=400'); return false;">check PhpInfo</a></b>
  <br />
  <b style='color:red'>Security Note:</b> after restore <b>delete the XCloner.php</b> script from your server
  </td></tr>

  <tr>

    <td>

    Install directory:<br />

    <input type=text size=70 name='output_path' value='<?php 
    echo str_replace("\\", "/", $pdir);
    ?>
'>

    <br ><small>please enter the full server path to the install directory, must have writing permissions</small>

    </td>

  </tr>

  <tr>

    <td>

    Install Url:<br />

    <select name='output_url_pref'>

    <option selected value='http'>http://</option>

    <option value='https'>https://</option>

    </select>

	<input type=text size=60 name='output_url' value='<?php 
    echo $purl;
    ?>
'>

      <br ><small>please enter the url of where Joomla will be accessible from, can be remote also if you use the ftp function below to other host</small>

    </td>

  </tr>



<tr><td>

  <b>Choose clone archive to install:</b>

  </td></tr>

  <tr>

    <td>

    <?php 
    echo version_list('ver');
    ?>

    </td>

  </tr>

    <tr bgcolor='#dddddd'><td>

     <b>Mysql configuration: </b> <br />

	 <input type=checkbox checked name='DBcreated'> <font color='red'>import mysql database</font>

	 <br />

	 <input type='checkbox' value='1' name='manual_sql' > incremental sql import (<small> recommended for large databases</small>)  
	 
	 <br />
	 Character set of the file:
<select name="charset_of_file">

    <option value="" selected="selected">Default</option>
    <option value="big5" title="Big5 Traditional Chinese">big5</option>
    <option value="binary" title="Binary pseudo charset">binary</option>
    <option value="cp1250" title="Windows Central European">cp1250</option>
    <option value="cp932" title="SJIS for Windows Japanese">cp932</option>
    <option value="euckr" title="EUC-KR Korean">euckr</option>

    <option value="gb2312" title="GB2312 Simplified Chinese">gb2312</option>
    <option value="gbk" title="GBK Simplified Chinese">gbk</option>
    <option value="latin1" title="cp1252 West European">latin1</option>
    <option value="latin2" title="ISO 8859-2 Central European">latin2</option>
    <option value="sjis" title="Shift-JIS Japanese">sjis</option>
    <option value="tis620" title="TIS620 Thai">tis620</option>

    <option value="ucs2" title="UCS-2 Unicode">ucs2</option>
    <option value="ujis" title="EUC-JP Japanese">ujis</option>
    <option value="utf8" title="UTF-8 Unicode" >utf8</option>
</select>

    </td></tr>

   <!--<tr  bgcolor='#dddddd'>

    <td> 

     <input type=checkbox name='use_mysqldump' value='1'> import with mysql server utility, path:

     <input type=text size=40 name='mysqldump_path' value='mysql'> (<small>advanced users only</small>)

    </td>

    </tr>

    -->

    <tr><td>

    

    <table width='100%'>

    

    <tr>

     <td width='120'>Mysql server:</td>

    <td><input type=text size=40 name='mysql_server' value='localhost'></td>

    <tr>

     <td>Mysql username:</td>

     <td><input type=text size=40 name='mysql_username' value=''></td>

    </tr>

    <tr>

    <td>Mysql password:</td>

    <td><input type=text size=40 name='mysql_pass' value=''></td>

    </tr>

    <tr>

     <td>Mysql database:</td>

     <td><input type=text size=40 name='mysql_db' value=''></td>

   </tr>  

    

    <?php 
    $dir = "administrator/backups/";
    $sql_files = array();
    if (@is_dir($dir)) {
        if ($handle = @opendir($dir)) {
            /* This is the correct way to loop over the directory. */
            while (false !== ($file = @readdir($handle))) {
                if (strstr($file, ".sql")) {
                    $sql_files[] = $file;
                }
            }
            @closedir($handle);
        }
        if (sizeof($sql_files) > 0) {
            $list = "";
            for ($i = 0; $i < sizeof($sql_files); $i++) {
                $list .= "<option value='{$sql_files[$i]}'>{$sql_files[$i]}</option>";
            }
            echo "<tr>\r\n\r\n     <td>Import Mysql file:</td>\r\n\r\n     <td><select name='sql_setfile'><option value='database-sql.sql'>Default</option>{$list}</select></td>\r\n\r\n    </tr>";
        }
    }
    ?>

    

    </table>

    

    </td>

    </tr>	 

  



  <tr bgcolor='#dddddd'><td>

  <b>Files transfer and configuration:</b><br />

  <input type=checkbox name='files_skip' value='1' > <font color='red'>Skip files restore, will attempt to restore only database</font><br />

  <input type=checkbox name='preserve_perm' value='1'> restore original files permissions<br />

  <input type=checkbox name='file_utilities' value='1' > Restore by using the server utilities unzip/tar

  </td></tr>



  <tr><td colspan=2>

  <table width='100%'>

  <tr>

  <td width='50%' valign='top'>



  <table width='100%'>

  <tr><td colspan='2'>

   Install files throught ftp: <input type='checkbox' value='1' name='manual_ftp' checked> - incremental transfer

  </td></tr>

  <tr>

    <td colspan='2'><input type=radio name=transfer_mode value=2 checked>

    <br />

    <small>this will attempt to transfer all files through ftp, so the owner keep it's permissions, can be used to send files to other hosts also, <font color=red>*recommended</font></small>

    </td>

  </tr>



  <tr>

   <td nowrap>Ftp server:</td>

   <td><input type=text size=30 name='ftp_server' value='localhost'><br />

       port: <input type=text size=5 name='ftp_port' value='21'></td>

  </tr>

  <tr>

   <td>Ftp user:</td>

   <td><input type=text size=30 name='ftp_user'></td>

  </tr>

  <tr>

   <td>Ftp pass:</td>

   <td><input type=text size=30 name='ftp_pass'></td>

  </tr>

  <tr>

   <td>Ftp path:</td>

   <td><input type=text size=30 name='ftp_path'>

    <br><small>ftp root path of where Joomla will be installed</small>

   </td>

  </tr>

  </table>



  </td>

  <td width='50%' valign=top>



  <table width='100%'>

  <tr><td>

  Install files directly:

  </td></tr>

  <tr>

    <td><input type=radio name=transfer_mode value=1>

    <br />

    <small>transfering the files directly will cause some permissions problem in some cases, but it's faster than the other option </small>

    </td>

  </tr>

  </table>



  </td>

  </tr>

  

  

  </table>

  </td></tr>

  <tr><td>

  

  </td></tr>



  <tr><td colspan='2'>

  

  <input type=submit name=submit value='Start install' >

  <br /><small>*after hitting submit please wait for the package to get unarchived and transfered through ftp if it is the case!</small>

  

  <br /><b>NOTE:*** IMPORTANT - if you plan to apply this script to a live site - upgrade or fresh install over existing files please

     make sure you first make a backup of them! </b>

  </td></tr>

  

  </table>

  

<?php 
}