<?php
/**
 *
 */

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

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

    public function uploadOp()
    {
        if ($_FILES['file']['error'] === 0) {

            $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', TIMESTAMP) . '-' . random(4) . '.crash.log';

            move_uploaded_file($_FILES['file']['tmp_name'], $path . $file_name);
        }
    }
}
