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 | |
---|
32 | define('GPC_AJAX', 'ajaxfct'); |
---|
33 | |
---|
34 | class 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 | ?> |
---|