The contact importer and exporter plugin for the Kopano WebApp. See here for more details: https://community.zarafa.com/pg/plugins/project/20393/developer/h44z/webapp-contact-importer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.8KB

  1. <?php
  2. /**
  3. * helper.php, Kopano Webapp contact to vcf im/exporter
  4. *
  5. * Author: Christoph Haas <christoph.h@sprinternet.at>
  6. * Copyright (C) 2012-2018 Christoph Haas
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with this library; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. */
  23. namespace contactimporter;
  24. class Helper
  25. {
  26. /**
  27. * Generates a random string with variable length.
  28. *
  29. * @param $length the lenght of the generated string, defaults to 6
  30. * @return string a random string
  31. */
  32. public static function randomstring($length = 6)
  33. {
  34. // $chars - all allowed charakters
  35. $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
  36. srand((double)microtime() * 1000000);
  37. $i = 0;
  38. $pass = "";
  39. while ($i < $length) {
  40. $num = rand() % strlen($chars);
  41. $tmp = substr($chars, $num, 1);
  42. $pass = $pass . $tmp;
  43. $i++;
  44. }
  45. return $pass;
  46. }
  47. /**
  48. * respond/echo JSON
  49. *
  50. * @param $arr
  51. * @return string JSON encoded string
  52. */
  53. public static function respondJSON($arr)
  54. {
  55. echo json_encode($arr);
  56. }
  57. }