@@ -4,8 +4,7 @@ |
||
4 | 4 | @author Andre Boivin base code |
5 | 5 | @author Julio Montoya fixing lot of little details |
6 | 6 | @todo this script is not ready for a production use that's why I'm commenting the function delete_inactive_student |
7 | - |
|
8 | -* @package chamilo.admin |
|
7 | + * @package chamilo.admin |
|
9 | 8 | * script pour effacer les user inactif depuis x temps |
10 | 9 | */ |
11 | 10 | $cidReset = true; |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | } |
32 | 32 | |
33 | 33 | public function deleteAction($id) { |
34 | - $event_email_template = new EventEmailTemplate(); |
|
34 | + $event_email_template = new EventEmailTemplate(); |
|
35 | 35 | return $event_email_template->delete($id); |
36 | 36 | } |
37 | 37 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | array('name'=>'language_id', 'index'=>'language_id', 'width'=>'80', 'align'=>'left'), |
74 | 74 | array('name'=>'activated', 'index'=>'activated', 'width'=>'80', 'align'=>'left'), |
75 | 75 | array('name'=>'actions', 'index'=>'actions', 'width'=>'100') |
76 | - ); |
|
76 | + ); |
|
77 | 77 | //Autowidth |
78 | 78 | $extra_params['autowidth'] = 'true'; |
79 | 79 | //height auto |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | // Login as ... |
21 | 21 | if ($action == "login_as" && !empty ($login_as_user_id)) |
22 | 22 | { |
23 | - login_user($login_as_user_id); |
|
23 | + login_user($login_as_user_id); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | //if we already have a session id and a user... |
@@ -37,150 +37,150 @@ discard block |
||
37 | 37 | |
38 | 38 | if (isset ($_GET['action'])) |
39 | 39 | { |
40 | - $check = Security::check_token('get'); |
|
41 | - if($check) |
|
42 | - { |
|
43 | - switch ($_GET['action']) |
|
44 | - { |
|
45 | - case 'show_message' : |
|
46 | - Display :: display_header($tool_name); |
|
47 | - Display :: display_normal_message($_GET['message']); |
|
48 | - break; |
|
49 | - case 'delete_user' : |
|
50 | - Display :: display_header($tool_name); |
|
51 | - if ($user_id != $_user['user_id'] && UserManager :: delete_user($_GET['user_id'])) |
|
52 | - { |
|
53 | - Display :: display_normal_message(get_lang('UserDeleted')); |
|
54 | - } |
|
55 | - else |
|
56 | - { |
|
57 | - Display :: display_error_message(get_lang('CannotDeleteUser')); |
|
58 | - } |
|
59 | - break; |
|
60 | - case 'lock' : |
|
61 | - Display :: display_header($tool_name); |
|
62 | - $message=lock_unlock_user('lock',$_GET['user_id']); |
|
63 | - Display :: display_normal_message($message); |
|
64 | - break; |
|
65 | - case 'unlock'; |
|
66 | - Display :: display_header($tool_name); |
|
67 | - $message=lock_unlock_user('unlock',$_GET['user_id']); |
|
68 | - Display :: display_normal_message($message); |
|
69 | - break; |
|
70 | - case 'add_user'; |
|
71 | - $id=$_GET['id']; |
|
72 | - $UserList=array(); |
|
73 | - $userid_match_login = array(); |
|
74 | - foreach ($id as $user_id) { |
|
75 | - $tmp = ldap_add_user($user_id); |
|
76 | - $UserList[]= $tmp; |
|
77 | - $userid_match_login[$tmp] = $user_id; |
|
78 | - } |
|
79 | - if (isset($_GET['id_session']) && ($_GET['id_session'] == strval(intval($_GET['id_session']))) && ($_GET['id_session']>0)) { |
|
80 | - ldap_add_user_to_session($UserList, $_GET['id_session']); |
|
81 | - header('Location: resume_session.php?id_session='.$_GET['id_session']); |
|
82 | - } else { |
|
83 | - Display :: display_header($tool_name); |
|
84 | - if(count($userid_match_login)>0) |
|
85 | - { |
|
86 | - $message=get_lang('LDAPUsersAddedOrUpdated').':<br />'; |
|
87 | - foreach($userid_match_login as $user_id => $login) |
|
88 | - { |
|
89 | - $message .= '- '.$login.'<br />'; |
|
90 | - } |
|
91 | - } |
|
92 | - else |
|
93 | - { |
|
94 | - $message=get_lang('NoUserAdded'); |
|
95 | - } |
|
96 | - Display :: display_normal_message($message,false); |
|
97 | - } |
|
98 | - break; |
|
99 | - default : |
|
100 | - Display :: display_header($tool_name); |
|
101 | - } |
|
102 | - Security::clear_token(); |
|
103 | - } |
|
104 | - else |
|
105 | - { |
|
106 | - Display::display_header($tool_name); |
|
107 | - } |
|
40 | + $check = Security::check_token('get'); |
|
41 | + if($check) |
|
42 | + { |
|
43 | + switch ($_GET['action']) |
|
44 | + { |
|
45 | + case 'show_message' : |
|
46 | + Display :: display_header($tool_name); |
|
47 | + Display :: display_normal_message($_GET['message']); |
|
48 | + break; |
|
49 | + case 'delete_user' : |
|
50 | + Display :: display_header($tool_name); |
|
51 | + if ($user_id != $_user['user_id'] && UserManager :: delete_user($_GET['user_id'])) |
|
52 | + { |
|
53 | + Display :: display_normal_message(get_lang('UserDeleted')); |
|
54 | + } |
|
55 | + else |
|
56 | + { |
|
57 | + Display :: display_error_message(get_lang('CannotDeleteUser')); |
|
58 | + } |
|
59 | + break; |
|
60 | + case 'lock' : |
|
61 | + Display :: display_header($tool_name); |
|
62 | + $message=lock_unlock_user('lock',$_GET['user_id']); |
|
63 | + Display :: display_normal_message($message); |
|
64 | + break; |
|
65 | + case 'unlock'; |
|
66 | + Display :: display_header($tool_name); |
|
67 | + $message=lock_unlock_user('unlock',$_GET['user_id']); |
|
68 | + Display :: display_normal_message($message); |
|
69 | + break; |
|
70 | + case 'add_user'; |
|
71 | + $id=$_GET['id']; |
|
72 | + $UserList=array(); |
|
73 | + $userid_match_login = array(); |
|
74 | + foreach ($id as $user_id) { |
|
75 | + $tmp = ldap_add_user($user_id); |
|
76 | + $UserList[]= $tmp; |
|
77 | + $userid_match_login[$tmp] = $user_id; |
|
78 | + } |
|
79 | + if (isset($_GET['id_session']) && ($_GET['id_session'] == strval(intval($_GET['id_session']))) && ($_GET['id_session']>0)) { |
|
80 | + ldap_add_user_to_session($UserList, $_GET['id_session']); |
|
81 | + header('Location: resume_session.php?id_session='.$_GET['id_session']); |
|
82 | + } else { |
|
83 | + Display :: display_header($tool_name); |
|
84 | + if(count($userid_match_login)>0) |
|
85 | + { |
|
86 | + $message=get_lang('LDAPUsersAddedOrUpdated').':<br />'; |
|
87 | + foreach($userid_match_login as $user_id => $login) |
|
88 | + { |
|
89 | + $message .= '- '.$login.'<br />'; |
|
90 | + } |
|
91 | + } |
|
92 | + else |
|
93 | + { |
|
94 | + $message=get_lang('NoUserAdded'); |
|
95 | + } |
|
96 | + Display :: display_normal_message($message,false); |
|
97 | + } |
|
98 | + break; |
|
99 | + default : |
|
100 | + Display :: display_header($tool_name); |
|
101 | + } |
|
102 | + Security::clear_token(); |
|
103 | + } |
|
104 | + else |
|
105 | + { |
|
106 | + Display::display_header($tool_name); |
|
107 | + } |
|
108 | 108 | } |
109 | 109 | else |
110 | 110 | { |
111 | - Display::display_header($tool_name); |
|
111 | + Display::display_header($tool_name); |
|
112 | 112 | } |
113 | 113 | if (isset ($_POST['action'])) |
114 | 114 | { |
115 | - $check = Security::check_token('get'); |
|
116 | - if($check) |
|
117 | - { |
|
118 | - switch ($_POST['action']) |
|
119 | - { |
|
120 | - case 'delete' : |
|
121 | - $number_of_selected_users = count($_POST['id']); |
|
122 | - $number_of_deleted_users = 0; |
|
123 | - foreach ($_POST['id'] as $index => $user_id) |
|
124 | - { |
|
125 | - if($user_id != $_user['user_id']) |
|
126 | - { |
|
127 | - if(UserManager :: delete_user($user_id)) |
|
128 | - { |
|
129 | - $number_of_deleted_users++; |
|
130 | - } |
|
131 | - } |
|
132 | - } |
|
133 | - if($number_of_selected_users == $number_of_deleted_users) |
|
134 | - { |
|
135 | - Display :: display_normal_message(get_lang('SelectedUsersDeleted')); |
|
136 | - } |
|
137 | - else |
|
138 | - { |
|
139 | - Display :: display_error_message(get_lang('SomeUsersNotDeleted')); |
|
140 | - } |
|
141 | - break; |
|
142 | - case 'add_user' : |
|
143 | - $number_of_selected_users = count($_POST['id']); |
|
144 | - $number_of_added_users = 0; |
|
145 | - $UserList=array(); |
|
146 | - foreach ($_POST['id'] as $index => $user_id) |
|
147 | - { |
|
148 | - if($user_id != $_user['user_id']) |
|
149 | - { |
|
150 | - $UserList[] = ldap_add_user($user_id); |
|
151 | - } |
|
152 | - } |
|
153 | - if (isset($_GET['id_session']) && (trim($_GET['id_session'])!="")) |
|
154 | - addUserToSession($UserList, $_GET['id_session']); |
|
155 | - if(count($UserList)>0) |
|
156 | - { |
|
157 | - Display :: display_normal_message(count($UserList)." ".get_lang('LDAPUsersAdded')); |
|
158 | - } |
|
159 | - else |
|
160 | - { |
|
161 | - Display :: display_normal_message(get_lang('NoUserAdded')); |
|
162 | - } |
|
163 | - break; |
|
115 | + $check = Security::check_token('get'); |
|
116 | + if($check) |
|
117 | + { |
|
118 | + switch ($_POST['action']) |
|
119 | + { |
|
120 | + case 'delete' : |
|
121 | + $number_of_selected_users = count($_POST['id']); |
|
122 | + $number_of_deleted_users = 0; |
|
123 | + foreach ($_POST['id'] as $index => $user_id) |
|
124 | + { |
|
125 | + if($user_id != $_user['user_id']) |
|
126 | + { |
|
127 | + if(UserManager :: delete_user($user_id)) |
|
128 | + { |
|
129 | + $number_of_deleted_users++; |
|
130 | + } |
|
131 | + } |
|
132 | + } |
|
133 | + if($number_of_selected_users == $number_of_deleted_users) |
|
134 | + { |
|
135 | + Display :: display_normal_message(get_lang('SelectedUsersDeleted')); |
|
136 | + } |
|
137 | + else |
|
138 | + { |
|
139 | + Display :: display_error_message(get_lang('SomeUsersNotDeleted')); |
|
140 | + } |
|
141 | + break; |
|
142 | + case 'add_user' : |
|
143 | + $number_of_selected_users = count($_POST['id']); |
|
144 | + $number_of_added_users = 0; |
|
145 | + $UserList=array(); |
|
146 | + foreach ($_POST['id'] as $index => $user_id) |
|
147 | + { |
|
148 | + if($user_id != $_user['user_id']) |
|
149 | + { |
|
150 | + $UserList[] = ldap_add_user($user_id); |
|
151 | + } |
|
152 | + } |
|
153 | + if (isset($_GET['id_session']) && (trim($_GET['id_session'])!="")) |
|
154 | + addUserToSession($UserList, $_GET['id_session']); |
|
155 | + if(count($UserList)>0) |
|
156 | + { |
|
157 | + Display :: display_normal_message(count($UserList)." ".get_lang('LDAPUsersAdded')); |
|
158 | + } |
|
159 | + else |
|
160 | + { |
|
161 | + Display :: display_normal_message(get_lang('NoUserAdded')); |
|
162 | + } |
|
163 | + break; |
|
164 | 164 | |
165 | - } |
|
166 | - Security::clear_token(); |
|
167 | - } |
|
165 | + } |
|
166 | + Security::clear_token(); |
|
167 | + } |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | $form = new FormValidator('advanced_search','get'); |
171 | 171 | $form->addText('keyword_username',get_lang('LoginName'),false); |
172 | 172 | if (api_is_western_name_order()) |
173 | 173 | { |
174 | - $form->addText('keyword_firstname', get_lang('FirstName'), false); |
|
175 | - $form->addText('keyword_lastname', get_lang('LastName'), false); |
|
174 | + $form->addText('keyword_firstname', get_lang('FirstName'), false); |
|
175 | + $form->addText('keyword_lastname', get_lang('LastName'), false); |
|
176 | 176 | } |
177 | 177 | else |
178 | 178 | { |
179 | - $form->addText('keyword_lastname',get_lang('LastName'),false); |
|
180 | - $form->addText('keyword_firstname',get_lang('FirstName'),false); |
|
179 | + $form->addText('keyword_lastname',get_lang('LastName'),false); |
|
180 | + $form->addText('keyword_firstname',get_lang('FirstName'),false); |
|
181 | 181 | } |
182 | 182 | if (isset($_GET['id_session'])) |
183 | - $form->addElement('hidden','id_session',$_GET['id_session']); |
|
183 | + $form->addElement('hidden','id_session',$_GET['id_session']); |
|
184 | 184 | |
185 | 185 | $type = array(); |
186 | 186 | $type["all"] = get_lang('All'); |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | $parameters['keyword_lastname'] = @$_GET['keyword_lastname'] ?: null; |
203 | 203 | $parameters['keyword_email'] = @$_GET['keyword_email'] ?: null; |
204 | 204 | if (isset($_GET['id_session'])) |
205 | - $parameters['id_session'] = $_GET['id_session']; |
|
205 | + $parameters['id_session'] = $_GET['id_session']; |
|
206 | 206 | // Create a sortable table with user-data |
207 | 207 | |
208 | 208 | $parameters['sec_token'] = Security::get_token(); |
@@ -212,13 +212,13 @@ discard block |
||
212 | 212 | $table->set_header(1, get_lang('LoginName')); |
213 | 213 | if (api_is_western_name_order()) |
214 | 214 | { |
215 | - $table->set_header(2, get_lang('FirstName')); |
|
216 | - $table->set_header(3, get_lang('LastName')); |
|
215 | + $table->set_header(2, get_lang('FirstName')); |
|
216 | + $table->set_header(3, get_lang('LastName')); |
|
217 | 217 | } |
218 | 218 | else |
219 | 219 | { |
220 | - $table->set_header(2, get_lang('LastName')); |
|
221 | - $table->set_header(3, get_lang('FirstName')); |
|
220 | + $table->set_header(2, get_lang('LastName')); |
|
221 | + $table->set_header(3, get_lang('FirstName')); |
|
222 | 222 | } |
223 | 223 | $table->set_header(4, get_lang('Email')); |
224 | 224 | $table->set_header(5, get_lang('Actions')); |
@@ -15,15 +15,15 @@ |
||
15 | 15 | Display::display_header($tool_name); |
16 | 16 | //api_display_tool_title($tool_name); |
17 | 17 | if (api_get_setting('server_type') != 'test') { |
18 | - echo get_lang('DummyCourseOnlyOnTestServer'); |
|
18 | + echo get_lang('DummyCourseOnlyOnTestServer'); |
|
19 | 19 | } elseif( isset($_POST['action'])) { |
20 | - require_once('../coursecopy/classes/DummyCourseCreator.class.php'); |
|
21 | - $dcc = new DummyCourseCreator(); |
|
22 | - $dcc->create_dummy_course($_POST['course_code']); |
|
23 | - echo get_lang('Done'); |
|
20 | + require_once('../coursecopy/classes/DummyCourseCreator.class.php'); |
|
21 | + $dcc = new DummyCourseCreator(); |
|
22 | + $dcc->create_dummy_course($_POST['course_code']); |
|
23 | + echo get_lang('Done'); |
|
24 | 24 | } else { |
25 | - echo get_lang('DummyCourseDescription'); |
|
26 | - echo '<form method="post"><input type="hidden" name="course_code" value="'.Security::remove_XSS($_GET['course_code']).'"/><input type="submit" name="action" value="'.get_lang('Ok').'"/></form>'; |
|
25 | + echo get_lang('DummyCourseDescription'); |
|
26 | + echo '<form method="post"><input type="hidden" name="course_code" value="'.Security::remove_XSS($_GET['course_code']).'"/><input type="submit" name="action" value="'.get_lang('Ok').'"/></form>'; |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | Display::display_footer(); |
@@ -33,36 +33,36 @@ |
||
33 | 33 | $result_course = Database::query($sql_course); |
34 | 34 | |
35 | 35 | if (Database::num_rows($result_course) > 0) { |
36 | - if (isset($_POST['export'])) { |
|
37 | - $export_result = export_csv($header, $data, 'test.csv'); // TODO: There is no data for exporting yet. |
|
38 | - Display :: display_error_message($export_result); |
|
39 | - } |
|
40 | - echo '<table class="data_table"><tr><th>'.get_lang('Course').'</th><th>'.get_lang('TempsFrequentation').'</th><th>'.get_lang('Progression').'</th><th>'.get_lang('MoyenneTest').'</th></tr>'; |
|
41 | - $header = array(get_lang('Course', ''), get_lang('TempsFrequentation', ''), get_lang('Progression', ''), get_lang('MoyenneTest', '')); |
|
42 | - while ($a_course = Database::fetch_array($result_course)) { |
|
43 | - // TODO: This query is to be checked, there are no HotPotatoes tests results. |
|
44 | - $sql_moy_test = "SELECT exe_result,exe_weighting |
|
36 | + if (isset($_POST['export'])) { |
|
37 | + $export_result = export_csv($header, $data, 'test.csv'); // TODO: There is no data for exporting yet. |
|
38 | + Display :: display_error_message($export_result); |
|
39 | + } |
|
40 | + echo '<table class="data_table"><tr><th>'.get_lang('Course').'</th><th>'.get_lang('TempsFrequentation').'</th><th>'.get_lang('Progression').'</th><th>'.get_lang('MoyenneTest').'</th></tr>'; |
|
41 | + $header = array(get_lang('Course', ''), get_lang('TempsFrequentation', ''), get_lang('Progression', ''), get_lang('MoyenneTest', '')); |
|
42 | + while ($a_course = Database::fetch_array($result_course)) { |
|
43 | + // TODO: This query is to be checked, there are no HotPotatoes tests results. |
|
44 | + $sql_moy_test = "SELECT exe_result,exe_weighting |
|
45 | 45 | FROM $tbl_track_exercice |
46 | 46 | WHERE c_id = ".$a_course['id']; |
47 | - $result_moy_test = Database::query($sql_moy_test); |
|
48 | - $result = 0; |
|
49 | - $weighting = 0; |
|
50 | - while ($moy_test = Database::fetch_array($result_moy_test)) { |
|
51 | - $result = $result + $moy_test['exe_result']; |
|
52 | - $weighting = $weighting + $moy_test['exe_weighting']; |
|
53 | - } |
|
54 | - if ($weighting != 0) { |
|
55 | - $moyenne_test = round(($result * 100) / $weighting); |
|
56 | - } else { |
|
57 | - $moyenne_test = null; |
|
58 | - } |
|
59 | - echo '<tr><td>'.$a_course['title'].'</td><td> </td><td> </td><td>'.(is_null($moyenne_test) ? '' : $moyenne_test.'%').'</td> </tr>'; |
|
60 | - } |
|
61 | - echo '</table>'; |
|
62 | - echo "<br /><br />"; |
|
63 | - echo "<form method='post'><input type='submit' name='export' value='".get_lang('ExportExcel')."'/><form>"; |
|
47 | + $result_moy_test = Database::query($sql_moy_test); |
|
48 | + $result = 0; |
|
49 | + $weighting = 0; |
|
50 | + while ($moy_test = Database::fetch_array($result_moy_test)) { |
|
51 | + $result = $result + $moy_test['exe_result']; |
|
52 | + $weighting = $weighting + $moy_test['exe_weighting']; |
|
53 | + } |
|
54 | + if ($weighting != 0) { |
|
55 | + $moyenne_test = round(($result * 100) / $weighting); |
|
56 | + } else { |
|
57 | + $moyenne_test = null; |
|
58 | + } |
|
59 | + echo '<tr><td>'.$a_course['title'].'</td><td> </td><td> </td><td>'.(is_null($moyenne_test) ? '' : $moyenne_test.'%').'</td> </tr>'; |
|
60 | + } |
|
61 | + echo '</table>'; |
|
62 | + echo "<br /><br />"; |
|
63 | + echo "<form method='post'><input type='submit' name='export' value='".get_lang('ExportExcel')."'/><form>"; |
|
64 | 64 | } else { |
65 | - echo get_lang('NoCourse'); |
|
65 | + echo get_lang('NoCourse'); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | Display :: display_footer(); |
@@ -16,7 +16,6 @@ |
||
16 | 16 | * @author Patrick Cool |
17 | 17 | * @author René Haentjens, added CSV file import (October 2004) |
18 | 18 | * @package chamilo.link |
19 | - |
|
20 | 19 | */ |
21 | 20 | |
22 | 21 | // Including libraries |
@@ -56,522 +56,522 @@ |
||
56 | 56 | const VIDEO_VP6 = 4; |
57 | 57 | |
58 | 58 | |
59 | - public function Analyze() |
|
60 | - { |
|
61 | - $info = &$this->getid3->info; |
|
62 | - |
|
63 | - $info['flv'] = array (); |
|
64 | - $info_flv = &$info['flv']; |
|
65 | - |
|
66 | - fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET); |
|
67 | - |
|
68 | - $flv_data_length = $info['avdataend'] - $info['avdataoffset']; |
|
69 | - $flv_header = fread($this->getid3->fp, 5); |
|
70 | - |
|
71 | - $info['fileformat'] = 'flv'; |
|
72 | - $info_flv['header']['signature'] = substr($flv_header, 0, 3); |
|
73 | - $info_flv['header']['version'] = getid3_lib::BigEndian2Int(substr($flv_header, 3, 1)); |
|
74 | - $type_flags = getid3_lib::BigEndian2Int(substr($flv_header, 4, 1)); |
|
75 | - |
|
76 | - $info_flv['header']['hasAudio'] = (bool) ($type_flags & 0x04); |
|
77 | - $info_flv['header']['hasVideo'] = (bool) ($type_flags & 0x01); |
|
78 | - |
|
79 | - $frame_size_data_length = getid3_lib::BigEndian2Int(fread($this->getid3->fp, 4)); |
|
80 | - $flv_header_frame_length = 9; |
|
81 | - if ($frame_size_data_length > $flv_header_frame_length) { |
|
82 | - fseek($this->getid3->fp, $frame_size_data_length - $flv_header_frame_length, SEEK_CUR); |
|
83 | - } |
|
84 | - |
|
85 | - $duration = 0; |
|
86 | - while ((ftell($this->getid3->fp) + 1) < $info['avdataend']) { |
|
87 | - |
|
88 | - $this_tag_header = fread($this->getid3->fp, 16); |
|
89 | - |
|
90 | - $previous_tag_length = getid3_lib::BigEndian2Int(substr($this_tag_header, 0, 4)); |
|
91 | - $tag_type = getid3_lib::BigEndian2Int(substr($this_tag_header, 4, 1)); |
|
92 | - $data_length = getid3_lib::BigEndian2Int(substr($this_tag_header, 5, 3)); |
|
93 | - $timestamp = getid3_lib::BigEndian2Int(substr($this_tag_header, 8, 3)); |
|
94 | - $last_header_byte = getid3_lib::BigEndian2Int(substr($this_tag_header, 15, 1)); |
|
95 | - $next_offset = ftell($this->getid3->fp) - 1 + $data_length; |
|
96 | - |
|
97 | - switch ($tag_type) { |
|
98 | - |
|
99 | - case getid3_flv::TAG_AUDIO: |
|
100 | - if (!isset($info_flv['audio']['audioFormat'])) { |
|
101 | - $info_flv['audio']['audioFormat'] = $last_header_byte & 0x07; |
|
102 | - $info_flv['audio']['audioRate'] = ($last_header_byte & 0x30) / 0x10; |
|
103 | - $info_flv['audio']['audioSampleSize'] = ($last_header_byte & 0x40) / 0x40; |
|
104 | - $info_flv['audio']['audioType'] = ($last_header_byte & 0x80) / 0x80; |
|
105 | - } |
|
106 | - break; |
|
107 | - |
|
108 | - |
|
109 | - case getid3_flv::TAG_VIDEO: |
|
110 | - if (!isset($info_flv['video']['videoCodec'])) { |
|
111 | - $info_flv['video']['videoCodec'] = $last_header_byte & 0x07; |
|
112 | - |
|
113 | - $flv_video_header = fread($this->getid3->fp, 11); |
|
114 | - |
|
115 | - if ($info_flv['video']['videoCodec'] != getid3_flv::VIDEO_VP6) { |
|
116 | - |
|
117 | - $picture_size_type = (getid3_lib::BigEndian2Int(substr($flv_video_header, 3, 2))) >> 7; |
|
118 | - $picture_size_type = $picture_size_type & 0x0007; |
|
119 | - $info_flv['header']['videoSizeType'] = $picture_size_type; |
|
120 | - |
|
121 | - switch ($picture_size_type) { |
|
122 | - case 0: |
|
123 | - $picture_size_enc = getid3_lib::BigEndian2Int(substr($flv_video_header, 5, 2)); |
|
124 | - $picture_size_enc <<= 1; |
|
125 | - $info['video']['resolution_x'] = ($picture_size_enc & 0xFF00) >> 8; |
|
126 | - $picture_size_enc = getid3_lib::BigEndian2Int(substr($flv_video_header, 6, 2)); |
|
127 | - $picture_size_enc <<= 1; |
|
128 | - $info['video']['resolution_y'] = ($picture_size_enc & 0xFF00) >> 8; |
|
129 | - break; |
|
130 | - |
|
131 | - case 1: |
|
132 | - $picture_size_enc = getid3_lib::BigEndian2Int(substr($flv_video_header, 5, 4)); |
|
133 | - $picture_size_enc <<= 1; |
|
134 | - $info['video']['resolution_x'] = ($picture_size_enc & 0xFFFF0000) >> 16; |
|
135 | - |
|
136 | - $picture_size_enc = getid3_lib::BigEndian2Int(substr($flv_video_header, 7, 4)); |
|
137 | - $picture_size_enc <<= 1; |
|
138 | - $info['video']['resolution_y'] = ($picture_size_enc & 0xFFFF0000) >> 16; |
|
139 | - break; |
|
140 | - |
|
141 | - case 2: |
|
142 | - $info['video']['resolution_x'] = 352; |
|
143 | - $info['video']['resolution_y'] = 288; |
|
144 | - break; |
|
145 | - |
|
146 | - case 3: |
|
147 | - $info['video']['resolution_x'] = 176; |
|
148 | - $info['video']['resolution_y'] = 144; |
|
149 | - break; |
|
150 | - |
|
151 | - case 4: |
|
152 | - $info['video']['resolution_x'] = 128; |
|
153 | - $info['video']['resolution_y'] = 96; |
|
154 | - break; |
|
155 | - |
|
156 | - case 5: |
|
157 | - $info['video']['resolution_x'] = 320; |
|
158 | - $info['video']['resolution_y'] = 240; |
|
159 | - break; |
|
160 | - |
|
161 | - case 6: |
|
162 | - $info['video']['resolution_x'] = 160; |
|
163 | - $info['video']['resolution_y'] = 120; |
|
164 | - break; |
|
165 | - |
|
166 | - default: |
|
167 | - $info['video']['resolution_x'] = 0; |
|
168 | - $info['video']['resolution_y'] = 0; |
|
169 | - break; |
|
170 | - } |
|
171 | - } |
|
172 | - } |
|
173 | - break; |
|
174 | - |
|
175 | - |
|
176 | - // Meta tag |
|
177 | - case getid3_flv::TAG_META: |
|
178 | - |
|
179 | - fseek($this->getid3->fp, -1, SEEK_CUR); |
|
180 | - $reader = new AMFReader(new AMFStream(fread($this->getid3->fp, $data_length))); |
|
181 | - $event_name = $reader->readData(); |
|
182 | - $info['meta'][$event_name] = $reader->readData(); |
|
183 | - unset($reader); |
|
184 | - |
|
185 | - $info['video']['frame_rate'] = @$info['meta']['onMetaData']['framerate']; |
|
186 | - $info['video']['resolution_x'] = @$info['meta']['onMetaData']['width']; |
|
187 | - $info['video']['resolution_y'] = @$info['meta']['onMetaData']['height']; |
|
188 | - break; |
|
189 | - |
|
190 | - default: |
|
191 | - // noop |
|
192 | - break; |
|
193 | - } |
|
194 | - |
|
195 | - if ($timestamp > $duration) { |
|
196 | - $duration = $timestamp; |
|
197 | - } |
|
198 | - |
|
199 | - fseek($this->getid3->fp, $next_offset, SEEK_SET); |
|
200 | - } |
|
201 | - |
|
202 | - if ($info['playtime_seconds'] = $duration / 1000) { |
|
203 | - $info['bitrate'] = ($info['avdataend'] - $info['avdataoffset']) / $info['playtime_seconds']; |
|
204 | - } |
|
205 | - |
|
206 | - if ($info_flv['header']['hasAudio']) { |
|
207 | - $info['audio']['codec'] = $this->FLVaudioFormat($info_flv['audio']['audioFormat']); |
|
208 | - $info['audio']['sample_rate'] = $this->FLVaudioRate($info_flv['audio']['audioRate']); |
|
209 | - $info['audio']['bits_per_sample'] = $this->FLVaudioBitDepth($info_flv['audio']['audioSampleSize']); |
|
210 | - |
|
211 | - $info['audio']['channels'] = $info_flv['audio']['audioType'] + 1; // 0=mono,1=stereo |
|
212 | - $info['audio']['lossless'] = ($info_flv['audio']['audioFormat'] ? false : true); // 0=uncompressed |
|
213 | - $info['audio']['dataformat'] = 'flv'; |
|
214 | - } |
|
215 | - if (@$info_flv['header']['hasVideo']) { |
|
216 | - $info['video']['codec'] = $this->FLVvideoCodec($info_flv['video']['videoCodec']); |
|
217 | - $info['video']['dataformat'] = 'flv'; |
|
218 | - $info['video']['lossless'] = false; |
|
219 | - } |
|
220 | - |
|
221 | - return true; |
|
222 | - } |
|
223 | - |
|
224 | - |
|
225 | - public static function FLVaudioFormat($id) { |
|
226 | - |
|
227 | - static $lookup = array( |
|
228 | - 0 => 'uncompressed', |
|
229 | - 1 => 'ADPCM', |
|
230 | - 2 => 'mp3', |
|
231 | - 5 => 'Nellymoser 8kHz mono', |
|
232 | - 6 => 'Nellymoser', |
|
233 | - ); |
|
234 | - return (@$lookup[$id] ? @$lookup[$id] : false); |
|
235 | - } |
|
236 | - |
|
237 | - |
|
238 | - public static function FLVaudioRate($id) { |
|
239 | - |
|
240 | - static $lookup = array( |
|
241 | - 0 => 5500, |
|
242 | - 1 => 11025, |
|
243 | - 2 => 22050, |
|
244 | - 3 => 44100, |
|
245 | - ); |
|
246 | - return (@$lookup[$id] ? @$lookup[$id] : false); |
|
247 | - } |
|
248 | - |
|
249 | - |
|
250 | - public static function FLVaudioBitDepth($id) { |
|
251 | - |
|
252 | - static $lookup = array( |
|
253 | - 0 => 8, |
|
254 | - 1 => 16, |
|
255 | - ); |
|
256 | - return (@$lookup[$id] ? @$lookup[$id] : false); |
|
257 | - } |
|
258 | - |
|
259 | - |
|
260 | - public static function FLVvideoCodec($id) { |
|
261 | - |
|
262 | - static $lookup = array( |
|
263 | - getid3_flv::VIDEO_H263 => 'Sorenson H.263', |
|
264 | - getid3_flv::VIDEO_SCREEN => 'Screen video', |
|
265 | - getid3_flv::VIDEO_VP6 => 'On2 VP6', |
|
266 | - ); |
|
267 | - return (@$lookup[$id] ? @$lookup[$id] : false); |
|
268 | - } |
|
59 | + public function Analyze() |
|
60 | + { |
|
61 | + $info = &$this->getid3->info; |
|
62 | + |
|
63 | + $info['flv'] = array (); |
|
64 | + $info_flv = &$info['flv']; |
|
65 | + |
|
66 | + fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET); |
|
67 | + |
|
68 | + $flv_data_length = $info['avdataend'] - $info['avdataoffset']; |
|
69 | + $flv_header = fread($this->getid3->fp, 5); |
|
70 | + |
|
71 | + $info['fileformat'] = 'flv'; |
|
72 | + $info_flv['header']['signature'] = substr($flv_header, 0, 3); |
|
73 | + $info_flv['header']['version'] = getid3_lib::BigEndian2Int(substr($flv_header, 3, 1)); |
|
74 | + $type_flags = getid3_lib::BigEndian2Int(substr($flv_header, 4, 1)); |
|
75 | + |
|
76 | + $info_flv['header']['hasAudio'] = (bool) ($type_flags & 0x04); |
|
77 | + $info_flv['header']['hasVideo'] = (bool) ($type_flags & 0x01); |
|
78 | + |
|
79 | + $frame_size_data_length = getid3_lib::BigEndian2Int(fread($this->getid3->fp, 4)); |
|
80 | + $flv_header_frame_length = 9; |
|
81 | + if ($frame_size_data_length > $flv_header_frame_length) { |
|
82 | + fseek($this->getid3->fp, $frame_size_data_length - $flv_header_frame_length, SEEK_CUR); |
|
83 | + } |
|
84 | + |
|
85 | + $duration = 0; |
|
86 | + while ((ftell($this->getid3->fp) + 1) < $info['avdataend']) { |
|
87 | + |
|
88 | + $this_tag_header = fread($this->getid3->fp, 16); |
|
89 | + |
|
90 | + $previous_tag_length = getid3_lib::BigEndian2Int(substr($this_tag_header, 0, 4)); |
|
91 | + $tag_type = getid3_lib::BigEndian2Int(substr($this_tag_header, 4, 1)); |
|
92 | + $data_length = getid3_lib::BigEndian2Int(substr($this_tag_header, 5, 3)); |
|
93 | + $timestamp = getid3_lib::BigEndian2Int(substr($this_tag_header, 8, 3)); |
|
94 | + $last_header_byte = getid3_lib::BigEndian2Int(substr($this_tag_header, 15, 1)); |
|
95 | + $next_offset = ftell($this->getid3->fp) - 1 + $data_length; |
|
96 | + |
|
97 | + switch ($tag_type) { |
|
98 | + |
|
99 | + case getid3_flv::TAG_AUDIO: |
|
100 | + if (!isset($info_flv['audio']['audioFormat'])) { |
|
101 | + $info_flv['audio']['audioFormat'] = $last_header_byte & 0x07; |
|
102 | + $info_flv['audio']['audioRate'] = ($last_header_byte & 0x30) / 0x10; |
|
103 | + $info_flv['audio']['audioSampleSize'] = ($last_header_byte & 0x40) / 0x40; |
|
104 | + $info_flv['audio']['audioType'] = ($last_header_byte & 0x80) / 0x80; |
|
105 | + } |
|
106 | + break; |
|
107 | + |
|
108 | + |
|
109 | + case getid3_flv::TAG_VIDEO: |
|
110 | + if (!isset($info_flv['video']['videoCodec'])) { |
|
111 | + $info_flv['video']['videoCodec'] = $last_header_byte & 0x07; |
|
112 | + |
|
113 | + $flv_video_header = fread($this->getid3->fp, 11); |
|
114 | + |
|
115 | + if ($info_flv['video']['videoCodec'] != getid3_flv::VIDEO_VP6) { |
|
116 | + |
|
117 | + $picture_size_type = (getid3_lib::BigEndian2Int(substr($flv_video_header, 3, 2))) >> 7; |
|
118 | + $picture_size_type = $picture_size_type & 0x0007; |
|
119 | + $info_flv['header']['videoSizeType'] = $picture_size_type; |
|
120 | + |
|
121 | + switch ($picture_size_type) { |
|
122 | + case 0: |
|
123 | + $picture_size_enc = getid3_lib::BigEndian2Int(substr($flv_video_header, 5, 2)); |
|
124 | + $picture_size_enc <<= 1; |
|
125 | + $info['video']['resolution_x'] = ($picture_size_enc & 0xFF00) >> 8; |
|
126 | + $picture_size_enc = getid3_lib::BigEndian2Int(substr($flv_video_header, 6, 2)); |
|
127 | + $picture_size_enc <<= 1; |
|
128 | + $info['video']['resolution_y'] = ($picture_size_enc & 0xFF00) >> 8; |
|
129 | + break; |
|
130 | + |
|
131 | + case 1: |
|
132 | + $picture_size_enc = getid3_lib::BigEndian2Int(substr($flv_video_header, 5, 4)); |
|
133 | + $picture_size_enc <<= 1; |
|
134 | + $info['video']['resolution_x'] = ($picture_size_enc & 0xFFFF0000) >> 16; |
|
135 | + |
|
136 | + $picture_size_enc = getid3_lib::BigEndian2Int(substr($flv_video_header, 7, 4)); |
|
137 | + $picture_size_enc <<= 1; |
|
138 | + $info['video']['resolution_y'] = ($picture_size_enc & 0xFFFF0000) >> 16; |
|
139 | + break; |
|
140 | + |
|
141 | + case 2: |
|
142 | + $info['video']['resolution_x'] = 352; |
|
143 | + $info['video']['resolution_y'] = 288; |
|
144 | + break; |
|
145 | + |
|
146 | + case 3: |
|
147 | + $info['video']['resolution_x'] = 176; |
|
148 | + $info['video']['resolution_y'] = 144; |
|
149 | + break; |
|
150 | + |
|
151 | + case 4: |
|
152 | + $info['video']['resolution_x'] = 128; |
|
153 | + $info['video']['resolution_y'] = 96; |
|
154 | + break; |
|
155 | + |
|
156 | + case 5: |
|
157 | + $info['video']['resolution_x'] = 320; |
|
158 | + $info['video']['resolution_y'] = 240; |
|
159 | + break; |
|
160 | + |
|
161 | + case 6: |
|
162 | + $info['video']['resolution_x'] = 160; |
|
163 | + $info['video']['resolution_y'] = 120; |
|
164 | + break; |
|
165 | + |
|
166 | + default: |
|
167 | + $info['video']['resolution_x'] = 0; |
|
168 | + $info['video']['resolution_y'] = 0; |
|
169 | + break; |
|
170 | + } |
|
171 | + } |
|
172 | + } |
|
173 | + break; |
|
174 | + |
|
175 | + |
|
176 | + // Meta tag |
|
177 | + case getid3_flv::TAG_META: |
|
178 | + |
|
179 | + fseek($this->getid3->fp, -1, SEEK_CUR); |
|
180 | + $reader = new AMFReader(new AMFStream(fread($this->getid3->fp, $data_length))); |
|
181 | + $event_name = $reader->readData(); |
|
182 | + $info['meta'][$event_name] = $reader->readData(); |
|
183 | + unset($reader); |
|
184 | + |
|
185 | + $info['video']['frame_rate'] = @$info['meta']['onMetaData']['framerate']; |
|
186 | + $info['video']['resolution_x'] = @$info['meta']['onMetaData']['width']; |
|
187 | + $info['video']['resolution_y'] = @$info['meta']['onMetaData']['height']; |
|
188 | + break; |
|
189 | + |
|
190 | + default: |
|
191 | + // noop |
|
192 | + break; |
|
193 | + } |
|
194 | + |
|
195 | + if ($timestamp > $duration) { |
|
196 | + $duration = $timestamp; |
|
197 | + } |
|
198 | + |
|
199 | + fseek($this->getid3->fp, $next_offset, SEEK_SET); |
|
200 | + } |
|
201 | + |
|
202 | + if ($info['playtime_seconds'] = $duration / 1000) { |
|
203 | + $info['bitrate'] = ($info['avdataend'] - $info['avdataoffset']) / $info['playtime_seconds']; |
|
204 | + } |
|
205 | + |
|
206 | + if ($info_flv['header']['hasAudio']) { |
|
207 | + $info['audio']['codec'] = $this->FLVaudioFormat($info_flv['audio']['audioFormat']); |
|
208 | + $info['audio']['sample_rate'] = $this->FLVaudioRate($info_flv['audio']['audioRate']); |
|
209 | + $info['audio']['bits_per_sample'] = $this->FLVaudioBitDepth($info_flv['audio']['audioSampleSize']); |
|
210 | + |
|
211 | + $info['audio']['channels'] = $info_flv['audio']['audioType'] + 1; // 0=mono,1=stereo |
|
212 | + $info['audio']['lossless'] = ($info_flv['audio']['audioFormat'] ? false : true); // 0=uncompressed |
|
213 | + $info['audio']['dataformat'] = 'flv'; |
|
214 | + } |
|
215 | + if (@$info_flv['header']['hasVideo']) { |
|
216 | + $info['video']['codec'] = $this->FLVvideoCodec($info_flv['video']['videoCodec']); |
|
217 | + $info['video']['dataformat'] = 'flv'; |
|
218 | + $info['video']['lossless'] = false; |
|
219 | + } |
|
220 | + |
|
221 | + return true; |
|
222 | + } |
|
223 | + |
|
224 | + |
|
225 | + public static function FLVaudioFormat($id) { |
|
226 | + |
|
227 | + static $lookup = array( |
|
228 | + 0 => 'uncompressed', |
|
229 | + 1 => 'ADPCM', |
|
230 | + 2 => 'mp3', |
|
231 | + 5 => 'Nellymoser 8kHz mono', |
|
232 | + 6 => 'Nellymoser', |
|
233 | + ); |
|
234 | + return (@$lookup[$id] ? @$lookup[$id] : false); |
|
235 | + } |
|
236 | + |
|
237 | + |
|
238 | + public static function FLVaudioRate($id) { |
|
239 | + |
|
240 | + static $lookup = array( |
|
241 | + 0 => 5500, |
|
242 | + 1 => 11025, |
|
243 | + 2 => 22050, |
|
244 | + 3 => 44100, |
|
245 | + ); |
|
246 | + return (@$lookup[$id] ? @$lookup[$id] : false); |
|
247 | + } |
|
248 | + |
|
249 | + |
|
250 | + public static function FLVaudioBitDepth($id) { |
|
251 | + |
|
252 | + static $lookup = array( |
|
253 | + 0 => 8, |
|
254 | + 1 => 16, |
|
255 | + ); |
|
256 | + return (@$lookup[$id] ? @$lookup[$id] : false); |
|
257 | + } |
|
258 | + |
|
259 | + |
|
260 | + public static function FLVvideoCodec($id) { |
|
261 | + |
|
262 | + static $lookup = array( |
|
263 | + getid3_flv::VIDEO_H263 => 'Sorenson H.263', |
|
264 | + getid3_flv::VIDEO_SCREEN => 'Screen video', |
|
265 | + getid3_flv::VIDEO_VP6 => 'On2 VP6', |
|
266 | + ); |
|
267 | + return (@$lookup[$id] ? @$lookup[$id] : false); |
|
268 | + } |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | |
272 | 272 | |
273 | 273 | class AMFStream |
274 | 274 | { |
275 | - public $bytes; |
|
276 | - public $pos; |
|
275 | + public $bytes; |
|
276 | + public $pos; |
|
277 | 277 | |
278 | 278 | |
279 | - public function AMFStream($bytes) { |
|
279 | + public function AMFStream($bytes) { |
|
280 | 280 | |
281 | - $this->bytes = $bytes; |
|
282 | - $this->pos = 0; |
|
283 | - } |
|
281 | + $this->bytes = $bytes; |
|
282 | + $this->pos = 0; |
|
283 | + } |
|
284 | 284 | |
285 | 285 | |
286 | - public function readByte() { |
|
286 | + public function readByte() { |
|
287 | 287 | |
288 | - return getid3_lib::BigEndian2Int(substr($this->bytes, $this->pos++, 1)); |
|
289 | - } |
|
288 | + return getid3_lib::BigEndian2Int(substr($this->bytes, $this->pos++, 1)); |
|
289 | + } |
|
290 | 290 | |
291 | 291 | |
292 | - public function readInt() { |
|
292 | + public function readInt() { |
|
293 | 293 | |
294 | - return ($this->readByte() << 8) + $this->readByte(); |
|
295 | - } |
|
294 | + return ($this->readByte() << 8) + $this->readByte(); |
|
295 | + } |
|
296 | 296 | |
297 | 297 | |
298 | - public function readLong() { |
|
298 | + public function readLong() { |
|
299 | 299 | |
300 | - return ($this->readByte() << 24) + ($this->readByte() << 16) + ($this->readByte() << 8) + $this->readByte(); |
|
301 | - } |
|
300 | + return ($this->readByte() << 24) + ($this->readByte() << 16) + ($this->readByte() << 8) + $this->readByte(); |
|
301 | + } |
|
302 | 302 | |
303 | 303 | |
304 | - public function readDouble() { |
|
304 | + public function readDouble() { |
|
305 | 305 | |
306 | - return getid3_lib::BigEndian2Float($this->read(8)); |
|
307 | - } |
|
306 | + return getid3_lib::BigEndian2Float($this->read(8)); |
|
307 | + } |
|
308 | 308 | |
309 | 309 | |
310 | - public function readUTF() { |
|
310 | + public function readUTF() { |
|
311 | 311 | |
312 | - $length = $this->readInt(); |
|
313 | - return $this->read($length); |
|
314 | - } |
|
312 | + $length = $this->readInt(); |
|
313 | + return $this->read($length); |
|
314 | + } |
|
315 | 315 | |
316 | 316 | |
317 | - public function readLongUTF() { |
|
317 | + public function readLongUTF() { |
|
318 | 318 | |
319 | - $length = $this->readLong(); |
|
320 | - return $this->read($length); |
|
321 | - } |
|
319 | + $length = $this->readLong(); |
|
320 | + return $this->read($length); |
|
321 | + } |
|
322 | 322 | |
323 | 323 | |
324 | - public function read($length) { |
|
324 | + public function read($length) { |
|
325 | 325 | |
326 | - $val = substr($this->bytes, $this->pos, $length); |
|
327 | - $this->pos += $length; |
|
328 | - return $val; |
|
329 | - } |
|
326 | + $val = substr($this->bytes, $this->pos, $length); |
|
327 | + $this->pos += $length; |
|
328 | + return $val; |
|
329 | + } |
|
330 | 330 | |
331 | 331 | |
332 | - public function peekByte() { |
|
332 | + public function peekByte() { |
|
333 | 333 | |
334 | - $pos = $this->pos; |
|
335 | - $val = $this->readByte(); |
|
336 | - $this->pos = $pos; |
|
337 | - return $val; |
|
338 | - } |
|
334 | + $pos = $this->pos; |
|
335 | + $val = $this->readByte(); |
|
336 | + $this->pos = $pos; |
|
337 | + return $val; |
|
338 | + } |
|
339 | 339 | |
340 | 340 | |
341 | - public function peekInt() { |
|
341 | + public function peekInt() { |
|
342 | 342 | |
343 | - $pos = $this->pos; |
|
344 | - $val = $this->readInt(); |
|
345 | - $this->pos = $pos; |
|
346 | - return $val; |
|
347 | - } |
|
343 | + $pos = $this->pos; |
|
344 | + $val = $this->readInt(); |
|
345 | + $this->pos = $pos; |
|
346 | + return $val; |
|
347 | + } |
|
348 | 348 | |
349 | 349 | |
350 | - public function peekLong() { |
|
350 | + public function peekLong() { |
|
351 | 351 | |
352 | - $pos = $this->pos; |
|
353 | - $val = $this->readLong(); |
|
354 | - $this->pos = $pos; |
|
355 | - return $val; |
|
356 | - } |
|
352 | + $pos = $this->pos; |
|
353 | + $val = $this->readLong(); |
|
354 | + $this->pos = $pos; |
|
355 | + return $val; |
|
356 | + } |
|
357 | 357 | |
358 | 358 | |
359 | - public function peekDouble() { |
|
359 | + public function peekDouble() { |
|
360 | 360 | |
361 | - $pos = $this->pos; |
|
362 | - $val = $this->readDouble(); |
|
363 | - $this->pos = $pos; |
|
364 | - return $val; |
|
365 | - } |
|
361 | + $pos = $this->pos; |
|
362 | + $val = $this->readDouble(); |
|
363 | + $this->pos = $pos; |
|
364 | + return $val; |
|
365 | + } |
|
366 | 366 | |
367 | 367 | |
368 | - public function peekUTF() { |
|
368 | + public function peekUTF() { |
|
369 | 369 | |
370 | - $pos = $this->pos; |
|
371 | - $val = $this->readUTF(); |
|
372 | - $this->pos = $pos; |
|
373 | - return $val; |
|
374 | - } |
|
370 | + $pos = $this->pos; |
|
371 | + $val = $this->readUTF(); |
|
372 | + $this->pos = $pos; |
|
373 | + return $val; |
|
374 | + } |
|
375 | 375 | |
376 | 376 | |
377 | - public function peekLongUTF() { |
|
377 | + public function peekLongUTF() { |
|
378 | 378 | |
379 | - $pos = $this->pos; |
|
380 | - $val = $this->readLongUTF(); |
|
381 | - $this->pos = $pos; |
|
382 | - return $val; |
|
383 | - } |
|
379 | + $pos = $this->pos; |
|
380 | + $val = $this->readLongUTF(); |
|
381 | + $this->pos = $pos; |
|
382 | + return $val; |
|
383 | + } |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | |
387 | 387 | |
388 | 388 | class AMFReader |
389 | 389 | { |
390 | - public $stream; |
|
390 | + public $stream; |
|
391 | 391 | |
392 | - public function __construct($stream) { |
|
392 | + public function __construct($stream) { |
|
393 | 393 | |
394 | - $this->stream = $stream; |
|
395 | - } |
|
394 | + $this->stream = $stream; |
|
395 | + } |
|
396 | 396 | |
397 | 397 | |
398 | - public function readData() { |
|
398 | + public function readData() { |
|
399 | 399 | |
400 | - $value = null; |
|
400 | + $value = null; |
|
401 | 401 | |
402 | - $type = $this->stream->readByte(); |
|
402 | + $type = $this->stream->readByte(); |
|
403 | 403 | |
404 | - switch($type) { |
|
405 | - // Double |
|
406 | - case 0: |
|
407 | - $value = $this->readDouble(); |
|
408 | - break; |
|
404 | + switch($type) { |
|
405 | + // Double |
|
406 | + case 0: |
|
407 | + $value = $this->readDouble(); |
|
408 | + break; |
|
409 | 409 | |
410 | - // Boolean |
|
411 | - case 1: |
|
412 | - $value = $this->readBoolean(); |
|
413 | - break; |
|
410 | + // Boolean |
|
411 | + case 1: |
|
412 | + $value = $this->readBoolean(); |
|
413 | + break; |
|
414 | 414 | |
415 | - // String |
|
416 | - case 2: |
|
417 | - $value = $this->readString(); |
|
418 | - break; |
|
415 | + // String |
|
416 | + case 2: |
|
417 | + $value = $this->readString(); |
|
418 | + break; |
|
419 | 419 | |
420 | - // Object |
|
421 | - case 3: |
|
422 | - $value = $this->readObject(); |
|
423 | - break; |
|
420 | + // Object |
|
421 | + case 3: |
|
422 | + $value = $this->readObject(); |
|
423 | + break; |
|
424 | 424 | |
425 | - // null |
|
426 | - case 6: |
|
427 | - return null; |
|
428 | - break; |
|
425 | + // null |
|
426 | + case 6: |
|
427 | + return null; |
|
428 | + break; |
|
429 | 429 | |
430 | - // Mixed array |
|
431 | - case 8: |
|
432 | - $value = $this->readMixedArray(); |
|
433 | - break; |
|
430 | + // Mixed array |
|
431 | + case 8: |
|
432 | + $value = $this->readMixedArray(); |
|
433 | + break; |
|
434 | 434 | |
435 | - // Array |
|
436 | - case 10: |
|
437 | - $value = $this->readArray(); |
|
438 | - break; |
|
435 | + // Array |
|
436 | + case 10: |
|
437 | + $value = $this->readArray(); |
|
438 | + break; |
|
439 | 439 | |
440 | - // Date |
|
441 | - case 11: |
|
442 | - $value = $this->readDate(); |
|
443 | - break; |
|
440 | + // Date |
|
441 | + case 11: |
|
442 | + $value = $this->readDate(); |
|
443 | + break; |
|
444 | 444 | |
445 | - // Long string |
|
446 | - case 13: |
|
447 | - $value = $this->readLongString(); |
|
448 | - break; |
|
445 | + // Long string |
|
446 | + case 13: |
|
447 | + $value = $this->readLongString(); |
|
448 | + break; |
|
449 | 449 | |
450 | - // XML (handled as string) |
|
451 | - case 15: |
|
452 | - $value = $this->readXML(); |
|
453 | - break; |
|
450 | + // XML (handled as string) |
|
451 | + case 15: |
|
452 | + $value = $this->readXML(); |
|
453 | + break; |
|
454 | 454 | |
455 | - // Typed object (handled as object) |
|
456 | - case 16: |
|
457 | - $value = $this->readTypedObject(); |
|
458 | - break; |
|
455 | + // Typed object (handled as object) |
|
456 | + case 16: |
|
457 | + $value = $this->readTypedObject(); |
|
458 | + break; |
|
459 | 459 | |
460 | - // Long string |
|
461 | - default: |
|
462 | - $value = '(unknown or unsupported data type)'; |
|
463 | - break; |
|
464 | - } |
|
460 | + // Long string |
|
461 | + default: |
|
462 | + $value = '(unknown or unsupported data type)'; |
|
463 | + break; |
|
464 | + } |
|
465 | 465 | |
466 | - return $value; |
|
467 | - } |
|
466 | + return $value; |
|
467 | + } |
|
468 | 468 | |
469 | 469 | |
470 | - public function readDouble() { |
|
470 | + public function readDouble() { |
|
471 | 471 | |
472 | - return $this->stream->readDouble(); |
|
473 | - } |
|
472 | + return $this->stream->readDouble(); |
|
473 | + } |
|
474 | 474 | |
475 | 475 | |
476 | - public function readBoolean() { |
|
476 | + public function readBoolean() { |
|
477 | 477 | |
478 | - return $this->stream->readByte() == 1; |
|
479 | - } |
|
478 | + return $this->stream->readByte() == 1; |
|
479 | + } |
|
480 | 480 | |
481 | 481 | |
482 | - public function readString() { |
|
482 | + public function readString() { |
|
483 | 483 | |
484 | - return $this->stream->readUTF(); |
|
485 | - } |
|
484 | + return $this->stream->readUTF(); |
|
485 | + } |
|
486 | 486 | |
487 | 487 | |
488 | - public function readObject() { |
|
488 | + public function readObject() { |
|
489 | 489 | |
490 | - // Get highest numerical index - ignored |
|
491 | - $highestIndex = $this->stream->readLong(); |
|
490 | + // Get highest numerical index - ignored |
|
491 | + $highestIndex = $this->stream->readLong(); |
|
492 | 492 | |
493 | - $data = array(); |
|
493 | + $data = array(); |
|
494 | 494 | |
495 | - while ($key = $this->stream->readUTF()) { |
|
496 | - // Mixed array record ends with empty string (0x00 0x00) and 0x09 |
|
497 | - if (($key == '') && ($this->stream->peekByte() == 0x09)) { |
|
498 | - // Consume byte |
|
499 | - $this->stream->readByte(); |
|
500 | - break; |
|
501 | - } |
|
495 | + while ($key = $this->stream->readUTF()) { |
|
496 | + // Mixed array record ends with empty string (0x00 0x00) and 0x09 |
|
497 | + if (($key == '') && ($this->stream->peekByte() == 0x09)) { |
|
498 | + // Consume byte |
|
499 | + $this->stream->readByte(); |
|
500 | + break; |
|
501 | + } |
|
502 | 502 | |
503 | - $data[$key] = $this->readData(); |
|
504 | - } |
|
503 | + $data[$key] = $this->readData(); |
|
504 | + } |
|
505 | 505 | |
506 | - return $data; |
|
507 | - } |
|
506 | + return $data; |
|
507 | + } |
|
508 | 508 | |
509 | 509 | |
510 | - public function readMixedArray() { |
|
510 | + public function readMixedArray() { |
|
511 | 511 | |
512 | - // Get highest numerical index - ignored |
|
513 | - $highestIndex = $this->stream->readLong(); |
|
512 | + // Get highest numerical index - ignored |
|
513 | + $highestIndex = $this->stream->readLong(); |
|
514 | 514 | |
515 | - $data = array(); |
|
515 | + $data = array(); |
|
516 | 516 | |
517 | - while ($key = $this->stream->readUTF()) { |
|
518 | - // Mixed array record ends with empty string (0x00 0x00) and 0x09 |
|
519 | - if (($key == '') && ($this->stream->peekByte() == 0x09)) { |
|
520 | - // Consume byte |
|
521 | - $this->stream->readByte(); |
|
522 | - break; |
|
523 | - } |
|
517 | + while ($key = $this->stream->readUTF()) { |
|
518 | + // Mixed array record ends with empty string (0x00 0x00) and 0x09 |
|
519 | + if (($key == '') && ($this->stream->peekByte() == 0x09)) { |
|
520 | + // Consume byte |
|
521 | + $this->stream->readByte(); |
|
522 | + break; |
|
523 | + } |
|
524 | 524 | |
525 | - if (is_numeric($key)) { |
|
526 | - $key = (float) $key; |
|
527 | - } |
|
525 | + if (is_numeric($key)) { |
|
526 | + $key = (float) $key; |
|
527 | + } |
|
528 | 528 | |
529 | - $data[$key] = $this->readData(); |
|
530 | - } |
|
529 | + $data[$key] = $this->readData(); |
|
530 | + } |
|
531 | 531 | |
532 | - return $data; |
|
533 | - } |
|
532 | + return $data; |
|
533 | + } |
|
534 | 534 | |
535 | 535 | |
536 | - public function readArray() { |
|
536 | + public function readArray() { |
|
537 | 537 | |
538 | - $length = $this->stream->readLong(); |
|
538 | + $length = $this->stream->readLong(); |
|
539 | 539 | |
540 | - $data = array(); |
|
540 | + $data = array(); |
|
541 | 541 | |
542 | - for ($i = 0; $i < count($length); $i++) { |
|
543 | - $data[] = $this->readData(); |
|
544 | - } |
|
542 | + for ($i = 0; $i < count($length); $i++) { |
|
543 | + $data[] = $this->readData(); |
|
544 | + } |
|
545 | 545 | |
546 | - return $data; |
|
547 | - } |
|
546 | + return $data; |
|
547 | + } |
|
548 | 548 | |
549 | 549 | |
550 | - public function readDate() { |
|
550 | + public function readDate() { |
|
551 | 551 | |
552 | - $timestamp = $this->stream->readDouble(); |
|
553 | - $timezone = $this->stream->readInt(); |
|
554 | - return $timestamp; |
|
555 | - } |
|
552 | + $timestamp = $this->stream->readDouble(); |
|
553 | + $timezone = $this->stream->readInt(); |
|
554 | + return $timestamp; |
|
555 | + } |
|
556 | 556 | |
557 | 557 | |
558 | - public function readLongString() { |
|
558 | + public function readLongString() { |
|
559 | 559 | |
560 | - return $this->stream->readLongUTF(); |
|
561 | - } |
|
560 | + return $this->stream->readLongUTF(); |
|
561 | + } |
|
562 | 562 | |
563 | 563 | |
564 | - public function readXML() { |
|
564 | + public function readXML() { |
|
565 | 565 | |
566 | - return $this->stream->readLongUTF(); |
|
567 | - } |
|
566 | + return $this->stream->readLongUTF(); |
|
567 | + } |
|
568 | 568 | |
569 | 569 | |
570 | - public function readTypedObject() { |
|
570 | + public function readTypedObject() { |
|
571 | 571 | |
572 | - $className = $this->stream->readUTF(); |
|
573 | - return $this->readObject(); |
|
574 | - } |
|
572 | + $className = $this->stream->readUTF(); |
|
573 | + return $this->readObject(); |
|
574 | + } |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | ?> |
@@ -693,8 +693,8 @@ discard block |
||
693 | 693 | */ |
694 | 694 | function get_week_from_day($date) { |
695 | 695 | if (!empty($date)) { |
696 | - $time = api_strtotime($date,'UTC'); |
|
697 | - return date('W', $time); |
|
696 | + $time = api_strtotime($date,'UTC'); |
|
697 | + return date('W', $time); |
|
698 | 698 | } else { |
699 | 699 | return date('W'); |
700 | 700 | } |
@@ -712,31 +712,31 @@ discard block |
||
712 | 712 | |
713 | 713 | function substrwords($text,$maxchar,$end='...') |
714 | 714 | { |
715 | - if(strlen($text)>$maxchar) |
|
716 | - { |
|
717 | - $words=explode(" ",$text); |
|
718 | - $output = ''; |
|
719 | - $i=0; |
|
720 | - while(1) |
|
721 | - { |
|
722 | - $length = (strlen($output)+strlen($words[$i])); |
|
723 | - if($length>$maxchar) |
|
724 | - { |
|
725 | - break; |
|
726 | - } |
|
727 | - else |
|
728 | - { |
|
729 | - $output = $output." ".$words[$i]; |
|
730 | - $i++; |
|
731 | - }; |
|
732 | - }; |
|
733 | - } |
|
734 | - else |
|
735 | - { |
|
736 | - $output = $text; |
|
737 | - return $output; |
|
738 | - } |
|
739 | - return $output.$end; |
|
715 | + if(strlen($text)>$maxchar) |
|
716 | + { |
|
717 | + $words=explode(" ",$text); |
|
718 | + $output = ''; |
|
719 | + $i=0; |
|
720 | + while(1) |
|
721 | + { |
|
722 | + $length = (strlen($output)+strlen($words[$i])); |
|
723 | + if($length>$maxchar) |
|
724 | + { |
|
725 | + break; |
|
726 | + } |
|
727 | + else |
|
728 | + { |
|
729 | + $output = $output." ".$words[$i]; |
|
730 | + $i++; |
|
731 | + }; |
|
732 | + }; |
|
733 | + } |
|
734 | + else |
|
735 | + { |
|
736 | + $output = $text; |
|
737 | + return $output; |
|
738 | + } |
|
739 | + return $output.$end; |
|
740 | 740 | } |
741 | 741 | |
742 | 742 | function implode_with_key($glue, $array) { |
@@ -16,7 +16,6 @@ |
||
16 | 16 | * @author Patrick Cool |
17 | 17 | * @author René Haentjens, added CSV file import (October 2004) |
18 | 18 | * @package chamilo.link |
19 | - |
|
20 | 19 | */ |
21 | 20 | |
22 | 21 | // Including libraries |