Greenguy's Board


Go Back   Greenguy's Board > Programming & Scripting
Register FAQ Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 2008-07-31, 03:53 PM   #1
Xallow
Hello, is this President Clinton? Good! I figured if anyone knew where to get some tang it would be you
 
Join Date: May 2006
Location: Denmark
Posts: 447
Send a message via ICQ to Xallow
split an url

hi guys and gals

I think I am getting tired, I have an url in a database called the following:

../../file.extention

I need to change that url to:

../file.extention

I can't for the life of me figure it... I know I am stupid... I need to split, but I cant get it to work

All help appreciated


Xallow
__________________
Porn Safe Submit Free Sites
Porn Party Porn Submit Free Sites
Xallow is offline   Reply With Quote
Old 2008-07-31, 04:18 PM   #2
cd34
a.k.a. Sparky
 
cd34's Avatar
 
Join Date: Sep 2004
Location: West Palm Beach, FL, USA
Posts: 2,396
If you're trying to remove it from the database, you could do:

Code:
update tablename set path=replace(path,'../../','../');
That would replace ../../../ with ../../ which may not be what you intend. You could set a condition on the update to match only those records that you want to fix.

If you are trying to remove it from some data, and you knew it was just the first three characters,

Code:
$path = substr('../../file.extension',3);
If you really wanted to remove those 3 characters, and only those 3 if they were present:

Code:
$path = preg_replace('/^..\//','','../../file.extension');
that way, if the string started with /asdf/file.extension, it wouldn't be affected

Another possibility is parse_url, but, I am not sure how it would react.

If you knew that you wanted to pull the first 'section' at the first /, you could do something like

Code:
$arr = (explode('/','../../file.extension'));
array_shift($arr);
$path = join($arr,'/');
That would always get rid of the first element.
__________________
SnapReplay.com a different way to share photos - iPhone & Android
cd34 is offline   Reply With Quote
Old 2008-08-01, 05:43 PM   #3
Xallow
Hello, is this President Clinton? Good! I figured if anyone knew where to get some tang it would be you
 
Join Date: May 2006
Location: Denmark
Posts: 447
Send a message via ICQ to Xallow
Thanks, that worked, I have another question though.

Is it not possible to get access to a folder on my server from my website? I created a folder on the server where my domains are hosted to use the files from that folder on all my sites, but when I link to those files I get nothing. Do I need to set some permission thingies or something?
__________________
Porn Safe Submit Free Sites
Porn Party Porn Submit Free Sites
Xallow is offline   Reply With Quote
Old 2008-08-01, 07:45 PM   #4
cd34
a.k.a. Sparky
 
cd34's Avatar
 
Join Date: Sep 2004
Location: West Palm Beach, FL, USA
Posts: 2,396
Depends on the server config. There are so many possible answers and configurations that you might need to check with your host. They could be restricting opens, you might be served from two different fileservers, so, while the path may look identical, you could be on two totally different paths, or many other possibilities.

You might do something like:

Code:
echo getcwd();
on each of your sites so that you can get the 'absolute' path. Though this might show you a chrooted path and not give you the true result. Your host should be able to help.
__________________
SnapReplay.com a different way to share photos - iPhone & Android
cd34 is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:14 AM.


Mark Read
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc