How to detect current path? - url-routing

I am developing my first standalone web-application and i faced the problem with routing. For example my index is located in sites/folder/folder/index.php, so url for it would be http://site.com/folder/folder/index.php. So what is the best way to get all after index.php? Just use for or foreach until index.php is found or may be there is a better way?

Have you tried parsing urls by parse_url? This may help you.

Related

Joomla - redirect using article alias name?

I am new to joomla,
I am working in redirection based on article alias name, is it possible without any component
For eg:, www.domain.com/sitename/category/article-alias
This s not working, is there any other way to achieve this?
I think using .htaccess is the best way for this. Here's how:
http://kb.mediatemple.net/questions/242/How+do+I+redirect+my+site+using+a+.htaccess+file%3F
You need to make sure your htaccess.txt file is renamed as .htaccess first or it won't work. You should also check that your site works after renaming it as sometimes it may require a bit of configuration.

Get full path of an uploaded file jsp

I have a form in which I upload a file. Until here, it's okay. But then I need to get the uploaded file's full path but I have no idea how to do it. I've searched a lot but still, nothing. Can anyone help me? Please? Thank's.
If you use apache commons io, you can use the FilenameUtils class.
The getFullPath method should return what you need. However, I think that for some security reasons some browsers may change the path

Generate Wordpress posts

Is there any way to generate posts/pages for Wordpress? I have a seperate database with information I would like to use. For example, I would like to create the posts with the ID from my own database as link in Wordpress.
I think this is the way: http://codex.wordpress.org/Function_Reference/wp_insert_post although I have no idea where to put this. functions.php or post.php? And is it possible to call it on intervals? Maybe through a cronjob.
If anyone can point me in the right direction/confirm that I am on the right path that would be very helpfull.
Thanks!
Yes, wp_insert_post is the correct function, but the code should be in your own Plugin.
And then set up a WP Cron Job with wp_schedule_event

Using Adblock Plus subscriptions to remove ads from downloaded pages

I'd like to use the adblosck plus subscriptions to remove ads from the pages I'm about to scrap. Have anyone used such approach? What is the performance of such solution? What is the algorithm used by the extension itself?
After some googling I've found the post by the extension author:
http://adblockplus.org/blog/investigating-filter-matching-algorithms
Faster matching algorithm for ABP: https://adblockplus.org/forum/viewtopic.php?t=6118

Passing arguments to a handler in app.yaml

My app.yaml wants to do this:
handlers:
- url: /process/(.*)
script: process.py \1
So that I can pass an argument to the process.py script.
This was working in the SDK, but oes not seem to be possible in the production servers, possibly because they are looking for a file to execute "process.py arg" which does not exist.
Can anyone think of a way to do this without having to use a framework like django etc?
This is part of their security I think.
In my code I do something similar but I just take the path that is given and then parse that to get what I want. There is a probably a better way to handle the capture group but I haven't had the need for it yet
path = self.request.path
remove the /process/ stuff and do the rest
I found that the best way to actually do this was to POST the data to the handler.
If this is working in the SDK, it's a bug - this isn't a design feature. You need to use a framework like webapp to parse the URL and pass fragments of it to your handler. Why do you not want to do so?

Resources