<?php
$postFieldsLogin = require ( 'config.php' ) ;
$assembleStr = function ( $array ) {
$str = '' ;
foreach ( $array as $key => $value ) {
$str .= $key . '=' . $value . '&' ;
}
return $str = rtrim ( $str , '&' ) ; } ;
$domain = 'https://w...content-available-to-author-only...e.ru' ;
$linkLogin = '/Account/Login' ;
$linkGetCsv = '/GetItems/Content?=&' ;
$todayMinusDays = 1 ;
$searchSubStr = 'Здравствуйте' ;
$cookie = 'cookie.txt' ;
$csv = 'content.csv' ;
$log = 'log.log' ;
$data = $fieldsString = '' ;
$sep = "\n " ;
$timesOfRepeatSep = 2 ;
$sleepTime = 180 ;
$postFieldsGetCsv = [
'account' => '' ,
'beginDate' => date ( 'd.m.Y' , 'endDate' => date ( 'd.m.Y' ) ] ;
//truncate files
do {
/*initial login request*/
$fieldsString = $assembleStr ( $postFieldsLogin ) ;
$isLogin = true ;
/*another request for getting formatted content*/
$fieldsString = $assembleStr ( $postFieldsGetCsv ) ;
}
else {
trim ( $sleepTime . " SECS DELAY" ) . str_repeat ( $sep , $timesOfRepeatSep ) ; }
}
while ( ! $isLogin ) ;
PD9waHAKc2V0X3RpbWVfbGltaXQoMzYwMCk7CiRwb3N0RmllbGRzTG9naW4gPSByZXF1aXJlICgnY29uZmlnLnBocCcpOwokYXNzZW1ibGVTdHIgPSBmdW5jdGlvbigkYXJyYXkpewogICAgJHN0ciA9ICcnOwogICAgZm9yZWFjaCgkYXJyYXkgYXMgJGtleSA9PiAkdmFsdWUpIHsKICAgICAgICAkc3RyLj0gJGtleSAuICc9JyAuICR2YWx1ZSAuICcmJzsKICAgIH0KICAgIHJldHVybiAkc3RyID0gcnRyaW0oJHN0ciwgJyYnKTsKfTsKJGRvbWFpbiA9ICdodHRwczovL3cuLi5jb250ZW50LWF2YWlsYWJsZS10by1hdXRob3Itb25seS4uLmUucnUnOwokbGlua0xvZ2luID0gJy9BY2NvdW50L0xvZ2luJzsKJGxpbmtHZXRDc3YgPSAnL0dldEl0ZW1zL0NvbnRlbnQ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