Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # połącz z Allegro i sprawdź czy jest nowa wersja listy kategorii
- if(!isset($_POST) || count($_POST) < 1)
- {
- try {
- $api = new allegro($allegro);
- }
- catch(Exception $e) {
- $tpl->ERROR = htmlspecialchars($e->getMessage());
- $blad = true;
- }
- if(!$blad)
- {
- $wersja_zdalna = $api->wersjaKategorii();
- if(!isset($allegro['catgversion']) || $wersja_zdalna != $allegro['catgversion'] || $_GET['reload'] === '1'
- || !file_exists('../../cache/allegro_cat_'.$allegro['countrycode'].'.dat') || !file_exists('../../cache/allegro_idx_'.$allegro['countrycode'].'.dat'))
- {
- $paczka = 50;
- settype($kategorie, array());
- $ilosc = ceil($api->iloscKategorii() / $paczka);
- echo '<div id="pgrsbar">'.$LNG['m_allegro']['%UpdateProgress%'].'</div>';
- ob_flush();
- flush();
- for($offset=0; $offset<=$ilosc; $offset++)
- {
- $new = $api->fragmentListyKategorii($paczka, $offset);
- unset($kategorie['ver-key']);
- unset($kategorie['ver-str']);
- $kategorie = array_merge_recursive($kategorie, $new);
- }
- unset($new);
- # zapisz kategorie i zbuduj indeksy kategorii
- file_put_contents('../../cache/allegro_cat_'.$allegro['countrycode'].'.dat', serialize($kategorie));
- @chmod('../../cache/allegro_cat_'.$allegro['countrycode'].'.dat', 0666);
- settype($indeksy, array());
- foreach($kategorie['cats-list'] as $k => $v) $indeksy[$v['cat-parent']][$v['cat-position']] = $k;
- file_put_contents('../../cache/allegro_idx_'.$allegro['countrycode'].'.dat', serialize($indeksy));
- @chmod('../../cache/allegro_idx_'.$allegro['countrycode'].'.dat', 0666);
- # zapisz info o wersji do pliku konfiguracyjnego szablonu
- $dom = new DOMDocument('1.0', 'UTF-8');
- $dom->formatOutput = true;
- $dom->load($cpath.$_GET['cf'].'/config.xml');
- $nodes = $dom->getElementsByTagName('catgversion');
- if($nodes->length > 0)
- foreach($nodes as $node)
- $dom->getElementsByTagName('allegro')->item(0)->removeChild($node);
- $text = $dom->createTextNode($wersja_zdalna);
- $node = $dom->createElement('catgversion');
- $node->appendChild($text);
- $dom->getElementsByTagName('allegro')->item(0)->appendChild($node);
- $dom->save($cpath.$_GET['cf'].'/config.xml');
- }//update
- public function fragmentListyKategorii($paczka=50, $offset=0)
- {
- unset($params);
- $params = array(
- 'country-id' => $this->config['countrycode'],
- 'local-version' => $this->versionKey,
- 'webapi-key' => $this->config['webapicode'],
- 'package-element' => intval($paczka),
- 'offset' => intval($offset),
- );
- $buff = $this->SOAPclient->call('doGetCatsDataLimit', $params, 'urn:AllegroWebApi', '#catsdatalimit');
- if($this->SOAPclient->getError())
- {
- throw new Exception('Błąd podczas pobierania listy kategorii z Allegro: '.$this->SOAPclient->getError());
- return false;
- }
- return $buff;
- }
Add Comment
Please, Sign In to add comment