Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

froogle.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: froogle.php,v 1.3 2005/03/08 16:18:42 ghb Exp $
5 //
6 // Created on: <22-Jun-2001 13:16:55 br>
7 //
8 // This source file is part of Exponential Basic, publishing software.
9 //
10 // Copyright (C) 1999-2005 eZ Systems. All rights reserved.
11 //
12 // This program is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
25 //
26
27
29 // Includes : include the classes.
30 ob_end_clean();
31
32 // include_once( "classes/template.inc" );
33 include_once( "eztrade/classes/ezproduct.php" );
34 include_once( "classes/INIFile.php" );
35
36 //
38
40 // increse php execution time to allow for long running scripts (re: ftp connections)
41 ini_set("max_execution_time", 300);
42 ini_set('upload_max_filesize', 5242880); // 5MB
43
45 // Settings
46
47 $ini =& eZINI::instance( 'site.ini' );
48
49 $SiteURL = $ini->variable( "site", "UserSiteURL" );
50 $wwwDir = $ini->variable( "site", "UserSiteURL" );
51 $PricesIncludeVAT = $ini->variable( "eZTradeMain", "PricesIncludeVAT" ) == "enabled" ? true : false;
52 $MainImageWidth = $ini->variable( "eZTradeMain", "MainImageWidth" );
53 $MainImageHeight = $ini->variable( "eZTradeMain", "MainImageHeight" );
54 $SitePath = $ini->variable( "site", "SitePath" );
55
56
58 // FTP: Server, User, Password
59
60 // use file location + name
61 //$FroogleServer = $ini->variable( "site", "ServerFroogle" );
62 //$FroogleUser = $ini->variable( "site", "UserFroogle" );
63 //$froogle_pass = $ini->variable( "site", "PasswordFroogle" );
64
65 $FroogleServer="hedwig.google.com";
66 $FroogleUser="fullthrottle";
67 $FroogleKey="key";
68
69 $FroogleServer="fullthrottle.com";
70 $FroogleServerPort="21";
71 $FroogleUser="full";
72 $FroogleKey="key";
73
74 if( $Action == "export" ){
75 $exportCSVFile = true;
76 } elseif( $Action == "export-cron" ) {
77 // export : csv file to user agent
78 $exportCSVFile = false;
79 } else {
80 $exportCSVFile = false;
81 }
82
83 // if( $Action == "export-cron" ) {
84 // export : csv file to user agent
85 // $exportCSVFile = false;
86 // }
87
88
90 // Build Product Export Data
91
92 // if ($exportCSVFile){
93
94 $product = new eZProduct();
95 $productList = $product->activeProducts( "time", 0, "" );
96
97 $feed = "product_url\t name\t description\t price\t image_url\t category\n";
98
99 /* Example of original rules (problems-inside)
100
101 $search = array ("'<script[^>]*?>.*?</script>'si", // Strip out javascript
102 "'<[\/\!]*?[^<>]*?>'si", // Strip out HTML tags
103 "'([\r\n])[\s]+'", // Strip out white space
104 "'[\r\n\s]+'",
105 "'&(quot|#34);'i", // Replace HTML entities
106 "'&(amp|#38);'i",
107 "'&(lt|#60);'i",
108 "'&(gt|#62);'i",
109 "'&(nbsp|#160);'i",
110 "'&(iexcl|#161);'i",
111 "'&(cent|#162);'i",
112 "'&(pound|#163);'i",
113 "'&(copy|#169);'i",
114 "'&#(\d+);'e"); // evaluate as php
115
116 $replace = array ("",
117 "",
118 "\\1",
119 "\"",
120 "&",
121 "<",
122 ">",
123 " ",
124 chr(161),
125 chr(162),
126 chr(163),
127 chr(169),
128 "chr(\\1)");
129 */
130
131 // these string patters might cause space to " problems
132
133 // "'([\r\n])[\s]+'", // Strip out white space
134 // "'[\r\n\s]+'",
135
136 // "\\1",
137 // "\"",
138
139 // replace the previous string patterns with these values (ordered list)
140 $replace = array ("",
141 "",
142 "&",
143 "<",
144 ">",
145 " ",
146 chr(161),
147 chr(162),
148 chr(163),
149 chr(169),
150 "chr(\\1)");
151
152 // patterns
153 $search = array ("'<script[^>]*?>.*?</script>'si", // Strip out javascript
154 "'<[\/\!]*?[^<>]*?>'si", // Strip out HTML tags
155 "'([\r\n])[\s]+'", // Strip out white space
156 "'\n'i",
157 "'\r\n'i",
158 "'\r'i",
159 "'&(quot|#34);'i", // Replace HTML entities
160 "'&(amp|#38);'i",
161 "'&(lt|#60);'i",
162 "'&(gt|#62);'i",
163 "'&(nbsp|#160);'i",
164 "'&(iexcl|#161);'i",
165 "'&(cent|#162);'i",
166 "'&(pound|#163);'i",
167 "'&(copy|#169);'i",
168 "'&#(\d+);'e"); // evaluate as php
169
170 $replace = array ("",
171 "",
172 "\\1",
173 "",
174 "",
175 "",
176 "&",
177 "<",
178 ">",
179 " ",
180 chr(161),
181 chr(162),
182 chr(163),
183 chr(169),
184 "chr(\\1)");
185
186 // prepare each product information
187 foreach ($productList as $product)
188 {
189 $line['product_url'] = "http://" . $wwwDir . "/trade/productview/" . $product->id() . "/";
190 $line['name'] = html_entity_decode( $product->name() ) ." - ". $product->productNumber();
191 // print($line['name']);
192 $line['description'] = html_entity_decode($product->brief());
193
194 // this line causes "" in product name, so we are removing it
195 $line['name'] = preg_replace($search, $replace, $line['name']);
196 // $line['name'] = $line['name'];
197
198 $line['description'] = preg_replace($search, $replace, $line['description']);
199 // $line['description'] = $line['description'];
200
201 // not sure why this is commented out? no tax in price?
202 // $line['price'] = str_replace( "$&nbsp;", "", $product->localePrice( $PricesIncludeVAT ) );
203 $line['price'] = $product->price();
204
205 $mainImage = $product->mainImage();
206 if ( $mainImage )
207 {
208 $variation =& $mainImage->requestImageVariation( $MainImageWidth, $MainImageHeight );
209 $line['image_url'] = "http://" . $SiteURL . "/" . $variation->imagePath();
210 }
211 else
212 $line['image_url'] = "";
213
214 $category = $product->categoryDefinition();
215 $pathArray =& $category->path();
216 $line['category'] = "";
217 $i = 1;
218
219 foreach ( $pathArray as $path )
220 {
221 $line['category'] .= $path[1];
222 if ( $i != count($pathArray) )
223 $line['category'] .= " > ";
224 $i++;
225 }
226
227 $feed .=
228 $line['product_url'] . "\t" .
229 $line['name'] . "\t" .
230 $line['description'] . "\t" .
231 $line['price'] . "\t" .
232 $line['image_url'] . "\t" .
233 $line['category'] . "\n";
234 }
235
236 $file = new eZFile();
237 $file->dumpFroogleDataToFile( $feed, "fullthrottle.txt" );
238
239 $fileName = $file->tmpName();
240 $fileSize = filesize( $fileName );
241
242 chmod( $fileName, 0644 );
243
244 // unlink ( "/home/web/public_html/export_froogle/");
245
246 $fp = fopen( $fileName, "r" );
247 $content =& fread( $fp, $fileSize );
248
249
250
251
252 /*
254 }
255 else {
256 // fake file
257 // $file = new eZFile();
258 // $file->dumpDataToFile( $feed, "fullthrottle.txt" );
259
260 // $fileName = $file->tmpName();
261 // $fileSize = filesize( $fileName );
262
263 $fileName = $SitePath . '/export_froogle/attQ98AJz';
264
265 $fileSize = filesize( $fileName );
266 //chmod( $fileName, 0777 );
267
268 // $fp = fopen( $fileName, "r" );
269 // $content =& fread( $fp, $fileSize );
270 }
272 */
273
274
275
276
278 // export to a file instead.... else, export to a file and ftp instead....
279 if( $exportCSVFile ){
280 header( "Cache-Control:" );
281 header( "Content-Length: $fileSize" );
282 header( "Content-disposition: attachment; filename=fullthrottle.txt" );
283 header( "Content-Transfer-Encoding: binary" );
284
285 echo($content);
286 unlink( $file->tmpName() );
287 } else {
288 $source_file_name = $fileName;
289
290
291 // $destination_file = "/trash/fullthrottle.txt";
292
293 /*
294 $source_fp = fopen( $source_file_name , 'r');
295 $source_c =& fread( $source_fp, $fileSize );
296 */
297
298 // die($source_c);
299
300
301 // begin debug / log output
302 echo "\n ############################################################### \n";
303
304 include_once("classes/ezdatetime.php");
305
306 $date = new eZDateTime();
307 $month = $date->month();
308 $day = $date->day();
309 $year = $date->year();
310 $hour = $date->addZero($date->hour());
311 $minute = $date->addZero($date->minute());
312
313 $date = "$month".'/'."$day".'/'."$year".' | '."$hour".' : '."$minute";
314 echo "Date : $date \n";
315 echo "CSV : Exponential Basic (trade) Product : Export File : ($fileSize kb) : $fileName \n";
316
317
319 // if ( isset( $dfile ) )
320 // {
321 // save the buffer contents
322
323 // echo "Run: $SitePath/bin/cron/froogle_upload.sh $SitePath/export_froogle/attQ98AJz \n";
324 echo "Run: $SitePath/bin/cron/froogle_upload.sh $fileName \n";
325
326 /*
327 $buffer =& ob_get_contents();
328 ob_end_clean();
329
330 // fetch the system printout
331 ob_start();
332 */
333
334 // $SitePath
335 // system( "$SitePath/bin/cron/froogle_upload.sh $SitePath/export_froogle/attQ98AJz" );
336
337 system( "$SitePath/bin/cron/froogle_upload.sh $fileName" );
338
339
340 /*
341 $ret = ob_get_contents();
342 ob_end_clean();
343
344 // fill the buffer with the old values
345 ob_start();
346 print( $buffer );
347 // }
348
349 */
350
351
352 // echo " \n";
353 // print("end of file\n\n");
355
356 // unlink export file
357 unlink( $file->tmpName() );
358
359 }
360
361 exit();
362
363 ?>
$category
if( $Action=="Edit") $category
Definition: adedit.php:378
$pathArray
$pathArray
Definition: admin/adlist.php:74
$i
$i
Definition: admin/adlist.php:91
eZDateTime
Definition: ezdatetime.php:55
eZFile
Tool class which has convencience functions for files and directories.
Definition: ezfile.php:19
eZProduct
Definition: ezproduct.php:71
$Action
$Action
Definition: companysearch.php:80
$variation
$variation
Definition: ezimagecatalogue/user/menubox.php:55
exit
exit
Definition: folder.php:81
$file
foreach($productList as $product) $file
Definition: froogle.php:236
$minute
$minute
Definition: froogle.php:311
$feed
$feed
Definition: froogle.php:97
$MainImageWidth
$MainImageWidth
Definition: froogle.php:52
$wwwDir
$wwwDir
Definition: froogle.php:50
$SitePath
$SitePath
Definition: froogle.php:54
$fp
$fp
Definition: froogle.php:246
$SiteURL
$SiteURL
Definition: froogle.php:49
$MainImageHeight
$MainImageHeight
Definition: froogle.php:53
$date
$date
Definition: froogle.php:306
$day
$day
Definition: froogle.php:308
$FroogleServerPort
$FroogleServerPort
Definition: froogle.php:70
$hour
$hour
Definition: froogle.php:310
$content
$content
Definition: froogle.php:247
$PricesIncludeVAT
$PricesIncludeVAT
Definition: froogle.php:51
$product
$product
Definition: froogle.php:94
$fileName
$fileName
Definition: froogle.php:239
$month
$month
Definition: froogle.php:307
$FroogleKey
$FroogleKey
Definition: froogle.php:67
$year
$year
Definition: froogle.php:309
$ini
$ini
Definition: froogle.php:47
$fileSize
$fileSize
Definition: froogle.php:240
$FroogleServer
$FroogleServer
Definition: froogle.php:65
$search
$search
Definition: froogle.php:153
$replace
$replace
Definition: froogle.php:140
$FroogleUser
$FroogleUser
Definition: froogle.php:66
$productList
$productList
Definition: froogle.php:95
$mainImage
foreach( $pathArray as $path) $mainImage
Definition: productpreview.php:167
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.