/
export.php
61 lines (61 loc) · 1.93 KB
/
export.php
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
<?php
$user = OpenVBX::getCurrentUser();
$tenant_id = $user->values['tenant_id'];
if(isset($_POST['id'])) {
$flows = OpenVBX::getFlows(array('id' => $_POST['id'], 'tenant_id' => $tenant_id));
$data = $flows[0]->values['data'];
$sms_data = $flows[0]->values['sms_data'];
$export = md5($data . $sms_data) . ':' . base64_encode($data) . ':' . base64_encode($sms_data);
if(isset($_POST['file'])) {
header('Content-type: text/plain');
header('Content-Disposition: attachment; filename=' . preg_replace('/\W/', '', $flows[0]->values['name']) . '.ovbx');
echo $export;
die;
}
}
$flows = OpenVBX::getFlows(array('tenant_id' => $tenant_id));
?>
<style>
.vbx-export-flow form {
margin-top: 20px;
}
.vbx-export-flow p {
margin: 10px 0;
padding: 0 20px;
}
.vbx-export-flow h3 {
font-size: 14px;
padding: 0 20px;
margin-top: 20px;
}
</style>
<div class="vbx-content-main">
<div class="vbx-content-menu vbx-content-menu-top">
<h2 class="vbx-content-heading">Export Flow</h2>
</div>
<div class="vbx-table-section vbx-export-flow">
<?php if(count($flows)): ?>
<form method="post" action="">
<fieldset class="vbx-input-container">
<p>
<label class="field-label">
<select name="id" class="medium">
<?php foreach($flows as $flow): ?>
<option value="<?php echo $flow->values['id']; ?>"<?php echo isset($_POST['id']) && $_POST['id'] == $flow->values['id'] ? ' selected="selected"' : ''; ?>><?php echo $flow->values['name']; ?></option>
<?php endforeach; ?>
</select>
</label>
</p>
<p><label><input type="checkbox" name="file" /> Save as file</label></p>
<p><button type="submit" class="submit-button"><span>Export</span></button></p>
</fieldset>
</form>
<?php if(isset($export)): ?>
<h3>Write this down!</h3>
<p><textarea rows="20" cols="100"><?php echo $export; ?></textarea></p>
<?php endif; ?>
<?php else: ?>
<h3>You do not have any flows.</h3>
<?php endif; ?>
</div>
</div>