Jump to content


Photo
* * * * * 1 votes

Rooter [PHP Root Folder Locator]


  • Please log in to reply
6 replies to this topic

#1 yanike

yanike

    Read below. I'm not the one to mess with.

  • Global Moderator
  • 4,522 posts

Posted 04 May 2012 - 07:13 PM

Rooter by Yanike Mann (YeoWorks)


Rooter is a better way of locating files from root using PHP. You can use Rooter for locating anything from a root folder of your choice. You can now place multiple includes in one file and rooter will know exactly how to find the files from root using the Rooter script. No more "./", "../", "../../", and etc done differently on each page to find files. Rooter takes care of that for you and also can use URLs as root as well.

Background of Rooter: I started my new job with a web development/video production company who used Microsoft Servers for development. Coming from PHP, I really didn't like ASP. Long story short.. Boss told me if I could find a way to make PHP use root like ASP does with "/", then I could code their sites in PHP. So I went home and created Rooter, which uses any folder of choice or domain as root
.

You can use my Rooter script in personal and/or commercial products for FREE. Just leave the Copyright intact.


ROOTER project

Edited by yanike, 11 May 2012 - 03:37 PM.


#2 yoni5002

yoni5002

    Active WinMatrixian

  • Member
  • 345 posts

Posted 05 May 2012 - 12:19 AM

This is indeed pretty handy Yanike. Thanks a lot for sharing :)

#3 yanike

yanike

    Read below. I'm not the one to mess with.

  • Global Moderator
  • 4,522 posts

Posted 05 May 2012 - 06:41 AM

This is indeed pretty handy Yanike. Thanks a lot for sharing :)


You're Welcome

#4 Mayankoo

Mayankoo

    Mayank Agarwal

  • Member
  • 177 posts

Posted 05 May 2012 - 06:50 AM

Boss doesn't know a thing.... :P
haha, You should get double the salary as much as your Boss gets... :P
Ha ha ha..

#5 yanike

yanike

    Read below. I'm not the one to mess with.

  • Global Moderator
  • 4,522 posts

Posted 11 May 2012 - 03:35 PM

http://code.google.com/p/rooter/

#6 yanike

yanike

    Read below. I'm not the one to mess with.

  • Global Moderator
  • 4,522 posts

Posted 15 May 2012 - 04:15 PM

---- Rooter v2----
In Rooter v2, Rooter is a function instead of a variable. You can now just type rdot('FILENAME'); to locate a file from your selected ROOT. For PHP INCLUDES, you will use rdotinc('FILE');.

// ROOTER INCLUDE - Copyright 2012 Yanike Mann (YeoWorks) www.ywcorp.com yeoworks@gmail.com
// USE rdot() for locating anything using ./, ../, etc. e.g. rdot('img/ball.png');[/color]
function rdot($rstr){
$rooterchecker = 0; $rootdot = './'; $rootdot2 = '../'; while($rooterchecker != 2){ if($rooterchecker == 0){ include($rootdot."rooter.php"); if($rootercheck == 1){ echo $rootdot.$rstr; break; } else { $rooterchecker++; } } elseif($rooterchecker == 1){ include($rootdot2."rooter.php"); if($rootercheck == 1){ echo $rootdot2.$rstr; break; } else { $rootdot2 .= '../'; } } }
}
 [color="#000000"]// USE rdotinc() FOR PHP INCLUDES e.g. rdotinc('inc/hi.php');[/color]
function rdotinc($rstr){
$rooterchecker = 0; $rootdot = './'; $rootdot2 = '../'; while($rooterchecker != 2){ if($rooterchecker == 0){ include($rootdot."rooter.php"); if($rootercheck == 1){ include($rootdot.$rstr); break; } else { $rooterchecker++; } } elseif($rooterchecker == 1){ include($rootdot2."rooter.php"); if($rootercheck == 1){ include($rootdot2.$rstr); break; } else { $rootdot2 .= '../'; } } }
}

<body>
	<p><?php rdotinc('inc/hi.php'); ?><br /><img src="<?php rdot('img/yeoworks.png'); ?>" /></p>
</body>

Download Rooter



A good reason to use Rooter is to easily have one or more root directories. No need to deal with config files. This is just another way to get to a ROOT folder or ROOT folders of your choice.

// rdot() is nba folder and rdot2() wnba folder.
<img src="<?php rdot('img/ball.png'); ?>" />
<img src="<?php rdot2('img/ball.png'); ?>" />

// using rdot() is easier to see and better than writing:

<img src="../../../../../../../nba/img/ball.png" />
<img src="../../../../../../../wnba/img/ball.png" />

// or writing this:

<img src="../../../../nba/img/ball.png" />
<img src="../../../../../../../wnba/img/ball.png" />


Especially if you have to use the right number of dots by hand. rdot() takes care of everything for you.

Edited by yanike, 15 May 2012 - 04:38 PM.


#7 yanike

yanike

    Read below. I'm not the one to mess with.

  • Global Moderator
  • 4,522 posts

Posted 16 May 2012 - 04:11 PM

Wiki now available on page that explains everything.

Link:
http://code.google.c...ter/wiki/Rooter

Enjoy :)

Edited by yanike, 16 May 2012 - 04:11 PM.


Want to comment?

Register or Sign In to go completely ad-free!