Commit b5554710 authored by Webserver User's avatar Webserver User

initial

parent 87f85621
DirectoryIndex index.php
# enable apache rewrite engine
RewriteEngine on
# set your rewrite base
# Edit this in your init method too if you script lives in a subfolder
RewriteBase /
# Deliver the folder or file directly if it exists on the server
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Push every request to index.php
RewriteRule ^(.*)$ index.php [QSA]
# Rewrite /foo/bar to /foo/bar.php
RewriteRule ^([^.?]+)$ %{REQUEST_URI}.php [L]
# Return 404 if original request is /foo/bar.php
RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$"
RewriteRule .* - [L,R=404]
# NOTE! FOR APACHE ON WINDOWS: Add [NC] to RewriteCond like this:
# RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$" [NC]
# hmlib
Library for needfull things and startup a project
\ No newline at end of file
<?
namespace HM;
class Dir {
/**
* Set a persons weight in Kilogram
*
* @description
*/
public $path;
/**
* Build object
*
* @param path (string)
*
*/
function __construct($path)
{
$this->path = $path;
$this->realpath = realpath($path);
}
/**
* Build object
*
* @param -
* @desc check if dir exists
*/
public function exists()
{
return $return = is_dir($this->path) ? true : false;
}
/**
* Build object
*
* @param -
* @desc check if dir exists
*/
public function create($mode = 0777, $recursive = false)
{
if (mkdir($this->path, $mode, $recursive) === true) :
$oldmask = umask(0);
chmod($this->path, $mode);
umask($oldmask);
return true;
endif;
}
}
\ No newline at end of file
<?
namespace HM;
class File {
/**
* Set a persons weight in Kilogram
*
* @description
*/
public $path;
/**
* Build object
*
* @param path (string)
*
*/
function __construct($path)
{
$this->path = $path;
$this->realpath = realpath($path);
}
/**
* Build object
*
* @param -
* @desc check if dir exists
*/
public function exists()
{
return $return = is_file($this->path) ? true : false;
}
/**
* Build object
*
* @param -
* @desc check if dir exists
*/
public function create($mode = 'a', $chmod = 0777)
{
if (file_put_contents($this->path,'') === true):
$oldmask = umask(0);
chmod($this->path, $mode);
umask($oldmask);
return true;
endif;
}
/**
* Build object
*
* @param -
* @desc check if dir exists
*/
public function write($content)
{
if (file_put_contents($this->path, $content)):
return true;
endif;
return false;
}
}
\ No newline at end of file
<?
namespace HM;
class MVC {
/**
* Generate page with controller and view
*
*
*
*/
public $page;
public $controller;
public $template;
public $view;
public $title;
/*
* Constructor
*
* @description
* build the complete page with controller and view
*
* @param
* page (string)
* template (string) [optional]
*
* @return
* -
*
*/
function __construct($page, $template = 'default')
{
$this->page($page);
$this->controller();
$this->template($template);
$this->view();
}
/*
* Page
*
* @description
* create page, if it does not exist, move on to 404
*
* @param
* page (string)
*
* @return
* -
*
*/
private function page($page)
{
# define page from the uri
$page = rtrim($page, '/');
$this->page = ($page === '') ? 'index' : $page;
}
/**
* Controller
*
* @description
* define controller
* controller/{page}.controller.php
*
* @param
* -
*
* @return
* -
*
*/
private function controller()
{
# define the first directory from path as controller
$controller = array_shift(array_filter(explode('/', $this->page)));
$this->controller = realpath(dirname(__DIR__) . '/controller/' . $controller .'.controller.php');
}
/**
* View
*
* @params
* -
*
* @description
* define view similar to the url structure
* '/page' will use this view 'render/views/page.view.php'
* '/page/item' will use the view 'render/views/page/item.view.php'
*
* @param
* -
*
* @return
* -
*
*/
private function view()
{
# create the template
$this->view = realpath(dirname(__DIR__) . '/render/views/' . $this->page . '.view.php');
}
/**
* View
*
* @description
* Defines the basic template, can be changed in the controller
* default template will use this 'render/template/default.template.php
*
* @param
* -
*
* @return
* -
*
*/
public function template($template)
{
# create the template
$this->template = dirname(__DIR__) . '/render/template/' . $template .'.template.php';
}
/**
* Create a page
*
* @description
* Create a full page included controller and view by a path
* $page->create('/catalog/product/') will be create files in
* /controller/catalog.controller.php
* /render/views/catalog/catalog.view.php
* /render/views/catalog/product/product.view.php
*
* @param
* page (string)
* @desc -
*
* @return
* -
*
*/
private function create($page)
{
$path_to = "";
$pages = explode('/', $page);
#if (count($pages)>0) :
$pages = array_filter($pages);
#endif;
$this->controller = realpath(__DIR__ . '/../controller/' . current($pages) .'.controller.php');
// current path
$this->page = substr($page,1);
// create directory if not exists
$path = new Dir(dirname(dirname(__DIR__) . '/render/views/' . $this->page));
if ($path->exists() === false) :
$path->create($mode = 0777, $recursive = true);
endif;
// create views, if not exists
foreach ($pages as $page):
$file = new File(dirname(__DIR__) . '/render/views/' . $path_to . $page . '.view.php');
if ($file->exists() === false) :
$file->create($mode = 0777, $recursive = true);
$file->write(str_replace('{TITLE}' , basename($file->path), file_get_contents(dirname(__DIR__) . '/render/template/default.view.php')));
endif;
$path_to .= $page . '/';
endforeach;
}
}
\ No newline at end of file
{
"name": "warzz/heiko.mettelsiefen",
"description": "startup lib and project",
"type": "library",
"license": "propietary",
"authors": [
{
"name": "Heiko Mettelsiefen",
"email": "heiko.mettelsiefen@mybannerworld.com"
}
],
"minimum-stability": "dev",
"require": {
},
"autoload": {
"psr-4": {
"HM\\":"classes/"
}
}
}
<?
$page->title = 'pagetitle';
$page->template('custom');
$array = array('Key' => 'Value');
$dir = new HM\Dir(__DIR__ . '/test');
<?
/*
$file = new HM\File($dir->path . '/test2.json');
if ($file->exists() === false) :
$file->create();
endif;
$info = new SplFileObject($file->path);
HM\Log::debug('hi');
*/
\ No newline at end of file
<?
$dir = new HM\Dir(__DIR__ . '/../media/files', 0777, TRUE);
if ($dir->exists() === false) :
$dir->create();
endif;
$A = "A";
#echo "controller";
#echo $dir->path;
HM\MVC::render();
/*
$file = new HM\File($dir->path . '/test2.json');
if ($file->exists() === false) :
$file->create();
endif;
$info = new SplFileObject($file->path);
HM\Log::debug('hi');
*/
?>
\ No newline at end of file
<?
#header('Content-Type: application/json');
\ No newline at end of file
<?
\ No newline at end of file
<?
require __DIR__ . '/globals/header.php';
require __DIR__ . '/globals/settings.php';
require __DIR__ . '/vendor/autoload.php';
$page = new HM\MVC($_SERVER["SCRIPT_URL"]);
#var_dump($page);
if ($page->view === false) : header('Location: '.'/404'); endif;
require($page->controller);
require($page->template);
\ No newline at end of file
<!doctype html>
<html>
<head>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet">
<link href="https://stackpath.bootstrapcdn.com/bootswatch/4.3.1/simplex/bootstrap.min.css" rel="stylesheet">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<meta charset="utf-8">
<title><?= $page->title; ?></title>
</head>
<body>
<? include($page->view); ?>
</body>
</html>
<!doctype html>
<html>
<head>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet">
<link href="https://stackpath.bootstrapcdn.com/bootswatch/4.3.1/cerulean/bootstrap.min.css" rel="stylesheet">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<meta charset="utf-8">
<title><?= $page->title; ?></title>
</head>
<body>
<? include($page->view); ?>
</body>
</html>
<main role="main" class="flex-shrink-0">
<div class="container">
<h1 class="mt-5">404</h1>
<p class="lead">not found</p>
<p>Use <a href="/index">Go to start</a></p>
</div>
</main>
<main role="main" class="flex-shrink-0">
<div class="container">
<h1 class="mt-5">catalog.view.php</h1>
<p class="lead"><? var_dump($array); ?><? var_dump($page); ?><?= "hi"; ?><?= $template; ?> a footer to the bottom of the viewport in desktop browsers with this custom HTML and CSS.</p>
<p>-----------</p>
<p>Test: $dir = new HM\Dir() : <?= $dir->path; ?></p>
<p>Page object <pre><? var_dump($page); ?></pre></p>
<p>Use <a href="/docs/4.3/examples/sticky-footer-navbar/">the sticky footer with a fixed navbar</a> if need be, too.</p>
</div>
</main>
\ No newline at end of file
<main role="main" class="flex-shrink-0">
<div class="container">
<h1 class="mt-5">show.view.php</h1>
<p>Page object <pre><? var_dump($page); ?></pre></p>
</div>
</main>
\ No newline at end of file
<main role="main" class="flex-shrink-0">
<div class="container">
<h1 class="mt-5">docs.view.php</h1>
<p class="lead">Pin a footer to the bottom of the viewport in desktop browsers with this custom HTML and CSS.</p>
<p>Use <a href="/docs/4.3/examples/sticky-footer-navbar/">the sticky footer with a fixed navbar</a> if need be, too.</p>
</div>
</main>
\ No newline at end of file
<main role="main" class="flex-shrink-0">
<div class="container">
<h1 class="mt-5">index.view.php</h1>
<p class="lead"><? var_dump($dir); ?></p>
<p>Use <a href="/docs/4.3/examples/sticky-footer-navbar/">the sticky footer with a fixed navbar</a> if need be, too.</p>
</div>
</main>
\ No newline at end of file
<main role="main" class="flex-shrink-0">
<div class="container">
<h1 class="mt-5">shop.view.php</h1>
<p class="lead"><? echo $A; ?></p>
<p><? echo $dir->path; HM\Log::debug($dir->path); echo $A; ?> b</p>
</div>
</main>
\ No newline at end of file
<main role="main" class="flex-shrink-0">
<div class="container">
<h1 class="mt-5">{TITLE}</h1>
<p class="lead">A new space for awesome content.</p>
<p>Use <a href="/docs/4.3/examples/sticky-footer-navbar/">the sticky footer with a fixed navbar</a> if need be, too.</p>
</div>
</main>
\ No newline at end of file
<?php
// autoload.php @generated by Composer
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInitc9276e89b85b1a7c62ea9fd02827598c::getLoader();
This diff is collapsed.
Copyright (c) Nils Adermann, Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
<?php
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'HM\\Dir' => $baseDir . '/classes/Dir.class.php',
'HM\\File' => $baseDir . '/classes/File.class.php',
'HM\\Log' => $baseDir . '/classes/Log.class.php',
'HM\\MVC' => $baseDir . '/classes/MVC.php',
);
<?php
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
);
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'HM\\' => array($baseDir . '/classes'),
);
<?php
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitc9276e89b85b1a7c62ea9fd02827598c
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitc9276e89b85b1a7c62ea9fd02827598c', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInitc9276e89b85b1a7c62ea9fd02827598c', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitc9276e89b85b1a7c62ea9fd02827598c::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->set($namespace, $path);
}
$map = require __DIR__ . '/autoload_psr4.php';
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
}
$loader->register(true);
return $loader;
}
}
<?php
// autoload_static.php @generated by Composer
namespace Composer\Autoload;
class ComposerStaticInitc9276e89b85b1a7c62ea9fd02827598c
{
public static $prefixLengthsPsr4 = array (
'H' =>
array (
'HM\\' => 3,
),
);
public static $prefixDirsPsr4 = array (
'HM\\' =>
array (
0 => __DIR__ . '/../..' . '/classes',
),
);
public static $classMap = array (
'HM\\Dir' => __DIR__ . '/../..' . '/classes/Dir.class.php',
'HM\\File' => __DIR__ . '/../..' . '/classes/File.class.php',
'HM\\Log' => __DIR__ . '/../..' . '/classes/Log.class.php',
'HM\\MVC' => __DIR__ . '/../..' . '/classes/MVC.php',
);
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitc9276e89b85b1a7c62ea9fd02827598c::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitc9276e89b85b1a7c62ea9fd02827598c::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitc9276e89b85b1a7c62ea9fd02827598c::$classMap;
}, null, ClassLoader::class);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment