added spaces + some curly braces + some usage of dbm::is_result()
[friendica.git/.git] / mod / like.php
1 <?php
2
3 require_once('include/security.php');
4 require_once('include/bbcode.php');
5 require_once('include/items.php');
6 require_once('include/like.php');
7
8 function like_content(App $a) {
9         if (! local_user() && ! remote_user()) {
10                 return false;
11         }
12
13
14         $verb = notags(trim($_GET['verb']));
15
16         if (! $verb) {
17                 $verb = 'like';
18         }
19
20         $item_id = (($a->argc > 1) ? notags(trim($a->argv[1])) : 0);
21
22         $r = do_like($item_id, $verb);
23         if (!$r) {
24                 return;
25         }
26
27         // See if we've been passed a return path to redirect to
28         $return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
29
30         like_content_return(App::get_baseurl(), $return_path);
31         killme(); // NOTREACHED
32 //      return; // NOTREACHED
33 }
34
35
36 // Decide how to return. If we were called with a 'return' argument,
37 // then redirect back to the calling page. If not, just quietly end
38
39 function like_content_return($baseurl, $return_path) {
40
41         if ($return_path) {
42                 $rand = '_=' . time();
43                 if (strpos($return_path, '?')) {
44                         $rand = "&$rand";
45                 } else {
46                         $rand = "?$rand";
47                 }
48
49                 goaway($baseurl . "/" . $return_path . $rand);
50         }
51
52         killme();
53 }
54