Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class pathClass {
- public $root = "";
- public $path = "";
- public function __construct(){
- $this->root = $_SERVER["DOCUMENT_ROOT"];
- $this->host = "http://".$_SERVER["HTTP_HOST"];
- }
- }
- $path = new pathClass();
- include_once($path->root."/test dictionary/scripts/php/prettyClass.php");
- include_once($path->root."/test dictionary/scripts/php/phlegmClass.php");
- $pretty = new prettyClass();
- $phlegm = new phlegmClass();
- include_once($path->root."/Classes/mapCsv2JsonClass.php");
- $pagedata = file_get_contents($path->root."/test dictionary/scripts/html/main.html");
- $pagedata = str_replace ( "{{ host }}", $path->host, $pagedata );
- $pagedata = $pretty->favIconRender($pagedata);
- $pagedata = str_replace("{{ fav icon }}", "{{ host }}/Sprites/icon/crescent-onion-dome.png", $pagedata);
- $prettyHost = str_replace ( " ",".", ucwords(str_replace ( "."," ",str_replace('http://','',$path->host))));
- $prettyName = str_replace ( " ",".", ucwords(str_replace ( "."," ",basename(__FILE__,".php"))));
- $pagedata = str_replace("{{ title }}", "Keal's Roe2Js $prettyName @ $prettyHost", $pagedata);
- $pagedata = str_replace("{{ tray }}", "", $pagedata);
- $pagedata = str_replace("{{ menu }}", "", $pagedata);
- $eventLog = "";
- $buffet = "";
- $pagedata = loader ( $pagedata );
- $pagedata = str_replace ("{{ table }}","<textarea>$eventLog</textarea>",$pagedata);
- $pagedata = str_replace ("{{ host }}",$path->host,$pagedata);
- header("Content-Type: text/html");
- echo $pagedata;
- exit;
- function loader ( $pagedata ) {
- $path = new pathClass ( );
- $pretty = new prettyClass ( );
- $Cookbook = new CookbookClass ( );
- foreach($Cookbook->formats as $ext => $tag){
- $lines = [];
- switch($ext) {
- case "js":
- case "css":
- $pagedata = str_replace ("{{ ${tag} }}","<${tag}></${tag}>",$pagedata);
- $lines[0] = "/* {{ #/test dictionary/scripts/json/includes/${ext} includes.csv }} */";
- $row = 0;
- while($row < count($lines)){
- $line = Linedancer ( $lines[$row] );
- $lines = remove( $lines, $row, 1 );
- if($line !== ""){
- $lines = insert( $lines, $row, $line );
- }
- $row++;
- }
- $pagedata = str_replace("</${tag}>",implode("\r\n",$lines)."</${tag}>",$pagedata);
- break;
- case "json":
- case "csv":
- break;
- }
- }
- return $pagedata;
- }
- function Linedancer ( $line ) {
- $path = new pathClass ( );
- $pretty = new prettyClass ( );
- $Cookbook = new CookbookClass ( );
- if(preg_match_all($Cookbook->hashMatch,$line,$matches,PREG_SET_ORDER ) > 0 ) {
- foreach($matches as $match){
- $pretty->jRmNumeric($match);
- $words = [];
- foreach(["op","var","path","file","ext"] as $key ) {
- $words[$key] = $match[$key];
- }
- }
- }else{
- return $line;
- }
- if ($words['op'] !== "#"){
- return $line;
- }
- $hit = array_search(substr("${words['ext']}",1), $Cookbook->formats);
- if ( $hit === false ) {
- return $line;
- }
- if(!is_file($path->root."${words['path']}${words['file']}${words['ext']}")) {
- return $line;
- }
- switch( substr("${words['ext']}",1) ){
- case 'js':
- case 'css':
- case 'csv':
- return file_get_contents($path->root."${words['path']}${words['file']}${words['ext']}");
- case "json":
- if($words['var'] === ""){
- return $line;
- }
- return "var ${words['var']} = ".file_get_contents($path->root."${words['path']}${words['file']}${words['ext']}");
- }
- return $line;
- }
- class CookbookClass {
- public $path;
- public $pretty;
- public $hashMatch;
- public $formats;
- public function __construct ( ) {
- $path = new pathClass ( );
- $pretty = new prettyClass ( );
- $this->hashMatch = '/\/\* {{ (?<op>#)(?<pad>(?<var>[A-Za-z][A-Za-z0-9_]*)=|)(?<path>\/[\/A-Za-z0-9\-_ ]*\/)(?<file>[A-Za-z0-9\-_ ^\/]+)(?<ext>\.[A-Za-z0-9\-_]+) }} \*\//m';
- $this->formats = json_decode(file_get_contents($path->root."/test dictionary/scripts/json/includes/formats.json"),true, 512, JSON_THROW_ON_ERROR);
- }
- }
- function insert($array, $index, $value) {
- if (!is_array($value)) {
- $value = explode("\r\n", $value);
- }
- $row = 0;
- foreach ($value as $item) {
- array_splice($array, $index + $row, 0, $item);
- $row++;
- }
- return $array;
- }
- function remove($array, $index, $count) {
- if(is_array($count)){
- $count = count($count);
- }
- array_splice($array, $index, $count);
- return $array;
- }
Add Comment
Please, Sign In to add comment