source: extensions/GrumPluginClasses/classes/GPCAjax.class.inc.php @ 16012

Last change on this file since 16012 was 16012, checked in by grum, 12 years ago

feature:2634- compatibility with Piwigo 2.4
+add some objects on js framework

  • Property svn:executable set to *
File size: 1.9 KB
Line 
1<?php
2
3/* -----------------------------------------------------------------------------
4  class name     : GPCAjax
5  class version  : 3.1.0
6  plugin version : 3.5.2
7  date           : 2012-06-19
8  ------------------------------------------------------------------------------
9  author: grum at piwigo.org
10  << May the Little SpaceFrog be with you >>
11  ------------------------------------------------------------------------------
12
13  :: HISTORY
14
15| release | date       |
16| 3.0.0   | 2010/03/30 | * Update class & function names
17|         |            |
18| 3.1.0   | 2012/06/19 | * Check token request
19|         |            |
20|         |            |
21|         |            |
22|         |            |
23|         |            |
24|         |            |
25|         |            |
26
27  ------------------------------------------------------------------------------
28    no constructor, only static function are provided
29    - static function return_result($str)
30   ---------------------------------------------------------------------- */
31
32define('GPC_AJAX', 'ajaxfct');
33
34class GPCAjax
35{
36  static public function returnResult($str)
37  {
38    //$chars=get_html_translation_table(HTML_ENTITIES, ENT_NOQUOTES);
39    $chars['<']='<';
40    $chars['>']='>';
41    $chars['&']='&';
42    exit(strtr($str, $chars));
43  }
44
45  /**
46   * check if there's a valid token in $_REQUEST
47   * if no, the GPC_AJAX call is set to empty value
48   *
49   * @param String $fct: the ajax function field (GPC_AJAX by default)
50   * @param String $token: the token field ('token' by default) to check
51   * @return Boolean: true if ok, otherwise false
52   */
53  static public function checkToken($fct=GPC_AJAX, $token='token')
54  {
55    if(!isset($_REQUEST[$token])) $_REQUEST[$token]='';
56    if($fct!='' && !isset($_REQUEST[$fct])) $_REQUEST[$fct]='';
57
58    if($_REQUEST[$token]==get_pwg_token()) return(true);
59
60    if($fct!='') $_REQUEST[$fct]='';
61    return(false);
62  }
63} //class
64
65?>
Note: See TracBrowser for help on using the repository browser.