private function sendToFtp() { try { require_once Xpandbuddy::$pathName . "/library/Ftp.php"; if (is_file(substr(ABSPATH, 0, -1) . self::$ds . 'wp-backups' . Xpandbuddy_Twig::_subdirCreation() . Xpandbuddy_Twig::$arrOptions['file_name']) !== false) { $_object = new Xpandbuddy_Ftp(); $_object->setChmod('0644')->setHost(urldecode(Xpandbuddy_Twig::$arrOptions['host']))->setUser(urldecode(Xpandbuddy_Twig::$arrOptions['user']))->setPassw(urldecode(Xpandbuddy_Twig::$arrOptions['pass']))->setRoot('/')->makeConnectToRootDir(); $_object->cd(Xpandbuddy_Twig::$arrOptions['dir_name']); $_object->fileUpload(Xpandbuddy_Twig::$arrOptions['file_name'], substr(ABSPATH, 0, -1) . self::$ds . 'wp-backups' . Xpandbuddy_Twig::_subdirCreation() . Xpandbuddy_Twig::$arrOptions['file_name']); $_object->closeConnection(); } @unlink(substr(ABSPATH, 0, -1) . self::$ds . 'wp-backups' . Xpandbuddy_Twig::_subdirCreation() . Xpandbuddy_Twig::$arrOptions['file_name']); return 'sended'; } catch (Exception $e) { return json_encode(array('error' => $e->getMessage(), 'status' => false)); } }
private function getResponce(&$strRes) { $_userTempDir = Xpandbuddy::$pathName . DIRECTORY_SEPARATOR . 'temp'; if (!Xpandbuddy::prepareTmpDir($_userTempDir)) { return false; } $file = '<?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "' . $this->getUri() . '" ); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0" ); curl_setopt($ch, CURLOPT_HTTPHEADER, array( "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Cache-Control: max-age=0", "Connection: keep-alive", "Keep-Alive: 300", "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7", "Accept-Language: en-us,en;q=0.5", )); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false); curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false); curl_setopt($ch, CURLOPT_TIMEOUT, 10); $responce = curl_exec($ch); // if( stripos($responce,"https://")&&stripos($responce,"refresh") ){ // curl_setopt($ch, CURLOPT_URL, "' . $this->getUri(true) . '" ); // $responce = curl_exec($ch); // } curl_close ($ch);'; if ($this->_skin == 'x3') { $file .= 'if( stripos( $responce , \'class="errors"\') ) { preg_match(\'/id="details">[\\n ]+([a-zA-Z .!]+)\\n/\', $responce, $match ); if( isset( $match[1] ) ){ echo $match[1]; }else{ echo "error"; } } else { echo "added"; }?>'; } else { $file .= 'if( stripos( $responce , "error") ) { echo "error"; } else { echo "added"; }?>'; } $_fileName = $_userTempDir . 'cpanel_creat.php'; if (!is_file($_fileName)) { $handle = fopen($_fileName, 'w'); fwrite($handle, $file); fclose($handle); } $_ftp = new Xpandbuddy_Ftp(); if (!$_ftp->setChmod('0644')->setHost(urldecode($this->_uri['host']))->setUser(urldecode($this->_uri['username']))->setPassw(urldecode($this->_uri['password']))->setRoot('public_html')->makeConnectToRootDir()) { return false; } if ($_ftp->fileUpload('cpanel_creat.php', $_fileName) !== true) { return false; } @unlink($_fileName); $strRes = $this->getUrl('http://' . $this->_uri['host'] . '/cpanel_creat.php'); if ($strRes === false) { return false; } if ($strRes === "added") { return true; } if (!empty($strRes) && $strRes != "error") { $this->error = $strRes; } return false; }