Archived
1
0
This repository has been archived on 2020-12-10. You can view files and clone it, but cannot push or open issues or pull requests.
old/application/controllers/Tools/Twitch.php

67 lines
2.2 KiB
PHP
Raw Normal View History

2018-10-16 16:28:42 +00:00
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Twitch extends MY_Controller {
public function __construct() {
parent::__construct('tools');
}
public function index($channel = 'kingofdog') {
if(isset($_GET['twitch-channel']) && !empty($_GET['twitch-channel'])) {
header("Location: /tools/twitch/" . $_GET['twitch-channel']);
}
$this->load->view('header', ['active' => 'twitch-tools', 'title' => lang('twitch_site_title')]);
$this->load->model('TwitchModel');
// $data =
$result = $this->load->view('twitch_result', ['json' => $this->TwitchModel->getTwitchInfos($channel), 'stream' => $this->TwitchModel->getTwitchStream($channel), 'videos' => $this->TwitchModel->getTwitchVideos($channel)], true);
$this->load->view('twitch', ['result' => $result]);
$this->load->view('footer');
}
public function sudoku() {
if(isset($_POST['sudoku'])) {
$sudoku = [];
$rows = [];
$cols = [];
$fields = [];
for ($i=0; $i < 9; $i++) {
for ($j=0; $j < 9; $j++) {
if(isset($_POST['field-' . $i . '-' . $j])) {
$sudoku[$i][$j] = $_POST['field-' . $i . '-' . $j];
} else {
$sudoku[$i][$j] = '_';
}
}
}
for ($i=0; $i < 9; $i++) {
for ($j=0; $j < 9; $j++) {
$rows[$i] .= $sudoku[$i][$j] . "|";
$cols[$i] .= $sudoku[$j][$i] . "|";
}
}
for ($i=0; $i < 3; $i++) {
for ($j=0; $j < 3; $j++) {
for ($k=0; $k < 3; $k++) {
for ($l=0; $l < 3; $l++) {
$fields[$i][$j] .= $sudoku[$i * $k][$j * $l] . "|";
}
}
}
}
var_dump($fields);
var_dump($rows);
var_dump($cols);
}
$this->load->view('header', ['active' => 'sudoku', 'title' => 'Sudoku-Löser']);
$this->load->view('sudoku');
$this->load->view('footer');
}
}