function parseAFD_Content_mainComment()
 {
     $GLOBALS['log'] .= "<span class='startCall'> ****************** Call ParseAFD_MainComment->parseAFD_Content_mainComment() <a target='_blank' <a href='GetAFDListbyDebateDateListID.php?DebateDateListID=" . $this->afd->debateDateListID . "#" . $this->afd->AFDTitleID . "'>" . $this->afd->AFDTitle . "</a> </span>";
     try {
         if (!$this->afd) {
             throw new Exception('this->afd is empty!');
         }
         //is allowed to parse the mainComment details
         if ($this->afd->flag_DoNotParse != 1) {
             //$MainEndResult = $matches_MainEndResult[1][0][0];
             //$GLOBALS['log'] .="<br/><span class='good'>Full Matched:</span>".$MainEndResult. " -- $condition_TheEndResultDate -- Start".  + ($matches_MainEndResult[0][0][1]) ." Lenght :".strlen("The result was ".$MainEndResult);
             //$startPosition_MainEndResult = $matches_MainEndResult[1][0][1] + strlen($matches_MainEndResult[1][0][0]);
             //$endResult_Middle = substr($endResult_Middle, $startPosition_MainEndResult );
             $signature = Signature::parse($this->mainComment_Html);
             if ($signature->parsedPassedNo == 4) {
                 $this->afd->parse_mainComment = 1;
             } else {
                 $this->afd->parse_mainComment = 0;
             }
             $mainComment_ExtraNote2_temp = substr($this->mainComment_Html, $signature->getAfterUTC_Position());
             if (strlen(trim($mainComment_ExtraNote2_temp)) > 15) {
                 $this->afd->mainComment_ExtraNote2 = $mainComment_ExtraNote2_temp;
                 $GLOBALS['log'] .= "<br/><span class='percentage'>MainComment_ExtraNote2:</span>" . " - lenght: " . strlen(trim($this->afd->mainComment_ExtraNote2)) . " - " . $this->afd->mainComment_ExtraNote2;
             }
             //$this->afd->endResult = $MainEndResult;
             $this->afd->mainComment_User = $signature->userID;
             $this->afd->mainComment_UserPosition = $signature->userID_StartPos;
             $this->afd->mainComment_UserTitle = $signature->userTitle;
             $this->afd->mainComment_UserURL = $signature->userURL;
             $this->afd->mainComment_UserURLType = $signature->userURLType;
             $this->afd->mainComment_Note = $signature->initialSentance;
             $this->afd->mainComment_Date = $signature->date;
             $this->afd->mainComment_Time = $signature->time;
             $this->afd->mainComment_DateTime = date('Y-m-d H:i:s', strtotime($signature->date . " " . $signature->time));
             $this->afd->updateAFD_OnlyMainComment_byAFDID();
         } else {
             $GLOBALS['log'] .= "<br/><span class='startCall'> By pass by flag_DoNotParse = 1.</span>";
         }
     } catch (Exception $e) {
         echo 'Caught exception: ', $e->getMessage(), "\n";
     }
     $GLOBALS['log'] .= "<br/><span class='endCall'>**** End Called ParseAFD_EndResult->parseAFD_Content_endResult()*******************</span>";
 }
 function parseAFD_Content()
 {
     $GLOBALS['log'] .= "<br/> <span class='startCall'> ****************** Call ParseAFD_OtherComment->parseAFD_Content() <a target='_blank' <a href='getAFDHtmlByID.php?id=" . $this->afd->AFDID . "#" . $this->afd->AFDTitleID . "'>" . $this->afd->AFDTitle . "</a> </span>";
     try {
         if (!$this->afd) {
             throw new Exception('this->afd is empty!');
         }
         //is allowed to parse the endresult details
         if ($this->afd->flag_DoNotParse != 1) {
             $parse_otherComment = 0;
             $parse_otherComment_User = 0;
             $otherComment_Total = 0;
             $GLOBALS['log'] .= closetags($this->otherComment_Html);
             $this->distinguishComments = new DistinguishComments($this->otherComment_Html, $this->debateDate->url);
             //Update AFD table
             $this->afd->otherComment_CounterTime = $this->distinguishComments->condition_time;
             $this->afd->otherComment_CounterDate = $this->distinguishComments->condition_date;
             $this->afd->otherComment_CounterUTC = $this->distinguishComments->condition_UTC;
             $this->afd->otherComment_CounterUserNormal = $this->distinguishComments->condition_UserID1;
             $this->afd->otherComment_CounterUserTalk = $this->distinguishComments->condition_UserID2;
             $this->afd->otherComment_CounterUserNew = $this->distinguishComments->condition_UserID3;
             $this->afd->otherComment_CounterUserIP = $this->distinguishComments->condition_UserID4;
             $this->afd->parse_otherComment = $this->distinguishComments->distinguishPercentage;
             $this->afd->parse_otherComment_User = $this->distinguishComments->distinguishPercentage_User;
             $this->afd->updateAFD_OnlyOtherComment_byAFDID();
             //clear the comment table to remove the previous records to prevent dublication
             //also if there was previous mistake it make show the mistake does not effect over the quality of data
             Comment::removedAllComment_ByAFDID($this->afd->AFDID);
             //set the condition to insert into comment table
             $GLOBALS['log'] .= "<hr style='border: 0; border-top: 1px solid gray;'/>";
             //set the (other)comment table
             for ($i = 0; $i < count($this->distinguishComments->array_time); $i++) {
                 $current_comment_Html = $this->distinguishComments->array_time[$i];
                 $current_comment_UserCheck = $this->distinguishComments->array_UTC_UserCheck[$i];
                 //$comment_User and $comment_DateTime are "", this is due to further development
                 $comment = new Comment($this->afd->AFDID, $this->afd->AFDTitleID, $this->afd->debateDateListID, $current_comment_Html, "", "", "");
                 $GLOBALS['log'] .= "<table border='1'><tr><td>";
                 $signature = Signature::parse($current_comment_Html);
                 $GLOBALS['log'] .= "</td></tr></table>";
                 $beforeSignature = $signature->initialSentance;
                 $debate_included = $this->check_debate_included($beforeSignature);
                 $bBlock = $this->check_Comment_bBlock($beforeSignature);
                 $comment->AFDTitle = $this->afd->AFDTitle;
                 $comment->articleID = $this->afd->articleID;
                 $comment->comment_UserCheck = $current_comment_UserCheck;
                 //liligago need to write for comment such as delete, keep and etc.
                 $comment->comment = $bBlock[1];
                 $comment->comment_User = $signature->userID;
                 $comment->comment_UserPosition = $signature->userID_StartPos;
                 $comment->comment_UserTitle = $signature->userTitle;
                 $comment->comment_UserURL = $signature->userURL;
                 $comment->comment_UserURLType = $signature->userURLType;
                 $comment->comment_Date = $signature->date;
                 $comment->comment_Time = $signature->time;
                 $comment->comment_DateTime = date('Y-m-d H:i:s', strtotime($signature->date . " " . $signature->time));
                 $comment->comment_Note = $bBlock[2];
                 $comment->comment_ExtraNote = $debate_included[1];
                 if ($bBlock[0] == 1 && $debate_included[0] == 1) {
                     $comment->comment_Type = 1;
                 } else {
                     if ($bBlock[0] == 1) {
                         $comment->comment_Type = "1Error";
                     } else {
                         if ($debate_included[0] == 1) {
                             $comment->comment_Type = "Flag_Text";
                         } else {
                             $comment->comment_Type = 0;
                         }
                     }
                 }
                 $comment->comment_Type2 = $bBlock[3];
                 if ($this->distinguishComments->distinguishPercentage >= 80) {
                     $comment->flag_DoNotVisualize_Comment = 0;
                 } else {
                     $comment->flag_DoNotVisualize_Comment = 1;
                 }
                 $comment->distinguishPercentage = $this->distinguishComments->distinguishPercentage;
                 //if(!empty($comment->comment_Note))
                 //    $GLOBALS['log'] .="<br/><span class='percentage'> Comment Note:</span><br/> ".strip_tags($comment->comment_Note);
                 if (strlen($comment->comment_Type) == strlen("Flag_Text")) {
                     $GLOBALS['log'] .= "<br/><span class='bad'> Flag_Text</span>";
                 }
                 //update the comment table
                 $comment->update_Comment();
                 $GLOBALS['log'] .= "<hr style='border: 0; border-top: 1px solid #FF3339;'/>";
             }
         } else {
             $GLOBALS['log'] .= "<br/><span class='startCall'> By pass by flag_DoNotParse = 1.</span>";
         }
     } catch (Exception $e) {
         echo 'Caught exception: ', $e->getMessage(), "\n";
     }
     $GLOBALS['log'] .= "<br/><span class='endCall'>**** End Called ParseAFD_OtherComment->parseAFD_Content()*******************</span>";
 }
 function parseAFD_Content_endResult()
 {
     $GLOBALS['log'] .= "<br/> <span class='startCall'> ****************** Call ParseAFD_EndResult->parseAFD_Content_endResult() <a target='_blank' <a href='GetAFDListbyDebateDateListID.php?DebateDateListID=" . $this->afd->debateDateListID . "#" . $this->afd->AFDTitleID . "'>" . $this->afd->AFDTitle . "</a> </span>";
     try {
         if (!$this->afd) {
             throw new Exception('this->afd is empty!');
         }
         //is allowed to parse the endresult details
         if ($this->afd->flag_DoNotParse != 1) {
             $parse_endResult_details = 0;
             //1.Cut off extra from the START section
             $condition_TheResultIs = preg_match_all("/(The result was)/", $this->endResult_Html, $matches_TheResultIs, PREG_OFFSET_CAPTURE);
             if ($condition_TheResultIs > 0) {
                 $startPosition_TheResultIs = $matches_TheResultIs[0][0][1] + 14;
                 $endResult_Middle = substr($this->endResult_Html, $startPosition_TheResultIs);
                 //2.Cut off extra from the END section
                 $condition_TheEndResultDate = preg_match_all("/\\((UTC)\\)/i", $endResult_Middle, $matches_TheEndResultDate, PREG_OFFSET_CAPTURE);
                 if ($condition_TheEndResultDate > 0) {
                     $condition_TheEndResultDate_LastIndex = count($matches_TheEndResultDate[1]) - 1;
                     $endPosition_TheEndResultDate = $matches_TheEndResultDate[0][$condition_TheEndResultDate_LastIndex][1];
                     $endResult_Middle = substr($endResult_Middle, 0, $endPosition_TheEndResultDate + 5);
                     //3.Extract the main section of EndResult
                     $condition_MainEndResult = preg_match_all("'<b>(.*?)</b>'i", $endResult_Middle, $matches_MainEndResult, PREG_OFFSET_CAPTURE);
                     if ($condition_MainEndResult > 0) {
                         $MainEndResult = $matches_MainEndResult[1][0][0];
                         $GLOBALS['log'] .= "<br/><span class='good'>Full Matched:</span>" . $MainEndResult . " -- {$condition_TheEndResultDate} -- Start" . +$matches_MainEndResult[0][0][1] . " Lenght :" . strlen("The result was " . $MainEndResult);
                         $startPosition_MainEndResult = $matches_MainEndResult[1][0][1] + strlen($matches_MainEndResult[1][0][0]);
                         $endResult_Middle = substr($endResult_Middle, $startPosition_MainEndResult);
                         $signature = Signature::parse($endResult_Middle);
                         if ($signature->parsedPassedNo > 2) {
                             if ($signature->parsedPassedNo == 4) {
                                 $this->afd->parse_endResult_details = 1;
                             } else {
                                 $this->afd->parse_endResult_details = 0;
                             }
                             $this->afd->endResult = $MainEndResult;
                             $this->afd->endResult_User = $signature->userID;
                             $this->afd->endResult_UserPosition = strlen("The result was " . $MainEndResult) + $signature->userID_StartPos;
                             $this->afd->endResult_UserTitle = $signature->userTitle;
                             $this->afd->endResult_UserURL = $signature->userURL;
                             $this->afd->endResult_UserURLType = $signature->userURLType;
                             $this->afd->endResult_Note = $signature->initialSentance;
                             $this->afd->endResult_Date = $signature->date;
                             $this->afd->endResult_Time = $signature->time;
                             $this->afd->endResult_DateTime = date('Y-m-d H:i:s', strtotime($signature->date . " " . $signature->time));
                             $this->afd->updateAFD_OnlyEndResult_byAFDID();
                         }
                     } else {
                         $GLOBALS['log'] .= "<br/><span class='bad'>Failed to Match Main_EndResult.</span>";
                     }
                 } else {
                     $GLOBALS['log'] .= "<br/><span class='bad'>Failed to Match.</span>";
                 }
             } else {
                 $GLOBALS['log'] .= "<br/><span class='bad'>Failed to Match.</span>";
             }
         } else {
             $GLOBALS['log'] .= "<br/><span class='startCall'> By pass by flag_DoNotParse = 1.</span>";
         }
     } catch (Exception $e) {
         echo 'Caught exception: ', $e->getMessage(), "\n";
     }
     $GLOBALS['log'] .= "<br/><span class='endCall'>**** End Called ParseAFD_EndResult->parseAFD_Content_endResult()*******************</span>";
 }