/**
  * Try to login with Facebook
  * @param array
  * @return boolean
  */
 public function login($arrProfile = null)
 {
     if (parent::login() === true) {
         return true;
     }
     // Return if the user is not found
     if (!$arrProfile || $this->findBy('fblogin', $arrProfile['id']) == false) {
         \Message::addError($GLOBALS['TL_LANG']['ERR']['invalidLogin']);
         return false;
     }
     // Return if the user ID does not match
     if (!$this->fblogin || $this->fblogin != $arrProfile['id']) {
         \Message::addError($GLOBALS['TL_LANG']['ERR']['invalidLogin']);
         return false;
     }
     $this->setUserFromDb();
     // Update the record
     $this->lastLogin = $this->currentLogin;
     $this->currentLogin = time();
     $this->loginCount = $GLOBALS['TL_CONFIG']['loginCount'];
     $this->save();
     // Generate the session
     $this->generateSession();
     $this->log('User "' . $this->username . '" has logged in', get_class($this) . ' login()', TL_ACCESS);
     // HOOK: post login callback
     if (isset($GLOBALS['TL_HOOKS']['postLogin']) && is_array($GLOBALS['TL_HOOKS']['postLogin'])) {
         foreach ($GLOBALS['TL_HOOKS']['postLogin'] as $callback) {
             $this->import($callback[0], 'objLogin', true);
             $this->objLogin->{$callback}[1]($this);
         }
     }
     return true;
 }
Exemplo n.º 2
0
 protected function initializeDefaultValues()
 {
     // Set default session data
     $arrSession = \Session::getInstance()->get('iso_reports');
     if ($arrSession[$this->name]['period'] == '') {
         $arrSession[$this->name]['period'] = 'month';
     }
     if ($arrSession[$this->name]['columns'] == '') {
         $arrSession[$this->name]['columns'] = '6';
     }
     if ($arrSession[$this->name]['from'] == '') {
         $arrSession[$this->name]['from'] = '';
     } elseif (!is_numeric($arrSession[$this->name]['from'])) {
         // Convert date formats into timestamps
         try {
             $objDate = new \Date($arrSession[$this->name]['from'], $GLOBALS['TL_CONFIG']['dateFormat']);
             $arrSession[$this->name]['from'] = $objDate->tstamp;
         } catch (\OutOfBoundsException $e) {
             \Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['date'], $GLOBALS['TL_CONFIG']['dateFormat']));
             $arrSession[$this->name]['from'] = '';
         }
     }
     if (!isset($arrSession[$this->name]['iso_status'])) {
         $objStatus = \Database::getInstance()->query("SELECT id FROM " . \Isotope\Model\OrderStatus::getTable() . " WHERE paid=1 ORDER BY sorting");
         $arrSession[$this->name]['iso_status'] = $objStatus->id;
     }
     \Session::getInstance()->set('iso_reports', $arrSession);
 }
Exemplo n.º 3
0
 /**
  * Update the robots.txt when the page was stored.
  */
 public function updateRobotsTxt(DataContainer $dc)
 {
     if (Hofff\Contao\RobotsTxtEditor\RobotsTxtEditor::generateRobotsTxts()) {
         \Message::addConfirmation($GLOBALS['TL_LANG']['MSC']['robotstxt_updated']);
     } else {
         \Message::addError($GLOBALS['TL_LANG']['ERR']['robotstxt_not_updated']);
     }
 }
Exemplo n.º 4
0
 public function getConfirm($code)
 {
     if ($this->auth->confirmByCode($code)) {
         \Message::addSuccess(trans('account.alerts.confirmation'));
     } else {
         \Message::addError(trans('account.alerts.wrong_confirmation'));
     }
     return redirect('/customer/login');
 }
Exemplo n.º 5
0
 /**
  * Run the controller and parse the password template
  */
 public function run()
 {
     /** @var \BackendTemplate|object $objTemplate */
     $objTemplate = new \BackendTemplate('be_password');
     if (\Input::post('FORM_SUBMIT') == 'tl_password') {
         $pw = \Input::postUnsafeRaw('password');
         $cnf = \Input::postUnsafeRaw('confirm');
         // The passwords do not match
         if ($pw != $cnf) {
             \Message::addError($GLOBALS['TL_LANG']['ERR']['passwordMatch']);
         } elseif (utf8_strlen($pw) < \Config::get('minPasswordLength')) {
             \Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['passwordLength'], \Config::get('minPasswordLength')));
         } elseif ($pw == $this->User->username) {
             \Message::addError($GLOBALS['TL_LANG']['ERR']['passwordName']);
         } else {
             // Make sure the password has been changed
             if (\Encryption::verify($pw, $this->User->password)) {
                 \Message::addError($GLOBALS['TL_LANG']['MSC']['pw_change']);
             } else {
                 $this->loadDataContainer('tl_user');
                 // Trigger the save_callback
                 if (is_array($GLOBALS['TL_DCA']['tl_user']['fields']['password']['save_callback'])) {
                     foreach ($GLOBALS['TL_DCA']['tl_user']['fields']['password']['save_callback'] as $callback) {
                         if (is_array($callback)) {
                             $this->import($callback[0]);
                             $pw = $this->{$callback[0]}->{$callback[1]}($pw);
                         } elseif (is_callable($callback)) {
                             $pw = $callback($pw);
                         }
                     }
                 }
                 $objUser = \UserModel::findByPk($this->User->id);
                 $objUser->pwChange = '';
                 $objUser->password = \Encryption::hash($pw);
                 $objUser->save();
                 \Message::addConfirmation($GLOBALS['TL_LANG']['MSC']['pw_changed']);
                 $this->redirect('' . $GLOBALS['TL_CONFIG']['backendPath'] . '/main.php');
             }
         }
         $this->reload();
     }
     $objTemplate->theme = \Backend::getTheme();
     $objTemplate->messages = \Message::generate();
     $objTemplate->base = \Environment::get('base');
     $objTemplate->language = $GLOBALS['TL_LANGUAGE'];
     $objTemplate->title = specialchars($GLOBALS['TL_LANG']['MSC']['pw_new']);
     $objTemplate->charset = \Config::get('characterSet');
     $objTemplate->action = ampersand(\Environment::get('request'));
     $objTemplate->headline = $GLOBALS['TL_LANG']['MSC']['pw_change'];
     $objTemplate->submitButton = specialchars($GLOBALS['TL_LANG']['MSC']['continue']);
     $objTemplate->password = $GLOBALS['TL_LANG']['MSC']['password'][0];
     $objTemplate->confirm = $GLOBALS['TL_LANG']['MSC']['confirm'][0];
     $objTemplate->output();
 }
Exemplo n.º 6
0
 /**
  * Export data
  *
  * @access		public
  * @param		string
  * @return		void
  */
 public static function run($dc = null, $strName = 'formsubmissions', $blnHeaders = true)
 {
     if (!in_array('!composer', \ModuleLoader::getActive())) {
         \Message::addError($GLOBALS['TL_LANG']['ERR']['exportExcelNoComposer']);
         \System::redirect(str_ireplace('&key=exportExcel', '', \Environment::get('request')));
         return;
     }
     if (!is_file(TL_ROOT . '/composer/vendor/phpoffice/phpexcel/Classes/PHPExcel.php')) {
         \Message::addError($GLOBALS['TL_LANG']['ERR']['exportExcelNoPHPExcel']);
         \System::redirect(str_ireplace('&key=exportExcel', '', \Environment::get('request')));
         return;
     }
     parent::run($dc, $strName, $blnHeaders);
 }
 /**
  * Import the default robots.txt
  * @param \DataContainer
  */
 public function importRobotsTxt(\DataContainer $dc)
 {
     if (\Input::get('key') != 'importRobotsTxt') {
         return '';
     }
     if (!file_exists(TL_ROOT . "/" . FILE_ROBOTS_TXT_DEFAULT)) {
         \Message::addError($GLOBALS['TL_LANG']['ERR']['no_robotstxt_default']);
         $this->redirect(str_replace('&key=importRobotsTxt', '', \Environment::get('request')));
     }
     $objVersions = new \Versions($dc->table, \Input::get('id'));
     $objVersions->create();
     $strFileContent = file_get_contents(TL_ROOT . "/" . FILE_ROBOTS_TXT_DEFAULT);
     \Database::getInstance()->prepare("UPDATE " . $dc->table . " SET robotsTxtContent=? WHERE id=?")->execute($strFileContent, \Input::get('id'));
     $this->redirect(str_replace('&key=importRobotsTxt', '', \Environment::get('request')));
 }
 public static function exportBe($objDc)
 {
     $strGlobalOperationKey = \Input::get('key');
     $strTable = \Input::get('table') ?: $objDc->table;
     if (!$strGlobalOperationKey || !$strTable) {
         return;
     }
     if (($objConfig = ExporterModel::findByKeyAndTable($strGlobalOperationKey, $strTable)) === null) {
         if (empty($_SESSION['TL_ERROR'])) {
             \Message::addError($GLOBALS['TL_LANG']['MSC']['exporter']['noConfigFound']);
             \Controller::redirect($_SERVER['HTTP_REFERER']);
         }
     } else {
         static::export($objConfig, \Input::get('id'));
     }
 }
Exemplo n.º 9
0
 /**
  * Run the controller and parse the password template
  */
 public function run()
 {
     $this->Template = new BackendTemplate('be_password');
     if (Input::post('FORM_SUBMIT') == 'tl_password') {
         $pw = Input::post('password');
         $cnf = Input::post('confirm');
         // Do not allow special characters
         if (preg_match('/[#\\(\\)\\/<=>]/', html_entity_decode(Input::post('password')))) {
             Message::addError($GLOBALS['TL_LANG']['ERR']['extnd']);
         } elseif ($pw != $cnf) {
             Message::addError($GLOBALS['TL_LANG']['ERR']['passwordMatch']);
         } elseif (utf8_strlen($pw) < $GLOBALS['TL_CONFIG']['minPasswordLength']) {
             Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['passwordLength'], $GLOBALS['TL_CONFIG']['minPasswordLength']));
         } elseif ($pw == $this->User->username) {
             Message::addError($GLOBALS['TL_LANG']['ERR']['passwordName']);
         } else {
             list(, $strSalt) = explode(':', $this->User->password);
             $strPassword = sha1($strSalt . $pw);
             // Make sure the password has been changed
             if ($strPassword . ':' . $strSalt == $this->User->password) {
                 Message::addError($GLOBALS['TL_LANG']['MSC']['pw_change']);
             } else {
                 $strSalt = substr(md5(uniqid(mt_rand(), true)), 0, 23);
                 $strPassword = sha1($strSalt . $pw);
                 $objUser = UserModel::findByPk($this->User->id);
                 $objUser->pwChange = '';
                 $objUser->password = $strPassword . ':' . $strSalt;
                 $objUser->save();
                 Message::addConfirmation($GLOBALS['TL_LANG']['MSC']['pw_changed']);
                 $this->redirect('contao/main.php');
             }
         }
         $this->reload();
     }
     $this->Template->theme = $this->getTheme();
     $this->Template->messages = Message::generate();
     $this->Template->base = Environment::get('base');
     $this->Template->language = $GLOBALS['TL_LANGUAGE'];
     $this->Template->title = specialchars($GLOBALS['TL_LANG']['MSC']['pw_new']);
     $this->Template->charset = $GLOBALS['TL_CONFIG']['characterSet'];
     $this->Template->action = ampersand(Environment::get('request'));
     $this->Template->headline = $GLOBALS['TL_LANG']['MSC']['pw_change'];
     $this->Template->submitButton = specialchars($GLOBALS['TL_LANG']['MSC']['continue']);
     $this->Template->password = $GLOBALS['TL_LANG']['MSC']['password'][0];
     $this->Template->confirm = $GLOBALS['TL_LANG']['MSC']['confirm'][0];
     $this->Template->output();
 }
 /**
  * Check the FTP connection
  * @param   \DataContainer
  */
 public function checkFileServerConnection(\DataContainer $dc)
 {
     if ($dc->activeRecord->type != 'ftp' || $dc->activeRecord->file_connection != 'ftp') {
         return;
     }
     $strClass = $GLOBALS['NOTIFICATION_CENTER']['FTP'][$dc->activeRecord->ftp_type];
     if (!class_exists($strClass)) {
         \Message::addError($GLOBALS['TL_LANG']['tl_nc_gateway']['ftp_error_class']);
         return;
     }
     $objHandler = new $strClass();
     try {
         $objHandler->connect($dc->activeRecord);
     } catch (\Exception $e) {
         \Message::addError(sprintf($GLOBALS['TL_LANG']['tl_nc_gateway']['ftp_error_connect'], $e->getMessage()));
         return;
     }
     \Message::addConfirmation($GLOBALS['TL_LANG']['tl_nc_gateway']['ftp_confirm']);
 }
Exemplo n.º 11
0
 /**
  * Store Login Module ID in Session, required by LdapAuth (Module config)
  * @return string
  */
 public function generate()
 {
     // Login
     if (\Input::post('FORM_SUBMIT') == 'tl_login') {
         if (\Input::post('username', true) && \Input::post('password', true)) {
             $objMember = \MemberModel::findBy('username', \Input::post('username', true));
             if ($objMember !== null) {
                 // always reset the password to a random value, otherwise checkCredentialsHook will never be triggered
                 LdapMember::resetPassword($objMember, \Input::post('username', true));
             }
         }
         // validate email
         if ($GLOBALS['TL_CONFIG']['ldap_uid'] == 'mail' && !\Validator::isEmail(\Input::post('username', true))) {
             \Message::addError($GLOBALS['TL_LANG']['ERR']['email']);
             $this->reload();
         }
     }
     $strParent = parent::generate();
     return $strParent;
 }
Exemplo n.º 12
0
 /**
  * Run the controller and parse the password template
  */
 public function run()
 {
     $this->Template = new BackendTemplate('be_password');
     if (Input::post('FORM_SUBMIT') == 'tl_password') {
         $pw = Input::post('password', true);
         $cnf = Input::post('confirm', true);
         // The passwords do not match
         if ($pw != $cnf) {
             Message::addError($GLOBALS['TL_LANG']['ERR']['passwordMatch']);
         } elseif (utf8_strlen($pw) < $GLOBALS['TL_CONFIG']['minPasswordLength']) {
             Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['passwordLength'], $GLOBALS['TL_CONFIG']['minPasswordLength']));
         } elseif ($pw == $this->User->username) {
             Message::addError($GLOBALS['TL_LANG']['ERR']['passwordName']);
         } else {
             // Make sure the password has been changed
             if (crypt($pw, $this->User->password) == $this->User->password) {
                 Message::addError($GLOBALS['TL_LANG']['MSC']['pw_change']);
             } else {
                 $objUser = UserModel::findByPk($this->User->id);
                 $objUser->pwChange = '';
                 $objUser->password = Encryption::hash($pw);
                 $objUser->save();
                 Message::addConfirmation($GLOBALS['TL_LANG']['MSC']['pw_changed']);
                 $this->redirect('contao/main.php');
             }
         }
         $this->reload();
     }
     $this->Template->theme = $this->getTheme();
     $this->Template->messages = Message::generate();
     $this->Template->base = Environment::get('base');
     $this->Template->language = $GLOBALS['TL_LANGUAGE'];
     $this->Template->title = specialchars($GLOBALS['TL_LANG']['MSC']['pw_new']);
     $this->Template->charset = $GLOBALS['TL_CONFIG']['characterSet'];
     $this->Template->action = ampersand(Environment::get('request'));
     $this->Template->headline = $GLOBALS['TL_LANG']['MSC']['pw_change'];
     $this->Template->submitButton = specialchars($GLOBALS['TL_LANG']['MSC']['continue']);
     $this->Template->password = $GLOBALS['TL_LANG']['MSC']['password'][0];
     $this->Template->confirm = $GLOBALS['TL_LANG']['MSC']['confirm'][0];
     $this->Template->output();
 }
Exemplo n.º 13
0
 public static function authenticateLdapMember($strUsername, $strPassword)
 {
     $objLdapUser = LdapMemberModel::findLdapMember($strUsername);
     if ($objLdapUser) {
         if (!@ldap_bind(Ldap::getConnection(), $objLdapUser->dn, $strPassword)) {
             $errno = ldap_errno(Ldap::getConnection());
             switch ($errno) {
                 case static::LDAP_INVALID_CREDENTIALS:
                     return false;
             }
             return false;
         }
         // ldap account requires an valid email and uid
         if ($objLdapUser->uid['count'] == 0 || $objLdapUser->mail['count'] == 0) {
             \Message::addError($GLOBALS['TL_LANG']['MSC']['ldap']['emailUidMissing']);
             return false;
         }
         return true;
     } else {
         return false;
     }
 }
 public function importExt()
 {
     $this->loadLanguageFile("tl_calendar_events");
     $this->Template = new BackendTemplate('be_importExt_calendar');
     $this->Template->headline = 'Test';
     $this->Template->message = \Message::generate();
     $this->Template->event_type = $this->getEventTypeWidget();
     $this->Template->hrefBack = ampersand(str_replace('&key=import', '', \Environment::get('request')));
     $this->Template->goBack = $GLOBALS['TL_LANG']['MSC']['goBack'];
     $this->Template->headline = $GLOBALS['TL_LANG']['MSC']['import_calendar'][0];
     $this->Template->request = ampersand(\Environment::get('request'), ENCODE_AMPERSANDS);
     $this->Template->submit = specialchars($GLOBALS['TL_LANG']['tl_calendar_events']['importExt'][0]);
     if (\Input::post('FORM_SUBMIT') == 'tl_importExt_calendar') {
         if (empty(\Input::post('event_type'))) {
             \Message::addError($GLOBALS['TL_LANG']['ERR']['all_fields']);
             $this->reload();
         } else {
             $this->Session->set('event_type', \Input::post('event_type'));
             $this->redirect(str_replace('&key=importExt', '&key=import', \Environment::get('request')));
         }
     }
     return $this->Template->parse();
 }
 public static function export($objDc)
 {
     $strExportType = \Input::get('exportType') ?: 'list';
     $strGlobalOperationKey = \Input::get('key');
     $intId = \Input::get('id') ?: '';
     $strTable = \Input::get('table') ?: $objDc->table;
     if (!$strGlobalOperationKey || !$strTable) {
         return;
     }
     if (($objConfig = ExporterModel::findByKeyAndTable($strGlobalOperationKey, $strTable)) === null) {
         if (empty($_SESSION['TL_ERROR'])) {
             \Message::addError($GLOBALS['TL_LANG']['MSC']['exporter']['noConfigFound']);
             \Controller::redirect($_SERVER['HTTP_REFERER']);
         }
     } else {
         $objExporter = null;
         switch ($objConfig->fileType) {
             case EXPORTER_FILE_TYPE_CSV:
                 $objExporter = new CsvExporter($objConfig);
                 break;
             case EXPORTER_FILE_TYPE_MEDIA:
                 $objExporter = new MediaExporter($objConfig);
                 break;
             case EXPORTER_FILE_TYPE_PDF:
                 $objExporter = new PdfExporter($objConfig);
                 break;
             case EXPORTER_FILE_TYPE_XLS:
                 $objExporter = new XlsExporter($objConfig);
                 break;
         }
         if ($objExporter) {
             $objExporter->export($strExportType, $intId);
         }
         die;
     }
 }
Exemplo n.º 16
0
 /**
  * Return the "newsletter" button
  * @param array
  * @param string
  * @param string
  * @param string
  * @param string
  * @param string
  * @return string
  */
 public function newsletterIcon($row, $href, $label, $title, $icon, $attributes)
 {
     $objArchive = \NewsArchiveModel::findByPk($row['pid']);
     if (!$objArchive->newsletter || !$objArchive->newsletter_channel || !$objArchive->nc_notification) {
         return '';
     }
     // Toggle the record
     if (Input::get('newsletter')) {
         if ($this->sendNewsMessage(Input::get('newsletter'))) {
             Message::addConfirmation($GLOBALS['TL_LANG']['tl_news']['message_news_newsletter_confirm']);
         } else {
             Message::addError($GLOBALS['TL_LANG']['tl_news']['message_news_newsletter_error']);
         }
         $this->redirect($this->getReferer());
     }
     // Return just an image if newsletter was sent
     if ($row['newsletter']) {
         return Image::getHtml(str_replace('.png', '_.png', $icon), $label);
     }
     // Add the confirmation popup
     $intRecipients = \NewsletterRecipientsModel::countBy(array("pid=? AND active=1"), $objArchive->newsletter_channel);
     $attributes = 'onclick="if(!confirm(\'' . sprintf($GLOBALS['TL_LANG']['tl_news']['sendNewsletterConfirm'], $intRecipients) . '\'))return false;Backend.getScrollOffset()"';
     return '<a href="' . $this->addToUrl($href . '&newsletter=' . $row['id']) . '" title="' . specialchars($title) . '"' . $attributes . '>' . Image::getHtml($icon, $label) . '</a> ';
 }
Exemplo n.º 17
0
    /**
     * Auto-generate a form to edit the local configuration file
     *
     * @return string
     */
    public function edit()
    {
        $return = '';
        $ajaxId = null;
        if (\Environment::get('isAjaxRequest')) {
            $ajaxId = func_get_arg(1);
        }
        // Build an array from boxes and rows
        $this->strPalette = $this->getPalette();
        $boxes = trimsplit(';', $this->strPalette);
        $legends = array();
        if (!empty($boxes)) {
            foreach ($boxes as $k => $v) {
                $boxes[$k] = trimsplit(',', $v);
                foreach ($boxes[$k] as $kk => $vv) {
                    if (preg_match('/^\\[.*\\]$/', $vv)) {
                        continue;
                    }
                    if (preg_match('/^\\{.*\\}$/', $vv)) {
                        $legends[$k] = substr($vv, 1, -1);
                        unset($boxes[$k][$kk]);
                    } elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$vv]['exclude'] || !is_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$vv])) {
                        unset($boxes[$k][$kk]);
                    }
                }
                // Unset a box if it does not contain any fields
                if (empty($boxes[$k])) {
                    unset($boxes[$k]);
                }
            }
            // Render boxes
            $class = 'tl_tbox';
            $fs = $this->Session->get('fieldset_states');
            $blnIsFirst = true;
            foreach ($boxes as $k => $v) {
                $strAjax = '';
                $blnAjax = false;
                $key = '';
                $cls = '';
                $legend = '';
                if (isset($legends[$k])) {
                    list($key, $cls) = explode(':', $legends[$k]);
                    $legend = "\n" . '<legend onclick="AjaxRequest.toggleFieldset(this, \'' . $key . '\', \'' . $this->strTable . '\')">' . (isset($GLOBALS['TL_LANG'][$this->strTable][$key]) ? $GLOBALS['TL_LANG'][$this->strTable][$key] : $key) . '</legend>';
                }
                if (isset($fs[$this->strTable][$key])) {
                    $class .= $fs[$this->strTable][$key] ? '' : ' collapsed';
                } else {
                    $class .= $cls && $legend ? ' ' . $cls : '';
                }
                $return .= "\n\n" . '<fieldset' . ($key ? ' id="pal_' . $key . '"' : '') . ' class="' . $class . ($legend ? '' : ' nolegend') . '">' . $legend;
                // Build rows of the current box
                foreach ($v as $vv) {
                    if ($vv == '[EOF]') {
                        if ($blnAjax && \Environment::get('isAjaxRequest')) {
                            return $strAjax . '<input type="hidden" name="FORM_FIELDS[]" value="' . specialchars($this->strPalette) . '">';
                        }
                        $blnAjax = false;
                        $return .= "\n  " . '</div>';
                        continue;
                    }
                    if (preg_match('/^\\[.*\\]$/', $vv)) {
                        $thisId = 'sub_' . substr($vv, 1, -1);
                        $blnAjax = $ajaxId == $thisId && \Environment::get('isAjaxRequest') ? true : false;
                        $return .= "\n  " . '<div id="' . $thisId . '">';
                        continue;
                    }
                    $this->strField = $vv;
                    $this->strInputName = $vv;
                    $this->varValue = \Config::get($this->strField);
                    // Handle entities
                    if ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField]['inputType'] == 'text' || $GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField]['inputType'] == 'textarea') {
                        if ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField]['eval']['multiple']) {
                            $this->varValue = deserialize($this->varValue);
                        }
                        if (!is_array($this->varValue)) {
                            $this->varValue = htmlspecialchars($this->varValue);
                        } else {
                            foreach ($this->varValue as $k => $v) {
                                $this->varValue[$k] = htmlspecialchars($v);
                            }
                        }
                    }
                    // Autofocus the first field
                    if ($blnIsFirst && $GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField]['inputType'] == 'text') {
                        $GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField]['eval']['autofocus'] = 'autofocus';
                        $blnIsFirst = false;
                    }
                    // Call load_callback
                    if (is_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField]['load_callback'])) {
                        foreach ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField]['load_callback'] as $callback) {
                            if (is_array($callback)) {
                                $this->import($callback[0]);
                                $this->varValue = $this->{$callback[0]}->{$callback[1]}($this->varValue, $this);
                            } elseif (is_callable($callback)) {
                                $this->varValue = $callback($this->varValue, $this);
                            }
                        }
                    }
                    // Build row
                    $blnAjax ? $strAjax .= $this->row() : ($return .= $this->row());
                }
                $class = 'tl_box';
                $return .= "\n" . '</fieldset>';
            }
        }
        $this->import('Files');
        // Check whether the target file is writeable
        if (!$this->Files->is_writeable('system/config/localconfig.php')) {
            \Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['notWriteable'], 'system/config/localconfig.php'));
        }
        // Submit buttons
        $arrButtons = array();
        $arrButtons['save'] = '<input type="submit" name="save" id="save" class="tl_submit" accesskey="s" value="' . specialchars($GLOBALS['TL_LANG']['MSC']['save']) . '">';
        $arrButtons['saveNclose'] = '<input type="submit" name="saveNclose" id="saveNclose" class="tl_submit" accesskey="c" value="' . specialchars($GLOBALS['TL_LANG']['MSC']['saveNclose']) . '">';
        // Call the buttons_callback (see #4691)
        if (is_array($GLOBALS['TL_DCA'][$this->strTable]['edit']['buttons_callback'])) {
            foreach ($GLOBALS['TL_DCA'][$this->strTable]['edit']['buttons_callback'] as $callback) {
                if (is_array($callback)) {
                    $this->import($callback[0]);
                    $arrButtons = $this->{$callback[0]}->{$callback[1]}($arrButtons, $this);
                } elseif (is_callable($callback)) {
                    $arrButtons = $callback($arrButtons, $this);
                }
            }
        }
        // Add the buttons and end the form
        $return .= '
</div>

<div class="tl_formbody_submit">

<div class="tl_submit_container">
  ' . implode(' ', $arrButtons) . '
</div>

</div>
</form>

<script>
  window.addEvent(\'domready\', function() {
    Theme.focusInput("' . $this->strTable . '");
  });
</script>';
        // Begin the form (-> DO NOT CHANGE THIS ORDER -> this way the onsubmit attribute of the form can be changed by a field)
        $return = '
<div id="tl_buttons">
<a href="' . $this->getReferer(true) . '" class="header_back" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['backBTTitle']) . '" accesskey="b" onclick="Backend.getScrollOffset()">' . $GLOBALS['TL_LANG']['MSC']['backBT'] . '</a>
</div>
' . \Message::generate() . '
<form action="' . ampersand(\Environment::get('request'), true) . '" id="' . $this->strTable . '" class="tl_form" method="post"' . (!empty($this->onsubmit) ? ' onsubmit="' . implode(' ', $this->onsubmit) . '"' : '') . '>

<div class="tl_formbody_edit">
<input type="hidden" name="FORM_SUBMIT" value="' . specialchars($this->strTable) . '">
<input type="hidden" name="REQUEST_TOKEN" value="' . REQUEST_TOKEN . '">
<input type="hidden" name="FORM_FIELDS[]" value="' . specialchars($this->strPalette) . '">' . ($this->noReload ? '

<p class="tl_error">' . $GLOBALS['TL_LANG']['ERR']['general'] . '</p>' : '') . $return;
        // Reload the page to prevent _POST variables from being sent twice
        if (\Input::post('FORM_SUBMIT') == $this->strTable && !$this->noReload) {
            // Call onsubmit_callback
            if (is_array($GLOBALS['TL_DCA'][$this->strTable]['config']['onsubmit_callback'])) {
                foreach ($GLOBALS['TL_DCA'][$this->strTable]['config']['onsubmit_callback'] as $callback) {
                    if (is_array($callback)) {
                        $this->import($callback[0]);
                        $this->{$callback[0]}->{$callback[1]}($this);
                    } elseif (is_callable($callback)) {
                        $callback($this);
                    }
                }
            }
            // Reload
            if (\Input::post('saveNclose')) {
                \Message::reset();
                \System::setCookie('BE_PAGE_OFFSET', 0, 0);
                $this->redirect($this->getReferer());
            }
            $this->reload();
        }
        // Set the focus if there is an error
        if ($this->noReload) {
            $return .= '

<script>
  window.addEvent(\'domready\', function() {
    Backend.vScrollTo(($(\'' . $this->strTable . '\').getElement(\'label.error\').getPosition().y - 20));
  });
</script>';
        }
        return $return;
    }
 /**
  * Create a language
  * 
  */
 public function actionCreatelang()
 {
     $model = new Message();
     if (isset($_POST['Message'])) {
         $model->attributes = $_POST['Message'];
         if (strlen($model->language) != 0) {
             $model->id = 1;
             $uniqueTest = Message::model()->find(array('condition' => 'language=\'' . $model->language . '\''));
             //echo $uniqueTest->language.";".count($uniqueTest).";";print_r($uniqueTest);die();
             if ($uniqueTest === null) {
                 $sources = SourceMessage::model()->findAll();
                 foreach ($sources as $source) {
                     $trans = new Message();
                     $trans->id = $source->id;
                     $trans->translation = $source->message;
                     $trans->language = $model->language;
                     $trans->save();
                 }
                 $this->redirect(array('admin', 'language' => $model->language));
             } else {
                 $model->addError('language', Yii::t('lazy8', 'This language already exists. Enter another language'));
             }
         } else {
             $model->addError('language', Yii::t('lazy8', 'You must enter a language'));
         }
     }
     $this->render('createlang', array('model' => $model));
 }
Exemplo n.º 19
0
 /**
  * Import files from selected folder
  *
  * @param string $strPath
  */
 protected function importFromPath($strPath)
 {
     $arrFiles = scan(TL_ROOT . '/' . $strPath);
     if (empty($arrFiles)) {
         \Message::addError($GLOBALS['TL_LANG']['MSC']['noFilesInFolder']);
         \Controller::reload();
     }
     $blnEmpty = true;
     $arrDelete = array();
     $objProducts = \Database::getInstance()->prepare("SELECT * FROM tl_iso_product WHERE pid=0")->execute();
     while ($objProducts->next()) {
         $arrImageNames = array();
         $arrImages = deserialize($objProducts->images);
         if (!is_array($arrImages)) {
             $arrImages = array();
         } else {
             foreach ($arrImages as $row) {
                 if ($row['src']) {
                     $arrImageNames[] = $row['src'];
                 }
             }
         }
         $arrPattern = array();
         $arrPattern[] = $objProducts->alias ? standardize($objProducts->alias) : null;
         $arrPattern[] = $objProducts->sku ? $objProducts->sku : null;
         $arrPattern[] = $objProducts->sku ? standardize($objProducts->sku) : null;
         $arrPattern[] = !empty($arrImageNames) ? implode('|', $arrImageNames) : null;
         // !HOOK: add custom import regex patterns
         if (isset($GLOBALS['ISO_HOOKS']['addAssetImportRegexp']) && is_array($GLOBALS['ISO_HOOKS']['addAssetImportRegexp'])) {
             foreach ($GLOBALS['ISO_HOOKS']['addAssetImportRegexp'] as $callback) {
                 $objCallback = \System::importStatic($callback[0]);
                 $arrPattern = $objCallback->{$callback}[1]($arrPattern, $objProducts);
             }
         }
         $strPattern = '@^(' . implode('|', array_filter($arrPattern)) . ')@i';
         $arrMatches = preg_grep($strPattern, $arrFiles);
         if (!empty($arrMatches)) {
             $arrNewImages = array();
             foreach ($arrMatches as $file) {
                 if (is_dir(TL_ROOT . '/' . $strPath . '/' . $file)) {
                     $arrSubfiles = scan(TL_ROOT . '/' . $strPath . '/' . $file);
                     if (!empty($arrSubfiles)) {
                         foreach ($arrSubfiles as $subfile) {
                             if (is_file($strPath . '/' . $file . '/' . $subfile)) {
                                 $objFile = new \File($strPath . '/' . $file . '/' . $subfile);
                                 if ($objFile->isGdImage) {
                                     $arrNewImages[] = $strPath . '/' . $file . '/' . $subfile;
                                 }
                             }
                         }
                     }
                 } elseif (is_file(TL_ROOT . '/' . $strPath . '/' . $file)) {
                     $objFile = new \File($strPath . '/' . $file);
                     if ($objFile->isGdImage) {
                         $arrNewImages[] = $strPath . '/' . $file;
                     }
                 }
             }
             if (!empty($arrNewImages)) {
                 foreach ($arrNewImages as $strFile) {
                     $pathinfo = pathinfo(TL_ROOT . '/' . $strFile);
                     // Will recursively create the folder
                     $objFolder = new \Folder('isotope/' . strtolower(substr($pathinfo['filename'], 0, 1)));
                     $strCacheName = $pathinfo['filename'] . '-' . substr(md5_file(TL_ROOT . '/' . $strFile), 0, 8) . '.' . $pathinfo['extension'];
                     \Files::getInstance()->copy($strFile, $objFolder->path . '/' . $strCacheName);
                     $arrImages[] = array('src' => $strCacheName);
                     $arrDelete[] = $strFile;
                     \Message::addConfirmation(sprintf($GLOBALS['TL_LANG']['MSC']['assetImportConfirmation'], $pathinfo['filename'] . '.' . $pathinfo['extension'], $objProducts->name));
                     $blnEmpty = false;
                 }
                 \Database::getInstance()->prepare("UPDATE tl_iso_product SET images=? WHERE id=?")->execute(serialize($arrImages), $objProducts->id);
             }
         }
     }
     if (!empty($arrDelete)) {
         $arrDelete = array_unique($arrDelete);
         foreach ($arrDelete as $file) {
             \Files::getInstance()->delete($file);
         }
     }
     if ($blnEmpty) {
         \Message::addInfo($GLOBALS['TL_LANG']['MSC']['assetImportNoFilesFound']);
     }
     \Controller::reload();
 }
Exemplo n.º 20
0
if (!is_dir(AT_SYSTEM_THEME_DIR . $_SESSION['prefs']['PREF_THEME']) && !is_dir(AT_SUBSITE_THEME_DIR . $_SESSION['prefs']['PREF_THEME']) || $_SESSION['prefs']['PREF_THEME'] == '') {
    $_SESSION['prefs']['PREF_THEME'] = get_system_default_theme();
}
// use "mobile" theme for mobile devices. For now, there's only one mobile theme and it's hardcoded.
// When more mobile themes come in, this should be changed.
if (isset($_SESSION['prefs']['PREF_THEME']) && isset($_SESSION['valid_user']) && $_SESSION['valid_user'] === true) {
    //check if the theme is enabled
    $row = queryDB("SELECT status FROM %sthemes WHERE dir_name='%s'", array(TABLE_PREFIX, $_SESSION['prefs']['PREF_THEME']), true);
    if ($row['status'] == 0) {
        // get user defined default theme if the preference theme is disabled
        $default_theme = get_default_theme();
        if (!is_dir(AT_SYSTEM_THEME_DIR . $default_theme) && !is_dir(AT_SUBSITE_THEME_DIR . $default_theme)) {
            $default_theme = get_system_default_theme();
        }
        $_SESSION['prefs']['PREF_THEME'] = $default_theme;
        $msg->addError('THEME_PREVIEW_DISABLED');
    }
}
// find out where PREF_THEME is located
$main_theme_folder = get_main_theme_dir(is_customized_theme($_SESSION['prefs']['PREF_THEME']));
$savant->addPath('template', $main_theme_folder . $_SESSION['prefs']['PREF_THEME'] . '/');
require $main_theme_folder . '../themes/' . $_SESSION['prefs']['PREF_THEME'] . '/theme.cfg.php';
// Define the directory where the customized data lives (used by multi sites):
// Main site: [ATutor-root]
// Subsites: [ATutor-root]/sites/[Subsite-URL]/
$theme_path = "";
if (is_customized_theme($_SESSION['prefs']['PREF_THEME'])) {
    $theme_path = AT_SITES_DIR . $_SERVER['HTTP_HOST'] . '/';
}
define('AT_CUSTOMIZED_DATA_DIR', AT_BASE_HREF . $theme_path);
/**************************************************/
Exemplo n.º 21
0
 protected function initializeDefaultValues()
 {
     // Set default session data
     $arrSession = \Session::getInstance()->get('iso_reports');
     if ($arrSession[$this->name]['period'] == '') {
         $arrSession[$this->name]['period'] = 'month';
     }
     if ($arrSession[$this->name]['stop'] == '') {
         $arrSession[$this->name]['stop'] = time();
     } elseif (!is_numeric($arrSession[$this->name]['stop'])) {
         // Convert date formats into timestamps
         try {
             $objDate = new \Date($arrSession[$this->name]['stop'], $GLOBALS['TL_CONFIG']['dateFormat']);
             $arrSession[$this->name]['stop'] = $objDate->tstamp;
         } catch (\OutOfBoundsException $e) {
             \Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['date'], $GLOBALS['TL_CONFIG']['dateFormat']));
             $arrSession[$this->name]['stop'] = time();
         }
     }
     if ($arrSession[$this->name]['start'] == '') {
         $arrSession[$this->name]['start'] = strtotime('-6 months');
     } elseif (!is_numeric($arrSession[$this->name]['start'])) {
         // Convert date formats into timestamps
         try {
             $objDate = new \Date($arrSession[$this->name]['start'], $GLOBALS['TL_CONFIG']['dateFormat']);
             $arrSession[$this->name]['start'] = $objDate->tstamp;
         } catch (\OutOfBoundsException $e) {
             \Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['date'], $GLOBALS['TL_CONFIG']['dateFormat']));
             $arrSession[$this->name]['start'] = strtotime('-6 months');
         }
     }
     \Session::getInstance()->set('iso_reports', $arrSession);
     parent::initializeDefaultValues();
 }
Exemplo n.º 22
0
 /**
  * Check the uploaded files and move them to the target directory
  *
  * @param string $strTarget
  *
  * @return array
  *
  * @throws \Exception
  */
 public function uploadTo($strTarget)
 {
     if ($strTarget == '' || \Validator::isInsecurePath($strTarget)) {
         throw new \InvalidArgumentException('Invalid target path ' . $strTarget);
     }
     $maxlength_kb = $this->getMaximumUploadSize();
     $maxlength_kb_readable = $this->getReadableSize($maxlength_kb);
     $arrUploaded = array();
     $arrFiles = $this->getFilesFromGlobal();
     foreach ($arrFiles as $file) {
         // Sanitize the filename
         try {
             $file['name'] = \StringUtil::sanitizeFileName($file['name']);
         } catch (\InvalidArgumentException $e) {
             \Message::addError($GLOBALS['TL_LANG']['ERR']['filename']);
             $this->blnHasError = true;
             continue;
         }
         // Invalid file name
         if (!\Validator::isValidFileName($file['name'])) {
             \Message::addError($GLOBALS['TL_LANG']['ERR']['filename']);
             $this->blnHasError = true;
         } elseif (!is_uploaded_file($file['tmp_name'])) {
             if ($file['error'] == 1 || $file['error'] == 2) {
                 \Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['filesize'], $maxlength_kb_readable));
                 $this->log('File "' . $file['name'] . '" exceeds the maximum file size of ' . $maxlength_kb_readable, __METHOD__, TL_ERROR);
                 $this->blnHasError = true;
             } elseif ($file['error'] == 3) {
                 \Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['filepartial'], $file['name']));
                 $this->log('File "' . $file['name'] . '" was only partially uploaded', __METHOD__, TL_ERROR);
                 $this->blnHasError = true;
             } elseif ($file['error'] > 0) {
                 \Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['fileerror'], $file['error'], $file['name']));
                 $this->log('File "' . $file['name'] . '" could not be uploaded (error ' . $file['error'] . ')', __METHOD__, TL_ERROR);
                 $this->blnHasError = true;
             }
         } elseif ($file['size'] > $maxlength_kb) {
             \Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['filesize'], $maxlength_kb_readable));
             $this->log('File "' . $file['name'] . '" exceeds the maximum file size of ' . $maxlength_kb_readable, __METHOD__, TL_ERROR);
             $this->blnHasError = true;
         } else {
             $strExtension = pathinfo($file['name'], PATHINFO_EXTENSION);
             $arrAllowedTypes = trimsplit(',', strtolower(\Config::get('uploadTypes')));
             // File type not allowed
             if (!in_array(strtolower($strExtension), $arrAllowedTypes)) {
                 \Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['filetype'], $strExtension));
                 $this->log('File type "' . $strExtension . '" is not allowed to be uploaded (' . $file['name'] . ')', __METHOD__, TL_ERROR);
                 $this->blnHasError = true;
             } else {
                 $this->import('Files');
                 $strNewFile = $strTarget . '/' . $file['name'];
                 // Set CHMOD and resize if neccessary
                 if ($this->Files->move_uploaded_file($file['tmp_name'], $strNewFile)) {
                     $this->Files->chmod($strNewFile, \Config::get('defaultFileChmod'));
                     $blnResized = $this->resizeUploadedImage($strNewFile);
                     // Notify the user
                     if (!$blnResized) {
                         \Message::addConfirmation(sprintf($GLOBALS['TL_LANG']['MSC']['fileUploaded'], $file['name']));
                         $this->log('File "' . $file['name'] . '" uploaded successfully', __METHOD__, TL_FILES);
                     }
                     $arrUploaded[] = $strNewFile;
                 }
             }
         }
     }
     return $arrUploaded;
 }
Exemplo n.º 23
0
    /**
     * Move one or more local files to the server
     *
     * @param boolean $blnIsAjax
     *
     * @return string
     */
    public function move($blnIsAjax = false)
    {
        $strFolder = \Input::get('pid', true);
        if (!file_exists(TL_ROOT . '/' . $strFolder) || !$this->isMounted($strFolder)) {
            $this->log('Folder "' . $strFolder . '" was not mounted or is not a directory', __METHOD__, TL_ERROR);
            $this->redirect('contao/main.php?act=error');
        }
        if (!preg_match('/^' . preg_quote(\Config::get('uploadPath'), '/') . '/i', $strFolder)) {
            $this->log('Parent folder "' . $strFolder . '" is not within the files directory', __METHOD__, TL_ERROR);
            $this->redirect('contao/main.php?act=error');
        }
        // Empty clipboard
        if (!$blnIsAjax) {
            $arrClipboard = $this->Session->get('CLIPBOARD');
            $arrClipboard[$this->strTable] = array();
            $this->Session->set('CLIPBOARD', $arrClipboard);
        }
        // Instantiate the uploader
        $this->import('BackendUser', 'User');
        $class = $this->User->uploader;
        // See #4086
        if (!class_exists($class)) {
            $class = 'FileUpload';
        }
        /** @var \FileUpload $objUploader */
        $objUploader = new $class();
        // Process the uploaded files
        if (\Input::post('FORM_SUBMIT') == 'tl_upload') {
            // Generate the DB entries
            if ($this->blnIsDbAssisted && \Dbafs::shouldBeSynchronized($strFolder)) {
                // Upload the files
                $arrUploaded = $objUploader->uploadTo($strFolder);
                if (empty($arrUploaded)) {
                    \Message::addError($GLOBALS['TL_LANG']['ERR']['emptyUpload']);
                    $this->reload();
                }
                foreach ($arrUploaded as $strFile) {
                    $objFile = \FilesModel::findByPath($strFile);
                    // Existing file is being replaced (see #4818)
                    if ($objFile !== null) {
                        $objFile->tstamp = time();
                        $objFile->path = $strFile;
                        $objFile->hash = md5_file(TL_ROOT . '/' . $strFile);
                        $objFile->save();
                    } else {
                        \Dbafs::addResource($strFile);
                    }
                }
            } else {
                // Not DB-assisted, so just upload the file
                $arrUploaded = $objUploader->uploadTo($strFolder);
            }
            // HOOK: post upload callback
            if (isset($GLOBALS['TL_HOOKS']['postUpload']) && is_array($GLOBALS['TL_HOOKS']['postUpload'])) {
                foreach ($GLOBALS['TL_HOOKS']['postUpload'] as $callback) {
                    if (is_array($callback)) {
                        $this->import($callback[0]);
                        $this->{$callback[0]}->{$callback[1]}($arrUploaded);
                    } elseif (is_callable($callback)) {
                        $callback($arrUploaded);
                    }
                }
            }
            // Update the hash of the target folder
            if ($this->blnIsDbAssisted && \Dbafs::shouldBeSynchronized($strFolder)) {
                \Dbafs::updateFolderHashes($strFolder);
            }
            // Redirect or reload
            if (!$objUploader->hasError()) {
                // Do not purge the html folder (see #2898)
                if (\Input::post('uploadNback') && !$objUploader->hasResized()) {
                    \Message::reset();
                    $this->redirect($this->getReferer());
                }
                $this->reload();
            }
        }
        // Submit buttons
        $arrButtons = array();
        $arrButtons['upload'] = '<input type="submit" name="upload" class="tl_submit" accesskey="s" value="' . specialchars($GLOBALS['TL_LANG'][$this->strTable]['upload']) . '">';
        $arrButtons['uploadNback'] = '<input type="submit" name="uploadNback" class="tl_submit" accesskey="c" value="' . specialchars($GLOBALS['TL_LANG'][$this->strTable]['uploadNback']) . '">';
        // Call the buttons_callback (see #4691)
        if (is_array($GLOBALS['TL_DCA'][$this->strTable]['edit']['buttons_callback'])) {
            foreach ($GLOBALS['TL_DCA'][$this->strTable]['edit']['buttons_callback'] as $callback) {
                if (is_array($callback)) {
                    $this->import($callback[0]);
                    $arrButtons = $this->{$callback[0]}->{$callback[1]}($arrButtons, $this);
                } elseif (is_callable($callback)) {
                    $arrButtons = $callback($arrButtons, $this);
                }
            }
        }
        // Display the upload form
        return '
<div id="tl_buttons">
<a href="' . $this->getReferer(true) . '" class="header_back" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['backBTTitle']) . '" accesskey="b" onclick="Backend.getScrollOffset()">' . $GLOBALS['TL_LANG']['MSC']['backBT'] . '</a>
</div>
' . \Message::generate() . '
<form action="' . ampersand(\Environment::get('request'), true) . '" id="' . $this->strTable . '" class="tl_form" method="post"' . (!empty($this->onsubmit) ? ' onsubmit="' . implode(' ', $this->onsubmit) . '"' : '') . ' enctype="multipart/form-data">
<div class="tl_formbody_edit">
<input type="hidden" name="FORM_SUBMIT" value="tl_upload">
<input type="hidden" name="REQUEST_TOKEN" value="' . REQUEST_TOKEN . '">
<input type="hidden" name="MAX_FILE_SIZE" value="' . \Config::get('maxFileSize') . '">

<div class="tl_tbox">
  <h3>' . $GLOBALS['TL_LANG'][$this->strTable]['fileupload'][0] . '</h3>' . $objUploader->generateMarkup() . '
</div>

</div>

<div class="tl_formbody_submit">

<div class="tl_submit_container">
  ' . implode(' ', $arrButtons) . '
</div>

</div>

</form>';
    }
Exemplo n.º 24
0
    /**
     * Return a form to choose a CSV file and import it
     *
     * @param DataContainer $dc
     *
     * @return string
     */
    public function importList(DataContainer $dc)
    {
        if (\Input::get('key') != 'list') {
            return '';
        }
        $this->import('BackendUser', 'User');
        $class = $this->User->uploader;
        // See #4086 and #7046
        if (!class_exists($class) || $class == 'DropZone') {
            $class = 'FileUpload';
        }
        /** @var FileUpload $objUploader */
        $objUploader = new $class();
        // Import CSS
        if (\Input::post('FORM_SUBMIT') == 'tl_list_import') {
            $arrUploaded = $objUploader->uploadTo('system/tmp');
            if (empty($arrUploaded)) {
                \Message::addError($GLOBALS['TL_LANG']['ERR']['all_fields']);
                $this->reload();
            }
            $this->import('Database');
            $arrList = array();
            foreach ($arrUploaded as $strCsvFile) {
                $objFile = new \File($strCsvFile);
                if ($objFile->extension != 'csv') {
                    \Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['filetype'], $objFile->extension));
                    continue;
                }
                // Get separator
                switch (\Input::post('separator')) {
                    case 'semicolon':
                        $strSeparator = ';';
                        break;
                    case 'tabulator':
                        $strSeparator = "\t";
                        break;
                    case 'linebreak':
                        $strSeparator = "\n";
                        break;
                    default:
                        $strSeparator = ',';
                        break;
                }
                $resFile = $objFile->handle;
                while (($arrRow = @fgetcsv($resFile, null, $strSeparator)) !== false) {
                    $arrList = array_merge($arrList, $arrRow);
                }
            }
            $objVersions = new \Versions($dc->table, \Input::get('id'));
            $objVersions->create();
            $this->Database->prepare("UPDATE " . $dc->table . " SET listitems=? WHERE id=?")->execute(serialize($arrList), \Input::get('id'));
            \System::setCookie('BE_PAGE_OFFSET', 0, 0);
            $this->redirect(str_replace('&key=list', '', \Environment::get('request')));
        }
        // Return form
        return '
<div id="tl_buttons">
<a href="' . ampersand(str_replace('&key=list', '', \Environment::get('request'))) . '" class="header_back" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['backBTTitle']) . '" accesskey="b">' . $GLOBALS['TL_LANG']['MSC']['backBT'] . '</a>
</div>
' . \Message::generate() . '
<form action="' . ampersand(\Environment::get('request'), true) . '" id="tl_list_import" class="tl_form" method="post" enctype="multipart/form-data">
<div class="tl_formbody_edit">
<input type="hidden" name="FORM_SUBMIT" value="tl_list_import">
<input type="hidden" name="REQUEST_TOKEN" value="' . REQUEST_TOKEN . '">
<input type="hidden" name="MAX_FILE_SIZE" value="' . \Config::get('maxFileSize') . '">

<div class="tl_tbox">
  <h3><label for="separator">' . $GLOBALS['TL_LANG']['MSC']['separator'][0] . '</label></h3>
  <select name="separator" id="separator" class="tl_select" onfocus="Backend.getScrollOffset()">
    <option value="comma">' . $GLOBALS['TL_LANG']['MSC']['comma'] . '</option>
    <option value="semicolon">' . $GLOBALS['TL_LANG']['MSC']['semicolon'] . '</option>
    <option value="tabulator">' . $GLOBALS['TL_LANG']['MSC']['tabulator'] . '</option>
    <option value="linebreak">' . $GLOBALS['TL_LANG']['MSC']['linebreak'] . '</option>
  </select>' . ($GLOBALS['TL_LANG']['MSC']['separator'][1] != '' ? '
  <p class="tl_help tl_tip">' . $GLOBALS['TL_LANG']['MSC']['separator'][1] . '</p>' : '') . '
  <h3>' . $GLOBALS['TL_LANG']['MSC']['source'][0] . '</h3>' . $objUploader->generateMarkup() . (isset($GLOBALS['TL_LANG']['MSC']['source'][1]) ? '
  <p class="tl_help tl_tip">' . $GLOBALS['TL_LANG']['MSC']['source'][1] . '</p>' : '') . '
</div>

</div>

<div class="tl_formbody_submit">

<div class="tl_submit_container">
  <button type="submit" name="save" id="save" class="tl_submit" accesskey="s">' . $GLOBALS['TL_LANG']['MSC']['lw_import'][0] . '</button>
</div>

</div>
</form>';
    }
Exemplo n.º 25
0
 /**
  * Add an error message
  * 
  * @param string $strMessage The error message
  * 
  * @deprecated Use Message::addError() instead
  */
 protected function addErrorMessage($strMessage)
 {
     \Message::addError($strMessage);
 }
Exemplo n.º 26
0
Arquivo: User.php Projeto: rikaix/core
 /**
  * Check the account status and return true if it is active
  * 
  * @return boolean True if the account is active
  */
 protected function checkAccountStatus()
 {
     $time = time();
     // Check whether the account is locked
     if ($this->locked + $GLOBALS['TL_CONFIG']['lockPeriod'] > $time) {
         \Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['accountLocked'], ceil(($this->locked + $GLOBALS['TL_CONFIG']['lockPeriod'] - $time) / 60)));
         return false;
     } elseif ($this->disable) {
         \Message::addError($GLOBALS['TL_LANG']['ERR']['invalidLogin']);
         $this->log('The account has been disabled', get_class($this) . ' login()', TL_ACCESS);
         return false;
     } elseif ($this instanceof \FrontendUser && !$this->login) {
         \Message::addError($GLOBALS['TL_LANG']['ERR']['invalidLogin']);
         $this->log('User "' . $this->username . '" is not allowed to log in', get_class($this) . ' login()', TL_ACCESS);
         return false;
     } elseif ($this->start != '' || $this->stop != '') {
         if ($this->start != '' && $this->start > $time) {
             \Message::addError($GLOBALS['TL_LANG']['ERR']['invalidLogin']);
             $this->log('The account was not active yet (activation date: ' . $this->parseDate($GLOBALS['TL_CONFIG']['dateFormat'], $this->start) . ')', get_class($this) . ' login()', TL_ACCESS);
             return false;
         }
         if ($this->stop != '' && $this->stop < $time) {
             \Message::addError($GLOBALS['TL_LANG']['ERR']['invalidLogin']);
             $this->log('The account was not active anymore (deactivation date: ' . $this->parseDate($GLOBALS['TL_CONFIG']['dateFormat'], $this->stop) . ')', get_class($this) . ' login()', TL_ACCESS);
             return false;
         }
     }
     return true;
 }
Exemplo n.º 27
0
Arquivo: Theme.php Projeto: Jobu/core
 /**
  * Extract the theme files and write the data to the database
  *
  * @param array $arrFiles
  * @param array $arrDbFields
  */
 protected function extractThemeFiles($arrFiles, $arrDbFields)
 {
     foreach ($arrFiles as $strZipFile) {
         $xml = null;
         // Open the archive
         $objArchive = new \ZipReader($strZipFile);
         // Extract all files
         while ($objArchive->next()) {
             // Load the XML file
             if ($objArchive->file_name == 'theme.xml') {
                 $xml = new \DOMDocument();
                 $xml->preserveWhiteSpace = false;
                 $xml->loadXML($objArchive->unzip());
                 continue;
             }
             // Limit file operations to files and the templates directory
             if (strncmp($objArchive->file_name, 'files/', 6) !== 0 && strncmp($objArchive->file_name, 'tl_files/', 9) !== 0 && strncmp($objArchive->file_name, 'templates/', 10) !== 0) {
                 \Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['invalidFile'], $objArchive->file_name));
                 continue;
             }
             // Extract the files
             try {
                 \File::putContent($this->customizeUploadPath($objArchive->file_name), $objArchive->unzip());
             } catch (\Exception $e) {
                 \Message::addError($e->getMessage());
             }
         }
         // Continue if there is no XML file
         if (!$xml instanceof \DOMDocument) {
             \Message::addError(sprintf($GLOBALS['TL_LANG']['tl_theme']['missing_xml'], basename($strZipFile)));
             continue;
         }
         $arrMapper = array();
         $tables = $xml->getElementsByTagName('table');
         $arrNewFolders = array();
         // Extract the folder names from the XML file
         for ($i = 0; $i < $tables->length; $i++) {
             if ($tables->item($i)->getAttribute('name') == 'tl_theme') {
                 $fields = $tables->item($i)->childNodes->item(0)->childNodes;
                 for ($k = 0; $k < $fields->length; $k++) {
                     if ($fields->item($k)->getAttribute('name') == 'folders') {
                         $arrNewFolders = deserialize($fields->item($k)->nodeValue);
                         break;
                     }
                 }
                 break;
             }
         }
         // Sync the new folder(s)
         if (!empty($arrNewFolders) && is_array($arrNewFolders)) {
             foreach ($arrNewFolders as $strFolder) {
                 \Dbafs::addResource($this->customizeUploadPath($strFolder));
             }
         }
         // Lock the tables
         $arrLocks = array('tl_files' => 'WRITE', 'tl_theme' => 'WRITE', 'tl_style_sheet' => 'WRITE', 'tl_style' => 'WRITE', 'tl_module' => 'WRITE', 'tl_layout' => 'WRITE', 'tl_image_size' => 'WRITE', 'tl_image_size_item' => 'WRITE');
         // Load the DCAs of the locked tables (see #7345)
         foreach (array_keys($arrLocks) as $table) {
             $this->loadDataContainer($table);
         }
         $this->Database->lockTables($arrLocks);
         // Get the current auto_increment values
         $tl_files = $this->Database->getNextId('tl_files');
         $tl_theme = $this->Database->getNextId('tl_theme');
         $tl_style_sheet = $this->Database->getNextId('tl_style_sheet');
         $tl_style = $this->Database->getNextId('tl_style');
         $tl_module = $this->Database->getNextId('tl_module');
         $tl_layout = $this->Database->getNextId('tl_layout');
         $tl_image_size = $this->Database->getNextId('tl_image_size');
         $tl_image_size_item = $this->Database->getNextId('tl_image_size_item');
         // Loop through the tables
         for ($i = 0; $i < $tables->length; $i++) {
             $rows = $tables->item($i)->childNodes;
             $table = $tables->item($i)->getAttribute('name');
             // Skip invalid tables
             if (!in_array($table, array_keys($arrLocks))) {
                 continue;
             }
             // Get the order fields
             $objDcaExtractor = \DcaExtractor::getInstance($table);
             $arrOrder = $objDcaExtractor->getOrderFields();
             // Loop through the rows
             for ($j = 0; $j < $rows->length; $j++) {
                 $set = array();
                 $fields = $rows->item($j)->childNodes;
                 // Loop through the fields
                 for ($k = 0; $k < $fields->length; $k++) {
                     $value = $fields->item($k)->nodeValue;
                     $name = $fields->item($k)->getAttribute('name');
                     // Skip NULL values
                     if ($value == 'NULL') {
                         continue;
                     } elseif ($name == 'id') {
                         $id = ${$table}++;
                         $arrMapper[$table][$value] = $id;
                         $value = $id;
                     } elseif ($name == 'pid') {
                         if ($table == 'tl_style') {
                             $value = $arrMapper['tl_style_sheet'][$value];
                         } elseif ($table == 'tl_image_size_item') {
                             $value = $arrMapper['tl_image_size'][$value];
                         } else {
                             $value = $arrMapper['tl_theme'][$value];
                         }
                     } elseif ($name == 'fallback') {
                         $value = '';
                     } elseif ($table == 'tl_layout' && $name == 'stylesheet') {
                         $stylesheets = deserialize($value);
                         if (is_array($stylesheets)) {
                             foreach (array_keys($stylesheets) as $key) {
                                 $stylesheets[$key] = $arrMapper['tl_style_sheet'][$stylesheets[$key]];
                             }
                             $value = serialize($stylesheets);
                         }
                     } elseif ($table == 'tl_layout' && $name == 'modules') {
                         $modules = deserialize($value);
                         if (is_array($modules)) {
                             foreach ($modules as $key => $mod) {
                                 if ($mod['mod'] > 0) {
                                     $modules[$key]['mod'] = $arrMapper['tl_module'][$mod['mod']];
                                 }
                             }
                             $value = serialize($modules);
                         }
                     } elseif (($table == 'tl_theme' || $table == 'tl_style_sheet') && $name == 'name') {
                         $objCount = $this->Database->prepare("SELECT COUNT(*) AS count FROM " . $table . " WHERE name=?")->execute($value);
                         if ($objCount->count > 0) {
                             $value = preg_replace('/( |\\-)[0-9]+$/', '', $value);
                             $value .= ($table == 'tl_style_sheet' ? '-' : ' ') . ${$table};
                         }
                     } elseif (($table == 'tl_style_sheet' || $table == 'tl_style' || $table == 'tl_files' && $name == 'path') && strpos($value, 'files') !== false) {
                         $tmp = deserialize($value);
                         if (is_array($tmp)) {
                             foreach ($tmp as $kk => $vv) {
                                 $tmp[$kk] = $this->customizeUploadPath($vv);
                             }
                             $value = serialize($tmp);
                         } else {
                             $value = $this->customizeUploadPath($value);
                         }
                     } elseif ($GLOBALS['TL_DCA'][$table]['fields'][$name]['inputType'] == 'fileTree' && !$GLOBALS['TL_DCA'][$table]['fields'][$name]['eval']['multiple']) {
                         if (!$value) {
                             $value = null;
                             // Contao >= 3.2
                         } else {
                             // Do not use the FilesModel here – tables are locked!
                             $objFile = $this->Database->prepare("SELECT uuid FROM tl_files WHERE path=?")->limit(1)->execute($this->customizeUploadPath($value));
                             $value = $objFile->uuid;
                         }
                     } elseif ($GLOBALS['TL_DCA'][$table]['fields'][$name]['inputType'] == 'fileTree' || in_array($name, $arrOrder)) {
                         $tmp = deserialize($value);
                         if (is_array($tmp)) {
                             foreach ($tmp as $kk => $vv) {
                                 // Do not use the FilesModel here – tables are locked!
                                 $objFile = $this->Database->prepare("SELECT uuid FROM tl_files WHERE path=?")->limit(1)->execute($this->customizeUploadPath($vv));
                                 $tmp[$kk] = $objFile->uuid;
                             }
                             $value = serialize($tmp);
                         }
                     } elseif ($GLOBALS['TL_DCA'][$table]['fields'][$name]['inputType'] == 'imageSize') {
                         $imageSizes = deserialize($value, true);
                         if (!empty($imageSizes)) {
                             if (is_numeric($imageSizes[2])) {
                                 $imageSizes[2] = $arrMapper['tl_image_size'][$imageSizes[2]];
                             }
                         }
                         $value = serialize($imageSizes);
                     }
                     $set[$name] = $value;
                 }
                 // Skip fields that are not in the database (e.g. because of missing extensions)
                 foreach ($set as $k => $v) {
                     if (!in_array($k, $arrDbFields[$table])) {
                         unset($set[$k]);
                     }
                 }
                 // Create the templates folder even if it is empty (see #4793)
                 if ($table == 'tl_theme' && isset($set['templates']) && strncmp($set['templates'], 'templates/', 10) === 0 && !is_dir(TL_ROOT . '/' . $set['templates'])) {
                     new \Folder($set['templates']);
                 }
                 // Update tl_files (entries have been created by the Dbafs class)
                 if ($table == 'tl_files') {
                     $this->Database->prepare("UPDATE {$table} %s WHERE path=?")->set($set)->execute($set['path']);
                 } else {
                     $this->Database->prepare("INSERT INTO {$table} %s")->set($set)->execute();
                 }
             }
         }
         // Unlock the tables
         $this->Database->unlockTables();
         // Update the style sheets
         $this->import('StyleSheets');
         $this->StyleSheets->updateStyleSheets();
         // Notify the user
         \Message::addConfirmation(sprintf($GLOBALS['TL_LANG']['tl_theme']['theme_imported'], basename($strZipFile)));
         // HOOK: add custom logic
         if (isset($GLOBALS['TL_HOOKS']['extractThemeFiles']) && is_array($GLOBALS['TL_HOOKS']['extractThemeFiles'])) {
             $intThemeId = empty($arrMapper['tl_theme']) ? null : reset($arrMapper['tl_theme']);
             foreach ($GLOBALS['TL_HOOKS']['extractThemeFiles'] as $callback) {
                 \System::importStatic($callback[0])->{$callback}[1]($xml, $objArchive, $intThemeId, $arrMapper);
             }
         }
         unset($tl_files, $tl_theme, $tl_style_sheet, $tl_style, $tl_module, $tl_layout, $tl_image_size, $tl_image_size_item);
     }
     \System::setCookie('BE_PAGE_OFFSET', 0, 0);
     $this->Session->remove('uploaded_themes');
     // Redirect
     $this->redirect(str_replace('&key=importTheme', '', \Environment::get('request')));
 }
Exemplo n.º 28
0
    /**
     * Return a form to choose a CSV file and import it
     *
     * @return string
     */
    public function importRecipients()
    {
        if (\Input::get('key') != 'import') {
            return '';
        }
        $this->import('BackendUser', 'User');
        $class = $this->User->uploader;
        // See #4086 and #7046
        if (!class_exists($class) || $class == 'DropZone') {
            $class = 'FileUpload';
        }
        /** @var \FileUpload $objUploader */
        $objUploader = new $class();
        // Import CSS
        if (\Input::post('FORM_SUBMIT') == 'tl_recipients_import') {
            $arrUploaded = $objUploader->uploadTo('system/tmp');
            if (empty($arrUploaded)) {
                \Message::addError($GLOBALS['TL_LANG']['ERR']['all_fields']);
                $this->reload();
            }
            $time = time();
            $intTotal = 0;
            $intInvalid = 0;
            foreach ($arrUploaded as $strCsvFile) {
                $objFile = new \File($strCsvFile, true);
                if ($objFile->extension != 'csv') {
                    \Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['filetype'], $objFile->extension));
                    continue;
                }
                // Get separator
                switch (\Input::post('separator')) {
                    case 'semicolon':
                        $strSeparator = ';';
                        break;
                    case 'tabulator':
                        $strSeparator = "\t";
                        break;
                    case 'linebreak':
                        $strSeparator = "\n";
                        break;
                    default:
                        $strSeparator = ',';
                        break;
                }
                $arrRecipients = array();
                $resFile = $objFile->handle;
                while (($arrRow = @fgetcsv($resFile, null, $strSeparator)) !== false) {
                    $arrRecipients = array_merge($arrRecipients, $arrRow);
                }
                $arrRecipients = array_filter(array_unique($arrRecipients));
                foreach ($arrRecipients as $strRecipient) {
                    // Skip invalid entries
                    if (!\Validator::isEmail($strRecipient)) {
                        $this->log('Recipient address "' . $strRecipient . '" seems to be invalid and has been skipped', __METHOD__, TL_ERROR);
                        ++$intInvalid;
                        continue;
                    }
                    // Check whether the e-mail address exists
                    $objRecipient = $this->Database->prepare("SELECT COUNT(*) AS count FROM tl_newsletter_recipients WHERE pid=? AND email=?")->execute(\Input::get('id'), $strRecipient);
                    if ($objRecipient->count < 1) {
                        $this->Database->prepare("INSERT INTO tl_newsletter_recipients SET pid=?, tstamp={$time}, email=?, active=1")->execute(\Input::get('id'), $strRecipient);
                        ++$intTotal;
                    }
                }
            }
            \Message::addConfirmation(sprintf($GLOBALS['TL_LANG']['tl_newsletter_recipients']['confirm'], $intTotal));
            if ($intInvalid > 0) {
                \Message::addInfo(sprintf($GLOBALS['TL_LANG']['tl_newsletter_recipients']['invalid'], $intInvalid));
            }
            \System::setCookie('BE_PAGE_OFFSET', 0, 0);
            $this->reload();
        }
        // Return form
        return '
<div id="tl_buttons">
<a href="' . ampersand(str_replace('&key=import', '', \Environment::get('request'))) . '" class="header_back" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['backBTTitle']) . '" accesskey="b">' . $GLOBALS['TL_LANG']['MSC']['backBT'] . '</a>
</div>
' . \Message::generate() . '
<form action="' . ampersand(\Environment::get('request'), true) . '" id="tl_recipients_import" class="tl_form" method="post" enctype="multipart/form-data">
<div class="tl_formbody_edit">
<input type="hidden" name="FORM_SUBMIT" value="tl_recipients_import">
<input type="hidden" name="REQUEST_TOKEN" value="' . REQUEST_TOKEN . '">
<input type="hidden" name="MAX_FILE_SIZE" value="' . \Config::get('maxFileSize') . '">

<div class="tl_tbox">
  <h3><label for="separator">' . $GLOBALS['TL_LANG']['MSC']['separator'][0] . '</label></h3>
  <select name="separator" id="separator" class="tl_select" onfocus="Backend.getScrollOffset()">
    <option value="comma">' . $GLOBALS['TL_LANG']['MSC']['comma'] . '</option>
    <option value="semicolon">' . $GLOBALS['TL_LANG']['MSC']['semicolon'] . '</option>
    <option value="tabulator">' . $GLOBALS['TL_LANG']['MSC']['tabulator'] . '</option>
    <option value="linebreak">' . $GLOBALS['TL_LANG']['MSC']['linebreak'] . '</option>
  </select>' . ($GLOBALS['TL_LANG']['MSC']['separator'][1] != '' ? '
  <p class="tl_help tl_tip">' . $GLOBALS['TL_LANG']['MSC']['separator'][1] . '</p>' : '') . '
  <h3>' . $GLOBALS['TL_LANG']['MSC']['source'][0] . '</h3>' . $objUploader->generateMarkup() . (isset($GLOBALS['TL_LANG']['MSC']['source'][1]) ? '
  <p class="tl_help tl_tip">' . $GLOBALS['TL_LANG']['MSC']['source'][1] . '</p>' : '') . '
</div>

</div>

<div class="tl_formbody_submit">

<div class="tl_submit_container">
  <input type="submit" name="save" id="save" class="tl_submit" accesskey="s" value="' . specialchars($GLOBALS['TL_LANG']['tl_newsletter_recipients']['import'][0]) . '">
</div>

</div>
</form>';
    }
    /**
     * Renturn a form to choose an existing style sheet and import it
     * @param \DataContainer
     * @return string
     */
    public function send(\DataContainer $objDc)
    {
        if (TL_MODE == 'BE') {
            $GLOBALS['TL_CSS'][] = 'system/modules/newsletter_content/assets/css/style.css';
            if ($this->isFlexible) {
                $GLOBALS['TL_CSS'][] = 'system/modules/newsletter_content/assets/css/style-flexible.css';
            }
        }
        $objNewsletter = $this->Database->prepare("SELECT n.*, c.useSMTP, c.smtpHost, c.smtpPort, c.smtpUser, c.smtpPass FROM tl_newsletter n LEFT JOIN tl_newsletter_channel c ON n.pid=c.id WHERE n.id=?")->limit(1)->execute($objDc->id);
        // Return if there is no newsletter
        if ($objNewsletter->numRows < 1) {
            return '';
        }
        // Overwrite the SMTP configuration
        if ($objNewsletter->useSMTP) {
            $GLOBALS['TL_CONFIG']['useSMTP'] = true;
            $GLOBALS['TL_CONFIG']['smtpHost'] = $objNewsletter->smtpHost;
            $GLOBALS['TL_CONFIG']['smtpUser'] = $objNewsletter->smtpUser;
            $GLOBALS['TL_CONFIG']['smtpPass'] = $objNewsletter->smtpPass;
            $GLOBALS['TL_CONFIG']['smtpEnc'] = $objNewsletter->smtpEnc;
            $GLOBALS['TL_CONFIG']['smtpPort'] = $objNewsletter->smtpPort;
        }
        // Add default sender address
        if ($objNewsletter->sender == '') {
            list($objNewsletter->senderName, $objNewsletter->sender) = \String::splitFriendlyEmail($GLOBALS['TL_CONFIG']['adminEmail']);
        }
        $arrAttachments = array();
        $blnAttachmentsFormatError = false;
        // Add attachments
        if ($objNewsletter->addFile) {
            $files = deserialize($objNewsletter->files);
            if (!empty($files) && is_array($files)) {
                $objFiles = \FilesModel::findMultipleByUuids($files);
                if ($objFiles === null) {
                    if (!\Validator::isUuid($files[0])) {
                        $blnAttachmentsFormatError = true;
                        \Message::addError($GLOBALS['TL_LANG']['ERR']['version2format']);
                    }
                } else {
                    while ($objFiles->next()) {
                        if (is_file(TL_ROOT . '/' . $objFiles->path)) {
                            $arrAttachments[] = $objFiles->path;
                        }
                    }
                }
            }
        }
        // Get content
        $html = '';
        $objContentElements = \ContentModel::findPublishedByPidAndTable($objNewsletter->id, 'tl_newsletter');
        if ($objContentElements !== null) {
            if (!defined('NEWSLETTER_CONTENT_PREVIEW')) {
                define('NEWSLETTER_CONTENT_PREVIEW', true);
            }
            while ($objContentElements->next()) {
                $html .= $this->getContentElement($objContentElements->id);
            }
        }
        // Replace insert tags
        $text = $this->replaceInsertTags($objNewsletter->text);
        $html = $this->replaceInsertTags($html);
        // Convert relative URLs
        $html = $this->convertRelativeUrls($html);
        // Set back to object
        $objNewsletter->content = $html;
        // Send newsletter
        if (!$blnAttachmentsFormatError && \Input::get('token') != '' && \Input::get('token') == $this->Session->get('tl_newsletter_send')) {
            $referer = preg_replace('/&(amp;)?(start|mpc|token|recipient|preview)=[^&]*/', '', \Environment::get('request'));
            // Preview
            if (isset($_GET['preview'])) {
                // Check the e-mail address
                if (!\Validator::isEmail(\Input::get('recipient', true))) {
                    $_SESSION['TL_PREVIEW_MAIL_ERROR'] = true;
                    $this->redirect($referer);
                }
                // get preview recipient
                $arrRecipient = array();
                $strEmail = urldecode(\Input::get('recipient', true));
                $objRecipient = $this->Database->prepare("SELECT * FROM tl_member m WHERE email=? ORDER BY email")->limit(1)->execute($strEmail);
                if ($objRecipient->num_rows < 1) {
                    $arrRecipient['email'] = $strEmail;
                } else {
                    $arrRecipient = $objRecipient->row();
                }
                $arrRecipient = array_merge($arrRecipient, array('extra' => '&preview=1', 'tracker_png' => \Environment::get('base') . 'tracking/?n=' . $objNewsletter->id . '&e=' . $strEmail . '&preview=1&t=png', 'tracker_gif' => \Environment::get('base') . 'tracking/?n=' . $objNewsletter->id . '&e=' . $strEmail . '&preview=1&t=gif', 'tracker_css' => \Environment::get('base') . 'tracking/?n=' . $objNewsletter->id . '&e=' . $strEmail . '&preview=1&t=css', 'tracker_js' => \Environment::get('base') . 'tracking/?n=' . $objNewsletter->id . '&e=' . $strEmail . '&preview=1&t=js'));
                // Send
                $objEmail = $this->generateEmailObject($objNewsletter, $arrAttachments);
                $objNewsletter->email = $strEmail;
                $this->sendNewsletter($objEmail, $objNewsletter, $arrRecipient, $text, $html);
                // Redirect
                \Message::addConfirmation(sprintf($GLOBALS['TL_LANG']['tl_newsletter']['confirm'], 1));
                $this->redirect($referer);
            }
            // Get the total number of recipients
            $objTotal = $this->Database->prepare("SELECT COUNT(DISTINCT email) AS count FROM tl_newsletter_recipients WHERE pid=? AND active=1")->execute($objNewsletter->pid);
            // Return if there are no recipients
            if ($objTotal->count < 1) {
                $this->Session->set('tl_newsletter_send', null);
                \Message::addError($GLOBALS['TL_LANG']['tl_newsletter']['error']);
                $this->redirect($referer);
            }
            $intTotal = $objTotal->count;
            // Get page and timeout
            $intTimeout = \Input::get('timeout') > 0 ? \Input::get('timeout') : 1;
            $intStart = \Input::get('start') ? \Input::get('start') : 0;
            $intPages = \Input::get('mpc') ? \Input::get('mpc') : 10;
            // Get recipients
            $objRecipients = $this->Database->prepare("SELECT *, r.email FROM tl_newsletter_recipients r LEFT JOIN tl_member m ON(r.email=m.email) WHERE r.pid=? AND r.active=1 GROUP BY r.email ORDER BY r.email")->limit($intPages, $intStart)->execute($objNewsletter->pid);
            echo '<div style="font-family:Verdana,sans-serif;font-size:11px;line-height:16px;margin-bottom:12px">';
            // Send newsletter
            if ($objRecipients->numRows > 0) {
                // Update status
                if ($intStart == 0) {
                    $this->Database->prepare("UPDATE tl_newsletter SET sent=1, date=? WHERE id=?")->execute(time(), $objNewsletter->id);
                    $_SESSION['REJECTED_RECIPIENTS'] = array();
                }
                while ($objRecipients->next()) {
                    $objEmail = $this->generateEmailObject($objNewsletter, $arrAttachments);
                    $objNewsletter->email = $objRecipients->email;
                    $arrRecipient = array_merge($objRecipients->row(), array('tracker_png' => \Environment::get('base') . 'tracking/?n=' . $objNewsletter->id . '&e=' . $objRecipients->email . '&t=png', 'tracker_gif' => \Environment::get('base') . 'tracking/?n=' . $objNewsletter->id . '&e=' . $objRecipients->email . '&t=gif', 'tracker_css' => \Environment::get('base') . 'tracking/?n=' . $objNewsletter->id . '&e=' . $objRecipients->email . '&t=css', 'tracker_js' => \Environment::get('base') . 'tracking/?n=' . $objNewsletter->id . '&e=' . $objRecipients->email . '&t=js'));
                    $this->sendNewsletter($objEmail, $objNewsletter, $arrRecipient, $text, $html);
                    echo 'Sending newsletter to <strong>' . $objRecipients->email . '</strong><br>';
                }
            }
            echo '<div style="margin-top:12px">';
            // Redirect back home
            if ($objRecipients->numRows < 1 || $intStart + $intPages >= $intTotal) {
                $this->Session->set('tl_newsletter_send', null);
                // Deactivate rejected addresses
                if (!empty($_SESSION['REJECTED_RECIPIENTS'])) {
                    $intRejected = count($_SESSION['REJECTED_RECIPIENTS']);
                    \Message::addInfo(sprintf($GLOBALS['TL_LANG']['tl_newsletter']['rejected'], $intRejected));
                    $intTotal -= $intRejected;
                    foreach ($_SESSION['REJECTED_RECIPIENTS'] as $strRecipient) {
                        $this->Database->prepare("UPDATE tl_newsletter_recipients SET active='' WHERE email=?")->execute($strRecipient);
                        $this->log('Recipient address "' . $strRecipient . '" was rejected and has been deactivated', __METHOD__, TL_ERROR);
                    }
                }
                $this->Database->prepare("UPDATE tl_newsletter SET recipients=?, rejected=? WHERE id=?")->execute($intTotal, $intRejected, $objNewsletter->id);
                \Message::addConfirmation(sprintf($GLOBALS['TL_LANG']['tl_newsletter']['confirm'], $intTotal));
                echo '<script>setTimeout(\'window.location="' . \Environment::get('base') . $referer . '"\',1000)</script>';
                echo '<a href="' . \Environment::get('base') . $referer . '">Please click here to proceed if you are not using JavaScript</a>';
            } else {
                $url = preg_replace('/&(amp;)?(start|mpc|recipient)=[^&]*/', '', \Environment::get('request')) . '&start=' . ($intStart + $intPages) . '&mpc=' . $intPages;
                echo '<script>setTimeout(\'window.location="' . \Environment::get('base') . $url . '"\',' . $intTimeout * 1000 . ')</script>';
                echo '<a href="' . \Environment::get('base') . $url . '">Please click here to proceed if you are not using JavaScript</a>';
            }
            echo '</div></div>';
            exit;
        }
        $strToken = md5(uniqid(mt_rand(), true));
        $this->Session->set('tl_newsletter_send', $strToken);
        $sprintf = $objNewsletter->senderName != '' ? $objNewsletter->senderName . ' &lt;%s&gt;' : '%s';
        $this->import('BackendUser', 'User');
        // prepare preview
        $preview = $text;
        if (!$objNewsletter->sendText) {
            // Default template
            if ($objNewsletter->template == '') {
                $objNewsletter->template = 'mail_default';
            }
            // Load the mail template
            $objTemplate = new \BackendTemplate($objNewsletter->template);
            $objTemplate->setData($objNewsletter->row());
            $objTemplate->title = $objNewsletter->subject;
            $objTemplate->body = $html;
            $objTemplate->charset = $GLOBALS['TL_CONFIG']['characterSet'];
            $objTemplate->css = $css;
            // Backwards compatibility
            // Parse template
            $preview = $objTemplate->parse();
        }
        // Replace inserttags
        $arrName = explode(' ', $this->User->name);
        $preview = $this->replaceInsertTags($preview);
        $preview = $this->prepareLinkTracking($preview, $objNewsletter->id, $this->User->email, '&preview=1');
        $preview = $this->parseSimpleTokens($preview, array('firstname' => $arrName[0], 'lastname' => $arrName[sizeof($arrName) - 1], 'street' => 'Königsbrücker Str. 9', 'postal' => '01099', 'city' => 'Dresden', 'phone' => '0351 30966184', 'email' => $this->User->email, 'tracker_png' => \Environment::get('base') . 'tracking/?n=' . $objNewsletter->id . '&e=' . $this->User->email . '&preview=1&t=png', 'tracker_gif' => \Environment::get('base') . 'tracking/?n=' . $objNewsletter->id . '&e=' . $this->User->email . '&preview=1&t=gif', 'tracker_css' => \Environment::get('base') . 'tracking/?n=' . $objNewsletter->id . '&e=' . $this->User->email . '&preview=1&t=css', 'tracker_js' => \Environment::get('base') . 'tracking/?n=' . $objNewsletter->id . '&e=' . $this->User->email . '&preview=1&t=js'));
        // Create cache folder
        if (!file_exists(TL_ROOT . '/system/cache/newsletter')) {
            mkdir(TL_ROOT . '/system/cache/newsletter');
            file_put_contents(TL_ROOT . '/system/cache/newsletter/.htaccess', '<IfModule !mod_authz_core.c>
  Order allow,deny
  Allow from all
</IfModule>
<IfModule mod_authz_core.c>
  Require all granted
</IfModule>');
        }
        // Cache preview
        file_put_contents(TL_ROOT . '/system/cache/newsletter/' . $objNewsletter->alias . '.html', preg_replace('/^\\s+|\\n|\\r|\\s+$/m', '', $preview));
        // Preview newsletter
        $return = '
<div id="tl_buttons">
<a href="' . $this->getReferer(true) . '" class="header_back" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['backBTTitle']) . '" accesskey="b">' . $GLOBALS['TL_LANG']['MSC']['backBT'] . '</a>
</div>

<h2 class="sub_headline">' . sprintf($GLOBALS['TL_LANG']['tl_newsletter']['send'][1], $objNewsletter->id) . '</h2>
' . \Message::generate() . '
<form action="' . ampersand(\Environment::get('script'), true) . '" id="tl_newsletter_send" class="tl_form" method="get">
<div class="tl_formbody_edit tl_newsletter_send">
<input type="hidden" name="do" value="' . \Input::get('do') . '">
<input type="hidden" name="table" value="' . \Input::get('table') . '">
<input type="hidden" name="key" value="' . \Input::get('key') . '">
<input type="hidden" name="id" value="' . \Input::get('id') . '">
<input type="hidden" name="token" value="' . $strToken . '">
<table class="prev_header">
  <tr class="row_0">
    <td class="col_0">' . $GLOBALS['TL_LANG']['tl_newsletter']['from'] . '</td>
    <td class="col_1">' . sprintf($sprintf, $objNewsletter->sender) . '</td>
  </tr>
  <tr class="row_1">
    <td class="col_0">' . $GLOBALS['TL_LANG']['tl_newsletter']['subject'][0] . '</td>
    <td class="col_1">' . $objNewsletter->subject . '</td>
  </tr>
  <tr class="row_2">
    <td class="col_0">' . $GLOBALS['TL_LANG']['tl_newsletter']['template'][0] . '</td>
    <td class="col_1">' . $objNewsletter->template . '</td>
  </tr>' . (!empty($arrAttachments) && is_array($arrAttachments) ? '
  <tr class="row_3">
    <td class="col_0">' . $GLOBALS['TL_LANG']['tl_newsletter']['attachments'] . '</td>
    <td class="col_1">' . implode(', ', $arrAttachments) . '</td>
  </tr>' : '') . '
</table>' . (!$objNewsletter->sendText ? '
<iframe class="preview_html" id="preview_html" seamless border="0" width="703px" height="503px" style="padding:0" src="system/cache/newsletter/' . $objNewsletter->alias . '.html"></iframe>
' : '') . '
<div class="preview_text">
' . nl2br_html5($text) . '
</div>

<div class="tl_tbox">
<div class="w50">
  <h3><label for="ctrl_mpc">' . $GLOBALS['TL_LANG']['tl_newsletter']['mailsPerCycle'][0] . '</label></h3>
  <input type="text" name="mpc" id="ctrl_mpc" value="10" class="tl_text" onfocus="Backend.getScrollOffset()">' . ($GLOBALS['TL_LANG']['tl_newsletter']['mailsPerCycle'][1] && $GLOBALS['TL_CONFIG']['showHelp'] ? '
  <p class="tl_help tl_tip">' . $GLOBALS['TL_LANG']['tl_newsletter']['mailsPerCycle'][1] . '</p>' : '') . '
</div>
<div class="w50">
  <h3><label for="ctrl_timeout">' . $GLOBALS['TL_LANG']['tl_newsletter']['timeout'][0] . '</label></h3>
  <input type="text" name="timeout" id="ctrl_timeout" value="1" class="tl_text" onfocus="Backend.getScrollOffset()">' . ($GLOBALS['TL_LANG']['tl_newsletter']['timeout'][1] && $GLOBALS['TL_CONFIG']['showHelp'] ? '
  <p class="tl_help tl_tip">' . $GLOBALS['TL_LANG']['tl_newsletter']['timeout'][1] . '</p>' : '') . '
</div>
<div class="w50">
  <h3><label for="ctrl_start">' . $GLOBALS['TL_LANG']['tl_newsletter']['start'][0] . '</label></h3>
  <input type="text" name="start" id="ctrl_start" value="0" class="tl_text" onfocus="Backend.getScrollOffset()">' . ($GLOBALS['TL_LANG']['tl_newsletter']['start'][1] && $GLOBALS['TL_CONFIG']['showHelp'] ? '
  <p class="tl_help tl_tip">' . $GLOBALS['TL_LANG']['tl_newsletter']['start'][1] . '</p>' : '') . '
</div>
<div class="w50">
  <h3><label for="ctrl_recipient">' . $GLOBALS['TL_LANG']['tl_newsletter']['sendPreviewTo'][0] . '</label></h3>
  <input type="text" name="recipient" id="ctrl_recipient" value="' . $this->User->email . '" class="tl_text" onfocus="Backend.getScrollOffset()">' . (isset($_SESSION['TL_PREVIEW_MAIL_ERROR']) ? '
  <div class="tl_error">' . $GLOBALS['TL_LANG']['ERR']['email'] . '</div>' : ($GLOBALS['TL_LANG']['tl_newsletter']['sendPreviewTo'][1] && $GLOBALS['TL_CONFIG']['showHelp'] ? '
  <p class="tl_help tl_tip">' . $GLOBALS['TL_LANG']['tl_newsletter']['sendPreviewTo'][1] . '</p>' : '')) . '
</div>
<div class="clear"></div>
</div>
</div>';
        // Do not send the newsletter if there is an attachment format error
        if (!$blnAttachmentsFormatError) {
            $return .= '

<div class="tl_formbody_submit">
<div class="tl_submit_container">
<input type="submit" name="preview" class="tl_submit" accesskey="p" value="' . specialchars($GLOBALS['TL_LANG']['tl_newsletter']['preview']) . '">
<input type="submit" id="send" class="tl_submit" accesskey="s" value="' . specialchars($GLOBALS['TL_LANG']['tl_newsletter']['send'][0]) . '" onclick="return confirm(\'' . str_replace("'", "\\'", $GLOBALS['TL_LANG']['tl_newsletter']['sendConfirm']) . '\')">
</div>
</div>';
        }
        $return .= '

</form>';
        unset($_SESSION['TL_PREVIEW_MAIL_ERROR']);
        return $return;
    }
Exemplo n.º 30
0
    /**
     * Generate the autoload.php files
     */
    protected function createAutoloadFiles()
    {
        $arrModules = \Input::post('modules');
        if (empty($arrModules)) {
            \Message::addError($GLOBALS['TL_LANG']['tl_autoload']['emptySelection']);
            return;
        }
        $intYear = date('Y');
        foreach ($arrModules as $strModule) {
            // The autoload.php file exists
            if (!\Input::post('override') && file_exists(TL_ROOT . '/system/modules/' . $strModule . '/config/autoload.php')) {
                \Message::addInfo(sprintf($GLOBALS['TL_LANG']['tl_autoload']['autoloadExists'], $strModule));
                continue;
            }
            $intClassWidth = 0;
            $arrFiles = array();
            $arrClassLoader = array();
            $arrNamespaces = array();
            // Default configuration
            $arrDefaultConfig = array('register_namespaces' => true, 'register_classes' => true, 'register_templates' => true);
            // Create the autoload.ini file if it does not yet exist
            if (!file_exists(TL_ROOT . '/system/modules/' . $strModule . '/config/autoload.ini')) {
                $objIni = new \File('system/modules/devtools/templates/dev_ini.html5', true);
                $objIni->copyTo('system/modules/' . $strModule . '/config/autoload.ini');
            }
            $arrDefaultConfig = array_merge($arrDefaultConfig, parse_ini_file(TL_ROOT . '/system/modules/' . $strModule . '/config/autoload.ini', true));
            /** @var \SplFileInfo[] $objFiles */
            $objFiles = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(TL_ROOT . '/system/modules/' . $strModule, \FilesystemIterator::UNIX_PATHS | \FilesystemIterator::FOLLOW_SYMLINKS | \FilesystemIterator::SKIP_DOTS));
            // Get all PHP files
            foreach ($objFiles as $objFile) {
                if ($objFile->getExtension() == 'php') {
                    $strRelpath = str_replace(TL_ROOT . '/system/modules/' . $strModule . '/', '', $objFile->getPathname());
                    if (strncmp($strRelpath, 'assets/', 7) !== 0 && strncmp($strRelpath, 'config/', 7) !== 0 && strncmp($strRelpath, 'dca/', 4) !== 0 && strncmp($strRelpath, 'languages/', 10) !== 0 && strncmp($strRelpath, 'templates/', 10) !== 0) {
                        $arrFiles[] = $strRelpath;
                    }
                }
            }
            // Scan for classes
            foreach ($arrFiles as $strFile) {
                $arrConfig = $arrDefaultConfig;
                // Search for a path configuration (see #4776)
                foreach ($arrDefaultConfig as $strPattern => $arrPathConfig) {
                    // Merge the path configuration with the global configuration
                    if (is_array($arrPathConfig) && fnmatch($strPattern, $strFile)) {
                        $arrConfig = array_merge($arrDefaultConfig, $arrPathConfig);
                        break;
                    }
                }
                // Continue if neither namespaces nor classes shall be registered
                if (!$arrConfig['register_namespaces'] && !$arrConfig['register_classes']) {
                    continue;
                }
                $strBuffer = '';
                $arrMatches = array();
                // Store the file size for fread()
                $size = filesize(TL_ROOT . '/system/modules/' . $strModule . '/' . $strFile);
                $fh = fopen(TL_ROOT . '/system/modules/' . $strModule . '/' . $strFile, 'rb');
                // Read until a class or interface definition has been found
                while (!preg_match('/(class|interface|trait) ' . preg_quote(basename($strFile, '.php'), '/') . '/', $strBuffer, $arrMatches) && $size > 0 && !feof($fh)) {
                    $length = min(512, $size);
                    $strBuffer .= fread($fh, $length);
                    $size -= $length;
                    // see #4876
                }
                fclose($fh);
                // The file does not contain a class or interface
                if (empty($arrMatches)) {
                    continue;
                }
                $strNamespace = preg_replace('/^.*namespace ([^; ]+);.*$/s', '$1', $strBuffer);
                // No namespace declaration found
                if ($strNamespace == $strBuffer) {
                    $strNamespace = '';
                }
                unset($strBuffer);
                // Register the namespace
                if ($strNamespace != '') {
                    if ($arrConfig['register_namespaces'] && $strNamespace != 'Contao') {
                        // Register only the first chunk as namespace
                        if (strpos($strNamespace, '\\') !== false) {
                            $arrNamespaces[] = substr($strNamespace, 0, strpos($strNamespace, '\\'));
                        } else {
                            $arrNamespaces[] = $strNamespace;
                        }
                    }
                    $strNamespace .= '\\';
                }
                // Register the class
                if ($arrConfig['register_classes']) {
                    $strKey = $strNamespace . basename($strFile, '.php');
                    $arrClassLoader[$strKey] = 'system/modules/' . $strModule . '/' . $strFile;
                    $intClassWidth = max(strlen($strKey), $intClassWidth);
                }
            }
            $intTplWidth = 0;
            $arrTplLoader = array();
            // Scan for templates
            if (is_dir(TL_ROOT . '/system/modules/' . $strModule . '/templates')) {
                /** @var \SplFileInfo[] $objFiles */
                $objFiles = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(TL_ROOT . '/system/modules/' . $strModule . '/templates', \FilesystemIterator::UNIX_PATHS | \FilesystemIterator::FOLLOW_SYMLINKS | \FilesystemIterator::SKIP_DOTS));
                foreach ($objFiles as $objFile) {
                    $arrConfig = $arrDefaultConfig;
                    $strRelpath = str_replace(TL_ROOT . '/system/modules/' . $strModule . '/', '', $objFile->getPathname());
                    // Search for a path configuration (see #4776)
                    foreach ($arrDefaultConfig as $strPattern => $arrPathConfig) {
                        // Merge the path configuration with the global configuration
                        if (is_array($arrPathConfig) && fnmatch($strPattern, $strRelpath)) {
                            $arrConfig = array_merge($arrDefaultConfig, $arrPathConfig);
                            break;
                        }
                    }
                    // Continue if templates shall not be registered
                    if (!$arrConfig['register_templates']) {
                        continue;
                    }
                    $arrTplExts = trimsplit(',', strtolower(\Config::get('templateFiles')));
                    // Add all known template types (see #5857)
                    if (in_array(strtolower($objFile->getExtension()), $arrTplExts)) {
                        $strRelpath = str_replace(TL_ROOT . '/', '', $objFile->getPathname());
                        $strKey = basename($strRelpath, strrchr($strRelpath, '.'));
                        $arrTplLoader[$strKey] = dirname($strRelpath);
                        $intTplWidth = max(strlen($strKey), $intTplWidth);
                    }
                }
            }
            // Neither classes nor templates found
            if (empty($arrNamespaces) && empty($arrClassLoader) && empty($arrTplLoader)) {
                continue;
            }
            $objFile = new \File('system/modules/' . $strModule . '/config/autoload.php', true);
            $objFile->write(<<<EOT
<?php

/**
 * Contao Open Source CMS
 *
 * Copyright (c) 2005-{$intYear} Leo Feyer
 *
 * @license LGPL-3.0+
 */

EOT
);
            // Namespaces
            if (!empty($arrNamespaces)) {
                $arrNamespaces = array_unique($arrNamespaces);
                if (!empty($arrNamespaces)) {
                    $objFile->append(<<<EOT


/**
 * Register the namespaces
 */
ClassLoader::addNamespaces(array
(
EOT
);
                    foreach ($arrNamespaces as $strNamespace) {
                        $objFile->append("\t'" . $strNamespace . "',");
                    }
                    $objFile->append('));');
                }
            }
            // Classes
            if (!empty($arrClassLoader)) {
                $objFile->append(<<<EOT


/**
 * Register the classes
 */
ClassLoader::addClasses(array
(
EOT
);
                $strGroup = null;
                foreach ($arrClassLoader as $strClass => $strPath) {
                    $strRelpath = str_replace('system/modules/' . $strModule . '/', '', $strPath);
                    $strBasedir = substr($strRelpath, 0, strpos($strRelpath, '/'));
                    if ($strBasedir != '') {
                        if ($strGroup === null) {
                            $strGroup = $strBasedir;
                            $objFile->append("\t// " . ucfirst($strBasedir));
                        } elseif ($strBasedir != $strGroup) {
                            $strGroup = $strBasedir;
                            $objFile->append("\n\t// " . ucfirst($strBasedir));
                        }
                    }
                    $strClass = "'" . $strClass . "'";
                    $objFile->append("\t" . str_pad($strClass, $intClassWidth + 2) . " => '{$strPath}',");
                }
                $objFile->append('));');
            }
            // Templates
            if (!empty($arrTplLoader)) {
                $objFile->append(<<<EOT


/**
 * Register the templates
 */
TemplateLoader::addFiles(array
(
EOT
);
                foreach ($arrTplLoader as $strName => $strPath) {
                    $strName = "'" . $strName . "'";
                    $objFile->append("\t" . str_pad($strName, $intTplWidth + 2) . " => '{$strPath}',");
                }
                $objFile->append('));');
            }
            $objFile->close();
            \Message::addConfirmation(sprintf($GLOBALS['TL_LANG']['tl_autoload']['autoloadConfirm'], $strModule));
        }
    }