Beispiel #1
0
                    foreach ($subscriptions as $sub) {
                        $user_id = $sub['user_id'];
                        if (!in_array($user_id, $alt_ids) && $user_id != $id_user_session) {
                            $user = new User($sub['user_id']);
                            $recipients[] = array("mail" => $user->getEmail(), "name" => $user->getUsername());
                        }
                    }
                    if (!empty($recipients)) {
                        // Send the mail to everybody
                        notify_multiple_users($user_session, $recipients, $subject_mail, $content_mail);
                        fMessaging::create('success', fURL::get(), 'The mail "' . $subject_mail . '" was successfully sent to all the users who subscribe to "' . $check->getName() . '"');
                    } else {
                        fMessaging::create('error', fURL::get(), "Nobody subscribe to this check");
                    }
                }
            }
        } catch (fNotFoundException $e) {
            fMessaging::create('error', $manage_url, 'The check requested, ' . fHTML::encode($check_id) . ', could not be found');
            fURL::redirect($manage_url);
        } catch (fExpectedException $e) {
            fMessaging::create('error', fURL::get(), $e->getMessage());
        }
        $page_num = fRequest::get('page', 'int', 1);
        $url_redirect = CheckResult::makeURL('list', $check) . "&page=" . $page_num;
        fURL::redirect($url_redirect);
    } else {
        $page_num = fRequest::get('page', 'int', 1);
        $check_results = CheckResult::findAll($check_id, false, $GLOBALS['PAGE_SIZE'], $page_num);
        include VIEW_PATH . '/list_check_results.php';
    }
}
 /**
  * Set the sort direction to be used on returning pages
  *
  * @param  string $sort_direction  The sort direction to save
  * @return void
  */
 private static function setPreviousSortDirection($sort_direction)
 {
     fSession::set(__CLASS__ . '::' . fURL::get() . '::previous_sort_direction', $sort_direction);
 }
Beispiel #3
0
<?php

$tmpl->set('title', 'Log In');
$tmpl->set('no-nav', true);
$tmpl->place('header');
?>
   <form action="<?php 
echo fURL::get() . '?action=log_in';
?>
" method="post">
     <div class="main" id="main">
       <fieldset>
         <div class="clearfix">
           <label for="username">Username</label>
           <div class="input">
             <input id="username" type="text" name="username" value="<?php 
echo fRequest::get('username');
?>
" />
           </div>
         </div><!-- /clearfix -->
         <div class="clearfix">
           <label for="password">Password</label>
           <div class="input">
             <input id="password" type="password" name="password" value="" />
           </div>
         </div><!-- /clearfix -->
         <div class="actions">       
           <input class="btn" type="submit" value="Log In" />
           <a class="btn" href="<?php 
echo User::makeUrl('add');
Beispiel #4
0
    // Get list of models
    $models = Model::getSimple($db);
    // Get types
    if (feature('consumable_types')) {
        $types = Tag::get_by_type('consumable_type');
    }
    include 'views/consumables/addedit.php';
}
/**
 * Delete a consumable
 */
if ($action == 'delete') {
    // Get ID
    $id = fRequest::get('id', 'integer');
    try {
        $c = new Consumable($id);
        if (fRequest::isPost()) {
            $c->delete();
            fMessaging::create('success', fURL::get(), 'The consumable ' . $c->getName() . ' was successfully deleted.');
            fURL::redirect(fURL::get());
        }
    } catch (fNotFoundException $e) {
        fMessaging::create('error', fURL::get(), 'The consumable requested, ID ' . $id . ', could not be found.');
        fURL::redirect($manage_url);
    } catch (fExpectedException $e) {
        fMessaging::create('error', fURL::get(), $e->getMessage());
    } catch (fSQLException $e) {
        fMessaging::create('error', fURL::get(), 'Database error: ' . $e->getMessage());
    }
    include 'views/consumables/delete.php';
}
Beispiel #5
0
 /**
  * Validates a request token generated by ::generateCSRFToken()
  * 
  * This method takes a request token and ensures it is valid, otherwise
  * it will throw an fValidationException.
  * 
  * @throws fValidationException  When the CSRF token specified is invalid
  * 
  * @param  string $token  The request token to validate
  * @param  string $url    The URL to validate the token for, default to the current page
  * @return void
  */
 public static function validateCSRFToken($token, $url = NULL)
 {
     if ($url === NULL) {
         $url = fURL::get();
     }
     $key = __CLASS__ . '::' . $url . '::csrf_tokens';
     $tokens = fSession::get($key, array());
     if (!in_array($token, $tokens)) {
         throw new fValidationException('The form submitted could not be validated as authentic, please try submitting it again');
     }
     $tokens = array_diff($tokens, array($token));
     fSession::set($key, $tokens);
 }
Beispiel #6
0
        </div>
      </div>
<?php 
}
?>
<div class="container-fluid">
<?php 
$breadcrumbs = $this->get('breadcrumbs');
if (is_array($breadcrumbs)) {
    echo '<ul class="breadcrumb">';
    $crumb_count = count($breadcrumbs);
    $crumb_counter = 1;
    foreach ($breadcrumbs as $crumb) {
        echo '<li' . (isset($crumb['class']) ? ' class="' . $crumb['class'] . '"' : ' class="active"') . '><a href="' . $crumb['url'] . '">' . $crumb['name'] . '</a>';
        if ($crumb_counter < $crumb_count) {
            echo '<span class="divider">/</span></li>';
        }
        $crumb_counter++;
    }
    echo '</ul>';
}
if (fMessaging::check('error', fURL::get())) {
    echo '<div class="alert-message error">';
    fMessaging::show('error', fURL::get());
    echo '</div>';
}
if (fMessaging::check('success', fURL::get())) {
    echo '<div class="alert-message success">';
    fMessaging::show('success', fURL::get());
    echo '</div>';
}
$tmpl->set('title', 'Self Service Alerts based on Graphite metrics');
$active_tab_alerts = " class=active";
$tmpl->set('breadcrumbs', $breadcrumbs);
$tmpl->place('header');
?>
<script type="text/javascript">
$(function(){
	$('#list_of_filters').change(function(){
		$(location).attr('href',$('#list_of_filters').val());
	});
});
</script>
<?php 
try {
    $checks->tossIfEmpty();
    $affected = fMessaging::retrieve('affected', fURL::get());
    ?>

<script type="text/javascript">
    function filterChecks() {
            var filter_text = $("#filter_text").val();
            var type = '<?php 
    echo $check_type;
    ?>
';
            var filter_group_id = <?php 
    echo $filter_group_id;
    ?>
;
            $.get(
                'inc/views/list_filtered_checks.php', 
$breadcrumbs[] = array('name' => $graph->prepareName(), 'url' => Graph::makeURL('edit',$graph),'active'=> false);
$breadcrumbs[] = array('name' => $page_title, 'url' => fURL::getWithQueryString(),'active'=> true);
$tmpl->set('breadcrumbs',$breadcrumbs);
$tmpl->place('header');
if (isset($line_id)) {
  $query_string = "&line_id=$line_id";
} elseif (isset($graph_id)) {
  $query_string = "&graph_id=$graph_id";  
} else {
  $query_string = '';
}
?>
  <div class="row">
    <div class="span6">
      <form action="<?php 
echo fURL::get();
?>
?action=<? echo $action.$query_string; ?>" method="post">
        <div class="main" id="main">
          <fieldset>
                <div class="clearfix">
	      <label for="line-alias">Alias<em>*</em></label>
              <div class="input">
	        <input id="line-alias" class="span3" type="text" size="30" name="alias" value="<?php 
echo $line->encodeAlias();
?>
" />
              </div>
            </div><!-- /clearfix -->
            <div class="clearfix">
              <label for="line-target">Target<em>*</em></label>
Beispiel #9
0
<?php
$page_title = ($action == 'add' ? 'Add a Check' : 'Editing : ' . $check->encodeName());
$tmpl->set('title', $page_title);
$breadcrumbs[] = array('name' => $page_title, 'url' => fURL::get(), 'active' => true);
$tmpl->set('breadcrumbs',$breadcrumbs);
$tmpl->place('header');
?>
<script>
  $(document).ready(function() {
    $("fieldset.startCollapsed").collapse( { closed: true } );
  });
</script>
  <div class="row">
    <div class="span4">
      <form class="form-stacked" action="<?=fURL::get(); ?>?action=<?=$action; ?>&check_id=<?=$check_id; ?>" method="post">
        <div class="main" id="main">
          <fieldset>
            <div class="clearfix">
	      <label for="check-name">Name<em>*</em></label>
              <div class="input">
	        <input id="check-name" class="span3" type="text" size="30" name="name" value="<?=$check->encodeName(); ?>" />
              </div>
            </div><!-- /clearfix -->
            <div class="clearfix">
	      <label for="check-target">Graphite Target<em>*</em></label>
              <div class="input">
                <input id="check-target" class="span3" type="text" size="30" name="target" value="<?=$check->encodeTarget(); ?>" />
              </div>
            </div><!-- /clearfix -->
	    <div class="clearfix">
	      <label for="check-error">Error Threshold<em>*</em></label>
Beispiel #10
0
     <td><?=$visibility_array[$check->getVisibility()]; ?></td>
     <td><?php if (fSession::get('user_id') == $check->getUserId()) { 
                 echo '<a href="' . Check::makeURL('edit', $check) . '">Edit</a> |'; 
               } ?>
     <a href="<?=Subscription::makeURL('add', $check); ?>">Subscribe</a></td>
     </tr>
 <?php } ?>
 </tbody></table>
 <?
 //check to see if paging is needed
 $total_pages = ceil($checks->count(TRUE) / $GLOBALS['PAGE_SIZE']);
 if ($total_pages > 1) {
   $prev_class = 'previous';
   $prev_link = fURL::get() . '?page=' . ($page_num - 1);
   $next_class = 'next';
   $next_link = fURL::get() . '?page=' . ($page_num + 1);
   if ($page_num == 1) {
     $prev_class .= ' disabled';
     $prev_link = '#';
   } elseif ($page_num == $total_pages) {
     $next_class .= ' disabled';
     $next_link = '#';
   }
   ?>
   <div class="pagination">
     <ul class="pager">
       <li class="<?=$prev_class; ?>">
         <a href="<?=$prev_link; ?>">&larr; Previous</a>
       </li>
       <li class="<?=$next_class; ?>">
         <a href="<?=$next_link; ?>">Next &rarr;</a>
Beispiel #11
0
        printf($colour, 'FFCC00');
    }
    if ($c->col_m) {
        printf($colour, 'CC0099');
    }
    if ($c->col_k) {
        printf($colour, '000');
    }
    echo '</td>';
    echo '<td><span class="name">' . $c->name . '</span></td>';
    echo '<td><span class="for">' . $c->model . '</span></td>';
    $bar = '<td width="110"><div class="progress-container"><div style="width: %d%%; background: #%s"></div></div></td>';
    printf($bar, $c->qty_percent, $qtycol);
    echo '<td align="center" width="20"><span class="qty">' . $c->qty . '</span></td>';
    // URL for updating stock
    $url = sprintf('stock.php?consumable_id=%d&redirect=%s', $c->id, fURL::get());
    echo '<td align="center" width="20" valign="middle"><a href="' . $url . '" rel="stock">';
    echo '<img src="web/img/package_green.png" width="16" height="16" alt="Enter new stock" />';
    echo '</a></td>';
    echo '</tr>';
}
?>

</table>

<script type="text/javascript">
$(document).ready(function(){
	// Filter tick-boxes. Hides rows.
	$('#consumable-filter input').click(function(){
		var row = $('table.consumables tr.consumable-' + $(this).attr("rel"));
		(!$(this).is(':checked')) ? row.hide() : row.show();
Beispiel #12
0
?>
</h1>

<p class="nav">
	<a href="<?php 
echo Check::makeURL('list');
?>
">List all checks</a> |
	<a class="related" href="<?php 
echo Check::makeURL('edit', $check);
?>
">Edit this check</a>
</p>

<?php 
fMessaging::show('error', fURL::get());
?>

<form action="<?php 
echo Check::makeURL('delete', $check);
?>
" method="post">
	
	<p class="warning">
		Are you sure you want to delete the check
		<strong><?php 
echo $check->prepareTitle();
?>
</strong>?
	</p>
	
Beispiel #13
0
 public static function is_menu_active($menu_to_active, $type = NULL)
 {
     $menu_included_in = array('result.php' => 'index', 'graphs.php' => 'dashboard', 'lines.php' => 'dashboard', 'groups.php' => 'group');
     $result = FALSE;
     $current_url = fURL::get();
     $pos_last_slash = strrpos($current_url, "/");
     $url_to_check = substr($current_url, $pos_last_slash + 1, strlen($current_url) - $pos_last_slash);
     if (in_array($url_to_check, array_keys($menu_included_in))) {
         $corresponding_menu = $menu_included_in[$url_to_check];
         if ($menu_to_active == $corresponding_menu) {
             $result = TRUE;
         }
     } else {
         // If it isn't in the array, we try to test manually
         if ($url_to_check == $menu_to_active . ".php") {
             $result = TRUE;
         }
     }
     if (!empty($type)) {
         $result = $result && strpos(fURL::getQueryString(), $type) !== FALSE;
     }
     return $result;
 }
 	<tr>
     <td><?=($check_result->prepareStatus() == 2 ? 'Warning' : 'Error'); ?></td>
     <td><?=$check_result->prepareValue(); ?></td>
     <td><?=$check->prepareError(); ?></td>
     <td><?=$check->prepareWarn(); ?></td>
     <td><?=$check_result->prepareState(); ?></td>
     <td><?=$check_result->prepareTimestamp('Y-m-d H:i:s'); ?></td>
     </tr>
 <?php } ?>
 </table></div>
 <?
 //check to see if paging is needed
 $total_pages = ceil($check_results->count(TRUE) / $GLOBALS['PAGE_SIZE']);
 if ($total_pages > 1) {
   $prev_class = 'previous';
   $current_link = fURL::get() . "?action=$action&check_id=$check_id";
   $prev_link = $current_link . '&page=' . ($page_num - 1);
   $next_class = 'next';
   $next_link = $current_link . '&page=' . ($page_num + 1);
   if ($page_num == 1) {
     $prev_class .= ' disabled';
     $prev_link = '#';
   } elseif ($page_num == $total_pages) {
     $next_class .= ' disabled';
     $next_link = '#';
   }
   ?>
   <div class="pagination">
     <ul class="pager">
       <li class="<?=$prev_class; ?>">
         <a href="<?=$prev_link; ?>">&larr; Previous</a>
Beispiel #15
0
<?php
$page_title = ($action == 'add' ? 'Add a Check' : 'Editing : ' . $check->encodeName());
$tmpl->set('title', $page_title);
$breadcrumbs[] = array('name' => $page_title, 'url' => fURL::get(), 'active' => true);
$tmpl->set('breadcrumbs',$breadcrumbs);
$tmpl->place('header');
?>
<script>
	$(document).ready(function() {
		$("fieldset.startCollapsed").collapse( { closed: true } );
	});
</script>
  <div class="row">
    <div class="span4">
      <form class="form-stacked" action="<?php echo fURL::get() ?>?action=<? echo $action; ?>&check_id=<? echo $check_id; ?>" method="post">
        <div class="main" id="main">
          <fieldset>
            <div class="clearfix">
	      <label for="check-name">Name<em>*</em></label>
              <div class="input">
	        <input id="check-name" class="span3" type="text" size="30" name="name" value="<?php echo $check->encodeName() ?>" />
              </div>
            </div><!-- /clearfix -->
            <div class="clearfix">
	      <label for="check-target">Graphite Target<em>*</em></label>
              <div class="input">
                <input id="check-target" class="span3" type="text" size="30" name="target" value="<?php echo $check->encodeTarget() ?>" />
              </div>
            </div><!-- /clearfix -->
	    <div class="clearfix">
	      <label for="check-error">Error Threshold<em>*</em></label>