HEX
Server: Apache/2.4.6 (CentOS) mpm-itk/2.4.7-04 mod_fcgid/2.3.9 PHP/5.4.16
System: Linux dvm.vladweb.ru 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: region-gk.ru (1016)
PHP: 7.3.33
Disabled: NONE
Upload Files
File: /home/temp/yarusvl.ru/adminx/core/RobotsAdmin.php
<?php

require_once('api/Mgc.php');

class RobotsAdmin extends Mgc {

    public function fetch() {
        if($this->request->post()){
            $robots_data = $this->request->post('robots');
            $this->get_robots($robots_data,'write');
        }

        /*Обновление файла*/
        $robots_txt = $this->get_robots('','read');
        $this->design->assign('robots_txt', $robots_txt);
        $perms = is_writable('robots.txt');
        if(!$perms) {
            $this->design->assign('message_error','write_error');
        }
        return $this->design->fetch('robots.tpl');
    }

    /*Чтение/Запись файла*/
    private function get_robots($data,$type){
        if ($type == 'write') {
            $perms = is_writable('robots.txt');
            if ($perms) {
                file_put_contents('robots.txt', strip_tags($data), LOCK_EX);
                $this->design->assign('message_success', 'updated');
            } else {
                $this->design->assign('message_error','write_error');
            }
        } elseif ($type='read') {
            $robots = file_get_contents("robots.txt");
            return $robots;
        }
    }

}