@@ -4,8 +4,9 @@ |
||
4 | 4 | require_once dirname(__FILE__).'/../../inc/global.inc.php'; |
5 | 5 | $url = api_get_path(WEB_PATH).'main/auth/conditional_login/complete_phone_number.php'; |
6 | 6 | |
7 | -if (! isset($_SESSION['conditional_login']['uid'])) |
|
7 | +if (! isset($_SESSION['conditional_login']['uid'])) { |
|
8 | 8 | die("Not Authorised"); |
9 | +} |
|
9 | 10 | ?> |
10 | 11 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
11 | 12 | <html lang="fr" xml:lang="fr" xmlns="http://www.w3.org/1999/xhtml"> |
@@ -144,7 +144,10 @@ |
||
144 | 144 | echo '</div>'; |
145 | 145 | ?> |
146 | 146 | |
147 | -<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?id=<?php echo $id; if(!empty($_GET['add'])) echo '&add=true' ; ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>> |
|
147 | +<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?id=<?php echo $id; if(!empty($_GET['add'])) { |
|
148 | + echo '&add=true' ; |
|
149 | +} |
|
150 | +?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>> |
|
148 | 151 | <?php echo '<legend>'.$tool_name.' '.$promotion_data['name'].'</legend>'; |
149 | 152 | |
150 | 153 | if ($add_type=='multiple') { |
@@ -144,7 +144,10 @@ |
||
144 | 144 | echo '</div>'; |
145 | 145 | ?> |
146 | 146 | |
147 | -<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?id=<?php echo $id; if(!empty($_GET['add'])) echo '&add=true' ; ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>> |
|
147 | +<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?id=<?php echo $id; if(!empty($_GET['add'])) { |
|
148 | + echo '&add=true' ; |
|
149 | +} |
|
150 | +?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>> |
|
148 | 151 | <?php echo '<legend>'.$tool_name.' '.$promotion_data['name'].'</legend>'; |
149 | 152 | |
150 | 153 | if ($add_type=='multiple') { |
@@ -119,8 +119,9 @@ |
||
119 | 119 | |
120 | 120 | for ($i = 0; $i<count($matches[0]); $i++) { |
121 | 121 | |
122 | - if (empty($matches[1][$i])) |
|
123 | - continue; |
|
122 | + if (empty($matches[1][$i])) { |
|
123 | + continue; |
|
124 | + } |
|
124 | 125 | |
125 | 126 | $content = api_strstr($content, $matches[0][$i]); |
126 | 127 | if ($i + 1 !== count($matches[0])) { |
@@ -454,7 +454,10 @@ |
||
454 | 454 | <blockquote> |
455 | 455 | <pre> |
456 | 456 | <b>UserName</b>;LastName;FirstName;Email;NewUserName;Password;AuthSource;OfficialCode;PhoneNumber;Status;ExpiryDate;Active;Language;Courses;ClassId; |
457 | - xxx;xxx;xxx;xxx;xxx;xxx;xxx;xxx;xxx;user/teacher/drh;0000-00-00 00:00:00;0/1;xxx;<span style="color:red;"><?php if (count($list_reponse) > 0) echo implode(';', $list_reponse).';'; ?></span>xxx1|xxx2|xxx3;1;<br /> |
|
457 | + xxx;xxx;xxx;xxx;xxx;xxx;xxx;xxx;xxx;user/teacher/drh;0000-00-00 00:00:00;0/1;xxx;<span style="color:red;"><?php if (count($list_reponse) > 0) { |
|
458 | + echo implode(';', $list_reponse).';'; |
|
459 | +} |
|
460 | +?></span>xxx1|xxx2|xxx3;1;<br /> |
|
458 | 461 | </pre> |
459 | 462 | </blockquote> |
460 | 463 | <p><?php |
@@ -434,8 +434,7 @@ |
||
434 | 434 | } else { |
435 | 435 | echo $question->options[2]; |
436 | 436 | } |
437 | - } |
|
438 | - else { |
|
437 | + } else { |
|
439 | 438 | echo '-'; |
440 | 439 | } |
441 | 440 | ?> |
@@ -734,7 +734,9 @@ discard block |
||
734 | 734 | WHERE user_id='$id'"; |
735 | 735 | $result = Database::query($sql); |
736 | 736 | $res = Database::fetch_array($result); |
737 | - if (!$res) return false; |
|
737 | + if (!$res) { |
|
738 | + return false; |
|
739 | + } |
|
738 | 740 | |
739 | 741 | return stripslashes($res['username']); |
740 | 742 | } |
@@ -810,10 +812,15 @@ discard block |
||
810 | 812 | "; |
811 | 813 | $result = Database::query($sql); |
812 | 814 | |
813 | - if (!($res = Database::fetch_array($result))) |
|
814 | - die(get_lang('GeneralError').' (code 901)'); |
|
815 | - if ($owner == 0) return $res['uploader_id']; |
|
816 | - if ($res['uploader_id'] == $owner) return true; |
|
815 | + if (!($res = Database::fetch_array($result))) { |
|
816 | + die(get_lang('GeneralError').' (code 901)'); |
|
817 | + } |
|
818 | + if ($owner == 0) { |
|
819 | + return $res['uploader_id']; |
|
820 | + } |
|
821 | + if ($res['uploader_id'] == $owner) { |
|
822 | + return true; |
|
823 | + } |
|
817 | 824 | die(get_lang('GeneralError').' (code '.$or_die.')'); |
818 | 825 | } |
819 | 826 |
@@ -106,7 +106,9 @@ discard block |
||
106 | 106 | //Check if the user is registered in the session otherwise we will add it |
107 | 107 | $result = SessionManager::get_users_by_session($new_session_id); |
108 | 108 | if (empty($result) || !in_array($user_id, array_keys($result))) { |
109 | - if ($debug) echo 'User added to the session'; |
|
109 | + if ($debug) { |
|
110 | + echo 'User added to the session'; |
|
111 | + } |
|
110 | 112 | //Registering user to the new session |
111 | 113 | SessionManager::suscribe_users_to_session($new_session_id,array($user_id),false); |
112 | 114 | } |
@@ -141,10 +143,11 @@ discard block |
||
141 | 143 | $list[$row['exe_id']]= $row; |
142 | 144 | } |
143 | 145 | |
144 | - if (!empty($list)) |
|
145 | - foreach ($list as $exe_id =>$data) { |
|
146 | + if (!empty($list)) { |
|
147 | + foreach ($list as $exe_id =>$data) { |
|
146 | 148 | if ($update_database) { |
147 | 149 | $sql = "UPDATE $TABLETRACK_EXERCICES SET session_id = '$new_session_id' WHERE exe_id = $exe_id"; |
150 | + } |
|
148 | 151 | $res = Database::query($sql); |
149 | 152 | $result_message[$TABLETRACK_EXERCICES]++; |
150 | 153 | } else { |
@@ -168,10 +171,11 @@ discard block |
||
168 | 171 | $list[$row['exe_id']]= $row; |
169 | 172 | } |
170 | 173 | |
171 | - if (!empty($list)) |
|
172 | - foreach ($list as $exe_id =>$data) { |
|
174 | + if (!empty($list)) { |
|
175 | + foreach ($list as $exe_id =>$data) { |
|
173 | 176 | if ($update_database) { |
174 | 177 | $sql = "UPDATE $TABLETRACK_EXERCICES SET session_id = '$new_session_id' WHERE exe_id = $exe_id"; |
178 | + } |
|
175 | 179 | $res = Database::query($sql); |
176 | 180 | $result_message[$TABLETRACK_EXERCICES]++; |
177 | 181 | } else { |
@@ -196,10 +200,11 @@ discard block |
||
196 | 200 | $list[$row['course_access_id']] = $row; |
197 | 201 | } |
198 | 202 | |
199 | - if (!empty($list)) |
|
200 | - foreach ($list as $id => $data) { |
|
203 | + if (!empty($list)) { |
|
204 | + foreach ($list as $id => $data) { |
|
201 | 205 | if ($update_database) { |
202 | 206 | $sql = "UPDATE $TBL_TRACK_E_COURSE_ACCESS SET session_id = $new_session_id WHERE course_access_id = $id"; |
207 | + } |
|
203 | 208 | if ($debug) { |
204 | 209 | echo $sql; |
205 | 210 | } |
@@ -218,13 +223,18 @@ discard block |
||
218 | 223 | while($row = Database::fetch_array($res,'ASSOC')) { |
219 | 224 | $list[] = $row['access_id']; |
220 | 225 | } |
221 | - if (!empty($list)) |
|
222 | - foreach ($list as $id) { |
|
226 | + if (!empty($list)) { |
|
227 | + foreach ($list as $id) { |
|
223 | 228 | if ($update_database) { |
224 | 229 | $sql = "UPDATE $TBL_TRACK_E_LAST_ACCESS SET access_session_id = $new_session_id WHERE access_id = $id"; |
225 | - if ($debug) echo $sql; |
|
230 | + } |
|
231 | + if ($debug) { |
|
232 | + echo $sql; |
|
233 | + } |
|
226 | 234 | $res = Database::query($sql); |
227 | - if ($debug) var_dump($res); |
|
235 | + if ($debug) { |
|
236 | + var_dump($res); |
|
237 | + } |
|
228 | 238 | $result_message[$TBL_TRACK_E_LAST_ACCESS]++; |
229 | 239 | } |
230 | 240 | } |
@@ -248,13 +258,18 @@ discard block |
||
248 | 258 | } |
249 | 259 | } |
250 | 260 | |
251 | - if (!empty($list)) |
|
252 | - foreach ($list as $id=>$data) { |
|
261 | + if (!empty($list)) { |
|
262 | + foreach ($list as $id=>$data) { |
|
253 | 263 | if ($update_database) { |
254 | 264 | $sql = "UPDATE $TBL_LP_VIEW SET session_id = $new_session_id WHERE c_id = $course_id AND id = $id "; |
255 | - if ($debug) var_dump($sql); |
|
265 | + } |
|
266 | + if ($debug) { |
|
267 | + var_dump($sql); |
|
268 | + } |
|
256 | 269 | $res = Database::query($sql); |
257 | - if ($debug) var_dump($res); |
|
270 | + if ($debug) { |
|
271 | + var_dump($res); |
|
272 | + } |
|
258 | 273 | $result_message[$TBL_LP_VIEW]++; |
259 | 274 | } else { |
260 | 275 | //Getting all information of that lp_item_id |
@@ -281,10 +296,11 @@ discard block |
||
281 | 296 | $list[$row['id']] = $row; |
282 | 297 | } |
283 | 298 | } |
284 | - if (!empty($list)) |
|
285 | - foreach ($list as $id=>$data) { |
|
299 | + if (!empty($list)) { |
|
300 | + foreach ($list as $id=>$data) { |
|
286 | 301 | //Getting all information of that lp_item_id |
287 | 302 | $score = Tracking::get_avg_student_score($user_id, $origin_course_code, array($data['lp_id']), $new_session_id); |
303 | + } |
|
288 | 304 | $progress = Tracking::get_avg_student_progress($user_id, $origin_course_code, array($data['lp_id']), $new_session_id); |
289 | 305 | $result_message_compare['LP_VIEW'][$data['lp_id']] = array('score' => $score, 'progress' =>$progress); |
290 | 306 | } |
@@ -300,9 +316,13 @@ discard block |
||
300 | 316 | $id = $row['ref']; |
301 | 317 | if ($update_database) { |
302 | 318 | $sql = "UPDATE $TBL_AGENDA SET session_id = $new_session_id WHERE c_id = $course_id AND id = $id "; |
303 | - if ($debug) var_dump($sql); |
|
319 | + if ($debug) { |
|
320 | + var_dump($sql); |
|
321 | + } |
|
304 | 322 | $res_update = Database::query($sql); |
305 | - if ($debug) var_dump($res_update); |
|
323 | + if ($debug) { |
|
324 | + var_dump($res_update); |
|
325 | + } |
|
306 | 326 | $result_message['agenda']++; |
307 | 327 | } |
308 | 328 | } |
@@ -314,22 +334,30 @@ discard block |
||
314 | 334 | //echo '<h1>Student publication</h1>'; |
315 | 335 | |
316 | 336 | $sql = "SELECT ref FROM $TBL_ITEM_PROPERTY WHERE tool = 'work' AND insert_user_id = $user_id AND c_id = $course_id"; |
317 | - if ($debug) echo $sql; |
|
337 | + if ($debug) { |
|
338 | + echo $sql; |
|
339 | + } |
|
318 | 340 | $res = Database::query($sql); |
319 | 341 | while($row = Database::fetch_array($res,'ASSOC')) { |
320 | 342 | $id = $row['ref']; |
321 | 343 | $sql = "SELECT * FROM $TBL_STUDENT_PUBLICATION WHERE id = $id AND session_id = $origin_session_id AND c_id = $course_id"; |
322 | - if ($debug) var_dump($sql); |
|
344 | + if ($debug) { |
|
345 | + var_dump($sql); |
|
346 | + } |
|
323 | 347 | $sub_res = Database::query($sql); |
324 | 348 | if (Database::num_rows($sub_res) > 0 ) { |
325 | 349 | $data = Database::fetch_array($sub_res,'ASSOC'); |
326 | - if ($debug) var_dump($data); |
|
350 | + if ($debug) { |
|
351 | + var_dump($data); |
|
352 | + } |
|
327 | 353 | $parent_id = $data['parent_id']; |
328 | 354 | if (isset($data['parent_id']) && !empty($data['parent_id'])) { |
329 | 355 | $sql = "SELECT * FROM $TBL_STUDENT_PUBLICATION WHERE id = $parent_id AND c_id = $course_id"; |
330 | 356 | $select_res = Database::query($sql); |
331 | 357 | $parent_data = Database::fetch_array($select_res,'ASSOC'); |
332 | - if ($debug) var_dump($parent_data); |
|
358 | + if ($debug) { |
|
359 | + var_dump($parent_data); |
|
360 | + } |
|
333 | 361 | |
334 | 362 | $sys_course_path = api_get_path(SYS_COURSE_PATH); |
335 | 363 | $course_dir = $sys_course_path . $course_info['path']; |
@@ -344,7 +372,9 @@ discard block |
||
344 | 372 | $sql = "SELECT * FROM $TBL_STUDENT_PUBLICATION |
345 | 373 | WHERE description like '%$search_this%' AND url LIKE '%$search_this2%' AND session_id = $new_session_id AND c_id = $course_id |
346 | 374 | ORDER BY id desc LIMIT 1"; |
347 | - if ($debug) echo $sql; |
|
375 | + if ($debug) { |
|
376 | + echo $sql; |
|
377 | + } |
|
348 | 378 | $sub_res = Database::query($sql); |
349 | 379 | $num_rows = Database::num_rows($sub_res); |
350 | 380 | |
@@ -377,12 +407,16 @@ discard block |
||
377 | 407 | date_of_qualification = '0000-00-00 00:00:00', |
378 | 408 | session_id = ".$new_session_id; |
379 | 409 | $rest_insert = Database::query($sql_add_publication); |
380 | - if ($debug) echo ($sql_add_publication); |
|
410 | + if ($debug) { |
|
411 | + echo ($sql_add_publication); |
|
412 | + } |
|
381 | 413 | // add the directory |
382 | 414 | $id = Database::insert_id(); |
383 | 415 | //Folder created |
384 | 416 | api_item_property_update($course_info, 'work', $id, 'DirectoryCreated', api_get_user_id()); |
385 | - if ($debug) var_dump($rest_insert); |
|
417 | + if ($debug) { |
|
418 | + var_dump($rest_insert); |
|
419 | + } |
|
386 | 420 | $new_parent_id = $id; |
387 | 421 | $result_message[$TBL_STUDENT_PUBLICATION.' - new folder created called: '.$created_dir]++; |
388 | 422 | } |
@@ -390,7 +424,9 @@ discard block |
||
390 | 424 | |
391 | 425 | //Creating student_publication_assignment if exists |
392 | 426 | $sql = "SELECT * FROM $TBL_STUDENT_PUBLICATION_ASSIGNMENT WHERE publication_id = $parent_id AND c_id = $course_id"; |
393 | - if ($debug) var_dump($sql); |
|
427 | + if ($debug) { |
|
428 | + var_dump($sql); |
|
429 | + } |
|
394 | 430 | $rest_select = Database::query($sql); |
395 | 431 | if (Database::num_rows($rest_select) > 0 ) { |
396 | 432 | if ($update_database) { |
@@ -402,7 +438,9 @@ discard block |
||
402 | 438 | add_to_calendar = '".$assignment_data['add_to_calendar']."', |
403 | 439 | enable_qualification = '".$assignment_data['enable_qualification']."', |
404 | 440 | publication_id = '".$new_parent_id."'"; |
405 | - if ($debug) echo $sql_add_publication; |
|
441 | + if ($debug) { |
|
442 | + echo $sql_add_publication; |
|
443 | + } |
|
406 | 444 | $rest_select = Database::query($sql_add_publication); |
407 | 445 | $id = Database::insert_id(); |
408 | 446 | |
@@ -410,11 +448,15 @@ discard block |
||
410 | 448 | "has_properties = '".$id."', |
411 | 449 | view_properties = '1' |
412 | 450 | WHERE id = ".$new_parent_id; |
413 | - if ($debug) echo $sql_update; |
|
451 | + if ($debug) { |
|
452 | + echo $sql_update; |
|
453 | + } |
|
414 | 454 | $rest_update = Database::query($sql_update); |
415 | 455 | |
416 | 456 | |
417 | - if ($debug) var_dump($sql_update); |
|
457 | + if ($debug) { |
|
458 | + var_dump($sql_update); |
|
459 | + } |
|
418 | 460 | $result_message[$TBL_STUDENT_PUBLICATION_ASSIGNMENT]++; |
419 | 461 | } |
420 | 462 | } |
@@ -437,9 +479,13 @@ discard block |
||
437 | 479 | parent_id = ".$new_parent_id ." , |
438 | 480 | session_id = ".$new_session_id; |
439 | 481 | |
440 | - if ($debug) echo $sql_add_publication; |
|
482 | + if ($debug) { |
|
483 | + echo $sql_add_publication; |
|
484 | + } |
|
441 | 485 | $rest_insert = Database::query($sql_add_publication); |
442 | - if ($debug) var_dump($rest_insert); |
|
486 | + if ($debug) { |
|
487 | + var_dump($rest_insert); |
|
488 | + } |
|
443 | 489 | $id = Database::insert_id(); |
444 | 490 | api_item_property_update($course_info, 'work', $id, 'DocumentAdded', $user_id); |
445 | 491 | $result_message[$TBL_STUDENT_PUBLICATION]++; |
@@ -453,7 +499,9 @@ discard block |
||
453 | 499 | if ($result) { |
454 | 500 | unlink($full_file_name); |
455 | 501 | $sql = "DELETE FROM $TBL_STUDENT_PUBLICATION WHERE id= ".$data['id']; |
456 | - if ($debug) var_dump($sql); |
|
502 | + if ($debug) { |
|
503 | + var_dump($sql); |
|
504 | + } |
|
457 | 505 | $result_delete = Database::query($sql); |
458 | 506 | api_item_property_update($course_info, 'work', $data['id'], 'DocumentDeleted', api_get_user_id()); |
459 | 507 | } |
@@ -469,22 +517,30 @@ discard block |
||
469 | 517 | //10. Dropbox - not neccesary to move categories (no presence of session_id) |
470 | 518 | |
471 | 519 | $sql = "SELECT id FROM $TBL_DROPBOX_FILE WHERE uploader_id = $user_id AND session_id = $origin_session_id AND c_id = $course_id"; |
472 | - if ($debug) var_dump($sql); |
|
520 | + if ($debug) { |
|
521 | + var_dump($sql); |
|
522 | + } |
|
473 | 523 | $res = Database::query($sql); |
474 | 524 | while($row = Database::fetch_array($res,'ASSOC')) { |
475 | 525 | $id = $row['id']; |
476 | 526 | if ($update_database) { |
477 | 527 | $sql = "UPDATE $TBL_DROPBOX_FILE SET session_id = $new_session_id WHERE c_id = $course_id AND id = $id"; |
478 | - if ($debug) var_dump($sql); |
|
528 | + if ($debug) { |
|
529 | + var_dump($sql); |
|
530 | + } |
|
479 | 531 | $res = Database::query($sql); |
480 | - if ($debug) var_dump($res); |
|
532 | + if ($debug) { |
|
533 | + var_dump($res); |
|
534 | + } |
|
481 | 535 | |
482 | 536 | $sql = "UPDATE $TBL_DROPBOX_POST SET session_id = $new_session_id WHERE file_id = $id"; |
483 | - if ($debug) |
|
484 | - var_dump($sql); |
|
537 | + if ($debug) { |
|
538 | + var_dump($sql); |
|
539 | + } |
|
485 | 540 | $res = Database::query($sql); |
486 | - if ($debug) |
|
487 | - var_dump($res); |
|
541 | + if ($debug) { |
|
542 | + var_dump($res); |
|
543 | + } |
|
488 | 544 | $result_message[$TBL_DROPBOX_FILE]++; |
489 | 545 | } |
490 | 546 | } |
@@ -493,23 +549,30 @@ discard block |
||
493 | 549 | |
494 | 550 | $sql = "SELECT notebook_id FROM $TBL_NOTEBOOK |
495 | 551 | WHERE user_id = $user_id AND session_id = $origin_session_id AND course = '$origin_course_code' AND c_id = $course_id"; |
496 | - if ($debug) var_dump($sql); |
|
552 | + if ($debug) { |
|
553 | + var_dump($sql); |
|
554 | + } |
|
497 | 555 | $res = Database::query($sql); |
498 | 556 | while($row = Database::fetch_array($res,'ASSOC')) { |
499 | 557 | $id = $row['notebook_id']; |
500 | 558 | if ($update_database) { |
501 | 559 | $sql = "UPDATE $TBL_NOTEBOOK SET session_id = $new_session_id WHERE c_id = $course_id AND notebook_id = $id"; |
502 | - if ($debug) var_dump($sql); |
|
560 | + if ($debug) { |
|
561 | + var_dump($sql); |
|
562 | + } |
|
503 | 563 | $res = Database::query($sql); |
504 | - if ($debug) var_dump($res); |
|
564 | + if ($debug) { |
|
565 | + var_dump($res); |
|
566 | + } |
|
505 | 567 | } |
506 | 568 | } |
507 | 569 | |
508 | 570 | if ($update_database) { |
509 | 571 | echo '<h2>'.get_lang('StatsMoved').'</h2>'; |
510 | - if (is_array($result_message)) |
|
511 | - foreach ($result_message as $table=>$times) { |
|
572 | + if (is_array($result_message)) { |
|
573 | + foreach ($result_message as $table=>$times) { |
|
512 | 574 | echo 'Table '.$table.' - '.$times.' records updated <br />'; |
575 | + } |
|
513 | 576 | } |
514 | 577 | } else { |
515 | 578 | echo '<h2>'.get_lang('UserInformationOfThisCourse').'</h2>'; |
@@ -626,10 +689,11 @@ discard block |
||
626 | 689 | } |
627 | 690 | $navigation .= ' '; |
628 | 691 | $page ++; |
629 | -if ($page < $nro_pages) |
|
692 | +if ($page < $nro_pages) { |
|
630 | 693 | $navigation .= '<a href="'.api_get_self().'?page='.$page.'">'.get_lang('Next').'</a>'; |
631 | -else |
|
694 | +} else { |
|
632 | 695 | $navigation .= get_lang('Next'); |
696 | +} |
|
633 | 697 | |
634 | 698 | echo $navigation; |
635 | 699 | $user_list = UserManager::get_user_list(array(), array(), $begin, $default); |
@@ -65,8 +65,10 @@ discard block |
||
65 | 65 | $bords = array_fill(0, $bord_lenght, array()); // building this array |
66 | 66 | |
67 | 67 | /* adding the first point of the polygone */ |
68 | - if (is_array($bords[$poly[0]['y']])) //avoid warning |
|
68 | + if (is_array($bords[$poly[0]['y']])) { |
|
69 | + //avoid warning |
|
69 | 70 | array_push($bords[$poly[0]['y']], $poly[0]['x']); |
71 | + } |
|
70 | 72 | |
71 | 73 | $i = 1; // we re-use $i and $old_pente bellow the loop |
72 | 74 | $old_pente=0; |
@@ -75,11 +77,14 @@ discard block |
||
75 | 77 | |
76 | 78 | /* special cases */ |
77 | 79 | if ($poly[$i-1]['y'] == $poly[$i]['y']) { |
78 | - if ($poly[$i-1]['x'] == $poly[$i]['x']) |
|
79 | - continue; // twice the same point |
|
80 | + if ($poly[$i-1]['x'] == $poly[$i]['x']) { |
|
81 | + continue; |
|
82 | + } |
|
83 | + // twice the same point |
|
80 | 84 | else { // infinite elevation of the edge |
81 | - if (is_array($bords[$poly[$i]['y']])) |
|
82 | - array_push($bords[$poly[$i]['y']],$poly[$i]['x']); |
|
85 | + if (is_array($bords[$poly[$i]['y']])) { |
|
86 | + array_push($bords[$poly[$i]['y']],$poly[$i]['x']); |
|
87 | + } |
|
83 | 88 | $old_pente=0; |
84 | 89 | continue; |
85 | 90 | } |
@@ -87,9 +92,13 @@ discard block |
||
87 | 92 | |
88 | 93 | //echo 'point:'.$poly[$i]['y']; bug here |
89 | 94 | // adding the point as a part of an edge |
90 | - if (is_array($bords[$poly[$i]['y']])) //avoid warning |
|
95 | + if (is_array($bords[$poly[$i]['y']])) { |
|
96 | + //avoid warning |
|
91 | 97 | array_push($bords[$poly[$i]['y']], $poly[$i]['x']); |
92 | - if (DEBUG) echo '('.$poly[$i]['x'].';'.$poly[$i]['y'].') '; |
|
98 | + } |
|
99 | + if (DEBUG) { |
|
100 | + echo '('.$poly[$i]['x'].';'.$poly[$i]['y'].') '; |
|
101 | + } |
|
93 | 102 | |
94 | 103 | /* computing the elevation of the edge going */ |
95 | 104 | // from $poly[$i-1] to $poly[$i] |
@@ -99,15 +108,17 @@ discard block |
||
99 | 108 | // if the sign of the elevation change from the one of the |
100 | 109 | // previous edge, the point must be added a second time inside |
101 | 110 | // $bords |
102 | - if ($i>1) |
|
103 | - if (($old_pente<0 && $pente>0) |
|
111 | + if ($i>1) { |
|
112 | + if (($old_pente<0 && $pente>0) |
|
104 | 113 | || ($old_pente>0 && $pente<0)) { |
105 | 114 | if (is_array($bords[$poly[$i]['y']])) //avoid warning |
106 | 115 | array_push($bords[$poly[$i]['y']],$poly[$i]['x']); |
116 | + } |
|
107 | 117 | |
108 | - if (DEBUG) |
|
109 | - echo '*('.$poly[$i]['x']. |
|
118 | + if (DEBUG) { |
|
119 | + echo '*('.$poly[$i]['x']. |
|
110 | 120 | ';'.$poly[$i]['y'].') '; |
121 | + } |
|
111 | 122 | } |
112 | 123 | |
113 | 124 | /* detect the direction of the elevation in Y */ |
@@ -136,10 +147,11 @@ discard block |
||
136 | 147 | |
137 | 148 | // elevation between $poly[0]['x'] and $poly[1]['x']) |
138 | 149 | $rest = $poly[0]['y']-$poly[1]['y']; |
139 | - if ($rest!=0) |
|
140 | - $pente1 = ($poly[0]['x']-$poly[1]['x'])/($rest); |
|
141 | - else |
|
142 | - $pente1 = 0; |
|
150 | + if ($rest!=0) { |
|
151 | + $pente1 = ($poly[0]['x']-$poly[1]['x'])/($rest); |
|
152 | + } else { |
|
153 | + $pente1 = 0; |
|
154 | + } |
|
143 | 155 | |
144 | 156 | // elevation between $poly[$i-1]['x'] and $poly[0]['x']) |
145 | 157 | $pente = ($poly[$i-1]['x']-$poly[0]['x'])/ |
@@ -151,14 +163,17 @@ discard block |
||
151 | 163 | |
152 | 164 | // doubling the first point if needed (see above) |
153 | 165 | if (($pente1<0 && $pente>0) || ($pente1>0 && $pente<0)) { |
154 | - if (is_array($bords[$poly[$i - 1]['y']])) |
|
155 | - array_push($bords[$poly[$i - 1]['y']], round($poly[$i - 1]['x'])); |
|
166 | + if (is_array($bords[$poly[$i - 1]['y']])) { |
|
167 | + array_push($bords[$poly[$i - 1]['y']], round($poly[$i - 1]['x'])); |
|
168 | + } |
|
156 | 169 | //if (DEBUG) echo '('.$poly[$i-1]['x'].';'.$poly[$i-1]['y'].') '; |
157 | 170 | } |
158 | 171 | // doubling the last point if neededd |
159 | 172 | if (($old_pente<0 && $pente>0) || ($old_pente>0 && $pente<0)) { |
160 | - if (is_array($bords[$poly[$i-1]['y']])) //avoid warning |
|
173 | + if (is_array($bords[$poly[$i-1]['y']])) { |
|
174 | + //avoid warning |
|
161 | 175 | array_push($bords[$poly[$i-1]['y']], round($poly[$i-1]['x'])); |
176 | + } |
|
162 | 177 | //if (DEBUG) echo '*('.$poly[$i-1]['x'].';'.$poly[$i-1]['y'].') '; |
163 | 178 | } |
164 | 179 | |
@@ -227,11 +242,13 @@ discard block |
||
227 | 242 | $s = "<div style='font-size: 8px; line-height:3px'><pre>\n"; |
228 | 243 | } |
229 | 244 | for ($i=0; $i<$max['y']; $i++) { |
230 | - for($j=0; $j<$max['x']; $j++) |
|
231 | - if($poly[$j][$i] == TRUE) |
|
245 | + for($j=0; $j<$max['x']; $j++) { |
|
246 | + if($poly[$j][$i] == TRUE) |
|
232 | 247 | $s .= ($format=='html'?"<b>1</b>":'1'); |
233 | - else |
|
234 | - $s .= "0"; |
|
248 | + } |
|
249 | + else { |
|
250 | + $s .= "0"; |
|
251 | + } |
|
235 | 252 | $s .= ($format=='html'?"<br />\n":"\n"); |
236 | 253 | } |
237 | 254 | $s .= ($format=='html'?"</pre></div>\n":"\n"); |
@@ -252,15 +269,19 @@ discard block |
||
252 | 269 | $surfaceOf1 = 0; |
253 | 270 | $surfaceOf2 = 0; |
254 | 271 | |
255 | - for ($i=0; $i<$max['x']; $i++) |
|
256 | - for($j=0; $j<$max['y']; $j++) { |
|
272 | + for ($i=0; $i<$max['x']; $i++) { |
|
273 | + for($j=0; |
|
274 | + } |
|
275 | + $j<$max['y']; $j++) { |
|
257 | 276 | if (isset($poly1[$i][$j]) && ($poly1[$i][$j] == TRUE)) { |
258 | 277 | $surfaceOf1++; |
259 | - if (isset($poly2[$i][$j]) && ($poly2[$i][$j] == FALSE)) |
|
260 | - $onlyIn1++; |
|
278 | + if (isset($poly2[$i][$j]) && ($poly2[$i][$j] == FALSE)) { |
|
279 | + $onlyIn1++; |
|
280 | + } |
|
281 | + } |
|
282 | + if (isset($poly2[$i][$j]) && ($poly2[$i][$j] == TRUE)) { |
|
283 | + $surfaceOf2++; |
|
261 | 284 | } |
262 | - if (isset($poly2[$i][$j]) && ($poly2[$i][$j] == TRUE)) |
|
263 | - $surfaceOf2++; |
|
264 | 285 | } |
265 | 286 | |
266 | 287 | return array ( |