コード例 #1
0
ファイル: form.php プロジェクト: knigherrant/decopatio
 public function store()
 {
     // Add XML header
     $this->xml->addHeader();
     // Add <form> tag
     $this->xml->add('form');
     $this->storeStructure();
     $this->storeFields();
     $this->storeCalculations();
     $this->storePost();
     $this->storeConditions();
     $this->storeDirectory();
     $this->storeEmails();
     $this->storeMappings();
     // Allow plugins to add their own data to the backup.
     JFactory::getApplication()->triggerEvent('rsfp_onFormBackup', array($this->form, $this->xml, $this->fields));
     // Close <form> tag
     $this->xml->add('/form');
     $archive = new RSFormProTar($this->path);
     $buffer = (string) $this->xml;
     $size = strlen($buffer);
     $archive->addHeader($size, RSFormProBackupHelper::getHash($this->form->FormId) . '.xml');
     $archive->add($buffer);
     $archive->addPadding($size);
     $archive->close();
 }
コード例 #2
0
ファイル: backup.php プロジェクト: knigherrant/decopatio
 public function storeMetaData()
 {
     // Load forms from the database
     $db =& $this->db;
     $query = $db->getQuery(true);
     $query->select('*')->from($db->qn('#__rsform_forms'))->where($db->qn('FormId') . ' IN (' . RSFormProBackupHelper::qi($this->formIds) . ')');
     $db->setQuery($query);
     $this->forms = $db->loadObjectList('FormId');
     // Count the number of submissions as well, if requested.
     if ($this->submissions) {
         $query->clear()->select('COUNT(' . $db->qn('SubmissionId') . ') AS ' . $db->qn('count'))->select($db->qn('FormId'))->from($db->qn('#__rsform_submissions'))->where($db->qn('FormId') . ' IN (' . RSFormProBackupHelper::qi($this->formIds) . ')')->group($db->qn('FormId'));
         $db->setQuery($query);
         if ($submissions = $db->loadObjectList()) {
             foreach ($submissions as $submission) {
                 if (isset($this->forms[$submission->FormId])) {
                     $this->forms[$submission->FormId]->SubmissionsCount = $submission->count;
                 }
             }
         }
     }
     // Initialize XML writer.
     $xml = new RSFormProBackupXML();
     $xml->addHeader()->add('rsform')->add('version', (string) new RSFormProVersion())->add('cms', JVERSION)->add('php', phpversion())->add('os', PHP_OS)->add('url', JUri::root())->add('root', JPATH_ROOT)->add('author', JFactory::getUser()->get('email'))->add('date', JFactory::getDate()->toSql());
     // Start adding form information
     if ($this->forms) {
         $xml->add('forms');
         foreach ($this->forms as $form) {
             $xml->add('form')->add('id', RSFormProBackupHelper::getHash($form->FormId))->add('name', $form->FormName)->add('title', $form->FormTitle)->add('submissions', !empty($form->SubmissionsCount) ? $form->SubmissionsCount : 0)->add('/form');
         }
         $xml->add('/forms');
     }
     // Finishup
     $xml->add('/rsform');
     $archive = new RSFormProTar($this->getPath());
     $buffer = (string) $xml;
     $size = strlen($buffer);
     $archive->addHeader($size, 'metadata.xml');
     $archive->add($buffer);
     $archive->addPadding($size);
     $archive->close();
 }
コード例 #3
0
ファイル: submissions.php プロジェクト: AlexanderKri/joom-upd
 public function store()
 {
     $archive = new RSFormProTar($this->path);
     $db =& $this->db;
     $done = false;
     // Set the data XML file number
     if ($this->limitstart >= $this->limit) {
         $xmlNumber = round($this->limitstart / $this->limit);
     } else {
         $xmlNumber = 0;
     }
     // Grab the submissions
     $query = $db->getQuery(true);
     $query->select('*')->from($db->qn('#__rsform_submissions'))->where($db->qn('FormId') . '=' . $db->q($this->id));
     $db->setQuery($query, $this->limitstart, $this->limit);
     if ($submissions = $db->loadObjectList('SubmissionId')) {
         $query->clear()->select('*')->from($db->qn('#__rsform_submission_values'))->where($db->qn('SubmissionId') . ' IN (' . RSFormProBackupHelper::qi(array_keys($submissions)) . ')');
         $db->setQuery($query);
         $values = $db->loadObjectList();
         // Record the position
         $this->header = $archive->tell();
         // Add the 512-bytes dummy header
         $archive->addEmptyHeader();
         // Add the XML header & opening tag.
         $this->xml->addHeader();
         $this->xml->add('submissions');
         foreach ($values as $value) {
             if (empty($submissions[$value->SubmissionId]->values)) {
                 $submissions[$value->SubmissionId]->values = array();
             }
             $submissions[$value->SubmissionId]->values[$value->FieldName] = $value->FieldValue;
         }
         foreach ($submissions as $submission) {
             $values = isset($submission->values) ? $submission->values : array();
             // No need for these.
             unset($submission->values, $submission->SubmissionId, $submission->FormId);
             $this->xml->add('submission');
             foreach ($submission as $property => $value) {
                 $this->xml->add($property, $value);
             }
             // Add values
             $this->xml->add('values');
             foreach ($values as $property => $value) {
                 $this->xml->add('value');
                 $this->xml->add('fieldname', $property);
                 $this->xml->add('fieldvalue', $value);
                 $this->xml->add('/value');
             }
             $this->xml->add('/values');
             $this->xml->add('/submission');
         }
         // We've finished, no more submissions, add the closing tag.
         $this->xml->add('/submissions');
         // Add data to archive.
         $archive->add((string) $this->xml);
         // Compute size of current file in archive.
         $size = $archive->tell() - $this->header - 512;
         // Add missing padding.
         $archive->addPadding($size);
         // Go to header (so we can add missing header data).
         $archive->seek($this->header);
         // Add missing header data.
         $archive->addHeader($size, RSFormProBackupHelper::getHash($this->id) . '-data-' . $xmlNumber . '.xml');
     } else {
         // Flag so that we can move on to the next form
         $done = true;
     }
     $archive->close();
     return (object) array('done' => $done, 'header' => $this->header);
 }
コード例 #4
0
ファイル: backup.php プロジェクト: knigherrant/decopatio
 public function compressGzip()
 {
     $input = JFactory::getApplication()->input;
     $key = $input->get('key', '', 'cmd');
     $seek = $input->get('seek', 0, 'cmd');
     $options = array('key' => $key);
     try {
         $backup = new RSFormProBackup($options);
         $archive = new RSFormProTar($backup->getPath());
         // GZIP compress it.
         $seek = $archive->compress($seek);
         // Continue with GZIP archive creation
         $this->showResponse(array('status' => 'ok', 'step' => $seek ? 'compress-gzip' : 'done', 'seek' => $seek));
     } catch (Exception $e) {
         $this->showError($e->getMessage());
     }
 }