Commit 7626cdf7 authored by NightWalker Yao's avatar NightWalker Yao 👦🏿
Browse files

Version 1.0

parent 03bc7382
; <?php /* Don't remove this line!
[web]
charset = "UTF-8"
timezone = "Africa/Abidjan"
name = "Simbou music 12"
author = "NightWalker Yao <about.me/nightwalker.y>"
url = "http://localhost"
default_cover = "/files/images/covers/default/KDduun9H.jpg"
keywords = "empty"
description = "empty"
default_language = "fr"
default_avatar = "/files/images/profiles/default/8qaRaRKD.jpg"
download_method = "readfile"
download_method_extra = "direct"
fb_plug_in = ""
[lang]
available = "fr"
default = "fr"
[email]
method = "smtp"
host = "localhost"
username = "root"
password = ""
port = 25
encryption = "tls"
admin_mail = "root@localhost"
noreply = "root@localhost"
[database]
driver = "mysql"
host = "localhost"
schema = "mp3_free_ci"
username = "root"
password = "root"
tbl_prefix = "mpf3_"
[dev]
published = true
display_errors = true
live_stats = false
advanced_stats = true
; Don't remove this line! */
/files/*
/logs/*
/var/*
Options +Indexes
Options +FollowSymlinks
RewriteEngine On
RewriteBase /mp3.free.ci/web/
RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
File mode changed from 100644 to 100755
<?php
$User = new User();
$User->checkStatus(true /*, true*/);
if(!$User->can_upload) {
die(json_encode([
'success'=> false,
'error'=> '403 Forbiden, You are not allowed to access this page'
]));
}
if(!empty($_POST)) {
extract($_POST);
require_once APP_ROOT."/php/gallery.class.php";
$album = new Gallery();
if(!empty($title)) {
$album->title = trim($title);
}
if(!empty($description)) {
$album->description = purify_html($description);
}
if(!empty($photos)) {
$p = [];
if(is_array($photos) && (!empty($captions) && is_array($captions))) {
for($i=0; $i<min(count($photos), count($captions)); $i++) {
$p[] = [
'path'=>strip_tags($photos[$i]),
'caption'=>$captions[$i]
];
}
}
$album->photos = $p;
}
$chk = $album->isSaveable();
if(empty($chk)) {
$album->author = $User->id;
$album->visible = $User->auto_validate_uploads ? 1 : 0;
//create thumbs and mobile formats
foreach ($album->photos as $key => $value) {
$album->photos[$key]['thumb'] = resize_image(APP_ROOT.$album->photos[$key]['path'], [348,235], get_upload_dir('photo_gallery'))[1];
$album->photos[$key]['medium'] = resize_image(APP_ROOT.$album->photos[$key]['path'], [480,315], get_upload_dir('photo_gallery'))[1];
$album->photos[$key]['large'] = resize_image(APP_ROOT.$album->photos[$key]['path'], [800,534], get_upload_dir('photo_gallery'))[1];
}
$album->cover = $album->photos[0];
$album->save();
die(json_encode([
'success'=>true,
'url'=> url('pg_view', ['slug'=>$album->slug])
]));
} else {
die(json_encode([
'success'=> false,
'error'=> implode('\n', $chk)
]));
}
}else {
die(json_encode([
'success'=> false,
'error'=> 'No data submitted'
]));
}
<?php
$User = new User();
$User->checkStatus(true, true);
if(!empty($_POST['id']) && !empty($_POST['field']) && isset($_POST['value'])) {
extract($_POST);
$m = new Adv();
$m->find(intval($id));
if(in_array($field, ['caption', 'link', 'author', 'created', 'publish_to', 'visible', 'impressions'])) {
$m->update([$field=> $value]);
die(json_encode([
'success'=>true,
'id'=>$id,
'field'=>$field,
'value'=>$value
]));
}
}
die(json_encode([
'success'=> false,
'error'=> 'Champs de formulaire non fournis'
]));
<?php
$User = new User();
$User->checkStatus(true, true);
if(!empty($_POST['id']) && !empty($_POST['field']) && isset($_POST['value'])) {
extract($_POST);
$m = new Album();
$m->find(intval($id));
if(in_array($field, ['slug', 'artist', 'name', 'genre', 'tracks_nb', 'year', 'duration', 'label', 'filesize', 'visible', 'uploader', 'uploaded', 'hits', 'featured', 'country', 'likes', 'dislikes', 'comments', 'other_infos'])) {
$m->update([$field=> $value]);
die(json_encode([
'success'=>true,
'id'=>$id,
'field'=>$field,
'value'=>$value
]));
}
}
die(json_encode([
'success'=> false,
'error'=> 'Champs de formulaire non fournis'
]));
<?php
$User = new User();
$User->checkStatus(true, true);
if(!empty($_POST['id']) && !empty($_POST['field']) && isset($_POST['value'])) {
extract($_POST);
$a = new Artist();
$a->find(intval($id));
if(in_array($field, ['slug', 'name', 'country', 'songs', 'albums'])) {
$a->update([$field=> $value]);
die(json_encode([
'success'=>true,
'id'=>$id,
'field'=>$field,
'value'=>$value
]));
}
}
die(json_encode([
'success'=> false,
'error'=> 'Champs de formulaire non fournis'
]));
<?php
$User = new User();
$User->checkStatus(true /*, true*/);
if(!$User->can_upload) {
die(json_encode([
'success'=> false,
'error'=> LANG_E_FORBIDEN
]));
}
if(!empty($_POST) && !empty($_POST['id'])) {
extract($_POST);
require_once APP_ROOT."/php/gallery.class.php";
$album = new Gallery();
$album->find(intval($id));
if(($album->author != $User->id && !$User->is_admin) || null === $album->id) {
die(json_encode([
'success'=> false,
'error'=> LANG_E_FORBIDEN
]));
}
if(!empty($_POST['quickaction'])) {
$v = intval($album->visible);
if($action === 'chstatus'){
$album->update(['visible'=>$v?0:1]);
die(json_encode([
'success'=> true,
'new_status'=> $v?0:1
]));
} elseif($action === 'delete') {
$photos = unserialize($album->photos);
foreach ($photos as $key => $value) {
@unlink(APP_ROOT.$value['path']);
@unlink(APP_ROOT.$value['thumb']);
@unlink(APP_ROOT.$value['medium']);
@unlink(APP_ROOT.$value['large']);
}
$album->clear($album->id);
die(json_encode(['success'=> true]));
}
}
$dat = [];
$slug = $album->slug;
if(!empty($title)) {
$dat['title'] = trim($title);
}
if(!empty($description)) {
$dat['description'] = purify_html($description);
}
if(!empty($photos)) {
$p = [];
if(is_array($photos) && (!empty($captions) && is_array($captions))) {
for($i=0; $i<min(count($photos), count($captions)); $i++) {
$p[] = [
'path'=>strip_tags($photos[$i]),
'caption'=>$captions[$i]
];
}
}
$dat['photos'] = $p;
}
$old_photos = unserialize($album->photos);
set_object_vars($album, $dat);
$chk = $album->isSaveable(false);
if(empty($chk)) {
//create thumbs and mobile formats
foreach ($old_photos as $key => $value) {
$found = false;
foreach ($album->photos as $k => $v) {
if($value['path'] == $v['path']) {
$album->photos[$k] = $value;
$album->photos[$k]['caption'] = $v['caption'];
$found = true;
}
}
if(!$found) { //photo changed, goto delete it
@unlink(APP_ROOT.$value['path']);
@unlink(APP_ROOT.$value['thumb']);
@unlink(APP_ROOT.$value['medium']);
@unlink(APP_ROOT.$value['large']);
}
}
foreach ($album->photos as $key => $value) {
if(!isset($value['thumb'])) { //it is a new photo
$album->photos[$key]['thumb'] = resize_image(APP_ROOT.$album->photos[$key]['path'], [348,235], get_upload_dir('photo_gallery'))[1];
$album->photos[$key]['medium'] = resize_image(APP_ROOT.$album->photos[$key]['path'], [480,315], get_upload_dir('photo_gallery'))[1];
$album->photos[$key]['large'] = resize_image(APP_ROOT.$album->photos[$key]['path'], [800,534], get_upload_dir('photo_gallery'))[0];
}
}
$dat['cover'] = serialize($album->photos[0]);
$dat['photos'] = serialize($album->photos);
$album->update($dat);
die(json_encode([
'success'=>true,
'url'=> url('pg_view', ['slug'=>$slug])
]));
} else {
die(json_encode([
'success'=> false,
'error'=> implode('\n', $chk)
]));
}
}else {
die(json_encode([
'success'=> false,
'error'=> 'No data submitted'
]));
}
<?php
$User = new User();
$User->checkStatus(true, true);
if(!empty($_POST['id']) && !empty($_POST['field']) && isset($_POST['value'])) {
extract($_POST);
$m = new Music();
$m->find(intval($id));
if(in_array($field, ['slug', 'artist', 'title', 'album', 'genre', 'track', 'year', 'duration', 'label', 'filesize', 'visible', 'uploader', 'uploaded', 'hits', 'featured', 'country', 'likes', 'dislikes', 'comments', 'bitrate'])) {
$m->update([$field=> $value]);
die(json_encode([
'success'=>true,
'id'=>$id,
'field'=>$field,
'value'=>$value
]));
}
}
die(json_encode([
'success'=> false,
'error'=> 'Champs de formulaire non fournis'
]));
<?php
$User = new User();
$User->checkStatus(true, true);
if(!empty($_POST['id']) && !empty($_POST['field']) && isset($_POST['value'])) {
extract($_POST);
$u = new User();
$u->find(intval($id));
if(in_array($field, ['username', 'password', 'email', 'full_name', 'token', 'registered', 'last_login', 'last_activity', 'last_ip', 'country', 'language', 'avatar', 'timezone', 'can_upload', 'auto_validate_uploads', 'downloads', 'is_admin'])) {
$u->update([$field=> $value]);
die(json_encode([
'success'=>true,
'id'=>$id,
'field'=>$field,
'value'=>$value
]));
}
}
die(json_encode([
'success'=> false,
'error'=> 'Champs de formulaire non fournis'
]));
<?php
$User = new User();
$User->checkStatus(true, true);
$arel = new Release();
if(!empty($_POST)) {
$arel -> find(['id'=>intval($_POST['id'])]);
array_trim($_POST);
$form_fields = ['artist', 'album', 'rdate', 'author', 'tracklist', 'comment', 'views'];
$dfs = [];
foreach ($form_fields as $value) {
if(isset($_POST[$value])) {
if(!empty($_POST[$value])) {
$dfs[$value] = $_POST[$value];
} else {
$dfs[$value] = "";
}
}
}
$dfs['comment'] = (empty($dfs['comment'])) ? '' : purify_html($dfs['comment']);
set_object_vars($arel, $dfs);
$ch = $arel->isSaveable(false);
if(empty($ch)) {
$dfs['visible'] = 1;
$dfs['tracklist'] = serialize($dfs['tracklist']);
$arel->update($dfs);
$dfs['tracklist'] = unserialize($dfs['tracklist']);
die(json_encode([
'success'=>true,
'new_values'=> $dfs
]));
} else {
die(json_encode([
'success'=>false,
'error'=>implode('<br>', $ch)
]));
}
}
die(json_encode([
'success'=>false,
'error'=>'Champs de formulaire non fournis'
]));
<?php
$User = new User();
$User->checkStatus(true, true);
$album = new Album();
if(!empty($_POST)) {
$album -> load(['id'=>intval($_POST['id'])]);
array_trim($_POST);
$form_fields = ['slug', 'artist', 'name', 'genre', 'tracks_nb', 'year', 'duration', 'label', 'filesize', 'visible', 'uploader', 'uploaded', 'hits', 'featured', 'country', 'likes', 'dislikes', 'comments', 'bitrate'];
$dfs = [];
$old_s = $album->slug;
$oi = $album->other_infos;
foreach ($form_fields as $value) {
if(isset($_POST[$value])) {
if(!empty($_POST[$value])) {
if($value == 'bitrate'){
$oi['bitrate'] = trim($_POST['bitrate']);
$dfs['other_infos'] = $oi;
}else{
$dfs[$value] = trim($_POST[$value]);
}
} else {
$dfs[$value] = "";
}
}
}
set_object_vars($album, $dfs);
$ch = $album->isSaveable(false);
if(empty($ch)) {
if(!empty($dfs['artist']) && !empty($dfs['name'])) {
$ns = make_slug($dfs['artist'] .'-'. $dfs['name']);
if($ns != $old_s) {
if($album->isUnique(['slug'=>$ns])) {
$dfs['slug'] = $ns;
$album->slug = $ns;
} else {
$album->slug = $old_s;
}
}
}
$dfs['visible'] = 1;
$dfs['other_infos'] = serialize($dfs['other_infos']);
$album->update($dfs);
die(json_encode([
'success'=>true,
]));
} else {
die(json_encode([
'success'=>false,
'error'=>implode('<br>', $ch)
]));
}
}
die(json_encode([
'success'=>false,
'error'=>'Champs de formulaire non fournis'
]));
<?php
$User = new User();
$User->checkStatus(true, true);
$music = new Music();
if(!empty($_POST)) {
$music -> load(['id'=>intval($_POST['id'])]);
array_trim($_POST);
$form_fields = ['slug', 'artist', 'title', 'album', 'genre', 'track', 'year', 'duration', 'label', 'filesize', 'visible', 'uploader', 'uploaded', 'hits', 'featured', 'country', 'likes', 'dislikes', 'comments', 'bitrate'];
$dfs = [];
$old_s = $music->slug;
foreach ($form_fields as $value) {
if(isset($_POST[$value])) {
if(!empty($_POST[$value])) {
$dfs[$value] = trim($_POST[$value]);
} else {
$dfs[$value] = "";
}
}
}
set_object_vars($music, $dfs);
$ch = $music->isSaveable(false);
if(empty($ch)) {
if(!empty($dfs['artist']) && !empty($dfs['title'])) {
$ns = make_slug($dfs['artist'] .'-'. $dfs['title']);
if($ns != $old_s) {
if($music->isUnique(['slug'=>$ns])) {
$dfs['slug'] = $ns;
$music->slug = $ns;
} else {
$music->slug = $old_s;
}
}
}
$dfs['visible'] = 1;
$music->update($dfs);
die(json_encode([
'success'=>true,
]));
} else {
die(json_encode([
'success'=>false,
'error'=>implode('\n', $ch)
]));
}
}
die(json_encode([
'success'=>false,
'error'=>'Champs de formulaire non fournis'
]));
<?php
$User = new User();
$User->checkStatus(true, true);
if(!empty($_POST['rels']) && !empty($_POST['action'])) {
extract($_POST);
$arel = new Release();
if($action === 'validate' || $action === 'hide') {
$arel->updateMultiple(['visible'=>($action=='hide'?0:1)], $rels);
} elseif($action === 'delete') {
$it = new Release();
foreach ($rels as $m) {
$it->find(['id'=>intval($m)]);
if(null !== $it->id) {
$imgs = unserialize($it->cover);
//die(var_dump($imgs));
$it->clear($it->id);
if($imgs['max'] !== APP_CONFIG['web']['default_cover']) {
@unlink(APP_ROOT.$imgs['max']);
@unlink(APP_ROOT.$imgs['min']);
}
}
$it->id = null;
}
}
die(json_encode([
'success'=>true,
'action'=>$action,
'items'=>$rels
]));
}
die(json_encode([
'success'=>false,
'error'=>'Champs de formulaire non fournis'
]));
<?php
$User = new User();
$User->checkStatus(true, true);
if(!empty($_POST['albums']) && !empty($_POST['action'])) {
extract($_POST);
$album = new Album();
if($action === 'validate' || $action === 'hide') {
$album->updateMultiple(['visible'=>($action=='hide'?0:1)], $albums);
} elseif($action === 'delete') {
$it = new Album();
foreach ($albums as $m) {
$it->load(['id'=>intval($m)]);
if(null !== $it->id) {
$imgs = $it->cover;
//die(var_dump($imgs));
$af = $it->file;
$it->clear($it->id);
if($imgs['max'] != APP_CONFIG['web']['default_cover']) {
@unlink(APP_ROOT.$imgs['max']);
@unlink(APP_ROOT.$imgs['min']);
}
if(is_dir(APP_ROOT.$af['dir'])) {
rrmdir(APP_ROOT.$af['dir']);
}
$Artist = new Artist();
$Artist->load($it->artist);