public static function create_hash($data) { $hash = Config::get('hash'); $context = hash_init($hash['hash_algorithm'], HASH_HMAC, $hash['hash_general_key']); hash_update($context, $data); return hash_final($context); }
/** * Twig::render() * * @param mixed $name * @param mixed $vars_array */ public function render($name, $vars_array = array()) { if (DEBUGING === true) { $debugBar = new DebugBar(); $debugBar->addCollector(new MessagesCollector()); $debugBar->addCollector(new ConfigCollector(Config::get())); $doctrine = Config::get('doctrine'); if ($doctrine) { $debugBar->addCollector(new DoctrineCollector($doctrine)); } $debugBar->addCollector(new TimeDataCollector()); $debugBar->addCollector(new RequestDataCollector()); $debugBar->addCollector(new MemoryCollector()); } $twig = $this->getInstance(); $content = $twig->loadTemplate($name . '.html.twig'); if (DEBUGING === true) { $debugBarRender = $debugBar->getJavascriptRenderer(); $bar['bar']['head'] = $debugBarRender->renderHead(); $bar['bar']['body'] = $debugBarRender->render(); $vars_array = array_merge($vars_array, $bar); } $args = array_merge($this->getGlobalArgs(), $vars_array); echo $content->render($args); }
public function __construct() { // Get configs $this->config = Config::get(); // Create View $this->view = new Twig(); $doctrine = new DoctrineBridge(); $this->em = $doctrine->getEm(); }
public static function app_backup() { $config = Config::get(); $destination = $config['backup']['path']; $zip = new Zip(); $zip->setArchiveName($destination . '/' . 'backup_' . date('d.m.Y')); $zip->setPath('/'); $zip->zip(); }
public static function send($to, $subject, $message, $charset = 'utf-8') { $email = Config::get('email'); $from = Config::get('from') ? Config::get('from') : null; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset={$charset}\r\n"; $headers .= "From: {$from} <{$email}>\r\n"; mail($to, $subject, $message, $headers); }
public function __construct($path_to_image, $output) { $config = Config::get('image'); $this->max_width = $config['max_width']; $this->max_height = $config['max_height']; $this->quality = $config['quality']; $this->imagesource = $path_to_image; $file = pathinfo($this->imagesource); $this->imagefullname = $file['basename']; $this->imagename = $file['filename']; $this->imagepath = $file['dirname']; list($this->original_width, $this->original_height) = getimagesize($this->imagesource); $this->ratio = $this->original_width / $this->original_height; if ($output) { $this->output = $this->imagepath . DIRECTORY_SEPARATOR . $output; } else { $this->output = $this->imagepath . DIRECTORY_SEPARATOR . $this->imagefullname; } }
public function addLangVars($lang = null) { $views = Config::get('settings', 'modules'); foreach ($views as $view) { $dir = explode('/', $view); $lang_dir = 'app/' . $dir[0] . '/lang'; $di = new Dirs(); if (is_dir($lang_dir) && !$di->isEmptyDirectory($lang_dir)) { if (is_file($lang_dir . '/' . $lang . '.php')) { $vars = (require_once $lang_dir . '/' . $lang . '.php'); } elseif (is_file($lang_dir . '/' . $this->config['default_lang'] . '.php')) { $vars = (require_once $lang_dir . '/' . $this->config['default_lang'] . '.php'); } else { $files = $di->getFiles(); $vars = (require_once $lang_dir . '/' . $files[0]); } $this->lang_var = array_merge($this->lang_var, $vars); } } }
/** * @param $path_to_image * @param $output */ public function __construct($path_to_image, $output) { $config = Config::get('image'); $this->max_width = $config['max_width']; $this->max_height = $config['max_height']; $this->quality = $config['quality']; $this->imagesource = new Imagick($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . $path_to_image); $file = pathinfo($this->imagesource->getimagefilename()); $this->imagefullname = $file['basename']; $this->imagename = $file['filename']; $this->imagepath = $file['dirname']; $size = $this->imagesource->getimagegeometry(); $this->original_width = $size['width']; $this->original_height = $size['height']; $this->ratio = $this->original_width / $this->original_height; if ($output) { $this->output = $this->imagepath . DIRECTORY_SEPARATOR . $output; } else { $this->output = $this->imagepath . DIRECTORY_SEPARATOR . $this->imagefullname; } }
public function __construct() { $config = (require 'app/config/database.php'); $driver = 'pdo_mysql'; $db_config = $config['connections'][$config['default']]; $username = isset($db_config['user']) ? $db_config['user'] : null; $password = isset($db_config['password']) ? $db_config['password'] : null; $database = isset($db_config['database']) ? $db_config['database'] : null; // set up the configuration $configDoctrine = new Configuration(); foreach (Config::get('settings', 'modules') as $controller) { if (is_dir('src/' . $controller . '/Entity')) { $paths[] = 'src/' . $controller . '/Entity'; } } $isDevMode = true; $driverImpl = $configDoctrine->newDefaultAnnotationDriver($paths, false); $configDoctrine->setMetadataDriverImpl($driverImpl); if ($isDevMode) { // set up simple array caching for development mode $cache = new ArrayCache(); } else { // set up caching with APC for production mode $cache = new ApcCache(); } $configDoctrine->setMetadataCacheImpl($cache); $configDoctrine->setQueryCacheImpl($cache); // set up proxy configuration $configDoctrine->setProxyDir('cache/Proxies'); $configDoctrine->setProxyNamespace('Proxies'); // auto-generate proxy classes if we are in development mode $configDoctrine->setAutoGenerateProxyClasses($isDevMode); // the connection configuration $dbParams = array('driver' => $driver, 'user' => $username, 'password' => $password, 'dbname' => $database, 'driverOptions' => array(1002 => 'SET NAMES utf8')); $debugStack = new DebugStack(); $this->em = EntityManager::create($dbParams, $configDoctrine); $this->getEm()->getConnection()->getConfiguration()->setSQLLogger($debugStack); Config::getInstance()->set(array('doctrine' => $this->getEm())); }
public static function readSessionFromDb($key = null) { $config = Config::get('session'); if (!$key) { $key = $config['cookie_default_key']; } if ($config['session_use_db'] === true) { $session_key = !is_null(self::getSession($key)) ? self::getSession($key) : self::getCookie($key); if ($session_key) { $db = new Database(); $result = $db->select("SELECT user_data FROM {$config['session_db_table']} WHERE session_key='{$session_key}'"); if (!empty($result)) { $user_data = unserialize($result[0]['user_data']); return $user_data; } else { return false; } } else { return false; } } return null; }
public function __construct($file) { $this->file = $file; $this->config = Config::get('upload'); }