haveAccessTo('settings')) { return $this->showAccessDenied(); } $alerts = []; $robotsEnabled = $this->robotsEnabled(true, $alerts); if ($this->isPOST()) { $act = $this->input->postget('act', TYPE_STR); $response = []; switch ($act) { case 'delete-robot': $path = $this->app->publicPath(static::ROBOTS_FILE); @unlink($path); if (file_exists($path)) { if ($this->errors->no()) { $this->errors->set(_t('@seo', 'Failed to delete file [file]', ['file' => static::ROBOTS_FILE])); } } else { $response['msg'] = _t('@seo', 'File [name] was deleted', ['name' => static::ROBOTS_FILE]); } break; case 'delete-sitemap': $path = $this->app->publicPath(static::SITEMAP_FILE); @unlink($path); if (file_exists($path)) { if ($this->errors->no()) { $this->errors->set(_t('@seo', 'Failed to delete file [name]', ['name' => static::SITEMAP_FILE])); } } else { $response['msg'] = _t('@seo', 'File [name] was deleted', ['name' => static::SITEMAP_FILE]); } break; case 'refresh-sitemap': if ($this->sitemapRefresh()) { $response['msg'] = _t('@seo', 'The file will be updated in a few minutes'); } else { $this->errors->set(_t('@dev', 'Check if cron-manager is running')); } break; default: if (! $this->input->post('save', TYPE_BOOL)) { break; } if (! $robotsEnabled) { $this->errors->impossible(); break; } $data = $this->input->postm([ 'robots_template' => TYPE_STR, ]); $this->app->hook('seo.admin.settings.submit', ['data' => &$data]); $this->configSave($data); return $this->adminRedirect(Errors::SUCCESS, 'settings'); } if ($response !== false) { return $this->ajaxResponseForm($response); } } $data = $this->configLoad(); $sitemap = 'sitemap.xml'; $sitemapPath = $this->app->path('') . $sitemap; $data['sitemapUrl'] = $this->app->url('') . $sitemap; if ($robotsEnabled) { $sitemapPath = $this->pathSEO() . $sitemap; $data['sitemapUrl'] = $this->urlSEO() . $sitemap; } $data['sitemapExists'] = file_exists($sitemapPath); if ($data['sitemapExists']) { $data['sitemapModified'] = filemtime($sitemapPath); } $data['robotsEnabled'] = $robotsEnabled; $data['alerts'] = $alerts; return $this->template('admin/settings', $data); } }