introducing a new URL notation scheme

Discussion in 'PHP' started by seductiveapps.com, Mar 1, 2017.

  1. #1
    Hi.

    With the introduction of 4K screens, i've been searching for a way to initialize multiple webapplications at the same time, neatly and from one website address (URL) string..
    (each app called up with parameters, and to be displayed in various windows/dialogs (DIVs) in the browser).
    I believe i have cracked the puzzle completely.
    Please note that some of the URLs in this post i had to mangle from http to htt p in order to be able to post this content here.

    Note the browser location bar in the following screenshots :

    20170301 1838 appParams parse correctly (1of1)
    [​IMG]

    The parser functions are :

    .htaccess rules :
    from my index.php :
    and from my URLresolver__functionCalls.php :
    my app 'jsonViewer' is able to call up (via the CURL module) other people's JSON files stored elsewhere on the web, and display those pretty-fied. So I also needed a way to include a standard 'HTML1 / HTML2 / HTML5' URL with parameters passed as ?param1=abc&param2=def in my new URL scheme. The only solution that worked in my case, but which i find a workable solution nonetheless, is to base64-encode and then base64-decode such 'traditional URLs'..

    URLs within URLs (apache, htaccess / browser location bar, PHP) (1of3) [​IMG]

    URLs within URLs (apache, htaccess / browser location bar, PHP) (2of3)
    [​IMG]

    URLs within URLs (apache, htaccess / browser location bar, PHP) (3of3)
    [​IMG]
     
    seductiveapps.com, Mar 1, 2017 IP
    deathshadow likes this.
  2. seductiveapps.com

    seductiveapps.com Active Member

    Messages:
    200
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #2
    seductiveapps.com, Mar 1, 2017 IP
  3. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #3
    Uhm, instead of base64 encode, couldn't you just urlencode them? Then you could parse them server-side.

    Big thing is, I'm really not sure I'm following what the point of all this is.... you're not opening multiple windows... you're just passing parameters right? I'm not following why you're getting .htaccess involved in this, much less much of anything else going on here.

    Could you better explain the POINT of this, maybe provide a working demo?
     
    deathshadow, Mar 2, 2017 IP
    ThePHPMaster likes this.
  4. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #4
    Yeah, the more I look at this, the more I wonder why you're screwing around with .htaccess in the first place, especially if you're just dumping it all into PHP. Just urlencode and pass as normal $_GET

    index.php?tarot[deck]=Original-Rider-Waite&tarot[reading]=3-Cards&music[youTubePlayList]=ABCDEFG

    Boom, there's your values in $_GET. Why waste all the extra processing and goofy nonsense when the functionality already exists? If they have actual URI's in them, urlencode makes them save to pass with none of that relic of 1970's mainframe base64 nonsense.

    Or am I completely missing what it is you're trying to do here?
     
    deathshadow, Mar 3, 2017 IP
  5. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #5
    You remember this guy, I hope? The seductiveapps all js crap with obfuscation and whatnot he's been pushing for at least a couple years?
     
    PoPSiCLe, Mar 4, 2017 IP
  6. seductiveapps.com

    seductiveapps.com Active Member

    Messages:
    200
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #6
    my ubuntu apache2 couldn't handle double urlencode at all, that why i switched to base64.
    and yes, i would be opening multiple windows each with their own set of variables. 4K is huge, compared to FullHD.
     
    seductiveapps.com, Mar 13, 2017 IP
  7. seductiveapps.com

    seductiveapps.com Active Member

    Messages:
    200
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #7
    i'm trying, and have succeeded as far as i'm concerned, to make a new URL notation scheme. it's not like i'm forcing anyone to use it you know :)
     
    seductiveapps.com, Mar 13, 2017 IP
  8. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #8
    Shouldn't need to double it, but I suspect that's why I'm not following why you have .htaccess involved in the first place.

    Well since there's NO way to do that from server-side code anyways, why is this even a thing? That's JavaScript's job. It's not like you can make server-side code that opens new windows all on its own.

    A sample URI you'd be trying to parse is something like this, right?
    /tarot(deck'Original-Rider-Waite',reading'3-Cards')/music(youtubePlayList'ABCDEFG')

    Why not just pass that as $_GET to php directly somewhat simpler?
    parse.php?tarot=tdeck~Original-Rider-Waite|reading~3-Cards&music=youtubePlayList~ABCDEFG

    Then let PHP do the grunt-work?

    Even if you were to try and do some form of goofy non-standard encoding, just simplify your .htaccess down to:

    
    RewriteEngine On
    RewriteRule (^(tarot|music)) parse.php
    
    Code (markup):
    and parse $_SERVER['REQUEST_URI'] for it rather than having Apache struggle with complex regex to do it?

    
    <?php
    
    define('SCRIPT_PATH', cleanPath(pathinfo($_SERVER['SCRIPT_NAME'], PATHINFO_DIRNAME)));
    define('ROOT_HTTP', '/' . SCRIPT_PATH . (SCRIPT_PATH == '' ? '' : '/'));
    
    function cleanPath($path) {
    	return trim(str_replace(['\\', '%5C'],  '/', $path), '/');
    }
    
    $path = parse_url(
    	trim(
    		str_replace(['\\','%5C'], '/', $_SERVER['REQUEST_URI']
    	), '/'),
    	PHP_URL_PATH
    );
    if (strpos($path, '..')) die('Hacking Attempt Detected, Aborting');
    $path = substr($path, strlen(ROOT_HTTP) - 1);
    
    $sections = explode('/', $path);
    $result = [];
    foreach ($sections as $section) {
    	$name = substr($section, 0, $index = strpos($section, '('));
    	$result[$name] = [];
    	$subSections = explode(',', substr($section, $index + 1));
    	foreach ($subSections as $subText) {
    		$split = explode("'", $subText);
    		$result[$name][$split[0]] = $split[1];
    	}
    }
    
    echo '<pre>', print_r($result), '</pre>';
    
    Code (markup):
    There's your URI parsed in the PHP without having to get knee-deep into making Apache have to do anything more complex than go "the URI starts with one of these". You want the URI's, put them in the PHP... since you'd have to send that client side to be opening new windows with JS anyways.

    Wait, are you trying to pass the DATA client side in the URI?

    I'm really not getting where your practical application for any of this comes from. If you can make a working URI, why are you screwing around with all this?

    Just trying to understand the WHY or WHAT this would actually be used for... other than taking something simple (passing data in the URI) and making it agonizingly complex. It just seems like a bunch of code for nothing.
     
    deathshadow, Mar 13, 2017 IP
    seductiveapps.com likes this.
  9. seductiveapps.com

    seductiveapps.com Active Member

    Messages:
    200
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #9
    'why are you making things so complicated'... noted, and answered with this :

    i finally managed to simplify my code by a lot,
    i've gone opensource with my company at github,
    see http s://github.com/seductiveapps/seductiveapps

    it also contains (see the __README__documentation folder, all files starting with startupSequence*.*) screenshots that describe what i have invented.

    i am unavailable to explain my every move. i respect people who dont get it and ask me for clarifications, but i simply can no longer spend my time on that. i want to evolve my company, not teach at forums like digitalpoint.
    instead, i've opened a facebook page where i explain bits of what i do with my seductiveapps codeframework; it's address is http s://facebook.com/SeductiveAppsAcademy

    bye for now..
     
    seductiveapps.com, May 11, 2017 IP