thunderbird-plugins.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. /* updates.php - this file is part of SOGo
  3. *
  4. * Copyright (C) 2006-2014 Inverse inc.
  5. *
  6. * This file is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2, or (at your option)
  9. * any later version.
  10. *
  11. * This file is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; see the file COPYING. If not, write to
  18. * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19. * Boston, MA 02111-1307, USA.
  20. */
  21. /* This script handles the automatic propagation of extensions pertaining to a
  22. SOGo site. It requires PHP 4.1.0 or later. */
  23. $plugin_dir = 'thunderbird-plugins';
  24. chdir($plugin_dir);
  25. $plugins = array();
  26. if (file_exists('version.csv'))
  27. {
  28. $fh = fopen('version.csv', 'r');
  29. if ($fh)
  30. {
  31. while (($row = fgetcsv($fh, 1000, ';')) !== FALSE)
  32. {
  33. $plugins[$row[0]] = array(
  34. 'application' => 'thunderbird',
  35. 'version' => $row[1],
  36. 'filename' => str_replace('__DOMAIN__', $_GET["domain"], $row[2]),
  37. );
  38. }
  39. fclose($fh);
  40. }
  41. }
  42. $applications
  43. = array( "thunderbird" => "<em:id>{3550f703-e582-4d05-9a08-453d09bdfdc6}</em:id>
  44. <em:minVersion>31.0</em:minVersion>
  45. <em:maxVersion>31.*</em:maxVersion>" );
  46. $pluginname = $_GET["plugin"];
  47. $plugin =& $plugins[$pluginname];
  48. $application =& $applications[$plugin["application"]];
  49. if ( $plugin ) {
  50. $platform = $_GET["platform"];
  51. if ( $platform
  52. && file_exists( $platform . "/" . $plugin["filename"] ) ) {
  53. $plugin["filename"] = $platform . "/" . $plugin["filename"];
  54. }
  55. elseif ( !file_exists( $plugin["filename"] ) ) {
  56. $plugin = false;
  57. }
  58. }
  59. if ( $plugin ) {
  60. header("Content-type: text/xml; charset=utf-8");
  61. echo ('<?xml version="1.0"?>' . "\n");
  62. ?>
  63. <!DOCTYPE RDF>
  64. <RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  65. xmlns:em="http://www.mozilla.org/2004/em-rdf#">
  66. <Description about="urn:mozilla:extension:<?php echo $pluginname ?>">
  67. <em:updates>
  68. <Seq>
  69. <li>
  70. <Description>
  71. <em:version><?php echo $plugin["version"] ?></em:version>
  72. <em:targetApplication>
  73. <Description>
  74. <?php echo $applications[$plugin["application"]] ?>
  75. <em:updateLink><?php echo 'https://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/' . $plugin_dir . '/' . $plugin["filename"] ?></em:updateLink>
  76. </Description>
  77. </em:targetApplication>
  78. </Description>
  79. </li>
  80. </Seq>
  81. </em:updates>
  82. </Description>
  83. </RDF>
  84. <?php
  85. } else {
  86. header("Content-type: text/plain; charset=utf-8", true, 404);
  87. echo( 'Plugin not found' );
  88. }
  89. ?>