summaryrefslogtreecommitdiff
path: root/js/callbacks/savesearches.php
blob: e656a0ad2698b4ffd001721ef66a30eedb73bfcd (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
<?php
/**
 * This script is the AJAX callback that saves a user's search
 */

define('IN_FS', true);

require_once('../../header.php');

if (Cookie::has('flyspray_userid') && Cookie::has('flyspray_passhash')) {
    $user = new User(Cookie::val('flyspray_userid'));
    $user->check_account_ok();

    if( !Post::has('csrftoken') ){
        http_response_code(428); # 'Precondition Required'
        die('missingtoken');
    }elseif( Post::val('csrftoken')==$_SESSION['csrftoken']){
        # empty
    }else{
        http_response_code(412); # 'Precondition Failed'
        die('wrongtoken');
    }
    
    $user->save_search();
}

?>