public function save() { Json::save($this->file, $this->content); }
public static function delete($file, $keys) { function del(&$array, $recursive, $i) { if (array_key_exists($recursive[$i], $array)) { $y = $i + 1; if ($y == count($recursive)) { unset($array[$recursive[$i]]); return true; } elseif (is_array($array[$i])) { $i++; del($array[$i], $recursive, $i); } else { return false; // no need to continue farther } } } $array = Json::open($file); if ($array === false) { return false; } $test = del($array, $keys, 0); if ($test) { return Json::save($file, $array); } return false; }
private function add_sys_cmd_checks() { $cmds_cache_path = Util::normalize_path($this->get('CACHE_PRV_PATH') . '/cmds.json', false); $cmds = Json::load($cmds_cache_path); if (sizeof($cmds) === 0 || $this->refresh) { $cmds['command'] = Util::exec_0('command -v command'); $cmds['which'] = Util::exec_0('which which'); $cmd = false; if ($cmds['command']) { $cmd = 'command -v'; } else { if ($cmds['which']) { $cmd = 'which'; } } foreach (['avconv', 'convert', 'du', 'ffmpeg', 'gm', 'tar', 'zip'] as $c) { $cmds[$c] = $cmd !== false && Util::exec_0($cmd . ' ' . $c); } Json::save($cmds_cache_path, $cmds); } foreach ($cmds as $c => $has) { $this->set('HAS_CMD_' . strtoupper($c), $has); } }