-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b140396
Showing
268 changed files
with
8,326 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
DB_HOST=localhost | ||
DB_NAME=musica_clone | ||
DB_USER=root | ||
DB_PASS= | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/AdminLTE/ | ||
/migrations/ | ||
/vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: vendor/bin/heroku-php-apache2 public/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
<?php | ||
|
||
namespace App\Controllers; | ||
|
||
use App\Models\Ads; | ||
use App\Models\User; | ||
use App\Models\Album; | ||
use App\Models\Lyric; | ||
use App\Models\Artist; | ||
use App\Models\Setting; | ||
use App\Helpers\Helpers; | ||
|
||
|
||
class AdminController extends BaseController { | ||
|
||
public function getIndex(){ | ||
|
||
Helpers::CheckAdmin(); | ||
|
||
$total_artistas = Artist::count(); | ||
$total_canciones = Lyric::where('status','=','1')->count(); | ||
$total_albums = Album::count(); | ||
// $canciones_inactivas = count(Song::where('actionsong_id','=','2')->get()); | ||
$total_usuarios= User::count(); | ||
|
||
|
||
return $this->view('admin/index.twig',compact('total_artistas','total_canciones','total_usuarios','total_albums')); | ||
} | ||
|
||
|
||
public function getAds(){ | ||
|
||
Helpers::CheckAdmin(); | ||
|
||
$ads = Ads::first(); | ||
|
||
return $this->view('admin/ads.twig',compact('ads')); | ||
} | ||
|
||
public function postAds(){ | ||
|
||
Helpers::CheckAdmin(); | ||
|
||
|
||
$ads = Ads::find(1); | ||
$ads->adaptable = $_POST['adaptable']; | ||
$ads->horizontal = ''; | ||
$ads->cuadro300 = $_POST['cuadro']; | ||
$ads->vertical300 = $_POST['300v']; | ||
$ads->vertical160 = ''; | ||
$ads->ads368 = $_POST['cuadro2']; | ||
|
||
if($ads->save()){ | ||
$this->setFlashMsg('success','Anuncios actualizados con exito!'); | ||
header('location:'.Helpers::getReferer()); | ||
exit; | ||
} | ||
$this->setFlashMsg('error','Hubo un error al actualizar vuelve a intentarlo'); | ||
header('location:'.Helpers::getReferer()); | ||
exit; | ||
} | ||
|
||
public function getAjustes(){ | ||
|
||
Helpers::CheckAdmin(); | ||
|
||
$setting = Setting::first(); | ||
|
||
return $this->view('admin/ajustes.twig',compact('setting')); | ||
} | ||
|
||
public function postAjustes(){ | ||
|
||
Helpers::CheckAdmin(); | ||
|
||
$setting = Setting::find(1); | ||
$setting->website_name = $_POST['website_name']; | ||
$setting->website_title = $_POST['website_title']; | ||
$setting->website_description = $_POST['website_description']; | ||
$setting->facebook_url = $_POST['facebook_url']; | ||
$setting->instagram_url = $_POST['instagram_url']; | ||
$setting->twitter_url = $_POST['twitter_url']; | ||
$setting->youtube_url = $_POST['youtube_url']; | ||
$setting->meta_head = $_POST['meta_head']; | ||
$setting->meta_footer = $_POST['meta_footer']; | ||
|
||
if($setting->save()){ | ||
$this->setFlashMsg('success','Ajustes actualizados con exito!'); | ||
header('location:'.Helpers::getReferer()); | ||
exit; | ||
} | ||
$this->setFlashMsg('error','Hubo un error al actualizar vuelve a intentarlo'); | ||
header('location:'.Helpers::getReferer()); | ||
exit; | ||
|
||
} | ||
|
||
public function getAjax(){ | ||
$tipo = $_GET['tipo']; | ||
if($tipo =='artista'){ | ||
$results = Artist::query()->select('name', 'id')->where('name', 'LIKE', $_GET['q'].'%')->limit(5)->get(); | ||
foreach ($results as $query) | ||
{ | ||
$arg[] = [ 'id' => $query->id, 'text' => $query->name]; | ||
} | ||
}else if($tipo =='album'){ | ||
$results = Album::query()->where('artist_id', $_GET['artist'])->get(); | ||
$arg = $results; | ||
} | ||
|
||
return json_encode($arg); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace App\Controllers; | ||
|
||
use App\Models\Ads; | ||
use App\Models\Lyric; | ||
use App\Models\Artist; | ||
use App\Models\Setting; | ||
use App\Helpers\Helpers; | ||
use Melbahja\Seo\Factory; | ||
|
||
class ArtistaController extends BaseController { | ||
|
||
public function getIndex($id = ''){ | ||
|
||
$lyric = Artist::query()->where('slug', '=', $id)->first(); | ||
if(!$lyric){ header('location:'.Helpers::home_url()); exit;} | ||
$lyric->view = $lyric->view+1; | ||
$setting = Setting::first(); | ||
$lyric->save(); | ||
$ads = Ads::first(); | ||
|
||
$metatags = Factory::metaTags(); | ||
|
||
$metatags->meta('title', 'Letra de '.$lyric->name.' - ' .$setting->website_name) | ||
->meta('description', 'Letras, fotos y videos de '.$lyric->nam) | ||
->meta('robots', 'index, follow') | ||
->image(Helpers::home_url().'upload/artista/'.$lyric->image) | ||
->url(Helpers::home_url().'artista/'.$lyric->slug) | ||
->facebook('locale', 'es_ES') | ||
->facebook('type', 'music.song'); | ||
|
||
|
||
$general = array( | ||
'title' => 'Letra de '.$lyric->name.' - ' .$setting->website_name, | ||
'setting' =>$setting, | ||
'metas' => $metatags | ||
); | ||
|
||
|
||
return $this->view('artista.twig',compact('lyric','ads','general')); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
namespace App\Controllers; | ||
|
||
use App\Models\User; | ||
use App\Helpers\Helpers; | ||
use Sirius\Validation\Validator; | ||
|
||
class AuthController extends BaseController{ | ||
|
||
|
||
public function getIndex(){ | ||
|
||
return $this->view('auth/login.twig'); | ||
} | ||
|
||
public function getLogin(){ | ||
|
||
return $this->view('auth/login.twig'); | ||
} | ||
|
||
public function postLogin(){ | ||
|
||
$validator = new Validator(); | ||
$validator->add('email','required', null,'El correo es obligatorio.'); | ||
$validator->add('email','email', null,'El correo es obligatorio.'); | ||
$validator->add('password','required', null,'El password es obligatorio.'); | ||
|
||
if($validator->validate($_POST)){ | ||
$user = User::where('email',$_POST['email'])->first(); | ||
if($user){ | ||
if(password_verify($_POST['password'],$user->password)){ | ||
$_SESSION['userId'] = $user->id; | ||
$_SESSION['name'] = $user->name; | ||
if(isset($_POST['ajax'])){ | ||
echo 1; | ||
exit; | ||
}else{ | ||
|
||
|
||
if(!\App\Helpers\Helpers::isAdmin($user->id)){ | ||
header('Location:' . \App\Helpers\Helpers::get_home_url().'cuenta'); | ||
exit; | ||
} | ||
header('Location:'. \App\Helpers\Helpers::get_home_url().'admin'); | ||
exit; | ||
} | ||
|
||
} | ||
} | ||
//Not OK | ||
$validator->addMessage('email','Correo/Password invalido intente de nuevo'); | ||
|
||
} | ||
$errors = $validator->getMessages(); | ||
|
||
return $this->view('auth/login.twig',['errors'=>$errors]); | ||
|
||
} | ||
|
||
public function getLogout(){ | ||
unset($_SESSION['userId'], $_SESSION['name']); | ||
header('Location:' .\App\Helpers\Helpers::home_url().'auth/login'); | ||
} | ||
|
||
public function getSalir(){ | ||
unset($_SESSION['userId'], $_SESSION['name']); | ||
header('Location:' .\App\Helpers\Helpers::getReferer()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
<?php | ||
|
||
namespace App\Controllers; | ||
|
||
use App\Models\Lists; | ||
use App\Models\Lyric; | ||
use App\Models\Artist; | ||
use App\Models\Setting; | ||
use App\Helpers\Helpers; | ||
use Plasticbrain\FlashMessages\FlashMessages; | ||
|
||
|
||
|
||
class BaseController extends Helpers { | ||
|
||
protected $templateEngine; | ||
public $cities; | ||
|
||
public function __construct(){ | ||
$loader = new \Twig\Loader\FilesystemLoader('../views'); | ||
$this->templateEngine = new \Twig\Environment($loader,[ | ||
'debug' => true, | ||
'cache' => false | ||
// 'cache' => '../temp' | ||
]); | ||
|
||
$filter = new \Twig\TwigFilter('url', function ($path) { | ||
return $this->home_url().$path; | ||
}); | ||
|
||
$twigFunction = new \Twig\TwigFilter('msg', function () { | ||
$msg = new FlashMessages(); | ||
// $msg->display(); | ||
return $msg; | ||
}); | ||
|
||
|
||
|
||
$this->templateEngine->addFunction( | ||
new \Twig\TwigFunction( | ||
'getChecked', | ||
function($id, $song) { | ||
|
||
$results = Lists::where('playlist_id', $id)->where('lyric_id', $song)->first(); | ||
return $results; | ||
} | ||
) | ||
); | ||
$this->templateEngine->addFunction( | ||
new \Twig\TwigFunction( | ||
'getTotal', | ||
function($ids) { | ||
|
||
foreach(json_decode($ids) as $item){ | ||
$find[] = $item->id; | ||
} | ||
if(empty($find)){ return false; } | ||
$results = Lyric::where('artist_id',$find)->count(); | ||
return $results; | ||
} | ||
) | ||
); | ||
|
||
$this->templateEngine->addFunction( | ||
new \Twig\TwigFunction( | ||
'getFeats', | ||
function($base,$feats) { | ||
$feats = unserialize($feats); | ||
$results['author'] = Artist::query()->select('name', 'slug')->find($base); | ||
$results['feats'] = Artist::query()->select('name', 'slug')->find($feats); | ||
return $results; | ||
} | ||
) | ||
); | ||
|
||
$this->templateEngine->addFunction( | ||
new \Twig\TwigFunction( | ||
'getArtistsFromID', | ||
function($ids,$unserial = false) { | ||
$ids = (!$unserial)? unserialize($ids) : $ids; | ||
$results = Artist::query()->select('name', 'id')->find($ids); | ||
return $results; | ||
} | ||
) | ||
); | ||
|
||
$this->templateEngine->addFilter($twigFunction); | ||
$this->templateEngine->addFilter($filter); | ||
$this->templateEngine ->addExtension(new \Twig\Extension\DebugExtension()); | ||
|
||
} | ||
|
||
public function view($fileName, $data = []){ | ||
if(isset($_SESSION['userId'])){ | ||
$data['estaLogin'] = true; | ||
$data['userName'] = $_SESSION['name']; | ||
} | ||
return $this->templateEngine->render($fileName,$data); | ||
} | ||
/** | ||
* @method success, info,warning,error | ||
* @param Method,Array | ||
*/ | ||
public function setFlashMsg($type ='', $text=[]){ | ||
$msg = new FlashMessages(); | ||
$initial_array = [$text]; | ||
$final_array = array_map([$msg, $type], $initial_array); | ||
return $msg; | ||
} | ||
} |
Oops, something went wrong.