Jump to content

sephira

Members
  • Posts

    8
  • Joined

  • Last visited

About sephira

  • Birthday 10/30/1990

Profile Information

  • Location
    Moscow
  • Activity
    Web development agency

sephira's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. I think I will add immediately to the database and will create a file called a hash If there are articles on the subject (say integration in custom script prestashop engine), please share
  2. Думаю, занесу сразу в базу и создам файл с хешовым названием, если есть статьи по этой теме (допустим интеграция в пользовательский скрипт движка prestashop), скиньте, пожалуйста
  3. Добрый день! Не могу найти в REST API раздела виртуальных/загружаемых файлов (из таблицы ps_product_download), чтобы импортировать туда скриптом свои (их несколько тысяч). Также не могу получить доступ к сохранению формы товара через curl к бэкофису из-за системы сессий, куки и токенов. Prestashop редиректит с 302 кодом на "sitename/admin0401/index.php?controller=AdminLogin&token=d7218c4a4f379d3b455e5fd45fccefc1&redirect=AdminProducts", даже когда токены и куки взяты из моего браузера (в котором сессия исправна) непосредственно. Пытался также залогиниться через контроллер AdminLogin, используя CURLOPT_COOKIEFILE и CURLOPT_COOKIEJAR, а далее обратиться к AdminProducts. Версия prestashop 1.6. Буду очень рад помощи хоть с какой-нибудь реализацией того функционала, что мне нужен. Есть идея использовать код загрузки виртуального файла в prestashop и самому обработать (переместить, захешировав название) и вставить в базу, но не знаю получится ли без использования всего фреймворка. И как, в таком случае, подключить фреймворк к стороннему скрипту (наподобие того, как делается с Zend и Yii) тоже не знаю. presto.ru - локальный домен (DNS на моем сервере) $url = 'http://presto.ru/admin0401/index.php?controller=AdminProducts&token=59576455bbd31e4bf712ede77c05a6d2'; rtrim($fields_string, '&'); $options = array( CURLOPT_RETURNTRANSFER => true, // return web page CURLOPT_HEADER => true, // don't return headers CURLOPT_FOLLOWLOCATION => true, // follow redirects CURLOPT_ENCODING => "", // handle all encodings CURLOPT_USERAGENT => "spider", // who am i CURLOPT_AUTOREFERER => true, // set referer on redirect CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect CURLOPT_TIMEOUT => 120, // timeout on response CURLOPT_MAXREDIRS => 10, // stop after 10 redirects CURLOPT_FRESH_CONNECT => true, CURLOPT_SSL_VERIFYPEER => false, // Disabled SSL Cert checks CURLOPT_COOKIE => 'ee71a5687e53d260a86f630d713c16c7=8n%2FM156B1IFMl6JyKvURwD5W%2FjQfsSE1ut6vFMzjFZ4CMgl2ErVV9NRS1dMVhKFoK6UJEmBi6j2S6rTpq4BPc1DrsVZgNOe%2B3%2BcPcXpvr69ejoJVe7ss1WvzBp6kxqhSMyCu9KJ%2B6uWFgp%2F90dz1guFo6WfULIks3iq6e%2BFEgVe4OMBFsLL5M%2FTd2wmNkMVtexu1HjwvIKLVL%2BOXFLJ%2FJmMXQlh6OYIoioNrqnxR1P82WUb%2Ft%2FDuh34nF%2B2cJ%2FV7rIJhHdSvkDgSKC8MDaFwwRep5Lt7LDsMdu73W%2BqHpKikWlyCIcNTqHzMKCUpVli%2BwgDTuM8GbLGSloqfIz7NU1ckBg6ZfGv%2FKzsYFNAO6%2F8ygShS6MVymXGnY6pwJ3tgvC%2FyAFBoJ7R7RkgwurhnwWMltghwnevR1p3KET5CN5INKaXBAtx4Yk8HH0u1PieitrNKG63N7tv6bS9sk732FWJmEvJ2pP0%2F4a4dHpuMCUI%3D000361; __utma=176580068.1616360627.1413726914.1413726914.1413726914.1; __utmc=176580068; __utmz=176580068.1413726914.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); 2a0f1a0291a189ec406f99a4c735e244=8n%2FM156B1IFMl6JyKvURwBcyxX%2F1li63hWLXICHOdvPyRkKBkYtSOZTWRILsBTDNgxX0IjdA2ukBzBVWBI%2BqTx3mlyiNDgwTcju5U181L0BG8%2BMEB%2Fcf1hP6SCRbcCZzw3ngUqlg0K3Gbl7Asvw5HwWc5o0nKFkD0DCunsF5aumxBKW6laQKs1U24FCXliH1bfy2yGHK7euIWdIyMcpCyXh12b9Ez3f2X2Sm8aCu%2Fxc3iToLS%2BDZAW0phFflvvSLIYCGZsvNVRdvxpYWa0TtyXnoMcSWk8AuyD%2FD5N8eWZk%3D000210', ); $ch = curl_init( $url ); curl_setopt_array( $ch, $options ); $content = curl_exec( $ch ); $err = curl_errno( $ch ); $errmsg = curl_error( $ch ); $header = curl_getinfo( $ch ); curl_close( $ch ); $header['errno'] = $err; $header['errmsg'] = $errmsg; $header['content'] = $content; var_dump($header); array(29) { ["url"]=> string(100) "http://presto.ru/admin0401/index.php?controller=AdminProducts&token=59576455bbd31e4bf712ede77c05a6d2" ["content_type"]=> string(24) "text/html; charset=utf-8" ["http_code"]=> int(302) ["header_size"]=> int(624) ["request_size"]=> int(131) ["filetime"]=> int(-1) ["ssl_verify_result"]=> int(0) ["redirect_count"]=> int(0) ["total_time"]=> float(0.074438) ["namelookup_time"]=> float(0.001165) ["connect_time"]=> float(0.001255) ["pretransfer_time"]=> float(0.001296) ["size_upload"]=> float(0) ["size_download"]=> float(0) ["speed_download"]=> float(0) ["speed_upload"]=> float(0) ["download_content_length"]=> float(0) ["upload_content_length"]=> float(0) ["starttransfer_time"]=> float(0.074392) ["redirect_time"]=> float(0) ["certinfo"]=> array(0) { } ["primary_ip"]=> string(12) "178.63.16.66" ["primary_port"]=> int(80) ["local_ip"]=> string(12) "178.63.16.66" ["local_port"]=> int(41922) ["redirect_url"]=> string(120) "http://presto.ru/admin0401/index.php?controller=AdminLogin&token=d7218c4a4f379d3b455e5fd45fccefc1&redirect=AdminProducts" ["errno"]=> int(0) ["errmsg"]=> string(0) "" ["content"]=> string(624) "HTTP/1.1 302 Found Server: nginx/1.2.1 Date: Wed, 29 Oct 2014 12:02:43 GMT Content-Type: text/html; charset=utf-8 Content-Length: 0 Connection: keep-alive X-Powered-By: PHP/5.4.4-14+deb7u11 Set-Cookie: 2a0f1a0291a189ec406f99a4c735e244=0; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=presto.ru; httponly Set-Cookie: 2a0f1a0291a189ec406f99a4c735e244=wk19Blz4NWrpyLvhiOOx5fxYzWjLnFSqlL9gk7mlrNA%3D000019; expires=Tue, 18-Nov-2014 12:02:43 GMT; path=/; domain=presto.ru; httponly Location: index.php?controller=AdminLogin&token=d7218c4a4f379d3b455e5fd45fccefc1&redirect=AdminProducts Vary: Accept-Encoding " }
  4. Good day, dear friends! Trying to solve the problem for several weeks with the import of thousands of Microsoft Word documents at the REST API I have not found the section of virtual files (table ps_product_download). Also I was not able to save the form products through the curl, since I could not deal with the of tokens and session in the backoffice. Prestashop always done a redirect (302) to "sitename/admin0401/index.php?controller=AdminLogin&token=d7218c4a4f379d3b455e5fd45fccefc1&redirect=AdminProducts" even the tokens and cookies have been right. Also I tried to login at AdminLogin controller (CURLOPT_COOKIEFILE and CURLOPT_COOKIEJAR) and after I send curl to AdminProducts Version prestashop 1.6. Please help with at least some of the functional implementation. presto.ru is a locale domain (DNS at my server) $url = 'http://presto.ru/admin0401/index.php?controller=AdminProducts&token=59576455bbd31e4bf712ede77c05a6d2'; rtrim($fields_string, '&'); $options = array( CURLOPT_RETURNTRANSFER => true, // return web page CURLOPT_HEADER => true, // don't return headers CURLOPT_FOLLOWLOCATION => true, // follow redirects CURLOPT_ENCODING => "", // handle all encodings CURLOPT_USERAGENT => "spider", // who am i CURLOPT_AUTOREFERER => true, // set referer on redirect CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect CURLOPT_TIMEOUT => 120, // timeout on response CURLOPT_MAXREDIRS => 10, // stop after 10 redirects CURLOPT_FRESH_CONNECT => true, CURLOPT_SSL_VERIFYPEER => false, // Disabled SSL Cert checks CURLOPT_COOKIE => 'ee71a5687e53d260a86f630d713c16c7=8n%2FM156B1IFMl6JyKvURwD5W%2FjQfsSE1ut6vFMzjFZ4CMgl2ErVV9NRS1dMVhKFoK6UJEmBi6j2S6rTpq4BPc1DrsVZgNOe%2B3%2BcPcXpvr69ejoJVe7ss1WvzBp6kxqhSMyCu9KJ%2B6uWFgp%2F90dz1guFo6WfULIks3iq6e%2BFEgVe4OMBFsLL5M%2FTd2wmNkMVtexu1HjwvIKLVL%2BOXFLJ%2FJmMXQlh6OYIoioNrqnxR1P82WUb%2Ft%2FDuh34nF%2B2cJ%2FV7rIJhHdSvkDgSKC8MDaFwwRep5Lt7LDsMdu73W%2BqHpKikWlyCIcNTqHzMKCUpVli%2BwgDTuM8GbLGSloqfIz7NU1ckBg6ZfGv%2FKzsYFNAO6%2F8ygShS6MVymXGnY6pwJ3tgvC%2FyAFBoJ7R7RkgwurhnwWMltghwnevR1p3KET5CN5INKaXBAtx4Yk8HH0u1PieitrNKG63N7tv6bS9sk732FWJmEvJ2pP0%2F4a4dHpuMCUI%3D000361; __utma=176580068.1616360627.1413726914.1413726914.1413726914.1; __utmc=176580068; __utmz=176580068.1413726914.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); 2a0f1a0291a189ec406f99a4c735e244=8n%2FM156B1IFMl6JyKvURwBcyxX%2F1li63hWLXICHOdvPyRkKBkYtSOZTWRILsBTDNgxX0IjdA2ukBzBVWBI%2BqTx3mlyiNDgwTcju5U181L0BG8%2BMEB%2Fcf1hP6SCRbcCZzw3ngUqlg0K3Gbl7Asvw5HwWc5o0nKFkD0DCunsF5aumxBKW6laQKs1U24FCXliH1bfy2yGHK7euIWdIyMcpCyXh12b9Ez3f2X2Sm8aCu%2Fxc3iToLS%2BDZAW0phFflvvSLIYCGZsvNVRdvxpYWa0TtyXnoMcSWk8AuyD%2FD5N8eWZk%3D000210', ); $ch = curl_init( $url ); curl_setopt_array( $ch, $options ); $content = curl_exec( $ch ); $err = curl_errno( $ch ); $errmsg = curl_error( $ch ); $header = curl_getinfo( $ch ); curl_close( $ch ); $header['errno'] = $err; $header['errmsg'] = $errmsg; $header['content'] = $content; var_dump($header); array(29) { ["url"]=> string(100) "http://presto.ru/admin0401/index.php?controller=AdminProducts&token=59576455bbd31e4bf712ede77c05a6d2" ["content_type"]=> string(24) "text/html; charset=utf-8" ["http_code"]=> int(302) ["header_size"]=> int(624) ["request_size"]=> int(131) ["filetime"]=> int(-1) ["ssl_verify_result"]=> int(0) ["redirect_count"]=> int(0) ["total_time"]=> float(0.074438) ["namelookup_time"]=> float(0.001165) ["connect_time"]=> float(0.001255) ["pretransfer_time"]=> float(0.001296) ["size_upload"]=> float(0) ["size_download"]=> float(0) ["speed_download"]=> float(0) ["speed_upload"]=> float(0) ["download_content_length"]=> float(0) ["upload_content_length"]=> float(0) ["starttransfer_time"]=> float(0.074392) ["redirect_time"]=> float(0) ["certinfo"]=> array(0) { } ["primary_ip"]=> string(12) "178.63.16.66" ["primary_port"]=> int(80) ["local_ip"]=> string(12) "178.63.16.66" ["local_port"]=> int(41922) ["redirect_url"]=> string(120) "http://presto.ru/admin0401/index.php?controller=AdminLogin&token=d7218c4a4f379d3b455e5fd45fccefc1&redirect=AdminProducts" ["errno"]=> int(0) ["errmsg"]=> string(0) "" ["content"]=> string(624) "HTTP/1.1 302 Found Server: nginx/1.2.1 Date: Wed, 29 Oct 2014 12:02:43 GMT Content-Type: text/html; charset=utf-8 Content-Length: 0 Connection: keep-alive X-Powered-By: PHP/5.4.4-14+deb7u11 Set-Cookie: 2a0f1a0291a189ec406f99a4c735e244=0; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=presto.ru; httponly Set-Cookie: 2a0f1a0291a189ec406f99a4c735e244=wk19Blz4NWrpyLvhiOOx5fxYzWjLnFSqlL9gk7mlrNA%3D000019; expires=Tue, 18-Nov-2014 12:02:43 GMT; path=/; domain=presto.ru; httponly Location: index.php?controller=AdminLogin&token=d7218c4a4f379d3b455e5fd45fccefc1&redirect=AdminProducts Vary: Accept-Encoding " }
×
×
  • Create New...