Completed
Push — 1.10.x ( 22fbaf...dc201d )
by
unknown
105:12 queued 60:06
created
main/document/create_audio.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -63,35 +63,35 @@  discard block
 block discarded – undo
63 63
 }
64 64
 
65 65
 if ($dir[0] != '/') {
66
-    $dir = '/' . $dir;
66
+    $dir = '/'.$dir;
67 67
 }
68 68
 
69 69
 if ($dir[strlen($dir) - 1] != '/') {
70 70
     $dir .= '/';
71 71
 }
72 72
 
73
-$filepath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document' . $dir;
73
+$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir;
74 74
 
75 75
 if (!is_dir($filepath)) {
76
-    $filepath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document/';
76
+    $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
77 77
     $dir = '/';
78 78
 }
79 79
 
80 80
 //groups //TODO: clean
81 81
 if (!empty($groupId)) {
82 82
     $interbreadcrumb[] = array(
83
-        "url" => "../group/group_space.php?" . api_get_cidreq(),
83
+        "url" => "../group/group_space.php?".api_get_cidreq(),
84 84
         "name" => get_lang('GroupSpace')
85 85
     );
86 86
     $group = GroupManager:: get_group_properties($groupId);
87 87
     $path = explode('/', $dir);
88
-    if ('/' . $path[1] != $group['directory']) {
88
+    if ('/'.$path[1] != $group['directory']) {
89 89
         api_not_allowed(true);
90 90
     }
91 91
 }
92 92
 
93 93
 $interbreadcrumb[] = array(
94
-    "url" => "./document.php?curdirpath=" . urlencode($dir) . "&" . api_get_cidreq(),
94
+    "url" => "./document.php?curdirpath=".urlencode($dir)."&".api_get_cidreq(),
95 95
     "name" => get_lang('Documents')
96 96
 );
97 97
 
@@ -128,11 +128,11 @@  discard block
 block discarded – undo
128 128
 
129 129
 $dir_acum = '';
130 130
 for ($i = 0; $i < $array_len; $i++) {
131
-    $url_dir = 'document.php?&curdirpath=' . $dir_acum . $dir_array[$i];
131
+    $url_dir = 'document.php?&curdirpath='.$dir_acum.$dir_array[$i];
132 132
     //Max char 80
133 133
     $url_to_who = cut($dir_array[$i], 80);
134 134
     $interbreadcrumb[] = array('url' => $url_dir, 'name' => $url_to_who);
135
-    $dir_acum .= $dir_array[$i] . '/';
135
+    $dir_acum .= $dir_array[$i].'/';
136 136
 }
137 137
 
138 138
 $service = isset($_GET['service']) ? $_GET['service'] : 'pediaphon';
@@ -140,15 +140,15 @@  discard block
 block discarded – undo
140 140
 Display:: display_header($nameTools, 'Doc');
141 141
 
142 142
 echo '<div class="actions">';
143
-echo '<a href="document.php?id=' . $document_id . '">' .
144
-    Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('DocumentsOverview'), '',
145
-        ICON_SIZE_MEDIUM) . '</a>';
143
+echo '<a href="document.php?id='.$document_id.'">'.
144
+    Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), '',
145
+        ICON_SIZE_MEDIUM).'</a>';
146 146
 
147
-echo '<a href="create_audio.php?' . api_get_cidreq() . '&id=' . $document_id . '&service=pediaphon">' .
148
-    Display::return_icon('pediaphon.png', get_lang('Pediaphon'), '', ICON_SIZE_MEDIUM) . '</a>';
147
+echo '<a href="create_audio.php?'.api_get_cidreq().'&id='.$document_id.'&service=pediaphon">'.
148
+    Display::return_icon('pediaphon.png', get_lang('Pediaphon'), '', ICON_SIZE_MEDIUM).'</a>';
149 149
 
150
-echo '<a href="create_audio.php?' . api_get_cidreq() . '&id=' . $document_id . '&service=google">' .
151
-    Display::return_icon('google.png', get_lang('GoogleAudio'), '', ICON_SIZE_MEDIUM) . '</a>';
150
+echo '<a href="create_audio.php?'.api_get_cidreq().'&id='.$document_id.'&service=google">'.
151
+    Display::return_icon('google.png', get_lang('GoogleAudio'), '', ICON_SIZE_MEDIUM).'</a>';
152 152
 echo '</div>';
153 153
 ?>
154 154
     <!-- javascript and styles for textareaCounter-->
@@ -213,14 +213,14 @@  discard block
 block discarded – undo
213 213
 $selected_language = null;
214 214
 
215 215
 while ($row = Database::fetch_array($result_select)) {
216
-    $options[$row['isocode']] = $row['original_name'] . ' (' . $row['english_name'] . ')';
216
+    $options[$row['isocode']] = $row['original_name'].' ('.$row['english_name'].')';
217 217
     if (in_array($row['isocode'], array('de', 'en', 'es', 'fr'))) {
218
-        $options_pedia[$row['isocode']] = $row['original_name'] . ' (' . $row['english_name'] . ')';
218
+        $options_pedia[$row['isocode']] = $row['original_name'].' ('.$row['english_name'].')';
219 219
     }
220 220
 }
221 221
 
222 222
 if ($service == 'google') {
223
-    $selected_language = api_get_language_isocode();//lang default is the course language
223
+    $selected_language = api_get_language_isocode(); //lang default is the course language
224 224
 
225 225
     $form = new FormValidator('form1', 'post', api_get_self().'?'.api_get_cidreq(), '', array('id' => 'form1'));
226 226
     $form->addHeader(get_lang('HelpText2Audio'));
@@ -272,16 +272,16 @@  discard block
 block discarded – undo
272 272
         var voices = new Array()
273 273
 
274 274
         <!--German -->
275
-        voices['de'] = ["<?php echo get_lang('Female') . ' (de1)'; ?>|de1", "<?php echo get_lang('Male') . ' (de2)'; ?>|de2", "<?php echo get_lang('Female') . ' (de3)'; ?>|de3", "<?php echo get_lang('Male') . ' (de4)'; ?>|de4", "<?php echo get_lang('Female') . ' (de5)'; ?>|de5", "<?php echo get_lang('Male') . ' (de6)'; ?>|de6", "<?php echo get_lang('Female') . ' (de7)'; ?>|de7", "<?php echo get_lang('Female') . ' (de8 HQ)'; ?>|de8"]
275
+        voices['de'] = ["<?php echo get_lang('Female').' (de1)'; ?>|de1", "<?php echo get_lang('Male').' (de2)'; ?>|de2", "<?php echo get_lang('Female').' (de3)'; ?>|de3", "<?php echo get_lang('Male').' (de4)'; ?>|de4", "<?php echo get_lang('Female').' (de5)'; ?>|de5", "<?php echo get_lang('Male').' (de6)'; ?>|de6", "<?php echo get_lang('Female').' (de7)'; ?>|de7", "<?php echo get_lang('Female').' (de8 HQ)'; ?>|de8"]
276 276
 
277 277
         <!--English -->
278
-        voices['en'] = ["<?php echo get_lang('Male') . ' (en1)'; ?>|en1", "<?php echo get_lang('Male') . ' (en2 HQ)'; ?>|en2", "<?php echo get_lang('Female') . ' (us1)'; ?>|us1", "<?php echo get_lang('Male') . ' (us2)'; ?>|us2", "<?php echo get_lang('Male') . ' (us3)'; ?>|us3", "<?php echo get_lang('Female') . '(us4 HQ)'; ?>|us4"]
278
+        voices['en'] = ["<?php echo get_lang('Male').' (en1)'; ?>|en1", "<?php echo get_lang('Male').' (en2 HQ)'; ?>|en2", "<?php echo get_lang('Female').' (us1)'; ?>|us1", "<?php echo get_lang('Male').' (us2)'; ?>|us2", "<?php echo get_lang('Male').' (us3)'; ?>|us3", "<?php echo get_lang('Female').'(us4 HQ)'; ?>|us4"]
279 279
 
280 280
         <!--Spanish -->
281
-        voices['es'] = ["<?php echo get_lang('Male') . ' (es5 HQ)'; ?>|es5"]
281
+        voices['es'] = ["<?php echo get_lang('Male').' (es5 HQ)'; ?>|es5"]
282 282
 
283 283
         <!--French -->
284
-        voices['fr'] = ["<?php echo get_lang('Female') . ' (fr8 HQ)'; ?>|fr8"]
284
+        voices['fr'] = ["<?php echo get_lang('Female').' (fr8 HQ)'; ?>|fr8"]
285 285
 
286 286
         $(document).ready(function () {
287 287
             $('.lang').on('change', function () {
@@ -312,11 +312,11 @@  discard block
 block discarded – undo
312 312
  */
313 313
 function downloadMP3_google($filepath, $dir)
314 314
 {
315
-    $location = 'create_audio.php?' . api_get_cidreq() . '&id=' . intval($_POST['id']) . '&service=google';
315
+    $location = 'create_audio.php?'.api_get_cidreq().'&id='.intval($_POST['id']).'&service=google';
316 316
 
317 317
     //security
318 318
     if (!isset($_POST['lang']) && !isset($_POST['text']) && !isset($_POST['title']) && !isset($filepath) && !isset($dir)) {
319
-        echo '<script>window.location.href="' . $location . '"</script>';
319
+        echo '<script>window.location.href="'.$location.'"</script>';
320 320
         return;
321 321
     }
322 322
 
@@ -326,33 +326,33 @@  discard block
 block discarded – undo
326 326
     $clean_title = trim($_POST['title']);
327 327
     $clean_text = trim($_POST['text']);
328 328
     if (empty($clean_title) || empty($clean_text)) {
329
-        echo '<script>window.location.href="' . $location . '"</script>';
329
+        echo '<script>window.location.href="'.$location.'"</script>';
330 330
         
331 331
         return;
332 332
     }
333 333
     $clean_title = Security::remove_XSS($clean_title);
334 334
     $clean_title = Database::escape_string($clean_title);
335
-    $clean_title = str_replace(' ', '_', $clean_title);//compound file names
335
+    $clean_title = str_replace(' ', '_', $clean_title); //compound file names
336 336
 
337 337
     $clean_text = Security::remove_XSS($clean_text);
338 338
     $clean_lang = Security::remove_XSS($_POST['lang']);
339 339
 
340 340
     $extension = 'mp3';
341
-    $audio_filename = $clean_title . '.' . $extension;
341
+    $audio_filename = $clean_title.'.'.$extension;
342 342
     $audio_title = str_replace('_', ' ', $clean_title);
343 343
 
344 344
     //prevent duplicates
345
-    if (file_exists($filepath . '/' . $clean_title . '.' . $extension)) {
345
+    if (file_exists($filepath.'/'.$clean_title.'.'.$extension)) {
346 346
         $i = 1;
347
-        while (file_exists($filepath . '/' . $clean_title . '_' . $i . '.' . $extension)) {
347
+        while (file_exists($filepath.'/'.$clean_title.'_'.$i.'.'.$extension)) {
348 348
             $i++;
349 349
         }
350
-        $audio_filename = $clean_title . '_' . $i . '.' . $extension;
351
-        $audio_title = $clean_title . '_' . $i . '.' . $extension;
350
+        $audio_filename = $clean_title.'_'.$i.'.'.$extension;
351
+        $audio_title = $clean_title.'_'.$i.'.'.$extension;
352 352
         $audio_title = str_replace('_', ' ', $audio_title);
353 353
     }
354 354
 
355
-    $documentPath = $filepath . '/' . $audio_filename;
355
+    $documentPath = $filepath.'/'.$audio_filename;
356 356
 
357 357
     $clean_text = api_replace_dangerous_char($clean_text);
358 358
 
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 
362 362
     $proxySettings = api_get_configuration_value('proxy_settings');
363 363
     $key = api_get_configuration_value('translate_app_google_key');
364
-    $url = "https://www.googleapis.com/language/translate/v2?key=$key&" . $clean_lang . "&target=$clean_lang&q=" . urlencode($clean_text) . "";
364
+    $url = "https://www.googleapis.com/language/translate/v2?key=$key&".$clean_lang."&target=$clean_lang&q=".urlencode($clean_text)."";
365 365
 
366 366
     if (empty($proxySettings)) {
367 367
         $content = file_get_contents($url);
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
     $relativeUrlPath = $dir;
382 382
     $doc_id = add_document(
383 383
         $_course,
384
-        $relativeUrlPath . $audio_filename,
384
+        $relativeUrlPath.$audio_filename,
385 385
         'file',
386 386
         filesize($documentPath),
387 387
         $audio_title
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
     );
401 401
     Display::display_confirmation_message(get_lang('DocumentCreated'));
402 402
     //return to location
403
-    echo '<script>window.location.href="' . $location . '"</script>';
403
+    echo '<script>window.location.href="'.$location.'"</script>';
404 404
 }
405 405
 
406 406
 /**
@@ -413,10 +413,10 @@  discard block
 block discarded – undo
413 413
  */
414 414
 function downloadMP3_pediaphon($filepath, $dir)
415 415
 {
416
-    $location = 'create_audio.php?' . api_get_cidreq() . '&id=' . intval($_POST['id']) . '&service=pediaphon';
416
+    $location = 'create_audio.php?'.api_get_cidreq().'&id='.intval($_POST['id']).'&service=pediaphon';
417 417
     //security
418 418
     if (!isset($_POST['lang']) && !isset($_POST['text']) && !isset($_POST['title']) && !isset($filepath) && !isset($dir)) {
419
-        echo '<script>window.location.href="' . $location . '"</script>';
419
+        echo '<script>window.location.href="'.$location.'"</script>';
420 420
         return;
421 421
     }
422 422
     $_course = api_get_course_info();
@@ -426,33 +426,33 @@  discard block
 block discarded – undo
426 426
     $clean_text = trim($_POST['text']);
427 427
     $clean_voices = Security::remove_XSS($_POST['voices']);
428 428
     if (empty($clean_title) || empty($clean_text) || empty($clean_voices)) {
429
-        echo '<script>window.location.href="' . $location . '"</script>';
429
+        echo '<script>window.location.href="'.$location.'"</script>';
430 430
 
431 431
         return;
432 432
     }
433 433
     $clean_title = Security::remove_XSS($clean_title);
434 434
     $clean_title = Database::escape_string($clean_title);
435
-    $clean_title = str_replace(' ', '_', $clean_title);//compound file names
435
+    $clean_title = str_replace(' ', '_', $clean_title); //compound file names
436 436
     $clean_text = Security::remove_XSS($clean_text);
437 437
     $clean_lang = Security::remove_XSS($_POST['lang']);
438 438
     $clean_speed = Security::remove_XSS($_POST['speed']);
439 439
 
440 440
     $extension = 'mp3';
441
-    $audio_filename = $clean_title . '.' . $extension;
441
+    $audio_filename = $clean_title.'.'.$extension;
442 442
     $audio_title = str_replace('_', ' ', $clean_title);
443 443
 
444 444
     //prevent duplicates
445
-    if (file_exists($filepath . '/' . $clean_title . '.' . $extension)) {
445
+    if (file_exists($filepath.'/'.$clean_title.'.'.$extension)) {
446 446
         $i = 1;
447
-        while (file_exists($filepath . '/' . $clean_title . '_' . $i . '.' . $extension)) {
447
+        while (file_exists($filepath.'/'.$clean_title.'_'.$i.'.'.$extension)) {
448 448
             $i++;
449 449
         }
450
-        $audio_filename = $clean_title . '_' . $i . '.' . $extension;
451
-        $audio_title = $clean_title . '_' . $i . '.' . $extension;
450
+        $audio_filename = $clean_title.'_'.$i.'.'.$extension;
451
+        $audio_title = $clean_title.'_'.$i.'.'.$extension;
452 452
         $audio_title = str_replace('_', ' ', $audio_title);
453 453
     }
454 454
 
455
-    $documentPath = $filepath . '/' . $audio_filename;
455
+    $documentPath = $filepath.'/'.$audio_filename;
456 456
     $clean_text = api_replace_dangerous_char($clean_text);
457 457
 
458 458
     //adding the file
@@ -461,17 +461,17 @@  discard block
 block discarded – undo
461 461
         $url_pediaphon = 'http://www.pediaphon.org/~bischoff/radiopedia/sprich_multivoice.cgi';
462 462
         $find_t2v = '/http\:\/\/www\.pediaphon\.org\/\~bischoff\/radiopedia\/mp3\/(.*)\.mp3\"/';
463 463
     } else {
464
-        $url_pediaphon = 'http://www.pediaphon.org/~bischoff/radiopedia/sprich_multivoice_' . $clean_lang . '.cgi';//en, es, fr
465
-        $find_t2v = '/http\:\/\/www\.pediaphon\.org\/\~bischoff\/radiopedia\/mp3\/' . $clean_lang . '\/(.*)\.mp3\"/';
464
+        $url_pediaphon = 'http://www.pediaphon.org/~bischoff/radiopedia/sprich_multivoice_'.$clean_lang.'.cgi'; //en, es, fr
465
+        $find_t2v = '/http\:\/\/www\.pediaphon\.org\/\~bischoff\/radiopedia\/mp3\/'.$clean_lang.'\/(.*)\.mp3\"/';
466 466
     }
467 467
 
468
-    $data = "stimme=" . $clean_voices . "&inputtext=" . $clean_text . "&speed=" . $clean_speed . "&go=speak";
468
+    $data = "stimme=".$clean_voices."&inputtext=".$clean_text."&speed=".$clean_speed."&go=speak";
469 469
     $opts = array(
470 470
         'http' =>
471 471
             array(
472 472
                 'method' => 'POST',
473 473
                 'header' => "Content-Type: application/x-www-form-urlencoded\r\n",
474
-                "Content-Length: " . strlen($data) . "\r\n",
474
+                "Content-Length: ".strlen($data)."\r\n",
475 475
                 'content' => $data
476 476
             )
477 477
     );
@@ -515,5 +515,5 @@  discard block
 block discarded – undo
515 515
     );
516 516
     Display::display_confirmation_message(get_lang('DocumentCreated'));
517 517
     //return to location
518
-    echo '<script>window.location.href="' . $location . '"</script>';
518
+    echo '<script>window.location.href="'.$location.'"</script>';
519 519
 }
Please login to merge, or discard this patch.
main/inc/lib/api.lib.php 1 patch
Braces   +22 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1835,7 +1835,9 @@  discard block
 block discarded – undo
1835 1835
     }
1836 1836
 
1837 1837
     global $_course;
1838
-    if ($_course == '-1') $_course = array();
1838
+    if ($_course == '-1') {
1839
+        $_course = array();
1840
+    }
1839 1841
     return $_course;
1840 1842
 }
1841 1843
 
@@ -4336,17 +4338,20 @@  discard block
 block discarded – undo
4336 4338
     switch ($lang_type) {
4337 4339
         case 'platform_lang':
4338 4340
             $temp_lang = api_get_setting('platformLanguage');
4339
-            if (!empty($temp_lang))
4340
-                $return = $temp_lang;
4341
+            if (!empty($temp_lang)) {
4342
+                            $return = $temp_lang;
4343
+            }
4341 4344
             break;
4342 4345
         case 'user_profil_lang':
4343 4346
             $_user = api_get_user_info();
4344
-            if (isset($_user['language']) && !empty($_user['language']))
4345
-                $return = $_user['language'];
4347
+            if (isset($_user['language']) && !empty($_user['language'])) {
4348
+                            $return = $_user['language'];
4349
+            }
4346 4350
             break;
4347 4351
         case 'user_selected_lang':
4348
-            if (isset($_SESSION['user_language_choice']) && !empty($_SESSION['user_language_choice']))
4349
-                $return = $_SESSION['user_language_choice'];
4352
+            if (isset($_SESSION['user_language_choice']) && !empty($_SESSION['user_language_choice'])) {
4353
+                            $return = $_SESSION['user_language_choice'];
4354
+            }
4350 4355
             break;
4351 4356
         case 'course_lang':
4352 4357
             global $_course;
@@ -4364,8 +4369,9 @@  discard block
 block discarded – undo
4364 4369
                 }
4365 4370
             }
4366 4371
             $_course = api_get_course_info($cidReq);
4367
-            if (isset($_course['language']) && !empty($_course['language']))
4368
-                $return = $_course['language'];
4372
+            if (isset($_course['language']) && !empty($_course['language'])) {
4373
+                            $return = $_course['language'];
4374
+            }
4369 4375
             break;
4370 4376
         default:
4371 4377
             $return = false;
@@ -5608,8 +5614,7 @@  discard block
 block discarded – undo
5608 5614
             $is_courseAdmin = false;
5609 5615
             $is_courseCoach = true;
5610 5616
             $is_sessionAdmin = false;
5611
-        }
5612
-        elseif ($row[0]['session_admin_id'] == $userid) {
5617
+        } elseif ($row[0]['session_admin_id'] == $userid) {
5613 5618
             $is_courseMember = false;
5614 5619
             $is_courseTutor = false;
5615 5620
             $is_courseAdmin = false;
@@ -5952,8 +5957,7 @@  discard block
 block discarded – undo
5952 5957
     elseif (isset($_ENV['OS'])) {
5953 5958
         // Sometimes $_ENV['OS'] may not be present (bugs?)
5954 5959
         $os = $_ENV['OS'];
5955
-    }
5956
-    elseif (defined('PHP_OS')) {
5960
+    } elseif (defined('PHP_OS')) {
5957 5961
         // PHP_OS means on which OS PHP was compiled, this is why
5958 5962
         // using PHP_OS is the last choice for detection.
5959 5963
         $os = PHP_OS;
@@ -6017,12 +6021,10 @@  discard block
 block discarded – undo
6017 6021
     if ($delta_width > $delta_height) {
6018 6022
         $result['width'] = ceil($image_width * $resize_factor_height);
6019 6023
         $result['height'] = ceil($image_height * $resize_factor_height);
6020
-    }
6021
-    elseif ($delta_width < $delta_height) {
6024
+    } elseif ($delta_width < $delta_height) {
6022 6025
         $result['width'] = ceil($image_width * $resize_factor_width);
6023 6026
         $result['height'] = ceil($image_height * $resize_factor_width);
6024
-    }
6025
-    else {
6027
+    } else {
6026 6028
         $result['width'] = ceil($target_width);
6027 6029
         $result['height'] = ceil($target_height);
6028 6030
     }
@@ -6800,7 +6802,9 @@  discard block
 block discarded – undo
6800 6802
         }
6801 6803
         $ip = trim($ip1);
6802 6804
     }
6803
-    if (!empty($debug)) error_log('Real IP: '.$ip);
6805
+    if (!empty($debug)) {
6806
+        error_log('Real IP: '.$ip);
6807
+    }
6804 6808
     return $ip;
6805 6809
 }
6806 6810
 
Please login to merge, or discard this patch.