Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- $accounts=Array("login1"=>'password1',
- "login2"=>'password2');
- $messages=Array();
- $msg_items=Array("privateMessage"=>"Личные сообщения",
- "supportMessage"=>"Сообщения СП",
- "request"=>"Пришла заявка",
- "article"=>"Пришла статья",
- 'troublePost'=>'Проблемные статьи',
- 'troubleIndex'=>'Статья выпала из Индекса',
- 'insurance'=>'Сработала страховка',
- 'request'=>'Пришла заявка',
- 'article'=>'Пришла статья',
- 'ban'=>'Площадка забанена',
- 'moneyIn'=>'Пришли деньги на счет',
- 'moneyOut'=>'Сняты деньги со счета',
- 'news'=>'Новости системы',
- 'pos'=>'Изменились показатели площадки');
- function getQElement()
- {
- // $code, $name1, $name2...
- $values=Array();
- $code=func_get_arg(0);
- $argsNum=func_num_args();
- for($arg=1;$arg<$argsNum;$arg++)
- {
- $name=func_get_arg($arg);
- // для каждого затребованного элемента вернуть значение
- $startEl=strpos($code, '"'.$name.'":{')+strlen('"'.$name.'":{');
- $endEl=strpos($code, "}", $startEl);
- $el=trim(substr($code, $startEl, $endEl-$startEl));
- $values[]=$el;
- }
- return $values;
- }
- // get data
- foreach($accounts as $login=>$pw)
- {
- if($tokenstr=implode('',file("http://www.miralinks.ru/toolbar/getToken?login=${login}&password=".base64_encode($pw))))
- {
- if(preg_match("/([a-z0-9]{32})/", $tokenstr, $tokenregs))
- {
- $token=$tokenregs[1];
- $codestr=implode('',file("http://www.miralinks.ru/toolbar/getInfo?tokens=${token}"));
- foreach($msg_items as $msg_translit=>$msg_rus)
- {
- if($arr=getQElement($codestr, $msg_translit))
- {
- if(preg_match('/"count":([0-9]+)/', $arr[0], $regs))
- {
- $messages[$login][$msg_translit]=$regs[1];
- }
- }
- }
- }
- }
- }
- // show parsed data
- $code='';
- $title='';
- // шапка
- $title.='<tr><td> </td>';
- foreach($accounts as $login=>$pw)
- {
- $title.='<td class="title_login">'.$login.'</td>';
- }
- $title.='</tr>';
- // табличка
- $cell=1;
- foreach($msg_items as $lat=>$rus)
- {
- $code.='<tr><td class="msg_title cell'.$cell.'">'.$rus.'</td>';
- foreach($accounts as $login=>$pw)
- {
- if(isset($messages[$login][$lat]))
- {
- $code.='<td align="center" class="cell'.$cell.'">'.$messages[$login][$lat].'</td>';
- }
- else
- {
- $code.='<td align="center" class="cell'.$cell.'">-</td>';
- }
- }
- if($cell==1) { $cell=2; } else { $cell=1; }
- $code.='</tr>';
- }
- print
- '<html>
- <head>
- <title>Miralinks</title>
- <meta http-equiv="Content-Type" content="text/html; charset=windows-1251"/>
- <style>
- body,td { font-family: Verdana; font-size: 12px; }
- table { }
- .title_login { text-align: center; background-color: lightgray; font-weight: bold; }
- .msg_title { font-weight: bold; }
- .cell1 { background-color: lightgray; }
- .cell2 { }
- </style>
- </head>
- <body>
- <table width="98%" cellpadding="2" border="1">
- '.$title.$code.'
- </table>
- </body>
- </html>';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment