WYSIWYG md editor SimpleMDE or use some desktop markdown text editor    Home    [ html2markdown ]
Markdown txt 02____________ MKD __________.txt Parsedown-ed to HTML.    [ Edit text ]    [ Colored text ]

<?php // J:\awww\www\fwphp\www4\glomodul\mkd\00 MKD4 .txt

/**  
*       C O N T R O L L E R  code  
* see J:\awww\www\fwphp\www4\glomodul\mkd\00_______________ MKD4 _______________.txt  
* protected function index(array &$urlqry_arr=[])
*/  

/**  
*       M O D E L  code  
*  
*   //J:\awww\www\fwphp\glomodul\mkd\_CtrP.php  
*   //CALLED FROM FW CORE clas _C trMain run() m e t h o d  
*  
*           __construct(object &$conf) :  
*   //parent::__construct(); //already instantiated in index.php  
*   //             instantiate model  
*   if ($conf) $this->conf = $conf ; //Dependency Injection  
*   //J:\awww\www\fwphp\glomodul\mkd\_MdlMkd.php :  
*   $this->mkdMdl = new _MdlMkd(__DIR__) ; // mkd module's dir  
*  
*   class _MdlMkd extends _CtrMain  
*   public function __construct($dir)  
*/  

/**  
*           V I E W  code  
*  
*   //J:\awww\www\fwphp\glomodul\mkd\_CtrP.php  
*   //CALLED FROM FW CORE clas _C trMain run() m e t h o d  
*  
*   //protected function index(array &$urlqry_arr=[])  
*       // require_once 'pg_content.php';  
*/  

// unfinished // URL call this script (not include) (QS unknown...) or better // this should be class like lsweb and page classes in www4

//$URL_TESTBELOWWS=$this->rps['UPTO_WSROOT'].$this->rps['PATHTESTBELOWWS'] ; //relative url //also works '/'.$this->rps['PATHTESTBELOWWS'] //

//namespace B12phpfw ;

//class CtrMkd extends Home //higher mnucls in tree //{ // class attributes //R O U T I N G T A B L E level 2 (pages properties) - links, see H ome cls crelink($ruta)

//class operations - methods
//public function Display()
//{

//echo '<h1>LINKS</h1>';

...............

// } //e n d f n D i s p l a y()

//} //e n d c l s

// $URLALLSITES :

// My: $URLALLSITES = '//' //URL_PROTOCOL . filter_var( $_SERVER['HTTP_HOST'] //URL_DOMAIN .$_SERVER['REQUEST_URI'] .'/' , FILTER_SANITIZE_URL ) ;

$url = 'http://username:password@hostname:9090/path?arg=value#anchor'; var_dump(parse_url($url)); // array(8) { ["scheme"]=>string(4) "http" ["host"]=>...

var_dump(parse_url($url, PHP_URL_SCHEME)); //string(4) "http"

var_dump(parse_url($url, PHP_URL_USER)); //string(8) "username" var_dump(parse_url($url, PHP_URL_PASS)); //string(8) "password" var_dump(parse_url($url, PHP_URL_HOST)); //string(8) "hostname" var_dump(parse_url($url, PHP_URL_PORT)); //int(9090)

var_dump(parse_url($url, PHP_URL_PATH)); //string(5) "/path" var_dump(parse_url($url, PHP_URL_QUERY)); //string(9) "arg=value" var_dump(parse_url($url, PHP_URL_FRAGMENT)); //string(6) "anchor"

//parse_url returns the host (ex. example.com) as the path when no scheme is provided in the input url. So I've written a quick function to get the real host: function getHost($Address) { $parseUrl = parse_url(trim($Address)); return trim($parseUrl[host] ? $parseUrl[host] : array_shift(explode('/', $parseUrl[path], 2))); }

getHost("example.com"); // Gives example.com getHost("http://example.com"); // Gives example.com getHost("www.example.com"); // Gives www.example.com getHost("http://example.com/xyz"); // Gives example.com

function get_file_path_from_url( $file_url ){ return realpath($_SERVER['DOCUMENT_ROOT'] . parse_url( $file_url, PHP_URL_PATH )); }

//https://stackoverflow.com/questions/6768793/get-the-full-url-in-php

print_r($_SERVER); // $HTTP_SERVER_VARS contains the same initial information, but is not a superglobal. (Note that $HTTP_SERVER_VARS and $_SERVER are different variables and that PHP handles them as such)

if ( ! array_key_exists( 'HTTP_ORIGIN', $_SERVER ) ) { $this->referer = $_SERVER['SERVER_NAME']; } else { $this->referer = $_SERVER['HTTP_ORIGIN']; }

public static function getCurrentURL() { $protocol = strpos(strtolower($_SERVER['SERVER_PROTOCOL']), 'https') === false ? 'http' : 'https'; $host = $_SERVER['HTTP_HOST']; $script = $_SERVER['SCRIPT_NAME']; $params = $_SERVER['QUERY_STRING'] == '' ? '' : '?' . $_SERVER['QUERY_STRING'];

return $protocol . '://' . $host . $script . $params;

}

//Here is the basis of a more secure version of the accepted answer, using PHP's filter_input function, which also makes up for the potential lack of $_SERVER['REQUEST_URI']: $protocol_https = filter_input(INPUT_SERVER, 'HTTPS', FILTER_SANITIZE_STRING); $host = filter_input(INPUT_SERVER, 'HTTP_HOST', FILTER_SANITIZE_URL); $request_uri = filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL); if(strlen($request_uri) == 0) { $request_uri = filter_input(INPUT_SERVER, 'SCRIPT_NAME', FILTER_SANITIZE_URL); $query_string = filter_input(INPUT_SERVER, 'QUERY_STRING', FILTER_SANITIZE_URL); if($query_string) { $request_uri .= '?' . $query_string; } } $full_url = ($protocol_https ? 'https' : 'http') . '://' . $host . $request_uri;

if($_SERVER['HTTP_HOST'] == "localhost"){ define('SITEURL', 'http://' . $_SERVER['HTTP_HOST']); define('SITEPATH', $_SERVER['DOCUMENT_ROOT']); define('CSS', $_SERVER['DOCUMENT_ROOT'] . '/css/'); define('IMAGES', $_SERVER['DOCUMENT_ROOT'] . '/images/'); } else{ define('SITEURL', 'http://' . $_SERVER['HTTP_HOST']); define('SITEPATH', $_SERVER['DOCUMENT_ROOT']); define('TEMPLATE', $_SERVER['DOCUMENT_ROOT'] . '/incs/template/'); define('CSS', $_SERVER['DOCUMENT_ROOT'] . '/css/'); define('IMAGES', $_SERVER['DOCUMENT_ROOT'] . '/images/'); }

$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";

//If you want to support both HTTP and HTTPS, you can use $actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . " : //$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";

//SERVER_NAME: sspc1, dev1, localhost, 127.0.0.1 : $siteurl='//'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT']; $ownurl = $siteurl . $modulerelpath ; // '/fwphp/utl/lsweb/lsweb.php'

$url = "http" . (($_SERVER['HTTPS'] === 'on') ? "s" : "") . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; // worse is $_SERVER['SERVER_PORT'] == 443

//NOT SO, IIS says "Undefined index: REQUEST_SCHEME" : $uri = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']

//Use this one-liner to find the parent folder URL (if you have no access to http_build_url() that comes along with pecl_http): $url = (isset($_SERVER['HTTPS']) ? 'https://' : 'http://').$_SERVER['SERVER_NAME'].str_replace($_SERVER['DOCUMENT_ROOT'], '', dirname(dirname(FILE)));

//Clear code, working in all webservers (Apache, nginx, IIS, ...): $url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];

// H E L P Read and edit (cRUd) flat files "DB" ee texts of type .txt, .md, .mkd...(easy is add extension : in _MdlMkd.php search "$ext === \'txt\'").

c(reate) and d(elete) we do with oper.system functions (eg in Windows explorer).
There is no need to code c and d here (like commercial Gator php lsweb sw does).

Code & data flow in (this B12phpfw, better say in every good) menu&crud code skeleton.
Menu&crud code skeleton (plus some other code functions) we call framework.

Content directory and directories structure

In bootstrap script (Mkd module's single entry point) fwphp\glomodul\mkd\www\index.php change to your values :
$upto_rootm_str = '../../..'; and $content_dir = 'help_fw'; .

$upto_rootm_str is PHP frameworks standard for "path science" eg in Yii. Means fwphp = third dir above www dir in fwphp\glomodul\mkd\www\index.php. Usually there is no need to change $upto_rootm_str because :
1. fwphp is our dir at internet provider site = server doc root
2. global module Mkd (mkd directory for help texts in markdown format) should be where it is.

In fwphp/www is root module = home page = our fwphp site's main menu (WEB SITE ROOT IS ABOVE fwphp dir !! - because it can be inet providers doc root).
Below fwphp are our groups of modules : glomodul group, materialbookkeeping group...
Module is like Oracle Forms module eg invoice.fmb (master-detail form).

$content_dir is help_fw in fwphp\glomodul\mkd\help_fw. Beside help_fw can be help_appx, help_mydog or... In their subdirs (no level limit) are .md or .mkd or .txt files.
This code in mkd Home controller class explains above steps :

//see module_namespc in router r u n ( ) 2. NAMESPACED CONTROLLER :
n amespace B12phpfw\glomodul\mkd\www ; //dirs in this dirtree can not be renamed,
   //but we can have many content dirs below mkd dir : help_fw, help_mydog...

TODO : It is not difficult to write code for user to select $content_dir value or to enter it in page title, but is not needed because brings not much user time saving (same as creating and deleting mardown text files and other CMS features in module PHP code).

So Mkd is flat files "DB" SimpleMDE cRUd module (Read and Update we do in module PHP code, creating and deleting we do in operating system). Mkd PHP module is Dreamweaver replacement for help files cRUd. Database tables rows CRUD (Msg module) is much more complicated than Mkd nodule, so to learn code and data flow Mkd module is best way.

PHP CRUD md or html files (Simplemde or Summernote WYSIWYG ed.) or DB tbls. PHP code skeleton (own framework) : MVC, router calls module's Home class which finds it's method or other ctr in DInjected (by ref) url array, namespaced classes, own autoloading class (Composer PSR-4 autol. classes also), own debugg (trace_log.html displayed in each page footer.

  <h4> CONTACT: 
  Phone +38510915867299, Email slavkoss22@gmail.com  
  <br /><a href="https://github.com/slavkoss/fwphp/">Github</a>
  <br /><a href="http://phporacle.altervista.com/">Blog</a>
  </h4>

// m n u l e v e l 1 displayed in Home cls use B12phpfw\fwphp\glomodul4\mkd\Home ; // 1.cls & incscript use B12phpfw\fwphp\glomodul4\mkd\Help ; // 1.cls & incscript //displays menu & page home_view.php //e n d D I R T R E E DESCRIPTION -------------------