PageRenderTime 42ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/admin/app/controllers/musics_controller.php

https://bitbucket.org/fxrialab/tickets
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
  1. <?php
  2. class MusicsController extends AppController
  3. {
  4. var $name='Musics';
  5. var $components = array('Pagination');
  6. var $helpers = array('Pagination', 'error');
  7. function manageusermusic()
  8. {
  9. $this->checkSession();
  10. $this->layout = 'default_user';
  11. }
  12. function view_musicgroup($id=null , $uid=null)
  13. {
  14. $this->checkSession();
  15. $this->layout = 'default_user';
  16. }
  17. function usermusicdetails($pid=null)
  18. {
  19. $this->checkSession();
  20. $this->layout = 'default_user';
  21. }
  22. function add_music()
  23. {
  24. $this->checkSession();
  25. $this->layout = 'default_user';
  26. /* Grtting the Music caltegory*/
  27. $music_cat = array();
  28. $music_cat[0] = "Select Category";
  29. $select_music_category = mysql_query("Select * from music_categories");
  30. while($select_music_category_res = mysql_fetch_array($select_music_category))
  31. {
  32. $music_cat[$select_music_category_res['id']] = $select_music_category_res['music_cat_name'] ;
  33. }
  34. $this->set('music_category',$music_cat);
  35. }
  36. function addmusicstep2()
  37. {
  38. $this->checkSession();
  39. $this->layout = 'default_user';
  40. if (!empty($this->data))
  41. {
  42. $this->data['Music']['user_id'] = $_REQUEST['musicuser'];
  43. if($_REQUEST['category']==0)
  44. $this->data['Music']['music_categorie_id'] = 1;
  45. $this->data['Music']['music_categorie_id'] = $_REQUEST['category'];
  46. if ($this->Music->save($this->data))
  47. {
  48. $music_id = $this->Music->getLastInsertId();
  49. $this->redirect('/musics/add_musicstep2?uid='.$_REQUEST['musicuser'].'&pid='.$music_id);
  50. }
  51. }
  52. }
  53. function add_musicstep2()
  54. {
  55. $this->checkSession();
  56. $this->layout = 'default_user';
  57. }
  58. function delete_musicgroup($id=null)
  59. {
  60. $this->checkSession();
  61. if(isset($_REQUEST['box']))
  62. {
  63. /////IF SEARCH IS COLLECTIVE OR CHOSEN BY ADMIN SELECTION//////
  64. $arr = $_REQUEST['box'];
  65. foreach($arr as $key => $value)
  66. {
  67. $sql_det = "delete from `musics` where `user_id` = '".$value."'";
  68. $res_det = mysql_query($sql_det);
  69. }
  70. }
  71. ////IF DELETE IS FOR A SPECIFIC USER////
  72. else
  73. {
  74. $user_id=$_REQUEST['id'];
  75. $this->data['Music']['menu'] = $_REQUEST['menu'];
  76. $sql_det = "delete from `musics` where `user_id` = '".$user_id."'";
  77. $res_det = mysql_query($sql_det);
  78. }
  79. //$user_id=$_REQUEST['id'];
  80. $this->data['Music']['menu'] = $_REQUEST['menu'];
  81. if(isset($_REQUEST['page']))
  82. {
  83. $page = $_REQUEST['page'];
  84. }
  85. $this->flash('The post with id: '.$id.' has been deleted.', '/posts');
  86. $this->redirect('/musics/manageusermusic?menu='.$this->data['Music']['menu'].'&page='.$page);
  87. }
  88. function managehotmusic()
  89. {
  90. $this->checkSession();
  91. $this->layout = 'default_user';
  92. }
  93. function edithotmusic()
  94. {
  95. $this->checkSession();
  96. $this->layout = 'default_user';
  97. $music_cat = array();
  98. $music_cat[0] = "Select Category";
  99. $select_music_category = mysql_query("Select * from music_categories");
  100. while($select_music_category_res = mysql_fetch_array($select_music_category))
  101. {
  102. $music_cat[$select_music_category_res['id']] = $select_music_category_res['music_cat_name'] ;
  103. }
  104. $this->set('music_category',$music_cat);
  105. }
  106. function saveedithotmusic()
  107. {
  108. $update_sql = "Update music_hot set title='".$_REQUEST['mustitle']."' , music_id =".$_REQUEST['musicinfo']." where id=".$_REQUEST['hid']."";
  109. mysql_query($update_sql);
  110. $this->redirect('/musics/edithotmusicphoto?id='.$_REQUEST['hid']);
  111. }
  112. function edithotmusicphoto()
  113. {
  114. $this->checkSession();
  115. $this->layout = 'default_user';
  116. }
  117. function listenhotmusic()
  118. {
  119. $this->checkSession();
  120. $this->layout = 'default_user';
  121. }
  122. function delhotmusic()
  123. {
  124. $this->checkSession();
  125. $this->layout = 'default_user';
  126. /* delete hot music */
  127. $delhot = mysql_query("Delete From music_hot where id=".$_REQUEST['id']."");
  128. $this->redirect('/musics/managehotmusic?menu='.$_REQUEST['menu']);
  129. }
  130. function delete_hotmusicgroup()
  131. {
  132. $this->checkSession();
  133. if(isset($_REQUEST['box']))
  134. {
  135. /////IF SEARCH IS COLLECTIVE OR CHOSEN BY ADMIN SELECTION//////
  136. $arr = $_REQUEST['box'];
  137. foreach($arr as $key => $value)
  138. {
  139. $sql_det = "delete from `music_hot` where `id` = '".$value."'";
  140. $res_det = mysql_query($sql_det);
  141. }
  142. }
  143. ////IF DELETE IS FOR A SPECIFIC USER////
  144. else
  145. {
  146. $user_id=$_REQUEST['id'];
  147. $this->data['Music']['menu'] = $_REQUEST['menu'];
  148. $sql_det = "delete from `music_hot` where `id` = '".$user_id."'";
  149. $res_det = mysql_query($sql_det);
  150. }
  151. //$user_id=$_REQUEST['id'];
  152. $this->data['Music']['menu'] = $_REQUEST['menu'];
  153. if(isset($_REQUEST['page']))
  154. {
  155. $page = $_REQUEST['page'];
  156. }
  157. $this->flash('The post with id: '.$id.' has been deleted.', '/posts');
  158. $this->redirect('/musics/managehotmusic?menu='.$this->data['Music']['menu'].'&page='.$page);
  159. }
  160. function add_hotmusic()
  161. {
  162. $this->checkSession();
  163. $this->layout = 'default_user';
  164. /* Grtting the Music caltegory*/
  165. $music_cat = array();
  166. $music_cat[0] = "Select Category";
  167. $select_music_category = mysql_query("Select * from music_categories");
  168. while($select_music_category_res = mysql_fetch_array($select_music_category))
  169. {
  170. $music_cat[$select_music_category_res['id']] = $select_music_category_res['music_cat_name'] ;
  171. }
  172. $this->set('music_category',$music_cat);
  173. }
  174. function addhotmusicstep2()
  175. {
  176. $this->checkSession();
  177. $this->layout = 'default_user';
  178. //pr($_REQUEST);
  179. /* Insert into table name */
  180. $inserhot = "INSERT INTO `music_hot` ( `id` , `title` , `music_desc` , `file_name` , `url` , `music_id` )
  181. VALUES ('', '".$_REQUEST['hottitle']."', '', '', '', '".$_REQUEST['musicinfo']."')" ;
  182. $inserhot_res = mysql_query($inserhot);
  183. $inserhot_res_id = mysql_insert_id();
  184. $this->redirect('/musics/edithotmusicphoto?id='.$inserhot_res_id);
  185. }
  186. function managefeaturedmusic()
  187. {
  188. $this->checkSession();
  189. $this->layout = 'default_user';
  190. }
  191. function delete_featuredmusicgroup()
  192. {
  193. $this->checkSession();
  194. if(isset($_REQUEST['box']))
  195. {
  196. /////IF SEARCH IS COLLECTIVE OR CHOSEN BY ADMIN SELECTION//////
  197. $arr = $_REQUEST['box'];
  198. foreach($arr as $key => $value)
  199. {
  200. $sql_det = "delete from `music_featured` where `id` = '".$value."'";
  201. $res_det = mysql_query($sql_det);
  202. }
  203. }
  204. ////IF DELETE IS FOR A SPECIFIC USER////
  205. else
  206. {
  207. $user_id=$_REQUEST['id'];
  208. $this->data['Music']['menu'] = $_REQUEST['menu'];
  209. $sql_det = "delete from `music_featured` where `id` = '".$user_id."'";
  210. $res_det = mysql_query($sql_det);
  211. }
  212. //$user_id=$_REQUEST['id'];
  213. $this->data['Music']['menu'] = $_REQUEST['menu'];
  214. if(isset($_REQUEST['page']))
  215. {
  216. $page = $_REQUEST['page'];
  217. }
  218. $this->flash('The post with id: '.$id.' has been deleted.', '/posts');
  219. $this->redirect('/musics/managefeaturedmusic?menu='.$this->data['Music']['menu'].'&page='.$page);
  220. }
  221. function delfeaturedmusic()
  222. {
  223. $this->checkSession();
  224. $this->layout = 'default_user';
  225. /* delete hot music */
  226. $delhot = mysql_query("Delete From music_featured where id=".$_REQUEST['id']."");
  227. $this->redirect('/musics/managefeaturedmusic?menu='.$_REQUEST['menu']);
  228. }
  229. function listenfeaturedmusic()
  230. {
  231. $this->checkSession();
  232. $this->layout = 'default_user';
  233. }
  234. function editfeaturedmusic()
  235. {
  236. $this->checkSession();
  237. $this->layout = 'default_user';
  238. $music_cat = array();
  239. $music_cat[0] = "Select Category";
  240. $select_music_category = mysql_query("Select * from music_categories");
  241. while($select_music_category_res = mysql_fetch_array($select_music_category))
  242. {
  243. $music_cat[$select_music_category_res['id']] = $select_music_category_res['music_cat_name'] ;
  244. }
  245. $this->set('music_category',$music_cat);
  246. }
  247. function saveeditfeaturedmusic()
  248. {
  249. $update_sql = "Update music_featured set title='".$_REQUEST['mustitle']."' , music_id =".$_REQUEST['musicinfo']." where id=".$_REQUEST['hid']."";
  250. mysql_query($update_sql);
  251. $this->redirect('/musics/editfeaturedmusicphoto?id='.$_REQUEST['hid']);
  252. }
  253. function editfeaturedmusicphoto()
  254. {
  255. $this->checkSession();
  256. $this->layout = 'default_user';
  257. }
  258. function managemusiccategory()
  259. {
  260. $this->checkSession();
  261. $this->layout = 'default_user';
  262. }
  263. function editmusiccategory()
  264. {
  265. $this->checkSession();
  266. $this->layout = 'default_user';
  267. /* Get the category name*/
  268. $category_sql = "select * from music_categories where id=".$_REQUEST['id']."";
  269. $category_res = mysql_fetch_array(mysql_query($category_sql));
  270. $this->set('catname', $category_res['music_cat_name']);
  271. $this->set('catid', $category_res['id']);
  272. /**/
  273. }
  274. function saveeditcategory()
  275. {
  276. $this->checkSession();
  277. $this->layout = 'default_user';
  278. /* Updation Table name */
  279. if($_REQUEST['cattitle']!="")
  280. {
  281. $update_sql = "Update music_categories set music_cat_name='".$_REQUEST['cattitle']."' where id = ".$_REQUEST['cid']."";
  282. mysql_query($update_sql);
  283. }
  284. $this->redirect('/musics/editfeaturedmusiccat?id='.$_REQUEST['cid']);
  285. /**/
  286. }
  287. function editfeaturedmusiccat()
  288. {
  289. $this->checkSession();
  290. $this->layout = 'default_user';
  291. }
  292. function delmusiccategory()
  293. {
  294. $this->checkSession();
  295. $this->layout = 'default_user';
  296. $delhot = mysql_query("Delete From music_categories where id=".$_REQUEST['id']."");
  297. $this->redirect('/musics/managemusiccategory?menu='.$_REQUEST['menu']);
  298. }
  299. function add_music_category()
  300. {
  301. $this->checkSession();
  302. $this->layout = 'default_user';
  303. }
  304. function savenewcategory()
  305. {
  306. $this->checkSession();
  307. $this->layout = 'default_user';
  308. /* Updation Table name */
  309. if($_REQUEST['cattitle']!="")
  310. {
  311. $update_sql = "insert into music_categories set music_cat_name='".$_REQUEST['cattitle']."'";
  312. mysql_query($update_sql);
  313. $catid = mysql_insert_id();
  314. $this->redirect('/musics/editfeaturedmusiccat?id='.$catid);
  315. }
  316. /**/
  317. }
  318. /* function block_photogroup()
  319. {
  320. /////IF BLOCKING IS COLLECTIVE OR BY ADMIN SELECTION/////
  321. $this->checkSession();
  322. if(isset($_REQUEST['box']))
  323. {
  324. $arr = $_REQUEST['box'];
  325. foreach($arr as $key => $value)
  326. {
  327. $sql = "update `user_photo_albums` set `is_blocked` = '1' where `user_id` ='".$value."'";
  328. $res = mysql_query($sql);
  329. //$sql_user = "update `users` set `user_status` = '1' where `id` ='".$value."'";
  330. //$res_user = mysql_query($sql_user);
  331. }
  332. }
  333. ////IF BLOCKING IS FOR A SPECIFIC USER////
  334. else
  335. {
  336. $qry="update `user_photo_albums` set `is_blocked`='1' where `user_id`='".$_REQUEST['id']."'";
  337. $res=mysql_query($qry);
  338. //$sql_user = "update `users` set `user_status` = '1' where `id` ='".$_REQUEST['id']."'";
  339. //$res_user = mysql_query($sql_user);
  340. }
  341. $this->data['UserPhotoAlbum']['menu'] = $_REQUEST['menu'];
  342. if(isset($_REQUEST['page']))
  343. {
  344. $page = $_REQUEST['page'];
  345. }
  346. else $page = 1;
  347. $this->redirect('/user_photo_albums/manageuserphoto?menu='.$this->data['UserPhotoAlbum']['menu'].'&page='.$page);
  348. }
  349. function active_photogroup()
  350. {
  351. /////IF BLOCKING IS COLLECTIVE OR BY ADMIN SELECTION/////
  352. $this->checkSession();
  353. if(isset($_REQUEST['box']))
  354. {
  355. $arr = $_REQUEST['box'];
  356. foreach($arr as $key => $value)
  357. {
  358. $sql = "update `user_photo_albums` set `is_blocked` = '0' where `user_id` ='".$value."'";
  359. $res = mysql_query($sql);
  360. //$sql_user = "update `users` set `user_status` = '0' where `id` ='".$value."'";
  361. //$res_user = mysql_query($sql_user);
  362. }
  363. }
  364. ////IF BLOCKING IS FOR A SPECIFIC USER////
  365. else
  366. {
  367. $qry="update `user_photo_albums` set `is_blocked`='0' where `user_id`='".$_REQUEST['id']."'";
  368. $res=mysql_query($qry);
  369. //echo $sql_user = "update `users` set `user_status` = '0' where `id` ='".$_REQUEST['id']."'";
  370. //$res_user = mysql_query($sql_user);
  371. }
  372. $this->data['UserPhotoAlbum']['menu'] = $_REQUEST['menu'];
  373. if(isset($_REQUEST['page']))
  374. {
  375. $page = $_REQUEST['page'];
  376. }
  377. else $page = 1;
  378. $this->redirect('/user_photo_albums/manageuserphoto?menu='.$this->data['UserPhotoAlbum']['menu'].'&page='.$page);
  379. }
  380. function userphotodetails($pid=null)
  381. {
  382. $this->checkSession();
  383. $this->layout = 'default_user';
  384. }
  385. function bk_del_selected_image()
  386. {
  387. $this->checkSession();
  388. $this->layout = 'default_user';
  389. $directory = "../../user_img";
  390. ### Deletion of the image file from the user_img directory
  391. $sel_img = mysql_fetch_array(mysql_query("select * from user_photo_albums where `user_id` = ".$_REQUEST['uid']." and `id` = ".$_REQUEST['pid'].""));
  392. $filename = $sel_img['pic_path'];
  393. $exp_filename = explode("/",$filename) ;
  394. $final_file = $exp_filename[4];
  395. $del_o = "../../../user_img/o/".$final_file;
  396. $del_l = "../../../user_img/l/".$final_file;
  397. $del_m = "../../../user_img/m/".$final_file;
  398. unlink($del_o);
  399. unlink($del_l);
  400. unlink($del_m);
  401. unlink($filename);
  402. ###
  403. $qry = "delete from `user_photo_albums` where `user_id` = ".$_REQUEST['uid']." and `id` = ".$_REQUEST['pid']."";
  404. $res = mysql_query($qry);
  405. $nextId = mysql_query("Select * from `user_photo_albums` where `user_id` = ".$_REQUEST['uid']." and `id` > ".$_REQUEST['pid']." order by id asc");
  406. if(mysql_num_rows($nextId)>0)
  407. {
  408. //echo "Select * from `user_photo_albums` where `user_id` = ".$_REQUEST['uid']." and `id` > ".$_REQUEST['pid']." order by id asc";
  409. $next_id_arr = mysql_fetch_array($nextId);
  410. $next_id = $next_id_arr['id'];
  411. }
  412. else
  413. {
  414. $nextId = mysql_query("Select * from `user_photo_albums` where `user_id` = ".$_REQUEST['uid']." order by id asc");
  415. $next_id_arr = mysql_fetch_array($nextId);
  416. $next_id = $next_id_arr['id'];
  417. }
  418. //$pid = $_REQUEST['pid']+1;
  419. $pid = $next_id;
  420. $this->flash('The Image with id: '.$id.' has been deleted.', '/user_photo_albums');
  421. $this->redirect('/user_photo_albums/userphotodetails?OffSet='.$_REQUEST['OffSet'].'&menu='.$_REQUEST['menu'].'&uid='.$_REQUEST['uid'].'&pid='.$pid.'&CurrentPage='.$_REQUEST['CurrentPage']);
  422. }
  423. function bk_block_selected_image()
  424. {
  425. $this->checkSession();
  426. $this->layout = 'default_user';
  427. echo $qry = "update `user_photo_albums` set `is_blocked` = '1' where `user_id` = ".$_REQUEST['uid']." and `id` = ".$_REQUEST['pid']."";
  428. $res = mysql_query($qry);
  429. $this->flash('The post with id: '.$id.' has been deleted.', '/posts');
  430. $this->redirect('/user_photo_albums/userphotodetails?OffSet='.$_REQUEST['OffSet'].'&menu='.$_REQUEST['menu'].'&uid='.$_REQUEST['uid'].'&pid='.$_REQUEST['pid'].'&CurrentPage='.$_REQUEST['CurrentPage']);
  431. }
  432. function bk_unblock_selected_image()
  433. {
  434. $this->checkSession();
  435. $this->layout = 'default_user';
  436. echo $qry = "update `user_photo_albums` set `is_blocked` = '0' where `user_id` = ".$_REQUEST['uid']." and `id` = ".$_REQUEST['pid']."";
  437. $res = mysql_query($qry);
  438. $this->flash('The post with id: '.$id.' has been deleted.', '/posts');
  439. $this->redirect('/user_photo_albums/userphotodetails?OffSet='.$_REQUEST['OffSet'].'&menu='.$_REQUEST['menu'].'&uid='.$_REQUEST['uid'].'&pid='.$_REQUEST['pid'].'&CurrentPage='.$_REQUEST['CurrentPage']);
  440. }
  441. */}
  442. ?>