public static function nettoyer_chemin($chemin, $est_un_motif = false)
 {
     // SÉCURITÉ : $chemin nettoyé
     //   * Ne contient pas '\0'
     //   * Ne contient pas '../'
     //   * Ne contient pas de double occurence de '/'
     //   * Ne se termine pas par '/'
     //   * Ne commence pas par '/'
     //   * Est découpé en segments
     //   * Chaque segment est nettoyé avec nettoyer_segment().
     $chemin = preg_replace("/\\0/", '', $chemin);
     // TODO : vérifier si c'est bien ça ! (supprime _toutes_ les occurences ???)
     $chemin = Path::normalize($chemin);
     $chemin = preg_replace("/^\\/*/", '', $chemin);
     $chemin = preg_replace("/\\/*\$/", '', $chemin);
     $segments = qw($chemin, '/');
     if ($est_un_motif) {
         $segments = array_map(array("self", "nettoyer_segment_motif"), $segments);
     } else {
         $segments = array_map(array("self", "nettoyer_segment"), $segments);
     }
     return $segments;
 }
Exemple #2
0
 function createDrawCommand($fname, $graph, $mode_name)
 {
     $this->graph = $graph;
     $ALL_MODES = qw('w>500 h>150 step>60 expire>300 e>now use_prev>0');
     $MODES = array('index' => qw('s>now-36h w>120 h>80 expire>5'), 'std' => qw('s>now-24h use_prev>1 step>600 expire>5'), 'daily' => qw('s>now-36h title>Daily'), 'weekly' => qw('s>now-2w title>Weekly'), 'monthly' => qw('s>now-2m title>Monthly'), 'annual' => qw('s>now-2y title>Annual'));
     $EXTRA = array('index' => qw('--only-graph'), 'daily' => array('--x-grid=HOUR:1:HOUR:3:HOUR:6:21600:%a %H:%M'), 'weekly' => qw('--x-grid=HOUR:6:DAY:1:DAY:1:86400:%a'));
     $mode = array_merge($ALL_MODES, $MODES[$mode_name]);
     header("Cache-control: public");
     header("Cache-control: max-age={$mode['expire']}");
     if (file_exists($fname) and filemtime($fname) >= time() - $mode['expire']) {
         return '';
     }
     $this->rrd_mask = $this->_rrdDir . '/' . $graph['rrd'] . '.rrd';
     $this->rrds = glob($this->rrd_mask);
     if (count($this->rrds) == 0) {
         trigger_error("No one RRD found for `{$this->rrd_mask}'", E_USER_ERROR);
     }
     $this->rrd_mask = preg_replace('/\\*/', '(.*)', $this->rrd_mask);
     $this->defs = array('def' => array(), 'vdef' => array(), 'cdef' => array(), 'draw' => array(), 'draw-th' => array());
     $len = 10 + ($graph['print-unit'] ? strlen($graph['print-unit']) + 1 : 0);
     $this->defs['draw'][] = "COMMENT:" . str_pad("Cur  ", $len, ' ', STR_PAD_LEFT) . str_pad("Min  ", $len, ' ', STR_PAD_LEFT) . str_pad("Max  ", $len, ' ', STR_PAD_LEFT) . ' (' . str_replace(':', '\\:', strftime('%F %T')) . ')\\n';
     foreach ($graph->children() as $type => $info) {
         $name = $this->add_var($info, $type);
         if ($mode['use_prev'] ? $graph['prev'] : 0) {
             $info['color'] = $info['prev-color'] ? '' . $info['prev-color'] : $info['color'] . '/80';
             $info['label'] .= ' (prev day)';
             $this->add_var($info, 'line', 86400);
         }
     }
     $attrs = $graph->attributes();
     unset($attrs['name'], $attrs['rrd'], $attrs['index'], $attrs['prev'], $attrs['dwmy'], $attrs['print-unit']);
     if ($mode == 'std') {
         unset($attrs['rigid']);
     }
     $extra = (array) @$EXTRA[$mode_name];
     foreach ($attrs as $n => $v) {
         if ($n == 'title' and @$mode['title']) {
             $v = $mode['title'] . ' ' . $v;
         }
         $extra[] = $v == '' ? "--{$n}" : "--{$n}={$v}";
     }
     return join(' ', array_map('escapeshellarg', array_merge(array('rrdtool', 'graph', $fname, "--start={$mode['s']}", "--end={$mode['e']}", "--width={$mode['w']}", @$mode['extra'], "--height={$mode['h']}", "--step={$mode['step']}"), $extra, $this->defs['def'], $this->defs['cdef'], $this->defs['vdef'], $this->defs['draw'], $this->defs['draw-th'])));
 }
Exemple #3
0
});
</script>
<div ng-controller="libraryController">
	<legend>
		<?php 
echo $library['title'];
?>
		<div class="btn-group pull-right">
			<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
				<i class="fa fa-cog"></i> Tools <span class="caret"></span>
			</a>
			<ul class="dropdown-menu" ng-include="'/partials/library-verbs.html'"></ul>
		</div>
	</legend>

	<? if (in_array($library['status'], qw('dedupe deduped'))) { ?>
	<div class="alert alert-info alert-block">
		<a href="#" data-dismiss="alert" class="close"><i class="fa fa-times-sign"></i></a>
		<h3><i class="fa fa-bell-o icon-animated-bell"></i> De-duplication in progress</h3>
		<p>This library is still marked as having duplicate references.</p>
		<div class="pull-center pad-top">
			<a class="btn" href="/libraries/dedupe/<?php 
echo $library['libraryid'];
?>
"><i class="fa fa-compress"></i> Examine duplicates</a>
			<a class="btn" href="/libraries/finish/<?php 
echo $library['libraryid'];
?>
"><i class="fa fa-stop"></i> Stop de-duping</a>
			<a class="btn" href="#" data-dismiss="alert"><i class="fa fa-times-sign"></i> Not right now</a>
		</div>
Exemple #4
0
 /**
  * API for setting the reference tag of an item
  * @param int $_REQUEST['referenceid'] The reference ID to work on
  * @param int $_REQUEST['tagid'] The ID of the tag to set
  */
 function JSONSetTag()
 {
     $this->load->model('Reference');
     foreach (qw('referenceid tagid') as $key) {
         if (!isset($_REQUEST[$key])) {
             die($this->site->JSONError("Missing parameter: {$key}"));
         }
     }
     if (!($reference = $this->Reference->Get($_REQUEST['referenceid']))) {
         $this->site->JSONError('Invalid reference');
     }
     if (!($library = $this->Library->Get($reference['libraryid']))) {
         $this->site->JSONError('Invalid library');
     }
     if (!$this->Library->CanEdit($library)) {
         $this->site->JSONError('You do not have access to this library');
     }
     $reference['referencetagid'] = $_REQUEST['tagid'];
     $this->Reference->Save($reference['referenceid'], $reference);
     $tags = array(0 => $this->Reference->Count(array('libraryid' => $library['libraryid'], 'status !=' => 'deleted')));
     foreach ($this->Library->GetAllTags($library['libraryid']) as $tag) {
         $tags[$tag['referencetagid']] = $this->Reference->Count(array('libraryid' => $library['libraryid'], 'status !=' => 'deleted', 'referencetagid' => $tag['referencetagid']));
     }
     $this->site->JSON(array('header' => array('status' => 'ok'), 'tags' => $tags));
 }
Exemple #5
0
	function Save($userid, $data) {
		$fields = array();
		
		//Allow authenticated admins to change the company assigned to a user
		foreach (qw('fname lname username email') as $field)
			if (isset($data[$field]))
				$fields[$field] = $data[$field];
		if (isset($data['password']))
			$fields['passhash'] = $this->HashSet($data['password']);
		if (isset($data['email']))
			$fields['username'] = $data['email'];

		if ($fields) {
			$this->db->where('userid', $userid);
			$this->db->update('users', $fields);
			$this->Log->Add('user', "Changed user #$userid details: " . $this->Log->NiceArray($fields));
			if (isset($_SESSION['user']) && $_SESSION['user']['userid'] == $userid) // Changing self
				$_SESSION['user'] = array_merge($_SESSION['user'], $this->Get($userid, TRUE));
			return TRUE;
		} else {
			return FALSE;
		}
	}
 public static function enregister_module($classe, $type, $get_post = array(), $post = array(), $file = array())
 {
     self::$liste_modules[$type] = array("classe" => $classe, "get_post" => qw($get_post), "post" => qw($post), "file" => qw($file));
     self::$liste_modules[$type]["get_post"][] = "action";
     // Toujours présent.
 }