Koozali.org: home of the SME Server

Using PHP to copy between ibays

Offline wdepot

  • ***
  • 90
  • +0/-0
    • http://westerndepot.com
Using PHP to copy between ibays
« on: March 24, 2024, 01:21:13 AM »
In my attempt to create an updated web site I need to be able to copy images from the original site using PHP since some images are going to be in new locations and the images on the old site are constantly changing as items are added and deleted. Unfortunately I am getting the following error from the PHP copy commands:
Code: [Select]
Warning: copy(): open_basedir restriction in effect. File(/home/e-smith/files/ibays/oldsite/html/images/imagename) is not within the allowed path(s):
As open_basedir is supposed to be settable anywhere according to the PHP manuals I have tried the following in my conversion program which is in the new ibay:
Code: [Select]
$tmp = ini_get('open_basedir');
$tmp .= ':/home/e-smith/files/ibays/oldsite/';
ini_set('open_basedir', $tmp);
However I still get the copy failure and when I do another ini_get after doing the ini_set I find that open_basedir hasn't been changed for some reason. I'm running PHP 8.3 on the new ibay. Anyone have any ideas for a workaround that will allow me to do what I'm trying to do? Maybe a temporary custom template for the settings on the new ibay that I can remove once the conversion is finalized?

Offline Jean-Philippe Pialasse

  • *
  • 2,819
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: Using PHP to copy between ibays
« Reply #1 on: March 24, 2024, 01:50:25 AM »
ibays are protected from each other
, and folders outside of the ibay too, to avoid one malicious script from doing harm everywhere on the server. this is called open_basedir


you can add some folder in the open_basedir list.  i suggest using smeserver-webhosting panel to alter this value for your need


Offline wdepot

  • ***
  • 90
  • +0/-0
    • http://westerndepot.com
Re: Using PHP to copy between ibays
« Reply #2 on: March 27, 2024, 06:38:13 PM »
ibays are protected from each other
, and folders outside of the ibay too, to avoid one malicious script from doing harm everywhere on the server. this is called open_basedir


you can add some folder in the open_basedir list.  i suggest using smeserver-webhosting panel to alter this value for your need
Thanks for the pointer. I had looked at Web Hosting but failed to notice the Basedir setting at the very bottom, perhaps because it defaults to blank which loads the default values I was seeing in ini_get.

Offline ReetP

  • *
  • 3,805
  • +5/-0
Re: Using PHP to copy between ibays
« Reply #3 on: March 27, 2024, 08:24:34 PM »
Remember that setting is there for your protection so make sure you don't forget to turn it off again!
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation