Guest User

Miralinks statistics PHP-script

a guest
Mar 13th, 2012
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.97 KB | None | 0 0
  1. <?
  2.     $accounts=Array("login1"=>'password1',
  3.                      "login2"=>'password2');
  4.    
  5.     $messages=Array();
  6.     $msg_items=Array("privateMessage"=>"Личные сообщения",
  7.                       "supportMessage"=>"Сообщения СП",
  8.                       "request"=>"Пришла заявка",
  9.                       "article"=>"Пришла статья",
  10.                       'troublePost'=>'Проблемные статьи',
  11.                       'troubleIndex'=>'Статья выпала из Индекса',
  12.                       'insurance'=>'Сработала страховка',
  13.                       'request'=>'Пришла заявка',
  14.                       'article'=>'Пришла статья',
  15.                       'ban'=>'Площадка забанена',
  16.                       'moneyIn'=>'Пришли деньги на счет',
  17.                       'moneyOut'=>'Сняты деньги со счета',
  18.                       'news'=>'Новости системы',
  19.                       'pos'=>'Изменились показатели площадки');
  20.    
  21.     function getQElement()
  22.     {
  23.         // $code, $name1, $name2...
  24.         $values=Array();
  25.        
  26.         $code=func_get_arg(0);
  27.         $argsNum=func_num_args();
  28.         for($arg=1;$arg<$argsNum;$arg++)
  29.         {
  30.             $name=func_get_arg($arg);
  31.            
  32.             // для каждого затребованного элемента вернуть значение
  33.             $startEl=strpos($code, '"'.$name.'":{')+strlen('"'.$name.'":{');
  34.             $endEl=strpos($code, "}", $startEl);
  35.            
  36.             $el=trim(substr($code, $startEl, $endEl-$startEl));
  37.            
  38.             $values[]=$el;
  39.         }
  40.        
  41.         return $values;
  42.     }
  43.    
  44.     // get data
  45.     foreach($accounts as $login=>$pw)
  46.     {
  47.         if($tokenstr=implode('',file("http://www.miralinks.ru/toolbar/getToken?login=${login}&password=".base64_encode($pw))))
  48.         {
  49.             if(preg_match("/([a-z0-9]{32})/", $tokenstr, $tokenregs))
  50.             {
  51.                 $token=$tokenregs[1];
  52.                
  53.                 $codestr=implode('',file("http://www.miralinks.ru/toolbar/getInfo?tokens=${token}"));
  54.                
  55.                 foreach($msg_items as $msg_translit=>$msg_rus)
  56.                 {
  57.                     if($arr=getQElement($codestr, $msg_translit))
  58.                     {
  59.                         if(preg_match('/"count":([0-9]+)/', $arr[0], $regs))
  60.                         {
  61.                             $messages[$login][$msg_translit]=$regs[1];
  62.                         }
  63.                     }
  64.                 }
  65.             }
  66.         }
  67.     }
  68.    
  69.     // show parsed data
  70.     $code='';
  71.     $title='';
  72.    
  73.     // шапка
  74.     $title.='<tr><td>&nbsp;</td>';
  75.     foreach($accounts as $login=>$pw)
  76.     {
  77.         $title.='<td class="title_login">'.$login.'</td>';
  78.     }
  79.     $title.='</tr>';
  80.    
  81.     // табличка
  82.     $cell=1;
  83.     foreach($msg_items as $lat=>$rus)
  84.     {
  85.         $code.='<tr><td class="msg_title cell'.$cell.'">'.$rus.'</td>';
  86.        
  87.         foreach($accounts as $login=>$pw)
  88.         {
  89.             if(isset($messages[$login][$lat]))
  90.             {
  91.                 $code.='<td align="center" class="cell'.$cell.'">'.$messages[$login][$lat].'</td>';
  92.             }
  93.             else
  94.             {
  95.                 $code.='<td align="center" class="cell'.$cell.'">-</td>';
  96.             }
  97.         }
  98.        
  99.         if($cell==1) { $cell=2; } else { $cell=1; }
  100.        
  101.         $code.='</tr>';
  102.     }
  103.    
  104.     print
  105. '<html>
  106. <head>
  107.    <title>Miralinks</title>
  108.    <meta http-equiv="Content-Type" content="text/html; charset=windows-1251"/>
  109.    <style>
  110.    body,td { font-family: Verdana; font-size: 12px; }
  111.    table { }
  112.    .title_login { text-align: center; background-color: lightgray; font-weight: bold; }
  113.    .msg_title { font-weight: bold; }
  114.    .cell1 { background-color: lightgray; }
  115.    .cell2 { }
  116.    </style>
  117. </head>
  118. <body>
  119. <table width="98%" cellpadding="2" border="1">
  120. '.$title.$code.'
  121. </table>
  122. </body>
  123. </html>';
  124. ?>
Advertisement
Add Comment
Please, Sign In to add comment