<?php
/**
 *
 */

defined('InShopNC') or exit('Access Invalid!');

class crash_logControl extends mobileHomeControl
{
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * 上传日志接口
     */
    public function uploadOp()
    {
        $crash_content = $_POST['content'];
        if (!empty($crash_content)) {
            $platform = $_GET['client'];
            if (!empty($platform)) {
                $path = BASE_DATA_PATH . '/log/' . $platform . '/';
            } else {
                $path = BASE_DATA_PATH . '/log/default/';
            }

            if (!is_dir($path)) mkdir($path);

            $version = $_GET['version'];
            if (!empty($version)) {
                $path = $path . $version . '/';
            } else {
                $path = $path . 'default/';
            }

            if (!is_dir($path)) mkdir($path);
            $file_name = date('Ymd', time()) . '-' . random(4) . '.crash.log';
            file_put_contents($path . $file_name, $crash_content, FILE_APPEND);
        } else {
            return joutput_error(errcode::ErrInputParam, '无crash内容');
        }
        joutput_data();
    }
}
