コード例 #1
0
ファイル: source.php プロジェクト: quickpacket/noclayer
 public function action_edit()
 {
     if ($_POST) {
         $val = \Validation::forge();
         $val->add_field('type', 'Action', 'required|min_length[1]|max_length[20]');
         $val->add_field('url', 'Value', 'required|min_length[1]');
         $val->add_field('usr', 'Value', 'max_length[200]');
         $val->add_field('pwd', 'Value', 'max_length[200]');
         $val->add_field('eid', 'Value', 'max_length[200]');
         if ($val->run()) {
             // add munin later...
             $cacti = new \Cacti($val->validated('url'));
             $code = $cacti->testConnection($val->validated('usr'), $val->validated('pwd'));
             if ($code == 200) {
                 $graph = Model_Source::find($val->validated('eid'));
                 if ($graph) {
                     //$graph->'typeID'=>$val->validated('type');
                     $graph->user = $val->validated('usr');
                     $graph->pass = $val->validated('pwd');
                     $graph->content = $val->validated('url');
                     $graph->meta_update_time = time();
                     //'meta_update_user'=>$this->user
                     //);
                     //$source=new Model_Graphing_Source($q);
                     $graph->save();
                     $code = 'ok';
                 } else {
                     $code = 'no';
                 }
             }
             echo json_encode(array('code' => $code, 'data' => array('name' => 'Cacti', 'content' => $val->validated('url'))));
         }
     }
 }
コード例 #2
0
ファイル: graph.php プロジェクト: quickpacket/noclayer
 public function action_get($sourceID = null, $id = null, $size, $rd)
 {
     ob_start();
     $source = Model_Source::find($sourceID);
     if ($source) {
         $cacti = new \Cacti($source->content);
         $code = $cacti->authentication($source->user, $source->pass);
         if ($code == 200) {
             $graph = $cacti->graph($id, $size, $rd);
             ob_end_clean();
             header('Content-Type: image/png');
             echo $graph['ret'];
             //$this->resize($graph['ret'],$size);
             //
             //
             //echo ;
         }
     }
     //
 }