Initial commit as of 2018-10-16
This commit is contained in:
66
application/controllers/Tools/Twitch.php
Normal file
66
application/controllers/Tools/Twitch.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user