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'); }
protected function collect($sCollectFunctionName, $bCheckAccess = false) { global $oSecurity; // echo '1'; $sPath = PATH_MODULES; $aDirectories = CDir::getDirs($sPath, false, false, false); foreach ($aDirectories as $module) { if (file_exists($sPath . "{$module}/m.{$module}.class.php")) { require_once $sPath . "{$module}/m.{$module}.class.php"; if (class_exists('M_' . $module) && method_exists('M_' . $module, $sCollectFunctionName)) { if ($bCheckAccess && !$oSecurity->haveAccessToModuleToMethod($module)) { continue; } call_user_func(array('M_' . $module, $sCollectFunctionName)); } } } //core modules $sPath = PATH_CORE . 'modules' . DIRECTORY_SEPARATOR; $aDirectories = CDir::getDirs($sPath, false, false, false); foreach ($aDirectories as $module) { if (file_exists($sPath . "{$module}/m.{$module}.class.php")) { require_once $sPath . "{$module}/m.{$module}.class.php"; if (class_exists('M_' . $module) && method_exists('M_' . $module, $sCollectFunctionName)) { call_user_func(array('M_' . $module, $sCollectFunctionName)); } } } // $cache_lite->save( $oMenu->items, 'cmenu::getusercollection'); }
function create($type) { $docManifestNode =& $this->xml->createElement("manifest:manifest"); $docManifestNode->setAttribute("xmlns:manifest", "http://openoffice.org/2001/manifest"); $fileEntryNode =& $this->xml->createElement("manifest:file-entry"); if (in_array($type, $this->XMLTYPE)) { $fileEntryNode->setAttribute("manifest:media-type", "application/" . $this->MIME[$type]); } else { $this->ErrorTracker(4, 'Le type ' . $type . " est inconnu", 'create', __FILE__, __LINE__); } $fileEntryNode->setAttribute("manifest:full-path", "/"); $docManifestNode->appendChild($fileEntryNode); $cdir = new CDir(); $cdir->Read($this->DIRXML . "/", "", true, 5, true, true); $allFiles = array(); $sortFiles = $cdir->sort("'Path'", false, 4, "'File'", true, 0); reset($sortFiles); while (list($sKey, $aFile) = each($sortFiles)) { $sFileName = $cdir->FileName($aFile); $sFilePath = $cdir->GetPath($aFile); $mediaType = ""; $sExtension = ""; $fileEntryNode =& $this->xml->createElement("manifest:file-entry"); $i = strrpos($sFileName, ".") + 1; if (substr($sFileName, $i - 1, 1) == ".") { $sExtension = substr($sFileName, $i); } switch ($sExtension) { case "": $mediaType = ""; break; case "png": case "gif": case "jpeg": $mediaType = "image/" . $sExtension; break; default: $mediaType = "text/xml"; } // switch $dirname = dirname($this->DIRXML . "/" . $sFilePath . $sFileName); $filename = basename($this->DIRXML . "/" . $sFilePath . $sFileName); if ($dirname != $this->DIRXML) { $filename = str_replace($this->DIRXML . "/", "", $dirname) . "/" . $filename; } else { if ($cdir->GetIsDirectory($aFile)) { $filename = $filename . "/"; } } $fileEntryNode->setAttribute("manifest:media-type", $mediaType); $fileEntryNode->setAttribute("manifest:full-path", $filename); $docManifestNode->appendChild($fileEntryNode); } $this->xml->setDocumentElement($docManifestNode); $this->xml->setXMLDeclaration("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); }
function listFiles() { $cdir = new CDir(); $cdir->Read($this->tmpdir . "/", "", true, 5, true, true); $allFiles = array(); reset($cdir->aFiles); while (list($sKey, $aFile) = each($cdir->aFiles)) { $sFileName = $cdir->FileName($aFile); $sFilePath = $cdir->GetPath($aFile); $allFiles[] = $this->tmpdir . "/" . $sFilePath . $sFileName; } return $allFiles; }
function thanks() { return CDir::getFileContent(PATH_BASE . 'modules/forms/tpl/thanks.htm'); }
/** * удаление забытых скриншотов :) * @param array модули (path, table) */ function deletelost() { global $oDb; if (!func_num_args()) { return; } $i = 0; clearstatcache(); $modules = func_get_args(); foreach ($modules as $module) { $previews = $oDb->select_one_column('SELECT CONCAT(id, "_", ' . $this->fieldPreview . ') FROM ' . $module['table'] . ' WHERE ' . $this->fieldPreview . '!="" '); $previews[] = 'default.gif'; $aFiles = CDir::getFiles($module['path'], false, false); foreach ($aFiles as $f) { if (!in_array($f, $previews)) { $i++; @unlink($module['path'] . '/' . $f); } } } return $i; }
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'); }
/** * Сохранение шаблона письма в файл * @param string ключ шаблона * @param array (body=>string, subject=>string) данные шаблона */ function saveMailTemplateToFile($sTemplateKey, $aTemplateData) { return CDir::putFileContent(SENDMAIL_TEMPLATES_PATH . $sTemplateKey . SENDMAIL_TEMPLATES_EXT, serialize($aTemplateData)); }
/** * удаление забытых аватар :) * @param array модули (path, table) */ function deletelost() { global $oDb; if (!func_num_args()) { return; } $i = 0; clearstatcache(); $modules = func_get_args(); foreach ($modules as $module) { $avatars = $oDb->select_one_column("SELECT (id || '_' || avatar) FROM \"{$module['table']}\" WHERE avatar!='' "); $avatars[] = 'default.gif'; $aFiles = CDir::getFiles($module['path'], false, false); foreach ($aFiles as $f) { if (!in_array($f, $avatars)) { $i++; @unlink($module['path'] . '/' . $f); } } } return $i; }
function mm_add() { if (!FORDEV || !$this->security->isSuperAdmin()) { return $this->showAccessDenied(); } $aData = array('method' => '', 'title' => '', 'module' => ''); if (Func::isPostMethod()) { $sMethod = Func::POST('method', true); $sTitle = Func::POST('title', true); $sModule = $this->db->str2sql(Func::POST('module')); Func::setSESSION('save_module', $sModule); if (!$sMethod) { $sMethod = $sModule; } if (!$sTitle) { $sTitle = ucwords($sModule . ' ' . $sMethod); } //get max module number $nNumber = (int) $this->db->one_data('SELECT max(number) FROM ' . TABLE_MODULE_METHODS . " \n WHERE module={$sModule} AND method!={$sModule} "); $nNumber++; //insert module-method $this->db->execute('INSERT INTO ' . TABLE_MODULE_METHODS . " (module, method, title, number)\n VALUES ({$sModule}, " . $this->db->str2sql($sMethod) . ', ' . $this->db->str2sql($sTitle) . ", {$nNumber})"); if ($this->errors->no()) { $this->adminRedirect(Errors::SUCCESSFULL, 'mm_listing'); } } if (!$aData['module']) { $aData['module'] = Func::SESSION('save_module'); } $aModules = CDir::getDirs(PATH_MODULES, false, false, false); foreach ($aModules as $k => $v) { if ($v[0] != '.' && $v[0] != '_') { $aModules[$v] = $v; } unset($aModules[$k]); } $this->tplAssign(array('aModules' => $aModules, 'aData' => $aData)); return $this->tplFetch('admin.mm.create.tpl'); }
/** * удаление забытых вложений :) * @param string */ function _clearlost($aAttachments = array()) { $i = 0; clearstatcache(); $filesALL = CDir::getFiles($this->path, false, false); foreach ($filesALL as $file) { list($file, $size, $ext) = explode(';', $file); if (!in_array($file, $aAttachments)) { $i++; @unlink($this->path . $file); } } return $i; }