You are here

Add new comment

Error message

The spam filter installed on this site is currently unavailable. Per site policy, we are unable to accept new submissions until that problem is resolved. Please try resubmitting the form in a couple of minutes.

Drupal a safe mode

Drupal 6.x lze po úpravě provozovat i na serveru, který má zapnutý Safe Mode (safe_mode=1), například na hostingu pipni.cz. Drupal ve standardní distribuci bohužel se Safe Mode neumí pracovat. Joomla například podporu pro Save Mode má. Zapnutý Safe Mode lze obejít pomocí použití funkcí FTP pro vytvoření adresáře.

Do souboru includes/file.inc je třeba přidat tuto funkci:

function mkdir_ftp($directory) {
  $directory = "your_drupal_ftp_base_folder/" . $directory;
  $ftpConn = ftp_connect("ftp.your.domain");
  if(false == ftp_login($ftpConn, "your_login", "your_password")) {
    watchdog('file system',
        'The directory cannot be created, ftp_login() failed.',
        array(), WATCHDOG_ERROR);
    return FALSE;
  }
  if(false == ftp_mkdir($ftpConn, $directory)) {
    watchdog('file system',
        'The directory %directory cannot be created, ftp_mkdir() failed.',
        array('%directory' => $directory), WATCHDOG_ERROR);
    return FALSE;
  }
  if(false == ftp_chmod($ftpConn, 0777, $directory)) {
    watchdog('file system',
        'The directory %directory cannot be created, ftp_chmod() failed.',
        array('%directory' => $directory), WATCHDOG_ERROR);
    return FALSE;
  }
  ftp_close($ftpConn);
  
  return TRUE;
}

a poté ji zavolat místo PHP funkce mkdir() ve stejném souboru, ve funkci file_check_directory():

function file_check_directory(&$directory, $mode = 0, $form_item = NULL) {
  $directory = rtrim($directory, '/\\');

  // Check if directory exists.
  if (!is_dir($directory)) {
    if (($mode & FILE_CREATE_DIRECTORY) && @mkdir_ftp($directory)) {
      drupal_set_message(t('The directory %directory has been created.', array('%directory' => $directory)));
      @chmod($directory, 0775); // Necessary for non-webserver users.
    }
...

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.