Initial commit as of 2018-10-16
This commit is contained in:
219
application/controllers/Tools/Csgo.php
Normal file
219
application/controllers/Tools/Csgo.php
Normal file
@@ -0,0 +1,219 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Csgo extends MY_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('tools');
|
||||
}
|
||||
|
||||
public function index($user = 'kingofdog')
|
||||
{
|
||||
if (isset($_GET['q']) && !empty($_GET['q'])) redirect(base_url('tools/csgo/' . $_GET['q']));
|
||||
|
||||
$this->load->view('header', ['active' => 'csgo', 'title' => 'CS:GO Tools', 'additionalStyles' => ['csgo.css']]);
|
||||
$this->load->view('tools/csgo', ['user' => $user]);
|
||||
$this->load->view('footer', ['additionalScripts' => ['lib/nanobar.min.js', 'csgo.js']]);
|
||||
}
|
||||
|
||||
public function data($user)
|
||||
{
|
||||
$data = simplexml_load_string(file_get_contents('http://steamcommunity.com/id/' . $user . '/?xml=1'));
|
||||
$a['player_exists'] = true;
|
||||
$a['player_owns_game'] = true;
|
||||
$a['id64'] = (string)$data->steamID64;
|
||||
$a['id'] = (string)$data->steamID;
|
||||
$a['name'] = (string)$data->realname;
|
||||
$a['location'] = (string)$data->location;
|
||||
$a['onStat'] = (string)$data->onlineState;
|
||||
$a['statusMes'] = (string)$data->stateMessage;
|
||||
$a['avatar'] = (string)$data->avatarFull;
|
||||
$a['vacban'] = (string)$data->vacBanned;
|
||||
$a['tradeban'] = (string)$data->tradeBanState;
|
||||
if($a['id'] == "") {
|
||||
$a['player_exists'] = false;
|
||||
$a['player_owns_game'] = false;
|
||||
echo json_encode($a);
|
||||
exit;
|
||||
}
|
||||
$status = ['in-game' => 'In Game', 'online' => 'Online', 'offline' => 'Offline', 'busy' => 'Busy', 'away' => 'Away'];
|
||||
$a['status'] = $status[$a['onStat']];
|
||||
|
||||
$successful = file_get_contents('http://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v0002/?appid=730&key=79E0709F4D4157636A833312C91639FC&steamid=' . $a['id64'], true);
|
||||
if($successful == false) {
|
||||
goto go_on;
|
||||
}
|
||||
|
||||
$data = json_decode($successful, true)['playerstats'];
|
||||
|
||||
$stats = $data['stats'];
|
||||
$kills = [];
|
||||
foreach ($stats as $stat) {
|
||||
$a[$stat['name']] = $stat['value'];
|
||||
if (strpos($stat['name'], 'total_kills_') !== false && !in_array($stat['name'], ['total_kills_headshot', 'total_kills_enemy_weapon', 'total_kills_enemy_blinded', 'total_kills_knife_fight', 'total_kills_against_zoomed_sniper'])) {
|
||||
$kills[] = $stat['value'] . '_' . explode('_', $stat['name'])[2];
|
||||
}
|
||||
}
|
||||
natsort($kills);
|
||||
$a['kills'] = array_reverse($kills);
|
||||
if ($a['last_match_wins'] > $a['last_match_rounds'] / 2) {
|
||||
$a['last_match_end_status'] = 2;
|
||||
} elseif ($a['last_match_wins'] < $a['last_match_rounds'] / 2) {
|
||||
$a['last_match_end_status'] = 0;
|
||||
} else {
|
||||
$a['last_match_end_status'] = 1;
|
||||
}
|
||||
|
||||
if(isset($data['achievements'])) {
|
||||
$ach = $data['achievements'];
|
||||
foreach ($ach as $entry) {
|
||||
$a[$entry['name']] = $entry['achieved'];
|
||||
}
|
||||
$a['total_time_played'] = round($a['total_time_played'] / 60 / 60);
|
||||
} else {
|
||||
$a['player_owns_game'] = false;
|
||||
}
|
||||
|
||||
go_on:
|
||||
$data = json_decode(file_get_contents('http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=79E0709F4D4157636A833312C91639FC&steamids=' . $a['id64']), true)['response'];
|
||||
$data = $data['players'];
|
||||
$data = $data[0];
|
||||
$a['lastseen'] = $data['lastlogoff'];
|
||||
$a['url'] = $data['profileurl'];
|
||||
$a['created'] = $data['timecreated'];
|
||||
$a['country'] = $data['loccountrycode'];
|
||||
|
||||
$a['weapon_list'] = [
|
||||
1 => ["Desert Eagle", "deagle"],
|
||||
2 => ["Dual Berettas", "elite"],
|
||||
3 => ["Five-SeveN", "fiveseven"],
|
||||
4 => ["Glock-18", "glock"],
|
||||
7 => ["AK-47", "ak47"],
|
||||
8 => ["AUG", "aug"],
|
||||
9 => ["AWP", "awp"],
|
||||
10 => ["FAMAS", "famas"],
|
||||
11 => ["G3SG1", "g3sg1"],
|
||||
13 => ["Galil AR", "galilar"],
|
||||
14 => ["M249", "m249"],
|
||||
16 => ["M4A4", "m4a4"],
|
||||
17 => ["MAC-10", "mac10"],
|
||||
19 => ["P90", "p90"],
|
||||
24 => ["UMP-45", "ump45"],
|
||||
25 => ["XM1014", "xm1014"],
|
||||
26 => ["PP-Bizon", "bizon"],
|
||||
27 => ["MAG-7", "mag7"],
|
||||
28 => ["Negev", "negev"],
|
||||
29 => ["Sawed-Off", "sawedoff"],
|
||||
30 => ["Tec-9", "tec9"],
|
||||
31 => ["Zeus x27", "taser"],
|
||||
32 => ["P2000", "hkp2000"],
|
||||
33 => ["MP7", "m79"],
|
||||
34 => ["MP9", "mp9"],
|
||||
35 => ["Nova", "nova"],
|
||||
36 => ["P250", "p250"],
|
||||
38 => ["SCAR-20", "scar20"],
|
||||
39 => ["SG 553", "sg556"],
|
||||
40 => ["SSG 08", "ssg08"],
|
||||
42 => ["Knife", "knife_ct"],
|
||||
43 => ["Flashbang", "flashbang"],
|
||||
44 => ["High Explosive Grenade", "hegrenade"],
|
||||
45 => ["Smoke Grenade", "smokegrenade"],
|
||||
46 => ["Molotov", "molotov"],
|
||||
47 => ["Decoy Grenade", "decoy"],
|
||||
48 => ["Incendiary Grenade", "incgrenade"],
|
||||
59 => ["Knife", "knife"],
|
||||
60 => ["M4A1-S", "m4a1"],
|
||||
61 => ["USP-S", "usp"],
|
||||
63 => ["CZ75-Auto", "cz75"],
|
||||
64 => ["R8 Revolver", "deagle"],
|
||||
];
|
||||
|
||||
if(isset($a['total_kills_headshot'])) {
|
||||
$a['total_headshot_rate'] = number_format(
|
||||
$a['total_kills_headshot'] / $a['total_kills'] * 100,
|
||||
1,
|
||||
lang('csgo_comma'),
|
||||
lang('csgo_point')) . " %";
|
||||
$a['total_kills'] = number_format($a['total_kills'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_time_played'] = number_format($a['total_time_played'], 0, lang('csgo_comma'), lang('csgo_point')) . " h";
|
||||
$a['total_accuracy'] = number_format($a['total_shots_hit'] / $a['total_shots_fired'] * 100, 1, lang('csgo_comma'), lang('csgo_point')) . " %";
|
||||
$a['total_mvps'] = number_format($a['total_mvps'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_win_rate'] = number_format($a['total_wins'] / $a['total_rounds_played'] * 100, 1, lang('csgo_comma'), lang('csgo_point')) . " %";
|
||||
$a['total_planted_bombs'] = number_format($a['total_planted_bombs'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_rescued_hostages'] = number_format($a['total_rescued_hostages'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['last_match_result'] = $a['last_match_end_status'] == 2 ? 'win' : '';
|
||||
$a['last_match_outcome'] = lang('csgo_' . $a['last_match_end_status']);
|
||||
$a['last_match_favweapon_accuracy'] = number_format($a['last_match_favweapon_hits'] / $a['last_match_favweapon_shots'] * 100, 1, lang('csgo_comma'), lang('csgo_point'));
|
||||
|
||||
$a['last_match_kd'] = number_format($a['last_match_kills'] / $a['last_match_deaths'], 2, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['last_match_kills'] = number_format($a['last_match_kills'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['last_match_deaths'] = number_format($a['last_match_deaths'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['last_match_mvps'] = number_format($a['last_match_mvps'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['last_match_damage'] = number_format($a['last_match_damage'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['last_match_money_spent'] = number_format($a['last_match_money_spent'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['last_match_dominations'] = number_format($a['last_match_dominations'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['last_match_revenges'] = number_format($a['last_match_revenges'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['last_match_contribution_score'] = number_format($a['last_match_contribution_score'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
|
||||
$a['favweapons'] = '';
|
||||
for ($i = 0;
|
||||
$i < 5;
|
||||
$i++) {
|
||||
$weapon = $a['kills'][$i];
|
||||
$killCount = explode('_', $weapon)[0];
|
||||
$weaponName = explode('_', $weapon)[1];
|
||||
|
||||
$a['favweapons'] .= '<li class="item ' . $weaponName . ' ';
|
||||
$a['favweapons'] .= $i == 0 ? 'card">' : 'line">';
|
||||
$a['favweapons'] .= '<h3 class="title"><span class="number">' . ($i + 1);
|
||||
if ($i > 0) {
|
||||
$a['favweapons'] .= '. ';
|
||||
}
|
||||
$a['favweapons'] .= '</span> ' . $weaponName . '</h3>';
|
||||
if ($i == 0) {
|
||||
$a['favweapons'] .= '<img src="' . base_url('file/csgo/weapon/' . $weaponName) . '" class="photo" alt="" />';
|
||||
} else {
|
||||
$a['favweapons'] .= ' <svg class="icon"><use xlink:href="#i-' . $weaponName . '"></use></svg>';
|
||||
}
|
||||
$a['favweapons'] .= '<p class="stat kills">' . $killCount . '<svg><use xlink:href="#i-kills"></use></svg></p></li>';
|
||||
}
|
||||
|
||||
$a['total_deaths'] = number_format($a['total_deaths'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_kd'] = number_format($a['total_kills'] / $a['total_deaths'], 2, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_contribution_score'] = number_format($a['total_contribution_score'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_damage_done'] = number_format($a['total_damage_done'], 0, lang('csgo_comma'), lang('csgo_point')) . ' HP';
|
||||
$a['total_shots_fired'] = number_format($a['total_shots_fired'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_shots_hit'] = number_format($a['total_shots_hit'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_kills_headshot'] = number_format($a['total_kills_headshot'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_dominations'] = number_format($a['total_dominations'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_revenges'] = number_format($a['total_revenges'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_matches_played'] = number_format($a['total_matches_played'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_matches_won'] = number_format($a['total_matches_won'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_matches_won_percent'] = number_format($a['total_matches_won'] / $a['total_matches_played'] * 100, 2, lang('csgo_comma'), lang('csgo_point')) . ' %';
|
||||
$a['total_rounds_played'] = number_format($a['total_rounds_played'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_wins'] = number_format($a['total_wins'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_wins_pistolround'] = number_format($a['total_wins_pistolround'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_defused_bombs'] = number_format($a['total_defused_bombs'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_rescued_hostages'] = number_format($a['total_rescued_hostages'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_kills_enemy_blinded'] = number_format($a['total_kills_enemy_blinded'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_kills_knife_fight'] = number_format($a['total_kills_knife_fight'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_kills_against_zoomed_sniper'] = number_format($a['total_kills_against_zoomed_sniper'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_kills_taser'] = number_format($a['total_kills_taser'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_kills_enemy_weapon'] = number_format($a['total_kills_enemy_weapon'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_money_earned'] = number_format($a['total_money_earned'], 0, lang('csgo_comma'), lang('csgo_point')) . ' $';
|
||||
$a['total_weapons_donated'] = number_format($a['total_weapons_donated'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_broken_windows'] = number_format($a['total_broken_windows'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
} else {
|
||||
$a['player_owns_game'] = false;
|
||||
}
|
||||
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($a);
|
||||
}
|
||||
|
||||
public function getDefaultPage($user) {
|
||||
$this->load->view('csgo-tools', ['user' => $user]);
|
||||
}
|
||||
}
|
25
application/controllers/Tools/Encoder.php
Normal file
25
application/controllers/Tools/Encoder.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Encoder extends MY_Controller {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct('tools');
|
||||
}
|
||||
|
||||
public function base64() {
|
||||
$this->load->view('header', ['active' => 'base64-encoder', 'title' => lang('base64_site_title')]);
|
||||
// $this->load->view('encoder', ['type' => 'base64']);
|
||||
$this->load->view('tools/encoders/base64');
|
||||
$this->load->view('footer');
|
||||
// $this->load->view('encoder_end', ['type' => 'base64']);
|
||||
}
|
||||
|
||||
public function url() {
|
||||
$this->load->view('header', ['active' => 'url-encoder', 'title' => lang('url_site_title')]);
|
||||
// $this->load->view('encoder', ['type' => 'url']);
|
||||
$this->load->view('tools/encoders/url');
|
||||
$this->load->view('footer');
|
||||
// $this->load->view('encoder_end', ['type' => 'url']);
|
||||
}
|
||||
}
|
15
application/controllers/Tools/Encrypter.php
Normal file
15
application/controllers/Tools/Encrypter.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Encrypter extends MY_Controller {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct('tools');
|
||||
}
|
||||
|
||||
public function index($active = 'adfgvx') {
|
||||
$this->load->view('header', ['active' => 'encrypter', 'title' => lang('encrypter_site_title')]);
|
||||
$this->load->view('tools/encrypter/main', ['active' => $active]);
|
||||
$this->load->view('footer', ['additionalScripts' => ['encrypters.js']]);
|
||||
}
|
||||
}
|
30
application/controllers/Tools/Generators.php
Normal file
30
application/controllers/Tools/Generators.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Generators extends MY_Controller {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct('tools');
|
||||
$this->load->model('NicknameModel', '', TRUE);
|
||||
}
|
||||
|
||||
public function nickname()
|
||||
{
|
||||
$this->load->view('header', ['active' => 'nickname-generator', 'title' => lang('nick_site_title')]);
|
||||
$this->load->view('tools/generators/nickname', ["counter" => "unendlich"]);
|
||||
$this->load->view('footer', ['additionalScripts' => ['nickname.js']]);
|
||||
}
|
||||
|
||||
public function nickname_functions()
|
||||
{
|
||||
$this->NicknameModel->generateName();
|
||||
}
|
||||
|
||||
public function password()
|
||||
{
|
||||
$this->load->view('header', ['active' => 'password-generator', 'title' => lang('pass_site_title'), 'additionalStyles' => ['tools.css']]);
|
||||
$this->load->view('tools/generators/password');
|
||||
$this->load->view('footer', ['additionalScripts' => ['password.js']]);
|
||||
}
|
||||
|
||||
}
|
92
application/controllers/Tools/Minecraft.php
Normal file
92
application/controllers/Tools/Minecraft.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Minecraft extends MY_Controller {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct('tools');
|
||||
$this->load->model('minecraftModel', '', TRUE);
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$this->load->view('header', ['active' => '', 'title' => 'Error']);
|
||||
$this->load->view('under_construction');
|
||||
$this->load->view('footer');
|
||||
}
|
||||
public function servers() {
|
||||
$this->load->view('header', ['active' => '', 'title' => 'Error']);
|
||||
$this->load->view('under_construction');
|
||||
$this->load->view('footer');
|
||||
}
|
||||
public function players() {
|
||||
$this->load->view('header', ['active' => '', 'title' => 'Error']);
|
||||
$this->load->view('under_construction');
|
||||
$this->load->view('footer');
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*public function server() {
|
||||
$serverip = isset($_GET['serverip']) ? $_GET['serverip'] : 'gommehd.net';
|
||||
|
||||
$errorIP = $this->MinecraftModel->getServerName($serverip) == lang('servers_error_ip') ? true : false;
|
||||
|
||||
$this->load->view('header', ['active' => 'minecraft-servers', 'title' => lang('servers_site_title')]);
|
||||
$this->load->view('minecraft', ['type' => 'server', 'serverip' => $serverip, 'error' => $errorIP]);
|
||||
$this->load->view('footer');
|
||||
}
|
||||
|
||||
public function player()
|
||||
{
|
||||
$username = !empty($_GET['username']) ? $_GET['username'] : "KingOfDog";
|
||||
$username = $this->MinecraftModel->getUUID($username)[1];
|
||||
|
||||
$cracked = $this->MinecraftModel->getUUID($username)[2] == true ? '<small>Cracked</small>' : '<small style="color:#FFAA00;">Premium</small>';
|
||||
$crackedBool = $this->MinecraftModel->getUUID($username)[2];
|
||||
if ($crackedBool == false) {
|
||||
$uuid = $this->MinecraftModel->getUUID($username)[0];
|
||||
$uuid_formatted = $this->MinecraftModel->formatUUID($uuid);
|
||||
} else {
|
||||
$uuid = null;
|
||||
$uuid_formatted = null;
|
||||
}
|
||||
|
||||
if (isset($_GET['download']) && !empty($_GET['download'])) {
|
||||
if ($_GET['download'] == "skin") {
|
||||
header('Content-Type: image/png');
|
||||
header('Content-Disposition: attachment; filename="skin_' . $username . '.png"');
|
||||
readfile('https://crafatar.com/skins/' . $username);
|
||||
die();
|
||||
}
|
||||
if ($_GET['download'] == "render") {
|
||||
header('Content-Type: image/png');
|
||||
header('Content-Disposition: attachment; filename="render_' . $username . '.png"');
|
||||
readfile('https://crafatar.com/renders/body/' . $username . '?overlay&scale=7');
|
||||
die();
|
||||
}
|
||||
if ($_GET['download'] == "head") {
|
||||
header('Content-Type: image/png');
|
||||
header('Content-Disposition: attachment; filename="head_' . $username . '.png"');
|
||||
readfile('https://crafatar.com/renders/head/' . $username . '?overlay&scale=7');
|
||||
die();
|
||||
}
|
||||
if ($_GET['download'] == "avatar") {
|
||||
if (isset($_GET['size']) && !empty($_GET['size'])) {
|
||||
$size = $_GET['size'];
|
||||
} else {
|
||||
$size = "128";
|
||||
}
|
||||
|
||||
header('Content-Type: image/png');
|
||||
header('Content-Disposition: attachment; filename="avatar' . $size . '_' . $username . '.png"');
|
||||
|
||||
readfile('https://crafatar.com/avatar/' . $username . '?overlay&size=' . $size);
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
$this->load->view('header', ['active' => 'minecraft-players', 'title' => lang('players_site_title')]);
|
||||
$this->load->view('minecraft', ['type' => 'player', 'username' => $username, 'uuid' => $uuid, 'uuid_formatted' => $uuid_formatted, 'cracked' => $cracked, 'crackedBool' => $crackedBool]);
|
||||
$this->load->view('footer');
|
||||
}*/
|
||||
}
|
16
application/controllers/Tools/Tools.php
Normal file
16
application/controllers/Tools/Tools.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Tools extends MY_Controller {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct('tools');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->load->view('header', ['active' => 'tools', 'title' => 'Tools']);
|
||||
$this->load->view('tools/index');
|
||||
$this->load->view('footer');
|
||||
}
|
||||
}
|
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');
|
||||
}
|
||||
}
|
287
application/controllers/Tools/Youtube.php
Normal file
287
application/controllers/Tools/Youtube.php
Normal file
@@ -0,0 +1,287 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Youtube extends MY_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('tools');
|
||||
$this->load->model('YoutubeDownloadModel', '', TRUE);
|
||||
$this->load->model('RedirectModel', '', TRUE);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->load->view('header', ['active' => 'youtube-downloader', 'title' => lang('ytdl_site_title')]);
|
||||
$this->load->view('youtube_downloader');
|
||||
$this->load->view('footer');
|
||||
}
|
||||
|
||||
public function download()
|
||||
{
|
||||
if (empty($_GET['mime']) OR empty($_GET['token'])) {
|
||||
header("Location: /youtube");
|
||||
}
|
||||
$mime = filter_var($_GET['mime']);
|
||||
$ext = str_replace(array('/', 'x-'), '', strstr($mime, '/'));
|
||||
$url = base64_decode(filter_var($_GET['token']));
|
||||
$name = urldecode($_GET['title']) . '.' . $ext;
|
||||
echo $url;
|
||||
if ($url) {
|
||||
$size = $this->YoutubeDownloadModel->get_size($url);
|
||||
// Generate the server headers
|
||||
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) {
|
||||
header('Content-Type: "' . $mime . '"');
|
||||
header('Content-Disposition: attachment; filename="' . $name . '"');
|
||||
header('Expires: 0');
|
||||
header('Content-Length: ' . $size);
|
||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
||||
header("Content-Transfer-Encoding: binary");
|
||||
header('Pragma: public');
|
||||
} else {
|
||||
header('Content-Type: "' . $mime . '"');
|
||||
header('Content-Disposition: attachment; filename="' . $name . '"');
|
||||
header("Content-Transfer-Encoding: binary");
|
||||
header('Expires: 0');
|
||||
header('Content-Length: ' . $size);
|
||||
header('Pragma: no-cache');
|
||||
}
|
||||
|
||||
readfile($url);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function video()
|
||||
{
|
||||
echo $this->load->view('header', ['title' => lang('ytdl_site_title'), 'active' => 'youtube-downloader'], true);
|
||||
if (isset($_REQUEST['videoid'])) {
|
||||
$my_id = $_REQUEST['videoid'];
|
||||
if (preg_match('/^https:\/\/w{3}?.youtube.com\//', $my_id)) {
|
||||
$url = parse_url($my_id);
|
||||
$my_id = NULL;
|
||||
if (is_array($url) && count($url) > 0 && isset($url['query']) && !empty($url['query'])) {
|
||||
$parts = explode('&', $url['query']);
|
||||
if (is_array($parts) && count($parts) > 0) {
|
||||
foreach ($parts as $p) {
|
||||
$pattern = '/^v\=/';
|
||||
if (preg_match($pattern, $p)) {
|
||||
$my_id = preg_replace($pattern, '', $p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$my_id) {
|
||||
header("Location: /tools/youtube?error=1");
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
header("Location: /tools/youtube?error=2");
|
||||
exit;
|
||||
}
|
||||
} elseif (preg_match('/^https?:\/\/youtu.be/', $my_id)) {
|
||||
$url = parse_url($my_id);
|
||||
$my_id = NULL;
|
||||
$my_id = preg_replace('/^\//', '', $url['path']);
|
||||
}
|
||||
} else {
|
||||
header("Location: /tools/youtube?error=1");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['type'])) {
|
||||
$my_type = $_REQUEST['type'];
|
||||
} else {
|
||||
$my_type = 'redirect';
|
||||
}
|
||||
|
||||
if ($my_type == 'Download') {
|
||||
?>
|
||||
|
||||
<section class="container">
|
||||
<h1 class="center"><?= lang('ytdl_title'); ?></h1>
|
||||
<p class="lead center"><?= lang('ytdl_description'); ?></p>
|
||||
<div class="row center">
|
||||
|
||||
<?php
|
||||
} // end of if for type=Download
|
||||
|
||||
/* First get the video info page for this video id */
|
||||
//$my_video_info = 'http://www.youtube.com/get_video_info?&video_id='. $my_id;
|
||||
$my_video_info = 'http://www.youtube.com/get_video_info?&video_id=' . $my_id . '&asv=3&el=detailpage&hl=' . lang('ytdl_language'); //video details fix *1
|
||||
$my_video_info = $this->YoutubeDownloadModel->curlGet($my_video_info);
|
||||
|
||||
/* TODO: Check return from curl for status code */
|
||||
if (empty($my_video_info)) {
|
||||
header("Location: /tools/youtube?error=3");
|
||||
}
|
||||
|
||||
$thumbnail_url = $title = $view_count = $author = $length_seconds = $url_encoded_fmt_stream_map = $type = $url = '';
|
||||
|
||||
parse_str($my_video_info);
|
||||
$length_seconds = date("i:s", $length_seconds);
|
||||
$view_count = number_format($view_count, 0, ',', '.');
|
||||
if ($status == 'fail') {
|
||||
header("Location: /tools/youtube?error=3");
|
||||
exit();
|
||||
} ?>
|
||||
<div id="info">
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
<a href="/file/thumbnail/<?= $my_id; ?>" target="_blank">
|
||||
<img class="float-right" style="max-width:100%" src="/file/thumbnail/<?= $my_id; ?>">
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
<a href="https://youtu.be/<?= $my_id ?>" target="_blank">
|
||||
<h3 align="left"><?= $title; ?></h3>
|
||||
</a>
|
||||
<h4 align="left"><?= lang('ytdl_views'); ?>: <?= $view_count; ?></h4>
|
||||
<h4 align="left"><?= lang('ytdl_length') . ': ' . $length_seconds . ' ' . lang('ytdl_minutes'); ?></h4>
|
||||
<h4 align="left"><?= lang('ytdl_author') ?>:
|
||||
<a href="http://youtube.com/<?= $author; ?>"
|
||||
target="_blank"><?= $author; ?></a>
|
||||
</h4>
|
||||
<a align="left" href="https://youtu.be/<?= $my_id; ?>" target="_blank"
|
||||
class="btn btn-primary raised pull-left"><?= lang('ytdl_watch'); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<?php
|
||||
$my_title = $title;
|
||||
$cleanedtitle = $this->YoutubeDownloadModel->clean($title);
|
||||
|
||||
if (isset($url_encoded_fmt_stream_map)) {
|
||||
/* Now get the url_encoded_fmt_stream_map, and explode on comma */
|
||||
$my_formats_array = explode(',', $url_encoded_fmt_stream_map);
|
||||
} else {
|
||||
echo '<p>No encoded format stream found.</p>';
|
||||
echo '<p>Here is what we got from YouTube:</p>';
|
||||
echo $my_video_info;
|
||||
}
|
||||
if (count($my_formats_array) == 0) {
|
||||
echo '<p>' . lang('ytdl_error_no_downloads') . '</p>';
|
||||
exit;
|
||||
}
|
||||
|
||||
/* create an array of available download formats */
|
||||
$avail_formats[] = '';
|
||||
$i = 0;
|
||||
$ipbits = $ip = $itag = $sig = $quality = '';
|
||||
$expire = time();
|
||||
|
||||
foreach ($my_formats_array as $format) {
|
||||
parse_str($format);
|
||||
$avail_formats[$i]['itag'] = $itag;
|
||||
$avail_formats[$i]['quality'] = $quality;
|
||||
$type = explode(';', $type);
|
||||
$avail_formats[$i]['type'] = $type[0];
|
||||
$avail_formats[$i]['url'] = urldecode($url) . '&signature=' . $sig;
|
||||
parse_str(urldecode($url));
|
||||
$avail_formats[$i]['expires'] = date("d.m.Y G:i:s", $expire);
|
||||
$avail_formats[$i]['ipbits'] = $ipbits;
|
||||
$avail_formats[$i]['ip'] = $ip;
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($my_type == 'Download') {
|
||||
echo '<p align="left"><b>' . lang('ytdl_available_formats') . ':</b></p>
|
||||
<div class="table-responsive"><table class="table table-hover table-striped"><thead><tr><td>' . lang('ytdl_format') . '</td><td>' . lang('ytdl_quality') . '</td><td>' . lang('ytdl_size') . '</td><td>' . lang('ytdl_download_link') . '</td><td>' . lang('ytdl_available_until') . '</td></tr></thead><tbody>';
|
||||
|
||||
$formats = [
|
||||
'22' => '720p',
|
||||
'18' => '360p',
|
||||
'43' => '360p',
|
||||
'5' => '240p',
|
||||
'36' => '240p',
|
||||
'17' => '144p'
|
||||
];
|
||||
/* now that we have the array, print the options */
|
||||
for ($i = 0; $i < count($avail_formats); $i++) {
|
||||
$type = explode('/', $avail_formats[$i]['type'])[1];
|
||||
$thisurl = base_url('tools/youtube/download?mime=' . $avail_formats[$i]['type'] . '&title=' . urlencode(htmlspecialchars($my_title)) . '&token=' . base64_encode($avail_formats[$i]['url']));
|
||||
$url = base_url('r/' . $this->RedirectModel->addRandomItem($thisurl, true, 6));
|
||||
echo '<tr><td>';
|
||||
echo '<a href="' . base_url('r/' . $this->RedirectModel->addRandomItem($avail_formats[$i]['url'] . '&title=' . $cleanedtitle, true, 6)) . '" class="mime">' . $type . '</a> ';
|
||||
echo '</td> ' .
|
||||
'<td>' . $formats[$avail_formats[$i]['itag']] . '</td><td><span class="size">' . $this->YoutubeDownloadModel->formatBytes($this->YoutubeDownloadModel->get_size($avail_formats[$i]['url'])) . '</span></td>';
|
||||
echo '<td><a href="' . $url . '" class="dl btn btn-default btn-sm">' . lang('ytdl_download_link') . '</a></td><td>' . $avail_formats[$i]['expires'] . '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
echo '</tbody></table></div><small>' . lang('ytdl_not_related_youtube') . '</small><br><small>' . lang('ytdl_no_haftung') . '</small><br><small>Der Betreiber nimmt Abstand von jeglichen urheberrechtsverletzenden Handlungen, die mit dem YouTube-Downloader durchgeführt werden könnten und unterstützt diese keinesfalls.</small>';
|
||||
?>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<?php
|
||||
|
||||
} else {
|
||||
|
||||
/* In this else, the request didn't come from a form but from something else
|
||||
* like an RSS feed.
|
||||
* As a result, we just want to return the best format, which depends on what
|
||||
* the user provided in the url.
|
||||
* If they provided "format=best" we just use the largest.
|
||||
* If they provided "format=free" we provide the best non-flash version
|
||||
* If they provided "format=ipad" we pull the best MP4 version
|
||||
*
|
||||
* Thanks to the python based youtube-dl for info on the formats
|
||||
* http://rg3.github.com/youtube-dl/
|
||||
*/
|
||||
|
||||
$format = $_REQUEST['format'];
|
||||
$target_formats = '';
|
||||
switch ($format) {
|
||||
case "best":
|
||||
/* largest formats first */
|
||||
$target_formats = array('38', '37', '46', '22', '45', '35', '44', '34', '18', '43', '6', '5', '17', '13');
|
||||
break;
|
||||
case "free":
|
||||
/* Here we include WebM but prefer it over FLV */
|
||||
$target_formats = array('38', '46', '37', '45', '22', '44', '35', '43', '34', '18', '6', '5', '17', '13');
|
||||
break;
|
||||
case "ipad":
|
||||
/* here we leave out WebM video and FLV - looking for MP4 */
|
||||
$target_formats = array('37', '22', '18', '17');
|
||||
break;
|
||||
default:
|
||||
/* If they passed in a number use it */
|
||||
if (is_numeric($format)) {
|
||||
$target_formats[] = $format;
|
||||
} else {
|
||||
$target_formats = array('38', '37', '46', '22', '45', '35', '44', '34', '18', '43', '6', '5', '17', '13');
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* Now we need to find our best format in the list of available formats */
|
||||
$best_format = '';
|
||||
for ($i = 0; $i < count($target_formats); $i++) {
|
||||
for ($j = 0; $j < count($avail_formats); $j++) {
|
||||
if ($target_formats[$i] == $avail_formats[$j]['itag']) {
|
||||
//echo '<p>Target format found, it is '. $avail_formats[$j]['itag'] .'</p>';
|
||||
$best_format = $j;
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//echo '<p>Out of loop, best_format is '. $best_format .'</p>';
|
||||
if ((isset($best_format)) &&
|
||||
(isset($avail_formats[$best_format]['url'])) &&
|
||||
(isset($avail_formats[$best_format]['type']))
|
||||
) {
|
||||
$redirect_url = $avail_formats[$best_format]['url'] . '&title=' . $cleanedtitle;
|
||||
$content_type = $avail_formats[$best_format]['type'];
|
||||
}
|
||||
if (isset($redirect_url)) {
|
||||
header("Location: $redirect_url");
|
||||
}
|
||||
|
||||
}
|
||||
$this->load->view('footer');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user