Changeset 1914965
- Timestamp:
- 07/25/2018 07:20:52 PM (8 years ago)
- Location:
- 2kb-amazon-dropship-manager/trunk
- Files:
-
- 2 added
- 3 edited
-
KbAmazonDropShipManagerController.php (modified) (3 diffs)
-
plugin.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
-
template/admin/downloadContent.phtml (added)
-
template/admin/downloadImages.phtml (added)
Legend:
- Unmodified
- Added
- Removed
-
2kb-amazon-dropship-manager/trunk/KbAmazonDropShipManagerController.php
r1261871 r1914965 139 139 return $view; 140 140 } 141 141 142 public function downloadImagesAction() 143 { 144 $view = new KbView(array()); 145 $view->setTemplate($this->getTemplatePath('downloadImages')); 146 return $view; 147 } 148 149 public function downloadContentAction() 150 { 151 $data = array(); 152 if (isset($_POST['asin'])) { 153 $importer = new KbAmazonImporter; 154 $item = $importer->find($_POST['asin']); 155 $item = $item->getItem(); 156 $data['item'] = $item; 157 } 158 159 $view = new KbView($data); 160 $view->setTemplate($this->getTemplatePath('downloadContent')); 161 return $view; 162 } 163 142 164 public function reportsAction() 143 165 { … … 166 188 'icon' => 'glyphicon-import', 167 189 'label' => __('Import Item'), 190 ), 191 array( 192 'action' => 'tools', 193 'icon' => 'glyphicon-cog', 194 'label' => __('Tools'), 195 'pages' => array( 196 array('action' => 'downloadImages', 'label' => __('Download Images by ASIN')), 197 array('action' => 'downloadContent', 'label' => __('Download Content ASIN')), 198 ) 168 199 ), 169 200 array( … … 199 230 return $KbAmazonDropShipManagerContoller; 200 231 } 232 233 234 if (isset($_POST['2kbDownloadImagesASIN'])) { 235 $importer = new KbAmazonImporter; 236 $item = $importer->find($_POST['asin']); 237 $item = $item->getItem(); 238 $url = $item['DetailPageURL']; 239 $response = wp_remote_get($url); 240 $html = $response['body']; 241 242 $lines = explode("\n", $html); 243 244 $images = []; 245 foreach ($lines as $line) { 246 if (strpos($line, 'data["colorImages"]') !== false) { 247 $pair = explode('data["colorImages"] =', $line); 248 $json = json_decode(substr(trim($pair[1]), 0, -1), true); 249 if (is_array($json)) { 250 foreach ($json as $group => $groupImages) { 251 foreach ($groupImages as $pair) { 252 $images[$group][] = !isset($pair['hiRes']) || empty($pair['hiRes']) ? $pair['large'] : $pair['hiRes']; 253 } 254 } 255 break; 256 } 257 } 258 } 259 260 if (empty($images)) { 261 foreach ($lines as $line) { 262 if (strpos($line, "'colorImages':") !== false) { 263 $pair = explode("'colorImages':", $line); 264 $jsonStr = str_replace("'initial'", '"initial"', trim(trim(substr($pair[1], 0, -1)))); 265 $result = json_decode($jsonStr, true); 266 if (is_array($result)) { 267 foreach ($result['initial'] as $data) { 268 $images['large'][] = !isset($data['hiRes']) || empty($data['hiRes']) ? $data['large'] : $data['hiRes']; 269 } 270 break; 271 } 272 } 273 } 274 } 275 276 $dir = sys_get_temp_dir(); 277 $zip = new \ZipArchive; 278 $zipFile = $dir . '/' . $_POST['asin'] . '.zip'; 279 $zip->open($zipFile, \ZipArchive::CREATE | \ZipArchive::OVERWRITE); 280 $filesToRemove = []; 281 $filesToRemove[] = $zipFile; 282 283 foreach ($images as $group => $groupImages) { 284 foreach ($groupImages as $key => $src) { 285 $tmp = $dir . '/' . uniqid($key) . '.jpg'; 286 file_put_contents($tmp, file_get_contents($src)); 287 288 $img = imagecreatefromjpeg($tmp); 289 imagejpeg($img, $tmp, 100); 290 291 $zip->addFile($tmp, $group . '/' . $key . '.jpg'); 292 $filesToRemove[] = $tmp; 293 } 294 } 295 $zip->close(); 296 297 header("Content-Type: application/force-download"); 298 header("Content-Type: application/octet-stream"); 299 header("Content-Type: application/download"); 300 header("Content-Disposition: attachment; filename=\"{$_POST['asin']}.zip\""); 301 header("Pragma: public"); 302 header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 303 header('Content-Length: ' . filesize($zipFile)); 304 305 readfile($zipFile); 306 307 foreach ($filesToRemove as $file) { 308 @unlink($file); 309 } 310 exit; 311 } -
2kb-amazon-dropship-manager/trunk/plugin.php
r1261871 r1914965 4 4 * Plugin URI: http://www.2kblater.com/ 5 5 * Description: Amazon DropShip Manager helps drop ship sellers to manage their products more easily. This plugin will help you keep track of quantity and price. It will send you reports for product changes by email. 6 * Version: 1. 0.06 * Version: 1.1.0 7 7 * Author: 2kblater.com 8 8 * Author URI: http://www.2kblater.com … … 12 12 !defined('ABSPATH') and exit; 13 13 14 define('KbAmazonDropShipManagerVersion', '1. 0.0');15 define('KbAmazonDropShipManagerNumber', 1 00);14 define('KbAmazonDropShipManagerVersion', '1.1.0'); 15 define('KbAmazonDropShipManagerNumber', 110); 16 16 define('KbAmazonDropShipManagerFolderName', pathinfo(dirname(__FILE__), PATHINFO_FILENAME)); 17 17 define('KbAmazonDropShipManagerPluginPath', dirname(__FILE__) . '/'); -
2kb-amazon-dropship-manager/trunk/readme.txt
r1810789 r1914965 3 3 Requires at least: 4.0 4 4 Tested up to: 4.1 5 Stable tag: 1. 0.15 Stable tag: 1.1.0 6 6 License: GPLv2 or later 7 7 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 30 30 31 31 == Changelog == 32 = 1.1.0 = 33 new tools added 32 34 = 1.0.1 = 33 35 modal removed
Note: See TracChangeset
for help on using the changeset viewer.