Exemplo n.º 1
0
    $q->execute(array($page_id));
    $count = $q->fetch();
    $count = $count['c'];
    if ($count >= get_premium_value($user, 'graphs_per_page')) {
        $errors[] = t("Cannot add graph: too many existing graphs on this page.") . ($user['is_premium'] ? "" : " " . t("To add more graphs on this page, upgrade to a :premium_account.", array(':premium_account' => link_to(url_for('premium'), t('premium account')))));
        set_temporary_errors($errors);
        redirect(url_for('profile', array('page' => $page_id)));
    }
}
// only permit valid values
$graph_types = graph_types();
$permitted_days = array();
foreach (get_permitted_days() as $key => $data) {
    $permitted_days[] = $data['days'];
}
$permitted_deltas = get_permitted_deltas();
if (!isset($graph_types[$graph_type])) {
    throw new Exception("Invalid graph type '" . htmlspecialchars($graph_type) . "'");
} else {
    if (!is_numeric($width) || $width < 1 || $width > 16) {
        throw new Exception("Invalid width '" . htmlspecialchars($width) . "'");
    } else {
        if (!is_numeric($height) || $height < 1 || $height > 16) {
            throw new Exception("Invalid height '" . htmlspecialchars($height) . "'");
        } else {
            if ($days && !in_array($days, $permitted_days)) {
                throw new Exception("Invalid days '" . htmlspecialchars($day) . "'");
            } else {
                if (!isset($permitted_deltas[$delta])) {
                    throw new Exception("Invalid delta '" . htmlspecialchars($delta) . "'");
                } else {
Exemplo n.º 2
0
    echo htmlspecialchars($days['title']);
    ?>
</option>
<?php 
}
?>
  </select></td>
</tr>
<tr id="add_graph_delta" style="display:none;">
  <th><?php 
echo ht("Delta:");
?>
</th>
  <td><select name="delta">
<?php 
foreach (get_permitted_deltas() as $key => $days) {
    ?>
    <option value="<?php 
    echo htmlspecialchars($key);
    ?>
"><?php 
    echo htmlspecialchars($days['description']);
    ?>
</option>
<?php 
}
?>
  </select></td>
</tr>
<tr id="add_graph_technical" style="display:none;">
  <th><?php