Firefox Sync 1.0

Installation d'un serveur FirefoxSync 1.0

Prérequis

  • un serveur php
  • une base MYSQL par ex: la base weave
Attention cela nécessite pour la configuration une ancienne version de Firefox (version 28 par ex) Pour les versions plus récentes, voir    Firefox_Sync_1.5

Installation de la base MYSQL

  • dans notre exemple la base s'appellera weavedb
  • lancer les commandes suivantes pour créer le schéma de la base


CREATE DATABASE weavedb;
USE weavedb;
CREATE TABLE `collections` (
  `userid` int(11) NOT NULL,
  `collectionid` smallint(6) NOT NULL,
  `name` varchar(32) NOT NULL,
  PRIMARY KEY (`userid`,`collectionid`),
  KEY `nameindex` (`userid`,`name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `users` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(32) DEFAULT NULL,
  `password_hash` varbinary(128) DEFAULT NULL,
  `email` varbinary(64) DEFAULT NULL,
  `status` tinyint(4) DEFAULT '1',
  `alert` text,
  `reset` varbinary(32) DEFAULT NULL,
  `reset_expiration` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=latin1;

CREATE TABLE `wbo` (
  `username` int(11) NOT NULL,
  `collection` smallint(6) NOT NULL DEFAULT '0',
  `id` varbinary(64) NOT NULL DEFAULT '',
  `parentid` varbinary(64) DEFAULT NULL,
  `predecessorid` varbinary(64) DEFAULT NULL,
  `sortindex` int(11) DEFAULT NULL,
  `modified` bigint(20) DEFAULT NULL,
  `payload` longtext,
  `payload_size` int(11) DEFAULT NULL,
  `ttl` int(11) DEFAULT '2100000000',
  PRIMARY KEY (`username`,`collection`,`id`),
  KEY `parentindex` (`username`,`collection`,`parentid`),
  KEY `modified` (`username`,`collection`,`modified`),
  KEY `weightindex` (`username`,`collection`,`sortindex`),
  KEY `predecessorindex` (`username`,`collection`,`predecessorid`),
  KEY `size_index` (`username`,`payload_size`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


 


Installation du serveur d'enregistrement

installer le serveur fourni par

deprecated/reg-server: Summary

dans notre exemple on l'installera sous weave\weaveserver_registration
installer le serveur de synchronisation fourni par

deprecated/sync-server: Summary

dans notre exemple on l'installera sous weave\weaveserver_sync
(optionnel) installer le client de synchronisation fourni par

mikerowehl/firefox-sync-client-php · GitHub

dans notre exemple on l'installera sous weave\firefox_sync_client
 


Mise à jour les alias

  • J'ai installé le serveur d'enregistrement et le serveur de synchronisation dans 2 sous-répertoires de /weave
  • J'ai mis à jour le fichier .htaccess du répertoire weave
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
RewriteBase /weave/
RewriteRule ^weave-registration-static/(.*)$ weaveserver_registration/1.0/static/index.php/$1 [QSA,L]
RewriteRule ^weave-password-reset weaveserver_registration/1.0/forgot_password.php [L]
RewriteRule ^user/1.0/(.*)$ weaveserver_registration/1.0/index.php?path=$1 [PT,QSA,L]
RewriteRule ^misc/1.0/captcha_html weaveserver_registration/1.0/captcha.php [PT,L]
RewriteRule ^1.0/(.*)$ weaveserver_sync/1.1/index.php?path=$1 [PT,L,QSA]
RewriteRule ^1.1/(.*)$ weaveserver_sync/1.1/index.php?path=$1 [PT,L,QSA]
RewriteRule ^syncclient/(.*)$ firefox_sync_client/$1 [PT,L,QSA]


 


Mise à jour du code du serveur

  • Fichier index.php: retourner l'adresse pour le serveur de synchro (la même sur notre site)
case 'node':
....
        /*if ($location === false|| $location == "null")
        {
                if (!$authdb->user_exists())
                {                                              
                        report_problem("No location", 404);
                        exit(NULL);
                }
                exit($location);
        }*/

        $location = WEAVE_MYSQL_NODE_URL;
        exit($location);


 


  • Fichier weave_user/mysql.php : créer un mot de passe en md5sum
function hash_password($password)
{
        //return $this->generateSSHAPassword($password);
        return md5($password);
}


 


  • cela permet de créer rapidement un utilisateur
INSERT INTO users ( id,username,md5,email,status,alert,reset)
VALUES (NULL , '<username>', MD5( <'PWD>' ) , '<email>', '1', NULL , NULL);


 


Utilisation du client

require_once('sync.php');

$garbage = array_shift($argv); // script name, discard
$username = array_shift($argv);
$password = array_shift($argv);
$sync_key = array_shift($argv);
$url_base = array_shift($argv);
$collection = array_shift($argv);

$sync = new Firefox_Sync($username, $password, $sync_key, $url_base);
#affiche la liste de items d'une collection par ex bookmarks
print_r($sync->collection_full($collection));




Liens Externes