-
Notifications
You must be signed in to change notification settings - Fork 0
/
ajax_loader.php
73 lines (57 loc) · 1.21 KB
/
ajax_loader.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
ob_start("ob_gzhandler");
/*
Crowd Source Classifier Training
Ajax Loader Page (ajax_loader.php)
26/08/10 Rob Ryan
*/
// load configuration file
include_once("config.php");
// load the database class
include_once("includes/db_mysql.php");
$db = new DB($config);
include_once("includes/xtemplate.class.php");
include_once("page_base.php");
$action = $_GET['action'];
$json_data = $_GET['json_string'];
$depth = 0;
function utf8json($inArray)
{
global $depth;
/* our return object */
$newArray = array();
/* safety recursion limit */
$depth++;
if($depth >= 30) {
return false;
}
/* step through inArray */
foreach($inArray as $key=>$val) {
if(is_array($val)) {
/* recurse on array elements */
$newArray[$key] = utf8json($val);
} else {
/* encode string values */
$newArray[$key] = utf8_encode($val);
}
}
/* return utf8 encoded array */
return $newArray;
}
switch($action)
{
case "vote":
include_once("stream.php");
$main_class = new stream(1);
$main_class->add_vote($json_data);
break;
case "get_tweets":
include_once("classify.php");
include_once("stream.php");
$main_class = new stream(1);
$main_class->get_tweets($json_data);
break;
default:
break;
}
?>