summaryrefslogtreecommitdiffstats
path: root/main/survey/sa_koda.php
blob: 8cbc54d0f6e2d67addd649e4ea3d9dab328f4eab (plain) (blame)
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
<?php
/***************************************
 * Description:
 * Autor: Robert Šmalc
 * Created date: 15.04.2016
 *****************************************/
include_once('../../settings.php');
include_once('../../function.php');

if (!empty($_POST['koda'])) {
    $koda = strtolower($_POST['koda']);

    $sql = sisplet_query("SELECT h.url, h.anketa_id, a.hash FROM srv_hierarhija_koda h, srv_anketa a WHERE h.koda='".$koda."' AND h.anketa_id=a.id");

    if ($sql->num_rows > 0) {
        $row = $sql->fetch_object();

        //kodiramo spremenljivke z base64_encode
        $url_encode_spremenljivke = urlencode(base64_encode($row->url));

        //celotni url do ankete
        header("Location: " . $site_url . "a/" . $row->hash . "?enc=" . $url_encode_spremenljivke);
        die();
    }

    // V kolikor gre za superšifro potem preverimo še med superšiframi
    $sql = sisplet_query("SELECT koda, kode, anketa_id FROM srv_hierarhija_supersifra WHERE koda='" . $koda . "'");
    if ($sql->num_rows > 0) {
        $row = $sql->fetch_object();
        $kode = unserialize($row->kode);

        $koda_resevanje = sisplet_query("SELECT url FROM srv_hierarhija_koda WHERE koda='" . $kode[0] . "' AND anketa_id='" . $row->anketa_id . "'", "obj");

        //kodiramo spremenljivke z base64_encode
        $url_encode_spremenljivke = urlencode(base64_encode($koda_resevanje->url . '&supersifra=' . $koda.'&resujem=0'));

        //celotni url do ankete
        header("Location: " . $site_url . "a/" . $row->hash . "?enc=" . $url_encode_spremenljivke);
        die();
    }

}

header("Location: " . $site_url);
die();