public static function getFiles() { $host = "localhost"; $ftp = new FtpClient(); $ftp->connect($host); $ftp->login("ftp", "ftp"); $remote_file = "techchar_values_assignment.xml"; $local_file = Yii::getAlias('@app') . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . "techchar_values_assignment.xml"; $ftp->get($local_file, $remote_file, $mode = FTP_ASCII); self::parse($local_file); }
public static function getFiles() { $host = Yii::$app->params['ftp']['host']; $name = Yii::$app->params['ftp']['name']; $pass = Yii::$app->params['ftp']['pass']; $ftp = new FtpClient(); $ftp->connect($host); $ftp->login($name, $pass); $remote_file = Yii::getAlias('@ftpXml') . DIRECTORY_SEPARATOR . "properties.xml"; $local_file = Yii::getAlias('@localXml') . DIRECTORY_SEPARATOR . "properties.xml"; $ftp->get($local_file, $remote_file, $mode = FTP_ASCII); self::parseValues($local_file); }
public static function getImages() { $host = Yii::$app->params['ftp']['host']; $name = Yii::$app->params['ftp']['name']; $pass = Yii::$app->params['ftp']['pass']; $ftp = new FtpClient(); $ftp->connect($host); $ftp->login($name, $pass); $files = $ftp->scanDir(Yii::getAlias('@ftpProductsImg')); foreach ($files as $file) { $local_file = Yii::getAlias('@localProductsImg') . DIRECTORY_SEPARATOR . $file['name']; $remote_file = Yii::getAlias('@ftpProductsImg') . DIRECTORY_SEPARATOR . $file['name']; $ftp->get($local_file, $remote_file, $mode = FTP_ASCII); } }
public function saveOrderFtp() { $host = Yii::$app->params['ftp']['host']; $name = Yii::$app->params['ftp']['name']; $pass = Yii::$app->params['ftp']['pass']; $ftp = new FtpClient(); $ftp->connect($host); $ftp->login($name, $pass); $dirExist = $ftp->isDir('orders'); if (!$dirExist) { $ftp->mkdir('orders'); } if (ftp_chdir($ftp->getConnection(), "orders")) { $order = $this; $orderXML = new \SimpleXMLElement("<?xml version=\"1.0\" encoding=\"windows-1251\"?><order></order>"); $orderXML->addAttribute('order_id', $order->order_id); $orderXML->addAttribute('create_time', $order->getFormattedCreateTime()); $orderXML->addAttribute('name', $order->name); $orderXML->addAttribute('email', $order->email); $orderXML->addAttribute('phone', $order->phone); $orderXML->addAttribute('delivery', $order->delivery); $orderXML->addAttribute('address', $order->address); $orderXML->addAttribute('comment', $order->comment); $products = $order->products; $productsXML = $orderXML->addChild('products'); foreach ($products as $product) { $productXML = $productsXML->addChild('product'); $productXML->addAttribute('product_id', $product->product_id); $productXML->addAttribute('name', $product->name); $productXML->addAttribute('quantity', $product->quantity); $productXML->addAttribute('price', $product->price); $productXML->addAttribute('summa', $product->summa); } $xml = $orderXML->asXML(); $ftp->putFromString('order_' . $order->order_id . '.xml', $xml); } }