Pop\Ftp\Ftp::chmod PHP Метод

chmod() публичный Метод

Change permissions.
public chmod ( string $file, string $mode ) : Ftp
$file string
$mode string
Результат Ftp
    public function chmod($file, $mode)
    {
        if (!ftp_chmod($this->conn, $mode, $file)) {
            throw new Exception('Error: There was an error changing the permission of ' . $file);
        }
        return $this;
    }

Usage Example

Пример #1
0
 public function fetch($resource)
 {
     if ($this->isValidPostData($this->request->getPost())) {
         $data = $this->parsePostData();
         try {
             $ftp = new Ftp($data['address'], $data['username'], $data['password'], $data['ssl']);
             $ftp->pasv($data['pasv']);
             switch ($resource) {
                 case 'phirecms':
                     if (file_exists(__DIR__ . '/../../public/releases/phire/phire.json')) {
                         $files = json_decode(file_get_contents(__DIR__ . '/../../public/releases/phire/phire.json'), true);
                         $remote = $data['root'] . $data['base_path'] . $data['app_path'] . '/';
                         foreach ($files as $file) {
                             $dir = dirname($file);
                             if (!$ftp->dirExists($remote . $dir)) {
                                 $ftp->mkdirs($remote . $dir);
                             }
                             $ftp->put($remote . $file, __DIR__ . '/../../public/releases/phire/phire-cms/' . $file);
                         }
                     }
                     break;
                 default:
                     if ($this->request->getQuery('theme') == 1 && file_exists(__DIR__ . '/../../public/releases/themes/' . $resource . '.zip') && !empty($data['content_path'])) {
                         $remote = $data['root'] . $data['base_path'] . $data['content_path'] . '/themes/';
                         $ftp->put($remote . $resource . '.zip', __DIR__ . '/../../public/releases/themes/' . $resource . '.zip');
                         $ftp->chmod($resource . '.zip', 0777);
                     } else {
                         if (file_exists(__DIR__ . '/../../public/releases/modules/' . $resource . '.zip') && !empty($data['content_path'])) {
                             $remote = $data['root'] . $data['base_path'] . $data['content_path'] . '/modules/';
                             $ftp->put($remote . $resource . '.zip', __DIR__ . '/../../public/releases/modules/' . $resource . '.zip');
                             $ftp->chmod($resource . '.zip', 0777);
                         }
                     }
             }
             $this->response->setBody(json_encode(['message' => 'Successful transfer.'], JSON_PRETTY_PRINT));
             $this->response->send(200);
         } catch (\Exception $e) {
             $this->response->setBody(json_encode(['error' => $e->getMessage()], JSON_PRETTY_PRINT));
             $this->response->send(401);
         }
     } else {
         $this->error();
     }
 }