@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | ) { |
72 | 72 | mkdir($this->store_path.$this->session_id.'/'.$this->exercise_id.'/'.$this->question_id.'/'.$this->user_id, $directoryPermissions); |
73 | 73 | } |
74 | - } |
|
74 | + } |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * Setting parameters: course id, session id, etc |
@@ -119,24 +119,24 @@ discard block |
||
119 | 119 | $this->question_id = 0; |
120 | 120 | } |
121 | 121 | |
122 | - $this->can_edit = false; |
|
122 | + $this->can_edit = false; |
|
123 | 123 | |
124 | - if (api_is_allowed_to_edit()) { |
|
125 | - $this->can_edit = true; |
|
126 | - } else { |
|
127 | - if ($this->user_id == api_get_user_id()) { |
|
128 | - $this->can_edit = true; |
|
129 | - } |
|
130 | - } |
|
124 | + if (api_is_allowed_to_edit()) { |
|
125 | + $this->can_edit = true; |
|
126 | + } else { |
|
127 | + if ($this->user_id == api_get_user_id()) { |
|
128 | + $this->can_edit = true; |
|
129 | + } |
|
130 | + } |
|
131 | 131 | |
132 | - // Settings the params array |
|
133 | - $this->params = $params; |
|
134 | - $this->store_path = api_get_path(SYS_COURSE_PATH).$this->course_info['path'].'/exercises/'; |
|
135 | - $this->create_user_folder(); |
|
136 | - $this->store_path = $this->store_path.implode('/', array($this->session_id, $this->exercise_id, $this->question_id, $this->user_id)).'/'; |
|
137 | - $this->filename = $this->generate_filename(); |
|
138 | - $this->store_filename = $this->store_path.$this->filename; |
|
139 | - } |
|
132 | + // Settings the params array |
|
133 | + $this->params = $params; |
|
134 | + $this->store_path = api_get_path(SYS_COURSE_PATH).$this->course_info['path'].'/exercises/'; |
|
135 | + $this->create_user_folder(); |
|
136 | + $this->store_path = $this->store_path.implode('/', array($this->session_id, $this->exercise_id, $this->question_id, $this->user_id)).'/'; |
|
137 | + $this->filename = $this->generate_filename(); |
|
138 | + $this->store_filename = $this->store_path.$this->filename; |
|
139 | + } |
|
140 | 140 | |
141 | 141 | /** |
142 | 142 | * Generates the filename with the next format: |
@@ -187,30 +187,30 @@ discard block |
||
187 | 187 | return $delete_found; |
188 | 188 | } |
189 | 189 | |
190 | - /** |
|
191 | - * |
|
192 | - * Tricky stuff to deal with the feedback = 0 in exercises (all question per page) |
|
190 | + /** |
|
191 | + * |
|
192 | + * Tricky stuff to deal with the feedback = 0 in exercises (all question per page) |
|
193 | 193 | * @param int $exe_id |
194 | - */ |
|
194 | + */ |
|
195 | 195 | public function replace_with_real_exe($exe_id) |
196 | 196 | { |
197 | - $filename = null; |
|
198 | - //@ugly fix |
|
199 | - foreach($this->available_extensions as $extension) { |
|
200 | - $items = explode('-', $this->filename); |
|
201 | - $items[5] = 'temp_exe'; |
|
202 | - $filename = implode('-', $items); |
|
203 | - if (is_file($this->store_path.$filename.'.'.$extension)) { |
|
204 | - $old_name = $this->store_path.$filename.'.'.$extension; |
|
205 | - $items = explode('-', $this->filename); |
|
206 | - $items[5] = $exe_id; |
|
207 | - $filename = $filename = implode('-', $items); |
|
208 | - $new_name = $this->store_path.$filename.'.'.$extension; |
|
209 | - rename($old_name, $new_name); |
|
210 | - break; |
|
211 | - } |
|
212 | - } |
|
213 | - } |
|
197 | + $filename = null; |
|
198 | + //@ugly fix |
|
199 | + foreach($this->available_extensions as $extension) { |
|
200 | + $items = explode('-', $this->filename); |
|
201 | + $items[5] = 'temp_exe'; |
|
202 | + $filename = implode('-', $items); |
|
203 | + if (is_file($this->store_path.$filename.'.'.$extension)) { |
|
204 | + $old_name = $this->store_path.$filename.'.'.$extension; |
|
205 | + $items = explode('-', $this->filename); |
|
206 | + $items[5] = $exe_id; |
|
207 | + $filename = $filename = implode('-', $items); |
|
208 | + $new_name = $this->store_path.$filename.'.'.$extension; |
|
209 | + rename($old_name, $new_name); |
|
210 | + break; |
|
211 | + } |
|
212 | + } |
|
213 | + } |
|
214 | 214 | |
215 | 215 | /** |
216 | 216 | * @param bool $load_from_database |
@@ -218,24 +218,24 @@ discard block |
||
218 | 218 | */ |
219 | 219 | public function load_filename_if_exists($load_from_database = false) |
220 | 220 | { |
221 | - $filename = null; |
|
222 | - //@ugly fix |
|
223 | - foreach($this->available_extensions as $extension) { |
|
224 | - if (is_file($this->store_path.$this->filename.'.'.$extension)) { |
|
225 | - $filename = $this->filename.'.'.$extension; |
|
226 | - break; |
|
227 | - } |
|
228 | - } |
|
221 | + $filename = null; |
|
222 | + //@ugly fix |
|
223 | + foreach($this->available_extensions as $extension) { |
|
224 | + if (is_file($this->store_path.$this->filename.'.'.$extension)) { |
|
225 | + $filename = $this->filename.'.'.$extension; |
|
226 | + break; |
|
227 | + } |
|
228 | + } |
|
229 | 229 | |
230 | - // temp_exe |
|
231 | - if ($load_from_database) { |
|
230 | + // temp_exe |
|
231 | + if ($load_from_database) { |
|
232 | 232 | |
233 | - //Load the real filename just if exists |
|
234 | - if (isset($this->params['exe_id']) && isset($this->params['user_id']) && |
|
233 | + //Load the real filename just if exists |
|
234 | + if (isset($this->params['exe_id']) && isset($this->params['user_id']) && |
|
235 | 235 | isset($this->params['question_id']) && isset($this->params['session_id']) && isset($this->params['course_id']) |
236 | 236 | ) { |
237 | - $attempt_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); |
|
238 | - $sql = "SELECT filename FROM $attempt_table |
|
237 | + $attempt_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); |
|
238 | + $sql = "SELECT filename FROM $attempt_table |
|
239 | 239 | WHERE |
240 | 240 | exe_id = ".$this->params['exe_id']." AND |
241 | 241 | user_id = ".$this->params['user_id']." AND |
@@ -243,107 +243,107 @@ discard block |
||
243 | 243 | session_id = ".$this->params['session_id']." AND |
244 | 244 | course_code = '".$this->course_info['code']."' |
245 | 245 | LIMIT 1"; |
246 | - $result = Database::query($sql); |
|
247 | - $result = Database::fetch_row($result,'ASSOC'); |
|
246 | + $result = Database::query($sql); |
|
247 | + $result = Database::fetch_row($result,'ASSOC'); |
|
248 | 248 | |
249 | - if (isset($result) && isset($result[0]) && !empty($result[0])) { |
|
250 | - $filename = $result[0]; |
|
251 | - } |
|
252 | - } |
|
253 | - } |
|
249 | + if (isset($result) && isset($result[0]) && !empty($result[0])) { |
|
250 | + $filename = $result[0]; |
|
251 | + } |
|
252 | + } |
|
253 | + } |
|
254 | 254 | |
255 | - if (is_file($this->store_path.$filename)) { |
|
256 | - return $this->store_path.$filename; |
|
257 | - } |
|
255 | + if (is_file($this->store_path.$filename)) { |
|
256 | + return $this->store_path.$filename; |
|
257 | + } |
|
258 | 258 | |
259 | - return null; |
|
260 | - } |
|
259 | + return null; |
|
260 | + } |
|
261 | 261 | |
262 | - /** |
|
263 | - * |
|
264 | - * Get the URL of the file |
|
265 | - * path courses/XXX/exercises/(session_id)/(exercise_id)/(question_id)/(user_id)/ |
|
262 | + /** |
|
263 | + * |
|
264 | + * Get the URL of the file |
|
265 | + * path courses/XXX/exercises/(session_id)/(exercise_id)/(question_id)/(user_id)/ |
|
266 | 266 | * @param int $force_download |
267 | - * |
|
268 | - * @return string |
|
269 | - */ |
|
267 | + * |
|
268 | + * @return string |
|
269 | + */ |
|
270 | 270 | public function get_public_url($force_download = 0) |
271 | 271 | { |
272 | - $params = $this->get_params(); |
|
273 | - $filename = basename($this->load_filename_if_exists()); |
|
272 | + $params = $this->get_params(); |
|
273 | + $filename = basename($this->load_filename_if_exists()); |
|
274 | 274 | $url = api_get_path(WEB_COURSE_PATH).$this->course_info['path'].'/exercises/'.$params['session_id'].'/'.$params['exercise_id'].'/'.$params['question_id'].'/'.$params['user_id'].'/'.$filename; |
275 | - return $url; |
|
276 | - } |
|
275 | + return $url; |
|
276 | + } |
|
277 | 277 | |
278 | - /** |
|
279 | - * Uploads the nanogong wav file |
|
278 | + /** |
|
279 | + * Uploads the nanogong wav file |
|
280 | 280 | * @param bool |
281 | - */ |
|
282 | - public function upload_file($is_nano = false) |
|
283 | - { |
|
284 | - if (!empty($_FILES)) { |
|
285 | - $upload_ok = process_uploaded_file($_FILES['file'], false); |
|
286 | - |
|
287 | - if (!is_uploaded_file($_FILES['file']['tmp_name'])) { |
|
288 | - return 0; |
|
289 | - } |
|
281 | + */ |
|
282 | + public function upload_file($is_nano = false) |
|
283 | + { |
|
284 | + if (!empty($_FILES)) { |
|
285 | + $upload_ok = process_uploaded_file($_FILES['file'], false); |
|
290 | 286 | |
291 | - if ($upload_ok) { |
|
292 | - // Check if there is enough space to save the file |
|
293 | - if (!DocumentManager::enough_space($_FILES['file']['size'], DocumentManager::get_course_quota())) { |
|
294 | - return 0; |
|
295 | - } |
|
287 | + if (!is_uploaded_file($_FILES['file']['tmp_name'])) { |
|
288 | + return 0; |
|
289 | + } |
|
296 | 290 | |
297 | - //first we delete everything before uploading the file |
|
298 | - $this->delete_files(); |
|
291 | + if ($upload_ok) { |
|
292 | + // Check if there is enough space to save the file |
|
293 | + if (!DocumentManager::enough_space($_FILES['file']['size'], DocumentManager::get_course_quota())) { |
|
294 | + return 0; |
|
295 | + } |
|
299 | 296 | |
300 | - //Reload the filename variable |
|
301 | - $file_name = add_ext_on_mime($_FILES['file']['name'], $_FILES['file']['type']); |
|
302 | - $file_name = strtolower($file_name); |
|
303 | - $file_info = pathinfo($file_name); |
|
297 | + //first we delete everything before uploading the file |
|
298 | + $this->delete_files(); |
|
304 | 299 | |
305 | - if ($is_nano == true) { |
|
306 | - $file_info['extension'] = 'wav'; |
|
307 | - } |
|
300 | + //Reload the filename variable |
|
301 | + $file_name = add_ext_on_mime($_FILES['file']['name'], $_FILES['file']['type']); |
|
302 | + $file_name = strtolower($file_name); |
|
303 | + $file_info = pathinfo($file_name); |
|
308 | 304 | |
309 | - $file_name = $this->filename.'.'.$file_info['extension']; |
|
305 | + if ($is_nano == true) { |
|
306 | + $file_info['extension'] = 'wav'; |
|
307 | + } |
|
310 | 308 | |
311 | - if (in_array($file_info['extension'], $this->available_extensions)) { |
|
312 | - if (move_uploaded_file($_FILES['file']['tmp_name'], $this->store_path.$file_name)) { |
|
313 | - $this->store_filename = $this->store_path.$file_name; |
|
314 | - return 1; |
|
315 | - } |
|
316 | - } |
|
317 | - } |
|
318 | - } |
|
309 | + $file_name = $this->filename.'.'.$file_info['extension']; |
|
310 | + |
|
311 | + if (in_array($file_info['extension'], $this->available_extensions)) { |
|
312 | + if (move_uploaded_file($_FILES['file']['tmp_name'], $this->store_path.$file_name)) { |
|
313 | + $this->store_filename = $this->store_path.$file_name; |
|
314 | + return 1; |
|
315 | + } |
|
316 | + } |
|
317 | + } |
|
318 | + } |
|
319 | 319 | |
320 | - return 0; |
|
321 | - } |
|
320 | + return 0; |
|
321 | + } |
|
322 | 322 | |
323 | - /** |
|
324 | - * Show the audio file + a button to download |
|
323 | + /** |
|
324 | + * Show the audio file + a button to download |
|
325 | 325 | * @param bool |
326 | - */ |
|
327 | - public function show_audio_file($show_delete_button = false) |
|
328 | - { |
|
329 | - $html = ''; |
|
330 | - $file_path = $this->load_filename_if_exists(); |
|
331 | - |
|
332 | - if (!empty($file_path)) { |
|
333 | - $url = $this->get_public_url(true); |
|
334 | - $actions = Display::url(Display::return_icon('save.png', get_lang('Download'), array(), ICON_SIZE_SMALL), $url, array('target'=>'_blank')); |
|
335 | - $download_button = Display::url(get_lang('Download'), $url, array('class' =>'btn btn-default')); |
|
336 | - |
|
337 | - if ($show_delete_button) { |
|
338 | - $actions .= ' '.Display::url(Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL), "#", array('onclick'=>'delete_file();')); |
|
339 | - } |
|
326 | + */ |
|
327 | + public function show_audio_file($show_delete_button = false) |
|
328 | + { |
|
329 | + $html = ''; |
|
330 | + $file_path = $this->load_filename_if_exists(); |
|
331 | + |
|
332 | + if (!empty($file_path)) { |
|
333 | + $url = $this->get_public_url(true); |
|
334 | + $actions = Display::url(Display::return_icon('save.png', get_lang('Download'), array(), ICON_SIZE_SMALL), $url, array('target'=>'_blank')); |
|
335 | + $download_button = Display::url(get_lang('Download'), $url, array('class' =>'btn btn-default')); |
|
340 | 336 | |
341 | - $basename = basename($file_path); |
|
342 | - $path_info = pathinfo($basename); |
|
337 | + if ($show_delete_button) { |
|
338 | + $actions .= ' '.Display::url(Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL), "#", array('onclick'=>'delete_file();')); |
|
339 | + } |
|
343 | 340 | |
344 | - if ($path_info['extension'] == 'wav') { |
|
341 | + $basename = basename($file_path); |
|
342 | + $path_info = pathinfo($basename); |
|
345 | 343 | |
346 | - $html .= '<script> |
|
344 | + if ($path_info['extension'] == 'wav') { |
|
345 | + |
|
346 | + $html .= '<script> |
|
347 | 347 | $(document).ready( function() { |
348 | 348 | var java_enabled = navigator.javaEnabled(); |
349 | 349 | |
@@ -357,56 +357,56 @@ discard block |
||
357 | 357 | }); |
358 | 358 | </script>'; |
359 | 359 | |
360 | - $html .= '<div id="nanogong_player_id" class="nanogong_player_container">'; |
|
361 | - $html .= '<div class="action_player">'.$actions.'</div>'; |
|
362 | - $html .= '<div class="nanogong_player">'; |
|
363 | - $html .= '<applet id="nanogong_player" archive="'.api_get_path(WEB_LIBRARY_PATH).'nanogong/nanogong.jar" code="gong.NanoGong" width="250" height="95" ALIGN="middle">'; |
|
364 | - $html .= '<param name="ShowRecordButton" value="false" />'; // default true |
|
365 | - $html .= '<param name="ShowSaveButton" value="false" />'; //you can save in local computer | (default true) |
|
366 | - //echo '<param name="ShowAudioLevel" value="false" />'; // it displays the audiometer | (default true) |
|
367 | - $html .= '<param name="ShowTime" value="true" />'; // default false |
|
368 | - $html .= '<param name="Color" value="#FFFFFF" />'; |
|
360 | + $html .= '<div id="nanogong_player_id" class="nanogong_player_container">'; |
|
361 | + $html .= '<div class="action_player">'.$actions.'</div>'; |
|
362 | + $html .= '<div class="nanogong_player">'; |
|
363 | + $html .= '<applet id="nanogong_player" archive="'.api_get_path(WEB_LIBRARY_PATH).'nanogong/nanogong.jar" code="gong.NanoGong" width="250" height="95" ALIGN="middle">'; |
|
364 | + $html .= '<param name="ShowRecordButton" value="false" />'; // default true |
|
365 | + $html .= '<param name="ShowSaveButton" value="false" />'; //you can save in local computer | (default true) |
|
366 | + //echo '<param name="ShowAudioLevel" value="false" />'; // it displays the audiometer | (default true) |
|
367 | + $html .= '<param name="ShowTime" value="true" />'; // default false |
|
368 | + $html .= '<param name="Color" value="#FFFFFF" />'; |
|
369 | 369 | $html .= '<param name="ShowSpeedButton" value="false" />'; |
370 | - //echo '<param name="StartTime" value="10.5" />'; |
|
371 | - //echo '<param name="EndTime" value="65" />'; |
|
372 | - $html .= '<param name="AudioFormat" value="ImaADPCM" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
373 | - //$html .= '<param name="AudioFormat" value="Speex" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
374 | - //Quality for ImaADPCM (low 8000, medium 11025, normal 22050, hight 44100) OR Quality for Speex (low 8000, medium 16000, normal 32000, hight 44100) | (default 44100) |
|
375 | - //echo '<param name="SamplingRate" value="32000" />'; |
|
376 | - //echo '<param name="MaxDuration" value="60" />'; |
|
377 | - $html .= '<param name="SoundFileURL" value="'.$url.'" />';//load a file |(default "") |
|
378 | - $html .= '</applet>'; |
|
379 | - $html .= '</div>'; |
|
380 | - $html .= '</div>'; |
|
370 | + //echo '<param name="StartTime" value="10.5" />'; |
|
371 | + //echo '<param name="EndTime" value="65" />'; |
|
372 | + $html .= '<param name="AudioFormat" value="ImaADPCM" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
373 | + //$html .= '<param name="AudioFormat" value="Speex" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
374 | + //Quality for ImaADPCM (low 8000, medium 11025, normal 22050, hight 44100) OR Quality for Speex (low 8000, medium 16000, normal 32000, hight 44100) | (default 44100) |
|
375 | + //echo '<param name="SamplingRate" value="32000" />'; |
|
376 | + //echo '<param name="MaxDuration" value="60" />'; |
|
377 | + $html .= '<param name="SoundFileURL" value="'.$url.'" />';//load a file |(default "") |
|
378 | + $html .= '</applet>'; |
|
379 | + $html .= '</div>'; |
|
380 | + $html .= '</div>'; |
|
381 | 381 | $html .= '<div id="nanogong_warning">'.Display::return_message(get_lang('BrowserDoesNotSupportNanogongPlayer'), 'warning').$download_button.'</div>'; |
382 | 382 | |
383 | - } elseif(in_array($path_info['extension'],array('mp3', 'ogg','wav'))) { |
|
384 | - $js_path = api_get_path(WEB_LIBRARY_PATH).'javascript/'; |
|
385 | - $html .= '<link rel="stylesheet" href="'.$js_path.'jquery-jplayer/skin/blue.monday/css/jplayer.blue.monday.css" type="text/css">'; |
|
386 | - $html .= '<script type="text/javascript" src="'.$js_path.'jquery-jplayer/jplayer/jquery.jplayer.min.js"></script>'; |
|
383 | + } elseif(in_array($path_info['extension'],array('mp3', 'ogg','wav'))) { |
|
384 | + $js_path = api_get_path(WEB_LIBRARY_PATH).'javascript/'; |
|
385 | + $html .= '<link rel="stylesheet" href="'.$js_path.'jquery-jplayer/skin/blue.monday/css/jplayer.blue.monday.css" type="text/css">'; |
|
386 | + $html .= '<script type="text/javascript" src="'.$js_path.'jquery-jplayer/jplayer/jquery.jplayer.min.js"></script>'; |
|
387 | 387 | |
388 | - $html .= '<div class="nanogong_player"></div>'; |
|
389 | - $html .= '<br /><div class="action_player">'.$actions.'</div><br /><br /><br />'; |
|
388 | + $html .= '<div class="nanogong_player"></div>'; |
|
389 | + $html .= '<br /><div class="action_player">'.$actions.'</div><br /><br /><br />'; |
|
390 | 390 | |
391 | 391 | $params = array( |
392 | 392 | 'url' => $url, |
393 | 393 | 'extension' =>$path_info['extension'], |
394 | 394 | 'count'=> 1 |
395 | - ); |
|
395 | + ); |
|
396 | 396 | $jquery = DocumentManager::generate_jplayer_jquery($params); |
397 | - $html .= '<script> |
|
397 | + $html .= '<script> |
|
398 | 398 | $(document).ready( function() { |
399 | 399 | //Experimental changes to preview mp3, ogg files |
400 | 400 | '.$jquery.' |
401 | 401 | }); |
402 | 402 | </script>'; |
403 | - $html .= DocumentManager::generate_media_preview(1, 'advanced'); |
|
404 | - } |
|
405 | - } |
|
403 | + $html .= DocumentManager::generate_media_preview(1, 'advanced'); |
|
404 | + } |
|
405 | + } |
|
406 | 406 | return $html; |
407 | - } |
|
407 | + } |
|
408 | 408 | |
409 | - /* |
|
409 | + /* |
|
410 | 410 | var filename = document.getElementById("audio_title").value+".wav"; |
411 | 411 | var filename = filename.replace(/\s/g, "_");//replace spaces by _ |
412 | 412 | var filename = encodeURIComponent(filename); |
@@ -416,19 +416,19 @@ discard block |
||
416 | 416 | var urlnanogong="'.$url.'?filename="+filename+"&filepath="+filepath+"&dir="+dir+"&course_code="+course_code; |
417 | 417 | */ |
418 | 418 | |
419 | - /** |
|
420 | - * Returns the nanogong javascript code |
|
421 | - * @return string |
|
422 | - */ |
|
419 | + /** |
|
420 | + * Returns the nanogong javascript code |
|
421 | + * @return string |
|
422 | + */ |
|
423 | 423 | public function return_js() |
424 | 424 | { |
425 | - $params = $this->get_params(true); |
|
426 | - $url = api_get_path(WEB_AJAX_PATH).'nanogong.ajax.php?a=save_file&'.$params.'&is_nano=1'; |
|
427 | - $url_load_file = api_get_path(WEB_AJAX_PATH).'nanogong.ajax.php?a=show_audio&'.$params; |
|
425 | + $params = $this->get_params(true); |
|
426 | + $url = api_get_path(WEB_AJAX_PATH).'nanogong.ajax.php?a=save_file&'.$params.'&is_nano=1'; |
|
427 | + $url_load_file = api_get_path(WEB_AJAX_PATH).'nanogong.ajax.php?a=show_audio&'.$params; |
|
428 | 428 | |
429 | - $url_delete = api_get_path(WEB_AJAX_PATH).'nanogong.ajax.php?a=delete&'.$params; |
|
429 | + $url_delete = api_get_path(WEB_AJAX_PATH).'nanogong.ajax.php?a=delete&'.$params; |
|
430 | 430 | |
431 | - $js = '<script language="javascript"> |
|
431 | + $js = '<script language="javascript"> |
|
432 | 432 | |
433 | 433 | //lang vars |
434 | 434 | |
@@ -544,77 +544,77 @@ discard block |
||
544 | 544 | return false; |
545 | 545 | } |
546 | 546 | </script>'; |
547 | - return $js; |
|
548 | - } |
|
547 | + return $js; |
|
548 | + } |
|
549 | 549 | |
550 | - /** |
|
551 | - * Returns the HTML form to upload a nano file or upload a file |
|
550 | + /** |
|
551 | + * Returns the HTML form to upload a nano file or upload a file |
|
552 | 552 | * @param string |
553 | - */ |
|
554 | - public function return_form($message = null) |
|
553 | + */ |
|
554 | + public function return_form($message = null) |
|
555 | 555 | { |
556 | 556 | |
557 | - $params = $this->get_params(true); |
|
558 | - $url = api_get_path(WEB_AJAX_PATH).'nanogong.ajax.php?a=save_file&'.$params; |
|
557 | + $params = $this->get_params(true); |
|
558 | + $url = api_get_path(WEB_AJAX_PATH).'nanogong.ajax.php?a=save_file&'.$params; |
|
559 | 559 | |
560 | - //check browser support and load form |
|
561 | - $array_browser = api_browser_support('check_browser'); |
|
560 | + //check browser support and load form |
|
561 | + $array_browser = api_browser_support('check_browser'); |
|
562 | 562 | |
563 | - $preview_file = $this->show_audio_file(true, true); |
|
563 | + $preview_file = $this->show_audio_file(true, true); |
|
564 | 564 | |
565 | 565 | $preview_file = Display::div( |
566 | 566 | $preview_file, |
567 | 567 | array('id' => 'preview', 'style' => 'text-align:center; padding-left: 25px;') |
568 | 568 | ); |
569 | 569 | |
570 | - $html = '<center>'; |
|
570 | + $html = '<center>'; |
|
571 | 571 | |
572 | - //Use normal upload file |
|
573 | - $html .= Display::return_icon('microphone.png', get_lang('PressRecordButton'),'', ICON_SIZE_BIG); |
|
574 | - $html .='<br />'; |
|
572 | + //Use normal upload file |
|
573 | + $html .= Display::return_icon('microphone.png', get_lang('PressRecordButton'),'', ICON_SIZE_BIG); |
|
574 | + $html .='<br />'; |
|
575 | 575 | |
576 | - $html .= '<div id="nanogong_div">'; |
|
576 | + $html .= '<div id="nanogong_div">'; |
|
577 | 577 | |
578 | - $html .= '<applet id="nanogong" archive="'.api_get_path(WEB_LIBRARY_PATH).'nanogong/nanogong.jar" code="gong.NanoGong" width="250" height="95" align="middle">'; |
|
579 | - //echo '<param name="ShowRecordButton" value="false" />'; // default true |
|
580 | - // echo '<param name="ShowSaveButton" value="false" />'; //you can save in local computer | (default true) |
|
578 | + $html .= '<applet id="nanogong" archive="'.api_get_path(WEB_LIBRARY_PATH).'nanogong/nanogong.jar" code="gong.NanoGong" width="250" height="95" align="middle">'; |
|
579 | + //echo '<param name="ShowRecordButton" value="false" />'; // default true |
|
580 | + // echo '<param name="ShowSaveButton" value="false" />'; //you can save in local computer | (default true) |
|
581 | 581 | $html .= '<param name="ShowSpeedButton" value="false" />'; // default true |
582 | - //echo '<param name="ShowAudioLevel" value="false" />'; // it displays the audiometer | (default true) |
|
583 | - $html .= '<param name="ShowTime" value="true" />'; // default false |
|
584 | - $html .= '<param name="Color" value="#FFFFFF" />'; // default #FFFFFF |
|
585 | - //echo '<param name="StartTime" value="10.5" />'; |
|
586 | - //echo '<param name="EndTime" value="65" />'; |
|
587 | - $html .= '<param name="AudioFormat" value="ImaADPCM" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
588 | - //$html .= '<param name="AudioFormat" value="Speex" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
582 | + //echo '<param name="ShowAudioLevel" value="false" />'; // it displays the audiometer | (default true) |
|
583 | + $html .= '<param name="ShowTime" value="true" />'; // default false |
|
584 | + $html .= '<param name="Color" value="#FFFFFF" />'; // default #FFFFFF |
|
585 | + //echo '<param name="StartTime" value="10.5" />'; |
|
586 | + //echo '<param name="EndTime" value="65" />'; |
|
587 | + $html .= '<param name="AudioFormat" value="ImaADPCM" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
588 | + //$html .= '<param name="AudioFormat" value="Speex" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
589 | 589 | |
590 | - //echo '<param name="SamplingRate" value="32000" />';//Quality for ImaADPCM (low 8000, medium 11025, normal 22050, hight 44100) OR Quality for Speex (low 8000, medium 16000, normal 32000, hight 44100) | (default 44100) |
|
591 | - //echo '<param name="MaxDuration" value="60" />'; |
|
592 | - //echo '<param name="SoundFileURL" value="http://somewhere.com/mysoundfile.wav" />';//load a file |(default "") |
|
593 | - $html .= '</applet>'; |
|
590 | + //echo '<param name="SamplingRate" value="32000" />';//Quality for ImaADPCM (low 8000, medium 11025, normal 22050, hight 44100) OR Quality for Speex (low 8000, medium 16000, normal 32000, hight 44100) | (default 44100) |
|
591 | + //echo '<param name="MaxDuration" value="60" />'; |
|
592 | + //echo '<param name="SoundFileURL" value="http://somewhere.com/mysoundfile.wav" />';//load a file |(default "") |
|
593 | + $html .= '</applet>'; |
|
594 | 594 | |
595 | - $html .= '<br /><br /><br />'; |
|
595 | + $html .= '<br /><br /><br />'; |
|
596 | 596 | |
597 | 597 | $html .= '<form name="form_nanogong_advanced">'; |
598 | - $html .= '<input type="hidden" name="is_nano" value="1">'; |
|
599 | - $html .= '<a href="#" class="btn btn-default" onclick="send_voice()" />'.get_lang('SendRecord').'</a>'; |
|
600 | - $html .= '</form></div>'; |
|
598 | + $html .= '<input type="hidden" name="is_nano" value="1">'; |
|
599 | + $html .= '<a href="#" class="btn btn-default" onclick="send_voice()" />'.get_lang('SendRecord').'</a>'; |
|
600 | + $html .= '</form></div>'; |
|
601 | 601 | |
602 | 602 | $html .= Display::url(get_lang('ProblemsRecordingUploadYourOwnAudioFile'), 'javascript:void(0)', array('onclick' => 'show_simple_upload_form();')); |
603 | 603 | |
604 | - $html .= '<br /><br /><div id="no_nanogong_div">'; |
|
605 | - //$html .= Display::return_message(get_lang('BrowserNotSupportNanogongSend'), 'warning'); |
|
606 | - $html .= '<form id="form_nanogong_simple" class="form-search" action="'.$url.'" name="form_nanogong" method="POST" enctype="multipart/form-data">'; |
|
607 | - $html .= '<input type="file" name="file">'; |
|
608 | - $html .= '<a href="#" class="btn btn-default" onclick="upload_file()" /><em class="fa fa-upload"></em> '.get_lang('UploadFile').'</a>'; |
|
609 | - $html .= '</form>'; |
|
604 | + $html .= '<br /><br /><div id="no_nanogong_div">'; |
|
605 | + //$html .= Display::return_message(get_lang('BrowserNotSupportNanogongSend'), 'warning'); |
|
606 | + $html .= '<form id="form_nanogong_simple" class="form-search" action="'.$url.'" name="form_nanogong" method="POST" enctype="multipart/form-data">'; |
|
607 | + $html .= '<input type="file" name="file">'; |
|
608 | + $html .= '<a href="#" class="btn btn-default" onclick="upload_file()" /><em class="fa fa-upload"></em> '.get_lang('UploadFile').'</a>'; |
|
609 | + $html .= '</form>'; |
|
610 | 610 | $html .= '</div>'; |
611 | - $html .= '</center>'; |
|
612 | - $html .= '<div style="display:none" id="status_ok" class="confirmation-message"></div><div style="display:none" id="status_warning" class="warning-message"></div>'; |
|
613 | - $html .= '<div id="messages">'.$message.'</div>'; |
|
614 | - $html .= $preview_file; |
|
611 | + $html .= '</center>'; |
|
612 | + $html .= '<div style="display:none" id="status_ok" class="confirmation-message"></div><div style="display:none" id="status_warning" class="warning-message"></div>'; |
|
613 | + $html .= '<div id="messages">'.$message.'</div>'; |
|
614 | + $html .= $preview_file; |
|
615 | 615 | |
616 | - return $html; |
|
617 | - } |
|
616 | + return $html; |
|
617 | + } |
|
618 | 618 | |
619 | 619 | /** |
620 | 620 | * @param bool $return_as_query |
@@ -622,15 +622,15 @@ discard block |
||
622 | 622 | */ |
623 | 623 | public function get_params($return_as_query = false) |
624 | 624 | { |
625 | - if (empty($this->params)) { |
|
626 | - return false; |
|
627 | - } |
|
628 | - if ($return_as_query) { |
|
629 | - return http_build_query($this->params); |
|
630 | - } |
|
625 | + if (empty($this->params)) { |
|
626 | + return false; |
|
627 | + } |
|
628 | + if ($return_as_query) { |
|
629 | + return http_build_query($this->params); |
|
630 | + } |
|
631 | 631 | |
632 | - return $this->params; |
|
633 | - } |
|
632 | + return $this->params; |
|
633 | + } |
|
634 | 634 | |
635 | 635 | /** |
636 | 636 | * @param $attribute |
@@ -638,18 +638,18 @@ discard block |
||
638 | 638 | */ |
639 | 639 | public function get_param_value($attribute) |
640 | 640 | { |
641 | - if (isset($this->params[$attribute])) { |
|
642 | - return $this->params[$attribute]; |
|
643 | - } |
|
644 | - } |
|
645 | - |
|
646 | - /** |
|
647 | - * Show a button to load the form |
|
648 | - * @return string |
|
649 | - */ |
|
641 | + if (isset($this->params[$attribute])) { |
|
642 | + return $this->params[$attribute]; |
|
643 | + } |
|
644 | + } |
|
645 | + |
|
646 | + /** |
|
647 | + * Show a button to load the form |
|
648 | + * @return string |
|
649 | + */ |
|
650 | 650 | public function show_button() |
651 | 651 | { |
652 | - $params_string = $this->get_params(true); |
|
652 | + $params_string = $this->get_params(true); |
|
653 | 653 | |
654 | 654 | $url = api_get_path(WEB_AJAX_PATH) |
655 | 655 | . 'nanogong.ajax.php?a=show_form&' |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | 'data-title' => get_lang('RecordAnswer') |
665 | 665 | ] |
666 | 666 | ); |
667 | - $html .= '<br /><br />'.Display::return_message(get_lang('UseTheMessageBelowToAddSomeComments')); |
|
668 | - return $html; |
|
669 | - } |
|
667 | + $html .= '<br /><br />'.Display::return_message(get_lang('UseTheMessageBelowToAddSomeComments')); |
|
668 | + return $html; |
|
669 | + } |
|
670 | 670 | } |
@@ -107,14 +107,14 @@ |
||
107 | 107 | return $resu; |
108 | 108 | } |
109 | 109 | |
110 | - /** |
|
111 | - * @author Sebastien Piraux <[email protected]> |
|
112 | - * @param sql : a sql query (as a string) |
|
113 | - * @return hours_array |
|
114 | - * @desc Return an assoc array. Keys are the hours, values are |
|
115 | - * the number of time this hours was found. |
|
116 | - * key 'total' return the sum of all number of time hours |
|
117 | - * appear |
|
110 | + /** |
|
111 | + * @author Sebastien Piraux <[email protected]> |
|
112 | + * @param sql : a sql query (as a string) |
|
113 | + * @return hours_array |
|
114 | + * @desc Return an assoc array. Keys are the hours, values are |
|
115 | + * the number of time this hours was found. |
|
116 | + * key 'total' return the sum of all number of time hours |
|
117 | + * appear |
|
118 | 118 | */ |
119 | 119 | public static function hoursTab($sql) |
120 | 120 | { |
@@ -5,42 +5,42 @@ |
||
5 | 5 | * @deprecated Don't use this class |
6 | 6 | */ |
7 | 7 | class Rights { |
8 | - private static $rights_cache = array(); |
|
9 | - private static $rights = array ( |
|
10 | - 'show_tabs:reports' => |
|
11 | - array ( |
|
12 | - 'type' => 'const', |
|
13 | - 'const' => 'true' ) |
|
14 | - ); |
|
8 | + private static $rights_cache = array(); |
|
9 | + private static $rights = array ( |
|
10 | + 'show_tabs:reports' => |
|
11 | + array ( |
|
12 | + 'type' => 'const', |
|
13 | + 'const' => 'true' ) |
|
14 | + ); |
|
15 | 15 | |
16 | - // warning the goal of this function is to enforce rights managment in Chamilo |
|
17 | - // thus default return value is always true |
|
18 | - public static function hasRight($handler) { |
|
19 | - if (array_key_exists($handler, self::$rights_cache)) |
|
20 | - return self::$rights_cache[$handler]; |
|
16 | + // warning the goal of this function is to enforce rights managment in Chamilo |
|
17 | + // thus default return value is always true |
|
18 | + public static function hasRight($handler) { |
|
19 | + if (array_key_exists($handler, self::$rights_cache)) |
|
20 | + return self::$rights_cache[$handler]; |
|
21 | 21 | |
22 | - if (!array_key_exists($handler, self::$rights)) |
|
23 | - return true; // handler does not exists |
|
22 | + if (!array_key_exists($handler, self::$rights)) |
|
23 | + return true; // handler does not exists |
|
24 | 24 | |
25 | - if (self::$rights[$handler]['type'] == 'sql') { |
|
26 | - $result = Database::query(self::$rights[$handler]['sql']); |
|
27 | - if (Database::num_rows($result) > 0) |
|
28 | - $result = true; |
|
29 | - else |
|
30 | - $result = false; |
|
31 | - } else if (self::$rights[$handler]['type'] == 'const') |
|
32 | - $result = self::$rights[$handler]['const']; |
|
33 | - else if (self::$rights[$handler]['type'] == 'func') |
|
34 | - $result = self::$rights[$handler]['func'](); |
|
35 | - else // handler type not implemented |
|
36 | - return true; |
|
37 | - self::$rights_cache[$handler] = $result; |
|
38 | - return $result; |
|
39 | - } |
|
25 | + if (self::$rights[$handler]['type'] == 'sql') { |
|
26 | + $result = Database::query(self::$rights[$handler]['sql']); |
|
27 | + if (Database::num_rows($result) > 0) |
|
28 | + $result = true; |
|
29 | + else |
|
30 | + $result = false; |
|
31 | + } else if (self::$rights[$handler]['type'] == 'const') |
|
32 | + $result = self::$rights[$handler]['const']; |
|
33 | + else if (self::$rights[$handler]['type'] == 'func') |
|
34 | + $result = self::$rights[$handler]['func'](); |
|
35 | + else // handler type not implemented |
|
36 | + return true; |
|
37 | + self::$rights_cache[$handler] = $result; |
|
38 | + return $result; |
|
39 | + } |
|
40 | 40 | |
41 | - public static function hasRightClosePageWithError($handler) { |
|
42 | - if (hasRight($handler) == false) |
|
43 | - die("You are not allowed here"); //FIXME |
|
44 | - } |
|
41 | + public static function hasRightClosePageWithError($handler) { |
|
42 | + if (hasRight($handler) == false) |
|
43 | + die("You are not allowed here"); //FIXME |
|
44 | + } |
|
45 | 45 | |
46 | 46 | } |
@@ -173,9 +173,9 @@ discard block |
||
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
176 | - * @param string $pluginName |
|
177 | - * @param int $urlId |
|
178 | - */ |
|
176 | + * @param string $pluginName |
|
177 | + * @param int $urlId |
|
178 | + */ |
|
179 | 179 | public function uninstall($pluginName, $urlId = null) |
180 | 180 | { |
181 | 181 | if (empty($urlId)) { |
@@ -252,12 +252,12 @@ discard block |
||
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
255 | - * @param string $region |
|
256 | - * @param string $template |
|
257 | - * @param bool $forced |
|
258 | - * |
|
259 | - * @return null|string |
|
260 | - */ |
|
255 | + * @param string $region |
|
256 | + * @param string $template |
|
257 | + * @param bool $forced |
|
258 | + * |
|
259 | + * @return null|string |
|
260 | + */ |
|
261 | 261 | public function load_region($region, $template, $forced = false) |
262 | 262 | { |
263 | 263 | if ($region == 'course_tool_plugin') { |
@@ -167,9 +167,9 @@ |
||
167 | 167 | ini_set('session.use_cookies', $old_use_cookies); |
168 | 168 | session_cache_limiter($old_session_cache_limiter); |
169 | 169 | } else { |
170 | - if (isset($_OLD_SESSION)) { |
|
171 | - $_SESSION = $_OLD_SESSION; |
|
172 | - unset($_OLD_SESSION); |
|
170 | + if (isset($_OLD_SESSION)) { |
|
171 | + $_SESSION = $_OLD_SESSION; |
|
172 | + unset($_OLD_SESSION); |
|
173 | 173 | } else { |
174 | 174 | unset($_SESSION); |
175 | 175 | } |
@@ -257,27 +257,27 @@ discard block |
||
257 | 257 | switch ($hash) { |
258 | 258 | case 'md2': |
259 | 259 | $this->b = 16; |
260 | - $this->hash = array($this, '_md2'); |
|
261 | - break; |
|
260 | + $this->hash = array($this, '_md2'); |
|
261 | + break; |
|
262 | 262 | case 'md5': |
263 | 263 | case 'md5-96': |
264 | 264 | $this->b = 64; |
265 | - $this->hash = array($this, '_md5'); |
|
266 | - break; |
|
265 | + $this->hash = array($this, '_md5'); |
|
266 | + break; |
|
267 | 267 | case 'sha256': |
268 | 268 | $this->b = 64; |
269 | - $this->hash = array($this, '_sha256'); |
|
270 | - break; |
|
269 | + $this->hash = array($this, '_sha256'); |
|
270 | + break; |
|
271 | 271 | case 'sha384': |
272 | 272 | case 'sha512': |
273 | 273 | $this->b = 128; |
274 | - $this->hash = array($this, '_sha512'); |
|
275 | - break; |
|
274 | + $this->hash = array($this, '_sha512'); |
|
275 | + break; |
|
276 | 276 | case 'sha1': |
277 | 277 | case 'sha1-96': |
278 | 278 | default: |
279 | 279 | $this->b = 64; |
280 | - $this->hash = array($this, '_sha1'); |
|
280 | + $this->hash = array($this, '_sha1'); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | $this->ipad = str_repeat(chr(0x36), $this->b); |
@@ -378,24 +378,24 @@ discard block |
||
378 | 378 | function _md2($m) |
379 | 379 | { |
380 | 380 | static $s = array( |
381 | - 41, 46, 67, 201, 162, 216, 124, 1, 61, 54, 84, 161, 236, 240, 6, |
|
382 | - 19, 98, 167, 5, 243, 192, 199, 115, 140, 152, 147, 43, 217, 188, |
|
383 | - 76, 130, 202, 30, 155, 87, 60, 253, 212, 224, 22, 103, 66, 111, 24, |
|
381 | + 41, 46, 67, 201, 162, 216, 124, 1, 61, 54, 84, 161, 236, 240, 6, |
|
382 | + 19, 98, 167, 5, 243, 192, 199, 115, 140, 152, 147, 43, 217, 188, |
|
383 | + 76, 130, 202, 30, 155, 87, 60, 253, 212, 224, 22, 103, 66, 111, 24, |
|
384 | 384 | 138, 23, 229, 18, 190, 78, 196, 214, 218, 158, 222, 73, 160, 251, |
385 | 385 | 245, 142, 187, 47, 238, 122, 169, 104, 121, 145, 21, 178, 7, 63, |
386 | 386 | 148, 194, 16, 137, 11, 34, 95, 33, 128, 127, 93, 154, 90, 144, 50, |
387 | - 39, 53, 62, 204, 231, 191, 247, 151, 3, 255, 25, 48, 179, 72, 165, |
|
387 | + 39, 53, 62, 204, 231, 191, 247, 151, 3, 255, 25, 48, 179, 72, 165, |
|
388 | 388 | 181, 209, 215, 94, 146, 42, 172, 86, 170, 198, 79, 184, 56, 210, |
389 | 389 | 150, 164, 125, 182, 118, 252, 107, 226, 156, 116, 4, 241, 69, 157, |
390 | 390 | 112, 89, 100, 113, 135, 32, 134, 91, 207, 101, 230, 45, 168, 2, 27, |
391 | - 96, 37, 173, 174, 176, 185, 246, 28, 70, 97, 105, 52, 64, 126, 15, |
|
392 | - 85, 71, 163, 35, 221, 81, 175, 58, 195, 92, 249, 206, 186, 197, |
|
391 | + 96, 37, 173, 174, 176, 185, 246, 28, 70, 97, 105, 52, 64, 126, 15, |
|
392 | + 85, 71, 163, 35, 221, 81, 175, 58, 195, 92, 249, 206, 186, 197, |
|
393 | 393 | 234, 38, 44, 83, 13, 110, 133, 40, 132, 9, 211, 223, 205, 244, 65, |
394 | 394 | 129, 77, 82, 106, 220, 55, 200, 108, 193, 171, 250, 36, 225, 123, |
395 | - 8, 12, 189, 177, 74, 120, 136, 149, 139, 227, 99, 232, 109, 233, |
|
395 | + 8, 12, 189, 177, 74, 120, 136, 149, 139, 227, 99, 232, 109, 233, |
|
396 | 396 | 203, 213, 254, 59, 0, 29, 57, 242, 239, 183, 14, 102, 88, 208, 228, |
397 | 397 | 166, 119, 114, 248, 235, 117, 75, 10, 49, 68, 80, 180, 143, 237, |
398 | - 31, 26, 219, 153, 141, 51, 159, 17, 131, 20 |
|
398 | + 31, 26, 219, 153, 141, 51, 159, 17, 131, 20 |
|
399 | 399 | ); |
400 | 400 | |
401 | 401 | // Step 1. Append Padding Bytes |
@@ -494,11 +494,11 @@ discard block |
||
494 | 494 | // Extend the sixteen 32-bit words into sixty-four 32-bit words |
495 | 495 | for ($i = 16; $i < 64; $i++) { |
496 | 496 | $s0 = $this->_rightRotate($w[$i - 15], 7) ^ |
497 | - $this->_rightRotate($w[$i - 15], 18) ^ |
|
498 | - $this->_rightShift( $w[$i - 15], 3); |
|
497 | + $this->_rightRotate($w[$i - 15], 18) ^ |
|
498 | + $this->_rightShift( $w[$i - 15], 3); |
|
499 | 499 | $s1 = $this->_rightRotate($w[$i - 2], 17) ^ |
500 | - $this->_rightRotate($w[$i - 2], 19) ^ |
|
501 | - $this->_rightShift( $w[$i - 2], 10); |
|
500 | + $this->_rightRotate($w[$i - 2], 19) ^ |
|
501 | + $this->_rightShift( $w[$i - 2], 10); |
|
502 | 502 | $w[$i] = $this->_add($w[$i - 16], $s0, $w[$i - 7], $s1); |
503 | 503 | |
504 | 504 | } |
@@ -509,18 +509,18 @@ discard block |
||
509 | 509 | // Main loop |
510 | 510 | for ($i = 0; $i < 64; $i++) { |
511 | 511 | $s0 = $this->_rightRotate($a, 2) ^ |
512 | - $this->_rightRotate($a, 13) ^ |
|
513 | - $this->_rightRotate($a, 22); |
|
512 | + $this->_rightRotate($a, 13) ^ |
|
513 | + $this->_rightRotate($a, 22); |
|
514 | 514 | $maj = ($a & $b) ^ |
515 | - ($a & $c) ^ |
|
516 | - ($b & $c); |
|
515 | + ($a & $c) ^ |
|
516 | + ($b & $c); |
|
517 | 517 | $t2 = $this->_add($s0, $maj); |
518 | 518 | |
519 | 519 | $s1 = $this->_rightRotate($e, 6) ^ |
520 | - $this->_rightRotate($e, 11) ^ |
|
521 | - $this->_rightRotate($e, 25); |
|
520 | + $this->_rightRotate($e, 11) ^ |
|
521 | + $this->_rightRotate($e, 25); |
|
522 | 522 | $ch = ($e & $f) ^ |
523 | - ($this->_not($e) & $g); |
|
523 | + ($this->_not($e) & $g); |
|
524 | 524 | $t1 = $this->_add($h, $s1, $ch, $k[$i], $w[$i]); |
525 | 525 | |
526 | 526 | $h = $g; |
@@ -635,16 +635,16 @@ discard block |
||
635 | 635 | // Extend the sixteen 32-bit words into eighty 32-bit words |
636 | 636 | for ($i = 16; $i < 80; $i++) { |
637 | 637 | $temp = array( |
638 | - $w[$i - 15]->bitwise_rightRotate(1), |
|
639 | - $w[$i - 15]->bitwise_rightRotate(8), |
|
640 | - $w[$i - 15]->bitwise_rightShift(7) |
|
638 | + $w[$i - 15]->bitwise_rightRotate(1), |
|
639 | + $w[$i - 15]->bitwise_rightRotate(8), |
|
640 | + $w[$i - 15]->bitwise_rightShift(7) |
|
641 | 641 | ); |
642 | 642 | $s0 = $temp[0]->bitwise_xor($temp[1]); |
643 | 643 | $s0 = $s0->bitwise_xor($temp[2]); |
644 | 644 | $temp = array( |
645 | - $w[$i - 2]->bitwise_rightRotate(19), |
|
646 | - $w[$i - 2]->bitwise_rightRotate(61), |
|
647 | - $w[$i - 2]->bitwise_rightShift(6) |
|
645 | + $w[$i - 2]->bitwise_rightRotate(19), |
|
646 | + $w[$i - 2]->bitwise_rightRotate(61), |
|
647 | + $w[$i - 2]->bitwise_rightShift(6) |
|
648 | 648 | ); |
649 | 649 | $s1 = $temp[0]->bitwise_xor($temp[1]); |
650 | 650 | $s1 = $s1->bitwise_xor($temp[2]); |
@@ -625,13 +625,13 @@ |
||
625 | 625 | $l^= $p[++$i]; |
626 | 626 | $r^= ($sb_0[$l >> 24 & 0xff] + |
627 | 627 | $sb_1[$l >> 16 & 0xff] ^ |
628 | - $sb_2[$l >> 8 & 0xff]) + |
|
628 | + $sb_2[$l >> 8 & 0xff]) + |
|
629 | 629 | $sb_3[$l & 0xff]; |
630 | 630 | |
631 | 631 | $r^= $p[++$i]; |
632 | 632 | $l^= ($sb_0[$r >> 24 & 0xff] + |
633 | 633 | $sb_1[$r >> 16 & 0xff] ^ |
634 | - $sb_2[$r >> 8 & 0xff]) + |
|
634 | + $sb_2[$r >> 8 & 0xff]) + |
|
635 | 635 | $sb_3[$r & 0xff]; |
636 | 636 | |
637 | 637 | } |
@@ -1137,7 +1137,7 @@ discard block |
||
1137 | 1137 | if ($this->continuousBuffer) { |
1138 | 1138 | $this->encryptIV = $xor; |
1139 | 1139 | if ($start = strlen($plaintext) & 7) { |
1140 | - $buffer['xor'] = substr($key, $start) . $buffer['xor']; |
|
1140 | + $buffer['xor'] = substr($key, $start) . $buffer['xor']; |
|
1141 | 1141 | } |
1142 | 1142 | } |
1143 | 1143 | } |
@@ -1332,7 +1332,7 @@ discard block |
||
1332 | 1332 | if ($this->continuousBuffer) { |
1333 | 1333 | $this->decryptIV = $xor; |
1334 | 1334 | if ($start = strlen($ciphertext) % 8) { |
1335 | - $buffer['xor'] = substr($key, $start) . $buffer['xor']; |
|
1335 | + $buffer['xor'] = substr($key, $start) . $buffer['xor']; |
|
1336 | 1336 | } |
1337 | 1337 | } |
1338 | 1338 | } |
@@ -1518,13 +1518,13 @@ discard block |
||
1518 | 1518 | $t = unpack('Nl/Nr', $block); |
1519 | 1519 | list($l, $r) = array($t['l'], $t['r']); |
1520 | 1520 | $block = ($shuffle[$ipmap[$r & 0xFF]] & "\x80\x80\x80\x80\x80\x80\x80\x80") | |
1521 | - ($shuffle[$ipmap[($r >> 8) & 0xFF]] & "\x40\x40\x40\x40\x40\x40\x40\x40") | |
|
1522 | - ($shuffle[$ipmap[($r >> 16) & 0xFF]] & "\x20\x20\x20\x20\x20\x20\x20\x20") | |
|
1523 | - ($shuffle[$ipmap[($r >> 24) & 0xFF]] & "\x10\x10\x10\x10\x10\x10\x10\x10") | |
|
1524 | - ($shuffle[$ipmap[$l & 0xFF]] & "\x08\x08\x08\x08\x08\x08\x08\x08") | |
|
1525 | - ($shuffle[$ipmap[($l >> 8) & 0xFF]] & "\x04\x04\x04\x04\x04\x04\x04\x04") | |
|
1526 | - ($shuffle[$ipmap[($l >> 16) & 0xFF]] & "\x02\x02\x02\x02\x02\x02\x02\x02") | |
|
1527 | - ($shuffle[$ipmap[($l >> 24) & 0xFF]] & "\x01\x01\x01\x01\x01\x01\x01\x01"); |
|
1521 | + ($shuffle[$ipmap[($r >> 8) & 0xFF]] & "\x40\x40\x40\x40\x40\x40\x40\x40") | |
|
1522 | + ($shuffle[$ipmap[($r >> 16) & 0xFF]] & "\x20\x20\x20\x20\x20\x20\x20\x20") | |
|
1523 | + ($shuffle[$ipmap[($r >> 24) & 0xFF]] & "\x10\x10\x10\x10\x10\x10\x10\x10") | |
|
1524 | + ($shuffle[$ipmap[$l & 0xFF]] & "\x08\x08\x08\x08\x08\x08\x08\x08") | |
|
1525 | + ($shuffle[$ipmap[($l >> 8) & 0xFF]] & "\x04\x04\x04\x04\x04\x04\x04\x04") | |
|
1526 | + ($shuffle[$ipmap[($l >> 16) & 0xFF]] & "\x02\x02\x02\x02\x02\x02\x02\x02") | |
|
1527 | + ($shuffle[$ipmap[($l >> 24) & 0xFF]] & "\x01\x01\x01\x01\x01\x01\x01\x01"); |
|
1528 | 1528 | |
1529 | 1529 | // Extract L0 and R0. |
1530 | 1530 | $t = unpack('Nl/Nr', $block); |
@@ -1540,9 +1540,9 @@ discard block |
||
1540 | 1540 | |
1541 | 1541 | // S-box indexing. |
1542 | 1542 | $t = $sbox1[($b1 >> 24) & 0x3F] ^ $sbox2[($b2 >> 24) & 0x3F] ^ |
1543 | - $sbox3[($b1 >> 16) & 0x3F] ^ $sbox4[($b2 >> 16) & 0x3F] ^ |
|
1544 | - $sbox5[($b1 >> 8) & 0x3F] ^ $sbox6[($b2 >> 8) & 0x3F] ^ |
|
1545 | - $sbox7[$b1 & 0x3F] ^ $sbox8[$b2 & 0x3F] ^ $l; |
|
1543 | + $sbox3[($b1 >> 16) & 0x3F] ^ $sbox4[($b2 >> 16) & 0x3F] ^ |
|
1544 | + $sbox5[($b1 >> 8) & 0x3F] ^ $sbox6[($b2 >> 8) & 0x3F] ^ |
|
1545 | + $sbox7[$b1 & 0x3F] ^ $sbox8[$b2 & 0x3F] ^ $l; |
|
1546 | 1546 | // end of "the Feistel (F) function" |
1547 | 1547 | |
1548 | 1548 | $l = $r; |
@@ -1551,13 +1551,13 @@ discard block |
||
1551 | 1551 | |
1552 | 1552 | // Perform the inverse IP permutation. |
1553 | 1553 | return ($shuffle[$invipmap[($l >> 24) & 0xFF]] & "\x80\x80\x80\x80\x80\x80\x80\x80") | |
1554 | - ($shuffle[$invipmap[($r >> 24) & 0xFF]] & "\x40\x40\x40\x40\x40\x40\x40\x40") | |
|
1555 | - ($shuffle[$invipmap[($l >> 16) & 0xFF]] & "\x20\x20\x20\x20\x20\x20\x20\x20") | |
|
1556 | - ($shuffle[$invipmap[($r >> 16) & 0xFF]] & "\x10\x10\x10\x10\x10\x10\x10\x10") | |
|
1557 | - ($shuffle[$invipmap[($l >> 8) & 0xFF]] & "\x08\x08\x08\x08\x08\x08\x08\x08") | |
|
1558 | - ($shuffle[$invipmap[($r >> 8) & 0xFF]] & "\x04\x04\x04\x04\x04\x04\x04\x04") | |
|
1559 | - ($shuffle[$invipmap[$l & 0xFF]] & "\x02\x02\x02\x02\x02\x02\x02\x02") | |
|
1560 | - ($shuffle[$invipmap[$r & 0xFF]] & "\x01\x01\x01\x01\x01\x01\x01\x01"); |
|
1554 | + ($shuffle[$invipmap[($r >> 24) & 0xFF]] & "\x40\x40\x40\x40\x40\x40\x40\x40") | |
|
1555 | + ($shuffle[$invipmap[($l >> 16) & 0xFF]] & "\x20\x20\x20\x20\x20\x20\x20\x20") | |
|
1556 | + ($shuffle[$invipmap[($r >> 16) & 0xFF]] & "\x10\x10\x10\x10\x10\x10\x10\x10") | |
|
1557 | + ($shuffle[$invipmap[($l >> 8) & 0xFF]] & "\x08\x08\x08\x08\x08\x08\x08\x08") | |
|
1558 | + ($shuffle[$invipmap[($r >> 8) & 0xFF]] & "\x04\x04\x04\x04\x04\x04\x04\x04") | |
|
1559 | + ($shuffle[$invipmap[$l & 0xFF]] & "\x02\x02\x02\x02\x02\x02\x02\x02") | |
|
1560 | + ($shuffle[$invipmap[$r & 0xFF]] & "\x01\x01\x01\x01\x01\x01\x01\x01"); |
|
1561 | 1561 | } |
1562 | 1562 | |
1563 | 1563 | /** |
@@ -2025,13 +2025,13 @@ discard block |
||
2025 | 2025 | $t = unpack('Nl/Nr', $key); |
2026 | 2026 | list($l, $r) = array($t['l'], $t['r']); |
2027 | 2027 | $key = ($this->shuffle[$pc1map[$r & 0xFF]] & "\x80\x80\x80\x80\x80\x80\x80\x00") | |
2028 | - ($this->shuffle[$pc1map[($r >> 8) & 0xFF]] & "\x40\x40\x40\x40\x40\x40\x40\x00") | |
|
2029 | - ($this->shuffle[$pc1map[($r >> 16) & 0xFF]] & "\x20\x20\x20\x20\x20\x20\x20\x00") | |
|
2030 | - ($this->shuffle[$pc1map[($r >> 24) & 0xFF]] & "\x10\x10\x10\x10\x10\x10\x10\x00") | |
|
2031 | - ($this->shuffle[$pc1map[$l & 0xFF]] & "\x08\x08\x08\x08\x08\x08\x08\x00") | |
|
2032 | - ($this->shuffle[$pc1map[($l >> 8) & 0xFF]] & "\x04\x04\x04\x04\x04\x04\x04\x00") | |
|
2033 | - ($this->shuffle[$pc1map[($l >> 16) & 0xFF]] & "\x02\x02\x02\x02\x02\x02\x02\x00") | |
|
2034 | - ($this->shuffle[$pc1map[($l >> 24) & 0xFF]] & "\x01\x01\x01\x01\x01\x01\x01\x00"); |
|
2028 | + ($this->shuffle[$pc1map[($r >> 8) & 0xFF]] & "\x40\x40\x40\x40\x40\x40\x40\x00") | |
|
2029 | + ($this->shuffle[$pc1map[($r >> 16) & 0xFF]] & "\x20\x20\x20\x20\x20\x20\x20\x00") | |
|
2030 | + ($this->shuffle[$pc1map[($r >> 24) & 0xFF]] & "\x10\x10\x10\x10\x10\x10\x10\x00") | |
|
2031 | + ($this->shuffle[$pc1map[$l & 0xFF]] & "\x08\x08\x08\x08\x08\x08\x08\x00") | |
|
2032 | + ($this->shuffle[$pc1map[($l >> 8) & 0xFF]] & "\x04\x04\x04\x04\x04\x04\x04\x00") | |
|
2033 | + ($this->shuffle[$pc1map[($l >> 16) & 0xFF]] & "\x02\x02\x02\x02\x02\x02\x02\x00") | |
|
2034 | + ($this->shuffle[$pc1map[($l >> 24) & 0xFF]] & "\x01\x01\x01\x01\x01\x01\x01\x00"); |
|
2035 | 2035 | $key = unpack('Nc/Nd', $key); |
2036 | 2036 | $c = ($key['c'] >> 4) & 0x0FFFFFFF; |
2037 | 2037 | $d = (($key['d'] >> 4) & 0x0FFFFFF0) | ($key['c'] & 0x0F); |
@@ -2045,9 +2045,9 @@ discard block |
||
2045 | 2045 | |
2046 | 2046 | // Perform the PC-2 transformation. |
2047 | 2047 | $cp = $pc2mapc1[$c >> 24] | $pc2mapc2[($c >> 16) & 0xFF] | |
2048 | - $pc2mapc3[($c >> 8) & 0xFF] | $pc2mapc4[$c & 0xFF]; |
|
2048 | + $pc2mapc3[($c >> 8) & 0xFF] | $pc2mapc4[$c & 0xFF]; |
|
2049 | 2049 | $dp = $pc2mapd1[$d >> 24] | $pc2mapd2[($d >> 16) & 0xFF] | |
2050 | - $pc2mapd3[($d >> 8) & 0xFF] | $pc2mapd4[$d & 0xFF]; |
|
2050 | + $pc2mapd3[($d >> 8) & 0xFF] | $pc2mapd4[$d & 0xFF]; |
|
2051 | 2051 | |
2052 | 2052 | // Reorder: odd bytes/even bytes. Push the result in key schedule. |
2053 | 2053 | $keys[] = array( |
@@ -703,15 +703,15 @@ discard block |
||
703 | 703 | return false; |
704 | 704 | } |
705 | 705 | return "<RSAKeyValue>\r\n" . |
706 | - ' <Modulus>' . base64_encode($raw['modulus']) . "</Modulus>\r\n" . |
|
707 | - ' <Exponent>' . base64_encode($raw['publicExponent']) . "</Exponent>\r\n" . |
|
708 | - ' <P>' . base64_encode($raw['prime1']) . "</P>\r\n" . |
|
709 | - ' <Q>' . base64_encode($raw['prime2']) . "</Q>\r\n" . |
|
710 | - ' <DP>' . base64_encode($raw['exponent1']) . "</DP>\r\n" . |
|
711 | - ' <DQ>' . base64_encode($raw['exponent2']) . "</DQ>\r\n" . |
|
712 | - ' <InverseQ>' . base64_encode($raw['coefficient']) . "</InverseQ>\r\n" . |
|
713 | - ' <D>' . base64_encode($raw['privateExponent']) . "</D>\r\n" . |
|
714 | - '</RSAKeyValue>'; |
|
706 | + ' <Modulus>' . base64_encode($raw['modulus']) . "</Modulus>\r\n" . |
|
707 | + ' <Exponent>' . base64_encode($raw['publicExponent']) . "</Exponent>\r\n" . |
|
708 | + ' <P>' . base64_encode($raw['prime1']) . "</P>\r\n" . |
|
709 | + ' <Q>' . base64_encode($raw['prime2']) . "</Q>\r\n" . |
|
710 | + ' <DP>' . base64_encode($raw['exponent1']) . "</DP>\r\n" . |
|
711 | + ' <DQ>' . base64_encode($raw['exponent2']) . "</DQ>\r\n" . |
|
712 | + ' <InverseQ>' . base64_encode($raw['coefficient']) . "</InverseQ>\r\n" . |
|
713 | + ' <D>' . base64_encode($raw['privateExponent']) . "</D>\r\n" . |
|
714 | + '</RSAKeyValue>'; |
|
715 | 715 | break; |
716 | 716 | case CRYPT_RSA_PRIVATE_FORMAT_PUTTY: |
717 | 717 | if ($num_primes != 2) { |
@@ -725,8 +725,8 @@ discard block |
||
725 | 725 | strlen('ssh-rsa'), 'ssh-rsa', strlen($raw['publicExponent']), $raw['publicExponent'], strlen($raw['modulus']), $raw['modulus'] |
726 | 726 | ); |
727 | 727 | $source = pack('Na*Na*Na*Na*', |
728 | - strlen('ssh-rsa'), 'ssh-rsa', strlen($encryption), $encryption, |
|
729 | - strlen($this->comment), $this->comment, strlen($public), $public |
|
728 | + strlen('ssh-rsa'), 'ssh-rsa', strlen($encryption), $encryption, |
|
729 | + strlen($this->comment), $this->comment, strlen($public), $public |
|
730 | 730 | ); |
731 | 731 | $public = base64_encode($public); |
732 | 732 | $key.= "Public-Lines: " . ((strlen($public) + 32) >> 6) . "\r\n"; |
@@ -810,15 +810,15 @@ discard block |
||
810 | 810 | $des->setIV($iv); |
811 | 811 | $iv = strtoupper(bin2hex($iv)); |
812 | 812 | $RSAPrivateKey = "-----BEGIN RSA PRIVATE KEY-----\r\n" . |
813 | - "Proc-Type: 4,ENCRYPTED\r\n" . |
|
814 | - "DEK-Info: DES-EDE3-CBC,$iv\r\n" . |
|
815 | - "\r\n" . |
|
816 | - chunk_split(base64_encode($des->encrypt($RSAPrivateKey)), 64) . |
|
817 | - '-----END RSA PRIVATE KEY-----'; |
|
813 | + "Proc-Type: 4,ENCRYPTED\r\n" . |
|
814 | + "DEK-Info: DES-EDE3-CBC,$iv\r\n" . |
|
815 | + "\r\n" . |
|
816 | + chunk_split(base64_encode($des->encrypt($RSAPrivateKey)), 64) . |
|
817 | + '-----END RSA PRIVATE KEY-----'; |
|
818 | 818 | } else { |
819 | 819 | $RSAPrivateKey = "-----BEGIN RSA PRIVATE KEY-----\r\n" . |
820 | - chunk_split(base64_encode($RSAPrivateKey), 64) . |
|
821 | - '-----END RSA PRIVATE KEY-----'; |
|
820 | + chunk_split(base64_encode($RSAPrivateKey), 64) . |
|
821 | + '-----END RSA PRIVATE KEY-----'; |
|
822 | 822 | } |
823 | 823 | |
824 | 824 | return $RSAPrivateKey; |
@@ -843,9 +843,9 @@ discard block |
||
843 | 843 | return array('e' => $e->copy(), 'n' => $n->copy()); |
844 | 844 | case CRYPT_RSA_PUBLIC_FORMAT_XML: |
845 | 845 | return "<RSAKeyValue>\r\n" . |
846 | - ' <Modulus>' . base64_encode($modulus) . "</Modulus>\r\n" . |
|
847 | - ' <Exponent>' . base64_encode($publicExponent) . "</Exponent>\r\n" . |
|
848 | - '</RSAKeyValue>'; |
|
846 | + ' <Modulus>' . base64_encode($modulus) . "</Modulus>\r\n" . |
|
847 | + ' <Exponent>' . base64_encode($publicExponent) . "</Exponent>\r\n" . |
|
848 | + '</RSAKeyValue>'; |
|
849 | 849 | break; |
850 | 850 | case CRYPT_RSA_PUBLIC_FORMAT_OPENSSH: |
851 | 851 | // from <http://tools.ietf.org/html/rfc4253#page-15>: |
@@ -884,8 +884,8 @@ discard block |
||
884 | 884 | } |
885 | 885 | |
886 | 886 | $RSAPublicKey = "-----BEGIN PUBLIC KEY-----\r\n" . |
887 | - chunk_split(base64_encode($RSAPublicKey), 64) . |
|
888 | - '-----END PUBLIC KEY-----'; |
|
887 | + chunk_split(base64_encode($RSAPublicKey), 64) . |
|
888 | + '-----END PUBLIC KEY-----'; |
|
889 | 889 | |
890 | 890 | return $RSAPublicKey; |
891 | 891 | } |