PageRenderTime 37ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/plugins/modules/annonces/class/class_action.php

http://malleo-cms.googlecode.com/
PHP | 116 lines | 62 code | 19 blank | 35 comment | 9 complexity | 1fbb5b14529f6b03d5d815227df374e6 MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1
  1. <?php
  2. /*
  3. |------------------------------------------------------------------------------------------------------------
  4. | Software: Malleo ( CMS ) - Module Citations
  5. | Contact: alain91 - http://www.malleo-cms.com
  6. | Support: http://www.malleo-cms.com?module=forum
  7. |------------------------------------------------------------------------------------------------------------
  8. | Author: Alain GANDON
  9. | Copyright (c) 2011, Alain GANDON All Rights Reserved
  10. |------------------------------------------------------------------------------------------------------------
  11. | License: Distributed under the CECILL V2 License
  12. | This program is distributed in the hope that it will be useful - WITHOUT
  13. | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. | FITNESS FOR A PARTICULAR PURPOSE.
  15. |
  16. | Please read Licence_CeCILL_V2-en.txt
  17. | SVP lisez Licence_CeCILL_V2-fr.txt
  18. |------------------------------------------------------------------------------------------------------------
  19. */
  20. defined('PROTECT') OR die("Tentative de Hacking");
  21. class Action
  22. {
  23. var $type_options;
  24. var $sort_options;
  25. var $mode_options;
  26. var $forgiven_tags;
  27. function __construct()
  28. {
  29. global $lang;
  30. $this->type_options = array(0 => $lang['sa_group_all']);
  31. for ($i = 1; $i <= 9; $i++) {
  32. if (!empty($lang['sa_group_'.$i]))
  33. $this->type_options[$i] = $lang['sa_group_'.$i];
  34. else
  35. break;
  36. }
  37. $this->sort_options = array(
  38. 'title' => $lang['sa_sort_title'],
  39. 'created_date' => $lang['sa_sort_date'],
  40. 'price' => $lang['sa_sort_price']);
  41. $this->mode_options = array(
  42. 'asc' => $lang['sa_mode_asc'],
  43. 'desc' => $lang['sa_mode_desc']);
  44. $this->forgiven_tags = array('code', 'math', 'html');
  45. $this->init();
  46. }
  47. function Action()
  48. {
  49. self::__construct();
  50. }
  51. function init()
  52. {}
  53. function run()
  54. {}
  55. /**
  56. * Renvoie l'attribut selected si valide
  57. *
  58. * @param name
  59. * @param value
  60. * @return attribut selected ou vide
  61. */
  62. function selected($name, $value)
  63. {
  64. return ($name == $value) ? 'selected="selected"' : '';
  65. }
  66. /**
  67. * Creation jeton securite
  68. *
  69. * @return string jeton id
  70. */
  71. function creer_jeton()
  72. {
  73. global $session;
  74. if (!session_id()) @session_start();
  75. $jeton = md5(uniqid(rand(), TRUE));
  76. $_SESSION['jeton'] = $jeton;
  77. $_SESSION['jeton_timestamp'] = $session->time;
  78. return $jeton;
  79. }
  80. /**
  81. * Verifier jeton securite
  82. *
  83. * @return bool
  84. */
  85. function verifier_jeton($var)
  86. {
  87. if (!session_id()) @session_start();
  88. if (!array_key_exists('jeton',$var)
  89. || $var['jeton'] != $_SESSION['jeton']
  90. || time() - $_SESSION['jeton_timestamp'] >= VALIDITE_JETON)
  91. {
  92. return false;
  93. }
  94. return true;
  95. }
  96. }
  97. ?>