Пример #1
0
 function storeId()
 {
     $ext_name = JRequest::getVar('ext');
     $download_id = JRequest::getVar('downloadid', '');
     $db = JFactory::getDBO();
     if (is_null($ext_name)) {
         return false;
     }
     $query = $db->getQuery(true);
     $query->select('state, params')->from('#__extensions')->where('(state>=0 OR state=-2)')->where('enabled=1')->where('type=' . $db->quote('sef_ext'))->where('element=' . $db->quote($ext_name));
     $db->setQuery($query);
     $ext = $db->loadObject();
     $params = new JRegistry(isset($ext->params) ? $ext->params : null);
     $params->set('downloadId', JRequest::getVar('downloadid', ''));
     $nparams = $params->toString();
     $query = $db->getQuery(true);
     if (isset($ext->state)) {
         $query->update('#__extensions')->set('params=' . $db->quote($nparams))->where('(state>=0 OR state=-2)')->where('enabled=1')->where('type=' . $db->quote('sef_ext'))->where('element=' . $db->quote($ext_name));
     } else {
         $query->insert('#__extensions')->set('params=' . $db->quote($nparams))->set('state=-2')->set('type=' . $db->quote('sef_ext'))->set('element=' . $db->quote($ext_name));
     }
     $db->setQuery($query);
     if (!$db->query()) {
         echo $db->stderr(true);
         $this->setError($db->stderr(true));
         return false;
     }
     if (isset($ext->state) && $ext->state >= 0) {
         if (!AUpdateHelper::setUpdateLink($ext_name, $download_id)) {
             return false;
         }
     }
     jexit();
 }
Пример #2
0
 /**
  * Method to store a record
  *
  * @access    public
  * @return    boolean    True on success
  */
 function store()
 {
     $db =& JFactory::getDBO();
     $sefConfig =& SEFConfig::getConfig();
     $sef_config_file = JPATH_COMPONENT . '/' . 'configuration.php';
     // Get POST variables through Joomla API to correctly support magic_quotes_gpc
     $post = JRequest::get('POST', JREQUEST_NOTRIM | JREQUEST_ALLOWRAW);
     // Unset the empty meta tags
     if (isset($post['metanames']) && is_array($post['metanames'])) {
         for ($i = 0, $n = count($post['metanames']); $i < $n; $i++) {
             if (empty($post['metanames'][$i])) {
                 unset($post['metanames'][$i]);
                 if (isset($post['metacontents'][$i])) {
                     unset($post['metacontents'][$i]);
                 }
             }
         }
         // Create the associative array of custom meta tags
         $post['customMetaTags'] = array_combine($post['metanames'], $post['metacontents']);
     } else {
         // No meta tags
         $post['customMetaTags'] = array();
     }
     // Parse the sitemap ping services
     if (isset($post['sitemap_services']) && !empty($post['sitemap_services'])) {
         $services = str_replace("\r", '', $post['sitemap_services']);
         $services = array_map('trim', explode("\n", $services));
         $post['sitemap_services'] = $services;
     } else {
         $post['sitemap_services'] = array();
     }
     // Check empty google_exclude_level
     if (!isset($post['google_exclude_level'])) {
         $post['google_exclude_level'] = array();
     }
     // Set values
     foreach ($post as $key => $value) {
         $sefConfig->set($key, $value);
     }
     // 404
     $sql = 'SELECT id,language  FROM #__content WHERE `title` = "404"';
     $db->setQuery($sql);
     $introtext = $post['introtext'];
     if ($page404 = $db->loadObject()) {
         $sql = 'UPDATE #__content SET introtext=' . $db->quote($introtext) . ',  modified =' . $db->quote(date("Y-m-d H:i:s")) . ($page404->language == '' ? ', language="*"' : '') . ' WHERE `id` = ' . $db->quote($page404->id) . ';';
     } else {
         $sql = 'INSERT INTO #__content (title, alias, introtext, `fulltext`, state, catid, created, created_by, created_by_alias, modified, modified_by, publish_up, publish_down, images, urls, attribs, version, ordering, metakey, metadesc, access, hits, language) ' . 'VALUES ("404", "404", ' . $db->quote($introtext) . ', "", "1", "0", ' . $db->quote(date("Y-m-d H:i:s")) . ', "42", "", "0000-00-00 00:00:00", "0", "2001-01-01 00:00:00", "0000-00-00 00:00:00", "", "", "menu_image=-1\\nitem_title=0\\npageclass_sfx=\\nback_button=\\nrating=0\\nauthor=0\\ncreatedate=0\\nmodifydate=0\\npdf=0\\nprint=0\\nemail=0", "1", "0", "", "", "1", "0", "*");';
     }
     $db->setQuery($sql);
     if (!$db->query()) {
         echo "<script> alert('" . addslashes($db->getErrorMsg()) . "'); window.history.go(-1); </script>\n";
         exit;
     }
     // Check the domains configuration
     if (count($sefConfig->jfSubDomains)) {
         foreach ($sefConfig->jfSubDomains as $code => $domain) {
             $domain = str_replace(array('http://', 'https://'), '', $domain);
             $domain = preg_replace('#/.*$#', '', $domain);
             $sefConfig->jfSubDomains[$code] = $domain;
         }
     }
     $subdomains = JRequest::getVar('subdomain', array(), 'post', 'array');
     $query = "DELETE FROM #__sef_subdomains \n";
     $query .= "WHERE `option`=" . $this->_db->quote("");
     $this->_db->setQuery($query);
     if (!$this->_db->query()) {
         $this->setError($this->_db->stderr(true));
         return false;
     }
     if (is_array($subdomains['title'])) {
         foreach ($subdomains["title"] as $lang => $items) {
             foreach ($items as $i => $item) {
                 $query = "INSERT INTO #__sef_subdomains SET subdomain=" . $this->_db->quote($item) . ", Itemid=" . $this->_db->quote(implode(",", $subdomains["Itemid"][$lang][$i])) . ", \n";
                 $query .= "Itemid_titlepage=" . $this->_db->quote($subdomains["titlepage"][$lang][$i]) . ", lang=" . $this->_db->quote($lang) . " \n";
                 $this->_db->setQuery($query);
                 if (!$this->_db->query()) {
                     $this->setError($this->_db->stderr(true));
                     return false;
                 }
             }
         }
     }
     if (!AUpdateHelper::setUpdateLink('com_joomsef', $sefConfig->artioDownloadId)) {
         return false;
     }
     $config_written = $sefConfig->saveConfig(0);
     if ($config_written != 0) {
         if ($sefConfig->langEnable) {
             $query = $db->getQuery(true);
             $query->select('enabled')->from('#__extensions')->where('element=' . $db->quote('languagefilter'));
             $db->setQuery($query);
             $enabled = $db->loadResult();
             if ($enabled == 1) {
                 JError::raiseWarning('', JText::_('COM_JOOMSEF_DISABLE_LANGUAGEFILTER'));
             }
         }
         return true;
     } else {
         return false;
     }
 }
Пример #3
0
 /**
  * Create object and load JoomDOC configuration.
  *
  * @return void
  */
 public function __construct($path = null)
 {
     $params = JComponentHelper::getParams(JOOMDOC_OPTION);
     /* @var $params JRegistry */
     $mainframe = JFactory::getApplication();
     /* @var $mainframe JApplication */
     $defaultDocRoot = JPATH_ROOT . DIRECTORY_SEPARATOR . 'documents';
     $maskDocRoot = '[%DOCROOT%]';
     $this->docroot = JPath::clean(JString::trim($params->get('docroot', $defaultDocRoot)));
     if (JFile::exists(JOOMDOC_CONFIG) && is_writable(JOOMDOC_CONFIG)) {
         $content = JFile::read(JOOMDOC_CONFIG);
         if (JString::strpos($content, $maskDocRoot) !== false) {
             $content = str_replace($maskDocRoot, $defaultDocRoot, $content);
             JFile::write(JOOMDOC_CONFIG, $content);
         }
     }
     $this->docrootrel = str_replace(JPATH_ROOT . DIRECTORY_SEPARATOR, '', $this->docroot);
     if (!JFolder::exists($this->docroot)) {
         if (!JFolder::create($this->docroot)) {
             if ($mainframe->isAdmin()) {
                 JError::raiseWarning(21, JText::sprintf('JOOMDOC_UNABLE_CREATE_DOCROOT', $this->docroot));
             }
             $this->docroot = false;
         } elseif ($mainframe->isAdmin()) {
             $mainframe->enqueueMessage(JText::sprintf('JOOMDOC_DOCROOT_CREATED', $this->docroot));
         }
     }
     $this->downloadId = JString::trim($params->get('download_id', ''));
     AUpdateHelper::setUpdateLink('ARTIO JoomDOC Updates', $this->downloadId);
     $this->defaultTitle = JString::trim($params->get('default_title'));
     $this->defaultDescription = JString::trim($params->get('default_description'));
     $this->defaultMetakeywords = JString::trim($params->get('default_metakeywords'));
     $this->defaultMetadescription = JString::trim($params->get('default_metadescription'));
     $this->versionFile = 0;
     $this->versionDocument = 0;
     $this->versionFileFrontend = 0;
     $this->versionRequired = 0;
     $this->displayFavorite = (int) $params->get('display_favorite', 1);
     $this->webdavAllow = (int) $params->get('webdav_allow', 25);
     $this->displaySignature = (int) $params->get('display_signature', 1);
     $this->path = $this->docroot;
     $this->documentOrdering = JOOMDOC_ORDER_ORDERING;
     $this->fileOrdering = JOOMDOC_ORDER_PATH;
     $this->orderingDirection = JString::trim($params->get('ordering_direction')) == 'asc' ? JOOMDOC_ORDER_ASC : JOOMDOC_ORDER_DESC;
     $this->foldersFirstSite = (bool) $params->get('folders_first_site', 0);
     $this->foldersFirstAdmin = (bool) $params->get('folders_first_admin', 0);
     if (!($this->iconTheme = JString::trim($params->get('icon_theme', 'default')))) {
         $this->iconTheme = 'default';
     }
     //fallback
     if (!($this->iconThemeBackend = JString::trim($params->get('icon_theme_backend', 'default')))) {
         $this->iconThemeBackend = 'default';
     }
     //fallback
     $this->docLayout = JString::trim($params->get('document_layout', 0));
     $this->docLayout = 0;
     //not done now
     $this->useWebdav = (int) $params->get('use_webdav', 0);
     $this->webdavType = (int) $params->get('webdav_type', 1);
     $this->accessHandling = (int) $params->get('access_handling', 1);
     $this->fileDeleting = (int) $params->get('file_deleting', 1);
     $this->fileDocumentAutomatically = (int) $params->get('file_document_automatically', 0);
     $this->editDocumentImmediately = (int) $params->get('edit_document_immediately', 0);
     $this->useSearch = (int) $params->get('use_search', 0);
     $this->searchShowParent = (int) $params->get('search_show_parent', 1);
     $this->searchKeyword = (int) $params->get('search_keyword', 1);
     $this->searchShowTitle = (int) $params->get('search_show_title', 1);
     $this->searchShowText = (int) $params->get('search_show_text', 1);
     $this->searchShowMetadata = (int) $params->get('search_show_metadata', 1);
     $this->searchShowFulltext = (int) $params->get('search_show_fulltext', 1);
     $this->searchShowType = (int) $params->get('search_show_type', 1);
     $this->searchTypes = (array) $params->get('search_types', array(JOOMDOC_SEARCH_ANYKEY, JOOMDOC_SEARCH_ALLKEY, JOOMDOC_SEARCH_PHRASE, JOOMDOC_SEARCH_REGEXP));
     $this->searchTypeAnykey = in_array(JOOMDOC_SEARCH_ANYKEY, $this->searchTypes);
     $this->searchTypeAllkey = in_array(JOOMDOC_SEARCH_ALLKEY, $this->searchTypes);
     $this->searchTypePhrase = in_array(JOOMDOC_SEARCH_PHRASE, $this->searchTypes);
     $this->searchTypeRegexp = in_array(JOOMDOC_SEARCH_REGEXP, $this->searchTypes);
     $this->searchDefaultType = (int) $params->get('search_default_type', JOOMDOC_SEARCH_ANYKEY);
     $this->searchShowOrder = (int) $params->get('search_show_order', 1);
     $this->searchOrders = (array) $params->get('search_orders', array(JOOMDOC_ORDER_NEWEST, JOOMDOC_ORDER_OLDEST, JOOMDOC_ORDER_HITS, JOOMDOC_ORDER_TITLE));
     $this->searchOrderNewest = in_array(JOOMDOC_ORDER_NEWEST, $this->searchOrders);
     $this->searchOrderOldest = in_array(JOOMDOC_ORDER_OLDEST, $this->searchOrders);
     $this->searchOrderHits = in_array(JOOMDOC_ORDER_HITS, $this->searchOrders);
     $this->searchOrderTitle = in_array(JOOMDOC_ORDER_TITLE, $this->searchOrders);
     $this->searchDefaultOrder = $params->get('search_default_order', JOOMDOC_ORDER_NEWEST);
     $this->useExplorer = (int) $params->get('use_explorer', 1);
     $this->explorerRoot = JString::trim($params->get('explorer_root', 'Documents'));
     $this->documentAccess = (int) $params->get('document_access', 1);
     $this->edocsList = (int) $params->get('edocs_list', 0);
     $this->edocsDetail = (int) $params->get('edocs_detail', 0);
     if ($mainframe->isSite()) {
         $menu = $mainframe->getMenu();
         /* @var $menu JMenuSite */
         $itemID = $path ? JoomDOCMenu::getMenuItemID($path) : null;
         $itemID = $itemID ? $itemID : JRequest::getInt('Itemid');
         $item = $itemID ? $menu->getItem($itemID) : $menu->getActive();
         if (is_object($item)) {
             if (isset($item->query['path'])) {
                 // get start folder from menu item URL (param path)
                 $path = JString::trim($item->query['path']);
                 if ($path) {
                     $path = JPath::clean($this->docroot . DIRECTORY_SEPARATOR . $path);
                     if (JFolder::exists($path) || JFile::exists($path)) {
                         $this->path = $path;
                     } else {
                         $this->path = false;
                     }
                 }
             }
             $params->merge($item->params);
             // get display options from menu item setting
             $this->showSubfolders = (int) $params->get('show_subfolders', 1);
             $this->filesWithoutDoc = (int) $params->get('files_without_doc', 1);
             $this->documentOrdering = $params->get('document_ordering', JOOMDOC_ORDER_ORDERING);
             $this->orderingDirection = JString::trim($params->get('ordering_direction')) == 'asc' ? JOOMDOC_ORDER_ASC : JOOMDOC_ORDER_DESC;
             $this->fileOrdering = $params->get('file_ordering', JOOMDOC_ORDER_PATH);
             $this->showFileicon = (int) $params->get('show_fileicon', 1);
             $this->showFilesize = (int) $params->get('show_filesize', 1);
             $this->showCreated = (int) $params->get('show_created', 1);
             $this->showModified = (int) $params->get('show_modified', 1);
             $this->showHits = (int) $params->get('show_hits', 1);
             $this->showOpenFile = (int) $params->get('show_open_file', 1);
             $this->showDownloadFile = (int) $params->get('show_download_file', 1);
             $this->showOpenFolder = (int) $params->get('show_open_folder', 1);
             $this->showFileDesc = (int) $params->get('show_file_desc', 1);
             $this->showFolderDesc = (int) $params->get('show_folder_desc', 1);
             $this->showLicense = (int) $params->get('show_license', 1);
             $this->virtualFolder = (int) $params->get('virtual_folder', 0);
         }
     }
 }