Skip to content

Commit

Permalink
Merge pull request #2 from widibaka/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
widibaka authored Jun 29, 2020
2 parents 8b7dae9 + 430c2c8 commit 5443988
Show file tree
Hide file tree
Showing 35 changed files with 686 additions and 310 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ Tujuan saya adalah untuk menyediakan software web bagi fansub yang ingin memulai
- Silakan hubungi WA 6281226203761 untuk ngobrol dgn saya :)
************
# Rencana Mendatang
- Fitur baru custom release
- Struktur sidebar back-end yang baru
- Membuat dokumentasi untuk mempermudah pengguna
- Membuat video tutorial di youtube, dari instalasi sampai penggunaan
- Notifikasi lewat e-mail masih ada bug, tapi belum diperbaiki
Expand Down
63 changes: 40 additions & 23 deletions application/controllers/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,30 +105,30 @@ public function series_manager_detail($id = 0)
$data['page'] = "series_manager_detail";
$data['page_title'] = 'Sedang mengedit "' . $data['anime']['title'].'"';

//Data from kitsuAPI is called to get 'reset default' work out
$kitsu_search = $data['anime']['title'];

// Karakter yang ngerusak link diganti, difilter
$explode = explode("(", $kitsu_search); // dipecah lalu,
$kitsu_search = $explode[0];// diambil bagian judul jepang doang

$kitsu_search = str_replace(' ', '%20', $kitsu_search); //replacing space characters
$kitsu_search = str_replace(':', '%20', $kitsu_search); //replacing idont know characters
$kitsu_search = str_replace('(', '%20', $kitsu_search); //replacing bracket characters
$kitsu_search = str_replace(')', '%20', $kitsu_search); //replacing bracket characters
$kitsu_search = str_replace('/', '%20', $kitsu_search); //replacing slash
$kitsu_search = str_replace('!', '%20', $kitsu_search); //replacing exclamation
$kitsu_search = str_replace('?', '%20', $kitsu_search); //replacing question mark
$kitsu_search = str_replace("'", '%20', $kitsu_search); //replacing single quote mark
$kitsu_search = htmlspecialchars($kitsu_search);

$data2 = $this->Admin_model->kitsuAPI_single($kitsu_search);
// //Data from kitsuAPI is called to get 'reset default' work out
// $kitsu_search = $data['anime']['title'];

// // Karakter yang ngerusak link diganti, difilter
// $explode = explode("(", $kitsu_search); // dipecah lalu,
// $kitsu_search = $explode[0];// diambil bagian judul jepang doang

// $kitsu_search = str_replace(' ', '%20', $kitsu_search); //replacing space characters
// $kitsu_search = str_replace(':', '%20', $kitsu_search); //replacing idont know characters
// $kitsu_search = str_replace('(', '%20', $kitsu_search); //replacing bracket characters
// $kitsu_search = str_replace(')', '%20', $kitsu_search); //replacing bracket characters
// $kitsu_search = str_replace('/', '%20', $kitsu_search); //replacing slash
// $kitsu_search = str_replace('!', '%20', $kitsu_search); //replacing exclamation
// $kitsu_search = str_replace('?', '%20', $kitsu_search); //replacing question mark
// $kitsu_search = str_replace("'", '%20', $kitsu_search); //replacing single quote mark
// $kitsu_search = htmlspecialchars($kitsu_search);

// $data2 = $this->Admin_model->kitsuAPI_single($kitsu_search);
$this->load->view('templates/header', $data);
$this->load->view('additions/after_header/series_manager_detail');
$this->load->view('templates/navbar', $data);
$this->load->view('templates/sidebar', $data);
// WIDIBAKA! DI sini meragukan! Aku khawatir, tolong check lagi data yang dikirim ke bawah ini.
$this->load->view('tools/admin/series_manager_detail',$data2); // <--
$this->load->view('tools/admin/series_manager_detail',$data); // <--
// Data yg pertama gak dikirim tapi gak error lho. Kok bisa? Harusnya kan 2 data yg dikirim...
$this->load->view('templates/footer', $data);
$this->load->view('additions/after_footer/series_manager_detail');
Expand Down Expand Up @@ -221,7 +221,8 @@ public function add_new_anime_series()
$kitsu_search = str_replace('/', '%20', $kitsu_search); //replacing slash
$kitsu_search = str_replace('!', '%20', $kitsu_search); //replacing exclamation
$kitsu_search = str_replace('?', '%20', $kitsu_search); //replacing question mark
$kitsu_search = str_replace("'", '%20', $kitsu_search); //replacing question mark
$kitsu_search = str_replace("'", '%20', $kitsu_search); //replacing quote mark
$kitsu_search = str_replace("&", '%20', $kitsu_search); //replacing & symbol
$kitsu_search = htmlspecialchars($kitsu_search);
$data['kitsu_anime'] = $this->Admin_model->kitsuAPI_search($kitsu_search, 5);
}
Expand All @@ -231,7 +232,7 @@ public function add_new_anime_series()


$data['page'] = "add_new_anime_series";
$data['page_title'] = 'Add New Anime Series';
$data['page_title'] = 'Add New Series';

$this->load->view('templates/header', $data);
$this->load->view('additions/after_header/series_manager_detail');
Expand All @@ -243,9 +244,24 @@ public function add_new_anime_series()

public function add_new_anime_series_step2($kitsu_search)
{
if (!empty($kitsu_search)) {
if (!empty($kitsu_search) AND $kitsu_search !== '===custom_rilis===') {
$data = $this->Admin_model->kitsuAPI_single($kitsu_search);
}
else {
// kalau custom rilis
$kitsu_anime = file_get_contents( base_url('assets/anime_kosong.json') ); // ambil data anime kosong
$kitsu_anime = json_decode($kitsu_anime, true);
$kitsu_anime = $kitsu_anime["data"][0];
$data['kitsu_anime'] = $kitsu_anime;
$data['kitsu_categories'] = "";
$data['poster_tiny'] = "";
$data['poster_medium'] = "";
$data['season'] = "";
$data['year'] = "";
$data['kitsu_info'] = "";
}
// var_dump($data);
// die();

$this->Admin_model->addAnimeSeries();// Data hasil submit akan ditampung di sini

Expand All @@ -259,7 +275,7 @@ public function add_new_anime_series_step2($kitsu_search)


$data['page'] = "add_new_anime_series_step2";
$data['page_title'] = 'Add New Anime Series Step 2';
$data['page_title'] = 'Add New Series Step 2';

$this->load->view('templates/header', $data);
$this->load->view('additions/after_header/add_new_anime_series_step2');
Expand Down Expand Up @@ -404,6 +420,7 @@ public function website_preferences()

$this->Admin_model->ubahFansubPreferences();

$data['themes_collection'] = $this->User_model->getAllThemesCollection('name'); // lihat di User_model utk lebih jelasnya

$data['page'] = "website_preferences";
$data['page_title'] = "Website Preferences";
Expand Down
50 changes: 26 additions & 24 deletions application/controllers/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,17 @@ public function index()
}
public function Home()
{
$limit = 100;

$data['theme'] = $this->User_model->getTheme();
$data['fansub_preferences'] = $this->Client_model->getFansubPreferences();
$data['five_recent_comments'] = $this->Client_model->getFiveRecentComments(); // 5 recnt comment to put into navbar


$data['episodes'] = $this->Client_model->getAllLatestEpisodes();// limited only 70 episodes in latest update page
$data['episodes'] = $this->Client_model->getAllLatestEpisodes( 100 );// limited to avoid lagging . in the bracket is the limit number
$data['page'] = "home";

$data['page_title'] = "Home";
$data['download_title'] = 'Update Terbaru (40 file terbaru)'; // set anime title to something other than title, to avoid error
$data['download_title'] = 'Update Terbaru ('.$limit.' file terbaru)'; // set anime title to something other than title, to avoid error
$this->load->view('templates/header', $data);
$this->load->view('templates/navbar', $data);
$this->load->view('templates/sidebar', $data);
Expand Down Expand Up @@ -673,27 +673,29 @@ public function upload()

$this->load->library('upload', $config);

if ( ! $this->upload->do_upload('profile_pic'))
{
$error = $this->upload->display_errors() ;
$this->session->set_flashdata('error',$error);
var_dump($error);
die();
}
else
{
$upload_data = $this->upload->data();
// var_dump($upload_data);

// Compress uploaded file
$user_id = $this->session->userdata('user_id');
$this->load->model('ResizeImage');
$this->ResizeImage->dir( $upload_data['full_path'] );
$this->ResizeImage->resizeTo(250, 250, 'maxHeight');
$this->ResizeImage->saveImage('assets/img/' . $user_id . '.jpg');

$this->load->helper('file');
unlink( $upload_data['full_path'] ); // delete temporary file
if ( empty($_FILES['profile_pic']["error"]) ) { // kalau ada error, misal krn tidak diisi, maka ignore aja
if ( ! $this->upload->do_upload('profile_pic'))
{
$error = $this->upload->display_errors() ;
$this->session->set_flashdata('error',$error);
var_dump($error);
die();
}
else
{
$upload_data = $this->upload->data();
// var_dump($upload_data);

// Compress uploaded file
$user_id = $this->session->userdata('user_id');
$this->load->model('ResizeImage');
$this->ResizeImage->dir( $upload_data['full_path'] );
$this->ResizeImage->resizeTo(250, 250, 'maxHeight');
$this->ResizeImage->saveImage('assets/img/' . $user_id . '.jpg');

$this->load->helper('file');
unlink( $upload_data['full_path'] ); // delete temporary file
}
}

$this->User_model->editProfile();
Expand Down
22 changes: 22 additions & 0 deletions application/controllers/Getepisode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
class Getepisode extends CI_Controller
{
public function __construct()
{
parent::__construct(); // Aturan saklek CI, ini harus ada

$this->load->model('Client_model');

//include the configuration
include( 'config/config.php' );
//initiate database with custom config
$this->load->database($config);


}
public function index($anime_child_id){
$data = $this->Client_model->getEpisodesByChildId($anime_child_id)[0];
$data['converted_links'] = explode("@", $data['links']);
echo json_encode($data);
}
}
42 changes: 42 additions & 0 deletions application/controllers/Getlinkmetadata.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
class Getlinkmetadata extends CI_Controller
{
public function index($URL){
$URL = base64_decode($URL);
// echo $URL;
// die();
$html = file_get_contents( $URL );
libxml_use_internal_errors(true); // Yeah if you are so worried about using @ with warnings
$doc = new DomDocument();
$doc->loadHTML($html);
$xpath = new DOMXPath($doc);
$query = '//*/meta[starts-with(@property, \'og:\')]';
$metas = $xpath->query($query);
$rmetas = array();
foreach ($metas as $meta) {
$property = str_replace(":", "_", $meta->getAttribute('property')); // hilangkan "og:" biar objek json nya bisa diakses
$content = $meta->getAttribute('content');
$rmetas[$property] = $content;
}

// get web page title
$rmetas['page_title'] = $this->getTitle( $URL );
// get meta tags
$meta_tags = get_meta_tags( $URL );
$rmetas['meta_tags'] = $meta_tags;

$json = json_encode($rmetas);
echo $json;

// var_dump($meta_tags);
// Output:
// Title: PHP 5 Tutorial
}
// function to get webpage title
public function getTitle($url) {
$page = file_get_contents($url);
$title = preg_match('/<title[^>]*>(.*?)<\/title>/ims', $page, $match) ? $match[1] : null;
return $title;
}
}
7 changes: 4 additions & 3 deletions application/models/Admin_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function kitsuAPI_search($anime_name, $limit)

public function kitsuAPI_single($anime_name)
{
$kitsu_anime = file_get_contents('https://kitsu.io/api/edge/anime?filter[text]='. $anime_name .'&page[limit]=1');
$kitsu_anime = file_get_contents('http://kitsu.io/api/edge/anime?filter[text]='. $anime_name .'&page[limit]=1');
if ( empty($kitsu_anime) ) {
echo "<script>alert('ERROR API! Tampaknya ada yang salah dengan Kitsu API.')</script>";
exit();
Expand Down Expand Up @@ -58,7 +58,7 @@ public function addEpisode( $anime_parent_id, $file_name, $links, $website )
$data = array(
'anime_parent_id' => $anime_parent_id,
'file_name' => $file_name,
'links' => $links,
'links' => substr($links, 0,-1), // ada karakter pengganggu @ di bagian buntut. harus dihilangkan
'website' => $website,
'link_status' => "0,0",
'timestamp' => $waktu_saat_ini,
Expand All @@ -73,7 +73,7 @@ public function editEpisode( $anime_child_id, $file_name, $links, $website )
$waktu_saat_ini = date("Y-m-d H:i:s");
$data = array(
'file_name' => $file_name,
'links' => $links,
'links' => substr($links, 0, -1),
'website' => $website,
'timestamp' => $waktu_saat_ini,
);
Expand Down Expand Up @@ -275,6 +275,7 @@ public function ubahFansubPreferences()
'rows_perpage_tile' => $this->input->post('rows_perpage_tile', true),
'rows_perpage_list' => $this->input->post('rows_perpage_list', true),
'about_text' => $this->input->post('about_text', true),
'theme_default' => $this->input->post('theme_default', true),
);
$this->db->where('id', 1);
$this->db->update('fansub_preferences', $data1);
Expand Down
4 changes: 2 additions & 2 deletions application/models/Client_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ public function getAllEpisodes()
return $episodes;
}

public function getAllLatestEpisodes()
public function getAllLatestEpisodes($limit)
{
$this->db->order_by('anime_child_id', 'DESC');
$this->db->limit(40); // limited until 70th to avoid lagging
$this->db->limit( $limit ); // limited to avoid lagging
$query = $this->db->get('episodes'); // Produces: SELECT * FROM mytable
$episodes = $query->result_array();
foreach ($episodes as $i => $eps) {
Expand Down
Loading

0 comments on commit 5443988

Please sign in to comment.