<commit_before><?php
/**
 * Created by PhpStorm.
 * User: beechen
 * Date: 17/2/13
 * Time: 21:57
 */

namespace App\Http\Controllers;


use App\Services\UserService;
use Illuminate\Http\Request;

class IndexController
{
    public function index()
    {
        $data = [
            'status' => 0,
        ];
        if(UserService::count() > 0){
            $data['status'] = 1;
        }
        return view('welcome',['data' => $data]);
    }

    public function init()
    {
        return view('init.init', ['data' => []]);
    }

    public function initDatabase(Request $request)
    {
        $init = $request->input("init_database");
        if( $init ){
            $host = $request->input("host");
            $port = $request->input("port");
            $database = $request->input("database");
            $user = $request->input("user");
            $password = $request->input("password");
            if(!$host || !$port || !$database || !$user || !$password){
                redirect("/init.php");
            }
            $path = public_path()."/../";
            $env_file = "$path.env";
            exec("echo 'DB_HOST=$host\r\nDB_PORT=$port\r\nDB_DATABASE=$database\r\nDB_USERNAME=$user\r\nDB_PASSWORD=$password' >> $env_file");
            exec("cd $path && php artisan migrate");
            return redirect("/user/register");
        }
        return redirect('/init');
    }

}<commit_msg>注册与登录<commit_after><?php
/**
 * Created by PhpStorm.
 * User: beechen
 * Date: 17/2/13
 * Time: 21:57
 */

namespace App\Http\Controllers;


use App\Services\UserService;
use Illuminate\Http\Request;

class IndexController
{
    public function index()
    {
        $data = [
            'status' => 0,
        ];
        if(UserService::count() > 0){
            $data['status'] = 1;
        }
        return view('welcome',['data' => $data]);
    }

    public function init()
    {
        return view('init.init', ['data' => []]);
    }

    public function initDatabase(Request $request)
    {
        $init = $request->input("init_database");
        if( $init ){
            $host = $request->input("host");
            $port = $request->input("port");
            $database = $request->input("database");
            $user = $request->input("user");
            $password = $request->input("password");
            if(!$host || !$port || !$database || !$user || !$password){
                redirect("/init.php");
            }
            $path = public_path()."/../";
            $env_file = "$path.env";
            exec("echo 'DB_HOST=$host\r\nDB_PORT=$port\r\nDB_DATABASE=$database\r\nDB_USERNAME=$user\r\nDB_PASSWORD=$password' >> $env_file");
            exec("php {$path}artisan migrate");
            return redirect("/user/register");
        }
        return redirect('/init');
    }

}
{'fraction_non_alphanumeric': 0.1847787610619469, 'fraction_numerical': 0.008495575221238939, 'mean_word_length': 2.0387096774193547, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1997449', 'n_tokens_mistral': 885, 'n_tokens_neox': 867, 'n_words': 152}