~xibo-maintainers/xibo/tempel

« back to all changes in this revision

Viewing changes to lib/Helper/BackupUploadHandler.php

  • Committer: GitHub
  • Author(s): Dan Garner
  • Date: 2018-11-23 16:08:30 UTC
  • mfrom: (253.3.69)
  • Revision ID: git-v1:f269df6637efba4b2b6d684bf24f217ec686e7e9
Merge pull request #426 from PeterMis/bugfix/1.8.12-pack3

Bugfix/1.8.12 pack3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
 
3
 
namespace Xibo\Helper;
4
 
 
5
 
use Exception;
6
 
 
7
 
/**
8
 
 * Class BackupUploadHandler
9
 
 * @package Xibo\Helper
10
 
 */
11
 
class BackupUploadHandler extends BlueImpUploadHandler
12
 
{
13
 
    protected function handle_form_data($file, $index)
14
 
    {
15
 
        $controller = $this->options['controller'];
16
 
        /* @var \Xibo\Controller\Base $controller */
17
 
 
18
 
        // Handle form data, e.g. $_REQUEST['description'][$index]
19
 
        $fileName = $file->name;
20
 
 
21
 
        $controller->getLog()->debug('Upload complete for ' . $fileName . '.');
22
 
 
23
 
        // Upload and Save
24
 
        try {
25
 
            // Move the uploaded file to a temporary location in the library
26
 
            $destination = tempnam($controller->getConfig()->GetSetting('LIBRARY_LOCATION') . 'temp/', 'dmp');
27
 
            rename($fileName, $destination);
28
 
 
29
 
            global $dbuser;
30
 
            global $dbpass;
31
 
            global $dbname;
32
 
 
33
 
            // Push the file into msqldump
34
 
            exec('mysql --user=' . $dbuser . ' --password=' . $dbpass . ' ' . $dbname . ' < ' . escapeshellarg($fileName) . ' ');
35
 
 
36
 
            $controller->getLog()->notice('mysql --user=' . $dbuser . ' --password=' . $dbpass . ' ' . $dbname . ' < ' . escapeshellarg($fileName) . ' ' );
37
 
 
38
 
            unlink($destination);
39
 
 
40
 
        } catch (Exception $e) {
41
 
            $controller->getLog()->error('Error uploading media: %s', $e->getMessage());
42
 
            $controller->getLog()->debug($e->getTraceAsString());
43
 
 
44
 
            $file->error = $e->getMessage();
45
 
 
46
 
            $controller->getApp()->commit = false;
47
 
        }
48
 
    }
49
 
}
 
 
b'\\ No newline at end of file'