Changeset 752566
- Timestamp:
- 08/06/2013 09:57:53 PM (13 years ago)
- File:
-
- 1 edited
-
amazon-wishlist-pro/trunk/Amazon-wishlist-pro.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
amazon-wishlist-pro/trunk/Amazon-wishlist-pro.php
r723007 r752566 27 27 { 28 28 unlink($cache_file); 29 update_option('Amazon-wishlist-pro-invalidate-cache', '0');30 29 } 31 30 } … … 37 36 $update = 1; 38 37 } 39 echo $wishListHTML;40 38 $wishListHTML = @file_get_html($wishListURL); 39 if($update == 1) 40 file_put_contents($cache_file, $wishListHTML, LOCK_EX); 41 $wishListHTML = $wishListHTML->find('div[id=item-page-wrapper]', 0); 42 41 43 if(!$wishListHTML) 42 44 return 'Invalid ListID ' . $listID .' for amazon.' . $website; 43 45 44 if($update == 1)45 file_put_contents($cache_file, $wishListHTML, LOCK_EX);46 46 47 47 $template = get_option('Amazon-wishlist-pro-layout'); 48 48 49 49 $output = ''; 50 $a = 0; 50 51 foreach($wishListHTML->find('.itemWrapper') as $element) 51 52 { … … 58 59 $output .= '</li>'; 59 60 60 61 $a++; 61 62 } 62 63 if(trim($output) != '') … … 65 66 $output = '<ul>' . $output . '</ul>'; 66 67 } 68 69 if($invalidateCache == 1) 70 update_option('Amazon-wishlist-pro-invalidate-cache', '0'); 71 67 72 return $output; 68 73 … … 71 76 function getItemInfo($node) 72 77 { 73 $price = utf8_encode($node->find('span.wlPriceBold',0)->plaintext);74 78 $image = $node->find('img',0)->src; 75 79 $buyLink = $node->find('.wlBuyButton a',0)->href; 76 80 $title = utf8_encode(trim($node->find('span.productTitle',0)->plaintext)); 77 81 $productLink = $node->find('span.productTitle strong a',0)->href; 82 $price = utf8_encode($node->find('span.wlPriceBold',0)->plaintext); 83 if(trim($price) == '') 84 { 85 $link = $productLink; 86 $useCache = get_option('Amazon-wishlist-pro-use-cache'); 87 $invalidateCache = get_option('Amazon-wishlist-pro-invalidate-cache'); 88 $cache_file_prod = __DIR__.'/' . md5($productLink) .'.cache'; 89 if($invalidateCache == 1) 90 { 91 if (file_exists($cache_file_prod)) 92 { 93 unlink($cache_file_prod); 94 } 95 } 96 if($useCache == 1) 97 { 98 if (file_exists($cache_file_prod) && (filemtime($cache_file_prod) > (time() - 60 * 24 ))) 99 $link = $cache_file_prod; 100 else 101 $update = 1; 102 } 103 $productHTML = @file_get_html($link); 104 if($update == 1) 105 file_put_contents($cache_file_prod, $productHTML, LOCK_EX); 106 107 $price = utf8_encode($productHTML->find('.priceLarge',0)->plaintext); 108 } 78 109 $info = array( 79 110 '@price@' => $price,
Note: See TracChangeset
for help on using the changeset viewer.