1 | <?php |
---|
2 | |
---|
3 | /* Configuration of Charlies */ |
---|
4 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
5 | if (!defined('IN_ADMIN') or !IN_ADMIN) die('Hacking attempt!'); |
---|
6 | $x = @file_get_contents( $conf['local_data_dir'].'/plugins/'.basename(dirname(__FILE__)).'.dat'); |
---|
7 | if ($x!==false) $charlie = unserialize($x); else $charlie = array(); |
---|
8 | $errors = array(); |
---|
9 | $infos = array(); |
---|
10 | |
---|
11 | $curtains = array(); |
---|
12 | for ($i = 1; $i <= 18; $i++) { $curtains['png' . $i] = 'png' . $i; } |
---|
13 | $curtains['none'] = 'none'; |
---|
14 | // Init all extensions and players |
---|
15 | // Existing first |
---|
16 | $extensions = array(); |
---|
17 | foreach ($charlie as $tpl => $ext) { |
---|
18 | if (is_array($ext)) { |
---|
19 | $players[] = array( 'name' => $tpl, 'ext' => $ext); |
---|
20 | $extensions = array_merge($extensions, $ext); |
---|
21 | } |
---|
22 | } |
---|
23 | // add some wellknown |
---|
24 | $extensions = array_merge($extensions, array( 'flv','swf','pls','m3u','wav', |
---|
25 | 'mid','au','aif','mp3','pdf','asf','wmv','divx','xvid','aiff','aac','bmp', |
---|
26 | 'gsm','mov','mpg','mpeg','mp4','m4a','psd','qt','qtif','qif','qti','snd', |
---|
27 | 'tif','tiff','3g2','3pg','zip','rar' )); |
---|
28 | // Adding some specific new extension by $conf['Charlies more extensions'] = array('dvx', 'mp8',); |
---|
29 | if (isset($conf['Charlies more extensions']) and is_array($conf['Charlies more extensions'])) |
---|
30 | $extensions = array_merge($extensions, $conf['Charlies more extensions']); |
---|
31 | // Uniqueness |
---|
32 | $extensions = array_unique($extensions); |
---|
33 | |
---|
34 | // Pending TODO |
---|
35 | // Addind some specific new players (comming from $conf['Charlies more players']) |
---|
36 | // Include added TPL (in template-extension as well) => need a change in charlie.inc.php |
---|
37 | // Check if templates are still available |
---|
38 | // Remove deleted players |
---|
39 | |
---|
40 | // Tabsheets |
---|
41 | include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); |
---|
42 | $CC_url = get_admin_plugin_menu_link(__FILE__); |
---|
43 | if (!isset($_GET['tab'])) $page['tab'] = 'templates'; |
---|
44 | else $page['tab'] = $_GET['tab']; |
---|
45 | |
---|
46 | $tabsheet = new tabsheet(); |
---|
47 | $tabsheet->add('templates', l10n('Templates configuration'), $CC_url.'&tab=templates'); |
---|
48 | $tabsheet->add('options', l10n('Players options'), $CC_url.'&tab=options'); |
---|
49 | $tabsheet->add('colors', l10n('Players colors'), $CC_url.'&tab=colors'); |
---|
50 | $tabsheet->add('curtain', l10n('Curtain selection'), $CC_url.'&tab=curtain'); |
---|
51 | $tabsheet->select($page['tab']); |
---|
52 | $tabsheet->assign(); |
---|
53 | $template->assign('page', $page['tab']); |
---|
54 | |
---|
55 | $sub = ( isset($_POST['submit']) ) ? true : false; |
---|
56 | |
---|
57 | // Check input on templates |
---|
58 | if ($sub and isset($_POST['from']) and $_POST['from']=='templates') { |
---|
59 | foreach ($_POST as $tpl => $ext) { |
---|
60 | if (is_array($ext) and isset($charlie[$tpl])) $charlie[$tpl] = $ext; |
---|
61 | } |
---|
62 | } |
---|
63 | // Check input on options |
---|
64 | if ($sub and isset($_POST['from']) and $_POST['from']=='options') { |
---|
65 | $charlie = array_merge($charlie, $_POST); |
---|
66 | if ( $charlie['forced_width']!='' and (!is_numeric($charlie['forced_width']) or $charlie['forced_width'] < 90 or $charlie['forced_width'] > 1024 )) |
---|
67 | array_push($errors, l10n('Forced width is out of range (Correct range: 90-1024)')); |
---|
68 | if ( $charlie['forced_height']!='' and (!is_numeric($charlie['forced_height']) or $charlie['forced_height'] < 90 or $charlie['forced_height'] > 1024 )) |
---|
69 | array_push($errors, l10n('Forced height is out of range (Correct range: 90-1024)')); |
---|
70 | if (!is_numeric($charlie['video_default_width']) or $charlie['video_default_width'] < 90 or $charlie['video_default_width'] > 1024 ) |
---|
71 | array_push($errors, l10n('Default width is out of range (Correct range: 90-1024)')); |
---|
72 | if (!is_numeric($charlie['video_default_height']) or $charlie['video_default_height'] < 90 or $charlie['video_default_height'] > 1024 ) |
---|
73 | array_push($errors, l10n('Default height is out of range (Correct range: 90-1024)')); |
---|
74 | if (!is_numeric($charlie['volume']) or $charlie['volume'] < 0 or $charlie['volume'] > 200 ) |
---|
75 | array_push($errors, l10n('Volume is out of range (Correct range: 0-200)')); |
---|
76 | if ($charlie['start_image'] != '' and !is_file($charlie['start_image'])) |
---|
77 | array_push($errors, l10n('Unknown file (Start image)')); |
---|
78 | if ($charlie['top1'] != '') { |
---|
79 | list($url, $x, $y) = explode('|', $charlie['top1'], 3); |
---|
80 | if ( !is_file($url) or !is_numeric($x) or !is_numeric($x) ) |
---|
81 | array_push($errors, l10n('Unknown file or URL|x|y error (x and y must be numeric)')); |
---|
82 | } |
---|
83 | if ( $charlie['titlesize']!='' and (!is_numeric($charlie['titlesize']) or $charlie['titlesize'] < 12 or $charlie['titlesize'] > 72 )) |
---|
84 | array_push($errors, l10n('Title font size is out of range (Correct range: 12-72)')); |
---|
85 | if (!is_numeric($charlie['iconplaybgalpha']) or $charlie['iconplaybgalpha'] < 0 or $charlie['iconplaybgalpha'] > 100 ) |
---|
86 | array_push($errors, l10n('Play icon transparency is out of range (Correct range: 0-100)')); |
---|
87 | if ( $charlie['margin']!='' and (!is_numeric($charlie['margin']) or $charlie['margin'] < 0 or $charlie['margin'] > 40 )) |
---|
88 | array_push($errors, l10n('Margin is out of range (Correct range: 0-40)')); |
---|
89 | if ($charlie['skin'] != '' and !is_file($charlie['skin'])) |
---|
90 | array_push($errors, l10n('Unknown file (skin)')); |
---|
91 | if (!is_numeric($charlie['playertimeout']) or $charlie['playertimeout'] < 0 or $charlie['playertimeout'] > 9999 ) |
---|
92 | array_push($errors, l10n('Autohide delay is out of range (Correct range: 0-9999)')); |
---|
93 | if (!is_numeric($charlie['playeralpha']) or $charlie['playeralpha'] < 0 or $charlie['playeralpha'] > 100 ) |
---|
94 | array_push($errors, l10n('Player transparency is out of range (Correct range: 0-100)')); |
---|
95 | if ( $charlie['srtsize']!='' and (!is_numeric($charlie['srtsize']) or $charlie['srtsize'] < 8 or $charlie['srtsize'] > 24 )) |
---|
96 | array_push($errors, l10n('Subtitle font size is out of range (Correct range: 8-24)')); |
---|
97 | if ($charlie['srturl'] != '' and !is_file($charlie['srturl']) and strtolower(substr($charlie['srturl'],-4))!='.srt') |
---|
98 | array_push($errors, l10n('Wrong filename or file not found (Subtitles file)')); |
---|
99 | if ($charlie['netconnection'] != '' and strtolower(substr($charlie['netconnection'],0,4))!='rtmp') |
---|
100 | array_push($errors, l10n('Wrong filename. RTMP (Real Time Messaging Protocol) is a TCP based propriety protocol |
---|
101 | developed by Adobe System for the purpose of streaming Audio/Video data between Flash Player and media server.')); |
---|
102 | } |
---|
103 | if ($sub and isset($_POST['from']) and $_POST['from']=='colors') { |
---|
104 | $charlie['color0'] = $_POST['color0']; |
---|
105 | $charlie['color1'] = $_POST['color1']; |
---|
106 | $charlie['color2'] = $_POST['color2']; |
---|
107 | $charlie['color3'] = $_POST['color3']; |
---|
108 | $charlie['color4'] = $_POST['color4']; |
---|
109 | $charlie['color5'] = $_POST['color5']; |
---|
110 | $charlie['color6'] = $_POST['color6']; |
---|
111 | $charlie['color7'] = $_POST['color7']; |
---|
112 | $charlie['color8'] = $_POST['color8']; |
---|
113 | $charlie['color9'] = $_POST['color9']; |
---|
114 | $charlie['color10'] = $_POST['color10']; |
---|
115 | $charlie['color11'] = $_POST['color11']; |
---|
116 | $charlie['color12'] = $_POST['color12']; |
---|
117 | $charlie['color13'] = $_POST['color13']; |
---|
118 | $charlie['color14'] = $_POST['color14']; |
---|
119 | $charlie['color15'] = $_POST['color15']; |
---|
120 | $charlie['color16'] = $_POST['color16']; |
---|
121 | $colors = $charlie['color0']. $charlie['color1'] . $charlie['color2'] . $charlie['color3'] . $charlie['color4'] |
---|
122 | . $charlie['color5']. $charlie['color6'] . $charlie['color7'] . $charlie['color8'] . $charlie['color9'] |
---|
123 | . $charlie['color10']. $charlie['color11'] . $charlie['color12'] . $charlie['color13'] . $charlie['color14'] |
---|
124 | . $charlie['color15']. $charlie['color16']; |
---|
125 | if ( !preg_match('/^(#([A-Fa-f0-9]{3}|[A-Fa-f0-9]{6})){17}$/', $colors) ) |
---|
126 | array_push($errors, l10n('Invalid color code: 3 or 6 hexadecimal characters, preceded by "#"')); |
---|
127 | } |
---|
128 | if ($sub and isset($_POST['from']) and $_POST['from']=='curtain') { |
---|
129 | $charlie['curtain'] = $_POST['curtain']; |
---|
130 | } |
---|
131 | $charlie['title'] = stripslashes(htmlspecialchars(strip_tags($charlie['title']))); |
---|
132 | // Submit and errors |
---|
133 | if ( $sub ) |
---|
134 | { |
---|
135 | if ( count($errors) > 0 ) |
---|
136 | array_push($errors, l10n('Your configuration is NOT saved due to above reasons.')); |
---|
137 | } |
---|
138 | // Submit and Advisor => Thanks |
---|
139 | if ( $sub and is_adviser() and count($errors) == 0 ) |
---|
140 | array_push($infos, l10n('You are Adviser and you are not authorized to change this configuration.')); |
---|
141 | |
---|
142 | // Submit and not Advisor => Update Config table |
---|
143 | if ( $sub and !is_adviser() and count($errors) == 0 ) |
---|
144 | { |
---|
145 | $dir = $conf['local_data_dir'].'/plugins/'; |
---|
146 | @mkdir($dir); |
---|
147 | $file = fopen( $dir.basename(dirname(__FILE__)).'.dat', 'w' ); |
---|
148 | fwrite($file, serialize($charlie)); |
---|
149 | fclose( $file ); |
---|
150 | array_push($infos, l10n('Your configuration is saved.')); |
---|
151 | } |
---|
152 | // Send data |
---|
153 | $template->set_filenames(array( |
---|
154 | 'plugin_admin_content' => dirname(__FILE__) . '/charlies_config.tpl')); |
---|
155 | if (count($errors) != 0) $template->assign('errors', $errors); |
---|
156 | if (count($infos) != 0) $template->assign('infos', $infos); |
---|
157 | if ($charlie['onclick']==0) $charlie['onclick'] = 'playpause'; // ??? |
---|
158 | $template->assign(array( |
---|
159 | 'Charlies' => $charlie, |
---|
160 | 'CHARLIES_PATH' => CHARLIES_PATH, |
---|
161 | 'curtains' => $curtains, |
---|
162 | 'players' => $players, |
---|
163 | 'extensions' => $extensions, |
---|
164 | ) ); |
---|
165 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
166 | //var_dump($charlie); |
---|
167 | ?> |
---|