Exemple #1
0
 private function read_robots_txt($path)
 {
     $msg = new AimySitemapMessageHelper();
     if (JFile::exists($path)) {
         $this->robotstxt = @file_get_contents($path);
         if ($this->robotstxt === false) {
             $msg->error(JText::_('AIMY_SM_ROBOTSTXT_FAILED_TO_READ'));
             $this->robotstxt = '';
         }
     } else {
         $msg->message(JText::_('AIMY_SM_ROBOTSTXT_DOES_NOT_EXIST'));
         $msg->message(JText::_('AIMY_SM_ROBOTSTXT_LOADING_DEFAULT'));
         $this->robotstxt = @file_get_contents(JPATH_COMPONENT . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'default-robots.txt');
         if ($this->robotstxt === false) {
             $msg->error(JText::_('AIMY_SM_ROBOTSTXT_LOADING_DEFAULT_FAILED'));
             $this->robotstxt = '';
         }
     }
 }
Exemple #2
0
 public function save()
 {
     JSession::checkToken() or jexit(JText::_('INVALID TOKEN'));
     $rights = AimySitemapRightsHelper::getRights();
     if (!$rights->get('aimysitemap.write')) {
         jexit(JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'));
     }
     require_once JPATH_COMPONENT . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'message.php';
     $msg = new AimySitemapMessageHelper();
     $app = JFactory::getApplication();
     $txt = $app->input->getString('robotstxt', '');
     $path = JPATH_ROOT . DIRECTORY_SEPARATOR . 'robots.txt';
     if (JFile::write($path, $txt) === false) {
         $msg->error(JText::_('AIMY_SM_ROBOTSTXT_FAILED_TO_WRITE'));
     } else {
         $msg->message(JText::_('AIMY_SM_ROBOTSTXT_WRITTEN'));
     }
     $this->setRedirect(JRoute::_('index.php?option=com_aimysitemap&view=robotstxt', false));
 }
Exemple #3
0
 public static function unlink_file_if_exists()
 {
     require_once JPATH_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_aimysitemap' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'message.php';
     $cfg = new AimySitemapConfigHelper();
     $msg = new AimySitemapMessageHelper();
     $rel_path = $cfg->get('xml_path');
     if (empty($rel_path)) {
         return false;
     }
     $full_path = JPATH_ROOT . '/' . $rel_path;
     if (!JFile::exists($full_path)) {
         return false;
     }
     if (JFile::delete($full_path) === true) {
         $msg->message(JText::_('AIMY_SM_MSG_XML_FILE_REMOVED'));
         return true;
     }
     $msg->error(JText::_('AIMY_SM_MSG_XML_FILE_ERR_REMOVE'));
     return false;
 }