/** * public * main process to generate report and store result in 3 arrays */ public function generateRpt() { $checksDAO = new ChecksDAO(); // generate section details foreach ($this->errors as $error) { $row = $checksDAO->getCheckByID($error["check_id"]); if ($row["confidence"] == KNOWN) { // no decision to make on known problems $this->nr_known_problems++; $this->group_known_problems[] = $this->generate_problem_section($error["check_id"], $error["line_number"], $error["col_number"], $error["html_code"], $error["image"], $error["image_alt"], $error["css_code"], _AC($row["err"]), _AC($row["how_to_repair"]), '', IS_ERROR); } else { if ($row["confidence"] == LIKELY) { if ($this->user_link_id == '') { $this->group_likely_problems_no_decision[] = $this->generate_problem_section($error["check_id"], $error["line_number"], $error["col_number"], $error["html_code"], $error["image"], $error["image_alt"], $error["css_code"], _AC($row["err"]), _AC($row["how_to_repair"]), '', IS_WARNING); $this->nr_likely_problems++; } else { $this->generate_cell_with_decision($row, $error["line_number"], $error["col_number"], $error["html_code"], $error['image'], $error["image_alt"], IS_WARNING); } } else { if ($row["confidence"] == POTENTIAL) { if ($this->user_link_id == '') { $this->group_potential_problems_no_decision[] = $this->generate_problem_section($error["check_id"], $error["line_number"], $error["col_number"], $error["html_code"], $error["image"], $error["image_alt"], $error["css_code"], _AC($row["err"]), _AC($row["how_to_repair"]), '', IS_INFO); $this->nr_potential_problems++; } else { $this->generate_cell_with_decision($row, $error["line_number"], $error["col_number"], $error["html_code"], $error['image'], $error["image_alt"], IS_INFO); } } } } } $this->group_likely_problems['no_decision'] = $this->group_likely_problems_no_decision; $this->group_likely_problems['with_decision'] = $this->group_likely_problems_with_decision; $this->group_potential_problems['no_decision'] = $this->group_potential_problems_no_decision; $this->group_potential_problems['with_decision'] = $this->group_potential_problems_with_decision; return array($this->group_known_problems, $this->group_likely_problems, $this->group_potential_problems); }
} $sql = "SELECT COUNT(check_id) AS cnt FROM " . TABLE_PREFIX . "checks WHERE {$condition}"; $rows = $dao->execute($sql); $num_results = $rows[0]['cnt']; $num_pages = max(ceil($num_results / $results_per_page), 1); $page = intval($_GET['p']); if (!$page) { $page = 1; } $count = ($page - 1) * $results_per_page + 1; $offset = ($page - 1) * $results_per_page; if (isset($_GET['apply_all']) && $_GET['change_status'] >= -1) { $offset = 0; $results_per_page = 999999; } $checksDAO = new ChecksDAO(); $sql = "SELECT * \r\n FROM " . TABLE_PREFIX . "checks\r\n WHERE {$condition} ORDER BY {$col} {$order} LIMIT {$offset}, {$results_per_page}"; $check_rows = $dao->execute($sql); // if prerequisite or next checks are inserted into db successfully, // $javascript_run_now is set to refresh parent window if (isset($javascript_run_now)) { $savant->assign('javascript_run_now', $javascript_run_now); } $savant->assign('check_rows', $check_rows); $savant->assign('all_html_tags', $checksDAO->getAllHtmlTags()); $savant->assign('results_per_page', $results_per_page); $savant->assign('num_results', $num_results); $savant->assign('col_counts', $col_counts); $savant->assign('page', $page); $savant->assign('page_string', $page_string); $savant->assign('orders', $orders);
/** * public * main process to generate report in html format */ public function generateRpt() { global $msg; // user_link_id must be given to show decision section if ((!isset($this->user_link_id) || $this->user_link_id == '') && $this->allow_set_decision == 'true') { $msg->addError('NONE_USER_LINK'); return false; } // initialize each section $this->rpt_errors = "<ul>\n"; $this->rpt_likely_problems = "<ul>\n"; $this->rpt_potential_problems = "<ul>\n"; $checksDAO = new ChecksDAO(); // generate section details foreach ($this->errors as $error) { $row = $checksDAO->getCheckByID($error["check_id"]); if ($row["confidence"] == KNOWN) { // no decision to make on known problems $this->num_of_errors++; $this->rpt_errors .= $this->generate_problem_section($error["check_id"], $error["line_number"], $error["col_number"], $error["html_code"], $error["image"], $error["image_alt"], $error["css_code"], _AC($row["err"]), _AC($row["how_to_repair"]), '', IS_ERROR); } else { if ($row["confidence"] == LIKELY) { $this->num_of_likely_problems++; if ($this->allow_set_decision == 'false' && !($this->from_referer == 'true' && $this->user_link_id > 0)) { $this->rpt_likely_problems .= $this->generate_problem_section($error["check_id"], $error["line_number"], $error["col_number"], $error["html_code"], $error["image"], $error["image_alt"], $error["css_code"], _AC($row["err"]), _AC($row["how_to_repair"]), '', IS_WARNING); $this->num_of_likely_problems_fail++; } else { $this->generate_cell_with_decision($row, $error["line_number"], $error["col_number"], $error["html_code"], $error['image'], $error["image_alt"], IS_WARNING); } } else { if ($row["confidence"] == POTENTIAL) { $this->num_of_potential_problems++; if ($this->allow_set_decision == 'false' && !($this->from_referer == 'true' && $this->user_link_id > 0)) { $this->rpt_potential_problems .= $this->generate_problem_section($error["check_id"], $error["line_number"], $error["col_number"], $error["html_code"], $error["image"], $error["image_alt"], $error["css_code"], _AC($row["err"]), _AC($row["how_to_repair"]), '', IS_INFO); $this->num_of_potential_problems_fail++; } else { $this->generate_cell_with_decision($row, $error["line_number"], $error["col_number"], $error["html_code"], $error['image'], $error["image_alt"], IS_INFO); } } } } } if ($this->allow_set_decision == 'true' || $this->allow_set_decision == 'false' && $this->from_referer == 'true' && $this->user_link_id > 0) { $this->rpt_likely_problems .= $this->rpt_likely_decision_not_made . $this->rpt_likely_decision_made; $this->rpt_potential_problems .= $this->rpt_potential_decision_not_made . $this->rpt_potential_decision_made; } $this->rpt_errors .= "</ul>"; $this->rpt_likely_problems .= "</ul>"; $this->rpt_potential_problems .= "</ul>"; if ($this->show_source == 'true') { $this->generateSourceRpt(); } }
} } } else { if (isset($_POST['remove_next'])) { if (is_array($_POST['del_next_checks_id'])) { foreach ($_POST['del_next_checks_id'] as $del_check_id) { $testPassDAO->Delete($check_id, $del_check_id); } } } } } } // end of handle submit // initialize page $checksDAO = new ChecksDAO(); if (isset($check_id)) { $check_row = $checksDAO->getCheckByID($check_id); if (!$check_row) { // invalid check id $msg->addError('INVALID_CHECK_ID'); require AC_INCLUDE_PATH . 'header.inc.php'; $msg->printAll(); require AC_INCLUDE_PATH . 'footer.inc.php'; exit; } // get author name $usersDAO = new UsersDAO(); $user_name = $usersDAO->getUserName($check_row['user_id']); if ($user_name != '') { $savant->assign('author', $user_name);
/************************************************************************/ /* Copyright (c) 2008 - 2011 */ /* Inclusive Design Institute */ /* */ /* This program is free software. You can redistribute it and/or */ /* modify it under the terms of the GNU General Public License */ /* as published by the Free Software Foundation. */ /************************************************************************/ // $Id$ include_once AC_INCLUDE_PATH . 'classes/DAO/GuidelineGroupsDAO.class.php'; include_once AC_INCLUDE_PATH . 'classes/DAO/GuidelineSubgroupsDAO.class.php'; include_once AC_INCLUDE_PATH . 'classes/DAO/ChecksDAO.class.php'; $gid = $this->gid; $guidelineGroupsDAO = new GuidelineGroupsDAO(); $guidelineSubgroupsDAO = new GuidelineSubgroupsDAO(); $checksDAO = new ChecksDAO(); $num_of_checks = 0; function dispaly_check_table($checks_array) { if (is_array($checks_array)) { ?> <table class="data" rules="rows" > <thead> <tr> <th align="center"><?php echo _AC('html_tag'); ?> </th> <th align="center"><?php echo _AC('error_type'); ?>
/** * Delete user * @access public * @param user_id * @return true, if successful * false and add error into global var $msg, if unsuccessful * @author Cindy Qi Li */ public function Delete($userIDs) { // delete customized guidelines created by user but yet open to public include_once AC_INCLUDE_PATH . 'classes/DAO/GuidelinesDAO.class.php'; include_once AC_INCLUDE_PATH . 'classes/DAO/ChecksDAO.class.php'; include_once AC_INCLUDE_PATH . 'classes/DAO/UserLinksDAO.class.php'; include_once AC_INCLUDE_PATH . 'classes/Utility.class.php'; $userIDs = Utility::sanitizeIntArray($userIDs); $guidelinesDAO = new GuidelinesDAO(); $guidelines = $guidelinesDAO->getGuidelineByUserIDs($userIDs); if (is_array($guidelines)) { foreach ($guidelines as $guideline) { if ($guideline['open_to_public'] == 0) { $guidelinesDAO->Delete($guideline['guideline_id']); } } } // delete customized checks created by user but yet open to public $checksDAO = new ChecksDAO(); $checks = $checksDAO->getCheckByUserIDs($userIDs); if (is_array($checks)) { foreach ($checks as $check) { if ($check['open_to_public'] == 0) { $checksDAO->Delete($check['check_id']); } } } // delete user links and decisions generated by this user $userLinksDAO = new UserLinksDAO(); $userLinks = $userLinksDAO->DeleteByUserID($userIDs); $sql = "DELETE FROM " . TABLE_PREFIX . "users\n\t\t WHERE user_id in (" . implode(",", $userIDs) . ")"; return $this->execute($sql); }
/** * check if the inner text is in one of the search string defined in checks.search_str * return true if in, otherwise, return false */ public static function isTextInSearchString($text, $check_id, $e) { $text = strtolower(trim($text)); $checksDAO = new ChecksDAO(); $row = $checksDAO->getCheckByID($check_id); $search_strings = explode(',', strtolower(_AC($row['search_str']))); if (!is_array($search_strings)) { return true; } else { return BasicChecks::inSearchString($text, $search_strings); } }
/************************************************************************/ /* AChecker */ /************************************************************************/ /* Copyright (c) 2008 - 2011 */ /* Inclusive Design Institute */ /* */ /* This program is free software. You can redistribute it and/or */ /* modify it under the terms of the GNU General Public License */ /* as published by the Free Software Foundation. */ /************************************************************************/ // $Id$ define('AC_INCLUDE_PATH', '../include/'); include AC_INCLUDE_PATH . 'vitals.inc.php'; include_once AC_INCLUDE_PATH . 'classes/DAO/ChecksDAO.class.php'; $checksDAO = new ChecksDAO(); if (isset($_POST['submit_no'])) { $msg->addFeedback('CANCELLED'); header('Location: index.php'); exit; } else { if (isset($_POST['submit_yes'])) { $checksDAO->Delete($_REQUEST['id']); $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY'); header('Location: index.php'); exit; } } require AC_INCLUDE_PATH . 'header.inc.php'; unset($hidden_vars); $row = $checksDAO->getCheckByID($_REQUEST['id']);
/** * 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; }
/** * private * main process to generate report in html format */ private function generateRESTRpt() { $num_of_errors = 0; $num_of_likely_problems = 0; $num_of_potential_problems = 0; $checksDAO = new ChecksDAO(); $userDecisionsDAO = new UserDecisionsDAO(); // generate section details foreach ($this->errors as $error) { // generate each error result $result_type = ''; $repair = ''; $decision = ''; $decision_questions = ''; $decision_made = ''; $row_check = $checksDAO->getCheckByID($error["check_id"]); if ($row_check["confidence"] == KNOWN) { // only known errors have <repair> $num_of_errors++; $result_type = _AC('error'); $repair = str_replace('{REPAIR}', htmlentities(_AC($row_check["how_to_repair"])), $this->rest_repair); } else { // generate user's decision. only likely and potential problems have decisions to make $row_userDecision = $userDecisionsDAO->getByUserLinkIDAndLineNumAndColNumAndCheckID($this->userLinkID, $error["line_number"], $error["col_number"], $error['check_id']); if ($row_userDecision['decision'] == AC_DECISION_PASS || $row_userDecision['decision'] == AC_DECISION_FAIL) { if ($row_userDecision['decision'] == AC_DECISION_PASS) { $decision_text = _AC('pass'); } if ($row_userDecision['decision'] == AC_DECISION_FAIL) { $decision_text = _AC('fail'); } $decision_made = str_replace(array('{DECISIONMADE}', '{DECISIONMADEDATE}'), array(htmlentities($decision_text), $row_userDecision['last_update']), $this->rest_decision_made); } if ($row_check["confidence"] == LIKELY) { $result_type = _AC('likely_problem'); if (!$row_userDecision || $row_userDecision['decision'] == AC_DECISION_FAIL) { $num_of_likely_problems++; } } if ($row_check["confidence"] == POTENTIAL) { $result_type = _AC('potential_problem'); if (!$row_userDecision || $row_userDecision['decision'] == AC_DECISION_FAIL) { $num_of_potential_problems++; } } $decision_questions = str_replace(array('{SEQUENCEID}', '{DECISIONPASS}', '{DECISIONFAIL}'), array($error['line_number'] . '_' . $error['col_number'] . '_' . $error['check_id'], htmlentities(_AC($row_check['decision_pass'])), htmlentities(_AC($row_check['decision_fail']))), $this->rest_decision_questions); $decision = $decision_questions . $decision_made; // end of generating user's decision } $result .= str_replace(array('{RESULTTYPE}', '{LINENUM}', '{COLUMNNUM}', '{BASE_HREF}', '{CHECK_ID}', '{TITLE}', '{ERRORMSG}', '{ERRORSOURCECODE}', '{REPAIR}', '{DECISION}'), array($result_type, $error["line_number"], $error["col_number"], htmlentities(AC_BASE_HREF), $error['check_id'], htmlentities(_AC("suggest_improvements")), htmlentities(_AC($row_check['err'])), htmlentities($error["html_code"], ENT_QUOTES, "UTF-8"), $repair, $decision), $this->rest_result); } // retrieve session id $userLinksDAO = new UserLinksDAO(); $row = $userLinksDAO->getByUserLinkID($this->userLinkID); $sessionID = $row['last_sessionID']; // generate guidelines $guidelinesDAO = new GuidelinesDAO(); foreach ($this->guidelineArray as $gid) { $row_guideline = $guidelinesDAO->getGuidelineByIDs($gid); $guidelines .= str_replace('{GUIDELINE}', htmlentities($row_guideline[0]['title']), $this->rest_guideline); } // find out result status: pass, fail, conditional pass if ($num_of_errors > 0) { $status = _AC('fail'); } else { if ($num_of_likely_problems + $num_of_potential_problems > 0) { $status = _AC('conditional_pass'); } else { $status = _AC('pass'); } } // generate final output $this->output = str_replace(array('{STATUS}', '{SESSIONID}', '{NUMOFERRORS}', '{NUMOFLIKELYPROBLEMS}', '{NUMOFPOTENTIALPROBLEMS}', '{GUIDELINES}', '{RESULTS}'), array($status, $sessionID, $num_of_errors, $num_of_likely_problems, $num_of_potential_problems, $guidelines, $result), $this->rest_main); }