public static function getConnection() { // Se a conexão não estiver feita, if (!static::$connection) { $config = Config::get('database'); $driver = $config['driver']; // Buscar parametros da driver e da base de dados if ($driver == 'mysql') { try { static::$connection = new \PDO('mysql:host=' . $config['host'] . ';dbname=' . $config['database'], $config['username'], $config['password']); static::$connection->setAttribute(\PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); static::$connection_status = self::$connection->getAttribute(PDO::ATTR_CONNECTION_STATUS); } catch (PDOException $e) { echo $e->getMessage(); exit; } } if ($driver === 'SQLite3') { try { static::$connection = new \PDO('sqlite:' . ROOT . DS . 'app' . DS . 'files' . DS . 'database' . DS . 'databases' . DS . $config['database'] . '.sq3'); static::$connection_status = self::$connection->getAttribute(PDO::ATTR_CONNECTION_STATUS); } catch (PDOException $e) { echo $e->getMessage(); exit; } } } return static::$connection; }
private static function setLanguage() { if (!Session::get('application-language')) { $lang = get_browser_language(); # Set the language in_array($lang, Config::get('language')['allowed-languages']) ? Session::set('application-language', $lang) : Session::set('application-language', Config::get('language')['default-language']); } include_once ROOT . DS . 'app' . DS . 'languages' . DS . Session::get('application-language') . '.php'; Lang::set($marianaFrameworkLanguageArray); }
public function check_first_report_exists() { if (Session::get('level') < 2) { $r = $this->r(); # Se estiver feito continua, caso contrário , location reload if ($r < 1) { $location = Config::get('website') . 'user/first-report/'; header("Location: {$location}"); die; } } return true; }
public function checkRememberMe() { // STEP 1: Check if there is a active session.. if (!isset($_SESSION["id"]) || empty($_SESSION["id"])) { $cookieId = Config::get("cookieID"); //STEP 2: Check for cookie that identifies this session (set at config)... if (isset($_COOKIE[Config::get("cookieID")]) && isset($_COOKIE[Config::get("cookieHash")])) { // STEP 3: Decrypt the hash $decriptedHash = Criptography::decript($_COOKIE[Config::get("cookieHash")]); $confirmation = Sessions::where("id", $_COOKIE[Config::get("cookieID")])->also("hash", $decriptedHash)->first(); // STEP 4: if exists in the database: $setSession = json_decode($confirmation["json_session"]); foreach ($setSession as $key => $pair) { Session::set($key, $pair); } } } }
private function validate($file) { /** * @param $file * @return bool * @desc validates files before uploading them */ # Property check $this->file_name = $file['name']; $this->file_tmp = $file['tmp_name']; $this->file_size = $file['size']; $this->file_type = $file['type']; $this->file_ext = explode('.', $this->file_name); $this->file_ext = end($this->file_ext); $file_error = $file['error']; # Error tracking ## File error if ($file_error !== 0) { $this->setErrors(Lang::get(0) . $file_error); } ## Check if it's allowed file type if (!in_array($this->file_type, Config::get('file-upload')['allowed-file-types'])) { $this->setErrors(Lang::get(1) . $this->file_type); } ## Check if it's allowed extension if (!in_array($this->file_ext, Config::get('file-upload')['allowed-file-extensions'])) { $this->setErrors(Lang::get(1) . $this->file_ext); } ## Check if it's smaller than maximum file size if ($this->file_size >= Config::get('file-upload')['max-file-size']) { $this->setErrors(Lang::get(2)); } if ($this->error_count > 0) { Flash::setMessages($this->error_messages); return false; } return true; }
<div style="width: 250px; z-index: 1000000; position: fixed; top: 100px; right: -300px; background: #000; color: #FFF; border: 1px solid #FFF;" id="toast-alert" role="alert" class="alert"> <div style="display:table"> <div style="display:table-cell; vertical-align: middle"> <img id="toast-alert-image" style="width: 50px" src="<?php echo \Mariana\Framework\Config::get('website'); ?> /app/www/img/logo32.png"> </div> <div style="display:table-cell; padding-left: 5px"> <b id="toast-alert-title" class="text-uppercase">Error: </b><br> <small id="toast-alert-content">Enter a valid email address</small> </div> </div> </div> <script> var mfr_toast_running = 0; var mfr_toast_timmer = 750; var mfr_toast = function(title,content){ if(mfr_toast_running == 0) { mfr_toast_running == 0 // Setting stuff $('#toast-alert-title').text(title); $('#toast-alert-content').text(content); // Rotate image //$('#toast-alert-image').animate({rotate: '-=45deg'}, 0); //$('#toast-alert-image').animate({rotate: '+=45deg'}, mfr_toast_timmer); //$('#toast-alert-image').animateRotate(90);
public function signin() { $scope = array('first-last-name' => Lang::get('first-last-name'), 'home' => Lang::get('home'), 'my-account' => Lang::get('my-account'), 'email' => Lang::get('email'), 'website' => Config::get('website'), 'username' => Lang::get('username'), 'password' => Lang::get('password'), 'password-confirm' => Lang::get('password-confirm'), 'submit' => Lang::get('submit'), 'forgot-password' => Lang::get('forgot-password'), 'sign-up' => Lang::get('sign-up'), 'sign-in' => Lang::get('sign-in'), 'title' => 'Make Fit Real', 'csrf' => $this->csrf, 'signup-coupon' => Lang::get('promotional-code')); $navbar_stuff = $this->navbar_stuff(); $scope['navbar-stuff'] = $navbar_stuff['stuff']; $scope['navbar-links'] = $navbar_stuff['links']; View::render('auth/index.php', $scope); }
ini_set('display_errors', 1); ini_set('display_startup_errors', 1); # DEFINE SOME VARIABLES define('ROOT', realpath(dirname(__FILE__))); define('DS', DIRECTORY_SEPARATOR); # GET AUTOLOAD require_once ROOT . DS . "vendor" . DS . "autoload.php"; require_once ROOT . DS . "app" . DS . "functions.php"; # DEFINE USAGES use Mariana\Framework\Config; use Mariana\Framework\Security\Environment; use Mariana\Framework\Database; # BOOT AND VALIDATE THE COMMAND LINE INTERFACE Environment::setup(); require_once ROOT . DS . "app" . DS . "config.php"; if (Config::get("mode") !== "dev") { echo "Console only available on dev mode, please configure your application"; exit; } # SET OPTIONS //////////////////////////////////////////////////////////////////////////////////////////////////////////////// //(Config::get("mode")== "dev")?: exit() ; $options = array(); $options[] = "help"; $options[] = "server"; $options[] = "create"; $options[] = "update"; # SET COMMANDS //////////////////////////////////////////////////////////////////////////////////////////////////////////////// array_shift($argv); $commands = $argv;
public function __construct() { $this->location = trim(Config::get('website'), '/'); }
public function migrate($database = false) { if ($database == false) { $database = Config::get('database'); } DatabaseManager::migrate($database); }
<label for="login-password"> <?php echo $scope['password']; ?> <span class="pink-text">*</span> <input name="login-password" id="login-password" type="password" class="form-control" required/> </label> </div> <div> <br> <button type="button" class="button" id="login" ><?php echo $scope['submit']; ?> </button> </div> </form> <a href="<?php echo \Mariana\Framework\Config::get('base-url'); ?> ?page_id=11&lost-password" id="recovery"><?php echo $scope['forgot-password']; ?> </a> </div> <div class="row"> <div id="signin-errors" class="errors-ul"> </div> </div> </div>
/** * Created by PhpStorm. * User: pihh * Date: 24/02/2016 * Time: 11:58 * * Usage: $args = array( 'page-title' => 'Sign in/Sign up', 'redirect-title' => 'home', 'redirect-url'=> 'http://mywebsite.com', 'website-part'=> 'My account' ); */ isset($args['page-title']) ?: ($args['page-title'] = 'Make Fit Real'); isset($args['redirect-url']) ?: ($args['redirect-url'] = \Mariana\Framework\Config::get('website')); isset($args['redirect-title']) ?: ($args['redirect-title'] = Mariana\Framework\Language\Lang::get('home')); isset($args['website-part']) ?: ($args['website-part'] = Mariana\Framework\Language\Lang::get('online-coaching')); ?> <div class="page_header_wrap clearfix" style="background:url('http://localhost:8000/wp-content/themes/accesspress-store/images/about-us-bg.jpg') no-repeat center; background-size: cover;"> <div class="ak-container" id="page-banner"> <header class="entry-header"> <h2 class="entry-title text-capitalize"><?php echo $args['page-title']; ?> </h2> </header> <div id="accesspress-breadcrumb"> <a href="<?php echo $args['redirect-url'];
public static function remakeDefault() { self::$default = str_replace("//", "/", Config::get("base-route") . self::$default); return true; }
function mfr_path() { return \Mariana\Framework\Config::get('website'); }
public static function migrate() { self::setup(); # Vars $database = Config::get('database')['database']; $dir_tables = ROOT . DS . 'app' . DS . 'files' . DS . 'database' . DS . 'tables' . DS . $database . DS; # Create the database self::createDatabase($database); # Get every php file in the directory $php = glob($dir_tables . "*.php"); foreach ($php as $p) { $file = str_replace('.php', '', str_replace($dir_tables, '', $p)); if (!is_dir($dir_tables . $file)) { mkdir($dir_tables . $file, 0700); } $sql = "CREATE TABLE IF NOT EXISTS {$file} ( `id` INT NOT NULL ) ENGINE = InnoDB; "; Database::getConnection()->prepare($sql)->execute(); self::updateTable($file); #quick Fix $cli = new \CLI(array('create:model', $file)); } }
public function __construct($folder = false, $timeout = false, $ext = false) { ($folder = false) ? $this->folder = FILE_PATH . DS . 'cache' . DS : ($this->folder = FILE_PATH . DS . $folder . DS); ($timeout = false) ? $this->timeout = Config::get('cache-timeout') : ($this->timeout = $timeout); ($ext = false) ? $this->ext = 'txt' : ($this->ext = $ext); }
# SET ERROR REPORTING ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); # set debug and log ini_set('log_errors', 1); ini_set('error_log', ROOT . DS . 'app' . DS . 'files' . DS . 'logs' . DS . 'error.log'); } # Database Connection Settings. //////////////////////////////////////////////////////////////////////////////////////////////////////////////// Config::set('database', array('host' => $_ENV['DB_HOST'], 'database' => $_ENV['DB_DATABASE'], 'driver' => 'mysql', 'username' => $_ENV['DB_USERNAME'], 'password' => $_ENV['DB_PASSWORD'], 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'engine' => 'InnoDB', 'prefix' => '')); # Session configuration //////////////////////////////////////////////////////////////////////////////////////////////////////////////// Config::set('session', array('https' => true, 'user_agent' => true, 'lifetime' => 7200, 'cookie_lifetime' => 0, 'refresh_session' => 600, 'table' => 'sessions', 'salt' => 'salt')); # Email Configuration //////////////////////////////////////////////////////////////////////////////////////////////////////////////// Config::set('email', array('smtp-server' => $_ENV['MAIL_HOST'], 'port' => $_ENV['MAIL_PORT'], 'timeout' => '30', 'email-login' => $_ENV['MAIL_USERNAME'], 'email-password' => $_ENV['MAIL_PASSWORD'], 'email-replyTo' => '*****@*****.**', 'website' => Config::get('website'), 'charset' => 'windows-1251')); # File Upload Configuration # Good source: http://www.sitepoint.com/web-foundations/mime-types-complete-list/ //////////////////////////////////////////////////////////////////////////////////////////////////////////////// Config::set('file-upload', array('allowed-file-types' => array('text/plain', 'image/jpeg', 'image/bmp', 'image/x-windows-bmp', 'image/gif', 'image/png', 'application/pdf', 'application/x-compressed', 'application/x-zip-compressed', 'application/zip', 'multipart/x-zip'), 'allowed-file-extensions' => array('txt', 'jpeg', 'jpg', 'bmp', 'gif', 'png', 'pdf', 'zip', 'rar'), 'max-file-size' => 2097152)); # Cache Settings //////////////////////////////////////////////////////////////////////////////////////////////////////////////// Config::set('cache-timeout', 60); # Security Settings //////////////////////////////////////////////////////////////////////////////////////////////////////////////// Config::set('hash', getenv('key')); Config::set('security-report-email-address', getenv('SECURITY_REPORT_MAIL')); # Template Engine Config::set('template-engine', array('active' => false, 'variable' => array('{{', '}}'), 'block' => array('{#', '#}')));