Beispiel #1
1
 function show($nPageID = null)
 {
     $nRecordID = !isset($nPageID) ? func::POSTGET('page') : (int) $nPageID;
     $aData = $this->db->one_array('SELECT title, mkeywords, mdescription, filename 
                               FROM ' . TABLE_PAGES . ' 
                               WHERE filename = ' . $this->db->str2sql($nRecordID) . ' 
                               LIMIT 1');
     if (empty($aData)) {
         Errors::httpError(404);
     }
     //get page content
     $aData['content'] = CDir::getFileContent(PAGES_PATH . $aData['filename'] . PAGES_EXTENSION);
     config::set(array('title' => $aData['title'] . ' | ' . config::get('title', ''), 'mkeywords' => $aData['mkeywords'], 'mdescription' => $aData['mdescription']));
     if ($aData['content'] === false) {
         Errors::httpError(404);
     }
     $aData['menu'] = bff::i()->Sitemap_getmenu('info', 'all-sub');
     // echo '<pre>', print_r($aData['menu'], true), '</pre>'; exit;
     $this->tplAssign('aData', $aData);
     return $this->tplFetch('page.tpl');
 }
Beispiel #2
0
 /**
  * Получение шаблона письма из файла                                                    
  * @param string ключ шаблона
  * @return array (body=>string, subject=>string)
  */
 function getMailTemplateFromFile($sTemplateKey)
 {
     static $cache = array();
     if (!empty($cache[$sTemplateKey])) {
         return $cache[$sTemplateKey];
     }
     # получаем шаблон письма
     $sContent = CDir::getFileContent(SENDMAIL_TEMPLATES_PATH . $sTemplateKey . SENDMAIL_TEMPLATES_EXT);
     if (!$sContent) {
         # нигде не нашли, восстанавливаем
         if ($this->restoreMailTemplateFile($sTemplateKey) !== false) {
             $sContent = CDir::getFileContent(SENDMAIL_TEMPLATES_PATH . $sTemplateKey . SENDMAIL_TEMPLATES_EXT);
         }
     }
     $sContentUn = !empty($sContent) ? @unserialize($sContent) : false;
     if (is_array($sContentUn)) {
         //un-сериализация прошла успешно
         $sContent = $sContentUn;
     }
     //сохраняем в кеш и возвращаем шаблон
     return $cache[$sTemplateKey] = is_array($sContent) ? $sContent : array('body' => $sContent, 'subject' => '');
 }
Beispiel #3
0
 function thanks()
 {
     return CDir::getFileContent(PATH_BASE . 'modules/forms/tpl/thanks.htm');
 }
Beispiel #4
0
 function edit()
 {
     if (!$this->haveAccessTo('edit')) {
         return $this->showAccessDenied();
     }
     $aData = array('content' => '', 'title' => '', 'filename' => '');
     $nRecordID = func::POSTGET('rec', false, true);
     if ($nRecordID <= 0) {
         $this->adminRedirect(Errors::IMPOSSIBLE);
     }
     if (func::isPostMethod()) {
         $sFilename = func::POST('filename', true);
         $sTitle = func::POST('title', true);
         $sMetaDescription = func::POST('mdescription', true);
         $sMetaKeywords = func::POST('mkeywords', true);
         $sContent = stripslashes(func::POST('content'));
         $sContent = eregi_replace('\\\\"', '"', $sContent);
         $sContent = eregi_replace('\\"', '"', $sContent);
         $sContent = eregi_replace('\\"', '"', $sContent);
         $sFilename = $this->db->one_data('SELECT filename FROM ' . TABLE_PAGES . ' WHERE id=' . $nRecordID . ' LIMIT 1');
         if ($this->errors->no()) {
             CDir::putFileContent(PAGES_PATH . $sFilename . PAGES_EXTENSION, $sContent);
             if (BFF_GENERATE_META_AUTOMATICALY) {
                 if ((empty($sMetaKeywords) || empty($sMetaDescription)) && !empty($sContent)) {
                     func::generateMeta($sContent, $aData);
                     if (empty($sMetaDescription)) {
                         $sMetaDescription = $aData['mdescription'];
                     }
                     if (empty($sMetaKeywords)) {
                         $sMetaKeywords = $aData['mkeywords'];
                     }
                 }
             }
             $this->db->execute('UPDATE ' . TABLE_PAGES . '
                              SET title = ' . $this->db->str2sql($sTitle) . ', 
                                  mkeywords = ' . $this->db->str2sql($sMetaKeywords) . ',
                                  mdescription = ' . $this->db->str2sql($sMetaDescription) . ", \n                                     modified = {$this->db->getNOW()}\n                                 WHERE id={$nRecordID}");
             $this->adminRedirect(Errors::SUCCESSFULL);
         }
         $aData = $_POST;
     } else {
         $aData = $this->db->one_array('SELECT * FROM ' . TABLE_PAGES . ' WHERE id=' . $nRecordID . ' LIMIT 1');
         $aData['content'] = CDir::getFileContent(PAGES_PATH . $aData['filename'] . PAGES_EXTENSION);
     }
     $this->tplAssign('aData', $aData);
     return $this->tplFetch('admin.form.tpl');
 }