/**
  * private
  * check given html dom node for given check_id, save result into $this->result
  * parameters:
  * $e: simple html dom node
  * $check_id: check id
  *
  * return "success" or "fail"
  */
 private function check($e, $check_id)
 {
     global $msg, $base_href, $tag_size;
     // don't check the lines before $line_offset
     if ($e->linenumber <= $this->line_offset) {
         return;
     }
     if ($e->linenumber == 1 && $this->col_offset > 0) {
         $col_number = $e->colnumber - $this->col_offset;
     } else {
         $col_number = $e->colnumber;
     }
     $line_number = $e->linenumber - $this->line_offset;
     $result = $this->get_check_result($line_number, $col_number, $check_id);
     // has not been checked
     if (!$result) {
         $check_result = eval($this->check_func_array[$check_id]);
         //CSS code variable
         $css_code = BasicChecks::getCssOutput();
         $checksDAO = new ChecksDAO();
         $row = $checksDAO->getCheckByID($check_id);
         if (is_null($check_result)) {
             // when $check_result is not true/false, must be something wrong with the check function.
             // show warning message and skip this check
             $msg->addError(array('CHECK_FUNC', $row['html_tag'] . ': ' . _AC($row['name'])));
             // skip this check
             $check_result = true;
         }
         if ($check_result === true) {
             $result = SUCCESS_RESULT;
             //MB
             // number of success checks
             if (isset($this->num_success[$check_id])) {
                 $this->num_success[$check_id]++;
             } else {
                 $this->num_success[$check_id] = 1;
             }
         } else {
             $result = FAIL_RESULT;
         }
         if ($result == FAIL_RESULT) {
             $preview_html = $e->outertext;
             if (strlen($preview_html) > DISPLAY_PREVIEW_HTML_LENGTH) {
                 $html_code = substr($preview_html, 0, DISPLAY_PREVIEW_HTML_LENGTH) . " ...";
             } else {
                 $html_code = $preview_html;
             }
             // find out preview images for validation on <img>
             if (strtolower(trim($row['html_tag'])) == 'img') {
                 $image = BasicChecks::getFile($e->attr['src'], $base_href, $this->uri);
                 // The lines below to check the existence of the image slows down the validation process.
                 // So commented out.
                 //$handle = @fopen($image, 'r');
                 //if (!$handle) $image = '';
                 //else @fclose($handle);
                 // find out image alt text for preview image
                 if (!isset($e->attr['alt'])) {
                     $image_alt = '_NOT_DEFINED';
                 } else {
                     if ($e->attr['alt'] == '') {
                         $image_alt = '_EMPTY';
                     } else {
                         $image_alt = $e->attr['alt'];
                     }
                 }
             }
             // If its a duplicate ID, switch the line number from the element line (body)
             // to the line where the duplicate ID appears.
             global $has_duplicate_attribute;
             if (is_array($has_duplicate_attribute)) {
                 $line_number = $has_duplicate_attribute[0];
                 $html_code .= "(" . $has_duplicate_attribute[1] . ")";
             }
             $this->save_result($line_number, $col_number, $html_code, $check_id, $result, $image, $image_alt, $css_code);
         }
     }
     return $result;
 }