Browse Source

add menu config custom robots.txt

pull/475/head
Yaya Laressa 4 years ago
parent
commit
cfd114b7d3
4 changed files with 65 additions and 2 deletions
  1. +3
    -0
      config/config.ini.example
  2. +1
    -1
      content/data/configList.json
  3. +58
    -1
      system/admin/views/config-metatags.html.php
  4. +3
    -0
      system/htmly.php

+ 3
- 0
config/config.ini.example View File

@ -96,6 +96,9 @@ description.char = "150"
; Post date display as, set "true" display as social media or set "false" as default
timeago.format = "false"
; Custom robots.txt configuration
custom.robots = "false"
; RSS feed count
rss.count = "10"


+ 1
- 1
content/data/configList.json View File

@ -1 +1 @@
["site.url","timezone","date.format","language","blog.title","blog.tagline","blog.description","blog.copyright","permalink.type","static.frontpage","blog.enable","social.twitter","social.facebook","breadcrumb.home","comment.system","fb.appid","fb.num","fb.color","disqus.shortname","google.wmt.id","google.analytics.id","google.gtag.id","google.reCaptcha","google.reCaptcha.public","google.reCaptcha.private","posts.perpage","category.perpage","tag.perpage","archive.perpage","search.perpage","profile.perpage","type.perpage","json.count","category.info","related.count","recent.count","popular.count","teaser.type","read.more","teaser.char","description.char","timeago.format","rss.count","rss.char","views.counter","sitemap.priority.base","sitemap.priority.post","sitemap.priority.static","sitemap.priority.category","sitemap.priority.tag","sitemap.priority.archiveDay","sitemap.priority.archiveMonth","sitemap.priority.archiveYear","sitemap.priority.author","sitemap.priority.type","prerelease","cache.expiration","cache.off","generation.time","cache.timestamp","cache.minify","views.root","views.layout"]
["site.url", "timezone", "date.format", "language", "blog.title", "blog.tagline", "blog.description", "blog.copyright", "permalink.type", "static.frontpage", "blog.enable", "social.twitter", "social.facebook", "breadcrumb.home", "comment.system", "fb.appid", "fb.num", "fb.color", "disqus.shortname", "google.wmt.id", "google.analytics.id", "google.gtag.id", "google.reCaptcha", "google.reCaptcha.public", "google.reCaptcha.private", "posts.perpage", "category.perpage", "tag.perpage", "archive.perpage", "search.perpage", "profile.perpage", "type.perpage", "json.count", "category.info", "related.count", "recent.count", "popular.count", "teaser.type", "read.more", "teaser.char", "description.char", "timeago.format", "custom.robots", "rss.count", "rss.char", "views.counter", "sitemap.priority.base", "sitemap.priority.post", "sitemap.priority.static", "sitemap.priority.category", "sitemap.priority.tag", "sitemap.priority.archiveDay", "sitemap.priority.archiveMonth", "sitemap.priority.archiveYear", "sitemap.priority.author", "sitemap.priority.type", "prerelease", "cache.expiration", "cache.off", "generation.time", "cache.timestamp", "cache.minify", "views.root", "views.layout"]

+ 58
- 1
system/admin/views/config-metatags.html.php View File

@ -5,6 +5,37 @@ $array = array();
if (file_exists($config_file)) {
$array = parse_ini_file($config_file, true);
}
// robots.txt config
$backup_robots = 'content/data/robots.backup';
$custom_robots = 'content/data/robots.custom';
if(!file_exists($backup_robots)) {
// backup robots.txt dulu jika belum ada backupan
$robots = file_get_contents('robots.txt');
file_put_contents($backup_robots, $robots);
}
if(!file_exists($custom_robots)) {
// buat custom robots.txt dulu jika belum ada
file_put_contents($custom_robots, '');
}
if(config('custom.robots') === 'true')
{
unlink('robots.txt');
// create robots.txt custom
$robots = file_get_contents($custom_robots);
file_put_contents('robots.txt', $robots);
}
if(config('custom.robots') === 'false')
{
unlink('robots.txt');
$robots = file_get_contents($backup_robots);
file_put_contents('robots.txt', $robots);
}
?>
<h2><?php echo i18n('Metatags_Settings');?></h2>
<br>
@ -38,7 +69,7 @@ if (file_exists($config_file)) {
</label>
</div>
</div>
</div>
</div>
</div>
<div class="form-group row">
<label for="description.char" class="col-sm-2 col-form-label"><?php echo i18n('Meta_description_character');?></label>
@ -52,6 +83,32 @@ if (file_exists($config_file)) {
<input type="text" name="-config-breadcrumb.home" class="form-control" id="breadcrumb.home" value="<?php echo valueMaker(config('breadcrumb.home'));?>" placeholder="<?php echo i18n('Home');?>">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label"><?php echo i18n('Enable_custom_robots_txt');?></label>
<div class="col-sm-10">
<div class="col-sm-10">
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-custom.robots" id="custom.robots1" value="true" <?php if (config('custom.robots') === 'true'):?>checked<?php endif;?>>
<label class="form-check-label" for="robots.type1">
<?php echo i18n('Enable');?>
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-custom.robots" id="custom.robots1" value="false" <?php if (config('custom.robots') === 'false'):?>checked<?php endif;?>>
<label class="form-check-label" for="robots.type2">
<?php echo i18n('Disable');?>
</label>
</div>
</div>
</div>
</div>
<div class="form-group row">
<label for="read.more" class="col-sm-2 col-form-label"><?php echo i18n('Custom_robots_txt_here');?></label>
<div class="col-sm-10">
<textarea id="robots1" name="robots" class="form-control" rows="10"><?php echo valueMaker(file_get_contents($custom_robots));?></textarea>
<small><em><?php echo i18n('Guidelines_for_creating_a_robots_txt_see');?> <a target="_blank" href="https://developers.google.com/search/docs/advanced/robots/create-robots-txt">https://developers.google.com/search/docs/advanced/robots/create-robots-txt</a></em></small>
</div>
</div>
<br>
<h4><?php echo i18n('Sitemap');?></h4>
<hr>


+ 3
- 0
system/htmly.php View File

@ -1710,6 +1710,8 @@ post('/admin/config/metatags', function () {
ini_set("display_errors", 1);
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
$robots = from($_REQUEST, 'robots');
if (login() && $proper) {
$new_config = array();
$new_Keys = array();
@ -1725,6 +1727,7 @@ post('/admin/config/metatags', function () {
}
}
save_config($new_config, $new_Keys);
file_put_contents('content/data/robots.custom', $robots);
$login = site_url() . 'admin/config/metatags';
header("location: $login");
} else {


Loading…
Cancel
Save