/** * Find XE installed path on ftp */ function getAdminFTPPath() { Context::loadLang(_XE_PATH_ . 'modules/autoinstall/lang'); @set_time_limit(5); $ftp_info = Context::getRequestVars(); if (!$ftp_info->ftp_user || !$ftp_info->ftp_password) { return new Object(1, 'msg_ftp_invalid_auth_info'); } if (!$ftp_info->ftp_host) { $ftp_info->ftp_host = '127.0.0.1'; } if (!$ftp_info->ftp_port || !is_numeric($ftp_info->ftp_port)) { $ftp_info->ftp_port = '21'; } if ($ftp_info->sftp == 'Y') { if (!function_exists('ssh2_sftp')) { return new Object(-1, 'disable_sftp_support'); } return $this->getSFTPPath(); } if ($ftp_info->ftp_pasv == 'N') { if (function_exists('ftp_connect')) { return $this->getFTPPath(); } $ftp_info->ftp_pasv = "Y"; } $oFTP = new ftp(); if (!$oFTP->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) { return new Object(1, sprintf(Context::getLang('msg_ftp_not_connected'), $ftp_info->ftp_host)); } if (!$oFTP->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) { return new Object(1, 'msg_ftp_invalid_auth_info'); } // create temp file $pin = $_SERVER['REQUEST_TIME']; FileHandler::writeFile('./files/cache/ftp_check', $pin); // create path candidate $xe_path = _XE_PATH_; $path_info = array_reverse(explode('/', _XE_PATH_)); array_pop($path_info); // remove last '/' $path_candidate = array(); $temp = ''; foreach ($path_info as $path) { $temp = '/' . $path . $temp; $path_candidate[] = $temp; } // try foreach ($path_candidate as $path) { // upload check file if (!$oFTP->ftp_put($path . 'ftp_check.html', FileHandler::getRealPath('./files/cache/ftp_check'))) { continue; } // get check file $result = FileHandler::getRemoteResource(getNotencodedFullUrl() . 'ftp_check.html'); // delete temp check file $oFTP->ftp_delete($path . 'ftp_check.html'); // found if ($result == $pin) { $found_path = $path; break; } } FileHandler::removeFile('./files/cache/ftp_check', $pin); if ($found_path) { $this->add('found_path', $found_path); } }
public function _home() { global $config, $user, $cache; $ftp = new ftp(); if (!$ftp->ftp_connect($config['broadcast_host'])) { _pre('Can not connect', true); } if (!$ftp->ftp_login($config['broadcast_username'], $config['broadcast_password'])) { $ftp->ftp_quit(); _pre('Can not login', true); } $cds_file = ROOT . 'interfase/cds/schedule_playlist.txt'; // Submit if (_button()) { $hours = request_var('hours', array('' => '')); $build = ''; foreach ($hours as $hour => $play) { $build .= ((!empty($build)) ? nr(1) : '') . trim($hour) . ':' . trim($play); } if ($fp = @fopen($cds_file, 'w')) { @flock($fp, LOCK_EX); fputs($fp, $build); @flock($fp, LOCK_UN); fclose($fp); _chmod($cds_file, $config['mask']); if ($ftp->ftp_put('/Schedule/schedule_playlist.txt', $cds_file)) { echo '<h1>El archivo fue procesado correctamente.</h1>'; } else { echo '<h1>Error al procesar, intenta nuevamente.</h1>'; } } else { echo 'Error de escritura en archivo local.'; } echo '<br />'; } if (!@file_exists($cds_file)) { fatal_error(); } $cds = @file($cds_file); $filelist = $ftp->ftp_nlist('/Schedule'); echo '<pre>'; print_r($filelist); echo '</pre>'; foreach ($cds as $item) { $e_item = array_map('trim', explode(':', $item)); if (!empty($e_item[0])) { echo sumhour($e_item[0]) . ' <input type="text" name="hours[' . $e_item[0] . ']" value="' . $e_item[1] . '" size="100"' . ((oclock($e_item[0])) ? 'class="highlight"' : '') . ' /><br />' . nr(); } } $ftp->ftp_quit(); return true; }