1 | <?php |
---|
2 | |
---|
3 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
4 | load_language('plugin.lang', WFS_PATH); |
---|
5 | |
---|
6 | $wfs_conf = explode(',' , $conf['wired_for_sound']); |
---|
7 | if (isset($page['category'])) |
---|
8 | { |
---|
9 | $cat_id = $page['category']['id']; |
---|
10 | } |
---|
11 | else |
---|
12 | { |
---|
13 | switch ($page['section']) |
---|
14 | { |
---|
15 | case 'categories': |
---|
16 | $cat_id = -1 ; |
---|
17 | break; |
---|
18 | case 'tags': |
---|
19 | $cat_id = -2 ; |
---|
20 | break; |
---|
21 | case 'search': |
---|
22 | $cat_id = -3 ; |
---|
23 | break; |
---|
24 | case 'favorites': |
---|
25 | $cat_id = -4 ; |
---|
26 | break; |
---|
27 | case 'recent_pics': |
---|
28 | $cat_id = -5 ; |
---|
29 | break; |
---|
30 | case 'recent_cats': |
---|
31 | $cat_id = -6 ; |
---|
32 | break; |
---|
33 | case 'most_visited': |
---|
34 | $cat_id = -7 ; |
---|
35 | break; |
---|
36 | case 'best_rated': |
---|
37 | $cat_id = -8 ; |
---|
38 | break; |
---|
39 | case 'list': |
---|
40 | $cat_id = -9 ; |
---|
41 | break; |
---|
42 | case 'most_commented': |
---|
43 | $cat_id = -10 ; |
---|
44 | break; |
---|
45 | } |
---|
46 | } |
---|
47 | |
---|
48 | if (empty($cat_id)) return; |
---|
49 | |
---|
50 | $q = 'SELECT sound.id AS id, sound.file AS sound, ic.volume AS volume |
---|
51 | FROM ' . WFS_SOUNDS_TABLE . ' AS sound |
---|
52 | INNER JOIN ' . WFS_IMG_CAT_TABLE . ' AS ic |
---|
53 | ON sound.id = ic.sound_id |
---|
54 | WHERE ic.cat_id = ' . $cat_id . ' AND ic.image_id IS NULL;'; |
---|
55 | |
---|
56 | $result = pwg_db_fetch_assoc(pwg_query($q)); |
---|
57 | |
---|
58 | if (is_admin()) |
---|
59 | { |
---|
60 | $template->assign('mp3_button', array( |
---|
61 | 'URL' => PHPWG_ROOT_PATH . 'admin.php?page=plugin&section=' . WFS_DIR . '%2Fadmin%2Fadd_page_on_index.php&catid=' . $cat_id . '&backurl=' . $_SERVER['REQUEST_URI'], |
---|
62 | 'ICON' => WFS_PATH . 'template/add_button.png')); |
---|
63 | } |
---|
64 | |
---|
65 | if (!empty($result)) |
---|
66 | { |
---|
67 | if (file_exists($result['sound'])) |
---|
68 | { |
---|
69 | if (!empty($result['volume'])) |
---|
70 | { |
---|
71 | $wfs_conf[1] = $result['volume']; |
---|
72 | } |
---|
73 | $template->assign('wfs', array( |
---|
74 | 'MP3' => WFS_PATH . 'dewplayer.swf?mp3=' . strtr($result['sound'] , array(' ' => '%20')), |
---|
75 | 'VOLUME' => $wfs_conf[1], |
---|
76 | 'PLAYER_WIDTH' => $wfs_conf[2] - 2, |
---|
77 | 'AUTOSTART' => $wfs_conf[3], |
---|
78 | 'AUTOREPLAY' => $wfs_conf[4])); |
---|
79 | } |
---|
80 | else |
---|
81 | { |
---|
82 | pwg_query('DELETE FROM ' . WFS_IMG_CAT_TABLE . ' WHERE sound_id = ' . $result['id'] . ';'); |
---|
83 | pwg_query('DELETE FROM ' . WFS_SOUNDS_TABLE . ' WHERE id = ' . $result['id'] . ';'); |
---|
84 | } |
---|
85 | } |
---|
86 | |
---|
87 | $template->set_filenames(array('wfs' => dirname(__FILE__) . '/template/wfs_on_index.tpl')); |
---|
88 | $template->concat('PLUGIN_INDEX_ACTIONS', $template->parse('wfs', true)); |
---|
89 | |
---|
90 | ?> |
---|