HEX
Server: Apache
System: FreeBSD www860.sakura.ne.jp 13.0-RELEASE-p14 FreeBSD 13.0-RELEASE-p14 #2: Mon Dec 9 13:54:55 JST 2024 root@www5301.sakura.ne.jp:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64
User: yoyo0427 (1306)
PHP: 8.3.8
Disabled: NONE
Upload Files
File: /home/yoyo0427/www/www.yn-artspace.com/wp-content/plugins/telsender/clasess/log.php
<?php

namespace pechenki\Telsender\clasess;

if (!defined('ABSPATH')) {
    exit;
}

class log
{


    const path = ABSPATH . "wp-content/uploads/telsender/error.log";

    public function __construct()
    {
        $this->initLogFile();
    }

    /**
     * @param $text
     * @return void
     */
    public static function setLog($text)
    {
        if (!defined('LOG_TS')) return;

        if (is_array($text)) {
            $text = json_encode($text);
        }
        $file = fopen(self::path, "a+");
        echo fwrite($file, "\n" . date('Y-m-d h:i:s') . " :: " . $text);
        fclose($file);
    }

    /**
     * @return false|string
     */
    public static function getLog()
    {

        if (!file_exists(self::path)) {
            return 'error none';
        }
        return trim(file_get_contents(self::path));
    }


    public static function clearLog()
    {
        return update_option(self::$logNameOption, '');
    }

    /**
     * @return void
     */
    private function initLogFile()
    {
        if (file_exists(self::path)) return;

        $upload = wp_upload_dir();
        $upload_dir = $upload['basedir'];
        $upload_dir = $upload_dir . '/telsender';
        if (!is_dir($upload_dir)) {
            mkdir($upload_dir, 0755);
        }
        try {
            fopen(self::path, 'x');
            file_put_contents($upload_dir . '/.htaccess', 'deny from all');
        }catch (\Exception $e){

        }


    }
}