WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.9 is now available!


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Droplets & Snippets »
  • New Page in Safe Mode=ON Permissions Problem (FTP UPLOAD)
  • Print
Pages: [1]   Go Down

Author Topic: New Page in Safe Mode=ON Permissions Problem (FTP UPLOAD)  (Read 5427 times)

saeidcdc

  • Guest
New Page in Safe Mode=ON Permissions Problem (FTP UPLOAD)
« on: November 08, 2009, 09:22:17 PM »
I had some problems with adding pages in safe_mode=enable server (plesk control panel)
so new pages had apache owner and not available!
I have changed this functions.php for work with folders & permissions, i know that is very ugly! but it works
in main pages and 2nd level pages and often in 3th level!

CHANGES: in framework/functions.php file:
take following function:
Code: [Select]
// Function to create directories
function make_dir($dir_name, $dir_mode = OCTAL_DIR_MODE) {
    if(!file_exists($dir_name)) {
        $umask = umask(0);
        mkdir($dir_name, $dir_mode);
        umask($umask);
        return true;
    } else {
        return false;    
    }
}
and replace with this:
Code: [Select]
// Function to create directories
function make_dir($dir_name, $dir_mode = OCTAL_DIR_MODE) {
    if(!file_exists($dir_name)) {
        $parent_folders = str_replace(WB_PATH.PAGES_DIRECTORY.'/', '', $dir_name);
        $ftp_server = "xxxxxxxx";
        $ftp_user = "xxxxxxxx";
        $ftp_pass = "xxxxxxxx";
        // set up a connection or die
        $conn = @ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server <br/>");
        // try to login
        if (@ftp_login($conn, $ftp_user, $ftp_pass)) {
//            echo "Connected as $ftp_user@$ftp_server\n<br/>";
        } else {
//            echo "Couldn't connect as $ftp_user\n<br/>";
        }

// YOU MAY NEED TO CHANGE THIS LINE
        @ftp_chdir($conn, "httpdocs/fa/pages");

        if (@ftp_mkdir($conn, $parent_folders)) {
//         echo "successfully created $parent_folders\n<br/>";
        } else {
//         echo "There was a problem while creating $parent_folders\n<br/>";
        }
        if (@ftp_chmod($conn, 0777, $parent_folders) !== false) {
//         echo "$parent_folders chmoded successfully to 0777\n<br/>";
        } else {
//         echo " could not chmod $parent_folders\n<br/>";
        }

        @ftp_close($conn);

//        umask($umask);
        return true;
    } else {
        return false;    
    }
}

and take following part:
Code: [Select]
       $handle = fopen($filename, 'w');
        fwrite($handle, $content);
        fclose($handle);
        // Chmod the file
        change_mode($filename);

and replace with this:
Code: [Select]
       $ftp_server = "xxxxxxxxx";
        $ftp_user = "xxxxxxxxx";
        $ftp_pass = "xxxxxxxxx";
        $file_ext = basename($filename);
        $filehandy = str_replace(WB_PATH.PAGES_DIRECTORY.'/', '', $filename);
        $destfolder = substr($filehandy , 0, strlen($filehandy)-strlen($file_ext)) ;
        // set up a connection or die
        $conn1 = @ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
        // try to login
        if (@ftp_login($conn1, $ftp_user, $ftp_pass)) {
//            echo "Connected as $ftp_user@$ftp_server\n";
        } else {
//            echo "Couldn't connect as $ftp_user\n";
        }

// YOU MAY NEED TO CHANGE THIS LINE
        @ftp_chdir($conn1, "httpdocs/fa/pages/");
        if (@ftp_chmod($conn1, 0777, substr($destfolder, 0, -1)) !== false) {
//         echo "$destfolder chmoded successfully to 0777\n<br/>";
        } else {
//         echo "could not chmod $destfolder\n<br/>";
        }

        $handle = fopen($filename.'.tmp', 'w');
        fwrite($handle, $content);
        fclose($handle);
//        Chmod the file
//        chmod($filename, 0755);
        change_mode($filename);

        if(@ftp_chdir($conn1, substr($destfolder, 0, -1))) {
//            echo "Current directory is now: " . $destfolder . "\n";
        } else {
//            echo "Couldn't change directory\n";
        };
        @ftp_chdir($conn1, WB_PATH.PAGES_DIRECTORY);
        if (@ftp_put($conn1, $file_ext, $filename.'.tmp', FTP_ASCII)) {
        echo "Successfully Created Page File\n";
        } else {
        echo "There was a problem while creating $filename\n";
        }
        unlink($filename.'.tmp');
   
        @ftp_chdir($conn1, "../");
        if (@ftp_chmod($conn1, 0755, substr($destfolder, 0, -1)) !== false) {
//         echo "$destfolder chmoded successfully to 0755\n<br/>";
        } else {
//         echo "could not chmod $destfolder\n<br/>";
        }
        @ftp_close($conn1);

ITS DONE! :-D
Logged

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Droplets & Snippets »
  • New Page in Safe Mode=ON Permissions Problem (FTP UPLOAD)
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2