/**
  * Appends a custom AChecker footer to all outgoing email then sends the email.
  * If mail_queue is enabled then instead of sending the mail out right away, it 
  * places it in the database and waits for the cron to send it using SendQueue().
  * The mail queue does not support reply-to, or attachments, and converts all BCCs
  * to regular To emails.
  * @access  public
  * @return  boolean	whether or not the mail was sent (or queued) successfully.
  * @see     parent::send()
  * @since   AChecker 0.2
  * @author  Joel Kronenberg
  */
 function Send()
 {
     global $_config;
     // attach the AChecker footer to the body first:
     $this->Body .= "\n\n" . '----------------------------------------------' . "\n";
     $this->Body .= _AC('sent_via_achecker', AC_BASE_HREF);
     $this->Body .= "\n" . _AC('achecker_home') . ': http://achecker.ca';
     // if this email has been queued then don't send it. instead insert it in the db
     // for each bcc or to or cc
     if ($_config['enable_mail_queue'] && !$this->attachment) {
         require_once AC_INCLUDE_PATH . 'classes/DAO/MailQueueDAO.class.php';
         $mailQueueDAO = new MailQueueDAO();
         for ($i = 0; $i < count($this->to); $i++) {
             $mailQueueDAO->Create(addslashes($this->to[$i][0]), addslashes($this->to[$i][1]), addslashes($this->From), addslashes($this->FromName), addslashes($this->Subject), addslashes($this->Body), addslashes($this->CharSet));
         }
         for ($i = 0; $i < count($this->cc); $i++) {
             $mailQueueDAO->Create(addslashes($this->cc[$i][0]), addslashes($this->cc[$i][1]), addslashes($this->From), addslashes($this->FromName), addslashes($this->Subject), addslashes($this->Body), addslashes($this->CharSet));
         }
         for ($i = 0; $i < count($this->bcc); $i++) {
             $mailQueueDAO->Create(addslashes($this->bcc[$i][0]), addslashes($this->bcc[$i][1]), addslashes($this->From), addslashes($this->FromName), addslashes($this->Subject), addslashes($this->Body), addslashes($this->CharSet));
         }
         return true;
     } else {
         return parent::Send();
     }
 }
function print_feedback($feedback, $notes = '')
{
    ?>
	<div class="input-form">
	<table border="0" class="fbkbox" cellpadding="3" cellspacing="2" width="100%" summary="" align="center">
	<tr class="fbkbox">
	<td><h3 class="feedback2"><img src="images/feedback.gif" align="top" alt="" class="img" /> <?php 
    echo _AC('AC_FEEDBACK_UPDATE_INSTALLED_SUCCESSFULLY');
    ?>
</h3>
		<?php 
    echo '<ul>';
    foreach ($feedback as $p) {
        echo '<li>' . $p . '</li>';
    }
    echo '</ul>';
    ?>
</td>
	</tr>
	<tr>
		<td>
		<?php 
    echo $notes;
    ?>
		</td>
	</tr>
	</table>
	</div>
<?php 
}
Exemple #3
0
function print_handbook($handbook_pages)
{
    global $_pages;
    foreach ($handbook_pages as $page_key => $page_value) {
        if (is_array($page_value)) {
            if (isset($_pages[$page_key])) {
                echo _AC($_pages[$page_key]['guide']) . "<br /><br />";
                print_handbook($page_value);
            }
        } else {
            if (isset($_pages[$page_value])) {
                echo _AC($_pages[$page_value]['guide']) . "<br /><br />";
            }
        }
    }
}
function get_status_by_code($status_code)
{
    if ($status_code == AC_STATUS_DISABLED) {
        return _AC('disabled');
    } else {
        if ($status_code == AC_STATUS_ENABLED) {
            return _AC('enabled');
        } else {
            if ($status_code == AC_STATUS_DEFAULT) {
                return _AC('default');
            } else {
                if ($status_code == AC_STATUS_UNCONFIRMED) {
                    return _AC('unconfirmed');
                } else {
                    return '';
                }
            }
        }
    }
}
/**
 * handbook toc printer
 * prints an unordered html list representation of the multidimensional array.
 * $handbook_pages    the array of items to print.
 * $section  the directory name of the files.
 */
function hb_print_toc($handbook_pages)
{
    global $_pages;
    echo '<ul id="handbook-toc">';
    foreach ($handbook_pages as $page_key => $page_value) {
        echo '<li>';
        if (is_array($page_value)) {
            if (isset($_pages[$page_key])) {
                echo '<a href="frame_content.php?p=' . $page_key . '" id="id' . $page_key . '" class="tree">' . _AC($_pages[$page_key]['title_var']) . '</a>';
                hb_print_toc($page_value);
            }
        } else {
            if (isset($_pages[$page_value])) {
                echo '<a href="frame_content.php?p=' . $page_value . '" id="id' . $page_value . '" class="leaf">' . _AC($_pages[$page_value]['title_var']) . '</a>';
            }
        }
        echo '</li>';
    }
    echo '</ul>';
}
 /**
  * Update an existing user group
  * @access  public
  * @param   user_group_id
  *          title
  *          description
  * @return  user id, if successful
  *          false and add error into global var $msg, if unsuccessful
  * @author  Cindy Qi Li
  */
 public function Update($user_group_id, $title, $description)
 {
     global $addslashes, $msg;
     $missing_fields = array();
     $user_group_id = intval($user_group_id);
     $title = $addslashes(trim($title));
     $description = $addslashes(trim($description));
     /* login name check */
     if ($title == '') {
         $missing_fields[] = _AC('title');
     }
     if ($missing_fields) {
         $missing_fields = implode(', ', $missing_fields);
         $msg->addError(array('EMPTY_FIELDS', $missing_fields));
     }
     if (!$msg->containsErrors()) {
         /* insert into the db */
         $sql = "UPDATE " . TABLE_PREFIX . "user_groups\n\t\t\t           SET title = '" . $title . "',\n\t\t\t               description = '" . $description . "',\n\t\t\t               last_update = now()\n\t\t\t         WHERE user_group_id = " . $user_group_id;
         return $this->execute($sql);
     }
 }
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');
        ?>
</th>
			<th align="center"><?php 
        echo _AC('description');
        ?>
</th>
			<th align="center"><?php 
        echo _AC('check_id');
        ?>
</th>
		</tr>
		</thead>
		
		<tbody>
	<?php 
        foreach ($checks_array as $check_row) {
            ?>
		<tr>
			<td><?php 
            echo htmlspecialchars($check_row['html_tag']);
            ?>
</td>
			<td><?php 
            echo get_confidence_by_code($check_row['confidence']);
            ?>
</td>
			<td><span class="msg"><a target="_new" href="<?php 
            echo AC_BASE_HREF;
            ?>
checker/suggestion.php?id=<?php 
            echo $check_row["check_id"];
            ?>
" onclick="AChecker.popup('<?php 
            echo AC_BASE_HREF;
            ?>
checker/suggestion.php?id=<?php 
            echo $check_row["check_id"];
            ?>
'); return false;"><?php 
            echo htmlspecialchars(_AC($check_row['name']));
            ?>
</a></span></td>
			<td><?php 
            echo $check_row['check_id'];
            ?>
</td>
		</tr>
	<?php 
        }
        // end of foreach
        ?>
		</tbody>
	</table>
	<?php 
    }
    // end of if
}
/* 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: index.php 495 2011-02-10 21:27:00Z cindy $
// Called by ajax request from guidelineline view report -> "make decision(s)" buttons
// @ see checker/js/checker.js
define('AC_INCLUDE_PATH', '../include/');
include AC_INCLUDE_PATH . 'vitals.inc.php';
include_once AC_INCLUDE_PATH . 'classes/Utility.class.php';
include_once AC_INCLUDE_PATH . 'classes/DAO/GuidelinesDAO.class.php';
include_once AC_INCLUDE_PATH . 'classes/DAO/UserLinksDAO.class.php';
// main process to save decisions
$guidelinesDAO = new GuidelinesDAO();
$guideline_rows = $guidelinesDAO->getGuidelineByIDs($_POST['gids']);
if (!is_array($guideline_rows)) {
    echo _AC("AC_ERROR_EMPTY_GID");
    exit;
}
$utility = new Utility();
$seals = $utility->getSeals($guideline_rows);
if (is_array($seals)) {
    $userLinksDAO = new UserLinksDAO();
    $rows = $userLinksDAO->getByUserIDAndURIAndSession($_SESSION['user_id'], $_POST['uri'], $_POST['jsessionid']);
    $savant->assign('user_link_id', $rows[0]['user_link_id']);
    $savant->assign('seals', $seals);
    $savant->display('checker/seals.tmpl.php');
}
exit;
            } else {
                if ($usersDAO->Update($_GET['id'], $_POST['user_group_id'], $_POST['login'], $_POST['email'], $_POST['first_name'], $_POST['last_name'], $_POST['status'])) {
                    $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
                    header('Location: index.php');
                    exit;
                }
            }
        }
    }
}
// end of handle submit
// initialize page
$userGroupsDAO = new UserGroupsDAO();
if (isset($_GET['id'])) {
    $usersDAO = new UsersDAO();
    $savant->assign('user_row', $usersDAO->getUserByID($_GET['id']));
    $savant->assign('show_password', false);
} else {
    $savant->assign('show_password', true);
}
/*****************************/
/* template starts down here */
global $onload;
$onload = 'document.form.login.focus();';
$savant->assign('show_user_group', true);
$savant->assign('show_status', true);
$savant->assign('all_user_groups', $userGroupsDAO->getAll());
$savant->assign('title', _AC('create_edit_user'));
$savant->assign('submit_button_text', _AC('save'));
$savant->assign('show_captcha', false);
$savant->display('register.tmpl.php');
 /**
  * Validate fields preparing for insert and update
  * @access  private
  * @param   $html_tag  
  *          $confidence
  *          $name
  *          $err
  *          $open_to_public
  * @return  true    if all fields are valid
  *          false   if any field is not valid
  * @author  Cindy Qi Li
  */
 private function isFieldsValid($html_tag, $confidence, $name, $err, $open_to_public)
 {
     global $msg;
     $missing_fields = array();
     if ($html_tag == '') {
         $missing_fields[] = _AC('html_tag');
     }
     if ($confidence != KNOWN && $confidence != LIKELY && $confidence != POTENTIAL) {
         $missing_fields[] = _AC('error_type');
     }
     if ($name == '') {
         $missing_fields[] = _AC('name');
     }
     if ($err == '') {
         $missing_fields[] = _AC('error');
     }
     if ($open_to_public != 0 && $open_to_public != 1) {
         $missing_fields[] = _AC('open_to_public');
     }
     if ($missing_fields) {
         $missing_fields = implode(', ', $missing_fields);
         $msg->addError(array('EMPTY_FIELDS', $missing_fields));
     }
     if (!$msg->containsErrors()) {
         return true;
     } else {
         return false;
     }
 }
    }
    if (isset($_GET['gg'])) {
        $guidelineGroupsDAO->Delete($_GET['gg']);
    }
    header('Location: create_edit_guideline.php?id=' . $gid);
    exit;
}
// interface display
if (!isset($gid)) {
    // create guideline
    $checksDAO = new ChecksDAO();
    $savant->assign('author', $_current_user->getUserName());
} else {
    // edit existing guideline
    $checksDAO = new ChecksDAO();
    $rows = $guidelinesDAO->getGuidelineByIDs($gid);
    // get author name
    $usersDAO = new UsersDAO();
    $user_name = $usersDAO->getUserName($rows[0]['user_id']);
    if (!$user_name) {
        $user_name = _AC('author_not_exist');
    }
    $savant->assign('gid', $gid);
    $savant->assign('row', $rows[0]);
    $savant->assign('author', $user_name);
    $savant->assign('checksDAO', $checksDAO);
}
if (isset($_current_user)) {
    $savant->assign('is_admin', $_current_user->isAdmin());
}
$savant->display('guideline/create_edit_guideline.tmpl.php');
<input type="text" name="query" /> <input type="submit" name="search" value="<?php 
echo _AC('search');
?>
" /> |  
<a href="print.php?p=<?php 
echo $this_page;
?>
" target="_top"><?php 
echo _AC('print_version');
?>
</a>

<script type="text/javascript">
//<!--
document.writeln(' | ');
showTocToggle('<?php 
echo _AC('show_contents');
?>
' ,'<?php 
echo _AC('hide_contents');
?>
');
if (top.name == 'popup') {
	toggleToc(true);
}
//-->
</script>

</form>
</body>
</html>
/**
 * Display checks in the given $checks_array in html table with 'remove' button at the bottom
 * @param $checks_array : array of all checks to display
 * @param $prefix: indicates where the checks belong to: guideline, guideline group or guideline subgroup.
 *                 'g_[guidelineID] for guideline checks
 *                 'gg_[groupID] for guideline group checks
 *                 'gsg_[subgroupID] for guideline subgroup checks
 * @return a html table to display all checks in $checks_array 
 */
function dispaly_check_table($checks_array, $prefix)
{
    if (is_array($checks_array)) {
        ?>
<form name="input_form_<?php 
        echo $prefix;
        ?>
" method="post" action="<?php 
        echo $_SERVER['PHP_SELF'];
        if (isset($_GET["id"])) {
            echo '?id=' . $_GET["id"];
        }
        ?>
" >
	<table class="data" rules="rows" >
		<thead>
		<tr>
			<th align="left" width="10%"><input type="checkbox" value="<?php 
        echo _AC('select_all');
        ?>
" id="all_del_<?php 
        echo $prefix;
        ?>
" title="<?php 
        echo _AC('select_all');
        ?>
" name="selectall_delchecks_<?php 
        echo $prefix;
        ?>
" onclick="CheckAll('del_checks_id_<?php 
        echo $prefix;
        ?>
[]','selectall_delchecks_<?php 
        echo $prefix;
        ?>
');" /></th>
			<th align="left" width="20%"><?php 
        echo _AC('html_tag');
        ?>
</th>
			<th align="left" width="20%"><?php 
        echo _AC('error_type');
        ?>
</th>
			<th align="left" width="40%"><?php 
        echo _AC('description');
        ?>
</th>
			<th align="left" width="10%"><?php 
        echo _AC('check_id');
        ?>
</th>
		</tr>
		</thead>
		
		<tfoot>
			<tr>
				<td colspan="5">
					<input type="submit" name="remove" value="<?php 
        echo _AC('remove');
        ?>
" onclick="javascript: return get_confirm();" />
				</td>
			</tr>
		</tfoot>

		<tbody>
<?php 
        foreach ($checks_array as $check_row) {
            ?>
		<tr onmousedown="document.getElementById('del_checks_<?php 
            echo $prefix . '_' . $check_row['check_id'];
            ?>
').checked = !document.getElementById('del_checks_<?php 
            echo $prefix . '_' . $check_row['check_id'];
            ?>
').checked; togglerowhighlight(this, 'del_checks_<?php 
            echo $prefix . '_' . $check_row['check_id'];
            ?>
');" 
		    onkeydown="document.getElementById('del_checks_<?php 
            echo $prefix . '_' . $check_row['check_id'];
            ?>
').checked = !document.getElementById('del_checks_<?php 
            echo $prefix . '_' . $check_row['check_id'];
            ?>
').checked; togglerowhighlight(this, 'del_checks_<?php 
            echo $prefix . '_' . $check_row['check_id'];
            ?>
');"
		    id="rdel_checks_<?php 
            echo $prefix . '_' . $check_row['check_id'];
            ?>
">
			<td><input type="checkbox" name="del_checks_id_<?php 
            echo $prefix;
            ?>
[]" value="<?php 
            echo $prefix . '_' . $check_row['check_id'];
            ?>
" id="del_checks_<?php 
            echo $prefix . '_' . $check_row['check_id'];
            ?>
" 
			           onmouseup="this.checked=!this.checked" onkeyup="this.checked=!this.checked" /></td>
			<td><?php 
            echo htmlspecialchars($check_row['html_tag']);
            ?>
</td>
			<td><?php 
            echo get_confidence_by_code($check_row['confidence']);
            ?>
</td>
			<td><span class="msg"><a target="_new" href="<?php 
            echo AC_BASE_HREF;
            ?>
checker/suggestion.php?id=<?php 
            echo $check_row["check_id"];
            ?>
" onclick="AChecker.popup('<?php 
            echo AC_BASE_HREF;
            ?>
checker/suggestion.php?id=<?php 
            echo $check_row["check_id"];
            ?>
'); return false;"><label for="del_checks_<?php 
            echo $prefix . '_' . $check_row['check_id'];
            ?>
"><?php 
            echo htmlspecialchars(_AC($check_row['name']));
            ?>
</label></a></span></td>
			<td><?php 
            echo $check_row['check_id'];
            ?>
</td>
		</tr>
<?php 
        }
        // end of foreach
        ?>
		</tbody>
	</table>
	<br/>
</form>
<?php 
    }
    // end of if
}
    echo htmlspecialchars($_POST['name']);
} else {
    echo htmlspecialchars(_AC($this->row['name']));
}
?>
</textarea></td>
		</tr>
	</table>

	<div class="row">
		<input type="submit" name="submit" value="<?php 
echo _AC('submit');
?>
" class="submit" /> 
		<input type="button" name="cancel" value="<?php 
echo _AC('cancel');
?>
" onclick="javascript: self.close(); return false;" class="submit"/>
	</div>
</fieldset>
</div>
</form>

<script type="text/JavaScript">
//<!--

function initial()
{
	// set cursor focus
	document.input_form.name.focus();
}
 /**
  * Validate fields preparing for insert and update
  * @access  private
  * @param   $title  
  *          $abbr
  *          $create_new: flag to indicate if this is creating new record or update.
  *                       true is to create new record, false is update record.
  *                       if update record, only check abbr uniqueness when abbr is modified.
  *          $guidelineID: must be given at updating record, when $create_new == false
  * @return  true    if all fields are valid
  *          false   if any field is not valid
  * @author  Cindy Qi Li
  */
 private function isFieldsValid($title, $abbr, $create_new, $guidelineID = 0)
 {
     global $msg;
     // check missing fields
     $missing_fields = array();
     if ($title == '') {
         $missing_fields[] = _AC('title');
     }
     if ($abbr == '') {
         $missing_fields[] = _AC('abbr');
     }
     if ($missing_fields) {
         $missing_fields = implode(', ', $missing_fields);
         $msg->addError(array('EMPTY_FIELDS', $missing_fields));
     }
     if (!$create_new) {
         $current_grow = $this->getGuidelineByIDs($guidelineID);
     }
     if ($create_new || !$create_new && $current_grow[0]['abbr'] != $abbr) {
         // abbr must be unique
         $sql = "SELECT * FROM " . TABLE_PREFIX . "guidelines WHERE abbr='" . $abbr . "'";
         if (is_array($this->execute($sql))) {
             $msg->addError('ABBR_EXISTS');
         }
     }
     if (!$msg->containsErrors()) {
         return true;
     } else {
         return false;
     }
 }
</td> \
			<td></td> \
			<td><INPUT type="hidden" NAME="overwrite_uploaded_file[{1}]" SIZE="40" style="max-width:100%" /></td> \
		</tr> \
		<tr> \
			<td><?php 
echo addslashes(_AC("upload_file"));
?>
</td> \
			<td><INPUT TYPE="file" NAME="overwrite_upload_file[{1}]" SIZE="40" style="max-width:100%" /></td> \
		</tr> \
	</table> \
	</div> \
	<div class="row" style="float:left"> \
		<input type="button" value="<?php 
echo addslashes(_AC("delete_this_file"));
?>
" onclick="del_file(event)" /> \
	</div> \
	<br /><br /> \
</div> \
';

//-->
</script>


<script language="JavaScript" type="text/javascript">
	var patch_files = <?php 
echo json_encode_result($this->file_rows);
?>
 /**
  * Validate fields preparing for insert and update
  * @access  private
  * @param   $validate_type : new/update. When validating for update, don't check if the login, email, name are unique  
  *          $user_group_id : user ID
  *          $login
  *          $email
  *          $first_name
  *          $last_name
  * @return  true    if update successfully
  *          false   if update unsuccessful
  * @author  Cindy Qi Li
  */
 private function isFieldsValid($validate_type, $user_group_id, $login, $email, $first_name, $last_name)
 {
     global $msg;
     $missing_fields = array();
     /* login name check */
     if ($login == '') {
         $missing_fields[] = _AC('login_name');
     } else {
         /* check for special characters */
         if (!preg_match("/^[a-zA-Z0-9_.-]([a-zA-Z0-9_.-])*\$/i", $login)) {
             $msg->addError('LOGIN_CHARS');
         } else {
             if ($validate_type == 'new') {
                 $sql = "SELECT * FROM " . TABLE_PREFIX . "users WHERE login='******'";
                 $rows_with_login = $this->execute($sql);
                 if (is_array($rows_with_login)) {
                     $msg->addError('LOGIN_EXISTS');
                 }
             }
         }
     }
     if ($user_group_id == '' || $user_group_id <= 0) {
         $missing_fields[] = _AC('user_group');
     }
     if ($email == '') {
         $missing_fields[] = _AC('email');
     } else {
         if (!preg_match("/^[a-z0-9\\._-]+@+[a-z0-9\\._-]+\\.+[a-z]{2,6}\$/i", $email)) {
             $msg->addError('EMAIL_INVALID');
         }
     }
     if ($validate_type == 'new') {
         $sql = "SELECT * FROM " . TABLE_PREFIX . "users WHERE email='" . $email . "'";
         $rows_with_email = $this->execute($sql);
         if (is_array($rows_with_email)) {
             $msg->addError('EMAIL_EXISTS');
         }
     }
     if (!$first_name) {
         $missing_fields[] = _AC('first_name');
     }
     if (!$last_name) {
         $missing_fields[] = _AC('last_name');
     }
     if ($missing_fields) {
         $missing_fields = implode(', ', $missing_fields);
         $msg->addError(array('EMPTY_FIELDS', $missing_fields));
     }
     if (!$msg->containsErrors()) {
         return true;
     } else {
         return false;
     }
 }
        }
    }
    if (!$msg->containsErrors()) {
        if (defined('AC_EMAIL_CONFIRMATION') && AC_EMAIL_CONFIRMATION) {
            //send confirmation email
            $row = $_current_user->getInfo();
            if ($row['email'] != $_POST['email']) {
                $code = substr(md5($_POST['email'] . $row['creation_date'] . $_SESSION['user_id']), 0, 10);
                $confirmation_link = AC_BASE_HREF . 'confirm.php?id=' . $_SESSION['user_id'] . SEP . 'e=' . urlencode($_POST['email']) . SEP . 'm=' . $code;
                /* send the email confirmation message: */
                require AC_INCLUDE_PATH . 'classes/phpmailer/acheckermailer.class.php';
                $mail = new ACheckerMailer();
                $mail->From = $_config['contact_email'];
                $mail->AddAddress($_POST['email']);
                $mail->Subject = SITE_NAME . ' - ' . _AC('email_confirmation_subject');
                $mail->Body = _AC('email_confirmation_message2', $_config['site_name'], $confirmation_link);
                $mail->Send();
                $msg->addFeedback('CONFIRM_EMAIL');
            } else {
                $msg->addFeedback('CHANGE_TO_SAME_EMAIL');
            }
        } else {
            //insert into database
            $_current_user->setEmail($_POST[email]);
            $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
        }
    }
}
$row = $_current_user->getInfo();
if (!isset($_POST['submit'])) {
    $_POST = $row;
 public static function getCssOutput()
 {
     // MB: To print the check on the rules of CSS
     // css rulesrelating the error
     // CSS: default font size and default font format
     //MB:per stampare le regole dei check sui CSS
     //regole css relative all'errore
     //CSS: default font size e default font format
     global $tag_size;
     global $csslist;
     global $array_css;
     global $background, $foreground;
     $back = $background;
     $fore = $foreground;
     $background = $foreground = '';
     $spazio = "{_}";
     $css_code = "";
     if (isset($array_css) && $array_css != null) {
         $tag_size = round($tag_size, 2);
         $css_code = $css_code . "<p>" . _AC("fixed_size_example_text") . ": <span style='font-size:20px;background-color:#" . $back . ";color:#" . $fore . "'>" . _AC("color_contrast_example") . "</span></p>";
         $bold = BasicChecks::get_p_css($e, "font-weight");
         //if($e->tag=="h1" || $e->tag=="h2" || $e->tag=="h3" || $e->tag=="h4" || $e->tag=="h5" || $e->tag=="h6")
         //	$bold="bold";
         if ($bold == "bold" || $bold >= 700 || $bold == "" && ($e->tag == "h1" || $e->tag == "h2" || $e->tag == "h3" || $e->tag == "h4" || $e->tag == "h5" || $e->tag == "h6")) {
             //$css_code = $css_code."Font size: ".$tag_size."points bold";
             $real_size_text = "<p>" . _AC("real_size_example_text") . " (" . $tag_size . " " . _AC("points") . " " . _AC("bold") . "): <span style='font-weight:bold;font-size:" . $tag_size . "pt;background-color:#" . $back . ";color:#" . $fore . "'>" . _AC("color_contrast_example") . "</span></p>";
         } else {
             //$css_code = $css_code."Font size: ".$tag_size."points";
             $real_size_text = "<p>" . _AC("real_size_example_text") . " (" . $tag_size . " " . _AC("points") . "): <span style='font-size:" . $tag_size . "pt;background-color:#" . $back . ";color:#" . $fore . "'>" . _AC("color_contrast_example") . "<span></p>";
         }
         $css_code = $css_code . $real_size_text;
         //------>
         $css_code .= "<p style='padding:1em'>" . _AC("element_CSS_rules") . ": </p>\n\t\n\t<pre>\n\t\n\t";
         $int_css = '';
         $ext_css = '';
         $size_of_css_list = sizeof($csslist);
         foreach ($array_css as $rule) {
             $temp_css_code = '';
             $num_to_end = sizeof($rule["prev"]) - 1;
             for ($i = $num_to_end; $i >= 0; $i--) {
                 $temp_css_code .= " " . $rule["prev"][$i];
             }
             $temp_css_code = str_ireplace(" .", ".", $temp_css_code);
             $temp_css_code = str_ireplace(" #", "#", $temp_css_code);
             $temp_css_code = str_ireplace(">.", "> .", $temp_css_code);
             $temp_css_code = str_ireplace(">#", "> #", $temp_css_code);
             $temp_css_code = str_ireplace("+.", "+ .", $temp_css_code);
             $temp_css_code = str_ireplace("+#", "+ #", $temp_css_code);
             $temp_css_code = str_ireplace(" " . $spazio, "", $temp_css_code);
             $temp_css_code = $temp_css_code . "{\n\t\n\t";
             foreach ($rule["regole"] as $prop => $value) {
                 $temp_css_code = $temp_css_code . "            " . $prop . ":" . $value["val"] . ";\n\t";
             }
             $temp_css_code = $temp_css_code . "      }\n\t\n\t";
             if ($rule["idcss"] == $size_of_css_list) {
                 //ultimo posto, stile interno
                 $int_css .= $temp_css_code;
             } else {
                 $ext_css[$csslist[$rule["idcss"]]] .= $temp_css_code;
             }
             //$css_code=$css_code._AC("external_CSS")." (<a title='external CSS link' href='".$csslist[$rule["idcss"]]."'>".$csslist[$rule["idcss"]]."</a>):\n\t\n\t      ";
         }
         if ($int_css != '') {
             $css_code .= _AC("internal_CSS") . ":\n\t\n\t " . $int_css;
         }
         if ($ext_css != '') {
             foreach ($ext_css as $url => $val) {
                 $css_code .= _AC("external_CSS") . " (<a title='external CSS link' href='" . $url . "'>" . $url . "</a>):\n\t\n\t      " . $val;
             }
         }
         $css_code .= "</pre>\n\t";
     }
     $array_css = array();
     return $css_code;
     //MB: per i check sui CSS (fine)
 }
unset($id);
// clean up the temporary id values set by vitals.inc.php
if (isset($_GET["id"])) {
    $id = intval($_GET["id"]);
}
$userGroupsDAO = new UserGroupsDAO();
// handle submits
if (isset($_POST['cancel'])) {
    $msg->addFeedback('CANCELLED');
    header('Location: user_group.php');
    exit;
} else {
    if (isset($_POST['save'])) {
        $title = trim($_POST['title']);
        if ($title == '') {
            $msg->addError(array('EMPTY_FIELDS', _AC('title')));
        }
        if (!$msg->containsErrors()) {
            if (isset($id)) {
                $userGroupsDAO->update($id, $title, trim($_POST['description']));
            } else {
                $id = $userGroupsDAO->Create($title, trim($_POST['description']));
            }
            if (!$msg->containsErrors()) {
                // add checks
                if (is_array($_POST['add_privileges_id'])) {
                    $userGroupPrivilegeDAO = new UserGroupPrivilegeDAO();
                    foreach ($_POST['add_privileges_id'] as $add_priv_id) {
                        $userGroupPrivilegeDAO->Create($id, $add_priv_id);
                    }
                }
 /**
  * Alter file based on <action_detail>
  * If user's local file is modified and user agrees to proceed with applying patch,
  * alter user's local file.
  * @access  private
  * @param   $row_num	row number of patch record to be processed
  * @author  Cindy Qi Li
  */
 function alterFile($row_num)
 {
     $local_file = $this->patch_array['files'][$row_num]['location'] . $this->patch_array['files'][$row_num]['name'];
     // backup user's file
     $backup_file = $local_file . "." . $this->backup_suffix;
     // Checking existence of $backup_file is to fix the bug when there are multiple alter/delete actions
     // on the same file, the following backups overwrite the first backup which results in the loss of the
     // original code.
     if (!file_exists($backup_file)) {
         $this->copyFile($local_file, $backup_file);
         $this->backup_files[] = realpath($backup_file);
     }
     $local_file_content = file_get_contents($local_file);
     // Modify user's file
     foreach ($this->patch_array['files'][$row_num]['action_detail'] as $garbage => $alter_file_action) {
         if ($alter_file_action['type'] == 'delete') {
             $modified_local_file_content = $this->strReplace($alter_file_action['code_from'], '', $local_file_content);
         }
         if ($alter_file_action['type'] == 'replace') {
             $modified_local_file_content = $this->strReplace($alter_file_action['code_from'], $alter_file_action['code_to'], $local_file_content);
         }
         // when code_from is not found, add in warning
         if ($modified_local_file_content == $local_file_content) {
             for ($i = 0; $i < count($this->backup_files); $i++) {
                 if ($this->backup_files[$i] == realpath($backup_file)) {
                     $this->backup_files[$i] .= ' ' . _AC("chunks_not_found");
                 }
             }
         } else {
             $local_file_content = $modified_local_file_content;
         }
         $this->createPatchesFilesActionsRecord($alter_file_action);
     }
     $fp = fopen($local_file, 'w');
     fwrite($fp, $local_file_content);
     fclose($fp);
     return true;
 }
 /**
  * Return all languages except the ones with language code in the given string 
  * @access  public
  * @param   $langCode : one language codes, for example: en
  * @return  table rows
  * @author  Cindy Qi Li
  */
 function ValidateFields($langCode, $charset, $nativeName, $englishName)
 {
     global $msg;
     $missing_fields = array();
     if ($langCode == '') {
         $missing_fields[] = _AC('lang_code');
     }
     if ($charset == '') {
         $missing_fields[] = _AC('charset');
     }
     if ($nativeName == '') {
         $missing_fields[] = _AC('name_in_language');
     }
     if ($englishName == '') {
         $missing_fields[] = _AC('name_in_english');
     }
     if ($missing_fields) {
         $missing_fields = implode(', ', $missing_fields);
         $msg->addError(array('EMPTY_FIELDS', $missing_fields));
         return false;
     }
     return true;
 }
    echo _AC($this->pages[$this->prev_page]['title_var']);
    ?>
 Alt+,"><?php 
    echo _AC($this->pages[$this->prev_page]['title_var']);
    ?>
</a><br />
	<?php 
}
?>

	<?php 
if (isset($this->next_page)) {
    ?>
		<?php 
    echo _AC('next_chapter');
    ?>
: <a href="frame_content.php?p=<?php 
    echo $this->next_page;
    ?>
" accesskey="," title="<?php 
    echo _AC($this->pages[$this->next_page]['title_var']);
    ?>
 Alt+,"><?php 
    echo _AC($this->pages[$this->next_page]['title_var']);
    ?>
</a><br />
	<?php 
}
?>
</div>
		<th scope="col">&nbsp;</th>
		<th scope="col"><?php 
echo _AC('html_tag');
?>
</th>
	</tr>
</thead>

<tfoot>
	<tr>
		<td colspan="2">
			<input type="submit" name="<?php 
echo _AC('select');
?>
" value="<?php 
echo _AC('select');
?>
" onclick="insertIntoParentWindow();"/>
		</td>
	</tr>
</tfoot>

<tbody>
<?php 
foreach ($this->all_html_tags as $row) {
    $html_tag_no_space = str_replace(' ', '', $row['html_tag']);
    ?>
	<tr onmousedown="document.form['m<?php 
    echo $html_tag_no_space;
    ?>
'].checked = true; rowselect(this);" 
    /**
     * private
     * writes report for CSS validation
     * return CSS validation result as HTML string
     */
    private function getCSS()
    {
        $provided_by = '';
        // str with error type and nr of errors
        if ($this->css_error == '' && $this->error_nr_css != -1) {
            $provided_by = '<ol><li class="msg_err">' . _AC("css_validator_provided_by") . '</li></ol>' . "\n";
        } else {
            if ($this->css_error == '' && $this->error_nr_css == -1) {
                // css validator is disabled
                $content = '<ol><li class="msg_err">
				<span class="info_msg">
					<img src="' . AC_BASE_HREF . 'images/info.png" width="15" height="15" alt="' . _AC("info") . '"/>  ' . _AC("css_validator_disabled") . '
				</span>
				</ol></li>';
            }
        }
        if ($this->css_error != '') {
            // non url input
            $content = '<ol><li class="msg_err">
				<span class="info_msg">
					<img src="' . AC_BASE_HREF . 'images/info.png" width="15" height="15" alt="' . _AC("info") . '"/>  ' . $this->css_error . '
				</span>
				</ol></li>';
        } else {
            // ok -> show css validation result
            if ($this->error_nr_css == 0) {
                // no errors
                $content = "<ul><li class='msg_info'>\n\t\t\t\t<span class='congrats_msg'>\n\t\t\t\t\t<img src='" . AC_BASE_HREF . "images/feedback.gif' alt='" . _AC("feedback") . "' />  " . _AC("congrats_css_validation") . "\n\t\t\t\t</span>\n\t\t\t\t</ul></li>";
            } else {
                // errors exist
                $content = $this->css;
            }
        }
        return str_replace(array('{DETAIL_TITLE}', '{DIV_ID}', '{DETAIL}'), array(_AC('css_validation_result'), 'css_validation', $provided_by . $content), $this->html_detail);
    }
</fieldset>
</form>
</div>

<div class="center-input-form">
<form name="frm_upload" enctype="multipart/form-data" method="post" action="<?php 
echo $_SERVER['PHP_SELF'];
?>
" >
	<fieldset class="group_form"><legend class="group_form"><?php 
echo _AC("upload");
?>
</legend>
	
		<div class="row"><?php 
echo _AC("upload_update");
?>
</div>

		<div class="row">
			<input type="hidden" name="MAX_FILE_SIZE" value="52428800" />
			<input type="file" name="patchfile"  size="50" />
		</div>
		
		<div class="row buttons">
			<input type="submit" name="install_upload" value="Install" onclick="javascript: return validate_filename(); " class="submit" />
			<input type="hidden" name="uploading" value="1" />
		</div>
	</fieldset>
</form>
</div>
    /** 
     * public
     * return error report in html
     * parameters: $errors: errors array
     * author: Cindy Qi Li
     */
    public static function generateErrorRpt($errors)
    {
        // html error template
        $html_error = '<div id="error">
	<h4>{ERROR_MSG_TITLE}</h4>
	{ERROR_DETAIL}
</div>';
        $html_error_detail = '		<ul>
			<li>{ERROR}</li>
		</ul>
';
        if (!is_array($errors)) {
            return false;
        }
        foreach ($errors as $err) {
            $error_detail .= str_replace("{ERROR}", _AC($err), $html_error_detail);
        }
        return str_replace(array('{ERROR_MSG_TITLE}', '{ERROR_DETAIL}'), array(_AC('the_follow_errors_occurred'), $error_detail), $html_error);
    }
 /**
  * Validate fields for insert and update
  * @access  private
  * @param   $guideline_ids
  *          $URI
  * @return  true    if update successfully
  *          false   if update unsuccessful
  * @author  Cindy Qi Li
  */
 private function isFieldsValid($guideline_ids, $URI)
 {
     global $msg;
     $missing_fields = array();
     /* login name check */
     if ($guideline_ids == '') {
         $missing_fields[] = _AC('guideline_ids');
     }
     if ($URI == '') {
         $missing_fields[] = _AC('URI');
     }
     if ($missing_fields) {
         $missing_fields = implode(', ', $missing_fields);
         $msg->addError(array('EMPTY_FIELDS', $missing_fields));
     }
     if ($msg->containsErrors()) {
         return false;
     } else {
         return true;
     }
 }
 /**
  * private
  * prints report for CSS validation; corresponding array in class should be set before calling
  */
 private function printCSS()
 {
     // str with error type and nr of errors
     if ($this->css_error == '' && $this->error_nr_css != -1) {
         $this->SetFont('DejaVu', 'B', 14);
         $this->SetTextColor(0);
         $this->Write(5, _AC('file_report_css') . ' (' . $this->error_nr_css . ' ' . _AC('file_report_found') . '):');
         $this->Ln(10);
         $this->SetFont('DejaVu', 'B', 12);
         $this->Write(5, strip_tags(_AC("css_validator_provided_by")));
         $this->Ln(10);
     } else {
         if ($this->css_error == '' && $this->error_nr_css == -1) {
             // css validator is disabled
             $this->SetTextColor(0, 0, 255);
             $path = AC_BASE_HREF . "images/jpg/info.jpg";
             $this->Image($path, $this->GetX(), $this->GetY(), 4, 4);
             $this->SetX(14);
             $this->SetFont('DejaVu', 'B', 12);
             $this->Write(5, _AC("css_validator_disabled"));
             $this->SetTextColor(0);
         }
     }
     if ($this->css_error != '') {
         // css validator is only available at validating url, not at validating a uploaded file or pasted html
         $this->Ln(3);
         $this->SetTextColor(0, 0, 255);
         $path = AC_BASE_HREF . "images/jpg/info.jpg";
         $this->Image($path, $this->GetX(), $this->GetY(), 4, 4);
         $this->SetX(14);
         $this->SetFont('DejaVu', 'B', 12);
         $this->Write(5, $this->css_error);
     } else {
         if ($this->error_nr_css == 0) {
             // show congratulations if no errors found
             $this->Ln(3);
             $this->SetTextColor(0, 128, 0);
             $path = AC_BASE_HREF . "images/jpg/feedback.jpg";
             $this->Image($path, $this->GetX(), $this->GetY(), 4, 4);
             $this->SetX(14);
             $this->SetFont('DejaVu', 'B', 12);
             $this->Write(5, _AC("congrats_css_validation"));
         } else {
             // else make report on errors
             foreach ($this->css as $uri => $group) {
                 // uri
                 $this->Ln(3);
                 $this->SetX(17);
                 $this->SetTextColor(0);
                 $this->SetFont('DejaVu', 'B', 10);
                 $this->Write(5, "URI: ");
                 $this->SetTextColor(26, 74, 114);
                 $this->SetFont('DejaVu', 'B', 12);
                 $this->Write(5, $uri);
                 $this->Ln(10);
                 foreach ($group as $error) {
                     // line, code
                     $this->SetX(17);
                     $this->SetTextColor(0);
                     $this->SetFont('DejaVu', 'BI', 9);
                     $location = _AC('line') . " " . $error['line'] . ":  ";
                     $this->Write(5, $location);
                     if ($error['code'] != '') {
                         $this->SetFont('DejaVu', '', 9);
                         $this->Write(5, $error['code']);
                     }
                     $this->Ln(7);
                     // parse
                     if ($error['parse'] != '') {
                         $this->SetX(17);
                         $this->SetFont('DejaVu', '', 10);
                         $str = str_replace("\t", "    ", strip_tags(htmlspecialchars_decode(html_entity_decode($error['parse']), ENT_QUOTES)));
                         $this->Write(5, $str);
                         $this->Ln(10);
                     }
                 }
                 // end foreach error
             }
             // end foreach group
         }
     }
 }
        } else {
            echo _AC('disabled');
        }
        ?>
</td>
		<?php 
    }
    ?>
		<?php 
    if ($this->isAdmin) {
        ?>
		<td><?php 
        if ($row['open_to_public']) {
            echo _AC('yes');
        } else {
            echo _AC('no');
        }
        ?>
</td>
		<?php 
    }
    ?>
	</tr>
<?php 
}
?>
</tbody>

</table>
</fieldset>
</div>