public function __construct($exec, $host, $user, $password, $database, $file) { if (empty($exec)) { throw new Exception(exec::message('Class mysqldump, function __construct, $exec is leeg !', 'error')); } if (empty($host)) { throw new Exception(exec::message('Class mysqldump, function __construct, $host is leeg !', 'error')); } if (empty($user)) { throw new Exception(exec::message('Class mysqldump, function __construct, $user is leeg !', 'error')); } if (empty($password)) { throw new Exception(exec::message('Class mysqldump, function __construct, $password is leeg !', 'error')); } if (empty($database)) { throw new Exception(exec::message('Class mysqldump, function __construct, $database is leeg !', 'error')); } if (empty($file)) { throw new Exception(exec::message('Class mysqldump, function __construct, $file is leeg !', 'error')); } $this->exec = $exec; $this->host = $host; $this->user = $user; $this->password = $password; $this->database = $database; $this->file = $file; }
/** * Kill Application PID * * @param unknown_type $PID * @return boolen */ function kill($PID) { if (exec::is_running($PID)) { exec("kill -KILL {$PID}"); return true; } else { return false; } }
public function run($commands) { if (empty($commands)) { exec::message('Class exec, function run, $commands is leeg !', 'error'); return false; } $command = ''; $message = ''; foreach ($commands as $cmd) { if (!isset($cmd[1]) or false == $cmd[1]) { // if we not need to use user and password $command .= $cmd[0] . ' && '; $message .= $cmd[0] . ' && '; } else { $command .= sprintf("echo '%s' | sudo -S %s", $this->pass, $cmd[0]) . ' && '; $message .= sprintf("echo (gebruikersnaam en wachtwoord niet zichtbaar) | sudo -S %s", $cmd[0]) . ' && '; } } $command = substr($command, 0, -4); $command .= ' 2>&1'; $message = substr($message, 0, -4); $message .= ' 2>&1'; exec::message_save(sprintf("Class exec, function run, Het volgende command word uitgevoerd: %s", $message)); exec::message_display(sprintf("Class exec, function run, Het volgende command word uitgevoerd: %s", $command)); $output = []; $return_var = -1; exec($command, $output, $return_var); //exec::message(sprintf("Class exec, function run, De return van het command: %s", $return_var)); exec::message_save(sprintf("Class exec, function run, De return van het command: %s", $return_var)); //exec::message('Class exec, function run, De ouput van het command: '); exec::message_save('Class exec, function run, De ouput van het command: '); exec::message_save(implode(PHP_EOL, $output)) . PHP_EOL; if (empty($return_var)) { return $output; } else { exec::message('Class exec, function run, Er is een error bij het uitvoeren van het command !', 'error'); return false; } }
<div class="table-responsive"> <table id="grid-data-api" class="table table-striped table-condensed" > <thead> <tr> <?php foreach ($fields as $field) { ?> <th data-column-id="<?php echo $field; ?> " <?php echo $elements->primary_key() == $field ? 'data-identifier="true"' : ''; ?> > <?php if (isset($captions[$field]) and !exec::is_callable($captions[$field])) { ?> <?php echo Text::ucfirst($captions[$field]['model'] . ' ' . $captions[$field]['caption']); ?> <?php } else { ?> <?php echo Text::ucfirst($field); ?> <?php } ?> </th> <?php
/** * execute telegram method * @param [type] $_name [description] * @param [type] $_args [description] * @return [type] [description] */ static function __callStatic($_name, $_args) { if (isset($_args[0])) { $_args = $_args[0]; } if (!array_key_exists('before', self::$methods)) { self::$methods['before'] = []; } foreach (self::$methods['before'] as $key => $value) { if (preg_match($key, $_name, $name)) { $value($_name, $_args); } } $return = exec::send($_name, $_args); if (!array_key_exists('after', self::$methods)) { self::$methods['after'] = []; } foreach (self::$methods['after'] as $key => $value) { if (preg_match($key, $_name, $name)) { $value($_name, $_args, $return); } } return $return; }
/** * gets the info used from index * @return string json */ public function action_ajax() { $elements = ORM::Factory($this->_orm_model); //search searchPhrase: from an array specified in the controller. If none search does not appear. do in bootdrig action if (Core::post('searchPhrase') !== NULL and count($this->_search_fields) > 0) { foreach ($this->_search_fields as $field) { $elements->or_where($field, 'LIKE', '%' . Core::post('searchPhrase') . '%'); } } //extra filters foreach ($this->_filter_post as $field => $value) { //forced null value if ($value === NULL) { $elements->where($field, 'IS', NULL); } elseif ($value === 'NOT NULL') { $elements->where($field, 'IS NOT', NULL); } elseif (is_array($value)) { $elements->where($field, 'BETWEEN', $value); } elseif (isset($this->_fields_caption[$field])) { if (is_numeric($value)) { $elements->where($field, '=', $value); } else { $data = $this->_fields_caption[$field]; $search = ORM::Factory($data['model']); $search = $search->where($data['caption'], 'LIKE', '%' . $value . '%')->find_all(); if (count($search) > 0) { $result = array(); foreach ($search as $res) { $result[] = $res->{$field}; } $elements->where($field, 'IN', $result); } else { //not found normal search then ;) $elements->where($field, 'LIKE', '%' . $value . '%'); } } } elseif (is_numeric($value)) { $elements->where($field, '=', $value); } else { $elements->where($field, 'LIKE', '%' . $value . '%'); } } //dr($elements); //sort by sort[group_name]:asc if (Core::post('sort') !== NULL) { $sort = Core::post('sort'); $field = key($sort); $dir = current($sort); if (in_array($field, array_keys($elements->table_columns()))) { $elements->order_by($field, $dir); } } else { $elements->order_by($elements->primary_key(), 'DESC'); } $pagination = Pagination::factory(array('view' => 'oc-panel/crud/pagination', 'current_page' => array('page' => Core::post('current', 1)), 'total_items' => $elements->count_all(), 'items_per_page' => Core::post('rowCount', 10)))->route_params(array('controller' => $this->request->controller(), 'action' => $this->request->action())); $elements = $elements->limit($pagination->items_per_page)->offset($pagination->offset)->find_all(); $rows = array(); foreach ($elements as $element) { foreach ($this->_index_fields as $field) { //captions for fields.... if (isset($this->_fields_caption[$field])) { //callable function if (exec::is_callable($function = $this->_fields_caption[$field])) { $result[$field] = call_user_func($function, $element->{$field}); } else { $model = $this->_fields_caption[$field]['model']; $caption = $this->_fields_caption[$field]['caption']; $result[$field] = $element->{$model}->{$caption}; } } else { $result[$field] = Text::limit_chars(strip_tags($element->{$field})); } } $rows[] = $result; $result = array(); } //the json returned $result = array('current' => $pagination->current_page, 'rowCount' => $pagination->items_per_page, 'rows' => $rows, 'total' => $pagination->total_items); $this->auto_render = FALSE; //$this->response->headers('Content-type','application/javascript');//why the heck doesnt work with this??? $this->template = View::factory('js'); $this->template->content = json_encode($result); }
/** * Kill Application PID * * @param integer $pid process id from unix * @return boolean */ public static function kill($pid) { if (exec::is_running($pid)) { exec('kill -9 ' . $pid); return TRUE; //killed } else { return FALSE; //not processing } }