OS::executeAndAssert('mkdir -p ' . ORIG_FILE_PREFIX); if (!file_exists($opts['f'])) { print "Input file does not exist.\n"; exit; } $handle = fopen($opts['f'], "r"); $i = 0; while (($fields = fgetcsv($handle, 10000, CSV_DELIMITER)) !== false) { $i++; if ($i <= $opts['h']) { continue; } $sku = $fields[$opts['s']]; print "Line {$i}: [{$sku}]\n"; // Reuse the record or create a new one $book = DivertaBook::get("sku = '{$sku}'"); if ($book) { print " Reusing book id = {$book->id}\n"; } else { print " Creating new book\n"; $book = new DivertaBook(); $book->sku = $sku; $book->impressions = 0; $book->clicks = 0; } if (overwrite($book, $opts, 't')) { $book->title = $fields[$opts['t']]; } if (overwrite($book, $opts, 'a')) { $book->author = $fields[$opts['a']]; }
require_once "../phplib/util.php"; require_once "../phplib/ads/adsModule.php"; $provider = util_getRequestParameter('provider'); // Display a banner for this provider $go = util_getRequestParameter('go'); // Track a click and redirect to this provider $clickurl = util_getRequestParameter('clickurl'); // Sent to us by OpenX; when displaying a banner, we have to link to this URL if ($go) { $provider = $go; $go = true; } require_once "../phplib/ads/{$provider}/{$provider}AdsModule.php"; if ($provider == 'diverta') { $bookId = util_getRequestParameter('bookId'); $book = DivertaBook::get_by_id($bookId); if (!$book) { exit; } if ($go) { $book->clicks++; $book->save(); util_redirect($book->url); } $book->impressions++; $book->save(); smarty_assign('book', $book); smarty_assign('hasImage', file_exists(util_getRootPath() . "wwwbase/img/diverta/thumb/{$book->sku}.jpg")); } smarty_assign('clickurl', str_replace('__', '&', $clickurl)); $output = smarty_fetch("ads/{$provider}.ihtml");