public function send()
 {
     if ($this->password == '') {
         return;
     }
     if ($this->onlychanged) {
         if ($this->posts == litepublisher::$classes->posts->count && $this->comments == litepublisher::$classes->commentmanager->count) {
             return;
         }
         $this->posts = litepublisher::$classes->posts->count;
         $this->comments = litepublisher::$classes->commentmanager->count;
         $this->save();
     }
     $backuper = tbackuper::i();
     $filename = $this->useshell ? $backuper->createshellbackup() : $backuper->createbackup();
     litepublisher::$classes->include_file(litepublisher::$paths->plugins . 'backup2dropbox' . DIRECTORY_SEPARATOR . 'DropboxUploader.php');
     $uploader = new DropboxUploader($this->email, $this->password);
     try {
         set_time_limit(600);
         $uploader->upload($filename, $this->dir);
         unlink($filename);
         if ($this->uploadfiles) {
             if ($this->useshell) {
                 $filename = $backuper->createshellfilesbackup();
                 $uploader->upload($filename, $this->dir);
                 unlink($filename);
             } else {
                 $this->upload_files($uploader, '');
             }
         }
     } catch (Exception $e) {
         return $e->getMessage();
     }
     return true;
 }
 /**
  * @test
  */
 public function testSetters()
 {
     $uploader = new DropboxUploader('email', 'pass');
     $this->addToAssertionCount(1);
     $uploader->setCaCertificateDir('');
     $this->addToAssertionCount(1);
     $uploader->setCaCertificateFile('');
 }
 private function configureUploader(DropboxUploader $uploader, array $configuration)
 {
     if ($caCertificateDir = $configuration['Dropbox_CaCertificateDir']) {
         $uploader->setCaCertificateDir($caCertificateDir);
     }
     if ($caCertificateFile = $configuration['Dropbox_CaCertificateFile']) {
         $uploader->setCaCertificateFile($caCertificateFile);
     }
 }
Exemple #4
0
</head>
<body>
<h1>Dropbox Uploader Demo</h1>
<?php 
if ($_POST) {
    require 'DropboxUploader.php';
    try {
        $uploader = null;
        if ($_FILES['file']['error'] !== UPLOAD_ERR_OK) {
            throw new Exception('File was not successfully uploaded from your computer.');
        }
        if ($_FILES['file']['name'] === "") {
            throw new Exception('File name not supplied by the browser.');
        }
        // Upload
        $uploader = new DropboxUploader($_POST['email'], $_POST['password']);
        $uploader->upload($_FILES['file']['tmp_name'], $_POST['destination'], $_FILES['file']['name']);
        echo '<span style="color: green">File successfully uploaded to your Dropbox!</span>';
    } catch (Exception $e) {
        // Handle Upload Exceptions
        $label = $uploader && $e->getCode() & $uploader::FLAG_DROPBOX_GENERIC ? 'DropboxUploader' : 'Exception';
        $error = sprintf("[%s] #%d %s", $label, $e->getCode(), $e->getMessage());
        echo '<span style="color: red">Error: ' . htmlspecialchars($error) . '</span>';
    }
}
?>
<form method="POST" enctype="multipart/form-data">
    <dl>
        <dt><label for="email">Dropbox e-mail</label></dt>
        <dd><input type="text" id="email" name="email"></dd>
        <dt><label for="password">Dropbox password</label></dt>
    function submit()
    {
        global $database, $ff_config, $ff_comsite, $ff_mossite, $ff_otherparams;
        // CONTENTBUILDER BEGIN
        $cbRecordId = 0;
        $cbEmailNotifications = false;
        $cbEmailUpdateNotifications = false;
        $cbResult = $this->cbCheckPermissions();
        if ($cbResult['data'] !== null && $cbResult['data']['email_notifications']) {
            if (!JRequest::getInt('cb_record_id', 0)) {
                $cbEmailNotifications = true;
            } else {
                $cbEmailNotifications = false;
            }
        }
        if ($cbResult['data'] !== null && $cbResult['data']['email_update_notifications']) {
            if (JRequest::getInt('cb_record_id', 0)) {
                $cbEmailUpdateNotifications = true;
            } else {
                $cbEmailUpdateNotifications = false;
            }
        }
        if ($cbResult['data'] === null) {
            $cbEmailNotifications = true;
            $cbEmailUpdateNotifications = true;
        }
        // CONTENTBUILDER END
        $database = JFactory::getDBO();
        if (!$this->okrun) {
            return;
        }
        // currently only available in classic mode
        if (trim($this->formrow->template_code_processed) == '') {
            set_error_handler('_ff_errorHandler');
        }
        ob_start();
        $this->record_id = '';
        $this->status = _FF_STATUS_OK;
        $this->message = '';
        $this->sendNotificationAfterPayment = false;
        // handle Begin Submit piece
        $halt = false;
        $this->collectSubmitdata($cbResult);
        if (!$halt) {
            require_once JPATH_SITE . '/administrator/components/com_breezingforms/libraries/Zend/Json/Decoder.php';
            require_once JPATH_SITE . '/administrator/components/com_breezingforms/libraries/Zend/Json/Encoder.php';
            require_once JPATH_SITE . '/administrator/components/com_breezingforms/libraries/crosstec/functions/helpers.php';
            $dataObject = Zend_Json::decode(base64_decode($this->formrow->template_code));
            $rootMdata = $dataObject['properties'];
            if (JRequest::getVar('ff_applic', '') != 'mod_facileforms' && JRequest::getInt('ff_frame', 0) != 1 && bf_is_mobile()) {
                $is_device = true;
                $this->isMobile = isset($rootMdata['mobileEnabled']) && isset($rootMdata['forceMobile']) && $rootMdata['mobileEnabled'] && $rootMdata['forceMobile'] ? true : (isset($rootMdata['mobileEnabled']) && isset($rootMdata['forceMobile']) && $rootMdata['mobileEnabled'] && JFactory::getSession()->get('com_breezingforms.mobile', false) ? true : false);
            } else {
                $this->isMobile = false;
            }
            // transforming recaptcha into captcha due to compatibility on mobiles
            if ($this->isMobile && trim($this->formrow->template_code_processed) == 'QuickMode') {
                for ($i = 0; $i < $this->rowcount; $i++) {
                    $row = $this->rows[$i];
                    if ($row->type == "ReCaptcha") {
                        $this->rows[$i]->type = 'Captcha';
                        break;
                    }
                }
            }
            for ($i = 0; $i < $this->rowcount; $i++) {
                $row = $this->rows[$i];
                if ($row->type == "Captcha") {
                    require_once JPATH_SITE . '/components/com_breezingforms/images/captcha/securimage.php';
                    $securimage = new Securimage();
                    if (!$securimage->check(JRequest::getVar('bfCaptchaEntry', ''))) {
                        $halt = true;
                        $this->status = _FF_STATUS_CAPTCHA_FAILED;
                        exit;
                    }
                    break;
                } else {
                    if ($row->type == "ReCaptcha") {
                        if (!JFactory::getSession()->get('bfrecapsuccess', false)) {
                            $halt = true;
                            $this->status = _FF_STATUS_CAPTCHA_FAILED;
                            exit;
                        }
                        JFactory::getSession()->set('bfrecapsuccess', false);
                        break;
                    }
                }
            }
            require_once JPATH_SITE . '/administrator/components/com_breezingforms/libraries/Zend/Json/Decoder.php';
            require_once JPATH_SITE . '/administrator/components/com_breezingforms/libraries/Zend/Json/Encoder.php';
            $areas = Zend_Json::decode($this->formrow->template_areas);
            if (is_array($areas)) {
                switch (JRequest::getVar('ff_payment_method', '')) {
                    case 'PayPal':
                    case 'Sofortueberweisung':
                        foreach ($areas as $area) {
                            foreach ($area['elements'] as $element) {
                                if ($element['internalType'] == 'bfPayPal' || $element['internalType'] == 'bfSofortueberweisung') {
                                    $options = $element['options'];
                                    if (isset($options['sendNotificationAfterPayment']) && $options['sendNotificationAfterPayment']) {
                                        $this->sendNotificationAfterPayment = true;
                                    }
                                }
                            }
                        }
                }
            }
        }
        if (!$halt) {
            $code = '';
            switch ($this->formrow->piece3cond) {
                case 1:
                    // library
                    $database->setQuery("select name, code from #__facileforms_pieces " . "where id=" . $this->formrow->piece3id . " and published=1 ");
                    $rows = $database->loadObjectList();
                    if (count($rows)) {
                        echo $this->execPiece($rows[0]->code, BFText::_('COM_BREEZINGFORMS_PROCESS_BSPIECE') . " " . $rows[0]->name, 'p', $this->formrow->piece3id, null);
                    }
                    break;
                case 2:
                    // custom code
                    echo $this->execPiece($this->formrow->piece3code, BFText::_('COM_BREEZINGFORMS_PROCESS_BSPIECEC'), 'f', $this->form, 3);
                    break;
                default:
                    break;
            }
            // switch
            if ($this->bury()) {
                return;
            }
            if ($this->status == _FF_STATUS_OK) {
                if (!$this->formrow->published) {
                    $this->status = _FF_STATUS_UNPUBLISHED;
                } else {
                    if ($this->status == _FF_STATUS_OK) {
                        if ($this->formrow->dblog > 0) {
                            $cbRecordId = $this->logToDatabase($cbResult);
                        }
                        if ($this->status == _FF_STATUS_OK) {
                            if ($this->formrow->emailntf > 0 && ($cbEmailNotifications || $cbEmailUpdateNotifications)) {
                                // CONTENTBUILDER
                                $this->sendEmailNotification();
                            }
                            if ($this->formrow->mb_emailntf > 0 && ($cbEmailNotifications || $cbEmailUpdateNotifications)) {
                                // CONTENTBUILDER
                                $this->sendMailbackNotification();
                            }
                            // DROPBOX
                            if ($this->formrow->dropbox_submission_enabled) {
                                if ($this->formrow->dropbox_email && $this->formrow->dropbox_password) {
                                    if (!class_exists('DropboxUploader')) {
                                        require_once JPATH_SITE . DS . 'administrator' . DS . 'components' . DS . 'com_breezingforms' . DS . 'libraries' . DS . 'dropbox' . DS . 'dropbox.php';
                                    }
                                    try {
                                        $dropbox = new DropboxUploader($this->formrow->dropbox_email, $this->formrow->dropbox_password);
                                        if ($this->formrow->dropbox_email && $this->formrow->dropbox_password) {
                                            $dropbox_types = explode(',', $this->formrow->dropbox_submission_types);
                                            foreach ($dropbox_types as $dropbox_type) {
                                                $dropbox_file = '';
                                                switch ($dropbox_type) {
                                                    case 'pdf':
                                                        $dropbox_file = $this->exppdf();
                                                        break;
                                                    case 'csv':
                                                        $dropbox_file = $this->expcsv();
                                                        break;
                                                    case 'xml':
                                                        $dropbox_file = $this->expxml();
                                                        break;
                                                }
                                                if ($dropbox_file != '') {
                                                    $dropbox->upload($dropbox_file, '/' . ($this->formrow->dropbox_folder != '' ? $this->formrow->dropbox_folder : $this->formrow->name));
                                                }
                                            }
                                        }
                                    } catch (Exception $e) {
                                    }
                                }
                            }
                            $this->sendMailChimpNotification();
                            $this->sendSalesforceNotification();
                            JPluginHelper::importPlugin('breezingforms_addons');
                            $dispatcher = JDispatcher::getInstance();
                            $dispatcher->trigger('onPropertiesExecute', array($this));
                            $tickets = JFactory::getSession()->get('bfFlashUploadTickets', array());
                            mt_srand();
                            if (isset($tickets[JRequest::getVar('bfFlashUploadTicket', mt_rand(0, mt_getrandmax()))])) {
                                unset($tickets[JRequest::getVar('bfFlashUploadTicket')]);
                                JFactory::getSession()->set('bfFlashUploadTickets', $tickets);
                            }
                        }
                    }
                    // if
                }
                // if
            }
            // if
            // handle End Submit piece
            JFactory::getDbo()->setQuery("SELECT MAX(id) FROM #__facileforms_records");
            $lastid = JFactory::getDbo()->loadResult();
            $_SESSION['virtuemart_bf_id'] = $lastid;
            $session = JFactory::getSession();
            $session->set('virtuemart_bf_id', $lastid);
            $code = '';
            switch ($this->formrow->piece4cond) {
                case 1:
                    // library
                    $database->setQuery("select name, code from #__facileforms_pieces " . "where id=" . $this->formrow->piece4id . " and published=1 ");
                    $rows = $database->loadObjectList();
                    if (count($rows)) {
                        echo $this->execPiece($rows[0]->code, BFText::_('COM_BREEZINGFORMS_PROCESS_ESPIECE') . " " . $rows[0]->name, 'p', $this->formrow->piece4id, null);
                    }
                    break;
                case 2:
                    // custom code
                    echo $this->execPiece($this->formrow->piece4code, BFText::_('COM_BREEZINGFORMS_PROCESS_ESPIECEC'), 'f', $this->form, 3);
                    break;
                default:
                    break;
            }
            // switch
            if ($this->bury()) {
                return;
            }
        }
        switch ($this->status) {
            case _FF_STATUS_OK:
                $message = BFText::_('COM_BREEZINGFORMS_PROCESS_SUBMITSUCCESS');
                break;
            case _FF_STATUS_UNPUBLISHED:
                $message = BFText::_('COM_BREEZINGFORMS_PROCESS_UNPUBLISHED');
                break;
            case _FF_STATUS_SAVERECORD_FAILED:
                $message = BFText::_('COM_BREEZINGFORMS_PROCESS_SAVERECFAILED');
                break;
            case _FF_STATUS_SAVESUBRECORD_FAILED:
                $message = BFText::_('COM_BREEZINGFORMS_PROCESS_SAVESUBFAILED');
                break;
            case _FF_STATUS_UPLOAD_FAILED:
                $message = BFText::_('COM_BREEZINGFORMS_PROCESS_UPLOADFAILED');
                break;
            case _FF_STATUS_SENDMAIL_FAILED:
                $message = BFText::_('COM_BREEZINGFORMS_PROCESS_SENDMAILFAILED');
                break;
            case _FF_STATUS_ATTACHMENT_FAILED:
                $message = BFText::_('COM_BREEZINGFORMS_PROCESS_ATTACHMTFAILED');
                break;
            case _FF_STATUS_CAPTCHA_FAILED:
                $message = BFText::_('COM_BREEZINGFORMS_CAPTCHA_ENTRY_FAILED');
                break;
            case _FF_STATUS_FILE_EXTENSION_NOT_ALLOWED:
                $message = BFText::_('COM_BREEZINGFORMS_FILE_EXTENSION_NOT_ALLOWED');
                break;
            default:
                $message = '';
                // custom piece status and message
                break;
        }
        // switch
        // built in PayPal action
        $paymentAction = false;
        if ($this->formrow->template_code != '') {
            require_once JPATH_SITE . '/administrator/components/com_breezingforms/libraries/Zend/Json/Decoder.php';
            require_once JPATH_SITE . '/administrator/components/com_breezingforms/libraries/Zend/Json/Encoder.php';
            $areas = Zend_Json::decode($this->formrow->template_areas);
            if (is_array($areas)) {
                jimport('joomla.version');
                $version = new JVersion();
                $j15 = true;
                if (version_compare($version->getShortVersion(), '1.6', '>=')) {
                    $j15 = false;
                }
                $paymentAction = true;
                switch (JRequest::getVar('ff_payment_method', '')) {
                    case 'PayPal':
                        foreach ($areas as $area) {
                            foreach ($area['elements'] as $element) {
                                if ($element['internalType'] == 'bfPayPal') {
                                    $options = $element['options'];
                                    $business = $options['business'];
                                    $paypal = 'https://www.paypal.com';
                                    if ($options['testaccount']) {
                                        $paypal = 'https://www.sandbox.paypal.com';
                                        $business = $options['testBusiness'];
                                    }
                                    $returnurl = htmlentities(JURI::root() . "index.php?option=com_breezingforms&confirmPayPal=true&form_id=" . $this->form . "&record_id=" . $this->record_id);
                                    $cancelurl = htmlentities(JURI::root() . "index.php?msg=" . BFText::_('Transaction Cancelled'));
                                    $html = '';
                                    if (!$this->inline) {
                                        $html .= '<html><head></head><body>';
                                    }
                                    JHTML::_('behavior.modal');
                                    $ppselect = JRequest::getVar('ff_nm_bfPaymentSelect', array());
                                    if (count($ppselect) != 0) {
                                        $ppselected = explode('|', $ppselect[0]);
                                        if (count($ppselected) == 4) {
                                            $options['itemname'] = htmlentities($ppselected[0], ENT_QUOTES, 'UTF-8');
                                            $options['itemnumber'] = htmlentities($ppselected[1], ENT_QUOTES, 'UTF-8');
                                            $options['amount'] = htmlentities($ppselected[2], ENT_QUOTES, 'UTF-8');
                                            $options['tax'] = htmlentities($ppselected[3], ENT_QUOTES, 'UTF-8');
                                        }
                                    }
                                    // keeping this for compat reasons
                                    $ppselect = JRequest::getVar('ff_nm_PayPalSelect', array());
                                    if (count($ppselect) != 0) {
                                        $ppselected = explode('|', $ppselect[0]);
                                        if (count($ppselected) == 4) {
                                            $options['itemname'] = htmlentities($ppselected[0], ENT_QUOTES, 'UTF-8');
                                            $options['itemnumber'] = htmlentities($ppselected[1], ENT_QUOTES, 'UTF-8');
                                            $options['amount'] = htmlentities($ppselected[2], ENT_QUOTES, 'UTF-8');
                                            $options['tax'] = htmlentities($ppselected[3], ENT_QUOTES, 'UTF-8');
                                        }
                                    }
                                    // compat end
                                    $html .= "<form name=\"ff_submitform\" action=\"" . $paypal . "/cgi-bin/webscr\" method=\"post\">";
                                    $html .= "<input type=\"hidden\" name=\"cmd\" value=\"_xclick\"/>";
                                    $html .= "<input type=\"hidden\" name=\"business\" value=\"" . $business . "\"/>";
                                    $html .= "<input type=\"hidden\" name=\"item_name\" value=\"" . $options['itemname'] . "\"/>";
                                    $html .= "<input type=\"hidden\" name=\"item_number\" value=\"" . $options['itemnumber'] . "\"/>";
                                    $html .= "<input type=\"hidden\" name=\"amount\" value=\"" . $options['amount'] . "\"/>";
                                    $html .= "<input type=\"hidden\" name=\"tax\" value=\"" . $options['tax'] . "\"/>";
                                    $html .= "<input type=\"hidden\" name=\"no_shipping\" value=\"1\"/>";
                                    $html .= "<input type=\"hidden\" name=\"no_note\" value=\"1\"/>";
                                    if ($options['useIpn']) {
                                        $html .= "<input type=\"hidden\" name=\"notify_url\" value=\"" . htmlentities(JURI::root() . "index.php?option=com_breezingforms&confirmPayPalIpn=true&raw=true&form_id=" . $this->form . "&record_id=" . $this->record_id) . "\"/>";
                                        if ($options['testaccount']) {
                                            $html .= "<input type=\"hidden\" name=\"test_ipn\" value=\"1\"/>";
                                        }
                                    } else {
                                        $html .= "<input type=\"hidden\" name=\"notify_url\" value=\"" . $returnurl . "\"/>";
                                    }
                                    $html .= "<input type=\"hidden\" name=\"return\" value=\"" . $returnurl . "\"/>";
                                    $html .= "<input type=\"hidden\" name=\"cancel_return\" value=\"" . $cancelurl . "\"/>";
                                    $html .= "<input type=\"hidden\" name=\"rm\" value=\"2\"/>";
                                    $html .= "<input type=\"hidden\" name=\"lc\" value=\"" . $options['locale'] . "\"/>";
                                    //$html .= "<input type=\"hidden\" name=\"pal\" value=\"D6MXR7SEX68LU\"/>";
                                    $html .= "<input type=\"hidden\" name=\"currency_code\" value=\"" . strtoupper($options['currencyCode']) . "\"/>";
                                    if (!$this->inline) {
                                        $html .= "</form></body></html>";
                                    }
                                    // TODO: let the user decide to use modal or simple alert
                                    if ($j15) {
                                        $html .= '<script type="text/javascript">' . nl() . indentc(1) . '<!--' . nl() . indentc(2) . '

										    SqueezeBox.initialize({});

										    SqueezeBox.loadModal = function(modalUrl,handler,x,y) {
										    		this.initialize();
										      		var options = $merge(options || {}, Json.evaluate("{handler: \'" + handler + "\', size: {x: " + x +", y: " + y + "}}"));
													this.setOptions(this.presets, options);
													this.assignOptions();
													this.setContent(handler,modalUrl);
										   	};

										    SqueezeBox.loadModal("' . JURI::root() . 'index.php?raw=true&option=com_breezingforms&showPayPalConnectMsg=true","iframe",300,100);

										 	

										' . nl() . indentc(1) . '// -->' . nl() . '</script>' . nl();
                                    }
                                    $html .= '<script type="text/javascript"><!--' . nl() . 'document.ff_submitform.submit();' . nl() . '//--></script>';
                                    echo $html;
                                    break;
                                }
                            }
                        }
                        break;
                    case 'Sofortueberweisung':
                        foreach ($areas as $area) {
                            foreach ($area['elements'] as $element) {
                                if ($element['internalType'] == 'bfSofortueberweisung') {
                                    $html = '';
                                    if (!$this->inline) {
                                        $html .= '<html><head></head><body>';
                                    }
                                    JHTML::_('behavior.modal');
                                    $options = $element['options'];
                                    $ppselect = JRequest::getVar('ff_nm_bfPaymentSelect', array());
                                    if (count($ppselect) != 0) {
                                        $ppselected = explode('|', $ppselect[0]);
                                        if (count($ppselected) == 4) {
                                            $options['reason_1'] = htmlentities($ppselected[0], ENT_QUOTES, 'UTF-8');
                                            $options['reason_2'] = htmlentities($ppselected[1], ENT_QUOTES, 'UTF-8');
                                            $options['amount'] = htmlentities($ppselected[2], ENT_QUOTES, 'UTF-8');
                                            if ($ppselected[3] != '' && intval($ppselected[3]) > 0) {
                                                $options['amount'] = '' . doubleval($options['amount']) + doubleval($ppselected[3]);
                                            }
                                        }
                                    }
                                    $options['amount'] = str_replace('.', ',', $options['amount']);
                                    $hash = '';
                                    if (isset($options['project_password']) && trim($options['project_password']) != '') {
                                        $data = array($options['user_id'], $options['project_id'], '', '', '', '', $options['amount'], $options['currency_id'], $options['reason_1'], $options['reason_2'], $this->form, $this->record_id, isset($options['mailback']) && $options['mailback'] ? implode('###', $this->mailbackRecipients) : '', '', '', '', $options['project_password']);
                                        $data_implode = implode('|', $data);
                                        $gen = sha1($data_implode);
                                        $hash = '<input type="hidden" name="hash" value="' . $gen . '" />';
                                    }
                                    $mailback = '';
                                    if (isset($options['mailback']) && $options['mailback']) {
                                        $mailback = '<input type="hidden" name="user_variable_2" value="' . implode('###', $this->mailbackRecipients) . '" />';
                                    }
                                    $html .= '
									<!-- sofortüberweisung.de -->
									<form method="post" name="ff_submitform" action="https://www.sofortueberweisung.de/payment/start">
									<input type="hidden" name="user_id" value="' . $options['user_id'] . '" />
									<input type="hidden" name="project_id" value="' . $options['project_id'] . '" />
									<input type="hidden" name="reason_1" value="' . $options['reason_1'] . '" />
									<input type="hidden" name="reason_2" value="' . $options['reason_2'] . '" />
									<input type="hidden" name="amount" value="' . $options['amount'] . '" />
									<input type="hidden" name="currency_id" value="' . $options['currency_id'] . '" />
									<input type="hidden" name="language_id" value="' . $options['language_id'] . '" />
									<input type="hidden" name="user_variable_0" value="' . $this->form . '" />
									<input type="hidden" name="user_variable_1" value="' . $this->record_id . '" />
									' . $mailback . '
									' . $hash . '
									</form>
									<!-- sofortüberweisung.de -->
									';
                                    if ($j15) {
                                        // TODO: let the user decide to use modal or simple alert
                                        $html .= '<script type="text/javascript">' . nl() . indentc(1) . '<!--' . nl() . indentc(2) . '

										    SqueezeBox.initialize({});

										    SqueezeBox.loadModal = function(modalUrl,handler,x,y) {
										    		this.initialize();
										      		var options = $merge(options || {}, Json.evaluate("{handler: \'" + handler + "\', size: {x: " + x +", y: " + y + "}}"));
													this.setOptions(this.presets, options);
													this.assignOptions();
													this.setContent(handler,modalUrl);
										   	};

										    SqueezeBox.loadModal("' . JURI::root() . 'index.php?raw=true&option=com_breezingforms&showPayPalConnectMsg=true","iframe",300,100);

										' . nl() . indentc(1) . '// -->' . nl() . '</script>' . nl();
                                    }
                                    $html .= '<script type="text/javascript"><!--' . nl() . 'document.ff_submitform.submit();' . nl() . '//--></script>';
                                    if (!$this->inline) {
                                        $html .= "</form></body></html>";
                                    }
                                    echo $html;
                                    break;
                                }
                            }
                        }
                        break;
                    default:
                        $paymentAction = false;
                }
            }
        }
        // CONTENTBUILDER
        if (JRequest::getVar('cb_controller', null) != 'edit' && $cbRecordId && is_array($cbResult) && isset($cbResult['data']) && isset($cbResult['data']['id']) && $cbResult['data']['id']) {
            if ($cbRecordId) {
                $return = JRequest::getVar('return', '');
                if ($return) {
                    $return = base64_decode($return);
                    if (JURI::isInternal($return)) {
                        JFactory::getApplication()->redirect($return, $msg);
                    }
                }
            }
            if ($cbResult['data']['force_login']) {
                jimport('joomla.version');
                $version = new JVersion();
                $is15 = true;
                if (version_compare($version->getShortVersion(), '1.6', '>=')) {
                    $is15 = false;
                }
                if (!JFactory::getUser()->get('id', 0)) {
                    if (!$is15) {
                        JFactory::getApplication()->redirect(JRoute::_('index.php?option=com_users&view=login&Itemid=' . JRequest::getInt('Itemid', 0), false));
                    } else {
                        JFactory::getApplication()->redirect(JRoute::_('index.php?option=com_user&view=login&Itemid=' . JRequest::getInt('Itemid', 0), false));
                    }
                } else {
                    if (!$is15) {
                        JFactory::getApplication()->redirect(JRoute::_('index.php?option=com_users&view=profile&Itemid=' . JRequest::getInt('Itemid', 0), false));
                    } else {
                        JFactory::getApplication()->redirect(JRoute::_('index.php?option=com_user&view=user&Itemid=' . JRequest::getInt('Itemid', 0), false));
                    }
                }
            } else {
                if (trim($cbResult['data']['force_url'])) {
                    JFactory::getApplication()->redirect(trim($cbResult['data']['force_url']));
                }
            }
            JFactory::getApplication()->redirect(JRoute::_('index.php?option=com_contentbuilder&controller=details&Itemid=' . JRequest::getInt('Itemid', 0) . '&backtolist=' . JRequest::getInt('backtolist', 0) . '&id=' . $cbResult['data']['id'] . '&record_id=' . $cbRecordId . '&limitstart=' . JRequest::getInt('limitstart', 0) . '&filter_order=' . JRequest::getCmd('filter_order'), false), BFText::_('COM_CONTENTBUILDER_SAVED'));
        }
        if (!$paymentAction) {
            if (!defined('VMBFCF_RUNNING')) {
                $ob = 0;
                while (ob_get_level() > 0 && $ob <= 32) {
                    ob_end_clean();
                    $ob++;
                }
                ob_start();
                echo '<!DOCTYPE html>
                    <html>
                    <head></head>
                    <body>';
            }
            if ($message == '') {
                $message = $this->message;
            } else {
                if ($this->message != '') {
                    $message .= ":" . nl() . $this->message;
                }
            }
            // if
            if (!$this->inline) {
                $url = $this->inframe ? $ff_mossite . '/index.php?format=html&tmpl=component' : ($this->runmode == _FF_RUNMODE_FRONTEND ? '' : 'index.php?format=html' . (JRequest::getCmd('tmpl', '') ? '&tmpl=' . JRequest::getCmd('tmpl', '') : ''));
                echo '<form name="ff_submitform" action="' . $url . '" method="post">' . nl();
            }
            // if
            switch ($this->runmode) {
                case _FF_RUNMODE_FRONTEND:
                    echo indentc(1) . '<input type="hidden" name="ff_form" value="' . htmlentities($this->form, ENT_QUOTES, 'UTF-8') . '"/>' . nl();
                    if ($this->target > 1) {
                        echo indentc(1) . '<input type="hidden" name="ff_target" value="' . htmlentities($this->target, ENT_QUOTES, 'UTF-8') . '"/>' . nl();
                    }
                    if ($this->inframe) {
                        echo indentc(1) . '<input type="hidden" name="ff_frame" value="1"/>' . nl();
                    }
                    if ($this->border) {
                        echo indentc(1) . '<input type="hidden" name="ff_border" value="1"/>' . nl();
                    }
                    if ($this->page != 1) {
                        indentc(1) . '<input type="hidden" name="ff_page" value="' . htmlentities($this->page, ENT_QUOTES, 'UTF-8') . '"/>' . nl();
                    }
                    if ($this->align != 1) {
                        echo indentc(1) . '<input type="hidden" name="ff_align" value="' . htmlentities($this->align, ENT_QUOTES, 'UTF-8') . '"/>' . nl();
                    }
                    if ($this->top != 0) {
                        echo indentc(1) . '<input type="hidden" name="ff_top" value="' . htmlentities($this->top, ENT_QUOTES, 'UTF-8') . '"/>' . nl();
                    }
                    reset($ff_otherparams);
                    while (list($prop, $val) = each($ff_otherparams)) {
                        echo indentc(1) . '<input type="hidden" name="' . htmlentities($prop, ENT_QUOTES, 'UTF-8') . '" value="' . htmlentities($val, ENT_QUOTES, 'UTF-8') . '"/>' . nl();
                    }
                    break;
                case _FF_RUNMODE_BACKEND:
                    echo indentc(1) . '<input type="hidden" name="option" value="com_breezingforms"/>' . nl() . indentc(1) . '<input type="hidden" name="act" value="run"/>' . nl() . indentc(1) . '<input type="hidden" name="ff_form" value="' . htmlentities($this->form, ENT_QUOTES, 'UTF-8') . '"/>' . nl() . indentc(1) . '<input type="hidden" name="ff_runmode" value="' . htmlentities($this->runmode, ENT_QUOTES, 'UTF-8') . '"/>' . nl();
                    if ($this->target > 1) {
                        echo indentc(1) . '<input type="hidden" name="ff_target" value="' . htmlentities($this->target, ENT_QUOTES, 'UTF-8') . '"/>' . nl();
                    }
                    if ($this->inframe) {
                        echo indentc(1) . '<input type="hidden" name="ff_frame" value="1"/>' . nl();
                    }
                    if ($this->border) {
                        echo indentc(1) . '<input type="hidden" name="ff_border" value="1"/>' . nl();
                    }
                    if ($this->page != 1) {
                        indentc(1) . '<input type="hidden" name="ff_page" value="' . htmlentities($this->page, ENT_QUOTES, 'UTF-8') . '"/>' . nl();
                    }
                    if ($this->align != 1) {
                        echo indentc(1) . '<input type="hidden" name="ff_align" value="' . htmlentities($this->align, ENT_QUOTES, 'UTF-8') . '"/>' . nl();
                    }
                    if ($this->top != 0) {
                        echo indentc(1) . '<input type="hidden" name="ff_top" value="' . htmlentities($this->top, ENT_QUOTES, 'UTF-8') . '"/>' . nl();
                    }
                    break;
                default:
                    // _FF_RUNMODE_PREVIEW:
                    if ($this->inframe) {
                        echo indentc(1) . '<input type="hidden" name="option" value="com_breezingforms"/>' . nl() . indentc(1) . '<input type="hidden" name="ff_frame" value="1"/>' . nl() . indentc(1) . '<input type="hidden" name="ff_form" value="' . htmlentities($this->form, ENT_QUOTES, 'UTF-8') . '"/>' . nl() . indentc(1) . '<input type="hidden" name="ff_runmode" value="' . htmlentities($this->runmode, ENT_QUOTES, 'UTF-8') . '"/>' . nl();
                        if ($this->page != 1) {
                            indentc(1) . '<input type="hidden" name="ff_page" value="' . htmlentities($this->page, ENT_QUOTES, 'UTF-8') . '"/>' . nl();
                        }
                    }
                    // if
            }
            // if
            echo indentc(1) . '<input type="hidden" name="ff_contentid" value="' . JRequest::getInt('ff_contentid', 0) . '"/>' . nl() . indentc(1) . '<input type="hidden" name="ff_applic" value="' . JRequest::getWord('ff_applic', '') . '"/>' . nl() . indentc(1) . '<input type="hidden" name="ff_module_id" value="' . JRequest::getInt('ff_module_id', 0) . '"/>' . nl() . indentc(1) . '<input type="hidden" name="ff_status" value="' . htmlentities($this->status, ENT_QUOTES, 'UTF-8') . '"/>' . nl() . indentc(1) . '<input type="hidden" name="ff_message" value="' . htmlentities(addcslashes($message, "..!@\\@..ÿ"), ENT_QUOTES, 'UTF-8') . '"/>' . nl() . indentc(1) . '<input type="hidden" name="ff_form_submitted" value="1"/>' . nl();
            if (JRequest::getVar('tmpl') == 'component') {
                echo indentc(1) . '<input type="hidden" name="tmpl" value="component"/>' . nl();
            }
            if (isset($_REQUEST['cb_form_id']) && isset($_REQUEST['cb_record_id'])) {
                echo indentc(1) . '<input type="hidden" name="cb_form_id" value="' . JRequest::getInt('cb_form_id', 0) . '"/>' . nl();
                echo indentc(1) . '<input type="hidden" name="cb_record_id" value="' . JRequest::getInt('cb_record_id', 0) . '"/>' . nl();
                echo indentc(1) . '<input type="hidden" name="return" value="' . htmlentities(JRequest::getVar('return', ''), ENT_QUOTES, 'UTF-8') . '"/>' . nl();
            }
            // TODO: turn off tracing in the options
            if ($this->traceMode & _FF_TRACEMODE_DIRECT) {
                $this->dumpTrace();
                ob_end_flush();
                echo '</pre>';
            } else {
                ob_end_flush();
                $this->dumpTrace();
            }
            // if
            restore_error_handler();
            if (!$this->inline) {
                echo '</form>' . nl() . '<script type="text/javascript">' . nl() . indentc(1) . '<!--' . nl() . indentc(2) . 'document.ff_submitform.submit();' . nl() . indentc(1) . '// -->' . nl() . '</script>' . nl();
            }
            // if
            if (!defined('VMBFCF_RUNNING')) {
                $c = ob_get_contents();
                ob_end_clean();
                echo $c;
                echo '</body>
                      </html>';
            }
        }
        unset($_SESSION['ff_editable_overridePlg' . JRequest::getInt('ff_contentid', 0) . $this->form_id]);
        unset($_SESSION['ff_editablePlg' . JRequest::getInt('ff_contentid', 0) . $this->form_id]);
        JFactory::getSession()->set('ff_editableMod' . JRequest::getInt('ff_module_id', 0) . $this->form_id, 0);
        JFactory::getSession()->set('ff_editable_overrideMod' . JRequest::getInt('ff_module_id', 0) . $this->form_id, 0);
        if (!defined('VMBFCF_RUNNING')) {
            exit;
        }
    }
 /**
  * @test
  * @link https://github.com/jakajancar/DropboxUploader/issues/18
  * @depends testLogin
  * @param DropboxUploader $uploader
  * @throws Exception
  */
 public function testUploadFileWithQuote(DropboxUploader $uploader)
 {
     $path = __DIR__ . '/../fixtures/file\'with-quote.ext';
     $this->addToAssertionCount(1);
     $uploader->upload($path, 'test/integration');
 }
Exemple #7
0
     if ($_FILES['file']['error'] !== UPLOAD_ERR_OK) {
         throw new Exception('File was not successfully uploaded from your computer.');
     }
     $tmpDir = uniqid('/tmp/');
     if (!mkdir($tmpDir)) {
         throw new Exception('Cannot create temporary directory!');
     }
     if ($_FILES['file']['name'] === "") {
         throw new Exception('File name not supplied by the browser.');
     }
     $tmpFile = $tmpDir . '/' . str_replace("/", '_', $_FILES['file']['name']);
     if (!move_uploaded_file($_FILES['file']['tmp_name'], $tmpFile)) {
         throw new Exception('Cannot rename uploaded file!');
     }
     // Upload
     $uploader = new DropboxUploader('*****@*****.**', 'initpass');
     $uploader->upload($tmpFile, 'resumes');
     $msg = "That's right, a new file was uploaded called " . $_FILES['file']['name'];
     $msg .= "\n\n It came from: " . $_POST['email'];
     $msg .= "\n\n And here's what they had to say about it: " . $_POST['comments'];
     mail("*****@*****.**", "New File uploaded at Umbaugh.com", $msg);
     $msg = '<span style="color: green">File successfully uploaded!</span>';
 } catch (Exception $e) {
     $msg = '<span style="color: red">Error: ' . htmlspecialchars($e->getMessage()) . '</span>';
 }
 // Clean up
 if (isset($tmpFile) && file_exists($tmpFile)) {
     unlink($tmpFile);
 }
 if (isset($tmpDir) && file_exists($tmpDir)) {
     rmdir($tmpDir);
             $z = new recurseZip();
             $fullpath = $z->compress($src, $dst);
             $source = basename($fullpath);
             if ($status != 'error') {
                 $status = 'success';
                 $message = 'The file has been sent to your Dropbox account.';
             }
             // Send to Dropbox
             $dropbox_email = escapeshellcmd(get_misc_data('dropbox_backup_email'));
             // Dropbox email address
             //$dropbox_pass=escapeshellcmd(get_misc_data('dropbox_backup_pass'));   	// Dropbox password
             //$dropbox_pass_save=escapeshellcmd(get_misc_data('dropbox_backup_save'));// Save password?
             $dropbox_dir = escapeshellcmd(get_misc_data('dropbox_backup_dir'));
             // DropBox directory (optional) - Folder on the Dropbox
             include 'DropboxUploader.php';
             $uploader = new DropboxUploader($dropbox_email, $dropbox_pass);
             // $uploader->setCaCertificateFile("modules/dropbox_backup/ca-bundle.crt");
             $uploader->upload($dst . '/' . $source, $dropbox_dir);
             // Delete the file
             $delete_me = $dst . '/' . $source;
             chmod($delete_me, 0666);
             unlink($delete_me);
         } else {
             $status = 'error';
             $message = '<h3>No backup files were found!</h3><p>Please <a href="admin/admin_backup.php">make a backup from this page</a> before trying to upload to Dropbox.</p>';
         }
     }
 }
 $main_smarty->assign('status', $status);
 $main_smarty->assign('message', $message);
 $main_smarty->assign('error', $error);
}
// initialize an iterator
// pass it the directory to be processed
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator("../{$folder_name}/"));
// iterate over the directory
// add each file found to the archive
// foreach ($iterator as $key=>$value) {
// if( strstr(realpath($key), "stark") == FALSE) {
// $zip->addFile(realpath($key), $key) or die ("ERROR: Could not add file: $key");
// }
// }
// close and save archive
$zip->close();
//$createBackup = "mysqldump -h ".$dbHost." -u ".$user." --password='******' ".$dbName." > ".$sqlFile;
//echo $createBackup;
//$createZip = "tar cvzf $backupFile $sqlFile";
//echo $createZip;
//exec($createBackup);
//exec($createZip);
try {
    // Upload database backup to Dropbox
    $uploader = new DropboxUploader($dropbox_user, $dropbox_password);
    @$uploader->upload('backup/backupdb' . date('Y-m-d') . '.sql', $dropbox_dest, 'backup/backupdb' . date('Y-m-d') . '.sql');
} catch (Exception $e) {
    die($e->getMessage());
}
@($backupfile = 'backup/backupdb' . date('Y-m-d') . '.sql');
echo "<script> window.location='admin/dashboard/admin_dashboard';alert('Successfully Backup Database');</script>";
// Delete the temporary files
//unlink($sqlFile);
unlink($backupfile);
        $flag = basename($source) . '/';
        //$zip->addEmptyDir(basename($source) . '/');
    }
    if (is_dir($source) === true) {
        $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST);
        foreach ($files as $file) {
            $file = str_replace('\\', '/', realpath($file));
            if (is_dir($file) === true) {
                $zip->addEmptyDir(str_replace($source . '/', '', $flag . $file . '/'));
            } else {
                if (is_file($file) === true) {
                    $zip->addFromString(str_replace($source . '/', '', $flag . $file), file_get_contents($file));
                }
            }
        }
    } else {
        if (is_file($source) === true) {
            $zip->addFromString($flag . basename($source), file_get_contents($source));
        }
    }
    //echo "Successfully Ziped Folder";
    return $zip->close();
}
try {
    // Upload database backup to Dropbox
    $uploader = new DropboxUploader($dropbox_user, $dropbox_password);
    @$uploader->upload($dest, $dropbox_dest, $dest);
} catch (Exception $e) {
    die($e->getMessage());
}
echo "<script> window.location='admin/dashboard/admin_dashboard';alert('Successfully Backup Database');</script>";