summaryrefslogtreecommitdiff
path: root/plugins/mobile/backend.php
blob: a62f462d5e7356bbccb3eadd56b7572392cfa1f0 (plain)
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
<?php
	error_reporting(E_ERROR | E_WARNING | E_PARSE);

	header('Content-Type: text/html; charset=utf-8');

	$basedir = dirname(dirname(dirname(__FILE__)));

	set_include_path(
		dirname(__FILE__) . PATH_SEPARATOR .
		$basedir . PATH_SEPARATOR .
		"$basedir/include" . PATH_SEPARATOR .
		get_include_path());

	define('MOBILE_VERSION', true);

	require_once "config.php";
	require_once "mobile-functions.php";

	require_once "functions.php";
	require_once "sessions.php";
	require_once "version.php";
	require_once "db-prefs.php";

	$link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);

	init_plugins($link);

	if (!$_SESSION["uid"]) return;

	$op = $_REQUEST["op"];

	switch ($op) {
	case "toggleMarked":
		$cmode = db_escape_string( $_REQUEST["mark"]);
		$id = db_escape_string( $_REQUEST["id"]);

		markArticlesById( array($id), $cmode);
		break;
	case "togglePublished":
		$cmode = db_escape_string( $_REQUEST["pub"]);
		$id = db_escape_string( $_REQUEST["id"]);

		publishArticlesById( array($id), $cmode);
		break;
	case "toggleUnread":
		$cmode = db_escape_string( $_REQUEST["unread"]);
		$id = db_escape_string( $_REQUEST["id"]);

		catchupArticlesById( array($id), $cmode);
		break;

	case "setPref":
		$id = db_escape_string( $_REQUEST["id"]);
		$value = db_escape_string( $_REQUEST["to"]);
		mobile_set_pref( $id, $value);
		print_r($_SESSION);
		break;
	default:
		print json_encode(array("error", "UNKNOWN_METHOD"));
		break;
	}
?>