private function preparePath($subfolder) { if (!ftp_chdir($this->stream, $this->path)) { $this->throwException('Cannot change directory to path "%s"', $this->path); } $p = $path = $this->path . $subfolder; $folders = array(); while ($p != $this->path) { if (!ftp_chdir($this->stream, $p)) { $folders[] = basename($p); $p = dirname($p); } else { krsort($folders); foreach ($folders as $folder) { $p .= '/' . $folder; if (!ftp_mkdir($this->stream, $p)) { $this->throwException('Cannot create path "%s"', $p); } ftp_chmod($this->stream, 0777, $p); } break; } } ftp_chdir($this->stream, $path); }
function putFile($filename) { if (!$this->connection || !$this->login_result) { $this->connect(); } $directories = dirname($filename); $file = basename($filename); $dir_array = explode('/', $directories); $empty = array_shift($dir_array); // Change into MIRROR_REMOTE_DIR. ftp_chdir($this->connection, MIRROR_REMOTE_DIR); // Create any folders that are needed. foreach ($dir_array as $dir) { // If it doesn't exist, create it. // Then chdir to it. if (@ftp_chdir($this->connection, $dir)) { // Do nothing. } else { if (ftp_mkdir($this->connection, $dir)) { ftp_chmod($this->connection, 0775, $dir); ftp_chdir($this->connection, $dir); } else { NDebug::debug('Cannot create a folder via ftp.', N_DEBUGTYPE_INFO); } } } // Put the file into the folder. $full_path = $_SERVER['DOCUMENT_ROOT'] . $filename; if (ftp_put($this->connection, $file, $full_path, FTP_BINARY)) { ftp_chmod($this->connection, 0775, $file); NDebug::debug("FTP Mirror: {$filename} was uploaded successfully", N_DEBUGTYPE_INFO); } else { NDebug::debug("FTP Mirror: {$filename} was NOT uploaded successfully", N_DEBUGTYPE_INFO); } }
/** * Set folder permission * @param string $folderChmod folder name * @param integer $permission permission value * @return string success message */ public function chmod($folderChmod, $permission) { if (ftp_chmod($this->conn, $permission, $folderChmod) !== false) { return true; } return false; }
public function ftp_chmod($mode, $file) { if (!$this->ftp_conn) { return false; } return @ftp_chmod($this->ftp_conn, $mode, $file); }
protected function Upload($dir, $files) { global $lang; $sum = 0; foreach ($files as $key => $val) { $sum += $_FILES[$val]['size']; } if ($sum <= 2097152) { $rel_dir = 'Uploads/'; $make_dir = FALSE; if (get_setting('ftp', 'use_ftp') || intval(get_setting('ftp', 'use_ftp')) == 1) { if ($conn_id = ftp_connect(get_setting('ftp', 'server'))) { if (@ftp_login($conn_id, get_setting('ftp', 'username'), get_setting('ftp', 'password'))) { @ftp_mkdir($conn_id, $rel_dir . $dir); @ftp_chmod($conn_id, 0777, $rel_dir . $dir); $make_dir = TRUE; } } } else { if (@mkdir($rel_dir . $dir)) { $make_dir = TRUE; } } if ($make_dir) { foreach ($files as $key => $file) { @move_uploaded_file($_FILES[$file]['tmp_name'], $rel_dir . $dir . '/' . $_FILES[$file]['name']); } } } else { return SetError::Set($lang['L_ERRORFILESTOOBIG']); } return TRUE; }
/** * preprocess Index action. * * @access public * @return string Forward name (null if no errors.) */ function prepare() { /* $this->af->setApp('xoops_cookie_path', '/itoh/hodajuku/html'); $this->af->set('xoops_root_path', '/home/smbuser/Site/main/public_html/itoh/hodajuku/html'); $this->af->set('xoops_trust_path', '/home/smbuser/Site/main/public_html/itoh/hodajuku/xoops_trust_path'); $this->af->setApp('result', 1); return 'json_copyfile'; */ if ($this->af->validate() == 0) { $username = $this->af->get('ftp_username'); $password = $this->af->get('ftp_password'); // let's copy if ($conn_id = ftp_connect('localhost')) { if (ftp_login($conn_id, $username, $password)) { $ftp_root = $this->seekFTPRoot($conn_id); $chroot = substr(BASE, strlen($ftp_root)); $xoops_root_path = substr($this->af->get('xoops_root_path'), strlen($ftp_root)); $remote_path = $chroot . '/tmp/html'; $this->ftpPut($remote_path, $xoops_root_path, $conn_id); $xoops_trust_path = substr($this->af->get('xoops_trust_path'), strlen($ftp_root)); $remote_path = $chroot . '/tmp/xoops_trust_path'; $this->ftpPut($remote_path, $xoops_trust_path, $conn_id); //// after script $dir777 = array($xoops_root_path . '/uploads', $xoops_root_path . '/uploads/fckeditor', $xoops_root_path . '/uploads/wizmobile', $xoops_trust_path . '/templates_c', $xoops_trust_path . '/cache', $xoops_trust_path . '/templates_c', $xoops_trust_path . '/uploads', $xoops_trust_path . '/session', $xoops_trust_path . '/log', $xoops_trust_path . '/tmp', $xoops_trust_path . '/modules/protector/configs', $xoops_trust_path . '/uploads/d3downloads', $xoops_trust_path . '/uploads/pico'); foreach ($dir777 as $_d) { ftp_chmod($conn_id, 0777, $_d); } /// mainfile.php ftp_chmod($conn_id, 0666, $xoops_root_path . '/mainfile.php'); ftp_close($conn_id); return null; } } } return 'json_error_reload'; }
protected function doChmod($remote_file, $chmod_code) { // try to chmod $chmod_code = octdec(str_pad($chmod_code, 4, '0', STR_PAD_LEFT)); $chmod_code = (int) $chmod_code; return ftp_chmod($this->getConnection(), $chmod_code, $remote_file); }
public static function changeMode($path, $chmodValue) { $fake = new ftpAccessWrapper(); $parts = $fake->parseUrl($path); $link = $fake->createFTPLink(); $serverPath = AJXP_Utils::securePath($fake->path . "/" . $parts["path"]); ftp_chmod($link, $chmodValue, $serverPath); }
public function chmod($mode = '0755', $file = '') { $this->dirlink = $file; if (FALSE === ftp_chmod($this->link, $mode, $this->dirlink)) { $this->errormsg = "Can't change this File/Dir"; return FALSE; } return TRUE; }
static function ftp_image_put_file($destFileName, $sourceFileName, $mode = FTP_BINARY) { if (self::ftp_image_connect()) { if (@ftp_put(ImageLib::$ftp_image_connect_id, $destFileName, $sourceFileName, $mode)) { @ftp_chmod(ImageLib::$ftp_image_connect_id, 0777, $destFileName); return true; } } return false; }
/** * write the compiled resource * * @param string $compile_path * @param string $compiled_content * @return true */ function myftpchmod($file) { $ftp_server = fvSite::$fvConfig->get("ftp.server_name"); $ftp_user_name = fvSite::$fvConfig->get("ftp.user"); $ftp_user_pass = fvSite::$fvConfig->get("ftp.pass"); $file = $file; $conn_id = ftp_connect($ftp_server); $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); $result = ftp_chmod($conn_id, 0777, $file); ftp_close($conn_id); return $result; }
function myftpchmod($file) { $ftp_server = "spo.ua"; $ftp_user_name = "spo"; $ftp_user_pass = "******"; $file = $file; $conn_id = ftp_connect($ftp_server); $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); $result = ftp_chmod($conn_id, 0777, $file); ftp_close($conn_id); return $result; }
public function chmod($mode, $file) { if ($this->_ftpStream) { if (function_exists('ftp_chmod')) { return ftp_chmod($this->_ftpStream, $mode, $file); } else { //echo "<h1>$file</h1>"; return ftp_site($this->_ftpStream, "chmod {$mode} {$file}"); //return ftp_exec($this->ftpStream, "chmod $mode $file"); } } return false; }
/** * Changes element CHMOD * * The param can be also instance of cFTP_Chmod * * @param int $chmod CHMOD * @throws cFTP_Exception */ public function changeMode($chmod) { if($chmod instanceof cFTP_Chmod) $chmod = $chmod->getChmod(); $success = @ftp_chmod($this->handle, $chmod, $filename); if( !$success ) throw new cFTP_Exception( "Could not change element CHMOD" ); return $this; }
/** * Log-Methode der erweiterten Query-Methode. * * Für jeden Monat wird eine Log-Datei erstellt. * Jede SQL-Anfrage wird protokolliert mit SQL-Anfrage, Zeitpunkt und Urheberskript. * * @param string $sqlQuery: SQL-Anfrage */ private function doLog($sqlQuery) { //Datei zum Schreiben bestimmen $logfile = PROJECT_DOCUMENT_ROOT . '/log/DB/dbEvents' . date('m_Y') . '.txt'; //Lokale Variable an globales FTP-Objekt anbinden $FTP = $GLOBALS['FTP']; ftp_chmod($FTP->FTPConn, 0757, PROJECT_DOCUMENT_ROOT . '/log/DB'); //String bereitstellen inkl. escapen $data = date("d.m.Y H:i:s", time()) . ' : ' . $sqlQuery . ' [' . $_SERVER['SCRIPT_FILENAME'] . ']' . "\n"; if (!file_put_contents($logfile, $data, FILE_APPEND)) { echo "Daten konnten nicht in Datei geschrieben werden."; } ftp_chmod($FTP->FTPConn, 0750, PROJECT_DOCUMENT_ROOT . '/log/DB'); }
function ftp_mksubdirs($ftpcon, $ftpbasedir, $ftpath) { @ftp_chdir($ftpcon, $ftpbasedir); // /var/www/uploads $parts = explode('/', $ftpath); // 2013/06/11/username foreach ($parts as $part) { if (!@ftp_chdir($ftpcon, $part)) { ftp_mkdir($ftpcon, $part); ftp_chdir($ftpcon, $part); ftp_chmod($ftpcon, 0777, $part); } } }
function set_permission($file, $mode) { $myreturn = ''; if ($this->op_mode == 'disk') { $myreturn = @chmod($file, $mode); } elseif ($this->op_mode == 'ftp') { $file = str_replace(_BASEPATH_ . '/', _FTPPATH_, $file); $old_de = ini_get('display_errors'); ini_set('display_errors', 0); if (function_exists('ftp_chmod')) { $myreturn = @ftp_chmod($this->ftp_id, $mode, $file); } else { $myreturn = ftp_site($this->ftp_id, "CHMOD {$mode} {$file}"); } ini_set('display_errors', $old_de); } }
function sendPorFtp(&$strRespuesta, $rutaArchivoFtp, $rutaArchivoTmp) { require_once 'Global.php'; $global = new G(); $conFtp = ftp_connect($global->getFtpServer()) or die("Error de conexion servidor de archivos"); $loginResultado = ftp_login($conFtp, $global->getFtpUserName(), $global->getFtpUserPass()) or die("Error de login"); if (!$conFtp || !$loginResultado) { die("La conexión a servido ftp no funciono!!"); } if (ftp_put($conFtp, $rutaArchivoFtp, $rutaArchivoTmp, FTP_BINARY)) { ftp_chmod($conFtp, 0775, $rutaArchivoFtp); $strRespuesta = $this->respOk . ": Archivo subido al repositorio"; ftp_close($conFtp); return true; } else { $strRespuesta = $this->respError . ": Problemas con el servidor de archivos"; ftp_close($conFtp); return false; } }
public static function uploadTestdata($judger, $data_config) { $prob_name = $data_config['name']; $testdata_path = MDL_Config::getInstance()->getVar('judger_testdata') . $prob_name . '/'; $temp_file = tempnam(sys_get_temp_dir(), 'Vakuum'); unset($data_config['id']); unset($data_config['title']); $xml = BFL_XML::Array2XML($data_config); file_put_contents($temp_file, $xml); $pftp = self::connect($judger); if (ftp_chdir($pftp, $judger->getConfig()->getTestdataPath()) === false) { throw new MDL_Exception_Judge_FTP(MDL_Exception_Judge_FTP::TESTDATA_UPLOAD); } if (@ftp_chdir($pftp, $prob_name) === false) { ftp_mkdir($pftp, $prob_name); ftp_chmod($pftp, 0755, $prob_name); ftp_chdir($pftp, $prob_name); } //Upload config.xml if (ftp_put($pftp, 'config.xml', $temp_file, FTP_BINARY) === false) { throw new MDL_Exception_Judge_FTP(MDL_Exception_Judge_FTP::TESTDATA_UPLOAD); } if ($data_config['checker']['type'] == 'custom') { //Upload checker $checker_source = $data_config['checker']['custom']['source']; $checker_file = $testdata_path . $checker_source; if (ftp_put($pftp, $checker_source, $checker_file, FTP_BINARY) === false) { throw new MDL_Exception_Judge_FTP(MDL_Exception_Judge_FTP::TESTDATA_UPLOAD); } } //Upload testdatas foreach ($data_config['case'] as $item) { foreach (array('input', 'output') as $key) { $testdata_file = $testdata_path . $item[$key]; if (ftp_put($pftp, $item[$key], $testdata_file, FTP_BINARY) === false) { throw new MDL_Exception_Judge_FTP(MDL_Exception_Judge_FTP::TESTDATA_UPLOAD); } } } ftp_close($pftp); }
public function eliminarDeFtp(&$strRespuesta, $rutaArchivoFtp) { require_once 'Global.php'; $global = new G(); $conFtp = ftp_connect($global->getFtpServer()) or die("Error de conexion"); $loginResultado = ftp_login($conFtp, $global->getFtpUserName(), $global->getFtpUserPass()) or die("Error de login"); if (!$conFtp || !$loginResultado) { die("La conexión a servido ftp no funciono!!"); } else { ftp_chmod($conFtp, 0777, $rutaArchivoFtp); } if (ftp_delete($conFtp, $rutaArchivoFtp)) { $strRespuesta = $this->respOk . ": Archivo eliminado del repositorio!"; ftp_close($conFtp); return true; } else { $strRespuesta = $this->respError . ": Problemas con el servidor de archivos"; ftp_close($conFtp); return false; } }
/** * preprocess Index action. * * @access public * @return string Forward name (null if no errors.) */ function prepare() { if ($this->af->validate() == 0) { $username = $this->af->get('ftp_username'); $password = $this->af->get('ftp_password'); $xoops_root_path = $this->af->get('root_path'); var_dump($username, $password, $xoops_root_path); if ($conn_id = ftp_connect('localhost')) { $this->af->setApp($i++, $i++); if (ftp_login($conn_id, $username, $password)) { $ftp_root = $this->seekFTPRoot($conn_id); if ($ftp_root !== false) { $install_dir = str_replace($ftp_root, '', $xoops_root_path) . '/install'; $install_dir_dest = $install_dir . '_' . Ethna_Util::getRandom(16); ftp_rename($conn_id, $install_dir, $install_dir_dest); $mainfile = str_replace($ftp_root, '', $xoops_root_path) . '/mainfile.php'; ftp_chmod($conn_id, 0644, $mainfile); return null; } } } } return 'json_error'; }
/** * 修改文件权限 * * @access public * @param string 目录标识(ftp) * @return boolean */ public function chmod($path, $perm) { if (!$this->_isconn()) { return FALSE; } //只有在PHP5中才定义了修改权限的函数(ftp) if (!function_exists('ftp_chmod')) { if ($this->debug === TRUE) { $this->_error("ftp_unable_to_chmod(function)"); } return FALSE; } $result = @ftp_chmod($this->conn_id, $perm, $path); if ($result === FALSE) { if ($this->debug === TRUE) { $this->_error("ftp_unable_to_chmod:path[" . $path . "]-chmod[" . $perm . "]"); } return FALSE; } return TRUE; }
function ftp_chmod($filename, $mod = 0777) { $filename = discuz_ftp::clear($filename); if (function_exists('ftp_chmod')) { return @ftp_chmod($this->connectid, $mod, $filename); } else { return @ftp_site($this->connectid, 'CHMOD ' . $mod . ' ' . $filename); } }
/** * chmod availability * * @param string $path * @param string $mode * @return bool */ protected function _chmod($path, $mode) { $modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o", $mode)); return @ftp_chmod($this->connect, $modeOct, $path); }
/** * @inheritdoc */ public function setVisibility($path, $visibility) { $mode = $visibility === AdapterInterface::VISIBILITY_PUBLIC ? $this->getPermPublic() : $this->getPermPrivate(); if (!ftp_chmod($this->getConnection(), $mode, $path)) { return false; } return compact('visibility'); }
/** * Create dir and return created dir path or false on failed * * @param string $path parent dir path * @param string $name new directory name * @return string|bool * @author Dmitry (dio) Levashov **/ protected function _mkdir($path, $name) { $path = $path . '/' . $name; if (ftp_mkdir($this->connect, $path) === false) { return false; } $this->options['dirMode'] && @ftp_chmod($this->connect, $this->options['dirMode'], $path); return $path; }
/** * Set file permissions * * @access public * @param string the file path * @param string the permissions * @return bool */ function chmod($path, $perm) { if (!$this->_is_conn()) { return FALSE; } // Permissions can only be set when running PHP 5 if (!function_exists('ftp_chmod')) { if ($this->debug == TRUE) { $this->_error('ftp_unable_to_chmod'); } return FALSE; } $result = @ftp_chmod($this->conn_id, $perm, $path); if ($result === FALSE) { if ($this->debug == TRUE) { $this->_error('ftp_unable_to_chmod'); } return FALSE; } return TRUE; }
} if (isset($ftp_server_array['ftp_check_login']) and intval($ftp_server_array['ftp_check_login']) == 1) { // Set up basic connection $conn_id = ftp_connect($ftp_server_array['ftp_server'], $ftp_server_array['ftp_port'], 10); // Login with username and password $login_result = ftp_login($conn_id, $ftp_server_array['ftp_user_name'], $ftp_server_array['ftp_user_pass']); if (!$conn_id || !$login_result) { $ftp_check_login = 3; } elseif (ftp_chdir($conn_id, $ftp_server_array['ftp_path'])) { $ftp_check_login = 1; } } if ($ftp_check_login == 1) { ftp_rename($conn_id, NV_TEMP_DIR . '/' . NV_CONFIG_FILENAME, NV_CONFIG_FILENAME); nv_chmod_dir($conn_id, NV_UPLOADS_DIR, true); ftp_chmod($conn_id, 0644, NV_CONFIG_FILENAME); ftp_close($conn_id); } else { @rename(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . NV_CONFIG_FILENAME, NV_ROOTDIR . '/' . NV_CONFIG_FILENAME); } } if (file_exists(NV_ROOTDIR . '/' . NV_CONFIG_FILENAME)) { $finish = 1; } else { $finish = 2; } $title = $lang_module['done']; $contents = nv_step_7($finish); } echo nv_site_theme($step, $title, $contents); function nv_save_file_config()
/** * @param string $file * @param int $mode * @param bool $recursive * @return bool */ public function chmod($file, $mode = false, $recursive = false) { if (!$mode) { if ($this->is_file($file)) { $mode = FS_CHMOD_FILE; } elseif ($this->is_dir($file)) { $mode = FS_CHMOD_DIR; } else { return false; } } // chmod any sub-objects if recursive. if ($recursive && $this->is_dir($file)) { $filelist = $this->dirlist($file); foreach ((array) $filelist as $filename => $filemeta) { $this->chmod($file . '/' . $filename, $mode, $recursive); } } // chmod the file or directory if (!function_exists('ftp_chmod')) { return (bool) @ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file)); } return (bool) @ftp_chmod($this->link, $mode, $file); }
/** * 设置文件权限 * * @access public * @param string 文件地址 * @param string 权限 * @return bool */ function chmod($path, $perm) { if (!$this->_is_conn()) { return FALSE; } // 仅PHP5才能运行 if (!function_exists('ftp_chmod')) { if ($this->debug == TRUE) { $this->_error('无法更改权限'); } return FALSE; } $result = @ftp_chmod($this->conn_id, $perm, $path); if ($result === FALSE) { if ($this->debug == TRUE) { $this->_error('无法更改权限'); } return FALSE; } return TRUE; }