public static function getMenuByGroup($group) { if (!is_array($group)) { $files = glob("../app/modules/*", GLOB_ONLYDIR); $T = array(); foreach ($files as $key => $filename) { $F = (include $filename . "/config.php"); if (count($F['menu']) > 0) { if ($F['container'] == $group) { if ($F['etat'] == "active") { $T[$key] = $F['menu']; } } } } return array_values($T); } else { if (Config::get('database.prefixing')) { $data = Database::read("select * from " . Config::get('database.prefixe') . $group['table'] . " where id='" . $group['id'] . "'", 1); $data = $data[0]; $menu = unserialize(base64_decode($data["content"])); } else { $data = Database::read("select * from " . $group['table'] . " where id='" . $group['id'] . "'", 1); $data = $data[0]; $menu = unserialize(base64_decode($data["content"])); } if (count($menu) > 0) { return $menu; } else { return "Error"; } } }
public static function attempt($array, $remember = false) { //Table::show(self::$hashedFields); // $hashed = array(); // foreach ($array as $key => $value) { if (Table::contains(self::$hashedFields, $key)) { Table::add($hashed, Hash::make($array[$key]), $key); } } // //Table::show($hashed); // $where = ""; $ok = false; // $i = 0; foreach ($array as $key => $value) { if ($i > 0) { $where .= " and "; } if (Table::contains(self::$hashedFields, $key)) { $where .= "{$key}='" . $hashed[$key] . "' "; } else { $where .= "{$key}='{$value}' "; } $i++; } $sql = "select * from " . self::$table . " where " . $where; //echo $sql; // if (Database::countS($sql) > 0) { //returning true value $ok = true; // // session $user = Database::read($sql); $saved = Config::get('auth.saved_fields'); // $static = array(); // foreach ($user[0] as $key => $value) { if (array_key_exists($key, $saved)) { $static[$key] = $value; } } // Session::put('auths', $static); // // remember cookie if ($remember) { Cookie::create(Config::get('auth.rememeber_cookie'), $user[0]["rememberToken"], time() + 3600 * 24 * 7); } } // return $ok; }
public static function where($where) { $self = self::instance(); $rows = new ModelArray(); // $sql = "select * from " . $self->DBtable . " where {$where} "; $data = Database::read($sql, 1); // foreach ($data as $key => $value) { $row = self::instance(); // foreach ($value as $key2 => $value2) { $row->{$key2} = $value2; } // $rows->add($row); } // return $rows; }
public function getAll() { return Database::read('select * from ' . $this->DatabaseTableName()); }
public function paginate($RowsPerPage) { // count data $sql = "select count(*) as nbRows from " . $this->name; $var = Database::read($sql); $this->RowsPerPage = $RowsPerPage; $this->nbRows = $var[0]['nbRows']; $this->nbPages = ceil($this->nbRows / $RowsPerPage); //if isset get $this->CurrentPage = 1; if (isset($_GET[Config::get('view.pagination_param')]) && !empty($_GET[Config::get('view.pagination_param')])) { if ($_GET[Config::get('view.pagination_param')] > 0 && $_GET[Config::get('view.pagination_param')] <= $this->nbPages) { $this->CurrentPage = Res::get(Config::get('view.pagination_param')); } } //get Data $r = array(); $sql = "select * from " . $this->name . " Limit " . ($this->CurrentPage - 1) * $this->RowsPerPage . ",{$this->RowsPerPage}"; $this->data = Database::read($sql); // return $this; }