PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/core/ajax/core.php

https://bitbucket.org/speedealing/speedealing
PHP | 59 lines | 34 code | 5 blank | 20 comment | 21 complexity | 64914e3354f5d24e4181602a13f5e8d3 MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, GPL-3.0, MIT
  1. <?php
  2. /* Copyright (C) 2013 Regis Houssin <regis.houssin@capnetworks.com>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. /**
  18. * \file core/ajax/core.php
  19. * \brief File to return core Ajax response
  20. */
  21. if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal
  22. if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
  23. //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
  24. if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
  25. include '../../main.inc.php';
  26. $action = GETPOST('action', 'alpha');
  27. $string = GETPOST('string', 'alpha');
  28. $class = GETPOST('element', 'alpha');
  29. if (!empty($action) && !empty($string)) {
  30. if ($action == 'getTrans') {
  31. echo $langs->trans($string);
  32. } else if ($action == 'getImage') {
  33. $imgMethod = 'img_'.$string;
  34. if (function_exists($imgMethod))
  35. echo call_user_func($imgMethod);
  36. } else if ($action == 'getNameUrl' && !empty($class)) {
  37. $withpicto = (GETPOST('option', 'int') ? GETPOST('option', 'int') : 0);
  38. $result = dol_include_once("/" . $class . "/class/" . strtolower($class) . ".class.php", $class);
  39. if (empty($result)) {
  40. dol_include_once("/" . strtolower($class) . "/class/" . strtolower($class) . ".class.php", $class); // Old version
  41. }
  42. $object = new $class();
  43. $res = $object->fetch($string);
  44. echo $object->getNomUrl($withpicto);
  45. } else if ($action == 'getTrash') {
  46. dol_include_once('/trash/class/trash.class.php', 'trash');
  47. $object = new Trash();
  48. if ($string == 'count') {
  49. $result = $object->getView($string);
  50. echo (!empty($result->rows) ? $result->rows[0]->value : false);
  51. }
  52. }
  53. }
  54. ?>