Sie sind nicht angemeldet.

  • »jeromebg« ist der Autor dieses Themas

Beiträge: 1 120

Wohnort: Angers - France

Beruf: 360 experiences creator

  • Nachricht senden

1

Sonntag, 27. September 2020, 14:30

krpanotools encrypt php

Hi, trying to encrypt a xml file server side with php with no success.
here is the php code :

Quellcode

1
2
3
4
5
6
7
8
9
10
11
<?php
error_reporting(E_ALL);
$file = __DIR__ . "/tour.xml";
$encrypted_file = __DIR__ . "/encrypted_tour.xml";
$output = array();
$result = 0;
exec(__DIR__ . "/krpanotools  register W/W5Ms+EuT253Zk******",$output, $result);
exec(__DIR__ . "/krpanotools encrypt -in=".$file." -out=".$encrypted_file, $output , $result);

print_r($output,true);
?>


no error displayed and no encrypted file on the server.
I have enabled exec php function on my server.
Any clue ?
Many thanx

Dieser Beitrag wurde bereits 3 mal editiert, zuletzt von »jeromebg« (28. September 2020, 09:11)


Douglas Rhiner

Fortgeschrittener

Beiträge: 141

Wohnort: San Anselmo, CA

Beruf: Code-Slave

  • Nachricht senden

2

Donnerstag, 1. Oktober 2020, 17:18

Here is the core scripting I've played with to get XML encrypted on the fly.
It does work. But it also "Burps" from time to time. Meaning, that there is a timing issue somewhere that I have not had time to track-down and fix.
Debugging things like this is a real PITA.....

Quellcode

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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
/*
 * All code copyright 2013-2020 XplorIt LLC llc.
 * Created in the Cerebrate Aquarium by douglasrhiner
 * createvtour.com
 * enc_xml.php
 * 2/21/18
 * 11:36 AM
*/

include_once $_SERVER['DOCUMENT_ROOT'] . "/conf/loader.inc.php";

ob_start();
include_once XP_LIBRARY . "xml/get_transition_xml.php";
$obContent = ob_get_contents();
ob_end_clean();

if (boolval(SECURE)) {

    $rec_log = true;
    $log_output .= "as SECURE";


    // begin forming the file name
    $my_filename = "enc_xml_";

    // custom identifier
    if (isset($_COOKIE['sess_ref']) && !empty($_COOKIE['sess_ref'])) {
        $my_filename .= $_COOKIE['sess_ref'];
    } elseif (isset($_GET['xSessionId']) && !empty($_GET['xSessionId'])) {
        $my_filename .= $_GET['xSessionId'];
    } else {
        $my_filename .= md5(microtime());
    };

    // suffix
    $my_filename .= ".xml";

    $rec_log = true;

    $log_output = 'TRANSITION, ' . date('Y-m-d H:i:s') . ", ";


    if ($fpc = file_put_contents($my_filename, $obContent)) {

        // lets make sure krpanotools is registered. Over-abundance of caution here.
        $reg_code = " ** YOUR REG CODE HERE ** ";
        $output = array();
        $return_var = 0;
        exec(KRTOOLS_PATH . ' register ' . $reg_code, $output, $return_var);

        // forming the file name
        $my_file_path = KRENC_PATH;
        $my_file_path .= $my_filename;

        // command string
        $this_command = KRTOOLS_PATH . ' encrypt -p -in=' . $my_file_path . ' -out=stdout';

        // encrypt
        $this_process = new process($this_command);

        if (is_resource($this_process->resource)) {

            $counter = 0;

            while ($this_process->is_running()) {
                $counter = $counter + 1;
            }

            $exit_data = $this_process->get_exitcode();
            $log_output .= "command -> " . $exit_data['command'] . ", ";
            $log_output .= "\n";
            $log_output .= $this_process->get_elapsed();
            $log_output .= "\n";
            $log_output .= "pid -> " . $exit_data['pid'] . ", ";
            $log_output .= "running -> " . $exit_data['running'] . ", ";
            $log_output .= "signaled -> " . $exit_data['signaled'] . ", ";
            $log_output .= "stopped -> " . $exit_data['stopped'] . ", ";
            $log_output .= "exitcode -> " . $exit_data['exitcode'] . ", ";
            $log_output .= "termsig -> " . $exit_data['termsig'] . ", ";
            $log_output .= "stopsig -> " . $exit_data['stopsig'] . ", ";

            if ($err = stream_get_contents($this_process->pipes[2])) {

                $log_output .= "PIPED ERROR -> $err, ";
                fclose($this_process->pipes[2]);
                $the_output = $obContent;

            } else {

                fclose($this_process->pipes[2]);

                if ($out = stream_get_contents($this_process->pipes[1])) {

                    $the_output = $out;
                    unlink($my_filename);
                    $rec_log = false;

                } else {

                    $log_output .= "\nERROR NOT DELETED, ";

                }

                fclose($this_process->pipes[1]);

            }

            proc_close($this_process->resource);

        }

    } else {

        $rec_log = true;
        $the_output = $obContent;
        $log_output .= "file_put_contents ERROR";

    };

    /*
    $rec_log = true;
    $the_output = $obContent;
    $log_output .= "file_put_contents ERROR";
    */

} else {
    $the_output = $obContent;
};

echo $the_output;

if ($rec_log) {

    file_put_contents('enc_error_log.txt', $log_output . "\n\n", FILE_APPEND);

}

exit();

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Douglas Rhiner« (1. Oktober 2020, 20:28)


3

Donnerstag, 1. Oktober 2020, 22:12

Hi,

instead of calling register first use the -license=### syntax - see here at the bottom of the page:
https://krpano.com/buy/howtoregister/

This avoids potential problems when e.g. two processes or two threads are trying to register at the same time.

Best regards,
Klaus

  • »jeromebg« ist der Autor dieses Themas

Beiträge: 1 120

Wohnort: Angers - France

Beruf: 360 experiences creator

  • Nachricht senden

4

Freitag, 2. Oktober 2020, 09:18

I already tried that before with no succes.
Even the most simple command won't do anything, problem is no error or warning is sent so I don't know from where comes the problem ?

Quellcode

1
2
3
<?php
exec("/krpanotools encrypt -in=tour.xml  -out=encypted.xml -license=W/W5Ms+EuT2******");
?>

Douglas Rhiner

Fortgeschrittener

Beiträge: 141

Wohnort: San Anselmo, CA

Beruf: Code-Slave

  • Nachricht senden

5

Sonntag, 4. Oktober 2020, 04:42

Klaus,

I had gone down that route, but several times I got an error saying that KRPano was not registered.