1<?php
2/**
3 * @package tikiwiki
4 */
5// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
6//
7// All Rights Reserved. See copyright.txt for details and a complete list of authors.
8// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
9// $Id$
10
11require_once('tiki-setup.php');
12
13$access->check_permission('tiki_p_admin');
14
15if (! empty($_REQUEST['submit'])) {
16  try {
17    $controller = new Services_RemoteController($_REQUEST['url'], 'export');
18    $response = $controller->sync_content(['user' => $_REQUEST['user'], 'password' => $_REQUEST['password']]);
19    if (! empty($response['error'])) {
20      throw new Exception($response['error']);
21    }
22    $remote_content = $response['data'];
23
24    $export_controller = new Services_Export_Controller();
25    $local_content = $export_controller->dumpContent();
26
27    require_once('lib/diff/difflib.php');
28    $diff = diff2($local_content, $remote_content, 'sidediff-full');
29    if (empty($diff)) {
30      $diff = '<tr><td colspan="4">The diff is empty.</td></tr>';
31    }
32    $smarty->assign('diff', $diff);
33
34  } catch (Exception $e) {
35    Feedback::error($e->getMessage(), '');
36  }
37}
38
39// Display the template
40$smarty->assign('mid', 'tiki-admin_sync.tpl');
41$smarty->display("tiki.tpl");
42