Jump to content

  • Log in with Facebook Log in with Twitter Log In with Google      Sign In   
  • Create Account

Subscribe to HRA Now!

 



SEO Class in Chicago, IL

Learn How To Optimize Your Website on July 26, 2013


Looking for personalized in-depth SEO training among your peers?



High Rankings is offering a 1-day customized SEO training class in Chicago. Class size is limited so please sign-up now if you want in!



 


Are you a Google Analytics enthusiast?

Share and download Custom Google Analytics Reports, dashboards and advanced segments--for FREE! 

 



 

 www.CustomReportSharing.com 

From the folks who brought you High Rankings!



Photo
- - - - -

Change The Name Of A Directory


  • Please log in to reply
8 replies to this topic

#1 piskie

piskie

    HR 7

  • Active Members
  • PipPipPipPipPipPipPip
  • 1,092 posts
  • Location:Cornwall

Posted 12 June 2008 - 06:51 PM

I need to provide the facility to change the name of a Sub Directory or Folder from a PHP Web Form. Is there an easy way to do this with my moderate PHP skills and can someone point me to an example please.

#2 Randy

Randy

    Convert Me!

  • Moderator
  • 17,540 posts

Posted 12 June 2008 - 10:55 PM

I don't understand the question piskie.

Where in the <form> are you needing to change the name of a subdirectory? What is the form supposed to do exactly?

#3 piskie

piskie

    HR 7

  • Active Members
  • PipPipPipPipPipPipPip
  • 1,092 posts
  • Location:Cornwall

Posted 13 June 2008 - 02:37 AM

This form is for the single purpose of Renaming a Sub Directory.
Intention is that the clients sales team can, when in the field, sell Pr-Configured Accounts consisting of full CMS with new merchant on their own Sub Directory. Such as:

website.co.uk/301
becomes
website.co.uk/smithbrothers

website.co.uk/302
becomes
website.co.uk/brownandson

The numbers 301 302 etc then becomes the merchant reference for MYSQL entries as well as billing and technical support. This allows a field sales person to set up a demo account and the whole thing can be configured from Web Forms with all other merchant profile specifics set using a normal record update form.

I do not wish to allow Sales People to have any "Powerful" access such as Cpanel etc for a multitude of obvious reasons and have spent a great deal of time designing the whole CMS Structure to work on the reference numbers leaving only the Renaming of a Sub Directory to be done, but it is not within my skills to do so.




#4 Randy

Randy

    Convert Me!

  • Moderator
  • 17,540 posts

Posted 13 June 2008 - 08:58 AM

Will the 301, 302, etc exist as physical locations on the server?

If so, it sounds like you're looking for PHP's rename function.

#5 piskie

piskie

    HR 7

  • Active Members
  • PipPipPipPipPipPipPip
  • 1,092 posts
  • Location:Cornwall

Posted 13 June 2008 - 07:15 PM

Yes Randy, there is a whole set of fully functioning sub directories 101 to 199 | 201 to 299 | 301 to 399 etc.

They are a;l working as merchant accounts with full CMS.
All that is required is to rename 301 to merchantname

Looking at the PHP rename function that you pointed me to it seems that is what I need to learn to do. I will look into examples etc and see if I can drive it from a form to do what I need.

By the way, will it maintain permissions including that of child folders and files within the renamed directory.



#6 Randy

Randy

    Convert Me!

  • Moderator
  • 17,540 posts

Posted 13 June 2008 - 09:20 PM

Good question piskie. And I'm not sure since I've never had the need to use that one. My guess however is that you'd probably run into problems.

How about another option that should actually be easier with the number of subdirectories you're talking about. You could use php to set up a Symbollic Link with the symlink() command, or a hard link with a link() command. Or if you have access to the exec funciton via php you can even use it with the normal *nix symlink command. eg exec('ln -s source destination');

Note if you use this one the order is going to seem a bit backwards. The Source is where the files actually exist. The Destination is what new location you want to enable. So in your case the number would come first and the merchantname would come second.

Also note that you may need to use the full server path, not the the path from the web root. When in doubt use the full path.

Using this method would mean the old subdirectories would still exist. The new directories would simply create a connection to allow the server to show it's sitting at one location when in actually it's still using the original location.

#7 piskie

piskie

    HR 7

  • Active Members
  • PipPipPipPipPipPipPip
  • 1,092 posts
  • Location:Cornwall

Posted 14 June 2008 - 01:26 PM

As we thought Randy, the permissions minefield rule out rename() and copy() so I am now looking at your symlink() suggestion. I am a bit puzzled by how exactly I can set this up so Field Sales Staff can configure using a Web Form.

The main criteria for a succesful solution is that sales person can change folder name (URL wise) without FTP and without request back to me to do it for them. Hence my focus on doing it via a Web Form and not to have too powerful a set of tools at that.

website.co.uk/302
becomes
website.co.uk/merchantsname

I can produce next available Number (302 etc) number from a Recordset because the number remains that merchant reference..
I could also produce Merchant Name from a recordset because the Sales person would have to enter that in the Table holding ALL Merchants details.

So I could quite easily make an include that would contain $reference along with associated $merchantname.
This include could be pulled into the redirect page after updating the Merchants Table.

So I have $reference and $merchantname to, pull into my symlink() page.
What exactly happens now ? Where is this stored ? Can I manually edit ?

Also will all URLs of files contained within the 302 folder be presented as:
merchantname/file.php
merchantname/products/file.php
instead of:
302/file.php
302/products/file.php
302/products/file.php

Further what about the possibility of SE Duplicate problems.

I know that's a lot to ask Randy, but I hope you have time.




#8 Randy

Randy

    Convert Me!

  • Moderator
  • 17,540 posts

Posted 15 June 2008 - 10:05 AM

I've gotta head out in just a bit (Father's Day stuff I'm being dragged off for) so won't be able to slap something together right now piskie, but it can be done. You'll really want the link(), symlink() or exec() statement to happen after the merchant number has been assigned, however it can all be done at once from a web form.

Definitely doable. Shouldn't be too hard. As soon as I get a few spare moments I'll try to whip up a little mockup for you to work from.

#9 Randy

Randy

    Convert Me!

  • Moderator
  • 17,540 posts

Posted 18 June 2008 - 01:50 PM

Well, this may end up being a bit more difficult than it appears at first glance. The functions are all there, but they don't work on any of my servers. I'm going to guess you're on a similar shared hosting *nix/Apache server. If you are, you're probably going to run into permission problems with having php set a symlink, link or even using exec("ln -s ...) to perform a linux symlink. At least I ran into permission problems on all of my servers when testing it a bit earlie today.

If you want to test it, create a test directory on the server in question. Then upload the following php file to the level just above this test directory and run it in your browser. (I'm naming the test directory testdir since it's hard coded.)

CODE
<?php
$actual_directory = "testdir";
$link_directory = "link_directory";
$symlink_directory = "symlink_directory";
$exec_directory = "exec_directory";

link($actual_directory, $link_directory);
symlink($actual_directory, $symlink_directory);
exec("ln -s " . $actual_directory . " " $exec_directory);
?>


If you have your php error reporting set to sensitive you'll see warning errors (Permission Denied) for the first two if they fail. For me the exec fails silently. Check in your FTP or control panel to see if any of the new directories have been created. I'm going to guess they probably haven't. After checking into it more closely, I doubt a host would open up those if they have them closed already since there are some pretty major security implications. I know I wouldn't.

So let me know how that goes and we can think on other ways to accomplish the same sort of thing. You could of course use a bit of mod_rewrite to allow people to use those named directories without them actually being created. And write a little php application to add lines to an .htaccess file to do it. This would probably be the easiest.

If you really wanted to make the symbolic linked directories real you'll probably have to resort to a cron job that fires every X minutes and reads from a file that php has written the details to. This should work in theory however since the server shouldn't run into the same permission problems Apache has.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users