private function parseCMD($st) { if (!mb_detect_encoding($st)) { $st = utf8_encode($st); } $tmp = explode("\n", $st); $res = []; foreach ($tmp as $t) { $i = strpos($t, ':'); if ($i > 0) { $res[\bbn\str\text::change_case(\bbn\str\text::encode_filename(substr($t, 0, $i)), 'lower')] = trim(substr($t, $i + 1)); } } return $res; }
public function get_all_history($table, $start = 0, $limit = 20, $dir = false) { $r = []; if (\bbn\str\text::check_name($table) && is_int($start) && is_int($limit)) { $r = self::$db->get_rows("\n SELECT DISTINCT(`line`)\n FROM " . self::$db->escape(self::$htable) . "\n WHERE `column` LIKE ?\n ORDER BY last_mod " . (is_string($dir) && \bbn\str\text::change_case($dir, 'lower') === 'asc' ? 'ASC' : 'DESC') . "\n LIMIT {$start}, {$limit}", self::$db->table_full_name($table) . '.%'); } return $r; }
/** * * */ public static function sort(&$ar) { usort($ar, function ($a, $b) { $a = str_replace('.', '0', str_replace('_', '1', \bbn\str\text::change_case($a, 'lower'))); $b = str_replace('.', '0', str_replace('_', '1', \bbn\str\text::change_case($b, 'lower'))); return strcmp($a, $b); }); }
public function get_next_date($frequency, $timestamp = false) { if (is_string($frequency) && strlen($frequency) >= 2) { if (!$timestamp) { $timestamp = time(); } $letter = \bbn\str\text::change_case(substr($frequency, 0, 1), 'lower'); $number = (int) substr($frequency, 1); if ($number > 0) { switch ($letter) { case 'i': $unit = 60; break; case 'h': $unit = 3600; break; case 'd': $unit = 24 * 3600; break; case 'w': $unit = 7 * 24 * 3600; break; } if (isset($unit)) { $r = $timestamp + $unit * $number; } if ($letter === 'm') { $r = mktime(date('H', $timestamp), date('i', $timestamp), date('s', $timestamp), date('n', $timestamp) + $number, date('j', $timestamp), date('Y', $timestamp)); } if ($letter === 'y') { $r = mktime(date('H', $timestamp), date('i', $timestamp), date('s', $timestamp), date('n', $timestamp) + $number, date('j', $timestamp), date('Y', $timestamp)); } if (isset($r)) { if ($r < time()) { return $this->get_next_date($frequency, $r); } return $r; } } } return false; }