Beispiel #1
0
 public function action_index()
 {
     if ($_POST) {
         $val = \Validation::forge();
         $val->add_field('id', 'Action', 'required|min_length[1]|max_length[20]');
         $val->add_field('action', 'Value', 'required|min_length[1]|max_length[20]');
         if ($val->run()) {
             $source = Model_Source::find($val->validated('id'));
             if ($val->validated('action') == 'get') {
                 $type = Model_Type::find($source->typeID);
                 $out = array('id' => $source['id'], 'type' => array('id' => $source->typeID, 'name' => $type->name), 'user' => $source['user'], 'pass' => $source['pass'], 'content' => $source['content']);
             }
             if ($val->validated('action') == 'remove') {
             }
             echo json_encode(array('source' => $out));
         }
     }
 }
Beispiel #2
0
 public function action_index()
 {
     $sources = Model_Source::find()->where('meta_update_user', $this->user)->get();
     $out = array('sources' => array(), 'data' => array(), 'munin' => array());
     foreach ($sources as $source) {
         $type = Model_Type::find($source->typeID);
         array_push($out['sources'], array('id' => $source['id'], 'type' => array('id' => $source->typeID, 'name' => $type->name), 'content' => $source['content']));
     }
     $data = Model_Data::find()->where('meta_update_user', $this->user)->get();
     foreach ($data as $d) {
         array_push($out['data'], array('value' => $d->value, 'name' => $d->name));
     }
     $munins = Model_Munin::find('all');
     foreach ($munins as $munin) {
         $device = $munin->device;
         array_push($out['munin'], array('id' => $munin->deviceID, 'url' => $munin->url, 'host' => $device->hostname));
     }
     echo json_encode($out);
 }