-
Notifications
You must be signed in to change notification settings - Fork 1
/
soapServerClass.php
executable file
·217 lines (195 loc) · 9.41 KB
/
soapServerClass.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<?php
require_once 'autoload.php';
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\FirePHPHandler;
class soapServerClass
{
/**
* @param string $LoginName
* @param string $Password
* @return string $XML
*/
function SDMRestAccount($LoginName,$Password)
{
// Create the logger
$logger = new Logger('logger_service');
// Now add some handlers
$logger->pushHandler(new StreamHandler(__DIR__.'/Log/service.log', Logger::DEBUG));
$logger->pushHandler(new FirePHPHandler());
// You can now use your logger
$logger->addInfo('Start running SDMRestAccount class');
$sLogin=$LoginName;
$sPassword=$Password;
$postData = 'password='.$sPassword.'&username='.$sLogin; //Ëîãèí è ïàðîëü
$data= http_request('https://retail.sdm.ru/logon?ReturnUrl=%2f',true,$postData,false,'','Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)',60);
if (!$data) return 'íåò îòâåòà îò ñåðâåðà';
//echo($data);
$cookie=substr($data,strpos($data,'cookie=')+7,strlen($data));
if (!$cookie) return 'íå ñìîãëè çàëîãèíèòüñÿ - íåò êóêèñîâ';
//echo($cookie);
$data= http_request('https://retail.sdm.ru/',false,'',false,$cookie,'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)',60);
if (!$data) return 'íå ìîæåì ïîëó÷èòü èíôîðìàöèþ ïî ñ÷åòàì';
$body=substr($data,strpos($data,'body=')+5,strlen($body)-8);
//echo($body);
$doc= new DOMDocument();
libxml_use_internal_errors(true);
$doc->loadHTML($body);
libxml_clear_errors();
$xpath = new DOMXPath($doc);
$xml = new DOMDocument('1.0','UTF-8');
// $xml = new DOMDocument('1.0','CP1251');
$xmlRoot=$xml->createElement('GetAccountRestAndStmSDM');
$xml->appendChild($xmlRoot);
$TableTrAccount = $xpath->query('//div[@class="Content-Center"]/div[1]//table/tr/td');
$TableTrCard = $xpath->query('//div[@class="Content-Center"]/div[2]//table/tr/td');
$CountAccount= ($TableTrAccount->length/4);
$CountCard=$TableTrCard->length/6;
//Ïî ñ÷åòàì
$xmlAccountList = $xml->createElement("AccountsList");
$xmlAccountListAttribute= $xml->createAttribute("count");
$xmlAccountListAttribute->value=$CountAccount;
$xmlAccountList->appendChild($xmlAccountListAttribute);
$xmlRoot->appendChild($xmlAccountList);
for ($i=0; $i<$CountAccount;$i++) {
$xmlAccount=$xml->createElement("Account");
$xmlAccountList->appendChild($xmlAccount);
for ($j = 0; $j < 4; $j++) //4 <td>
{
// printf('i='.$i.';j='.$j.';'.nodeContent($TableTrAccount->item($i*4+$j)).'<br>');
switch ($j)
{
case 0:
$xmlCurrCode=$xml->createElement("CurrCode");
$xmlAccount->appendChild($xmlCurrCode);
$xmlCurrCode->nodeValue=
str_replace('"/','',
str_replace(' ','',
str_replace(' "ico-l" ','',
str_replace('img src="/img/ico_usd.gif" width="16" height="19" alt="','',
str_replace('img src="/img/ico_rur.gif" width="16" height="19" alt="','',
str_replace('img src="/img/ico_eur.gif" width="16" height="19" alt="','',
nodeContent($TableTrAccount->item($i*4 + j))
))))));
break;
case 1:
$xmlAccountName=$xml->createElement("AccountName");
$xmlAccount->appendChild($xmlAccountName);
$xmlAccountName->nodeValue=nodeContent($TableTrAccount->item($i*4 +j+1));
break;
case 2:
$xmlRest=$xml->createElement("Rest");
$xmlAccount->appendChild($xmlRest);
$xmlRest->nodeValue= nodeContent($TableTrAccount->item($i*4 + $j));
break;
case 3:
$xmlAcountID=$xml->createElement("AcountID");
$xmlAccount->appendChild($xmlAcountID);
$xmlAcountID->nodeValue=
str_replace('" "ajax-window"Èñòîðèÿ ïëàòåæåé/a','',
str_replace('a href="/finances/account/','',
nodeContent($TableTrAccount->item($i*4 + $j))
));
break;
default:
// Xml_.WriteStartElement("Param" + (j + 1).ToString());
break;
}
}
}
//Ïî êàðòàì
$xmlCardList = $xml->createElement("CardList");
$xmlCardListAttribute= $xml->createAttribute("count");
$xmlCardListAttribute->value=$CountCard;
$xmlCardList->appendChild($xmlCardListAttribute);
$xmlRoot->appendChild($xmlCardList);
for ($i=0; $i<$CountCard;$i++) {
$xmlCard=$xml->createElement("Cards");
$xmlCardList->appendChild($xmlCard);
for ($j = 0; $j < 6; $j++) //6 <td>
{
// printf('i='.$i.';j='.$j.';'.nodeContent($TableTrCard->item($i*6+$j)).'<br>');
switch ($j)
{
case 0:
$xmlCurrCodeCard=$xml->createElement("CurrCode");
$xmlCard->appendChild($xmlCurrCodeCard);
$xmlCurrCodeCard->nodeValue=
str_replace('"/','',
str_replace(' ','',
str_replace(' "ico-l" ','',
str_replace('img src="/img/ico_usd.gif" width="16" height="19" alt="','',
str_replace('img src="/img/ico_rur.gif" width="16" height="19" alt="','',
str_replace('img src="/img/ico_eur.gif" width="16" height="19" alt="','',
nodeContent($TableTrCard->item($i*6+$j))
))))));
break;
case 1:
$xmlCardType=$xml->createElement("CardType");
$xmlCard->appendChild($xmlCardType);
$xmlCardType->nodeValue=
str_replace(' ','',
str_replace('img src=img/ico_mastercard.gif" width="32" height="20" alt="','',
str_replace('"/','',
str_replace(' "ico-r"','',
str_replace('img src="/img/ico_visa.gif" width="32" height="20" alt="','',
nodeContent($TableTrCard->item($i*6+$j))
)))));
break;
case 2:
$xmlCardID=$xml->createElement("CardID");
$xmlCard->appendChild($xmlCardID);
$xmlCardID->nodeValue=
str_replace('"MASTERCARD GOLD','',
str_replace('"VISA PLATINUM','',
str_replace('"VISA GOLD','',
str_replace('"VISA CLASSIC','',
str_replace('"MASTERCARD ELECTRONIC','',
str_replace('"VISA ELECTRON','',
str_replace('/a','',
str_replace('a "ajax-window" href="/finances/card/','',
nodeContent($TableTrCard->item($i*6+$j))
))))))));
break;
case 4:
$xmlRestCard=$xml->createElement("Rest");
$xmlCard->appendChild($xmlRestCard);
$xmlRestCard->nodeValue= nodeContent($TableTrCard->item($i*6+$j));
break;
case 5:
$xmlCardClose=$xml->createElement("CloseCard");
$xmlCard->appendChild($xmlCardClose);
$xmlCardClose->nodeValue= str_replace('ñðîê äåéñòâèÿ: ','',nodeContent($TableTrCard->item($i*6+$j)));
break;
default:
break;
}
}
}
/*
foreach ($TableTrAccount as $tag) {
echo $tag->C14N();
echo nodeContent($tag);
}
foreach ($TableTrAccount as $tag)
{
echo ($tag->nodeValue.'<br>');
}
foreach ($TableTrCard as $tag)
{
echo ($tag->nodeValue.'<br>');
}
*/
//return cp1251_to_utf8($xml->saveXML());
$logger->addInfo('Good result: '.$xml->saveXML());
$logger->addInfo('End SDMRestAccount class');
return $xml->saveXML();
}
/**
* @return int test
*/
public function Test()
{
return 5;
}
}