/admin/app/controllers/musics_controller.php
PHP | 493 lines | 298 code | 36 blank | 159 comment | 11 complexity | 2efae988d690ba6e4cc30296632accf8 MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0, GPL-2.0, MIT
- <?php
- class MusicsController extends AppController
- {
- var $name='Musics';
- var $components = array('Pagination');
- var $helpers = array('Pagination', 'error');
- function manageusermusic()
- {
- $this->checkSession();
- $this->layout = 'default_user';
- }
-
- function view_musicgroup($id=null , $uid=null)
- {
- $this->checkSession();
- $this->layout = 'default_user';
- }
- function usermusicdetails($pid=null)
- {
- $this->checkSession();
- $this->layout = 'default_user';
-
- }
-
- function add_music()
- {
- $this->checkSession();
- $this->layout = 'default_user';
-
- /* Grtting the Music caltegory*/
- $music_cat = array();
- $music_cat[0] = "Select Category";
- $select_music_category = mysql_query("Select * from music_categories");
- while($select_music_category_res = mysql_fetch_array($select_music_category))
- {
- $music_cat[$select_music_category_res['id']] = $select_music_category_res['music_cat_name'] ;
- }
- $this->set('music_category',$music_cat);
-
- }
- function addmusicstep2()
- {
- $this->checkSession();
- $this->layout = 'default_user';
-
- if (!empty($this->data))
- {
- $this->data['Music']['user_id'] = $_REQUEST['musicuser'];
- if($_REQUEST['category']==0)
- $this->data['Music']['music_categorie_id'] = 1;
-
- $this->data['Music']['music_categorie_id'] = $_REQUEST['category'];
-
- if ($this->Music->save($this->data))
- {
- $music_id = $this->Music->getLastInsertId();
- $this->redirect('/musics/add_musicstep2?uid='.$_REQUEST['musicuser'].'&pid='.$music_id);
- }
- }
-
- }
- function add_musicstep2()
- {
- $this->checkSession();
- $this->layout = 'default_user';
- }
- function delete_musicgroup($id=null)
- {
- $this->checkSession();
- if(isset($_REQUEST['box']))
- {
- /////IF SEARCH IS COLLECTIVE OR CHOSEN BY ADMIN SELECTION//////
-
- $arr = $_REQUEST['box'];
- foreach($arr as $key => $value)
- {
- $sql_det = "delete from `musics` where `user_id` = '".$value."'";
- $res_det = mysql_query($sql_det);
- }
- }
- ////IF DELETE IS FOR A SPECIFIC USER////
- else
- {
- $user_id=$_REQUEST['id'];
- $this->data['Music']['menu'] = $_REQUEST['menu'];
- $sql_det = "delete from `musics` where `user_id` = '".$user_id."'";
- $res_det = mysql_query($sql_det);
- }
- //$user_id=$_REQUEST['id'];
- $this->data['Music']['menu'] = $_REQUEST['menu'];
- if(isset($_REQUEST['page']))
- {
- $page = $_REQUEST['page'];
- }
- $this->flash('The post with id: '.$id.' has been deleted.', '/posts');
- $this->redirect('/musics/manageusermusic?menu='.$this->data['Music']['menu'].'&page='.$page);
- }
-
- function managehotmusic()
- {
- $this->checkSession();
- $this->layout = 'default_user';
-
- }
- function edithotmusic()
- {
- $this->checkSession();
- $this->layout = 'default_user';
-
-
- $music_cat = array();
- $music_cat[0] = "Select Category";
- $select_music_category = mysql_query("Select * from music_categories");
- while($select_music_category_res = mysql_fetch_array($select_music_category))
- {
- $music_cat[$select_music_category_res['id']] = $select_music_category_res['music_cat_name'] ;
- }
- $this->set('music_category',$music_cat);
-
- }
- function saveedithotmusic()
- {
- $update_sql = "Update music_hot set title='".$_REQUEST['mustitle']."' , music_id =".$_REQUEST['musicinfo']." where id=".$_REQUEST['hid']."";
- mysql_query($update_sql);
- $this->redirect('/musics/edithotmusicphoto?id='.$_REQUEST['hid']);
- }
- function edithotmusicphoto()
- {
- $this->checkSession();
- $this->layout = 'default_user';
- }
- function listenhotmusic()
- {
- $this->checkSession();
- $this->layout = 'default_user';
- }
- function delhotmusic()
- {
- $this->checkSession();
- $this->layout = 'default_user';
- /* delete hot music */
- $delhot = mysql_query("Delete From music_hot where id=".$_REQUEST['id']."");
-
- $this->redirect('/musics/managehotmusic?menu='.$_REQUEST['menu']);
-
- }
- function delete_hotmusicgroup()
- {
- $this->checkSession();
- if(isset($_REQUEST['box']))
- {
- /////IF SEARCH IS COLLECTIVE OR CHOSEN BY ADMIN SELECTION//////
-
- $arr = $_REQUEST['box'];
- foreach($arr as $key => $value)
- {
- $sql_det = "delete from `music_hot` where `id` = '".$value."'";
- $res_det = mysql_query($sql_det);
- }
- }
- ////IF DELETE IS FOR A SPECIFIC USER////
- else
- {
- $user_id=$_REQUEST['id'];
- $this->data['Music']['menu'] = $_REQUEST['menu'];
- $sql_det = "delete from `music_hot` where `id` = '".$user_id."'";
- $res_det = mysql_query($sql_det);
- }
- //$user_id=$_REQUEST['id'];
- $this->data['Music']['menu'] = $_REQUEST['menu'];
- if(isset($_REQUEST['page']))
- {
- $page = $_REQUEST['page'];
- }
- $this->flash('The post with id: '.$id.' has been deleted.', '/posts');
- $this->redirect('/musics/managehotmusic?menu='.$this->data['Music']['menu'].'&page='.$page);
- }
- function add_hotmusic()
- {
- $this->checkSession();
- $this->layout = 'default_user';
-
- /* Grtting the Music caltegory*/
- $music_cat = array();
- $music_cat[0] = "Select Category";
- $select_music_category = mysql_query("Select * from music_categories");
- while($select_music_category_res = mysql_fetch_array($select_music_category))
- {
- $music_cat[$select_music_category_res['id']] = $select_music_category_res['music_cat_name'] ;
- }
- $this->set('music_category',$music_cat);
-
- }
- function addhotmusicstep2()
- {
- $this->checkSession();
- $this->layout = 'default_user';
- //pr($_REQUEST);
- /* Insert into table name */
- $inserhot = "INSERT INTO `music_hot` ( `id` , `title` , `music_desc` , `file_name` , `url` , `music_id` )
- VALUES ('', '".$_REQUEST['hottitle']."', '', '', '', '".$_REQUEST['musicinfo']."')" ;
- $inserhot_res = mysql_query($inserhot);
- $inserhot_res_id = mysql_insert_id();
- $this->redirect('/musics/edithotmusicphoto?id='.$inserhot_res_id);
-
- }
- function managefeaturedmusic()
- {
- $this->checkSession();
- $this->layout = 'default_user';
- }
-
- function delete_featuredmusicgroup()
- {
- $this->checkSession();
- if(isset($_REQUEST['box']))
- {
- /////IF SEARCH IS COLLECTIVE OR CHOSEN BY ADMIN SELECTION//////
-
- $arr = $_REQUEST['box'];
- foreach($arr as $key => $value)
- {
- $sql_det = "delete from `music_featured` where `id` = '".$value."'";
- $res_det = mysql_query($sql_det);
- }
- }
- ////IF DELETE IS FOR A SPECIFIC USER////
- else
- {
- $user_id=$_REQUEST['id'];
- $this->data['Music']['menu'] = $_REQUEST['menu'];
- $sql_det = "delete from `music_featured` where `id` = '".$user_id."'";
- $res_det = mysql_query($sql_det);
- }
- //$user_id=$_REQUEST['id'];
- $this->data['Music']['menu'] = $_REQUEST['menu'];
- if(isset($_REQUEST['page']))
- {
- $page = $_REQUEST['page'];
- }
- $this->flash('The post with id: '.$id.' has been deleted.', '/posts');
- $this->redirect('/musics/managefeaturedmusic?menu='.$this->data['Music']['menu'].'&page='.$page);
-
- }
- function delfeaturedmusic()
- {
- $this->checkSession();
- $this->layout = 'default_user';
- /* delete hot music */
- $delhot = mysql_query("Delete From music_featured where id=".$_REQUEST['id']."");
-
- $this->redirect('/musics/managefeaturedmusic?menu='.$_REQUEST['menu']);
-
- }
- function listenfeaturedmusic()
- {
- $this->checkSession();
- $this->layout = 'default_user';
- }
- function editfeaturedmusic()
- {
- $this->checkSession();
- $this->layout = 'default_user';
- $music_cat = array();
- $music_cat[0] = "Select Category";
- $select_music_category = mysql_query("Select * from music_categories");
- while($select_music_category_res = mysql_fetch_array($select_music_category))
- {
- $music_cat[$select_music_category_res['id']] = $select_music_category_res['music_cat_name'] ;
- }
- $this->set('music_category',$music_cat);
-
- }
- function saveeditfeaturedmusic()
- {
- $update_sql = "Update music_featured set title='".$_REQUEST['mustitle']."' , music_id =".$_REQUEST['musicinfo']." where id=".$_REQUEST['hid']."";
- mysql_query($update_sql);
- $this->redirect('/musics/editfeaturedmusicphoto?id='.$_REQUEST['hid']);
- }
- function editfeaturedmusicphoto()
- {
- $this->checkSession();
- $this->layout = 'default_user';
-
- }
- function managemusiccategory()
- {
- $this->checkSession();
- $this->layout = 'default_user';
- }
- function editmusiccategory()
- {
- $this->checkSession();
- $this->layout = 'default_user';
- /* Get the category name*/
- $category_sql = "select * from music_categories where id=".$_REQUEST['id']."";
- $category_res = mysql_fetch_array(mysql_query($category_sql));
- $this->set('catname', $category_res['music_cat_name']);
- $this->set('catid', $category_res['id']);
-
- /**/
-
- }
- function saveeditcategory()
- {
- $this->checkSession();
- $this->layout = 'default_user';
-
- /* Updation Table name */
- if($_REQUEST['cattitle']!="")
- {
- $update_sql = "Update music_categories set music_cat_name='".$_REQUEST['cattitle']."' where id = ".$_REQUEST['cid']."";
- mysql_query($update_sql);
- }
- $this->redirect('/musics/editfeaturedmusiccat?id='.$_REQUEST['cid']);
- /**/
-
- }
- function editfeaturedmusiccat()
- {
- $this->checkSession();
- $this->layout = 'default_user';
- }
-
- function delmusiccategory()
- {
- $this->checkSession();
- $this->layout = 'default_user';
- $delhot = mysql_query("Delete From music_categories where id=".$_REQUEST['id']."");
- $this->redirect('/musics/managemusiccategory?menu='.$_REQUEST['menu']);
-
- }
- function add_music_category()
- {
- $this->checkSession();
- $this->layout = 'default_user';
- }
- function savenewcategory()
- {
- $this->checkSession();
- $this->layout = 'default_user';
-
- /* Updation Table name */
- if($_REQUEST['cattitle']!="")
- {
- $update_sql = "insert into music_categories set music_cat_name='".$_REQUEST['cattitle']."'";
- mysql_query($update_sql);
- $catid = mysql_insert_id();
- $this->redirect('/musics/editfeaturedmusiccat?id='.$catid);
- }
- /**/
-
- }
- /* function block_photogroup()
- {
-
- /////IF BLOCKING IS COLLECTIVE OR BY ADMIN SELECTION/////
- $this->checkSession();
- if(isset($_REQUEST['box']))
- {
- $arr = $_REQUEST['box'];
- foreach($arr as $key => $value)
- {
- $sql = "update `user_photo_albums` set `is_blocked` = '1' where `user_id` ='".$value."'";
- $res = mysql_query($sql);
- //$sql_user = "update `users` set `user_status` = '1' where `id` ='".$value."'";
- //$res_user = mysql_query($sql_user);
- }
- }
- ////IF BLOCKING IS FOR A SPECIFIC USER////
- else
- {
- $qry="update `user_photo_albums` set `is_blocked`='1' where `user_id`='".$_REQUEST['id']."'";
- $res=mysql_query($qry);
- //$sql_user = "update `users` set `user_status` = '1' where `id` ='".$_REQUEST['id']."'";
- //$res_user = mysql_query($sql_user);
- }
- $this->data['UserPhotoAlbum']['menu'] = $_REQUEST['menu'];
- if(isset($_REQUEST['page']))
- {
- $page = $_REQUEST['page'];
- }
- else $page = 1;
- $this->redirect('/user_photo_albums/manageuserphoto?menu='.$this->data['UserPhotoAlbum']['menu'].'&page='.$page);
-
- }
- function active_photogroup()
- {
-
- /////IF BLOCKING IS COLLECTIVE OR BY ADMIN SELECTION/////
- $this->checkSession();
- if(isset($_REQUEST['box']))
- {
- $arr = $_REQUEST['box'];
- foreach($arr as $key => $value)
- {
- $sql = "update `user_photo_albums` set `is_blocked` = '0' where `user_id` ='".$value."'";
- $res = mysql_query($sql);
- //$sql_user = "update `users` set `user_status` = '0' where `id` ='".$value."'";
- //$res_user = mysql_query($sql_user);
- }
- }
- ////IF BLOCKING IS FOR A SPECIFIC USER////
- else
- {
- $qry="update `user_photo_albums` set `is_blocked`='0' where `user_id`='".$_REQUEST['id']."'";
- $res=mysql_query($qry);
- //echo $sql_user = "update `users` set `user_status` = '0' where `id` ='".$_REQUEST['id']."'";
- //$res_user = mysql_query($sql_user);
- }
- $this->data['UserPhotoAlbum']['menu'] = $_REQUEST['menu'];
- if(isset($_REQUEST['page']))
- {
- $page = $_REQUEST['page'];
- }
- else $page = 1;
- $this->redirect('/user_photo_albums/manageuserphoto?menu='.$this->data['UserPhotoAlbum']['menu'].'&page='.$page);
-
- }
- function userphotodetails($pid=null)
- {
- $this->checkSession();
- $this->layout = 'default_user';
-
- }
- function bk_del_selected_image()
- {
- $this->checkSession();
- $this->layout = 'default_user';
- $directory = "../../user_img";
-
-
- ### Deletion of the image file from the user_img directory
- $sel_img = mysql_fetch_array(mysql_query("select * from user_photo_albums where `user_id` = ".$_REQUEST['uid']." and `id` = ".$_REQUEST['pid'].""));
-
- $filename = $sel_img['pic_path'];
- $exp_filename = explode("/",$filename) ;
- $final_file = $exp_filename[4];
- $del_o = "../../../user_img/o/".$final_file;
- $del_l = "../../../user_img/l/".$final_file;
- $del_m = "../../../user_img/m/".$final_file;
- unlink($del_o);
- unlink($del_l);
- unlink($del_m);
- unlink($filename);
- ###
-
- $qry = "delete from `user_photo_albums` where `user_id` = ".$_REQUEST['uid']." and `id` = ".$_REQUEST['pid']."";
- $res = mysql_query($qry);
-
-
- $nextId = mysql_query("Select * from `user_photo_albums` where `user_id` = ".$_REQUEST['uid']." and `id` > ".$_REQUEST['pid']." order by id asc");
- if(mysql_num_rows($nextId)>0)
- {
- //echo "Select * from `user_photo_albums` where `user_id` = ".$_REQUEST['uid']." and `id` > ".$_REQUEST['pid']." order by id asc";
- $next_id_arr = mysql_fetch_array($nextId);
- $next_id = $next_id_arr['id'];
- }
- else
- {
- $nextId = mysql_query("Select * from `user_photo_albums` where `user_id` = ".$_REQUEST['uid']." order by id asc");
- $next_id_arr = mysql_fetch_array($nextId);
- $next_id = $next_id_arr['id'];
-
- }
- //$pid = $_REQUEST['pid']+1;
- $pid = $next_id;
-
- $this->flash('The Image with id: '.$id.' has been deleted.', '/user_photo_albums');
- $this->redirect('/user_photo_albums/userphotodetails?OffSet='.$_REQUEST['OffSet'].'&menu='.$_REQUEST['menu'].'&uid='.$_REQUEST['uid'].'&pid='.$pid.'&CurrentPage='.$_REQUEST['CurrentPage']);
-
-
- }
- function bk_block_selected_image()
- {
- $this->checkSession();
- $this->layout = 'default_user';
- echo $qry = "update `user_photo_albums` set `is_blocked` = '1' where `user_id` = ".$_REQUEST['uid']." and `id` = ".$_REQUEST['pid']."";
- $res = mysql_query($qry);
- $this->flash('The post with id: '.$id.' has been deleted.', '/posts');
- $this->redirect('/user_photo_albums/userphotodetails?OffSet='.$_REQUEST['OffSet'].'&menu='.$_REQUEST['menu'].'&uid='.$_REQUEST['uid'].'&pid='.$_REQUEST['pid'].'&CurrentPage='.$_REQUEST['CurrentPage']);
- }
- function bk_unblock_selected_image()
- {
- $this->checkSession();
- $this->layout = 'default_user';
- echo $qry = "update `user_photo_albums` set `is_blocked` = '0' where `user_id` = ".$_REQUEST['uid']." and `id` = ".$_REQUEST['pid']."";
- $res = mysql_query($qry);
- $this->flash('The post with id: '.$id.' has been deleted.', '/posts');
- $this->redirect('/user_photo_albums/userphotodetails?OffSet='.$_REQUEST['OffSet'].'&menu='.$_REQUEST['menu'].'&uid='.$_REQUEST['uid'].'&pid='.$_REQUEST['pid'].'&CurrentPage='.$_REQUEST['CurrentPage']);
- }
- */}
- ?>