public function repl($rule, $value, $ignore_extends = false) { if ($rule == 'include') { $page = str_replace("'", "", $value); $ds = Config::get('DS'); $folder = Config::get('APP'); $page = $folder . $ds . 'public' . $ds . 'layout' . $ds . $page; $content = file_get_contents($page); return $content; } }
public static function render($page, $not_ignored_repl = true) { $page = strtolower($page); $ds = Config::get('DS'); $folder = Config::get('APP'); $page = str_replace(".", $ds, $page); $page .= ".php"; $page = $folder . $ds . 'public' . $ds . 'pages' . $ds . $page; $content = file_get_contents($page); $element = new Element(); $element = $element->make($content, $not_ignored_repl); return $element; }
public function regex_render($path, $base) { foreach ($base as $route => $http) { $route = preg_replace("/[\\/\\/ ]/", "", $route); if (preg_match("/(" . $route . ")/", $path)) { $static_folder = Config::get('static') . "\\.."; $static_folder .= str_replace("/", "\\", $path); if (is_file($static_folder)) { $content = new FileSystem(); return $content->render($static_folder); } } } return "Not Found"; }
public function Connect() { $env = Config::get(array('DB_TYPE' => 'MYSQL')); $this->database = $env['DATABASE']; $this->driver = $env['DRIVER']; if ($env['DRIVER'] == 'mysql') { try { $this->pdo = new PDO($env['DRIVER'] . ':host=' . $env['HOST'] . ';dbname=' . $env['DATABASE'], $env['USER'], $env['PASS'], array(PDO::ATTR_PERSISTENT => true)); } catch (PDOException $e) { echo $e->getMessage(); die; } } if ($env['DRIVER'] == 'pgsql') { try { $this->pdo = new PDO($env['DRIVER'] . ':dbname=' . $env['DATABASE'] . ';host=' . $env['HOST'], $env['USER'], $env['PASS']); } catch (PDOException $e) { echo $e->getMessage(); die; } } if ($env['DRIVER'] == 'sqlite') { try { if (!empty($env['DATABASE'])) { $this->pdo = new PDO($env['DRIVER'] . ':' . $env['DATABASE']); } else { $this->pdo = new PDO($env['DRIVER'] . '::memory'); } } catch (PDOException $e) { echo $e->getMessage(); die; } } $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $this->pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); return $this->pdo; }
<?php require_once 'init.php'; use Agil\View\View; use Agil\Config\Config; use Agil\ReCaptcha\ReCaptcha; use Agil\Session\Session; $secret = Config::get('G_SECRET'); $request = View::route($_POST); if ($request['METHOD'] == 'POST' && !empty($request['name']) && !empty($request['email']) && !empty($request['login']) && !empty($request['password']) && !empty($request['re_password']) && $request['password'] == $request['re_password'] && filter_var($request['email'], FILTER_VALIDATE_EMAIL)) { // $recaptcha = new ReCaptcha($secret); /* * $resp = $recaptcha->verify($request['g-recaptcha-response'], $request['REMOTE_ADDR']); */ $name = $request['name']; $email = $request['email']; $username = $request['login']; $password = $request['password']; $member = compact('name', 'email'); $model = new Member($member); $member = $model->save(); $id_member = $model->lastInsertId(); $login = compact('username', 'password', 'id_member'); $model = new Login($login); $login = $model->save(); if ($login && $member) { $password = md5($password); $sql = array('username' => $username, 'password' => $password, 'status' => '1'); $model = new Login(); $model->fields = array('username', 'id_member', 'status'); $rs = $model->get($sql);
<?php require_once 'init.php'; use Agil\Session\Session; use Agil\View\View; use Agil\Config\Config; $request = View::route($_GET); if (isset($_FILES['image']) && !empty($_FILES['image']) && !empty($request['pk']) && is_numeric($request['pk'])) { $logado = Session::get('logado'); $id_admin = $logado['id_member']; $pk = $request['pk']; $name = md5(sha1(date("Y-m-d H:m:s"))); $file = $_FILES['image']; $ds = Config::get('ds'); $media = Config::get('media'); $extensions = Config::get('images'); $ext = explode(".", $file['name']); $ext = $ext[count($ext) - 1]; $sql = array("id_project" => $pk, "id_admin" => $id_admin); $project = new Project(); $row = $project->count($sql); if ($row == 1 && in_array($ext, $extensions)) { $user = $media . $id_admin; if (!is_dir($user)) { $mkdir = mkdir($user, 0700); $chmod = chmod($user, 0700); } $project = $media . $id_admin . $ds . $pk; if (!is_dir($project)) { $mkdir = mkdir($project, 0700); $chmod = chmod($project, 0700);